return (opt->code > 0 ? opt : NULL);
}
-/* Find first occurrence of any character in the string <needles>
- * within the string <haystack>
- * */
-static char *get_sep_pos(const char *haystack, const char *needles)
-{
- unsigned int i;
- char *first = NULL;
-
- for (i = 0; i < strlen(needles); i++) {
- char *found = strchr(haystack, needles[i]);
- if (found && ((found < first) || (first == NULL)))
- first = found;
- }
-
- return first;
-}
-
static int parse_opt_u8(const char *src, uint8_t **dst)
{
int len = strlen(src);
static int parse_opt_string(const char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
- char *sep = get_sep_pos(src, ARRAY_SEP);
+ char *sep = strpbrk(src, ARRAY_SEP);
if (sep && !array)
return -1;
src = sep;
if (sep)
- sep = get_sep_pos(src, ARRAY_SEP);
+ sep = strpbrk(src, ARRAY_SEP);
} while (src);
return o_len;
static int parse_opt_dns_string(const char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
- char *sep = get_sep_pos(src, ARRAY_SEP);
+ char *sep = strpbrk(src, ARRAY_SEP);
if (sep && !array)
return -1;
src = sep;
if (sep)
- sep = get_sep_pos(src, ARRAY_SEP);
+ sep = strpbrk(src, ARRAY_SEP);
} while (src);
return o_len;
static int parse_opt_ip6(const char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
- char *sep = get_sep_pos(src, ARRAY_SEP);
+ char *sep = strpbrk(src, ARRAY_SEP);
if (sep && !array)
return -1;
src = sep;
if (sep)
- sep = get_sep_pos(src, ARRAY_SEP);
+ sep = strpbrk(src, ARRAY_SEP);
} while (src);
return o_len;
static int parse_opt_user_class(const char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
- char *sep = get_sep_pos(src, ARRAY_SEP);
+ char *sep = strpbrk(src, ARRAY_SEP);
if (sep && !array)
return -1;
src = sep;
if (sep)
- sep = get_sep_pos(src, ARRAY_SEP);
+ sep = strpbrk(src, ARRAY_SEP);
} while (src);
return o_len;
struct odhcp6c_opt *dopt = NULL;
int ret = -1;
- data = get_sep_pos(opt, ":");
+ data = strpbrk(opt, ":");
if (!data)
return -1;