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.
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.
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,
17 * Copyright © 2007 Pierre Habouzit
20 #include <lib-lib/lib-lib.h>
21 #include <lib-lua/lib-lua.h>
23 #include <sys/types.h>
28 static const char *madmutt_init_shell(void)
30 struct passwd *pw = getpwuid(getuid());
31 return pw ? pw->pw_shell : (getenv("SHELL") ?: "/bin/sh");
34 static const char *madmutt_init_username(void)
36 struct passwd *pw = getpwuid(getuid());
37 return pw ? pw->pw_name : (getenv("USER") ?: "john_doe");
40 static const char *madmutt_init_homedir(void)
42 struct passwd *pw = getpwuid(getuid());
43 return pw ? pw->pw_dir : (getenv("HOME") ?: "/");
46 static const char *madmutt_pwd(void)
48 char path[_POSIX_PATH_MAX];
49 getcwd(path, sizeof(path));
53 static const char *luaM_path_post(const char *val)
56 _mutt_expand_path(path, sizeof(path), val, 0);
62 .ctype = unsigned : 1;
67 .ctype = const char *;
71 .push = luaM_path_post($$);
78 .check = luaM_checkquadopt($L, $$);
79 .ctype = unsigned : 2;
82 #if defined(HAVE_QDBM)
83 # define HCACHE_BACKEND "qdbm"
84 #elif defined(HAVE_GDBM)
85 # define HCACHE_BACKEND "gdbm"
86 #elif defined(HAVE_DB4)
87 # define HCACHE_BACKEND "db4"
89 # define HCACHE_BACKEND "unknown"
93 const string_t version = VERSION;
94 const string_t sysconfdir = SYSCONFDIR;
95 const string_t bindir = BINDIR;
96 const string_t docdir = PKGDOCDIR;
97 const string_t hcache_backend = HCACHE_BACKEND;
99 path_t dotlock = BINDIR "/mutt_dotlock";
100 path_t editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
101 path_t shell = madmutt_init_shell();
102 path_t username = madmutt_init_username();
103 path_t homedir = madmutt_init_homedir();
104 path_t tmpdir = getenv("TMPDIR") ?: "/tmp";
106 quadopt_t quit = M_YES;
110 const string_t pwd(void) = madmutt_pwd();
113 @package MTransport {
114 path_t sendmail = SENDMAIL " -eom -oi";
116 string_t dsn_notify = NULL;
117 string_t dsn_return = NULL;