Changeset 6887 for trunk/stac/src/stacConfig.c
- Timestamp:
- Apr 18, 2006, 12:20:45 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacConfig.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacConfig.c
r5743 r6887 24 24 config->outnx = 0; 25 25 config->outny = 0; 26 config->saturated = 65535.0; // Saturation level27 config->bad = 0.0; // Bad level26 config->saturated = 65535.0; // Saturation level 27 config->bad = 0.0; // Bad level 28 28 config->reject = 2.5; 29 29 config->frac = 0.45; … … 39 39 // Free the vectors, if necessary 40 40 if (config->inputs) { 41 psFree(config->inputs);41 psFree(config->inputs); 42 42 } 43 43 // Free everything … … 46 46 47 47 48 stacConfig *stacParseConfig(int argc, // Number of command-line arguments49 char **argv // Command-line arguments48 stacConfig *stacParseConfig(int argc, // Number of command-line arguments 49 char **argv // Command-line arguments 50 50 ) 51 51 { 52 52 stacConfig *config = stacConfigAlloc(); // Configuration values 53 const char *programName = argv[0]; // Program name53 const char *programName = argv[0]; // Program name 54 54 55 55 /* Variables for getopt */ … … 61 61 while ((opt = getopt(argc, argv, "hvSg:r:o:s:b:k:n:f:G:p:a:")) != -1) { 62 62 switch (opt) { 63 case 'h':64 help(programName);65 exit(EXIT_SUCCESS);66 case 'v':63 case 'h': 64 help(programName); 65 exit(EXIT_SUCCESS); 66 case 'v': 67 67 config->verbose++; 68 68 break; 69 case 'g':70 if (sscanf(optarg, "%f", &config->gain) != 1) {71 help(programName);72 exit(EXIT_FAILURE);73 }74 break;75 case 'r':76 if (sscanf(optarg, "%f", &config->readnoise) != 1) {77 help(programName);78 exit(EXIT_FAILURE);79 }80 break;81 case 'o':69 case 'g': 70 if (sscanf(optarg, "%f", &config->gain) != 1) { 71 help(programName); 72 exit(EXIT_FAILURE); 73 } 74 break; 75 case 'r': 76 if (sscanf(optarg, "%f", &config->readnoise) != 1) { 77 help(programName); 78 exit(EXIT_FAILURE); 79 } 80 break; 81 case 'o': 82 82 if ((sscanf(argv[optind-1], "%d", &config->outnx) != 1) || 83 83 (sscanf(argv[optind++], "%d", &config->outny) != 1)) { … … 86 86 exit(EXIT_FAILURE); 87 87 } 88 break;89 case 's':90 if (sscanf(optarg, "%f", &config->saturated) != 1) {91 help(programName);92 exit(EXIT_FAILURE);93 }94 break;95 case 'b':96 if (sscanf(optarg, "%f", &config->bad) != 1) {97 help(programName);98 exit(EXIT_FAILURE);99 }100 break;101 case 'p':102 if (argc < optind+1) {103 help(programName);104 exit(EXIT_FAILURE);105 }106 config->starFile = argv[optind-1];107 config->starMapFile = argv[optind++];108 // Note: incrementing optind, so I can read more than one parameter.109 break;110 case 'a':111 if (sscanf(optarg, "%f", &config->aper) != 1) {112 help(programName);113 exit(EXIT_FAILURE);114 }115 break;116 case 'k':117 if (sscanf(optarg, "%f", &config->reject) != 1) {118 help(programName);119 exit(EXIT_FAILURE);120 }121 break;122 case 'n':123 if (sscanf(optarg, "%d", &config->nReject) != 1) {124 help(programName);125 exit(EXIT_FAILURE);126 }127 break;128 case 'f':129 if (sscanf(optarg, "%f", &config->frac) != 1) {130 help(programName);131 exit(EXIT_FAILURE);132 }133 break;134 case 'G':135 if (sscanf(optarg, "%f", &config->grad) != 1) {136 help(programName);137 exit(EXIT_FAILURE);138 }139 break;140 case 'S':141 config->saveShifts = true;142 break;143 default:144 help(programName);145 }88 break; 89 case 's': 90 if (sscanf(optarg, "%f", &config->saturated) != 1) { 91 help(programName); 92 exit(EXIT_FAILURE); 93 } 94 break; 95 case 'b': 96 if (sscanf(optarg, "%f", &config->bad) != 1) { 97 help(programName); 98 exit(EXIT_FAILURE); 99 } 100 break; 101 case 'p': 102 if (argc < optind+1) { 103 help(programName); 104 exit(EXIT_FAILURE); 105 } 106 config->starFile = argv[optind-1]; 107 config->starMapFile = argv[optind++]; 108 // Note: incrementing optind, so I can read more than one parameter. 109 break; 110 case 'a': 111 if (sscanf(optarg, "%f", &config->aper) != 1) { 112 help(programName); 113 exit(EXIT_FAILURE); 114 } 115 break; 116 case 'k': 117 if (sscanf(optarg, "%f", &config->reject) != 1) { 118 help(programName); 119 exit(EXIT_FAILURE); 120 } 121 break; 122 case 'n': 123 if (sscanf(optarg, "%d", &config->nReject) != 1) { 124 help(programName); 125 exit(EXIT_FAILURE); 126 } 127 break; 128 case 'f': 129 if (sscanf(optarg, "%f", &config->frac) != 1) { 130 help(programName); 131 exit(EXIT_FAILURE); 132 } 133 break; 134 case 'G': 135 if (sscanf(optarg, "%f", &config->grad) != 1) { 136 help(programName); 137 exit(EXIT_FAILURE); 138 } 139 break; 140 case 'S': 141 config->saveShifts = true; 142 break; 143 default: 144 help(programName); 145 } 146 146 } 147 147 … … 154 154 } 155 155 156 config->output = argv[0]; // Output file156 config->output = argv[0]; // Output file 157 157 // Get the input files 158 config->inputs = psArrayAlloc(argc-1); 158 config->inputs = psArrayAlloc(argc - 1); 159 config->inputs->n = argc - 1; 159 160 for (int i = 1; i < argc; i++) { 160 config->inputs->data[i-1] = psAlloc(strlen(argv[i]));161 strncpy(config->inputs->data[i-1], argv[i], strlen(argv[i]));161 config->inputs->data[i-1] = psAlloc(strlen(argv[i])); 162 strncpy(config->inputs->data[i-1], argv[i], strlen(argv[i])); 162 163 } 163 164 … … 167 168 psTrace("stac.config", 9, "%d inputs:\n",config->inputs->n); 168 169 for (int i = 0; i < config->inputs->n; i++) { 169 psTrace("stac.config", 9, "\t%s\n", config->inputs->data[i]);170 psTrace("stac.config", 9, "\t%s\n", config->inputs->data[i]); 170 171 } 171 172 psTrace("stac.config", 9, "Output file is %s\n",config->output);
Note:
See TracChangeset
for help on using the changeset viewer.
