From 9d54c4a9a278a83fa70c8eeb812fc8d68a2eda94 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 16 Apr 2009 03:04:54 +0000 Subject: [PATCH] * Added some traces and minor additions, getting ready to optimize load_ical_object() so that it doesn't have to call load_mimepart() most of the time --- webcit/calendar.c | 18 ++++++++++++++++-- webcit/webcit.c | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/webcit/calendar.c b/webcit/calendar.c index e419d3b4d..fe1911afc 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -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); diff --git a/webcit/webcit.c b/webcit/webcit.c index 9f4300490..00afe8eb5 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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 ); } -- 2.39.2