]> diplodocus.org Git - nmh/commitdiff
Replaced raw hack to add the credentials profile entry in post.c
authorDavid Levine <levinedl@acm.org>
Sat, 4 May 2013 14:01:42 +0000 (09:01 -0500)
committerDavid Levine <levinedl@acm.org>
Sat, 4 May 2013 14:01:42 +0000 (09:01 -0500)
with new add_profile_entry() function.

h/prototypes.h
sbr/readconfig.c
uip/post.c

index 8830de02356189e80a9774e096c7467d564da98c..0df91b1d690be7c7b7554805faa09940ee346353 100644 (file)
@@ -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);
index 866747a2ab6ce1bb50e424547076ef638eaf5294..06a9470b06be4110d35b60c5e389a53136aa453e 100644 (file)
@@ -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;
+}
index 69f5b82103f1a7109bacdb9793ca8f5ce767477b..aadc6271a00fdf89ffbfdb72824afee91e1d9240 100644 (file)
@@ -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;
                }