]> sjero.net Git - wget/commitdiff
Gisle's MS-DOS support
authorMicah Cowan <micah@cowan.name>
Fri, 28 Sep 2007 21:47:46 +0000 (14:47 -0700)
committerMicah Cowan <micah@cowan.name>
Fri, 28 Sep 2007 21:47:46 +0000 (14:47 -0700)
14 files changed:
AUTHORS
ChangeLog.README
msdos/ChangeLog [new file with mode: 0644]
msdos/Makefile.DJ [new file with mode: 0644]
msdos/config.h [new file with mode: 0644]
src/ChangeLog
src/connect.c
src/init.c
src/main.c
src/openssl.c
src/options.h
src/sysdep.h
src/url.c
src/utils.c

diff --git a/AUTHORS b/AUTHORS
index 94adf57e4331378ea10d60e31e558f8d61bab8a4..49a48ca6c5b1e431aa3355b0f854085c506b67c9 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -28,9 +28,9 @@ Ian Abbott.  Contributed bugfixes, Windows-related fixes, provided a
 prototype implementation of the new recursive code, and more.
 Co-maintained Wget during the 1.8 release cycle.
 
-Gisle Vanem.  Contributed Windows improvements, including a port of
-run_with_timeout to Windows, additions to Makefiles, and many bug
-reports and fixes.
+Gisle Vanem.  Contributed Windows and MS-DOS improvements, including a
+port of run_with_timeout to Windows, additions to Makefiles, and many
+bug reports and fixes.
 
 Mauro Tortonesi.  Improved IPv6 support, adding support for dual
 family systems.  Refactored and enhanced FTP IPv6 code. Maintained GNU
index d50b07821e59805de91f110940f1fcd172eaecc9..19394501798117fb869b93579188291e382adc3f 100644 (file)
@@ -10,5 +10,7 @@ Please note that Wget has more than one ChangeLog file:
 
     windows/ChangeLog: documents only changes to files in the windows directory
 
+    msdos/ChangeLog: documents only changes to files in the msdos directory
+
 When checking to see if a patch you sent in has been applied, please
 look in the appropriate ChangeLog(s).
diff --git a/msdos/ChangeLog b/msdos/ChangeLog
new file mode 100644 (file)
index 0000000..dcf8127
--- /dev/null
@@ -0,0 +1,4 @@
+2007-09-24  Gisle Vanem  <giva@bgnett.no>
+
+       * Makefile.DJ, config.h: Added to support building on MS-DOS via
+       DJGPP.
diff --git a/msdos/Makefile.DJ b/msdos/Makefile.DJ
new file mode 100644 (file)
index 0000000..bed35cd
--- /dev/null
@@ -0,0 +1,67 @@
+#
+# GNU Makefile for wget / djgpp / MSDOS.
+# By Gisle Vanem <giva@bgnett.no>.
+#
+.SUFFIXES: .exe .map
+
+USE_OPENSSL = 0
+USE_IPV6    = 1
+
+OPENSSL_ROOT = e:/net/OpenSSL.099
+ZLIB_ROOT    = e:/djgpp/contrib/zlib
+
+VPATH   = ../src
+OBJ_DIR = djgpp.obj
+CC      = gcc
+CFLAGS  = -O2 -g -Wall -Wcast-align -I. -I../src -I/dev/env/WATT_ROOT/inc \
+          -DHAVE_CONFIG_H -DENABLE_DEBUG
+
+# LDFLAGS = -s
+
+ifeq ($(USE_OPENSSL),1)
+  CFLAGS  += -DHAVE_OPENSSL -DHAVE_SSL -I$(OPENSSL_ROOT)
+  EX_LIBS += $(OPENSSL_ROOT)/lib/libssl.a $(OPENSSL_ROOT)/lib/libcrypt.a \
+             $(ZLIB_ROOT)/libz.a
+  SOURCES  = ../src/openssl.c ../src/http-ntlm.c
+endif
+
+ifeq ($(USE_IPV6),1)
+  CFLAGS += -DENABLE_IPV6
+endif
+
+EX_LIBS += /dev/env/WATT_ROOT/lib/libwatt.a
+
+SOURCES += $(addprefix ../src/, cmpt.c connect.c cookies.c ftp.c ftp-basic.c \
+             ftp-ls.c ftp-opie.c getopt.c hash.c host.c html-parse.c html-url.c \
+             http.c init.c log.c main.c gen-md5.c gnu-md5.c netrc.c progress.c \
+             recur.c res.c retr.c safe-ctype.c url.c utils.c version.c convert.c \
+             xmalloc.c ptimer.c spider.c)
+
+OBJECTS = $(addprefix $(OBJ_DIR)/, $(notdir $(SOURCES:.c=.o)))
+
+all: $(OBJ_DIR) ../wget-dos.exe
+       @echo 'Welcome to Wget'
+
+$(OBJ_DIR):
+       mkdir $(OBJ_DIR)
+
+../wget-dos.exe: $(OBJECTS)
+       $(CC) $(LDFLAGS) -o $@ $^ $(EX_LIBS)
+
+clean:
+       rm -f $(OBJECTS) $(MAPFILE)
+
+vclean realclean: clean
+       rm -f ../wget-dos.exe depend.dj
+       - rmdir $(OBJ_DIR)
+
+$(OBJ_DIR)/%.o: %.c
+       $(CC) $(CFLAGS) -o $@ -c $<
+       @echo
+
+depend:
+       $(CC) -MM $(CFLAGS) $(SOURCES) | \
+        sed -e 's/^\([a-zA-Z0-9_-]*\.o:\)/$$(OBJ_DIR)\/\1/' > depend.dj
+
+-include depend.dj
+
diff --git a/msdos/config.h b/msdos/config.h
new file mode 100644 (file)
index 0000000..b5a4625
--- /dev/null
@@ -0,0 +1,143 @@
+/* Configuration header file for MS-DOS/Watt-32
+
+   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+   In addition, as a special exception, the Free Software Foundation
+   gives permission to link the code of its release of Wget with the
+   OpenSSL project's "OpenSSL" library (or with modified versions of it
+   that use the same license as the "OpenSSL" library), and distribute
+   the linked executables.  You must obey the GNU General Public License
+   in all respects for all of the code used other than "OpenSSL".  If you
+   modify this file, you may extend this exception to your version of the
+   file, but you are not obligated to do so.  If you do not wish to do
+   so, delete this exception statement from your version.  */
+
+
+#ifndef CONFIG_DOS_H
+#define CONFIG_DOS_H
+
+#include <stdlib.h>
+#include <limits.h>
+#include <tcp.h>
+#include <malloc.h>
+
+#ifdef __DJGPP__
+#include <sys/config.h>
+#endif
+
+#include <sys/errno.h>
+
+#if defined(__WATCOMC__) && (__WATCOMC__ >= 1250)  /* OW 1.5+ */
+  #define OPENWATCOM_15
+#endif
+
+#if defined(__HIGHC__)
+  #define inline
+  #define HAVE_UNISTD_H 1
+  #define HAVE_UTIME_H 1
+#endif
+
+#if defined(__WATCOMC__) || defined(__BORLANDC__)
+  #define inline
+#endif
+
+#ifdef HAVE_SSL
+  #define OPENSSL_NO_KRB5
+#endif
+
+#define STDC_HEADERS 1
+#define RETSIGTYPE void
+
+#define USE_OPIE 1
+#define USE_DIGEST 1
+#define DEBUG
+
+#ifdef __DJGPP__
+  #define HAVE_STRUCT_UTIMBUF 1
+  #define HAVE_UNAME 1
+  #define HAVE_UTIME_H 1
+  #define HAVE_STRCASECMP 1
+  #define HAVE_STRNCASECMP 1
+  #define HAVE_SYS_SELECT_H 1
+  #define HAVE_USLEEP 1
+  #define HAVE_SIGNAL 1
+  #define HAVE_BASENAME 1
+  #define HAVE_SIGSETJMP 1
+  #define HAVE_SIGBLOCK 1
+  #define HAVE__BOOL 1
+
+  #if (DJGPP_MINOR >= 4)
+    #include <stdbool.h>
+    #define HAVE_SNPRINTF 1
+    #define HAVE_VSNPRINTF 1
+    #define HAVE_UINT32_T 1
+  #endif
+#endif
+
+#ifdef __HIGHC__
+  #define HAVE_STRUCT_UTIMBUF 1
+  #define HAVE_UTIME_H 1
+#endif
+
+#ifdef OPENWATCOM_15
+  #define HAVE_STRCASECMP
+  #define HAVE_STRNCASECMP
+#endif
+
+#define HAVE_GETHOSTBYNAME 1
+#define HAVE_GETHOSTNAME 1
+#define HAVE_SELECT 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRSTR 1
+#define HAVE_MKTIME 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_MD5 1
+#define HAVE_BUILTIN_MD5 1
+#define HAVE_ISATTY 1
+#define HAVE_MEMMOVE 1
+
+#define OS_TYPE "DOS"
+#define CTRLBREAK_BACKGND 1
+#define PROTOTYPES 1
+
+#define WGET_USE_STDARG
+
+#define lookup_host  wget_lookuphost
+#define select       select_s
+#define socklen_t    int
+
+#define sock_read    wget_sock_read
+#define sock_write   wget_sock_write
+#define sock_close   wget_sock_close
+
+#if defined(__DJGPP__)
+  #define MKDIR(p,a) mkdir(p,a)
+#else
+  #define strcasecmp stricmp
+  #define MKDIR(p,a) mkdir(p)
+#endif
+
+#if !defined(MSDOS)
+#define MSDOS
+#endif
+
+#endif  /* CONFIG_DOS_H */
index 17e398607afbfcfb49399b89917debf30bf65a2f..e0583343d464bef9d43053d3360366620ecc5180 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-24  Gisle Vanem  <giva@bgnett.no>
+
+       * connect.c, init.c, main.c, openssl.c, options.h, sysdep.h,
+       url.c, utils.c: Added support for building on MS-DOS.
+
 2007-09-24  Jochen Roderburg  <roderburg@uni-koeln.de>
 
        * http.c (http_zero): Remove no-longer-used local_size variable.
index 11d6e193faa69fa3603bbf885404e22efdad9f0a..0188353cfa812ee7393f76c9a13717aca08a06e7 100644 (file)
@@ -668,7 +668,7 @@ test_socket_open (int sock)
 \f
 /* Basic socket operations, mostly EINTR wrappers.  */
 
-#ifdef WINDOWS
+#if defined(WINDOWS) || defined(MSDOS)
 # define read(fd, buf, cnt) recv (fd, buf, cnt, 0)
 # define write(fd, buf, cnt) send (fd, buf, cnt, 0)
 # define close(fd) closesocket (fd)
index 7d861922741ecef84eb62c0d4a07ee99b5564084..d8c71764350419a943b67e1db5f2cd821e8890e1 100644 (file)
@@ -103,7 +103,7 @@ CMD_DECLARE (cmd_spec_verbose);
    add any entries that allocate memory (e.g. cmd_string and
    cmd_vector) to the cleanup() function below. */
 
-static struct {
+static const struct {
   const char *name;
   void *place;
   bool (*action) (const char *, const char *, void *);
@@ -241,7 +241,10 @@ static struct {
   { "useragent",        NULL,                   cmd_spec_useragent },
   { "verbose",          NULL,                   cmd_spec_verbose },
   { "wait",             &opt.wait,              cmd_time },
-  { "waitretry",        &opt.waitretry,         cmd_time }
+  { "waitretry",        &opt.waitretry,         cmd_time },
+#ifdef MSDOS
+  { "wdebug",           &opt.wdebug,            cmd_boolean },
+#endif
 };
 
 /* Look up CMDNAME in the commands[] and return its position in the
@@ -313,10 +316,10 @@ defaults (void)
 #endif
 
   /* The default for file name restriction defaults to the OS type. */
-#if !defined(WINDOWS) && !defined(__CYGWIN__)
-  opt.restrict_files_os = restrict_unix;
-#else
+#if defined(WINDOWS) || defined(MSDOS) || defined(__CYGWIN__)
   opt.restrict_files_os = restrict_windows;
+#else
+  opt.restrict_files_os = restrict_unix;
 #endif
   opt.restrict_files_ctrl = true;
   opt.restrict_files_case = restrict_no_case_restriction;
@@ -333,14 +336,27 @@ home_dir (void)
 
   if (!home)
     {
-#ifndef WINDOWS
+#if defined(MSDOS)
+      /* Under MSDOS, if $HOME isn't defined, use the directory where
+         `wget.exe' resides.  */
+      const char *_w32_get_argv0 (void); /* in libwatt.a/pcconfig.c */
+      char *p, buf[PATH_MAX];
+
+      strcpy (buf, _w32_get_argv0 ());
+      p = strrchr (buf, '/');            /* djgpp */
+      if (!p)
+        p = strrchr (buf, '\\');          /* others */
+      assert (p);
+      *p = '\0';
+      home = buf;
+#elif !defined(WINDOWS)
       /* If HOME is not defined, try getting it from the password
          file.  */
       struct passwd *pwd = getpwuid (getuid ());
       if (!pwd || !pwd->pw_dir)
         return NULL;
       home = pwd->pw_dir;
-#else  /* WINDOWS */
+#else  /* !WINDOWS */
       /* Under Windows, if $HOME isn't defined, use the directory where
          `wget.exe' resides.  */
       home = ws_mypath ();
@@ -750,10 +766,10 @@ cmd_string (const char *com, const char *val, void *place)
   return true;
 }
 
-#ifndef WINDOWS
-# define ISSEP(c) ((c) == '/')
-#else
+#if defined(WINDOWS) || defined(MSDOS)
 # define ISSEP(c) ((c) == '/' || (c) == '\\')
+#else
+# define ISSEP(c) ((c) == '/')
 #endif
 
 /* Like the above, but handles tilde-expansion when reading a user's
@@ -791,7 +807,7 @@ cmd_file (const char *com, const char *val, void *place)
       *pstring = concat_strings (home, "/", val, (char *) 0);
     }
 
-#ifdef WINDOWS
+#if defined(WINDOWS) || defined(MSDOS)
   /* Convert "\" to "/". */
   {
     char *s;
index 4f0c123c5bd1879d26cad1865c899f4002a6e019..ea3088c2e95782af3140fca915dc52da835bbcc7 100644 (file)
@@ -244,6 +244,9 @@ static struct cmdline_option option_data[] =
     { "version", 'V', OPT_FUNCALL, (void *) print_version, no_argument },
     { "wait", 'w', OPT_VALUE, "wait", -1 },
     { "waitretry", 0, OPT_VALUE, "waitretry", -1 },
+#ifdef MSDOS
+    { "wdebug", 0, OPT_BOOLEAN, "wdebug", -1 },
+#endif
   };
 
 #undef WHEN_DEBUG
@@ -386,6 +389,10 @@ Logging and input file:\n"),
 #ifdef ENABLE_DEBUG
     N_("\
   -d,  --debug               print lots of debugging information.\n"),
+#endif
+#ifdef MSDOS
+    N_("\
+       --wdebug              print Watt-32 debug output.\n"),
 #endif
     N_("\
   -q,  --quiet               quiet (no output).\n"),
@@ -680,6 +687,7 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout);
   exit (0);
 }
 \f
+
 int
 main (int argc, char *const *argv)
 {
@@ -891,8 +899,14 @@ Can't timestamp and not clobber old files at the same time.\n"));
       exit (1);
     }
 
+#ifdef MSDOS
+  if (opt.wdebug)
+     dbug_init();
+  sock_init();
+#else
   if (opt.background)
     fork_to_background ();
+#endif
 
   /* Initialize progress.  Have to do this after the options are
      processed so we know where the log file is.  */
index 71faa0c0b26cda27f61f2335ef56da61b2806a66..0d4ec155667060b5b8fd701c1f4e0d48fabcb924 100644 (file)
@@ -356,7 +356,7 @@ openssl_close (int fd, void *arg)
   xfree_null (ctx->last_error);
   xfree (ctx);
 
-#ifdef WINDOWS
+#if defined(WINDOWS) || defined(MSDOS)
   closesocket (fd);
 #else
   close (fd);
index 7fda95e3a47098ad010ea328c24beff0345f2d86..5fc49e2a69b2438bbede7bb78cfc89ebab9f1039 100644 (file)
@@ -131,6 +131,10 @@ struct options
   bool debug;                  /* Debugging on/off */
 #endif
 
+#ifdef MSDOS
+  bool wdebug;                  /* Watt-32 tcp/ip debugging on/off */
+#endif
+
   bool timestamping;           /* Whether to use time-stamping. */
 
   bool backup_converted;       /* Do we save pre-converted files as *.orig? */
index 98b3c13bd8c6d1a0f5e3e725348e264099e59693..2c7ba31eb80a0b2687f4537fcdd390177bdc06de 100644 (file)
@@ -69,15 +69,15 @@ typedef unsigned char _Bool;
 # define __bool_true_false_are_defined 1
 #endif
 
-/* Needed for compilation under OS/2: */
-#ifdef __EMX__
+/* Needed for compilation under OS/2 and MSDOS */
+#if defined(__EMX__) || defined(MSDOS)
 # ifndef S_ISLNK
 #  define S_ISLNK(m) 0
 # endif
 # ifndef lstat
 #  define lstat stat
 # endif
-#endif /* __EMX__ */
+#endif /* __EMX__ || MSDOS */
 
 /* Reportedly, stat() macros are broken on some old systems.  Those
    systems will have to fend for themselves, as I will not introduce
index d721501ab0f53527c0f4337e66e9d81017cd3f4c..9b20c51916b950b74f8209fef086f34edc2ff862 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -1220,7 +1220,7 @@ append_char (char ch, struct growable *dest)
 
 enum {
   filechr_not_unix    = 1,      /* unusable on Unix, / and \0 */
-  filechr_not_windows = 2,      /* unusable on Windows, one of \|/<>?:*" */
+  filechr_not_windows = 2,      /* unusable on MSDOS/Windows, one of \|/<>?:*" */
   filechr_control     = 4       /* a control character, e.g. 0-31 */
 };
 
index 0a222d997925fb8b5e4538d58ab3e825ee853032..937eb57f3712f4341908b77c6d668a2913c75148 100644 (file)
@@ -287,9 +287,9 @@ datetime_str (time_t t)
 }
 \f
 /* The Windows versions of the following two functions are defined in
-   mswindows.c.  */
+   mswindows.c. On MSDOS this function should never be called. */
 
-#ifndef WINDOWS
+#if !defined(WINDOWS) && !defined(MSDOS)
 void
 fork_to_background (void)
 {
@@ -333,7 +333,7 @@ fork_to_background (void)
   freopen ("/dev/null", "w", stdout);
   freopen ("/dev/null", "w", stderr);
 }
-#endif /* not WINDOWS */
+#endif /* !WINDOWS && !MSDOS */
 \f
 /* "Touch" FILE, i.e. make its mtime ("modified time") equal the time
    specified with TM.  The atime ("access time") is set to the current