Changeset 9790 for trunk/ippTools/src/camtool.c
- Timestamp:
- Oct 30, 2006, 11:56:09 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/camtool.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/camtool.c
r9392 r9790 30 30 static bool pendingimfileMode(pxConfig *config); 31 31 static bool addprocessedexpMode(pxConfig *config); 32 static bool blockMode(pxConfig *config); 33 static bool maskedMode(pxConfig *config); 34 static bool unblockMode(pxConfig *config); 32 35 33 36 # define MODECASE(caseName, func) \ … … 48 51 MODECASE(P3TOOL_MODE_PENDINGIMFILE, pendingimfileMode); 49 52 MODECASE(P3TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpMode); 53 MODECASE(P3TOOL_MODE_BLOCK, blockMode); 54 MODECASE(P3TOOL_MODE_MASKED, maskedMode); 55 MODECASE(P3TOOL_MODE_UNBLOCK, unblockMode); 50 56 default: 51 57 psAbort(argv[0], "invalid option (this should not happen)"); … … 76 82 " LEFT JOIN p3ProcessedExp" 77 83 " USING(exp_tag)" 84 " LEFT JOIN p3Mask" 85 " ON p3PendingExp.label = p3Mask.label" 78 86 " WHERE" 79 87 " p3ProcessedExp.exp_tag IS NULL" 88 " AND p3Mask.label IS NULL" 80 89 ); 81 90 … … 132 141 133 142 psString query = psStringCopy( 134 "SELECT p2ProcessedImfile.*" 135 " FROM p3PendingExp" 136 " JOIN p2ProcessedImfile" 137 " USING(exp_tag, p2_version)" 143 "SELECT p2ProcessedImfile.*" 144 " FROM p3PendingExp" 145 " JOIN p2ProcessedImfile" 146 " USING(exp_tag, p2_version)" 147 " LEFT JOIN p3ProcessedExp" 148 " USING(exp_tag)" 149 " LEFT JOIN p3Mask" 150 " ON p3PendingExp.label = p3Mask.label" 151 " WHERE" 152 " p3ProcessedExp.exp_tag IS NULL" 153 " AND p3Mask.label IS NULL" 138 154 ); 139 155 … … 349 365 zp_stdev, 350 366 pendingRow->p2_version, 351 pendingRow->p3_version 367 pendingRow->p3_version, 368 pendingRow->label 352 369 ); 353 370 psFree(pendingRow); … … 364 381 return true; 365 382 } 383 384 static bool blockMode(pxConfig *config) 385 { 386 PS_ASSERT_PTR_NON_NULL(config, false); 387 388 bool status = false; 389 psString label = psMetadataLookupStr(&status, config->args, "-label"); 390 if (!status) { 391 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 392 return false; 393 } 394 if (!label) { 395 psError(PS_ERR_UNKNOWN, true, "-label is required"); 396 return false; 397 } 398 399 if (!p3MaskInsert(config->dbh, label)) { 400 psError(PS_ERR_UNKNOWN, false, "database error"); 401 return false; 402 } 403 404 return true; 405 } 406 407 static bool maskedMode(pxConfig *config) 408 { 409 PS_ASSERT_PTR_NON_NULL(config, false); 410 411 psString query = psStringCopy("SELECT * FROM p3Mask"); 412 413 if (!p_psDBRunQuery(config->dbh, query)) { 414 psError(PS_ERR_UNKNOWN, false, "database error"); 415 psFree(query); 416 return false; 417 } 418 psFree(query); 419 420 psArray *output = p_psDBFetchResult(config->dbh); 421 if (!output) { 422 psError(PS_ERR_UNKNOWN, false, "database error"); 423 return false; 424 } 425 if (!psArrayLength(output)) { 426 // XXX check psError here 427 psError(PS_ERR_UNKNOWN, false, "no p3Mask rows found"); 428 psFree(output); 429 return true; 430 } 431 432 bool simple = false; 433 { 434 bool status = false; 435 simple = psMetadataLookupBool(&status, config->args, "-simple"); 436 if (!status) { 437 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 438 return false; 439 } 440 } 441 442 // negative simple so the default is true 443 if (!ippdbPrintMetadatas(stdout, output, "p3Mask", !simple)) { 444 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 445 psFree(output); 446 return false; 447 } 448 449 psFree(output); 450 451 return true; 452 } 453 454 static bool unblockMode(pxConfig *config) 455 { 456 PS_ASSERT_PTR_NON_NULL(config, false); 457 458 bool status = false; 459 psString label = psMetadataLookupStr(&status, config->args, "-label"); 460 if (!status) { 461 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 462 return false; 463 } 464 if (!label) { 465 psError(PS_ERR_UNKNOWN, true, "-label is required"); 466 return false; 467 } 468 469 char *query = "DELETE FROM p3Mask WHERE label = '%s'"; 470 471 if (!p_psDBRunQuery(config->dbh, query, label)) { 472 psError(PS_ERR_UNKNOWN, false, "database error"); 473 psFree(query); 474 return false; 475 } 476 477 return true; 478 }
Note:
See TracChangeset
for help on using the changeset viewer.
