Changeset 17863 for branches/cleanup/ippTools/src
- Timestamp:
- May 30, 2008, 11:03:23 AM (18 years ago)
- Location:
- branches/cleanup/ippTools/src
- Files:
-
- 1 added
- 7 edited
-
Makefile.am (modified) (1 diff)
-
chiptool.c (modified) (4 diffs)
-
chiptool.h (modified) (1 diff)
-
chiptoolConfig.c (modified) (2 diffs)
-
pxchip.c (modified) (4 diffs)
-
pxchip.h (modified) (1 diff)
-
pxtools.c (added)
-
pxtools.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/ippTools/src/Makefile.am
r17856 r17863 69 69 pxregister.c \ 70 70 pxtag.c \ 71 pxtools.c \ 71 72 pxtoolsErrorCodes.c \ 72 73 pxtree.c \ -
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); -
branches/cleanup/ippTools/src/chiptool.h
r17859 r17863 39 39 CHIPTOOL_MODE_PENDINGCLEANUP, 40 40 CHIPTOOL_MODE_DONECLEANUP, 41 CHIPTOOL_MODE_RUN 41 42 } chiptoolMode; 42 43 -
branches/cleanup/ippTools/src/chiptoolConfig.c
r17859 r17863 283 283 psMetadataAddU64(donecleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 284 284 285 // -run 286 psMetadata *runArgs = psMetadataAlloc(); 287 psMetadataAddStr(runArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 288 psMetadataAddBool(runArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 289 psMetadataAddU64(runArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 290 psMetadataAddStr(runArgs, PS_LIST_TAIL, "-state", 0, "search by state (required)", NULL); 291 285 292 psMetadata *argSets = psMetadataAlloc(); 286 293 psMetadata *modes = psMetadataAlloc(); … … 312 319 PXOPT_ADD_MODE("-donecleanup", "show runs that have been cleaned", 313 320 CHIPTOOL_MODE_DONECLEANUP, donecleanupArgs); 321 PXOPT_ADD_MODE("-run", "show runs", 322 CHIPTOOL_MODE_RUN, runArgs); 314 323 315 324 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cleanup/ippTools/src/pxchip.c
r17161 r17863 35 35 36 36 // check that state is a valid string value 37 if (!( 38 (strncmp(state, "run", 4) == 0) 39 || (strncmp(state, "stop", 5) == 0) 40 || (strncmp(state, "reg", 4) == 0) 41 ) 42 ) { 43 psError(PS_ERR_UNKNOWN, false, 44 "invalid chipRun state: %s", state); 37 if (!pxIsValidState(state)) { 38 psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state); 45 39 return false; 46 40 } … … 63 57 64 58 // check that state is a valid string value 65 if (!( 66 (strncmp(state, "run", 4) == 0) 67 || (strncmp(state, "stop", 5) == 0) 68 || (strncmp(state, "reg", 4) == 0) 69 ) 70 ) { 71 psError(PS_ERR_UNKNOWN, false, 72 "invalid chipRun state: %s", state); 59 if (!pxIsValidState(state)) { 60 psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state); 73 61 return false; 74 62 } 63 75 64 76 65 psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id) SET state = '%s'"); … … 151 140 0x0, // chip_id 152 141 exp_id, 153 " run", // state142 "new", // state 154 143 workdir, 155 144 "dirty", // workdir_state … … 167 156 return psDBLastInsertID(config->dbh); 168 157 } 158 -
branches/cleanup/ippTools/src/pxchip.h
r17161 r17863 40 40 const char *end_stage); 41 41 42 42 43 #endif // PXCHIP_H -
branches/cleanup/ippTools/src/pxtools.h
r16170 r17863 41 41 # define PXTOOL_MODE_NONE 0x0 42 42 43 bool pxCreateTables (pxConfig *config); 44 bool pxDeleteTables (pxConfig *config); 43 bool pxIsValidState(const char *state); 45 44 46 45 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code);
Note:
See TracChangeset
for help on using the changeset viewer.
