Changeset 6851 for trunk/psphot/src/psphotArguments.c
- Timestamp:
- Apr 12, 2006, 8:59:15 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotArguments.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotArguments.c
r6715 r6851 10 10 11 11 int N; 12 bool status; 12 13 13 14 if (*argc == 1) usage (); … … 118 119 } 119 120 120 // we load all input files onto a psArray, to be parsed later 121 psArray *input = psArrayAlloc (16); 122 input->n = 0; 123 124 // load the list of filenames the supplied file (may be a glob: "file*.fits") 125 if ((N = psArgumentGet (*argc, argv, "-file"))) { 126 glob_t globList; 127 psArgumentRemove (N, argc, argv); 128 globList.gl_offs = 0; 129 glob (argv[N], 0, NULL, &globList); 130 for (int i = 0; i < globList.gl_pathc; i++) { 131 char *filename = psStringCopy (globList.gl_pathv[i]); 132 psArrayAdd (input, 16, filename); 133 psFree (filename); 134 } 135 psArgumentRemove (N, argc, argv); 136 } 137 138 // load the list from the supplied text file 139 if ((N = psArgumentGet (*argc, argv, "-list"))) { 140 int nItems; 141 char line[1024]; // XXX limits the list lines to 1024 chars 142 char word[1024]; 143 char *filename; 144 145 psArgumentRemove (N, argc, argv); 146 FILE *f = fopen (argv[N], "r"); 147 if (f == NULL) { 148 psAbort ("psphot", "unable to open specified list file"); 149 } 150 while (fgets (line, 1024, f) != NULL) { 151 nItems = sscanf (line, "%s", word); 152 switch (nItems) { 153 case 0: 154 break; 155 case 1: 156 filename = psStringCopy (word); 157 psArrayAdd (input, 16, filename); 158 psFree (filename); 159 break; 160 default: 161 // rigid format, no comments allowed? 162 psAbort ("psphot", "error parsing input list file"); 163 break; 164 } 165 } 166 psArgumentRemove (N, argc, argv); 167 } 168 if (input->n < 1) usage (); 169 170 // input list gets places as an array on the config->arguements list 171 psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "INPUT", PS_DATA_ARRAY, "", input); 172 psFree (input); 121 // the input file is a required argument; if not found, we will exit 122 status = pmConfigFileSetsMD (config->arguments, argc, argv, "INPUT", "-file", "-list"); 123 if (!status) { usage ();} 173 124 174 125 if (*argc != 2) usage ();
Note:
See TracChangeset
for help on using the changeset viewer.
