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

svn_hash.h

Go to the documentation of this file.
00001 /**
00002  * @copyright
00003  * ====================================================================
00004  * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
00005  *
00006  * This software is licensed as described in the file COPYING, which
00007  * you should have received as part of this distribution.  The terms
00008  * are also available at http://subversion.tigris.org/license-1.html.
00009  * If newer versions of this license are posted there, you may use a
00010  * newer version instead, at your option.
00011  *
00012  * This software consists of voluntary contributions made by many
00013  * individuals.  For exact contribution history, see the revision
00014  * history and logs, available at http://subversion.tigris.org/.
00015  * ====================================================================
00016  * @endcopyright
00017  *
00018  * @file svn_hash.h
00019  * @brief Dumping and reading hash tables to/from files.
00020  */
00021 
00022 
00023 #ifndef SVN_HASH_H
00024 #define SVN_HASH_H
00025 
00026 #include <apr_pools.h>
00027 #include <apr_hash.h>
00028 #include <apr_file_io.h>
00029 
00030 #include "svn_types.h"
00031 #include "svn_io.h"
00032 #include "svn_error.h"
00033 
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif /* __cplusplus */
00038 
00039 
00040 /** The longest the "K <number>" line can be in one of our hashdump files. */
00041 #define SVN_KEYLINE_MAXLEN 100
00042 
00043 
00044 /*----------------------------------------------------*/
00045 
00046 /** Reading/writing hashtables to disk
00047  *
00048  * @defgroup svn_hash_read_write reading and writing hashtables to disk
00049  * @{
00050  */
00051 
00052 /** @since New in 1.1.
00053  * The conventional terminator for hash dumps. */
00054 #define SVN_HASH_TERMINATOR "END"
00055 
00056 /**
00057  * @since New in 1.1.
00058  *
00059  * Read a hash table from @a stream, storing the resultants names and
00060  * values in @a hash.  Use a @a pool for all allocations.  @a hash will
00061  * have <tt>const char *</tt> keys and <tt>svn_string_t *</tt> values.
00062  * If @a terminator is NULL, expect the hash to be terminated by the
00063  * end of the stream; otherwise, expect the hash to be terminated by a
00064  * line containing @a terminator.  Pass @c SVN_HASH_TERMINATOR to use
00065  * the conventional terminator "END".
00066  */
00067 svn_error_t *svn_hash_read2 (apr_hash_t *hash,
00068                              svn_stream_t *stream,
00069                              const char *terminator,
00070                              apr_pool_t *pool);
00071 
00072 /**
00073  * @since New in 1.1.
00074  *
00075  * Dump @a hash to @a stream.  Use @a pool for all allocations.  @a
00076  * hash has <tt>const char *</tt> keys and <tt>svn_string_t *</tt>
00077  * values.  If @a terminator is not NULL, terminate the hash with a
00078  * line containing @a terminator.
00079  */
00080 svn_error_t *svn_hash_write2 (apr_hash_t *hash, 
00081                               svn_stream_t *stream,
00082                               const char *terminator,
00083                               apr_pool_t *pool);
00084 
00085 /**
00086  * @since New in 1.1.
00087  *
00088  * Similar to @c svn_hash_read2(), but allows @a stream to contain
00089  * deletion lines which remove entries from @a hash as well as adding
00090  * to it.
00091  */
00092 svn_error_t *svn_hash_read_incremental (apr_hash_t *hash,
00093                                         svn_stream_t *stream,
00094                                         const char *terminator,
00095                                         apr_pool_t *pool);
00096 
00097 /**
00098  * @since New in 1.1.
00099  *
00100  * Similar to @c svn_hash_write2(), but only writes out entries for
00101  * keys which differ between @a hash and @a oldhash, and also writes
00102  * out deletion lines for keys which are present in @a oldhash but not
00103  * in @a hash.
00104  */
00105 svn_error_t *svn_hash_write_incremental (apr_hash_t *hash,
00106                                          apr_hash_t *oldhash,
00107                                          svn_stream_t *stream,
00108                                          const char *terminator,
00109                                          apr_pool_t *pool);
00110 
00111 /** @deprecated Provided for backward compatibility with the 1.0.0
00112  * API.  This function behaves like svn_hash_read2, but it only works
00113  * on an apr_file_t input, empty files are accepted, and the hash is
00114  * expected to be terminated with a line containing "END" or
00115  * "PROPS-END".
00116  */
00117 svn_error_t *svn_hash_read (apr_hash_t *hash, 
00118                             apr_file_t *srcfile,
00119                             apr_pool_t *pool);
00120 
00121 /** @deprecated Provided for backward compatibility with the 1.0.0
00122  * API.  This function behaves like svn_hash_write2, but it only works
00123  * on an apr_file_t output, and the terminator is always "END". */
00124 svn_error_t *svn_hash_write (apr_hash_t *hash, 
00125                              apr_file_t *destfile,
00126                              apr_pool_t *pool);
00127 
00128 /** @} */
00129 
00130 
00131 /** Taking the "diff" of two hash tables.
00132  *
00133  * @defgroup svn_hash_diff taking the diff of two hash tables.
00134  * @{
00135  */
00136 
00137 /** Hash key status indicator for svn_hash_diff_func_t.  */
00138 enum svn_hash_diff_key_status
00139   {
00140     /* Key is present in both hashes. */
00141     svn_hash_diff_key_both,
00142 
00143     /* Key is present in first hash only. */
00144     svn_hash_diff_key_a,
00145 
00146     /* Key is present in second hash only. */
00147     svn_hash_diff_key_b
00148   };
00149 
00150 
00151 /** Function type for expressing a key's status between two hash tables. */
00152 typedef svn_error_t *(*svn_hash_diff_func_t)
00153        (const void *key, apr_ssize_t klen,
00154         enum svn_hash_diff_key_status status,
00155         void *baton);
00156 
00157 
00158 /** Take the diff of two hashtables.
00159  *
00160  * For each key in the union of @a hash_a's and @a hash_b's keys, invoke
00161  * @a diff_func exactly once, passing the key, the key's length, an enum
00162  * @c svn_hash_diff_key_status indicating which table(s) the key appears
00163  * in, and @a diff_func_baton.
00164  *
00165  * Process all keys of @a hash_a first, then all remaining keys of @a hash_b. 
00166  *
00167  * If @a diff_func returns error, return that error immediately, without
00168  * applying @a diff_func to anything else.
00169  *
00170  * @a hash_a or @a hash_b or both may be null; treat a null table as though
00171  * empty.
00172  *
00173  * Use @a pool for temporary allocation.
00174  */
00175 svn_error_t *svn_hash_diff (apr_hash_t *hash_a,
00176                             apr_hash_t *hash_b,
00177                             svn_hash_diff_func_t diff_func,
00178                             void *diff_func_baton,
00179                             apr_pool_t *pool);
00180 
00181 /** @} */
00182 
00183 #ifdef __cplusplus
00184 }
00185 #endif /* __cplusplus */
00186 
00187 #endif /* SVN_HASH_H */

Generated on Sat Apr 2 00:11:39 2005 for Subversion by doxygen 1.3.5