]> diplodocus.org Git - nmh/blob - sbr/context_foil.c
Just reworded the bit about '%s' being safe not to quote (it's only safe not to
[nmh] / sbr / context_foil.c
1
2 /*
3 * context_foil.c -- foil search of profile and context
4 *
5 * $Id$
6 */
7
8 #include <h/mh.h>
9
10 /*
11 * Foil search of users .mh_profile
12 * If error, return -1, else return 0
13 */
14
15 int
16 context_foil (char *path)
17 {
18 register struct node *np;
19
20 defpath = context = "/dev/null";
21
22 /*
23 * If path is given, create a minimal profile/context list
24 */
25 if (path) {
26 if (!(m_defs = (struct node *) malloc (sizeof(*np)))) {
27 advise (NULL, "unable to allocate profile storage");
28 return -1;
29 }
30
31 np = m_defs;
32 if (!(np->n_name = strdup ("Path"))) {
33 advise (NULL, "strdup failed");
34 return -1;
35 }
36 if (!(np->n_field = strdup (path))) {
37 advise (NULL, "strdup failed");
38 return -1;
39 }
40 np->n_context = 0;
41 np->n_next = NULL;
42
43 if (mypath == NULL && (mypath = getenv ("HOME")) != NULL)
44 if (!(mypath = strdup (mypath))) {
45 advise (NULL, "strdup failed");
46 return -1;
47 }
48 }
49
50 return 0;
51 }
52