Changeset 9970
- Timestamp:
- Nov 13, 2006, 5:15:56 PM (20 years ago)
- Location:
- trunk/ippdb
- Files:
-
- 8 edited
-
configure.ac (modified) (1 diff)
-
src/ippdb.c (modified) (10 diffs)
-
src/ippdb.h (modified) (3 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)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/configure.ac
r9796 r9970 7 7 AC_PREREQ(2.59) 8 8 9 AC_INIT([ippdb], [0.0.5 4], [pan-starrs.ifa.hawaii.edu])9 AC_INIT([ippdb], [0.0.55], [pan-starrs.ifa.hawaii.edu]) 10 10 AC_CONFIG_SRCDIR([ippdb.pc.in]) 11 11 -
trunk/ippdb/src/ippdb.c
r9796 r9970 234 234 static void summitExpRowFree(summitExpRow *object); 235 235 236 summitExpRow *summitExpRowAlloc(const char *exp_id, const char *camera, const char *telescope, const char *exp_type, const char *uri)236 summitExpRow *summitExpRowAlloc(const char *exp_id, const char *camera, const char *telescope, psTime* time, const char *exp_type, const char *uri) 237 237 { 238 238 summitExpRow *_object; … … 244 244 _object->camera = psStringCopy(camera); 245 245 _object->telescope = psStringCopy(telescope); 246 _object->time = psTimeCopy(time); 246 247 _object->exp_type = psStringCopy(exp_type); 247 248 _object->uri = psStringCopy(uri); … … 255 256 psFree(object->camera); 256 257 psFree(object->telescope); 258 psFree(object->time); 257 259 psFree(object->exp_type); 258 260 psFree(object->uri); … … 277 279 return false; 278 280 } 281 psTime* time = psTimeFromISO("", PS_TIME_UTC); 282 if (!psMetadataAdd(md, PS_LIST_TAIL, "time", PS_DATA_TIME, NULL, time)) { 283 psFree(time); 284 psError(PS_ERR_UNKNOWN, false, "failed to add item time"); 285 psFree(md); 286 return false; 287 } 288 psFree(time); 279 289 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, "64")) { 280 290 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type"); … … 300 310 } 301 311 302 bool summitExpInsert(psDB * dbh, const char *exp_id, const char *camera, const char *telescope, const char *exp_type, const char *uri)312 bool summitExpInsert(psDB * dbh, const char *exp_id, const char *camera, const char *telescope, psTime* time, const char *exp_type, const char *uri) 303 313 { 304 314 psMetadata *md = psMetadataAlloc(); … … 315 325 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, telescope)) { 316 326 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 327 psFree(md); 328 return false; 329 } 330 if (!psMetadataAdd(md, PS_LIST_TAIL, "time", PS_DATA_TIME, NULL, time)) { 331 psError(PS_ERR_UNKNOWN, false, "failed to add item time"); 317 332 psFree(md); 318 333 return false; … … 351 366 bool summitExpInsertObject(psDB *dbh, summitExpRow *object) 352 367 { 353 return summitExpInsert(dbh, object->exp_id, object->camera, object->telescope, object-> exp_type, object->uri);368 return summitExpInsert(dbh, object->exp_id, object->camera, object->telescope, object->time, object->exp_type, object->uri); 354 369 } 355 370 … … 439 454 return false; 440 455 } 456 if (!psMetadataAdd(md, PS_LIST_TAIL, "time", PS_DATA_TIME, NULL, object->time)) { 457 psError(PS_ERR_UNKNOWN, false, "failed to add item time"); 458 psFree(md); 459 return false; 460 } 441 461 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, object->exp_type)) { 442 462 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type"); … … 473 493 return false; 474 494 } 495 psTime* time = psMetadataLookupPtr(&status, md, "time"); 496 if (!status) { 497 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item time"); 498 return false; 499 } 475 500 char* exp_type = psMetadataLookupPtr(&status, md, "exp_type"); 476 501 if (!status) { … … 484 509 } 485 510 486 return summitExpRowAlloc(exp_id, camera, telescope, exp_type, uri);511 return summitExpRowAlloc(exp_id, camera, telescope, time, exp_type, uri); 487 512 } 488 513 psArray *summitExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
trunk/ippdb/src/ippdb.h
r9796 r9970 134 134 char *camera; 135 135 char *telescope; 136 psTime* time; 136 137 char *exp_type; 137 138 char *uri; … … 147 148 const char *camera, 148 149 const char *telescope, 150 psTime* time, 149 151 const char *exp_type, 150 152 const char *uri … … 181 183 const char *camera, 182 184 const char *telescope, 185 psTime* time, 183 186 const char *exp_type, 184 187 const char *uri -
trunk/ippdb/tests/alloc.c
r9788 r9970 11 11 summitExpRow *object; 12 12 13 object = summitExpRowAlloc("a string", "a string", "a string", " a string", "a string" );13 object = summitExpRowAlloc("a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string" ); 14 14 15 15 if (!object) { … … 26 26 } 27 27 if (strncmp(object->telescope, "a string", MAX_STRING_LENGTH)) { 28 psFree(object); 29 exit(EXIT_FAILURE); 30 } 28 31 psFree(object); 29 32 exit(EXIT_FAILURE); -
trunk/ippdb/tests/insert.c
r9788 r9970 13 13 } 14 14 15 if (!summitExpInsert(dbh, "a string", "a string", "a string", " a string", "a string")) {15 if (!summitExpInsert(dbh, "a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string")) { 16 16 exit(EXIT_FAILURE); 17 17 } -
trunk/ippdb/tests/insertobject.c
r9788 r9970 14 14 } 15 15 16 object = summitExpRowAlloc("a string", "a string", "a string", " a string", "a string");16 object = summitExpRowAlloc("a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string"); 17 17 if (!object) { 18 18 exit(EXIT_FAILURE); -
trunk/ippdb/tests/metadatafromobject.c
r9788 r9970 13 13 bool status; 14 14 15 object = summitExpRowAlloc("a string", "a string", "a string", " a string", "a string");15 object = summitExpRowAlloc("a string", "a string", "a string", "0001-01-01T00:00:00Z", "a string", "a string"); 16 16 if (!object) { 17 17 exit(EXIT_FAILURE); … … 34 34 } 35 35 if (strncmp(psMetadataLookupPtr(&status, md, "telescope"), "a string", MAX_STRING_LENGTH)) { 36 psFree(md); 37 exit(EXIT_FAILURE); 38 } 36 39 psFree(md); 37 40 exit(EXIT_FAILURE); -
trunk/ippdb/tests/objectfrommetadata.c
r9788 r9970 25 25 exit(EXIT_FAILURE); 26 26 } 27 psFree(md); 28 exit(EXIT_FAILURE); 29 } 27 30 if (!psMetadataAddStr(md, PS_LIST_TAIL, "exp_type", 0, NULL, "a string")) { 28 31 psFree(md); … … 51 54 } 52 55 if (strncmp(object->telescope, "a string", MAX_STRING_LENGTH)) { 56 psFree(object); 57 exit(EXIT_FAILURE); 58 } 53 59 psFree(object); 54 60 exit(EXIT_FAILURE);
Note:
See TracChangeset
for help on using the changeset viewer.
