00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 * ==================================================================== 00021 * @endcopyright 00022 * 00023 * @file svn_path.h 00024 * @brief A path manipulation library 00025 * 00026 * All incoming and outgoing paths are non-NULL and in UTF-8, unless 00027 * otherwise documented. 00028 * 00029 * No result path ever ends with a separator, no matter whether the 00030 * path is a file or directory, because we always canonicalize() it. 00031 * 00032 * Nearly all the @c svn_path_xxx functions expect paths passed into 00033 * them to be in canonical form as defined by the Subversion path 00034 * library itself. The only functions which do *not* have such 00035 * expectations are: 00036 * 00037 * - @c svn_path_canonicalize() 00038 * - @c svn_path_is_canonical() 00039 * - @c svn_path_internal_style() 00040 * - @c svn_path_uri_encode() 00041 * 00042 * For the most part, we mean what most anyone would mean when talking 00043 * about canonical paths, but to be on the safe side, you must run 00044 * your paths through @c svn_path_canonicalize() before passing them to 00045 * other functions in this API. 00046 */ 00047 00048 #ifndef SVN_PATH_H 00049 #define SVN_PATH_H 00050 00051 #include <apr.h> 00052 #include <apr_pools.h> 00053 #include <apr_tables.h> 00054 00055 #include "svn_types.h" 00056 #include "svn_string.h" 00057 #include "svn_dirent_uri.h" 00058 00059 00060 #ifdef __cplusplus 00061 extern "C" { 00062 #endif /* __cplusplus */ 00063 00064 00065 00066 /** Convert @a path from the local style to the canonical internal style. 00067 * 00068 * @deprecated Provided for backward compatibility with the 1.6 API. 00069 * New code should use svn_dirent_internal_style(). 00070 */ 00071 SVN_DEPRECATED 00072 const char * 00073 svn_path_internal_style(const char *path, apr_pool_t *pool); 00074 00075 /** Convert @a path from the canonical internal style to the local style. 00076 * 00077 * @deprecated Provided for backward compatibility with the 1.6 API. 00078 * New code should use svn_dirent_local_style(). 00079 */ 00080 SVN_DEPRECATED 00081 const char * 00082 svn_path_local_style(const char *path, apr_pool_t *pool); 00083 00084 00085 /** Join a base path (@a base) with a component (@a component), allocating 00086 * the result in @a pool. @a component need not be a single component: it 00087 * can be any path, absolute or relative to @a base. 00088 * 00089 * If either @a base or @a component is the empty path, then the other 00090 * argument will be copied and returned. If both are the empty path the 00091 * empty path is returned. 00092 * 00093 * If the @a component is an absolute path, then it is copied and returned. 00094 * Exactly one slash character ('/') is used to join the components, 00095 * accounting for any trailing slash in @a base. 00096 * 00097 * Note that the contents of @a base are not examined, so it is possible to 00098 * use this function for constructing URLs, or for relative URLs or 00099 * repository paths. 00100 * 00101 * This function is NOT appropriate for native (local) file 00102 * paths. Only for "internal" canonicalized paths, since it uses '/' 00103 * for the separator. Further, an absolute path (for @a component) is 00104 * based on a leading '/' character. Thus, an "absolute URI" for the 00105 * @a component won't be detected. An absolute URI can only be used 00106 * for the base. 00107 * 00108 * @deprecated Provided for backward compatibility with the 1.6 API. 00109 * New code should use svn_dirent_join(), svn_relpath_join() or 00110 * svn_fspath__join(). 00111 */ 00112 SVN_DEPRECATED 00113 char * 00114 svn_path_join(const char *base, const char *component, apr_pool_t *pool); 00115 00116 /** Join multiple components onto a @a base path, allocated in @a pool. The 00117 * components are terminated by a @c NULL. 00118 * 00119 * If any component is the empty string, it will be ignored. 00120 * 00121 * If any component is an absolute path, then it resets the base and 00122 * further components will be appended to it. 00123 * 00124 * This function does not support URLs. 00125 * 00126 * See svn_path_join() for further notes about joining paths. 00127 * 00128 * @deprecated Provided for backward compatibility with the 1.6 API. 00129 * For new code, consider using svn_dirent_join_many() or a sequence of 00130 * calls to one of the *_join() functions. 00131 */ 00132 SVN_DEPRECATED 00133 char * 00134 svn_path_join_many(apr_pool_t *pool, const char *base, ...); 00135 00136 00137 /** Get the basename of the specified canonicalized @a path. The 00138 * basename is defined as the last component of the path (ignoring any 00139 * trailing slashes). If the @a path is root ("/"), then that is 00140 * returned. Otherwise, the returned value will have no slashes in 00141 * it. 00142 * 00143 * Example: svn_path_basename("/foo/bar") -> "bar" 00144 * 00145 * The returned basename will be allocated in @a pool. 00146 * 00147 * @note If an empty string is passed, then an empty string will be returned. 00148 * 00149 * @deprecated Provided for backward compatibility with the 1.6 API. 00150 * New code should use svn_dirent_basename(), svn_uri_basename(), 00151 * svn_relpath_basename() or svn_fspath__basename(). 00152 */ 00153 SVN_DEPRECATED 00154 char * 00155 svn_path_basename(const char *path, apr_pool_t *pool); 00156 00157 /** Get the dirname of the specified canonicalized @a path, defined as 00158 * the path with its basename removed. If @a path is root ("/"), it is 00159 * returned unchanged. 00160 * 00161 * The returned dirname will be allocated in @a pool. 00162 * 00163 * @deprecated Provided for backward compatibility with the 1.6 API. 00164 * New code should use svn_dirent_dirname(), svn_uri_dirname(), 00165 * svn_relpath_dirname() or svn_fspath__dirname(). 00166 */ 00167 SVN_DEPRECATED 00168 char * 00169 svn_path_dirname(const char *path, apr_pool_t *pool); 00170 00171 /** Split @a path into a root portion and an extension such that 00172 * the root + the extension = the original path, and where the 00173 * extension contains no period (.) characters. If not @c NULL, set 00174 * @a *path_root to the root portion. If not @c NULL, set 00175 * @a *path_ext to the extension (or "" if there is no extension 00176 * found). Allocate both @a *path_root and @a *path_ext in @a pool. 00177 * 00178 * @since New in 1.5. 00179 */ 00180 void 00181 svn_path_splitext(const char **path_root, const char **path_ext, 00182 const char *path, apr_pool_t *pool); 00183 00184 /** Return the number of components in the canonicalized @a path. 00185 * 00186 * @since New in 1.1. 00187 */ 00188 apr_size_t 00189 svn_path_component_count(const char *path); 00190 00191 /** Add a @a component (a NULL-terminated C-string) to the 00192 * canonicalized @a path. @a component is allowed to contain 00193 * directory separators. 00194 * 00195 * If @a path is non-empty, append the appropriate directory separator 00196 * character, and then @a component. If @a path is empty, simply set it to 00197 * @a component; don't add any separator character. 00198 * 00199 * If the result ends in a separator character, then remove the separator. 00200 */ 00201 void 00202 svn_path_add_component(svn_stringbuf_t *path, const char *component); 00203 00204 /** Remove one component off the end of the canonicalized @a path. */ 00205 void 00206 svn_path_remove_component(svn_stringbuf_t *path); 00207 00208 /** Remove @a n components off the end of the canonicalized @a path. 00209 * Equivalent to calling svn_path_remove_component() @a n times. 00210 * 00211 * @since New in 1.1. 00212 */ 00213 void 00214 svn_path_remove_components(svn_stringbuf_t *path, apr_size_t n); 00215 00216 /** Divide the canonicalized @a path into @a *dirpath and @a 00217 * *base_name, allocated in @a pool. 00218 * 00219 * If @a dirpath or @a base_name is NULL, then don't set that one. 00220 * 00221 * Either @a dirpath or @a base_name may be @a path's own address, but they 00222 * may not both be the same address, or the results are undefined. 00223 * 00224 * If @a path has two or more components, the separator between @a dirpath 00225 * and @a base_name is not included in either of the new names. 00226 * 00227 * examples: 00228 * - <pre>"/foo/bar/baz" ==> "/foo/bar" and "baz"</pre> 00229 * - <pre>"/bar" ==> "/" and "bar"</pre> 00230 * - <pre>"/" ==> "/" and "/"</pre> 00231 * - <pre>"X:/" ==> "X:/" and "X:/"</pre> 00232 * - <pre>"bar" ==> "" and "bar"</pre> 00233 * - <pre>"" ==> "" and ""</pre> 00234 * 00235 * @deprecated Provided for backward compatibility with the 1.6 API. 00236 * New code should use svn_dirent_split(), svn_uri_split(), 00237 * svn_relpath_split() or svn_fspath__split(). 00238 */ 00239 SVN_DEPRECATED 00240 void 00241 svn_path_split(const char *path, 00242 const char **dirpath, 00243 const char **base_name, 00244 apr_pool_t *pool); 00245 00246 00247 /** Return non-zero iff @a path is empty ("") or represents the current 00248 * directory -- that is, if prepending it as a component to an existing 00249 * path would result in no meaningful change. 00250 */ 00251 int 00252 svn_path_is_empty(const char *path); 00253 00254 00255 #ifndef SVN_DIRENT_URI_H 00256 /* This declaration has been moved to svn_dirent_uri.h, and remains 00257 here only for compatibility reasons. */ 00258 svn_boolean_t 00259 svn_dirent_is_root(const char *dirent, apr_size_t len); 00260 #endif /* SVN_DIRENT_URI_H */ 00261 00262 00263 /** Return a new path (or URL) like @a path, but transformed such that 00264 * some types of path specification redundancies are removed. 00265 * 00266 * This involves collapsing redundant "/./" elements, removing 00267 * multiple adjacent separator characters, removing trailing 00268 * separator characters, and possibly other semantically inoperative 00269 * transformations. 00270 * 00271 * Convert the scheme and hostname to lowercase (see issue #2475) 00272 * 00273 * The returned path may be statically allocated, equal to @a path, or 00274 * allocated from @a pool. 00275 * 00276 * @deprecated Provided for backward compatibility with the 1.6 API. 00277 * New code should use svn_dirent_canonicalize(), svn_uri_canonicalize(), 00278 * svn_relpath_canonicalize() or svn_fspath__canonicalize(). 00279 */ 00280 SVN_DEPRECATED 00281 const char * 00282 svn_path_canonicalize(const char *path, apr_pool_t *pool); 00283 00284 /** Return @c TRUE iff path is canonical. Use @a pool for temporary 00285 * allocations. 00286 * 00287 * @since New in 1.5. 00288 * @deprecated Provided for backward compatibility with the 1.6 API. 00289 * New code should use svn_dirent_is_canonical(), svn_uri_is_canonical(), 00290 * svn_relpath_is_canonical() or svn_fspath__is_canonical(). 00291 */ 00292 SVN_DEPRECATED 00293 svn_boolean_t 00294 svn_path_is_canonical(const char *path, apr_pool_t *pool); 00295 00296 00297 /** Return an integer greater than, equal to, or less than 0, according 00298 * as @a path1 is greater than, equal to, or less than @a path2. 00299 * 00300 * This function works like strcmp() except that it orders children in 00301 * subdirectories directly after their parents. This allows using the 00302 * given ordering for a depth first walk. 00303 */ 00304 int 00305 svn_path_compare_paths(const char *path1, const char *path2); 00306 00307 00308 /** Return the longest common path shared by two canonicalized paths, 00309 * @a path1 and @a path2. If there's no common ancestor, return the 00310 * empty path. 00311 * 00312 * @a path1 and @a path2 may be URLs. In order for two URLs to have 00313 * a common ancestor, they must (a) have the same protocol (since two URLs 00314 * with the same path but different protocols may point at completely 00315 * different resources), and (b) share a common ancestor in their path 00316 * component, i.e. 'protocol://' is not a sufficient ancestor. 00317 * 00318 * @deprecated Provided for backward compatibility with the 1.6 API. 00319 * New code should use svn_dirent_get_longest_ancestor(), 00320 * svn_uri_get_longest_ancestor(), svn_relpath_get_longest_ancestor() or 00321 * svn_fspath__get_longest_ancestor(). 00322 */ 00323 SVN_DEPRECATED 00324 char * 00325 svn_path_get_longest_ancestor(const char *path1, 00326 const char *path2, 00327 apr_pool_t *pool); 00328 00329 /** Convert @a relative canonicalized path to an absolute path and 00330 * return the results in @a *pabsolute, allocated in @a pool. 00331 * 00332 * @a relative may be a URL, in which case no attempt is made to convert it, 00333 * and a copy of the URL is returned. 00334 * 00335 * @deprecated Provided for backward compatibility with the 1.6 API. 00336 * New code should use svn_dirent_get_absolute() on a non-URL input. 00337 */ 00338 SVN_DEPRECATED 00339 svn_error_t * 00340 svn_path_get_absolute(const char **pabsolute, 00341 const char *relative, 00342 apr_pool_t *pool); 00343 00344 /** Return the path part of the canonicalized @a path in @a 00345 * *pdirectory, and the file part in @a *pfile. If @a path is a 00346 * directory, set @a *pdirectory to @a path, and @a *pfile to the 00347 * empty string. If @a path does not exist it is treated as if it is 00348 * a file, since directories do not normally vanish. 00349 * 00350 * @deprecated Provided for backward compatibility with the 1.6 API. 00351 * New code should implement the required logic directly; no direct 00352 * replacement is provided. 00353 */ 00354 SVN_DEPRECATED 00355 svn_error_t * 00356 svn_path_split_if_file(const char *path, 00357 const char **pdirectory, 00358 const char **pfile, 00359 apr_pool_t *pool); 00360 00361 /** Find the common prefix of the canonicalized paths in @a targets 00362 * (an array of <tt>const char *</tt>'s), and remove redundant paths if @a 00363 * remove_redundancies is TRUE. 00364 * 00365 * - Set @a *pcommon to the absolute path of the path or URL common to 00366 * all of the targets. If the targets have no common prefix, or 00367 * are a mix of URLs and local paths, set @a *pcommon to the 00368 * empty string. 00369 * 00370 * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets 00371 * to an array of targets relative to @a *pcommon, and if 00372 * @a remove_redundancies is TRUE, omit any paths/URLs that are 00373 * descendants of another path/URL in @a targets. If *pcommon 00374 * is empty, @a *pcondensed_targets will contain full URLs and/or 00375 * absolute paths; redundancies can still be removed (from both URLs 00376 * and paths). If @a pcondensed_targets is NULL, leave it alone. 00377 * 00378 * Else if there is exactly one target, then 00379 * 00380 * - Set @a *pcommon to that target, and 00381 * 00382 * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets 00383 * to an array containing zero elements. Else if 00384 * @a pcondensed_targets is NULL, leave it alone. 00385 * 00386 * If there are no items in @a targets, set @a *pcommon and (if 00387 * applicable) @a *pcondensed_targets to @c NULL. 00388 * 00389 * @note There is no guarantee that @a *pcommon is within a working 00390 * copy. 00391 * 00392 * @deprecated Provided for backward compatibility with the 1.6 API. 00393 * New code should use svn_dirent_condense_targets() or 00394 * svn_uri_condense_targets(). 00395 */ 00396 SVN_DEPRECATED 00397 svn_error_t * 00398 svn_path_condense_targets(const char **pcommon, 00399 apr_array_header_t **pcondensed_targets, 00400 const apr_array_header_t *targets, 00401 svn_boolean_t remove_redundancies, 00402 apr_pool_t *pool); 00403 00404 00405 /** Copy a list of canonicalized @a targets, one at a time, into @a 00406 * pcondensed_targets, omitting any targets that are found earlier in 00407 * the list, or whose ancestor is found earlier in the list. Ordering 00408 * of targets in the original list is preserved in the condensed list 00409 * of targets. Use @a pool for any allocations. 00410 * 00411 * How does this differ in functionality from svn_path_condense_targets()? 00412 * 00413 * Here's the short version: 00414 * 00415 * 1. Disclaimer: if you wish to debate the following, talk to Karl. :-) 00416 * Order matters for updates because a multi-arg update is not 00417 * atomic, and CVS users are used to, when doing 'cvs up targetA 00418 * targetB' seeing targetA get updated, then targetB. I think the 00419 * idea is that if you're in a time-sensitive or flaky-network 00420 * situation, a user can say, "I really *need* to update 00421 * wc/A/D/G/tau, but I might as well update my whole working copy if 00422 * I can." So that user will do 'svn up wc/A/D/G/tau wc', and if 00423 * something dies in the middles of the 'wc' update, at least the 00424 * user has 'tau' up-to-date. 00425 * 00426 * 2. Also, we have this notion of an anchor and a target for updates 00427 * (the anchor is where the update editor is rooted, the target is 00428 * the actual thing we want to update). I needed a function that 00429 * would NOT screw with my input paths so that I could tell the 00430 * difference between someone being in A/D and saying 'svn up G' and 00431 * being in A/D/G and saying 'svn up .' -- believe it or not, these 00432 * two things don't mean the same thing. svn_path_condense_targets() 00433 * plays with absolute paths (which is fine, so does 00434 * svn_path_remove_redundancies()), but the difference is that it 00435 * actually tweaks those targets to be relative to the "grandfather 00436 * path" common to all the targets. Updates don't require a 00437 * "grandfather path" at all, and even if it did, the whole 00438 * conversion to an absolute path drops the crucial difference 00439 * between saying "i'm in foo, update bar" and "i'm in foo/bar, 00440 * update '.'" 00441 */ 00442 svn_error_t * 00443 svn_path_remove_redundancies(apr_array_header_t **pcondensed_targets, 00444 const apr_array_header_t *targets, 00445 apr_pool_t *pool); 00446 00447 00448 /** Decompose the canonicalized @a path into an array of <tt>const 00449 * char *</tt> components, allocated in @a pool. If @a path is 00450 * absolute, the first component will be a lone dir separator (the 00451 * root directory). 00452 */ 00453 apr_array_header_t * 00454 svn_path_decompose(const char *path, apr_pool_t *pool); 00455 00456 /** Join an array of <tt>const char *</tt> components into a '/' 00457 * separated path, allocated in @a pool. The joined path is absolute if 00458 * the first component is a lone dir separator. 00459 * 00460 * Calling svn_path_compose() on the output of svn_path_decompose() 00461 * will return the exact same path. 00462 * 00463 * @since New in 1.5. 00464 */ 00465 const char * 00466 svn_path_compose(const apr_array_header_t *components, apr_pool_t *pool); 00467 00468 /** Test that @a name is a single path component, that is: 00469 * - not @c NULL or empty. 00470 * - not a `/'-separated directory path 00471 * - not empty or `..' 00472 */ 00473 svn_boolean_t 00474 svn_path_is_single_path_component(const char *name); 00475 00476 00477 /** 00478 * Test to see if a backpath, i.e. '..', is present in @a path. 00479 * If not, return @c FALSE. 00480 * If so, return @c TRUE. 00481 * 00482 * @since New in 1.1. 00483 */ 00484 svn_boolean_t 00485 svn_path_is_backpath_present(const char *path); 00486 00487 00488 /** 00489 * Test to see if a dotpath, i.e. '.', is present in @a path. 00490 * If not, return @c FALSE. 00491 * If so, return @c TRUE. 00492 * 00493 * @since New in 1.6. 00494 */ 00495 svn_boolean_t 00496 svn_path_is_dotpath_present(const char *path); 00497 00498 00499 /** Test if @a path2 is a child of @a path1. 00500 * If not, return @c NULL. 00501 * If so, return a copy of the remainder path, allocated in @a pool. 00502 * (The remainder is the component which, added to @a path1, yields 00503 * @a path2. The remainder does not begin with a dir separator.) 00504 * 00505 * Both paths must be in canonical form, and must either be absolute, 00506 * or contain no ".." components. 00507 * 00508 * If @a path2 is the same as @a path1, it is not considered a child, so the 00509 * result is @c NULL; an empty string is never returned. 00510 * 00511 * @note In 1.5 this function has been extended to allow a @c NULL @a pool 00512 * in which case a pointer into @a path2 will be returned to 00513 * identify the remainder path. 00514 * 00515 * @deprecated Provided for backward compatibility with the 1.6 API. 00516 * For replacement functionality, see svn_dirent_skip_ancestor(), 00517 * svn_dirent_is_child(), svn_uri_skip_ancestor(), and 00518 * svn_relpath_skip_ancestor(). 00519 */ 00520 SVN_DEPRECATED 00521 const char * 00522 svn_path_is_child(const char *path1, const char *path2, apr_pool_t *pool); 00523 00524 /** Return TRUE if @a path1 is an ancestor of @a path2 or the paths are equal 00525 * and FALSE otherwise. 00526 * 00527 * @since New in 1.3. 00528 * 00529 * @deprecated Provided for backward compatibility with the 1.6 API. 00530 * For replacement functionality, see svn_dirent_skip_ancestor(), 00531 * svn_uri_skip_ancestor(), and svn_relpath_skip_ancestor(). 00532 */ 00533 SVN_DEPRECATED 00534 svn_boolean_t 00535 svn_path_is_ancestor(const char *path1, const char *path2); 00536 00537 /** 00538 * Check whether @a path is a valid Subversion path. 00539 * 00540 * A valid Subversion pathname is a UTF-8 string without control 00541 * characters. "Valid" means Subversion can store the pathname in 00542 * a repository. There may be other, OS-specific, limitations on 00543 * what paths can be represented in a working copy. 00544 * 00545 * ASSUMPTION: @a path is a valid UTF-8 string. This function does 00546 * not check UTF-8 validity. 00547 * 00548 * Return @c SVN_NO_ERROR if valid and @c SVN_ERR_FS_PATH_SYNTAX if 00549 * invalid. 00550 * 00551 * @note Despite returning an @c SVN_ERR_FS_* error, this function has 00552 * nothing to do with the versioned filesystem's concept of validity. 00553 * 00554 * @since New in 1.2. 00555 */ 00556 svn_error_t * 00557 svn_path_check_valid(const char *path, apr_pool_t *pool); 00558 00559 00560 /** URI/URL stuff 00561 * 00562 * @defgroup svn_path_uri_stuff URI/URL conversion 00563 * @{ 00564 */ 00565 00566 /** Return TRUE iff @a path looks like a valid absolute URL. */ 00567 svn_boolean_t 00568 svn_path_is_url(const char *path); 00569 00570 /** Return @c TRUE iff @a path is URI-safe, @c FALSE otherwise. */ 00571 svn_boolean_t 00572 svn_path_is_uri_safe(const char *path); 00573 00574 /** Return a URI-encoded copy of @a path, allocated in @a pool. (@a 00575 path can be an arbitrary UTF-8 string and does not have to be a 00576 canonical path.) */ 00577 const char * 00578 svn_path_uri_encode(const char *path, apr_pool_t *pool); 00579 00580 /** Return a URI-decoded copy of @a path, allocated in @a pool. */ 00581 const char * 00582 svn_path_uri_decode(const char *path, apr_pool_t *pool); 00583 00584 /** Extend @a url by @a component, URI-encoding that @a component 00585 * before adding it to the @a url; return the new @a url, allocated in 00586 * @a pool. If @a component is @c NULL, just return a copy of @a url, 00587 * allocated in @a pool. 00588 * 00589 * @a component need not be a single path segment, but if it contains 00590 * multiple segments, they must be separated by '/'. @a component 00591 * should not begin with '/', however; if it does, the behavior is 00592 * undefined. 00593 * 00594 * @a url must be in canonical format; it may not have a trailing '/'. 00595 * 00596 * @note To add a component that is already URI-encoded, use 00597 * <tt>svn_path_join(url, component, pool)</tt> instead. 00598 * 00599 * @note gstein suggests this for when @a component begins with '/': 00600 * 00601 * "replace the path entirely 00602 * https://example.com:4444/base/path joined with /leading/slash, 00603 * should return: https://example.com:4444/leading/slash 00604 * per the RFCs on combining URIs" 00605 * 00606 * We may implement that someday, which is why leading '/' is 00607 * merely undefined right now. 00608 * 00609 * @since New in 1.6. 00610 */ 00611 const char * 00612 svn_path_url_add_component2(const char *url, 00613 const char *component, 00614 apr_pool_t *pool); 00615 00616 /** Like svn_path_url_add_component2(), but allows path components that 00617 * end with a trailing '/' 00618 * 00619 * @deprecated Provided for backward compatibility with the 1.5 API. 00620 */ 00621 SVN_DEPRECATED 00622 const char * 00623 svn_path_url_add_component(const char *url, 00624 const char *component, 00625 apr_pool_t *pool); 00626 00627 /** 00628 * Convert @a iri (Internationalized URI) to an URI. 00629 * The return value may be the same as @a iri if it was already 00630 * a URI. Else, allocate the return value in @a pool. 00631 * 00632 * @since New in 1.1. 00633 */ 00634 const char * 00635 svn_path_uri_from_iri(const char *iri, apr_pool_t *pool); 00636 00637 /** 00638 * URI-encode certain characters in @a uri that are not valid in an URI, but 00639 * doesn't have any special meaning in @a uri at their positions. If no 00640 * characters need escaping, just return @a uri. 00641 * 00642 * @note Currently, this function escapes <, >, ", space, {, }, |, \, ^, and `. 00643 * This may be extended in the future to do context-dependent escaping. 00644 * 00645 * @since New in 1.1. 00646 */ 00647 const char * 00648 svn_path_uri_autoescape(const char *uri, apr_pool_t *pool); 00649 00650 /** @} */ 00651 00652 /** Charset conversion stuff 00653 * 00654 * @defgroup svn_path_charset_stuff Charset conversion 00655 * @{ 00656 */ 00657 00658 /** Convert @a path_utf8 from UTF-8 to the internal encoding used by APR. */ 00659 svn_error_t * 00660 svn_path_cstring_from_utf8(const char **path_apr, 00661 const char *path_utf8, 00662 apr_pool_t *pool); 00663 00664 /** Convert @a path_apr from the internal encoding used by APR to UTF-8. */ 00665 svn_error_t * 00666 svn_path_cstring_to_utf8(const char **path_utf8, 00667 const char *path_apr, 00668 apr_pool_t *pool); 00669 00670 00671 /** @} */ 00672 00673 00674 /** Repository relative URLs 00675 * 00676 * @defgroup svn_path_repos_relative_urls Repository relative URLs 00677 * @{ 00678 */ 00679 00680 /** 00681 * Return @c TRUE iff @a path is a repository-relative URL: specifically 00682 * that it starts with the characters "^/" 00683 * 00684 * @a path is in UTF-8 encoding. 00685 * 00686 * Does not check whether @a path is a properly URI-encoded, canonical, or 00687 * valid in any other way. 00688 * 00689 * @since New in 1.8. 00690 */ 00691 svn_boolean_t 00692 svn_path_is_repos_relative_url(const char *path); 00693 00694 /** 00695 * Set @a absolute_url to the absolute URL represented by @a relative_url 00696 * relative to @a repos_root_url, preserving any peg revision 00697 * specifier present in @a relative_url. Allocate @a absolute_url 00698 * from @a pool. 00699 * 00700 * @a relative_url is in repository-relative syntax: "^/[REL-URL][@PEG]" 00701 * 00702 * @a repos_root_url is the absolute URL of the repository root. 00703 * 00704 * All strings are in UTF-8 encoding. 00705 * 00706 * @a repos_root_url and @a relative_url do not have to be properly 00707 * URI-encoded, canonical, or valid in any other way. The caller is 00708 * expected to perform canonicalization on @a absolute_url after the 00709 * call to the function. 00710 * 00711 * @since New in 1.8. 00712 */ 00713 svn_error_t * 00714 svn_path_resolve_repos_relative_url(const char **absolute_url, 00715 const char *relative_url, 00716 const char *repos_root_url, 00717 apr_pool_t *pool); 00718 00719 /* Return a copy of @a path, allocated from @a pool, for which control 00720 * characters have been escaped using the form \NNN (where NNN is the 00721 * octal representation of the byte's ordinal value). 00722 * 00723 * @since New in 1.8. */ 00724 const char * 00725 svn_path_illegal_path_escape(const char *path, apr_pool_t *pool); 00726 00727 /** @} */ 00728 00729 #ifdef __cplusplus 00730 } 00731 #endif /* __cplusplus */ 00732 00733 00734 #endif /* SVN_PATH_H */