svn_stream_t * svn_txdelta_target_push(svn_txdelta_window_handler_t handler, void *handler_baton, svn_stream_t *source, apr_pool_t *pool) { struct tpush_baton *tb; svn_stream_t *stream; /* Initialize baton. */ tb = apr_palloc(pool, sizeof(*tb)); tb->source = source; tb->wh = handler; tb->whb = handler_baton; tb->pool = pool; tb->buf = apr_palloc(pool, 2 * SVN_DELTA_WINDOW_SIZE); tb->source_offset = 0; tb->source_len = 0; tb->source_done = FALSE; tb->target_len = 0; /* Create and return writable stream. */ stream = svn_stream_create(tb, pool); svn_stream_set_write(stream, tpush_write_handler); svn_stream_set_close(stream, tpush_close_handler); return stream; }
static svn_error_t *ra_svn_apply_textdelta(void *file_baton, const char *base_checksum, apr_pool_t *pool, svn_txdelta_window_handler_t *wh, void **wh_baton) { ra_svn_baton_t *b = file_baton; svn_stream_t *diff_stream; /* Tell the other side we're starting a text delta. */ SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_apply_textdelta(b->conn, pool, b->token, base_checksum)); /* Transform the window stream to an svndiff stream. Reuse the * file baton for the stream handler, since it has all the * needed information. */ diff_stream = svn_stream_create(b, pool); svn_stream_set_write(diff_stream, ra_svn_svndiff_handler); svn_stream_set_close(diff_stream, ra_svn_svndiff_close_handler); /* If the connection does not support SVNDIFF1 or if we don't want to use * compression, use the non-compressing "version 0" implementation */ if ( svn_ra_svn_compression_level(b->conn) > 0 && svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_SVNDIFF1)) svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 1, b->conn->compression_level, pool); else svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 0, b->conn->compression_level, pool); return SVN_NO_ERROR; }
svn_stream_t * svn_stream_from_aprfile2(apr_file_t *file, svn_boolean_t disown, apr_pool_t *pool) { struct baton_apr *baton; svn_stream_t *stream; if (file == NULL) return svn_stream_empty(pool); baton = apr_palloc(pool, sizeof(*baton)); baton->file = file; baton->pool = pool; stream = svn_stream_create(baton, pool); svn_stream_set_read(stream, read_handler_apr); svn_stream_set_write(stream, write_handler_apr); svn_stream_set_skip(stream, skip_handler_apr); svn_stream_set_mark(stream, mark_handler_apr); svn_stream_set_seek(stream, seek_handler_apr); svn_stream__set_is_buffered(stream, is_buffered_handler_apr); if (! disown) svn_stream_set_close(stream, close_handler_apr); return stream; }
svn_stream_t * svn_stream_compressed(svn_stream_t *stream, apr_pool_t *pool) { struct svn_stream_t *zstream; struct zbaton *baton; assert(stream != NULL); baton = apr_palloc(pool, sizeof(*baton)); baton->in = baton->out = NULL; baton->read = stream->read_fn; baton->write = stream->write_fn; baton->close = stream->close_fn; baton->subbaton = stream->baton; baton->pool = pool; baton->read_buffer = NULL; baton->read_flush = Z_SYNC_FLUSH; zstream = svn_stream_create(baton, pool); svn_stream_set_read(zstream, read_handler_gz); svn_stream_set_write(zstream, write_handler_gz); svn_stream_set_close(zstream, close_handler_gz); return zstream; }
/** * Create a svn_stream_t structure for this object. This will be used * as an input stream by Subversion. * @param pool the pool, from which the structure is allocated * @return the input stream */ svn_stream_t *Inputer::getStream(const Pool &pool) { // Create a stream with this as the baton and set the read and // close functions. svn_stream_t *ret = svn_stream_create(this, pool.pool()); svn_stream_set_read(ret, Inputer::read); svn_stream_set_close(ret, Inputer::close); return ret; }
svn_stream_t * svn_stream_tee(svn_stream_t *out1, svn_stream_t *out2, apr_pool_t *pool) { struct baton_tee *baton; svn_stream_t *stream; if (out1 == NULL) return out2; if (out2 == NULL) return out1; baton = apr_palloc(pool, sizeof(*baton)); baton->out1 = out1; baton->out2 = out2; stream = svn_stream_create(baton, pool); svn_stream_set_write(stream, write_handler_tee); svn_stream_set_close(stream, close_handler_tee); return stream; }
svn_stream_t * svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func, void *open_baton, apr_pool_t *result_pool) { lazyopen_baton_t *lob = apr_pcalloc(result_pool, sizeof(*lob)); svn_stream_t *stream; lob->open_func = open_func; lob->open_baton = open_baton; lob->real_stream = NULL; lob->pool = result_pool; stream = svn_stream_create(lob, result_pool); svn_stream_set_read(stream, read_handler_lazyopen); svn_stream_set_skip(stream, skip_handler_lazyopen); svn_stream_set_write(stream, write_handler_lazyopen); svn_stream_set_close(stream, close_handler_lazyopen); svn_stream_set_mark(stream, mark_handler_lazyopen); svn_stream_set_seek(stream, seek_handler_lazyopen); return stream; }
svn_stream_t * svn_stream_checksummed(svn_stream_t *stream, const unsigned char **read_digest, const unsigned char **write_digest, svn_boolean_t read_all, apr_pool_t *pool) { svn_stream_t *s; struct md5_stream_baton *baton; if (! read_digest && ! write_digest) return stream; baton = apr_palloc(pool, sizeof(*baton)); baton->read_digest = read_digest; baton->write_digest = write_digest; baton->pool = pool; /* Set BATON->proxy to a stream that will fill in BATON->read_checksum * and BATON->write_checksum (if we want them) when it is closed. */ baton->proxy = svn_stream_checksummed2(stream, read_digest ? &baton->read_checksum : NULL, write_digest ? &baton->write_checksum : NULL, svn_checksum_md5, read_all, pool); /* Create a stream that will forward its read/write/close operations to * BATON->proxy and will fill in *READ_DIGEST and *WRITE_DIGEST (if we * want them) after it closes BATON->proxy. */ s = svn_stream_create(baton, pool); svn_stream_set_read(s, read_handler_md5); svn_stream_set_skip(s, skip_handler_md5); svn_stream_set_write(s, write_handler_md5); svn_stream_set_close(s, close_handler_md5); return s; }
svn_stream_t * svn_stream_checksummed2(svn_stream_t *stream, svn_checksum_t **read_checksum, svn_checksum_t **write_checksum, svn_checksum_kind_t checksum_kind, svn_boolean_t read_all, apr_pool_t *pool) { svn_stream_t *s; struct checksum_stream_baton *baton; if (read_checksum == NULL && write_checksum == NULL) return stream; baton = apr_palloc(pool, sizeof(*baton)); if (read_checksum) baton->read_ctx = svn_checksum_ctx_create(checksum_kind, pool); else baton->read_ctx = NULL; if (write_checksum) baton->write_ctx = svn_checksum_ctx_create(checksum_kind, pool); else baton->write_ctx = NULL; baton->read_checksum = read_checksum; baton->write_checksum = write_checksum; baton->proxy = stream; baton->read_more = read_all; baton->pool = pool; s = svn_stream_create(baton, pool); svn_stream_set_read(s, read_handler_checksum); svn_stream_set_write(s, write_handler_checksum); svn_stream_set_close(s, close_handler_checksum); return s; }