From: Pierre Habouzit Date: Thu, 29 Mar 2007 22:56:52 +0000 (+0200) Subject: add some lua in the mime module as well. X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=98533911b5d5279b6f4574c66f77fbd6c772ac6f add some lua in the mime module as well. Signed-off-by: Pierre Habouzit --- diff --git a/globals.h b/globals.h index ef9b7b9..5ab1bb2 100644 --- a/globals.h +++ b/globals.h @@ -123,7 +123,6 @@ WHERE unsigned short SmtpPort; WHERE char *SmtpUseTLS; #endif WHERE char *Spoolfile; -WHERE char *SpamSep; #if defined(USE_SSL) || defined(USE_GNUTLS) WHERE char *SslCertFile INITVAL (NULL); diff --git a/init.h b/init.h index f083620..8be3a84 100644 --- a/init.h +++ b/init.h @@ -2970,15 +2970,6 @@ struct option_t MuttVars[] = { ** Madmutt will attach the message whether or not this is the case, ** as long as the non-``$$reply_regexp'' parts of both messages are identical. */ - {"spam_separator", DT_STR, R_NONE, UL &SpamSep, ","}, - /* - ** .pp - ** ``$spam_separator'' controls what happens when multiple spam headers - ** are matched: if \fIunset\fP, each successive header will overwrite any - ** previous matches value for the spam label. If \fIset\fP, each successive - ** match will append to the previous, using ``$spam_separator'' as a - ** separator. - */ {"spoolfile", DT_PATH, R_NONE, UL &Spoolfile, "" }, /* ** .pp diff --git a/lib-lua/lua-token.sh b/lib-lua/lua-token.sh index 7fd5e55..9ca1422 100644 --- a/lib-lua/lua-token.sh +++ b/lib-lua/lua-token.sh @@ -137,6 +137,7 @@ exit 0 ## sendmail_wait ## shell ## shorthost +## spam_separator ## sysconfdir ## tmpdir ## use_8bitmime diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index 1b976c9..1e806c4 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -41,6 +41,7 @@ void luaM_initialize(void) {"MTransport", luaopen_MTransport}, {"MAlias", luaopen_MAlias}, {"MCharset", luaopen_MCharset}, + {"Mime", luaopen_Mime}, }; int i; diff --git a/lib-mime/Makefile.am b/lib-mime/Makefile.am index 24c8e0f..b47ba4c 100644 --- a/lib-mime/Makefile.am +++ b/lib-mime/Makefile.am @@ -15,4 +15,5 @@ noinst_HEADERS = mime.h mime-types.h mime-token.c mime-token.h: mime-token.def mime-token.sh sh mime-token.sh $@ < $< +include $(top_builddir)/tools/cpkg2c.mk -include $(top_builddir)/tools/cflags.mk diff --git a/lib-mime/mime.c b/lib-mime/mime.cpkg similarity index 92% rename from lib-mime/mime.c rename to lib-mime/mime.cpkg index 8f10d56..e953211 100644 --- a/lib-mime/mime.c +++ b/lib-mime/mime.cpkg @@ -23,11 +23,11 @@ */ #include - +#include #include "mime.h" +@import "../lib-lua/base.cpkg" #define BOUNDARYLEN 16 - const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t"; const char *BodyTypes[] = { @@ -52,6 +52,18 @@ const char *BodyEncodings[] = { "x-uuencoded", }; +@package Mime { + /* + ** .pp + ** ``$spam_separator'' controls what happens when multiple spam headers + ** are matched: if \fIunset\fP, each successive header will overwrite any + ** previous matches value for the spam label. If \fIset\fP, each successive + ** match will append to the previous, using ``$spam_separator'' as a + ** separator. + */ + string_t spam_separator = m_strdup(","); +}; + /****************************************************************************/ /* rfc822 header parameters */ /****************************************************************************/ @@ -243,3 +255,4 @@ int mutt_is_text_part(BODY * b) } } +/* vim:set ft=c: */ diff --git a/lib-mime/mime.h b/lib-mime/mime.h index 0ff5bce..8feddfe 100644 --- a/lib-mime/mime.h +++ b/lib-mime/mime.h @@ -32,6 +32,9 @@ #include "mime-types.h" #include "mime-token.h" +#include +#include "mime.li" + extern const char MimeSpecials[]; extern const char *BodyTypes[]; extern const char *BodyEncodings[]; diff --git a/lib-mime/rfc822parse.c b/lib-mime/rfc822parse.c index 3e77c57..fa0beaa 100644 --- a/lib-mime/rfc822parse.c +++ b/lib-mime/rfc822parse.c @@ -1034,15 +1034,12 @@ mutt_read_rfc822_header(FILE *f, HEADER *hdr, short user_hdrs, short weed) { /* if spam tag already exists, figure out how to amend it */ if (e->spam && *buf) { - if (SpamSep) { - /* If SpamSep defined, append with separator */ - mutt_buffer_addstr(e->spam, SpamSep); - mutt_buffer_addstr(e->spam, buf); + if (Mime.spam_separator) { + mutt_buffer_addstr(e->spam, Mime.spam_separator); } else { - /* else overwrite */ mutt_buffer_reset(e->spam); - mutt_buffer_addstr(e->spam, buf); } + mutt_buffer_addstr(e->spam, buf); } if (!e->spam) { diff --git a/tools/Makefile b/tools/Makefile index 39394f5..1ae72cc 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,8 +1,9 @@ # automake sucks, badly all: ../lib-mime/mime-token.h \ - ../lib-lua/lua-token.h \ - ../lib-lua/madmutt.li \ - ../charset.li + ../lib-mime/mime.li \ + ../lib-lua/lua-token.h \ + ../lib-lua/madmutt.li \ + ../charset.li ../%: ; $(MAKE) -C $(@D) $(@F)