Changeset 16613 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Feb 22, 2008, 10:23:58 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r16556 r16613 42 42 static bool blockMode(pxConfig *config); 43 43 static bool maskedMode(pxConfig *config); 44 static bool unmaskedMode(pxConfig *config); 44 45 static bool unblockMode(pxConfig *config); 45 46 … … 71 72 MODECASE(CHIPTOOL_MODE_BLOCK, blockMode); 72 73 MODECASE(CHIPTOOL_MODE_MASKED, maskedMode); 74 MODECASE(CHIPTOOL_MODE_UNMASKED, unmaskedMode); 73 75 MODECASE(CHIPTOOL_MODE_UNBLOCK, unblockMode); 74 76 default: … … 504 506 505 507 if (psDBAffectedRows(config->dbh) < 1) { 506 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row");508 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row"); 507 509 return false; 508 510 } … … 545 547 PS_ASSERT_PTR_NON_NULL(config, false); 546 548 549 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 550 551 psMetadata *where = psMetadataAlloc(); 552 553 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 554 555 if (where->list->n < 1) { 556 psFree(where); 557 where = NULL; 558 } 559 547 560 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 548 561 549 562 psString query = psStringCopy("SELECT * FROM chipMask"); 563 564 if (where) { 565 psString whereClause = psDBGenerateWhereSQL(where, NULL); 566 psFree(where); 567 psStringAppend(&query, " %s", whereClause); 568 psFree(whereClause); 569 } 570 571 // treat limit == 0 as "no limit" 572 if (limit) { 573 psString limitString = psDBGenerateLimitSQL(limit); 574 psStringAppend(&query, " %s", limitString); 575 psFree(limitString); 576 } 550 577 551 578 if (!p_psDBRunQuery(config->dbh, query)) { … … 575 602 // negative simple so the default is true 576 603 if (!ippdbPrintMetadatas(stdout, output, "chipMask", !simple)) { 604 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 605 psFree(output); 606 return false; 607 } 608 609 psFree(output); 610 611 return true; 612 } 613 614 // return the list of labels which are NOT blocked 615 static bool unmaskedMode(pxConfig *config) 616 { 617 PS_ASSERT_PTR_NON_NULL(config, false); 618 619 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 620 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 621 622 psMetadata *where = psMetadataAlloc(); 623 624 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 625 626 if (where->list->n < 1) { 627 psFree(where); 628 where = NULL; 629 } 630 631 psString query = pxDataGet("chiptool_unmasked.sql"); 632 if (!query) { 633 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 634 return false; 635 } 636 637 if (where) { 638 psString whereClause = psDBGenerateWhereSQL(where, "chipUnmask"); 639 psFree(where); 640 psStringAppend(&query, " %s", whereClause); 641 psFree(whereClause); 642 } 643 644 // treat limit == 0 as "no limit" 645 if (limit) { 646 psString limitString = psDBGenerateLimitSQL(limit); 647 psStringAppend(&query, " %s", limitString); 648 psFree(limitString); 649 } 650 651 if (!p_psDBRunQuery(config->dbh, query)) { 652 psError(PS_ERR_UNKNOWN, false, "database error"); 653 psFree(query); 654 return false; 655 } 656 psFree(query); 657 658 psArray *output = p_psDBFetchResult(config->dbh); 659 if (!output) { 660 psError(PS_ERR_UNKNOWN, false, "database error"); 661 return false; 662 } 663 if (!psArrayLength(output)) { 664 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 665 psFree(output); 666 return true; 667 } 668 669 if (!convertIdToStr(output)) { 670 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 671 psFree(output); 672 return false; 673 } 674 675 // negative simple so the default is true 676 if (!ippdbPrintMetadatas(stdout, output, "chipUnmask", !simple)) { 577 677 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 578 678 psFree(output);
Note:
See TracChangeset
for help on using the changeset viewer.
