- case SILC_STREAM_CAN_READ:
- SILC_LOG_DEBUG(("Reading data from stream"));
-
- /* Make sure we have fair amount of free space in inbuf */
- if (silc_buffer_taillen(&ps->inbuf) < SILC_PACKET_DEFAULT_SIZE)
- if (!silc_buffer_realloc(&ps->inbuf, silc_buffer_truelen(&ps->inbuf) +
- SILC_PACKET_DEFAULT_SIZE * 2))
- return;
-
- /* Read data from stream */
- ret = silc_stream_read(ps->stream, &ps->inbuf.tail,
- silc_buffer_taillen(&ps->inbuf));
-
- if (ret == 0) {
- /* EOS */
- SILC_PACKET_CALLBACK_EOS(ps);
- silc_buffer_reset(&ps->inbuf);
- return;
- }
-
- if (ret == -2) {
- /* Error */
- SILC_PACKET_CALLBACK_ERROR(ps, SILC_PACKET_ERR_READ);
- silc_buffer_reset(&ps->inbuf);
- return;
- }
-
- if (ret == -1) {
- /* Cannot read now, do it later. */
- silc_buffer_pull(&ps->inbuf, silc_buffer_len(&ps->inbuf));
- return;
- }
-
- /* Read some data */
- silc_buffer_pull_tail(&ps->inbuf, ret);
-
- /* Now process the data */
- silc_sftp_client_receive_process(sftp);
- break;
-