cfg_read(3)

NAME
cfg_setpfile(), cfg_read(), cfg_append(), cfg_get(), cfg_free() - read and process configuration via Cfg type chains.

SYNOPSIS
#include "fwfunc.h"
#include "firewall.h"
int	cfg_setpfile(char *s)
Cfg*	cfg_read(char *app)
Cfg*	cfg_append(char *cfile,Cfg *chainstart,char *app)
Cfg*	cfg_get(char *fac,Cfg *cp)
void	cfg_free(Cfg *cp)

DESCRIPTION
Cfg function group deals with Cfg type chains, consisting of following structures:

typedef struct  cfgrec  {
	int     flags;          /* see below */
	int     ln;             /* line# in config file */
	char    *op;            /* facility name */
	int     argc;           /* number of arguments */
	char    **argv;         /* vector */
	struct  cfgrec  *next;
	} Cfg;
flags are:
#define PERM_ALLOW      01
#define PERM_DENY       02
the chain ends with next = (Cfg *) 0.
The cfg_setpfile function overrides compile-time default path for netperm-table file used by cfg_read and sets it to s.

The cfg_read function reads netperm-table entries (see appropriate manual page) matching application app into newly-allocated Cfg chain.

The cfg_append function appends netperm-table entries from file cfile matching application app to existing chain chainstart. If chainstart is NULL, a new chain is created.

The cfg_get function selects an entry matching tag fac from chain cp. If cp is NULL, next matching entry is selected.

The cfg_free function destroys chain cp and deallocates memory used by it.

RETURN VALUES
If a fatal error occurs, (Cfg*) -1 is returned by cfg_read function, and unchanged original chain by cfg_append.

cfg_setpfile returns 0 on success and 1 if file path is invalid.

cfg_get returns next matching entry on success and NULL if there are no more matching entries.

SEE ALSO
netperm-table(5)

HISTORY
cfg_setpfile,cfg_read,cfg_get and cfg_free functions are present in fwtk since v1

cfg_append first appeared in OpenFWTK project.