From: Felix Fietkau Date: Tue, 22 Jan 2008 23:42:56 +0000 (+0100) Subject: add a few more comments X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=04a7e4c12fa0584671ac25d8cf6c2dfdec57509b;p=uci.git add a few more comments --- diff --git a/uci.h b/uci.h index 7cd7eb9..4b792d6 100644 --- a/uci.h +++ b/uci.h @@ -106,9 +106,10 @@ extern char **uci_list_configs(); struct uci_context { + /* list of config packages */ struct uci_list root; - /* for error handling only */ + /* parser context, use for error handling only */ struct uci_parse_context *pctx; /* private: */ @@ -118,6 +119,7 @@ struct uci_context struct uci_parse_context { + /* error context */ const char *reason; int line; int byte; @@ -163,10 +165,28 @@ struct uci_option #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif +/* returns true if a list is empty */ #define uci_list_empty(list) ((list)->next == (list)) + +/** + * uci_list_entry: casts an uci_list pointer to the containing struct. + * @_type: config, section or option + * @_ptr: pointer to the uci_list struct + */ #define uci_list_entry(_type, _ptr) \ ((struct uci_ ## _type *) ((char *)(_ptr) - offsetof(struct uci_ ## _type,list))) +/** + * uci_foreach_entry: loop through a list of configs, sections or options + * @_type: see uci_list_entry + * @_list: pointer to the uci_list struct + * @_ptr: iteration variable + * + * use like a for loop, e.g: + * uci_foreach(section, &list, p) { + * ... + * } + */ #define uci_foreach_entry(_type, _list, _ptr) \ for(_ptr = uci_list_entry(_type, (_list)->next); \ &_ptr->list != (_list); \