]> diplodocus.org Git - nmh/commitdiff
Beginnings of selectable CTE; allow specification in mhbuild directives,
authorKen Hornstein <kenh@pobox.com>
Wed, 29 Jan 2014 20:56:01 +0000 (15:56 -0500)
committerKen Hornstein <kenh@pobox.com>
Wed, 29 Jan 2014 20:56:01 +0000 (15:56 -0500)
but it doesn't do anything quite yet.

h/mhparse.h
uip/mhparse.c

index 29fc1afe1fcc2fc964e434e942578847c87cc4ba..85b1bc16ea70ad19678f95666831c543a99b0982 100644 (file)
@@ -109,6 +109,7 @@ struct Content {
     /* Content-Transfer-Encoding info (decoded contents) */
     struct cefile c_cefile;    /* structure holding decoded content */
     int        c_encoding;             /* internal flag for encoding type   */
     /* Content-Transfer-Encoding info (decoded contents) */
     struct cefile c_cefile;    /* structure holding decoded content */
     int        c_encoding;             /* internal flag for encoding type   */
+    int c_reqencoding;         /* Requested encoding (by mhbuild)   */
 
     /* Content-MD5 info */
     int        c_digested;             /* have we seen this header before?  */
 
     /* Content-MD5 info */
     int        c_digested;             /* have we seen this header before?  */
index 716a22f73144de4b8436883d9cfe87c9d2c41459..371d0c926567e084418a74dcea4dfd1a40886778 100644 (file)
@@ -80,6 +80,19 @@ struct k2v SubApplication[] = {
     { NULL,           APPLICATION_UNKNOWN }    /* this one must be last! */
 };
 
     { NULL,           APPLICATION_UNKNOWN }    /* this one must be last! */
 };
 
+/*
+ * Mapping of names of CTE types in mhbuild directives
+ */
+static struct k2v EncodingType[] = {
+    { "8bit",                  CE_8BIT },
+    { "qp",                    CE_QUOTED },
+    { "q-p",                   CE_QUOTED },
+    { "quoted-printable",      CE_QUOTED },
+    { "b64",                   CE_BASE64 },
+    { "base64",                        CE_BASE64 },
+    { NULL,                    0 },
+};
+
 
 /* mhcachesbr.c */
 int find_cache (CT, int, int *, char *, char *, int);
 
 /* mhcachesbr.c */
 int find_cache (CT, int, int *, char *, char *, int);
@@ -838,6 +851,47 @@ magic_skip:
            cp++;
     }
 
            cp++;
     }
 
+    /*
+     * Get any extension directives (right now just the content transfer
+     * encoding, but maybe others) that we care about.
+     */
+
+    if (magic && *cp == '*') {
+       /*
+        * See if it's a CTE we match on
+        */
+       struct k2v *kv;
+
+       dp = ++cp;
+       while (*cp != '\0' && ! isspace((unsigned char) *cp))
+           cp++;
+
+       if (dp == cp) {
+           advise (NULL, "invalid null transfer encoding specification");
+           return NOTOK;
+       }
+
+       if (*cp != '\0')
+           *cp++ = '\0';
+
+       ct->c_reqencoding = CE_UNKNOWN;
+
+       for (kv = EncodingType; kv->kv_key; kv++) {
+           if (strcasecmp(kv->kv_key, dp) == 0) {
+               ct->c_reqencoding = kv->kv_value;
+               break;
+           }
+       }
+
+       if (ct->c_reqencoding == CE_UNKNOWN) {
+           advise (NULL, "invalid CTE specification: \"%s\"", dp);
+           return NOTOK;
+       }
+
+       while (isspace ((unsigned char) *cp))
+           cp++;
+    }
+
     /*
      * Check if anything is left over
      */
     /*
      * Check if anything is left over
      */