mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Copiousoutput final stage. I doubt that /dev/fd/%d is portable. It works
at least under Linux. I didn't test network part of external handlers. Files in tmpdir must be delete somehow. Maybe make a list of files to unlink and delete them while quitting ELinks.
This commit is contained in:
parent
a2c12d7653
commit
6ead4e9c65
@ -535,7 +535,7 @@ format_command(unsigned char *command, unsigned char *type, int copiousoutput)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (copiousoutput) {
|
||||
unsigned char *pager = getenv("PAGER");
|
||||
|
||||
@ -552,7 +552,7 @@ format_command(unsigned char *command, unsigned char *type, int copiousoutput)
|
||||
add_to_string(&cmd, pager);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return cmd.source;
|
||||
}
|
||||
|
||||
|
@ -301,6 +301,23 @@ abort_download_and_beep(struct file_download *file_download, struct terminal *te
|
||||
abort_download(file_download);
|
||||
}
|
||||
|
||||
static void
|
||||
read_from_popen(struct session *ses, unsigned char *handler)
|
||||
{
|
||||
FILE *pop = popen(handler, "r");
|
||||
|
||||
if (pop) {
|
||||
int fd = fileno(pop);
|
||||
|
||||
if (fd > 0) {
|
||||
unsigned char buf[48];
|
||||
|
||||
snprintf(buf, 48, "file:///dev/fd/%d", fd);
|
||||
goto_url(ses, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
download_data_store(struct download *download, struct file_download *file_download)
|
||||
{
|
||||
@ -338,11 +355,16 @@ download_data_store(struct download *download, struct file_download *file_downlo
|
||||
prealloc_truncate(file_download->handle, file_download->seek);
|
||||
close(file_download->handle);
|
||||
file_download->handle = -1;
|
||||
exec_on_terminal(term, file_download->external_handler,
|
||||
if (file_download->copiousoutput) {
|
||||
read_from_popen(file_download->ses,
|
||||
file_download->external_handler);
|
||||
} else {
|
||||
exec_on_terminal(term, file_download->external_handler,
|
||||
file_download->file,
|
||||
!!file_download->block);
|
||||
file_download->delete = 0;
|
||||
abort_download_and_beep(file_download, term);
|
||||
file_download->delete = 0;
|
||||
abort_download_and_beep(file_download, term);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -974,23 +996,6 @@ tp_display(struct type_query *type_query)
|
||||
done_type_query(type_query);
|
||||
}
|
||||
|
||||
static void
|
||||
read_from_popen(struct type_query *type_query, unsigned char *handler)
|
||||
{
|
||||
FILE *pop = popen(handler, "r");
|
||||
|
||||
if (pop) {
|
||||
int fd = fileno(pop);
|
||||
|
||||
if (fd > 0) {
|
||||
struct session *ses = type_query->ses;
|
||||
unsigned char buf[48];
|
||||
|
||||
snprintf(buf, 48, "file:///dev/fd/%d", fd);
|
||||
goto_url(ses, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tp_open(struct type_query *type_query)
|
||||
@ -1011,7 +1016,7 @@ tp_open(struct type_query *type_query)
|
||||
|
||||
if (handler) {
|
||||
if (type_query->copiousoutput)
|
||||
read_from_popen(type_query, handler);
|
||||
read_from_popen(type_query->ses, handler);
|
||||
else
|
||||
exec_on_terminal(type_query->ses->tab->term,
|
||||
handler, "", !!type_query->block);
|
||||
|
Loading…
Reference in New Issue
Block a user