.B #include <grp.h>
.P
.BI "int getgrent_r(struct group *restrict " gbuf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct group **restrict " gbufp );
.BI "int fgetgrent_r(FILE *restrict " stream ", struct group *restrict " gbuf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct group **restrict " gbufp );
.fi
.P
And next the buffer
.I buf
of size
-.I buflen
+.I size
that can hold additional strings.
The result of these functions, the \fIstruct group\fP read from the stream,
is stored in the provided buffer
.P
.in +4n
.EX
-struct group *getgrent_r(struct group *grp, char *buf,
- int buflen);
+struct group *getgrent_r(struct group *grp, char buf[.size],
+ int size);
.EE
.in
.P
.P
.in +4n
.EX
-int getgrent_r(struct group *grp, char *buf, int buflen,
+int getgrent_r(struct group *grp, char buf[.size], int size,
FILE **gr_fp);
.EE
.in
.P
.BI "int getgrnam_r(const char *restrict " name \
", struct group *restrict " grp ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct group **restrict " result );
.BI "int getgrgid_r(gid_t " gid ", struct group *restrict " grp ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct group **restrict " result );
.fi
.P
structure are stored in the buffer
.I buf
of size
-.IR buflen .
+.IR size .
A pointer to the result (in case of success) or NULL (in case no entry
was found or an error occurred) is stored in
.IR *result .
.BI "struct hostent *gethostbyname2(const char *" name ", int " af );
.P
.BI "int gethostent_r(struct hostent *restrict " ret ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." bufsize "], size_t " bufsize ,
.BI " struct hostent **restrict " result ,
.BI " int *restrict " h_errnop );
.P
.BI "int gethostbyaddr_r(const void " addr "[restrict ." size "], socklen_t " size ,
.BI " int " type ,
.BI " struct hostent *restrict " ret ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." bufsize "], size_t " bufsize ,
.BI " struct hostent **restrict " result ,
.BI " int *restrict " h_errnop );
.B [[deprecated]]
.BI "int gethostbyname_r(const char *restrict " name ,
.BI " struct hostent *restrict " ret ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." bufsize "], size_t " bufsize ,
.BI " struct hostent **restrict " result ,
.BI " int *restrict " h_errnop );
.B [[deprecated]]
.BI "int gethostbyname2_r(const char *restrict " name ", int " af,
.BI " struct hostent *restrict " ret ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." bufsize "], size_t " bufsize ,
.BI " struct hostent **restrict " result ,
.BI " int *restrict " h_errnop );
.fi
which will be filled in on success, and a temporary work buffer
.I buf
of size
-.IR buflen .
+.IR bufsize .
After the call,
.I result
will point to the result on success.
.P
.BI "struct mntent *getmntent_r(FILE *restrict " streamp ,
.BI " struct mntent *restrict " mntbuf ,
-.BI " char " buf "[restrict ." buflen "], int " buflen );
+.BI " char " buf "[restrict ." size "], int " size );
.fi
.P
.RS -4
in the provided array
.I buf
of size
-.IR buflen .
+.IR size .
.P
The
.I mntent
.B #include <netdb.h>
.P
.BI "int getnetent_r(struct netent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct netent **restrict " result ,
.BI " int *restrict " h_errnop );
.BI "int getnetbyname_r(const char *restrict " name ,
.BI " struct netent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct netent **restrict " result ,
.BI " int *restrict " h_errnop );
.BI "int getnetbyaddr_r(uint32_t " net ", int " type ,
.BI " struct netent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct netent **restrict " result ,
.BI " int *restrict " h_errnop );
.P
structure.
(The nonreentrant functions allocate these strings in static storage.)
The size of this array is specified in
-.IR buflen .
+.IR size .
If
.I buf
is too small, the call fails with the error
.BR ERANGE ,
and the caller must try again with a larger buffer.
-(A buffer of length 1024 bytes should be sufficient for most applications.)
+(A buffer of size 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.
.P
is too small.
Try again with a larger buffer
(and increased
-.IR buflen ).
+.IR size ).
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.B #include <netdb.h>
.P
.BI "int getprotoent_r(struct protoent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct protoent **restrict " result );
.BI "int getprotobyname_r(const char *restrict " name ,
.BI " struct protoent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct protoent **restrict " result );
.BI "int getprotobynumber_r(int " proto ,
.BI " struct protoent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct protoent **restrict " result );
.P
.fi
structure.
(The nonreentrant functions allocate these strings in static storage.)
The size of this array is specified in
-.IR buflen .
+.IR size .
If
.I buf
is too small, the call fails with the error
.BR ERANGE ,
and the caller must try again with a larger buffer.
-(A buffer of length 1024 bytes should be sufficient for most applications.)
+(A buffer of size 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.
.\" The 1024 byte value is also what the Solaris man page suggests. -- mtk
is too small.
Try again with a larger buffer
(and increased
-.IR buflen ).
+.IR size ).
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
in its first command-line argument.
If a second (integer) command-line argument is supplied,
it is used as the initial value for
-.IR buflen ;
+.IR size ;
if
.BR getprotobyname_r ()
fails with the error
.EX
.RB "$" " ./a.out tcp 1"
ERANGE! Retrying with larger buffer
-getprotobyname_r() returned: 0 (success) (buflen=78)
+getprotobyname_r() returned: 0 (success) (size=78)
p_name=tcp; p_proto=6; aliases=TCP
.RB "$" " ./a.out xxx 1"
ERANGE! Retrying with larger buffer
-getprotobyname_r() returned: 0 (success) (buflen=100)
+getprotobyname_r() returned: 0 (success) (size=100)
Call failed/record not found
.EE
.in
int
main(int argc, char *argv[])
{
- int buflen, erange_cnt, s;
+ int size, erange_cnt, s;
struct protoent result_buf;
struct protoent *result;
char buf[MAX_BUF];
\&
if (argc < 2) {
- printf("Usage: %s proto\-name [buflen]\[rs]n", argv[0]);
+ printf("Usage: %s proto\-name [size]\[rs]n", argv[0]);
exit(EXIT_FAILURE);
}
\&
- buflen = 1024;
+ size = 1024;
if (argc > 2)
- buflen = atoi(argv[2]);
+ size = atoi(argv[2]);
\&
- if (buflen > MAX_BUF) {
+ if (size > MAX_BUF) {
printf("Exceeded buffer limit (%d)\[rs]n", MAX_BUF);
exit(EXIT_FAILURE);
}
erange_cnt = 0;
do {
s = getprotobyname_r(argv[1], &result_buf,
- buf, buflen, &result);
+ buf, size, &result);
if (s == ERANGE) {
if (erange_cnt == 0)
printf("ERANGE! Retrying with larger buffer\[rs]n");
/* Increment a byte at a time so we can see exactly
what size buffer was required. */
\&
- buflen++;
+ size++;
\&
- if (buflen > MAX_BUF) {
+ if (size > MAX_BUF) {
printf("Exceeded buffer limit (%d)\[rs]n", MAX_BUF);
exit(EXIT_FAILURE);
}
}
} while (s == ERANGE);
\&
- printf("getprotobyname_r() returned: %s (buflen=%d)\[rs]n",
+ printf("getprotobyname_r() returned: %s (size=%d)\[rs]n",
(s == 0) ? "0 (success)" : (s == ENOENT) ? "ENOENT" :
- strerror(s), buflen);
+ strerror(s), size);
\&
if (s != 0 || result == NULL) {
printf("Call failed/record not found\[rs]n");
.B #include <pwd.h>
.P
.BI "int getpwent_r(struct passwd *restrict " pwbuf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct passwd **restrict " pwbufp );
.BI "int fgetpwent_r(FILE *restrict " stream \
", struct passwd *restrict " pwbuf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct passwd **restrict " pwbufp );
.fi
.P
And next the buffer
.I buf
of size
-.I buflen
+.I size
that can hold additional strings.
The result of these functions, the \fIstruct passwd\fP read from the stream,
is stored in the provided buffer
.in +4n
.EX
struct passwd *
-getpwent_r(struct passwd *pwd, char *buf, int buflen);
+getpwent_r(struct passwd *pwd, char buf[.size], int size);
.EE
.in
.P
.in +4n
.EX
int
-getpwent_r(struct passwd *pwd, char *buf, int buflen,
+getpwent_r(struct passwd *pwd, char buf[.size], int size,
FILE **pw_fp);
.EE
.in
.P
.BI "int getpwnam_r(const char *restrict " name ", \
struct passwd *restrict " pwd ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct passwd **restrict " result );
.BI "int getpwuid_r(uid_t " uid ", struct passwd *restrict " pwd ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct passwd **restrict " result );
.fi
.P
structure are stored in the buffer
.I buf
of size
-.IR buflen .
+.IR size .
A pointer to the result (in case of success) or NULL (in case no entry
was found or an error occurred) is stored in
.IR *result .
.nf
.B #include <netdb.h>
.P
-.BI "int getrpcent_r(struct rpcent *" result_buf ", char " buf [. buflen ],
-.BI " size_t " buflen ", struct rpcent **" result );
+.BI "int getrpcent_r(struct rpcent *" result_buf ", char " buf [. size ],
+.BI " size_t " size ", struct rpcent **" result );
.BI "int getrpcbyname_r(const char *" name ,
-.BI " struct rpcent *" result_buf ", char " buf [. buflen ],
-.BI " size_t " buflen ", struct rpcent **" result );
+.BI " struct rpcent *" result_buf ", char " buf [. size ],
+.BI " size_t " size ", struct rpcent **" result );
.BI "int getrpcbynumber_r(int " number ,
-.BI " struct rpcent *" result_buf ", char " buf [. buflen ],
-.BI " size_t " buflen ", struct rpcent **" result );
+.BI " struct rpcent *" result_buf ", char " buf [. size ],
+.BI " size_t " size ", struct rpcent **" result );
.P
.fi
.RS -4
structure.
(The nonreentrant functions allocate these strings in static storage.)
The size of this array is specified in
-.IR buflen .
+.IR size .
If
.I buf
is too small, the call fails with the error
.BR ERANGE ,
and the caller must try again with a larger buffer.
-(A buffer of length 1024 bytes should be sufficient for most applications.)
+(A buffer of size 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.
.P
is too small.
Try again with a larger buffer
(and increased
-.IR buflen ).
+.IR size ).
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.B #include <netdb.h>
.P
.BI "int getservent_r(struct servent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct servent **restrict " result );
.BI "int getservbyname_r(const char *restrict " name ,
.BI " const char *restrict " proto ,
.BI " struct servent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct servent **restrict " result );
.BI "int getservbyport_r(int " port ,
.BI " const char *restrict " proto ,
.BI " struct servent *restrict " result_buf ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen ,
+.BI " char " buf "[restrict ." size "], size_t " size ,
.BI " struct servent **restrict " result );
.P
.fi
structure.
(The nonreentrant functions allocate these strings in static storage.)
The size of this array is specified in
-.IR buflen .
+.IR size .
If
.I buf
is too small, the call fails with the error
.BR ERANGE ,
and the caller must try again with a larger buffer.
-(A buffer of length 1024 bytes should be sufficient for most applications.)
+(A buffer of size 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.
.P
is too small.
Try again with a larger buffer
(and increased
-.IR buflen ).
+.IR size ).
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
in its first command-line argument.
If a third (integer) command-line argument is supplied,
it is used as the initial value for
-.IR buflen ;
+.IR size ;
if
.BR getservbyport_r ()
fails with the error
.EX
.RB "$" " ./a.out 7 tcp 1"
ERANGE! Retrying with larger buffer
-getservbyport_r() returned: 0 (success) (buflen=87)
+getservbyport_r() returned: 0 (success) (size=87)
s_name=echo; s_proto=tcp; s_port=7; aliases=
.RB "$" " ./a.out 77777 tcp"
-getservbyport_r() returned: 0 (success) (buflen=1024)
+getservbyport_r() returned: 0 (success) (size=1024)
Call failed/record not found
.EE
.in
int
main(int argc, char *argv[])
{
- int buflen, erange_cnt, port, s;
+ int size, erange_cnt, port, s;
struct servent result_buf;
struct servent *result;
char buf[MAX_BUF];
char *protop;
\&
if (argc < 3) {
- printf("Usage: %s port\-num proto\-name [buflen]\[rs]n", argv[0]);
+ printf("Usage: %s port\-num proto\-name [size]\[rs]n", argv[0]);
exit(EXIT_FAILURE);
}
\&
protop = (strcmp(argv[2], "null") == 0 ||
strcmp(argv[2], "NULL") == 0) ? NULL : argv[2];
\&
- buflen = 1024;
+ size = 1024;
if (argc > 3)
- buflen = atoi(argv[3]);
+ size = atoi(argv[3]);
\&
- if (buflen > MAX_BUF) {
+ if (size > MAX_BUF) {
printf("Exceeded buffer limit (%d)\[rs]n", MAX_BUF);
exit(EXIT_FAILURE);
}
erange_cnt = 0;
do {
s = getservbyport_r(port, protop, &result_buf,
- buf, buflen, &result);
+ buf, size, &result);
if (s == ERANGE) {
if (erange_cnt == 0)
printf("ERANGE! Retrying with larger buffer\[rs]n");
/* Increment a byte at a time so we can see exactly
what size buffer was required. */
\&
- buflen++;
+ size++;
\&
- if (buflen > MAX_BUF) {
+ if (size > MAX_BUF) {
printf("Exceeded buffer limit (%d)\[rs]n", MAX_BUF);
exit(EXIT_FAILURE);
}
}
} while (s == ERANGE);
\&
- printf("getservbyport_r() returned: %s (buflen=%d)\[rs]n",
+ printf("getservbyport_r() returned: %s (size=%d)\[rs]n",
(s == 0) ? "0 (success)" : (s == ENOENT) ? "ENOENT" :
- strerror(s), buflen);
+ strerror(s), size);
\&
if (s != 0 || result == NULL) {
printf("Call failed/record not found\[rs]n");
.B #include <shadow.h>
.P
.BI "int getspent_r(struct spwd *" spbuf ,
-.BI " char " buf [. buflen "], size_t " buflen ", \
+.BI " char " buf [. size "], size_t " size ", \
struct spwd **" spbufp );
.BI "int getspnam_r(const char *" name ", struct spwd *" spbuf ,
-.BI " char " buf [. buflen "], size_t " buflen ", \
+.BI " char " buf [. size "], size_t " size ", \
struct spwd **" spbufp );
.P
.BI "int fgetspent_r(FILE *" stream ", struct spwd *" spbuf ,
-.BI " char " buf [. buflen "], size_t " buflen ", \
+.BI " char " buf [. size "], size_t " size ", \
struct spwd **" spbufp );
.BI "int sgetspent_r(const char *" s ", struct spwd *" spbuf ,
-.BI " char " buf [. buflen "], size_t " buflen ", \
+.BI " char " buf [. size "], size_t " size ", \
struct spwd **" spbufp );
.fi
.P
are stored in the buffer
.I buf
of size
-.IR buflen .
+.IR size .
A pointer to the result (in case of success) or NULL (in case no entry
was found or an error occurred) is stored in
.IR *spbufp .
.B #include <stdlib.h>
.P
.BI "char *ptsname(int " fd );
-.BI "int ptsname_r(int " fd ", char " buf [. buflen "], size_t " buflen );
+.BI "int ptsname_r(int " fd ", char " buf [. size "], size_t " size );
.fi
.P
.RS -4
null-terminated string in the buffer pointed to by
.IR buf .
The
-.I buflen
+.I size
argument specifies the number of bytes available in
.IR buf .
.SH RETURN VALUE
.BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type \
", NETLINK_ROUTE);"
.P
-.BI "int RTA_OK(struct rtattr *" rta ", int " rtabuflen );
+.BI "int RTA_OK(struct rtattr *" rta ", int " size );
.P
.BI "void *RTA_DATA(struct rtattr *" rta );
.BI "unsigned int RTA_PAYLOAD(struct rtattr *" rta );
.P
.BI "struct rtattr *RTA_NEXT(struct rtattr *" rta \
-", unsigned int " rtabuflen );
+", unsigned int " size );
.P
.BI "unsigned int RTA_LENGTH(unsigned int " size );
.BI "unsigned int RTA_SPACE(unsigned int "size );
message header and appended attributes.
The attributes should be manipulated only using the macros provided here.
.P
-.BI RTA_OK( rta ", " attrlen )
+.BI RTA_OK( rta ", " size )
returns true if
.I rta
points to a valid routing attribute;
-.I attrlen
+.I size
is the running size of the attribute buffer.
When not true then you must assume there are no more attributes in the
message, even if
-.I attrlen
+.I size
is nonzero.
.P
.BI RTA_DATA( rta )
.BI RTA_PAYLOAD( rta )
returns the size of this attribute's data.
.P
-.BI RTA_NEXT( rta ", " attrlen )
+.BI RTA_NEXT( rta ", " size )
gets the next attribute after
.IR rta .
Calling this macro will update
-.IR attrlen .
+.IR size .
You should use
.B RTA_OK
to check the validity of the returned pointer.
.P
.B "struct aliasent *getaliasent(void);"
.BI "int getaliasent_r(struct aliasent *restrict " result ,
-.BI " char " buffer "[restrict ." buflen "], \
-size_t " buflen ,
+.BI " char " buffer "[restrict ." size "], \
+size_t " size ,
.BI " struct aliasent **restrict " res );
.P
.BI "struct aliasent *getaliasbyname(const char *" name );
.BI "int getaliasbyname_r(const char *restrict " name ,
.BI " struct aliasent *restrict " result ,
-.BI " char " buffer "[restrict ." buflen "], \
-size_t " buflen ,
+.BI " char " buffer "[restrict ." size "], \
+size_t " size ,
.BI " struct aliasent **restrict " res );
.fi
.SH DESCRIPTION
.BI " char **restrict " user ", char **restrict " domain );
.BI "int getnetgrent_r(char **restrict " host ,
.BI " char **restrict " user ", char **restrict " domain ,
-.BI " char " buf "[restrict ." buflen "], size_t " buflen );
+.BI " char " buf "[restrict ." size "], size_t " size );
.P
.BI "int innetgr(const char *" netgroup ", const char *" host ,
.BI " const char *" user ", const char *" domain );
.BI "const char *strerrorname_np(int " errnum );
.BI "const char *strerrordesc_np(int " errnum );
.P
-.BI "int strerror_r(int " errnum ", char " buf [. buflen "], size_t " buflen );
+.BI "int strerror_r(int " errnum ", char " buf [. size "], size_t " size );
/* XSI-compliant */
.P
-.BI "char *strerror_r(int " errnum ", char " buf [. buflen "], size_t " buflen );
+.BI "char *strerror_r(int " errnum ", char " buf [. size "], size_t " size );
/* GNU-specific */
.P
.BI "char *strerror_l(int " errnum ", locale_t " locale );
is preferred for portable applications.
It returns the error string in the user-supplied buffer
.I buf
-of length
-.IR buflen .
+of size
+.IR size .
.P
The GNU-specific
.BR strerror_r ()
If the function stores a string in
.IR buf ,
then at most
-.I buflen
+.I size
bytes are stored (the string may be truncated if
-.I buflen
+.I size
is too small and
.I errnum
is unknown).
.B #include <unistd.h>
.P
.BI "char *ttyname(int " fd );
-.BI "int ttyname_r(int " fd ", char " buf [. buflen "], size_t " buflen );
+.BI "int ttyname_r(int " fd ", char " buf [. size "], size_t " size );
.fi
.SH DESCRIPTION
The function
.BR ttyname_r ()
stores this pathname in the buffer
.I buf
-of length
-.IR buflen .
+of size
+.IR size .
.SH RETURN VALUE
The function
.BR ttyname ()
.TP
.B ERANGE
.RB ( ttyname_r ())
-.I buflen
+.I size
was too small to allow storing the pathname.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see