| 156 | } |
| 157 | |
| 158 | static int parse (struct GMT_CTRL *GMT, struct X2SYS_INIT_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 159 | |
| 160 | /* This parses the options provided to grdcut and sets parameters in CTRL. |
| 161 | * Any GMT common options will override values set previously by other commands. |
| 162 | * It also replaces any file names specified as input or output with the data ID |
| 163 | * returned when registering these sources/destinations with the API. |
| 164 | */ |
| 165 | |
| 166 | unsigned int n_errors = 0, k, n_tags = 0; |
| 167 | char *c = NULL; |
| 168 | struct GMT_OPTION *opt = NULL; |
| 169 | struct GMTAPI_CTRL *API = GMT->parent; |
| 170 | /* We are just checking the options for syntax here, not parsing is actually needed */ |
| 171 | |
| 172 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 173 | k = 0; |
| 174 | switch (opt->option) { |
| 175 | /* Common parameters */ |
| 176 | |
| 177 | case '<': /* Tags */ |
| 178 | if (n_tags == 0) Ctrl->In.TAG = strdup (opt->arg); |
| 179 | n_tags++; |
| 180 | break; |
| 181 | |
| 182 | /* Processes program-specific parameters */ |
| 183 | |
| 184 | case 'C': /* Distance calculation flag */ |
| 185 | if (gmt_M_compat_check (API->GMT, 6)) { |
| 186 | GMT_Report (API, GMT_MSG_COMPAT, "The -C option is deprecated; use the GMT common option -j<mode> instead\n"); |
| 187 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 188 | if (!strchr ("cefg", (int)opt->arg[0])) { |
| 189 | GMT_Report (API, GMT_MSG_ERROR, "Option -C: Flag must be c, f, g, or e\n"); |
| 190 | n_errors++; |
| 191 | } |
| 192 | if (!n_errors) Ctrl->C.string = strdup (opt->arg); |
| 193 | } |
| 194 | else { |
| 195 | GMT_Report (API, GMT_MSG_ERROR, "Unrecognized option -C\n"); |
| 196 | n_errors++; |
| 197 | } |
| 198 | break; |
| 199 | case 'D': |
| 200 | n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active); |
| 201 | if ((c = strstr (opt->arg, "." X2SYS_FMT_EXT)) == NULL && (c = strstr (opt->arg, "." X2SYS_FMT_EXT_OLD)) == NULL) |
| 202 | Ctrl->D.file = strdup (opt->arg); /* Gave no extension so store everything */ |
| 203 | else { /* Must avoid the extension */ |
| 204 | c[0] = '\0'; /* Chop off extension */ |
| 205 | Ctrl->D.file = strdup (opt->arg); |
| 206 | c[0] = '.'; /* Restore extension */ |
| 207 | } |
| 208 | break; |
| 209 | case 'E': |
| 210 | n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active); |
| 211 | n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->E.string); |
| 212 | break; |
| 213 | case 'G': /* Geographical coordinates, set discontinuity */ |
| 214 | n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active); |
| 215 | if (opt->arg[0]) Ctrl->G.string = strdup (opt->arg); |
no test coverage detected