- Timestamp:
- Jul 21, 2008, 12:12:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080719/ippTools/src/dettool_normalizedimfile.c
r18641 r18643 228 228 return true; 229 229 } 230 231 bool pendingcleanup_normalizedimfileMode(pxConfig *config) 232 { 233 PS_ASSERT_PTR_NON_NULL(config, NULL); 234 235 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false); 236 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 237 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 238 239 psMetadata *where = psMetadataAlloc(); 240 if (chip_id) { 241 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 242 } 243 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 244 245 psString query = pxDataGet("dettool_pendingcleanup_normalizedimfile.sql"); 246 if (!query) { 247 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 248 return false; 249 } 250 251 if (where && psListLength(where->list)) { 252 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 253 psStringAppend(&query, " AND %s", whereClause); 254 psFree(whereClause); 255 } 256 psFree(where); 257 258 // treat limit == 0 as "no limit" 259 if (limit) { 260 psString limitString = psDBGenerateLimitSQL(limit); 261 psStringAppend(&query, " %s", limitString); 262 psFree(limitString); 263 } 264 265 if (!p_psDBRunQuery(config->dbh, query)) { 266 psError(PS_ERR_UNKNOWN, false, "database error"); 267 psFree(query); 268 return false; 269 } 270 psFree(query); 271 272 psArray *output = p_psDBFetchResult(config->dbh); 273 if (!output) { 274 psError(PS_ERR_UNKNOWN, false, "database error"); 275 return false; 276 } 277 if (!psArrayLength(output)) { 278 psTrace("dettool", PS_LOG_INFO, "no rows found"); 279 psFree(output); 280 return true; 281 } 282 283 // negative simple so the default is true 284 if (!ippdbPrintMetadatas(stdout, output, "detPendingCleanup_normalizedimfile", !simple)) { 285 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 286 psFree(output); 287 return false; 288 } 289 290 psFree(output); 291 292 return true; 293 } 294 295 296 bool donecleanup_normalizedimfileMode(pxConfig *config) 297 { 298 PS_ASSERT_PTR_NON_NULL(config, NULL); 299 300 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 301 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 302 303 psMetadata *where = psMetadataAlloc(); 304 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 305 306 psString query = pxDataGet("dettool_donecleanup_normalizedimfile.sql"); 307 if (!query) { 308 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 309 return false; 310 } 311 312 if (where && psListLength(where->list)) { 313 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 314 psStringAppend(&query, " AND %s", whereClause); 315 psFree(whereClause); 316 } 317 psFree(where); 318 319 // treat limit == 0 as "no limit" 320 if (limit) { 321 psString limitString = psDBGenerateLimitSQL(limit); 322 psStringAppend(&query, " %s", limitString); 323 psFree(limitString); 324 } 325 326 if (!p_psDBRunQuery(config->dbh, query)) { 327 psError(PS_ERR_UNKNOWN, false, "database error"); 328 psFree(query); 329 return false; 330 } 331 psFree(query); 332 333 psArray *output = p_psDBFetchResult(config->dbh); 334 if (!output) { 335 psError(PS_ERR_UNKNOWN, false, "database error"); 336 return false; 337 } 338 if (!psArrayLength(output)) { 339 psTrace("dettool", PS_LOG_INFO, "no rows found"); 340 psFree(output); 341 return true; 342 } 343 344 // negative simple so the default is true 345 if (!ippdbPrintMetadatas(stdout, output, "detDoneCleanup_normalizedimfile", !simple)) { 346 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 347 psFree(output); 348 return false; 349 } 350 351 psFree(output); 352 353 return true; 354 } 355
Note:
See TracChangeset
for help on using the changeset viewer.
