diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-01-30 17:10:19 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-01-31 14:57:35 +0200 |
commit | 34025229771c88e1b8118c40553a95ec4e2fc1c8 (patch) | |
tree | 30b64322ca8db8e2f09f9358c6124886371653d7 /imap4d | |
parent | 1a29c40ae9f491fe1f6895b383d3391450bc3736 (diff) | |
download | mailutils-34025229771c88e1b8118c40553a95ec4e2fc1c8.tar.gz mailutils-34025229771c88e1b8118c40553a95ec4e2fc1c8.tar.bz2 |
Rewrite the transcript stream
The new implementation consists of two independent state machines for
each transcript channel (input and output). The MU_XSCRIPT_PAYLOAD
state can be turned on for a predefined number of bytes on each channel.
After that many bytes pass through, the state will return back to
MU_XSCRIPT_NUMBER. This allows, in particular, to improve logging of
client commands containing literals in imap4d.
* include/mailutils/stream.h (MU_IOCTL_XSCRIPTSTREAM_CHANNEL): New
ioctl subcode.
(mu_xscript_channel): New struct.
(MU_XSCRIPT_LEVEL_IS_PACKED)
(MU_XSCRIPT_LEVEL_MASK,MU_XSCRIPT_LEVEL_UNMASK)
(MU_XSCRIPT_LEVEL_PACK): New macros.
* include/mailutils/sys/xscript-stream.h (_mu_xscript_channel): New struct.
(_mu_xscript_stream): Keep independent state for each channel.
* libmailutils/stream/xscript-stream.c: Rewrite as a state machine with
independent states for input and output channels.
* libmailutils/tests/xscript.at: Test packed channel levels and
MU_IOCTL_XSCRIPTSTREAM_CHANNEL ioctl.
* libmailutils/tests/xscript.c: Rewrite command parser.
* imap4d/imap4d.h (xscript_declare_client_payload): New proto.
* imap4d/util.c (xscript_declare_client_payload): New function.
* imap4d/io.c (imap4d_readline): Use xscript_declare_client_payload
after literals.
Diffstat (limited to 'imap4d')
-rw-r--r-- | imap4d/imap4d.h | 1 | ||||
-rw-r--r-- | imap4d/io.c | 3 | ||||
-rw-r--r-- | imap4d/util.c | 14 |
3 files changed, 16 insertions, 2 deletions
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h index 2bfae7a61..93fde1b19 100644 --- a/imap4d/imap4d.h +++ b/imap4d/imap4d.h @@ -471,6 +471,7 @@ void unistr_downcase (char const *input, char **output); int unistr_is_substring (char const *haystack, char const *needle); int set_xscript_level (int xlev); +void xscript_declare_client_payload (size_t len); int imap4d_init_tls_server (struct mu_tls_config *); diff --git a/imap4d/io.c b/imap4d/io.c index a2be5a212..afd379403 100644 --- a/imap4d/io.c +++ b/imap4d/io.c @@ -688,7 +688,6 @@ imap4d_readline (struct imap4d_tokbuf *tok) char *sp = NULL; char *buf; size_t len; - int xlev = set_xscript_level (MU_XSCRIPT_PAYLOAD); number = strtoul (last_arg + 1, &sp, 10); /* Client can ask for non-synchronised literal, @@ -697,6 +696,7 @@ imap4d_readline (struct imap4d_tokbuf *tok) io_sendf ("+ GO AHEAD\n"); else if (*sp != '+') break; + xscript_declare_client_payload (number); imap4d_tokbuf_expand (tok, number + 1); off = tok->level; buf = tok->buffer + off; @@ -715,7 +715,6 @@ imap4d_readline (struct imap4d_tokbuf *tok) tok->level += len; tok->buffer[tok->level++] = 0; tok->argp[tok->argc - 1] = off; - set_xscript_level (xlev); } else break; diff --git a/imap4d/util.c b/imap4d/util.c index cc494788b..92f46bd7a 100644 --- a/imap4d/util.c +++ b/imap4d/util.c @@ -292,3 +292,17 @@ set_xscript_level (int xlev) } return 0; } + +/* Hide next LEN bytes of client input in transcript */ +void +xscript_declare_client_payload (size_t len) +{ + struct mu_xscript_channel chan; + + chan.cd = 0; + chan.level = MU_XSCRIPT_PAYLOAD; + chan.length = len; + mu_stream_ioctl (iostream, MU_IOCTL_XSCRIPTSTREAM, + MU_IOCTL_XSCRIPTSTREAM_CHANNEL, &chan); +} + |