Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getprotobynumber(3)

getprotobyname(3)

setprotoent(3)

endprotoent(3)

getprotoent(3)  —  Subroutines

NAME

getprotoent, getprotoent_r − Get a protocol entry

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <netdb.h> struct protoent ∗getprotoent(void); int getprotoent_r(
struct protoent ∗proto,
struct protoent_data ∗proto_data);

PARAMETERS

protoPoints to the protoent structure. 

proto_dataIs data for the protocols database. 

DESCRIPTION

The getprotoent() (get protocol entry) function retrieves protocol information from the /etc/protocols file.  The getprotoent() function returns a pointer to a protoent structure, which contains the fields for a line of information in the /etc/protocols file.  The netdb.h header file defines the protoent structure. 

An application program can use the getprotoent() function to access a protocol name, its aliases, and protocol number.  Use the endprotoent() function to close the /etc/protocols file.  Use the setprotoent() function to rewind. 

The getprotoent_r() function is the reentrant version of the getprotoent() function.  Upon successful completion, the returned structure is pointed to by proto.  Use the setprotoent_r() function to rewind and the endprotoent_r() function to close.  The netdb.h header file defines the protoent and protoent_data structures. 

The system searches either the local /etc/protocols 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

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

Before its first access by either the setprotoent_r() or getprotoent_r() function, you must zero-fill the protoent_data structure. 

If the system is configured to access the protocols database through NIS, the getprotoent_r()  function may not produce correct results if called from multiple threads. 

RETURN VALUES

Upon successful completion, the getprotoent() function returns a pointer to a protoent structure. 

If an error occurs or the end of the file is reached, the getprotoent() function returns a NULL pointer. 

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

ERRORS

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

[EINVAL]The proto or proto_data parameter is invalid. 

[ESRCH]The search failed. 

In addition, if the function fails to open the file, it sets errno to indicate the cause of the failure. 

FILES

/etc/protocols
Contains protocol information.

RELATED INFORMATION

Functions: getprotobynumber(3), getprotobyname(3), setprotoent(3), endprotoent(3). 

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