Removed the space between function names and the opening parenthesis.
[mmh] / sbr / context_foil.c
1 /*
2 ** context_foil.c -- foil search of profile and context
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 #include <h/utils.h>
11
12 /*
13 ** Foil search of users .mh_profile
14 ** If error, return -1, else return 0
15 */
16
17 int
18 context_foil(char *path)
19 {
20         register struct node *np;
21
22         /* In fact, nobody examines defpath in code paths where
23         ** it's been set by us -- the uses in the source tree are:
24         **  1 sbr/context_read.c uses it only after setting it itself
25         **  2 uip/install_mh.c uses it only after setting it itself
26         **  3 uip/mark.c print it if given the -debug switch
27         ** A worthwhile piece of code cleanup would be to make 1 and
28         ** 2 use a local variable and just delete 3.
29         **
30         ** Similarly, context and ctxpath are not really used
31         ** outside the context_* routines. It might be worth combining
32         ** them into one file so the variables can be made static.
33         */
34
35         /* We set context to NULL to indicate that no context file
36         ** is to be read. (Using /dev/null doesn't work because we
37         ** would try to lock it, which causes timeouts with some
38         ** locking methods.)
39         */
40         defpath = context = NULL;
41
42         /*
43         ** If path is given, create a minimal profile/context list
44         */
45         if (path) {
46                 m_defs = (struct node *) mh_xmalloc(sizeof(*np));
47
48                 np = m_defs;
49                 if (!(np->n_name = strdup("Path"))) {
50                         advise(NULL, "strdup failed");
51                         return -1;
52                 }
53                 if (!(np->n_field = strdup(path))) {
54                         advise(NULL, "strdup failed");
55                         return -1;
56                 }
57                 np->n_context = 0;
58                 np->n_next = NULL;
59
60                 if (mypath == NULL && (mypath = getenv("HOME")) != NULL)
61                         if (!(mypath = strdup(mypath))) {
62                                 advise(NULL, "strdup failed");
63                                 return -1;
64                         }
65         }
66
67         return 0;
68 }