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