MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / parse

Function parse

src/gmtinfo.c:186–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186static int parse (struct GMT_CTRL *GMT, struct GMTINFO_CTRL *Ctrl, struct GMT_OPTION *options) {
187 /* This parses the options provided to gmtinfo and sets parameters in CTRL.
188 * Any GMT common options will override values set previously by other commands.
189 * It also replaces any file names specified as input or output with the data ID
190 * returned when registering these sources/destinations with the API.
191 */
192
193 int j, ival;
194 unsigned int n_errors = 0, k;
195 bool special = false;
196 char *c = NULL;
197 struct GMT_OPTION *opt = NULL;
198 struct GMTAPI_CTRL *API = GMT->parent;
199
200 for (opt = options; opt; opt = opt->next) {
201 switch (opt->option) {
202
203 case '<': /* Input files */
204 if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
205 Ctrl->n_files++;
206 break;
207
208 /* Processes program-specific parameters */
209
210 case 'A': /* Reporting unit */
211 n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
212 switch (opt->arg[0]) {
213 case 'a':
214 Ctrl->A.mode = REPORT_PER_DATASET;
215 break;
216 case 't': case 'f': /* Keep f (file) for backwards compatibility, but "table" is used in all similar situations */
217 Ctrl->A.mode = REPORT_PER_TABLE;
218 break;
219 case 's':
220 Ctrl->A.mode = REPORT_PER_SEGMENT;
221 break;
222 default:
223 n_errors++;
224 GMT_Report (API, GMT_MSG_ERROR, "Option -A: Flags are a|t|s.\n");
225 break;
226 }
227 break;
228 case 'C': /* Column output */
229 n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active);
230 n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
231 break;
232 case '0': /* Hidden option to get 2 more columns back with column types */
233 Ctrl->C.extra = 2; /* Need to report back x and y data types */
234 n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
235 break;
236 case 'D': /* Region adjustment Granularity */
237 n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
238 if (opt->arg[0]) {
239 if ((Ctrl->D.ncol = gmt_getincn (GMT, opt->arg, Ctrl->D.inc, GMT_MAX_COLUMNS)) < 0) n_errors++;
240 Ctrl->D.mode = 1;
241 }
242 break;
243 case 'E': /* Extrema reporting */

Callers 1

GMT_gmtinfoFunction · 0.70

Calls 8

GMT_Get_FilePathFunction · 0.85
GMT_ReportFunction · 0.85
gmt_get_no_argumentFunction · 0.85
gmt_getincnFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_check_binary_ioFunction · 0.85

Tested by

no test coverage detected