From: Pierre Habouzit Date: Sun, 11 Mar 2007 18:22:55 +0000 (+0100) Subject: deal with sendmail and dotlock in LUA. X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=3132c5f07ae687b5daac6b570347369967850863 deal with sendmail and dotlock in LUA. Signed-off-by: Pierre Habouzit --- diff --git a/globals.h b/globals.h index fe17703..7430db3 100644 --- a/globals.h +++ b/globals.h @@ -21,8 +21,6 @@ WHERE char AttachmentMarker[STRING]; WHERE char Quotebuf[STRING]; -WHERE char *MuttDotlock; - WHERE address_t *EnvFrom; WHERE address_t *From; @@ -118,7 +116,6 @@ WHERE char *PrintCmd; WHERE char *QueryCmd; WHERE char *Realname; WHERE char *SendCharset; -WHERE char *Sendmail; WHERE char *SidebarDelim; WHERE char *SidebarNumberFormat; WHERE char *SidebarBoundary; diff --git a/init.h b/init.h index 66603eb..a2b4c3d 100644 --- a/init.h +++ b/init.h @@ -543,12 +543,6 @@ struct option_t MuttVars[] = { ** is viewed it is passed as standard input to $$display_filter, and the ** filtered message is read from the standard output. */ - {"dotlock_program", DT_PATH, R_NONE, UL &MuttDotlock, "$madmutt_bindir/muttng_dotlock"}, - /* - ** .pp - ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by - ** Madmutt. - */ {"dsn_notify", DT_STR, R_NONE, UL &DsnNotify, ""}, /* ** .pp @@ -2956,13 +2950,6 @@ struct option_t MuttVars[] = { ** \fTiso-8859-2\fP, \fTkoi8-r\fP or \fTiso-2022-jp\fP) either ** instead of or after \fTiso-8859-1\fP. */ - {"sendmail", DT_PATH, R_NONE, UL &Sendmail, SENDMAIL " -oem -oi"}, - /* - ** .pp - ** Specifies the program and arguments used to deliver mail sent by Madmutt. - ** Madmutt expects that the specified program interprets additional - ** arguments as recipient addresses. - */ {"sendmail_wait", DT_NUM, R_NONE, UL &SendmailWait, "0" }, /* ** .pp diff --git a/lib-lua/lua-token.sh b/lib-lua/lua-token.sh index 4bf256f..0cac016 100644 --- a/lib-lua/lua-token.sh +++ b/lib-lua/lua-token.sh @@ -97,5 +97,6 @@ chmod -w $1 exit 0 ############ Put tokens here ############ -## shell +## dotlock ## sendmail +## shell diff --git a/lib-lua/madmutt.c b/lib-lua/madmutt.c index cc6cb8f..d4f55a3 100644 --- a/lib-lua/madmutt.c +++ b/lib-lua/madmutt.c @@ -67,6 +67,7 @@ static int madmutt_assign(lua_State *L) luaL_error(L, "bad subscript to madmutt: %s", val); return 0; + case LTK_DOTLOCK: case LTK_SENDMAIL: case LTK_SHELL: _mutt_expand_path(buf, sizeof(buf), val, 0); @@ -165,6 +166,20 @@ static const struct { ** header chaching's database backend.\fP */ #endif + + {"dotlock", "/mutt_dotlock"}, + /* + ** .pp + ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by + ** Madmutt. + */ + {"sendmail", SENDMAIL " -oem -oi"}, + /* + ** .pp + ** Specifies the program and arguments used to deliver mail sent by Madmutt. + ** Madmutt expects that the specified program interprets additional + ** arguments as recipient addresses. + */ }; static void madmutt_init_shell(char *buf, ssize_t len) diff --git a/lib-mx/mx.c b/lib-mx/mx.c index 96dab2c..9c0221a 100644 --- a/lib-mx/mx.c +++ b/lib-mx/mx.c @@ -12,9 +12,11 @@ #include +#include #include #include #include +#include #include "mutt.h" #include "pattern.h" @@ -36,8 +38,6 @@ #include #endif -#include - static mx_t const *mxfmts[] = { &mbox_mx, &mmdf_mx, @@ -63,15 +63,17 @@ static int invoke_dotlock (const char *path, int flags, int retry) char cmd[LONG_STRING + _POSIX_PATH_MAX]; char f[STRING + _POSIX_PATH_MAX]; char r[STRING]; + int pos; if (flags & DL_FL_RETRY) snprintf (r, sizeof (r), "-r %d ", retry ? MAXLOCKATTEMPT : 0); mutt_quote_filename (f, sizeof (f), path); - snprintf (cmd, sizeof (cmd), - "%s %s%s%s%s%s%s%s", - NONULL (MuttDotlock), + pos = mlua_value(cmd, sizeof(cmd), "madmutt", "dotlock"); + + snprintf(cmd + pos, sizeof(cmd) - pos, + " %s%s%s%s%s%s%s", flags & DL_FL_TRY ? "-t " : "", flags & DL_FL_UNLOCK ? "-u " : "", flags & DL_FL_USEPRIV ? "-p " : "", diff --git a/sendlib.c b/sendlib.c index 73d41b3..0a63e34 100644 --- a/sendlib.c +++ b/sendlib.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -1831,31 +1832,29 @@ static int mutt_invoke_sendmail (address_t * from, /* the sender */ const char *msg, /* file containing message */ int eightbit) { /* message contains 8bit chars */ - char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL; + char cmd[LONG_STRING]; + char *ps = NULL, *path = NULL, *childout = NULL; const char **args = NULL; ssize_t argslen = 0, argsmax = 0; int i; #ifdef USE_NNTP if (option (OPTNEWSSEND)) { - char cmd[LONG_STRING]; - m_strformat(cmd, sizeof(cmd), 0, Inews, nntp_format_str, 0, 0); if (m_strisempty(cmd)) { i = nntp_post (msg); unlink (msg); return i; } - - s = m_strdup(cmd); - } - else + } else #endif - s = m_strdup(Sendmail); + { + mlua_value(cmd, sizeof(cmd), "madmutt", "sendmail"); + } - ps = s; + ps = cmd; i = 0; - while ((ps = strtok (ps, " "))) { + while ((ps = strtok(ps, " "))) { if (argslen == argsmax) p_realloc(&args, argsmax += 5); @@ -1930,7 +1929,6 @@ static int mutt_invoke_sendmail (address_t * from, /* the sender */ p_delete(&childout); p_delete(&path); - p_delete(&s); p_delete(&args); if (i == (EX_OK & 0xff))