X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-lua%2Fmadmutt.cpkg;h=610ee929f23c813da149ded1013da08adf9e02fe;hb=597020b9829312a50c15784916f473da9e75efd0;hp=aefb74ff0612251fceec7ae294fd48e399a3cc2f;hpb=892df7e70376da43374d834b8a825ea2d59efd06;p=apps%2Fmadmutt.git diff --git a/lib-lua/madmutt.cpkg b/lib-lua/madmutt.cpkg index aefb74f..610ee92 100644 --- a/lib-lua/madmutt.cpkg +++ b/lib-lua/madmutt.cpkg @@ -25,23 +25,28 @@ #include "../mutt.h" -static const char *madmutt_init_shell(void) +static char *madmutt_init_shell(void) { struct passwd *pw = getpwuid(getuid()); - return pw ? pw->pw_shell : (getenv("SHELL") ?: "/bin/sh"); + return m_strdup(pw ? pw->pw_shell : (getenv("SHELL") ?: "/bin/sh")); } -static const char *madmutt_pwd(void) +static char *madmutt_init_username(void) { - char path[_POSIX_PATH_MAX]; - getcwd(path, sizeof(path)); - return path; + struct passwd *pw = getpwuid(getuid()); + return m_strdup(pw ? pw->pw_name : (getenv("USER") ?: "john_doe")); } -static const char *luaM_path_post(const char *val) +static char *madmutt_init_homedir(void) { - char path[PATH_MAX]; - _mutt_expand_path(path, sizeof(path), val, 0); + struct passwd *pw = getpwuid(getuid()); + return m_strdup(pw ? pw->pw_dir : (getenv("HOME") ?: "/")); +} + +static const char *madmutt_pwd(void) +{ + char path[_POSIX_PATH_MAX]; + getcwd(path, sizeof(path)); return path; } @@ -51,14 +56,17 @@ static const char *luaM_path_post(const char *val) }; @type string_t = { - .kind = 's'; - .ctype = const char *; + .kind = 's'; + .ctype = char *; + .dtor = p_delete($$); + .ctor = m_strdup($$); }; @type path_t = { - .push = luaM_path_post($$); .kind = 's'; .ctype = char *; + .dtor = p_delete($$); + .ctor = luaM_pathnew($$); }; @type quadopt_t = { @@ -67,6 +75,15 @@ static const char *luaM_path_post(const char *val) .ctype = unsigned : 2; }; +@type rx_t = { + .kind = 's'; + .ctype = rx_t *; + .check = luaM_checkrx($L, $$); + .push = ($$)->pattern; + .ctor = luaM_rxnew($$); + .dtor = rx_delete($$); +}; + #if defined(HAVE_QDBM) # define HCACHE_BACKEND "qdbm" #elif defined(HAVE_GDBM) @@ -84,9 +101,13 @@ static const char *luaM_path_post(const char *val) const string_t docdir = PKGDOCDIR; const string_t hcache_backend = HCACHE_BACKEND; - path_t dotlock = BINDIR "/mutt_dotlock"; - path_t editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi"; - path_t shell = madmutt_init_shell(); + path_t dotlock = m_strdup(BINDIR "/mutt_dotlock"); + path_t editor = m_strdup(getenv("VISUAL") ?: getenv("EDITOR") ?: "vi"); + path_t shell = madmutt_init_shell(); + path_t username = madmutt_init_username(); + path_t homedir = madmutt_init_homedir(); + path_t tmpdir = m_strdup(getenv("TMPDIR") ?: "/tmp"); + rx_t gecos_mask = luaM_rxnew("^[^,]*"); quadopt_t quit = M_YES; bool beep = 1; @@ -96,10 +117,10 @@ static const char *luaM_path_post(const char *val) } MCore; @package MTransport { - path_t sendmail = SENDMAIL " -eom -oi"; + path_t sendmail = m_strdup(SENDMAIL " -eom -oi"); - string_t dsn_notify = NULL; - string_t dsn_return = NULL; + string_t dsn_notify = NULL /* TODO: check it's NULL, hdrs or full */; + string_t dsn_return = NULL /* TODO: check it's never, delay, failure, success with ',' */; } MTransport; /* vim:set ft=c: */