diff options
author | Geoff Levand <geoffrey.levand@am.sony.com> | 2009-03-25 12:35:56 +0000 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2009-03-30 20:20:11 +1100 |
commit | 5472ed16df5642aedc124a1b49a35d99da98cc37 (patch) | |
tree | 8a0000146473f0dc1f88196f227ad48115641012 /discover/parser-conf.h | |
parent | ff7fa9c37c952d0df20ba73f3109182c01347f2e (diff) | |
download | talos-petitboot-5472ed16df5642aedc124a1b49a35d99da98cc37.tar.gz talos-petitboot-5472ed16df5642aedc124a1b49a35d99da98cc37.zip |
Split common routines from kboot parser
Pull out the common .conf file parsing logic from kboot-parser.c and
into two new files parser-conf.h and parser-conf.c, and rework
the kboot parser to use those common routines.
The new common routines are based on a .conf file parser context
struct conf_context. The specific parsers setup the context then
call the main parsing entry routine conf_parse(). conf_parse()
uses the context info to open and read .conf files and call
parser specific callbacks to process name:value pairs and to
add boot_option instances to the discover server.
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/parser-conf.h')
-rw-r--r-- | discover/parser-conf.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/discover/parser-conf.h b/discover/parser-conf.h new file mode 100644 index 0000000..09015d1 --- /dev/null +++ b/discover/parser-conf.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Sony Computer Entertainment Inc. + * Copyright 2009 Sony Corp. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#if !defined(_PB_DISCOVER_CONFIG_H) +#define _PB_DISCOVER_CONFIG_H + +#include "device-handler.h" + +struct conf_global_option { + const char *name; + char *value; +}; + +struct conf_context { + void *parser_info; + struct discover_context *dc; + char *buf; + struct conf_global_option *global_options; + const char *const *conf_files; + + void (*process_pair)(struct conf_context *conf, const char *name, + char *value); + void (*finish)(struct conf_context *conf); +}; + +int conf_parse(struct conf_context *conf); +char *conf_get_param_pair(char *str, char **name_out, char **value_out, + char terminator); +const char *conf_get_global_option(struct conf_context *conf, + const char *name); +int conf_set_global_option(struct conf_context *conf, const char *name, + const char *value); + +/* utility routines */ + +int conf_param_in_list(const char *const *list, const char *param); +char *conf_strip_str(char *s); + +#endif |