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