2 ** context_replace.c -- add/replace an entry in the context/profile list
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
14 context_replace(char *key, char *value)
16 register struct node *np;
19 ** If list is emtpy, allocate head of profile/context list.
22 m_defs = (struct node *) mh_xmalloc(sizeof(*np));
25 np->n_name = getcpy(key);
26 np->n_field = getcpy(value);
34 ** Search list of context/profile entries for
35 ** this key, and replace its value if found.
37 for (np = m_defs;; np = np->n_next) {
38 if (!mh_strcasecmp(np->n_name, key)) {
39 if (strcmp(value, np->n_field)!=0) {
41 admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
44 np->n_field = getcpy(value);
54 ** Else add this new entry at the end
56 np->n_next = (struct node *) mh_xmalloc(sizeof(*np));
59 np->n_name = getcpy(key);
60 np->n_field = getcpy(value);