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_empty(apr_pool_t *pool) { svn_stream_t *stream; stream = svn_stream_create(NULL, pool); svn_stream_set_read(stream, read_handler_empty); svn_stream_set_write(stream, write_handler_empty); svn_stream_set_mark(stream, mark_handler_empty); svn_stream_set_seek(stream, seek_handler_empty); svn_stream__set_is_buffered(stream, is_buffered_handler_empty); return stream; }
svn_stream_t * svn_stream_disown(svn_stream_t *stream, apr_pool_t *pool) { svn_stream_t *s = svn_stream_create(stream, pool); svn_stream_set_read(s, read_handler_disown); svn_stream_set_skip(s, skip_handler_disown); svn_stream_set_write(s, write_handler_disown); svn_stream_set_mark(s, mark_handler_disown); svn_stream_set_seek(s, seek_handler_disown); svn_stream__set_is_buffered(s, is_buffered_handler_disown); return s; }
svn_ra_svn__stream_t * svn_ra_svn__stream_create(void *baton, svn_read_fn_t read_cb, svn_write_fn_t write_cb, ra_svn_timeout_fn_t timeout_cb, ra_svn_pending_fn_t pending_cb, apr_pool_t *pool) { svn_ra_svn__stream_t *s = apr_palloc(pool, sizeof(*s)); s->stream = svn_stream_empty(pool); svn_stream_set_baton(s->stream, baton); if (read_cb) svn_stream_set_read(s->stream, read_cb); if (write_cb) svn_stream_set_write(s->stream, write_cb); s->baton = baton; s->timeout_fn = timeout_cb; s->pending_fn = pending_cb; return s; }
svn_stream_t * svn_stream_from_string(const svn_string_t *str, apr_pool_t *pool) { svn_stream_t *stream; struct string_stream_baton *baton; if (! str) return svn_stream_empty(pool); baton = apr_palloc(pool, sizeof(*baton)); baton->str = str; baton->amt_read = 0; stream = svn_stream_create(baton, pool); svn_stream_set_read(stream, read_handler_string); svn_stream_set_mark(stream, mark_handler_string); svn_stream_set_seek(stream, seek_handler_string); svn_stream_set_skip(stream, skip_handler_string); svn_stream__set_is_buffered(stream, is_buffered_handler_string); 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; }
svn_error_t * svn_wc__internal_translated_stream(svn_stream_t **stream, svn_wc__db_t *db, const char *local_abspath, const char *versioned_abspath, apr_uint32_t flags, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_boolean_t special; svn_boolean_t to_nf = flags & SVN_WC_TRANSLATE_TO_NF; svn_subst_eol_style_t style; const char *eol; apr_hash_t *keywords; svn_boolean_t repair_forced = flags & SVN_WC_TRANSLATE_FORCE_EOL_REPAIR; SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_abspath)); SVN_ERR(svn_wc__get_translate_info(&style, &eol, &keywords, &special, db, versioned_abspath, NULL, FALSE, scratch_pool, scratch_pool)); if (special) { if (to_nf) return svn_subst_read_specialfile(stream, local_abspath, result_pool, scratch_pool); return svn_subst_create_specialfile(stream, local_abspath, result_pool, scratch_pool); } if (to_nf) SVN_ERR(svn_stream_open_readonly(stream, local_abspath, result_pool, scratch_pool)); else { apr_file_t *file; /* We don't want the "open-exclusively" feature of the normal svn_stream_open_writable interface. Do this manually. */ SVN_ERR(svn_io_file_open(&file, local_abspath, APR_CREATE | APR_WRITE | APR_BUFFERED, APR_OS_DEFAULT, result_pool)); *stream = svn_stream_from_aprfile2(file, FALSE, result_pool); } if (svn_subst_translation_required(style, eol, keywords, special, TRUE)) { if (to_nf) { if (style == svn_subst_eol_style_native) eol = SVN_SUBST_NATIVE_EOL_STR; else if (style == svn_subst_eol_style_fixed) repair_forced = TRUE; else if (style != svn_subst_eol_style_none) return svn_error_create(SVN_ERR_IO_UNKNOWN_EOL, NULL, NULL); /* Wrap the stream to translate to normal form */ *stream = svn_subst_stream_translated(*stream, eol, repair_forced, keywords, FALSE /* expand */, result_pool); /* Enforce our contract. TO_NF streams are readonly */ svn_stream_set_write(*stream, write_handler_unsupported); } else { *stream = svn_subst_stream_translated(*stream, eol, TRUE, keywords, TRUE, result_pool); /* Enforce our contract. FROM_NF streams are write-only */ svn_stream_set_read(*stream, read_handler_unsupported); } } return SVN_NO_ERROR; }