Changeset 15348 for trunk/ippTools/src/magictool.c
- Timestamp:
- Oct 19, 2007, 4:14:17 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magictool.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magictool.c
r15347 r15348 692 692 { 693 693 PS_ASSERT_PTR_NON_NULL(config, false); 694 695 bool status = false; 696 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 697 if (!status) { 698 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 699 return false; 700 } 701 702 psString query = pxDataGet("magictool_toskyfilemask.sql"); 703 if (!query) { 704 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 705 return false; 706 } 707 708 // treat limit == 0 as "no limit" 709 if (limit) { 710 psString limitString = psDBGenerateLimitSQL(limit); 711 psStringAppend(&query, " %s", limitString); 712 psFree(limitString); 713 } 714 715 if (!p_psDBRunQuery(config->dbh, query)) { 716 psError(PS_ERR_UNKNOWN, false, "database error"); 717 psFree(query); 718 return false; 719 } 720 psFree(query); 721 722 psArray *output = p_psDBFetchResult(config->dbh); 723 if (!output) { 724 psErrorCode err = psErrorCodeLast(); 725 switch (err) { 726 case PS_ERR_DB_CLIENT: 727 psError(PXTOOLS_ERR_SYS, false, "database error"); 728 case PS_ERR_DB_SERVER: 729 psError(PXTOOLS_ERR_PROG, false, "database error"); 730 default: 731 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 732 } 733 734 return false; 735 } 736 if (!psArrayLength(output)) { 737 psTrace("magictool", PS_LOG_INFO, "no rows found"); 738 psFree(output); 739 return true; 740 } 741 742 bool simple = false; 743 { 744 bool status = false; 745 simple = psMetadataLookupBool(&status, config->args, "-simple"); 746 if (!status) { 747 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 748 return false; 749 } 750 } 751 752 if (psArrayLength(output)) { 753 if (!convertIdToStr(output)) { 754 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 755 psFree(output); 756 return false; 757 } 758 759 // negative simple so the default is true 760 if (!ippdbPrintMetadatas(stdout, output, "toskyfilemask", !simple)) { 761 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 762 psFree(output); 763 return false; 764 } 765 } 766 767 psFree(output); 768 694 769 return true; 695 770 }
Note:
See TracChangeset
for help on using the changeset viewer.
