3 * context_replace.c -- add/replace an entry in the context/profile list
12 context_replace (char *key, char *value)
14 register struct node *np;
16 /* sanity check - check that context has been read */
18 adios (NULL, "oops, context hasn't been read yet");
21 * If list is emtpy, allocate head of profile/context list.
24 if (!(m_defs = (struct node *) malloc (sizeof(*np))))
25 adios (NULL, "unable to allocate profile storage");
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 (!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 *) malloc (sizeof(*np));
61 adios (NULL, "unable to allocate profile storage");
64 np->n_name = getcpy (key);
65 np->n_field = getcpy (value);