Open System Services System Calls Reference Manual (G06.28+, H06.05+)

System Functions (f - i) getservbyname_r(2)
NAME
getservbyname_r - Gets a network service entry by name (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <netdb.h>]
#include <spthread.h>
struct servent *getservbyname_r (
const char *name,
const char *proto,
struct servent *ret,
char *buffer,
int buen
);
PARAMETERS
name Species the service name or the service alias name.
proto Species the name of the protocol to use when contacting the service.
ret Points to a servent structure allocated by the caller.
buffer Points to the buffer supplied by the caller and used as a storage space for
returned data.
buflen Species the size of the buffer passed in bytes.
DESCRIPTION
The getservbyname_r() function is the reentrant version of the getservbyname( ) function.
The getservbyname_r() function searches the /etc/services le sequentially for a match with the
name parameter and the proto parameter. When the proto parameter is a null pointer, any proto-
col value in the /etc/services le can match.
This function returns a pointer to a structure of type servent whose members specify data from
the /etc/services database le. The netdb.h header le denes the servent structure.
The getservbyname_r() function updates the servent structure pointed to by the ret parameter.
Storage referenced by the servent structure is allocated from the memory provided using the
buffer parameter, which is buen characters in size.
RETURN VALUES
Upon successful completion, the getservbyname_r() function returns a pointer to a servent
structure if a match is found, or a null pointer if no match is found. If the call to
getservbyname_r() fails, a null pointer is returned.
ERRORS
If this condition occurs, the getservbyname( ) function sets errno to the corresponding value:
[ERANGE] Insufcient storage was supplied via buffer and buen to contain the data to be
referenced by the resulting servent structure.
527186-007 Hewlett-Packard Company 3111