The Fn getnetpath function returns a pointer to the netconfig database entry corresponding to the first valid NETPATH component. The netconfig entry is formatted as a Ft struct netconfig . On each subsequent call, Fn getnetpath returns a pointer to the netconfig entry that corresponds to the next valid NETPATH component. The Fn getnetpath function can thus be used to search the netconfig database for all networks included in the NETPATH variable. When NETPATH has been exhausted, Fn getnetpath returns NULL
A call to Fn setnetpath ``binds'' to or ``rewinds'' NETPATH The Fn setnetpath function must be called before the first call to Fn getnetpath and may be called at any other time. It returns a handle that is used by Fn getnetpath .
The Fn 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, Fn 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 Fn endnetpath function may be called to ``unbind'' from NETPATH when processing is complete, releasing resources for reuse. Programmers should be aware, however, that Fn endnetpath frees all memory allocated by Fn getnetpath for the struct netconfig data structure.
The Fn endnetpath function returns 0 on success and -1 on failure (for example, if Fn setnetpath was not called previously). The Fn nc_perror or Fn nc_sperror function can be used to print out the reason for failure. See getnetconfig(3).