Sync with upstream
[svnrdump.git] / svn17_compat.h
blob1a4d2b1280ae53a499b785e0aa1651a6ff95c79c
1 /**
2 * @copyright
3 * ====================================================================
4 * This file is derived from code licensed to the Apache
5 * Software Foundation (ASF) under one or more contributor
6 * license agreements. See the NOTICE file distributed with
7 * this file for additional information regarding copyright
8 * ownership. The ASF licenses those portions to you under
9 * the Apache License, Version 2.0 (the "License"); you may
10 * not use those portions except in compliance with the
11 * License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
22 * Any code in this file not licensed from the ASF is
23 * original code in the public domain. You may freely use,
24 * modify, distribute, and relicense such code.
25 * ====================================================================
26 * @endcopyright
28 * @file compat.h
29 * @brief SVN 1.7 compatibility routines.
32 #ifndef SVN17_COMPAT_H
33 #define SVN17_COMPAT_H
35 #include <apr.h>
36 #include <apr_pools.h>
38 #include <svn_types.h>
40 /** Join a valid base uri (@a base) with a relative path or uri
41 * (@a component), allocating the result in @a pool. @a component need
42 * not be a single component: it can be a relative path or a '/'
43 * prefixed relative path to join component to the root path of @a base.
45 * If @a component is the empty path, then @a base will be copied and
46 * returned.
48 * If the @a component is an absolute uri, then it is copied and returned.
50 * If @a component starts with a '/' and @a base contains a scheme, the
51 * scheme defined joining rules are applied.
53 * From svn_dirent_uri.h.
55 char *
56 svn_uri_join(const char *base,
57 const char *component,
58 apr_pool_t *pool);
60 /** Join a base relpath (@a base) with a component (@a component), allocating
61 * the result in @a pool. @a component need not be a single component.
63 * If either @a base or @a component is the empty path, then the other
64 * argument will be copied and returned. If both are the empty path the
65 * empty path is returned.
67 * From svn_dirent_uri.h.
69 char *
70 svn_relpath_join(const char *base,
71 const char *component,
72 apr_pool_t *pool);
74 /** Return the longest common path shared by two relative paths,
75 * @a relpath1 and @a relpath2. If there's no common ancestor, return the
76 * empty path.
78 * From svn_dirent_uri.h.
80 char *
81 svn_relpath_get_longest_ancestor(const char *relpath1,
82 const char *relpath2,
83 apr_pool_t *pool);
85 /** Return the relative path part of @a child_relpath that is below
86 * @a parent_relpath, or just "" if @a parent_relpath is equal to
87 * @a child_relpath. If @a child_relpath is not below @a parent_relpath,
88 * return @a child_relpath.
90 * From svn_dirent_uri.h.
92 const char *
93 svn_relpath_skip_ancestor(const char *parent_relpath,
94 const char *child_relpath);
96 /** Get the basename of the specified canonicalized @a relpath. The
97 * basename is defined as the last component of the relpath. If the @a
98 * relpath has only one component then that is returned. The returned
99 * value will have no slashes in it.
101 * Example: svn_relpath_basename("/trunk/foo/bar") -> "bar"
103 * The returned basename will be allocated in @a pool. If @a
104 * pool is NULL a pointer to the basename in @a relpath is returned.
106 * @note If an empty string is passed, then an empty string will be returned.
108 * From svn_dirent_uri.h.
110 const char *
111 svn_relpath_basename(const char *uri,
112 apr_pool_t *pool);
114 /** Get the dirname of the specified canonicalized @a relpath, defined as
115 * the relpath with its basename removed.
117 * If @a relpath is empty, "" is returned.
119 * The returned relpath will be allocated in @a pool.
121 * From svn_dirent_uri.h.
123 char *
124 svn_relpath_dirname(const char *relpath,
125 apr_pool_t *pool);
127 /** Gets the name of the specified canonicalized @a dirent as it is known
128 * within its parent directory. If the @a dirent is root, return "". The
129 * returned value will not have slashes in it.
131 * Example: svn_dirent_basename("/foo/bar") -> "bar"
133 * The returned basename will be allocated in @a pool. If @a pool is NULL
134 * a pointer to the basename in @a dirent is returned.
136 * @note If an empty string is passed, then an empty string will be returned.
138 * From svn_dirent_uri.h.
140 const char *
141 svn_dirent_basename(const char *dirent,
142 apr_pool_t *pool);
144 /** Return a new uri like @a uri, but transformed such that some types
145 * of uri specification redundancies are removed.
147 * This involves collapsing redundant "/./" elements, removing
148 * multiple adjacent separator characters, removing trailing
149 * separator characters, and possibly other semantically inoperative
150 * transformations.
152 * If @a uri starts with a schema, this function also normalizes the
153 * escaping of the path component by unescaping characters that don't
154 * need escaping and escaping characters that do need escaping but
155 * weren't.
157 * This functions supports URLs.
159 * The returned uri may be statically allocated or allocated from @a pool.
161 * From svn_dirent_uri.h.
163 const char *
164 svn_uri_canonicalize(const char *uri,
165 apr_pool_t *pool);
167 /** Return a new relpath like @a relpath, but transformed such that some types
168 * of relpath specification redundancies are removed.
170 * This involves collapsing redundant "/./" elements, removing
171 * multiple adjacent separator characters, removing trailing
172 * separator characters, and possibly other semantically inoperative
173 * transformations.
175 * This functions supports relpaths.
177 * The returned relpath may be statically allocated or allocated from @a
178 * pool.
180 * From svn_dirent_uri.h.
182 const char *
183 svn_relpath_canonicalize(const char *uri,
184 apr_pool_t *pool);
186 /** Remove file @a path, a utf8-encoded path. This wraps apr_file_remove(),
187 * converting any error to a Subversion error. If @a ignore_enoent is TRUE, and
188 * the file is not present (APR_STATUS_IS_ENOENT returns TRUE), then no
189 * error will be returned.
191 * From svn_io.h.
193 svn_error_t *
194 svn_io_remove_file2(const char *path,
195 svn_boolean_t ignore_enoent,
196 apr_pool_t *scratch_pool);
199 /** @defgroup apr_hash_utilities APR Hash Table Helpers
200 * These functions enable the caller to dereference an APR hash table index
201 * without type casts or temporary variables.
203 * ### These are private, and may go away when APR implements them natively.
205 * From svn_types.h.
206 * @{
209 /** Return the key of the hash table entry indexed by @a hi. */
210 const void *
211 svn__apr_hash_index_key(const apr_hash_index_t *hi);
213 /** Return the value of the hash table entry indexed by @a hi. */
214 void *
215 svn__apr_hash_index_val(const apr_hash_index_t *hi);
217 /** @} */
219 /* From svn_private_config.h.
221 #define PACKAGE_NAME "subversion"
222 #define N_(x) x
223 #include <locale.h>
224 #include <libintl.h>
225 #define _(x) dgettext(PACKAGE_NAME, x)
227 /** Sets the config options in @a config_options, an apr array containing
228 * svn_cmdline__config_argument_t* elements to the configuration in @a cfg,
229 * a hash mapping of <tt>const char *</tt> configuration file names to
230 * @c svn_config_t *'s. Write warnings to stderr.
232 * Use @a prefix as prefix and @a argument_name in warning messages.
234 * From private/svn_cmdline_private.h.
236 svn_error_t *
237 svn_cmdline__apply_config_options(apr_hash_t *config,
238 const apr_array_header_t *config_options,
239 const char *prefix,
240 const char *argument_name);
242 /** Container for config options parsed with svn_cmdline__parse_config_option
244 * From private/svn_cmdline_private.h.
246 typedef struct svn_cmdline__config_argument_t
248 const char *file;
249 const char *section;
250 const char *option;
251 const char *value;
252 } svn_cmdline__config_argument_t;
254 /** Parser for 'FILE:SECTION:OPTION=[VALUE]'-style option arguments.
256 * Parses @a opt_arg and places its value in @a config_options, an apr array
257 * containing svn_cmdline__config_argument_t* elements, allocating the option
258 * data in @a pool
260 * From private/svn_cmdline_private.h.
262 svn_error_t *
263 svn_cmdline__parse_config_option(apr_array_header_t *config_options,
264 const char *opt_arg,
265 apr_pool_t *pool);
268 #endif /* SVN17_COMPAT_H */