]>
diplodocus.org Git - nmh/blob - sbr/context_replace.c
3 * context_replace.c -- add/replace an entry in the context/profile list
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
17 context_replace (char *key
, char *value
)
19 register struct node
*np
;
22 * If list is emtpy, allocate head of profile/context list.
25 m_defs
= (struct node
*) mh_xmalloc (sizeof(*np
));
28 np
->n_name
= getcpy (key
);
29 np
->n_field
= getcpy (value
);
37 * Search list of context/profile entries for
38 * this key, and replace its value if found.
40 for (np
= m_defs
;; np
= np
->n_next
) {
41 if (!mh_strcasecmp (np
->n_name
, key
)) {
42 if (strcmp (value
, np
->n_field
)) {
44 admonish (NULL
, "bug: context_replace(key=\"%s\",value=\"%s\")", key
, value
);
47 np
->n_field
= getcpy (value
);
57 * Else add this new entry at the end
59 np
->n_next
= (struct node
*) mh_xmalloc (sizeof(*np
));
62 np
->n_name
= getcpy (key
);
63 np
->n_field
= getcpy (value
);