1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

MIME: When there is no % in the handler string (no %s in the mailcap entry)

the handler reads data from stdin. I think it only works with copiousoutput.
read_from_popen delayed because of internal errors.
This commit is contained in:
Witold Filipczyk 2007-02-21 13:43:16 +01:00 committed by Witold Filipczyk
parent 469481b272
commit 4a7b9415e1
3 changed files with 36 additions and 1 deletions

View File

@ -315,6 +315,7 @@ read_from_popen(struct session *ses, unsigned char *handler, unsigned char *file
unsigned char buf[48];
struct popen_data *data = mem_calloc(1, sizeof(*data));
struct delayed_open *deo;
if (!data) {
fclose(stream);
@ -324,8 +325,13 @@ read_from_popen(struct session *ses, unsigned char *handler, unsigned char *file
data->stream = stream;
if (filename) data->filename = stracpy(filename);
add_to_list(copiousoutput_data, data);
deo = mem_calloc(1, sizeof(*deo));
if (!deo) return;
snprintf(buf, 48, "file:///dev/fd/%d", fd);
goto_url(ses, buf);
deo->uri = get_uri(buf, 0);
deo->ses = ses;
register_bottom_half(delayed_goto_uri, deo);
}
}
}
@ -778,6 +784,9 @@ static unsigned char *
subst_file(unsigned char *prog, unsigned char *file)
{
struct string name;
/* When there is no %s in the mailcap entry, the handler program reads
* data from stdin instead of a file. */
int input = 1;
if (!init_string(&name)) return NULL;
@ -790,6 +799,7 @@ subst_file(unsigned char *prog, unsigned char *file)
prog += p;
if (*prog == '%') {
input = 0;
#if defined(HAVE_CYGWIN_CONV_TO_FULL_WIN32_PATH)
#ifdef MAX_PATH
unsigned char new_path[MAX_PATH];
@ -808,6 +818,19 @@ subst_file(unsigned char *prog, unsigned char *file)
}
}
if (input) {
struct string s;
if (init_string(&s)) {
add_to_string(&s, "/bin/cat ");
add_char_to_string(&s, '"');
add_to_string(&s, file);
add_to_string(&s, "\" | ");
add_string_to_string(&s, &name);
done_string(&name);
return s.source;
}
}
return name.source;
}

View File

@ -682,6 +682,17 @@ delayed_goto_uri_frame(void *data)
mem_free(deo);
}
void
delayed_goto_uri(void *data)
{
struct delayed_open *deo = data;
assert(deo);
goto_uri(deo->ses, deo->uri);
done_uri(deo->uri);
mem_free(deo);
}
/* menu_func_T */
void
map_selected(struct terminal *term, void *ld_, void *ses_)

View File

@ -28,6 +28,7 @@ struct uri *get_hooked_uri(unsigned char *uristring, struct session *ses, unsign
void goto_uri(struct session *ses, struct uri *uri);
void goto_uri_frame(struct session *, struct uri *, unsigned char *, enum cache_mode);
void delayed_goto_uri_frame(void *);
void delayed_goto_uri(void *);
void goto_url(struct session *, unsigned char *);
void goto_url_with_hook(struct session *, unsigned char *);
int goto_url_home(struct session *ses);