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

Function parse

src/surface_old.c:1583–1734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1581}
1582
1583static int parse (struct GMT_CTRL *GMT, struct SURFACE_CTRL *Ctrl, struct GMT_OPTION *options) {
1584 /* This parses the options provided to surface and sets parameters in CTRL.
1585 * Any GMT common options will override values set previously by other commands.
1586 * It also replaces any file names specified as input or output with the data ID
1587 * returned when registering these sources/destinations with the API.
1588 */
1589
1590 unsigned int n_errors = 0, k;
1591 char modifier;
1592 struct GMT_OPTION *opt = NULL;
1593 struct GMTAPI_CTRL *API = GMT->parent;
1594
1595 for (opt = options; opt; opt = opt->next) {
1596 switch (opt->option) {
1597
1598 case '<': /* Skip input files */
1599 if (GMT_Get_FilePath (GMT->parent, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
1600 break;
1601
1602 /* Processes program-specific parameters */
1603
1604 case 'A':
1605 Ctrl->A.active = true;
1606 if (opt->arg[0] == 'm')
1607 Ctrl->A.mode = 1;
1608 else
1609 Ctrl->A.value = atof (opt->arg);
1610 break;
1611 case 'C':
1612 Ctrl->C.active = true;
1613 Ctrl->C.value = atof (opt->arg);
1614 if (strchr (opt->arg, '%')) { /* Gave convergence in percent */
1615 Ctrl->C.mode = 1;
1616 Ctrl->C.value *= 0.01;
1617 }
1618 break;
1619 case 'D':
1620 if ((Ctrl->D.active = gmt_check_filearg (GMT, 'D', opt->arg, GMT_IN, GMT_IS_DATASET)) != 0)
1621 Ctrl->D.file = strdup (opt->arg);
1622 else
1623 n_errors++;
1624 break;
1625 case 'G':
1626 if ((Ctrl->G.active = gmt_check_filearg (GMT, 'G', opt->arg, GMT_OUT, GMT_IS_GRID)) != 0)
1627 Ctrl->G.file = strdup (opt->arg);
1628 else
1629 n_errors++;
1630 break;
1631 case 'I':
1632 n_errors += gmt_parse_inc_option (GMT, 'I', opt->arg);
1633 break;
1634 case 'L': /* Set limits */
1635 Ctrl->L.active = true;
1636 switch (opt->arg[0]) {
1637 case 'l': /* Lower limit */
1638 n_errors += gmt_M_check_condition (GMT, opt->arg[1] == 0, "Option -Ll: No argument given\n");
1639 Ctrl->L.low = strdup (&opt->arg[1]);
1640 if (!gmt_access (GMT, Ctrl->L.low, F_OK)) /* file exists */

Callers 1

GMT_surface_oldFunction · 0.70

Calls 8

GMT_Get_FilePathFunction · 0.85
gmt_check_fileargFunction · 0.85
strdupFunction · 0.85
gmt_parse_inc_optionFunction · 0.85
gmt_accessFunction · 0.85
GMT_ReportFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_check_binary_ioFunction · 0.85

Tested by

no test coverage detected