1/*
2 * translate.h :  eol and keyword translation
3 *
4 * ====================================================================
5 *    Licensed to the Apache Software Foundation (ASF) under one
6 *    or more contributor license agreements.  See the NOTICE file
7 *    distributed with this work for additional information
8 *    regarding copyright ownership.  The ASF licenses this file
9 *    to you under the Apache License, Version 2.0 (the
10 *    "License"); you may not use this file except in compliance
11 *    with the License.  You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 *    Unless required by applicable law or agreed to in writing,
16 *    software distributed under the License is distributed on an
17 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 *    KIND, either express or implied.  See the License for the
19 *    specific language governing permissions and limitations
20 *    under the License.
21 * ====================================================================
22 */
23
24
25#ifndef SVN_LIBSVN_WC_TRANSLATE_H
26#define SVN_LIBSVN_WC_TRANSLATE_H
27
28#include <apr_pools.h>
29#include "svn_types.h"
30#include "svn_subst.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
36
37/* Newline and keyword translation properties */
38
39/* If EOL is not-NULL query the SVN_PROP_EOL_STYLE property on file
40   LOCAL_ABSPATH in DB.  If STYLE is non-null, set *STYLE to LOCAL_ABSPATH's
41   eol style.  Set *EOL to
42
43      - NULL for svn_subst_eol_style_none, or
44
45      - a null-terminated C string containing the native eol marker
46        for this platform, for svn_subst_eol_style_native, or
47
48      - a null-terminated C string containing the eol marker indicated
49        by the property value, for svn_subst_eol_style_fixed.
50
51   If STYLE is null on entry, ignore it.  If *EOL is non-null on exit,
52   it is a static string not allocated in POOL.
53
54   If KEYWORDS is not NULL Expand keywords for the file at LOCAL_ABSPATH
55   in DB, by parsing a whitespace-delimited list of keywords.  If any keywords
56   are found in the list, allocate *KEYWORDS from RESULT_POOL and populate it
57   with mappings from (const char *) keywords to their (svn_string_t *)
58   values (also allocated in RESULT_POOL).
59
60   If a keyword is in the list, but no corresponding value is
61   available, do not create a hash entry for it.  If no keywords are
62   found in the list, or if there is no list, set *KEYWORDS to NULL.
63
64   If SPECIAL is not NULL determine if the svn:special flag is set on
65   LOCAL_ABSPATH in DB.  If so, set SPECIAL to TRUE, if not, set it to FALSE.
66
67   If PROPS is not NULL, use PROPS instead of the properties on LOCAL_ABSPATH.
68
69   If WRI_ABSPATH is not NULL, retrieve the information for LOCAL_ABSPATH
70   from the working copy identified by WRI_ABSPATH. Falling back to file
71   external information if the file is not present as versioned node.
72
73   If FOR_NORMALIZATION is TRUE, just return a list of keywords instead of
74   calculating their intended values.
75
76   Use SCRATCH_POOL for temporary allocation, RESULT_POOL for allocating
77   *STYLE and *EOL.
78*/
79svn_error_t *
80svn_wc__get_translate_info(svn_subst_eol_style_t *style,
81                           const char **eol,
82                           apr_hash_t **keywords,
83                           svn_boolean_t *special,
84                           svn_wc__db_t *db,
85                           const char *local_abspath,
86                           apr_hash_t *props,
87                           svn_boolean_t for_normalization,
88                           apr_pool_t *result_pool,
89                           apr_pool_t *scratch_pool);
90
91/* Reverse parser.  Given a real EOL string ("\n", "\r", or "\r\n"),
92   return an encoded *VALUE ("LF", "CR", "CRLF") that one might see in
93   the property value. */
94void svn_wc__eol_value_from_string(const char **value,
95                                   const char *eol);
96
97/* Expand keywords for the file at LOCAL_ABSPATH in DB, by parsing a
98   whitespace-delimited list of keywords KEYWORD_LIST.  If any keywords
99   are found in the list, allocate *KEYWORDS from RESULT_POOL and populate
100   it with mappings from (const char *) keywords to their (svn_string_t *)
101   values (also allocated in RESULT_POOL).
102
103   If a keyword is in the list, but no corresponding value is
104   available, do not create a hash entry for it.  If no keywords are
105   found in the list, or if there is no list, set *KEYWORDS to NULL.
106     ### THIS LOOKS WRONG -- it creates a hash entry for every recognized kw
107         and expands each missing value as an empty string or "-1" or similar.
108
109   Use LOCAL_ABSPATH to expand keyword values.
110
111   If WRI_ABSPATH is not NULL, retrieve the information for LOCAL_ABSPATH
112   from the working copy identified by WRI_ABSPATH. Falling back to file
113   external information if the file is not present as versioned node.
114     ### THIS IS NOT IMPLEMENTED -- WRI_ABSPATH is ignored
115
116   If FOR_NORMALIZATION is TRUE, just return a list of keywords instead of
117   calculating their intended values.
118     ### This would be better done by a separate API, since in this case
119         only the KEYWORD_LIST input parameter is needed. (And there is no
120         need to print "-1" as the revision value.)
121
122   Use SCRATCH_POOL for any temporary allocations.
123*/
124svn_error_t *
125svn_wc__expand_keywords(apr_hash_t **keywords,
126                        svn_wc__db_t *db,
127                        const char *local_abspath,
128                        const char *wri_abspath,
129                        const char *keyword_list,
130                        svn_boolean_t for_normalization,
131                        apr_pool_t *result_pool,
132                        apr_pool_t *scratch_pool);
133
134/* Sync the write and execute bit for LOCAL_ABSPATH with what is currently
135   indicated by the properties in the database:
136
137    * If the SVN_PROP_NEEDS_LOCK property is present and there is no
138      lock token for the file in the working copy, set LOCAL_ABSPATH to
139      read-only.
140    * If the SVN_PROP_EXECUTABLE property is present at all, then set
141      LOCAL_ABSPATH executable.
142
143   If DID_SET is non-null, then liberally set *DID_SET to TRUE if we might
144   have change the permissions on LOCAL_ABSPATH.  (A TRUE value in *DID_SET
145   does not guarantee that we changed the permissions, simply that more
146   investigation is warrented.)
147
148   This function looks at the current values of the above properties,
149   including any scheduled-but-not-yet-committed changes.
150
151   If LOCAL_ABSPATH is a directory, this function is a no-op.
152
153   Use SCRATCH_POOL for any temporary allocations.
154 */
155svn_error_t *
156svn_wc__sync_flags_with_props(svn_boolean_t *did_set,
157                              svn_wc__db_t *db,
158                              const char *local_abspath,
159                              apr_pool_t *scratch_pool);
160
161/* Internal version of svn_wc_translated_stream2(), which see. */
162svn_error_t *
163svn_wc__internal_translated_stream(svn_stream_t **stream,
164                                   svn_wc__db_t *db,
165                                   const char *local_abspath,
166                                   const char *versioned_abspath,
167                                   apr_uint32_t flags,
168                                   apr_pool_t *result_pool,
169                                   apr_pool_t *scratch_pool);
170
171/* Like svn_wc_translated_file2(), except the working copy database
172 * is used directly and the function assumes abspaths. */
173svn_error_t *
174svn_wc__internal_translated_file(const char **xlated_abspath,
175                                 const char *src_abspath,
176                                 svn_wc__db_t *db,
177                                 const char *versioned_abspath,
178                                 apr_uint32_t flags,
179                                 svn_cancel_func_t cancel_func,
180                                 void *cancel_baton,
181                                 apr_pool_t *result_pool,
182                                 apr_pool_t *scratch_pool);
183
184
185#ifdef __cplusplus
186}
187#endif /* __cplusplus */
188
189#endif /* SVN_LIBSVN_WC_TRANSLATE_H */
190