1251881Speter/** 2251881Speter * @copyright 3251881Speter * ==================================================================== 4251881Speter * Licensed to the Apache Software Foundation (ASF) under one 5251881Speter * or more contributor license agreements. See the NOTICE file 6251881Speter * distributed with this work for additional information 7251881Speter * regarding copyright ownership. The ASF licenses this file 8251881Speter * to you under the Apache License, Version 2.0 (the 9251881Speter * "License"); you may not use this file except in compliance 10251881Speter * with the License. You may obtain a copy of the License at 11251881Speter * 12251881Speter * http://www.apache.org/licenses/LICENSE-2.0 13251881Speter * 14251881Speter * Unless required by applicable law or agreed to in writing, 15251881Speter * software distributed under the License is distributed on an 16251881Speter * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17251881Speter * KIND, either express or implied. See the License for the 18251881Speter * specific language governing permissions and limitations 19251881Speter * under the License. 20251881Speter * ==================================================================== 21251881Speter * @endcopyright 22251881Speter * 23251881Speter * @file svn_subst.h 24251881Speter * @brief Data substitution (keywords and EOL style) 25251881Speter */ 26251881Speter 27251881Speter 28251881Speter 29251881Speter#ifndef SVN_SUBST_H 30251881Speter#define SVN_SUBST_H 31251881Speter 32251881Speter#include <apr_pools.h> 33251881Speter#include <apr_hash.h> 34251881Speter#include <apr_time.h> 35251881Speter 36251881Speter#include "svn_types.h" 37251881Speter#include "svn_string.h" 38251881Speter#include "svn_io.h" 39251881Speter 40251881Speter#ifdef __cplusplus 41251881Speterextern "C" { 42251881Speter#endif /* __cplusplus */ 43251881Speter 44251881Speter/* EOL conversion and keyword expansion. */ 45251881Speter 46251881Speter/** The EOL used in the Repository for "native" files */ 47251881Speter#define SVN_SUBST_NATIVE_EOL_STR "\n" 48251881Speter 49251881Speter/** Valid states for 'svn:eol-style' property. 50251881Speter * 51251881Speter * Property nonexistence is equivalent to 'none'. 52251881Speter */ 53251881Spetertypedef enum svn_subst_eol_style 54251881Speter{ 55251881Speter /** An unrecognized style */ 56251881Speter svn_subst_eol_style_unknown, 57251881Speter 58251881Speter /** EOL translation is "off" or ignored value */ 59251881Speter svn_subst_eol_style_none, 60251881Speter 61251881Speter /** Translation is set to client's native eol */ 62251881Speter svn_subst_eol_style_native, 63251881Speter 64251881Speter /** Translation is set to one of LF, CR, CRLF */ 65251881Speter svn_subst_eol_style_fixed 66251881Speter 67251881Speter} svn_subst_eol_style_t; 68251881Speter 69251881Speter/** Set @a *style to the appropriate @c svn_subst_eol_style_t and @a *eol to 70251881Speter * the appropriate cstring for a given svn:eol-style property value. 71251881Speter * 72251881Speter * Set @a *eol to 73251881Speter * 74251881Speter * - @c NULL for @c svn_subst_eol_style_none, or 75251881Speter * 76251881Speter * - a NULL-terminated C string containing the native eol marker 77251881Speter * for this platform, for @c svn_subst_eol_style_native, or 78251881Speter * 79251881Speter * - a NULL-terminated C string containing the eol marker indicated 80251881Speter * by the property value, for @c svn_subst_eol_style_fixed. 81251881Speter * 82251881Speter * If @a *style is NULL, it is ignored. 83251881Speter */ 84251881Spetervoid 85251881Spetersvn_subst_eol_style_from_value(svn_subst_eol_style_t *style, 86251881Speter const char **eol, 87251881Speter const char *value); 88251881Speter 89251881Speter/** Indicates whether the working copy and normalized versions of a file 90251881Speter * with the given the parameters differ. If @a force_eol_check is TRUE, 91251881Speter * the routine also accounts for all translations required due to repairing 92251881Speter * fixed eol styles. 93251881Speter * 94251881Speter * @since New in 1.4 95251881Speter * 96251881Speter */ 97251881Spetersvn_boolean_t 98251881Spetersvn_subst_translation_required(svn_subst_eol_style_t style, 99251881Speter const char *eol, 100251881Speter apr_hash_t *keywords, 101251881Speter svn_boolean_t special, 102251881Speter svn_boolean_t force_eol_check); 103251881Speter 104251881Speter 105251881Speter/** Values used in keyword expansion. 106251881Speter * 107251881Speter * @deprecated Provided for backward compatibility with the 1.2 API. 108251881Speter */ 109251881Spetertypedef struct svn_subst_keywords_t 110251881Speter{ 111251881Speter /** 112251881Speter * @name svn_subst_keywords_t fields 113251881Speter * String expansion of the like-named keyword, or NULL if the keyword 114251881Speter * was not selected in the svn:keywords property. 115251881Speter * @{ 116251881Speter */ 117251881Speter const svn_string_t *revision; 118251881Speter const svn_string_t *date; 119251881Speter const svn_string_t *author; 120251881Speter const svn_string_t *url; 121251881Speter const svn_string_t *id; 122251881Speter /** @} */ 123251881Speter} svn_subst_keywords_t; 124251881Speter 125251881Speter 126251881Speter/** 127251881Speter * Set @a *kw to a new keywords hash filled with the appropriate contents 128251881Speter * given a @a keywords_string (the contents of the svn:keywords 129251881Speter * property for the file in question), the revision @a rev, the @a url, 130251881Speter * the @a date the file was committed on, the @a author of the last 131251881Speter * commit, and the URL of the repository root @a repos_root_url. 132251881Speter * 133251881Speter * Custom keywords defined in svn:keywords properties are expanded 134251881Speter * using the provided parameters and in accordance with the following 135251881Speter * format substitutions in the @a keywords_string: 136251881Speter * %a - The author. 137251881Speter * %b - The basename of the URL. 138251881Speter * %d - Short format of the date. 139251881Speter * %D - Long format of the date. 140251881Speter * %P - The file's path, relative to the repository root URL. 141251881Speter * %r - The revision. 142251881Speter * %R - The URL to the root of the repository. 143251881Speter * %u - The URL of the file. 144251881Speter * %_ - A space (keyword definitions cannot contain a literal space). 145251881Speter * %% - A literal '%'. 146251881Speter * %H - Equivalent to %P%_%r%_%d%_%a. 147251881Speter * %I - Equivalent to %b%_%r%_%d%_%a. 148251881Speter * 149251881Speter * Custom keywords are defined by appending '=' to the keyword name, followed 150251881Speter * by a string containing any combination of the format substitutions. 151251881Speter * 152251881Speter * Any of the inputs @a rev, @a url, @a date, @a author, and @a repos_root_url 153251881Speter * can be @c NULL, or @c 0 for @a date, to indicate that the information is 154251881Speter * not present. Each piece of information that is not present expands to the 155251881Speter * empty string wherever it appears in an expanded keyword value. (This can 156251881Speter * result in multiple adjacent spaces in the expansion of a multi-valued 157251881Speter * keyword such as "Id".) 158251881Speter * 159251881Speter * Hash keys are of type <tt>const char *</tt>. 160251881Speter * Hash values are of type <tt>svn_string_t *</tt>. 161251881Speter * 162251881Speter * All memory is allocated out of @a pool. 163251881Speter * 164251881Speter * @since New in 1.8. 165251881Speter */ 166251881Spetersvn_error_t * 167251881Spetersvn_subst_build_keywords3(apr_hash_t **kw, 168251881Speter const char *keywords_string, 169251881Speter const char *rev, 170251881Speter const char *url, 171251881Speter const char *repos_root_url, 172251881Speter apr_time_t date, 173251881Speter const char *author, 174251881Speter apr_pool_t *pool); 175251881Speter 176251881Speter/** Similar to svn_subst_build_keywords3() except that it does not accept 177251881Speter * the @a repos_root_url parameter and hence supports less substitutions, 178251881Speter * and also does not support custom keyword definitions. 179251881Speter * 180251881Speter * @since New in 1.3. 181251881Speter * @deprecated Provided for backward compatibility with the 1.7 API. 182251881Speter */ 183251881SpeterSVN_DEPRECATED 184251881Spetersvn_error_t * 185251881Spetersvn_subst_build_keywords2(apr_hash_t **kw, 186251881Speter const char *keywords_string, 187251881Speter const char *rev, 188251881Speter const char *url, 189251881Speter apr_time_t date, 190251881Speter const char *author, 191251881Speter apr_pool_t *pool); 192251881Speter 193251881Speter/** Similar to svn_subst_build_keywords2() except that it populates 194251881Speter * an existing structure @a *kw instead of creating a keywords hash. 195251881Speter * 196251881Speter * @deprecated Provided for backward compatibility with the 1.2 API. 197251881Speter */ 198251881SpeterSVN_DEPRECATED 199251881Spetersvn_error_t * 200251881Spetersvn_subst_build_keywords(svn_subst_keywords_t *kw, 201251881Speter const char *keywords_string, 202251881Speter const char *rev, 203251881Speter const char *url, 204251881Speter apr_time_t date, 205251881Speter const char *author, 206251881Speter apr_pool_t *pool); 207251881Speter 208251881Speter 209251881Speter/** Return @c TRUE if @a a and @a b do not hold the same keywords. 210251881Speter * 211251881Speter * @a a and @a b are hashes of the form produced by 212251881Speter * svn_subst_build_keywords2(). 213251881Speter * 214251881Speter * @since New in 1.3. 215251881Speter * 216251881Speter * If @a compare_values is @c TRUE, "same" means that the @a a and @a b 217251881Speter * contain exactly the same set of keywords, and the values of corresponding 218251881Speter * keywords match as well. Else if @a compare_values is @c FALSE, then 219251881Speter * "same" merely means that @a a and @a b hold the same set of keywords, 220251881Speter * although those keywords' values might differ. 221251881Speter * 222251881Speter * @a a and/or @a b may be @c NULL; for purposes of comparison, @c NULL is 223251881Speter * equivalent to holding no keywords. 224251881Speter */ 225251881Spetersvn_boolean_t 226251881Spetersvn_subst_keywords_differ2(apr_hash_t *a, 227251881Speter apr_hash_t *b, 228251881Speter svn_boolean_t compare_values, 229251881Speter apr_pool_t *pool); 230251881Speter 231251881Speter/** Similar to svn_subst_keywords_differ2() except that it compares 232251881Speter * two @c svn_subst_keywords_t structs instead of keyword hashes. 233251881Speter * 234251881Speter * @deprecated Provided for backward compatibility with the 1.2 API. 235251881Speter */ 236251881SpeterSVN_DEPRECATED 237251881Spetersvn_boolean_t 238251881Spetersvn_subst_keywords_differ(const svn_subst_keywords_t *a, 239251881Speter const svn_subst_keywords_t *b, 240251881Speter svn_boolean_t compare_values); 241251881Speter 242251881Speter 243251881Speter/** 244251881Speter * Copy and translate the data in @a src_stream into @a dst_stream. It is 245251881Speter * assumed that @a src_stream is a readable stream and @a dst_stream is a 246251881Speter * writable stream. 247251881Speter * 248251881Speter * If @a eol_str is non-@c NULL, replace whatever bytestring @a src_stream 249251881Speter * uses to denote line endings with @a eol_str in the output. If 250251881Speter * @a src_stream has an inconsistent line ending style, then: if @a repair 251251881Speter * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is 252251881Speter * @c TRUE, convert any line ending in @a src_stream to @a eol_str in 253251881Speter * @a dst_stream. Recognized line endings are: "\n", "\r", and "\r\n". 254251881Speter * 255251881Speter * See svn_subst_stream_translated() for details of the keyword substitution 256251881Speter * which is controlled by the @a expand and @a keywords parameters. 257251881Speter * 258251881Speter * Note that a translation request is *required*: one of @a eol_str or 259251881Speter * @a keywords must be non-@c NULL. 260251881Speter * 261251881Speter * Notes: 262251881Speter * 263251881Speter * See svn_wc__get_keywords() and svn_wc__get_eol_style() for a 264251881Speter * convenient way to get @a eol_str and @a keywords if in libsvn_wc. 265251881Speter * 266251881Speter * @since New in 1.3. 267251881Speter * 268251881Speter * @deprecated Provided for backward compatibility with the 1.5 API. 269251881Speter * Callers should use svn_subst_stream_translated() instead. 270251881Speter */ 271251881SpeterSVN_DEPRECATED 272251881Spetersvn_error_t * 273251881Spetersvn_subst_translate_stream3(svn_stream_t *src_stream, 274251881Speter svn_stream_t *dst_stream, 275251881Speter const char *eol_str, 276251881Speter svn_boolean_t repair, 277251881Speter apr_hash_t *keywords, 278251881Speter svn_boolean_t expand, 279251881Speter apr_pool_t *scratch_pool); 280251881Speter 281251881Speter 282251881Speter/** Similar to svn_subst_translate_stream3() except relies upon a 283251881Speter * @c svn_subst_keywords_t struct instead of a hash for the keywords. 284251881Speter * 285251881Speter * @deprecated Provided for backward compatibility with the 1.2 API. 286251881Speter */ 287251881SpeterSVN_DEPRECATED 288251881Spetersvn_error_t * 289251881Spetersvn_subst_translate_stream2(svn_stream_t *src_stream, 290251881Speter svn_stream_t *dst_stream, 291251881Speter const char *eol_str, 292251881Speter svn_boolean_t repair, 293251881Speter const svn_subst_keywords_t *keywords, 294251881Speter svn_boolean_t expand, 295251881Speter apr_pool_t *scratch_pool); 296251881Speter 297251881Speter 298251881Speter/** 299251881Speter * Same as svn_subst_translate_stream2(), but does not take a @a pool 300251881Speter * argument, instead creates a temporary subpool of the global pool, and 301251881Speter * destroys it before returning. 302251881Speter * 303251881Speter * @deprecated Provided for backward compatibility with the 1.1 API. 304251881Speter */ 305251881SpeterSVN_DEPRECATED 306251881Spetersvn_error_t * 307251881Spetersvn_subst_translate_stream(svn_stream_t *src_stream, 308251881Speter svn_stream_t *dst_stream, 309251881Speter const char *eol_str, 310251881Speter svn_boolean_t repair, 311251881Speter const svn_subst_keywords_t *keywords, 312251881Speter svn_boolean_t expand); 313251881Speter 314251881Speter 315251881Speter/** Return a stream which performs eol translation and keyword 316251881Speter * expansion when read from or written to. The stream @a stream 317251881Speter * is used to read and write all data. 318251881Speter * 319251881Speter * Make sure you call svn_stream_close() on the returned stream to 320251881Speter * ensure all data is flushed and cleaned up (this will also close 321251881Speter * the provided @a stream). 322251881Speter * 323251881Speter * Read operations from and write operations to the stream 324251881Speter * perform the same operation: if @a expand is @c FALSE, both 325251881Speter * contract keywords. One stream supports both read and write 326251881Speter * operations. Reads and writes may be mixed. 327251881Speter * 328251881Speter * If @a eol_str is non-@c NULL, replace whatever bytestring the input uses 329251881Speter * to denote line endings with @a eol_str in the output. If the input has 330251881Speter * an inconsistent line ending style, then: if @a repair is @c FALSE, then a 331251881Speter * subsequent read, write or other operation on the stream will return 332251881Speter * @c SVN_ERR_IO_INCONSISTENT_EOL when the inconsistency is detected, else 333251881Speter * if @a repair is @c TRUE, convert any line ending to @a eol_str. 334251881Speter * Recognized line endings are: "\n", "\r", and "\r\n". 335251881Speter * 336251881Speter * Expand and contract keywords using the contents of @a keywords as the 337251881Speter * new values. If @a expand is @c TRUE, expand contracted keywords and 338251881Speter * re-expand expanded keywords. If @a expand is @c FALSE, contract expanded 339251881Speter * keywords and ignore contracted ones. Keywords not found in the hash are 340251881Speter * ignored (not contracted or expanded). If the @a keywords hash 341251881Speter * itself is @c NULL, keyword substitution will be altogether ignored. 342251881Speter * 343251881Speter * Detect only keywords that are no longer than @c SVN_KEYWORD_MAX_LEN 344251881Speter * bytes, including the delimiters and the keyword itself. 345251881Speter * 346251881Speter * Recommendation: if @a expand is FALSE, then you don't care about the 347251881Speter * keyword values, so use empty strings as non-NULL signifiers when you 348251881Speter * build the keywords hash. 349251881Speter * 350251881Speter * The stream returned is allocated in @a result_pool. 351251881Speter * 352251881Speter * If the inner stream implements resetting via svn_stream_reset(), 353251881Speter * or marking and seeking via svn_stream_mark() and svn_stream_seek(), 354251881Speter * the translated stream will too. 355251881Speter * 356251881Speter * @since New in 1.4. 357251881Speter */ 358251881Spetersvn_stream_t * 359251881Spetersvn_subst_stream_translated(svn_stream_t *stream, 360251881Speter const char *eol_str, 361251881Speter svn_boolean_t repair, 362251881Speter apr_hash_t *keywords, 363251881Speter svn_boolean_t expand, 364251881Speter apr_pool_t *result_pool); 365251881Speter 366251881Speter 367251881Speter/** Set @a *stream to a stream which performs eol translation and keyword 368251881Speter * expansion when read from or written to. The stream @a source 369251881Speter * is used to read and write all data. Make sure you call 370251881Speter * svn_stream_close() on @a stream to make sure all data are flushed 371251881Speter * and cleaned up. 372251881Speter * 373251881Speter * When @a stream is closed, then @a source will be closed. 374251881Speter * 375251881Speter * Read and write operations perform the same transformation: 376251881Speter * all data is translated to normal form. 377251881Speter * 378251881Speter * @see svn_subst_translate_to_normal_form() 379251881Speter * 380251881Speter * @since New in 1.5. 381251881Speter * @deprecated Provided for backward compatibility with the 1.5 API. 382251881Speter */ 383251881SpeterSVN_DEPRECATED 384251881Spetersvn_error_t * 385251881Spetersvn_subst_stream_translated_to_normal_form(svn_stream_t **stream, 386251881Speter svn_stream_t *source, 387251881Speter svn_subst_eol_style_t eol_style, 388251881Speter const char *eol_str, 389251881Speter svn_boolean_t always_repair_eols, 390251881Speter apr_hash_t *keywords, 391251881Speter apr_pool_t *pool); 392251881Speter 393251881Speter 394251881Speter/** Set @a *stream to a readable stream containing the "normal form" 395251881Speter * of the special file located at @a path. The stream will be allocated 396251881Speter * in @a result_pool, and any temporary allocations will be made in 397251881Speter * @a scratch_pool. 398251881Speter * 399251881Speter * If the file at @a path is in fact a regular file, just read its content, 400251881Speter * which should be in the "normal form" for a special file. This enables 401251881Speter * special files to be written and read on platforms that do not treat them 402251881Speter * as special. 403251881Speter * 404251881Speter * @since New in 1.6. 405251881Speter */ 406251881Spetersvn_error_t * 407251881Spetersvn_subst_read_specialfile(svn_stream_t **stream, 408251881Speter const char *path, 409251881Speter apr_pool_t *result_pool, 410251881Speter apr_pool_t *scratch_pool); 411251881Speter 412251881Speter 413251881Speter/** Set @a *stream to a writable stream that accepts content in 414251881Speter * the "normal form" for a special file, to be located at @a path, and 415251881Speter * will create that file when the stream is closed. The stream will be 416251881Speter * allocated in @a result_pool, and any temporary allocations will be 417251881Speter * made in @a scratch_pool. 418251881Speter * 419251881Speter * If the platform does not support the semantics of the special file, write 420251881Speter * a regular file containing the "normal form" text. This enables special 421251881Speter * files to be written and read on platforms that do not treat them as 422251881Speter * special. 423251881Speter * 424251881Speter * Note: the target file is created in a temporary location, then renamed 425251881Speter * into position, so the creation can be considered "atomic". 426251881Speter * 427251881Speter * @since New in 1.6. 428251881Speter */ 429251881Spetersvn_error_t * 430251881Spetersvn_subst_create_specialfile(svn_stream_t **stream, 431251881Speter const char *path, 432251881Speter apr_pool_t *result_pool, 433251881Speter apr_pool_t *scratch_pool); 434251881Speter 435251881Speter 436251881Speter/** Set @a *stream to a stream which translates the special file at @a path 437251881Speter * to the internal representation for special files when read from. When 438251881Speter * written to, it does the reverse: creating a special file when the 439251881Speter * stream is closed. 440251881Speter * 441251881Speter * @since New in 1.5. 442251881Speter * 443251881Speter * @deprecated Provided for backward compatibility with the 1.5 API. 444251881Speter * Callers should use svn_subst_read_specialfile or 445251881Speter * svn_subst_create_specialfile as appropriate. 446251881Speter */ 447251881SpeterSVN_DEPRECATED 448251881Spetersvn_error_t * 449251881Spetersvn_subst_stream_from_specialfile(svn_stream_t **stream, 450251881Speter const char *path, 451251881Speter apr_pool_t *pool); 452251881Speter 453251881Speter 454251881Speter/** 455251881Speter * Copy the contents of file-path @a src to file-path @a dst atomically, 456251881Speter * either creating @a dst or overwriting @a dst if it exists, possibly 457251881Speter * performing line ending and keyword translations. 458251881Speter * 459251881Speter * The parameters @a *eol_str, @a repair, @a *keywords and @a expand are 460251881Speter * defined the same as in svn_subst_translate_stream3(). 461251881Speter * 462251881Speter * In addition, it will create a special file from normal form or 463251881Speter * translate one to normal form if @a special is @c TRUE. 464251881Speter * 465251881Speter * If anything goes wrong during the copy, attempt to delete @a dst (if 466251881Speter * it exists). 467251881Speter * 468251881Speter * If @a eol_str and @a keywords are @c NULL, behavior is just a byte-for-byte 469251881Speter * copy. 470251881Speter * 471251881Speter * @a cancel_func and @a cancel_baton will be called (if not NULL) 472251881Speter * periodically to check for cancellation. 473251881Speter * 474251881Speter * @since New in 1.7. 475251881Speter */ 476251881Spetersvn_error_t * 477251881Spetersvn_subst_copy_and_translate4(const char *src, 478251881Speter const char *dst, 479251881Speter const char *eol_str, 480251881Speter svn_boolean_t repair, 481251881Speter apr_hash_t *keywords, 482251881Speter svn_boolean_t expand, 483251881Speter svn_boolean_t special, 484251881Speter svn_cancel_func_t cancel_func, 485251881Speter void *cancel_baton, 486251881Speter apr_pool_t *pool); 487251881Speter 488251881Speter 489251881Speter/** 490251881Speter * Similar to svn_subst_copy_and_translate4() but without a cancellation 491251881Speter * function and baton. 492251881Speter * 493251881Speter * @since New in 1.3. 494251881Speter * @deprecated Provided for backward compatibility with the 1.6 API. 495251881Speter */ 496251881SpeterSVN_DEPRECATED 497251881Spetersvn_error_t * 498251881Spetersvn_subst_copy_and_translate3(const char *src, 499251881Speter const char *dst, 500251881Speter const char *eol_str, 501251881Speter svn_boolean_t repair, 502251881Speter apr_hash_t *keywords, 503251881Speter svn_boolean_t expand, 504251881Speter svn_boolean_t special, 505251881Speter apr_pool_t *pool); 506251881Speter 507251881Speter 508251881Speter/** 509251881Speter * Similar to svn_subst_copy_and_translate3() except that @a keywords is a 510251881Speter * @c svn_subst_keywords_t struct instead of a keywords hash. 511251881Speter * 512251881Speter * @deprecated Provided for backward compatibility with the 1.2 API. 513251881Speter * @since New in 1.1. 514251881Speter */ 515251881SpeterSVN_DEPRECATED 516251881Spetersvn_error_t * 517251881Spetersvn_subst_copy_and_translate2(const char *src, 518251881Speter const char *dst, 519251881Speter const char *eol_str, 520251881Speter svn_boolean_t repair, 521251881Speter const svn_subst_keywords_t *keywords, 522251881Speter svn_boolean_t expand, 523251881Speter svn_boolean_t special, 524251881Speter apr_pool_t *pool); 525251881Speter 526251881Speter/** 527251881Speter * Similar to svn_subst_copy_and_translate2() except that @a special is 528251881Speter * always set to @c FALSE. 529251881Speter * 530251881Speter * @deprecated Provided for backward compatibility with the 1.0 API. 531251881Speter */ 532251881SpeterSVN_DEPRECATED 533251881Spetersvn_error_t * 534251881Spetersvn_subst_copy_and_translate(const char *src, 535251881Speter const char *dst, 536251881Speter const char *eol_str, 537251881Speter svn_boolean_t repair, 538251881Speter const svn_subst_keywords_t *keywords, 539251881Speter svn_boolean_t expand, 540251881Speter apr_pool_t *pool); 541251881Speter 542251881Speter 543251881Speter/** 544251881Speter * Set @a *dst to a copy of the string @a src, possibly performing line 545251881Speter * ending and keyword translations. 546251881Speter * 547251881Speter * This is a variant of svn_subst_translate_stream3() that operates on 548251881Speter * cstrings. @see svn_subst_stream_translated() for details of the 549251881Speter * translation and of @a eol_str, @a repair, @a keywords and @a expand. 550251881Speter * 551251881Speter * If @a eol_str and @a keywords are @c NULL, behavior is just a byte-for-byte 552251881Speter * copy. 553251881Speter * 554251881Speter * Allocate @a *dst in @a pool. 555251881Speter * 556251881Speter * @since New in 1.3. 557251881Speter */ 558251881Spetersvn_error_t * 559251881Spetersvn_subst_translate_cstring2(const char *src, 560251881Speter const char **dst, 561251881Speter const char *eol_str, 562251881Speter svn_boolean_t repair, 563251881Speter apr_hash_t *keywords, 564251881Speter svn_boolean_t expand, 565251881Speter apr_pool_t *pool); 566251881Speter 567251881Speter/** 568251881Speter * Similar to svn_subst_translate_cstring2() except that @a keywords is a 569251881Speter * @c svn_subst_keywords_t struct instead of a keywords hash. 570251881Speter * 571251881Speter * @deprecated Provided for backward compatibility with the 1.2 API. 572251881Speter */ 573251881SpeterSVN_DEPRECATED 574251881Spetersvn_error_t * 575251881Spetersvn_subst_translate_cstring(const char *src, 576251881Speter const char **dst, 577251881Speter const char *eol_str, 578251881Speter svn_boolean_t repair, 579251881Speter const svn_subst_keywords_t *keywords, 580251881Speter svn_boolean_t expand, 581251881Speter apr_pool_t *pool); 582251881Speter 583251881Speter/** 584251881Speter * Translate the file @a src in working copy form to a file @a dst in 585251881Speter * normal form. 586251881Speter * 587251881Speter * The values specified for @a eol_style, @a *eol_str, @a keywords and 588251881Speter * @a special, should be the ones used to translate the file to its 589251881Speter * working copy form. Usually, these are the values specified by the 590251881Speter * user in the files' properties. 591251881Speter * 592251881Speter * Inconsistent line endings in the file will be automatically repaired 593251881Speter * (made consistent) for some eol styles. For all others, an error is 594251881Speter * returned. By setting @a always_repair_eols to @c TRUE, eols will be 595251881Speter * made consistent even for those styles which don't have it by default. 596251881Speter * 597251881Speter * @note To translate a file FROM normal form, use 598251881Speter * svn_subst_copy_and_translate3(). 599251881Speter * 600251881Speter * @since New in 1.4 601251881Speter * @deprecated Provided for backward compatibility with the 1.5 API 602251881Speter */ 603251881SpeterSVN_DEPRECATED 604251881Spetersvn_error_t * 605251881Spetersvn_subst_translate_to_normal_form(const char *src, 606251881Speter const char *dst, 607251881Speter svn_subst_eol_style_t eol_style, 608251881Speter const char *eol_str, 609251881Speter svn_boolean_t always_repair_eols, 610251881Speter apr_hash_t *keywords, 611251881Speter svn_boolean_t special, 612251881Speter apr_pool_t *pool); 613251881Speter 614251881Speter/** 615251881Speter * Set @a *stream_p to a stream that detranslates the file @a src from 616251881Speter * working copy form to normal form, allocated in @a pool. 617251881Speter * 618251881Speter * The values specified for @a eol_style, @a *eol_str, @a keywords and 619251881Speter * @a special, should be the ones used to translate the file to its 620251881Speter * working copy form. Usually, these are the values specified by the 621251881Speter * user in the files' properties. 622251881Speter * 623251881Speter * Inconsistent line endings in the file will be automatically repaired 624251881Speter * (made consistent) for some eol styles. For all others, an error is 625251881Speter * returned. By setting @a always_repair_eols to @c TRUE, eols will be 626251881Speter * made consistent even for those styles which don't have it by default. 627251881Speter * 628251881Speter * @since New in 1.4. 629251881Speter * 630251881Speter * @deprecated Provided for backward compatibility with the 1.5 API. 631251881Speter * Use svn_subst_stream_from_specialfile if the source is special; 632251881Speter * otherwise, use svn_subst_stream_translated_to_normal_form. 633251881Speter */ 634251881SpeterSVN_DEPRECATED 635251881Spetersvn_error_t * 636251881Spetersvn_subst_stream_detranslated(svn_stream_t **stream_p, 637251881Speter const char *src, 638251881Speter svn_subst_eol_style_t eol_style, 639251881Speter const char *eol_str, 640251881Speter svn_boolean_t always_repair_eols, 641251881Speter apr_hash_t *keywords, 642251881Speter svn_boolean_t special, 643251881Speter apr_pool_t *pool); 644251881Speter 645251881Speter 646251881Speter/* EOL conversion and character encodings */ 647251881Speter 648251881Speter/** Translate the string @a value from character encoding @a encoding to 649251881Speter * UTF8, and also from its current line-ending style to LF line-endings. If 650251881Speter * @a encoding is @c NULL, translate from the system-default encoding. 651251881Speter * 652251881Speter * If @a translated_to_utf8 is not @c NULL, then set @a *translated_to_utf8 653251881Speter * to @c TRUE if at least one character of @a value in the source character 654251881Speter * encoding was translated to UTF-8, or to @c FALSE otherwise. 655251881Speter * 656251881Speter * If @a translated_line_endings is not @c NULL, then set @a 657251881Speter * *translated_line_endings to @c TRUE if at least one line ending was 658251881Speter * changed to LF, or to @c FALSE otherwise. 659251881Speter * 660251881Speter * If @a value has an inconsistent line ending style, then: if @a repair 661251881Speter * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is 662251881Speter * @c TRUE, convert any line ending in @a value to "\n" in 663251881Speter * @a *new_value. Recognized line endings are: "\n", "\r", and "\r\n". 664251881Speter * 665251881Speter * Set @a *new_value to the translated string, allocated in @a result_pool. 666251881Speter * 667251881Speter * @a scratch_pool is used for temporary allocations. 668251881Speter * 669251881Speter * @since New in 1.7. 670251881Speter */ 671251881Spetersvn_error_t * 672251881Spetersvn_subst_translate_string2(svn_string_t **new_value, 673251881Speter svn_boolean_t *translated_to_utf8, 674251881Speter svn_boolean_t *translated_line_endings, 675251881Speter const svn_string_t *value, 676251881Speter const char *encoding, 677251881Speter svn_boolean_t repair, 678251881Speter apr_pool_t *result_pool, 679251881Speter apr_pool_t *scratch_pool); 680251881Speter 681251881Speter/** Similar to svn_subst_translate_string2(), except that the information about 682251881Speter * whether re-encoding or line ending translation were performed is discarded. 683251881Speter * 684251881Speter * @deprecated Provided for backward compatibility with the 1.6 API. 685251881Speter */ 686251881SpeterSVN_DEPRECATED 687251881Spetersvn_error_t *svn_subst_translate_string(svn_string_t **new_value, 688251881Speter const svn_string_t *value, 689251881Speter const char *encoding, 690251881Speter apr_pool_t *pool); 691251881Speter 692251881Speter/** Translate the string @a value from UTF8 and LF line-endings into native 693251881Speter * character encoding and native line-endings. If @a for_output is TRUE, 694251881Speter * translate to the character encoding of the output locale, else to that of 695251881Speter * the default locale. 696251881Speter * 697251881Speter * Set @a *new_value to the translated string, allocated in @a pool. 698251881Speter */ 699251881Spetersvn_error_t *svn_subst_detranslate_string(svn_string_t **new_value, 700251881Speter const svn_string_t *value, 701251881Speter svn_boolean_t for_output, 702251881Speter apr_pool_t *pool); 703251881Speter 704251881Speter#ifdef __cplusplus 705251881Speter} 706251881Speter#endif /* __cplusplus */ 707251881Speter 708251881Speter#endif /* SVN_SUBST_H */ 709