Changeset 16362 for trunk/ippTools/src/pztool.c
- Timestamp:
- Feb 7, 2008, 3:54:05 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pztool.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pztool.c
r16360 r16362 651 651 { 652 652 PS_ASSERT_PTR_NON_NULL(config, false); 653 654 psMetadata *where = psMetadataAlloc(); 655 656 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 657 PXOPT_COPY_STR(config->args, where, "-inst", "inst", "=="); 658 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 659 PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); 660 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 661 662 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 663 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 664 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 665 666 psString query = psStringCopy("SELECT * FROM pzDoneImfile"); 667 668 if (faulted) { 669 // list only faulted rows 670 psStringAppend(&query, " %s", "WHERE pzDoneImfile.fault != 0"); 671 } else { 672 // don't list faulted rows 673 psStringAppend(&query, " %s", "WHERE pzDoneImfile.fault = 0"); 674 } 675 676 if (psListLength(where->list)) { 677 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDoneImfile"); 678 psStringAppend(&query, " AND %s", whereClause); 679 psFree(whereClause); 680 } 681 psFree(where); 682 683 // treat limit == 0 as "no limit" 684 if (limit) { 685 psString limitString = psDBGenerateLimitSQL(limit); 686 psStringAppend(&query, " %s", limitString); 687 psFree(limitString); 688 } 689 690 if (!p_psDBRunQuery(config->dbh, query)) { 691 psError(PS_ERR_UNKNOWN, false, "database error"); 692 psFree(query); 693 return false; 694 } 695 psFree(query); 696 697 psArray *output = p_psDBFetchResult(config->dbh); 698 if (!output) { 699 psError(PS_ERR_UNKNOWN, false, "database error"); 700 return false; 701 } 702 if (!psArrayLength(output)) { 703 psTrace("pztool", PS_LOG_INFO, "no rows found"); 704 psFree(output); 705 return true; 706 } 707 708 // negative simple so the default is true 709 if (!ippdbPrintMetadatas(stdout, output, "chipPendingImfile", !simple)) { 710 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 711 psFree(output); 712 return false; 713 } 714 715 psFree(output); 716 653 717 return true; 654 718 }
Note:
See TracChangeset
for help on using the changeset viewer.
