common to optfn_catname(), optfn_dogname(), optfn_horsename() */
| 845 | |
| 846 | /* common to optfn_catname(), optfn_dogname(), optfn_horsename() */ |
| 847 | staticfn int |
| 848 | petname_optfn( |
| 849 | int optidx, int req, |
| 850 | boolean negated, |
| 851 | char *opts, char *op) |
| 852 | { |
| 853 | char failsafe[PL_PSIZ + 1]; |
| 854 | char *petname = (optidx == opt_catname) ? gc.catname |
| 855 | : (optidx == opt_dogname) ? gd.dogname |
| 856 | : (optidx == opt_horsename) ? gh.horsename |
| 857 | : failsafe; |
| 858 | |
| 859 | if (req == do_init) { |
| 860 | ; |
| 861 | } else if (req == do_set) { |
| 862 | if (op == empty_optstr && !negated) |
| 863 | return optn_err; |
| 864 | if (negated || !strcmp(op, "none") || !strcmp(op, none)) |
| 865 | op = empty_optstr; |
| 866 | nmcpy(petname, op, PL_PSIZ); |
| 867 | sanitize_name(petname); |
| 868 | } else if (req == get_val || req == get_cnf_val) { |
| 869 | failsafe[0] = '\0'; |
| 870 | Sprintf(opts, "%s", *petname ? petname |
| 871 | : (req == get_cnf_val) ? "none" : none); |
| 872 | } |
| 873 | return optn_ok; |
| 874 | } |
| 875 | |
| 876 | /* |
| 877 | ********************************** |
no test coverage detected