Changeset 27684 for trunk/ippToPsps/src/ippToPsps.c
- Timestamp:
- Apr 14, 2010, 3:53:21 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/ippToPsps.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/ippToPsps.c
r27433 r27684 18 18 #include "ippToPsps.h" 19 19 20 extern boolippToPsps_batchInit(IppToPsps *data);21 extern boolippToPsps_batchDetection(IppToPsps *data);22 extern boolippToPsps_batchStack(IppToPsps *data);23 extern boolippToPsps_batchDifference(IppToPsps *data);20 extern int ippToPsps_batchInit(IppToPsps *data); 21 extern int ippToPsps_batchDetection(IppToPsps *data); 22 extern int ippToPsps_batchStack(IppToPsps *data); 23 extern int ippToPsps_batchDifference(IppToPsps *data); 24 24 25 25 // Destructor 26 26 static void ippToPsps_Destructor(IppToPsps* this) { 27 27 28 // if unsuccessful, then delete FITS file 29 if (!this->success) { 30 31 psError(PS_ERR_UNKNOWN, false, "Failed, so deleting %s", this->fitsOutPath); 32 33 // if process failed, we need to delete that FITS file 34 if (remove(this->fitsOutPath) == -1) { 35 36 psError(PS_ERR_UNKNOWN, false, "Unable to delete %s", this->fitsOutPath); 37 } 38 } 39 // ...otherwise, close file 40 else { 41 42 int status = 0; 43 if (fits_close_file(this->fitsOut, &status)) { 44 45 psError(PS_ERR_IO, false, "Unable to close FITS file %s", this->fitsOutPath); 46 fits_report_error(stderr, status); 28 // if we created an output file... 29 if (this->fitsOut) { 30 31 // if unsuccessful, then delete FITS file 32 if (this->exitCode != PS_EXIT_SUCCESS) { 33 34 psError(PS_ERR_UNKNOWN, false, "Failed, so deleting %s", this->fitsOutPath); 35 36 // if process failed, we need to delete that FITS file 37 if (remove(this->fitsOutPath) == -1) { 38 39 psError(PS_ERR_UNKNOWN, false, "Unable to delete %s", this->fitsOutPath); 40 } 41 } 42 // ...otherwise, close file 43 else { 44 45 int status = 0; 46 if (fits_close_file(this->fitsOut, &status)) { 47 48 psError(PS_ERR_IO, false, "Unable to close FITS file %s", this->fitsOutPath); 49 fits_report_error(stderr, status); 50 } 47 51 } 48 52 } … … 77 81 78 82 psError(PS_ERR_UNKNOWN, false, "Unable to open file at %s", this->fitsInPath); 79 return NULL;83 return false; 80 84 } 81 85 … … 188 192 189 193 // Runs the requested process 190 static bool ippToPsps_run(IppToPsps *this) { 191 192 // which product? 193 switch(this->product) { 194 195 case PRODUCT_INIT: 196 this->success = ippToPsps_batchInit(this); 197 break; 198 case PRODUCT_DETECTION: 199 this->success = ippToPsps_batchDetection(this); 200 break; 201 case PRODUCT_STACK: 202 this->success = ippToPsps_batchStack(this); 203 break; 204 case PRODUCT_DIFFERENCE: 205 this->success = ippToPsps_batchDifference(this); 206 break; 207 default: 208 psError(PS_ERR_UNKNOWN, false, "Unable to run for this product type (%d)", this->product); 209 this->success = false; 210 break; 211 } 212 213 return this->success; 194 static int ippToPsps_run(IppToPsps *this) { 195 196 if(this->exitCode == PS_EXIT_SUCCESS) { 197 198 // which product? 199 switch(this->product) { 200 201 case PRODUCT_INIT: 202 this->exitCode = ippToPsps_batchInit(this); 203 break; 204 case PRODUCT_DETECTION: 205 this->exitCode = ippToPsps_batchDetection(this); 206 break; 207 case PRODUCT_STACK: 208 this->exitCode = ippToPsps_batchStack(this); 209 break; 210 case PRODUCT_DIFFERENCE: 211 this->exitCode = ippToPsps_batchDifference(this); 212 break; 213 default: 214 psError(PS_ERR_UNKNOWN, false, "Unable to run for this product type (%d)", this->product); 215 this->exitCode = false; 216 break; 217 } 218 } 219 220 return this->exitCode; 214 221 } 215 222 … … 236 243 this->dvoConfig = dvoConfigRead(argc, argv); 237 244 this->pmconfig = pmConfigRead(argc, argv, NULL); 238 this-> success = false;245 this->exitCode = PS_EXIT_SUCCESS; 239 246 this->run = ippToPsps_run; 240 247 … … 242 249 243 250 psError(PS_ERR_UNKNOWN, false, "Unable to read configuration."); 244 return NULL; 251 this->exitCode = PS_EXIT_CONFIG_ERROR; 252 return this; 245 253 } 246 254 … … 248 256 249 257 psFree(this); 250 return NULL; 251 } 252 253 if (this->product != PRODUCT_INIT && !ippToPsps_readInputFilePaths(this)) return NULL; 258 this->exitCode = PS_EXIT_CONFIG_ERROR; 259 return this; 260 } 261 262 if (this->product != PRODUCT_INIT && !ippToPsps_readInputFilePaths(this)) { 263 264 this->exitCode = PS_EXIT_DATA_ERROR; 265 return this; 266 } 254 267 255 268 if (this->product == PRODUCT_INIT) … … 272 285 fits_report_error(stderr, status); 273 286 psError(PS_ERR_IO, false, "Unable to create file at: '%s'", this->fitsOutPath); 274 return NULL; 287 this->exitCode = PS_EXIT_SYS_ERROR; 288 return this; 275 289 } 276 290 277 291 this->config = ippToPspsConfig_Constructor(this->configsDir); 278 if (this->config == NULL) return NULL; 292 if (this->config == NULL) { 293 294 this->exitCode = PS_EXIT_CONFIG_ERROR; 295 return this; 296 } 279 297 280 298 // ready results file, if necessary
Note:
See TracChangeset
for help on using the changeset viewer.
