2007-04-15 00:17:19 +04:00
|
|
|
/* $NetBSD: printpool.c,v 1.1.1.3 2007/04/14 20:17:31 martin Exp $ */
|
2004-03-28 12:55:20 +04:00
|
|
|
|
|
|
|
/*
|
2007-04-15 00:17:19 +04:00
|
|
|
* Copyright (C) 2002-2005 by Darren Reed.
|
2004-03-28 12:55:20 +04:00
|
|
|
*
|
|
|
|
* See the IPFILTER.LICENCE file for details on licencing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ipf.h"
|
|
|
|
|
|
|
|
#define PRINTF (void)printf
|
|
|
|
#define FPRINTF (void)fprintf
|
|
|
|
|
2005-02-20 00:26:02 +03:00
|
|
|
ip_pool_t *printpool(pp, copyfunc, name, opts)
|
2004-03-28 12:55:20 +04:00
|
|
|
ip_pool_t *pp;
|
|
|
|
copyfunc_t copyfunc;
|
2005-02-20 00:26:02 +03:00
|
|
|
char *name;
|
2004-03-28 12:55:20 +04:00
|
|
|
int opts;
|
|
|
|
{
|
|
|
|
ip_pool_node_t *ipnp, *ipnpn, ipn;
|
|
|
|
ip_pool_t ipp;
|
|
|
|
|
|
|
|
if ((*copyfunc)(pp, &ipp, sizeof(ipp)))
|
|
|
|
return NULL;
|
|
|
|
|
2005-02-20 00:26:02 +03:00
|
|
|
if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN))
|
|
|
|
return ipp.ipo_next;
|
|
|
|
|
2007-04-15 00:17:19 +04:00
|
|
|
printpooldata(&ipp, opts);
|
2004-03-28 12:55:20 +04:00
|
|
|
|
2007-04-15 00:17:19 +04:00
|
|
|
if ((ipp.ipo_flags & IPOOL_DELETE) != 0)
|
|
|
|
PRINTF("# ");
|
|
|
|
if ((opts & OPT_DEBUG) == 0)
|
2004-03-28 12:55:20 +04:00
|
|
|
PRINTF("\t{");
|
|
|
|
|
|
|
|
ipnpn = ipp.ipo_list;
|
|
|
|
ipp.ipo_list = NULL;
|
|
|
|
while (ipnpn != NULL) {
|
|
|
|
ipnp = (ip_pool_node_t *)malloc(sizeof(*ipnp));
|
|
|
|
(*copyfunc)(ipnpn, ipnp, sizeof(ipn));
|
|
|
|
ipnpn = ipnp->ipn_next;
|
|
|
|
ipnp->ipn_next = ipp.ipo_list;
|
|
|
|
ipp.ipo_list = ipnp;
|
|
|
|
}
|
|
|
|
|
2005-02-20 00:26:02 +03:00
|
|
|
if (ipp.ipo_list == NULL) {
|
|
|
|
putchar(';');
|
|
|
|
} else {
|
|
|
|
for (ipnp = ipp.ipo_list; ipnp != NULL; ) {
|
|
|
|
ipnp = printpoolnode(ipnp, opts);
|
2004-03-28 12:55:20 +04:00
|
|
|
|
2005-02-20 00:26:02 +03:00
|
|
|
if ((opts & OPT_DEBUG) == 0) {
|
|
|
|
putchar(';');
|
|
|
|
}
|
2004-03-28 12:55:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((opts & OPT_DEBUG) == 0)
|
|
|
|
PRINTF(" };\n");
|
|
|
|
|
|
|
|
return ipp.ipo_next;
|
|
|
|
}
|