Changeset 8020
- Timestamp:
- Jul 31, 2006, 3:44:47 PM (20 years ago)
- Location:
- branches/jhoblitt/ippdb
- Files:
-
- 9 edited
-
configure.ac (modified) (1 diff)
-
src/ippdb.c (modified) (28 diffs)
-
src/ippdb.h (modified) (8 diffs)
-
tests/alloc.c (modified) (3 diffs)
-
tests/insert.c (modified) (2 diffs)
-
tests/insertobject.c (modified) (2 diffs)
-
tests/metadatafromobject.c (modified) (4 diffs)
-
tests/objectfrommetadata.c (modified) (4 diffs)
-
tests/pop.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jhoblitt/ippdb/configure.ac
r7460 r8020 1 1 AC_PREREQ(2.59) 2 2 3 AC_INIT([ippdb], [0.0. 1], [pan-starrs.ifa.hawaii.edu])3 AC_INIT([ippdb], [0.0.4], [pan-starrs.ifa.hawaii.edu]) 4 4 AC_CONFIG_SRCDIR([ippdb.pc.in]) 5 5 -
branches/jhoblitt/ippdb/src/ippdb.c
r8006 r8020 4670 4670 static void pzPendingImfileRowFree(pzPendingImfileRow *object); 4671 4671 4672 pzPendingImfileRow *pzPendingImfileRowAlloc(const char *exp_id, psS32 bytes, const char *md5sum, const char *class , const char *class_id, const char *uri)4672 pzPendingImfileRow *pzPendingImfileRowAlloc(const char *exp_id, psS32 bytes, const char *md5sum, const char *class_id, const char *uri) 4673 4673 { 4674 4674 pzPendingImfileRow *object; … … 4680 4680 object->bytes = bytes; 4681 4681 object->md5sum = psStringCopy(md5sum); 4682 object->class = psStringCopy(class);4683 4682 object->class_id = psStringCopy(class_id); 4684 4683 object->uri = psStringCopy(uri); … … 4691 4690 psFree(object->exp_id); 4692 4691 psFree(object->md5sum); 4693 psFree(object->class);4694 4692 psFree(object->class_id); 4695 4693 psFree(object->uri); … … 4722 4720 return false; 4723 4721 } 4724 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, "64")) {4725 psError(PS_ERR_UNKNOWN, false, "failed to add item class");4726 psFree(md);4727 return false;4728 }4729 4722 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "64")) { 4730 4723 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 4750 4743 } 4751 4744 4752 bool pzPendingImfileInsert(psDB * dbh, const char *exp_id, psS32 bytes, const char *md5sum, const char *class , const char *class_id, const char *uri)4745 bool pzPendingImfileInsert(psDB * dbh, const char *exp_id, psS32 bytes, const char *md5sum, const char *class_id, const char *uri) 4753 4746 { 4754 4747 psMetadata *md; … … 4771 4764 return false; 4772 4765 } 4773 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, class)) {4774 psError(PS_ERR_UNKNOWN, false, "failed to add item class");4775 psFree(md);4776 return false;4777 }4778 4766 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, class_id)) { 4779 4767 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 4793 4781 } 4794 4782 4795 bool pzPendingImfilePop(psDB *dbh, char **exp_id, psS32 *bytes, char **md5sum, char **class , char **class_id, char **uri)4783 bool pzPendingImfilePop(psDB *dbh, char **exp_id, psS32 *bytes, char **md5sum, char **class_id, char **uri) 4796 4784 { 4797 4785 psArray *rowSet; … … 4855 4843 return false; 4856 4844 } 4857 *class = psMetadataLookupPtr(&status, row, "class");4858 if (!status) {4859 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class");4860 psFree(row);4861 return false;4862 }4863 4845 *class_id = psMetadataLookupPtr(&status, row, "class_id"); 4864 4846 if (!status) { … … 4881 4863 bool pzPendingImfileInsertObject(psDB *dbh, pzPendingImfileRow *object) 4882 4864 { 4883 return pzPendingImfileInsert(dbh, object->exp_id, object->bytes, object->md5sum, object->class , object->class_id, object->uri);4865 return pzPendingImfileInsert(dbh, object->exp_id, object->bytes, object->md5sum, object->class_id, object->uri); 4884 4866 } 4885 4867 … … 4889 4871 psS32 bytes; 4890 4872 char md5sum[256]; 4891 char class[256];4892 4873 char class_id[256]; 4893 4874 char uri[256]; 4894 4875 4895 if (!pzPendingImfilePop(dbh, (char **)&exp_id, &bytes, (char **)&md5sum, (char **)&class , (char **)&class_id, (char **)&uri)) {4876 if (!pzPendingImfilePop(dbh, (char **)&exp_id, &bytes, (char **)&md5sum, (char **)&class_id, (char **)&uri)) { 4896 4877 psError(PS_ERR_UNKNOWN, false, "failed to pop a database row"); 4897 4878 return NULL; 4898 4879 } 4899 4880 4900 return pzPendingImfileRowAlloc(exp_id, bytes, md5sum, class , class_id, uri);4881 return pzPendingImfileRowAlloc(exp_id, bytes, md5sum, class_id, uri); 4901 4882 } 4902 4883 … … 5012 4993 return NULL; 5013 4994 } 5014 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, object->class)) {5015 psError(PS_ERR_UNKNOWN, false, "failed to add item class");5016 psFree(md);5017 return NULL;5018 }5019 4995 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, object->class_id)) { 5020 4996 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 5037 5013 psS32 bytes; 5038 5014 char *md5sum; 5039 char *class;5040 5015 char *class_id; 5041 5016 char *uri; … … 5056 5031 return false; 5057 5032 } 5058 class = psMetadataLookupPtr(&status, md, "class");5059 if (!status) {5060 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class");5061 return false;5062 }5063 5033 class_id = psMetadataLookupPtr(&status, md, "class_id"); 5064 5034 if (!status) { … … 5072 5042 } 5073 5043 5074 return pzPendingImfileRowAlloc(exp_id, bytes, md5sum, class , class_id, uri);5044 return pzPendingImfileRowAlloc(exp_id, bytes, md5sum, class_id, uri); 5075 5045 } 5076 5046 psArray *pzPendingImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 5560 5530 static void newImfileRowFree(newImfileRow *object); 5561 5531 5562 newImfileRow *newImfileRowAlloc(const char *exp_id, const char *class , const char *class_id, const char *uri)5532 newImfileRow *newImfileRowAlloc(const char *exp_id, const char *class_id, const char *uri) 5563 5533 { 5564 5534 newImfileRow *object; … … 5568 5538 5569 5539 object->exp_id = psStringCopy(exp_id); 5570 object->class = psStringCopy(class);5571 5540 object->class_id = psStringCopy(class_id); 5572 5541 object->uri = psStringCopy(uri); … … 5578 5547 { 5579 5548 psFree(object->exp_id); 5580 psFree(object->class);5581 5549 psFree(object->class_id); 5582 5550 psFree(object->uri); … … 5599 5567 return false; 5600 5568 } 5601 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, "64")) {5602 psError(PS_ERR_UNKNOWN, false, "failed to add item class");5603 psFree(md);5604 return false;5605 }5606 5569 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "64")) { 5607 5570 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 5627 5590 } 5628 5591 5629 bool newImfileInsert(psDB * dbh, const char *exp_id, const char *class , const char *class_id, const char *uri)5592 bool newImfileInsert(psDB * dbh, const char *exp_id, const char *class_id, const char *uri) 5630 5593 { 5631 5594 psMetadata *md; … … 5638 5601 return false; 5639 5602 } 5640 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, class)) {5641 psError(PS_ERR_UNKNOWN, false, "failed to add item class");5642 psFree(md);5643 return false;5644 }5645 5603 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, class_id)) { 5646 5604 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 5660 5618 } 5661 5619 5662 bool newImfilePop(psDB *dbh, char **exp_id, char **class , char **class_id, char **uri)5620 bool newImfilePop(psDB *dbh, char **exp_id, char **class_id, char **uri) 5663 5621 { 5664 5622 psArray *rowSet; … … 5710 5668 return false; 5711 5669 } 5712 *class = psMetadataLookupPtr(&status, row, "class");5713 if (!status) {5714 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class");5715 psFree(row);5716 return false;5717 }5718 5670 *class_id = psMetadataLookupPtr(&status, row, "class_id"); 5719 5671 if (!status) { … … 5736 5688 bool newImfileInsertObject(psDB *dbh, newImfileRow *object) 5737 5689 { 5738 return newImfileInsert(dbh, object->exp_id, object->class , object->class_id, object->uri);5690 return newImfileInsert(dbh, object->exp_id, object->class_id, object->uri); 5739 5691 } 5740 5692 … … 5742 5694 { 5743 5695 char exp_id[256]; 5744 char class[256];5745 5696 char class_id[256]; 5746 5697 char uri[256]; 5747 5698 5748 if (!newImfilePop(dbh, (char **)&exp_id, (char **)&class , (char **)&class_id, (char **)&uri)) {5699 if (!newImfilePop(dbh, (char **)&exp_id, (char **)&class_id, (char **)&uri)) { 5749 5700 psError(PS_ERR_UNKNOWN, false, "failed to pop a database row"); 5750 5701 return NULL; 5751 5702 } 5752 5703 5753 return newImfileRowAlloc(exp_id, class , class_id, uri);5704 return newImfileRowAlloc(exp_id, class_id, uri); 5754 5705 } 5755 5706 … … 5855 5806 return NULL; 5856 5807 } 5857 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, object->class)) {5858 psError(PS_ERR_UNKNOWN, false, "failed to add item class");5859 psFree(md);5860 return NULL;5861 }5862 5808 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, object->class_id)) { 5863 5809 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 5878 5824 bool status; 5879 5825 char *exp_id; 5880 char *class;5881 5826 char *class_id; 5882 5827 char *uri; … … 5887 5832 return false; 5888 5833 } 5889 class = psMetadataLookupPtr(&status, md, "class");5890 if (!status) {5891 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class");5892 return false;5893 }5894 5834 class_id = psMetadataLookupPtr(&status, md, "class_id"); 5895 5835 if (!status) { … … 5903 5843 } 5904 5844 5905 return newImfileRowAlloc(exp_id, class , class_id, uri);5845 return newImfileRowAlloc(exp_id, class_id, uri); 5906 5846 } 5907 5847 psArray *newImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
branches/jhoblitt/ippdb/src/ippdb.h
r8006 r8020 1914 1914 psS32 bytes; 1915 1915 char *md5sum; 1916 char *class;1917 1916 char *class_id; 1918 1917 char *uri; … … 1928 1927 psS32 bytes, 1929 1928 const char *md5sum, 1930 const char *class,1931 1929 const char *class_id, 1932 1930 const char *uri … … 1963 1961 psS32 bytes, 1964 1962 const char *md5sum, 1965 const char *class,1966 1963 const char *class_id, 1967 1964 const char *uri … … 1978 1975 psS32 *bytes, 1979 1976 char **md5sum, 1980 char **class,1981 1977 char **class_id, 1982 1978 char **uri … … 2282 2278 typedef struct { 2283 2279 char *exp_id; 2284 char *class;2285 2280 char *class_id; 2286 2281 char *uri; … … 2294 2289 newImfileRow *newImfileRowAlloc( 2295 2290 const char *exp_id, 2296 const char *class,2297 2291 const char *class_id, 2298 2292 const char *uri … … 2327 2321 psDB *dbh, ///< Database handle 2328 2322 const char *exp_id, 2329 const char *class,2330 2323 const char *class_id, 2331 2324 const char *uri … … 2340 2333 psDB *dbh, ///< Database handle 2341 2334 char **exp_id, 2342 char **class,2343 2335 char **class_id, 2344 2336 char **uri -
branches/jhoblitt/ippdb/tests/alloc.c
r8006 r8020 384 384 pzPendingImfileRow *object; 385 385 386 object = pzPendingImfileRowAlloc("a string", -32, "a string", "a string", "a string" , "a string");386 object = pzPendingImfileRowAlloc("a string", -32, "a string", "a string", "a string" ); 387 387 388 388 if (!object) { … … 402 402 exit(EXIT_FAILURE); 403 403 } 404 if (strncmp(object->class, "a string", MAX_STRING_LENGTH)) {405 psFree(object);406 exit(EXIT_FAILURE);407 }408 404 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 409 405 psFree(object); … … 454 450 newImfileRow *object; 455 451 456 object = newImfileRowAlloc("a string", "a string", "a string", "a string" ); 457 458 if (!object) { 459 exit(EXIT_FAILURE); 460 } 461 462 if (strncmp(object->exp_id, "a string", MAX_STRING_LENGTH)) { 463 psFree(object); 464 exit(EXIT_FAILURE); 465 } 466 if (strncmp(object->class, "a string", MAX_STRING_LENGTH)) { 452 object = newImfileRowAlloc("a string", "a string", "a string" ); 453 454 if (!object) { 455 exit(EXIT_FAILURE); 456 } 457 458 if (strncmp(object->exp_id, "a string", MAX_STRING_LENGTH)) { 467 459 psFree(object); 468 460 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/insert.c
r8006 r8020 163 163 } 164 164 165 if (!pzPendingImfileInsert(dbh, "a string", -32, "a string", "a string", "a string" , "a string")) {165 if (!pzPendingImfileInsert(dbh, "a string", -32, "a string", "a string", "a string")) { 166 166 exit(EXIT_FAILURE); 167 167 } … … 193 193 } 194 194 195 if (!newImfileInsert(dbh, "a string", "a string", "a string" , "a string")) {195 if (!newImfileInsert(dbh, "a string", "a string", "a string")) { 196 196 exit(EXIT_FAILURE); 197 197 } -
branches/jhoblitt/ippdb/tests/insertobject.c
r8006 r8020 234 234 } 235 235 236 object = pzPendingImfileRowAlloc("a string", -32, "a string", "a string", "a string" , "a string");236 object = pzPendingImfileRowAlloc("a string", -32, "a string", "a string", "a string"); 237 237 if (!object) { 238 238 exit(EXIT_FAILURE); … … 278 278 } 279 279 280 object = newImfileRowAlloc("a string", "a string", "a string" , "a string");280 object = newImfileRowAlloc("a string", "a string", "a string"); 281 281 if (!object) { 282 282 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/metadatafromobject.c
r8006 r8020 467 467 bool status; 468 468 469 object = pzPendingImfileRowAlloc("a string", -32, "a string", "a string", "a string" , "a string");469 object = pzPendingImfileRowAlloc("a string", -32, "a string", "a string", "a string"); 470 470 if (!object) { 471 471 exit(EXIT_FAILURE); … … 491 491 exit(EXIT_FAILURE); 492 492 } 493 if (strncmp(psMetadataLookupPtr(&status, md, "class"), "a string", MAX_STRING_LENGTH)) {494 psFree(md);495 exit(EXIT_FAILURE);496 }497 493 if (strncmp(psMetadataLookupPtr(&status, md, "class_id"), "a string", MAX_STRING_LENGTH)) { 498 494 psFree(md); … … 553 549 bool status; 554 550 555 object = newImfileRowAlloc("a string", "a string", "a string" , "a string");551 object = newImfileRowAlloc("a string", "a string", "a string"); 556 552 if (!object) { 557 553 exit(EXIT_FAILURE); … … 566 562 567 563 if (strncmp(psMetadataLookupPtr(&status, md, "exp_id"), "a string", MAX_STRING_LENGTH)) { 568 psFree(md);569 exit(EXIT_FAILURE);570 }571 if (strncmp(psMetadataLookupPtr(&status, md, "class"), "a string", MAX_STRING_LENGTH)) {572 564 psFree(md); 573 565 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/objectfrommetadata.c
r8006 r8020 693 693 exit(EXIT_FAILURE); 694 694 } 695 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, "a string")) {696 psFree(md);697 exit(EXIT_FAILURE);698 }699 695 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) { 700 696 psFree(md); … … 726 722 exit(EXIT_FAILURE); 727 723 } 728 if (strncmp(object->class, "a string", MAX_STRING_LENGTH)) {729 psFree(object);730 exit(EXIT_FAILURE);731 }732 724 if (strncmp(object->class_id, "a string", MAX_STRING_LENGTH)) { 733 725 psFree(object); … … 809 801 exit(EXIT_FAILURE); 810 802 } 811 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class", 0, NULL, "a string")) {812 psFree(md);813 exit(EXIT_FAILURE);814 }815 803 if (!psMetadataAddStr(md, PS_LIST_TAIL, "class_id", 0, NULL, "a string")) { 816 804 psFree(md); … … 831 819 832 820 if (strncmp(object->exp_id, "a string", MAX_STRING_LENGTH)) { 833 psFree(object);834 exit(EXIT_FAILURE);835 }836 if (strncmp(object->class, "a string", MAX_STRING_LENGTH)) {837 821 psFree(object); 838 822 exit(EXIT_FAILURE); -
branches/jhoblitt/ippdb/tests/pop.c
r8006 r8020 221 221 psS32 bytes; 222 222 char md5sum[256]; 223 char class[256]; 224 char class_id[256]; 225 char uri[256]; 226 227 dbh = psDBInit("localhost", "test", NULL, "test"); 228 if (!dbh) { 229 exit(EXIT_FAILURE); 230 } 231 232 if (!pzPendingImfilePop(dbh, (char **)&exp_id, &bytes, (char **)&md5sum, (char **)&class, (char **)&class_id, (char **)&uri)) { 223 char class_id[256]; 224 char uri[256]; 225 226 dbh = psDBInit("localhost", "test", NULL, "test"); 227 if (!dbh) { 228 exit(EXIT_FAILURE); 229 } 230 231 if (!pzPendingImfilePop(dbh, (char **)&exp_id, &bytes, (char **)&md5sum, (char **)&class_id, (char **)&uri)) { 233 232 exit(EXIT_FAILURE); 234 233 } … … 260 259 psDB *dbh; 261 260 char exp_id[256]; 262 char class[256]; 263 char class_id[256]; 264 char uri[256]; 265 266 dbh = psDBInit("localhost", "test", NULL, "test"); 267 if (!dbh) { 268 exit(EXIT_FAILURE); 269 } 270 271 if (!newImfilePop(dbh, (char **)&exp_id, (char **)&class, (char **)&class_id, (char **)&uri)) { 261 char class_id[256]; 262 char uri[256]; 263 264 dbh = psDBInit("localhost", "test", NULL, "test"); 265 if (!dbh) { 266 exit(EXIT_FAILURE); 267 } 268 269 if (!newImfilePop(dbh, (char **)&exp_id, (char **)&class_id, (char **)&uri)) { 272 270 exit(EXIT_FAILURE); 273 271 }
Note:
See TracChangeset
for help on using the changeset viewer.
