| 152 | |
| 153 | static const char* feOptAction(feOptIndex opt); |
| 154 | const char* feSetOptValue(feOptIndex opt, char* optarg) |
| 155 | { |
| 156 | if (opt == FE_OPT_UNDEF) return "option undefined"; |
| 157 | |
| 158 | if (feOptSpec[opt].type != feOptUntyped) |
| 159 | { |
| 160 | if (feOptSpec[opt].type != feOptString) |
| 161 | { |
| 162 | if (optarg != NULL) |
| 163 | { |
| 164 | errno = 0; |
| 165 | feOptSpec[opt].value = (void*) strtol(optarg, NULL, 10); |
| 166 | if (errno) return "invalid integer argument"; |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | feOptSpec[opt].value = (void*) 0; |
| 171 | } |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | assume(feOptSpec[opt].type == feOptString); |
| 176 | if (feOptSpec[opt].set && feOptSpec[opt].value != NULL) |
| 177 | omFree(feOptSpec[opt].value); |
| 178 | if (optarg != NULL) |
| 179 | feOptSpec[opt].value = omStrDup(optarg); |
| 180 | else |
| 181 | feOptSpec[opt].value = NULL; |
| 182 | feOptSpec[opt].set = 1; |
| 183 | } |
| 184 | } |
| 185 | return feOptAction(opt); |
| 186 | } |
| 187 | |
| 188 | const char* feSetOptValue(feOptIndex opt, int optarg) |
| 189 | { |