]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables: use C99 lists for struct options
authorGáspár Lajos <swifty@freemail.hu>
Thu, 27 Mar 2008 07:20:39 +0000 (08:20 +0100)
committerPatrick McHardy <kaber@trash.net>
Mon, 14 Apr 2008 06:51:33 +0000 (08:51 +0200)
ip6tables-restore.c
ip6tables-save.c
ip6tables.c
iptables-restore.c
iptables-save.c
iptables.c

index 2c3e95de4fa6d33cce1d9cb845a6a13c3b44ce59..c2703dc5a5c1bde0b97d16f74061d72c6b577d21 100644 (file)
 static int binary = 0, counters = 0, verbose = 0, noflush = 0;
 
 /* Keeping track of external matches and targets.  */
-static struct option options[] = {
-       { "binary", 0, 0, 'b' },
-       { "counters", 0, 0, 'c' },
-       { "verbose", 0, 0, 'v' },
-       { "test", 0, 0, 't' },
-       { "help", 0, 0, 'h' },
-       { "noflush", 0, 0, 'n'},
-       { "modprobe", 1, 0, 'M'},
-       { 0 }
+static const struct option options[] = {
+       {.name = "binary",   .has_arg = false, .val = 'b'},
+       {.name = "counters", .has_arg = false, .val = 'c'},
+       {.name = "verbose",  .has_arg = false, .val = 'v'},
+       {.name = "test",     .has_arg = false, .val = 't'},
+       {.name = "help",     .has_arg = false, .val = 'h'},
+       {.name = "noflush",  .has_arg = false, .val = 'n'},
+       {.name = "modprobe", .has_arg = true,  .val = 'M'},
+       {NULL},
 };
 
 static void print_usage(const char *name, const char *version) __attribute__((noreturn));
index e4408872c4c61b3875a7618493b31d48e90cb0e3..6e2fea5d2968c795c57076e7fa3b49c7207beb56 100644 (file)
 
 static int show_binary = 0, show_counters = 0;
 
-static struct option options[] = {
-       { "binary", 0, 0, 'b' },
-       { "counters", 0, 0, 'c' },
-       { "dump", 0, 0, 'd' },
-       { "table", 1, 0, 't' },
-       { 0 }
+static const struct option options[] = {
+       {.name = "binary",   .has_arg = false, .val = 'b'},
+       {.name = "counters", .has_arg = false, .val = 'c'},
+       {.name = "dump",     .has_arg = false, .val = 'd'},
+       {.name = "table",    .has_arg = true,  .val = 't'},
+       {NULL},
 };
 
 
index c7d4a4f7698bdebb5ac5cbdaf1eb8afca67f3624..908700e25052fa237815027338286042ed4e7249 100644 (file)
@@ -101,36 +101,36 @@ static const char optflags[NUMBER_OF_OPT]
 = { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', '0', 'c'};
 
 static struct option original_opts[] = {
-       { "append", 1, 0, 'A' },
-       { "delete", 1, 0,  'D' },
-       { "insert", 1, 0,  'I' },
-       { "replace", 1, 0,  'R' },
-       { "list", 2, 0,  'L' },
-       { "flush", 2, 0,  'F' },
-       { "zero", 2, 0,  'Z' },
-       { "new-chain", 1, 0,  'N' },
-       { "delete-chain", 2, 0,  'X' },
-       { "rename-chain", 1, 0,  'E' },
-       { "policy", 1, 0,  'P' },
-       { "source", 1, 0, 's' },
-       { "destination", 1, 0,  'd' },
-       { "src", 1, 0,  's' }, /* synonym */
-       { "dst", 1, 0,  'd' }, /* synonym */
-       { "protocol", 1, 0,  'p' },
-       { "in-interface", 1, 0, 'i' },
-       { "jump", 1, 0, 'j' },
-       { "table", 1, 0, 't' },
-       { "match", 1, 0, 'm' },
-       { "numeric", 0, 0, 'n' },
-       { "out-interface", 1, 0, 'o' },
-       { "verbose", 0, 0, 'v' },
-       { "exact", 0, 0, 'x' },
-       { "version", 0, 0, 'V' },
-       { "help", 2, 0, 'h' },
-       { "line-numbers", 0, 0, '0' },
-       { "modprobe", 1, 0, 'M' },
-       { "set-counters", 1, 0, 'c' },
-       { 0 }
+       {.name = "append",        .has_arg = 1, .val = 'A'},
+       {.name = "delete",        .has_arg = 1, .val = 'D'},
+       {.name = "insert",        .has_arg = 1, .val = 'I'},
+       {.name = "replace",       .has_arg = 1, .val = 'R'},
+       {.name = "list",          .has_arg = 2, .val = 'L'},
+       {.name = "flush",         .has_arg = 2, .val = 'F'},
+       {.name = "zero",          .has_arg = 2, .val = 'Z'},
+       {.name = "new-chain",     .has_arg = 1, .val = 'N'},
+       {.name = "delete-chain",  .has_arg = 2, .val = 'X'},
+       {.name = "rename-chain",  .has_arg = 1, .val = 'E'},
+       {.name = "policy",        .has_arg = 1, .val = 'P'},
+       {.name = "source",        .has_arg = 1, .val = 's'},
+       {.name = "destination",   .has_arg = 1, .val = 'd'},
+       {.name = "src",           .has_arg = 1, .val = 's'}, /* synonym */
+       {.name = "dst",           .has_arg = 1, .val = 'd'}, /* synonym */
+       {.name = "protocol",      .has_arg = 1, .val = 'p'},
+       {.name = "in-interface",  .has_arg = 1, .val = 'i'},
+       {.name = "jump",          .has_arg = 1, .val = 'j'},
+       {.name = "table",         .has_arg = 1, .val = 't'},
+       {.name = "match",         .has_arg = 1, .val = 'm'},
+       {.name = "numeric",       .has_arg = 0, .val = 'n'},
+       {.name = "out-interface", .has_arg = 1, .val = 'o'},
+       {.name = "verbose",       .has_arg = 0, .val = 'v'},
+       {.name = "exact",         .has_arg = 0, .val = 'x'},
+       {.name = "version",       .has_arg = 0, .val = 'V'},
+       {.name = "help",          .has_arg = 2, .val = 'h'},
+       {.name = "line-numbers",  .has_arg = 0, .val = '0'},
+       {.name = "modprobe",      .has_arg = 1, .val = 'M'},
+       {.name = "set-counters",  .has_arg = 1, .val = 'c'},
+       {NULL},
 };
 
 /* we need this for ip6tables-restore. ip6tables-restore.c sets line to the
index f556fa54f0cb254c7005026d1b26320d25e61608..ecf7b2d8e9105716e1aa36efd6c1a5fe8b66a9b9 100644 (file)
 static int binary = 0, counters = 0, verbose = 0, noflush = 0;
 
 /* Keeping track of external matches and targets.  */
-static struct option options[] = {
-       { "binary", 0, 0, 'b' },
-       { "counters", 0, 0, 'c' },
-       { "verbose", 0, 0, 'v' },
-       { "test", 0, 0, 't' },
-       { "help", 0, 0, 'h' },
-       { "noflush", 0, 0, 'n'},
-       { "modprobe", 1, 0, 'M'},
-       { "table", 1, 0, 'T'},
-       { 0 }
+static const struct option options[] = {
+       {.name = "binary",   .has_arg = false, .val = 'b'},
+       {.name = "counters", .has_arg = false, .val = 'c'},
+       {.name = "verbose",  .has_arg = false, .val = 'v'},
+       {.name = "test",     .has_arg = false, .val = 't'},
+       {.name = "help",     .has_arg = false, .val = 'h'},
+       {.name = "noflush",  .has_arg = false, .val = 'n'},
+       {.name = "modprobe", .has_arg = true,  .val = 'M'},
+       {.name = "table",    .has_arg = true,  .val = 'T'},
+       {NULL},
 };
 
 static void print_usage(const char *name, const char *version) __attribute__((noreturn));
index 1ce2090174cd17c318cbeb3166063f5e2067c10e..4272202ef1798e5734924191edf1ffe0e3e61a3f 100644 (file)
 
 static int show_binary = 0, show_counters = 0;
 
-static struct option options[] = {
-       { "binary", 0, 0, 'b' },
-       { "counters", 0, 0, 'c' },
-       { "dump", 0, 0, 'd' },
-       { "table", 1, 0, 't' },
-       { 0 }
+static const struct option options[] = {
+       {.name = "binary",   .has_arg = false, .val = 'b'},
+       {.name = "counters", .has_arg = false, .val = 'c'},
+       {.name = "dump",     .has_arg = false, .val = 'd'},
+       {.name = "table",    .has_arg = true,  .val = 't'},
+       {NULL},
 };
 
 #define IP_PARTS_NATIVE(n)                     \
index 7cc2448f4137b97e03a93d2ba102f7772d5d9188..0300027cb111d12628f831bc690f999f48d4a57a 100644 (file)
@@ -99,38 +99,38 @@ static const char optflags[NUMBER_OF_OPT]
 = { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', 'f', '0', 'c'};
 
 static struct option original_opts[] = {
-       { "append", 1, NULL, 'A' },
-       { "delete", 1, NULL,  'D' },
-       { "insert", 1, NULL,  'I' },
-       { "replace", 1, NULL,  'R' },
-       { "list", 2, NULL,  'L' },
-       { "flush", 2, NULL,  'F' },
-       { "zero", 2, NULL,  'Z' },
-       { "new-chain", 1, NULL,  'N' },
-       { "delete-chain", 2, NULL,  'X' },
-       { "rename-chain", 1, NULL,  'E' },
-       { "policy", 1, NULL,  'P' },
-       { "source", 1, NULL, 's' },
-       { "destination", 1, NULL,  'd' },
-       { "src", 1, NULL,  's' }, /* synonym */
-       { "dst", 1, NULL,  'd' }, /* synonym */
-       { "protocol", 1, NULL,  'p' },
-       { "in-interface", 1, NULL, 'i' },
-       { "jump", 1, NULL, 'j' },
-       { "table", 1, NULL, 't' },
-       { "match", 1, NULL, 'm' },
-       { "numeric", 0, NULL, 'n' },
-       { "out-interface", 1, NULL, 'o' },
-       { "verbose", 0, NULL, 'v' },
-       { "exact", 0, NULL, 'x' },
-       { "fragments", 0, NULL, 'f' },
-       { "version", 0, NULL, 'V' },
-       { "help", 2, NULL, 'h' },
-       { "line-numbers", 0, NULL, '0' },
-       { "modprobe", 1, NULL, 'M' },
-       { "set-counters", 1, NULL, 'c' },
-       { "goto", 1, NULL, 'g' },
-       { }
+       {.name = "append",        .has_arg = 1, .val = 'A'},
+       {.name = "delete",        .has_arg = 1, .val = 'D'},
+       {.name = "insert",        .has_arg = 1, .val = 'I'},
+       {.name = "replace",       .has_arg = 1, .val = 'R'},
+       {.name = "list",          .has_arg = 2, .val = 'L'},
+       {.name = "flush",         .has_arg = 2, .val = 'F'},
+       {.name = "zero",          .has_arg = 2, .val = 'Z'},
+       {.name = "new-chain",     .has_arg = 1, .val = 'N'},
+       {.name = "delete-chain",  .has_arg = 2, .val = 'X'},
+       {.name = "rename-chain",  .has_arg = 1, .val = 'E'},
+       {.name = "policy",        .has_arg = 1, .val = 'P'},
+       {.name = "source",        .has_arg = 1, .val = 's'},
+       {.name = "destination",   .has_arg = 1, .val = 'd'},
+       {.name = "src",           .has_arg = 1, .val = 's'}, /* synonym */
+       {.name = "dst",           .has_arg = 1, .val = 'd'}, /* synonym */
+       {.name = "protocol",      .has_arg = 1, .val = 'p'},
+       {.name = "in-interface",  .has_arg = 1, .val = 'i'},
+       {.name = "jump",          .has_arg = 1, .val = 'j'},
+       {.name = "table",         .has_arg = 1, .val = 't'},
+       {.name = "match",         .has_arg = 1, .val = 'm'},
+       {.name = "numeric",       .has_arg = 0, .val = 'n'},
+       {.name = "out-interface", .has_arg = 1, .val = 'o'},
+       {.name = "verbose",       .has_arg = 0, .val = 'v'},
+       {.name = "exact",         .has_arg = 0, .val = 'x'},
+       {.name = "fragments",     .has_arg = 0, .val = 'f'},
+       {.name = "version",       .has_arg = 0, .val = 'V'},
+       {.name = "help",          .has_arg = 2, .val = 'h'},
+       {.name = "line-numbers",  .has_arg = 0, .val = '0'},
+       {.name = "modprobe",      .has_arg = 1, .val = 'M'},
+       {.name = "set-counters",  .has_arg = 1, .val = 'c'},
+       {.name = "goto",          .has_arg = 1, .val = 'g'},
+       {NULL},
 };
 
 /* we need this for iptables-restore.  iptables-restore.c sets line to the