HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
g
getnetent(3N) getnetent(3N)
In a multithreaded application, getnetent() , getentbyaddr(), and getentbyname() use
thread-specific storage that is re-used in each call. The return value, struct netent, should be unique
for each thread and should be saved, if desired, before the thread makes the next getnet*() call.
For enumeration in multithreaded applications, the position within the enumeration is a process-wide pro-
perty shared by all threads. setnetent() may be used in a multithreaded application, but resets the
enumeration position for all threads. If multiple threads interleave calls to getnetent(), the threads
will enumerate disjoint subsets of the network database.
Name Service Switch-Based Operation
The library routines getnetbyname(), getnetbyaddr(), and getnetent() internally call the
name service switch to access the "networks" database lookup policy configured in the
/etc/nsswitch.conf file (see nsswitch.conf(4)). The lookup policy defines the order and the criteria
of the supported name services used to resolve network names and addresses.
RETURN VALUE
getnetent() , getnetbyname(), and getnetbyaddr() return a null pointer (0) on EOF or when
they are unable to open /etc/networks. getnetbyaddr() also returns a null pointer if its type
parameter is invalid.
EXAMPLE
The following code excerpt counts the number of network entries:
int count = 0;
(void) setnetent(0);
while (netbuf=getnetent() != NULL)
count++;
(void) endnetent();
OBSOLESCENT INTERFACES
int getnetent_r(struct netent *result, struct netent_data *buffer);
int getnetbyname_r(
const char *name,
struct netent *result,
struct netent_data *buffer);
int getnetbyaddr_r(
int net,
int type,
struct netent *result,
struct netent_data *buffer);
int setnetent_r(int stayopen, struct netent_data *buffer);
int endnetent_r(struct netent_data *buffer);
The above reentrant interfaces have been moved from libc to libd4r. They are included to support
existing applicationsand may be removed in the future release. New multithreaded applications should not
use these APIs.
The reentrant interfaces function the same as the regular interfaces (those without the -r suffix.) How-
ever,
getnetent_r(), getnetbyname_r()
, and getnetbyaddr_r() expect to be passed the
address of a struct netent and will store the address of the result at the supplied parameter. An additional
parameter, the address of struct netent_data, which is defined in the file
<netdb.h>
, cannot be a NULL
pointer.
getnetent_r(), getnetbyname_r(), getnetbyaddr_r()
, setnetent_r(), and
endnetent_t() return a 1 if the operation is unsuccessful. A 0 is returned otherwise.
WARNINGS
Programs that use the interfaces described in this manpage cannot be linked statically because the imple-
mentations of these functions employ dynamic loading and linking of shared objects at run time.
AUTHOR
getnetent() was developed by Sun Microsystems Inc.
Section 3316 2 HP-UX Release 11i: December 2000
___
___