]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man3/getprotoent_r.3
Start of man-pages-5.03: renaming .Announce and .lsm files
[thirdparty/man-pages.git] / man3 / getprotoent_r.3
index cd1839d75c4762a77ba6ecd76229705ea36533ed..57b9c63afbdc63af23cb727f5332c0bd58abf609 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk
 .\"    <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
-.TH GETPROTOENT_R 3  2008-08-19 "GNU" "Linux Programmer's Manual"
+.TH GETPROTOENT_R 3  2019-03-06 "GNU" "Linux Programmer's Manual"
 .SH NAME
 getprotoent_r, getprotobyname_r, getprotobynumber_r \- get
 protocol entry (reentrant)
 .SH SYNOPSIS
 .nf
 .B #include <netdb.h>
-.sp
+.PP
 .BI "int getprotoent_r(struct protoent *" result_buf ", char *" buf ,
 .BI "                size_t " buflen ", struct protoent **" result );
-.sp
+.PP
 .BI "int getprotobyname_r(const char *" name ,
 .BI "                struct protoent *" result_buf ", char *" buf ,
 .BI "                size_t " buflen ", struct protoent **" result );
-.sp
+.PP
 .BI "int getprotobynumber_r(int " proto ,
 .BI "                struct protoent *" result_buf ", char *" buf ,
 .BI "                size_t " buflen ", struct protoent **" result );
-.sp
+.PP
 .fi
 .in -4n
 Feature Test Macro Requirements for glibc (see
 .BR feature_test_macros (7)):
 .ad l
 .in
-.sp
+.PP
 .BR getprotoent_r (),
 .BR getprotobyname_r (),
 .BR getprotobynumber_r ():
-_BSD_SOURCE || _SVID_SOURCE
+    Since glibc 2.19:
+        _DEFAULT_SOURCE
+    Glibc 2.19 and earlier:
+        _BSD_SOURCE || _SVID_SOURCE
 .ad b
 .SH DESCRIPTION
 The
@@ -68,20 +73,20 @@ They differ in the way that the
 structure is returned,
 and in the function calling signature and return value.
 This manual page describes just the differences from
-the non-reentrant functions.
-
+the nonreentrant functions.
+.PP
 Instead of returning a pointer to a statically allocated
 .I protoent
 structure as the function result,
 these functions copy the structure into the location pointed to by
 .IR result_buf .
-
+.PP
 The
 .I buf
 array is used to store the string fields pointed to by the returned
 .I protoent
 structure.
-(The non-reentrant functions allocate these strings in static storage.)
+(The nonreentrant functions allocate these strings in static storage.)
 The size of this array is specified in
 .IR buflen .
 If
@@ -91,9 +96,9 @@ is too small, the call fails with the error
 and the caller must try again with a larger buffer.
 (A buffer of length 1024 bytes should be sufficient for most applications.)
 .\" I can find no information on the required/recommended buffer size;
-.\" the non-reentrant functions use a 1024 byte buffer.
+.\" the nonreentrant functions use a 1024 byte buffer.
 .\" The 1024 byte value is also what the Solaris man page suggests. -- mtk
-
+.PP
 If the function call successfully obtains a protocol record, then
 .I *result
 is set pointing to
@@ -101,10 +106,10 @@ is set pointing to
 otherwise,
 .I *result
 is set to NULL.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 On success, these functions return 0.
-On error, a positive error number is returned.
-
+On error, they return one of the positive error numbers listed in ERRORS.
+.PP
 On error, record not found
 .RB ( getprotobyname_r (),
 .BR getprotobynumber_r ()),
@@ -124,7 +129,24 @@ is too small.
 Try again with a larger buffer
 (and increased
 .IR buflen ).
-.SH "CONFORMING TO"
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lbw20 lb lb
+l l l.
+Interface      Attribute       Value
+T{
+.BR getprotoent_r (),
+.br
+.BR getprotobyname_r (),
+.br
+.BR getprotobynumber_r ()
+T}     Thread safety   MT-Safe locale
+.TE
+.sp 1
+.SH CONFORMING TO
 These functions are GNU extensions.
 Functions with similar names exist on some other systems,
 though typically with different calling signatures.
@@ -142,21 +164,22 @@ fails with the error
 .BR ERANGE ,
 the program retries with larger buffer sizes.
 The following shell session shows a couple of sample runs:
+.PP
 .in +4n
-.nf
-
-$ ./a.out tcp 1
+.EX
+.RB "$" " ./a.out tcp 1"
 ERANGE! Retrying with larger buffer
 getprotobyname_r() returned: 0 (success)  (buflen=78)
 p_name=tcp; p_proto=6; aliases=TCP
-$ ./a.out xxx 1
+.RB "$" " ./a.out xxx 1"
 ERANGE! Retrying with larger buffer
 getprotobyname_r() returned: 0 (success)  (buflen=100)
 Call failed/record not found
-
-.fi
+.EE
 .in
-.nf
+.SS Program source
+\&
+.EX
 #define _GNU_SOURCE
 #include <ctype.h>
 #include <netdb.h>
@@ -177,7 +200,7 @@ main(int argc, char *argv[])
     char **p;
 
     if (argc < 2) {
-        printf("Usage: %s proto\-name [buflen]\\n", argv[0]);
+        printf("Usage: %s proto\-name [buflen]\en", argv[0]);
         exit(EXIT_FAILURE);
     }
 
@@ -186,7 +209,7 @@ main(int argc, char *argv[])
         buflen = atoi(argv[2]);
 
     if (buflen > MAX_BUF) {
-        printf("Exceeded buffer limit (%d)\\n", MAX_BUF);
+        printf("Exceeded buffer limit (%d)\en", MAX_BUF);
         exit(EXIT_FAILURE);
     }
 
@@ -196,7 +219,7 @@ main(int argc, char *argv[])
                      buf, buflen, &result);
         if (s == ERANGE) {
             if (erange_cnt == 0)
-                printf("ERANGE! Retrying with larger buffer\\n");
+                printf("ERANGE! Retrying with larger buffer\en");
             erange_cnt++;
 
             /* Increment a byte at a time so we can see exactly
@@ -205,18 +228,18 @@ main(int argc, char *argv[])
             buflen++;
 
             if (buflen > MAX_BUF) {
-                printf("Exceeded buffer limit (%d)\\n", MAX_BUF);
+                printf("Exceeded buffer limit (%d)\en", MAX_BUF);
                 exit(EXIT_FAILURE);
             }
         }
     } while (s == ERANGE);
 
-    printf("getprotobyname_r() returned: %s  (buflen=%d)\\n",
+    printf("getprotobyname_r() returned: %s  (buflen=%d)\en",
             (s == 0) ? "0 (success)" : (s == ENOENT) ? "ENOENT" :
             strerror(s), buflen);
 
     if (s != 0 || result == NULL) {
-        printf("Call failed/record not found\\n");
+        printf("Call failed/record not found\en");
         exit(EXIT_FAILURE);
     }
 
@@ -224,11 +247,11 @@ main(int argc, char *argv[])
                 result_buf.p_name, result_buf.p_proto);
     for (p = result_buf.p_aliases; *p != NULL; p++)
         printf("%s ", *p);
-    printf("\\n");
+    printf("\en");
 
     exit(EXIT_SUCCESS);
 }
-.fi
-.SH "SEE ALSO"
+.EE
+.SH SEE ALSO
 .BR getprotoent (3),
 .BR protocols (5)