istream-dot.c revision a8c5a86d183db25a57bf193c06b41e092ec2e151
5717e8e12768ab1d667cd3e908e5f3ffe540655aTimo Sirainen/* Copyright (c) 2007-2014 Dovecot authors, see the included COPYING file */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* how far in string "\r\n.\r" are we */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk unsigned int state;
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* state didn't actually start with \r */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* state didn't contain \n either (only at the beginnign of stream) */
0610b6dfbdcb6a8f234a6495ec243bcf996b5572Pascal Volk /* we've seen the "." line, keep returning EOF */
88c816e8be4e1a29bca8b67d67a92c67a33f3795Timo Sirainenstatic int i_stream_dot_read_some(struct dot_istream *dstream)
ed1ad90a15ea48d43edef858da3a598adca8b1feTimo Sirainen struct istream_private *stream = &dstream->istream;
f6b42d6832887ee5a94deb278f924bae7216e660Pascal Volk if (ret <= 0 && (ret != -2 || stream->skip == 0)) {
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* we didn't see "." line */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk "dot-input stream ends without '.' line");
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volkstatic bool flush_pending(struct dot_istream *dstream, size_t *destp)
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk struct istream_private *stream = &dstream->istream;
0610b6dfbdcb6a8f234a6495ec243bcf996b5572Pascal Volk unsigned int i = 0;
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk for (; dstream->pending[i] != '\0' && dest < stream->buffer_size; i++)
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volkstatic bool flush_dot_state(struct dot_istream *dstream, size_t *destp)
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk unsigned int i = 0;
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volk /* \r\n.\r seen, go back to \r state */
fa9f5378ec558c451f1f1c47a4c41aa7c916c929Pascal Volkstatic void i_stream_dot_eof(struct dot_istream *dstream, size_t *destp)
static ssize_t
return ret;
const unsigned char *data;
if (ret1 != 0)
return ret1;
goto end;
goto end;
goto end;
goto end;
goto end;
goto end;
end:
if (ret == 0)
return ret;