'\"macro stdmacro
.if n .pH g3n.getnetconfig @(#)getnetconfig	40.14 of 12/1/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} getnetconfig 3N "Networking Services Architecture" "\&"
.if \nX=1 .ds x} getnetconfig 3N "Networking Services Architecture"
.if \nX=2 .ds x} getnetconfig 3N "" "\&"
.if \nX=3 .ds x} getnetconfig "" "" "\&"
.TH \*(x}
.SH "NAME"
\f4getnetconfig\f1 \- get network configuration database entry
.SH "SYNOPSIS"
.nf
\f4#include <netconfig.h>
.sp .5
void *
setnetconfig()
.sp .5
struct netconfig *
getnetconfig(handlep)
void * handlep
.sp .5
int
endnetconfig(handlep)
void * handlep
.sp .5
struct netconfig *
getnetconfigent(netid)
        char * netid ;
.sp .5
int
freenetconfigent(netconfigp)
	struct netconfig * netconfigp ;\f1
.fi
.P
.\"[\(rh  Should \f4NCONF_HANDLE\fP be defined here? \(lh]
.SH "DESCRIPTION"
The five library routines described on this page are
part of the \s-1UNIX\s+1 System V
Network Selection component.
They provide application access to
the system network configuration database, \f4/etc/netconfig\f1.
In addition to the \f4netconfig\f1 database and the routines for
accessing it, Network Selection includes the environment variable
\f4NETPATH\f1
(see \f4environ\f1(5))
and the 
\f4NETPATH\f1
access routines described in \f4getnetpath\f1(3N).
.P
A call to \f4setnetconfig()\f1 has the effect of ``binding'' or
``rewinding'' the \f4netconfig\f1 database.
\f4setnetconfig()\f1
must be called before the first call to \f4getnetconfig()\f1
and may be called at any
other time.
\f4setnetconfig()\f1 need \f2not\f1 be called before a call to 
\f4getnetconfigent()\f1.
\f4setnetconfig()\f1
returns a unique handle to be used by \f4getnetconfig()\fP.
.P
When first called, \f4getnetconfig()\f1 returns a pointer to the
current entry in the \f4netconfig\f1 database, formatted as a
\f(CWstruct netconfig\f1.
\f4getnetconfig()\f1 can thus be
used to search the entire \f4netconfig\f1 file.
\f4getnetconfig()\f1 returns
\s-1NULL\s+1 at end of file.
.P
\f4endnetconfig()\f1 should be called
when processing is complete to release resources for reuse.
Programmers should be aware, however, that 
the last call to \f4endnetconfig()\fP
frees all memory allocated by \f4getnetconfig()\fP for the
\f4struct netconfig\fP data structure.
\f4endnetconfig()\f1 may not be called before
\f4setnetconfig()\f1.
\f4endnetconfig()\f1 returns \f40\f1 on success and \f4\-1\f1 on failure
(e.g., if \f4setnetconfig()\f1 was not called previously).
.P
\f4getnetconfigent(\f2netid\f4)\f1 returns a pointer to the \f(CWstruct
netconfig\f1 structure corresponding
to \f2netid\f1.
It returns \s-1NULL\s+1 if \f2netid\f1 is invalid
(i.e., does not name an entry in the \f4netconfig\f1 database).
It returns
\s-1NULL\s+1 and sets \f2errno\f1 in case of failure (e.g., if
\f4setnetconfig()\f1 was not called previously).
.P
\f4freenetconfigent(\f2netconfigp\f4)\f1 frees the 
netconfig structure pointed to by \f2netconfigp\f1
(previously returned by \f4getnetconfigent()\f1).
.SH "SEE ALSO"
\f4netconfig\fP(4), \f4getnetpath\fP(3N), \f4environ\fP(5)
.br
\f2Network Programmer's Guide\f1
.br
\f2System Administrator's Guide\f1
