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

Function parse

src/filter1d.c:267–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267static int parse (struct GMT_CTRL *GMT, struct FILTER1D_CTRL *Ctrl, struct GMT_OPTION *options) {
268 /* This parses the options provided to filter1d and sets parameters in CTRL.
269 * Any GMT common options will override values set previously by other commands.
270 * It also replaces any file names specified as input or output with the data ID
271 * returned when registering these sources/destinations with the API.
272 */
273
274 unsigned int n_errors = 0;
275 int sval = 0;
276 char *c = NULL, p, txt[GMT_LEN64] = {""}, *t_arg = NULL;
277 struct GMT_OPTION *opt = NULL;
278 struct GMTAPI_CTRL *API = GMT->parent;
279
280 for (opt = options; opt; opt = opt->next) {
281 switch (opt->option) {
282
283 case '<': /* Skip input files */
284 if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
285 break;
286
287 /* Processes program-specific parameters */
288
289 case 'D': /* Get fixed increment */
290 n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
291 n_errors += gmt_get_required_double (GMT, opt->arg, opt->option, 0, &Ctrl->D.inc);
292 break;
293 case 'E': /* Include ends of series */
294 n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active);
295 n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
296 break;
297 case 'F': /* Filter selection */
298 n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active);
299 if (opt->arg[0] && strchr ("BbCcGgMmPpLlUuFf", opt->arg[0])) { /* OK filter code */
300 n_errors += gmt_get_required_char (GMT, opt->arg, opt->option, 0, &Ctrl->F.filter);
301 if ((c = strstr (opt->arg, "+h"))) { /* Want high-pass filter */
302 Ctrl->F.highpass = true;
303 c[0] = '\0'; /* Chop off +h */
304 }
305 if (gmt_access (GMT, &opt->arg[1], R_OK)) /* Not a file we can read */
306 Ctrl->F.width = atof (&opt->arg[1]);
307 else if (Ctrl->F.filter != 'f') { /* Got variable filter width series */
308 Ctrl->F.variable = true;
309 Ctrl->F.file = strdup (&opt->arg[1]);
310 }
311 switch (Ctrl->F.filter) { /* Get some further info from some filters */
312 case 'P':
313 case 'p':
314 p = opt->arg[strlen(opt->arg-1)]; /* Last character */
315 if (strstr (opt->arg, "+l")) Ctrl->F.mode = -1;
316 else if (strstr (opt->arg, "+u")) Ctrl->F.mode = +1;
317 else if (p == '-') Ctrl->F.mode = -1; /* Old style */
318 else if (p == '+') Ctrl->F.mode = +1; /* Old style */
319 break;
320 case 'F':
321 case 'f':
322 Ctrl->F.width = DBL_MAX; /* To avoid range test errors before reading coefficients */
323 if (opt->arg[1] && !gmt_access (GMT, &opt->arg[1], R_OK))
324 Ctrl->F.file = strdup (&opt->arg[1]);

Callers 1

GMT_filter1dFunction · 0.70

Calls 12

GMT_Get_FilePathFunction · 0.85
gmt_get_required_doubleFunction · 0.85
gmt_get_no_argumentFunction · 0.85
gmt_get_required_charFunction · 0.85
gmt_accessFunction · 0.85
strdupFunction · 0.85
GMT_ReportFunction · 0.85
gmt_parse_d_optionFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_get_required_intFunction · 0.85
gmt_parse_arrayFunction · 0.85

Tested by

no test coverage detected