more config functions
[project/uci.git] / libuci.h
index e4990a2..de96f45 100644 (file)
--- a/libuci.h
+++ b/libuci.h
@@ -50,7 +50,7 @@ extern struct uci_context *uci_alloc(void);
  * uci_perror: Print the last uci error that occured
  * @ctx: uci context
  * @str: string to print before the error message
- */ 
+ */
 extern void uci_perror(struct uci_context *ctx, const char *str);
 
 /**
@@ -74,13 +74,15 @@ int uci_cleanup(struct uci_context *ctx);
 struct uci_context
 {
        struct uci_list root;
-       
+
        /* for error handling only */
        struct uci_parse_context *pctx;
 
        /* private: */
        int errno;
        jmp_buf trap;
+       jmp_buf trap_saved;
+       int saved;
 };
 
 struct uci_parse_context
@@ -89,6 +91,7 @@ struct uci_parse_context
        int byte;
 
        /* private: */
+       struct uci_config *cfg;
        FILE *file;
        char *buf;
        int bufsz;
@@ -124,13 +127,13 @@ struct uci_option
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
 
-#define uci_list_entry(type, ptr) \
-       ((struct uci_#type *) ((char *)(ptr) - offsetof(struct uci_#type,list)))
-
+#define uci_list_empty(list) (list->next == ptr)
+#define uci_list_entry(_type, _ptr) \
+       ((struct uci_ ## _type *) ((char *)(_ptr) - offsetof(struct uci_ ## _type,list)))
 
-#define uci_foreach_entry(type, list, ptr)             \
-       for(ptr = uci_list_entry(type, (list)->next);   \
-               &ptr->list != list;                     \
-               ptr = uci_list_entry(type, ptr->list.next))
+#define uci_foreach_entry(_type, _list, _ptr)          \
+       for(_ptr = uci_list_entry(_type, (_list)->next);        \
+               &_ptr->list != (_list);                 \
+               _ptr = uci_list_entry(_type, _ptr->list.next))
 
 #endif