Remove RCS keywords, since they no longer work after git migration.
[mmh] / sbr / context_replace.c
1
2 /*
3  * context_replace.c -- add/replace an entry in the context/profile list
4  *
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.
8  */
9
10 #include <h/mh.h>
11 #include <h/utils.h>
12
13
14 void
15 context_replace (char *key, char *value)
16 {
17     register struct node *np;
18
19     /*
20      * If list is emtpy, allocate head of profile/context list.
21      */
22     if (!m_defs) {
23         m_defs = (struct node *) mh_xmalloc (sizeof(*np));
24
25         np = m_defs;
26         np->n_name = getcpy (key);
27         np->n_field = getcpy (value);
28         np->n_context = 1;
29         np->n_next = NULL;
30         ctxflags |= CTXMOD;
31         return;
32     }
33
34     /*
35      * Search list of context/profile entries for
36      * this key, and replace its value if found.
37      */
38     for (np = m_defs;; np = np->n_next) {
39         if (!mh_strcasecmp (np->n_name, key)) {
40             if (strcmp (value, np->n_field)) {
41                 if (!np->n_context)
42                     admonish (NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
43                 if (np->n_field)
44                     free (np->n_field);
45                 np->n_field = getcpy (value);
46                 ctxflags |= CTXMOD;
47             }
48             return;
49         }
50         if (!np->n_next)
51             break;
52     }
53
54     /*
55      * Else add this new entry at the end
56      */
57     np->n_next = (struct node *) mh_xmalloc (sizeof(*np));
58
59     np = np->n_next;
60     np->n_name = getcpy (key);
61     np->n_field = getcpy (value);
62     np->n_context = 1;
63     np->n_next = NULL;
64     ctxflags |= CTXMOD;
65 }