unify object freeing
[project/firewall3.git] / options.c
index 5d325fc..0de4775 100644 (file)
--- a/options.c
+++ b/options.c
 
 #include "options.h"
 
+const char *fw3_flag_names[FW3_DEFAULT_DROP_INVALID + 1] = {
+       "filter",
+       "nat",
+       "mangle",
+       "raw",
+
+       "IPv4",
+       "IPv6",
+
+       "ACCEPT",
+       "REJECT",
+       "DROP",
+       "NOTRACK",
+       "DNAT",
+       "SNAT",
+};
+
 bool
 fw3_parse_bool(void *ptr, const char *val)
 {
@@ -481,16 +498,14 @@ fw3_parse_ipset_datatype(void *ptr, const char *val)
 
 
 void
-fw3_parse_options(void *s,
-                  struct fw3_option *opts, int n,
+fw3_parse_options(void *s, const struct fw3_option *opts,
                   struct uci_section *section)
 {
-       int i;
        char *p;
        bool known;
        struct uci_element *e, *l;
        struct uci_option *o;
-       struct fw3_option *opt;
+       const struct fw3_option *opt;
        struct list_head *item;
        struct list_head *dest;
 
@@ -499,11 +514,9 @@ fw3_parse_options(void *s,
                o = uci_to_option(e);
                known = false;
 
-               for (i = 0; i < n; i++)
+               for (opt = opts; opt->name; opt++)
                {
-                       opt = &opts[i];
-
-                       if (!opt->parse || !opt->name)
+                       if (!opt->parse)
                                continue;
 
                        if (strcmp(opt->name, e->name))