Changeset 18561 for trunk/ippTools/src/dettool_correction.c
- Timestamp:
- Jul 15, 2008, 10:30:59 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool_correction.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool_correction.c
r18336 r18561 18 18 */ 19 19 20 #ifdef HAVB_CONFIG_H21 #include <config.h>22 #endif23 24 #include <stdio.h>25 #include <string.h>26 #include <stdlib.h>27 #include <stdint.h>28 #include <inttypes.h>29 30 #include <ippdb.h>31 32 #include "pxtools.h"33 20 #include "dettool.h" 34 21 … … 37 24 PS_ASSERT_PTR_NON_NULL(config, false); 38 25 39 bool status = false; 40 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 41 if (!status) { 42 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 43 return false; 44 } 45 if (!det_id) { 46 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 47 return false; 48 } 49 50 psArray *runs = detRunSelectRowObjects(config->dbh, config->where, 1); 26 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); // required 27 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); // optional 28 29 // build the needed where 30 psMetadata *where = psMetadataAlloc(); 31 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", (psS64)atoll(det_id)); 32 psArray *runs = detRunSelectRowObjects(config->dbh, where, 1); 33 psFree (where); 34 51 35 if (!psArrayLength(runs)) { 52 36 psError(PS_ERR_UNKNOWN, false, "database error"); … … 103 87 } 104 88 105 psArray *detRuns = NULL; 106 { 107 psMetadata *where = psMetadataAlloc(); 108 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", new_det_id); 109 detRuns = psDBSelectRows(config->dbh, "detRun", where, 0); 110 psFree(where); 111 } 89 psMetadata *where_new = psMetadataAlloc(); 90 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", new_det_id); 91 psArray *detRuns = psDBSelectRows(config->dbh, "detRun", where_new, 0); 92 psFree(where_new); 93 112 94 if (!detRuns) { 113 95 psError(PS_ERR_UNKNOWN, false, "can't find the detRun we just created"); … … 118 100 psAbort("found more then one detRun matching det_id %" PRId64 "(this should not happen)", new_det_id); 119 101 return false; 120 }121 122 bool simple = false;123 {124 bool status = false;125 simple = psMetadataLookupBool(&status, config->args, "-simple");126 if (!status) {127 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");128 return false;129 }130 102 } 131 103 … … 145 117 PS_ASSERT_PTR_NON_NULL(config, false); 146 118 147 bool status = false; 148 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 149 if (!status) { 150 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 151 return false; 152 } 119 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 120 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 153 121 154 122 psString query = pxDataGet("dettool_tocorrectexp.sql"); … … 183 151 } 184 152 185 bool simple = false;186 {187 bool status = false;188 simple = psMetadataLookupBool(&status, config->args, "-simple");189 if (!status) {190 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");191 return false;192 }193 }194 195 153 // negative simple so the default is true 196 154 if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) { … … 209 167 PS_ASSERT_PTR_NON_NULL(config, false); 210 168 211 bool status = false; 212 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 213 if (!status) { 214 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 215 return false; 216 } 169 psMetadata *where = psMetadataAlloc(); 170 PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "=="); 171 172 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 173 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 217 174 218 175 psString query = pxDataGet("dettool_tocorrectimfile.sql"); … … 222 179 } 223 180 224 if (config->where) { 225 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "det1"); 181 if (psListLength(where->list)) { 182 // NOTE the SQL uses an intermediate table 'det1' for this query 183 psString whereClause = psDBGenerateWhereConditionSQL(where, "det1"); 226 184 psStringAppend(&query, " AND %s", whereClause); 227 185 psFree(whereClause); 228 186 } 187 psFree (where); 229 188 230 189 // treat limit == 0 as "no limit" … … 253 212 } 254 213 255 bool simple = false;256 {257 bool status = false;258 simple = psMetadataLookupBool(&status, config->args, "-simple");259 if (!status) {260 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");261 return false;262 }263 }264 265 214 // negative simple so the default is true 266 215 if (!ippdbPrintMetadatas(stdout, output, "detPendingCorrectImfile", !simple)) { … … 275 224 } 276 225 226 // NOTE : the command-line args are parsed by register_detrend_imfileMode 277 227 bool addcorrectimfileMode(pxConfig *config) 278 228 {
Note:
See TracChangeset
for help on using the changeset viewer.
