]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
libxt_geoip: reorder option parsing code
authorJan Engelhardt <jengelh@medozas.de>
Sun, 24 Aug 2008 16:34:31 +0000 (12:34 -0400)
committerJan Engelhardt <jengelh@medozas.de>
Sun, 24 Aug 2008 16:34:31 +0000 (12:34 -0400)
extensions/libxt_geoip.c

index 85f5036bea61f6ec03c523157f22423a88ba6137..2f83e53e67da2ee1d4e3c273794a3e7d0b3a6000 100644 (file)
@@ -173,35 +173,37 @@ static int geoip_parse(int c, char **argv, int invert, unsigned int *flags,
 {
        struct xt_geoip_match_info *info = (void *)(*match)->data;
 
-       switch(c) {
-               case '1':
-               // Ensure that XT_GEOIP_SRC *OR* XT_GEOIP_DST haven't been used yet.
+       switch (c) {
+       case '1':
                if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
                        exit_error(PARAMETER_PROBLEM,
-                               "geoip: only use --source-country *OR* --destination-country once!");
+                               "geoip: Only exactly one of --source-country "
+                               "or --destination-country must be specified!");
 
                *flags |= XT_GEOIP_SRC;
-               break;
+               if (invert)
+                       *flags |= XT_GEOIP_INV;
+
+               info->count = parse_geoip_cc(argv[optind-1], info->cc, info->mem);
+               info->flags = *flags;
+               return true;
 
        case '2':
-               // Ensure that XT_GEOIP_SRC *OR* XT_GEOIP_DST haven't been used yet.
                if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
                        exit_error(PARAMETER_PROBLEM,
-                               "geoip: only use --source-country *OR* --destination-country once!");
+                               "geoip: Only exactly one of --source-country "
+                               "or --destination-country must be specified!");
 
                *flags |= XT_GEOIP_DST;
-               break;
+               if (invert)
+                       *flags |= XT_GEOIP_INV;
 
-       default:
-               return 0;
+               info->count = parse_geoip_cc(argv[optind-1], info->cc, info->mem);
+               info->flags = *flags;
+               return true;
        }
 
-       if (invert)
-               *flags |= XT_GEOIP_INV;
-
-       info->count = parse_geoip_cc(argv[optind-1], info->cc, info->mem);
-       info->flags = *flags;
-       return 1;
+       return false;
 }
 
 static void