#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 <string.h>
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
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 = {
CF_TYPE(struct ipaccess_entry),
CF_ITEMS {
- CF_LOOKUP("Mode", PTR_TO(struct ipaccess_entry, allow), ((char*[]) { "deny", "allow", NULL })),
+ CF_LOOKUP("Mode", PTR_TO(struct ipaccess_entry, allow), ((byte*[]) { "deny", "allow", NULL })),
CF_USER("IP", PTR_TO(struct ipaccess_entry, addr), &addrmask_type),
CF_END
}
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];