WHERE char *Mixmaster;
WHERE char *MixEntryFormat;
-
-WHERE char *OperatingSystem INITVAL (NULL);
-
WHERE char *Muttrc INITVAL (NULL);
#ifdef USE_NNTP
WHERE char *CurrentFolder;
WHERE char *LastFolder;
-WHERE string_list_t *AutoViewList INITVAL (0);
-WHERE string_list_t *AlternativeOrderList INITVAL (0);
WHERE string_list_t *AttachAllow INITVAL(0);
WHERE string_list_t *AttachExclude INITVAL(0);
WHERE string_list_t *InlineAllow INITVAL(0);
WHERE string_list_t *InlineExclude INITVAL(0);
WHERE string_list_t *HeaderOrderList INITVAL (0);
WHERE string_list_t *Ignore INITVAL (0);
-WHERE string_list_t *MimeLookupList INITVAL (0);
WHERE string_list_t *UnIgnore INITVAL (0);
/* bit vector for boolean variables */
/* not reached */
}
-static void add_to_list(string_list_t **list, const char *str)
-{
- /* don't add a NULL or empty string to the list */
- if (m_strisempty(str))
- return;
-
- /* check to make sure the item is not already on this list */
- while (*list) {
- if (!ascii_strcasecmp(str, (*list)->data))
- return;
- list = &(*list)->next;
- }
-
- *list = p_new(string_list_t, 1);
- (*list)->data = m_strdup(str);
-}
-
-static void remove_from_list(string_list_t **l, const char *str)
-{
- if (!m_strcmp("*", str)) {
- string_list_wipe(l); /* ``unCMD *'' means delete all current entries */
- return;
- }
-
- while (*l) {
- if (!ascii_strcasecmp(str, (*l)->data)) {
- string_list_t *it = string_list_pop(l);
- string_item_delete(&it);
- } else {
- l = &(*l)->next;
- }
- }
-}
-
static int parse_unignore (BUFFER * buf, BUFFER * s,
unsigned long data __attribute__ ((unused)),
BUFFER * err __attribute__ ((unused)))
mutt_extract_token (buf, s, 0);
/* don't add "*" to the unignore list */
- if (m_strcmp (buf->data, "*"))
- add_to_list (&UnIgnore, buf->data);
-
- remove_from_list (&Ignore, buf->data);
+ if (m_strcmp(buf->data, "*")) {
+ string_list_add(&UnIgnore, buf->data);
+ string_list_remove(&Ignore, buf->data);
+ } else {
+ string_list_wipe(&Ignore);
+ }
} while (MoreArgs (s));
return 0;
{
do {
mutt_extract_token (buf, s, 0);
- remove_from_list (&UnIgnore, buf->data);
- add_to_list (&Ignore, buf->data);
+ if (m_strcmp(buf->data, "*")) {
+ string_list_remove(&UnIgnore, buf->data);
+ } else {
+ string_list_wipe(&UnIgnore);
+ }
+ string_list_add(&Ignore, buf->data);
} while (MoreArgs(s));
return 0;
}
{
do {
mutt_extract_token (buf, s, 0);
- add_to_list ((string_list_t **) data, buf->data);
+ string_list_add ((string_list_t **) data, buf->data);
} while (MoreArgs(s));
return 0;
}
/*
* Check for deletion of entire list
*/
- if (m_strcmp(buf->data, "*") == 0) {
+ if (!m_strcmp(buf->data, "*")) {
string_list_wipe((string_list_t **) data);
break;
}
- remove_from_list ((string_list_t **) data, buf->data);
+ string_list_remove((string_list_t **) data, buf->data);
}
while (MoreArgs (s));
}
major = mutt_check_mime_type(tmp);
- /* We must do our own walk here because remove_from_list() will only
+ /* We must do our own walk here because string_list_remove() will only
* remove the string_list_t->data, not anything pointed to by the string_list_t->data. */
lastp = NULL;
for(lp = *ldata; lp; ) {
** This specifies the folder into which read mail in your ``$$spoolfile''
** folder will be appended.
*/
- {"operating_system", DT_STR, R_NONE, UL &OperatingSystem, "" },
- /*
- ** .pp
- ** This specifies the operating system name for the \fTUser-Agent:\fP header field. If
- ** this is \fIunset\fP, it will be set to the operating system name that \fTuname(2)\fP
- ** returns. If \fTuname(2)\fP fails, ``UNIX'' will be used.
- ** .pp
- ** It may, for example, look as: ``\fTMadmutt 1.5.9i (Linux)\fP''.
- */
{"sidebar_boundary", DT_STR, R_BOTH, UL &SidebarBoundary, "." },
/*
** .pp
{"alias", parse_alias, 0},
{"attachments", parse_attachments, 0 },
{"ignore", parse_ignore, 0},
- {"alternative_order", parse_list, UL &AlternativeOrderList},
- {"auto_view", parse_list, UL &AutoViewList},
{"hdr_order", parse_list, UL &HeaderOrderList},
- {"mime_lookup", parse_list, UL &MimeLookupList},
{"my_hdr", parse_my_hdr, 0},
{"reset", parse_set, M_SET_RESET},
{"set", parse_set, 0},
{"unalias", parse_unalias, 0},
{"unattachments", parse_unattachments, 0},
{"unignore", parse_unignore, 0},
- {"unalternative_order", parse_unlist, UL &AlternativeOrderList},
- {"unauto_view", parse_unlist, UL &AutoViewList},
{"unhdr_order", parse_unlist, UL &HeaderOrderList},
- {"unmime_lookup", parse_unlist, UL &MimeLookupList},
{"unmy_hdr", parse_unmy_hdr, 0},
{NULL, NULL, 0}
};
return 0;
}
+void string_list_add(string_list_t **list, const char *str)
+{
+ if (m_strisempty(str))
+ return;
+
+ while (*list) {
+ if (!ascii_strcasecmp(str, (*list)->data))
+ return;
+ list = &(*list)->next;
+ }
+
+ *list = p_new(string_list_t, 1);
+ (*list)->data = m_strdup(str);
+}
+
+void string_list_remove(string_list_t **l, const char *str)
+{
+ while (*l) {
+ if (!ascii_strcasecmp(str, (*l)->data)) {
+ string_list_t *it = string_list_pop(l);
+ string_item_delete(&it);
+ } else {
+ l = &(*l)->next;
+ }
+ }
+}
/* FIXME: b0rken API's, replace that at any cost */
string_list_t *mutt_add_list_n(string_list_t *head, const void *data, size_t len) {
string_list_t *string_list_dup(const string_list_t *);
int string_list_contains(const string_list_t *, const char *, const char *);
+void string_list_add(string_list_t **, const char *);
+void string_list_remove(string_list_t **l, const char *str);
/* FIXME: b0rken API's, replace that at any cost */
/* add an element to a list */
## mailcap_path
## mailcap_sanitize
## no
+## operating_system
## quit
## send_charset
## sendmail
return p_dupstr(utsname.nodename, p - utsname.nodename);
}
+static char *madmutt_init_os(void)
+{
+ struct utsname un;
+ return m_strdup(uname(&un) < 0 ? "Unix" : un.sysname);
+}
+
static char *madmutt_init_hostname(void)
{
char buffer[STRING];
*/
path_t shell = madmutt_init_shell();
+ /*
+ ** .pp
+ ** This specifies the operating system name for the \fTUser-Agent:\fP header field. If
+ ** this is \fIunset\fP, it will be set to the operating system name that \fTuname(2)\fP
+ ** returns. If \fTuname(2)\fP fails, ``UNIX'' will be used.
+ ** .pp
+ ** It may, for example, look as: ``\fTMadmutt 1.5.9i (Linux)\fP''.
+ */
+ string_t operating_system = madmutt_init_os();
+
path_t username = madmutt_init_username();
path_t homedir = madmutt_init_homedir();
};
rx_t *SpamList = NULL, *NoSpamList = NULL;
+string_list_t *AutoViewList, *AlternativeOrderList, *MimeLookupList;
static char *mailcap_init(void)
{
}
RETURN();
};
+
+ void auto_view(string_t s) {
+ string_list_add(&AutoViewList, s);
+ RETURN();
+ };
+ void unauto_view(string_t s) {
+ if (m_strcmp(s, "*")) {
+ string_list_remove(&AutoViewList, s);
+ } else {
+ string_list_wipe(&AutoViewList);
+ }
+ RETURN();
+ };
+
+ void alternative_order(string_t s) {
+ string_list_add(&AlternativeOrderList, s);
+ RETURN();
+ };
+ void unalternative_order(string_t s) {
+ if (m_strcmp(s, "*")) {
+ string_list_remove(&AlternativeOrderList, s);
+ } else {
+ string_list_wipe(&AlternativeOrderList);
+ }
+ RETURN();
+ };
+
+ void lookup(string_t s) {
+ string_list_add(&MimeLookupList, s);
+ RETURN();
+ };
+ void unlookup(string_t s) {
+ if (m_strcmp(s, "*")) {
+ string_list_remove(&MimeLookupList, s);
+ } else {
+ string_list_wipe(&MimeLookupList);
+ }
+ RETURN();
+ };
};
/****************************************************************************/
extern const char *BodyEncodings[];
extern rx_t *SpamList, *NoSpamList;
+extern string_list_t *AutoViewList;
+extern string_list_t *AlternativeOrderList;
+extern string_list_t *MimeLookupList;
+
/* MIME encoding/decoding global vars */
#define is_multipart(x) \
#include <lib-lib/lib-lib.h>
#include <signal.h>
-#include <sys/utsname.h>
#include <lib-lua/lib-lua.h>
#include <lib-sys/exit.h>
}
if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent) {
- const char *os;
-
- if (OperatingSystem != NULL) {
- os = OperatingSystem;
+ if (MCore.operating_system) {
+ fprintf(fp, "User-Agent: %s (%s)\n", mutt_make_version(),
+ MCore.operating_system);
} else {
- struct utsname un;
- os = (uname(&un) == -1) ? "UNIX" : un.sysname;
+ fprintf(fp, "User-Agent: %s\n", mutt_make_version());
}
- /* Add a vanity header */
- fprintf (fp, "User-Agent: %s (%s)\n", mutt_make_version(), os);
}
return (ferror (fp) == 0 ? 0 : -1);