* cygwin.din: Add symbol hstrerror.

* net.cc: Change meaning of member `s' of struct host_errmap.
        (set_host_errno): Fix error in loop condition.
        (hstrerror): Ditto.
        (herror): Add appropriate functionality.
        * include/netdb.h: Add declaration of hstrerror.
        * include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR to 29.
This commit is contained in:
Corinna Vinschen 2000-10-14 08:55:44 +00:00
parent aece55b982
commit 7d9688b793
4 changed files with 55 additions and 10 deletions

View File

@ -925,6 +925,7 @@ _ntohs = ntohs
accept = cygwin_accept accept = cygwin_accept
bind = cygwin_bind bind = cygwin_bind
connect = cygwin_connect connect = cygwin_connect
hstrerror = cygwin_hstrerror
herror = cygwin_herror herror = cygwin_herror
inet_addr = cygwin_inet_addr inet_addr = cygwin_inet_addr
inet_network = cygwin_inet_network inet_network = cygwin_inet_network

View File

@ -118,10 +118,11 @@ details. */
26: CW_GET_CYGDRIVE_PREFIXES addition to external.cc 26: CW_GET_CYGDRIVE_PREFIXES addition to external.cc
27: CW_GETPINFO_FULL addition to external.cc 27: CW_GETPINFO_FULL addition to external.cc
28: Accidentally bumped by cgf 28: Accidentally bumped by cgf
29: Export hstrerror
*/ */
#define CYGWIN_VERSION_API_MAJOR 0 #define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 28 #define CYGWIN_VERSION_API_MINOR 29
/* There is also a compatibity version number associated with the /* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible shared memory regions. It is incremented when incompatible

View File

@ -151,6 +151,7 @@ struct servent *getservent (void);
struct rpcent *getrpcent (void); struct rpcent *getrpcent (void);
struct rpcent *getrpcbyname (const char *); struct rpcent *getrpcbyname (const char *);
struct rpcent *getrpcbynumber (int); struct rpcent *getrpcbynumber (int);
const char *hstrerror (int);
void herror (const char *); void herror (const char *);
void sethostent (int); void sethostent (int);
void setnetent (int); void setnetent (int);

View File

@ -252,12 +252,16 @@ __set_winsock_errno (const char *fn, int ln)
} }
} }
/*
* Since the member `s' isn't used for debug output we can use it
* for the error text returned by herror and hstrerror.
*/
static struct tl host_errmap[] = static struct tl host_errmap[] =
{ {
{WSAHOST_NOT_FOUND, "WSAHOST_NOT_FOUND", HOST_NOT_FOUND}, {WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND},
{WSATRY_AGAIN, "WSATRY_AGAIN", TRY_AGAIN}, {WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN},
{WSANO_RECOVERY, "WSANO_RECOVERY", NO_RECOVERY}, {WSANO_RECOVERY, "Unknown server error", NO_RECOVERY},
{WSANO_DATA, "WSANO_DATA", NO_DATA}, {WSANO_DATA, "No address associated with name", NO_DATA},
{0, NULL, 0} {0, NULL, 0}
}; };
@ -268,7 +272,7 @@ set_host_errno ()
int i; int i;
int why = WSAGetLastError (); int why = WSAGetLastError ();
for (i = 0; i < host_errmap[i].w != 0; ++i) for (i = 0; host_errmap[i].w != 0; ++i)
if (why == host_errmap[i].w) if (why == host_errmap[i].w)
break; break;
@ -884,11 +888,49 @@ cygwin_shutdown (int fd, int how)
return res; return res;
} }
/* exported as herror: standards? */ /* exported as hstrerror: BSD 4.3 */
extern "C" void extern "C" const char *
cygwin_herror (const char *) cygwin_hstrerror (int err)
{ {
debug_printf ("********%d*************", __LINE__); int i;
for (i = 0; host_errmap[i].e != 0; ++i)
if (err == host_errmap[i].e)
break;
return host_errmap[i].s;
}
/* exported as herror: BSD 4.3 */
extern "C" void
cygwin_herror (const char *s)
{
if (fdtab.not_open (2))
return;
if (s)
{
write (2, s, strlen (s));
write (2, ": ", 2);
}
const char *h_errstr = cygwin_hstrerror (h_errno);
if (!h_errstr)
switch (h_errno)
{
case NETDB_INTERNAL:
h_errstr = "Resolver internal error";
break;
case NETDB_SUCCESS:
h_errstr = "Resolver error 0 (no error)";
break;
default:
h_errstr = "Unknown resolver error";
break;
}
write (2, h_errstr, strlen (h_errstr));
write (2, "\n", 1);
} }
/* exported as getpeername: standards? */ /* exported as getpeername: standards? */