Cosmetic refactoring
[mmh] / sbr / getfolder.c
1 /*
2 ** getfolder.c -- get the current or default folder
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
12 /*
13 ** Return the default (=inbox) or current folder.
14 ** E.g. `getfolder(FDEF)' usually returns ``inbox''.
15 */
16 char *
17 getfolder(int wantcurrent)
18 {
19         char *folder;
20
21         if (wantcurrent &&
22                         (folder = context_find(pfolder)) && *folder != '\0') {
23                 /* If wantcurrent, then try the current folder first */
24                 return folder;
25
26         } else if ((folder = context_find(inbox)) && *folder != '\0') {
27                 /* try the Inbox profile entry */
28                 return folder;
29
30         } else {
31                 /* return the compile time default  */
32                 return defaultfolder;
33         }
34 }