~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/lib-mail/istream-dot.c

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2007-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "istream-private.h"
24
24
static int i_stream_dot_read_some(struct dot_istream *dstream)
25
25
{
26
26
        struct istream_private *stream = &dstream->istream;
27
 
        size_t size;
 
27
        size_t size, avail;
28
28
        ssize_t ret;
29
29
 
30
 
        (void)i_stream_get_data(stream->parent, &size);
 
30
        size = i_stream_get_data_size(stream->parent);
31
31
        if (size == 0) {
32
32
                ret = i_stream_read(stream->parent);
33
33
                if (ret <= 0 && (ret != -2 || stream->skip == 0)) {
40
40
                        }
41
41
                        return ret;
42
42
                }
43
 
                (void)i_stream_get_data(stream->parent, &size);
 
43
                size = i_stream_get_data_size(stream->parent);
44
44
                i_assert(size != 0);
45
45
        }
46
46
 
47
 
        if (!i_stream_get_buffer_space(stream, size, NULL))
 
47
        if (!i_stream_try_alloc(stream, size, &avail))
48
48
                return -2;
49
49
        return 1;
50
50
}
109
109
        /* @UNSAFE */
110
110
        struct dot_istream *dstream = (struct dot_istream *)stream;
111
111
        const unsigned char *data;
112
 
        size_t i, dest, size;
 
112
        size_t i, dest, size, avail;
113
113
        ssize_t ret, ret1;
114
114
 
115
115
        if (dstream->pending[0] != '\0') {
116
 
                if (!i_stream_get_buffer_space(stream, 1, NULL))
 
116
                if (!i_stream_try_alloc(stream, 1, &avail))
117
117
                        return -2;
118
118
                dest = stream->pos;
119
119
                (void)flush_pending(dstream, &dest);
211
211
        return ret;
212
212
}
213
213
 
214
 
static const struct stat *
215
 
i_stream_dot_stat(struct istream_private *stream, bool exact)
216
 
{
217
 
        return i_stream_stat(stream->parent, exact);
218
 
}
219
 
 
220
214
struct istream *i_stream_create_dot(struct istream *input, bool send_last_lf)
221
215
{
222
216
        struct dot_istream *dstream;
223
217
 
224
218
        dstream = i_new(struct dot_istream, 1);
225
219
        dstream->istream.max_buffer_size = input->real_stream->max_buffer_size;
226
 
 
227
220
        dstream->istream.read = i_stream_dot_read;
228
 
        dstream->istream.stat = i_stream_dot_stat;
229
221
 
230
222
        dstream->istream.istream.readable_fd = FALSE;
231
223
        dstream->istream.istream.blocking = input->blocking;