[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

getprotobyname_r Subroutine

Purpose

Gets protocol entry from the /etc/protocols file by protocol name.

Library

Standard C Library (libc.a)

Syntax

#include <netdb.h>

int  getprotobyname_r(Name, protoent, proto_data)
register const char *Name;
struct protoent *protoent;
struct protoent_data *proto_data;

Description

The getprotobyname_r subroutine retrieves protocol information from the /etc/protocols file by protocol name.

An application program can use the getprotobyname_r subroutine to access a protocol name, aliases, and protocol number.

The getprotobyname_r subroutine searches the protocols file sequentially from the start of the file until it finds a matching protocol name or until it reaches the end of the file. The subroutine writes the protoent structure, which contains fields for a line of information in the /etc/protocols file.

The netdb.h file defines the protoent structure.

The getprotobyname subroutine overwrites any static data returned in subsequent calls. The getprotobyname_r subroutine does not.

Use the endprotoent_r subroutine to close the /etc/protocols file.

Parameters

Name Specifies the protocol name.
protoent Points to the protoent structure.
proto_data Points to the proto_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 getprotobyname_r subroutine returns a -1 to indicate error.

Related Information

endprotoent_r Subroutine, getprotobynumber_r Subroutine, getprotoent_r Subroutine, and setprotoent_r Subroutine.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]