* Added some traces and minor additions, getting ready to optimize load_ical_object...
authorArt Cancro <ajc@citadel.org>
Thu, 16 Apr 2009 03:04:54 +0000 (03:04 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 16 Apr 2009 03:04:54 +0000 (03:04 +0000)
webcit/calendar.c
webcit/webcit.c

index e419d3b4d862b3ac3b66d49d21448519a203994c..fe1911afced9e0aca908b216c7c3a990015354aa 100644 (file)
@@ -1017,6 +1017,7 @@ void load_ical_object(long msgnum, int unread,
        char relevant_partnum[256];
        char *relevant_source = NULL;
        icalcomponent *cal, *c;
+       int phase = 0;                          /* 0 = citadel headers, 1 = mime headers, 2 = body */
 
        relevant_partnum[0] = '\0';
        sprintf(buf, "MSG4 %ld", msgnum);       /* we need the mime headers */
@@ -1027,7 +1028,7 @@ void load_ical_object(long msgnum, int unread,
        Buf = NewStrBuf();
        while (BufLen = StrBuf_ServGetlnBuffered(Buf), strcmp(ChrPtr(Buf), "000")) {
                bptr = ChrPtr(Buf);
-               if (!strncasecmp(bptr, "part=", 5)) {
+               if ((phase == 0) && (!strncasecmp(bptr, "part=", 5))) {
                        extract_token(mime_filename, &bptr[5], 1, '|', sizeof mime_filename);
                        extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum);
                        extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition);
@@ -1041,9 +1042,22 @@ void load_ical_object(long msgnum, int unread,
                                strcpy(relevant_partnum, mime_partnum);
                        }
                }
-               else if (!strncasecmp(bptr, "from=", 4)) {
+               else if ((phase == 0) && (!strncasecmp(bptr, "from=", 4))) {
                        extract_token(from, bptr, 1, '=', sizeof(from));
                }
+               else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
+                       phase = 1;
+               }
+               else if ((phase == 1) && (IsEmptyStr(bptr))) {
+                       phase = 2;
+               }
+/**
+ ** FIXME optimize here
+ **
+               else if ((phase == 1) && (!strncasecmp(bptr, "Content-type:", 13))) {
+                       lprintf(9, "%s\n", bptr);
+               }
+ **/
        }
        FreeStrBuf(&Buf);
 
index 9f430049004915f170e1246155da84709c6b792f..00afe8eb590abcc4448beacf5b54ef7ab682bd1f 100644 (file)
@@ -1055,9 +1055,9 @@ SKIP_ALL_THIS_CRAP:
        /* How long did this transaction take? */
        gettimeofday(&tx_finish, NULL);
        
-       lprintf(9, "Transaction completed in %ld microseconds.\n",
-               (tx_finish.tv_sec*1000000 + tx_finish.tv_usec)
-               - (tx_start.tv_sec*1000000 + tx_start.tv_usec)
+       lprintf(9, "Transaction completed in %ld.%06ld seconds.\n",
+               ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
+               ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000
        );
 }