]> diplodocus.org Git - nmh/blob - sbr/context_del.c
sendsbr.c: Move interface to own file.
[nmh] / sbr / context_del.c
1 /* context_del.c -- delete an entry from the context/profile list
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include "h/mh.h"
9 #include "context_del.h"
10 #include "error.h"
11 #include "h/utils.h"
12
13 /*
14 * Delete a key/value pair from the context/profile list.
15 * Return 0 if key is found, else return 1.
16 */
17
18 int
19 context_del (char *key)
20 {
21 struct node *np, *pp;
22
23 key = FENDNULL(key);
24 for (np = m_defs, pp = NULL; np; pp = np, np = np->n_next) {
25 if (!strcasecmp(FENDNULL(np->n_name), key)) {
26 if (!np->n_context)
27 inform("bug: context_del(key=\"%s\"), continuing...", 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 free(np->n_field);
34 free(np);
35 ctxflags |= CTXMOD;
36 return 0;
37 }
38 }
39
40 return 1;
41 }