w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit e8b09b22ca867974cd15d9e4a6c8150598a3d7a3
parent 1281e765c91e901a975fec0353f20f12fcf201e4
Author: inu <inu>
Date:   Wed, 23 May 2007 15:06:05 +0000

[w3m-dev 04155] fix for minpw.

Diffstat:
MChangeLog | 7++++---
Mconfig.h.in | 14++++++++++++++
Mconfigure | 4++--
Mconfigure.ac | 4++--
Metc.c | 24++++++++++++++++++++++++
Mfile.c | 14++++++++++++++
Mftp.c | 17+++++++++++++++++
Mindep.c | 8++++++--
Mistream.c | 11+++++++++++
Mlocal.c | 10++++++++++
Mmain.c | 34++++++++++++++++++++++++++++++++++
Mrc.c | 4++++
Mterms.c | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Murl.c | 9+++++++++
14 files changed, 232 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,7 +1,8 @@ 2007-05-23 NOKUBI Takatsugu <knok@daionet.gr.jp> - - * [w3m-dev 04246] Re: road to 0.5.2 - * configure.ac: delete nsl and dl for cross building. + * [w3m-dev 04155] w3m mingw patch + * config.h, configure.ac, etc.c, file.c, ftp.c, indep.c, istream.c, + local.c, main.c, rc.c, terms.c, url.c: fix for minpw, except for + deleting nsl and dl from configure.ac. * configure: regenerated. 2007-05-23 Hiroyuki Ito <ZXB01226@nifty.com> diff --git a/config.h.in b/config.h.in @@ -166,9 +166,15 @@ typedef RETSIGTYPE MySignalHandler; #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 @@ typedef RETSIGTYPE MySignalHandler; #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 */ diff --git a/configure b/configure @@ -6220,7 +6220,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF -for lib in bsd BSD 44bsd socket dld +for lib in bsd BSD 44bsd socket nsl dld dl do lib=$lib { echo "$as_me:$LINENO: checking for -l$lib" >&5 @@ -8072,7 +8072,7 @@ _ACEOF case "$host_os" in - *cygwin*|*os2-emx*) + *cygwin*|*os2-emx*|*mingw*) cat >>confdefs.h <<\_ACEOF #define USE_BINMODE_STREAM 1 _ACEOF diff --git a/configure.ac b/configure.ac @@ -82,7 +82,7 @@ AC_W3M_MAILER AC_W3M_EXT_BROWSER dnl Checks for ext libs -for lib in bsd BSD 44bsd socket dld +for lib in bsd BSD 44bsd socket nsl dld dl do AC_W3M_EXTLIBS($lib) done @@ -109,7 +109,7 @@ AC_DEFINE(AUXBIN_TARGETS, "$AUXBIN_TARGETS") AC_SUBST(USE_BINMODE_STREAM) case "$host_os" in - *cygwin*|*os2-emx*) + *cygwin*|*os2-emx*|*mingw*) AC_DEFINE(USE_BINMODE_STREAM) ;; esac diff --git a/etc.c b/etc.c @@ -1,6 +1,8 @@ /* $Id$ */ #include "fm.h" +#ifndef __MINGW32_VERSION #include <pwd.h> +#endif #include "myctype.h" #include "html.h" #include "local.h" @@ -1310,9 +1312,13 @@ romanAlphabet(int n) 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 @@ setup_child(int child, int i, int f) { 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 @@ setup_child(int child, int i, int f) TrapSignal = FALSE; } +#ifndef __MINGW32_VERSION pid_t open_pipe_rw(FILE ** fr, FILE ** fw) { @@ -1421,6 +1430,7 @@ open_pipe_rw(FILE ** fr, FILE ** fw) err0: return (pid_t) - 1; } +#endif /* __MINGW32_VERSION */ void myExec(char *command) @@ -1433,6 +1443,7 @@ myExec(char *command) void mySystem(char *command, int background) { +#ifndef __MINGW32_VERSION if (background) { #ifndef __EMX__ flush_tty(); @@ -1447,6 +1458,7 @@ mySystem(char *command, int background) #endif } else +#endif /* __MINGW32_VERSION */ system(command); } @@ -1516,6 +1528,13 @@ myEditor(char *cmd, char *file, int line) return tmp; } +#ifdef __MINGW32_VERSION +char * +expandName(char *name) +{ + return getenv("HOME"); +} +#else char * expandName(char *name) { @@ -1559,6 +1578,7 @@ expandName(char *name) rest: return name; } +#endif char * file_to_url(char *file) @@ -1898,7 +1918,11 @@ mymktime(char *timestr) #ifdef INET6 #include <sys/socket.h> #endif /* INET6 */ +#ifndef __MINGW32_VERSION #include <netdb.h> +#else +#include <winsock.h> +#endif char * FQDN(char *host) { diff --git a/file.c b/file.c @@ -1602,9 +1602,17 @@ getAuthCookie(struct http_auth *hauth, char *auth_header, 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 } } @@ -7901,6 +7909,7 @@ _MoveFile(char *path1, char *path2) int _doFileCopy(char *tmpf, char *defstr, int download) { +#ifndef __MINGW32_VERSION Str msg; Str filen; char *p, *q = NULL; @@ -8007,6 +8016,7 @@ _doFileCopy(char *tmpf, char *defstr, int download) if (PreserveTimestamp && !is_pipe && !stat(tmpf, &st)) setModtime(p, st.st_mtime); } +#endif /* __MINGW32_VERSION */ return 0; } @@ -8021,6 +8031,7 @@ doFileMove(char *tmpf, char *defstr) int doFileSave(URLFile uf, char *defstr) { +#ifndef __MINGW32_VERSION Str msg; Str filen; char *p, *q; @@ -8117,6 +8128,7 @@ doFileSave(URLFile uf, char *defstr) if (PreserveTimestamp && uf.modtime != -1) setModtime(p, uf.modtime); } +#endif /* __MINGW32_VERSION */ return 0; } @@ -8187,6 +8199,7 @@ inputAnswer(char *prompt) static void uncompress_stream(URLFile *uf, char **src) { +#ifndef __MINGW32_VERSION pid_t pid1; FILE *f1; char *expand_cmd = GUNZIP_CMDNAME; @@ -8270,6 +8283,7 @@ uncompress_stream(URLFile *uf, char **src) } UFhalfclose(uf); uf->stream = newFileStream(f1, (void (*)())fclose); +#endif /* __MINGW32_VERSION */ } static FILE * diff --git a/ftp.c b/ftp.c @@ -1,6 +1,8 @@ /* $Id$ */ #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 @@ openFTPStream(ParsedURL *pu, URLFile *uf) 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 @@ openFTPStream(ParsedURL *pu, URLFile *uf) 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; } diff --git a/indep.c b/indep.c @@ -1,7 +1,9 @@ /* $Id$ */ #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 @@ expandPath(char *name) p = name; if (*p == '~') { p++; +#ifndef __MINGW32_VERSION if (IS_ALPHA(*p)) { char *q = strchr(p, '/'); if (q) { /* ~user/dir... */ @@ -238,8 +241,9 @@ expandPath(char *name) 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 diff --git a/istream.c b/istream.c @@ -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 @@ ssl_get_certificate(SSL * ssl, char *hostname) 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 diff --git a/local.c b/local.c @@ -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 @@ -194,8 +198,10 @@ check_local_cgi(char *file, int status) 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; } @@ -354,6 +360,9 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer) 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; @@ -413,4 +422,5 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer) file, mybasename(file), strerror(errno)); exit(1); return NULL; +#endif } diff --git a/main.c b/main.c @@ -24,6 +24,12 @@ extern int do_getch(); #endif /* defined(USE_GPM) || defined(USE_SYSMOUSE) */ #endif +#ifdef __MINGW32_VERSION +#include <winsock.h> + +WSADATA WSAData; +#endif + #define DSTR_LEN 256 Hist *LoadHist; @@ -64,7 +70,11 @@ static char *MarkString = NULL; 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); @@ -753,6 +763,23 @@ main(int argc, char **argv, char **envp) 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; @@ -5728,6 +5755,9 @@ w3m_exit(int i) #ifdef USE_NNTP disconnectNews(); #endif +#ifdef __MINGW32_VERSION + WSACleanup(); +#endif exit(i); } @@ -6452,7 +6482,9 @@ download_action(struct parsed_tagarg *arg) 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]); @@ -6486,7 +6518,9 @@ stopDownload(void) for (d = FirstDL; d != NULL; d = d->next) { if (d->ok) continue; +#ifndef __MINGW32_VERSION kill(d->pid, SIGKILL); +#endif unlink(d->lock); } } diff --git a/rc.c b/rc.c @@ -1126,7 +1126,11 @@ do_mkdir(const char *dir, long mode) 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 diff --git a/terms.c b/terms.c @@ -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 @@ typedef struct sgttyb TerminalMode; #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 @@ set_tty(void) void ttymode_set(int mode, int imode) { +#ifndef __MINGW32_VERSION TerminalMode ioval; TerminalGet(tty, &ioval); @@ -525,11 +566,13 @@ ttymode_set(int mode, int imode) 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 @@ ttymode_reset(int mode, int imode) 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 @@ touch_cursor() #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 */ diff --git a/url.c b/url.c @@ -1,10 +1,14 @@ /* $Id$ */ #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] = {