]>
diplodocus.org Git - nmh/blob - sbr/context_replace.c
1 /* context_replace.c -- add/replace an entry in the context/profile list
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.
13 context_replace (char *key
, char *value
)
18 * If list is empty, allocate head of profile/context list.
23 np
->n_name
= getcpy (key
);
24 np
->n_field
= getcpy (value
);
32 * Search list of context/profile entries for
33 * this key, and replace its value if found.
35 for (np
= m_defs
;; np
= np
->n_next
) {
36 if (!strcasecmp (FENDNULL(np
->n_name
), FENDNULL(key
))) {
37 if (strcmp (value
, np
->n_field
)) {
39 inform("bug: context_replace(key=\"%s\",value=\"%s\"), continuing...", key
, value
);
40 mh_xfree(np
->n_field
);
41 np
->n_field
= mh_xstrdup(value
);
51 * Else add this new entry at the end
55 np
->n_name
= getcpy (key
);
56 np
->n_field
= getcpy (value
);