| 154 | } |
| 155 | |
| 156 | static int parse (struct GMT_CTRL *GMT, struct GRDEDIT_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 157 | |
| 158 | /* This parses the options provided to grdedit and sets parameters in Ctrl. |
| 159 | * Note Ctrl has already been initialized and non-zero default values set. |
| 160 | * Any GMT common options will override values set previously by other commands. |
| 161 | * It also replaces any file names specified as input or output with the data ID |
| 162 | * returned when registering these sources/destinations with the API. |
| 163 | */ |
| 164 | |
| 165 | unsigned int n_errors = 0; |
| 166 | struct GMT_OPTION *opt = NULL; |
| 167 | struct GMTAPI_CTRL *API = GMT->parent; |
| 168 | |
| 169 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 170 | switch (opt->option) { |
| 171 | /* Common parameters */ |
| 172 | |
| 173 | case '<': /* Input file (only one is accepted) */ |
| 174 | n_errors += gmt_M_repeated_module_option (API, Ctrl->In.active); |
| 175 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->In.file)); |
| 176 | break; |
| 177 | |
| 178 | /* Processes program-specific parameters */ |
| 179 | |
| 180 | case 'A': /* Adjust increments */ |
| 181 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 182 | n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0); |
| 183 | break; |
| 184 | case 'C': /* Control history output -Cb|c|n|p */ |
| 185 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 186 | switch (opt->arg[0]) { |
| 187 | case 'b': Ctrl->C.mode = GMT_GRDHISTORY_BOTH; break; |
| 188 | case 'c': Ctrl->C.mode = GMT_GRDHISTORY_NEW; break; |
| 189 | case 'p': Ctrl->C.mode = GMT_GRDHISTORY_OLD; break; |
| 190 | case 'n': case '\0': Ctrl->C.mode = GMT_GRDHISTORY_NONE; break; /* Default */ |
| 191 | default: |
| 192 | GMT_Report (API, GMT_MSG_ERROR, "Option -C: Unrecognized directive %s\n", opt->arg); |
| 193 | n_errors++; |
| 194 | break; |
| 195 | } |
| 196 | break; |
| 197 | case 'D': /* Give grid information */ |
| 198 | n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active); |
| 199 | n_errors += gmt_get_required_string (GMT, opt->arg, opt->option, 0, &Ctrl->D.information); |
| 200 | break; |
| 201 | case 'E': /* Transpose or rotate grid */ |
| 202 | n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active); |
| 203 | if (opt->arg[0] == '\0') /* Default transpose */ |
| 204 | Ctrl->E.mode = 't'; |
| 205 | else if (strchr ("aehlrtv", opt->arg[0])) |
| 206 | Ctrl->E.mode = opt->arg[0]; |
| 207 | else { |
| 208 | n_errors++; |
| 209 | GMT_Report (API, GMT_MSG_ERROR, "Option -E: Unrecognized modifier %c\n", opt->arg[0]); |
| 210 | } |
| 211 | break; |
| 212 | case 'G': /* Separate output grid file */ |
| 213 | n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active); |
no test coverage detected