]> diplodocus.org Git - nmh/blob - config/config.c
Added const to argument of getname().
[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 /* Will leak because caller doesn't know cp was
73 dynamically allocated. */
74 return cp;
75 } else {
76 free (cp);
77 }
78 }
79
80 /* Check nmh `etc' directory */
81 snprintf (epath, sizeof(epath), nmhetcdir(/%s), file);
82 return (access (epath, R_OK) != NOTOK ? epath : file);
83 }
84
85
86 /*
87 * Standard yes/no switches structure
88 */
89
90 struct swit anoyes[] = {
91 { "no", 0, 0 },
92 { "yes", 0, 1 },
93 { NULL, 0, 0 }
94 };
95
96 /*
97 * nmh constants
98 */
99
100 /* initial profile for new users */
101 char *mh_defaults = nmhetcdir (/mh.profile);
102
103 /* default name of user profile */
104 char *mh_profile = ".mh_profile";
105
106 /* name of credentials file, defaults to .netrc in either Path or $HOME. */
107 char *credentials_file;
108
109 /* name of current message "sequence" */
110 char *current = "cur";
111
112 /* standard component files */
113 char *components = "components"; /* comp */
114 char *replcomps = "replcomps"; /* repl */
115 char *replgroupcomps = "replgroupcomps"; /* repl -group */
116 char *forwcomps = "forwcomps"; /* forw */
117 char *distcomps = "distcomps"; /* dist */
118 char *rcvdistcomps = "rcvdistcomps"; /* rcvdist */
119 char *digestcomps = "digestcomps"; /* forw -digest */
120
121 /* standard format (filter) files */
122 char *mhlformat = "mhl.format"; /* show */
123 char *mhlreply = "mhl.reply"; /* repl -filter */
124 char *mhlforward = "mhl.forward"; /* forw -filter */
125
126 char *draft = "draft";
127
128 char *inbox = "Inbox";
129 char *defaultfolder = "inbox";
130
131 char *pfolder = "Current-Folder";
132 char *usequence = "Unseen-Sequence";
133 char *psequence = "Previous-Sequence";
134 char *nsequence = "Sequence-Negation";
135
136 /* profile entries for storage locations */
137 char *nmhstorage = "nmh-storage";
138 char *nmhcache = "nmh-cache";
139 char *nmhprivcache = "nmh-private-cache";
140
141 /* profile entry for external ftp access command */
142 char *nmhaccessftp = "nmh-access-ftp";
143
144 /* profile entry for external url access command */
145 char *nmhaccessurl = "nmh-access-url";
146
147 char *mhlibdir = NMHLIBDIR;
148 char *mhetcdir = NMHETCDIR;
149
150 /*
151 * nmh not-so constants
152 */
153
154 /*
155 * Default name for the nmh context file.
156 */
157 char *context = "context";
158
159 /*
160 * Default name of file for public sequences. If NULL,
161 * then nmh will use private sequences by default, unless the
162 * user defines a value using the "mh-sequences" profile entry.
163 */
164 #ifdef NOPUBLICSEQ
165 char *mh_seq = NULL;
166 #else
167 char *mh_seq = ".mh_sequences";
168 #endif
169
170 /*
171 * nmh globals
172 */
173
174 char ctxflags; /* status of user's context */
175 char *invo_name; /* command invocation name */
176 char *mypath; /* user's $HOME */
177 char *defpath; /* pathname of user's profile */
178 char *ctxpath; /* pathname of user's context */
179 struct node *m_defs; /* profile/context structure */
180
181 /*
182 * nmh processes
183 */
184
185 /*
186 * This is the program to process MIME composition files
187 */
188 char *buildmimeproc = nmhbindir (/mhbuild);
189 /*
190 * This is the program to `cat' a file.
191 */
192 char *catproc = "/bin/cat";
193
194 /*
195 * This program is usually called directly by users, but it is
196 * also invoked by the post program to process an "Fcc", or by
197 * comp/repl/forw/dist to refile a draft message.
198 */
199
200 char *fileproc = nmhbindir (/refile);
201
202 /*
203 * This program is used to optionally format the bodies of messages by
204 * "mhl".
205 */
206
207 char *formatproc = NULL;
208
209 /*
210 * This program is called to incorporate messages into a folder.
211 */
212
213 char *incproc = nmhbindir (/inc);
214
215 /*
216 * This is the default program invoked by a "list" response
217 * at the "What now?" prompt. It is also used by the draft
218 * folder facility in comp/dist/forw/repl to display the
219 * draft message.
220 */
221
222 char *lproc = NULL;
223
224 /*
225 * This is the path for the Bell equivalent mail program.
226 */
227
228 char *mailproc = nmhbindir (/mhmail);
229
230 /*
231 * This is used by mhl as a front-end. It is also used
232 * by mhn as the default method of displaying message bodies
233 * or message parts of type text/plain.
234 */
235
236 char *moreproc = NULL;
237
238 /*
239 * This is the program (mhl) used to filter messages. It is
240 * used by mhn to filter and display the message headers of
241 * MIME messages. It is used by repl/forw (with -filter)
242 * to filter the message to which you are replying/forwarding.
243 * It is used by send/post (with -filter) to filter the message
244 * for "Bcc:" recipients.
245 */
246
247 char *mhlproc = nmhlibdir (/mhl);
248
249 /*
250 * This is the super handy BBoard reading program, which is
251 * really just the nmh shell program.
252 */
253
254 char *mshproc = nmhbindir (/msh);
255
256 /*
257 * This program is called to pack a folder.
258 */
259
260 char *packproc = nmhbindir (/packf);
261
262 /*
263 * This is the delivery program called by send to actually
264 * deliver mail to users. This is the interface to the MTS.
265 */
266
267 char *postproc = nmhlibdir (/post);
268
269 /*
270 * This is program is called by slocal to handle
271 * the action `folder' or `+'.
272 */
273
274 char *rcvstoreproc = nmhlibdir (/rcvstore);
275
276 /*
277 * This program is called to remove a message by rmm or refile -nolink.
278 * It's usually empty, which means to rename the file to a backup name.
279 */
280
281 char *rmmproc = NULL;
282
283 /*
284 * This program is usually called by the user's whatnowproc, but it
285 * may also be called directly to send a message previously composed.
286 */
287
288 char *sendproc = nmhbindir (/send);
289
290 /*
291 * This is the path to the program used by "show"
292 * to display non-text (MIME) messages.
293 */
294
295 char *showmimeproc = nmhbindir (/mhshow);
296
297 /*
298 * This is the default program called by "show" to filter
299 * and display standard text (non-MIME) messages. It can be
300 * changed to a pager (such as "more" or "less") if you prefer
301 * that such message not be filtered in any way.
302 */
303
304 char *showproc = nmhlibdir (/mhl);
305
306 /*
307 * This program is called by vmh as the back-end to the window management
308 * protocol
309 */
310
311 char *vmhproc = nmhbindir (/msh);
312
313 /*
314 * This program is called after comp, et. al., have built a draft
315 */
316
317 char *whatnowproc = nmhbindir (/whatnow);
318
319 /*
320 * This program is called to list/validate the addresses in a message.
321 */
322
323 char *whomproc = nmhbindir (/whom);
324
325 /*
326 * This is the global nmh alias file. It is somewhat obsolete, since
327 * global aliases should be handled by the Mail Transport Agent (MTA).
328 */
329
330 char *AliasFile = nmhetcdir (/MailAliases);
331
332 /*
333 * File protections
334 */
335
336 /*
337 * Folders (directories) are created with this protection (mode)
338 */
339
340 char *foldprot = "700";
341
342 /*
343 * Every NEW message will be created with this protection. When a
344 * message is filed it retains its protection, so this only applies
345 * to messages coming in through inc.
346 */
347
348 char *msgprot = "600";
349