Updating user programs to use <h/tws> instead of <zotnet/tws/tws.h>
[mmh] / uip / mhparse.c
index fc5ab20..0813aa7 100644 (file)
@@ -13,7 +13,7 @@
 #include <setjmp.h>
 #include <signal.h>
 #include <zotnet/mts/mts.h>
-#include <zotnet/tws/tws.h>
+#include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 
@@ -205,8 +205,7 @@ pidcheck (int status)
 
     fflush (stdout);
     fflush (stderr);
-    done (1);
-    /* NOTREACHED */
+    return done (1);
 }
 
 
@@ -1569,6 +1568,8 @@ openBase64 (CT ct, char **file)
     unsigned long bits;
     unsigned char value, *b, *b1, *b2, *b3;
     char *cp, *ep, buffer[BUFSIZ];
+    /* sbeck -- handle prefixes */
+    CI ci;
     CE ce;
     MD5_CTX mdContext;
 
@@ -1599,6 +1600,19 @@ openBase64 (CT ct, char **file)
        ce->ce_unlink = 0;
     }
 
+    /* sbeck@cise.ufl.edu -- handle suffixes */
+    ci = &ct->c_ctinfo;
+    snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+              invo_name, ci->ci_type, ci->ci_subtype);
+    cp = context_find (buffer);
+    if (cp == NULL || *cp == '\0') {
+        snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+                  ci->ci_type);
+        cp = context_find (buffer);
+    }
+    if (cp != NULL && *cp != '\0')
+        ce->ce_file = add (cp, ce->ce_file);
+
     if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
        content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
        return NOTOK;
@@ -1768,6 +1782,8 @@ openQuoted (CT ct, char **file)
     char buffer[BUFSIZ];
     unsigned char mask;
     CE ce;
+    /* sbeck -- handle prefixes */
+    CI ci;
     MD5_CTX mdContext;
 
     ce = ct->c_cefile;
@@ -1792,6 +1808,24 @@ openQuoted (CT ct, char **file)
        ce->ce_unlink = 0;
     }
 
+    /* sbeck@cise.ufl.edu -- handle suffixes */
+    ci = &ct->c_ctinfo;
+    snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+              invo_name, ci->ci_type, ci->ci_subtype);
+    cp = context_find (buffer);
+    if (cp == NULL || *cp == '\0') {
+        snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+                  ci->ci_type);
+        cp = context_find (buffer);
+    }
+    if (cp != NULL && *cp != '\0')
+        ce->ce_file = add (cp, ce->ce_file);
+
+    if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
+       content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+       return NOTOK;
+    }
+
     if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
        content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
        return NOTOK;
@@ -1966,6 +2000,9 @@ open7Bit (CT ct, char **file)
 {
     int        cc, fd, len;
     char buffer[BUFSIZ];
+    /* sbeck -- handle prefixes */
+    char *cp;
+    CI ci;
     CE ce;
 
     ce = ct->c_cefile;
@@ -1990,6 +2027,19 @@ open7Bit (CT ct, char **file)
        ce->ce_unlink = 0;
     }
 
+    /* sbeck@cise.ufl.edu -- handle suffixes */
+    ci = &ct->c_ctinfo;
+    snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+              invo_name, ci->ci_type, ci->ci_subtype);
+    cp = context_find (buffer);
+    if (cp == NULL || *cp == '\0') {
+        snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+                  ci->ci_type);
+        cp = context_find (buffer);
+    }
+    if (cp != NULL && *cp != '\0')
+        ce->ce_file = add (cp, ce->ce_file);
+
     if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
        content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
        return NOTOK;
@@ -2400,7 +2450,7 @@ losing_ftp:
            goto losing_ftp;
 #endif
 
-    if (cachefile[0])
+    if (cachefile[0]) {
        if (caching)
            chmod (cachefile, cachetype ? m_gmprot () : 0444);
        else {
@@ -2414,7 +2464,7 @@ losing_ftp:
 
                fseek (gp, 0L, SEEK_SET);
 
-               while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), gp))
+               while ((cc= fread (buffer, sizeof(*buffer), sizeof(buffer), gp))
                           > 0)
                    fwrite (buffer, sizeof(*buffer), cc, fp);
                fflush (fp);
@@ -2432,6 +2482,7 @@ losing_ftp:
            }
            umask (mask);
        }
+    }
 
     fseek (ce->ce_fp, 0L, SEEK_SET);
     *file = ce->ce_file;