Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getnetbyname_r(3) — OSF/1 3.0 αXP

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getnetent(3)

getnetbyaddr(3)

setnetent(3)

,endnetent(3)

getnetbyname(3)  —  Subroutines

NAME

getnetbyname, getnetbyname_r − Get a network entry by name

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <netdb.h>

struct netent ∗getnetbyname(
const char ∗name);

int getnetbyname_r(
const char ∗name,
struct netent ∗net,
struct netent_data ∗net_data);

PARAMETERS

nameSpecifies the official network name or alias. 

netPoints to the netent structure. 

net_dataIs data for the networks database. 

DESCRIPTION

The getnetbyname() function returns a pointer to a structure of type netent. Its members specify data in fields from a record line in the /etc/networks network name database file. The netdb.h header file defines the netent structure. 

The getnetbyname() function searches the /etc/networks file sequentially until a match with the name parameter occurs. When EOF (End-of-File) is reached without a match, an error value is returned by this function. 

Use the endnetent() function to close the /etc/networks file. 

The getnetbyname_r() function is the reentrant version of the getnetbyname() function.  Upon successful completion, the returned structure is pointed to by net.  The netdb.h header file defines the netent and netent_data structures. 

NOTES

The getnetbyname() return value points to static data, which is overwritten by any subsequently called functions using the same structure. 

Before the first access (by either the setnetent_r() or getnetbyname_r() functions), set to NULL the net_fp field of the netent_data structure.  In addition, the _net_stayopen flag of the netent_data structure should be initialized if the setnetent() function is not used. 

RETURN VALUES

Upon successful completion, the getnetbyname() function returns a pointer to a netent structure.  A value of 0 (zero) is returned when an error occurs or when the end of the /etc/networks name file is reached. 

Upon successful completion, the getnetbyname_r() function returns a value of 0 (zero).  Otherwise, a value of -1 is returned. 

ERRORS

If any of the following conditions occurs, the getnetbyname_r() function sets errno to the corresponding value:

[EINVAL]The net or net_data parameter is invalid. 

[ESRCH]The search failed. 

FILES

/etc/networks
This file is the DARPA Internet network name database file. Each record in the file occupies a single line and has three fields: the official network name, the network number, and alias.

RELATED INFORMATION

Functions: getnetent(3), getnetbyaddr(3), setnetent(3),endnetent(3). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026