1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Gisle's MS-DOS support

This commit is contained in:
Micah Cowan 2007-09-28 14:47:46 -07:00
parent a5ac5eaee8
commit df8b19a28e
14 changed files with 278 additions and 23 deletions

View File

@ -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

View 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).

4
msdos/ChangeLog Normal file
View File

@ -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.

67
msdos/Makefile.DJ Normal file
View File

@ -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

143
msdos/config.h Normal file
View File

@ -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 */

View 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.

View File

@ -668,7 +668,7 @@ test_socket_open (int sock)
/* 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)

View 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;

View 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);
}
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. */

View 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);

View 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? */

View 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

View File

@ -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 */
};

View File

@ -287,9 +287,9 @@ datetime_str (time_t t)
}
/* 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 */
/* "Touch" FILE, i.e. make its mtime ("modified time") equal the time
specified with TM. The atime ("access time") is set to the current