Commit 1f44f1ad 1f44f1ad1f04c4d11ae4f56d2595a6126b223540 by Sergey Poznyakoff

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.
1 parent ec3fa1b1
......@@ -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)
......
......@@ -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);
}
......
......@@ -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}.
......
......@@ -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"),
......
......@@ -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",
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
/* The following ioctls are for nullstreams only: */
#define MU_IOCTL_NULLSTREAM_SET_PATTERN 14
/* 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
/* 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 */
#define MU_IOCTL_NULLSTREAM_CLRSIZE 3
/* The following are for logstreams */
/* 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);
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
......
......@@ -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;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans = ptr;
ptrans[0] = (mu_transport_t) s->transport;
ptrans[1] = NULL;
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);
default:
return ENOSYS;
}
break;
case MU_IOCTL_SUBSTREAM:
case MU_IOCTL_TRANSPORT_BUFFER:
return mu_stream_ioctl (s->transport, code, opcode, ptr);
default:
return ENOSYS;
......
......@@ -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
......
......@@ -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,20 +768,30 @@ _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;
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, arg);
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:
rc = ENOSYS;
}
......
......@@ -29,13 +29,14 @@ mu_dbgstream_create (mu_stream_t *pstr, int severity)
int rc;
mu_transport_t trans[2];
rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_GET_TRANSPORT, trans);
rc = mu_stream_ioctl (mu_strerr, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, trans);
if (rc)
return rc;
rc = mu_log_stream_create (pstr, (mu_stream_t) trans[0]);
if (rc)
return rc;
mu_stream_ioctl (*pstr, MU_IOCTL_LOGSTREAM_SET_SEVERITY, &severity);
mu_stream_ioctl (*pstr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_SEVERITY,
&severity);
return 0;
}
......
......@@ -117,10 +117,12 @@ mu_stdstream_strerr_setup (int type)
if (mu_log_print_severity)
{
int mode = MU_LOGMODE_SEVERITY;
mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
}
if (mu_log_severity_threshold > MU_LOG_DEBUG)
mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY,
mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY,
&mu_log_severity_threshold);
mu_stream_destroy (&mu_strerr);
mu_strerr = str;
......
......@@ -204,50 +204,56 @@ fd_error_string (struct _mu_stream *str, int rc)
#endif
static int
fd_ioctl (struct _mu_stream *str, int code, void *ptr)
fd_ioctl (struct _mu_stream *str, int code, int opcode, void *ptr)
{
struct _mu_file_stream *fstr = (struct _mu_file_stream *) str;
mu_transport_t *ptrans;
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!ptr)
return EINVAL;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans = ptr;
ptrans[0] = (mu_transport_t) fstr->fd;
ptrans[1] = NULL;
break;
case MU_IOCTL_SET_TRANSPORT:
if (!ptr)
return EINVAL;
case MU_IOCTL_OP_SET:
ptrans = ptr;
fstr->fd = (int) ptrans[0];
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
if (!ptr)
return EINVAL;
else
{
struct mu_buffer_query *qp = ptr;
return mu_stream_get_buffer (str, qp);
}
break;
case MU_IOCTL_SET_TRANSPORT_BUFFER:
case MU_IOCTL_TRANSPORT_BUFFER:
if (!ptr)
return EINVAL;
else
{
struct mu_buffer_query *qp = ptr;
switch (opcode)
{
case MU_IOCTL_OP_GET:
return mu_stream_get_buffer (str, qp);
case MU_IOCTL_OP_SET:
return mu_stream_set_buffer (str, qp->buftype, qp->bufsize);
}
}
break;
case MU_IOCTL_SET_ECHO:
case MU_IOCTL_ECHO:
if (!ptr)
return EINVAL;
else
switch (opcode)
{
case MU_IOCTL_OP_GET:
*(int*)ptr = fstr->flags & _MU_FILE_STREAM_ECHO_OFF;
break;
case MU_IOCTL_OP_SET:
{
int status;
struct termios t;
......@@ -284,7 +290,8 @@ fd_ioctl (struct _mu_stream *str, int code, void *ptr)
{
if (!(fstr->flags & _MU_FILE_STREAM_ECHO_OFF))
return 0;
if (tcsetattr (fstr->fd, TCSAFLUSH | TCSASOFT, fstr->echo_state))
if (tcsetattr (fstr->fd, TCSAFLUSH | TCSASOFT,
fstr->echo_state))
status = errno;
else
{
......@@ -299,12 +306,7 @@ fd_ioctl (struct _mu_stream *str, int code, void *ptr)
return ENOSYS;
#endif
}
case MU_IOCTL_GET_ECHO:
if (!ptr)
return EINVAL;
else
*(int*)ptr = fstr->flags & _MU_FILE_STREAM_ECHO_OFF;
}
break;
default:
......
......@@ -358,23 +358,29 @@ filter_seek (struct _mu_stream *stream, mu_off_t off, mu_off_t *ppos)
}
static int
filter_ctl (struct _mu_stream *stream, int op, void *ptr)
filter_ctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
{
struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream;
mu_transport_t *ptrans;
switch (op)
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
switch (opcode)
{
case MU_IOCTL_OP_GET:
if (!ptr)
return EINVAL;
ptrans = ptr;
else
{
mu_transport_t *ptrans = ptr;
ptrans[0] = (mu_transport_t) fs->transport;
ptrans[1] = NULL;
}
break;
}
/* fall through */
default:
return mu_stream_ioctl (fs->transport, op, ptr);
return mu_stream_ioctl (fs->transport, code, opcode, ptr);
}
return 0;
}
......
......@@ -126,50 +126,54 @@ _iostream_done (struct _mu_stream *str)
}
static int
_iostream_ctl (struct _mu_stream *str, int op, void *arg)
_iostream_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_iostream *sp = (struct _mu_iostream *)str;
mu_transport_t *ptrans;
switch (op)
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!arg)
return EINVAL;
ptrans = arg;
else
{
mu_transport_t *ptrans = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) sp->transport[_MU_STREAM_INPUT];
ptrans[1] = (mu_transport_t) sp->transport[_MU_STREAM_OUTPUT];
break;
case MU_IOCTL_SET_TRANSPORT:
if (!arg)
return EINVAL;
case MU_IOCTL_OP_SET:
ptrans = arg;
sp->transport[_MU_STREAM_INPUT] = (mu_stream_t) ptrans[0];
sp->transport[_MU_STREAM_OUTPUT] = (mu_stream_t) ptrans[1];
break;
case MU_IOCTL_GET_STREAM:
default:
return EINVAL;
}
}
break;
case MU_IOCTL_SUBSTREAM:
if (!arg)
return EINVAL;
else
{
mu_stream_t *pstr = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
pstr[0] = sp->transport[0];
mu_stream_ref (pstr[0]);
pstr[1] = sp->transport[1];
mu_stream_ref (pstr[1]);
}
break;
case MU_IOCTL_SET_STREAM:
if (!arg)
return EINVAL;
else
{
mu_stream_t *pstr = arg;
case MU_IOCTL_OP_SET:
mu_stream_unref (sp->transport[0]);
sp->transport[0] = pstr[0];
mu_stream_ref (sp->transport[0]);
......@@ -177,11 +181,15 @@ _iostream_ctl (struct _mu_stream *str, int op, void *arg)
mu_stream_unref (sp->transport[1]);
sp->transport[1] = pstr[1];
mu_stream_ref (sp->transport[1]);
break;
default:
return EINVAL;
}
}
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
case MU_IOCTL_SET_TRANSPORT_BUFFER:
case MU_IOCTL_TRANSPORT_BUFFER:
if (!arg)
return EINVAL;
else
......@@ -189,7 +197,7 @@ _iostream_ctl (struct _mu_stream *str, int op, void *arg)
struct mu_buffer_query *qp = arg;
if (!MU_TRANSPORT_VALID_TYPE (qp->type) || !sp->transport[qp->type])
return EINVAL;
return mu_stream_ioctl (sp->transport[qp->type], op, arg);
return mu_stream_ioctl (sp->transport[qp->type], code, opcode, arg);
}
default:
......
......@@ -213,7 +213,8 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size,
return 0;
}
mu_stream_ioctl (sp->transport, MU_IOCTL_LOGSTREAM_SET_SEVERITY, &severity);
mu_stream_ioctl (sp->transport, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_SEVERITY, &severity);
if (logmode & MU_LOGMODE_LOCUS)
{
......@@ -278,29 +279,40 @@ _log_setbuf_hook (mu_stream_t str, enum mu_buffer_type type, size_t size)
}
static int
_log_ctl (struct _mu_stream *str, int op, void *arg)
_log_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_log_stream *sp = (struct _mu_log_stream *)str;
mu_transport_t *ptrans;
switch (op)
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!arg)
return EINVAL;
ptrans = arg;
else
{
mu_transport_t *ptrans = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) sp->transport;
ptrans[1] = NULL;
break;
case MU_IOCTL_SET_TRANSPORT:
if (!arg)
return EINVAL;
case MU_IOCTL_OP_SET:
ptrans = arg;
if (ptrans[0])
sp->transport = (mu_stream_t) ptrans[0];
break;
default:
return EINVAL;
}
}
break;
case MU_IOCTL_LOGSTREAM:
switch (opcode)
{
case MU_IOCTL_LOGSTREAM_GET_SEVERITY:
if (!arg)
return EINVAL;
......@@ -328,10 +340,11 @@ _log_ctl (struct _mu_stream *str, int op, void *arg)
break;
case MU_IOCTL_LOGSTREAM_GET_LOCUS:
{
struct mu_locus *ploc = arg;
if (!arg)
return EINVAL;
else
{
struct mu_locus *ploc = arg;
if (sp->locus.mu_file)
{
ploc->mu_file = strdup (sp->locus.mu_file);
......@@ -342,8 +355,8 @@ _log_ctl (struct _mu_stream *str, int op, void *arg)
ploc->mu_file = NULL;
ploc->mu_line = sp->locus.mu_line;
ploc->mu_col = sp->locus.mu_col;
break;
}
break;
case MU_IOCTL_LOGSTREAM_SET_LOCUS:
{
......@@ -395,6 +408,10 @@ _log_ctl (struct _mu_stream *str, int op, void *arg)
sp->threshold = MU_LOG_DEBUG;
else
return mu_severity_from_string ((const char *) arg, &sp->threshold);
default:
return EINVAL;
}
break;
default:
......
......@@ -206,29 +206,49 @@ _mapfile_flush (mu_stream_t stream)
}
static int
_mapfile_ioctl (struct _mu_stream *str, int code, void *ptr)
_mapfile_ioctl (struct _mu_stream *str, int code, int opcode, void *ptr)
{
struct _mu_mapfile_stream *mfs = (struct _mu_mapfile_stream *) str;
mu_transport_t ptrans[2];
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!ptr)
return EINVAL;
else
{
mu_transport_t *ptrans = ptr;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) mfs->fd;
ptrans[1] = NULL;
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
{
struct mu_buffer_query *qp = ptr;
return mu_stream_get_buffer (str, qp);
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
}
break;
case MU_IOCTL_SET_TRANSPORT_BUFFER:
case MU_IOCTL_TRANSPORT_BUFFER:
if (!ptr)
return EINVAL;
else
{
struct mu_buffer_query *qp = ptr;
switch (opcode)
{
case MU_IOCTL_OP_GET:
return mu_stream_get_buffer (str, qp);
case MU_IOCTL_OP_SET:
return mu_stream_set_buffer (str, qp->buftype, qp->bufsize);
default:
return EINVAL;
}
}
break;
default:
return ENOSYS;
......
......@@ -144,32 +144,49 @@ _memory_open (mu_stream_t stream)
}
static int
_memory_ioctl (struct _mu_stream *stream, int code, void *ptr)
_memory_ioctl (struct _mu_stream *stream, int code, int opcode, void *ptr)
{
struct _mu_memory_stream *mfs = (struct _mu_memory_stream *) stream;
mu_transport_t *ptrans;
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!ptr)
return EINVAL;
ptrans = ptr;
else
{
mu_transport_t *ptrans = ptr;
switch (code)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) mfs->ptr;
ptrans[1] = NULL;
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
{
struct mu_buffer_query *qp = ptr;
return mu_stream_get_buffer (stream, qp);
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
}
break;
case MU_IOCTL_SET_TRANSPORT_BUFFER:
case MU_IOCTL_TRANSPORT_BUFFER:
if (!ptr)
return EINVAL;
else
{
struct mu_buffer_query *qp = ptr;
switch (code)
{
case MU_IOCTL_OP_GET:
return mu_stream_get_buffer (stream, qp);
case MU_IOCTL_OP_SET:
return mu_stream_set_buffer (stream, qp->buftype, qp->bufsize);
default:
return EINVAL;
}
}
break;
default:
return ENOSYS;
......
......@@ -108,11 +108,14 @@ _nullstream_truncate (struct _mu_stream *str, mu_off_t size)
}
static int
_nullstream_ctl (struct _mu_stream *str, int op, void *arg)
_nullstream_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_nullstream *np = (struct _mu_nullstream *)str;
switch (op)
if (code != MU_IOCTL_NULLSTREAM)
/* Only this code is supported */
return ENOSYS;
switch (opcode)
{
case MU_IOCTL_NULLSTREAM_SET_PATTERN:
if (!arg)
......
......@@ -352,33 +352,54 @@ _prog_flush (mu_stream_t stream)
}
static int
_prog_ioctl (struct _mu_stream *str, int code, void *ptr)
_prog_ioctl (struct _mu_stream *str, int code, int opcode, void *ptr)
{
struct _mu_prog_stream *fstr = (struct _mu_prog_stream *) str;
mu_transport_t t[2];
mu_transport_t *ptrans;
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!ptr)
return EINVAL;
mu_stream_ioctl (fstr->in, MU_IOCTL_GET_TRANSPORT, t);
else
{
mu_transport_t *ptrans = ptr;
mu_transport_t t[2];
switch (opcode)
{
case MU_IOCTL_OP_GET:
mu_stream_ioctl (fstr->in, MU_IOCTL_TRANSPORT,
MU_IOCTL_OP_GET, t);
ptrans[0] = t[0];
mu_stream_ioctl (fstr->out, MU_IOCTL_GET_TRANSPORT, t);
mu_stream_ioctl (fstr->out, MU_IOCTL_TRANSPORT,
MU_IOCTL_OP_GET, t);
ptrans[1] = t[1];
break;
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
}
break;
case MU_IOCTL_GET_STATUS:
case MU_IOCTL_PROGSTREAM:
if (!ptr)
return EINVAL;
switch (opcode)
{
case MU_IOCTL_PROG_STATUS:
*(int*)ptr = fstr->status;
break;
case MU_IOCTL_GET_PID:
if (!ptr)
case MU_IOCTL_PROG_PID:
*(pid_t*)ptr = fstr->pid;
break;
default:
return EINVAL;
*(int*)ptr = fstr->pid;
}
break;
default:
......
......@@ -116,23 +116,34 @@ rdcache_wait (struct _mu_stream *str, int *pflags, struct timeval *tvp)
/* FIXME: Truncate? */
static int
rdcache_ioctl (struct _mu_stream *str, int op, void *arg)
rdcache_ioctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_rdcache_stream *sp = (struct _mu_rdcache_stream *) str;
mu_transport_t *ptrans;
switch (op)
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!arg)
return EINVAL;
ptrans = arg;
else
{
mu_transport_t *ptrans = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) sp->transport;
ptrans[1] = NULL;
break;
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
}
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
case MU_IOCTL_SET_TRANSPORT_BUFFER:
case MU_IOCTL_TRANSPORT_BUFFER:
if (!arg)
return EINVAL;
else
......@@ -140,7 +151,7 @@ rdcache_ioctl (struct _mu_stream *str, int op, void *arg)
struct mu_buffer_query *qp = arg;
if (qp->type != MU_TRANSPORT_INPUT || !sp->transport)
return EINVAL;
return mu_stream_ioctl (sp->transport, op, arg);
return mu_stream_ioctl (sp->transport, code, opcode, arg);
}
default:
......
......@@ -1124,11 +1124,11 @@ mu_stream_size (mu_stream_t stream, mu_off_t *psize)
}
int
mu_stream_ioctl (mu_stream_t stream, int code, void *ptr)
mu_stream_ioctl (mu_stream_t stream, int family, int opcode, void *ptr)
{
if (stream->ctl == NULL)
return ENOSYS;
return stream->ctl (stream, code, ptr);
return stream->ctl (stream, family, opcode, ptr);
}
int
......@@ -1150,7 +1150,7 @@ mu_stream_wait (mu_stream_t stream, int *pflags, struct timeval *tvp)
_stream_init (stream);
}
#endif
/* Take to acount if we have any buffering. */
/* Take into account if we have any buffering. */
/* FIXME: How about MU_STREAM_READY_WR? */
if ((*pflags) & MU_STREAM_READY_RD
&& stream->buftype != mu_buffer_none
......
......@@ -201,30 +201,38 @@ _streamref_size (struct _mu_stream *str, mu_off_t *psize)
}
static int
_streamref_ctl (struct _mu_stream *str, int op, void *arg)
_streamref_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_streamref *sp = (struct _mu_streamref *)str;
mu_off_t *lim;
switch (op)
switch (code)
{
case MU_IOCTL_ABRIDGE_SEEK:
case MU_IOCTL_SEEK_LIMITS:
if (!arg)
return EINVAL;
lim = arg;
else
{
mu_off_t *lim;
switch (opcode)
{
case MU_IOCTL_OP_GET:
lim[0] = sp->start;
lim[1] = sp->end;
return 0;
case MU_IOCTL_OP_SET:
sp->start = lim[0];
sp->end = lim[1];
return 0;
case MU_IOCTL_GET_SEEK_LIMITS:
if (!arg)
default:
return EINVAL;
lim = arg;
lim[0] = sp->start;
lim[1] = sp->end;
return 0;
}
return streamref_return (sp, mu_stream_ioctl (sp->transport, op, arg));
}
}
return streamref_return (sp, mu_stream_ioctl (sp->transport, code,
opcode, arg));
}
static int
......
......@@ -52,12 +52,15 @@ static int sev2prio[] = {
};
static int
_syslog_ctl (struct _mu_stream *str, int op, void *arg)
_syslog_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_syslog_stream *sp = (struct _mu_syslog_stream *)str;
unsigned n;
switch (op)
if (code != MU_IOCTL_LOGSTREAM)
return ENOSYS;
switch (opcode)
{
case MU_IOCTL_LOGSTREAM_GET_SEVERITY:
if (!arg)
......
......@@ -193,20 +193,31 @@ _tcp_open (mu_stream_t stream)
}
static int
_tcp_ioctl (mu_stream_t stream, int code, void *ptr)
_tcp_ioctl (mu_stream_t stream, int code, int opcode, void *ptr)
{
struct _tcp_instance *tcp = (struct _tcp_instance *)stream;
mu_transport_t *ptrans;
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!ptr)
return EINVAL;
ptrans = ptr;
else
{
mu_transport_t *ptrans = ptr;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) tcp->fd;
ptrans[1] = NULL;
break;
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
}
break;
default:
return ENOSYS;
......
......@@ -254,25 +254,27 @@ _xscript_size (struct _mu_stream *str, mu_off_t *psize)
}
static int
_xscript_ctl (struct _mu_stream *str, int op, void *arg)
_xscript_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
{
struct _mu_xscript_stream *sp = (struct _mu_xscript_stream *)str;
mu_transport_t *ptrans;
int status = 0;
switch (op)
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!arg)
return EINVAL;
ptrans = arg;
else
{
mu_transport_t *ptrans = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) sp->transport;
ptrans[1] = (mu_transport_t) sp->logstr;
break;
case MU_IOCTL_SET_TRANSPORT:
if (!arg)
return EINVAL;
case MU_IOCTL_OP_SET:
ptrans = arg;
if (ptrans[0])
sp->transport = (mu_stream_t) ptrans[0];
......@@ -280,13 +282,22 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg)
sp->logstr = (mu_stream_t) ptrans[1];
break;
case MU_IOCTL_GET_STREAM:
default:
return EINVAL;
}
}
break;
case MU_IOCTL_SUBSTREAM:
if (!arg)
return EINVAL;
switch (opcode)
{
case MU_IOCTL_OP_GET:
if (!sp->transport)
status = ENOSYS;
else
status = mu_stream_ioctl (sp->transport, op, arg);
status = mu_stream_ioctl (sp->transport, code, opcode, arg);
if (status == EINVAL || status == ENOSYS)
{
mu_stream_t *pstr = arg;
......@@ -299,13 +310,11 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg)
}
break;
case MU_IOCTL_SET_STREAM:
if (!arg)
return EINVAL;
case MU_IOCTL_OP_SET:
if (!sp->transport)
status = ENOSYS;
else
status = mu_stream_ioctl (sp->transport, op, arg);
status = mu_stream_ioctl (sp->transport, code, opcode, arg);
if (status == EINVAL || status == ENOSYS)
{
mu_stream_t *pstr = arg;
......@@ -329,20 +338,20 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg)
mu_stream_unref (sp->transport);
sp->transport = tmp;
}
}
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
case MU_IOCTL_SET_TRANSPORT_BUFFER:
{
case MU_IOCTL_TRANSPORT_BUFFER:
if (!sp->transport)
return EINVAL;
return mu_stream_ioctl (sp->transport, op, arg);
}
return mu_stream_ioctl (sp->transport, code, opcode, arg);
case MU_IOCTL_LEVEL:
case MU_IOCTL_XSCRIPTSTREAM:
if (!arg)
return EINVAL;
else
switch (opcode)
{
case MU_IOCTL_XSCRIPTSTREAM_LEVEL:
{
int oldlev = sp->level;
sp->level = *(int*)arg;
......@@ -351,9 +360,13 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg)
*(int*)arg = oldlev;
}
break;
default:
return EINVAL;
}
break;
default:
return mu_stream_ioctl (sp->transport, op, arg);
return mu_stream_ioctl (sp->transport, code, opcode, arg);
}
return status;
}
......
......@@ -262,21 +262,34 @@ _tls_wr_wait (struct _mu_stream *stream, int *pflags, struct timeval *tvp)
}
static int
_tls_io_ioctl (struct _mu_stream *stream, int op, void *arg)
_tls_io_ioctl (struct _mu_stream *stream, int code, int opcode, void *arg)
{
struct _mu_tls_io_stream *sp = (struct _mu_tls_io_stream *) stream;
mu_transport_t *ptrans;
switch (op)
switch (code)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
if (!arg)
return EINVAL;
ptrans = arg;
else
{
mu_transport_t *ptrans = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
ptrans[0] = (mu_transport_t) sp->transport;
ptrans[1] = NULL;
break;
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
}
break;
default:
return ENOSYS;
}
......@@ -387,7 +400,7 @@ _tls_server_open (mu_stream_t stream)
gnutls_certificate_set_dh_params (x509_cred, dh_params);
sp->session = initialize_tls_session ();
mu_stream_ioctl (stream, MU_IOCTL_GET_TRANSPORT, transport);
mu_stream_ioctl (stream, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, transport);
gnutls_transport_set_ptr2 (sp->session,
(gnutls_transport_ptr) transport[0],
(gnutls_transport_ptr) transport[1]);
......@@ -441,7 +454,7 @@ prepare_client_session (mu_stream_t stream)
gnutls_credentials_set (sp->session, GNUTLS_CRD_CERTIFICATE, x509_cred);
mu_stream_ioctl (stream, MU_IOCTL_GET_TRANSPORT, transport);
mu_stream_ioctl (stream, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, transport);
gnutls_transport_set_ptr2 (sp->session,
(gnutls_transport_ptr) transport[0],
(gnutls_transport_ptr) transport[1]);
......@@ -503,13 +516,16 @@ _tls_write (struct _mu_stream *str, const char *buf, size_t bufsize,
}
static int
_tls_ioctl (struct _mu_stream *stream, int op, void *arg)
_tls_ioctl (struct _mu_stream *stream, int code, int opcode, void *arg)
{
struct _mu_tls_stream *sp = (struct _mu_tls_stream *) stream;
switch (op)
switch (opcode)
{
case MU_IOCTL_GET_TRANSPORT:
case MU_IOCTL_TRANSPORT:
switch (opcode)
{
case MU_IOCTL_OP_GET:
if (!arg)
return EINVAL;
else
......@@ -517,41 +533,53 @@ _tls_ioctl (struct _mu_stream *stream, int op, void *arg)
mu_transport_t *ptrans, trans[2];
ptrans = arg;
mu_stream_ioctl (sp->transport[0], MU_IOCTL_GET_TRANSPORT, trans);
mu_stream_ioctl (sp->transport[0], MU_IOCTL_TRANSPORT,
MU_IOCTL_OP_GET, trans);
ptrans[0] = trans[0];
mu_stream_ioctl (sp->transport[1], MU_IOCTL_GET_TRANSPORT, trans);
mu_stream_ioctl (sp->transport[1], MU_IOCTL_TRANSPORT,
MU_IOCTL_OP_GET, trans);
ptrans[1] = trans[0];
}
break;
case MU_IOCTL_GET_TRANSPORT_BUFFER:
case MU_IOCTL_OP_SET:
return ENOSYS;
default:
return EINVAL;
}
break;
case MU_IOCTL_TRANSPORT_BUFFER:
if (!arg)
return EINVAL;
else
{
struct mu_buffer_query *qp = arg;
switch (opcode)
{
case MU_IOCTL_OP_GET:
if (!MU_TRANSPORT_VALID_TYPE (qp->type) ||
!sp->transport[qp->type])
return EINVAL;
return mu_stream_get_buffer (sp->transport[qp->type], qp);
}
case MU_IOCTL_SET_TRANSPORT_BUFFER:
if (!arg)
return EINVAL;
else
{
struct mu_buffer_query *qp = arg;
case MU_IOCTL_OP_SET:
if (!MU_TRANSPORT_VALID_TYPE (qp->type) ||
!sp->transport[qp->type])
return EINVAL;
return mu_stream_set_buffer (sp->transport[qp->type],
qp->buftype, qp->bufsize);
}
default:
return EINVAL;
}
}
break;
default:
return ENOSYS;
}
return 0;
}
......
......@@ -42,7 +42,8 @@ void
_mu_sv_instr_source (mu_sieve_machine_t mach)
{
mach->locus.mu_file = (char*) SIEVE_ARG (mach, 0, string);
mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM_SET_LOCUS,
mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS,
&mach->locus);
if (INSTR_DEBUG (mach))
mu_sieve_debug (mach, "%4lu: SOURCE %s",
......@@ -55,7 +56,8 @@ void
_mu_sv_instr_line (mu_sieve_machine_t mach)
{
mach->locus.mu_line = SIEVE_ARG (mach, 0, line);
mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM_SET_LOCUS,
mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS,
&mach->locus);
if (INSTR_DEBUG (mach))
mu_sieve_debug (mach, "%4lu: LINE %u",
......
......@@ -536,7 +536,8 @@ mu_sieve_machine_destroy (mu_sieve_machine_t *pmach)
{
mu_sieve_machine_t mach = *pmach;
/* FIXME: Restore stream state (locus & mode) */
mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL);
mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL);
mu_stream_destroy (&mach->errstream);
mu_mailer_destroy (&mach->mailer);
mu_list_do (mach->destr_list, _run_destructor, NULL);
......
......@@ -192,7 +192,8 @@ mu_sv_compile_error (struct mu_locus *ploc, const char *fmt, ...)
va_start (ap, fmt);
mu_sieve_error_count++;
mu_stream_ioctl (mu_sieve_machine->errstream, MU_IOCTL_LOGSTREAM_SET_LOCUS,
mu_stream_ioctl (mu_sieve_machine->errstream,
MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS,
ploc);
mu_stream_printf (mu_sieve_machine->errstream,
"\033s<%d>\033O<%d>",
......
......@@ -76,7 +76,7 @@ _mu_imap_trace_disable (mu_imap_t imap)
if (!xstr)
return 0;
rc = mu_stream_ioctl (xstr, MU_IOCTL_GET_TRANSPORT, stream);
rc = mu_stream_ioctl (xstr, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, stream);
if (rc)
return rc;
......@@ -138,7 +138,8 @@ mu_imap_trace_mask (mu_imap_t imap, int op, int lev)
int
_mu_imap_xscript_level (mu_imap_t imap, int xlev)
{
if (mu_stream_ioctl (imap->carrier, MU_IOCTL_LEVEL, &xlev) == 0)
if (mu_stream_ioctl (imap->carrier, MU_IOCTL_XSCRIPTSTREAM,
MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0)
return xlev;
return MU_XSCRIPT_NORMAL;
}
......
......@@ -47,15 +47,15 @@ _mu_smtp_data_begin (mu_smtp_t smtp)
_mu_smtp_xscript_level (smtp, MU_XSCRIPT_PAYLOAD);
smtp->savebuf.type = MU_TRANSPORT_OUTPUT;
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_GET_TRANSPORT_BUFFER,
&smtp->savebuf) == 0)
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_TRANSPORT_BUFFER,
MU_IOCTL_OP_GET, &smtp->savebuf) == 0)
{
struct mu_buffer_query newbuf;
newbuf.type = MU_TRANSPORT_OUTPUT;
newbuf.buftype = mu_buffer_full;
newbuf.bufsize = 64*1024;
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_SET_TRANSPORT_BUFFER,
&newbuf) == 0)
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_TRANSPORT_BUFFER,
MU_IOCTL_OP_SET, &newbuf) == 0)
MU_SMTP_FSET (smtp, _MU_SMTP_SAVEBUF);
}
return 0;
......@@ -68,8 +68,8 @@ _mu_smtp_data_end (mu_smtp_t smtp)
/* code is always _MU_STR_EVENT_CLOSE */
if (MU_SMTP_FISSET (smtp, _MU_SMTP_SAVEBUF))
{
status = mu_stream_ioctl (smtp->carrier, MU_IOCTL_SET_TRANSPORT_BUFFER,
&smtp->savebuf);
status = mu_stream_ioctl (smtp->carrier, MU_IOCTL_TRANSPORT_BUFFER,
MU_IOCTL_OP_SET, &smtp->savebuf);
if (status)
mu_diag_output (MU_DIAG_NOTICE,
"failed to restore buffer state on SMTP carrier: %s",
......
......@@ -33,7 +33,8 @@ _mu_smtp_get_streams (mu_smtp_t smtp, mu_stream_t *streams)
int rc;
if (MU_SMTP_FISSET (smtp, _MU_SMTP_TRACE))
rc = mu_stream_ioctl (smtp->carrier, MU_IOCTL_GET_STREAM, streams);
rc = mu_stream_ioctl (smtp->carrier, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_GET,
streams);
else
{
streams[0] = smtp->carrier;
......@@ -51,7 +52,8 @@ _mu_smtp_set_streams (mu_smtp_t smtp, mu_stream_t *streams)
int rc;
if (MU_SMTP_FISSET (smtp, _MU_SMTP_TRACE))
rc = mu_stream_ioctl (smtp->carrier, MU_IOCTL_SET_STREAM, streams);
rc = mu_stream_ioctl (smtp->carrier, MU_IOCTL_SUBSTREAM, MU_IOCTL_OP_SET,
streams);
else
{
mu_stream_t tmp;
......
......@@ -75,7 +75,7 @@ _mu_smtp_trace_disable (mu_smtp_t smtp)
if (!xstr)
return 0;
rc = mu_stream_ioctl (xstr, MU_IOCTL_GET_TRANSPORT, stream);
rc = mu_stream_ioctl (xstr, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, stream);
if (rc)
return rc;
......@@ -137,7 +137,8 @@ mu_smtp_trace_mask (mu_smtp_t smtp, int op, int lev)
int
_mu_smtp_xscript_level (mu_smtp_t smtp, int xlev)
{
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_LEVEL, &xlev) == 0)
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_XSCRIPTSTREAM,
MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0)
return xlev;
return MU_XSCRIPT_NORMAL;
}
......
......@@ -35,7 +35,8 @@ pop3_get_streams (mu_pop3_t pop3, mu_stream_t *streams)
int rc;
if (MU_POP3_FISSET (pop3, MU_POP3_TRACE))
rc = mu_stream_ioctl (pop3->carrier, MU_IOCTL_GET_STREAM, streams);
rc = mu_stream_ioctl (pop3->carrier, MU_IOCTL_SUBSTREAM,
MU_IOCTL_OP_GET, streams);
else
{
streams[0] = pop3->carrier;
......@@ -53,7 +54,8 @@ pop3_set_streams (mu_pop3_t pop3, mu_stream_t *streams)
int rc;
if (MU_POP3_FISSET (pop3, MU_POP3_TRACE))
rc = mu_stream_ioctl (pop3->carrier, MU_IOCTL_SET_STREAM, streams);
rc = mu_stream_ioctl (pop3->carrier, MU_IOCTL_SUBSTREAM,
MU_IOCTL_OP_SET, streams);
else
{
mu_stream_t tmp;
......
......@@ -49,7 +49,8 @@ _pop3_event_cb (mu_stream_t str, int ev, unsigned long flags,
{
mu_transport_t trans[2];
if (mu_stream_ioctl (str, MU_IOCTL_GET_TRANSPORT, trans) == 0)
if (mu_stream_ioctl (str, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET,
trans) == 0)
{
struct mu_pop3_stream *sp = (struct mu_pop3_stream *) trans[0];
_mu_pop3_xscript_level (sp->pop3, MU_XSCRIPT_NORMAL);
......@@ -58,7 +59,7 @@ _pop3_event_cb (mu_stream_t str, int ev, unsigned long flags,
if (sp->flags & _POP3F_CHBUF)
{
mu_stream_ioctl (sp->pop3->carrier,
MU_IOCTL_SET_TRANSPORT_BUFFER,
MU_IOCTL_TRANSPORT_BUFFER, MU_IOCTL_OP_SET,
&sp->oldbuf);
sp->flags = _POP3F_DONE;
}
......@@ -82,7 +83,8 @@ mu_pop3_filter_create (mu_stream_t *pstream, mu_stream_t stream)
str->event_mask = _MU_STR_EVMASK(_MU_STR_EVENT_SETFLAG);
sp->oldbuf.type = MU_TRANSPORT_OUTPUT;
if (mu_stream_ioctl (sp->pop3->carrier, MU_IOCTL_GET_TRANSPORT_BUFFER,
if (mu_stream_ioctl (sp->pop3->carrier, MU_IOCTL_TRANSPORT_BUFFER,
MU_IOCTL_OP_GET,
&sp->oldbuf) == 0)
{
struct mu_buffer_query newbuf;
......@@ -91,7 +93,8 @@ mu_pop3_filter_create (mu_stream_t *pstream, mu_stream_t stream)
newbuf.type = MU_TRANSPORT_OUTPUT;
newbuf.buftype = mu_buffer_full;
newbuf.bufsize = 64*1024;
mu_stream_ioctl (sp->pop3->carrier, MU_IOCTL_SET_TRANSPORT_BUFFER,
mu_stream_ioctl (sp->pop3->carrier, MU_IOCTL_TRANSPORT_BUFFER,
MU_IOCTL_OP_SET,
&newbuf);
}
}
......
......@@ -76,7 +76,7 @@ _mu_pop3_trace_disable (mu_pop3_t pop3)
if (!xstr)
return 0;
rc = mu_stream_ioctl (xstr, MU_IOCTL_GET_TRANSPORT, stream);
rc = mu_stream_ioctl (xstr, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, stream);
if (rc)
return rc;
......@@ -138,7 +138,8 @@ mu_pop3_trace_mask (mu_pop3_t pop3, int op, int lev)
int
_mu_pop3_xscript_level (mu_pop3_t pop3, int xlev)
{
if (mu_stream_ioctl (pop3->carrier, MU_IOCTL_LEVEL, &xlev) == 0)
if (mu_stream_ioctl (pop3->carrier, MU_IOCTL_XSCRIPTSTREAM,
MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0)
return xlev;
return MU_XSCRIPT_NORMAL;
}
......
......@@ -385,25 +385,30 @@ cfun_data (mu_stream_t iostr, char *arg)
lmtp_reply (iostr, "354", NULL, "Go ahead");
if (mu_stream_ioctl (iostr, MU_IOCTL_GET_TRANSPORT_BUFFER, &oldbuf) == 0)
if (mu_stream_ioctl (iostr, MU_IOCTL_TRANSPORT_BUFFER,
MU_IOCTL_OP_GET, &oldbuf) == 0)
{
struct mu_buffer_query newbuf;
newbuf.type = MU_TRANSPORT_OUTPUT;
newbuf.buftype = mu_buffer_full;
newbuf.bufsize = 64*1024;
if (mu_stream_ioctl (iostr, MU_IOCTL_SET_TRANSPORT_BUFFER, &newbuf))
if (mu_stream_ioctl (iostr, MU_IOCTL_TRANSPORT_BUFFER, MU_IOCTL_OP_SET,
&newbuf))
buf_switch = 1;
}
if (mu_stream_ioctl (iostr, MU_IOCTL_LEVEL, &xlev) == 0)
if (mu_stream_ioctl (iostr, MU_IOCTL_XSCRIPTSTREAM,
MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0)
xlev_switch = 1;
rc = mu_stream_copy (tempstr, flt, 0, NULL);
mu_stream_destroy (&flt);
if (xlev_switch)
mu_stream_ioctl (iostr, MU_IOCTL_LEVEL, &xlev);
mu_stream_ioctl (iostr, MU_IOCTL_XSCRIPTSTREAM,
MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev);
if (buf_switch)
mu_stream_ioctl (iostr, MU_IOCTL_SET_TRANSPORT_BUFFER, &oldbuf);
mu_stream_ioctl (iostr, MU_IOCTL_TRANSPORT_BUFFER, MU_IOCTL_OP_SET,
&oldbuf);
if (rc)
{
maidag_error (_("copy error: %s"), mu_strerror (rc));
......
......@@ -27,7 +27,8 @@ source_readline (void *closure, int cont MU_ARG_UNUSED)
if (getline (&buf, &s, fp) >= 0)
{
mu_rtrim_class (buf, MU_CTYPE_SPACE);
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
return buf;
}
......@@ -65,10 +66,12 @@ mail_source (int argc, char **argv)
locus.mu_file = argv[1];
locus.mu_line = 0;
locus.mu_col = 0;
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);
mail_mainloop (source_readline, fp, 0);
interactive = save_term;
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);
fclose (fp);
return 0;
}
......
......@@ -168,10 +168,13 @@ mutool_logger (int argc, char **argv)
}
mode = MU_LOGMODE_SEVERITY | MU_LOGMODE_LOCUS;
mu_stream_ioctl (logger, MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
mu_stream_ioctl (logger, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
if (locus.mu_file)
mu_stream_ioctl (logger, MU_IOCTL_LOGSTREAM_SET_LOCUS, &locus);
mu_stream_ioctl (logger, MU_IOCTL_LOGSTREAM_SET_SEVERITY, &log_severity);
mu_stream_ioctl (logger, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS, &locus);
mu_stream_ioctl (logger, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_SEVERITY, &log_severity);
if (argc)
{
......
......@@ -187,7 +187,7 @@ pop3d_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",
......@@ -202,7 +202,7 @@ pop3d_init_tls_server ()
return 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);
mu_stream_unref (stream[0]);
mu_stream_unref (stream[1]);
if (rc)
......@@ -340,7 +340,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;
......
......@@ -27,12 +27,12 @@ pop3d_send_payload (mu_stream_t stream, mu_stream_t linestr, size_t maxlines)
int xscript_level = set_xscript_level (MU_XSCRIPT_PAYLOAD);
oldbuf.type = MU_TRANSPORT_OUTPUT;
mu_stream_ioctl (iostream, MU_IOCTL_GET_TRANSPORT_BUFFER,
mu_stream_ioctl (iostream, MU_IOCTL_TRANSPORT_BUFFER, MU_IOCTL_OP_GET,
&oldbuf);
newbuf.type = MU_TRANSPORT_OUTPUT;
newbuf.buftype = mu_buffer_full;
newbuf.bufsize = pop3d_output_bufsize;
mu_stream_ioctl (iostream, MU_IOCTL_SET_TRANSPORT_BUFFER,
mu_stream_ioctl (iostream, MU_IOCTL_TRANSPORT_BUFFER, MU_IOCTL_OP_SET,
&newbuf);
/* FIXME: Return code */
mu_filter_create (&flt, iostream, "DOT", MU_FILTER_ENCODE,
......@@ -56,7 +56,7 @@ pop3d_send_payload (mu_stream_t stream, mu_stream_t linestr, size_t maxlines)
mu_stream_close (flt);
mu_stream_destroy (&flt);
mu_stream_ioctl (iostream, MU_IOCTL_SET_TRANSPORT_BUFFER,
mu_stream_ioctl (iostream, MU_IOCTL_TRANSPORT_BUFFER, MU_IOCTL_OP_SET,
&oldbuf);
set_xscript_level (xscript_level);
}
......