--- \tempapache\apache-1.3\src\main\rfc1413.c	Tue Sep 16 17:24:08 2003
+++ rfc1413.c	Wed Sep 17 12:50:42 2003
@@ -99,6 +99,32 @@
 
 int ap_rfc1413_timeout = RFC1413_TIMEOUT;	/* Global so it can be changed */
 
+#if (defined(NETWARE) || defined(WIN32))
+#define write(a,b,c) send(a,b,c,0)
+#define read(a,b,c) recv(a,b,c,0)
+#define STATIC 
+
+static int setsocktimeout (int sock, int timeout)
+{
+    u_long msec = 0;
+
+    /* Make sure that we are in blocking mode */
+    if (ioctlsocket(sock, FIONBIO, &msec) == SOCKET_ERROR) {
+        return h_errno;
+    }
+
+    /* Win32 timeouts are in msec, represented as int */
+    msec = timeout * 1000;
+    setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, 
+               (char *) &msec, sizeof(msec));
+    setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, 
+               (char *) &msec, sizeof(msec));
+
+    return 0;
+}
+#else /* NETWARE || WIN32 */
+
+#define STATIC static
 static JMP_BUF timebuf;
 
 /* ident_timeout - handle timeouts */
@@ -106,6 +132,7 @@
 {
     ap_longjmp(timebuf, sig);
 }
+#endif
 
 /* bind_connect - bind both ends of a socket */
 /* Ambarish fix this. Very broken */
@@ -237,22 +264,28 @@
 /* rfc1413 - return remote user name, given socket structures */
 API_EXPORT(char *) ap_rfc1413(conn_rec *conn, server_rec *srv)
 {
-    static char user[RFC1413_USERLEN + 1];	/* XXX */
-    static char *result;
-    static int sock;
+    STATIC char user[RFC1413_USERLEN + 1];	/* XXX */
+    STATIC char *result;
+    STATIC int sock;
 
     result = FROM_UNKNOWN;
 
     sock = ap_psocket_ex(conn->pool, AF_INET, SOCK_STREAM, IPPROTO_TCP, 1);
     if (sock < 0) {
-	ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
-		    "socket: rfc1413: error creating socket");
-	conn->remote_logname = result;
+    	ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
+    		    "socket: rfc1413: error creating socket");
+    	conn->remote_logname = result;
     }
 
     /*
      * Set up a timer so we won't get stuck while waiting for the server.
      */
+#if (defined(NETWARE) || defined(WIN32))
+    if (setsocktimeout(sock, ap_rfc1413_timeout) == 0) {
+        if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user, srv) >= 0)
+            result = ap_pstrdup (conn->pool, user);
+    }
+#else
     if (ap_setjmp(timebuf) == 0) {
 	ap_set_callback_and_alarm(ident_timeout, ap_rfc1413_timeout);
 
@@ -260,8 +293,10 @@
 	    result = user;
     }
     ap_set_callback_and_alarm(NULL, 0);
+#endif
     ap_pclosesocket(conn->pool, sock);
     conn->remote_logname = result;
 
     return conn->remote_logname;
 }
+
