getnetent.3n (2010 09)

g
getnetent(3N) getnetent(3N)
/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.
EXAMPLES
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 applications and 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 addi-
tional 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.
FILES
/etc/networks
SEE ALSO
ypserv(1M), networks(4), ypfiles(4), nsswitch.conf(4), thread_safety(5).
STANDARDS CONFORMANCE
getnetent(): XPG4
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010