]> code.citadel.org Git - citadel.git/blobdiff - webcit/useredit.c
* make shure the buffer is cleared
[citadel.git] / webcit / useredit.c
index 09d10898743c82e5840e893d558252b5662868aa..b1d2479fe73024fec01fd32ec7ba4ca8f7f65501 100644 (file)
@@ -442,7 +442,8 @@ TRYAGAIN:
                        
                        if (Msg->AllAttach != NULL) {
                                att = GetNewHashPos(Msg->AllAttach, 0);
-                               while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg)) {
+                               while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg) && 
+                                      (vcard_msgnum == -1)) {
                                        Att = (wc_mime_attachment*) vMsg;
                                        if (
                                                (strcasecmp(ChrPtr(Att->ContentType), "text/x-vcard") == 0)
@@ -450,9 +451,9 @@ TRYAGAIN:
                                        ) {
                                                *VCAtt = Att;
                                                *VCMsg = Msg;
+                                               vcard_msgnum = Msg->msgnum;
                                                if (Att->Data == NULL) {
                                                        MimeLoadData(Att);
-                                                       vcard_msgnum = Msg->msgnum;
                                                }
                                        }
                                }
@@ -466,6 +467,7 @@ TRYAGAIN:
 
        /* If there's no vcard, create one */
        if ((*VCMsg == NULL) && (already_tried_creating_one == 0)) {
+               FlushStrBuf(Buf);
                already_tried_creating_one = 1;
                serv_puts("ENT0 1|||4");
                StrBuf_ServGetln(Buf);
@@ -476,6 +478,8 @@ TRYAGAIN:
                        serv_puts("end:vcard");
                        serv_puts("000");
                }
+               else 
+                       lprintf(1, "Error while creating user vcard: %s\n", ChrPtr(Buf));
                goto TRYAGAIN;
        }
        FreeStrBuf(&Buf);