.\" openfwtk project: cfg_read.3 1-Nov-2000 .TH cfg_read 3 .SH NAME cfg_setpfile(), cfg_read(), cfg_append(), cfg_get(), cfg_free() \- read and process configuration via Cfg type chains. .SH SYNOPSIS .nf #include "fwfunc.h" #include "firewall.h" int \fBcfg_setpfile\fP(char *s) Cfg* \fBcfg_read\fP(char *app) Cfg* \fBcfg_append\fP(char *cfile,Cfg *chainstart,char *app) Cfg* \fBcfg_get\fP(char *fac,Cfg *cp) void \fBcfg_free\fP(Cfg *cp) .fi .SH DESCRIPTION Cfg function group deals with Cfg type chains, consisting of following structures: .sp .nf 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. .fi The \fIcfg_setpfile\fP function overrides compile-time default path for netperm-table file used by \fIcfg_read\fP and sets it to \fIs\fP. .PP The \fIcfg_read\fP function reads netperm-table entries (see appropriate manual page) matching application \fIapp\fP into newly-allocated Cfg chain. .PP The \fIcfg_append\fP function appends netperm-table entries from file \fIcfile\fP matching application \fIapp\fP to existing chain \fIchainstart\fP. If \fIchainstart\fP is NULL, a new chain is created. .PP The \fIcfg_get\fP function selects an entry matching tag \fIfac\fP from chain \fIcp\fP. If \fIcp\fP is NULL, next matching entry is selected. .PP The \fIcfg_free\fP function destroys chain \fIcp\fP and deallocates memory used by it. .SH RETURN VALUES If a fatal error occurs, (Cfg*) -1 is returned by \fIcfg_read\fP function, and unchanged original chain by \fIcfg_append\fP. .PP \fIcfg_setpfile\fP returns 0 on success and 1 if file path is invalid. .PP \fIcfg_get\fP returns next matching entry on success and NULL if there are no more matching entries. .SH SEE ALSO netperm-table(5) .SH HISTORY cfg_setpfile,cfg_read,cfg_get and cfg_free functions are present in fwtk since v1 .PP cfg_append first appeared in OpenFWTK project.