Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getnetbyaddr(3)

getnetbyname(3)

getnetent(3)

setnetent(3)  —  Subroutines

NAME

setnetent, setnetent_r, endnetent, endnetent_r − Opens, rewinds, or closes the networks file

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <netdb.h> int setnetent(
int stay_open); int setnetent_r(
int stay_open,
struct netent_data ∗net_data); void endnetent(void); void endnetent_r(
struct netent_data ∗net_data);

PARAMETERS

stay_openSpecifies a value that indicates when to close the networks file.  Specifying a value of 0 (zero) closes the networks file after each call to the getnetent() function.  Specifying a nonzero value leaves the /etc/networks file open after each call. 

net_dataPoints at a structure where setnetent_r() and endnetent_r() store information about the networks file. 

DESCRIPTION

The setnetent() (set network entry) function opens the /etc/networks file and sets the file marker at the beginning of the file. 

The setnetent_r() function is the reentrant version of the setnetent() function.  Note that when you first call the setnetent_r() function, you must set to NULL the net_fp field of the netent_data structure.  The netdb.h header file defines the netent_data structure. 

The endnetent() function closes the /etc/networks file, previously opened with the getnetent(), getnetbyaddr(), setnetent(), or getnetbyname() function. 

The endnetent_r() function is the reentrant version of the endnetent() function.  The netdb.h header file defines the netent_data structure. 

The system searches either the local /etc/networks file or the NIS distributed networks file for the requested information.  To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file. 

NOTES

If the setnetent() function is called with a non-zero stay_open parameter, the connection remains until the endnetent() or exit() functions are called. 

RETURN VALUES

Upon successful completion, the setnetent() function returns a value of 1.  Otherwise, it returns a value of 0 (zero). 

Upon successful completion, the setnetent_r() function returns a value of 0 (zero).  Otherwise, it returns a value of -1. 

The endnetent() and endnetent_r() functions do not return a value. 

ERRORS

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

[EINVAL]If net_data is invalid. 

In addition, the setnetent() and setnetent_r() functions can fail to open the file.  In this case, errno will be set to the appropriate value. 

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: getnetbyaddr(3), getnetbyname(3), getnetent(3). 

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