3 * context_replace.c -- add/replace an entry in the context/profile list
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.
15 context_replace (char *key, char *value)
17 register struct node *np;
20 * If list is emtpy, allocate head of profile/context list.
23 m_defs = (struct node *) mh_xmalloc (sizeof(*np));
26 np->n_name = getcpy (key);
27 np->n_field = getcpy (value);
35 * Search list of context/profile entries for
36 * this key, and replace its value if found.
38 for (np = m_defs;; np = np->n_next) {
39 if (!mh_strcasecmp (np->n_name, key)) {
40 if (strcmp (value, np->n_field)) {
42 admonish (NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
45 np->n_field = getcpy (value);
55 * Else add this new entry at the end
57 np->n_next = (struct node *) mh_xmalloc (sizeof(*np));
60 np->n_name = getcpy (key);
61 np->n_field = getcpy (value);