Fixed _get_fd methods.
Showing
7 changed files
with
44 additions
and
12 deletions
... | @@ -35,7 +35,7 @@ | ... | @@ -35,7 +35,7 @@ |
35 | #define BODY_MODIFIED 0x10000 | 35 | #define BODY_MODIFIED 0x10000 |
36 | 36 | ||
37 | static int _body_flush __P ((stream_t)); | 37 | static int _body_flush __P ((stream_t)); |
38 | static int _body_get_fd __P ((stream_t, int *)); | 38 | static int _body_get_fd __P ((stream_t, int *, int *)); |
39 | static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *)); | 39 | static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *)); |
40 | static int _body_readline __P ((stream_t, char *, size_t, off_t, size_t *)); | 40 | static int _body_readline __P ((stream_t, char *, size_t, off_t, size_t *)); |
41 | static int _body_truncate __P ((stream_t, off_t)); | 41 | static int _body_truncate __P ((stream_t, off_t)); |
... | @@ -241,10 +241,15 @@ body_set_size (body_t body, int (*_size)(body_t, size_t*) , void *owner) | ... | @@ -241,10 +241,15 @@ body_set_size (body_t body, int (*_size)(body_t, size_t*) , void *owner) |
241 | /* Stub function for the body stream. */ | 241 | /* Stub function for the body stream. */ |
242 | 242 | ||
243 | static int | 243 | static int |
244 | _body_get_fd (stream_t stream, int *fd) | 244 | _body_get_fd (stream_t stream, int *fd, int *fd2) |
245 | { | 245 | { |
246 | if (fd2) | ||
247 | return ENOSYS; | ||
248 | else | ||
249 | { | ||
246 | body_t body = stream_get_owner (stream); | 250 | body_t body = stream_get_owner (stream); |
247 | return stream_get_fd (body->fstream, fd); | 251 | return stream_get_fd (body->fstream, fd); |
252 | } | ||
248 | } | 253 | } |
249 | 254 | ||
250 | static int | 255 | static int | ... | ... |
... | @@ -314,10 +314,14 @@ _file_flush (stream_t stream) | ... | @@ -314,10 +314,14 @@ _file_flush (stream_t stream) |
314 | } | 314 | } |
315 | 315 | ||
316 | static int | 316 | static int |
317 | _file_get_fd (stream_t stream, int *pfd) | 317 | _file_get_fd (stream_t stream, int *pfd, int *pfd2) |
318 | { | 318 | { |
319 | struct _file_stream *fs = stream_get_owner (stream); | 319 | struct _file_stream *fs = stream_get_owner (stream); |
320 | int status = 0; | 320 | int status = 0; |
321 | |||
322 | if (pfd2) | ||
323 | return ENOSYS; | ||
324 | |||
321 | if (pfd) | 325 | if (pfd) |
322 | { | 326 | { |
323 | if (fs->file) | 327 | if (fs->file) | ... | ... |
... | @@ -111,10 +111,15 @@ filter_flush (stream_t stream) | ... | @@ -111,10 +111,15 @@ filter_flush (stream_t stream) |
111 | } | 111 | } |
112 | 112 | ||
113 | static int | 113 | static int |
114 | filter_get_fd (stream_t stream, int *pfd) | 114 | filter_get_fd (stream_t stream, int *pfd, int *pfd2) |
115 | { | 115 | { |
116 | if (pfd2) | ||
117 | return ENOSYS; | ||
118 | else | ||
119 | { | ||
116 | filter_t filter = stream_get_owner (stream); | 120 | filter_t filter = stream_get_owner (stream); |
117 | return stream_get_fd (filter->stream, pfd); | 121 | return stream_get_fd (filter->stream, pfd); |
122 | } | ||
118 | } | 123 | } |
119 | 124 | ||
120 | static int | 125 | static int | ... | ... |
... | @@ -77,7 +77,7 @@ static int mbox_append_message0 __P ((mailbox_t, message_t, off_t *, | ... | @@ -77,7 +77,7 @@ static int mbox_append_message0 __P ((mailbox_t, message_t, off_t *, |
77 | static int mbox_message_uid __P ((message_t, size_t *)); | 77 | static int mbox_message_uid __P ((message_t, size_t *)); |
78 | static int mbox_header_fill __P ((header_t, char *, size_t, off_t, | 78 | static int mbox_header_fill __P ((header_t, char *, size_t, off_t, |
79 | size_t *)); | 79 | size_t *)); |
80 | static int mbox_get_body_fd __P ((stream_t, int *)); | 80 | static int mbox_get_body_fd __P ((stream_t, int *, int *)); |
81 | static int mbox_get_fd __P ((mbox_message_t, int *)); | 81 | static int mbox_get_fd __P ((mbox_message_t, int *)); |
82 | static int mbox_get_attr_flags __P ((attribute_t, int *)); | 82 | static int mbox_get_attr_flags __P ((attribute_t, int *)); |
83 | static int mbox_set_attr_flags __P ((attribute_t, int)); | 83 | static int mbox_set_attr_flags __P ((attribute_t, int)); |
... | @@ -828,12 +828,17 @@ mbox_message_uid (message_t msg, size_t *puid) | ... | @@ -828,12 +828,17 @@ mbox_message_uid (message_t msg, size_t *puid) |
828 | } | 828 | } |
829 | 829 | ||
830 | static int | 830 | static int |
831 | mbox_get_body_fd (stream_t is, int *pfd) | 831 | mbox_get_body_fd (stream_t is, int *pfd, int *pfd2) |
832 | { | 832 | { |
833 | if (pfd2) | ||
834 | return ENOSYS; | ||
835 | else | ||
836 | { | ||
833 | body_t body = stream_get_owner (is); | 837 | body_t body = stream_get_owner (is); |
834 | message_t msg = body_get_owner (body); | 838 | message_t msg = body_get_owner (body); |
835 | mbox_message_t mum = message_get_owner (msg); | 839 | mbox_message_t mum = message_get_owner (msg); |
836 | return mbox_get_fd (mum, pfd); | 840 | return mbox_get_fd (mum, pfd); |
841 | } | ||
837 | } | 842 | } |
838 | 843 | ||
839 | static int | 844 | static int | ... | ... |
... | @@ -56,7 +56,7 @@ static int message_read __P ((stream_t is, char *buf, size_t buflen, | ... | @@ -56,7 +56,7 @@ static int message_read __P ((stream_t is, char *buf, size_t buflen, |
56 | off_t off, size_t *pnread )); | 56 | off_t off, size_t *pnread )); |
57 | static int message_write __P ((stream_t os, const char *buf, size_t buflen, | 57 | static int message_write __P ((stream_t os, const char *buf, size_t buflen, |
58 | off_t off, size_t *pnwrite)); | 58 | off_t off, size_t *pnwrite)); |
59 | static int message_get_fd __P ((stream_t stream, int *pfd)); | 59 | static int message_get_fd __P ((stream_t stream, int *pfd, int *pfd2)); |
60 | static int message_sender __P ((envelope_t envelope, char *buf, size_t len, | 60 | static int message_sender __P ((envelope_t envelope, char *buf, size_t len, |
61 | size_t *pnwrite)); | 61 | size_t *pnwrite)); |
62 | static int message_date __P ((envelope_t envelope, char *buf, size_t len, | 62 | static int message_date __P ((envelope_t envelope, char *buf, size_t len, |
... | @@ -882,7 +882,7 @@ message_write (stream_t os, const char *buf, size_t buflen, | ... | @@ -882,7 +882,7 @@ message_write (stream_t os, const char *buf, size_t buflen, |
882 | 882 | ||
883 | /* Implements the stream_get_fd () on the message stream. */ | 883 | /* Implements the stream_get_fd () on the message stream. */ |
884 | static int | 884 | static int |
885 | message_get_fd (stream_t stream, int *pfd) | 885 | message_get_fd (stream_t stream, int *pfd, int *pfd2) |
886 | { | 886 | { |
887 | message_t msg = stream_get_owner (stream); | 887 | message_t msg = stream_get_owner (stream); |
888 | body_t body; | 888 | body_t body; |
... | @@ -890,6 +890,8 @@ message_get_fd (stream_t stream, int *pfd) | ... | @@ -890,6 +890,8 @@ message_get_fd (stream_t stream, int *pfd) |
890 | 890 | ||
891 | if (msg == NULL) | 891 | if (msg == NULL) |
892 | return EINVAL; | 892 | return EINVAL; |
893 | if (pfd2) | ||
894 | return ENOSYS; | ||
893 | 895 | ||
894 | /* Probably being lazy, then create a body for the stream. */ | 896 | /* Probably being lazy, then create a body for the stream. */ |
895 | if (msg->body == NULL) | 897 | if (msg->body == NULL) | ... | ... |
... | @@ -432,13 +432,17 @@ _mimepart_body_read (stream_t stream, char *buf, size_t buflen, off_t off, | ... | @@ -432,13 +432,17 @@ _mimepart_body_read (stream_t stream, char *buf, size_t buflen, off_t off, |
432 | } | 432 | } |
433 | 433 | ||
434 | static int | 434 | static int |
435 | _mimepart_body_fd (stream_t stream, int *fd) | 435 | _mimepart_body_fd (stream_t stream, int *fd, int *fd2) |
436 | { | 436 | { |
437 | if (fd2) | ||
438 | return ENOSYS; | ||
439 | else | ||
440 | { | ||
437 | body_t body = stream_get_owner (stream); | 441 | body_t body = stream_get_owner (stream); |
438 | message_t msg = body_get_owner (body); | 442 | message_t msg = body_get_owner (body); |
439 | struct _mime_part *mime_part = message_get_owner (msg); | 443 | struct _mime_part *mime_part = message_get_owner (msg); |
440 | |||
441 | return stream_get_fd (mime_part->mime->stream, fd); | 444 | return stream_get_fd (mime_part->mime->stream, fd); |
445 | } | ||
442 | } | 446 | } |
443 | 447 | ||
444 | static int | 448 | static int |
... | @@ -657,8 +661,12 @@ _mime_body_read (stream_t stream, char *buf, size_t buflen, off_t off, | ... | @@ -657,8 +661,12 @@ _mime_body_read (stream_t stream, char *buf, size_t buflen, off_t off, |
657 | } | 661 | } |
658 | 662 | ||
659 | static int | 663 | static int |
660 | _mime_body_fd (stream_t stream, int *fd) | 664 | _mime_body_fd (stream_t stream, int *fd, int *fd2) |
661 | { | 665 | { |
666 | if (fd2) | ||
667 | return ENOSYS; | ||
668 | else | ||
669 | { | ||
662 | body_t body = stream_get_owner (stream); | 670 | body_t body = stream_get_owner (stream); |
663 | message_t msg = body_get_owner (body); | 671 | message_t msg = body_get_owner (body); |
664 | mime_t mime = message_get_owner (msg); | 672 | mime_t mime = message_get_owner (msg); |
... | @@ -668,6 +676,7 @@ _mime_body_fd (stream_t stream, int *fd) | ... | @@ -668,6 +676,7 @@ _mime_body_fd (stream_t stream, int *fd) |
668 | return EINVAL; | 676 | return EINVAL; |
669 | message_get_stream (mime->mtp_parts[mime->cur_part]->msg, &msg_stream); | 677 | message_get_stream (mime->mtp_parts[mime->cur_part]->msg, &msg_stream); |
670 | return stream_get_fd (msg_stream, fd); | 678 | return stream_get_fd (msg_stream, fd); |
679 | } | ||
671 | } | 680 | } |
672 | 681 | ||
673 | static int | 682 | static int | ... | ... |
... | @@ -150,12 +150,14 @@ _tcp_open (stream_t stream) | ... | @@ -150,12 +150,14 @@ _tcp_open (stream_t stream) |
150 | 150 | ||
151 | 151 | ||
152 | static int | 152 | static int |
153 | _tcp_get_fd (stream_t stream, int *fd) | 153 | _tcp_get_fd (stream_t stream, int *fd, int *fd2) |
154 | { | 154 | { |
155 | struct _tcp_instance *tcp = stream_get_owner (stream); | 155 | struct _tcp_instance *tcp = stream_get_owner (stream); |
156 | 156 | ||
157 | if (fd == NULL || tcp->fd == -1) | 157 | if (fd == NULL || tcp->fd == -1) |
158 | return EINVAL; | 158 | return EINVAL; |
159 | if (fd2) | ||
160 | return ENOSYS; | ||
159 | 161 | ||
160 | *fd = tcp->fd; | 162 | *fd = tcp->fd; |
161 | return 0; | 163 | return 0; | ... | ... |
-
Please register or sign in to post a comment