lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev patch: DJGPP && WATT32 now do DNS lookup via gethostbyname()


From: Leonid Pauzner
Subject: lynx-dev patch: DJGPP && WATT32 now do DNS lookup via gethostbyname()
Date: Wed, 25 Aug 1999 22:08:01 +0400 (MSD)

Hi!

I check whether it is possible to build DJGPP lynx with
unix native DNS lookup (not resolve() but via WATT-32 gethostbyname() etc.)
so we will got a resonable error recovery when DNS lookup is failed,
not a hang interrupted with ^C only.

I made a mimimal changes in HTTCP.c, HTTCP.h and LYUtils.c so compilation
succeed. Doug Kaufman was reporting this patch work via ppp with DOSPPP driver.

With nullpkt.com I got a status message "Nameserver ARP failed"
on external link and return to the command mode in a second. Seems OK.


* DJGPP with WATT32 now doing DNS lookup via LYGetHostByName()/gethostbyname()
  like other lynx ports so we got a reasonable error recovery when DNS lookup
  failed. (For example, we now avoid a hang when wattcp.cfg not configured
  properly - a typical situation when playing with nullpkt.com).
  Build with -DNSL_FORK (in both src and WWW makefiles) is recommended: this
  will prevent unexpected 1 second curses delay when alerting a wrongly
  configured tcp. (No real fork() in DJGPP, unfortunately: this function
  always returns -1 and set 'errno' to ENOMEM, as MS-DOS does not support
  multiple processes. It exists only to assist in porting Unix programs.) - LP



The patch against dev.6 but should also work for any reasonable 2.8.3dev.xx


diff -u ../httcp.c ./httcp.c
--- ../httcp.c  Mon Aug  2 01:19:40 1999
+++ ./httcp.c   Wed Aug 25 20:41:20 1999
@@ -32,6 +32,10 @@
 #include <resolv.h>
 #endif

+#if defined(__DJGPP__) && defined (WATT32)
+#include <netdb.h>
+#endif /* __DJGPP__ */
+
 #define OK_HOST(p) ((p) != 0 && ((p)->h_length) != 0)

 #ifdef SVR4_BSDSELECT
@@ -377,7 +381,7 @@

 PUBLIC int lynx_nsl_status = HT_OK;

-#ifndef DJGPP                  /* much excluded! */
+#if !( defined(__DJGPP__) && !defined(WATT32) )    /* much excluded! */

 #define DEBUG_HOSTENT          /* disable in case of problems */
 #define DEBUG_HOSTENT_CHILD  /* for NSL_FORK, may screw up trace file */
@@ -1151,7 +1155,7 @@
     return NULL;
 }

-#endif /* from here on DJGPP joins us again. */
+#endif /* from here on DJGPP without WATT32 joins us again. */


 /*     Parse a network node address and port
@@ -1248,7 +1252,7 @@
     */
     if (dotcount_ip == 3) {   /* Numeric node address: */

-#ifdef DJGPP
+#if defined(__DJGPP__) && !defined(WATT32)
        soc_in->sin_addr.s_addr = htonl(aton(host));
 #else
 #ifdef DGUX_OLD
@@ -1270,7 +1274,7 @@
 #endif /* HAVE_INET_ATON */
 #endif /* GUSI */
 #endif /* DGUX_OLD */
-#endif /* DJGPP */
+#endif /* __DJGPP__ && !WATT32 */
 #ifndef _WINDOWS_NSL
        FREE(host);
 #endif /* _WINDOWS_NSL */
@@ -1280,7 +1284,7 @@
        CTRACE(tfp, "HTParseInet: Calling LYGetHostByName(%s)\n", host);
 #endif /* MVS */

-#ifdef DJGPP
+#if defined(__DJGPP__) && !defined(WATT32)
        if (!valid_hostname(host)) {
            FREE(host);
            return HT_NOT_ACCEPTABLE; /* only HTDoConnect checks this. */
@@ -1289,12 +1293,12 @@
        if (soc_in->sin_addr.s_addr == 0) {
            goto failed;
        }
-#else /* !DJGPP: */
+#else /* !(__DJGPP__ && !WATT32) */
 #ifdef _WINDOWS_NSL
        phost = LYGetHostByName(host);  /* See above */
        if (!phost) goto failed;
        memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
-#else /* !DJGPP, !_WINDOWS_NSL: */
+#else /* !(__DJGPP__ && !WATT32) && !_WINDOWS_NSL */
        {
            struct hostent  *phost;
            phost = LYGetHostByName(host);      /* See above */
@@ -1318,8 +1322,8 @@
            memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
 #endif /* VMS && CMU_TCP */
        }
-#endif /* !DJGPP, !_WINDOWS_NSL */
-#endif /* !DJGPP */
+#endif /* _WINDOWS_NSL */
+#endif /* __DJGPP__ && !WATT32 */
 #ifndef _WINDOWS_NSL
        FREE(host);
 #endif /* _WINDOWS_NSL */
@@ -1544,7 +1548,7 @@
     } else
 #endif /* SOCKS */
     status = connect(*s, (struct sockaddr*)&soc_address, sizeof(soc_address));
-#ifndef DJGPP
+#ifndef __DJGPP__
     /*
     ** According to the Sun man page for connect:
     **    EINPROGRESS         The socket is non-blocking and the  con-
@@ -1735,7 +1739,7 @@
            errno = saved_errno;        /* I don't trust HTInetStatus */
     }
 #endif /* SOCKET_DEBUG_TRACE */
-#endif /* !DJGPP */
+#endif /* !__DJGPP__ */
     if (status < 0) {
        /*
        **  The connect attempt failed or was interrupted,
diff -u ../httcp.h ./httcp.h
--- ../httcp.h  Wed Jul 14 09:25:26 1999
+++ ./httcp.h   Wed Aug 25 20:46:28 1999
@@ -86,10 +86,10 @@
 */
 extern int lynx_nsl_status;

-#ifndef DJGPP
+#if !(defined(__DJGPP__) && !defined(WATT32))
 extern struct hostent * LYGetHostByName PARAMS((
        CONST char *    str));
-#endif /* DJGPP */
+#endif


 /*      Parse an internet node address and port
diff -u ../lyutils.c ./lyutils.c
--- ../lyutils.c        Mon Aug 16 11:30:16 1999
+++ ./lyutils.c Wed Aug 25 20:41:20 1999
@@ -4851,11 +4851,12 @@
     } else if (Startup && !dump_output_immediately) {
        fprintf(stdout, "%s '%s'%s\n", WWW_FIND_MESSAGE, host, FIRST_SEGMENT);
     }
-#ifndef DJGPP
-    if (LYGetHostByName(host) != NULL)
-#else
+
+#if defined(__DJGPP__) && !defined(WATT32)
     if (resolve(host) != 0)
-#endif /* DJGPP */
+#else /* normal systems */
+    if (LYGetHostByName(host) != NULL)
+#endif
     {
        /*
         *  Clear any residual interrupt. - FM
@@ -4875,11 +4876,11 @@
        FREE(MsgStr);
        return GotHost;
     }
-#ifndef DJGPP
-    else if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED))
-#else /* DJGPP */
+#if defined(__DJGPP__) && !defined(WATT32)
     else if (LYCursesON && HTCheckForInterrupt())
-#endif /* DJGPP */
+#else /* normal systems */
+    else if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED))
+#endif
     {
        /*
         *  Give the user chance to interrupt lookup cycles. - KW & FM
@@ -4976,11 +4977,11 @@
            } else if (Startup && !dump_output_immediately) {
                fprintf(stdout, "%s '%s'%s\n", WWW_FIND_MESSAGE, host, 
GUESSING_SEGMENT);
            }
-#ifdef DJGPP
-           GotHost = (resolve(host) != 0);
-#else
-           GotHost = (LYGetHostByName(host) != NULL);
-#endif /* DJGPP */
+#if defined(__DJGPP__) && !defined(WATT32)
+    if (resolve(host) != 0)
+#else /* normal systems */
+    if (LYGetHostByName(host) != NULL)
+#endif
            if (HostColon != NULL) {
                *HostColon = ':';
            }
@@ -4988,11 +4989,11 @@
                /*
                 *  Give the user chance to interrupt lookup cycles. - KW
                 */
-#ifdef DJGPP
+#if defined(__DJGPP__) && !defined(WATT32)
                if (LYCursesON && HTCheckForInterrupt())
-#else /* !DJGPP */
+#else /* normal systems */
                if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED))
-#endif /* DJGPP */
+#endif
                {
                    CTRACE(tfp,
        "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n",




reply via email to

[Prev in Thread] Current Thread [Next in Thread]