Changeset 18154 for branches/cleanup/ippTools/src/chiptool.c
- Timestamp:
- Jun 16, 2008, 3:58:22 PM (18 years ago)
- File:
-
- 1 edited
-
branches/cleanup/ippTools/src/chiptool.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/ippTools/src/chiptool.c
r18153 r18154 45 45 static bool unmaskedMode(pxConfig *config); 46 46 static bool unblockMode(pxConfig *config); 47 static bool pendingcleanupMode(pxConfig *config); 47 static bool pendingcleanuprunMode(pxConfig *config); 48 static bool pendingcleanupimfileMode(pxConfig *config); 48 49 static bool donecleanupMode(pxConfig *config); 49 50 static bool runMode(pxConfig *config); … … 68 69 69 70 switch (config->mode) { 70 MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY, definebyqueryMode);71 MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 71 72 MODECASE(CHIPTOOL_MODE_UPDATERUN, updaterunMode); 72 73 MODECASE(CHIPTOOL_MODE_PENDINGIMFILE, pendingimfileMode); … … 79 80 MODECASE(CHIPTOOL_MODE_UNMASKED, unmaskedMode); 80 81 MODECASE(CHIPTOOL_MODE_UNBLOCK, unblockMode); 81 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUP, pendingcleanupMode); 82 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 83 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPIMFILE, pendingcleanupimfileMode); 82 84 MODECASE(CHIPTOOL_MODE_DONECLEANUP, donecleanupMode); 83 85 MODECASE(CHIPTOOL_MODE_RUN, runMode); … … 942 944 943 945 944 static bool pendingcleanup Mode(pxConfig *config)946 static bool pendingcleanuprunMode(pxConfig *config) 945 947 { 946 948 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 952 954 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 953 955 954 psString query = pxDataGet("chiptool_pendingcleanup .sql");956 psString query = pxDataGet("chiptool_pendingcleanuprun.sql"); 955 957 if (!query) { 956 958 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 997 999 998 1000 // negative simple so the default is true 999 if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanup", !simple)) { 1001 if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanupRun", !simple)) { 1002 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1003 psFree(output); 1004 return false; 1005 } 1006 1007 psFree(output); 1008 1009 return true; 1010 } 1011 1012 1013 static bool pendingcleanupimfileMode(pxConfig *config) 1014 { 1015 PS_ASSERT_PTR_NON_NULL(config, NULL); 1016 1017 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false); 1018 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1019 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1020 1021 psMetadata *where = psMetadataAlloc(); 1022 if (chip_id) { 1023 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 1024 } 1025 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1026 1027 psString query = pxDataGet("chiptool_pendingcleanupimfile.sql"); 1028 if (!query) { 1029 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1030 return false; 1031 } 1032 1033 if (where && psListLength(where->list)) { 1034 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1035 psStringAppend(&query, " AND %s", whereClause); 1036 psFree(whereClause); 1037 } 1038 psFree(where); 1039 1040 // treat limit == 0 as "no limit" 1041 if (limit) { 1042 psString limitString = psDBGenerateLimitSQL(limit); 1043 psStringAppend(&query, " %s", limitString); 1044 psFree(limitString); 1045 } 1046 1047 if (!p_psDBRunQuery(config->dbh, query)) { 1048 psError(PS_ERR_UNKNOWN, false, "database error"); 1049 psFree(query); 1050 return false; 1051 } 1052 psFree(query); 1053 1054 psArray *output = p_psDBFetchResult(config->dbh); 1055 if (!output) { 1056 psError(PS_ERR_UNKNOWN, false, "database error"); 1057 return false; 1058 } 1059 if (!psArrayLength(output)) { 1060 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1061 psFree(output); 1062 return true; 1063 } 1064 1065 if (!convertIdToStr(output)) { 1066 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 1067 psFree(output); 1068 return false; 1069 } 1070 1071 // negative simple so the default is true 1072 if (!ippdbPrintMetadatas(stdout, output, "chipPendingCleanupImfile", !simple)) { 1000 1073 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1001 1074 psFree(output);
Note:
See TracChangeset
for help on using the changeset viewer.
