From: David Levine Date: Sat, 4 May 2013 14:01:42 +0000 (-0500) Subject: Replaced raw hack to add the credentials profile entry in post.c X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/1ff43c7e4735e2dd95003570f96b10d7e0f88b7d?ds=inline;hp=-c Replaced raw hack to add the credentials profile entry in post.c with new add_profile_entry() function. --- 1ff43c7e4735e2dd95003570f96b10d7e0f88b7d diff --git a/h/prototypes.h b/h/prototypes.h index 8830de02..0df91b1d 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -29,6 +29,7 @@ char *etcpath(char *); struct msgs_array; +void add_profile_entry (const char *, const char *); void adios (char *, char *, ...) NORETURN; void admonish (char *, char *, ...); void advertise (char *, char *, char *, va_list); diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 866747a2..06a9470b 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -155,3 +155,18 @@ readconfig (struct node **npp, FILE *ib, char *file, int ctx) opp = npp; } + + +void +add_profile_entry (const char *key, const char *value) { + struct node *newnode = (struct node *) mh_xmalloc (sizeof *newnode); + + /* This inserts the new node at the beginning of m_defs because + that doesn't require traversing it or checking to see if it's + empty. */ + newnode->n_name = getcpy (key); + newnode->n_field = getcpy (value); + newnode->n_context = 0; + newnode->n_next = m_defs; + m_defs = newnode; +} diff --git a/uip/post.c b/uip/post.c index 69f5b821..aadc6271 100644 --- a/uip/post.c +++ b/uip/post.c @@ -496,17 +496,9 @@ main (int argc, char **argv) continue; case CREDENTIALSSW: { - /* post doesn't read the profile, so insert credentials - entry the hard way. */ - struct node *np = (struct node *) mh_xmalloc (sizeof *np); - if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); - np->n_name = "credentials"; - np->n_field = cp; - np->n_context = 0; - np->n_next = m_defs; - m_defs = np; + add_profile_entry ("credentials", cp); continue; }