MAN page from Old RedHat 5.X bind-4.9.6-11.i386.rpm
getnetent
Section: C Library Functions (3)
Index NAME
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent - get networksentry
SYNTAX
#include <netdb.h>struct netent *getnetent()struct netent *getnetbyname(name)char *name;struct netent *getnetbyaddr(net, type)unsigned long net; int type;void setnetent(stayopen)int stayopen;void endnetent()
DESCRIPTION
The
getnetent,
getnetbyname,and
getnetbyaddrsubroutineseach return a pointer to an object with thefollowing structurecontaining the broken-outfields of a line in the
networks database.
struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net number type */ long n_net; /* net number */};
The members of this structure are:
- n_name
- The official name of the network.
- n_aliases
- A zero terminated list of alternate names for the network.
- n_addrtype
- The type of the network number returned: AF_INET.
- n_net
- The network number. Network numbers are returned in machine byteorder.
If thestayopenflag on a setnetentsubroutine is NULL, thenetworksdatabase is opened. Otherwise thesetnetenthas the effect of rewinding the networks database.Theendnetentmay be called toclose the networks database when processing is complete.
Thegetnetentsubroutine simply reads the nextline whilegetnetbynameandgetnetbyaddrsearch until a matchingnameornetnumber is found(or until EOF is encountered). The type must be AF_INET.Thegetnetentsubroutine keeps a pointer in the database, allowingsuccessive calls to be used to search the entire file.
A call tosetnetentmust be made before awhileloop usinggetnetentin order to perform initialization and anendnetentmust be used after the loop. Bothgetnetbynameandgetnetbyaddrmake calls tosetnetentandendnetent .
FILES
/etc/networks DIAGNOSTICS
Null pointer (0) returned on EOF or error.
SEE ALSO
networks(5)RFC 1101
HISTORY
The getnetent(), getnetbyaddr(), getnetbyname(), setnetent(), andendnetent() functions appeared in 4.2BSD.
BUGS
The data space used by these functions is static; if future use requires thedata, it should be copied before any subsequent calls to these functionsoverwrite it. Only Internet network numbers are currently understood.Expecting network numbers to fit in no more than 32 bits is probably naive.
Index
- NAME
- SYNTAX
- DESCRIPTION
- FILES
- DIAGNOSTICS
- SEE ALSO
- HISTORY
- BUGS
This document was created byman2html,using the manual pages.