~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/include/svn_hash.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
4
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
5
 *
 
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.
 
11
 *
 
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
 * ====================================================================
 
16
 * @endcopyright
 
17
 *
 
18
 * @file svn_hash.h
 
19
 * @brief Dumping and reading hash tables to/from files.
 
20
 */
 
21
 
 
22
 
 
23
#ifndef SVN_HASH_H
 
24
#define SVN_HASH_H
 
25
 
 
26
#include <apr_pools.h>
 
27
#include <apr_hash.h>
 
28
#include <apr_file_io.h>
 
29
 
 
30
#include "svn_types.h"
 
31
#include "svn_io.h"
 
32
#include "svn_error.h"
 
33
 
 
34
 
 
35
#ifdef __cplusplus
 
36
extern "C" {
 
37
#endif /* __cplusplus */
 
38
 
 
39
 
 
40
/** The longest the "K <number>" line can be in one of our hashdump files. */
 
41
#define SVN_KEYLINE_MAXLEN 100
 
42
 
 
43
 
 
44
/*----------------------------------------------------*/
 
45
 
 
46
/** Reading/writing hashtables to disk
 
47
 *
 
48
 * @defgroup svn_hash_read_write reading and writing hashtables to disk
 
49
 * @{
 
50
 */
 
51
 
 
52
/**
 
53
 * @since New in 1.1.
 
54
 *
 
55
 * The conventional terminator for hash dumps. */
 
56
#define SVN_HASH_TERMINATOR "END"
 
57
 
 
58
/**
 
59
 * @since New in 1.1.
 
60
 *
 
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".
 
68
 */
 
69
svn_error_t *svn_hash_read2 (apr_hash_t *hash,
 
70
                             svn_stream_t *stream,
 
71
                             const char *terminator,
 
72
                             apr_pool_t *pool);
 
73
 
 
74
/**
 
75
 * @since New in 1.1.
 
76
 *
 
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.
 
81
 */
 
82
svn_error_t *svn_hash_write2 (apr_hash_t *hash, 
 
83
                              svn_stream_t *stream,
 
84
                              const char *terminator,
 
85
                              apr_pool_t *pool);
 
86
 
 
87
/**
 
88
 * @since New in 1.1.
 
89
 *
 
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
 
92
 * to it.
 
93
 */
 
94
svn_error_t *svn_hash_read_incremental (apr_hash_t *hash,
 
95
                                        svn_stream_t *stream,
 
96
                                        const char *terminator,
 
97
                                        apr_pool_t *pool);
 
98
 
 
99
/**
 
100
 * @since New in 1.1.
 
101
 *
 
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
 
105
 * in @a hash.
 
106
 */
 
107
svn_error_t *svn_hash_write_incremental (apr_hash_t *hash,
 
108
                                         apr_hash_t *oldhash,
 
109
                                         svn_stream_t *stream,
 
110
                                         const char *terminator,
 
111
                                         apr_pool_t *pool);
 
112
 
 
113
/**
 
114
 * @deprecated Provided for backward compatibility with the 1.0 API.
 
115
 *
 
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
 
119
 * "PROPS-END".
 
120
 */
 
121
svn_error_t *svn_hash_read (apr_hash_t *hash, 
 
122
                            apr_file_t *srcfile,
 
123
                            apr_pool_t *pool);
 
124
 
 
125
/**
 
126
 * @deprecated Provided for backward compatibility with the 1.0 API.
 
127
 *
 
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,
 
132
                             apr_pool_t *pool);
 
133
 
 
134
/** @} */
 
135
 
 
136
 
 
137
/** Taking the "diff" of two hash tables.
 
138
 *
 
139
 * @defgroup svn_hash_diff taking the diff of two hash tables.
 
140
 * @{
 
141
 */
 
142
 
 
143
/** Hash key status indicator for svn_hash_diff_func_t.  */
 
144
enum svn_hash_diff_key_status
 
145
  {
 
146
    /* Key is present in both hashes. */
 
147
    svn_hash_diff_key_both,
 
148
 
 
149
    /* Key is present in first hash only. */
 
150
    svn_hash_diff_key_a,
 
151
 
 
152
    /* Key is present in second hash only. */
 
153
    svn_hash_diff_key_b
 
154
  };
 
155
 
 
156
 
 
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,
 
161
        void *baton);
 
162
 
 
163
 
 
164
/** Take the diff of two hashtables.
 
165
 *
 
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.
 
170
 *
 
171
 * Process all keys of @a hash_a first, then all remaining keys of @a hash_b. 
 
172
 *
 
173
 * If @a diff_func returns error, return that error immediately, without
 
174
 * applying @a diff_func to anything else.
 
175
 *
 
176
 * @a hash_a or @a hash_b or both may be null; treat a null table as though
 
177
 * empty.
 
178
 *
 
179
 * Use @a pool for temporary allocation.
 
180
 */
 
181
svn_error_t *svn_hash_diff (apr_hash_t *hash_a,
 
182
                            apr_hash_t *hash_b,
 
183
                            svn_hash_diff_func_t diff_func,
 
184
                            void *diff_func_baton,
 
185
                            apr_pool_t *pool);
 
186
 
 
187
/** @} */
 
188
 
 
189
#ifdef __cplusplus
 
190
}
 
191
#endif /* __cplusplus */
 
192
 
 
193
#endif /* SVN_HASH_H */