Changeset 7247 for trunk/ippTools/src/dettool.c
- Timestamp:
- May 30, 2006, 3:59:22 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r7243 r7247 4 4 5 5 #include <stdlib.h> 6 #include <metadatadb.h> 6 7 7 8 #include "pxtools.h" … … 9 10 10 11 static bool defineMode(pxConfig *config); 12 static bool runsMode(pxConfig *config); 11 13 static bool rawMode(pxConfig *config); 12 14 static bool addprocMode(pxConfig *config); … … 31 33 case DETTOOL_MODE_DEFINE: 32 34 if (!defineMode(config)) { 35 goto FAIL; 36 } 37 break; 38 case DETTOOL_MODE_RUNS: 39 if (!runsMode(config)) { 33 40 goto FAIL; 34 41 } … … 163 170 // print the new det_id 164 171 printf("%ld\n", det_id); 172 173 return true; 174 } 175 176 static bool runsMode(pxConfig *config) 177 { 178 PS_ASSERT_PTR_NON_NULL(config, false); 179 180 // psArray *runs = detRunSelectRowObjects(config->dbh, config->where, 0); 181 // XXX fix the hard coding of the table name 182 psArray *runs = psDBSelectRows(config->dbh, "detRun", config->where, 0); 183 if (!runs) { 184 psError(PS_ERR_UNKNOWN, false, "no detRun rows found"); 185 return false; 186 } 187 188 // print imfile list 189 psMetadata *output = psMetadataAlloc(); 190 for (long i = 0; i < psArrayLength(runs); i++) { 191 psMetadata *run = runs->data[i]; 192 psMetadata *md = psMetadataAlloc(); 193 bool status = false; 194 // we need to change "position" to "det_id" 195 // lookup values 196 psS32 det_id = psMetadataLookupS32(&status, run, "position"); 197 if (!status) { 198 psError(PS_ERR_UNKNOWN, false, 199 "failed to lookup value for position"); 200 psFree(output); 201 psFree(md); 202 psFree(runs); 203 return false; 204 } 205 psString det_type = psMetadataLookupStr(&status, run, "det_type"); 206 if (!status) { 207 psError(PS_ERR_UNKNOWN, false, 208 "failed to lookup value for det_type"); 209 psFree(output); 210 psFree(md); 211 psFree(runs); 212 return false; 213 } 214 // add values 215 if (!psMetadataAddS32(md, PS_LIST_TAIL, "det_id", PS_META_DUPLICATE_OK, 216 NULL, det_id)) { 217 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 218 psFree(output); 219 psFree(md); 220 psFree(runs); 221 return false; 222 } 223 if (!psMetadataAddStr(md, PS_LIST_TAIL, "det_type", 224 PS_META_DUPLICATE_OK, NULL, det_type)) { 225 psError(PS_ERR_UNKNOWN, false, "failed to add item det_type"); 226 psFree(output); 227 psFree(md); 228 psFree(runs); 229 return false; 230 } 231 psMetadataAddMetadata( 232 output, PS_LIST_TAIL, "detRun", PS_META_DUPLICATE_OK, NULL, md 233 ); 234 } 235 236 psString str = psMetadataConfigFormat(output); 237 psFree(output); 238 fprintf(stdout, "%s\n", str); 239 psFree(str); 240 241 psFree(runs); 165 242 166 243 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
