* Brought over the debugged mime parser from Citadel
authorArt Cancro <ajc@citadel.org>
Sun, 13 Jan 2002 09:06:38 +0000 (09:06 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 13 Jan 2002 09:06:38 +0000 (09:06 +0000)
webcit/ChangeLog
webcit/README.txt
webcit/mime_parser.c
webcit/webcit.h

index cc0786f2033c9989d07b9ac13a73ebf7881102f0..a463b3f2d2ed32f0fb51c6a179fcda885aaa0fa4 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 322.4  2002/01/13 09:06:38  ajc
+* Brought over the debugged mime parser from Citadel
+
 Revision 322.3  2002/01/05 06:19:17  error
 * Add MIME types text/css and image/png
 
@@ -707,4 +710,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index b561bd0ca03a94dd25445a62cf72cdab1f71cc6d..1a96ad1d234fec94e3b8958e0458ee5b5605adfe 100644 (file)
@@ -1,5 +1,5 @@
                       WEBCIT for the Citadel/UX System
-                               version 3.22
+                               version 3.23
  
    Copyright (C) 1996-2001 by the authors.  Portions written by:
        Art Cancro
index 021d5e52be11fba11822e472a13a33b7611ee25c..2fa52d9a1e517304b0677d15c075ea35f5e698b8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * This is the MIME parser for Citadel.  Sometimes it actually works.
  *
- * Copyright (c) 1998-2001 by Art Cancro
+ * Copyright (c) 1998-2002 by Art Cancro
  * This code is distributed under the terms of the GNU General Public License.
  *
  */
@@ -17,9 +17,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <pthread.h>
 #include "webcit.h"
-#include "mime_parser.h"
 
 
 void extract_key(char *target, char *source, char *key)
@@ -166,6 +164,8 @@ void mime_decode(char *partnum,
        char *decoded;
        size_t bytes_decoded = 0;
 
+       fprintf(stderr, "mime_decode() called\n");
+
        /* Some encodings aren't really encodings */
        if (!strcasecmp(encoding, "7bit"))
                strcpy(encoding, "");
@@ -183,6 +183,7 @@ void mime_decode(char *partnum,
                        }
                return;
        }
+       
        if ((strcasecmp(encoding, "base64"))
            && (strcasecmp(encoding, "quoted-printable"))) {
                fprintf(stderr, "ERROR: unknown MIME encoding '%s'\n", encoding);
@@ -192,15 +193,18 @@ void mime_decode(char *partnum,
         * Allocate a buffer for the decoded data.  The output buffer is the
         * same size as the input buffer; this assumes that the decoded data
         * will never be larger than the encoded data.  This is a safe
-        * assumption with base64, uuencode, and quoted-printable.  Just to
-        * be safe, we still pad the buffer a bit.
+        * assumption with base64, uuencode, and quoted-printable.
         */
-       decoded = malloc(length + 1024);
+       fprintf(stderr, "About to allocate %d bytes for decoded part\n",
+               length+2048);
+       decoded = malloc(length+2048);
        if (decoded == NULL) {
                fprintf(stderr, "ERROR: cannot allocate memory.\n");
                return;
        }
+       fprintf(stderr, "Got it!\n");
 
+       fprintf(stderr, "Decoding %s\n", encoding);
        if (!strcasecmp(encoding, "base64")) {
                bytes_decoded = decode_base64(decoded, part_start);
        }
@@ -208,6 +212,7 @@ void mime_decode(char *partnum,
                bytes_decoded = decode_quoted_printable(decoded,
                                                        part_start, length);
        }
+       fprintf(stderr, "Bytes decoded: %d\n", bytes_decoded);
 
        if (bytes_decoded > 0) if (CallBack != NULL) {
                CallBack(name, filename, fixed_partnum(partnum),
@@ -218,9 +223,6 @@ void mime_decode(char *partnum,
        free(decoded);
 }
 
-
-
-
 /*
  * Break out the components of a multipart message
  * (This function expects to be fed HEADERS + CONTENT)
@@ -322,7 +324,7 @@ void the_mime_parser(char *partnum,
        /* Learn interesting things from the headers */
        strcpy(header, "");
        do {
-               ptr = memreadline(ptr, buf, sizeof buf);
+               ptr = memreadline(ptr, buf, SIZ);
                if (ptr >= content_end) {
                        goto end_parser;
                }
@@ -351,7 +353,7 @@ void the_mime_parser(char *partnum,
                                extract_key(boundary, header, "boundary");
                        strcpy(header, "");
                }
-               if ((strlen(header) + strlen(buf) + 2) < sizeof(header))
+               if ((strlen(header) + strlen(buf) + 2) < SIZ)
                        strcat(header, buf);
        } while ((strlen(buf) > 0) && (*ptr != 0));
 
@@ -410,7 +412,7 @@ void the_mime_parser(char *partnum,
                                                        userdata,
                                                        dont_decode);
                                }
-                               ptr = memreadline(ptr, buf, sizeof(buf));
+                               ptr = memreadline(ptr, buf, SIZ);
                                part_start = ptr;
                        }
                        else {
@@ -464,10 +466,6 @@ end_parser:        /* free the buffers!  end the oppression!! */
 
 
 
-
-
-
-
 /*
  * Entry point for the MIME parser.
  * (This function expects to be fed HEADERS + CONTENT)
index 522a48193760d8afc3a03c9e4a79ec6159e62221..d7f809615f40bcba6452a73332d82a3894a3e0c7 100644 (file)
@@ -7,10 +7,10 @@
 #define SLEEPING               180             /* TCP connection timeout */
 #define WEBCIT_TIMEOUT         900             /* WebCit session timeout */
 #define PORT_NUM               2000            /* port number to listen on */
-#define SERVER                 "WebCit v3.22"  /* who's in da house */
+#define SERVER                 "WebCit v3.23"  /* who's in da house */
 #define DEVELOPER_ID           0
 #define CLIENT_ID              4
-#define CLIENT_VERSION         322
+#define CLIENT_VERSION         323
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define LB                     (1)             /* Internal escape chars */