2 * Copyright 2010, Oliver Tappe <zooey@hirschkaefer.de>.
3 * Distributed under the terms of the MIT License.
12 getsubopt(char** optionPtr
, char* const* keys
, char** valuePtr
)
14 if (optionPtr
== NULL
|| valuePtr
== NULL
)
17 char* option
= *optionPtr
;
21 char* startOfNextOption
= strchr(option
, ',');
22 if (startOfNextOption
!= NULL
)
23 *startOfNextOption
++ = '\0';
25 startOfNextOption
= option
+ strlen(option
);
26 *optionPtr
= startOfNextOption
;
28 char* startOfValue
= strchr(option
, '=');
29 if (startOfValue
!= NULL
)
30 *startOfValue
++ = '\0';
31 *valuePtr
= startOfValue
;
33 for (int keyIndex
= 0; keys
[keyIndex
] != NULL
; ++keyIndex
) {
34 if (strcmp(option
, keys
[keyIndex
]) == 0)