+void display_addressbook(long msgnum, char alpha) {
+ char buf[SIZ];
+ char mime_partnum[SIZ];
+ char mime_filename[SIZ];
+ char mime_content_type[SIZ];
+ char mime_disposition[SIZ];
+ int mime_length;
+ char vcard_partnum[SIZ];
+ char *vcard_source = NULL;
+
+ struct {
+ char date[SIZ];
+ char from[SIZ];
+ char to[SIZ];
+ char subj[SIZ];
+ int hasattachments;
+ } summ;
+
+ memset(&summ, 0, sizeof(summ));
+ strcpy(summ.subj, "(no subject)");
+
+ sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
+ serv_puts(buf);
+ serv_gets(buf);
+ if (buf[0] != '1') return;
+
+ while (serv_gets(buf), strcmp(buf, "000")) {
+ if (!strncasecmp(buf, "part=", 5)) {
+ extract(mime_filename, &buf[5], 1);
+ extract(mime_partnum, &buf[5], 2);
+ extract(mime_disposition, &buf[5], 3);
+ extract(mime_content_type, &buf[5], 4);
+ mime_length = extract_int(&buf[5], 5);
+
+ if (!strcasecmp(mime_content_type, "text/x-vcard")) {
+ strcpy(vcard_partnum, mime_partnum);
+ }
+
+ }
+ }
+
+ if (strlen(vcard_partnum) > 0) {
+ vcard_source = load_mimepart(msgnum, vcard_partnum);
+ if (vcard_source != NULL) {
+
+ /* If it's my vCard I can edit it */
+ if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
+ || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
+ wprintf("<A HREF=\"/edit_vcard?"
+ "msgnum=%ld&partnum=%s\">",
+ msgnum, vcard_partnum);
+ wprintf("(edit)</A>");
+ }
+
+ /* In all cases, display it */
+ display_vcard(vcard_source, alpha);
+ free(vcard_source);
+ }
+ }
+
+}
+
+
+