Changeset 9765 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Oct 27, 2006, 2:47:05 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r9764 r9765 33 33 static bool pendingimfileMode(pxConfig *config); 34 34 static bool addprocessedimfileMode(pxConfig *config); 35 static bool blockMode(pxConfig *config); 36 static bool maskedMode(pxConfig *config); 37 static bool unblockMode(pxConfig *config); 35 38 static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile); 36 39 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp); … … 51 54 52 55 switch (config->mode) { 53 MODECASE(P2TOOL_MODE_QUICK, quickMode);54 MODECASE(P2TOOL_MODE_DEFINE, defineMode);56 MODECASE(P2TOOL_MODE_QUICK, quickMode); 57 MODECASE(P2TOOL_MODE_DEFINE, defineMode); 55 58 MODECASE(P2TOOL_MODE_PENDINGIMFILE, pendingimfileMode); 56 59 MODECASE(P2TOOL_MODE_ADDPROCESSEDIMFILE, addprocessedimfileMode); 60 MODECASE(P2TOOL_MODE_BLOCK, blockMode); 61 MODECASE(P2TOOL_MODE_MASKED, maskedMode); 62 MODECASE(P2TOOL_MODE_UNBLOCK, unblockMode); 57 63 default: 58 64 psAbort(argv[0], "invalid option (this should not happen)"); … … 385 391 if (!psDBCommit(config->dbh)) { 386 392 psError(PS_ERR_UNKNOWN, false, "database error"); 393 return false; 394 } 395 396 return true; 397 } 398 399 static bool blockMode(pxConfig *config) 400 { 401 PS_ASSERT_PTR_NON_NULL(config, false); 402 403 bool status = false; 404 psString label = psMetadataLookupStr(&status, config->args, "-label"); 405 if (!status) { 406 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 407 return false; 408 } 409 if (!label) { 410 psError(PS_ERR_UNKNOWN, true, "-label is required"); 411 return false; 412 } 413 414 if (!p2MaskInsert(config->dbh, label)) { 415 psError(PS_ERR_UNKNOWN, false, "database error"); 416 return false; 417 } 418 419 return true; 420 } 421 422 static bool maskedMode(pxConfig *config) 423 { 424 PS_ASSERT_PTR_NON_NULL(config, false); 425 426 psString query = psStringCopy("SELECT * FROM p2Mask"); 427 428 if (!p_psDBRunQuery(config->dbh, query)) { 429 psError(PS_ERR_UNKNOWN, false, "database error"); 430 psFree(query); 431 return false; 432 } 433 psFree(query); 434 435 psArray *output = p_psDBFetchResult(config->dbh); 436 if (!output) { 437 psError(PS_ERR_UNKNOWN, false, "database error"); 438 return false; 439 } 440 if (!psArrayLength(output)) { 441 // XXX check psError here 442 psError(PS_ERR_UNKNOWN, false, "no p2Mask rows found"); 443 psFree(output); 444 return true; 445 } 446 447 bool simple = false; 448 { 449 bool status = false; 450 simple = psMetadataLookupBool(&status, config->args, "-simple"); 451 if (!status) { 452 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 453 return false; 454 } 455 } 456 457 // negative simple so the default is true 458 if (!ippdbPrintMetadatas(stdout, output, "p2Mask", !simple)) { 459 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 460 psFree(output); 461 return false; 462 } 463 464 psFree(output); 465 466 return true; 467 } 468 469 static bool unblockMode(pxConfig *config) 470 { 471 PS_ASSERT_PTR_NON_NULL(config, false); 472 473 bool status = false; 474 psString label = psMetadataLookupStr(&status, config->args, "-label"); 475 if (!status) { 476 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 477 return false; 478 } 479 if (!label) { 480 psError(PS_ERR_UNKNOWN, true, "-label is required"); 481 return false; 482 } 483 484 char *query = "DELETE FROM p2Mask WHERE label = '%s'"; 485 486 if (!p_psDBRunQuery(config->dbh, query, label)) { 487 psError(PS_ERR_UNKNOWN, false, "database error"); 488 psFree(query); 387 489 return false; 388 490 }
Note:
See TracChangeset
for help on using the changeset viewer.
