コード例 #1
0
ファイル: streams.c プロジェクト: 2asoft/freebsd
svn_ra_svn__stream_t *
svn_ra_svn__stream_from_sock(apr_socket_t *sock,
                             apr_pool_t *result_pool)
{
  sock_baton_t *b = apr_palloc(result_pool, sizeof(*b));
  svn_stream_t *sock_stream;

  b->sock = sock;
  b->pool = svn_pool_create(result_pool);

  sock_stream = svn_stream_create(b, result_pool);

  svn_stream_set_read2(sock_stream, sock_read_cb, NULL /* use default */);
  svn_stream_set_write(sock_stream, sock_write_cb);
  svn_stream_set_data_available(sock_stream, sock_pending_cb);

  return svn_ra_svn__stream_create(sock_stream, sock_stream,
                                   b, sock_timeout_cb, result_pool);
}
コード例 #2
0
ファイル: spillbuf.c プロジェクト: FreeBSDFoundation/freebsd
svn_stream_t *
svn_stream__from_spillbuf(svn_spillbuf_t *buf,
                          apr_pool_t *result_pool)
{
  svn_stream_t *stream;
  struct spillbuf_baton *sb = apr_palloc(result_pool, sizeof(*sb));

  sb->reader = apr_pcalloc(result_pool, sizeof(*sb->reader));
  sb->reader->buf = buf;
  sb->scratch_pool = svn_pool_create(result_pool);

  stream = svn_stream_create(sb, result_pool);

  svn_stream_set_read2(stream, NULL /* only full read support */,
                       read_handler_spillbuf);
  svn_stream_set_write(stream, write_handler_spillbuf);

  return stream;
}
コード例 #3
0
ファイル: stream-test.c プロジェクト: gunjanms/svnmigration
static svn_error_t *
test_stream_compressed_read_full(apr_pool_t *pool)
{
  svn_stream_t *stream, *empty_stream;
  char buf[1];
  apr_size_t len;

  /* Reading an empty stream with read_full only support should not error. */
  empty_stream = svn_stream_create(NULL, pool);

  /* Create stream with only full read support. */
  svn_stream_set_read2(empty_stream, NULL, empty_read_full_fn);

  stream = svn_stream_compressed(empty_stream, pool);
  len = sizeof(buf);
  SVN_ERR(svn_stream_read_full(stream, buf, &len));
  if (len > 0)
    return svn_error_create(SVN_ERR_TEST_FAILED, NULL,
                            "Got unexpected result.");

  SVN_ERR(svn_stream_close(stream));

  return SVN_NO_ERROR;
}