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_error.h"
00032
00033
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif /* __cplusplus */
00037
00038
00039 /** The longest the "K <number>" line can be in one of our hashdump files. */
00040 #define SVN_KEYLINE_MAXLEN 100
00041
00042
00043 /*----------------------------------------------------*/
00044
00045 /** Reading/writing hashtables to disk
00046 *
00047 * @defgroup svn_hash_read_write reading and writing hashtables to disk
00048 * @{
00049 */
00050
00051 /** Read a hash table from @a srcfile, storing the resultants names and
00052 * values in @a hash. Use a @a pool for all allocations. @a hash will
00053 * have <tt>const char *</tt> keys and <tt>svn_string_t *</tt> values.
00054 */
00055 svn_error_t *svn_hash_read (apr_hash_t *hash,
00056 apr_file_t *srcfile,
00057 apr_pool_t *pool);
00058
00059 /** Dump @a hash to @a destfile. Use @a pool for all allocations. @a hash
00060 * has <tt>const char *</tt> keys and <tt>svn_string_t *</tt> values.
00061 */
00062 svn_error_t *svn_hash_write (apr_hash_t *hash,
00063 apr_file_t *destfile,
00064 apr_pool_t *pool);
00065
00066 /** @} */
00067
00068
00069 /** Taking the "diff" of two hash tables.
00070 *
00071 * @defgroup svn_hash_diff taking the diff of two hash tables.
00072 * @{
00073 */
00074
00075 /** Hash key status indicator for svn_hash_diff_func_t. */
00076 enum svn_hash_diff_key_status
00077 {
00078 /* Key is present in both hashes. */
00079 svn_hash_diff_key_both,
00080
00081 /* Key is present in first hash only. */
00082 svn_hash_diff_key_a,
00083
00084 /* Key is present in second hash only. */
00085 svn_hash_diff_key_b
00086 };
00087
00088
00089 /** Function type for expressing a key's status between two hash tables. */
00090 typedef svn_error_t *(*svn_hash_diff_func_t)
00091 (const void *key, apr_ssize_t klen,
00092 enum svn_hash_diff_key_status status,
00093 void *baton);
00094
00095
00096 /** Take the diff of two hashtables.
00097 *
00098 * For each key in the union of @a hash_a's and @a hash_b's keys, invoke
00099 * @a diff_func exactly once, passing the key, the key's length, an enum
00100 * @c svn_hash_diff_key_status indicating which table(s) the key appears
00101 * in, and @a diff_func_baton.
00102 *
00103 * Process all keys of @a hash_a first, then all remaining keys of @a hash_b.
00104 *
00105 * If @a diff_func returns error, return that error immediately, without
00106 * applying @a diff_func to anything else.
00107 *
00108 * @a hash_a or @a hash_b or both may be null; treat a null table as though
00109 * empty.
00110 *
00111 * Use @a pool for temporary allocation.
00112 */
00113 svn_error_t *svn_hash_diff (apr_hash_t *hash_a,
00114 apr_hash_t *hash_b,
00115 svn_hash_diff_func_t diff_func,
00116 void *diff_func_baton,
00117 apr_pool_t *pool);
00118
00119 /** @} */
00120
00121 #ifdef __cplusplus
00122 }
00123 #endif /* __cplusplus */
00124
00125 #endif /* SVN_HASH_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002