aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-11-22 15:49:42 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-11-22 15:49:42 +0000
commitcdc65fdf224d19b5c7926ec6d4d4e78f57c0a0e0 (patch)
tree9114bb5eb68be8e82fc8f5864c4e5248b58e86e0
parent* doc/README.mouse_menu: delete column 10 limit (diff)
downloadw3m-cdc65fdf224d19b5c7926ec6d4d4e78f57c0a0e0.tar.gz
w3m-cdc65fdf224d19b5c7926ec6d4d4e78f57c0a0e0.zip
[w3m-dev 03459] background download when external viewer
* etc.c (myExec): added (mySystem): rewrite to use myExec() * file.c (doExternal): run background if BackgroundExtViewer * proto.h (myExec): added From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r--ChangeLog10
-rw-r--r--etc.c43
-rw-r--r--file.c31
-rw-r--r--proto.h3
4 files changed, 62 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 5711257..525b704 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-11-23 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
+ * [w3m-dev 03459] background download when external viewer
+ * etc.c (myExec): added
+ (mySystem): rewrite to use myExec()
+ * file.c (doExternal): run background if BackgroundExtViewer
+ * proto.h (myExec): added
+
2002-11-23 Fumitoshi UKAI <ukai@debian.or.jp>
* doc/README.mouse_menu: delete column 10 limit
@@ -5032,4 +5040,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.547 2002/11/22 15:45:01 ukai Exp $
+$Id: ChangeLog,v 1.548 2002/11/22 15:49:42 ukai Exp $
diff --git a/etc.c b/etc.c
index 2ea7868..2484bc9 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.37 2002/11/08 15:54:47 ukai Exp $ */
+/* $Id: etc.c,v 1.38 2002/11/22 15:49:43 ukai Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -1295,6 +1295,27 @@ reset_signals(void)
}
void
+myExec(char *command)
+{
+ int i;
+
+ reset_signals();
+ SETPGRP();
+ close_tty();
+ dup2(open("/dev/null", O_RDONLY), 0);
+ dup2(open("/dev/null", O_WRONLY), 1);
+ dup2(open("/dev/null", O_WRONLY), 2);
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 1024 /* XXX */
+#endif
+ /* close all other file descriptors (socket, ...) */
+ for (i = 3; i < FOPEN_MAX; i++)
+ close(i);
+ execl("/bin/sh", "sh", "-c", command, NULL);
+ exit(127);
+}
+
+void
mySystem(char *command, int background)
{
if (background) {
@@ -1303,25 +1324,9 @@ mySystem(char *command, int background)
Strcat_charp(cmd, command);
system(cmd->ptr);
#else
- int pid;
flush_tty();
- if ((pid = fork()) == 0) {
- int i;
- reset_signals();
- SETPGRP();
- close_tty();
- dup2(open("/dev/null", O_RDONLY), 0);
- dup2(open("/dev/null", O_WRONLY), 1);
- dup2(open("/dev/null", O_WRONLY), 2);
-#ifndef FOPEN_MAX
-#define FOPEN_MAX 1024 /* XXX */
-#endif
- /* close all other file descriptors (socket, ...) */
- for (i = 3; i < FOPEN_MAX; i++)
- close(i);
- execl("/bin/sh", "sh", "-c", command, NULL);
- exit(127);
- }
+ if (! fork())
+ myExec(command);
#endif
}
else
diff --git a/file.c b/file.c
index ba798c7..40bf843 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.123 2002/11/18 18:11:25 ukai Exp $ */
+/* $Id: file.c,v 1.124 2002/11/22 15:49:43 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -7090,11 +7090,10 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,
if (uf.ext && *uf.ext) {
Strcat_charp(tmpf, uf.ext);
}
+
_save:
if (IStype(uf.stream) != IST_ENCODED)
uf.stream = newEncodedStream(uf.stream, uf.encoding);
- if (save2tmp(uf, tmpf->ptr) < 0)
- return 0;
header = checkHeader(defaultbuf, "Content-Type:");
if (header)
header = conv_to_system(header);
@@ -7105,6 +7104,31 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,
command = tmp;
}
#endif
+
+ pushText(fileToDelete, tmpf->ptr);
+#ifdef HAVE_SETPGRP
+ if (! (mcap->flags & (MAILCAP_HTMLOUTPUT | MAILCAP_COPIOUSOUTPUT)) &&
+ ! (mcap->flags & MAILCAP_NEEDSTERMINAL) && BackgroundExtViewer) {
+ flush_tty();
+ if (! fork()) {
+ reset_signals();
+ signal(SIGINT, SIG_IGN);
+ close_tty();
+ QuietMessage = TRUE;
+ fmInitialized = FALSE;
+ if (save2tmp(uf, tmpf->ptr) < 0)
+ exit(1);
+ myExec(command->ptr);
+ }
+ *bufp = NO_BUFFER;
+ return 1;
+ }
+ else
+#endif
+ {
+ if (save2tmp(uf, tmpf->ptr) < 0)
+ return 0; /* ??? */
+ }
if (mcap->flags & (MAILCAP_HTMLOUTPUT | MAILCAP_COPIOUSOUTPUT)) {
if (defaultbuf == NULL)
defaultbuf = newBuffer(INIT_BUFFER_WIDTH);
@@ -7147,7 +7171,6 @@ doExternal(URLFile uf, char *path, char *type, Buffer **bufp,
buf->mailcap = mcap;
}
*bufp = buf;
- pushText(fileToDelete, tmpf->ptr);
return 1;
}
diff --git a/proto.h b/proto.h
index 181cdb0..5954883 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.59 2002/11/22 15:43:14 ukai Exp $ */
+/* $Id: proto.h,v 1.60 2002/11/22 15:49:44 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -560,6 +560,7 @@ extern char *last_modified(Buffer *buf);
extern Str romanNumeral(int n);
extern Str romanAlphabet(int n);
extern void reset_signals(void);
+extern void myExec(char *command);
extern void mySystem(char *command, int background);
extern Str myExtCommand(char *cmd, char *arg, int redirect);
extern Str myEditor(char *cmd, char *file, int line);