Commit 79e940c6 79e940c6fdbd58fe15e72d4daa9059dc099a1220 by Sergey Poznyakoff

(stream_get_fd)

(stream_get_fd2,stream_set_fd): Removed
(stream_get_transport2,stream_get_transport)
(stream_wait,stream_set_get_transport2)
(stream_set_wait): New functions
1 parent 96ce3ce6
......@@ -64,8 +64,12 @@ extern void stream_destroy __P ((stream_t *, void *owner));
extern int stream_open __P ((stream_t));
extern int stream_close __P ((stream_t));
extern int stream_is_seekable __P ((stream_t));
extern int stream_get_fd __P ((stream_t, int *));
extern int stream_get_fd2 __P ((stream_t, int *, int *));
extern int stream_get_transport2 __P ((stream_t stream,
mu_transport_t *pt,
mu_transport_t *pt2));
extern int stream_get_transport __P ((stream_t stream,
mu_transport_t *pt));
extern int stream_read __P ((stream_t, char *, size_t, off_t,
size_t *));
extern int stream_readline __P ((stream_t, char *, size_t, off_t,
......@@ -77,6 +81,9 @@ extern int stream_write __P ((stream_t, const char *, size_t, off_t,
extern int stream_setbufsiz __P ((stream_t stream, size_t size));
extern int stream_flush __P ((stream_t));
#define MU_STREAM_READY_RD 0x1
#define MU_STREAM_READY_WR 0x2
extern int stream_wait __P((stream_t stream, int *pflags, struct timeval *));
/* Functions useful to implementors of new stream types. */
......@@ -107,8 +114,9 @@ extern int stream_set_open __P ((stream_t,
extern int stream_set_close __P ((stream_t,
int (*_close) __PMT ((stream_t)), void *owner));
extern int stream_set_fd __P ((stream_t,
int (*_get_fd) __PMT ((stream_t, int *, int *)), void *owner));
extern int stream_set_get_transport2 __P ((stream_t,
int (*_get_fd) __PMT ((stream_t, mu_transport_t *, mu_transport_t *)),
void *owner));
extern int stream_set_read __P ((stream_t,
int (*_read) __PMT ((stream_t, char *, size_t, off_t, size_t *)),
......@@ -133,6 +141,9 @@ extern int stream_set_flush __P ((stream_t,
extern int stream_set_strerror __P ((stream_t stream,
int (*fp) (stream_t, char **), void *owner));
extern int stream_set_wait __P ((stream_t stream,
int (*wait) (stream_t, int *, struct timeval *), void *owner));
extern int stream_sequential_read __P((stream_t stream,
char *buf, size_t size, size_t *nbytes));
......
......@@ -425,19 +425,19 @@ stream_write (stream_t os, const char *buf, size_t count,
}
int
stream_get_fd (stream_t stream, int *pfd)
stream_get_transport2 (stream_t stream,
mu_transport_t *p1, mu_transport_t *p2)
{
if (stream == NULL || stream->_get_fd == NULL)
if (stream == NULL || stream->_get_transport2 == NULL)
return EINVAL;
return stream->_get_fd (stream, pfd, NULL);
return stream->_get_transport2 (stream, p1, p2);
}
int
stream_get_fd2 (stream_t stream, int *pfd1, int *pfd2)
stream_get_transport (stream_t stream,
mu_transport_t *pt)
{
if (stream == NULL || stream->_get_fd == NULL)
return EINVAL;
return stream->_get_fd (stream, pfd1, pfd2);
return stream_get_transport2 (stream, pt, NULL);
}
int
......@@ -558,14 +558,15 @@ stream_set_close (stream_t stream, int (*_close) (stream_t), void *owner)
}
int
stream_set_fd (stream_t stream, int (*_get_fd) (stream_t, int *, int *),
void *owner)
stream_set_get_transport2 (stream_t stream,
int (*_get_trans) (stream_t, mu_transport_t *, mu_transport_t *),
void *owner)
{
if (stream == NULL)
return EINVAL;
if (owner == stream->owner)
{
stream->_get_fd = _get_fd;
stream->_get_transport2 = _get_trans;
return 0;
}
return EACCES;
......@@ -673,6 +674,18 @@ stream_set_strerror (stream_t stream,
}
int
stream_set_wait (stream_t stream,
int (*wait) (stream_t, int *, struct timeval *), void *owner)
{
if (stream == NULL)
return EINVAL;
if (stream->owner != owner)
return EACCES;
stream->_wait = wait;
return 0;
}
int
stream_sequential_read (stream_t stream, char *buf, size_t size,
size_t *nbytes)
{
......@@ -757,6 +770,16 @@ stream_seek (stream_t stream, off_t off, int whence)
}
int
stream_wait (stream_t stream, int *pflags, struct timeval *tvp)
{
if (stream == NULL)
return EINVAL;
if (stream->_wait)
return stream->_wait (stream, pflags, tvp);
return ENOSYS;
}
int
stream_strerror (stream_t stream, char **p)
{
if (stream == NULL)
......