Subject: lib/1065: misc h_errno and hstrerror() stuff
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: John Hawkinson <jhawk@MIT.EDU>
List: netbsd-bugs
Date: 05/19/1995 01:20:04
>Number:         1065
>Category:       lib
>Synopsis:       misc h_errno and hstrerror() stuff
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri May 19 01:20:02 1995
>Originator:     John Hawkinson
>Organization:
MIT SIPB
>Release:        -current. Fri May 19 04:08:35 EDT 1995
>Environment:
	
System: NetBSD lola-granola 1.0A NetBSD 1.0A (LOLA) #14: Thu May 18 15:17:31 EDT 1995 mycroft@limekiller:/afs/sipb.mit.edu/system/i386_nbsd1/usr/src/sys/arch/i386/compile/LOLA i386


>Description:

	*	h_errno ought to be declared in netdb.h so that
		programs using it do not have to define it explictly.
		The bind 4.9 resolver does this too, incidently.

	*	hstrerror() needs to be documented so people use it
		instead of the (non-documented, presumably disallowed)
		h_errlist and h_nerr. If this assumption is wrong, then
		please list h_errlist and h_nerr in some man page.
>How-To-Repeat:
>Fix:

*** /usr/src/include/netdb.h	1995/05/19 07:43:32	1.1
--- /usr/src/include/netdb.h	1995/05/19 07:47:21	1.2
***************
*** 44,49 ****
--- 44,51 ----
  #define	_PATH_PROTOCOLS	"/etc/protocols"
  #define	_PATH_SERVICES	"/etc/services"
  
+ extern int h_errno;
+ 
  /*
   * Structures returned by network data base library.  All addresses are
   * supplied in host order, and returned in network order (suitable for

*** gethostbyname.3	1995/05/19 07:49:30	1.1
--- /usr/src/lib/libc/net/gethostbyname.3	1995/05/19 08:02:28
***************
*** 42,52 ****
  .Nm gethostent ,
  .Nm sethostent ,
  .Nm endhostent ,
! .Nm herror
  .Nd get network host entry
  .Sh SYNOPSIS
  .Fd #include <netdb.h>
- .Fd extern int h_errno;
  .Ft struct hostent *
  .Fn gethostbyname "const char *name"
  .Ft struct hostent *
--- 42,53 ----
  .Nm gethostent ,
  .Nm sethostent ,
  .Nm endhostent ,
! .Nm h_errno ,
! .Nm herror ,
! .Nm hstrerror
  .Nd get network host entry
  .Sh SYNOPSIS
  .Fd #include <netdb.h>
  .Ft struct hostent *
  .Fn gethostbyname "const char *name"
  .Ft struct hostent *
***************
*** 55,61 ****
--- 56,65 ----
  .Fn gethostent void
  .Fn sethostent "int stayopen"
  .Fn endhostent void
+ .Fd extern int h_errno
  .Fn herror "char *string"
+ .Ft char *
+ .Fn hstrerror "int herrnum"
  .Sh DESCRIPTION
  The
  .Fn gethostbyname
***************
*** 152,158 ****
  .Fn gethostbyaddr
  is indicated by return of a null pointer.
  The external integer
! .Va h_errno
  may then be checked to see whether this is a temporary failure
  or an invalid or unknown host.
  The routine
--- 156,162 ----
  .Fn gethostbyaddr
  is indicated by return of a null pointer.
  The external integer
! .Fd h_errno
  may then be checked to see whether this is a temporary failure
  or an invalid or unknown host.
  The routine
***************
*** 166,172 ****
  The error message is printed with a trailing newline.
  .Pp
  The variable
! .Va h_errno
  can have the following values:
  .Bl -tag -width HOST_NOT_FOUND
  .It Dv HOST_NOT_FOUND
--- 170,176 ----
  The error message is printed with a trailing newline.
  .Pp
  The variable
! .Fd h_errno
  can have the following values:
  .Bl -tag -width HOST_NOT_FOUND
  .It Dv HOST_NOT_FOUND
***************
*** 188,193 ****
--- 192,206 ----
  will result in an answer;
  for example, a mail-forwarder may be registered for this domain.
  .El
+ .Pp
+ The function
+ .Fn hstrerror
+ function returns a pointer to the message string affiliated
+ with an error number; this is the same string printed out by
+ .Fn herror .
+ The array pointed to is not to be modified by the program, but
+ may be overwritten with subsequent calls to
+ .Fn hstrerror .
  .Sh SEE ALSO
  .Xr resolver 3 ,
  .Xr hosts 5 ,
*** Makefile.inc	1995/05/19 08:05:07	1.1
--- /usr/src/lib/libc/net/Makefile.inc	1995/05/19 08:05:33	1.2
***************
*** 27,33 ****
  	ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3
  MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
  	gethostbyname.3 sethostent.3 gethostbyname.3 gethostent.3 \
! 	gethostbyname.3 herror.3
  MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \
  	getnetent.3 getnetbyname.3 getnetent.3 setnetent.3
  MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \
--- 27,33 ----
  	ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3
  MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
  	gethostbyname.3 sethostent.3 gethostbyname.3 gethostent.3 \
! 	gethostbyname.3 herror.3 h_errno.3 hstrerror.3
  MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \
  	getnetent.3 getnetbyname.3 getnetent.3 setnetent.3
  MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \

>Audit-Trail:
>Unformatted: