summary refs log tree commit diff
path: root/manual/socket.texi
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-06-30 17:16:08 +0000
committerUlrich Drepper <drepper@redhat.com>1999-06-30 17:16:08 +0000
commit0ea5db4f1f55e55942f6afd0e4e69ceb2163ed25 (patch)
treea3427369d6193a9618eb9a0c7078a0832210c282 /manual/socket.texi
parent16848c985d9e4d6f8ca7a9c2c4ac711ef63835ec (diff)
downloadglibc-0ea5db4f1f55e55942f6afd0e4e69ceb2163ed25.tar.gz
glibc-0ea5db4f1f55e55942f6afd0e4e69ceb2163ed25.tar.xz
glibc-0ea5db4f1f55e55942f6afd0e4e69ceb2163ed25.zip
Update.
1999-06-28  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* inet/rcmd.c (__icheckhost): Test for gethostbyname_r result
	correctly.

1999-06-25  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* manual/arith.texi (System V Number Conversion): Fix the
	description which confused pointer and value to pointer.
	Reported by Andries.Brouwer@cwi.nl.

1999-06-28  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* pwd/getpw.c (__getpw): Check for NULL result pointer.

1999-06-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* manual/users.texi (Lookup User): Document POSIX return
	semantics for getpwuid_r and getgrgid_r.

	* manual/socket.texi (Host Names): Document that the result
	pointer is null in case of error or host not found and fix a
	typo.  Give a small example.
Diffstat (limited to 'manual/socket.texi')
-rw-r--r--manual/socket.texi45
1 files changed, 37 insertions, 8 deletions
diff --git a/manual/socket.texi b/manual/socket.texi
index b9102c62e1..d77e556214 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -1284,13 +1284,42 @@ pointer and the size of the buffer in the @var{buf} and @var{buflen}
 parameters.
 
 A pointer to the buffer, in which the result is stored, is available in
-@code{*@var{result}} after the function call successfully returned.
-Success is signalled by a zero return value.  If the function failed the
-return value is an error number.  In addition to the errors defined for
-@code{gethostbyname} it can also be @code{ERANGE}.  In this case the
-call should be repeated with a larger buffer.  Additional error
-information is not stored in the global variable @code{h_errno} but
-instead in the object pointed to by @var{h_errnop}.
+@code{*@var{result}} after the function call successfully returned.  If
+an error occurs or if no entry is found, the pointer @code{*var{result}
+is a null pointer.  Success is signalled by a zero return value.  If the
+function failed the return value is an error number.  In addition to the
+errors defined for @code{gethostbyname} it can also be @code{ERANGE}.
+In this case the call should be repeated with a larger buffer.
+Additional error information is not stored in the global variable
+@code{h_errno} but instead in the object pointed to by @var{h_errnop}.
+
+Here's a small example:
+@smallexample
+struct hostent *
+gethostname (char *host)
+@{
+  struct hostent hostbuf, *hp;
+  size_t hstbuflen;
+  char *tmphstbuf;
+  int res;
+  int herr;
+
+  hstbuflen = 1024;
+  tmphstbuf = malloc (hstbuflen);
+
+  while ((res = gethostbyname_r (host, &hostbuf, tmphstbuf, hstbuflen,
+                                 &hp, &herr)) == ERANGE)
+    @{
+      /* Enlarge the buffer.  */
+      hstbuflen *= 2;
+      tmphstbuf = realloc (tmphstbuf, hstbuflen);
+    @}
+  /*  Check for errors.  */
+  if (res || hp == NULL)
+    return NULL;
+  return hp->h_name;
+@}
+@end smallexample
 @end deftypefun
 
 @comment netdb.h
@@ -1314,7 +1343,7 @@ Internet address, use @code{AF_INET6}.
 
 Similar to the @code{gethostbyname_r} function, the caller must provide
 buffers for the result and memory used internally.  In case of success
-the funciton returns zero.  Otherwise the value is an error number where
+the function returns zero.  Otherwise the value is an error number where
 @code{ERANGE} has the special meaning that the caller-provided buffer is
 too small.
 @end deftypefun