getprotobyname_r -- retrieve information from the network protocol database by protocol name, reentrantly


#include <netdb.h>

int getprotobyname_r(const char * name, struct protoent * result_buf, char * buf, size_t buflen, struct protoent * * result);


The getprotobyname_r() function is a reentrant version of the getprotobyname() function.

The getprotobyname_r() function shall search the network protocol database for an entry with the name name.

If a matching entry is found in the database, this function shall copy the relevant information to the application-supplied protoent structure referenced by result_buf, and return a pointer to this structure in *result. If no matching entry is found, *result shall be set to a null pointer.

The array buf shall contain the string fields referenced by the protoent structure that was returned. The parameter buflen shall specify the array's size. 1024 bytes should be enough for most uses.

Return Value

On success, the getprotobyname_r() function shall return 0. If the return value was ERANGE, the size of the buffer buf, indicated by buflen, was too small.