Changeset 17863 for branches/cleanup/ippTools/src/chiptool.c
- Timestamp:
- May 30, 2008, 11:03:23 AM (18 years ago)
- File:
-
- 1 edited
-
branches/cleanup/ippTools/src/chiptool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/ippTools/src/chiptool.c
r17859 r17863 47 47 static bool pendingcleanupMode(pxConfig *config); 48 48 static bool donecleanupMode(pxConfig *config); 49 static bool runMode(pxConfig *config); 49 50 50 51 static bool chipProcessedCompleteExp(pxConfig *config); … … 80 81 MODECASE(CHIPTOOL_MODE_PENDINGCLEANUP, pendingcleanupMode); 81 82 MODECASE(CHIPTOOL_MODE_DONECLEANUP, donecleanupMode); 83 MODECASE(CHIPTOOL_MODE_RUN, runMode); 82 84 default: 83 85 psAbort("invalid option (this should not happen)"); … … 1074 1076 1075 1077 1078 static bool runMode(pxConfig *config) 1079 { 1080 PS_ASSERT_PTR_NON_NULL(config, NULL); 1081 1082 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 1083 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1084 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1085 1086 // make sure that the state string is valid 1087 if (!pxIsValidState(state)) { 1088 psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state); 1089 return false; 1090 } 1091 1092 psMetadata *where = psMetadataAlloc(); 1093 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1094 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 1095 1096 psString query = pxDataGet("chiptool_run.sql"); 1097 if (!query) { 1098 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1099 return false; 1100 } 1101 1102 if (where && psListLength(where->list)) { 1103 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1104 psStringAppend(&query, " %s", whereClause); 1105 psFree(whereClause); 1106 } 1107 psFree(where); 1108 1109 // treat limit == 0 as "no limit" 1110 if (limit) { 1111 psString limitString = psDBGenerateLimitSQL(limit); 1112 psStringAppend(&query, " %s", limitString); 1113 psFree(limitString); 1114 } 1115 1116 if (!p_psDBRunQuery(config->dbh, query)) { 1117 psError(PS_ERR_UNKNOWN, false, "database error"); 1118 psFree(query); 1119 return false; 1120 } 1121 psFree(query); 1122 1123 psArray *output = p_psDBFetchResult(config->dbh); 1124 if (!output) { 1125 psError(PS_ERR_UNKNOWN, false, "database error"); 1126 return false; 1127 } 1128 if (!psArrayLength(output)) { 1129 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1130 psFree(output); 1131 return true; 1132 } 1133 1134 if (!convertIdToStr(output)) { 1135 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 1136 psFree(output); 1137 return false; 1138 } 1139 1140 // negative simple so the default is true 1141 if (!ippdbPrintMetadatas(stdout, output, "chipDoneCleanup", !simple)) { 1142 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1143 psFree(output); 1144 return false; 1145 } 1146 1147 psFree(output); 1148 1149 return true; 1150 } 1151 1152 1076 1153 static bool chipProcessedCompleteExp(pxConfig *config) 1077 1154 { … … 1109 1186 chipRunRow *chipRun = chipRunObjectFromMetadata(row); 1110 1187 // set chipRun.state to 'stop' 1111 if (!pxchipRunSetState(config, chipRun->chip_id, " stop")) {1188 if (!pxchipRunSetState(config, chipRun->chip_id, "full")) { 1112 1189 psError(PS_ERR_UNKNOWN, false, "failed to change chipRun.state for chip_id: %" PRId64, chipRun->chip_id); 1113 1190 psFree(chipRun);
Note:
See TracChangeset
for help on using the changeset viewer.
