diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-07-09 17:41:02 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-07-09 17:41:02 +0000 |
commit | c8bb4b9413f72f2e9c5f81b5f1674c9341ed369f (patch) | |
tree | 74770120ab2da93e9432f04d90eab006c8bd534d /mailbox | |
parent | 00668ac3d890df067217835b0ebb127b60902099 (diff) | |
download | mailutils-c8bb4b9413f72f2e9c5f81b5f1674c9341ed369f.tar.gz mailutils-c8bb4b9413f72f2e9c5f81b5f1674c9341ed369f.tar.bz2 |
Rewrite using new envelope accessors
Diffstat (limited to 'mailbox')
-rw-r--r-- | mailbox/amd.c | 21 | ||||
-rw-r--r-- | mailbox/mutil.c | 24 |
2 files changed, 18 insertions, 27 deletions
diff --git a/mailbox/amd.c b/mailbox/amd.c index 67a9f34e4..e4d96164f 100644 --- a/mailbox/amd.c +++ b/mailbox/amd.c @@ -554,7 +554,7 @@ _amd_message_save (struct _amd_data *amd, struct _amd_message *mhm, int expunge) int status; mu_attribute_t attr; mu_body_t body; - char buffer[512]; + const char *sbuf; mu_envelope_t env = NULL; status = mu_message_size (msg, &bsize); @@ -608,23 +608,22 @@ _amd_message_save (struct _amd_data *amd, struct _amd_message *mhm, int expunge) } mu_message_get_envelope (msg, &env); - if (mu_envelope_date (env, buffer, sizeof buffer, &n) == 0 && n > 0) + if (mu_envelope_sget_date (env, &sbuf) == 0) { - /* NOTE: buffer is terminated with \n */ - char *p = buffer; - while (isspace (*p)) - p++; - nbytes += fprintf (fp, "%s: %s", MU_HEADER_ENV_DATE, p); + /* NOTE: buffer might be terminated with \n */ + while (*sbuf && isspace (*sbuf)) + sbuf++; + nbytes += fprintf (fp, "%s: %s", MU_HEADER_ENV_DATE, sbuf); - if (*p && p[strlen (p) - 1] != '\n') + if (*sbuf && sbuf[strlen (sbuf) - 1] != '\n') nbytes += fprintf (fp, "\n"); nlines++; } - if (mu_envelope_sender (env, buffer, sizeof buffer, &n) == 0 && n > 0) + if (mu_envelope_sget_sender (env, &sbuf) == 0) { - fprintf (fp, "%s: %s\n", MU_HEADER_ENV_SENDER, buffer); + fprintf (fp, "%s: %s\n", MU_HEADER_ENV_SENDER, sbuf); nlines++; } @@ -1394,7 +1393,7 @@ amd_unset_attr_flags (mu_attribute_t attr, int flags) /* Envelope */ static int amd_envelope_date (mu_envelope_t envelope, char *buf, size_t len, - size_t *psize) + size_t *psize) { mu_message_t msg = mu_envelope_get_owner (envelope); struct _amd_message *mhm = mu_message_get_owner (msg); diff --git a/mailbox/mutil.c b/mailbox/mutil.c index ac56a60d8..83f23420f 100644 --- a/mailbox/mutil.c +++ b/mailbox/mutil.c @@ -1067,7 +1067,8 @@ mu_rfc2822_msg_id (int subpart, char **pval) int mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr) { - char *value, *s1 = NULL, *s2 = NULL; + const char *value = NULL; + char *s1 = NULL, *s2 = NULL; mu_header_t hdr; int rc; @@ -1075,39 +1076,30 @@ mu_rfc2822_in_reply_to (mu_message_t msg, char **pstr) if (rc) return rc; - if (mu_header_aget_value (hdr, MU_HEADER_DATE, &value)) + if (mu_header_sget_value (hdr, MU_HEADER_DATE, &value)) { mu_envelope_t envelope = NULL; - value = malloc (DATEBUFSIZE); - if (value) - { - mu_message_get_envelope (msg, &envelope); - mu_envelope_date (envelope, value, DATEBUFSIZE, NULL); - } + mu_message_get_envelope (msg, &envelope); + mu_envelope_sget_date (envelope, &value); } if (value) { s1 = malloc (sizeof (COMMENT) + strlen (value)); - if (s1) - strcat (strcpy (s1, COMMENT), value); - free (value); if (!s1) return ENOMEM; + strcat (strcpy (s1, COMMENT), value); } - if (mu_header_aget_value (hdr, MU_HEADER_MESSAGE_ID, &value) == 0) + if (mu_header_sget_value (hdr, MU_HEADER_MESSAGE_ID, &value) == 0) { s2 = malloc (strlen (value) + 3); - if (s2) - strcat (strcpy (s2, "\n\t"), value); - - free (value); if (!s2) { free (s1); return ENOMEM; } + strcat (strcpy (s2, "\n\t"), value); } if (s1 || s2) |