| 168 | } |
| 169 | |
| 170 | static int parse (struct GMT_CTRL *GMT, struct GRDINTERPOLATE_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 171 | /* This parses the options provided to grdcut and sets parameters in CTRL. |
| 172 | * Any GMT common options will override values set previously by other commands. |
| 173 | * It also replaces any file names specified as input or output with the data ID |
| 174 | * returned when registering these sources/destinations with the API. |
| 175 | */ |
| 176 | |
| 177 | unsigned int n_errors = 0, n_files = 0, n_alloc = 0, k = 0; |
| 178 | char *c = NULL; |
| 179 | struct GMT_OPTION *opt = NULL; |
| 180 | struct GMTAPI_CTRL *API = GMT->parent; |
| 181 | |
| 182 | for (opt = options; opt; opt = opt->next) { |
| 183 | switch (opt->option) { |
| 184 | |
| 185 | case '<': /* Input files */ |
| 186 | if (n_alloc <= Ctrl->In.n_files) { |
| 187 | n_alloc += GMT_SMALL_CHUNK; |
| 188 | Ctrl->In.file = gmt_M_memory (GMT, Ctrl->In.file, n_alloc, char *); |
| 189 | } |
| 190 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->In.file[Ctrl->In.n_files])); |
| 191 | Ctrl->In.n_files++; |
| 192 | break; |
| 193 | |
| 194 | /* Processes program-specific parameters */ |
| 195 | |
| 196 | case 'D': /* Give grid information */ |
| 197 | n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active); |
| 198 | n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->D.information); |
| 199 | break; |
| 200 | case 'E': /* Create or read an equidistant profile for slicing */ |
| 201 | n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active); |
| 202 | n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->E.lines); |
| 203 | break; |
| 204 | case 'F': /* Set the spline type */ |
| 205 | n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active); |
| 206 | n_errors += gmt_parse_interpolant (API, opt->arg, &(Ctrl->F.mode), &(Ctrl->F.type), &(Ctrl->F.fit)); |
| 207 | strncpy (Ctrl->F.spline, opt->arg, GMT_LEN8-1); /* Keep track of what was given since it may need to be passed verbatim to other modules */ |
| 208 | break; |
| 209 | case 'G': /* Output file or name template */ |
| 210 | n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active); |
| 211 | if (n_files++ > 0) { n_errors++; continue; } |
| 212 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_GRID, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->G.file)); |
| 213 | break; |
| 214 | case 'T': /* Set level sampling spacing */ |
| 215 | n_errors += gmt_M_repeated_module_option (API, Ctrl->T.active); |
| 216 | n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->T.string); |
| 217 | n_errors += gmt_parse_array (GMT, 'T', opt->arg, &(Ctrl->T.T), GMT_ARRAY_TIME | GMT_ARRAY_SCALAR | GMT_ARRAY_RANGE | GMT_ARRAY_UNIQUE, GMT_Z); |
| 218 | break; |
| 219 | |
| 220 | case 'S': /* Sample vertically across the grid stack at one or more points */ |
| 221 | n_errors += gmt_M_repeated_module_option (API, Ctrl->S.active); |
| 222 | if ((c = strstr (opt->arg, "+h"))) { /* Got a fixed header string for output segment headers */ |
| 223 | if (c[2]) |
| 224 | Ctrl->S.header = strdup (&c[2]); |
| 225 | else { |
| 226 | GMT_Report (API, GMT_MSG_ERROR, "Option -S: Modifier +h not given a header string\n"); |
| 227 | n_errors++; |
no test coverage detected