HP-UX Reference (11i v2 07/12) - 3 Library Functions A-M (vol 6)
g
getnetconfig(3N) getnetconfig(3N)
NAME
getnetconfig(), setnetconfig(), endnetconfig(), getnetconfigent(), freenetconfigent(), nc_perror(), nc_sperror()
- get network configuration database entry
SYNOPSIS
#include <netconfig.h>
struct netconfig *getnetconfig(void *handlep );
void *setnetconfig(void);
int endnetconfig(void *handlep );
struct netconfig *getnetconfigent(const char *netid );
void freenetconfigent(struct netconfig *netconfigp );
void nc_perror(const char *msg );
char *nc_sperror(void);
MULTITHREAD USAGE
Thread Safe: Yes
Cancel Safe: Yes
Fork Safe: No
Async-cancel Safe: No
Async-signal Safe: No
These functions can be called safely in a multithreaded environment. They may be cancellation points in
that they call functions that are cancel points.
In a multithreaded environment, these functions are not safe to be called by a child process after
fork()
and before exec(). These functions should not be called by a multithreaded application that support
asynchronous cancellation or asynchronous signals.
DESCRIPTION
The library routines described on this page are part of the Network Selection component. They provide the
application access to the system network configuration database, /etc/netconfig
. In addition to the
routines for accessing the
netconfig database, Network Selection includes the environment variable
NETPATH (see environ(5)) and the NETPATH access routines described in getnetpath(3N).
getnetconfig() returns a pointer to the current entry in the
netconfig database, formatted as a
struct netconfig. Successive calls will return successive netconfig entries in the netconfig
database. getnetconfig() can be used to search the entire
netconfig file. getnetconfig()
returns NULL at the end of the file. handlep is the handle obtained through setnetconfig()
.
A call to
setnetconfig()
has the effect of ‘‘binding’’ to or ‘‘rewinding’’ the
netconfig database.
setnetconfig() must be called before the first call to
getnetconfig() and may be called at any
other time.
setnetconfig()
need not be called before a call to getnetconfigent().
setnetconfig() returns a unique handle to be used by
getnetconfig().
endnetconfig() should be called when processing is complete to release resources for reuse. handlep
is the handle obtained through setnetconfig(). Programmers should be aware, however, that the last
call to endnetconfig() frees all memory allocated by getnetconfig()
for the struct netcon-
fig
data structure. endnetconfig() may not be called before setnetconfig()
.
getnetconfigent() returns a pointer to the struct netconfig structure corresponding to netid.It
returns NULL if netid is invalid (that is, does not name an entry in the netconfig database).
freenetconfigent() frees the netconfig structure pointed to by netconfigp (previously returned
by
getnetconfigent()).
nc_perror() prints a message to the standard error indicating why any of the above routines failed.
The message is prepended with the string msg and a colon. A NEWLINE is appended at the end of the
message.
nc_sperror() is similar to nc_perror() but instead of sending the message to the standard error,
will return a pointer to a string that contains the error message.
HP-UX 11i Version 2: December 2007 Update − 1 − Hewlett-Packard Company 507