]> diplodocus.org Git - nmh/blob - config/config.c
Document argsplit changes in mh-profile man page.
[nmh] / 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, 0 },
87 { "yes", 0, 1 },
88 { NULL, 0, 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 * This is the default program invoked by a "list" response
206 * at the "What now?" prompt. It is also used by the draft
207 * folder facility in comp/dist/forw/repl to display the
208 * draft message.
209 */
210
211 char *lproc = NULL;
212
213 /*
214 * This is the path for the Bell equivalent mail program.
215 */
216
217 char *mailproc = nmhbindir (/mhmail);
218
219 /*
220 * This is used by mhl as a front-end. It is also used
221 * by mhn as the default method of displaying message bodies
222 * or message parts of type text/plain.
223 */
224
225 char *moreproc = NULL;
226
227 /*
228 * This is the program (mhl) used to filter messages. It is
229 * used by mhn to filter and display the message headers of
230 * MIME messages. It is used by repl/forw (with -filter)
231 * to filter the message to which you are replying/forwarding.
232 * It is used by send/post (with -filter) to filter the message
233 * for "Bcc:" recipients.
234 */
235
236 char *mhlproc = nmhlibdir (/mhl);
237
238 /*
239 * This is the super handy BBoard reading program, which is
240 * really just the nmh shell program.
241 */
242
243 char *mshproc = nmhbindir (/msh);
244
245 /*
246 * This program is called to pack a folder.
247 */
248
249 char *packproc = nmhbindir (/packf);
250
251 /*
252 * This is the delivery program called by send to actually
253 * deliver mail to users. This is the interface to the MTS.
254 */
255
256 char *postproc = nmhlibdir (/post);
257
258 /*
259 * This is program is called by slocal to handle
260 * the action `folder' or `+'.
261 */
262
263 char *rcvstoreproc = nmhlibdir (/rcvstore);
264
265 /*
266 * This program is called to remove a message by rmm or refile -nolink.
267 * It's usually empty, which means to rename the file to a backup name.
268 */
269
270 char *rmmproc = NULL;
271
272 /*
273 * This program is usually called by the user's whatnowproc, but it
274 * may also be called directly to send a message previously composed.
275 */
276
277 char *sendproc = nmhbindir (/send);
278
279 /*
280 * This is the path to the program used by "show"
281 * to display non-text (MIME) messages.
282 */
283
284 char *showmimeproc = nmhbindir (/mhshow);
285
286 /*
287 * This is the default program called by "show" to filter
288 * and display standard text (non-MIME) messages. It can be
289 * changed to a pager (such as "more" or "less") if you prefer
290 * that such message not be filtered in any way.
291 */
292
293 char *showproc = nmhlibdir (/mhl);
294
295 /*
296 * This program is called by vmh as the back-end to the window management
297 * protocol
298 */
299
300 char *vmhproc = nmhbindir (/msh);
301
302 /*
303 * This program is called after comp, et. al., have built a draft
304 */
305
306 char *whatnowproc = nmhbindir (/whatnow);
307
308 /*
309 * This program is called to list/validate the addresses in a message.
310 */
311
312 char *whomproc = nmhbindir (/whom);
313
314 /*
315 * This is the global nmh alias file. It is somewhat obsolete, since
316 * global aliases should be handled by the Mail Transport Agent (MTA).
317 */
318
319 char *AliasFile = nmhetcdir (/MailAliases);
320
321 /*
322 * File protections
323 */
324
325 /*
326 * Folders (directories) are created with this protection (mode)
327 */
328
329 char *foldprot = "700";
330
331 /*
332 * Every NEW message will be created with this protection. When a
333 * message is filed it retains its protection, so this only applies
334 * to messages coming in through inc.
335 */
336
337 char *msgprot = "600";
338