]> code.citadel.org Git - citadel.git/commitdiff
* mime_parser.c: minor changes for easier porting between Citadel and WebCit
authorArt Cancro <ajc@citadel.org>
Tue, 19 Mar 2002 04:34:42 +0000 (04:34 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 19 Mar 2002 04:34:42 +0000 (04:34 +0000)
citadel/ChangeLog
citadel/mime_parser.c
citadel/mime_parser.h

index 3d5c1ed5c4f54041d862e0fb81c1f019ead16ae9..b1f04318a2a35620285676bd5922c6cb0c32a059 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 590.158  2002/03/19 04:34:42  ajc
+ * mime_parser.c: minor changes for easier porting between Citadel and WebCit
+
  Revision 590.157  2002/03/19 04:19:33  ajc
  * Saw what IO did with strchr() and did the same in a few more places
 
@@ -3519,3 +3522,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 6d99bf47774360d41ff03613ba4aec006b9bef3a..0029ece557b419d883c8faa82cc20fed7a67562f 100644 (file)
 #include <string.h>
 #include <sys/stat.h>
 #include <errno.h>
+
 #include "citadel.h"
 #include "server.h"
 #include "dynloader.h"
 #include "sysdep_decls.h"
-#include "mime_parser.h"
 #include "tools.h"
 
+#include "mime_parser.h"
+
 
 void extract_key(char *target, char *source, char *key)
 {
@@ -173,8 +175,6 @@ void mime_decode(char *partnum,
        char *decoded;
        size_t bytes_decoded = 0;
 
-       lprintf(9, "mime_decode() called\n");
-
        /* Some encodings aren't really encodings */
        if (!strcasecmp(encoding, "7bit"))
                strcpy(encoding, "");
@@ -195,7 +195,6 @@ void mime_decode(char *partnum,
        
        if ((strcasecmp(encoding, "base64"))
            && (strcasecmp(encoding, "quoted-printable"))) {
-               lprintf(9, "ERROR: unknown MIME encoding '%s'\n", encoding);
                return;
        }
        /*
@@ -204,16 +203,11 @@ void mime_decode(char *partnum,
         * will never be larger than the encoded data.  This is a safe
         * assumption with base64, uuencode, and quoted-printable.
         */
-       lprintf(9, "About to allocate %d bytes for decoded part\n",
-               length+2048);
        decoded = mallok(length+2048);
        if (decoded == NULL) {
-               lprintf(9, "ERROR: cannot allocate memory.\n");
                return;
        }
-       lprintf(9, "Got it!\n");
 
-       lprintf(9, "Decoding %s\n", encoding);
        if (!strcasecmp(encoding, "base64")) {
                bytes_decoded = decode_base64(decoded, part_start, length);
        }
@@ -221,7 +215,6 @@ void mime_decode(char *partnum,
                bytes_decoded = decode_quoted_printable(decoded,
                                                        part_start, length);
        }
-       lprintf(9, "Bytes decoded: %d\n", bytes_decoded);
 
        if (bytes_decoded > 0) if (CallBack != NULL) {
                CallBack(name, filename, fixed_partnum(partnum),
@@ -294,7 +287,6 @@ void the_mime_parser(char *partnum,
        size_t length;
        char nested_partnum[SIZ];
 
-       lprintf(9, "the_mime_parser() called\n");
        ptr = content_start;
        content_length = 0;
 
@@ -350,8 +342,6 @@ void the_mime_parser(char *partnum,
                                        *(strchr(content_type, ' ')) = '\0';
                                if (strchr(content_type, ';'))
                                        *(strchr(content_type, ';')) = '\0';
-                               lprintf(9, "Extracted content-type <%s>\n",
-                                       content_type);
                        }
                        if (!strncasecmp(header, "Content-Disposition: ", 21)) {
                                strcpy(disposition, &header[21]);
@@ -384,9 +374,6 @@ void the_mime_parser(char *partnum,
                is_multipart = 0;
        }
 
-       lprintf(9, "is_multipart=%d, boundary=<%s>\n",
-               is_multipart, boundary);
-
        /* If this is a multipart message, then recursively process it */
        part_start = NULL;
        if (is_multipart) {
@@ -404,7 +391,6 @@ void the_mime_parser(char *partnum,
                do {
                        if ( (!strncasecmp(ptr, startary, strlen(startary)))
                           || (!strncasecmp(ptr, endary, strlen(endary))) ) {
-                               lprintf(9, "hit boundary!\n");
                                if (part_start != NULL) {
                                        if (strlen(partnum) > 0) {
                                                snprintf(nested_partnum,
@@ -442,7 +428,6 @@ void the_mime_parser(char *partnum,
 
        /* If it's not a multipart message, then do something with it */
        if (!is_multipart) {
-               lprintf(9, "doing non-multipart thing\n");
                part_start = ptr;
                length = 0;
                while (ptr < content_end) {
@@ -454,7 +439,6 @@ void the_mime_parser(char *partnum,
                /* Truncate if the header told us to */
                if ( (content_length > 0) && (length > content_length) ) {
                        length = content_length;
-                       lprintf(9, "truncated to %ld\n", (long)content_length);
                }
                
                mime_decode(partnum,
@@ -526,7 +510,6 @@ void mime_parser(char *content_start,
 )
 {
 
-       lprintf(9, "mime_parser() called\n");
        the_mime_parser("", content_start, content_end,
                        CallBack,
                        PreMultiPartCallBack,
index 9518374bbc89416424925cb1f1dd68225f9cc7cc..9464f01fae32802f2c5839328204db87260f6f75 100644 (file)
@@ -3,8 +3,33 @@
  *
  */
 
-
+/*
+ * Here's a bunch of stupid magic to make the MIME parser portable between
+ * Citadel and WebCit.
+ */
+#ifndef SIZ
 #define SIZ    4096
+#endif
+
+#ifndef mallok
+#define mallok(x) malloc(x)
+#endif
+
+#ifndef phree
+#define phree(x) free(x)
+#endif
+
+#ifndef reallok
+#define reallok(x,y) realloc(x,y)
+#endif
+
+#ifndef strdoop
+#define strdoop(x) strdup(x)
+#endif
+
+/* 
+ * Declarations for functions in the parser
+ */
 
 void extract_key(char *target, char *source, char *key);