diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2011-05-31 19:38:00 +0200 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2011-05-31 19:38:00 +0200 |
commit | 3f83fda46c14e47392ce3bb4d7aef5780a80ac78 (patch) | |
tree | 27283f40fe6410a06649095b24fd35039f44929b /src | |
parent | 418a3a4f4d4e38abd1d691f81f2445590f02ecaf (diff) |
Whitespace and coding fixes detected by checkpatch.pl
Diffstat (limited to 'src')
-rw-r--r-- | src/errcode.c | 20 | ||||
-rw-r--r-- | src/ipset.c | 102 | ||||
-rw-r--r-- | src/ipset_bitmap_ip.c | 12 | ||||
-rw-r--r-- | src/ipset_bitmap_ipmac.c | 14 | ||||
-rw-r--r-- | src/ipset_bitmap_port.c | 12 | ||||
-rw-r--r-- | src/ipset_hash_ip.c | 10 | ||||
-rw-r--r-- | src/ipset_hash_ipport.c | 14 | ||||
-rw-r--r-- | src/ipset_hash_ipportip.c | 16 | ||||
-rw-r--r-- | src/ipset_hash_ipportnet.c | 24 | ||||
-rw-r--r-- | src/ipset_hash_net.c | 16 | ||||
-rw-r--r-- | src/ipset_hash_netiface.c | 14 | ||||
-rw-r--r-- | src/ipset_hash_netport.c | 20 | ||||
-rw-r--r-- | src/ipset_list_set.c | 12 | ||||
-rw-r--r-- | src/ui.c | 74 |
14 files changed, 182 insertions, 178 deletions
diff --git a/src/errcode.c b/src/errcode.c index 9d5f226..1ce5c00 100644 --- a/src/errcode.c +++ b/src/errcode.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <assert.h> /* assert */ @@ -70,7 +70,7 @@ static const struct ipset_errcode_table core_errcode_table[] = { "An IPv4 address is expected, but not received" }, { IPSET_ERR_IPADDR_IPV6, 0, "An IPv6 address is expected, but not received" }, - + /* ADD specific error codes */ { IPSET_ERR_EXIST, IPSET_CMD_ADD, "Element cannot be added to the set: it's already added" }, @@ -157,10 +157,10 @@ ipset_errcode(struct ipset_session *session, enum ipset_cmd cmd, int errcode) { const struct ipset_errcode_table *table = core_errcode_table; int i, generic; - + if (errcode >= IPSET_ERR_TYPE_SPECIFIC) { const struct ipset_type *type; - + type = ipset_saved_type(session); if (type) { if (MATCH_TYPENAME(type->name, "bitmap:")) @@ -174,11 +174,11 @@ ipset_errcode(struct ipset_session *session, enum ipset_cmd cmd, int errcode) retry: for (i = 0, generic = -1; table[i].errcode; i++) { - if (table[i].errcode == errcode - && (table[i].cmd == cmd || table[i].cmd == 0)) { - if (table[i].cmd == 0) { - generic = i; - continue; + if (table[i].errcode == errcode && + (table[i].cmd == cmd || table[i].cmd == 0)) { + if (table[i].cmd == 0) { + generic = i; + continue; } return ipset_err(session, table[i].message); } diff --git a/src/ipset.c b/src/ipset.c index 032564c..358befe 100644 --- a/src/ipset.c +++ b/src/ipset.c @@ -2,8 +2,8 @@ * Patrick Schaaf (bof@bof.de) * Copyright 2003-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <ctype.h> /* isspace */ @@ -26,12 +26,12 @@ static char program_name[] = PACKAGE; static char program_version[] = PACKAGE_VERSION; -static struct ipset_session *session = NULL; -static uint32_t restore_line = 0; -static bool interactive = false; +static struct ipset_session *session; +static uint32_t restore_line; +static bool interactive; static char cmdline[1024]; static char *newargv[255]; -static int newargc = 0; +static int newargc; /* The known set types: (typename, revision, family) is unique */ extern struct ipset_type ipset_bitmap_ip0; @@ -57,12 +57,12 @@ enum exittype { SESSION_PROBLEM, }; -static int __attribute__((format(printf,2,3))) +static int __attribute__((format(printf, 2, 3))) exit_error(int status, const char *msg, ...) { - bool quiet = !interactive - && session - && ipset_envopt_test(session, IPSET_ENV_QUIET); + bool quiet = !interactive && + session && + ipset_envopt_test(session, IPSET_ENV_QUIET); if (status && msg && !quiet) { va_list args; @@ -98,8 +98,8 @@ exit_error(int status, const char *msg, ...) static int handle_error(void) { - if (ipset_session_warning(session) - && !ipset_envopt_test(session, IPSET_ENV_QUIET)) + if (ipset_session_warning(session) && + !ipset_envopt_test(session, IPSET_ENV_QUIET)) fprintf(stderr, "Warning: %s\n", ipset_session_warning(session)); if (ipset_session_error(session)) @@ -111,7 +111,7 @@ handle_error(void) exit(OTHER_PROBLEM); } - ipset_session_report_reset(session); + ipset_session_report_reset(session); return -1; } @@ -120,16 +120,15 @@ help(void) { const struct ipset_commands *c; const struct ipset_envopts *opt = ipset_envopts; - + printf("%s v%s\n\n" "Usage: %s [options] COMMAND\n\nCommands:\n", program_name, program_version, program_name); - for (c = ipset_commands; c->cmd; c++) { + for (c = ipset_commands; c->cmd; c++) printf("%s %s\n", c->name[0], c->help); - } printf("\nOptions:\n"); - + while (opt->flag) { if (opt->help) printf("%s %s\n", opt->name[0], opt->help); @@ -144,7 +143,7 @@ build_argv(char *buffer) char *ptr; int i; - /* Reset */ + /* Reset */ for (i = 1; i < newargc; i++) newargv[i] = NULL; newargc = 1; @@ -173,7 +172,7 @@ restore(char *argv0) { int ret = 0; char *c; - + /* Initialize newargv/newargc */ newargc = 0; newargv[newargc++] = argv0; @@ -193,7 +192,7 @@ restore(char *argv0) } /* Build faked argv, argc */ build_argv(c); - + /* Execute line */ ret = parse_commandline(newargc, newargv); if (ret < 0) @@ -213,7 +212,7 @@ call_parser(int *argc, char *argv[], const struct ipset_arg *args) int ret = 0; const struct ipset_arg *arg; const char *optstr; - + /* Currently CREATE and ADT may have got additional arguments */ if (!args && *argc > 1) goto err_unknown; @@ -237,7 +236,8 @@ call_parser(int *argc, char *argv[], const struct ipset_arg *args) /* Fall through */ case IPSET_OPTIONAL_ARG: if (*argc >= 2) { - ret = ipset_call_parser(session, arg, argv[1]); + ret = ipset_call_parser(session, + arg, argv[1]); if (ret < 0) return ret; ipset_shift_argv(argc, argv, 1); @@ -263,7 +263,7 @@ err_unknown: static enum ipset_adt cmd2cmd(int cmd) { - switch(cmd) { + switch (cmd) { case IPSET_CMD_ADD: return IPSET_ADD; case IPSET_CMD_DEL: @@ -343,15 +343,15 @@ check_allowed(const struct ipset_type *type, enum ipset_cmd command) ? IPSET_CREATE_FLAGS : IPSET_ADT_FLAGS; const struct ipset_arg *arg = type->args[cmd]; enum ipset_opt i; - + /* Range can be expressed by ip/cidr or from-to */ if (allowed & IPSET_FLAG(IPSET_OPT_IP_TO)) allowed |= IPSET_FLAG(IPSET_OPT_CIDR); for (i = IPSET_OPT_IP; i < IPSET_OPT_FLAGS; i++) { - if (!(cmdflags & IPSET_FLAG(i)) - || (allowed & IPSET_FLAG(i)) - || !(flags & IPSET_FLAG(i))) + if (!(cmdflags & IPSET_FLAG(i)) || + (allowed & IPSET_FLAG(i)) || + !(flags & IPSET_FLAG(i))) continue; /* Not allowed element-expressions */ switch (i) { @@ -359,19 +359,22 @@ check_allowed(const struct ipset_type *type, enum ipset_cmd command) exit_error(OTHER_PROBLEM, "IP/CIDR range is not allowed in command %s " "with set type %s and family %s", - cmd2name(command), type->name, session_family()); + cmd2name(command), type->name, + session_family()); return; case IPSET_OPT_IP_TO: exit_error(OTHER_PROBLEM, "FROM-TO IP range is not allowed in command %s " "with set type %s and family %s", - cmd2name(command), type->name, session_family()); + cmd2name(command), type->name, + session_family()); return; case IPSET_OPT_PORT_TO: exit_error(OTHER_PROBLEM, "FROM-TO port range is not allowed in command %s " "with set type %s and family %s", - cmd2name(command), type->name, session_family()); + cmd2name(command), type->name, + session_family()); return; default: break; @@ -391,7 +394,8 @@ check_allowed(const struct ipset_type *type, enum ipset_cmd command) "%s parameter is not allowed in command %s " "with set type %s and family %s", arg->name[0], - cmd2name(command), type->name, session_family()); + cmd2name(command), type->name, + session_family()); return; } exit_error(OTHER_PROBLEM, @@ -406,7 +410,7 @@ static const struct ipset_type * type_find(const char *name) { const struct ipset_type *t = ipset_types(); - + while (t) { if (ipset_match_typename(name, t)) return t; @@ -477,10 +481,10 @@ parse_commandline(int argc, char *argv[]) if (!ipset_match_cmd(argv[1], command->name)) continue; - if (restore_line != 0 - && (command->cmd == IPSET_CMD_RESTORE - || command->cmd == IPSET_CMD_VERSION - || command->cmd == IPSET_CMD_HELP)) + if (restore_line != 0 && + (command->cmd == IPSET_CMD_RESTORE || + command->cmd == IPSET_CMD_VERSION || + command->cmd == IPSET_CMD_HELP)) return exit_error(PARAMETER_PROBLEM, "Command `%s' is invalid " "in restore mode.", @@ -565,9 +569,9 @@ parse_commandline(int argc, char *argv[]) case IPSET_CMD_HELP: help(); - if (interactive - || !ipset_envopt_test(session, IPSET_ENV_QUIET)) { - if (arg0) { + if (interactive || + !ipset_envopt_test(session, IPSET_ENV_QUIET)) { + if (arg0) { /* Type-specific help, without kernel checking */ type = type_find(arg0); if (!type) @@ -597,7 +601,7 @@ parse_commandline(int argc, char *argv[]) printf(" %s\n", type->name); type = type->next; } - } + } } if (interactive) return 0; @@ -607,7 +611,7 @@ parse_commandline(int argc, char *argv[]) default: break; } - + /* Forth: parse command args and issue the command */ switch (cmd) { case IPSET_CMD_CREATE: @@ -630,11 +634,11 @@ parse_commandline(int argc, char *argv[]) return handle_error(); else if (ret) return ret; - + /* Check mandatory, then allowed options */ check_mandatory(type, cmd); check_allowed(type, cmd); - + break; case IPSET_CMD_DESTROY: case IPSET_CMD_FLUSH: @@ -678,22 +682,22 @@ parse_commandline(int argc, char *argv[]) type = ipset_type_get(session, cmd); if (type == NULL) return handle_error(); - + ret = ipset_parse_elem(session, type->last_elem_optional, arg1); if (ret < 0) return handle_error(); - + /* Parse additional ADT options */ ret = call_parser(&argc, argv, type->args[cmd2cmd(cmd)]); if (ret < 0) return handle_error(); else if (ret) return ret; - + /* Check mandatory, then allowed options */ check_mandatory(type, cmd); check_allowed(type, cmd); - + break; default: break; @@ -744,8 +748,8 @@ main(int argc, char *argv[]) "Cannot initialize ipset session, aborting."); ret = parse_commandline(argc, argv); - + ipset_session_fini(session); - + return ret; } diff --git a/src/ipset_bitmap_ip.c b/src/ipset_bitmap_ip.c index 4194875..e73bc7c 100644 --- a/src/ipset_bitmap_ip.c +++ b/src/ipset_bitmap_ip.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -37,7 +37,7 @@ static const struct ipset_arg bitmap_ip_create_args[] = { .parse = ipset_parse_net, }, { }, -}; +}; static const struct ipset_arg bitmap_ip_add_args[] = { { .name = { "timeout", NULL }, @@ -45,7 +45,7 @@ static const struct ipset_arg bitmap_ip_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char bitmap_ip_usage[] = "create SETNAME bitmap:ip range IP/CIDR|FROM-TO\n" @@ -62,8 +62,8 @@ struct ipset_type ipset_bitmap_ip0 = { .revision = 0, .family = AF_INET, .dimension = IPSET_DIM_ONE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip, .print = ipset_print_ip, .opt = IPSET_OPT_IP diff --git a/src/ipset_bitmap_ipmac.c b/src/ipset_bitmap_ipmac.c index 8f2cb72..f47f25d 100644 --- a/src/ipset_bitmap_ipmac.c +++ b/src/ipset_bitmap_ipmac.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -33,7 +33,7 @@ static const struct ipset_arg bitmap_ipmac_create_args[] = { .parse = ipset_parse_net, }, { }, -}; +}; static const struct ipset_arg bitmap_ipmac_add_args[] = { { .name = { "timeout", NULL }, @@ -41,7 +41,7 @@ static const struct ipset_arg bitmap_ipmac_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char bitmap_ipmac_usage[] = "create SETNAME bitmap:ip,mac range IP/CIDR|FROM-TO\n" @@ -60,13 +60,13 @@ struct ipset_type ipset_bitmap_ipmac0 = { .family = AF_INET, .dimension = IPSET_DIM_TWO, .last_elem_optional = true, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_single_ip, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_ether, .print = ipset_print_ether, .opt = IPSET_OPT_ETHER diff --git a/src/ipset_bitmap_port.c b/src/ipset_bitmap_port.c index 82b98a4..c8c6e1f 100644 --- a/src/ipset_bitmap_port.c +++ b/src/ipset_bitmap_port.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -29,7 +29,7 @@ static const struct ipset_arg bitmap_port_create_args[] = { .parse = ipset_parse_single_tcp_port, }, { }, -}; +}; static const struct ipset_arg bitmap_port_add_args[] = { { .name = { "timeout", NULL }, @@ -37,7 +37,7 @@ static const struct ipset_arg bitmap_port_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char bitmap_port_usage[] = "create SETNAME bitmap:port range FROM-TO\n" @@ -53,8 +53,8 @@ struct ipset_type ipset_bitmap_port0 = { .revision = 0, .family = AF_UNSPEC, .dimension = IPSET_DIM_ONE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_tcp_port, .print = ipset_print_port, .opt = IPSET_OPT_PORT diff --git a/src/ipset_hash_ip.c b/src/ipset_hash_ip.c index 6926644..315804a 100644 --- a/src/ipset_hash_ip.c +++ b/src/ipset_hash_ip.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -63,7 +63,7 @@ static const struct ipset_arg hash_ip_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_ip_usage[] = "create SETNAME hash:ip\n" @@ -85,8 +85,8 @@ struct ipset_type ipset_hash_ip0 = { .revision = 0, .family = AF_INET46, .dimension = IPSET_DIM_ONE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_single6, .print = ipset_print_ip, .opt = IPSET_OPT_IP diff --git a/src/ipset_hash_ipport.c b/src/ipset_hash_ipport.c index 58ea76c..b5bd41b 100644 --- a/src/ipset_hash_ipport.c +++ b/src/ipset_hash_ipport.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -60,7 +60,7 @@ static const struct ipset_arg hash_ipport_create_args[] = { .parse = ipset_parse_ignored, }, { }, -}; +}; static const struct ipset_arg hash_ipport_add_args[] = { { .name = { "timeout", NULL }, @@ -68,7 +68,7 @@ static const struct ipset_arg hash_ipport_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_ipport1_usage[] = "create SETNAME hash:ip,port\n" @@ -91,13 +91,13 @@ struct ipset_type ipset_hash_ipport1 = { .revision = 1, .family = AF_INET46, .dimension = IPSET_DIM_TWO, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_single6, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_proto_port, .print = ipset_print_proto_port, .opt = IPSET_OPT_PORT diff --git a/src/ipset_hash_ipportip.c b/src/ipset_hash_ipportip.c index 2f310ea..b27cebf 100644 --- a/src/ipset_hash_ipportip.c +++ b/src/ipset_hash_ipportip.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -60,7 +60,7 @@ static const struct ipset_arg hash_ipportip_create_args[] = { .parse = ipset_parse_ignored, }, { }, -}; +}; static const struct ipset_arg hash_ipportip_add_args[] = { { .name = { "timeout", NULL }, @@ -68,7 +68,7 @@ static const struct ipset_arg hash_ipportip_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_ipportip1_usage[] = "create SETNAME hash:ip,port,ip\n" @@ -91,18 +91,18 @@ struct ipset_type ipset_hash_ipportip1 = { .revision = 1, .family = AF_INET46, .dimension = IPSET_DIM_THREE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_single6, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_proto_port, .print = ipset_print_proto_port, .opt = IPSET_OPT_PORT }, - [IPSET_DIM_THREE] = { + [IPSET_DIM_THREE] = { .parse = ipset_parse_single_ip, .print = ipset_print_ip, .opt = IPSET_OPT_IP2 diff --git a/src/ipset_hash_ipportnet.c b/src/ipset_hash_ipportnet.c index c2eece8..ecab191 100644 --- a/src/ipset_hash_ipportnet.c +++ b/src/ipset_hash_ipportnet.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -60,7 +60,7 @@ static const struct ipset_arg hash_ipportnet_create_args[] = { .parse = ipset_parse_ignored, }, { }, -}; +}; static const struct ipset_arg hash_ipportnet_add_args[] = { { .name = { "timeout", NULL }, @@ -68,7 +68,7 @@ static const struct ipset_arg hash_ipportnet_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_ipportnet1_usage[] = "create SETNAME hash:ip,port,net\n" @@ -92,18 +92,18 @@ struct ipset_type ipset_hash_ipportnet1 = { .revision = 1, .family = AF_INET46, .dimension = IPSET_DIM_THREE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_single6, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_proto_port, .print = ipset_print_proto_port, .opt = IPSET_OPT_PORT }, - [IPSET_DIM_THREE] = { + [IPSET_DIM_THREE] = { .parse = ipset_parse_ipnet, .print = ipset_print_ip, .opt = IPSET_OPT_IP2 @@ -182,18 +182,18 @@ struct ipset_type ipset_hash_ipportnet2 = { .revision = 2, .family = AF_INET46, .dimension = IPSET_DIM_THREE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_single6, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_proto_port, .print = ipset_print_proto_port, .opt = IPSET_OPT_PORT }, - [IPSET_DIM_THREE] = { + [IPSET_DIM_THREE] = { .parse = ipset_parse_ip4_net6, .print = ipset_print_ip, .opt = IPSET_OPT_IP2 diff --git a/src/ipset_hash_net.c b/src/ipset_hash_net.c index 9c0a6ca..665c398 100644 --- a/src/ipset_hash_net.c +++ b/src/ipset_hash_net.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -47,7 +47,7 @@ static const struct ipset_arg hash_net_create_args[] = { .parse = ipset_parse_ignored, .print = ipset_print_number, }, { }, -}; +}; static const struct ipset_arg hash_net_add_args[] = { { .name = { "timeout", NULL }, @@ -55,7 +55,7 @@ static const struct ipset_arg hash_net_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_net0_usage[] = "create SETNAME hash:net\n" @@ -75,8 +75,8 @@ struct ipset_type ipset_hash_net0 = { .revision = 0, .family = AF_INET46, .dimension = IPSET_DIM_ONE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ipnet, .print = ipset_print_ip, .opt = IPSET_OPT_IP @@ -127,8 +127,8 @@ struct ipset_type ipset_hash_net1 = { .revision = 1, .family = AF_INET46, .dimension = IPSET_DIM_ONE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_net6, .print = ipset_print_ip, .opt = IPSET_OPT_IP diff --git a/src/ipset_hash_netiface.c b/src/ipset_hash_netiface.c index bac860b..2fbe27d 100644 --- a/src/ipset_hash_netiface.c +++ b/src/ipset_hash_netiface.c @@ -1,7 +1,7 @@ /* Copyright 2011 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -39,7 +39,7 @@ static const struct ipset_arg hash_netiface_create_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const struct ipset_arg hash_netiface_add_args[] = { { .name = { "timeout", NULL }, @@ -47,7 +47,7 @@ static const struct ipset_arg hash_netiface_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_netiface_usage[] = "create SETNAME hash:net,iface\n" @@ -68,13 +68,13 @@ struct ipset_type ipset_hash_netiface0 = { .revision = 0, .family = AF_INET46, .dimension = IPSET_DIM_TWO, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_net6, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_iface, .print = ipset_print_iface, .opt = IPSET_OPT_IFACE diff --git a/src/ipset_hash_netport.c b/src/ipset_hash_netport.c index 7964319..480dd84 100644 --- a/src/ipset_hash_netport.c +++ b/src/ipset_hash_netport.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -39,7 +39,7 @@ static const struct ipset_arg hash_netport_create_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const struct ipset_arg hash_netport_add_args[] = { { .name = { "timeout", NULL }, @@ -47,7 +47,7 @@ static const struct ipset_arg hash_netport_add_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const char hash_netport1_usage[] = "create SETNAME hash:net,port\n" @@ -69,13 +69,13 @@ struct ipset_type ipset_hash_netport1 = { .revision = 1, .family = AF_INET46, .dimension = IPSET_DIM_TWO, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ipnet, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_proto_port, .print = ipset_print_proto_port, .opt = IPSET_OPT_PORT @@ -143,13 +143,13 @@ struct ipset_type ipset_hash_netport2 = { .revision = 2, .family = AF_INET46, .dimension = IPSET_DIM_TWO, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_ip4_net6, .print = ipset_print_ip, .opt = IPSET_OPT_IP }, - [IPSET_DIM_TWO] = { + [IPSET_DIM_TWO] = { .parse = ipset_parse_proto_port, .print = ipset_print_proto_port, .opt = IPSET_OPT_PORT diff --git a/src/ipset_list_set.c b/src/ipset_list_set.c index 7e7ddff..f3fa6df 100644 --- a/src/ipset_list_set.c +++ b/src/ipset_list_set.c @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <libipset/data.h> /* IPSET_OPT_* */ @@ -20,7 +20,7 @@ static const struct ipset_arg list_set_create_args[] = { .parse = ipset_parse_uint32, .print = ipset_print_number, }, { }, -}; +}; static const struct ipset_arg list_set_adt_args[] = { { .name = { "timeout", NULL }, @@ -36,7 +36,7 @@ static const struct ipset_arg list_set_adt_args[] = { .parse = ipset_parse_after, }, { }, -}; +}; static const char list_set_usage[] = "create SETNAME list:set\n" @@ -52,8 +52,8 @@ struct ipset_type ipset_list_set0 = { .revision = 0, .family = AF_UNSPEC, .dimension = IPSET_DIM_ONE, - .elem = { - [IPSET_DIM_ONE] = { + .elem = { + [IPSET_DIM_ONE] = { .parse = ipset_parse_setname, .print = ipset_print_name, .opt = IPSET_OPT_NAME @@ -1,7 +1,7 @@ /* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <assert.h> /* assert */ @@ -35,91 +35,91 @@ const struct ipset_commands ipset_commands[] = { .name = { "add", NULL }, .has_arg = IPSET_MANDATORY_ARG2, .help = "SETNAME ENTRY\n" - " Add entry to the named set", + " Add entry to the named set", }, { /* d[el], --del, -D */ .cmd = IPSET_CMD_DEL, .name = { "del", NULL }, .has_arg = IPSET_MANDATORY_ARG2, .help = "SETNAME ENTRY\n" - " Delete entry from the named set", + " Delete entry from the named set", }, { /* t[est], --test, -T */ .cmd = IPSET_CMD_TEST, .name = { "test", NULL }, .has_arg = IPSET_MANDATORY_ARG2, .help = "SETNAME ENTRY\n" - " Test entry in the named set", + " Test entry in the named set", }, { /* des[troy], --destroy, x, -X */ .cmd = IPSET_CMD_DESTROY, .name = { "destroy", "x" }, .has_arg = IPSET_OPTIONAL_ARG, .help = "[SETNAME]\n" - " Destroy a named set or all sets", + " Destroy a named set or all sets", }, { /* l[ist], --list, -L */ .cmd = IPSET_CMD_LIST, .name = { "list", NULL }, .has_arg = IPSET_OPTIONAL_ARG, .help = "[SETNAME]\n" - " List the entries of a named set or all sets", + " List the entries of a named set or all sets", }, { /* s[save], --save, -S */ .cmd = IPSET_CMD_SAVE, .name = { "save", NULL }, .has_arg = IPSET_OPTIONAL_ARG, .help = "[SETNAME]\n" - " Save the named set or all sets to stdout", + " Save the named set or all sets to stdout", }, { /* r[estore], --restore, -R */ .cmd = IPSET_CMD_RESTORE, .name = { "restore", NULL }, .has_arg = IPSET_NO_ARG, .help = "\n" - " Restore a saved state", + " Restore a saved state", }, { /* f[lush], --flush, -F */ .cmd = IPSET_CMD_FLUSH, .name = { "flush", NULL }, .has_arg = IPSET_OPTIONAL_ARG, .help = "[SETNAME]\n" - " Flush a named set or all sets", + " Flush a named set or all sets", }, { /* ren[ame], --rename, e, -E */ .cmd = IPSET_CMD_RENAME, .name = { "rename", "e" }, .has_arg = IPSET_MANDATORY_ARG2, .help = "FROM-SETNAME TO-SETNAME\n" - " Rename two sets", + " Rename two sets", }, { /* sw[ap], --swap, w, -W */ .cmd = IPSET_CMD_SWAP, .name = { "swap", "w" }, .has_arg = IPSET_MANDATORY_ARG2, .help = "FROM-SETNAME TO-SETNAME\n" - " Swap the contect of two existing sets", + " Swap the contect of two existing sets", }, { /* h[elp, --help, -H */ .cmd = IPSET_CMD_HELP, .name = { "help", NULL }, .has_arg = IPSET_OPTIONAL_ARG, .help = "[TYPENAME]\n" - " Print help, and settype specific help", + " Print help, and settype specific help", }, { /* v[ersion], --version, -V */ .cmd = IPSET_CMD_VERSION, .name = { "version", NULL }, .has_arg = IPSET_NO_ARG, .help = "\n" - " Print version information", + " Print version information", }, { /* q[uit] */ .cmd = IPSET_CMD_QUIT, .name = { "quit", NULL }, .has_arg = IPSET_NO_ARG, .help = "\n" - " Quit interactive mode", + " Quit interactive mode", }, { }, }; @@ -149,8 +149,9 @@ ipset_match_cmd(const char *arg, const char * const name[]) return true; else if (len != 1) return false; - else return tolower(arg[0]) == name[0][0] || - (name[1] != NULL && tolower(arg[0]) == name[1][0]); + else + return tolower(arg[0]) == name[0][0] || + (name[1] != NULL && tolower(arg[0]) == name[1][0]); } const struct ipset_envopts ipset_envopts[] = { @@ -158,47 +159,47 @@ const struct ipset_envopts ipset_envopts[] = { .has_arg = IPSET_MANDATORY_ARG, .flag = IPSET_OPT_MAX, .parse = ipset_parse_output, .help = "plain|save|xml\n" - " Specify output mode for listing sets.\n" - " Default value for \"list\" command is mode \"plain\"\n" - " and for \"save\" command is mode \"save\".", + " Specify output mode for listing sets.\n" + " Default value for \"list\" command is mode \"plain\"\n" + " and for \"save\" command is mode \"save\".", }, { .name = { "-s", "-sorted" }, .parse = ipset_envopt_parse, .has_arg = IPSET_NO_ARG, .flag = IPSET_ENV_SORTED, .help = "\n" - " Print elements sorted (if supported by the set type).", + " Print elements sorted (if supported by the set type).", }, { .name = { "-q", "-quiet" }, .parse = ipset_envopt_parse, .has_arg = IPSET_NO_ARG, .flag = IPSET_ENV_QUIET, .help = "\n" - " Suppress any notice or warning message.", + " Suppress any notice or warning message.", }, { .name = { "-r", "-resolve" }, .parse = ipset_envopt_parse, .has_arg = IPSET_NO_ARG, .flag = IPSET_ENV_RESOLVE, .help = "\n" - " Try to resolve IP addresses in the output (slow!)", + " Try to resolve IP addresses in the output (slow!)", }, { .name = { "-!", "-exist" }, .parse = ipset_envopt_parse, .has_arg = IPSET_NO_ARG, .flag = IPSET_ENV_EXIST, .help = "\n" - " Ignore errors when creating already created sets,\n" - " when adding already existing elements\n" + " Ignore errors when creating already created sets,\n" + " when adding already existing elements\n" " or when deleting non-existing elements.", }, { .name = { "-n", "-name" }, .parse = ipset_envopt_parse, .has_arg = IPSET_NO_ARG, .flag = IPSET_ENV_LIST_SETNAME, .help = "\n" - " When listing, list just setnames from kernel.\n", + " When listing, list just setnames from kernel.\n", }, { .name = { "-t", "-terse" }, .parse = ipset_envopt_parse, .has_arg = IPSET_NO_ARG, .flag = IPSET_ENV_LIST_HEADER, .help = "\n" - " When listing, list setnames and set headers\n" + " When listing, list setnames and set headers\n" " from kernel only.", }, { }, @@ -210,13 +211,13 @@ ipset_match_option(const char *arg, const char * const name[]) { assert(arg); assert(name && name[0]); - + /* Skip two leading dashes */ if (arg[0] == '-' && arg[1] == '-') arg++, arg++; - return STREQ(arg, name[0]) - || (name[1] != NULL && STREQ(arg, name[1])); + return STREQ(arg, name[0]) || + (name[1] != NULL && STREQ(arg, name[1])); } /* Strict envopt matching */ @@ -225,13 +226,13 @@ ipset_match_envopt(const char *arg, const char * const name[]) { assert(arg); assert(name && name[0]); - + /* Skip one leading dash */ if (arg[0] == '-' && arg[1] == '-') arg++; - return STREQ(arg, name[0]) - || (name[1] != NULL && STREQ(arg, name[1])); + return STREQ(arg, name[0]) || + (name[1] != NULL && STREQ(arg, name[1])); } /** @@ -247,19 +248,18 @@ void ipset_shift_argv(int *argc, char *argv[], int from) { int i; - + assert(*argc >= from + 1); - for (i = from + 1; i <= *argc; i++) { + for (i = from + 1; i <= *argc; i++) argv[i-1] = argv[i]; - } (*argc)--; return; } /** * ipset_port_usage - prints the usage for the port parameter - * + * * Print the usage for the port parameter to stdout. */ void |