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_subst.h 00024 * @brief Data substitution (keywords and EOL style) 00025 */ 00026 00027 00028 00029 #ifndef SVN_SUBST_H 00030 #define SVN_SUBST_H 00031 00032 #include <apr_pools.h> 00033 #include <apr_hash.h> 00034 #include <apr_time.h> 00035 00036 #include "svn_types.h" 00037 #include "svn_string.h" 00038 #include "svn_io.h" 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif /* __cplusplus */ 00043 00044 /* EOL conversion and keyword expansion. */ 00045 00046 /** The EOL used in the Repository for "native" files */ 00047 #define SVN_SUBST_NATIVE_EOL_STR "\n" 00048 00049 /** Valid states for 'svn:eol-style' property. 00050 * 00051 * Property nonexistence is equivalent to 'none'. 00052 */ 00053 typedef enum svn_subst_eol_style 00054 { 00055 /** An unrecognized style */ 00056 svn_subst_eol_style_unknown, 00057 00058 /** EOL translation is "off" or ignored value */ 00059 svn_subst_eol_style_none, 00060 00061 /** Translation is set to client's native eol */ 00062 svn_subst_eol_style_native, 00063 00064 /** Translation is set to one of LF, CR, CRLF */ 00065 svn_subst_eol_style_fixed 00066 00067 } svn_subst_eol_style_t; 00068 00069 /** Set @a *style to the appropriate @c svn_subst_eol_style_t and @a *eol to 00070 * the appropriate cstring for a given svn:eol-style property value. 00071 * 00072 * Set @a *eol to 00073 * 00074 * - @c NULL for @c svn_subst_eol_style_none, or 00075 * 00076 * - a NULL-terminated C string containing the native eol marker 00077 * for this platform, for @c svn_subst_eol_style_native, or 00078 * 00079 * - a NULL-terminated C string containing the eol marker indicated 00080 * by the property value, for @c svn_subst_eol_style_fixed. 00081 * 00082 * If @a *style is NULL, it is ignored. 00083 */ 00084 void 00085 svn_subst_eol_style_from_value(svn_subst_eol_style_t *style, 00086 const char **eol, 00087 const char *value); 00088 00089 /** Indicates whether the working copy and normalized versions of a file 00090 * with the given the parameters differ. If @a force_eol_check is TRUE, 00091 * the routine also accounts for all translations required due to repairing 00092 * fixed eol styles. 00093 * 00094 * @since New in 1.4 00095 * 00096 */ 00097 svn_boolean_t 00098 svn_subst_translation_required(svn_subst_eol_style_t style, 00099 const char *eol, 00100 apr_hash_t *keywords, 00101 svn_boolean_t special, 00102 svn_boolean_t force_eol_check); 00103 00104 00105 /** Values used in keyword expansion. 00106 * 00107 * @deprecated Provided for backward compatibility with the 1.2 API. 00108 */ 00109 typedef struct svn_subst_keywords_t 00110 { 00111 /** 00112 * @name svn_subst_keywords_t fields 00113 * String expansion of the like-named keyword, or NULL if the keyword 00114 * was not selected in the svn:keywords property. 00115 * @{ 00116 */ 00117 const svn_string_t *revision; 00118 const svn_string_t *date; 00119 const svn_string_t *author; 00120 const svn_string_t *url; 00121 const svn_string_t *id; 00122 /** @} */ 00123 } svn_subst_keywords_t; 00124 00125 00126 /** 00127 * Set @a *kw to a new keywords hash filled with the appropriate contents 00128 * given a @a keywords_string (the contents of the svn:keywords 00129 * property for the file in question), the revision @a rev, the @a url, 00130 * the @a date the file was committed on, the @a author of the last 00131 * commit, and the URL of the repository root @a repos_root_url. 00132 * 00133 * Custom keywords defined in svn:keywords properties are expanded 00134 * using the provided parameters and in accordance with the following 00135 * format substitutions in the @a keywords_string: 00136 * %a - The author. 00137 * %b - The basename of the URL. 00138 * %d - Short format of the date. 00139 * %D - Long format of the date. 00140 * %P - The file's path, relative to the repository root URL. 00141 * %r - The revision. 00142 * %R - The URL to the root of the repository. 00143 * %u - The URL of the file. 00144 * %_ - A space (keyword definitions cannot contain a literal space). 00145 * %% - A literal '%'. 00146 * %H - Equivalent to %P%_%r%_%d%_%a. 00147 * %I - Equivalent to %b%_%r%_%d%_%a. 00148 * 00149 * Custom keywords are defined by appending '=' to the keyword name, followed 00150 * by a string containing any combination of the format substitutions. 00151 * 00152 * Any of the inputs @a rev, @a url, @a date, @a author, and @a repos_root_url 00153 * can be @c NULL, or @c 0 for @a date, to indicate that the information is 00154 * not present. Each piece of information that is not present expands to the 00155 * empty string wherever it appears in an expanded keyword value. (This can 00156 * result in multiple adjacent spaces in the expansion of a multi-valued 00157 * keyword such as "Id".) 00158 * 00159 * Hash keys are of type <tt>const char *</tt>. 00160 * Hash values are of type <tt>svn_string_t *</tt>. 00161 * 00162 * All memory is allocated out of @a pool. 00163 * 00164 * @since New in 1.8. 00165 */ 00166 svn_error_t * 00167 svn_subst_build_keywords3(apr_hash_t **kw, 00168 const char *keywords_string, 00169 const char *rev, 00170 const char *url, 00171 const char *repos_root_url, 00172 apr_time_t date, 00173 const char *author, 00174 apr_pool_t *pool); 00175 00176 /** Similar to svn_subst_build_keywords3() except that it does not accept 00177 * the @a repos_root_url parameter and hence supports less substitutions, 00178 * and also does not support custom keyword definitions. 00179 * 00180 * @since New in 1.3. 00181 * @deprecated Provided for backward compatibility with the 1.7 API. 00182 */ 00183 SVN_DEPRECATED 00184 svn_error_t * 00185 svn_subst_build_keywords2(apr_hash_t **kw, 00186 const char *keywords_string, 00187 const char *rev, 00188 const char *url, 00189 apr_time_t date, 00190 const char *author, 00191 apr_pool_t *pool); 00192 00193 /** Similar to svn_subst_build_keywords2() except that it populates 00194 * an existing structure @a *kw instead of creating a keywords hash. 00195 * 00196 * @deprecated Provided for backward compatibility with the 1.2 API. 00197 */ 00198 SVN_DEPRECATED 00199 svn_error_t * 00200 svn_subst_build_keywords(svn_subst_keywords_t *kw, 00201 const char *keywords_string, 00202 const char *rev, 00203 const char *url, 00204 apr_time_t date, 00205 const char *author, 00206 apr_pool_t *pool); 00207 00208 00209 /** Return @c TRUE if @a a and @a b do not hold the same keywords. 00210 * 00211 * @a a and @a b are hashes of the form produced by 00212 * svn_subst_build_keywords2(). 00213 * 00214 * @since New in 1.3. 00215 * 00216 * If @a compare_values is @c TRUE, "same" means that the @a a and @a b 00217 * contain exactly the same set of keywords, and the values of corresponding 00218 * keywords match as well. Else if @a compare_values is @c FALSE, then 00219 * "same" merely means that @a a and @a b hold the same set of keywords, 00220 * although those keywords' values might differ. 00221 * 00222 * @a a and/or @a b may be @c NULL; for purposes of comparison, @c NULL is 00223 * equivalent to holding no keywords. 00224 */ 00225 svn_boolean_t 00226 svn_subst_keywords_differ2(apr_hash_t *a, 00227 apr_hash_t *b, 00228 svn_boolean_t compare_values, 00229 apr_pool_t *pool); 00230 00231 /** Similar to svn_subst_keywords_differ2() except that it compares 00232 * two @c svn_subst_keywords_t structs instead of keyword hashes. 00233 * 00234 * @deprecated Provided for backward compatibility with the 1.2 API. 00235 */ 00236 SVN_DEPRECATED 00237 svn_boolean_t 00238 svn_subst_keywords_differ(const svn_subst_keywords_t *a, 00239 const svn_subst_keywords_t *b, 00240 svn_boolean_t compare_values); 00241 00242 00243 /** 00244 * Copy and translate the data in @a src_stream into @a dst_stream. It is 00245 * assumed that @a src_stream is a readable stream and @a dst_stream is a 00246 * writable stream. 00247 * 00248 * If @a eol_str is non-@c NULL, replace whatever bytestring @a src_stream 00249 * uses to denote line endings with @a eol_str in the output. If 00250 * @a src_stream has an inconsistent line ending style, then: if @a repair 00251 * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is 00252 * @c TRUE, convert any line ending in @a src_stream to @a eol_str in 00253 * @a dst_stream. Recognized line endings are: "\n", "\r", and "\r\n". 00254 * 00255 * See svn_subst_stream_translated() for details of the keyword substitution 00256 * which is controlled by the @a expand and @a keywords parameters. 00257 * 00258 * Note that a translation request is *required*: one of @a eol_str or 00259 * @a keywords must be non-@c NULL. 00260 * 00261 * Notes: 00262 * 00263 * See svn_wc__get_keywords() and svn_wc__get_eol_style() for a 00264 * convenient way to get @a eol_str and @a keywords if in libsvn_wc. 00265 * 00266 * @since New in 1.3. 00267 * 00268 * @deprecated Provided for backward compatibility with the 1.5 API. 00269 * Callers should use svn_subst_stream_translated() instead. 00270 */ 00271 SVN_DEPRECATED 00272 svn_error_t * 00273 svn_subst_translate_stream3(svn_stream_t *src_stream, 00274 svn_stream_t *dst_stream, 00275 const char *eol_str, 00276 svn_boolean_t repair, 00277 apr_hash_t *keywords, 00278 svn_boolean_t expand, 00279 apr_pool_t *scratch_pool); 00280 00281 00282 /** Similar to svn_subst_translate_stream3() except relies upon a 00283 * @c svn_subst_keywords_t struct instead of a hash for the keywords. 00284 * 00285 * @deprecated Provided for backward compatibility with the 1.2 API. 00286 */ 00287 SVN_DEPRECATED 00288 svn_error_t * 00289 svn_subst_translate_stream2(svn_stream_t *src_stream, 00290 svn_stream_t *dst_stream, 00291 const char *eol_str, 00292 svn_boolean_t repair, 00293 const svn_subst_keywords_t *keywords, 00294 svn_boolean_t expand, 00295 apr_pool_t *scratch_pool); 00296 00297 00298 /** 00299 * Same as svn_subst_translate_stream2(), but does not take a @a pool 00300 * argument, instead creates a temporary subpool of the global pool, and 00301 * destroys it before returning. 00302 * 00303 * @deprecated Provided for backward compatibility with the 1.1 API. 00304 */ 00305 SVN_DEPRECATED 00306 svn_error_t * 00307 svn_subst_translate_stream(svn_stream_t *src_stream, 00308 svn_stream_t *dst_stream, 00309 const char *eol_str, 00310 svn_boolean_t repair, 00311 const svn_subst_keywords_t *keywords, 00312 svn_boolean_t expand); 00313 00314 00315 /** Return a stream which performs eol translation and keyword 00316 * expansion when read from or written to. The stream @a stream 00317 * is used to read and write all data. 00318 * 00319 * Make sure you call svn_stream_close() on the returned stream to 00320 * ensure all data is flushed and cleaned up (this will also close 00321 * the provided @a stream). 00322 * 00323 * Read operations from and write operations to the stream 00324 * perform the same operation: if @a expand is @c FALSE, both 00325 * contract keywords. One stream supports both read and write 00326 * operations. Reads and writes may be mixed. 00327 * 00328 * If @a eol_str is non-@c NULL, replace whatever bytestring the input uses 00329 * to denote line endings with @a eol_str in the output. If the input has 00330 * an inconsistent line ending style, then: if @a repair is @c FALSE, then a 00331 * subsequent read, write or other operation on the stream will return 00332 * @c SVN_ERR_IO_INCONSISTENT_EOL when the inconsistency is detected, else 00333 * if @a repair is @c TRUE, convert any line ending to @a eol_str. 00334 * Recognized line endings are: "\n", "\r", and "\r\n". 00335 * 00336 * Expand and contract keywords using the contents of @a keywords as the 00337 * new values. If @a expand is @c TRUE, expand contracted keywords and 00338 * re-expand expanded keywords. If @a expand is @c FALSE, contract expanded 00339 * keywords and ignore contracted ones. Keywords not found in the hash are 00340 * ignored (not contracted or expanded). If the @a keywords hash 00341 * itself is @c NULL, keyword substitution will be altogether ignored. 00342 * 00343 * Detect only keywords that are no longer than @c SVN_KEYWORD_MAX_LEN 00344 * bytes, including the delimiters and the keyword itself. 00345 * 00346 * Recommendation: if @a expand is FALSE, then you don't care about the 00347 * keyword values, so use empty strings as non-NULL signifiers when you 00348 * build the keywords hash. 00349 * 00350 * The stream returned is allocated in @a result_pool. 00351 * 00352 * If the inner stream implements resetting via svn_stream_reset(), 00353 * or marking and seeking via svn_stream_mark() and svn_stream_seek(), 00354 * the translated stream will too. 00355 * 00356 * @since New in 1.4. 00357 */ 00358 svn_stream_t * 00359 svn_subst_stream_translated(svn_stream_t *stream, 00360 const char *eol_str, 00361 svn_boolean_t repair, 00362 apr_hash_t *keywords, 00363 svn_boolean_t expand, 00364 apr_pool_t *result_pool); 00365 00366 00367 /** Set @a *stream to a stream which performs eol translation and keyword 00368 * expansion when read from or written to. The stream @a source 00369 * is used to read and write all data. Make sure you call 00370 * svn_stream_close() on @a stream to make sure all data are flushed 00371 * and cleaned up. 00372 * 00373 * When @a stream is closed, then @a source will be closed. 00374 * 00375 * Read and write operations perform the same transformation: 00376 * all data is translated to normal form. 00377 * 00378 * @see svn_subst_translate_to_normal_form() 00379 * 00380 * @since New in 1.5. 00381 * @deprecated Provided for backward compatibility with the 1.5 API. 00382 */ 00383 SVN_DEPRECATED 00384 svn_error_t * 00385 svn_subst_stream_translated_to_normal_form(svn_stream_t **stream, 00386 svn_stream_t *source, 00387 svn_subst_eol_style_t eol_style, 00388 const char *eol_str, 00389 svn_boolean_t always_repair_eols, 00390 apr_hash_t *keywords, 00391 apr_pool_t *pool); 00392 00393 00394 /** Set @a *stream to a readable stream containing the "normal form" 00395 * of the special file located at @a path. The stream will be allocated 00396 * in @a result_pool, and any temporary allocations will be made in 00397 * @a scratch_pool. 00398 * 00399 * If the file at @a path is in fact a regular file, just read its content, 00400 * which should be in the "normal form" for a special file. This enables 00401 * special files to be written and read on platforms that do not treat them 00402 * as special. 00403 * 00404 * @since New in 1.6. 00405 */ 00406 svn_error_t * 00407 svn_subst_read_specialfile(svn_stream_t **stream, 00408 const char *path, 00409 apr_pool_t *result_pool, 00410 apr_pool_t *scratch_pool); 00411 00412 00413 /** Set @a *stream to a writable stream that accepts content in 00414 * the "normal form" for a special file, to be located at @a path, and 00415 * will create that file when the stream is closed. The stream will be 00416 * allocated in @a result_pool, and any temporary allocations will be 00417 * made in @a scratch_pool. 00418 * 00419 * If the platform does not support the semantics of the special file, write 00420 * a regular file containing the "normal form" text. This enables special 00421 * files to be written and read on platforms that do not treat them as 00422 * special. 00423 * 00424 * Note: the target file is created in a temporary location, then renamed 00425 * into position, so the creation can be considered "atomic". 00426 * 00427 * @since New in 1.6. 00428 */ 00429 svn_error_t * 00430 svn_subst_create_specialfile(svn_stream_t **stream, 00431 const char *path, 00432 apr_pool_t *result_pool, 00433 apr_pool_t *scratch_pool); 00434 00435 00436 /** Set @a *stream to a stream which translates the special file at @a path 00437 * to the internal representation for special files when read from. When 00438 * written to, it does the reverse: creating a special file when the 00439 * stream is closed. 00440 * 00441 * @since New in 1.5. 00442 * 00443 * @deprecated Provided for backward compatibility with the 1.5 API. 00444 * Callers should use svn_subst_read_specialfile or 00445 * svn_subst_create_specialfile as appropriate. 00446 */ 00447 SVN_DEPRECATED 00448 svn_error_t * 00449 svn_subst_stream_from_specialfile(svn_stream_t **stream, 00450 const char *path, 00451 apr_pool_t *pool); 00452 00453 00454 /** 00455 * Copy the contents of file-path @a src to file-path @a dst atomically, 00456 * either creating @a dst or overwriting @a dst if it exists, possibly 00457 * performing line ending and keyword translations. 00458 * 00459 * The parameters @a *eol_str, @a repair, @a *keywords and @a expand are 00460 * defined the same as in svn_subst_translate_stream3(). 00461 * 00462 * In addition, it will create a special file from normal form or 00463 * translate one to normal form if @a special is @c TRUE. 00464 * 00465 * If anything goes wrong during the copy, attempt to delete @a dst (if 00466 * it exists). 00467 * 00468 * If @a eol_str and @a keywords are @c NULL, behavior is just a byte-for-byte 00469 * copy. 00470 * 00471 * @a cancel_func and @a cancel_baton will be called (if not NULL) 00472 * periodically to check for cancellation. 00473 * 00474 * @since New in 1.7. 00475 */ 00476 svn_error_t * 00477 svn_subst_copy_and_translate4(const char *src, 00478 const char *dst, 00479 const char *eol_str, 00480 svn_boolean_t repair, 00481 apr_hash_t *keywords, 00482 svn_boolean_t expand, 00483 svn_boolean_t special, 00484 svn_cancel_func_t cancel_func, 00485 void *cancel_baton, 00486 apr_pool_t *pool); 00487 00488 00489 /** 00490 * Similar to svn_subst_copy_and_translate4() but without a cancellation 00491 * function and baton. 00492 * 00493 * @since New in 1.3. 00494 * @deprecated Provided for backward compatibility with the 1.6 API. 00495 */ 00496 SVN_DEPRECATED 00497 svn_error_t * 00498 svn_subst_copy_and_translate3(const char *src, 00499 const char *dst, 00500 const char *eol_str, 00501 svn_boolean_t repair, 00502 apr_hash_t *keywords, 00503 svn_boolean_t expand, 00504 svn_boolean_t special, 00505 apr_pool_t *pool); 00506 00507 00508 /** 00509 * Similar to svn_subst_copy_and_translate3() except that @a keywords is a 00510 * @c svn_subst_keywords_t struct instead of a keywords hash. 00511 * 00512 * @deprecated Provided for backward compatibility with the 1.2 API. 00513 * @since New in 1.1. 00514 */ 00515 SVN_DEPRECATED 00516 svn_error_t * 00517 svn_subst_copy_and_translate2(const char *src, 00518 const char *dst, 00519 const char *eol_str, 00520 svn_boolean_t repair, 00521 const svn_subst_keywords_t *keywords, 00522 svn_boolean_t expand, 00523 svn_boolean_t special, 00524 apr_pool_t *pool); 00525 00526 /** 00527 * Similar to svn_subst_copy_and_translate2() except that @a special is 00528 * always set to @c FALSE. 00529 * 00530 * @deprecated Provided for backward compatibility with the 1.0 API. 00531 */ 00532 SVN_DEPRECATED 00533 svn_error_t * 00534 svn_subst_copy_and_translate(const char *src, 00535 const char *dst, 00536 const char *eol_str, 00537 svn_boolean_t repair, 00538 const svn_subst_keywords_t *keywords, 00539 svn_boolean_t expand, 00540 apr_pool_t *pool); 00541 00542 00543 /** 00544 * Set @a *dst to a copy of the string @a src, possibly performing line 00545 * ending and keyword translations. 00546 * 00547 * This is a variant of svn_subst_translate_stream3() that operates on 00548 * cstrings. @see svn_subst_stream_translated() for details of the 00549 * translation and of @a eol_str, @a repair, @a keywords and @a expand. 00550 * 00551 * If @a eol_str and @a keywords are @c NULL, behavior is just a byte-for-byte 00552 * copy. 00553 * 00554 * Allocate @a *dst in @a pool. 00555 * 00556 * @since New in 1.3. 00557 */ 00558 svn_error_t * 00559 svn_subst_translate_cstring2(const char *src, 00560 const char **dst, 00561 const char *eol_str, 00562 svn_boolean_t repair, 00563 apr_hash_t *keywords, 00564 svn_boolean_t expand, 00565 apr_pool_t *pool); 00566 00567 /** 00568 * Similar to svn_subst_translate_cstring2() except that @a keywords is a 00569 * @c svn_subst_keywords_t struct instead of a keywords hash. 00570 * 00571 * @deprecated Provided for backward compatibility with the 1.2 API. 00572 */ 00573 SVN_DEPRECATED 00574 svn_error_t * 00575 svn_subst_translate_cstring(const char *src, 00576 const char **dst, 00577 const char *eol_str, 00578 svn_boolean_t repair, 00579 const svn_subst_keywords_t *keywords, 00580 svn_boolean_t expand, 00581 apr_pool_t *pool); 00582 00583 /** 00584 * Translate the file @a src in working copy form to a file @a dst in 00585 * normal form. 00586 * 00587 * The values specified for @a eol_style, @a *eol_str, @a keywords and 00588 * @a special, should be the ones used to translate the file to its 00589 * working copy form. Usually, these are the values specified by the 00590 * user in the files' properties. 00591 * 00592 * Inconsistent line endings in the file will be automatically repaired 00593 * (made consistent) for some eol styles. For all others, an error is 00594 * returned. By setting @a always_repair_eols to @c TRUE, eols will be 00595 * made consistent even for those styles which don't have it by default. 00596 * 00597 * @note To translate a file FROM normal form, use 00598 * svn_subst_copy_and_translate3(). 00599 * 00600 * @since New in 1.4 00601 * @deprecated Provided for backward compatibility with the 1.5 API 00602 */ 00603 SVN_DEPRECATED 00604 svn_error_t * 00605 svn_subst_translate_to_normal_form(const char *src, 00606 const char *dst, 00607 svn_subst_eol_style_t eol_style, 00608 const char *eol_str, 00609 svn_boolean_t always_repair_eols, 00610 apr_hash_t *keywords, 00611 svn_boolean_t special, 00612 apr_pool_t *pool); 00613 00614 /** 00615 * Set @a *stream_p to a stream that detranslates the file @a src from 00616 * working copy form to normal form, allocated in @a pool. 00617 * 00618 * The values specified for @a eol_style, @a *eol_str, @a keywords and 00619 * @a special, should be the ones used to translate the file to its 00620 * working copy form. Usually, these are the values specified by the 00621 * user in the files' properties. 00622 * 00623 * Inconsistent line endings in the file will be automatically repaired 00624 * (made consistent) for some eol styles. For all others, an error is 00625 * returned. By setting @a always_repair_eols to @c TRUE, eols will be 00626 * made consistent even for those styles which don't have it by default. 00627 * 00628 * @since New in 1.4. 00629 * 00630 * @deprecated Provided for backward compatibility with the 1.5 API. 00631 * Use svn_subst_stream_from_specialfile if the source is special; 00632 * otherwise, use svn_subst_stream_translated_to_normal_form. 00633 */ 00634 SVN_DEPRECATED 00635 svn_error_t * 00636 svn_subst_stream_detranslated(svn_stream_t **stream_p, 00637 const char *src, 00638 svn_subst_eol_style_t eol_style, 00639 const char *eol_str, 00640 svn_boolean_t always_repair_eols, 00641 apr_hash_t *keywords, 00642 svn_boolean_t special, 00643 apr_pool_t *pool); 00644 00645 00646 /* EOL conversion and character encodings */ 00647 00648 /** Translate the string @a value from character encoding @a encoding to 00649 * UTF8, and also from its current line-ending style to LF line-endings. If 00650 * @a encoding is @c NULL, translate from the system-default encoding. 00651 * 00652 * If @a translated_to_utf8 is not @c NULL, then set @a *translated_to_utf8 00653 * to @c TRUE if at least one character of @a value in the source character 00654 * encoding was translated to UTF-8, or to @c FALSE otherwise. 00655 * 00656 * If @a translated_line_endings is not @c NULL, then set @a 00657 * *translated_line_endings to @c TRUE if at least one line ending was 00658 * changed to LF, or to @c FALSE otherwise. 00659 * 00660 * If @a value has an inconsistent line ending style, then: if @a repair 00661 * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is 00662 * @c TRUE, convert any line ending in @a value to "\n" in 00663 * @a *new_value. Recognized line endings are: "\n", "\r", and "\r\n". 00664 * 00665 * Set @a *new_value to the translated string, allocated in @a result_pool. 00666 * 00667 * @a scratch_pool is used for temporary allocations. 00668 * 00669 * @since New in 1.7. 00670 */ 00671 svn_error_t * 00672 svn_subst_translate_string2(svn_string_t **new_value, 00673 svn_boolean_t *translated_to_utf8, 00674 svn_boolean_t *translated_line_endings, 00675 const svn_string_t *value, 00676 const char *encoding, 00677 svn_boolean_t repair, 00678 apr_pool_t *result_pool, 00679 apr_pool_t *scratch_pool); 00680 00681 /** Similar to svn_subst_translate_string2(), except that the information about 00682 * whether re-encoding or line ending translation were performed is discarded. 00683 * 00684 * @deprecated Provided for backward compatibility with the 1.6 API. 00685 */ 00686 SVN_DEPRECATED 00687 svn_error_t *svn_subst_translate_string(svn_string_t **new_value, 00688 const svn_string_t *value, 00689 const char *encoding, 00690 apr_pool_t *pool); 00691 00692 /** Translate the string @a value from UTF8 and LF line-endings into native 00693 * character encoding and native line-endings. If @a for_output is TRUE, 00694 * translate to the character encoding of the output locale, else to that of 00695 * the default locale. 00696 * 00697 * Set @a *new_value to the translated string, allocated in @a pool. 00698 */ 00699 svn_error_t *svn_subst_detranslate_string(svn_string_t **new_value, 00700 const svn_string_t *value, 00701 svn_boolean_t for_output, 00702 apr_pool_t *pool); 00703 00704 #ifdef __cplusplus 00705 } 00706 #endif /* __cplusplus */ 00707 00708 #endif /* SVN_SUBST_H */