getservent_r -- read the next entry of the network services database, reentrantly


#include <netdb.h>

int getservent_r(struct servent * result_buf, char * buf, size_t buflen, struct servent * * result);


The getservent_r() function is a reentrant version of the getservent() function.

The getservent_r() function shall search the network services database for the next entry.

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

The array buf shall contain the string fields referenced by the servent 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 getservent_r() function shall return 0.

If the return value was ENOENT, there were no more entries in the database.

If the return value was ERANGE, the size of the buffer buf, indicated by buflen, was too small.