diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-06 15:01:33 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-12-06 15:26:42 +0200 |
commit | 1f44f1ad1f04c4d11ae4f56d2595a6126b223540 (patch) | |
tree | 71d762756ea73c596380a27f2b3302626393423b | |
parent | ec3fa1b18321ac99a62a00321ad6a059b6d30a27 (diff) | |
download | mailutils-1f44f1ad1f04c4d11ae4f56d2595a6126b223540.tar.gz mailutils-1f44f1ad1f04c4d11ae4f56d2595a6126b223540.tar.bz2 |
Revise stream ioctl support.
The mu_stream_ioctl function gets two argument that identify the ioctl
in question: "family", which identifies a family of ioctls in question,
and "opcode", which indicates the requested operation within that family.
* include/mailutils/stream.h: Define ioctl families and opcodes.
(mu_stream_ioctl): Change signature.
* include/mailutils/sys/stream.h (_mu_stream)<ctl>: Change signature.
* include/mailutils/log.h (mu_severity_from_string)
(mu_severity_to_string): New protos.
* libmailutils/stream/stream.c (mu_stream_ioctl): Change signature.
* libmailutils/filter/filter_iconv.c: Rewrite ioctl support.
* libmailutils/stream/file_stream.c: Likewise.
* libmailutils/stream/fltstream.c: Likewise.
* libmailutils/stream/iostream.c: Likewise.
* libmailutils/stream/logstream.c: Likewise.
* libmailutils/stream/mapfile_stream.c: Likewise.
* libmailutils/stream/memory_stream.c: Likewise.
* libmailutils/stream/nullstream.c: Likewise.
* libmailutils/stream/prog_stream.c: Likewise.
* libmailutils/stream/rdcache_stream.c: Likewise.
* libmailutils/stream/streamref.c: Likewise.
* libmailutils/stream/syslogstream.c: Likewise.
* libmailutils/stream/tcp.c: Likewise.
* libmailutils/stream/xscript-stream.c: Likewise.
* libmu_auth/tls.c: Likewise.
* comsat/action.c: Change calls to mu_stream_ioctl.
* imap4d/auth_gsasl.c: Likewise.
* imap4d/io.c: Likewise.
* imap4d/util.c: Likewise.
* libmailutils/base/getpass.c: Likewise.
* libmailutils/cfg/parser.y: Likewise.
* libmailutils/mailbox/body.c: Likewise.
* libmailutils/mime/mime.c: Likewise.
* libmailutils/stdstream/dbgstream.c: Likewise.
* libmailutils/stdstream/strerr.c: Likewise.
* libmu_sieve/runtime.c: Likewise.
* libmu_sieve/sieve.y: Likewise.
* libmu_sieve/util.c: Likewise.
* libproto/imap/trace.c: Likewise.
* libproto/mailer/smtp_data.c: Likewise.
* libproto/mailer/smtp_starttls.c: Likewise.
* libproto/mailer/smtp_trace.c: Likewise.
* libproto/pop/pop3_stls.c: Likewise.
* libproto/pop/pop3_stream.c: Likewise.
* libproto/pop/pop3_trace.c: Likewise.
* maidag/lmtp.c: Likewise.
* mail/source.c: Likewise.
* mu/logger.c: Likewise.
* pop3d/extra.c: Likewise.
* pop3d/retr.c: Likewise.
* TODO: Update.
* doc/texinfo/nullstream.texi: Update.
46 files changed, 835 insertions, 563 deletions
@@ -14,6 +14,8 @@ Software Foundation, Inc. See also mu_rfc2822_in_reply_to. +* Check id _mu_smtp_trace_disable correctly dereferences streams. + * mail: rewrite I/O support using streams. * re-implement imap4 client (in progress) diff --git a/comsat/action.c b/comsat/action.c index 020079f62..1ec5840ed 100644 --- a/comsat/action.c +++ b/comsat/action.c @@ -396,7 +396,8 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) if (mu_wordsplit (stmt, &ws, MU_WRDSF_DEFFLAGS | MU_WRDSF_COMMENT) && ws.ws_wordc) { - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_LOCUS, &locus); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS, &locus); if (strcmp (ws.ws_wordv[0], "beep") == 0) { /* FIXME: excess arguments are ignored */ @@ -445,7 +446,8 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) locus.mu_line += n; } fclose (fp); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL); free (rcname); } diff --git a/doc/texinfo/nullstream.texi b/doc/texinfo/nullstream.texi index a14015008..a368b747a 100644 --- a/doc/texinfo/nullstream.texi +++ b/doc/texinfo/nullstream.texi @@ -51,9 +51,22 @@ with @file{/dev/null}, or @file{/dev/zero}. We refer to these devices only to illustrate the behavior of @dfn{null streams}.}. This is the default behavior when reading. It can be altered using -the following @dfn{ioctls}. +the @samp{MU_IOCTL_NULLSTREAM} ioctl. -@defvr {ioctl} MU_IOCTL_NULLSTREAM_SET_PATTERN +@defvr {ioctl} MU_IOCTL_NULLSTREAM +This ioctl controls various parameters of a null stream. Synopsis: + +@example +mu_stream_ioctl (@var{stream}, MU_IOCTL_NULLSTREAM, @var{opcode}, @var{arg}); +@end example + +@noindent +where @var{opcode} is the operation code specific to null streams and +@var{arg} is the operation argument. Supported operation codes and +their arguments are discussed below in this document. +@end defvr + +@defvr {ioctl opcode} MU_IOCTL_NULLSTREAM_SET_PATTERN Set the @dfn{pattern} for reads. The argument is a pointer to @dfn{struct mu_nullstream_pattern}, defined as: @@ -78,7 +91,10 @@ are returned cyclically at each read. For example, suppose that pat.pattern = "01234567"; pat.size = 8; - mu_stream_ioctl (str, MU_IOCTL_NULLSTREAM_SET_PATTERN, &pat); + mu_stream_ioctl (str, + MU_IOCTL_NULLSTREAM, + MU_IOCTL_NULLSTREAM_SET_PATTERN, + &pat); mu_stream_read (str, buf, sizeof (buf), &n); @end smallexample @@ -115,7 +131,10 @@ The default behavior corresponds to the following initialization: @group pat.pattern = ""; pat.size = 1; - mu_stream_ioctl (str, MU_IOCTL_NULLSTREAM_SET_PATTERN, &pat); + mu_stream_ioctl (str, + MU_IOCTL_NULLSTREAM, + MU_IOCTL_NULLSTREAM_SET_PATTERN, + &pat); @end group @end smallexample @@ -124,7 +143,10 @@ argument causes all subsequent reads from that stream to return @samp{EOF}: @smallexample @group - mu_stream_ioctl (str, MU_IOCTL_NULLSTREAM_SET_PATTERN, NULL); + mu_stream_ioctl (str, + MU_IOCTL_NULLSTREAM, + MU_IOCTL_NULLSTREAM_SET_PATTERN, + NULL); @dots{} rc = mu_stream_read (str, buf, sizeof (buf), &n); @@ -134,7 +156,7 @@ argument causes all subsequent reads from that stream to return @samp{EOF}: @end smallexample @end defvr -@defvr {ioctl} MU_IOCTL_NULLSTREAM_SET_PATCLASS +@defvr {ioctl opcode} MU_IOCTL_NULLSTREAM_SET_PATCLASS Set read pattern in terms of @dfn{C character classes} (@FIXME-pxref{C character classes}). Argument is a pointer to an integer containing a bitwise @samp{OR} of the desired @@ -143,7 +165,10 @@ the following code: @smallexample int class = MU_CTYPE_DIGIT|MU_CTYPE_XLETR; - mu_stream_ioctl (str, MU_IOCTL_NULLSTREAM_SET_PATCLASS, &class); + mu_stream_ioctl (str, + MU_IOCTL_NULLSTREAM, + MU_IOCTL_NULLSTREAM_SET_PATCLASS, + &class); @end smallexample @noindent @@ -157,7 +182,7 @@ initializes the read pattern to the following string: Two ioctls are provided to control the @dfn{size} of a null stream available to seek and read operations. -@defvr {ioctl} MU_IOCTL_NULLSTREAM_SETSIZE +@defvr {ioctl opcode} MU_IOCTL_NULLSTREAM_SETSIZE Limit the addressable size of a null stream. Argument is a pointer to @samp{mu_off_t} object specifying the new size. The example below limits the stream size to 32 bytes: @@ -165,7 +190,10 @@ limits the stream size to 32 bytes: @smallexample @group mu_off_t limit = 32; - mu_stream_ioctl (str, MU_IOCTL_NULLSTREAM_SETSIZE, &limit); + mu_stream_ioctl (str, + MU_IOCTL_NULLSTREAM, + MU_IOCTL_NULLSTREAM_SETSIZE, + &limit); @end group @end smallexample @end defvr @@ -181,7 +209,7 @@ Setting the stream size to @samp{0} causes all subsequent reads from that stream to return @samp{EOF}. The similar effect has the @samp{MU_IOCTL_NULLSTREAM_SET_PATTERN} ioctl with the @samp{NULL} argument. -@defvr {ioctl} MU_IOCTL_NULLSTREAM_CLRSIZE +@defvr {ioctl opcode} MU_IOCTL_NULLSTREAM_CLRSIZE Cancel the size limitation imposed by a previous @samp{MU_IOCTL_NULLSTREAM_SETSIZE} ioctl or a call to @samp{mu_stream_truncate}. Argument must be @samp{NULL}. diff --git a/imap4d/auth_gsasl.c b/imap4d/auth_gsasl.c index 54e206af1..d516d31d1 100644 --- a/imap4d/auth_gsasl.c +++ b/imap4d/auth_gsasl.c @@ -111,7 +111,8 @@ auth_gsasl (struct imap4d_auth *ap) { mu_stream_t stream[2], newstream[2]; - rc = mu_stream_ioctl (iostream, MU_IOCTL_GET_STREAM, stream); + rc = mu_stream_ioctl (iostream, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, + stream); if (rc) { mu_error (_("%s failed: %s"), "MU_IOCTL_GET_STREAM", @@ -157,7 +158,8 @@ auth_gsasl (struct imap4d_auth *ap) mu_stream_unref (stream[0]); mu_stream_unref (stream[1]); - rc = mu_stream_ioctl (iostream, MU_IOCTL_SET_STREAM, newstream); + rc = mu_stream_ioctl (iostream, MU_IOCTL_SUBSTREAM, + MU_IOCTL_OP_SET, newstream); if (rc) { mu_error (_("%s failed when it should not: %s"), diff --git a/imap4d/io.c b/imap4d/io.c index 9ed4f4609..0e9d71aec 100644 --- a/imap4d/io.c +++ b/imap4d/io.c @@ -83,7 +83,7 @@ imap4d_init_tls_server () mu_stream_t tlsstream, stream[2]; int rc; - rc = mu_stream_ioctl (iostream, MU_IOCTL_GET_STREAM, stream); + rc = mu_stream_ioctl (iostream, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET, stream); if (rc) { mu_error (_("%s failed: %s"), "MU_IOCTL_GET_STREAM", @@ -103,7 +103,7 @@ imap4d_init_tls_server () mu_stream_unref (stream[1]); stream[0] = stream[1] = tlsstream; - rc = mu_stream_ioctl (iostream, MU_IOCTL_SET_STREAM, stream); + rc = mu_stream_ioctl (iostream, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_SET, stream); if (rc) { mu_error (_("%s failed: %s"), "MU_IOCTL_SET_STREAM", diff --git a/imap4d/util.c b/imap4d/util.c index 6d3ebcb71..81faaf933 100644 --- a/imap4d/util.c +++ b/imap4d/util.c @@ -683,7 +683,8 @@ set_xscript_level (int xlev) return MU_XSCRIPT_NORMAL; } - if (mu_stream_ioctl (iostream, MU_IOCTL_LEVEL, &xlev) == 0) + if (mu_stream_ioctl (iostream, MU_IOCTL_XSCRIPTSTREAM, + MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0) return xlev; } return 0; diff --git a/include/mailutils/log.h b/include/mailutils/log.h index a36b85ab5..0b989cf52 100644 --- a/include/mailutils/log.h +++ b/include/mailutils/log.h @@ -38,6 +38,9 @@ extern "C" { int mu_log_stream_create (mu_stream_t *, mu_stream_t); int mu_syslog_stream_create (mu_stream_t *, int); +int mu_severity_from_string (const char *str, unsigned *pn); +int mu_severity_to_string (unsigned n, const char **pstr); + extern char *_mu_severity_str[]; extern int _mu_severity_num; diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h index 7a191e81e..300639e57 100644 --- a/include/mailutils/stream.h +++ b/include/mailutils/stream.h @@ -59,74 +59,83 @@ enum mu_buffer_type #define MU_STREAM_IWOTH 0x00008000 #define MU_STREAM_IMASK 0x0000F000 -#define MU_IOCTL_GET_TRANSPORT 1 -#define MU_IOCTL_GET_STATUS 2 -#define MU_IOCTL_GET_PID 3 -#define MU_IOCTL_SET_SEEK_LIMITS 4 -#define MU_IOCTL_ABRIDGE_SEEK MU_IOCTL_SET_SEEK_LIMITS -#define MU_IOCTL_GET_SEEK_LIMITS 5 -#define MU_IOCTL_SET_TRANSPORT 6 -#define MU_IOCTL_GET_STREAM 7 -#define MU_IOCTL_SET_STREAM 8 - -#define MU_IOCTL_LEVEL 9 - -#define MU_IOCTL_GET_TRANSPORT_BUFFER 10 -#define MU_IOCTL_SET_TRANSPORT_BUFFER 11 - -#define MU_IOCTL_GET_ECHO 12 -#define MU_IOCTL_SET_ECHO 13 + /* Ioctl families */ +#define MU_IOCTL_TRANSPORT 0 +#define MU_IOCTL_PROGSTREAM 1 /* Program stream */ +#define MU_IOCTL_SEEK_LIMITS 2 /* Seek limits (get/set), + Arg: mu_off_t[2] */ +#define MU_IOCTL_SUBSTREAM 3 /* Substream (get/set) */ +#define MU_IOCTL_TRANSPORT_BUFFER 4 /* get/set */ +#define MU_IOCTL_ECHO 5 /* get/set */ +#define MU_IOCTL_NULLSTREAM 6 /* Null stream (see below) */ +#define MU_IOCTL_LOGSTREAM 7 /* Log stream (see below) */ +#define MU_IOCTL_XSCRIPTSTREAM 8 /* Transcript stream (see below) */ + + /* Opcodes common for various families */ +#define MU_IOCTL_OP_GET 0 +#define MU_IOCTL_OP_SET 1 -/* The following ioctls are for nullstreams only: */ -#define MU_IOCTL_NULLSTREAM_SET_PATTERN 14 + /* Opcodes for MU_IOCTL_PROGSTREAM */ +#define MU_IOCTL_PROG_STATUS 0 +#define MU_IOCTL_PROG_PID 1 + + /* Opcodes for MU_IOCTL_NULLSTREAM */ /* Set read pattern. Argument: struct mu_nullstream_pattern *pat. If pat==NULL, any reads from that stream will return EOF. */ -#define MU_IOCTL_NULLSTREAM_SET_PATCLASS 15 +#define MU_IOCTL_NULLSTREAM_SET_PATTERN 0 /* Set pattern class for reads: Argument int *pclass (a class mask from mailutils/cctype.h */ -#define MU_IOCTL_NULLSTREAM_SETSIZE 16 +#define MU_IOCTL_NULLSTREAM_SET_PATCLASS 1 /* Limit stream size. Argument: mu_off_t *psize; */ -#define MU_IOCTL_NULLSTREAM_CLRSIZE 17 +#define MU_IOCTL_NULLSTREAM_SETSIZE 2 /* Lift the size limit. Argument: NULL */ - -/* The following are for logstreams */ - /* Get or set logging severity. +#define MU_IOCTL_NULLSTREAM_CLRSIZE 3 + + /* Get or set logging severity. Arg: unsigned * */ -#define MU_IOCTL_LOGSTREAM_GET_SEVERITY 18 -#define MU_IOCTL_LOGSTREAM_SET_SEVERITY 19 +#define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0 +#define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1 /* Get or set locus. Arg: struct mu_locus * */ -#define MU_IOCTL_LOGSTREAM_GET_LOCUS 20 -#define MU_IOCTL_LOGSTREAM_SET_LOCUS 21 +#define MU_IOCTL_LOGSTREAM_GET_LOCUS 2 +#define MU_IOCTL_LOGSTREAM_SET_LOCUS 3 /* Get or set log mode. Arg: int * */ -#define MU_IOCTL_LOGSTREAM_GET_MODE 22 -#define MU_IOCTL_LOGSTREAM_SET_MODE 23 +#define MU_IOCTL_LOGSTREAM_GET_MODE 4 +#define MU_IOCTL_LOGSTREAM_SET_MODE 5 /* Advance locus line. Arg: NULL (increment by 1) int * */ -#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE 24 +#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE 6 /* Advance locus column. Arg: NULL (increment by 1) int * */ -#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_COL 25 +#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_COL 7 /* Suppress output of messages having severity lower than the given threshold. Arg: int * */ -#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY 26 +#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY 8 /* Same as above, but: Arg: const char * */ -#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 27 +#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 9 + + /* Opcodes for MU_IOCTL_XSCRIPTSTREAM */ + /* Swap transcript levels. + Arg: int *X + + New transcript level is set to *X. Previous level is stored in X. + */ +#define MU_IOCTL_XSCRIPTSTREAM_LEVEL 0 #define MU_TRANSPORT_INPUT 0 #define MU_TRANSPORT_OUTPUT 1 @@ -206,7 +215,7 @@ int mu_stream_writeline (mu_stream_t stream, const char *buf, size_t size); int mu_stream_flush (mu_stream_t stream); int mu_stream_close (mu_stream_t stream); int mu_stream_size (mu_stream_t stream, mu_off_t *psize); -int mu_stream_ioctl (mu_stream_t stream, int code, void *ptr); +int mu_stream_ioctl (mu_stream_t stream, int family, int opcode, void *ptr); int mu_stream_truncate (mu_stream_t stream, mu_off_t); int mu_stream_shutdown (mu_stream_t stream, int how); diff --git a/include/mailutils/sys/stream.h b/include/mailutils/sys/stream.h index f4217da58..964c01f99 100644 --- a/include/mailutils/sys/stream.h +++ b/include/mailutils/sys/stream.h @@ -60,7 +60,7 @@ struct _mu_stream void (*done) (struct _mu_stream *); int (*seek) (struct _mu_stream *, mu_off_t, mu_off_t *); int (*size) (struct _mu_stream *, mu_off_t *); - int (*ctl) (struct _mu_stream *, int, void *); + int (*ctl) (struct _mu_stream *, int, int, void *); int (*wait) (struct _mu_stream *, int *, struct timeval *); int (*truncate) (struct _mu_stream *, mu_off_t); int (*shutdown) (struct _mu_stream *, int); diff --git a/libmailutils/base/getpass.c b/libmailutils/base/getpass.c index ec88b0e5d..2c6fcaab7 100644 --- a/libmailutils/base/getpass.c +++ b/libmailutils/base/getpass.c @@ -40,13 +40,13 @@ mu_getpass (mu_stream_t in, mu_stream_t out, const char *prompt, if (status) return status; mu_stream_flush (out); - status = mu_stream_ioctl (in, MU_IOCTL_SET_ECHO, &echo_state); + status = mu_stream_ioctl (in, MU_IOCTL_ECHO, MU_IOCTL_OP_SET, &echo_state); if (status == 0) echo_state = 1; status = mu_stream_getline (in, &buf, &size, NULL); if (echo_state) { - mu_stream_ioctl (in, MU_IOCTL_SET_ECHO, &echo_state); + mu_stream_ioctl (in, MU_IOCTL_ECHO, MU_IOCTL_OP_SET, &echo_state); mu_stream_write (out, "\n", 1, NULL); } if (status == 0) diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y index f5b866cb2..603351d3f 100644 --- a/libmailutils/cfg/parser.y +++ b/libmailutils/cfg/parser.y @@ -395,12 +395,15 @@ mu_cfg_parse (mu_cfg_tree_t **ptree) int save_mode = 0, mode; struct mu_locus save_locus = { NULL, }; - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_GET_MODE, &save_mode); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_MODE, + &save_mode); mode = save_mode | MU_LOGMODE_LOCUS; - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_MODE, &mode); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_GET_LOCUS, &save_locus); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE, + &mode); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_LOCUS, + &save_locus); - mu_cfg_set_debug ();//FIXME + mu_cfg_set_debug (); _mu_cfg_errcnt = 0; rc = yyparse (); @@ -419,8 +422,10 @@ mu_cfg_parse (mu_cfg_tree_t **ptree) *ptree = tree; } - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_MODE, &save_mode); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_GET_LOCUS, &save_locus); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE, + &save_mode); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS, + &save_locus); free (save_locus.mu_file); return rc; @@ -1246,7 +1251,8 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) node->tag); abort (); } - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_LOCUS, + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS, (void*) &node->locus); if (param->callback (tgt, node->label)) return 1; @@ -1289,7 +1295,8 @@ _scan_tree_helper (const mu_cfg_node_t *node, void *data) sec->target = (char*)sdata->target + sec->offset; if (sec->parser) { - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_LOCUS, + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS, (void*) &node->locus); if (sec->parser (mu_cfg_section_start, node, sec->label, &sec->target, @@ -1355,10 +1362,13 @@ mu_cfg_scan_tree (mu_cfg_tree_t *tree, struct mu_cfg_section *sections, dat.call_data = data; dat.target = target; - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_GET_MODE, &save_mode); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_GET_MODE, &save_mode); mode = save_mode | MU_LOGMODE_LOCUS; - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_MODE, &mode); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_GET_LOCUS, &save_locus); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_MODE, &mode); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_GET_LOCUS, &save_locus); if (push_section (&dat, sections)) return 1; @@ -1368,8 +1378,10 @@ mu_cfg_scan_tree (mu_cfg_tree_t *tree, struct mu_cfg_section *sections, mu_cfg_preorder (tree->nodes, &clos); pop_section (&dat); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_SET_MODE, &save_mode); - mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_GET_LOCUS, &save_locus); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_MODE, &save_mode); + mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, + MU_IOCTL_LOGSTREAM_SET_LOCUS, &save_locus); free (save_locus.mu_file); return dat.error; diff --git a/libmailutils/filter/filter_iconv.c b/libmailutils/filter/filter_iconv.c index 79835a579..cab442d5d 100644 --- a/libmailutils/filter/filter_iconv.c +++ b/libmailutils/filter/filter_iconv.c @@ -384,26 +384,32 @@ _icvt_strerror (mu_stream_t stream, int rc) } static int -_icvt_ioctl (mu_stream_t stream, int code, void *ptr) +_icvt_ioctl (mu_stream_t stream, int code, int opcode, void *ptr) { struct icvt_stream *s = (struct icvt_stream *)stream; mu_transport_t *ptrans; switch (code) { - case MU_IOCTL_GET_TRANSPORT: + case MU_IOCTL_TRANSPORT: if (!ptr) return EINVAL; - ptrans = ptr; - ptrans[0] = (mu_transport_t) s->transport; - ptrans[1] = NULL; + switch (opcode) + { + case MU_IOCTL_OP_GET: + ptrans = ptr; + ptrans[0] = (mu_transport_t) s->transport; + ptrans[1] = NULL; + break; + + default: + return ENOSYS; + } break; - case MU_IOCTL_GET_STREAM: - case MU_IOCTL_SET_STREAM: - case MU_IOCTL_GET_TRANSPORT_BUFFER: - case MU_IOCTL_SET_TRANSPORT_BUFFER: - return mu_stream_ioctl (s->transport, code, ptr); + case MU_IOCTL_SUBSTREAM: + case MU_IOCTL_TRANSPORT_BUFFER: + return mu_stream_ioctl (s->transport, code, opcode, ptr); default: return ENOSYS; diff --git a/libmailutils/mailbox/body.c b/libmailutils/mailbox/body.c index 5db2216a7..ceaa309b9 100644 --- a/libmailutils/mailbox/body.c +++ b/libmailutils/mailbox/body.c @@ -42,7 +42,7 @@ static int _body_read (mu_stream_t, char *, size_t, size_t *); static int _body_truncate (mu_stream_t, mu_off_t); static int _body_size (mu_stream_t, mu_off_t *); static int _body_write (mu_stream_t, const char *, size_t, size_t *); -static int _body_ioctl (mu_stream_t, int, void *); +static int _body_ioctl (mu_stream_t, int, int, void *); static int _body_seek (mu_stream_t, mu_off_t, mu_off_t *); static const char *_body_error_string (mu_stream_t, int); @@ -289,11 +289,11 @@ _body_error_string (mu_stream_t stream, int rc) } static int -_body_ioctl (mu_stream_t stream, int code, void *ptr) +_body_ioctl (mu_stream_t stream, int code, int opcode, void *ptr) { struct _mu_body_stream *str = (struct _mu_body_stream*) stream; mu_body_t body = str->body; - return mu_stream_ioctl (body->fstream, code, ptr); + return mu_stream_ioctl (body->fstream, code, opcode, ptr); } static int diff --git a/libmailutils/mime/mime.c b/libmailutils/mime/mime.c index be75b314c..c3bec6fcd 100644 --- a/libmailutils/mime/mime.c +++ b/libmailutils/mime/mime.c @@ -759,7 +759,7 @@ _mime_body_stream_read (mu_stream_t stream, char *buf, size_t buflen, size_t *nb } static int -_mime_body_stream_ioctl (mu_stream_t stream, int code, void *arg) +_mime_body_stream_ioctl (mu_stream_t stream, int code, int opcode, void *arg) { struct _mime_body_stream *mstr = (struct _mime_body_stream *)stream; mu_mime_t mime = mstr->mime; @@ -768,18 +768,28 @@ _mime_body_stream_ioctl (mu_stream_t stream, int code, void *arg) switch (code) { - case MU_IOCTL_GET_TRANSPORT: + case MU_IOCTL_TRANSPORT: if (!arg) return EINVAL; - - if (mime->nmtp_parts == 0 || mime->cur_offset == 0) - return EINVAL; - rc = mu_message_get_streamref (mime->mtp_parts[mime->cur_part]->msg, - &msg_stream); - if (rc) - break; - rc = mu_stream_ioctl (msg_stream, code, arg); - mu_stream_destroy (&msg_stream); + switch (opcode) + { + case MU_IOCTL_OP_GET: + if (mime->nmtp_parts == 0 || mime->cur_offset == 0) + return EINVAL; + rc = mu_message_get_streamref (mime->mtp_parts[mime->cur_part]->msg, + &msg_stream); + if (rc) + break; + rc = mu_stream_ioctl (msg_stream, code, opcode, arg); + mu_stream_destroy (&msg_stream); + break; + + case MU_IOCTL_OP_SET: + return ENOSYS; + + default: + return EINVAL; + } break; default: diff --git a/libmailutils/stdstream/dbgstream.c b/libmailutils/stdstre |