Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

generic byte streams

Generic byte-streams. More...

Typedefs

typedef svn_stream_t svn_stream_t
 An abstract stream of bytes--either incoming or outgoing or both.

typedef svn_error_t *(* svn_read_fn_t )(void *baton, char *buffer, apr_size_t *len)
 Read handler function for a generic stream.

typedef svn_error_t *(* svn_write_fn_t )(void *baton, const char *data, apr_size_t *len)
 Write handler function for a generic stream.

typedef svn_error_t *(* svn_close_fn_t )(void *baton)
 Close handler function for a generic stream.


Functions

svn_stream_tsvn_stream_create (void *baton, apr_pool_t *pool)
 Create a generic stream.

void svn_stream_set_baton (svn_stream_t *stream, void *baton)
 Set stream's baton to baton.

void svn_stream_set_read (svn_stream_t *stream, svn_read_fn_t read_fn)
 Set stream's read function to read_fn.

void svn_stream_set_write (svn_stream_t *stream, svn_write_fn_t write_fn)
 Set stream's write function to write_fn.

void svn_stream_set_close (svn_stream_t *stream, svn_close_fn_t close_fn)
 Set stream's close function to close_fn.

svn_stream_tsvn_stream_empty (apr_pool_t *pool)
 Create a stream that is empty for reading and infinite for writing.

svn_stream_tsvn_stream_disown (svn_stream_t *stream, apr_pool_t *pool)
 Return a stream allocated in pool which forwards all requests to stream.

svn_stream_tsvn_stream_from_aprfile2 (apr_file_t *file, svn_boolean_t disown, apr_pool_t *pool)
 Create a stream from an APR file.

svn_stream_tsvn_stream_from_aprfile (apr_file_t *file, apr_pool_t *pool)
 Similar to svn_stream_from_aprfile2(), except that the file will always be disowned.

svn_error_tsvn_stream_for_stdout (svn_stream_t **out, apr_pool_t *pool)
 Set *out to a generic stream connected to stdout, allocated in pool.

svn_stream_tsvn_stream_from_stringbuf (svn_stringbuf_t *str, apr_pool_t *pool)
 Return a generic stream connected to stringbuf str.

svn_stream_tsvn_stream_compressed (svn_stream_t *stream, apr_pool_t *pool)
 Return a stream that decompresses all data read and compresses all data written.

svn_stream_tsvn_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)
 Return a stream that calculates checksums for all data read and written.

svn_error_tsvn_stream_read (svn_stream_t *stream, char *buffer, apr_size_t *len)
 Read from a generic stream.

svn_error_tsvn_stream_write (svn_stream_t *stream, const char *data, apr_size_t *len)
 Write to a generic stream.

svn_error_tsvn_stream_close (svn_stream_t *stream)
 Close a generic stream.

svn_error_tsvn_stream_printf (svn_stream_t *stream, apr_pool_t *pool, const char *fmt,...)
 Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from pool.

svn_error_tsvn_stream_printf_from_utf8 (svn_stream_t *stream, const char *encoding, apr_pool_t *pool, const char *fmt,...)
 Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from pool.

svn_error_tsvn_stream_readline (svn_stream_t *stream, svn_stringbuf_t **stringbuf, const char *eol, svn_boolean_t *eof, apr_pool_t *pool)
 Allocate *stringbuf in pool, and read into it one line (terminated by eol) from stream.

svn_error_tsvn_stream_copy (svn_stream_t *from, svn_stream_t *to, apr_pool_t *pool)
 Read the contents of the readable stream from and write them to the writable stream to.

svn_error_tsvn_stream_contents_same (svn_boolean_t *same, svn_stream_t *stream1, svn_stream_t *stream2, apr_pool_t *pool)
 Set *same to TRUE if stream1 and stream2 have the same contents, else set it to FALSE.


Detailed Description

Generic byte-streams.


Typedef Documentation

typedef svn_error_t*(* svn_close_fn_t)(void *baton)
 

Close handler function for a generic stream.

See also:
svn_stream_t.

Definition at line 537 of file svn_io.h.

typedef svn_error_t*(* svn_read_fn_t)(void *baton, char *buffer, apr_size_t *len)
 

Read handler function for a generic stream.

See also:
svn_stream_t.

Definition at line 527 of file svn_io.h.

typedef struct svn_stream_t svn_stream_t
 

An abstract stream of bytes--either incoming or outgoing or both.

The creator of a stream sets functions to handle read and write. Both of these handlers accept a baton whose value is determined at stream creation time; this baton can point to a structure containing data associated with the stream. If a caller attempts to invoke a handler which has not been set, it will generate a runtime assertion failure. The creator can also set a handler for close requests so that it can flush buffered data or whatever; if a close handler is not specified, a close request on the stream will simply be ignored. Note that svn_stream_close() does not deallocate the memory used to allocate the stream structure; free the pool you created the stream in to free that memory.

The read and write handlers accept length arguments via pointer. On entry to the handler, the pointed-to value should be the amount of data which can be read or the amount of data to write. When the handler returns, the value is reset to the amount of data actually read or written. Handlers are obliged to complete a read or write to the maximum extent possible; thus, a short read with no associated error implies the end of the input stream, and a short write should never occur without an associated error.

Definition at line 522 of file svn_io.h.

typedef svn_error_t*(* svn_write_fn_t)(void *baton, const char *data, apr_size_t *len)
 

Write handler function for a generic stream.

See also:
svn_stream_t.

Definition at line 532 of file svn_io.h.


Function Documentation

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
 

Return a stream that calculates checksums for all data read and written.

The stream stream is used to read and write all data. The stream and the resulting digests are allocated in pool.

When the stream is closed, read_digest and write_digest are set to point to the resulting digests.

Both read_digest and write_digest can be NULL, in which case the respective checksum isn't calculated.

If read_all is true, make sure that all data available on stream is read (and checksummed) when the stream is closed.

Read and write operations can be mixed without interfering.

The stream passed into this function is closed when the created stream is closed.

Since:
New in 1.4.

svn_error_t* svn_stream_close svn_stream_t stream  ) 
 

Close a generic stream.

See also:
svn_stream_t.

svn_stream_t* svn_stream_compressed svn_stream_t stream,
apr_pool_t *  pool
 

Return a stream that decompresses all data read and compresses all data written.

The stream stream is used to read and write all compressed data. All compression data structures are allocated on pool. If compression support is not compiled in then svn_stream_compressed() returns stream unmodified. Make sure you call svn_stream_close() on the stream returned by this function, so that all data are flushed and cleaned up.

svn_error_t* svn_stream_contents_same svn_boolean_t same,
svn_stream_t stream1,
svn_stream_t stream2,
apr_pool_t *  pool
 

Set *same to TRUE if stream1 and stream2 have the same contents, else set it to FALSE.

Use pool for temporary allocations.

Since:
New in 1.4.

svn_error_t* svn_stream_copy svn_stream_t from,
svn_stream_t to,
apr_pool_t *  pool
 

Read the contents of the readable stream from and write them to the writable stream to.

Since:
New in 1.1.

svn_stream_t* svn_stream_create void *  baton,
apr_pool_t *  pool
 

Create a generic stream.

See also:
svn_stream_t.

svn_stream_t* svn_stream_disown svn_stream_t stream,
apr_pool_t *  pool
 

Return a stream allocated in pool which forwards all requests to stream.

Destruction is explicitly excluded from forwarding.

See also:
notes/destruction-of-stacked-resources
Since:
New in 1.4.

svn_error_t* svn_stream_for_stdout svn_stream_t **  out,
apr_pool_t *  pool
 

Set *out to a generic stream connected to stdout, allocated in pool.

The stream and its underlying APR handle will be closed when pool is cleared or destroyed.

svn_stream_t* svn_stream_from_aprfile apr_file_t *  file,
apr_pool_t *  pool
 

Similar to svn_stream_from_aprfile2(), except that the file will always be disowned.

Note:
The stream returned is not considered to "own" the underlying file, meaning that svn_stream_close() on the stream will not close the file.

Deprecated:
Provided for backward compatibility with the 1.3 API.

svn_stream_t* svn_stream_from_aprfile2 apr_file_t *  file,
svn_boolean_t  disown,
apr_pool_t *  pool
 

Create a stream from an APR file.

For convenience, if file is NULL, an empty stream created by svn_stream_empty() is returned.

This function should normally be called with disown set to false, in which case closing the stream will also close the underlying file.

If disown is true, the stream will disown the underlying file, meaning that svn_stream_close() will not close the file.

Since:
New in 1.4.

svn_stream_t* svn_stream_from_stringbuf svn_stringbuf_t str,
apr_pool_t *  pool
 

Return a generic stream connected to stringbuf str.

Allocate the stream in pool.

svn_error_t* svn_stream_printf_from_utf8 svn_stream_t stream,
const char *  encoding,
apr_pool_t *  pool,
const char *  fmt,
... 
 

Write to stream using a printf-style fmt specifier, passed through apr_psprintf() using memory from pool.

The resulting string will be translated to encoding before it is sent to stream.

Note:
Use APR_LOCALE_CHARSET to translate to the encoding of the current locale.
Since:
New in 1.3.

svn_error_t* svn_stream_read svn_stream_t stream,
char *  buffer,
apr_size_t *  len
 

Read from a generic stream.

See also:
svn_stream_t.

svn_error_t* svn_stream_readline svn_stream_t stream,
svn_stringbuf_t **  stringbuf,
const char *  eol,
svn_boolean_t eof,
apr_pool_t *  pool
 

Allocate *stringbuf in pool, and read into it one line (terminated by eol) from stream.

The line-terminator is read from the stream, but is not added to the end of the stringbuf. Instead, the stringbuf ends with a usual '\0'.

If stream runs out of bytes before encountering a line-terminator, then set *eof to TRUE, otherwise set *eof to FALSE.

svn_error_t* svn_stream_write svn_stream_t stream,
const char *  data,
apr_size_t *  len
 

Write to a generic stream.

See also:
svn_stream_t.


Generated on Sun Mar 16 14:48:44 2008 for Subversion by doxygen 1.3.5