Changeset 10972 for trunk/ippTools/src/regtool.c
- Timestamp:
- Jan 8, 2007, 2:34:21 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/regtool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/regtool.c
r10671 r10972 31 31 static bool updateexpMode(pxConfig *config); 32 32 static bool updateimfileMode(pxConfig *config); 33 static bool faultimfileMode(pxConfig *config); 33 34 static bool rawimfileMode(pxConfig *config); 34 35 // static p1PendingExpRow *newToP1PendingExp(newExpRow *newExp); … … 38 39 static rawDetrendExpRow *newToRawDetrendExp(pxConfig *config, newExpRow *exp); 39 40 static rawImfileRow *newToRawImfile(pxConfig *config, newImfileRow *exp); 41 static psU32 mapCodeStrToInt(char *codeStr); 40 42 41 43 … … 58 60 MODECASE(P0TOOL_MODE_UPDATEEXP, updateexpMode); 59 61 MODECASE(P0TOOL_MODE_UPDATEIMFILE, updateimfileMode); 62 MODECASE(P0TOOL_MODE_FAULTIMFILE, faultimfileMode); 60 63 MODECASE(P0TOOL_MODE_RAWIMFILE, rawimfileMode); 61 64 default: … … 234 237 235 238 psFree(output); 239 240 return true; 241 } 242 243 static bool faultimfileMode(pxConfig *config) 244 { 245 PS_ASSERT_PTR_NON_NULL(config, false); 246 247 bool status = false; 248 psString codeStr = psMetadataLookupStr(&status, config->args, "-code"); 249 if (!status) { 250 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 251 return false; 252 } 253 if (!codeStr) { 254 psError(PS_ERR_UNKNOWN, true, "-code is required"); 255 return false; 256 } 257 258 // map code string to numeric fault code 259 psU32 code = mapCodeStrToInt(codeStr); 260 if (code == (psU32)-1) { 261 psError(PS_ERR_UNKNOWN, false, "error resolving error code"); 262 return false; 263 } 264 265 // update the database 266 psMetadata *values = psMetadataAlloc(); 267 if (!psMetadataAddU32(values, PS_LIST_HEAD, "flags", 0, NULL, code)) { 268 psError(PS_ERR_UNKNOWN, false, "failed to add metadata item flags"); 269 psFree(values); 270 return false; 271 } 272 psFree(values); 273 274 long rowsAffected = psDBUpdateRows(config->dbh, "newImfile", config->where, values); 275 if (rowsAffected < 0) { 276 // database error 277 psError(PS_ERR_UNKNOWN, false, "database error"); 278 return false; 279 } 280 if (rowsAffected < 1) { 281 // we didn't do anything 282 psError(PS_ERR_UNKNOWN, false, "zero rows were affected - either the search criteria didn't match any rows or the field already had the value being set."); 283 return false; 284 } 236 285 237 286 return true; … … 1025 1074 } 1026 1075 1076 static psU32 mapCodeStrToInt(char *codeStr) 1077 { 1078 if (strcasestr(codeStr, "none")) { 1079 return PX_ERROR_NONE; 1080 } else if (strcasestr(codeStr, "unknown")) { 1081 return PX_ERROR_UNKNOWN; 1082 } else if (strcasestr(codeStr, "bad_data")) { 1083 return PX_ERROR_BAD_DATA; 1084 } else if (strcasestr(codeStr, "id10t")) { 1085 return PX_ERROR_ID10T; 1086 } 1087 1088 psError(PS_ERR_UNKNOWN, true, "invalid fault code string"); 1089 1090 return (psU32) -1; 1091 }
Note:
See TracChangeset
for help on using the changeset viewer.
