[w3m-dev 04155] w3m mingw patch
NOKUBI Takatsugu <[email protected]> Tue, 10 Jan 2006 17:36:19 +0900
| Newsgroups | gmane.comp.web.w3m.devel |
|---|---|
| Message-ID | <[email protected]> |
w3mMingW emacs-w3m-dump fork() config.h * setjmp * signaldefine configure.ac * cross buildnsl, dl(*1) * mingwUSE_BINMODE_STREAM etc.c * pwd.hinclude * * setpgrp() * fork()open_pipe_rw, mySystem * getpw*expandName$HOME * sys/sockect.hwinsock.h file.c * getpassinputLine * fork()(doFileCopy, doFileSave, uncompress_stream) ftp.c * include * getpassinputLine * getpw*anonymous indep.c * include * ~user istream.c * include * read, closerecv, closesocket local.c * include * localcgi_post(open_pipe_rw) main.c * winsock * JMP_BUF rc.c * mkdir terms.c * include * termios(*2) * curses(*3) url.c * include * write, close *1: AC_W3M_EXTLIBSSITE_CONFIG *2: *3: ANSI : * basic -- E-mail: [email protected] [email protected] / [email protected] Index: config.h.in =================================================================== RCS file: /cvsroot/w3m/w3m/config.h.in,v retrieving revision 1.16 diff -u -r1.16 config.h.in --- config.h.in 26 Feb 2005 17:06:44 -0000 1.16 +++ config.h.in 10 Jan 2006 08:03:37 -0000 @@ -166,9 +166,15 @@ #define SIGNAL_RETURN @SIGNAL_RETURN@ #ifdef HAVE_SIGSETJMP +#ifdef __MINGW32_VERSION +# define SETJMP(env) setjmp(env) +# define LONGJMP(env,val) longjmp(env, val) +# define JMP_BUF jmp_buf +#else # define SETJMP(env) sigsetjmp(env,1) # define LONGJMP(env,val) siglongjmp(env,val) # define JMP_BUF sigjmp_buf +#endif /* __MINGW32_VERSION */ #else # define SETJMP(env) setjmp(env) # define LONGJMP(env,val) longjmp(env) @@ -233,4 +239,12 @@ #define BUNZIP2_NAME "bunzip2" #define INFLATE_NAME "inflate" +#ifdef __MINGW32_VERSION +#define SIGKILL SIGTERM +#define S_IXGRP 0 +#define S_IXOTH 0 +#define S_IRWXG 0 +#define S_IRWXO 0 +#endif /* __MINGW32_VERSION */ + #endif /* CONFIG_H_SEEN */ Index: configure.ac =================================================================== RCS file: /cvsroot/w3m/w3m/configure.ac,v retrieving revision 1.1 diff -u -r1.1 configure.ac --- configure.ac 26 Feb 2005 17:13:59 -0000 1.1 +++ configure.ac 10 Jan 2006 08:03:41 -0000 @@ -83,7 +83,7 @@ AC_W3M_EXT_BROWSER dnl Checks for ext libs -for lib in bsd BSD 44bsd socket nsl dld dl +for lib in bsd BSD 44bsd socket dld do AC_W3M_EXTLIBS($lib) done @@ -110,7 +110,7 @@ AC_SUBST(USE_BINMODE_STREAM) case "$host_os" in - *cygwin*|*os2-emx*) + *cygwin*|*os2-emx*|*mingw*) AC_DEFINE(USE_BINMODE_STREAM) ;; esac Index: etc.c =================================================================== RCS file: /cvsroot/w3m/w3m/etc.c,v retrieving revision 1.78 diff -u -r1.78 etc.c --- etc.c 16 Apr 2004 18:47:19 -0000 1.78 +++ etc.c 10 Jan 2006 08:03:41 -0000 @@ -1,6 +1,8 @@ /* $Id: etc.c,v 1.78 2004/04/16 18:47:19 ukai Exp $ */ #include "fm.h" +#ifndef __MINGW32_VERSION #include <pwd.h> +#endif #include "myctype.h" #include "html.h" #include "local.h" @@ -1310,9 +1312,13 @@ static void reset_signals(void) { +#ifdef SIGHUP mySignal(SIGHUP, SIG_DFL); /* terminate process */ +#endif mySignal(SIGINT, SIG_DFL); /* terminate process */ +#ifdef SIGQUIT mySignal(SIGQUIT, SIG_DFL); /* terminate process */ +#endif mySignal(SIGTERM, SIG_DFL); /* terminate process */ mySignal(SIGILL, SIG_DFL); /* create core image */ mySignal(SIGIOT, SIG_DFL); /* create core image */ @@ -1355,8 +1361,10 @@ { reset_signals(); mySignal(SIGINT, SIG_IGN); +#ifndef __MINGW32_VERSION if (!child) SETPGRP(); +#endif /* __MINGW32_VERSION */ close_tty(); close_all_fds_except(i, f); QuietMessage = TRUE; @@ -1364,6 +1372,7 @@ TrapSignal = FALSE; } +#ifndef __MINGW32_VERSION pid_t open_pipe_rw(FILE ** fr, FILE ** fw) { @@ -1421,6 +1430,7 @@ err0: return (pid_t) - 1; } +#endif /* __MINGW32_VERSION */ void myExec(char *command) @@ -1433,6 +1443,7 @@ void mySystem(char *command, int background) { +#ifndef __MINGW32_VERSION if (background) { #ifndef __EMX__ flush_tty(); @@ -1447,6 +1458,7 @@ #endif } else +#endif /* __MINGW32_VERSION */ system(command); } @@ -1516,6 +1528,13 @@ return tmp; } +#ifdef __MINGW32_VERSION +char * +expandName(char *name) +{ + return getenv("HOME"); +} +#else char * expandName(char *name) { @@ -1559,6 +1578,7 @@ rest: return name; } +#endif char * file_to_url(char *file) @@ -1898,7 +1918,11 @@ #ifdef INET6 #include <sys/socket.h> #endif /* INET6 */ +#ifndef __MINGW32_VERSION #include <netdb.h> +#else +#include <winsock.h> +#endif char * FQDN(char *host) { Index: file.c =================================================================== RCS file: /cvsroot/w3m/w3m/file.c,v retrieving revision 1.237 diff -u -r1.237 file.c --- file.c 4 Jan 2005 15:51:04 -0000 1.237 +++ file.c 10 Jan 2006 08:03:47 -0000 @@ -1599,9 +1599,17 @@ getpassphrase(proxy ? "Proxy Password: " : "Password: ")); #else +#ifndef __MINGW32_VERSION *pwd = Strnew_charp((char *) getpass(proxy ? "Proxy Password: " : "Password: ")); +#else + term_raw(); + *pwd = Strnew_charp((char *) + inputLine(proxy ? "Proxy Password: " : + "Password: ", NULL, IN_PASSWORD)); + term_cbreak(); +#endif /* __MINGW32_VERSION */ #endif } } @@ -7670,6 +7678,7 @@ int _doFileCopy(char *tmpf, char *defstr, int download) { +#ifndef __MINGW32_VERSION Str msg; Str filen; char *p, *q = NULL; @@ -7776,6 +7785,7 @@ if (PreserveTimestamp && !is_pipe && !stat(tmpf, &st)) setModtime(p, st.st_mtime); } +#endif /* __MINGW32_VERSION */ return 0; } @@ -7790,6 +7800,7 @@ int doFileSave(URLFile uf, char *defstr) { +#ifndef __MINGW32_VERSION Str msg; Str filen; char *p, *q; @@ -7875,6 +7886,7 @@ if (PreserveTimestamp && uf.modtime != -1) setModtime(p, uf.modtime); } +#endif /* __MINGW32_VERSION */ return 0; } @@ -7945,6 +7957,7 @@ static void uncompress_stream(URLFile *uf, char **src) { +#ifndef __MINGW32_VERSION pid_t pid1; FILE *f1; char *expand_cmd = GUNZIP_CMDNAME; @@ -8028,6 +8041,7 @@ } UFhalfclose(uf); uf->stream = newFileStream(f1, (void (*)())pclose); +#endif /* __MINGW32_VERSION */ } static FILE * Index: ftp.c =================================================================== RCS file: /cvsroot/w3m/w3m/ftp.c,v retrieving revision 1.35 diff -u -r1.35 ftp.c --- ftp.c 16 Apr 2004 18:47:19 -0000 1.35 +++ ftp.c 10 Jan 2006 08:03:47 -0000 @@ -1,6 +1,8 @@ /* $Id: ftp.c,v 1.35 2004/04/16 18:47:19 ukai Exp $ */ #include <stdio.h> +#ifndef __MINGW32_VERSION #include <pwd.h> +#endif /* __MINGW32_VERSION */ #include <Str.h> #include <signal.h> #include <setjmp.h> @@ -14,10 +16,14 @@ #include <malloc.h> #endif /* DEBUG */ +#ifndef __MINGW32_VERSION #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> +#else +#include <winsock.h> +#endif /* __MINGW32_VERSION */ typedef struct _FTP { char *host; @@ -371,7 +377,14 @@ term_cbreak(); } else { +#ifndef __MINGW32_VERSION pwd = Strnew_charp((char *)getpass("Password: ")); +#else + term_raw(); + pwd = Strnew_charp(inputLine("Password: ", NULL, IN_PASSWORD)); + pwd = Str_conv_to_system(pwd); + term_cbreak(); +#endif /* __MINGW32_VERSION */ } add_auth_cookie_flag = TRUE; } @@ -380,8 +393,12 @@ else if (ftppasswd != NULL && *ftppasswd != '\0') pass = ftppasswd; else { +#ifndef __MINGW32_VERSION struct passwd *mypw = getpwuid(getuid()); tmp = Strnew_charp(mypw ? mypw->pw_name : "anonymous"); +#else + tmp = Strnew_charp("anonymous"); +#endif __MINGW32_VERSION Strcat_char(tmp, '@'); pass = tmp->ptr; } Index: indep.c =================================================================== RCS file: /cvsroot/w3m/w3m/indep.c,v retrieving revision 1.35 diff -u -r1.35 indep.c --- indep.c 9 Apr 2004 17:18:49 -0000 1.35 +++ indep.c 10 Jan 2006 08:03:47 -0000 @@ -1,7 +1,9 @@ /* $Id: indep.c,v 1.35 2004/04/09 17:18:49 ukai Exp $ */ #include "fm.h" #include <stdio.h> +#ifndef __MINGW32_VERSION #include <pwd.h> +#endif /* __MINGW32_VERSION */ #include <sys/param.h> #include <sys/types.h> #include <stdlib.h> @@ -225,6 +227,7 @@ p = name; if (*p == '~') { p++; +#ifndef __MINGW32_VERSION if (IS_ALPHA(*p)) { char *q = strchr(p, '/'); if (q) { /* ~user/dir... */ @@ -238,8 +241,9 @@ if (!passent) goto rest; extpath = Strnew_charp(passent->pw_dir); - } - else if (*p == '/' || *p == '\0') { /* ~/dir... or ~ */ + } else +#endif /* __MINGW32_VERSION */ + if (*p == '/' || *p == '\0') { /* ~/dir... or ~ */ extpath = Strnew_charp(getenv("HOME")); } else Index: istream.c =================================================================== RCS file: /cvsroot/w3m/w3m/istream.c,v retrieving revision 1.23 diff -u -r1.23 istream.c --- istream.c 20 Oct 2003 16:41:56 -0000 1.23 +++ istream.c 10 Jan 2006 08:03:47 -0000 @@ -6,6 +6,9 @@ #ifdef USE_SSL #include <openssl/x509v3.h> #endif +#ifdef __MINGW32_VERSION +#include <winsock.h> +#endif #define uchar unsigned char @@ -617,13 +620,21 @@ static void basic_close(int *handle) { +#ifdef __MINGW32_VERSION + closesocket(*(int *)handle); +#else close(*(int *)handle); +#endif } static int basic_read(int *handle, char *buf, int len) { +#ifdef __MINGW32_VERSION + return recv(*(int *)handle, buf, len, 0); +#else return read(*(int *)handle, buf, len); +#endif } static void Index: local.c =================================================================== RCS file: /cvsroot/w3m/w3m/local.c,v retrieving revision 1.31 diff -u -r1.31 local.c --- local.c 26 Sep 2003 17:59:51 -0000 1.31 +++ local.c 10 Jan 2006 08:03:47 -0000 @@ -16,6 +16,10 @@ #include "local.h" #include "hash.h" +#ifdef __MINGW32_VERSION +#include <winsock.h> +#endif + #define CGIFN_NORMAL 0 #define CGIFN_LIBDIR 1 #define CGIFN_CGIBIN 2 @@ -193,8 +197,10 @@ return -1; if (S_ISDIR(st.st_mode)) return -1; +#ifndef __MINGW32_VERSION if ((st.st_uid == geteuid() && (st.st_mode & S_IXUSR)) || (st.st_gid == getegid() && (st.st_mode & S_IXGRP)) || (st.st_mode & S_IXOTH)) /* executable */ return 0; +#endif return -1; } @@ -353,6 +359,9 @@ pid_t pid; char *file = uri, *name = uri, *path_info = NULL, *tmpf = NULL; +#ifdef __MINGW32_VERSION + return NULL; +#else status = cgi_filename(uri, &file, &name, &path_info); if (check_local_cgi(file, status) < 0) return NULL; @@ -412,4 +421,5 @@ file, mybasename(file), strerror(errno)); exit(1); return NULL; +#endif } Index: main.c =================================================================== RCS file: /cvsroot/w3m/w3m/main.c,v retrieving revision 1.247 diff -u -r1.247 main.c --- main.c 26 Feb 2005 17:06:44 -0000 1.247 +++ main.c 10 Jan 2006 08:03:47 -0000 @@ -24,6 +24,12 @@ #endif /* defined(USE_GPM) || defined(USE_SYSMOUSE) */ #endif +#ifdef __MINGW32_VERSION +#include <winsock.h> + +WSADATA WSAData; +#endif + #define DSTR_LEN 256 Hist *LoadHist; @@ -65,7 +71,11 @@ static char *SearchString = NULL; int (*searchRoutine) (Buffer *, char *); +#ifndef __MINGW32_VERSION JMP_BUF IntReturn; +#else +_JBTYPE IntReturn[_JBLEN]; +#endif /* __MINGW32_VERSION */ static void delBuffer(Buffer *buf); static void cmd_loadfile(char *path); @@ -748,6 +758,23 @@ sock_init(); #endif +#ifdef __MINGW32_VERSION + { + int err; + WORD wVerReq; + + wVerReq = MAKEWORD(1, 1); + + err = WSAStartup(wVerReq, &WSAData); + if (err != 0) + { + fprintf(stderr, "Can't find winsock\n"); + return 1; + } + _fmode = _O_BINARY; + } +#endif + FirstTab = NULL; LastTab = NULL; nTab = 0; @@ -5714,6 +5741,9 @@ #ifdef USE_NNTP disconnectNews(); #endif +#ifdef __MINGW32_VERSION + WSACleanup(); +#endif exit(i); } @@ -6438,7 +6468,9 @@ for (; arg; arg = arg->next) { if (!strncmp(arg->arg, "stop", 4)) { pid = (pid_t) atoi(&arg->arg[4]); +#ifndef __MINGW32_VERSION kill(pid, SIGKILL); +#endif } else if (!strncmp(arg->arg, "ok", 2)) pid = (pid_t) atoi(&arg->arg[2]); @@ -6472,7 +6504,9 @@ for (d = FirstDL; d != NULL; d = d->next) { if (d->ok) continue; +#ifndef __MINGW32_VERSION kill(d->pid, SIGKILL); +#endif unlink(d->lock); } } Index: rc.c =================================================================== RCS file: /cvsroot/w3m/w3m/rc.c,v retrieving revision 1.99 diff -u -r1.99 rc.c --- rc.c 2 Aug 2004 15:40:50 -0000 1.99 +++ rc.c 10 Jan 2006 08:03:47 -0000 @@ -1111,7 +1111,11 @@ return mkdir(abs, mode); } #else /* not __EMX__ */ +#ifdef __MINGW32_VERSION +#define do_mkdir(dir,mode) mkdir(dir) +#else #define do_mkdir(dir,mode) mkdir(dir,mode) +#endif /* not __MINW32_VERSION */ #endif /* not __EMX__ */ void Index: terms.c =================================================================== RCS file: /cvsroot/w3m/w3m/terms.c,v retrieving revision 1.53 diff -u -r1.53 terms.c --- terms.c 18 Jan 2005 16:38:01 -0000 1.53 +++ terms.c 10 Jan 2006 08:03:48 -0000 @@ -15,7 +15,11 @@ #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> #endif +#ifndef __MINGW32_VERSION #include <sys/ioctl.h> +#else +#include <winsock.h> +#endif /* __MINGW32_VERSION */ #ifdef USE_MOUSE #ifdef USE_GPM #include <gpm.h> @@ -287,6 +291,42 @@ #define MODEFLAG(d) ((d).sg_flags) #endif /* HAVE_SGTTY_H */ +#ifdef __MINGW32_VERSION +/* dummy struct */ +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 32 +struct termios + { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ + }; +typedef struct termios TerminalMode; +#define TerminalSet(fd,x) (0) +#define TerminalGet(fd,x) (0) +#define MODEFLAG(d) (0) + +/* dummy defines */ +#define SIGHUP (0) +#define SIGQUIT (0) +#define ECHO (0) +#define ISIG (0) +#define VEOF (0) +#define ICANON (0) +#define IXON (0) +#define IXOFF (0) + +char *ttyname(int); +#endif /* __MINGW32_VERSION */ + #define MAX_LINE 200 #define MAX_COLUMN 400 @@ -511,6 +551,7 @@ void ttymode_set(int mode, int imode) { +#ifndef __MINGW32_VERSION TerminalMode ioval; TerminalGet(tty, &ioval); @@ -525,11 +566,13 @@ printf("Error occured while set %x: errno=%d\n", mode, errno); reset_exit(SIGNAL_ARGLIST); } +#endif } void ttymode_reset(int mode, int imode) { +#ifndef __MINGW32_VERSION TerminalMode ioval; TerminalGet(tty, &ioval); @@ -544,6 +587,7 @@ printf("Error occured while reset %x: errno=%d\n", mode, errno); reset_exit(SIGNAL_ARGLIST); } +#endif /* __MINGW32_VERSION */ } #ifndef HAVE_SGTTY_H @@ -2172,3 +2216,40 @@ #endif } #endif + +#ifdef __MINGW32_VERSION + +int tgetent(char *bp, char *name) +{ + return 0; +} + +int tgetnum(char *id) +{ + return -1; +} + +int tgetflag(char *id) +{ + return 0; +} + +char *tgetstr(char *id, char **area) +{ + id = ""; +} + +char *tgoto(char *cap, int col, int row) +{ +} + +int tputs(char *str, int affcnt, int (*putc)(char)) +{ +} + +char *ttyname(int tty) +{ + return "CON"; +} + +#endif /* __MINGW32_VERSION */ Index: url.c =================================================================== RCS file: /cvsroot/w3m/w3m/url.c,v retrieving revision 1.89 diff -u -r1.89 url.c --- url.c 16 Apr 2004 18:47:19 -0000 1.89 +++ url.c 10 Jan 2006 08:03:48 -0000 @@ -1,10 +1,14 @@ /* $Id: url.c,v 1.89 2004/04/16 18:47:19 ukai Exp $ */ #include "fm.h" +#ifndef __MINGW32_VERSION #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> +#else +#include <winsock.h> +#endif /* __MINGW32_VERSION */ #include <signal.h> #include <setjmp.h> @@ -31,6 +35,11 @@ #define write(a,b,c) write_s(a,b,c) #endif /* __WATT32__ */ +#ifdef __MINGW32_VERSION +#define write(a,b,c) send(a,b,c, 0) +#define close(fd) closesocket(fd) +#endif + #ifdef INET6 /* see rc.c, "dns_order" and dnsorders[] */ int ai_family_order_table[7][3] = {