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

Function gmt_parse_common_options

src/gmt_init.c:18437–18866  ·  view source on GitHub ↗

! gmt_parse_common_options interprets the command line for the common, unique options * -B, -J, -K, -O, -P, -R, -U, -V, -X, -Y, -a, -b, -c, -d, -e, -f, -g, -h, -i, -j, -l, -n, -o, -p, -q, -r, -s, -t, -w, -:, -- and -^. * The list passes all of these that we should consider. * The API will also consider -I for grid increments. */

Source from the content-addressed store, hash-verified

18435 * The API will also consider -I for grid increments.
18436 */
18437int gmt_parse_common_options (struct GMT_CTRL *GMT, char *list, char option, char *item) {
18438
18439 int error = 0, n_repeat = 0, q = 0; /* The n_repeat and n_repeat += gmt_M_more_than_once are there just to avoid compiler warnings... */
18440
18441 if (!list || !strchr (list, option)) return (0); /* Not a common option we accept */
18442
18443 if (gmt_M_compat_check (GMT, 4)) {
18444 /* Translate some uppercase old global GMT4 options to GMT6 and beyond equivalent options */
18445 switch (option) {
18446 case 'E': gmt_M_compat_opt ('p'); break;
18447 case 'F': gmt_M_compat_opt ('r'); break;
18448 case 'H': gmt_M_compat_opt ('h'); break;
18449 }
18450 }
18451
18452 switch (option) { /* Handle parsing of this option, if allowed here */
18453 case 'B':
18454 switch (item[0]) { /* Check for -B[p] and -Bs */
18455 case 'p': GMT->common.B.active[GMT_PRIMARY] = true; q = 1; break;
18456 case 's': GMT->common.B.active[GMT_SECONDARY] = true; q = 1; break;
18457 default: GMT->common.B.active[GMT_PRIMARY] = true; break;
18458 }
18459 if (!error) {
18460 if (GMT->current.setting.run_mode == GMT_MODERN && (!GMT->current.map.frame.set[GMT_X] || !GMT->current.map.frame.set[GMT_Y] || (GMT->common.J.zactive && !GMT->current.map.frame.set[GMT_Z]))) {
18461 char code[2], args[GMT_LEN256] = {""}, *c = strchr (item, '+'); /* Start of modifiers, if any */
18462 if (item[q] && strstr (item, "+f")) GMT->current.plot.calclock.geo.wesn = 1; /* Got +f, so enable W|E|S|N suffixes */
18463 if (c && strchr (GMT_AXIS_MODIFIERS, c[1])) /* We got the ones suitable for axes that we can chop off */
18464 c[0] = '\0'; /* Temporarily chop off these modifiers only */
18465 code[0] = item[q]; code[1] = (item[q]) ? item[q+1] : '\0';
18466 if (c) c[0] = '+'; /* Restore modifiers */
18467 if (code[0] == '\0') { /* Default is -Baf if nothing given */
18468 if (q) args[0] = item[0]; strcat (args, "af"); if (c) strncat (args, c, GMT_LEN256-1);
18469 }
18470 else if (code[0] == 'x' && code[1] == '\0') { /* If indicating x we do -Bxaf */
18471 if (q) args[0] = item[0]; strcat (args, "xaf"); if (c) strncat (args, c, GMT_LEN256-1);
18472 }
18473 else if (code[0] == 'y' && code[1] == '\0') { /* If indicating y we do -Byaf */
18474 if (q) args[0] = item[0]; strcat (args, "yaf"); if (c) strncat (args, c, GMT_LEN256-1);
18475 }
18476 else if (code[0] == 'z' && code[1] == '\0') { /* If indicating z we do -Bzaf */
18477 if (q) args[0] = item[0]; strcat (args, "zaf"); if (c) strncat (args, c, GMT_LEN256-1);
18478 }
18479 else /* Keep what we got */
18480 strncpy (args, item, GMT_LEN256-1);
18481 error = gmtlib_parse_B_option (GMT, args);
18482 }
18483 else
18484 error = gmtlib_parse_B_option (GMT, item);
18485 }
18486 break;
18487
18488 case 'I': /* -I is an API common option only and not a true GMT common option like -R -J etc. */
18489 if (GMT->hidden.func_level > GMT_CONTROLLER) return (0); /* Skip if we are inside a GMT module, else process it. */
18490 error = gmt_parse_inc_option (GMT, 'I', item);
18491 GMT->common.R.active[ISET] = true;
18492 break;
18493
18494 case 'J':

Callers 15

parseFunction · 0.85
parseFunction · 0.85
GMT_gmtspatialFunction · 0.85
parseFunction · 0.85
gmt_get_dist_unitsFunction · 0.85
GMT_gmtlogoFunction · 0.85
parseFunction · 0.85
GMT_grdgdalFunction · 0.85
GMT_sphtriangulateFunction · 0.85
gmt_proj_setupFunction · 0.85
gmt_init_distazFunction · 0.85
GMT_psmaskFunction · 0.85

Calls 15

gmtlib_parse_B_optionFunction · 0.85
gmt_parse_inc_optionFunction · 0.85
gmtinit_parse_J_optionFunction · 0.85
GMT_ReportFunction · 0.85
gmtinit_parse_proj4Function · 0.85
gmt_parse_R_optionFunction · 0.85
gmtinit_parse_U_optionFunction · 0.85
gmtinit_parse_V_optionFunction · 0.85
gmtinit_parse_X_optionFunction · 0.85
gmtinit_parse_Y_optionFunction · 0.85

Tested by

no test coverage detected