Commit c8bb4b94 c8bb4b9413f72f2e9c5f81b5f1674c9341ed369f by Sergey Poznyakoff

Rewrite using new envelope accessors

1 parent 00668ac3
...@@ -37,16 +37,18 @@ util_get_sender (int msgno) ...@@ -37,16 +37,18 @@ util_get_sender (int msgno)
37 mu_header_t header = NULL; 37 mu_header_t header = NULL;
38 mu_address_t addr = NULL; 38 mu_address_t addr = NULL;
39 mu_message_t msg = NULL; 39 mu_message_t msg = NULL;
40 char buffer[512]; 40 const char *buffer;
41 char *email;
41 42
42 mu_mailbox_get_message (mbox, msgno, &msg); 43 mu_mailbox_get_message (mbox, msgno, &msg);
43 mu_message_get_header (msg, &header); 44 mu_message_get_header (msg, &header);
44 if (mu_header_get_value (header, MU_HEADER_FROM, buffer, sizeof (buffer), NULL) 45 if (mu_header_sget_value (header, MU_HEADER_FROM, &buffer)
45 || mu_address_create (&addr, buffer)) 46 || mu_address_create (&addr, buffer))
46 { 47 {
47 mu_envelope_t env = NULL; 48 mu_envelope_t env = NULL;
48 mu_message_get_envelope (msg, &env); 49 mu_message_get_envelope (msg, &env);
49 if (mu_envelope_sender (env, buffer, sizeof (buffer), NULL) 50
51 if (mu_envelope_sget_sender (env, &buffer)
50 || mu_address_create (&addr, buffer)) 52 || mu_address_create (&addr, buffer))
51 { 53 {
52 util_error (_("Cannot determine sender name (msg %d)"), msgno); 54 util_error (_("Cannot determine sender name (msg %d)"), msgno);
...@@ -54,7 +56,7 @@ util_get_sender (int msgno) ...@@ -54,7 +56,7 @@ util_get_sender (int msgno)
54 } 56 }
55 } 57 }
56 58
57 if (mu_address_get_email (addr, 1, buffer, sizeof (buffer), NULL)) 59 if (mu_address_aget_email (addr, 1, &email))
58 { 60 {
59 util_error (_("Cannot determine sender name (msg %d)"), msgno); 61 util_error (_("Cannot determine sender name (msg %d)"), msgno);
60 mu_address_destroy (&addr); 62 mu_address_destroy (&addr);
...@@ -62,6 +64,6 @@ util_get_sender (int msgno) ...@@ -62,6 +64,6 @@ util_get_sender (int msgno)
62 } 64 }
63 65
64 mu_address_destroy (&addr); 66 mu_address_destroy (&addr);
65 return strdup (buffer); 67 return email;
66 } 68 }
67 69
......
...@@ -65,16 +65,25 @@ static int ...@@ -65,16 +65,25 @@ static int
65 _append_date (mu_envelope_t envelope, char *buf, size_t len, size_t *pnwrite) 65 _append_date (mu_envelope_t envelope, char *buf, size_t len, size_t *pnwrite)
66 { 66 {
67 mu_message_t msg = mu_envelope_get_owner (envelope); 67 mu_message_t msg = mu_envelope_get_owner (envelope);
68 struct tm **tm = mu_message_get_owner (msg); 68 size_t size;
69 69 if (!buf)
70 mu_strftime (buf, len, "%a %b %d %H:%M:%S %Y", *tm); 70 size = MU_ENVELOPE_DATE_LENGTH;
71 else
72 {
73 struct tm **tm = mu_message_get_owner (msg);
74 size = mu_strftime (buf, len, "%a %b %d %H:%M:%S %Y", *tm);
75 }
76 if (pnwrite)
77 *pnwrite = size;
71 return 0; 78 return 0;
72 } 79 }
73 80
74 static int 81 static int
75 _append_sender (mu_envelope_t envelope, char *buf, size_t len, size_t *pnwrite) 82 _append_sender (mu_envelope_t envelope, char *buf, size_t len, size_t *pnwrite)
76 { 83 {
77 strncpy (buf, "GNU-imap4d", len); 84 size_t n = mu_cpystr (buf, "GNU-imap4d", len);
85 if (pnwrite)
86 *pnwrite = n;
78 return 0; 87 return 0;
79 } 88 }
80 89
...@@ -139,4 +148,3 @@ imap4d_append0 (mu_mailbox_t mbox, int flags, char *text) ...@@ -139,4 +148,3 @@ imap4d_append0 (mu_mailbox_t mbox, int flags, char *text)
139 } 148 }
140 149
141 150
142
......
...@@ -349,27 +349,24 @@ fetch_flags (struct fetch_command *command, char **arg) ...@@ -349,27 +349,24 @@ fetch_flags (struct fetch_command *command, char **arg)
349 static int 349 static int
350 fetch_internaldate (struct fetch_command *command, char **arg MU_ARG_UNUSED) 350 fetch_internaldate (struct fetch_command *command, char **arg MU_ARG_UNUSED)
351 { 351 {
352 char date[128]; 352 const char *date;
353 mu_envelope_t env = NULL; 353 mu_envelope_t env = NULL;
354 struct tm tm, *tmp = NULL; 354 struct tm tm, *tmp = NULL;
355 mu_timezone tz; 355 mu_timezone tz;
356 char datebuf[sizeof ("13-Jul-2002 00:00:00")];
356 357
357 mu_message_get_envelope (command->msg, &env); 358 mu_message_get_envelope (command->msg, &env);
358 date[0] = '\0'; 359 if (mu_envelope_sget_date (env, &date) == 0
359 if (mu_envelope_date (env, date, sizeof (date), NULL) == 0) 360 && mu_parse_ctime_date_time (&date, &tm, &tz) == 0)
360 { 361 tmp = &tm;
361 char *p = date; 362 else
362 if (mu_parse_ctime_date_time ((const char **) &p, &tm, &tz) == 0)
363 tmp = &tm;
364 }
365 if (!tmp)
366 { 363 {
367 time_t t = time(NULL); 364 time_t t = time (NULL);
368 tmp = localtime(&t); 365 tmp = localtime (&t);
369 } 366 }
370 mu_strftime (date, sizeof (date), "%d-%b-%Y %H:%M:%S", tmp); 367 mu_strftime (datebuf, sizeof (datebuf), "%d-%b-%Y %H:%M:%S", tmp);
371 util_send ("%s", command->name); 368 util_send ("%s", command->name);
372 util_send (" \"%s +0000\"", date); 369 util_send (" \"%s +0000\"", datebuf);
373 return RESP_OK; 370 return RESP_OK;
374 } 371 }
375 372
......
...@@ -790,12 +790,13 @@ cond_before (struct parsebuf *pb) ...@@ -790,12 +790,13 @@ cond_before (struct parsebuf *pb)
790 { 790 {
791 time_t t = (time_t)_search_arg (pb); 791 time_t t = (time_t)_search_arg (pb);
792 time_t mesg_time; 792 time_t mesg_time;
793 char buffer[512]; 793 const char *date;
794 mu_envelope_t env; 794 mu_envelope_t env;
795 795
796 mu_message_get_envelope (pb->msg, &env); 796 mu_message_get_envelope (pb->msg, &env);
797 mu_envelope_date (env, buffer, sizeof (buffer), NULL); 797 if (mu_envelope_sget_date (env, &date))
798 util_parse_ctime_date (buffer, &mesg_time); 798 return 0;
799 util_parse_ctime_date (date, &mesg_time);
799 _search_push (pb, mesg_time < t); 800 _search_push (pb, mesg_time < t);
800 } 801 }
801 802
...@@ -816,12 +817,12 @@ cond_from (struct parsebuf *pb) ...@@ -816,12 +817,12 @@ cond_from (struct parsebuf *pb)
816 { 817 {
817 char *s = _search_arg (pb); 818 char *s = _search_arg (pb);
818 mu_envelope_t env; 819 mu_envelope_t env;
819 char buffer[512]; 820 const char *from;
820 int rc = 0; 821 int rc = 0;
821 822
822 mu_message_get_envelope (pb->msg, &env); 823 mu_message_get_envelope (pb->msg, &env);
823 if (mu_envelope_sender (env, buffer, sizeof (buffer), NULL) == 0) 824 if (mu_envelope_sget_sender (env, &from) == 0)
824 rc = util_strcasestr (buffer, s) != NULL; 825 rc = util_strcasestr (from, s) != NULL;
825 _search_push (pb, _scan_header (pb, "from", s)); 826 _search_push (pb, _scan_header (pb, "from", s));
826 } 827 }
827 828
...@@ -859,12 +860,13 @@ cond_on (struct parsebuf *pb) ...@@ -859,12 +860,13 @@ cond_on (struct parsebuf *pb)
859 { 860 {
860 time_t t = (time_t)_search_arg (pb); 861 time_t t = (time_t)_search_arg (pb);
861 time_t mesg_time; 862 time_t mesg_time;
862 char buffer[512]; 863 const char *date;
863 mu_envelope_t env; 864 mu_envelope_t env;
864 865
865 mu_message_get_envelope (pb->msg, &env); 866 mu_message_get_envelope (pb->msg, &env);
866 mu_envelope_date (env, buffer, sizeof (buffer), NULL); 867 if (mu_envelope_sget_date (env, &date))
867 util_parse_ctime_date (buffer, &mesg_time); 868 return 0;
869 util_parse_ctime_date (date, &mesg_time);
868 _search_push (pb, t <= mesg_time && mesg_time <= t + 86400); 870 _search_push (pb, t <= mesg_time && mesg_time <= t + 86400);
869 } 871 }
870 872
...@@ -903,12 +905,13 @@ cond_since (struct parsebuf *pb) ...@@ -903,12 +905,13 @@ cond_since (struct parsebuf *pb)
903 { 905 {
904 time_t t = (time_t)_search_arg (pb); 906 time_t t = (time_t)_search_arg (pb);
905 time_t mesg_time; 907 time_t mesg_time;
906 char buffer[512]; 908 const char *date;
907 mu_envelope_t env; 909 mu_envelope_t env;
908 910
909 mu_message_get_envelope (pb->msg, &env); 911 mu_message_get_envelope (pb->msg, &env);
910 mu_envelope_date (env, buffer, sizeof (buffer), NULL); 912 if (mu_envelope_sget_date (env, &date))
911 util_parse_ctime_date (buffer, &mesg_time); 913 return 0;
914 util_parse_ctime_date (date, &mesg_time);
912 _search_push (pb, mesg_time >= t); 915 _search_push (pb, mesg_time >= t);
913 } 916 }
914 917
......
...@@ -53,10 +53,10 @@ static char * ...@@ -53,10 +53,10 @@ static char *
53 _get_envelope_sender (mu_envelope_t env) 53 _get_envelope_sender (mu_envelope_t env)
54 { 54 {
55 mu_address_t addr; 55 mu_address_t addr;
56 char buffer[128]; 56 const char *buffer;
57 char *ptr; 57 char *ptr;
58 58
59 if (mu_envelope_sender (env, buffer, sizeof (buffer), NULL) 59 if (mu_envelope_sget_sender (env, &buffer)
60 || mu_address_create (&addr, buffer)) 60 || mu_address_create (&addr, buffer))
61 return NULL; 61 return NULL;
62 62
...@@ -75,11 +75,12 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate) ...@@ -75,11 +75,12 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate)
75 { 75 {
76 struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob); 76 struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob);
77 mu_envelope_t env = NULL; 77 mu_envelope_t env = NULL;
78 char buffer[128]; 78 const char *buffer;
79 const char *p; 79 const char *p;
80 size_t m_size = 0, m_lines = 0; 80 size_t m_size = 0, m_lines = 0;
81 struct tm tm; 81 struct tm tm;
82 mu_timezone tz; 82 mu_timezone tz;
83 char datebuf[sizeof ("Mon Jan 01 00:00")]; /* Warning: length must be > 9 */
83 84
84 mu_message_get_envelope (mum->msg, &env); 85 mu_message_get_envelope (mum->msg, &env);
85 86
...@@ -102,12 +103,14 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate) ...@@ -102,12 +103,14 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate)
102 else 103 else
103 scm_puts ("UNKNOWN", port); 104 scm_puts ("UNKNOWN", port);
104 105
105 mu_envelope_date (env, buffer, sizeof (buffer), NULL); 106 if (mu_envelope_sget_date (env, &buffer) == 0
106 p = buffer; 107 && mu_parse_ctime_date_time (&p, &tm, &tz) == 0)
107 if (mu_parse_ctime_date_time (&p, &tm, &tz) == 0) 108 {
108 strftime (buffer, sizeof (buffer), "%a %b %e %H:%M", &tm); 109 strftime (datebuf, sizeof (datebuf), "%a %b %e %H:%M", &tm);
110 buffer = datebuf;
111 }
109 else 112 else
110 strcpy (buffer, "UNKNOWN"); 113 buffer = "UNKNOWN";
111 scm_puts ("\" \"", port); 114 scm_puts ("\" \"", port);
112 scm_puts (buffer, port); 115 scm_puts (buffer, port);
113 scm_puts ("\" ", port); 116 scm_puts ("\" ", port);
...@@ -115,9 +118,9 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate) ...@@ -115,9 +118,9 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate)
115 mu_message_size (mum->msg, &m_size); 118 mu_message_size (mum->msg, &m_size);
116 mu_message_lines (mum->msg, &m_lines); 119 mu_message_lines (mum->msg, &m_lines);
117 120
118 snprintf (buffer, sizeof (buffer), "%3lu %-5lu", 121 snprintf (datebuf, sizeof (datebuf), "%3lu %-5lu",
119 (unsigned long) m_lines, (unsigned long) m_size); 122 (unsigned long) m_lines, (unsigned long) m_size);
120 scm_puts (buffer, port); 123 scm_puts (datebuf, port);
121 } 124 }
122 scm_puts (">", port); 125 scm_puts (">", port);
123 return 1; 126 return 1;
......
...@@ -107,30 +107,19 @@ mu_sieve_get_message_sender (mu_message_t msg, char **ptext) ...@@ -107,30 +107,19 @@ mu_sieve_get_message_sender (mu_message_t msg, char **ptext)
107 { 107 {
108 int rc; 108 int rc;
109 mu_envelope_t envelope; 109 mu_envelope_t envelope;
110 char *text;
111 size_t size;
112 110
113 rc = mu_message_get_envelope (msg, &envelope); 111 rc = mu_message_get_envelope (msg, &envelope);
114 if (rc) 112 if (rc)
115 return rc; 113 return rc;
116 114
117 rc = mu_envelope_sender (envelope, NULL, 0, &size); 115 rc = mu_envelope_aget_sender (envelope, ptext);
118 if (rc == 0) 116 if (rc)
119 {
120 if (!(text = malloc (size + 1)))
121 return ENOMEM;
122 mu_envelope_sender (envelope, text, size + 1, NULL);
123 }
124 else
125 { 117 {
126 mu_header_t hdr = NULL; 118 mu_header_t hdr = NULL;
127 mu_message_get_header (msg, &hdr); 119 mu_message_get_header (msg, &hdr);
128 if ((rc = mu_header_aget_value (hdr, MU_HEADER_SENDER, &text))) 120 if ((rc = mu_header_aget_value (hdr, MU_HEADER_SENDER, ptext)))
129 rc = mu_header_aget_value (hdr, MU_HEADER_FROM, &text); 121 rc = mu_header_aget_value (hdr, MU_HEADER_FROM, ptext);
130 } 122 }
131
132 if (rc == 0)
133 *ptext = text;
134 return rc; 123 return rc;
135 } 124 }
136 125
...@@ -431,10 +420,9 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) ...@@ -431,10 +420,9 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
431 if (rc) 420 if (rc)
432 { 421 {
433 mu_sieve_error (mach, 422 mu_sieve_error (mach,
434 "redirect", 423 _("%d: cannot create sender address <%s>: %s"),
435 _("%d: cannot create sender address <%s>: %s"), 424 mu_sieve_get_message_num (mach),
436 mu_sieve_get_message_num (mach), 425 fromaddr, mu_strerror (rc));
437 fromaddr, mu_strerror (rc));
438 free (fromaddr); 426 free (fromaddr);
439 goto end; 427 goto end;
440 } 428 }
......
...@@ -61,7 +61,7 @@ struct address_closure ...@@ -61,7 +61,7 @@ struct address_closure
61 { 61 {
62 address_aget_t aget; /* appropriate address_aget_ function */ 62 address_aget_t aget; /* appropriate address_aget_ function */
63 void *data; /* Either mu_header_t or mu_envelope_t */ 63 void *data; /* Either mu_header_t or mu_envelope_t */
64 mu_address_t addr; /* Obtained address */ 64 mu_address_t addr; /* Obtained address */
65 }; 65 };
66 66
67 static int 67 static int
...@@ -243,13 +243,12 @@ retrieve_envelope (void *item, void *data, int idx, char **pval) ...@@ -243,13 +243,12 @@ retrieve_envelope (void *item, void *data, int idx, char **pval)
243 243
244 if (!ap->addr) 244 if (!ap->addr)
245 { 245 {
246 char buf[512]; 246 const char *buf;
247 size_t n;
248 247
249 if (strcasecmp ((char*)item, "from") != 0) 248 if (strcasecmp ((char*)item, "from") != 0)
250 return 1; 249 return 1;
251 250
252 if (mu_envelope_sender ((mu_envelope_t)ap->data, buf, sizeof(buf), &n)) 251 if (mu_envelope_sget_sender ((mu_envelope_t)ap->data, &buf))
253 return 1; 252 return 1;
254 253
255 rc = mu_address_create (&ap->addr, buf); 254 rc = mu_address_create (&ap->addr, buf);
...@@ -291,7 +290,8 @@ sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) ...@@ -291,7 +290,8 @@ sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
291 mu_sieve_abort (mach); 290 mu_sieve_abort (mach);
292 } 291 }
293 292
294 mu_message_get_envelope (mu_sieve_get_message (mach), (mu_envelope_t*)&clos.data); 293 mu_message_get_envelope (mu_sieve_get_message (mach),
294 (mu_envelope_t*)&clos.data);
295 clos.aget = sieve_get_address_part (tags); 295 clos.aget = sieve_get_address_part (tags);
296 clos.addr = NULL; 296 clos.addr = NULL;
297 rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_envelope, &clos, 297 rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_envelope, &clos,
......
...@@ -121,9 +121,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -121,9 +121,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
121 mu_timezone tz; 121 mu_timezone tz;
122 122
123 mu_message_get_envelope (msg, &env); 123 mu_message_get_envelope (msg, &env);
124 mu_envelope_date (env, date, sizeof (date), NULL); 124 if (mu_envelope_sget_date (env, &p) == 0
125 p = date; 125 && mu_parse_ctime_date_time (&p, &tm, &tz) == 0)
126 if (mu_parse_ctime_date_time (&p, &tm, &tz) == 0)
127 strftime (date, sizeof(date), "%a %b %e %H:%M", &tm); 126 strftime (date, sizeof(date), "%a %b %e %H:%M", &tm);
128 } 127 }
129 128
......
...@@ -554,7 +554,7 @@ _amd_message_save (struct _amd_data *amd, struct _amd_message *mhm, int expunge) ...@@ -554,7 +554,7 @@ _amd_message_save (struct _amd_data *amd, struct _amd_message *mhm, int expunge)
554 int status; 554 int status;
555 mu_attribute_t attr; 555 mu_attribute_t attr;
556 mu_body_t body; 556 mu_body_t body;
557 char buffer[512]; 557 const char *sbuf;
558 mu_envelope_t env = NULL; 558 mu_envelope_t env = NULL;
559 559
560 status = mu_message_size (msg, &bsize); 560 status = mu_message_size (msg, &bsize);
...@@ -608,23 +608,22 @@ _amd_message_save (struct _amd_data *amd, struct _amd_message *mhm, int expunge) ...@@ -608,23 +608,22 @@ _amd_message_save (struct _amd_data *amd, struct _amd_message *mhm, int expunge)
608 } 608 }
609 609
610 mu_message_get_envelope (msg, &env); 610 mu_message_get_envelope (msg, &env);
611 if (mu_envelope_date (env, buffer, sizeof buffer, &n) == 0 && n > 0) 611 if (mu_envelope_sget_date (env, &sbuf) == 0)
612 { 612 {
613 /* NOTE: buffer is terminated with \n */ 613 /* NOTE: buffer might be terminated with \n */
614 char *p = buffer; 614 while (*sbuf && isspace (*sbuf))
615 while (isspace (*p)) 615 sbuf++;
616 p++; 616 nbytes += fprintf (fp, "%s: %s", MU_HEADER_ENV_DATE, sbuf);
617 nbytes += fprintf (fp, "%s: %s", MU_HEADER_ENV_DATE, p);
618 617
619 if (*p && p[strlen (p) - 1] != '\n') 618 if (*sbuf && sbuf[strlen (sbuf) - 1] != '\n')
620 nbytes += fprintf (fp, "\n"); 619 nbytes += fprintf (fp, "\n");
621 620
622 nlines++; 621 nlines++;
623 } 622 }
624 623
625 if (mu_envelope_sender (env, buffer, sizeof buffer, &n) == 0 && n > 0) 624 if (mu_envelope_sget_sender (env, &sbuf) == 0)
626 { 625 {
627 fprintf (fp, "%s: %s\n", MU_HEADER_ENV_SENDER, buffer); 626 fprintf (fp, "%s: %s\n", MU_HEADER_ENV_SENDER, sbuf);
628 nlines++; 627 nlines++;
629 } 628 }
630 629
...@@ -1394,7 +1393,7 @@ amd_unset_attr_flags (mu_attribute_t attr, int flags) ...@@ -1394,7 +1393,7 @@ amd_unset_attr_flags (mu_attribute_t attr, int flags)
1394 /* Envelope */ 1393 /* Envelope */
1395 static int 1394 static int
1396 amd_envelope_date (mu_envelope_t envelope, char *buf, size_t len, 1395 amd_envelope_date (mu_envelope_t envelope, char *buf, size_t len,
1397 size_t *psize) 1396 size_t *psize)
1398 { 1397 {
1399 mu_message_t msg = mu_envelope_get_owner (envelope); 1398 mu_message_t msg = mu_envelope_get_owner (envelope);
1400 struct _amd_message *mhm = mu_message_get_owner (msg); 1399 struct _amd_message *mhm = mu_message_get_owner (msg);
......
...@@ -1067,7 +1067,8 @@ mu_rfc2822_msg_id (int subpart, char **pval) ...@@ -1067,7 +1067,8 @@ mu_rfc2822_msg_id (int subpart, char **pval)
1067 int 1067 int
1068 mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr) 1068 mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr)
1069 { 1069 {
1070 char *value, *s1 = NULL, *s2 = NULL; 1070 const char *value = NULL;
1071 char *s1 = NULL, *s2 = NULL;
1071 mu_header_t hdr; 1072 mu_header_t hdr;
1072 int rc; 1073 int rc;
1073 1074
...@@ -1075,39 +1076,30 @@ mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr) ...@@ -1075,39 +1076,30 @@ mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr)
1075 if (rc) 1076 if (rc)
1076 return rc; 1077 return rc;
1077 1078
1078 if (mu_header_aget_value (hdr, MU_HEADER_DATE, &value)) 1079 if (mu_header_sget_value (hdr, MU_HEADER_DATE, &value))
1079 { 1080 {
1080 mu_envelope_t envelope = NULL; 1081 mu_envelope_t envelope = NULL;
1081 value = malloc (DATEBUFSIZE); 1082 mu_message_get_envelope (msg, &envelope);
1082 if (value) 1083 mu_envelope_sget_date (envelope, &value);
1083 {
1084 mu_message_get_envelope (msg, &envelope);
1085 mu_envelope_date (envelope, value, DATEBUFSIZE, NULL);
1086 }
1087 } 1084 }
1088 1085
1089 if (value) 1086 if (value)
1090 { 1087 {
1091 s1 = malloc (sizeof (COMMENT) + strlen (value)); 1088 s1 = malloc (sizeof (COMMENT) + strlen (value));
1092 if (s1)
1093 strcat (strcpy (s1, COMMENT), value);
1094 free (value);
1095 if (!s1) 1089 if (!s1)
1096 return ENOMEM; 1090 return ENOMEM;
1091 strcat (strcpy (s1, COMMENT), value);
1097 } 1092 }
1098 1093
1099 if (mu_header_aget_value (hdr, MU_HEADER_MESSAGE_ID, &value) == 0) 1094 if (mu_header_sget_value (hdr, MU_HEADER_MESSAGE_ID, &value) == 0)
1100 { 1095 {
1101 s2 = malloc (strlen (value) + 3); 1096 s2 = malloc (strlen (value) + 3);
1102 if (s2)
1103 strcat (strcpy (s2, "\n\t"), value);
1104
1105 free (value);
1106 if (!s2) 1097 if (!s2)
1107 { 1098 {
1108 free (s1); 1099 free (s1);
1109 return ENOMEM; 1100 return ENOMEM;
1110 } 1101 }
1102 strcat (strcpy (s2, "\n\t"), value);
1111 } 1103 }
1112 1104
1113 if (s1 || s2) 1105 if (s1 || s2)
......