fd56f52ae8ecb91cf00c9d4e0627656362501795
[apps/madmutt.git] / lib-lua / madmutt.cpkg
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or (at
5  *  your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful, but
8  *  WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
15  *  MA 02110-1301, USA.
16  *
17  *  Copyright © 2007 Pierre Habouzit
18  */
19
20 #include <lib-lib/lib-lib.h>
21 #include <lib-lua/lib-lua.h>
22
23 #include <sys/types.h>
24 #include <pwd.h>
25
26 #include "../mutt.h"
27 @import "base.cpkg"
28
29 static char *madmutt_init_shell(void)
30 {
31     struct passwd *pw = getpwuid(getuid());
32     return m_strdup(pw ? pw->pw_shell : (getenv("SHELL") ?: "/bin/sh"));
33 }
34
35 static char *madmutt_init_username(void)
36 {
37     struct passwd *pw = getpwuid(getuid());
38     return m_strdup(pw ? pw->pw_name : (getenv("USER") ?: "john_doe"));
39 }
40
41 static char *madmutt_init_homedir(void)
42 {
43     struct passwd *pw = getpwuid(getuid());
44     return m_strdup(pw ? pw->pw_dir : (getenv("HOME") ?: "/"));
45 }
46
47 #if defined(HAVE_QDBM)
48 #  define HCACHE_BACKEND  "qdbm"
49 #elif defined(HAVE_GDBM)
50 #  define HCACHE_BACKEND  "gdbm"
51 #elif defined(HAVE_DB4)
52 #  define HCACHE_BACKEND  "db4"
53 #else
54 #  define HCACHE_BACKEND  NULL
55 #endif
56
57 @package MCore {
58     const string_t version    = VERSION;
59     const string_t sysconfdir = SYSCONFDIR;
60     const string_t bindir     = BINDIR;
61     const string_t docdir     = PKGDOCDIR;
62     const string_t hcache_backend = HCACHE_BACKEND;
63
64     path_t dotlock     = m_strdup(BINDIR "/mutt_dotlock");
65     path_t editor      = m_strdup(getenv("VISUAL") ?: getenv("EDITOR") ?: "vi");
66     path_t shell       = madmutt_init_shell();
67     path_t username    = madmutt_init_username();
68     path_t homedir     = madmutt_init_homedir();
69     path_t tmpdir      = m_strdup(getenv("TMPDIR") ?: "/tmp");
70     rx_t   gecos_mask  = luaM_rxnew("^[^,]*");
71
72     quadopt_t quit     = M_YES;
73     bool      beep     = 1;
74     bool      beep_new = 0;
75
76     const string_t pwd(void) {
77         char path[_POSIX_PATH_MAX];
78         getcwd(path, sizeof(path));
79         RETURN(path);
80     };
81 };
82
83 @package MTransport {
84     path_t   sendmail = m_strdup(SENDMAIL " -eom -oi");
85
86     /* TODO: check it's NULL, hdrs or full */
87     string_t dsn_notify = NULL;
88
89     /* TODO: check it's never, delay, failure, success with ',' */
90     string_t dsn_return = NULL;
91 };
92
93 /* vim:set ft=c: */