]>
diplodocus.org Git - nmh/blob - sbr/context_foil.c
3 * context_foil.c -- foil search of profile and context
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.
14 * Foil search of users .mh_profile
15 * If error, return -1, else return 0
19 context_foil (char *path
)
21 register struct node
*np
;
23 /* In fact, nobody examines defpath in code paths where
24 * it's been set by us -- the uses in the source tree are:
25 * 1 sbr/context_read.c uses it only after setting it itself
26 * 2 uip/install_mh.c uses it only after setting it itself
27 * 3 uip/mshcmds.c and uip/mark.c print it if given the -debug switch
28 * A worthwhile piece of code cleanup would be to make 1 and
29 * 2 use a local variable and just delete 3.
31 * Similarly, context and ctxpath are not really used
32 * outside the context_* routines. It might be worth combining
33 * them into one file so the variables can be made static.
36 /* We set context to NULL to indicate that no context file
37 * is to be read. (Using /dev/null doesn't work because we
38 * would try to lock it, which causes timeouts with some
41 defpath
= context
= NULL
;
44 * If path is given, create a minimal profile/context list
47 m_defs
= (struct node
*) mh_xmalloc (sizeof(*np
));
50 if (!(np
->n_name
= strdup ("Path"))) {
51 advise (NULL
, "strdup failed");
54 if (!(np
->n_field
= strdup (path
))) {
55 advise (NULL
, "strdup failed");
61 if (mypath
== NULL
&& (mypath
= getenv ("HOME")) != NULL
)
62 if (!(mypath
= strdup (mypath
))) {
63 advise (NULL
, "strdup failed");