cc1212849dad1c1c7edd9d27dc54f7d423f77bb3
[mmh] / config / config.c
1 /*
2 ** config.c -- master nmh configuration file
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11 #ifdef MHRC
12 # include <pwd.h>
13 #endif
14
15
16 /*
17 ** Find the location of a format or configuration
18 ** file, and return its absolute pathname.
19 **
20 ** 1) If already absolute pathname, then leave unchanged.
21 ** 2) Next, if it begins with ~user, then expand it.
22 ** 3) Next, check in nmh Mail directory.
23 ** 4) Next, check in nmh `etc' directory.
24 */
25
26 char *
27 etcpath (char *file)
28 {
29         static char epath[PATH_MAX];
30         char *cp;
31 #ifdef MHRC
32         char *pp;
33         struct passwd *pw;
34
35         context_read();
36         if (*file == '~') {
37                 /* Expand ~username */
38                 if ((cp = strchr(pp = file + 1, '/')))
39                         *cp++ = '\0';
40                 if (*pp == '\0') {
41                         pp = mypath;
42                 } else {
43                         if ((pw = getpwnam (pp)))
44                                 pp = pw->pw_dir;
45                         else {
46                                 if (cp)
47                                 *--cp = '/';
48                                 goto try_it;
49                         }
50                 }
51
52                 snprintf (epath, sizeof(epath), "%s/%s", pp, cp ? cp : "");
53                 if (cp)
54                         *--cp = '/';
55
56                 if (access (epath, R_OK) != NOTOK)
57                         return epath;  /* else fall */
58         }
59 try_it:
60 #endif /* MHRC */
61
62         if (*file == '/') {
63                 /* If already absolute pathname, return it */
64                 return file;
65         }
66
67         /* Check nmh Mail directory */
68         strncpy(epath, toabsdir(file), sizeof epath);
69         if (access (epath, R_OK) != NOTOK)
70                 return epath;
71
72         /* Check nmh `etc' directory */
73         snprintf (epath, sizeof(epath), NMHETCDIR"/%s", file);
74         return (access (epath, R_OK) != NOTOK ? epath : file);
75 }
76
77
78 /*
79 ** Standard yes/no switches structure
80 */
81
82 struct swit anoyes[] = {
83         { "no", 0 },
84         { "yes", 0 },
85         { NULL, 0 }
86 };
87
88 /*
89 ** nmh constants
90 */
91
92 /* initial profile for new users */
93 char *mh_defaults = NMHETCDIR"/mh.profile";
94
95 /* default name of user profile */
96 char *mh_profile = ".mh_profile";
97
98 /* name of current message "sequence" */
99 char *current = "cur";
100
101 /* standard component files */
102 char *components = "components";           /* comp         */
103 char *replcomps = "replcomps";             /* repl         */
104 char *replgroupcomps = "replgroupcomps";   /* repl -group  */
105 char *forwcomps = "forwcomps";             /* forw         */
106 char *distcomps = "distcomps";             /* dist         */
107 char *rcvdistcomps = "rcvdistcomps";       /* rcvdist      */
108 char *digestcomps = "digestcomps";         /* forw -digest */
109
110 /* standard format (filter) files */
111 char *mhlformat = "mhl.format";            /* show         */
112 char *mhlreply = "mhl.reply";              /* repl -filter */
113 char *mhlforward = "mhl.forward";          /* forw -filter */
114
115 char *draftfolder = "+drafts";
116
117 char *inbox = "Inbox";
118 char *defaultfolder = "+inbox";
119
120 char *pfolder = "Current-Folder";
121 char *usequence = "Unseen-Sequence";
122 char *psequence = "Previous-Sequence";
123 char *nsequence = "Sequence-Negation";
124
125 /* profile entries for storage locations */
126 char *nmhstorage = "nmh-storage";
127 char *nmhcache = "nmh-cache";
128 char *nmhprivcache = "nmh-private-cache";
129
130 /* profile entry for external ftp access command */
131 char *nmhaccessftp = "nmh-access-ftp";
132
133 char *mhlibdir = NMHLIBDIR;
134 char *mhetcdir = NMHETCDIR;
135
136 /*
137 ** nmh not-so constants
138 */
139
140 /*
141 ** Default name for the nmh context file.
142 */
143 char *context = "context";
144
145 /*
146 ** Default name of file for public sequences.  If NULL,
147 ** then nmh will use private sequences by default, unless the
148 ** user defines a value using the "mh-sequences" profile entry.
149 */
150 #ifdef NOPUBLICSEQ
151 char *mh_seq = NULL;
152 #else
153 char *mh_seq = ".mh_sequences";
154 #endif
155
156 /*
157 ** nmh globals
158 */
159
160 char ctxflags;          /* status of user's context   */
161 char *invo_name;        /* command invocation name    */
162 char *mypath;           /* user's $HOME               */
163 char *defpath;          /* pathname of user's profile */
164 char *ctxpath;          /* pathname of user's context */
165 struct node *m_defs;    /* profile/context structure  */
166
167 /*
168 ** nmh processes
169 */
170
171 /*
172 ** This is the program to process MIME composition files
173 */
174 char *buildmimeproc = NMHBINDIR"/mhbuild";
175 /*
176 ** This is the program to `cat' a file.
177 */
178 char *catproc = "/bin/cat";
179
180 /*
181 ** mhl runs this program as a visual-end.
182 */
183 char *faceproc = NULL;
184
185 /*
186 ** This program is usually called directly by users, but it is
187 ** also invoked by the spost program to process an "Fcc", or by
188 ** comp/repl/forw/dist to refile a draft message.
189 */
190 char *fileproc = NMHBINDIR"/refile";
191
192 /*
193 ** This program is called to incorporate messages into a folder.
194 */
195 char *incproc = NMHBINDIR"/inc";
196
197 /*
198 ** When a user runs an nmh program for the first time, this program
199 ** is called to create his nmh profile, and mail directory.
200 */
201 char *installproc = NMHLIBDIR"/install-mh";
202
203 /*
204 ** This is the default program invoked by a "list" response
205 ** at the "What now?" prompt.  It is also used by the draft
206 ** folder facility in comp/dist/forw/repl to display the
207 ** draft message.
208 */
209 char *lproc = "more";
210
211 /*
212 ** This is the path for the Bell equivalent mail program.
213 */
214 char *mailproc = NMHBINDIR"/mhmail";
215
216 /*
217 ** This is used by mhl as a front-end.  It is also used
218 ** by mhshow as the default method of displaying message bodies
219 ** or message parts of type text/plain.
220 */
221 char *moreproc = "more";
222
223 /*
224 ** This is the program (mhl) used to filter messages.  It is
225 ** used by mhshow to filter and display the message headers of
226 ** MIME messages.  It is used by repl/forw (with -filter)
227 ** to filter the message to which you are replying/forwarding.
228 ** It is used by send/spost (with -filter) to filter the message
229 ** for "Bcc:" recipients.
230 */
231 char *mhlproc = NMHLIBDIR"/mhl";
232
233 /*
234 ** This program is called to pack a folder.
235 */
236 char *packproc = NMHBINDIR"/packf";
237
238 /*
239 ** This is the delivery program called by send to actually
240 ** deliver mail to users.  This is the interface to the MTS.
241 */
242 char *postproc = NMHLIBDIR"/spost";
243
244 /*
245 ** This is program is called by slocal to handle
246 ** the action `folder' or `+'.
247 */
248 char *rcvstoreproc = NMHLIBDIR"/rcvstore";
249
250 /*
251 ** This program is called to remove a folder.
252 */
253 char *rmfproc = NMHBINDIR"/rmf";
254
255 /*
256 ** This program is called to remove a message by rmm or refile -nolink.
257 ** It's usually empty, which means to rename the file to a backup name.
258 */
259 char *rmmproc = NULL;
260
261 /*
262 ** This program is usually called by the user's whatnowproc, but it
263 ** may also be called directly to send a message previously composed.
264  */
265 char *sendproc = NMHBINDIR"/send";
266
267 /*
268 ** This is the path to the program used by "show"
269 ** to display non-text (MIME) messages.
270 */
271 char *showmimeproc = NMHBINDIR"/mhshow";
272
273 /*
274 ** This is the default program called by "show" to filter
275 ** and display standard text (non-MIME) messages.  It can be
276 ** changed to a pager (such as "more" or "less") if you prefer
277 ** that such message not be filtered in any way.
278 */
279 char *showproc = NMHLIBDIR"/mhl";
280
281 /*
282 ** This program is called after comp, et. al., have built a draft
283 */
284 char *whatnowproc = NMHBINDIR"/whatnow";
285
286 /*
287 ** This is the sendmail interface to use for sending mail.
288 */
289 char *sendmail = SENDMAILPATH;
290
291 /*
292 ** The prefix that is prepended to the name of message files when they
293 ** are "removed" by rmm. This should typically be `,' or `#'.
294 */
295 char *backup_prefix = ",";
296
297 /*
298 ** This is the editor invoked by the various message
299 ** composition programs.  It SHOULD be a full screen
300 ** editor, such as vi or emacs, but any editor will work.
301 */
302 char *defaulteditor = "vi";
303
304 /*
305 ** Name of link to file to which you are replying or which you are
306 ** redistributing. See `$mhaltmsg' in the mh-profile(5) man page.
307 */
308 char *altmsglink = "@";
309
310 /*
311 ** This is the global nmh alias file.  It is somewhat obsolete, since
312 ** global aliases should be handled by the Mail Transport Agent (MTA).
313 */
314 char *AliasFile = NMHETCDIR"/MailAliases";
315
316 /*
317 ** File protections
318 */
319
320 /*
321 ** Folders (directories) are created with this protection (mode)
322 */
323 char *foldprot = "700";
324
325 /*
326 ** Every NEW message will be created with this protection.  When a
327 ** message is filed it retains its protection, so this only applies
328 ** to messages coming in through inc.
329 */
330 char *msgprot = "600";