# getnetconfig(3t) - man - phpman

[GETNETCONFIG(3)](https://www.chedong.com/phpMan.php/man/GETNETCONFIG/3/markdown)          BSD Library Functions Manual          [GETNETCONFIG(3)](https://www.chedong.com/phpMan.php/man/GETNETCONFIG/3/markdown)

## 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_);

## DESCRIPTION
     The library routines described on this page provide the application access to the system net‐
     work configuration database, _/etc/netconfig_.  The **getnetconfig**() function 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.  The **getnetconfig**() func‐
     tion can be used to search the entire netconfig file.  The **getnetconfig**() function returns NULL
     at the end of the file.  The _handlep_ argument is the handle obtained through **setnetconfig**().

     A call to **setnetconfig**() has the effect of “binding” to or “rewinding” the netconfig database.
     The **setnetconfig**() function must be called before the first call to **getnetconfig**() and may be
     called at any other time.  The **setnetconfig**() function need not be called before a call to
     **getnetconfigent**().  The **setnetconfig**() function returns a unique handle to be used by
     **getnetconfig**().

     The **endnetconfig**() function should be called when processing is complete to release resources
     for reuse.  The _handlep_ argument 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_ _netconfig_ data structure.  The **endnetconfig**() function may not be
     called before **setnetconfig**().

     The **getnetconfigent**() function returns a pointer to the netconfig structure corresponding to
     _netid_.  It returns NULL if _netid_ is invalid (that is, does not name an entry in the netconfig
     database).

     The **freenetconfigent**() function frees the netconfig structure pointed to by _netconfigp_ (previ‐
     ously returned by **getnetconfigent**()).

     The **nc**___**perror**() function 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 charac‐
     ter is appended at the end of the message.

     The **nc**___**sperror**() function 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.

     The **nc**___**perror**() and **nc**___**sperror**() functions can also be used with the NETPATH access routines
     defined in [getnetpath(3)](https://www.chedong.com/phpMan.php/man/getnetpath/3/markdown).

## RETURN VALUES
     The **setnetconfig**() function returns a unique handle to be used by **getnetconfig**().  In the case
     of an error, **setnetconfig**() returns NULL and **nc**___**perror**() or **nc**___**sperror**() can be used to print
     the reason for failure.

     The **getnetconfig**() function returns a pointer to the current entry in the netconfig database,
     formatted as a _struct_ _netconfig_.  The **getnetconfig**() function returns NULL at the end of the
     file, or upon failure.

     The **endnetconfig**() function returns 0 on success and -1 on failure (for example, if
     **setnetconfig**() was not called previously).

     On success, **getnetconfigent**() returns a pointer to the _struct_ _netconfig_ structure corresponding
     to _netid_; otherwise it returns NULL.

     The **nc**___**sperror**() function returns a pointer to a buffer which contains the error message
     string.  This buffer is overwritten on each call.  In multithreaded applications, this buffer
     is implemented as thread-specific data.

## FILES
     /etc/netconfig

## AVAILABILITY
     These functions are part of libtirpc.

## SEE ALSO
     [getnetpath(3)](https://www.chedong.com/phpMan.php/man/getnetpath/3/markdown), [netconfig(5)](https://www.chedong.com/phpMan.php/man/netconfig/5/markdown)

BSD                             April 22, 2000                             BSD
