X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fmadmutt.cpkg;h=458bdb5ff136aaa3132615c47b3a44dd8abb1a05;hp=65ad75645fefa5b19dbb97f3e50e7de605d1137a;hb=603331772aefd46c010c985e6e1ea01264d8d17d;hpb=e80bef3a43b0f679b6fff30cbecce56539b7980e diff --git a/lib-lua/madmutt.cpkg b/lib-lua/madmutt.cpkg index 65ad756..458bdb5 100644 --- a/lib-lua/madmutt.cpkg +++ b/lib-lua/madmutt.cpkg @@ -18,11 +18,14 @@ */ #include -#include +#include #include #include +#include +#include + #include "../mutt.h" @import "base.cpkg" @@ -44,6 +47,40 @@ static char *madmutt_init_homedir(void) return m_strdup(pw ? pw->pw_dir : (getenv("HOME") ?: "/")); } +static char *madmutt_init_shorthost(void) +{ + struct utsname utsname; + const char *p; + + /* some systems report the FQDN instead of just the hostname */ + uname(&utsname); + p = m_strchrnul(utsname.nodename, '.'); + 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]; + + if (getdnsdomainname(buffer, sizeof(buffer)) < 0) + return m_strdup("@"); + + if (*buffer != '@') { + int len = m_strlen(buffer) + m_strlen(MCore.shorthost) + 2; + char *res = p_new(char, len); + snprintf(res, len, "%s.%s", NONULL(MCore.shorthost), buffer); + return res; + } + + return m_strdup(NONULL(MCore.shorthost)); +} + #if defined(HAVE_QDBM) # define HCACHE_BACKEND "qdbm" #elif defined(HAVE_GDBM) @@ -106,12 +143,30 @@ static char *madmutt_init_homedir(void) */ path_t shell = madmutt_init_shell(); - /* TODO: document */ - path_t username = madmutt_init_username(); + /* + ** .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(); - /* TODO: document */ + path_t username = madmutt_init_username(); path_t homedir = madmutt_init_homedir(); + /* + ** .pp + ** Specifies the hostname to use after the ``\fT@\fP'' in local e-mail + ** addresses and during generation of \fTMessage-ID:\fP headers. + ** .pp + ** Please be sure to really know what you are doing when changing this variable + ** to configure a custom domain part of Message-IDs. + */ + string_t hostname = madmutt_init_hostname(); + string_t shorthost = madmutt_init_shorthost(); + /* ** .pp ** This variable allows you to specify where Madmutt will place its @@ -259,6 +314,56 @@ static char *madmutt_init_homedir(void) */ /* TODO: check it's never, delay, failure, success with ',' */ string_t dsn_return = NULL; + + /* + ** .pp + ** Specifies the number of seconds to wait for the ``$$sendmail'' process + ** to finish before giving up and putting delivery in the background. + ** .pp + ** Madmutt interprets the value of this variable as follows: + ** .dl + ** .dt >0 .dd number of seconds to wait for sendmail to finish before continuing + ** .dt 0 .dd wait forever for sendmail to finish + ** .dt <0 .dd always put sendmail in the background without waiting + ** .de + ** .pp + ** Note that if you specify a value other than 0, the output of the child + ** process will be put in a temporary file. If there is some error, you + ** will be informed as to where to find the output. + */ + int sendmail_wait = 0; + /* + ** .pp + ** \fBWarning:\fP do not set this variable unless you are using a version + ** of sendmail which supports the \fT-B8BITMIME\fP flag (such as sendmail + ** 8.8.x) or in connection with the SMTP support via libESMTP. + ** Otherwise you may not be able to send mail. + ** .pp + ** When \fIset\fP, Madmutt will either invoke ``$$sendmail'' with the \fT-B8BITMIME\fP + ** flag when sending 8-bit messages to enable ESMTP negotiation or tell + ** libESMTP to do so. + */ + bool use_8bitmime = 0; + + /* + ** .pp + ** When \fIset\fP, Madmutt will use ``$$envelope_from_address'' as the + ** \fIenvelope\fP sender if that is set, otherwise it will attempt to + ** derive it from the "From:" header. + ** + ** .pp + ** \fBNote:\fP This information is passed + ** to sendmail command using the "-f" command line switch and + ** passed to the SMTP server for libESMTP (if support is compiled in). + */ + bool use_envelope_from = 0; + + /* + ** .pp + ** Manually sets the \fIenvelope\fP sender for outgoing messages. + ** This value is ignored if ``$$use_envelope_from'' is unset. + */ + address_t envelope_from_address = NULL; }; /* vim:set ft=c: */