| 220 | } |
| 221 | |
| 222 | static int poptConfigLine(poptContext con, char * line) |
| 223 | { |
| 224 | char *b = NULL; |
| 225 | size_t nb = 0; |
| 226 | char * se = line; |
| 227 | const char * appName; |
| 228 | const char * entryType; |
| 229 | const char * opt; |
| 230 | struct poptItem_s item_buf; |
| 231 | poptItem item = &item_buf; |
| 232 | int i, j; |
| 233 | int rc = POPT_ERROR_BADCONFIG; |
| 234 | |
| 235 | if (con->appName == NULL) |
| 236 | goto exit; |
| 237 | |
| 238 | memset(item, 0, sizeof(*item)); |
| 239 | |
| 240 | appName = se; |
| 241 | while (*se != '\0' && !_isspaceptr(se)) se++; |
| 242 | if (*se == '\0') |
| 243 | goto exit; |
| 244 | else |
| 245 | *se++ = '\0'; |
| 246 | |
| 247 | if (configAppMatch(con, appName)) goto exit; |
| 248 | |
| 249 | while (*se != '\0' && _isspaceptr(se)) se++; |
| 250 | entryType = se; |
| 251 | while (*se != '\0' && !_isspaceptr(se)) se++; |
| 252 | if (*se != '\0') *se++ = '\0'; |
| 253 | |
| 254 | while (*se != '\0' && _isspaceptr(se)) se++; |
| 255 | if (*se == '\0') goto exit; |
| 256 | opt = se; |
| 257 | while (*se != '\0' && !_isspaceptr(se)) se++; |
| 258 | if (opt[0] == '-' && *se == '\0') goto exit; |
| 259 | if (*se != '\0') *se++ = '\0'; |
| 260 | |
| 261 | while (*se != '\0' && _isspaceptr(se)) se++; |
| 262 | if (opt[0] == '-' && *se == '\0') goto exit; |
| 263 | |
| 264 | if (opt[0] == '-' && opt[1] == '-') |
| 265 | item->option.longName = opt + 2; |
| 266 | else if (opt[0] == '-' && opt[2] == '\0') |
| 267 | item->option.shortName = opt[1]; |
| 268 | else { |
| 269 | const char * fn = opt; |
| 270 | |
| 271 | /* XXX handle globs and directories in fn? */ |
| 272 | if ((rc = poptReadFile(fn, &b, &nb, POPT_READFILE_TRIMNEWLINES)) != 0) |
| 273 | goto exit; |
| 274 | if (b == NULL || nb == 0) |
| 275 | goto exit; |
| 276 | |
| 277 | /* Append remaining text to the interpolated file option text. */ |
| 278 | if (*se != '\0') { |
| 279 | size_t nse = strlen(se) + 1; |
no test coverage detected