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