I've been porting Wget to MSDOS using the djgpp environment. The task was rather simple; adding a new directory ./msdos with a config.h and Makefile.dj. I intend to support other DOS-compilerslater. Please take a look at the attached patch and ./msdos files. Would there be any interest in adding this?
--gv
diff -u3 -Hb SVN-Latest\src\connect.c src\connect.c
--- SVN-Latest\src\connect.c Thu Aug 23 19:07:43 2007
+++ src\connect.c Tue Aug 28 15:12:21 2007
@@ -668,7 +668,7 @@
/* 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)
diff -u3 -Hb SVN-Latest\src\init.c src\init.c
--- SVN-Latest\src\init.c Thu Aug 23 19:07:42 2007
+++ src\init.c Tue Aug 28 16:30:39 2007
@@ -103,7 +103,7 @@
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 @@
{ "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 @@
#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 @@
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 @@
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 @@
*pstring = concat_strings (home, "/", val, (char *) 0);
}
-#ifdef WINDOWS
+#if defined(WINDOWS) || defined(MSDOS)
/* Convert "\" to "/". */
{
char *s;
diff -u3 -Hb SVN-Latest\src\main.c src\main.c
--- SVN-Latest\src\main.c Mon Aug 27 22:51:17 2007
+++ src\main.c Tue Aug 28 14:56:38 2007
@@ -244,6 +244,9 @@
{ "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
@@ -387,6 +390,10 @@
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"),
N_("\
@@ -680,6 +687,7 @@
exit (0);
}
+
int
main (int argc, char *const *argv)
{
@@ -891,8 +899,14 @@
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. */
diff -u3 -Hb SVN-Latest\src\openssl.c src\openssl.c
--- SVN-Latest\src\openssl.c Mon Aug 27 21:07:25 2007
+++ src\openssl.c Tue Aug 28 15:45:29 2007
@@ -356,7 +356,7 @@
xfree_null (ctx->last_error);
xfree (ctx);
-#ifdef WINDOWS
+#if defined(WINDOWS) || defined(MSDOS)
closesocket (fd);
#else
close (fd);
diff -u3 -Hb SVN-Latest\src\options.h src\options.h
--- SVN-Latest\src\options.h Thu Aug 23 19:07:42 2007
+++ src\options.h Tue Aug 28 16:31:52 2007
@@ -131,6 +131,10 @@
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? */
diff -u3 -Hb SVN-Latest\src\sysdep.h src\sysdep.h
--- SVN-Latest\src\sysdep.h Thu Aug 23 19:07:42 2007
+++ src\sysdep.h Mon Aug 27 22:03:30 2007
@@ -69,15 +69,15 @@
# 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
diff -u3 -Hb SVN-Latest\src\url.c src\url.c
--- SVN-Latest\src\url.c Thu Aug 23 19:07:44 2007
+++ src\url.c Tue Aug 28 15:56:47 2007
@@ -1220,7 +1220,7 @@
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 */
};
diff -u3 -Hb SVN-Latest\src\utils.c src\utils.c
--- SVN-Latest\src\utils.c Mon Aug 27 22:51:17 2007
+++ src\utils.c Tue Aug 28 15:48:36 2007
@@ -287,9 +287,9 @@
}
/* 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 @@
freopen ("/dev/null", "w", stdout);
freopen ("/dev/null", "w", stderr);
}
-#endif /* not WINDOWS */
+#endif /* !WINDOWS && !MSDOS */
/* "Touch" FILE, i.e. make its mtime ("modified time") equal the time
specified with TM. The atime ("access time") is set to the current
MAKEFILE.DJ
Description: Binary data
CONFIG.H
Description: Binary data
