getnetbyname_r Subroutine

Purpose

Gets network entry by name.

Library

Standard C Library (libc.a)

Syntax

#include <netdb.h>
int getnetbyname_r(Name, netent, net_data)
register const char *Name;
struct netent *netent;
struct netent_data *net_data;

Description

The getnetbyname_r subroutine retrieves information from the /etc/networks file using the Name parameter as a search key.

The getnetbyname_r subroutine internally calls the getnetbyname subroutine and stores the information in the structure data.

The getnetbyname subroutine overwrites the static data returned in subsequent calls. The getnetbyname_r subroutine does not.

Use the endnetent_r subroutine to close the /etc/networks file.

Parameters

Item Description
Name Points to a string containing the name of the network.
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 getnetbyname_r subroutine returns a -1 to indicate error.

Files

Item Description
/etc/networks Contains official network names.