Changeset 8999
- Timestamp:
- Sep 26, 2006, 3:41:46 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ppNorm/src/ppNormCalc.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppNorm/src/ppNormCalc.c
r8785 r8999 7 7 #include <psmodules.h> 8 8 9 void helpAndDie(const char *programName) 10 { 11 printf("Calculate normalisation for flat fields.\n\n" 12 "Usage: %s [IN.mdc [OUT.mdc]]\n\n" 13 "where IN.mdc is a metadata config file containing the background\n" 14 " value for each component of each exposure;\n" 15 "and OUT.mdc is a metadata config file containing the output\n" 16 " normalisation factors.\n" 17 "\n", programName); 18 exit(EXIT_FAILURE); 19 } 20 9 21 10 22 int main(int argc, char *argv[]) … … 14 26 psFree(config); 15 27 16 if (argc != 2) { 17 printf("Calculate normalisation for flat fields.\n\n" 18 "Usage: %s IN.mdc\n\n" 19 "where IN.mdc is a metadata config file containing the background\n" 20 "value for each component of each exposure.\n\n", argv[0]); 21 exit(EXIT_FAILURE); 28 if (argc > 3 || 29 psArgumentGet(argc, argv, "-h") || 30 psArgumentGet(argc, argv, "-help") || 31 psArgumentGet(argc, argv, "--help") || 32 psArgumentGet(argc, argv, "-?")) { 33 helpAndDie(argv[0]); 34 } 35 36 FILE *inFile = stdin; // Input file stream 37 FILE *outFile = stdout; // Output file stream 38 39 if (argc >= 2) { 40 inFile = fopen(argv[1], "r"); 41 if (!inFile) { 42 psError(PS_ERR_IO, true, "Unable to open input file: %s\n\n", argv[1]); 43 helpAndDie(argv[0]); 44 } 45 } 46 if (argc == 3) { 47 outFile = fopen(argv[2], "w"); 48 if (!outFile) { 49 psError(PS_ERR_IO, true, "Unable to open output file: %s\n\n", argv[2]); 50 helpAndDie(argv[0]); 51 } 52 } 53 54 psString inputMDC = psSlurpFile(inFile); // Input metadata config stuff 55 if (argc >= 2) { 56 fclose(inFile); 22 57 } 23 58 24 59 psU32 badLines = 0; // Number of bad lines 25 psMetadata *exposures = psMetadataConfig Read(NULL, &badLines, argv[1], false); // Exposure statistics60 psMetadata *exposures = psMetadataConfigParse(NULL, &badLines, inputMDC, false); // Exposure statistics 26 61 if (badLines > 0) { 27 ps LogMsg("ppNormCalc", PS_LOG_WARN, "%d bad lines found when reading %s\n", badLines, argv[1]);62 psWarning("%d bad lines found when reading input\n", badLines); 28 63 } 29 64 … … 97 132 psFree(compsIter); 98 133 psString outputString = psMetadataConfigFormat(outputMD); 99 printf("%s", outputString);134 fprintf(outFile, "%s", outputString); 100 135 psFree(outputString); 101 136 psFree(outputMD); 137 if (argc == 3) { 138 fclose(outFile); 139 } 102 140 103 141 // Clean up
Note:
See TracChangeset
for help on using the changeset viewer.
