getnetent_r Subroutine
Purpose
Gets network entry.
Library
Standard C Library (libc.a)
Syntax
#include <netdb.h>
int getnetent_r(netent, net_data)
struct netent *netent;
struct netent_data *net_data;
Description
The getnetent_r subroutine retrieves network information by opening and sequentially reading the /etc/networks file. This subroutine internally calls the getnetent subroutine and stores the values in the hostent structure.
The getnetent subroutine overwrites the static data returned in subsequent calls. The getnetent_r subroutine does not. Use the endnetent_r subroutine to close the /etc/networks file.
Parameters
Item | Description |
---|---|
netent | Points to the netent structure. |
net_data | Points to the net_data structure. |
Return Values
The function returns a 0 if successful and a -1 if unsuccessful.
Note: If
an error occurs or the end of the file is reached, the getnetent_r subroutine
returns a -1 to indicate error.
Files
Item | Description |
---|---|
/etc/networks | Contains official network names. |