Main Page | Data Structures | Directories | File List | Data Fields | Globals

lcn_istream.h

Go to the documentation of this file.
00001 /* Copyright 2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /**
00018  * @file lcn_istream.h
00019  * @brief Routines for manipulating read-only streams of data
00020  */
00021 
00022 #ifndef _LCN_ISTREAM_H
00023 #define _LCN_ISTREAM_H
00024 
00025 #include "lcn_types.h"
00026 
00027 #include <apr_file_io.h>
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif /* __cplusplus */
00032 
00033 /** Opaque structure representing a stream of data. */
00034 typedef struct lcn_istream_t lcn_istream_t;
00035 
00036 /** Return a memory backed istream containing @a length bytes of data from
00037  * @a buffer, the stream is allocated from @a pool.
00038  */
00039 lcn_istream_t *
00040 lcn_ram_istream_create (const char *buffer,
00041                         apr_size_t length,
00042                         apr_pool_t *pool);
00043 
00044 /** Return a file backed istream that wraps @a file, allocated from @a pool. */
00045 lcn_istream_t *
00046 lcn_file_istream_create (apr_file_t *file, apr_pool_t *pool);
00047 
00048 /** Read a single byte from @a stream into @a byte, using @a pool for any
00049  * allocation.
00050  */
00051 lcn_error_t *
00052 lcn_istream_read_byte (lcn_istream_t *stream,
00053                        char *byte,
00054                        apr_pool_t *pool);
00055 
00056 /** Read @a len bytes from @a stream into @a buffer, using @a pool for any
00057  * allocation
00058  */
00059 lcn_error_t *
00060 lcn_istream_read_bytes (lcn_istream_t *stream,
00061                         char *buffer,
00062                         apr_size_t len,
00063                         apr_pool_t *pool);
00064 
00065 /** Read a 32 bit integer from @a stream into @a i, using @a pool for any
00066  * allocation
00067  */
00068 lcn_error_t *
00069 lcn_istream_read_int (lcn_istream_t *stream,
00070                       apr_uint32_t *i,
00071                       apr_pool_t *pool);
00072 
00073 /** Read a variable length 32 bit integer from @a steam into @a i, using
00074  * @a pool for any allocation.
00075  */
00076 lcn_error_t *
00077 lcn_istream_read_vint (lcn_istream_t *stream,
00078                        apr_uint32_t *i,
00079                        apr_pool_t *pool);
00080 
00081 /** Read a 64 bit integer from @a stream into @a l, using @a pool for any
00082  * allocation.
00083  */
00084 lcn_error_t *
00085 lcn_istream_read_long (lcn_istream_t *stream,
00086                        apr_uint64_t *l,
00087                        apr_pool_t *pool);
00088 
00089 /** Read a variable length 64 bit integer from @a stream into @a l, using
00090  * @a pool for any allocation.
00091  */
00092 lcn_error_t *
00093 lcn_istream_read_vlong (lcn_istream_t *stream,
00094                         apr_uint64_t *l,
00095                         apr_pool_t *pool);
00096 
00097 /** Read a string from @a stream into @a str, allocated from @a pool. */
00098 lcn_error_t *
00099 lcn_istream_read_string (lcn_istream_t *stream,
00100                          lcn_char_t **str,
00101                          apr_pool_t *pool);
00102 
00103 /** Read @a length chars from @a stream, returning them in @a buffer, using
00104  * @a pool for allocation. */
00105 lcn_error_t *
00106 lcn_istream_read_chars (lcn_istream_t *stream,
00107                         lcn_char_t **buffer,
00108                         apr_size_t length,
00109                         apr_pool_t *pool);
00110 
00111 /** Seek @a stream to @a offset, using @a pool for temporary allocations. */
00112 lcn_error_t *
00113 lcn_istream_seek (lcn_istream_t *stream, apr_off_t offset, apr_pool_t *pool);
00114 
00115 /** Close @a stream, using @a pool for temporary allocations. */
00116 lcn_error_t *
00117 lcn_istream_close (lcn_istream_t *stream, apr_pool_t *pool);
00118 
00119 /** Return the length of @a stream in @a length, using @a pool for temporary
00120  * allocations.
00121  */
00122 lcn_error_t *
00123 lcn_istream_length (lcn_istream_t *stream,
00124                     apr_size_t *length,
00125                     apr_pool_t *pool);
00126 
00127 /** Return the current position of @a stream in @a offset, using @a pool for
00128  * temporary allocations.
00129  */
00130 lcn_error_t *
00131 lcn_istream_offset (lcn_istream_t *stream,
00132                     apr_off_t *offset,
00133                     apr_pool_t *pool);
00134 
00135 /** Return a duplicate of @a source in @a dest, allocated within @a pool. */
00136 lcn_error_t *
00137 lcn_istream_duplicate (lcn_istream_t **dest,
00138                        lcn_istream_t *source,
00139                        apr_pool_t *pool);
00140 
00141 #ifdef __cplusplus
00142 }
00143 #endif /* __cplusplus */
00144 
00145 #endif

Generated on Sat Mar 26 08:12:11 2005 for Lucene4c by  doxygen 1.4.0