]> diplodocus.org Git - nmh/blob - sbr/context_del.c
Just reworded the bit about '%s' being safe not to quote (it's only safe not to
[nmh] / sbr / context_del.c
1
2 /*
3 * context_del.c -- delete an entry from the context/profile list
4 *
5 * $Id$
6 */
7
8 #include <h/mh.h>
9
10 /*
11 * Delete a key/value pair from the context/profile list.
12 * Return 0 if key is found, else return 1.
13 */
14
15 int
16 context_del (char *key)
17 {
18 register struct node *np, *pp;
19
20 /* sanity check - check that context has been read */
21 if (defpath == NULL)
22 adios (NULL, "oops, context hasn't been read yet");
23
24 for (np = m_defs, pp = NULL; np; pp = np, np = np->n_next) {
25 if (!strcasecmp (np->n_name, key)) {
26 if (!np->n_context)
27 admonish (NULL, "bug: context_del(key=\"%s\")", np->n_name);
28 if (pp)
29 pp->n_next = np->n_next;
30 else
31 m_defs = np->n_next;
32 free (np->n_name);
33 if (np->n_field)
34 free (np->n_field);
35 free ((char *) np);
36 ctxflags |= CTXMOD;
37 return 0;
38 }
39 }
40
41 return 1;
42 }