2 * libuci - Library for the Unified Configuration Interface
3 * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
5 * this program is free software; you can redistribute it and/or modify
6 * it under the terms of the gnu lesser general public license version 2.1
7 * as published by the free software foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
41 struct uci_parse_context;
45 * uci_alloc: Allocate a new uci context
47 extern struct uci_context *uci_alloc(void);
50 * uci_perror: Print the last uci error that occured
52 * @str: string to print before the error message
54 extern void uci_perror(struct uci_context *ctx, const char *str);
57 * uci_parse: Parse an uci config file and store it in the uci context
60 * @name: name of the config file (relative to the config directory)
62 int uci_parse(struct uci_context *ctx, const char *name);
65 * uci_cleanup: Clean up after an error
69 int uci_cleanup(struct uci_context *ctx);
72 /* UCI data structures */
78 /* for error handling only */
79 struct uci_parse_context *pctx;
86 struct uci_parse_context
100 struct uci_list sections;
101 struct uci_context *ctx;
107 struct uci_list list;
108 struct uci_list options;
109 struct uci_config *config;
116 struct uci_list list;
117 struct uci_section *section;
122 /* linked list handling */
124 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
127 #define uci_list_entry(type, ptr) \
128 ((struct uci_#type *) ((char *)(ptr) - offsetof(struct uci_#type,list)))
131 #define uci_foreach_entry(type, list, ptr) \
132 for(ptr = uci_list_entry(type, (list)->next); \
133 &ptr->list != list; \
134 ptr = uci_list_entry(type, ptr->list.next))