Prefer mu_header_sgetwhere possible. Remove obsolete header calls.
Showing
12 changed files
with
73 additions
and
174 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2005, 2007 Free Software Foundation, Inc. |
3 | 3 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 4 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
... | @@ -29,8 +29,8 @@ | ... | @@ -29,8 +29,8 @@ |
29 | 29 | ||
30 | void message_display_parts(mu_message_t msg, int indent); | 30 | void message_display_parts(mu_message_t msg, int indent); |
31 | 31 | ||
32 | char from[256]; | 32 | const char *from; |
33 | char subject[256]; | 33 | const char *subject; |
34 | int print_attachments; | 34 | int print_attachments; |
35 | int indent_level = 4; | 35 | int indent_level = 4; |
36 | 36 | ||
... | @@ -120,9 +120,10 @@ main (int argc, char **argv) | ... | @@ -120,9 +120,10 @@ main (int argc, char **argv) |
120 | CATCH (mu_message_size (msg, &msize)); | 120 | CATCH (mu_message_size (msg, &msize)); |
121 | CATCH (mu_message_lines (msg, &nlines)); | 121 | CATCH (mu_message_lines (msg, &nlines)); |
122 | CATCH (mu_message_get_header (msg, &hdr)); | 122 | CATCH (mu_message_get_header (msg, &hdr)); |
123 | mu_header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); | 123 | if (mu_header_sget_value (hdr, MU_HEADER_FROM, &from)) |
124 | mu_header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), | 124 | from = ""; |
125 | NULL); | 125 | if (mu_header_sget_value (hdr, MU_HEADER_SUBJECT, &subject)) |
126 | subject = ""; | ||
126 | printf ("Message: %lu\n", (unsigned long) i); | 127 | printf ("Message: %lu\n", (unsigned long) i); |
127 | printf ("From: %s\n", from); | 128 | printf ("From: %s\n", from); |
128 | printf ("Subject: %s\n", subject); | 129 | printf ("Subject: %s\n", subject); |
... | @@ -170,8 +171,8 @@ message_display_parts (mu_message_t msg, int indent) | ... | @@ -170,8 +171,8 @@ message_display_parts (mu_message_t msg, int indent) |
170 | size_t nparts, nsubparts; | 171 | size_t nparts, nsubparts; |
171 | mu_message_t part; | 172 | mu_message_t part; |
172 | mu_header_t hdr; | 173 | mu_header_t hdr; |
173 | char type[256]; | 174 | const char *type; |
174 | char encoding[256]; | 175 | const char *encoding; |
175 | mu_stream_t str; | 176 | mu_stream_t str; |
176 | mu_body_t body; | 177 | mu_body_t body; |
177 | int offset, ismulti; | 178 | int offset, ismulti; |
... | @@ -189,15 +190,22 @@ message_display_parts (mu_message_t msg, int indent) | ... | @@ -189,15 +190,22 @@ message_display_parts (mu_message_t msg, int indent) |
189 | its own that can have other subparts(recursive). */ | 190 | its own that can have other subparts(recursive). */ |
190 | for (j = 1; j <= nparts; j++) | 191 | for (j = 1; j <= nparts; j++) |
191 | { | 192 | { |
193 | int status; | ||
192 | CATCH (mu_message_get_part (msg, j, &part)); | 194 | CATCH (mu_message_get_part (msg, j, &part)); |
193 | CATCH (mu_message_get_header (part, &hdr)); | 195 | CATCH (mu_message_get_header (part, &hdr)); |
194 | mu_header_get_value (hdr, MU_HEADER_CONTENT_TYPE, type, sizeof (type), | 196 | status = mu_header_sget_value (hdr, MU_HEADER_CONTENT_TYPE, &type); |
195 | NULL); | 197 | if (status == MU_ERR_NOENT) |
198 | type = ""; | ||
199 | else if (status != 0) | ||
200 | { | ||
201 | type = ""; | ||
202 | mu_error ("Cannot get header value: %s", mu_strerror (status)); | ||
203 | } | ||
196 | printf ("%*.*sType of part %d = %s\n", indent, indent, "", j, type); | 204 | printf ("%*.*sType of part %d = %s\n", indent, indent, "", j, type); |
197 | print_message_part_sizes (part, indent); | 205 | print_message_part_sizes (part, indent); |
198 | encoding[0] = '\0'; | 206 | if (mu_header_sget_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, |
199 | mu_header_get_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, encoding, | 207 | &encoding)) |
200 | sizeof (encoding), NULL); | 208 | encoding = ""; |
201 | ismulti = 0; | 209 | ismulti = 0; |
202 | if ((type[0] | 210 | if ((type[0] |
203 | && strncasecmp (type, "message/rfc822", strlen (type)) == 0) | 211 | && strncasecmp (type, "message/rfc822", strlen (type)) == 0) |
... | @@ -207,9 +215,10 @@ message_display_parts (mu_message_t msg, int indent) | ... | @@ -207,9 +215,10 @@ message_display_parts (mu_message_t msg, int indent) |
207 | CATCH (mu_message_unencapsulate (part, &part, NULL)); | 215 | CATCH (mu_message_unencapsulate (part, &part, NULL)); |
208 | 216 | ||
209 | CATCH (mu_message_get_header (part, &hdr)); | 217 | CATCH (mu_message_get_header (part, &hdr)); |
210 | mu_header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); | 218 | if (mu_header_sget_value (hdr, MU_HEADER_FROM, &from)) |
211 | mu_header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), | 219 | from = ""; |
212 | NULL); | 220 | if (mu_header_sget_value (hdr, MU_HEADER_SUBJECT, &subject)) |
221 | subject = ""; | ||
213 | printf ("%*.*sEncapsulated message : %s\t%s\n", | 222 | printf ("%*.*sEncapsulated message : %s\t%s\n", |
214 | indent, indent, "", from, subject); | 223 | indent, indent, "", from, subject); |
215 | printf ("%*.*sBegin\n", indent, indent, ""); | 224 | printf ("%*.*sBegin\n", indent, indent, ""); | ... | ... |
... | @@ -100,7 +100,6 @@ static int imap_attr_unset_flags (mu_attribute_t, int); | ... | @@ -100,7 +100,6 @@ static int imap_attr_unset_flags (mu_attribute_t, int); |
100 | 100 | ||
101 | /* mu_header_t API. */ | 101 | /* mu_header_t API. */ |
102 | static int imap_header_read (mu_header_t, char*, size_t, mu_off_t, size_t *); | 102 | static int imap_header_read (mu_header_t, char*, size_t, mu_off_t, size_t *); |
103 | static int imap_header_get_value (mu_header_t, const char*, char *, size_t, size_t *); | ||
104 | 103 | ||
105 | /* mu_body_t API. */ | 104 | /* mu_body_t API. */ |
106 | static int imap_body_read (mu_stream_t, char *, size_t, mu_off_t, size_t *); | 105 | static int imap_body_read (mu_stream_t, char *, size_t, mu_off_t, size_t *); |
... | @@ -545,7 +544,6 @@ imap_get_message0 (msg_imap_t msg_imap, mu_message_t *pmsg) | ... | @@ -545,7 +544,6 @@ imap_get_message0 (msg_imap_t msg_imap, mu_message_t *pmsg) |
545 | return status; | 544 | return status; |
546 | } | 545 | } |
547 | mu_header_set_fill (header, imap_header_read, msg); | 546 | mu_header_set_fill (header, imap_header_read, msg); |
548 | mu_header_set_get_value (header, imap_header_get_value, msg); | ||
549 | mu_message_set_header (msg, header, msg_imap); | 547 | mu_message_set_header (msg, header, msg_imap); |
550 | } | 548 | } |
551 | 549 | ||
... | @@ -1451,7 +1449,6 @@ imap_get_part (mu_message_t msg, size_t partno, mu_message_t *pmsg) | ... | @@ -1451,7 +1449,6 @@ imap_get_part (mu_message_t msg, size_t partno, mu_message_t *pmsg) |
1451 | { | 1449 | { |
1452 | mu_header_t header; | 1450 | mu_header_t header; |
1453 | mu_message_get_header (message, &header); | 1451 | mu_message_get_header (message, &header); |
1454 | mu_header_set_get_value (header, NULL, message); | ||
1455 | mu_message_set_stream (message, NULL, msg_imap->parts[partno - 1]); | 1452 | mu_message_set_stream (message, NULL, msg_imap->parts[partno - 1]); |
1456 | /* mu_message_set_size (message, NULL, msg_imap->parts[partno - 1]); */ | 1453 | /* mu_message_set_size (message, NULL, msg_imap->parts[partno - 1]); */ |
1457 | msg_imap->parts[partno - 1]->message = message; | 1454 | msg_imap->parts[partno - 1]->message = message; |
... | @@ -1721,89 +1718,6 @@ imap_attr_unset_flags (mu_attribute_t attribute, int flag) | ... | @@ -1721,89 +1718,6 @@ imap_attr_unset_flags (mu_attribute_t attribute, int flag) |
1721 | 1718 | ||
1722 | /* Header. */ | 1719 | /* Header. */ |
1723 | static int | 1720 | static int |
1724 | imap_header_get_value (mu_header_t header, const char *field, char * buffer, | ||
1725 | size_t buflen, size_t *plen) | ||
1726 | { | ||
1727 | mu_message_t msg = mu_header_get_owner (header); | ||
1728 | msg_imap_t msg_imap = mu_message_get_owner (msg); | ||
1729 | m_imap_t m_imap = msg_imap->m_imap; | ||
1730 | f_imap_t f_imap = m_imap->f_imap; | ||
1731 | int status; | ||
1732 | size_t len = 0; | ||
1733 | char *value; | ||
1734 | |||
1735 | /* Select first. */ | ||
1736 | status = imap_messages_count (m_imap->mailbox, NULL); | ||
1737 | if (status != 0) | ||
1738 | return status; | ||
1739 | |||
1740 | /* Hack, if buffer == NULL they want to know how big is the field value, | ||
1741 | Unfortunately IMAP does not say, so we take a guess hoping that the | ||
1742 | value will not be over 1024. */ | ||
1743 | if (buffer == NULL || buflen == 0) | ||
1744 | len = 1024; | ||
1745 | else | ||
1746 | len = strlen (field) + buflen + 4; | ||
1747 | |||
1748 | if (f_imap->state == IMAP_NO_STATE) | ||
1749 | { | ||
1750 | /* Select first. */ | ||
1751 | status = imap_messages_count (m_imap->mailbox, NULL); | ||
1752 | if (status != 0) | ||
1753 | return status; | ||
1754 | status = imap_writeline (f_imap, | ||
1755 | "g%s FETCH %s BODY.PEEK[HEADER.FIELDS (%s)]<0.%s>\r\n", | ||
1756 | mu_umaxtostr (0, f_imap->seq++), | ||
1757 | mu_umaxtostr (1, msg_imap->num), | ||
1758 | field, | ||
1759 | mu_umaxtostr (2, len)); | ||
1760 | CHECK_ERROR (f_imap, status); | ||
1761 | MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer); | ||
1762 | f_imap->state = IMAP_FETCH; | ||
1763 | |||
1764 | } | ||
1765 | |||
1766 | value = calloc (len, sizeof (*value)); | ||
1767 | status = fetch_operation (f_imap, msg_imap, value, len, &len); | ||
1768 | if (status == 0) | ||
1769 | { | ||
1770 | char *colon; | ||
1771 | /* The field-matching is case-insensitive. In all cases, the | ||
1772 | delimiting newline between the header and the body is always | ||
1773 | included. Nuke it */ | ||
1774 | if (len) | ||
1775 | value[len - 1] = '\0'; | ||
1776 | |||
1777 | /* Move pass the field-name. */ | ||
1778 | colon = strchr (value, ':'); | ||
1779 | if (colon) | ||
1780 | { | ||
1781 | colon++; | ||
1782 | if (*colon == ' ') | ||
1783 | colon++; | ||
1784 | } | ||
1785 | else | ||
1786 | colon = value; | ||
1787 | |||
1788 | while (*colon && colon[strlen (colon) - 1] == '\n') | ||
1789 | colon[strlen (colon) - 1] = '\0'; | ||
1790 | |||
1791 | if (buffer && buflen) | ||
1792 | { | ||
1793 | strncpy (buffer, colon, buflen); | ||
1794 | buffer[buflen - 1] = '\0'; | ||
1795 | } | ||
1796 | len = strlen (buffer); | ||
1797 | if (plen) | ||
1798 | *plen = len; | ||
1799 | if (len == 0) | ||
1800 | status = MU_ERR_NOENT; | ||
1801 | } | ||
1802 | free (value); | ||
1803 | return status; | ||
1804 | } | ||
1805 | |||
1806 | static int | ||
1807 | imap_header_read (mu_header_t header, char *buffer, | 1721 | imap_header_read (mu_header_t header, char *buffer, |
1808 | size_t buflen, mu_off_t offset, | 1722 | size_t buflen, mu_off_t offset, |
1809 | size_t *plen) | 1723 | size_t *plen) | ... | ... |
... | @@ -63,8 +63,6 @@ static int mbox_readstream (mbox_message_t, char *, size_t, | ... | @@ -63,8 +63,6 @@ static int mbox_readstream (mbox_message_t, char *, size_t, |
63 | mu_off_t, size_t *, int, mu_off_t, mu_off_t); | 63 | mu_off_t, size_t *, int, mu_off_t, mu_off_t); |
64 | static int mbox_stream_size (mu_stream_t stream, mu_off_t *psize); | 64 | static int mbox_stream_size (mu_stream_t stream, mu_off_t *psize); |
65 | 65 | ||
66 | static int mbox_header_size (mu_header_t, size_t *); | ||
67 | static int mbox_header_lines (mu_header_t, size_t *); | ||
68 | static int mbox_body_size (mu_body_t, size_t *); | 66 | static int mbox_body_size (mu_body_t, size_t *); |
69 | static int mbox_body_lines (mu_body_t, size_t *); | 67 | static int mbox_body_lines (mu_body_t, size_t *); |
70 | static int mbox_envelope_sender (mu_envelope_t, char *, size_t, size_t *); | 68 | static int mbox_envelope_sender (mu_envelope_t, char *, size_t, size_t *); |
... | @@ -894,7 +892,7 @@ mbox_readstream (mbox_message_t mum, char *buffer, size_t buflen, | ... | @@ -894,7 +892,7 @@ mbox_readstream (mbox_message_t mum, char *buffer, size_t buflen, |
894 | start + off, &nread); | 892 | start + off, &nread); |
895 | else | 893 | else |
896 | status = mu_stream_read (mum->mud->mailbox->stream, buffer, nread, | 894 | status = mu_stream_read (mum->mud->mailbox->stream, buffer, nread, |
897 | start + off, &nread); | 895 | start + off, &nread); |
898 | } | 896 | } |
899 | } | 897 | } |
900 | mu_monitor_unlock (mum->mud->mailbox->monitor); | 898 | mu_monitor_unlock (mum->mud->mailbox->monitor); |
... | @@ -918,30 +916,6 @@ mbox_header_fill (mu_header_t header, char *buffer, size_t len, | ... | @@ -918,30 +916,6 @@ mbox_header_fill (mu_header_t header, char *buffer, size_t len, |
918 | } | 916 | } |
919 | 917 | ||
920 | static int | 918 | static int |
921 | mbox_header_size (mu_header_t header, size_t *psize) | ||
922 | { | ||
923 | mu_message_t msg = mu_header_get_owner (header); | ||
924 | mbox_message_t mum = mu_message_get_owner (msg); | ||
925 | if (mum == NULL) | ||
926 | return EINVAL; | ||
927 | if (psize) | ||
928 | *psize = mum->body - mum->header_from_end; | ||
929 | return 0; | ||
930 | } | ||
931 | |||
932 | static int | ||
933 | mbox_header_lines (mu_header_t header, size_t *plines) | ||
934 | { | ||
935 | mu_message_t msg = mu_header_get_owner (header); | ||
936 | mbox_message_t mum = mu_message_get_owner (msg); | ||
937 | if (mum == NULL) | ||
938 | return EINVAL; | ||
939 | if (plines) | ||
940 | *plines = mum->header_lines; | ||
941 | return 0; | ||
942 | } | ||
943 | |||
944 | static int | ||
945 | mbox_body_size (mu_body_t body, size_t *psize) | 919 | mbox_body_size (mu_body_t body, size_t *psize) |
946 | { | 920 | { |
947 | mu_message_t msg = mu_body_get_owner (body); | 921 | mu_message_t msg = mu_body_get_owner (body); |
... | @@ -1120,8 +1094,6 @@ mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg) | ... | @@ -1120,8 +1094,6 @@ mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg) |
1120 | return status; | 1094 | return status; |
1121 | } | 1095 | } |
1122 | mu_header_set_fill (header, mbox_header_fill, msg); | 1096 | mu_header_set_fill (header, mbox_header_fill, msg); |
1123 | mu_header_set_size (header, mbox_header_size, msg); | ||
1124 | mu_header_set_lines (header, mbox_header_lines, msg); | ||
1125 | mu_message_set_header (msg, header, mum); | 1097 | mu_message_set_header (msg, header, mum); |
1126 | } | 1098 | } |
1127 | 1099 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, |
3 | 2006 Free Software Foundation, Inc. | 3 | 2006, 2007 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -146,8 +146,9 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) | ... | @@ -146,8 +146,9 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) |
146 | mu_body_t body; | 146 | mu_body_t body; |
147 | mu_header_t hdr; | 147 | mu_header_t hdr; |
148 | char datestr[80]; | 148 | char datestr[80]; |
149 | static char *content_header = "Content-Type: text/plain;charset=" MU_SIEVE_CHARSET "\n" | 149 | static char *content_header = |
150 | "Content-Transfer-Encoding: 8bit\n"; | 150 | "Content-Type: text/plain;charset=" MU_SIEVE_CHARSET "\n" |
151 | "Content-Transfer-Encoding: 8bit\n"; | ||
151 | 152 | ||
152 | mu_message_create (&newmsg, NULL); | 153 | mu_message_create (&newmsg, NULL); |
153 | mu_message_get_body (newmsg, &body); | 154 | mu_message_get_body (newmsg, &body); |
... | @@ -160,7 +161,7 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) | ... | @@ -160,7 +161,7 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text) |
160 | mu_sieve_get_message_sender (msg, &sender); | 161 | mu_sieve_get_message_sender (msg, &sender); |
161 | 162 | ||
162 | mu_stream_printf (stream, &off, | 163 | mu_stream_printf (stream, &off, |
163 | "\nThe original message was received at %s from %s.\n", | 164 | "The original message was received at %s from %s.\n", |
164 | datestr, sender); | 165 | datestr, sender); |
165 | free (sender); | 166 | free (sender); |
166 | mu_stream_printf (stream, &off, | 167 | mu_stream_printf (stream, &off, |
... | @@ -302,10 +303,10 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -302,10 +303,10 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
302 | if (rc) | 303 | if (rc) |
303 | { | 304 | { |
304 | mu_sieve_error (mach, | 305 | mu_sieve_error (mach, |
305 | _("%d: cannot create sender address <%s>: %s"), | 306 | _("%d: cannot create sender address <%s>: %s"), |
306 | mu_sieve_get_message_num (mach), | 307 | mu_sieve_get_message_num (mach), |
307 | mu_sieve_get_daemon_email (mach), | 308 | mu_sieve_get_daemon_email (mach), |
308 | mu_strerror (rc)); | 309 | mu_strerror (rc)); |
309 | goto end; | 310 | goto end; |
310 | } | 311 | } |
311 | 312 | ||
... | @@ -316,10 +317,10 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -316,10 +317,10 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
316 | mu_mailer_get_url (mailer, &url); | 317 | mu_mailer_get_url (mailer, &url); |
317 | 318 | ||
318 | mu_sieve_error (mach, | 319 | mu_sieve_error (mach, |
319 | _("%d: cannot open mailer %s: %s"), | 320 | _("%d: cannot open mailer %s: %s"), |
320 | mu_sieve_get_message_num (mach), | 321 | mu_sieve_get_message_num (mach), |
321 | mu_url_to_string (url), | 322 | mu_url_to_string (url), |
322 | mu_strerror (rc)); | 323 | mu_strerror (rc)); |
323 | goto end; | 324 | goto end; |
324 | } | 325 | } |
325 | 326 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2004, |
3 | 2005 Free Software Foundation, Inc. | 3 | 2005, 2007 Free Software Foundation, Inc. |
4 | 4 | ||
5 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -155,7 +155,7 @@ sql_retrieve_quota (char *name, mu_off_t *quota) | ... | @@ -155,7 +155,7 @@ sql_retrieve_quota (char *name, mu_off_t *quota) |
155 | char *query_str; | 155 | char *query_str; |
156 | int rc, status; | 156 | int rc, status; |
157 | char *tmp; | 157 | char *tmp; |
158 | mu_off_t n; | 158 | size_t n; |
159 | 159 | ||
160 | query_str = mu_sql_expand_query (quota_query, name); | 160 | query_str = mu_sql_expand_query (quota_query, name); |
161 | if (!query_str) | 161 | if (!query_str) | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, |
3 | 2005 Free Software Foundation, Inc. | 3 | 2005, 2007 Free Software Foundation, Inc. |
4 | 4 | ||
5 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -83,19 +83,20 @@ display_headers (FILE *out, mu_message_t mesg, const msgset_t *msgset ARG_UNUSED | ... | @@ -83,19 +83,20 @@ display_headers (FILE *out, mu_message_t mesg, const msgset_t *msgset ARG_UNUSED |
83 | { | 83 | { |
84 | size_t num = 0; | 84 | size_t num = 0; |
85 | size_t i = 0; | 85 | size_t i = 0; |
86 | char buffer[512]; | 86 | const char *sptr; |
87 | 87 | ||
88 | mu_message_get_header (mesg, &hdr); | 88 | mu_message_get_header (mesg, &hdr); |
89 | mu_header_get_field_count (hdr, &num); | 89 | mu_header_get_field_count (hdr, &num); |
90 | for (i = 1; i <= num; i++) | 90 | for (i = 1; i <= num; i++) |
91 | { | 91 | { |
92 | buffer[0] = '\0'; | 92 | if (mu_header_sget_field_name (hdr, i, &sptr)) |
93 | mu_header_get_field_name (hdr, i, buffer, sizeof(buffer), NULL); | 93 | continue; |
94 | if (mail_header_is_visible (buffer)) | 94 | if (mail_header_is_visible (sptr)) |
95 | { | 95 | { |
96 | fprintf (out, "%s: ", buffer); | 96 | fprintf (out, "%s: ", sptr); |
97 | mu_header_get_field_value (hdr, i, buffer, sizeof(buffer), NULL); | 97 | if (mu_header_sget_field_value (hdr, i, &sptr)) |
98 | fprintf (out, "%s\n", buffer); | 98 | sptr = ""; |
99 | fprintf (out, "%s\n", sptr); | ||
99 | } | 100 | } |
100 | } | 101 | } |
101 | fprintf (out, "\n"); | 102 | fprintf (out, "\n"); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2005, 2006, |
3 | 2007 Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -456,20 +457,20 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data) | ... | @@ -456,20 +457,20 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data) |
456 | if (*(int*)data) | 457 | if (*(int*)data) |
457 | { | 458 | { |
458 | size_t i, num = 0; | 459 | size_t i, num = 0; |
459 | char buf[512]; | 460 | const char *sptr; |
460 | 461 | ||
461 | mu_message_get_header (mesg, &hdr); | 462 | mu_message_get_header (mesg, &hdr); |
462 | mu_header_get_field_count (hdr, &num); | 463 | mu_header_get_field_count (hdr, &num); |
463 | 464 | ||
464 | for (i = 1; i <= num; i++) | 465 | for (i = 1; i <= num; i++) |
465 | { | 466 | { |
466 | mu_header_get_field_name (hdr, i, buf, sizeof buf, NULL); | 467 | mu_header_sget_field_name (hdr, i, &sptr); |
467 | if (mail_header_is_visible (buf)) | 468 | if (mail_header_is_visible (sptr)) |
468 | { | 469 | { |
469 | char *value; | 470 | char *value; |
470 | 471 | ||
471 | fprintf (ofile, "%s%s: ", prefix, buf); | 472 | fprintf (ofile, "%s%s: ", prefix, sptr); |
472 | if (mu_header_aget_value (hdr, buf, &value) == 0) | 473 | if (mu_header_aget_value (hdr, sptr, &value) == 0) |
473 | { | 474 | { |
474 | int i; | 475 | int i; |
475 | char *p, *s; | 476 | char *p, *s; | ... | ... |
... | @@ -251,8 +251,8 @@ extern int mail_mbox_commit (void); | ... | @@ -251,8 +251,8 @@ extern int mail_mbox_commit (void); |
251 | extern int mail_is_my_name (const char *name); | 251 | extern int mail_is_my_name (const char *name); |
252 | extern void mail_set_my_name (char *name); | 252 | extern void mail_set_my_name (char *name); |
253 | extern char *mail_whoami (void); | 253 | extern char *mail_whoami (void); |
254 | extern int mail_header_is_visible (char *str); | 254 | extern int mail_header_is_visible (const char *str); |
255 | extern int mail_header_is_unfoldable (char *str); | 255 | extern int mail_header_is_unfoldable (const char *str); |
256 | extern int mail_mbox_close (void); | 256 | extern int mail_mbox_close (void); |
257 | extern char *mail_expand_name (const char *name); | 257 | extern char *mail_expand_name (const char *name); |
258 | 258 | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, |
3 | 2007 Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -61,7 +62,7 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data) | ... | @@ -61,7 +62,7 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data) |
61 | if (*(int *) data) /* print was called with a lowercase 'p' */ | 62 | if (*(int *) data) /* print was called with a lowercase 'p' */ |
62 | { | 63 | { |
63 | size_t i, num = 0; | 64 | size_t i, num = 0; |
64 | char buf[512]; | 65 | const char *sptr; |
65 | char *tmp; | 66 | char *tmp; |
66 | 67 | ||
67 | mu_message_get_header (mesg, &hdr); | 68 | mu_message_get_header (mesg, &hdr); |
... | @@ -69,12 +70,13 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data) | ... | @@ -69,12 +70,13 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data) |
69 | 70 | ||
70 | for (i = 1; i <= num; i++) | 71 | for (i = 1; i <= num; i++) |
71 | { | 72 | { |
72 | mu_header_get_field_name (hdr, i, buf, sizeof buf, NULL); | 73 | if (mu_header_sget_field_name (hdr, i, &sptr)) |
73 | if (mail_header_is_visible (buf)) | 74 | continue; |
75 | if (mail_header_is_visible (sptr)) | ||
74 | { | 76 | { |
75 | fprintf (out, "%s: ", buf); | 77 | fprintf (out, "%s: ", sptr); |
76 | mu_header_aget_field_value (hdr, i, &tmp); | 78 | mu_header_aget_field_value (hdr, i, &tmp); |
77 | if (mail_header_is_unfoldable (buf)) | 79 | if (mail_header_is_unfoldable (sptr)) |
78 | mu_string_unfold (tmp, NULL); | 80 | mu_string_unfold (tmp, NULL); |
79 | util_rfc2047_decode (&tmp); | 81 | util_rfc2047_decode (&tmp); |
80 | fprintf (out, "%s\n", tmp); | 82 | fprintf (out, "%s\n", tmp); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2001, 2002, 2004, 2005, |
3 | 2007 Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -94,13 +95,13 @@ mail_nounfold (int argc, char **argv) | ... | @@ -94,13 +95,13 @@ mail_nounfold (int argc, char **argv) |
94 | } | 95 | } |
95 | 96 | ||
96 | int | 97 | int |
97 | mail_header_is_unfoldable (char *str) | 98 | mail_header_is_unfoldable (const char *str) |
98 | { | 99 | { |
99 | return util_slist_lookup (unfolded_headers, str); | 100 | return util_slist_lookup (unfolded_headers, str); |
100 | } | 101 | } |
101 | 102 | ||
102 | int | 103 | int |
103 | mail_header_is_visible (char *str) | 104 | mail_header_is_visible (const char *str) |
104 | { | 105 | { |
105 | if (retained_headers) | 106 | if (retained_headers) |
106 | return util_slist_lookup (retained_headers, str); | 107 | return util_slist_lookup (retained_headers, str); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2001, 2002, 2003, 2004, | 2 | Copyright (C) 1999, 2001, 2002, 2003, 2004, |
3 | 2005, 2006 Free Software Foundation, Inc. | 3 | 2005, 2006, 2007 Free Software Foundation, Inc. |
4 | 4 | ||
5 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -366,7 +366,6 @@ mail_send0 (compose_env_t * env, int save_to) | ... | @@ -366,7 +366,6 @@ mail_send0 (compose_env_t * env, int save_to) |
366 | char *escape; | 366 | char *escape; |
367 | 367 | ||
368 | fd = mu_tempfile (NULL, &filename); | 368 | fd = mu_tempfile (NULL, &filename); |
369 | |||
370 | if (fd == -1) | 369 | if (fd == -1) |
371 | { | 370 | { |
372 | util_error (_("Cannot open temporary file")); | 371 | util_error (_("Cannot open temporary file")); |
... | @@ -527,7 +526,6 @@ mail_send0 (compose_env_t * env, int save_to) | ... | @@ -527,7 +526,6 @@ mail_send0 (compose_env_t * env, int save_to) |
527 | int rc; | 526 | int rc; |
528 | 527 | ||
529 | mu_message_create (&msg, NULL); | 528 | mu_message_create (&msg, NULL); |
530 | |||
531 | mu_message_set_header (msg, env->header, NULL); | 529 | mu_message_set_header (msg, env->header, NULL); |
532 | 530 | ||
533 | /* Fill the body. */ | 531 | /* Fill the body. */ | ... | ... |
... | @@ -359,7 +359,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from, | ... | @@ -359,7 +359,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from, |
359 | 359 | ||
360 | MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending headers...\n"); | 360 | MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending headers...\n"); |
361 | while ((status = mu_stream_readline (stream, buffer, sizeof (buffer), | 361 | while ((status = mu_stream_readline (stream, buffer, sizeof (buffer), |
362 | offset, &len)) == 0 | 362 | offset, &len)) == 0 |
363 | && len != 0) | 363 | && len != 0) |
364 | { | 364 | { |
365 | if (strncasecmp (buffer, MU_HEADER_FCC, | 365 | if (strncasecmp (buffer, MU_HEADER_FCC, | ... | ... |
-
Please register or sign in to post a comment