* use linebuffered reading while reading calendar; first draft.
authorWilfried Göesgens <willi@citadel.org>
Sat, 11 Apr 2009 13:57:35 +0000 (13:57 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 11 Apr 2009 13:57:35 +0000 (13:57 +0000)
webcit/calendar.c

index 9fcf8b7c8ffadb9d14e070dcbbbc9bd6c86d8b33..d110b8f50ef24c376110bf921ff3120ae3ae6c7c 100644 (file)
@@ -1004,6 +1004,8 @@ void load_ical_object(long msgnum, int unread,
                           struct calview *calv
        ) 
 {
+       StrBuf *Buf;
+       size_t BufLen;
        char buf[1024];
        char from[128] = "";
        char mime_partnum[256];
@@ -1021,13 +1023,14 @@ void load_ical_object(long msgnum, int unread,
        serv_getln(buf, sizeof buf);
        if (buf[0] != '1') return;
 
-       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               if (!strncasecmp(buf, "part=", 5)) {
-                       extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
-                       extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
-                       extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
-                       extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
-                       mime_length = extract_int(&buf[5], 5);
+       Buf = NewStrBuf();
+       while (BufLen = StrBuf_ServGetlnBuffered(Buf), strcmp(ChrPtr(Buf), "000")) {
+               if (!strncasecmp(ChrPtr(Buf), "part=", 5)) {
+                       extract_token(mime_filename, &ChrPtr(Buf)[5], 1, '|', sizeof mime_filename);
+                       extract_token(mime_partnum, &ChrPtr(Buf)[5], 2, '|', sizeof mime_partnum);
+                       extract_token(mime_disposition, &ChrPtr(Buf)[5], 3, '|', sizeof mime_disposition);
+                       extract_token(mime_content_type, &ChrPtr(Buf)[5], 4, '|', sizeof mime_content_type);
+                       mime_length = extract_int(&ChrPtr(Buf)[5], 5);
 
                        if (  (!strcasecmp(mime_content_type, "text/calendar"))
                              || (!strcasecmp(mime_content_type, "application/ics"))
@@ -1036,10 +1039,11 @@ void load_ical_object(long msgnum, int unread,
                                strcpy(relevant_partnum, mime_partnum);
                        }
                }
-               else if (!strncasecmp(buf, "from=", 4)) {
-                       extract_token(from, buf, 1, '=', sizeof(from));
+               else if (!strncasecmp(ChrPtr(Buf), "from=", 4)) {
+                       extract_token(from, ChrPtr(Buf), 1, '=', sizeof(from));
                }
        }
+       FreeStrBuf(&Buf);
 
        if (!IsEmptyStr(relevant_partnum)) {
                relevant_source = load_mimepart(msgnum, relevant_partnum);