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