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