ELinks 0.18.0
|
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "config/options.h"
#include "intl/libintl.h"
#include "main/module.h"
#include "mime/backend/common.h"
#include "mime/backend/mailcap.h"
#include "mime/mime.h"
#include "osdep/osdep.h"
#include "session/session.h"
#include "util/file.h"
#include "util/hash.h"
#include "util/lists.h"
#include "util/memory.h"
#include "util/string.h"
Data Structures | |
struct | mailcap_hash_item |
struct | mailcap_entry |
Macros | |
#define | get_opt_mailcap(which) |
#define | get_mailcap(which) |
#define | get_mailcap_ask() |
#define | get_mailcap_description() |
#define | get_mailcap_enable() |
#define | get_mailcap_prioritize() |
#define | get_mailcap_path() |
Enumerations | |
enum | mailcap_option { MAILCAP_TREE , MAILCAP_ENABLE , MAILCAP_PATH , MAILCAP_ASK , MAILCAP_DESCRIPTION , MAILCAP_PRIORITIZE , MAILCAP_OPTIONS } |
Functions | |
static void | done_mailcap_entry (struct mailcap_entry *entry) |
static struct mailcap_entry * | init_mailcap_entry (char *command, int priority) |
static void | add_mailcap_entry (struct mailcap_entry *entry, char *type, int typelen) |
static char * | get_mailcap_field (char **next) |
static char * | get_mailcap_field_text (char *field) |
static int | parse_optional_fields (struct mailcap_entry *entry, char *line) |
static void | parse_mailcap_file (char *filename, unsigned int priority) |
static struct hash * | init_mailcap_map (void) |
static void | done_mailcap (struct module *module) |
static int | change_hook_mailcap (struct session *ses, struct option *current, struct option *changed) |
static void | init_mailcap (struct module *module) |
static char * | format_command (char *command, char *type, int copiousoutput) |
static struct mailcap_entry * | check_entries (struct mailcap_hash_item *item) |
static struct mailcap_entry * | get_mailcap_entry (char *type) |
static void | set_display (int xwin, int restore) |
Set or unset the DISPLAY environment variable before a mailcap check, or restore it afterwards. | |
static struct mime_handler * | get_mime_handler_mailcap (char *type, int xwin) |
Variables | |
static union option_info | mailcap_options [] |
static struct hash * | mailcap_map = NULL |
const struct mime_backend | mailcap_mime_backend |
struct module | mailcap_mime_module |
#define get_mailcap | ( | which | ) |
#define get_mailcap_ask | ( | ) |
#define get_mailcap_description | ( | ) |
#define get_mailcap_enable | ( | ) |
#define get_mailcap_path | ( | ) |
#define get_mailcap_prioritize | ( | ) |
#define get_opt_mailcap | ( | which | ) |
enum mailcap_option |
|
inlinestatic |
|
static |
|
static |
|
static |
|
inlinestatic |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
inlinestatic |
|
static |
|
static |
|
inlinestatic |
|
static |
Set or unset the DISPLAY environment variable before a mailcap check, or restore it afterwards.
In a mailcap file, each entry can specify a test command that checks whether the entry is applicable to the user's environment. For example:
* audio/mpegurl; xmms %s; test=test "$DISPLAY" != "" *
This means the entry should be used only if the DISPLAY environment variable is not empty, i.e. there is an X display. In ELinks, check_entries() runs these test commands, so they inherit the environment variables of the master ELinks process. However, if the user is running ELinks on multiple terminals, then each slave ELinks process has its own environment variables, which may or may not include DISPLAY. Because the actual mailcap command may be run from a slave ELinks process and inherit the environment from it, any test command should also be run in the same environment.
This function does not fully implement the ideal described above. Instead, it only sets the DISPLAY environment variable as ":0" if the terminal has any X display at all, or unsets DISPLAY if not. This should be enough for most test commands seen in practice. After the test commands of mailcap entries have been run, this function must be called again to restore DISPLAY.
xwin | Whether the terminal has an associated X display. |
restore | If this is 0, the function sets or clears DISPLAY, as described above. If this is 1, the function restores the original value of DISPLAY. There is only room for one saved value; do not nest calls. |
const struct mime_backend mailcap_mime_backend |
struct module mailcap_mime_module |
|
static |