# getnetpath(3) - man - phpMan

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

## NAME
     **getnetpath**, **setnetpath**, **endnetpath** — get _/etc/netconfig_ entry corresponding to NETPATH compo‐
     nent

## SYNOPSIS
### #include <netconfig.h>

     _struct_ _netconfig_ _*_
     **getnetpath**(_void_ _*handlep_);

     _void_ _*_
     **setnetpath**(_void_);

     _int_
     **endnetpath**(_void_ _*handlep_);

## DESCRIPTION
     The routines described in this page provide the application access to the system network con‐
     figuration database, _/etc/netconfig_, as it is “filtered” by the NETPATH environment variable
     (see [environ(7)](https://www.chedong.com/phpMan.php/man/environ/7/markdown)).  See [getnetconfig(3)](https://www.chedong.com/phpMan.php/man/getnetconfig/3/markdown) for other routines that also access the network configu‐
     ration database directly.  The NETPATH variable is a list of colon-separated network identi‐
     fiers.

     The **getnetpath**() function returns a pointer to the netconfig database entry corresponding to
     the first valid NETPATH component.  The netconfig entry is formatted as a _struct_ _netconfig_.  On
     each subsequent call, **getnetpath**() returns a pointer to the netconfig entry that corresponds to
     the next valid NETPATH component.  The **getnetpath**() function can thus be used to search the
     netconfig database for all networks included in the NETPATH variable.  When NETPATH has been
     exhausted, **getnetpath**() returns NULL.

     A call to **setnetpath**() “binds” to or “rewinds” NETPATH.  The **setnetpath**() function must be
     called before the first call to **getnetpath**() and may be called at any other time.  It returns a
     handle that is used by **getnetpath**().

     The **getnetpath**() function silently ignores invalid NETPATH components.  A NETPATH component is
     invalid if there is no corresponding entry in the netconfig database.

     If the NETPATH variable is unset, **getnetpath**() behaves as if NETPATH were set to the sequence
     of “default” or “visible” networks in the netconfig database, in the order in which they are
     listed.

     The **endnetpath**() function may be called to “unbind” from NETPATH when processing is complete,
     releasing resources for reuse.  Programmers should be aware, however, that **endnetpath**() frees
     all memory allocated by **getnetpath**() for the struct netconfig data structure.

## RETURN VALUES
     The **setnetpath**() function returns a handle that is used by **getnetpath**().  In case of an error,
     **setnetpath**() returns NULL.

     The **endnetpath**() function returns 0 on success and -1 on failure (for example, if **setnetpath**()
     was not called previously).  The **nc**___**perror**() or **nc**___**sperror**() function can be used to print out
     the reason for failure.  See [getnetconfig(3)](https://www.chedong.com/phpMan.php/man/getnetconfig/3/markdown).

     When first called, **getnetpath**() returns a pointer to the netconfig database entry corresponding
     to the first valid NETPATH component.  When NETPATH has been exhausted, **getnetpath**() returns
     NULL.

## AVAILABILITY
     These functions are part of libtirpc.

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

BSD                             April 22, 2000                             BSD
