1 /* parse_util.c - the opkg package management system
3 Copyright (C) 2009 Ubiq Technologies <graham.gower@gmail.com>
6 Copyright (C) 2002 Compaq Computer Corporation
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
21 #include "opkg_utils.h"
22 #include "libbb/libbb.h"
24 #include "parse_util.h"
27 is_field(const char *type, const char *line)
29 if (!strncmp(line, type, strlen(type)))
35 parse_simple(const char *type, const char *line)
37 return trim_xstrdup(line + strlen(type) + 1);
41 * Parse a comma separated string into an array.
44 parse_list(const char *raw, unsigned int *count, const char sep, int skip_field)
46 char **depends = NULL;
47 const char *start, *end;
50 /* skip past the "Field:" marker */
52 while (*raw && *raw != ':')
57 if (line_is_blank(raw)) {
63 depends = xrealloc(depends, sizeof(char *) * (line_count + 1));
69 while (*raw != sep && *raw)
73 while (end > start && isspace(*end))
79 depends[line_count] = xstrndup(start, end-start);