+#define ucimap_foreach_option(_sm, _o) \
+ if (!(_sm)->options_size) \
+ (_sm)->options_size = sizeof(struct uci_optmap); \
+ for (_o = &(_sm)->options[0]; \
+ ((char *)(_o)) < ((char *) &(_sm)->options[0] + \
+ (_sm)->options_size * (_sm)->n_options); \
+ _o = (struct uci_optmap *) ((char *)(_o) + \
+ (_sm)->options_size))
+
+
+static inline bool
+ucimap_is_alloc(enum ucimap_type type)
+{
+ switch(type & UCIMAP_SUBTYPE) {
+ case UCIMAP_STRING:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool
+ucimap_is_fixup(enum ucimap_type type)
+{
+ switch(type & UCIMAP_SUBTYPE) {
+ case UCIMAP_SECTION:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool
+ucimap_is_simple(enum ucimap_type type)
+{
+ return ((type & UCIMAP_TYPE) == UCIMAP_SIMPLE);
+}
+
+static inline bool
+ucimap_is_list(enum ucimap_type type)
+{
+ return ((type & UCIMAP_TYPE) == UCIMAP_LIST);
+}
+
+static inline union ucimap_data *
+ucimap_get_data(struct uci_sectmap_data *sd, struct uci_optmap *om)
+{
+ void *data;
+
+ data = (char *) sd + sizeof(struct uci_sectmap_data) + om->offset;
+ return data;
+}
+