Fix markup. Fix backslashes to surive roff.
[netbsd-mini2440.git] / dist / ipf / lib / printhash.c
blobea3b150e42b6c489b5cbfb89f03aa90b8fcd2351
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2002-2005 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
9 #include "ipf.h"
11 #define PRINTF (void)printf
12 #define FPRINTF (void)fprintf
15 iphtable_t *printhash(hp, copyfunc, name, opts)
16 iphtable_t *hp;
17 copyfunc_t copyfunc;
18 char *name;
19 int opts;
21 iphtent_t *ipep, **table;
22 iphtable_t iph;
23 int printed;
24 size_t sz;
26 if ((*copyfunc)((char *)hp, (char *)&iph, sizeof(iph)))
27 return NULL;
29 if ((name != NULL) && strncmp(name, iph.iph_name, FR_GROUPLEN))
30 return iph.iph_next;
32 printhashdata(hp, opts);
34 if ((hp->iph_flags & IPHASH_DELETE) != 0)
35 PRINTF("# ");
37 if ((opts & OPT_DEBUG) == 0)
38 PRINTF("\t{");
40 sz = iph.iph_size * sizeof(*table);
41 table = malloc(sz);
42 if ((*copyfunc)((char *)iph.iph_table, (char *)table, sz))
43 return NULL;
45 for (printed = 0, ipep = iph.iph_list; ipep != NULL; ) {
46 ipep = printhashnode(&iph, ipep, copyfunc, opts);
47 printed++;
49 if (printed == 0)
50 putchar(';');
52 free(table);
54 if ((opts & OPT_DEBUG) == 0)
55 PRINTF(" };\n");
57 return iph.iph_next;