|
|
#include <netconfig.h>void *setnetconfig(void);
struct netconfig *getnetconfig(void *handlep);
int endnetconfig(void *handlep);
struct netconfig *getnetconfigent(char *netid);
void freenetconfigent(struct netconfig *netconfigp);
void nc_perror(char *msg);
char *nc_sperror(void);
A call to setnetconfig has the effect of ``binding'' 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. In the case of an error, setnetconfig returns NULL.
When first called, getnetconfig returns a pointer to the current entry in the netconfig database, formatted as a netconfig structure. getnetconfig can thus be used to search the entire netconfig database. getnetconfig returns NULL at end of file.
endnetconfig should be called when processing is complete to release resources for reuse. Programmers should be aware, however, that the last call to endnetconfig frees all memory allocated by getnetconfig for the struct netconfig data structure. endnetconfig may not be called before setnetconfig. endnetconfig returns 0 on success and -1 on failure (for example, if setnetconfig was not called previously).
getnetconfigent 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).
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 string msg and a colon. A newline is appended to the end of the message.
nc_sperror is similar to nc_perror but instead of sending the message to the standard error indicating why the network selection routines failed, it returns a pointer to the message.
Functions that provide successive entries in files on successive calls must be called from a single thread.