| 130 | } |
| 131 | |
| 132 | static int parse (struct GMT_CTRL *GMT, struct PSIMAGE_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 133 | /* This parses the options provided to psimage and sets parameters in Ctrl. |
| 134 | * Note Ctrl has already been initialized and non-zero default values set. |
| 135 | * Any GMT common options will override values set previously by other commands. |
| 136 | * It also replaces any file names specified as input or output with the data ID |
| 137 | * returned when registering these sources/destinations with the API. |
| 138 | */ |
| 139 | |
| 140 | unsigned int n_errors = 0, ind = PSIMAGE_FGD, k = 0; |
| 141 | int n; |
| 142 | char cstring[GMT_LEN256] = {""}, fstring[GMT_LEN256] = {""}, *p = NULL; |
| 143 | char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[4] = {""}; |
| 144 | struct GMT_OPTION *opt = NULL; |
| 145 | struct GMTAPI_CTRL *API = GMT->parent; |
| 146 | |
| 147 | /* Because of backwards compatibility with deprecated -C optino and upgraded -F option we need to |
| 148 | * per-scane for those options and capture their arguments so that later we can handle the backwards |
| 149 | * checking without worry about option order. */ |
| 150 | |
| 151 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 152 | if (opt->option == 'C') { /* Deprecated */ |
| 153 | GMT_Report (API, GMT_MSG_COMPAT, "-C option is deprecated, use -Dx instead.\n"); |
| 154 | n = sscanf (opt->arg, "%[^/]/%[^/]/%2s", txt_a, txt_b, txt_c); |
| 155 | sprintf (cstring, "x%s/%s", txt_a, txt_b); /* Build +x modifier* for -D */ |
| 156 | if (n == 3) { /* Append modifier +j with given argument */ |
| 157 | strcat (cstring, "+j"); |
| 158 | strcat (cstring, txt_c); |
| 159 | } |
| 160 | } |
| 161 | else if (opt->option == 'F') { /* Check for deprecated version of -F<pen> */ |
| 162 | if (gmt_M_compat_check (GMT, 5) && opt->arg[0] != '+') { /* Warn but process old -F<pen> */ |
| 163 | GMT_Report (API, GMT_MSG_COMPAT, "The -F<pen> option is deprecated but was accepted. Use -F modifier +p<pen> instead\n"); |
| 164 | sprintf (fstring, "+c0+p%s", opt->arg); /* Reformat using new syntax */ |
| 165 | } |
| 166 | else /* Expected syntax given (we hope) */ |
| 167 | strncpy (fstring, opt->arg, GMT_LEN256-1); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 172 | |
| 173 | switch (opt->option) { |
| 174 | |
| 175 | case '<': /* Input files */ |
| 176 | n_errors += gmt_M_repeated_module_option (API, Ctrl->In.active); |
| 177 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_IMAGE, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->In.file)); |
| 178 | break; |
| 179 | |
| 180 | /* Processes program-specific parameters */ |
| 181 | |
| 182 | case 'D': |
| 183 | n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active); |
| 184 | p = (cstring[0]) ? cstring : opt->arg; /* If -C was used then cstring was set above */ |
| 185 | if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, p, 'D')) == NULL) { /* Failed basic parsing */ |
| 186 | GMT_Report (API, GMT_MSG_ERROR, "Option -D: Basic parsing of reference point in %s failed\n", opt->arg); |
| 187 | n_errors++; |
| 188 | } |
| 189 | else { /* args are now [+j<justify>][+n<n_columns>[/<n_rows>]][+o<dx>[/<dy>]][+r<dpi>[c]][+[-]<width>] */ |
no test coverage detected