release 0.1
[u-tools.git] / u-tools / apps / libdiskconfig_usb / include / config_utils.h
blobf3fb370a8a35fda7b5faa3969e74a483db89c990
1 /*
2 * Copyright (C) 2006 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __CUTILS_CONFIG_UTILS_H
18 #define __CUTILS_CONFIG_UTILS_H
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
24 typedef struct cnode cnode;
27 struct cnode
29 cnode *next;
30 cnode *first_child;
31 cnode *last_child;
32 const char *name;
33 const char *value;
36 /* parse a text string into a config node tree */
37 void config_load(cnode *root, char *data);
39 /* parse a file into a config node tree */
40 void config_load_file(cnode *root, const char *fn);
42 /* create a single config node */
43 cnode* config_node(const char *name, const char *value);
45 /* locate a named child of a config node */
46 cnode* config_find(cnode *root, const char *name);
48 /* look up a child by name and return the boolean value */
49 int config_bool(cnode *root, const char *name, int _default);
51 /* look up a child by name and return the string value */
52 const char* config_str(cnode *root, const char *name, const char *_default);
54 /* add a named child to a config node (or modify it if it already exists) */
55 void config_set(cnode *root, const char *name, const char *value);
57 #ifdef __cplusplus
59 #endif
61 #endif