summaryrefslogtreecommitdiff
path: root/include/mailutils/stream.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-05-27 23:00:10 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-05-29 12:12:05 +0300
commit55da31fa5954aaf2e41c27ba24b4300c32232d47 (patch)
treecec87f60375941299a07ccfece7db267dac27587 /include/mailutils/stream.h
parentf9d6e59d678a540da08c8a7795f45621e9d49a9c (diff)
downloadmailutils-55da31fa5954aaf2e41c27ba24b4300c32232d47.tar.gz
mailutils-55da31fa5954aaf2e41c27ba24b4300c32232d47.tar.bz2
mail: write command operates on message parts as well as on messages
Messages or message parts are decoded before being written to a disk file. * include/mailutils/cstr.h (mu_mem_c_count): New proto. * include/mailutils/stream.h (MU_STREAM_STAT_INLN) (MU_STREAM_STAT_OUTLN): New constants. * libmailutils/stream/stream.c (_stream_stat_incr) (_stream_seek): Rewrite as inline functions. (_stream_read, _stream_write): Rewrite as inline functions. Optionally count number of lines read/written. * libmailutils/string/strcount.c (mu_mem_c_count): New function. * libmailutils/tests/fltst.c: Update. * mail/decode.c (format_msgset): Remove. Use msgset_str instead. (print_message_body): New function. * mail/mail.h (msgset_part_str) (util_get_message_part): New protos. (msgset_str): New function. * mail/msgset.y: Change the message part syntax. Components are separated by dots, instead of being enclosed in brackets. Old syntax is still supported for compatibility. * mail/struct.c (show_part): Use msgset_str. * mail/testsuite/mail/read.exp: Fix expected strings. * mail/util.c (util_get_message_part): New function. * mail/write.c (mail_write): Write message part if requested. Decode the body if the Content-Transfer-Encoding header is set.
Diffstat (limited to 'include/mailutils/stream.h')
-rw-r--r--include/mailutils/stream.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index 1c67c4880..327493870 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -270,22 +270,30 @@ struct mu_buffer_query
size_t bufsize; /* Buffer size */
};
-/* Statistics */
-#define MU_STREAM_STAT_IN 0
-#define MU_STREAM_STAT_OUT 1
-#define MU_STREAM_STAT_READS 2
-#define MU_STREAM_STAT_WRITES 3
-#define MU_STREAM_STAT_SEEKS 4
-#define _MU_STREAM_STAT_MAX 5
+/* Statistics */
+enum
+ {
+ MU_STREAM_STAT_IN, /* Bytes read */
+ MU_STREAM_STAT_OUT, /* Bytes written */
+ MU_STREAM_STAT_READS, /* Number of reads */
+ MU_STREAM_STAT_WRITES, /* Number of writes */
+ MU_STREAM_STAT_SEEKS, /* Number of seeks */
+ MU_STREAM_STAT_INLN, /* Lines read */
+ MU_STREAM_STAT_OUTLN, /* Lines written */
+ _MU_STREAM_STAT_MAX
+ };
#define MU_STREAM_STAT_MASK(n) (1U<<(n+1))
+
#define MU_STREAM_STAT_MASK_ALL \
(MU_STREAM_STAT_MASK (MU_STREAM_STAT_IN) | \
MU_STREAM_STAT_MASK (MU_STREAM_STAT_OUT) | \
MU_STREAM_STAT_MASK (MU_STREAM_STAT_READS) | \
MU_STREAM_STAT_MASK (MU_STREAM_STAT_WRITES) | \
- MU_STREAM_STAT_MASK (MU_STREAM_STAT_SEEKS))
-
+ MU_STREAM_STAT_MASK (MU_STREAM_STAT_SEEKS) | \
+ MU_STREAM_STAT_MASK (MU_STREAM_STAT_INLN) | \
+ MU_STREAM_STAT_MASK (MU_STREAM_STAT_OUTLN))
+
typedef mu_off_t mu_stream_stat_buffer[_MU_STREAM_STAT_MAX];
int mu_stream_set_stat (mu_stream_t stream, int statmask,
mu_stream_stat_buffer statbuf);

Return to:

Send suggestions and report system problems to the System administrator.