bump for release
[uclibc-ng.git] / libc / unistd / getsubopt-susv3.c
blob9ff33ef114ec89f481c4de40e40e2cea8dc01187
1 /*
2 * Copyright (C) 2006 Rich Felker <dalias@aerifal.cx>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 #include <stdlib.h>
8 #include <string.h>
11 int getsubopt(char **opt, char *const *keys, char **val)
13 char *s = *opt;
14 int i;
16 *val = NULL;
17 *opt = strchr(s, ',');
18 if (*opt) *(*opt)++ = 0;
19 else *opt = s + strlen(s);
21 for (i=0; keys[i]; i++) {
22 size_t l = strlen(keys[i]);
23 if (strncmp(keys[i], s, l)) continue;
24 if (s[l] == '=')
25 *val = s + l;
26 else if (s[l]) continue;
27 return i;
29 return -1;