X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fipaccess.c;h=79508ab0eb113e4d72b32562fe4e9725118de058;hb=8c48090e240d68564c79eb29ac9004cc911bb5d0;hp=3323d0a775ce61dfbe6b2b02c37ac93642616d46;hpb=b8ff2afe00e7795f8ea8800fc2ce86eeeff0a9b9;p=libucw.git diff --git a/lib/ipaccess.c b/lib/ipaccess.c index 3323d0a7..79508ab0 100644 --- a/lib/ipaccess.c +++ b/lib/ipaccess.c @@ -9,7 +9,9 @@ #include "lib/lib.h" #include "lib/clists.h" -#include "lib/conf2.h" +#include "lib/conf.h" +#include "lib/getopt.h" +#include "lib/fastbuf.h" #include "lib/ipaccess.h" #include @@ -25,7 +27,8 @@ struct ipaccess_entry { struct addrmask addr; }; -static byte *addrmask_parser(byte *c, void *ptr) +static byte * +addrmask_parser(byte *c, void *ptr) { /* * This is tricky: addrmasks will be compared by memcmp(), so we must ensure @@ -53,9 +56,18 @@ static byte *addrmask_parser(byte *c, void *ptr) return NULL; } +static void +addrmask_dumper(struct fastbuf *fb, void *ptr) +{ + struct addrmask *am = ptr; + bprintf(fb, "%08x/%08x ", am->addr, am->mask); +} + static struct cf_user_type addrmask_type = { .size = sizeof(struct addrmask), - .parser = addrmask_parser + .name = "addrmask", + .parser = addrmask_parser, + .dumper = addrmask_dumper }; struct cf_section ipaccess_cf = { @@ -92,7 +104,7 @@ static struct cf_section test_cf = { int main(int argc, char **argv) { cf_declare_section("T", &test_cf, 0); - if (cf_get_opt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) != -1) + if (cf_getopt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) != -1) die("Invalid arguments"); byte buf[256];