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