A call to Fn setnetconfig has the effect of ``binding'' to or ``rewinding'' the netconfig database. The Fn setnetconfig function must be called before the first call to Fn getnetconfig and may be called at any other time. The Fn setnetconfig function need not be called before a call to Fn getnetconfigent . The Fn setnetconfig function returns a unique handle to be used by Fn getnetconfig .
The Fn endnetconfig function should be called when processing is complete to release resources for reuse. The Fa handlep argument is the handle obtained through Fn setnetconfig . Programmers should be aware, however, that the last call to Fn endnetconfig frees all memory allocated by Fn getnetconfig for the Ft struct netconfig data structure. The Fn endnetconfig function may not be called before Fn setnetconfig .
The Fn getnetconfigent function returns a pointer to the netconfig structure corresponding to Fa netid . It returns NULL if Fa netid is invalid (that is, does not name an entry in the netconfig database).
The Fn freenetconfigent function frees the netconfig structure pointed to by Fa netconfigp (previously returned by Fn getnetconfigent ) .
The Fn 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 Fa msg and a colon. A newline character is appended at the end of the message.
The Fn nc_sperror function is similar to Fn 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 Fn nc_perror and Fn nc_sperror functions can also be used with the NETPATH access routines defined in getnetpath(3).
The Fn getnetconfig function returns a pointer to the current entry in the netconfig database, formatted as a Ft struct netconfig . The Fn getnetconfig function returns NULL at the end of the file, or upon failure.
The Fn endnetconfig function returns 0 on success and -1 on failure (for example, if Fn setnetconfig was not called previously).
On success, Fn getnetconfigent returns a pointer to the Ft struct netconfig structure corresponding to Fa netid ; otherwise it returns NULL
The Fn 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.