3
* ====================================================================
4
* Copyright (c) 2000-2004 CollabNet. All rights reserved.
6
* This software is licensed as described in the file COPYING, which
7
* you should have received as part of this distribution. The terms
8
* are also available at http://subversion.tigris.org/license-1.html.
9
* If newer versions of this license are posted there, you may use a
10
* newer version instead, at your option.
12
* This software consists of voluntary contributions made by many
13
* individuals. For exact contribution history, see the revision
14
* history and logs, available at http://subversion.tigris.org/.
15
* ====================================================================
19
* @brief Dumping and reading hash tables to/from files.
26
#include <apr_pools.h>
28
#include <apr_file_io.h>
30
#include "svn_types.h"
32
#include "svn_error.h"
37
#endif /* __cplusplus */
40
/** The longest the "K <number>" line can be in one of our hashdump files. */
41
#define SVN_KEYLINE_MAXLEN 100
44
/*----------------------------------------------------*/
46
/** Reading/writing hashtables to disk
48
* @defgroup svn_hash_read_write reading and writing hashtables to disk
55
* The conventional terminator for hash dumps. */
56
#define SVN_HASH_TERMINATOR "END"
61
* Read a hash table from @a stream, storing the resultants names and
62
* values in @a hash. Use a @a pool for all allocations. @a hash will
63
* have <tt>const char *</tt> keys and <tt>svn_string_t *</tt> values.
64
* If @a terminator is NULL, expect the hash to be terminated by the
65
* end of the stream; otherwise, expect the hash to be terminated by a
66
* line containing @a terminator. Pass @c SVN_HASH_TERMINATOR to use
67
* the conventional terminator "END".
69
svn_error_t *svn_hash_read2 (apr_hash_t *hash,
71
const char *terminator,
77
* Dump @a hash to @a stream. Use @a pool for all allocations. @a
78
* hash has <tt>const char *</tt> keys and <tt>svn_string_t *</tt>
79
* values. If @a terminator is not NULL, terminate the hash with a
80
* line containing @a terminator.
82
svn_error_t *svn_hash_write2 (apr_hash_t *hash,
84
const char *terminator,
90
* Similar to @c svn_hash_read2(), but allows @a stream to contain
91
* deletion lines which remove entries from @a hash as well as adding
94
svn_error_t *svn_hash_read_incremental (apr_hash_t *hash,
96
const char *terminator,
102
* Similar to @c svn_hash_write2(), but only writes out entries for
103
* keys which differ between @a hash and @a oldhash, and also writes
104
* out deletion lines for keys which are present in @a oldhash but not
107
svn_error_t *svn_hash_write_incremental (apr_hash_t *hash,
109
svn_stream_t *stream,
110
const char *terminator,
114
* @deprecated Provided for backward compatibility with the 1.0 API.
116
* This function behaves like svn_hash_read2, but it only works
117
* on an apr_file_t input, empty files are accepted, and the hash is
118
* expected to be terminated with a line containing "END" or
121
svn_error_t *svn_hash_read (apr_hash_t *hash,
126
* @deprecated Provided for backward compatibility with the 1.0 API.
128
* This function behaves like svn_hash_write2, but it only works
129
* on an apr_file_t output, and the terminator is always "END". */
130
svn_error_t *svn_hash_write (apr_hash_t *hash,
131
apr_file_t *destfile,
137
/** Taking the "diff" of two hash tables.
139
* @defgroup svn_hash_diff taking the diff of two hash tables.
143
/** Hash key status indicator for svn_hash_diff_func_t. */
144
enum svn_hash_diff_key_status
146
/* Key is present in both hashes. */
147
svn_hash_diff_key_both,
149
/* Key is present in first hash only. */
152
/* Key is present in second hash only. */
157
/** Function type for expressing a key's status between two hash tables. */
158
typedef svn_error_t *(*svn_hash_diff_func_t)
159
(const void *key, apr_ssize_t klen,
160
enum svn_hash_diff_key_status status,
164
/** Take the diff of two hashtables.
166
* For each key in the union of @a hash_a's and @a hash_b's keys, invoke
167
* @a diff_func exactly once, passing the key, the key's length, an enum
168
* @c svn_hash_diff_key_status indicating which table(s) the key appears
169
* in, and @a diff_func_baton.
171
* Process all keys of @a hash_a first, then all remaining keys of @a hash_b.
173
* If @a diff_func returns error, return that error immediately, without
174
* applying @a diff_func to anything else.
176
* @a hash_a or @a hash_b or both may be null; treat a null table as though
179
* Use @a pool for temporary allocation.
181
svn_error_t *svn_hash_diff (apr_hash_t *hash_a,
183
svn_hash_diff_func_t diff_func,
184
void *diff_func_baton,
191
#endif /* __cplusplus */
193
#endif /* SVN_HASH_H */