Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2000-10-14 12:55:44 +0400
committerCorinna Vinschen <corinna@vinschen.de>2000-10-14 12:55:44 +0400
commit7d9688b79355c0e0d91ce1f6d1e5189ed8121797 (patch)
tree2d9b0bdae274e74b35a87dd9a5c2f36eabc65cbc /winsup/cygwin/net.cc
parentaece55b982a562c6ae305d3892b4206f3efa3f22 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc58
1 files changed, 50 insertions, 8 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 8f4220637..c6d88f613 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -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[] =
{
- {WSAHOST_NOT_FOUND, "WSAHOST_NOT_FOUND", HOST_NOT_FOUND},
- {WSATRY_AGAIN, "WSATRY_AGAIN", TRY_AGAIN},
- {WSANO_RECOVERY, "WSANO_RECOVERY", NO_RECOVERY},
- {WSANO_DATA, "WSANO_DATA", NO_DATA},
+ {WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND},
+ {WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN},
+ {WSANO_RECOVERY, "Unknown server error", NO_RECOVERY},
+ {WSANO_DATA, "No address associated with name", NO_DATA},
{0, NULL, 0}
};
@@ -268,7 +272,7 @@ set_host_errno ()
int i;
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)
break;
@@ -884,11 +888,49 @@ cygwin_shutdown (int fd, int how)
return res;
}
-/* exported as herror: standards? */
+/* exported as hstrerror: BSD 4.3 */
+extern "C" const char *
+cygwin_hstrerror (int err)
+{
+ 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 *)
+cygwin_herror (const char *s)
{
- debug_printf ("********%d*************", __LINE__);
+ 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? */