]> mj.ucw.cz Git - libucw.git/commitdiff
Use CF_LOOKUP.
authorMartin Mares <mj@ucw.cz>
Tue, 25 Apr 2006 21:53:15 +0000 (23:53 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 25 Apr 2006 21:53:15 +0000 (23:53 +0200)
lib/ipaccess.c

index 2116f71d9b6193815a947c6653b1a8440601e437..f1637c8554587a4b2b86af046ddfcc366773d873 100644 (file)
 #include "lib/conf2.h"
 #include "lib/ipaccess.h"
 
-#undef ipaccess_check                  /* FIXME */
-
 #include <string.h>
 
 struct ipaccess_entry {
   cnode n;
-  uns allow;
+  int allow;
   u32 addr, mask;
 };
 
@@ -48,23 +46,10 @@ ipaccess_cf_ip(uns n UNUSED, byte **pars, struct ipaccess_entry *a)
   return NULL;
 }
 
-static byte *
-ipaccess_cf_mode(uns n UNUSED, byte **pars, struct ipaccess_entry *a)
-{
-  CF_JOURNAL_VAR(a->allow);
-  if (!strcasecmp(pars[0], "allow"))
-    a->allow = 1;
-  else if (!strcasecmp(pars[0], "deny"))
-    a->allow = 0;
-  else
-    return "Either `allow' or `deny' expected";
-  return NULL;
-}
-
 struct cf_section ipaccess_cf = {
   CF_TYPE(struct ipaccess_entry),
   CF_ITEMS {
-    CF_PARSER("Mode", NULL, ipaccess_cf_mode, 1),
+    CF_LOOKUP("Mode", PTR_TO(struct ipaccess_entry, allow), ((char*[]) { "deny", "allow" })),
     CF_PARSER("IP", NULL, ipaccess_cf_ip, 1),
     CF_END
   }