#include "svn_types.h"
#include "svn_string.h"
#include "svn_io.h"
Go to the source code of this file.
Data Structures | |
struct | svn_subst_keywords_t |
Values used in keyword expansion. More... | |
Typedefs | |
typedef enum svn_subst_eol_style | svn_subst_eol_style_t |
Valid states for 'svn:eol-style' property. | |
Enumerations | |
enum | svn_subst_eol_style { svn_subst_eol_style_unknown, svn_subst_eol_style_none, svn_subst_eol_style_native, svn_subst_eol_style_fixed } |
Valid states for 'svn:eol-style' property. More... | |
Functions | |
void | svn_subst_eol_style_from_value (svn_subst_eol_style_t *style, const char **eol, const char *value) |
Set *style to the appropriate svn_subst_eol_style_t and *eol to the appropriate cstring for a given svn:eol-style property value. | |
svn_error_t * | svn_subst_build_keywords2 (apr_hash_t **kw, const char *keywords_string, const char *rev, const char *url, apr_time_t date, const char *author, apr_pool_t *pool) |
Set *kw to a new keywords hash filled with the appropriate contents given a keywords_string (the contents of the svn:keywords property for the file in question), the revision rev, the url, the date the file was committed on, and the author of the last commit. | |
svn_error_t * | svn_subst_build_keywords (svn_subst_keywords_t *kw, const char *keywords_string, const char *rev, const char *url, apr_time_t date, const char *author, apr_pool_t *pool) |
Similar to svn_subst_build_keywords2() except that it populates an existing structure *kw instead of creating a keywords hash. | |
svn_boolean_t | svn_subst_keywords_differ2 (apr_hash_t *a, apr_hash_t *b, svn_boolean_t compare_values, apr_pool_t *pool) |
Return TRUE if a and b do not hold the same keywords. | |
svn_boolean_t | svn_subst_keywords_differ (const svn_subst_keywords_t *a, const svn_subst_keywords_t *b, svn_boolean_t compare_values) |
Similar to svn_subst_keywords_differ2() except that it compares two svn_subst_keywords_t structs instead of keyword hashes. | |
svn_error_t * | svn_subst_translate_stream3 (svn_stream_t *src, svn_stream_t *dst, const char *eol_str, svn_boolean_t repair, apr_hash_t *keywords, svn_boolean_t expand, apr_pool_t *pool) |
Copy and translate the data in stream src into stream dst. | |
svn_error_t * | svn_subst_translate_stream2 (svn_stream_t *src, svn_stream_t *dst, const char *eol_str, svn_boolean_t repair, const svn_subst_keywords_t *keywords, svn_boolean_t expand, apr_pool_t *pool) |
Similar to svn_subst_translate_stream3() except relies upon a svn_subst_keywords_t struct instead of a hash for the keywords. | |
svn_error_t * | svn_subst_translate_stream (svn_stream_t *src, svn_stream_t *dst, const char *eol_str, svn_boolean_t repair, const svn_subst_keywords_t *keywords, svn_boolean_t expand) |
Same as svn_subst_translate_stream2(), but does not take a pool argument, instead creates a temporary subpool of the global pool, and destroys it before returning. | |
svn_error_t * | svn_subst_copy_and_translate3 (const char *src, const char *dst, const char *eol_str, svn_boolean_t repair, apr_hash_t *keywords, svn_boolean_t expand, svn_boolean_t special, apr_pool_t *pool) |
Convenience routine: a variant of svn_subst_translate_stream3() which operates on files. | |
svn_error_t * | svn_subst_copy_and_translate2 (const char *src, const char *dst, const char *eol_str, svn_boolean_t repair, const svn_subst_keywords_t *keywords, svn_boolean_t expand, svn_boolean_t special, apr_pool_t *pool) |
Similar to svn_subst_copy_and_translate3() except that keywords is a svn_subst_keywords_t struct instead of a keywords hash. | |
svn_error_t * | svn_subst_copy_and_translate (const char *src, const char *dst, const char *eol_str, svn_boolean_t repair, const svn_subst_keywords_t *keywords, svn_boolean_t expand, apr_pool_t *pool) |
Similar to svn_subst_copy_and_translate2() except that special is always set to FALSE . | |
svn_error_t * | svn_subst_translate_cstring2 (const char *src, const char **dst, const char *eol_str, svn_boolean_t repair, apr_hash_t *keywords, svn_boolean_t expand, apr_pool_t *pool) |
Convenience routine: a variant of svn_subst_translate_stream3() which operates on cstrings. | |
svn_error_t * | svn_subst_translate_cstring (const char *src, const char **dst, const char *eol_str, svn_boolean_t repair, const svn_subst_keywords_t *keywords, svn_boolean_t expand, apr_pool_t *pool) |
Similar to svn_subst_translate_cstring2() except that keywords is a svn_subst_keywords_t struct instead of a keywords hash. | |
svn_error_t * | svn_subst_translate_string (svn_string_t **new_value, const svn_string_t *value, const char *encoding, apr_pool_t *pool) |
Translate the data in value (assumed to be in encoded in charset encoding) to UTF8 and LF line-endings. | |
svn_error_t * | svn_subst_detranslate_string (svn_string_t **new_value, const svn_string_t *value, svn_boolean_t for_stdout, apr_pool_t *pool) |
Translate the data in value from UTF8 and LF line-endings into native locale and native line-endings, or to the output locale if for_output is TRUE. |
Definition in file svn_subst.h.
typedef enum svn_subst_eol_style svn_subst_eol_style_t |
Valid states for 'svn:eol-style' property.
Property nonexistence is equivalent to 'none'.
enum svn_subst_eol_style |
Valid states for 'svn:eol-style' property.
Property nonexistence is equivalent to 'none'.
Definition at line 41 of file svn_subst.h.
svn_error_t* svn_subst_build_keywords | ( | svn_subst_keywords_t * | kw, | |
const char * | keywords_string, | |||
const char * | rev, | |||
const char * | url, | |||
apr_time_t | date, | |||
const char * | author, | |||
apr_pool_t * | pool | |||
) |
Similar to svn_subst_build_keywords2() except that it populates an existing structure *kw instead of creating a keywords hash.
svn_error_t* svn_subst_build_keywords2 | ( | apr_hash_t ** | kw, | |
const char * | keywords_string, | |||
const char * | rev, | |||
const char * | url, | |||
apr_time_t | date, | |||
const char * | author, | |||
apr_pool_t * | pool | |||
) |
Set *kw to a new keywords hash filled with the appropriate contents given a keywords_string (the contents of the svn:keywords property for the file in question), the revision rev, the url, the date the file was committed on, and the author of the last commit.
Any of these can be NULL
to indicate that the information is not present, or 0
for date.
Hash keys are of type const char *
. Hash values are of type svn_string_t *
.
All memory is allocated out of pool.
svn_error_t* svn_subst_copy_and_translate | ( | const char * | src, | |
const char * | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
const svn_subst_keywords_t * | keywords, | |||
svn_boolean_t | expand, | |||
apr_pool_t * | pool | |||
) |
Similar to svn_subst_copy_and_translate2() except that special is always set to FALSE
.
svn_error_t* svn_subst_copy_and_translate2 | ( | const char * | src, | |
const char * | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
const svn_subst_keywords_t * | keywords, | |||
svn_boolean_t | expand, | |||
svn_boolean_t | special, | |||
apr_pool_t * | pool | |||
) |
Similar to svn_subst_copy_and_translate3() except that keywords is a svn_subst_keywords_t
struct instead of a keywords hash.
svn_error_t* svn_subst_copy_and_translate3 | ( | const char * | src, | |
const char * | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
apr_hash_t * | keywords, | |||
svn_boolean_t | expand, | |||
svn_boolean_t | special, | |||
apr_pool_t * | pool | |||
) |
Convenience routine: a variant of svn_subst_translate_stream3() which operates on files.
In addition, it will create/detranslate a special file if special is TRUE
.
Copy the contents of file-path src to file-path dst atomically, either creating dst (or overwriting dst if it exists), possibly performing line ending and keyword translations.
If anything goes wrong during the copy, attempt to delete dst (if it exists).
If eol_str and keywords are NULL
, behavior is just a byte-for-byte copy.
svn_error_t* svn_subst_detranslate_string | ( | svn_string_t ** | new_value, | |
const svn_string_t * | value, | |||
svn_boolean_t | for_stdout, | |||
apr_pool_t * | pool | |||
) |
Translate the data in value from UTF8 and LF line-endings into native locale and native line-endings, or to the output locale if for_output is TRUE.
Return the translated data in *new_value, allocated in pool.
void svn_subst_eol_style_from_value | ( | svn_subst_eol_style_t * | style, | |
const char ** | eol, | |||
const char * | value | |||
) |
Set *style to the appropriate svn_subst_eol_style_t
and *eol to the appropriate cstring for a given svn:eol-style property value.
Set *eol to
NULL
for svn_subst_eol_style_none
, or
svn_subst_eol_style_native
, or
svn_subst_eol_style_fixed
.
If *style is NULL
, then value was not a valid property value.
svn_boolean_t svn_subst_keywords_differ | ( | const svn_subst_keywords_t * | a, | |
const svn_subst_keywords_t * | b, | |||
svn_boolean_t | compare_values | |||
) |
Similar to svn_subst_keywords_differ2() except that it compares two svn_subst_keywords_t
structs instead of keyword hashes.
svn_boolean_t svn_subst_keywords_differ2 | ( | apr_hash_t * | a, | |
apr_hash_t * | b, | |||
svn_boolean_t | compare_values, | |||
apr_pool_t * | pool | |||
) |
Return TRUE
if a and b do not hold the same keywords.
a and b are hashes of the form produced by svn_subst_build_keywords2().
TRUE
, "same" means that the a and b contain exactly the same set of keywords, and the values of corresponding keywords match as well. Else if compare_values is FALSE
, then "same" merely means that a and b hold the same set of keywords, although those keywords' values might differ.
a and/or b may be NULL
; for purposes of comparison, NULL
is equivalent to holding no keywords.
svn_error_t* svn_subst_translate_cstring | ( | const char * | src, | |
const char ** | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
const svn_subst_keywords_t * | keywords, | |||
svn_boolean_t | expand, | |||
apr_pool_t * | pool | |||
) |
Similar to svn_subst_translate_cstring2() except that keywords is a svn_subst_keywords_t
struct instead of a keywords hash.
svn_error_t* svn_subst_translate_cstring2 | ( | const char * | src, | |
const char ** | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
apr_hash_t * | keywords, | |||
svn_boolean_t | expand, | |||
apr_pool_t * | pool | |||
) |
Convenience routine: a variant of svn_subst_translate_stream3() which operates on cstrings.
If eol_str and keywords are NULL
, behavior is just a byte-for-byte copy.
svn_error_t* svn_subst_translate_stream | ( | svn_stream_t * | src, | |
svn_stream_t * | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
const svn_subst_keywords_t * | keywords, | |||
svn_boolean_t | expand | |||
) |
Same as svn_subst_translate_stream2(), but does not take a pool argument, instead creates a temporary subpool of the global pool, and destroys it before returning.
svn_error_t* svn_subst_translate_stream2 | ( | svn_stream_t * | src, | |
svn_stream_t * | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
const svn_subst_keywords_t * | keywords, | |||
svn_boolean_t | expand, | |||
apr_pool_t * | pool | |||
) |
Similar to svn_subst_translate_stream3() except relies upon a svn_subst_keywords_t
struct instead of a hash for the keywords.
svn_error_t* svn_subst_translate_stream3 | ( | svn_stream_t * | src, | |
svn_stream_t * | dst, | |||
const char * | eol_str, | |||
svn_boolean_t | repair, | |||
apr_hash_t * | keywords, | |||
svn_boolean_t | expand, | |||
apr_pool_t * | pool | |||
) |
Copy and translate the data in stream src into stream dst.
It is assumed that src is a readable stream and dst is a writable stream.
NULL
, replace whatever bytestring src uses to denote line endings with eol_str in the output. If src has an inconsistent line ending style, then: if repair is FALSE
, return SVN_ERR_IO_INCONSISTENT_EOL
, else if repair is TRUE
, convert any line ending in src to eol_str in dst. Recognized line endings are: "\n", "\r", and "\r\n".
Expand and contract keywords using the contents of keywords as the new values. If expand is TRUE
, expand contracted keywords and re-expand expanded keywords. If expand is FALSE
, contract expanded keywords and ignore contracted ones. Keywords not found in the hash are ignored (not contracted or expanded). If the keywords hash itself is NULL
, keyword substitution will be altogether ignored.
Detect only keywords that are no longer than SVN_IO_MAX_KEYWORD_LEN
bytes, including the delimiters and the keyword itself.
Note that a translation request is *required*: one of eol_str or keywords must be non-NULL
.
Recommendation: if expand is false, then you don't care about the keyword values, so use empty strings as non-null signifiers when you build the keywords hash.
Notes:
See svn_wc__get_keywords() and svn_wc__get_eol_style() for a convenient way to get eol_str and keywords if in libsvn_wc.
svn_error_t* svn_subst_translate_string | ( | svn_string_t ** | new_value, | |
const svn_string_t * | value, | |||
const char * | encoding, | |||
apr_pool_t * | pool | |||
) |
Translate the data in value (assumed to be in encoded in charset encoding) to UTF8 and LF line-endings.
If encoding is NULL
, then assume that value is in the system-default language encoding. Return the translated data in *new_value, allocated in pool.