Changeset 20841 for trunk/ippTools/src
- Timestamp:
- Nov 25, 2008, 5:21:13 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magicdstool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magicdstool.c
r20788 r20841 41 41 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); 42 42 static bool magicDSRunComplete(pxConfig *config); 43 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id); 43 44 44 45 #ifdef notdef … … 344 345 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 345 346 347 psS64 stage_id, cam_id; 348 349 if (!magicDSGetIDs(config, stage, magic_id, &stage_id, &cam_id)) { 350 psError(PS_ERR_UNKNOWN, false, "failed to get ids"); 351 return false; 352 } 353 346 354 magicDSRunRow *run = magicDSRunRowAlloc( 347 355 0, // ID … … 349 357 "run", // state 350 358 stage, 351 outroot, 359 stage_id, 360 cam_id, 361 outroot, 352 362 recoveryroot, 353 363 re_place, … … 517 527 } 518 528 529 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id) 530 { 531 PS_ASSERT_PTR_NON_NULL(config, false); 532 PS_ASSERT_PTR_NON_NULL(stage, false); 533 PS_ASSERT_PTR_NON_NULL(stage_id, false); 534 PS_ASSERT_PTR_NON_NULL(cam_id, false); 535 536 if (!strcmp(stage, "diff")) { 537 // don't need these ids for diff stage 538 *stage_id = 0; 539 *cam_id = 0; 540 return true; 541 } 542 543 int stageNum; 544 if (!strcmp(stage, "raw")) { 545 stageNum = 0; 546 } else if (!strcmp(stage, "chip")) { 547 stageNum = 1; 548 } else if (!strcmp(stage, "warp")) { 549 stageNum = 2; 550 } else { 551 psError(PXTOOLS_ERR_DATA, true, "%s is not a valid value for stage", stage); 552 return false; 553 } 554 555 556 psString query = pxDataGet("magicdstool_getrunids.sql"); 557 if (!query) { 558 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 559 return false; 560 } 561 562 if (!p_psDBRunQuery(config->dbh, query, magic_id)) { 563 psError(PS_ERR_UNKNOWN, false, "database error"); 564 psFree(query); 565 return false; 566 } 567 psFree(query); 568 569 psArray *output = p_psDBFetchResult(config->dbh); 570 if (!output) { 571 psError(PS_ERR_UNKNOWN, false, "database error"); 572 return false; 573 } 574 if (!psArrayLength(output)) { 575 psTrace("magicdstool", PS_LOG_INFO, "no rows found"); 576 psFree(output); 577 return true; 578 } 579 if (psArrayLength(output) > 1) { 580 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_id %ld", 581 psArrayLength(output), magic_id); 582 return false; 583 } 584 psMetadata *row = output->data[0]; 585 586 *cam_id = psMetadataLookupS64(NULL, row, "cam_id"); 587 if (stageNum == 0) { 588 *stage_id = psMetadataLookupS64(NULL, row, "exp_id"); 589 } else if (stageNum == 1) { 590 *stage_id = psMetadataLookupS64(NULL, row, "chip_id"); 591 } else if (stageNum == 2) { 592 *stage_id = psMetadataLookupS64(NULL, row, "warp_id"); 593 } 594 595 return true; 596 } 597 519 598 static bool magicDSRunComplete(pxConfig *config) 520 599 {
Note:
See TracChangeset
for help on using the changeset viewer.
