Changeset 9173
- Timestamp:
- Oct 3, 2006, 4:59:05 PM (20 years ago)
- Location:
- trunk/ippdb
- Files:
-
- 9 edited
-
configure.ac (modified) (1 diff)
-
src/ippdb.c (modified) (13 diffs)
-
src/ippdb.h (modified) (4 diffs)
-
tests/alloc.c (modified) (2 diffs)
-
tests/insert.c (modified) (1 diff)
-
tests/insertobject.c (modified) (1 diff)
-
tests/metadatafromobject.c (modified) (2 diffs)
-
tests/objectfrommetadata.c (modified) (2 diffs)
-
tests/pop.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/configure.ac
r9155 r9173 7 7 AC_PREREQ(2.59) 8 8 9 AC_INIT([ippdb], [0.0.4 0], [pan-starrs.ifa.hawaii.edu])9 AC_INIT([ippdb], [0.0.41], [pan-starrs.ifa.hawaii.edu]) 10 10 AC_CONFIG_SRCDIR([ippdb.pc.in]) 11 11 -
trunk/ippdb/src/ippdb.c
r9149 r9173 12770 12770 static void detRunRowFree(detRunRow *object); 12771 12771 12772 detRunRow *detRunRowAlloc(psS32 iteration, const char *det_type )12772 detRunRow *detRunRowAlloc(psS32 iteration, const char *det_type, const char *state) 12773 12773 { 12774 12774 detRunRow *object; … … 12779 12779 object->iteration = iteration; 12780 12780 object->det_type = psStringCopy(det_type); 12781 object->state = psStringCopy(state); 12781 12782 12782 12783 return object; … … 12786 12787 { 12787 12788 psFree(object->det_type); 12789 psFree(object->state); 12788 12790 } 12789 12791 … … 12809 12811 return false; 12810 12812 } 12813 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, "Key", "64")) { 12814 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 12815 psFree(md); 12816 return false; 12817 } 12811 12818 12812 12819 status = psDBCreateTable(dbh, DETRUN_TABLE_NAME, md); … … 12822 12829 } 12823 12830 12824 bool detRunInsert(psDB * dbh, psS32 iteration, const char *det_type )12831 bool detRunInsert(psDB * dbh, psS32 iteration, const char *det_type, const char *state) 12825 12832 { 12826 12833 psMetadata *md; … … 12835 12842 if (!psMetadataAddStr(md, PS_LIST_TAIL, "det_type", 0, NULL, det_type)) { 12836 12843 psError(PS_ERR_UNKNOWN, false, "failed to add item det_type"); 12844 psFree(md); 12845 return false; 12846 } 12847 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, state)) { 12848 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 12837 12849 psFree(md); 12838 12850 return false; … … 12859 12871 return deleted; 12860 12872 } 12861 bool detRunPop(psDB *dbh, psS32 *iteration, char **det_type )12873 bool detRunPop(psDB *dbh, psS32 *iteration, char **det_type, char **state) 12862 12874 { 12863 12875 psArray *rowSet; … … 12915 12927 return false; 12916 12928 } 12929 *state = psMetadataLookupPtr(&status, row, "state"); 12930 if (!status) { 12931 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 12932 psFree(row); 12933 return false; 12934 } 12917 12935 12918 12936 psFree(row); … … 12923 12941 bool detRunInsertObject(psDB *dbh, detRunRow *object) 12924 12942 { 12925 return detRunInsert(dbh, object->iteration, object->det_type );12943 return detRunInsert(dbh, object->iteration, object->det_type, object->state); 12926 12944 } 12927 12945 … … 12941 12959 psS32 iteration; 12942 12960 char det_type[256]; 12943 12944 if (!detRunPop(dbh, &iteration, (char **)&det_type)) { 12961 char state[256]; 12962 12963 if (!detRunPop(dbh, &iteration, (char **)&det_type, (char **)&state)) { 12945 12964 psError(PS_ERR_UNKNOWN, false, "failed to pop a database row"); 12946 12965 return NULL; 12947 12966 } 12948 12967 12949 return detRunRowAlloc(iteration, det_type );12968 return detRunRowAlloc(iteration, det_type, state); 12950 12969 } 12951 12970 … … 13056 13075 return NULL; 13057 13076 } 13077 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, object->state)) { 13078 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 13079 psFree(md); 13080 return NULL; 13081 } 13058 13082 13059 13083 return md; … … 13065 13089 psS32 iteration; 13066 13090 char *det_type; 13091 char *state; 13067 13092 13068 13093 iteration = psMetadataLookupS32(&status, md, "iteration"); … … 13076 13101 return false; 13077 13102 } 13078 13079 return detRunRowAlloc(iteration, det_type); 13103 state = psMetadataLookupPtr(&status, md, "state"); 13104 if (!status) { 13105 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 13106 return false; 13107 } 13108 13109 return detRunRowAlloc(iteration, det_type, state); 13080 13110 } 13081 13111 psArray *detRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
trunk/ippdb/src/ippdb.h
r9149 r9173 5395 5395 psS32 iteration; 5396 5396 char *det_type; 5397 char *state; 5397 5398 } detRunRow; 5398 5399 … … 5404 5405 detRunRow *detRunRowAlloc( 5405 5406 psS32 iteration, 5406 const char *det_type 5407 const char *det_type, 5408 const char *state 5407 5409 ); 5408 5410 … … 5435 5437 psDB *dbh, ///< Database handle 5436 5438 psS32 iteration, 5437 const char *det_type 5439 const char *det_type, 5440 const char *state 5438 5441 ); 5439 5442 … … 5457 5460 psDB *dbh, ///< Database handle 5458 5461 psS32 *iteration, 5459 char **det_type 5462 char **det_type, 5463 char **state 5460 5464 ); 5461 5465 -
trunk/ippdb/tests/alloc.c
r9149 r9173 937 937 detRunRow *object; 938 938 939 object = detRunRowAlloc(-32, "a string" );939 object = detRunRowAlloc(-32, "a string", "a string" ); 940 940 941 941 if (!object) { … … 948 948 } 949 949 if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) { 950 psFree(object); 951 exit(EXIT_FAILURE); 952 } 953 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 950 954 psFree(object); 951 955 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insert.c
r9149 r9173 343 343 } 344 344 345 if (!detRunInsert(dbh, -32, "a string" )) {345 if (!detRunInsert(dbh, -32, "a string", "a string")) { 346 346 exit(EXIT_FAILURE); 347 347 } -
trunk/ippdb/tests/insertobject.c
r9149 r9173 498 498 } 499 499 500 object = detRunRowAlloc(-32, "a string" );500 object = detRunRowAlloc(-32, "a string", "a string"); 501 501 if (!object) { 502 502 exit(EXIT_FAILURE); -
trunk/ippdb/tests/metadatafromobject.c
r9149 r9173 1115 1115 bool status; 1116 1116 1117 object = detRunRowAlloc(-32, "a string" );1117 object = detRunRowAlloc(-32, "a string", "a string"); 1118 1118 if (!object) { 1119 1119 exit(EXIT_FAILURE); … … 1132 1132 } 1133 1133 if (strncmp(psMetadataLookupPtr(&status, md, "det_type"), "a string", MAX_STRING_LENGTH)) { 1134 psFree(md); 1135 exit(EXIT_FAILURE); 1136 } 1137 if (strncmp(psMetadataLookupPtr(&status, md, "state"), "a string", MAX_STRING_LENGTH)) { 1134 1138 psFree(md); 1135 1139 exit(EXIT_FAILURE); -
trunk/ippdb/tests/objectfrommetadata.c
r9149 r9173 1697 1697 exit(EXIT_FAILURE); 1698 1698 } 1699 if (!psMetadataAddStr(md, PS_LIST_TAIL, "state", 0, NULL, "a string")) { 1700 psFree(md); 1701 exit(EXIT_FAILURE); 1702 } 1699 1703 1700 1704 object = detRunObjectFromMetadata(md); … … 1711 1715 } 1712 1716 if (strncmp(object->det_type, "a string", MAX_STRING_LENGTH)) { 1717 psFree(object); 1718 exit(EXIT_FAILURE); 1719 } 1720 if (strncmp(object->state, "a string", MAX_STRING_LENGTH)) { 1713 1721 psFree(object); 1714 1722 exit(EXIT_FAILURE); -
trunk/ippdb/tests/pop.c
r9149 r9173 499 499 psS32 iteration; 500 500 char det_type[256]; 501 502 dbh = psDBInit("localhost", "test", NULL, "test"); 503 if (!dbh) { 504 exit(EXIT_FAILURE); 505 } 506 507 if (!detRunPop(dbh, &iteration, (char **)&det_type)) { 501 char state[256]; 502 503 dbh = psDBInit("localhost", "test", NULL, "test"); 504 if (!dbh) { 505 exit(EXIT_FAILURE); 506 } 507 508 if (!detRunPop(dbh, &iteration, (char **)&det_type, (char **)&state)) { 508 509 exit(EXIT_FAILURE); 509 510 }
Note:
See TracChangeset
for help on using the changeset viewer.
