]> code.citadel.org Git - citadel.git/commitdiff
* Began some hacks for vCard processing
authorArt Cancro <ajc@citadel.org>
Wed, 13 Feb 2002 15:04:26 +0000 (15:04 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 13 Feb 2002 15:04:26 +0000 (15:04 +0000)
webcit/ChangeLog
webcit/messages.c
webcit/webcit.c
webcit/webcit.h

index 905450eb481e81f1cacfc5c58c44ea89b837754b..5a780b3da6d5b100e3c0fa0580601af8fcdddb47 100644 (file)
@@ -1,6 +1,6 @@
 $Log$
-Revision 323.1  2002/01/24 23:50:36  error
-* Trace file using lprintf() similarly to citserver
+Revision 323.2  2002/02/13 15:04:25  ajc
+* Began some hacks for vCard processing
 
 Revision 323.0  2002/01/13 09:07:06  ajc
 * THIS IS 3.23
index 33794ddca5a160cbd68465c2a353bcaf4a611bc3..da0e2b6be266d14e5944089226a589087ff33932 100644 (file)
@@ -98,11 +98,14 @@ void read_message(long msgnum, int is_summary) {
        int format_type = 0;
        int nhdr = 0;
        int bq = 0;
+       char vcard_partnum[SIZ];
+       char *vcard_source = NULL;
 
        strcpy(from, "");
        strcpy(node, "");
        strcpy(rfca, "");
        strcpy(reply_to, "");
+       strcpy(vcard_partnum, "");
 
        sprintf(buf, "MSG0 %ld", msgnum);
        serv_puts(buf);
@@ -208,6 +211,10 @@ void read_message(long msgnum, int is_summary) {
                                        msgnum, mime_partnum);
                        }
 
+                       if (!strcasecmp(mime_content_type, "text/x-vcard")) {
+                               strcpy(vcard_partnum, mime_partnum);
+                       }
+
                }
 
        }
@@ -309,6 +316,16 @@ void read_message(long msgnum, int is_summary) {
                wprintf("%s", mime_http);
                free(mime_http);
        }
+
+       if (strlen(vcard_partnum) > 0) {
+               vcard_source = load_mimepart(msgnum, vcard_partnum);
+               if (vcard_source != NULL) {
+                       wprintf("vcard object length = %d<BR>\n",
+                               strlen(vcard_source));
+                       free(vcard_source);
+               }
+       }
+
 }
 
 
index 4cae23969a032f24e02efad88913dda5115c778b..f8839f8444d6049a7dd4f5456e29e2a4beea1757 100644 (file)
@@ -29,7 +29,6 @@
 #include <pthread.h>
 #include <signal.h>
 #include "webcit.h"
-#include "webserver.h"
 #include "mime_parser.h"
 
 /*
@@ -436,7 +435,7 @@ void output_static(char *what)
 
                fstat(fileno(fp), &statbuf);
                bytes = statbuf.st_size;
-               lprintf(5, "Static: %s, %ld bytes\n", what, bytes);
+               fprintf(stderr, "Static: %s, %ld bytes\n", what, bytes);
                wprintf("Content-length: %ld\n", (long) bytes);
                wprintf("\n");
                bigbuffer = malloc(bytes);
@@ -555,6 +554,57 @@ void output_mimepart()
 }
 
 
+/*
+ */
+char *load_mimepart(long msgnum, char *partnum)
+{
+       char buf[SIZ];
+       off_t bytes;
+       off_t thisblock;
+       off_t accomplished = 0L;
+       char content_type[SIZ];
+       char *content;
+       
+       serv_printf("OPNA %ld|%s", msgnum, partnum);
+       serv_gets(buf);
+       if (buf[0] == '2') {
+               bytes = extract_long(&buf[4], 0);
+               extract(content_type, &buf[4], 3);
+
+               content = malloc(bytes + 1);
+
+               while (bytes > (off_t) 0) {
+                       thisblock = bytes;
+                       if (thisblock > 4096L) {
+                               thisblock = 4096L;
+                       }
+                       if (thisblock > bytes) {
+                               thisblock = bytes;
+                       }
+                       serv_printf("READ %ld|%ld", accomplished, thisblock);
+                       serv_gets(buf);
+                       if (buf[0] == '6') {
+                               thisblock = extract_long(&buf[4], 0);
+                               serv_read(&content[accomplished], (int) thisblock);
+                       }
+                       else {
+                               memset(&content[accomplished], 0, thisblock);
+                       }
+                       bytes = bytes - thisblock;
+                       accomplished = accomplished + thisblock;
+               }
+               serv_puts("CLOS");
+               serv_gets(buf);
+               content[accomplished] = 0;      /* null terminate for good measure */
+               return(content);
+       }
+       else {
+               return(NULL);
+       }
+
+}
+
+
 /*
  * Convenience functions to display a page containing only a string
  */
@@ -632,12 +682,12 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp,
                        char *encoding, void *userdata)
 {
 
-       lprintf(9, "UPLOAD HANDLER CALLED\n");
-       lprintf(9, "    name = %s\n", name);
-       lprintf(9, "filename = %s\n", filename);
-       lprintf(9, "encoding = %s\n", encoding);
-       lprintf(9, "    type = %s\n", cbtype);
-       lprintf(9, "  length = %ld\n", (long)length);
+       fprintf(stderr, "UPLOAD HANDLER CALLED\n");
+       fprintf(stderr, "    name = %s\n", name);
+       fprintf(stderr, "filename = %s\n", filename);
+       fprintf(stderr, "encoding = %s\n", encoding);
+       fprintf(stderr, "    type = %s\n", cbtype);
+       fprintf(stderr, "  length = %ld\n", (long)length);
 
        if (length > 0) {
                WC->upload = malloc(length);
@@ -646,7 +696,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp,
                        memcpy(WC->upload, content, length);
                }
                else {
-                       lprintf(1, "malloc() failed: %s\n",
+                       fprintf(stderr, "malloc() failed: %s\n",
                                strerror(errno));
                }
        }
@@ -718,7 +768,7 @@ void session_loop(struct httprequest *req)
        }
 
        if (ContentLength > 0) {
-               lprintf(5, "Content length: %d\n", ContentLength);
+               fprintf(stderr, "Content length: %d\n", ContentLength);
                content = malloc(ContentLength + 1);
                memset(content, 0, ContentLength+1);
                BytesRead = 0;
index d7f809615f40bcba6452a73332d82a3894a3e0c7..ab70de2f0cc4f2212be8c21058fea5887a53f94e 100644 (file)
@@ -285,3 +285,4 @@ int num_tokens (char *source, char tok);
 void extract_token(char *dest, char *source, int parmnum, char separator);
 void remove_token(char *source, int parmnum, char separator);
 int decode_base64(char *dest, char *source);
+char *load_mimepart(long msgnum, char *partnum);