| 189 | } |
| 190 | |
| 191 | static int parse (struct GMT_CTRL *GMT, struct GRDINFO_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 192 | |
| 193 | /* This parses the options provided to grdcut and sets parameters in CTRL. |
| 194 | * Any GMT common options will override values set previously by other commands. |
| 195 | * It also replaces any file names specified as input or output with the data ID |
| 196 | * returned when registering these sources/destinations with the API. |
| 197 | */ |
| 198 | |
| 199 | bool no_file_OK, num_report; |
| 200 | unsigned int n_errors = 0, nc = 0, ng = 0; |
| 201 | char text[GMT_LEN32] = {""}, *c = NULL; |
| 202 | static char *M[2] = {"minimum", "maximum"}, *V[3] = {"negative", "all", "positive"}, *T[2] = {"column", "row"}; |
| 203 | struct GMT_OPTION *opt = NULL; |
| 204 | struct GMTAPI_CTRL *API = GMT->parent; |
| 205 | |
| 206 | /* First precheck if we are dealing with cubes or grids - no mixing is allowed */ |
| 207 | |
| 208 | for (opt = options; opt; opt = opt->next) { /* Loop over arguments, skip options */ |
| 209 | |
| 210 | if (opt->option != '<') continue; /* We are only processing filenames here */ |
| 211 | |
| 212 | if (gmt_M_memfile_is_grid (opt->arg)) /* Can just check file name */ |
| 213 | ng++; |
| 214 | else if (gmt_M_memfile_is_cube (opt->arg)) /* Can just check file name */ |
| 215 | nc++; |
| 216 | else if (gmt_nc_is_cube (API, opt->arg)) /* Determine if this file is a netCDF cube or not */ |
| 217 | nc++; |
| 218 | else /* Thus a grid */ |
| 219 | ng++; |
| 220 | } |
| 221 | |
| 222 | if (nc && ng) { |
| 223 | GMT_Report (API, GMT_MSG_ERROR, "Cannot give a mixed list of data cubes and data grids\n"); |
| 224 | n_errors++; |
| 225 | goto time_to_return; |
| 226 | } |
| 227 | Ctrl->is_cube = (nc > 0); |
| 228 | |
| 229 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 230 | |
| 231 | switch (opt->option) { |
| 232 | /* Common parameters */ |
| 233 | |
| 234 | case '<': /* Input files */ |
| 235 | if (GMT_Get_FilePath (API, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) |
| 236 | n_errors++; |
| 237 | else |
| 238 | Ctrl->n_files++; |
| 239 | break; |
| 240 | |
| 241 | /* Processes program-specific parameters */ |
| 242 | |
| 243 | case 'C': /* Column format */ |
| 244 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 245 | if (opt->arg[0] == 'n') |
| 246 | Ctrl->C.mode = GRDINFO_NUMERICAL; |
| 247 | else if (opt->arg[0] == 't') |
| 248 | Ctrl->C.mode = GRDINFO_TRAILING; |
no test coverage detected