📄 getnetent.3
字号:
.\" $Id: getnetent.3,v 4.11 1993/09/08 18:23:56 vixie Exp $.TH getnetent 3.SH NAMEgetnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get networksentry.SH SYNTAX.nf.B #include <netdb.h>.PP.B struct netent *getnetent().PP.B struct netent *getnetbyname(\fIname\fP).B char *\fIname\fP;.PP.B struct netent *getnetbyaddr(\fInet\fP, \fItype\fP).B long \fInet\fP; int \fItype\fP;.PP.B void setnetent(\fIstayopen\fP).B int \fIstayopen\fP;.PP.B void endnetent().fi.SH DESCRIPTIONThe.IR getnetent ,.IR getnetbyname ,and.I getnetbyaddrsubroutineseach return a pointer to an object with thefollowing structurecontaining the broken-outfields of a line in the .I networks database..RS.PP.nfstruct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net number type */ long n_net; /* net number */};.ft R.ad.fi.RE.PPThe members of this structure are:.TP \w'n_addrtype'u+2nn_nameThe official name of the network..TP \w'n_addrtype'u+2nn_aliasesA zero terminated list of alternate names for the network..TP \w'n_addrtype'u+2nn_addrtypeThe type of the network number returned: AF_INET..TP \w'n_addrtype'u+2nn_netThe network number. Network numbers are returned in machine byteorder..PPIf the.I stayopenflag on a .I setnetentsubroutine is NULL, the.I networksdatabase is opened. Otherwise the.I setnetenthas the effect of rewinding the .I networks database.The.I endnetentmay be called toclose the .I networks database when processing is complete..PPThe.I getnetentsubroutine simply reads the nextline while.I getnetbynameand.I getnetbyaddrsearch until a matching.I nameor.I netnumber is found(or until EOF is encountered). The \fItype\fP must be AF_INET.The.I getnetentsubroutine keeps a pointer in the database, allowingsuccessive calls to be used to search the entire file..PPA call to.I setnetentmust be made before a.I whileloop using.I getnetentin order to perform initialization and an.I endnetentmust be used after the loop. Both.I getnetbynameand.I getnetbyaddrmake calls to.I setnetentand.I endnetent ..SH FILES.I /etc/networks.SH DIAGNOSTICSNull pointer (0) returned on EOF or error..SH SEE ALSO.nfnetworks(5)RFC 1101.SH HISTORYThe getnetent(), getnetbyaddr(), getnetbyname(), setnetent(), andendnetent() functions appeared in 4.2BSD..SH BUGSThe 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -