.SH SYNOPSIS
.nf
.B #include <netdb.h>
-.PP
+.P
.BI "int getservent_r(struct servent *restrict " result_buf ,
.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
.BI " struct servent **restrict " result );
.BI " struct servent *restrict " result_buf ,
.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
.BI " struct servent **restrict " result );
-.PP
+.P
.fi
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
-.PP
+.P
.BR getservent_r (),
.BR getservbyname_r (),
.BR getservbyport_r ():
and in the function calling signature and return value.
This manual page describes just the differences from
the nonreentrant functions.
-.PP
+.P
Instead of returning a pointer to a statically allocated
.I servent
structure as the function result,
these functions copy the structure into the location pointed to by
.IR result_buf .
-.PP
+.P
The
.I buf
array is used to store the string fields pointed to by the returned
(A buffer of length 1024 bytes should be sufficient for most applications.)
.\" I can find no information on the required/recommended buffer size;
.\" the nonreentrant functions use a 1024 byte buffer -- mtk.
-.PP
+.P
If the function call successfully obtains a service record, then
.I *result
is set pointing to
.SH RETURN VALUE
On success, these functions return 0.
On error, they return one of the positive error numbers listed in errors.
-.PP
+.P
On error, record not found
.RB ( getservbyname_r (),
.BR getservbyport_r ()),
.BR ERANGE ,
the program retries with larger buffer sizes.
The following shell session shows a couple of sample runs:
-.PP
+.P
.in +4n
.EX
.RB "$" " ./a.out 7 tcp 1"