Changeset 28412 for trunk/ippTools/src/diffphottool.c
- Timestamp:
- Jun 18, 2010, 4:29:36 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/diffphottool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/diffphottool.c
r28387 r28412 38 38 static bool advanceMode(pxConfig *config); 39 39 static bool revertMode(pxConfig *config); 40 static bool dataMode(pxConfig *config); 40 41 41 42 # define MODECASE(caseName, func) \ … … 64 65 MODECASE(DIFFPHOTTOOL_MODE_ADVANCE, advanceMode); 65 66 MODECASE(DIFFPHOTTOOL_MODE_REVERT, revertMode); 67 MODECASE(DIFFPHOTTOOL_MODE_DATA, dataMode); 66 68 67 69 default: … … 490 492 } 491 493 494 static bool dataMode(pxConfig *config) 495 { 496 PS_ASSERT_PTR_NON_NULL(config, false); 497 498 psMetadata *where = psMetadataAlloc(); 499 500 PXOPT_COPY_S64(config->args, where, "-diff_phot_id", "diff_phot_id", "=="); 501 PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "=="); 502 503 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 504 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 505 506 psString query = pxDataGet("diffphottool_data.sql"); 507 if (!query) { 508 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 509 return false; 510 } 511 512 if (psListLength(where->list)) { 513 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 514 psStringAppend(&query, "\nWHERE %s", clause); 515 psFree(clause); 516 } 517 psFree(where); 518 519 if (limit) { 520 psString limitString = psDBGenerateLimitSQL(limit); 521 psStringAppend(&query, "\n%s", limitString); 522 psFree(limitString); 523 } 524 525 if (!p_psDBRunQuery(config->dbh, query)) { 526 psError(psErrorCodeLast(), false, "database error"); 527 psFree(query); 528 return false; 529 } 530 psFree(query); 531 532 psArray *output = p_psDBFetchResult(config->dbh); 533 if (!output) { 534 psError(psErrorCodeLast(), false, "database error"); 535 return false; 536 } 537 if (!psArrayLength(output)) { 538 psTrace("diffphottool", PS_LOG_INFO, "no rows found"); 539 psFree(output); 540 return true; 541 } 542 543 if (!ippdbPrintMetadatas(stdout, output, "diffPhotSkyfile", !simple)) { 544 psError(psErrorCodeLast(), false, "failed to print array"); 545 psFree(output); 546 return false; 547 } 548 psFree(output); 549 550 return true; 551 } 552
Note:
See TracChangeset
for help on using the changeset viewer.
