Changeset 18520 for trunk/ippTools/src/magictool.c
- Timestamp:
- Jul 14, 2008, 3:18:02 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magictool.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magictool.c
r18336 r18520 41 41 static bool tomaskMode(pxConfig *config); 42 42 static bool addmaskMode(pxConfig *config); 43 static bool toskyfilemaskMode(pxConfig *config);44 static bool addskyfilemaskMode(pxConfig *config);45 43 46 44 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state); … … 75 73 MODECASE(MAGICTOOL_MODE_TOMASK, tomaskMode); 76 74 MODECASE(MAGICTOOL_MODE_ADDMASK, addmaskMode); 77 MODECASE(MAGICTOOL_MODE_TOSKYFILEMASK, toskyfilemaskMode);78 MODECASE(MAGICTOOL_MODE_ADDSKYFILEMASK, addskyfilemaskMode);79 75 default: 80 76 psAbort("invalid option (this should not happen)"); … … 211 207 NULL, // label 212 208 NULL, // dvodb 213 NULL // registered 209 NULL, // registered 210 0 // fault 214 211 ); 215 212 if (!run) { … … 262 259 PS_ASSERT_PTR_NON_NULL(config, false); 263 260 264 // required 261 // required 265 262 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 266 263 … … 278 275 label, 279 276 dvodb, 280 registered 277 registered, 278 0 281 279 ); 282 280 psFree(registered); 283 281 if (!run) { 284 282 psError(PS_ERR_UNKNOWN, false, "failed to alloc magicRun object"); 285 return true;283 return false; 286 284 } 287 285 if (!magicRunInsertObject(config->dbh, run)) { 288 286 psError(PS_ERR_UNKNOWN, false, "database error"); 289 287 psFree(run); 290 return true;288 return false; 291 289 } 292 290 … … 444 442 return false; 445 443 } 446 444 447 445 return true; 448 446 } … … 491 489 return false; 492 490 } 493 491 494 492 return true; 495 493 } … … 589 587 return true; 590 588 } 591 589 592 590 psHash *forest = psHashAlloc(psArrayLength(magicTree)); 593 591 … … 642 640 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 643 641 PXOPT_LOOKUP_STR(node, config->args, "-node", true, false); 644 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 642 643 // optional 644 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 645 646 // default values 647 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 645 648 646 649 if (!magicNodeResultInsert(config->dbh, 647 (psS64)atoll(magic_id), 648 node, 649 uri 650 (psS64)atoll(magic_id), 651 node, 652 uri, 653 code 650 654 )) { 651 655 psError(PS_ERR_UNKNOWN, false, "database error"); … … 726 730 // required 727 731 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 728 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 732 733 // optional 734 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 735 PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false); 736 737 // default values 738 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 729 739 730 740 if (!magicMaskInsert(config->dbh, 731 (psS64)atoll(magic_id), 732 uri 733 )) { 734 psError(PS_ERR_UNKNOWN, false, "database error"); 735 return false; 736 } 737 738 return true; 739 } 740 741 742 static bool toskyfilemaskMode(pxConfig *config) 743 { 744 PS_ASSERT_PTR_NON_NULL(config, false); 745 746 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 747 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 748 749 psString query = pxDataGet("magictool_toskyfilemask.sql"); 750 if (!query) { 751 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 752 return false; 753 } 754 755 // treat limit == 0 as "no limit" 756 if (limit) { 757 psString limitString = psDBGenerateLimitSQL(limit); 758 psStringAppend(&query, " %s", limitString); 759 psFree(limitString); 760 } 761 762 if (!p_psDBRunQuery(config->dbh, query)) { 763 psError(PS_ERR_UNKNOWN, false, "database error"); 764 psFree(query); 765 return false; 766 } 767 psFree(query); 768 769 psArray *output = p_psDBFetchResult(config->dbh); 770 if (!output) { 771 psErrorCode err = psErrorCodeLast(); 772 switch (err) { 773 case PS_ERR_DB_CLIENT: 774 psError(PXTOOLS_ERR_SYS, false, "database error"); 775 case PS_ERR_DB_SERVER: 776 psError(PXTOOLS_ERR_PROG, false, "database error"); 777 default: 778 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 779 } 780 781 return false; 782 } 783 if (!psArrayLength(output)) { 784 psTrace("magictool", PS_LOG_INFO, "no rows found"); 785 psFree(output); 786 return true; 787 } 788 789 if (psArrayLength(output)) { 790 // negative simple so the default is true 791 if (!ippdbPrintMetadatas(stdout, output, "toskyfilemask", !simple)) { 792 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 793 psFree(output); 794 return false; 795 } 796 } 797 798 psFree(output); 799 800 return true; 801 } 802 803 804 static bool addskyfilemaskMode(pxConfig *config) 805 { 806 PS_ASSERT_PTR_NON_NULL(config, false); 807 808 // required 809 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 810 PXOPT_LOOKUP_STR(diff_id, config->args, "diff_id", true, false); 811 PXOPT_LOOKUP_STR(uri, config->args, "uri", true, false); 812 813 if (!magicSkyfileMaskInsert(config->dbh, 814 (psS64)atoll(magic_id), 815 (psS64)atoll(diff_id), 816 uri 741 (psS64)atoll(magic_id), 742 uri, 743 streaks, 744 code 817 745 )) { 818 746 psError(PS_ERR_UNKNOWN, false, "database error");
Note:
See TracChangeset
for help on using the changeset viewer.
