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)); ...@@ -64,8 +64,12 @@ extern void stream_destroy __P ((stream_t *, void *owner));
64 extern int stream_open __P ((stream_t)); 64 extern int stream_open __P ((stream_t));
65 extern int stream_close __P ((stream_t)); 65 extern int stream_close __P ((stream_t));
66 extern int stream_is_seekable __P ((stream_t)); 66 extern int stream_is_seekable __P ((stream_t));
67 extern int stream_get_fd __P ((stream_t, int *)); 67 extern int stream_get_transport2 __P ((stream_t stream,
68 extern int stream_get_fd2 __P ((stream_t, int *, int *)); 68 mu_transport_t *pt,
69 mu_transport_t *pt2));
70 extern int stream_get_transport __P ((stream_t stream,
71 mu_transport_t *pt));
72
69 extern int stream_read __P ((stream_t, char *, size_t, off_t, 73 extern int stream_read __P ((stream_t, char *, size_t, off_t,
70 size_t *)); 74 size_t *));
71 extern int stream_readline __P ((stream_t, char *, size_t, off_t, 75 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, ...@@ -77,6 +81,9 @@ extern int stream_write __P ((stream_t, const char *, size_t, off_t,
77 extern int stream_setbufsiz __P ((stream_t stream, size_t size)); 81 extern int stream_setbufsiz __P ((stream_t stream, size_t size));
78 extern int stream_flush __P ((stream_t)); 82 extern int stream_flush __P ((stream_t));
79 83
84 #define MU_STREAM_READY_RD 0x1
85 #define MU_STREAM_READY_WR 0x2
86 extern int stream_wait __P((stream_t stream, int *pflags, struct timeval *));
80 87
81 /* Functions useful to implementors of new stream types. */ 88 /* Functions useful to implementors of new stream types. */
82 89
...@@ -107,8 +114,9 @@ extern int stream_set_open __P ((stream_t, ...@@ -107,8 +114,9 @@ extern int stream_set_open __P ((stream_t,
107 extern int stream_set_close __P ((stream_t, 114 extern int stream_set_close __P ((stream_t,
108 int (*_close) __PMT ((stream_t)), void *owner)); 115 int (*_close) __PMT ((stream_t)), void *owner));
109 116
110 extern int stream_set_fd __P ((stream_t, 117 extern int stream_set_get_transport2 __P ((stream_t,
111 int (*_get_fd) __PMT ((stream_t, int *, int *)), void *owner)); 118 int (*_get_fd) __PMT ((stream_t, mu_transport_t *, mu_transport_t *)),
119 void *owner));
112 120
113 extern int stream_set_read __P ((stream_t, 121 extern int stream_set_read __P ((stream_t,
114 int (*_read) __PMT ((stream_t, char *, size_t, off_t, size_t *)), 122 int (*_read) __PMT ((stream_t, char *, size_t, off_t, size_t *)),
...@@ -133,6 +141,9 @@ extern int stream_set_flush __P ((stream_t, ...@@ -133,6 +141,9 @@ extern int stream_set_flush __P ((stream_t,
133 141
134 extern int stream_set_strerror __P ((stream_t stream, 142 extern int stream_set_strerror __P ((stream_t stream,
135 int (*fp) (stream_t, char **), void *owner)); 143 int (*fp) (stream_t, char **), void *owner));
144
145 extern int stream_set_wait __P ((stream_t stream,
146 int (*wait) (stream_t, int *, struct timeval *), void *owner));
136 147
137 extern int stream_sequential_read __P((stream_t stream, 148 extern int stream_sequential_read __P((stream_t stream,
138 char *buf, size_t size, size_t *nbytes)); 149 char *buf, size_t size, size_t *nbytes));
......
...@@ -425,19 +425,19 @@ stream_write (stream_t os, const char *buf, size_t count, ...@@ -425,19 +425,19 @@ stream_write (stream_t os, const char *buf, size_t count,
425 } 425 }
426 426
427 int 427 int
428 stream_get_fd (stream_t stream, int *pfd) 428 stream_get_transport2 (stream_t stream,
429 mu_transport_t *p1, mu_transport_t *p2)
429 { 430 {
430 if (stream == NULL || stream->_get_fd == NULL) 431 if (stream == NULL || stream->_get_transport2 == NULL)
431 return EINVAL; 432 return EINVAL;
432 return stream->_get_fd (stream, pfd, NULL); 433 return stream->_get_transport2 (stream, p1, p2);
433 } 434 }
434 435
435 int 436 int
436 stream_get_fd2 (stream_t stream, int *pfd1, int *pfd2) 437 stream_get_transport (stream_t stream,
438 mu_transport_t *pt)
437 { 439 {
438 if (stream == NULL || stream->_get_fd == NULL) 440 return stream_get_transport2 (stream, pt, NULL);
439 return EINVAL;
440 return stream->_get_fd (stream, pfd1, pfd2);
441 } 441 }
442 442
443 int 443 int
...@@ -558,14 +558,15 @@ stream_set_close (stream_t stream, int (*_close) (stream_t), void *owner) ...@@ -558,14 +558,15 @@ stream_set_close (stream_t stream, int (*_close) (stream_t), void *owner)
558 } 558 }
559 559
560 int 560 int
561 stream_set_fd (stream_t stream, int (*_get_fd) (stream_t, int *, int *), 561 stream_set_get_transport2 (stream_t stream,
562 void *owner) 562 int (*_get_trans) (stream_t, mu_transport_t *, mu_transport_t *),
563 void *owner)
563 { 564 {
564 if (stream == NULL) 565 if (stream == NULL)
565 return EINVAL; 566 return EINVAL;
566 if (owner == stream->owner) 567 if (owner == stream->owner)
567 { 568 {
568 stream->_get_fd = _get_fd; 569 stream->_get_transport2 = _get_trans;
569 return 0; 570 return 0;
570 } 571 }
571 return EACCES; 572 return EACCES;
...@@ -673,6 +674,18 @@ stream_set_strerror (stream_t stream, ...@@ -673,6 +674,18 @@ stream_set_strerror (stream_t stream,
673 } 674 }
674 675
675 int 676 int
677 stream_set_wait (stream_t stream,
678 int (*wait) (stream_t, int *, struct timeval *), void *owner)
679 {
680 if (stream == NULL)
681 return EINVAL;
682 if (stream->owner != owner)
683 return EACCES;
684 stream->_wait = wait;
685 return 0;
686 }
687
688 int
676 stream_sequential_read (stream_t stream, char *buf, size_t size, 689 stream_sequential_read (stream_t stream, char *buf, size_t size,
677 size_t *nbytes) 690 size_t *nbytes)
678 { 691 {
...@@ -757,6 +770,16 @@ stream_seek (stream_t stream, off_t off, int whence) ...@@ -757,6 +770,16 @@ stream_seek (stream_t stream, off_t off, int whence)
757 } 770 }
758 771
759 int 772 int
773 stream_wait (stream_t stream, int *pflags, struct timeval *tvp)
774 {
775 if (stream == NULL)
776 return EINVAL;
777 if (stream->_wait)
778 return stream->_wait (stream, pflags, tvp);
779 return ENOSYS;
780 }
781
782 int
760 stream_strerror (stream_t stream, char **p) 783 stream_strerror (stream_t stream, char **p)
761 { 784 {
762 if (stream == NULL) 785 if (stream == NULL)
......