Changeset 15340 for trunk/ippTools/src/magictool.c
- Timestamp:
- Oct 19, 2007, 3:23:46 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magictool.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magictool.c
r15339 r15340 572 572 { 573 573 PS_ASSERT_PTR_NON_NULL(config, false); 574 575 bool status = false; 576 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 577 if (!status) { 578 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 579 return false; 580 } 581 582 // look for "inputs" that need to processed 583 psString query = pxDataGet("magictool_tomask.sql"); 584 if (!query) { 585 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 586 return false; 587 } 588 589 // treat limit == 0 as "no limit" 590 if (limit) { 591 psString limitString = psDBGenerateLimitSQL(limit); 592 psStringAppend(&query, " %s", limitString); 593 psFree(limitString); 594 } 595 596 if (!p_psDBRunQuery(config->dbh, query)) { 597 psError(PS_ERR_UNKNOWN, false, "database error"); 598 psFree(query); 599 return false; 600 } 601 psFree(query); 602 603 psArray *output = p_psDBFetchResult(config->dbh); 604 if (!output) { 605 psErrorCode err = psErrorCodeLast(); 606 switch (err) { 607 case PS_ERR_DB_CLIENT: 608 psError(PXTOOLS_ERR_SYS, false, "database error"); 609 case PS_ERR_DB_SERVER: 610 psError(PXTOOLS_ERR_PROG, false, "database error"); 611 default: 612 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 613 } 614 615 return false; 616 } 617 if (!psArrayLength(output)) { 618 psTrace("magictool", PS_LOG_INFO, "no rows found"); 619 psFree(output); 620 return true; 621 } 622 623 bool simple = false; 624 { 625 bool status = false; 626 simple = psMetadataLookupBool(&status, config->args, "-simple"); 627 if (!status) { 628 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 629 return false; 630 } 631 } 632 633 if (psArrayLength(output)) { 634 if (!convertIdToStr(output)) { 635 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 636 psFree(output); 637 return false; 638 } 639 640 // negative simple so the default is true 641 if (!ippdbPrintMetadatas(stdout, output, "toprocess", !simple)) { 642 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 643 psFree(output); 644 return false; 645 } 646 } 647 648 psFree(output); 649 574 650 return true; 575 651 }
Note:
See TracChangeset
for help on using the changeset viewer.
