mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Revert "Mailcap on slave terminals seems to work right."
This reverts commit f45d4c17823e59e150930e6ec68592d098451bbd.
This commit is contained in:
parent
69d7208ade
commit
6b059d3d36
@ -1,4 +1,3 @@
|
||||
#define _GNU_SOURCE /* stpcpy */
|
||||
/* RFC1524 (mailcap file) implementation */
|
||||
|
||||
/* This file contains various functions for implementing a fair subset of
|
||||
@ -35,19 +34,13 @@
|
||||
#include "mime/mime.h"
|
||||
#include "osdep/osdep.h" /* For exe() */
|
||||
#include "session/session.h"
|
||||
#include "terminal/hardio.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/file.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/lists.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/sem.h"
|
||||
#include "util/string.h"
|
||||
|
||||
extern int master_sem;
|
||||
extern int slave_sem;
|
||||
extern unsigned char *shared_mem;
|
||||
|
||||
struct mailcap_hash_item {
|
||||
/* The entries associated with the type */
|
||||
LIST_OF(struct mailcap_entry) entries;
|
||||
@ -641,7 +634,7 @@ get_mailcap_entry(unsigned char *type)
|
||||
}
|
||||
|
||||
static struct mime_handler *
|
||||
get_mime_handler_mailcap_common(unsigned char *type)
|
||||
get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
|
||||
{
|
||||
struct mailcap_entry *entry;
|
||||
struct mime_handler *handler;
|
||||
@ -668,87 +661,6 @@ get_mime_handler_mailcap_common(unsigned char *type)
|
||||
return handler;
|
||||
}
|
||||
|
||||
static struct mime_handler *
|
||||
get_mime_handler_mailcap(unsigned char *type, struct terminal *term)
|
||||
{
|
||||
struct mime_handler *handler;
|
||||
unsigned char *desc, *data;
|
||||
int block, len;
|
||||
|
||||
if (!term || term->master)
|
||||
return get_mime_handler_mailcap_common(type);
|
||||
|
||||
len = strlen(type) + 1;
|
||||
data = fmem_alloc(2 + len);
|
||||
if (!data)
|
||||
return NULL;
|
||||
data[0] = 0;
|
||||
data[1] = 3; /* Mailcap */
|
||||
memcpy(data + 2, type, len);
|
||||
hard_write(term->fdout, data, len + 2);
|
||||
fmem_free(data);
|
||||
|
||||
sem_signal(slave_sem);
|
||||
sem_wait(master_sem);
|
||||
if (!shared_mem || !*shared_mem)
|
||||
return NULL;
|
||||
desc = strchr(shared_mem, '\0') + 1;
|
||||
block = (shared_mem[4095] > 0);
|
||||
handler = init_mime_handler(shared_mem, desc, mailcap_mime_module.name,
|
||||
get_mailcap_ask(), block);
|
||||
if (handler) handler->copiousoutput = shared_mem[4095] & 1;
|
||||
return handler;
|
||||
}
|
||||
|
||||
/* Called by slaves. */
|
||||
void
|
||||
get_slave_mailcap(unsigned char *type)
|
||||
{
|
||||
sem_wait(slave_sem);
|
||||
if (shared_mem) {
|
||||
struct mailcap_entry *entry;
|
||||
unsigned char *program;
|
||||
unsigned char *current;
|
||||
int len;
|
||||
|
||||
if (!get_mailcap_enable()
|
||||
|| (!mailcap_map && !init_mailcap_map())) {
|
||||
shared_mem[0] = '\0';
|
||||
goto end;
|
||||
}
|
||||
|
||||
entry = get_mailcap_entry(type);
|
||||
if (!entry) {
|
||||
shared_mem[0] = '\0';
|
||||
goto end;
|
||||
}
|
||||
|
||||
program = format_command(entry->command, type, entry->copiousoutput);
|
||||
if (!program) {
|
||||
shared_mem[0] = '\0';
|
||||
goto end;
|
||||
}
|
||||
len = strlen(program) + 1;
|
||||
if (entry->description)
|
||||
len += strlen(entry->description);
|
||||
len++;
|
||||
if (len > 4095) { /* size of the shared memory block */
|
||||
mem_free(program);
|
||||
shared_mem[0] = '\0';
|
||||
goto end;
|
||||
}
|
||||
current = stpcpy(shared_mem, program);
|
||||
mem_free(program);
|
||||
if (entry->description)
|
||||
current = stpcpy(current, entry->description);
|
||||
else
|
||||
*++current = '\0';
|
||||
shared_mem[4095] = (entry->needsterminal << 1) | (entry->copiousoutput << 0);
|
||||
done_mailcap(NULL);
|
||||
}
|
||||
end:
|
||||
sem_signal(master_sem);
|
||||
}
|
||||
|
||||
const struct mime_backend mailcap_mime_backend = {
|
||||
/* get_content_type: */ NULL,
|
||||
|
@ -8,6 +8,4 @@
|
||||
extern const struct mime_backend mailcap_mime_backend;
|
||||
extern struct module mailcap_mime_module;
|
||||
|
||||
void get_slave_mailcap(unsigned char *type);
|
||||
|
||||
#endif
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "main/timer.h"
|
||||
#include "mime/backend/mailcap.h"
|
||||
#include "osdep/ascii.h"
|
||||
#include "osdep/osdep.h"
|
||||
#include "terminal/hardio.h"
|
||||
@ -565,12 +564,6 @@ has_nul_byte:
|
||||
add_char_to_string(&path, ch);
|
||||
}
|
||||
|
||||
if (fg == 3) {
|
||||
/* Mailcap */
|
||||
get_slave_mailcap(path.source);
|
||||
goto next_round;
|
||||
}
|
||||
|
||||
if (!init_string(&delete)) {
|
||||
done_string(&path);
|
||||
goto free_and_return;
|
||||
@ -636,9 +629,8 @@ has_nul_byte:
|
||||
}
|
||||
|
||||
nasty_thing:
|
||||
done_string(&delete);
|
||||
next_round:
|
||||
done_string(&path);
|
||||
done_string(&delete);
|
||||
assert(ITRM_OUT_QUEUE_SIZE - p > 0);
|
||||
memmove(buf, buf + p, ITRM_OUT_QUEUE_SIZE - p);
|
||||
bytes_read -= p;
|
||||
|
Loading…
x
Reference in New Issue
Block a user