]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/subversion/subversion/include/private/svn_cmdline_private.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / subversion / subversion / include / private / svn_cmdline_private.h
1 /**
2  * @copyright
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_cmdline_private.h
24  * @brief Private functions for Subversion cmdline.
25  */
26
27 #ifndef SVN_CMDLINE_PRIVATE_H
28 #define SVN_CMDLINE_PRIVATE_H
29
30 #include <apr_pools.h>
31 #include <apr_hash.h>
32
33 #include "svn_string.h"
34 #include "svn_error.h"
35 #include "svn_io.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40
41 /** Write a property as an XML element into @a *outstr.
42  *
43  * If @a outstr is NULL, allocate @a *outstr in @a pool; else append to
44  * @a *outstr, allocating in @a outstr's pool
45  *
46  * @a propname is the property name. @a propval is the property value, which
47  * will be encoded if it contains unsafe bytes.
48  *
49  * If @a inherited_prop is TRUE then @a propname is an inherited property,
50  * otherwise @a propname is an explicit property.
51  */
52 void
53 svn_cmdline__print_xml_prop(svn_stringbuf_t **outstr,
54                             const char *propname,
55                             svn_string_t *propval,
56                             svn_boolean_t inherited_prop,
57                             apr_pool_t *pool);
58
59
60 /** An implementation of @c svn_auth_gnome_keyring_unlock_prompt_func_t that
61  * prompts the user for default GNOME Keyring password.
62  *
63  * Expects a @c svn_cmdline_prompt_baton2_t to be passed as @a baton.
64  *
65  * @since New in 1.6.
66  */
67 svn_error_t *
68 svn_cmdline__auth_gnome_keyring_unlock_prompt(char **keyring_password,
69                                               const char *keyring_name,
70                                               void *baton,
71                                               apr_pool_t *pool);
72
73 /** Container for config options parsed with svn_cmdline__parse_config_option
74  *
75  * @since New in 1.7.
76  */
77 typedef struct svn_cmdline__config_argument_t
78 {
79   const char *file;
80   const char *section;
81   const char *option;
82   const char *value;
83 } svn_cmdline__config_argument_t;
84
85 /** Parser for 'FILE:SECTION:OPTION=[VALUE]'-style option arguments.
86  *
87  * Parses @a opt_arg and places its value in @a config_options, an apr array
88  * containing svn_cmdline__config_argument_t* elements, allocating the option
89  * data in @a pool
90  *
91  * @since New in 1.7.
92  */
93 svn_error_t *
94 svn_cmdline__parse_config_option(apr_array_header_t *config_options,
95                                  const char *opt_arg,
96                                  apr_pool_t *pool);
97
98 /** Sets the config options in @a config_options, an apr array containing
99  * @c svn_cmdline__config_argument_t* elements, to the configuration in @a cfg,
100  * a hash mapping of <tt>const char *</tt> configuration file names to
101  * @c svn_config_t *'s. Write warnings to stderr.
102  *
103  * Use @a prefix as prefix and @a argument_name in warning messages.
104  *
105  * @since New in 1.7.
106  */
107 svn_error_t *
108 svn_cmdline__apply_config_options(apr_hash_t *config,
109                                   const apr_array_header_t *config_options,
110                                   const char *prefix,
111                                   const char *argument_name);
112
113 /* Return a string allocated in POOL that is a copy of STR but with each
114  * line prefixed with INDENT. A line is all characters up to the first
115  * CR-LF, LF-CR, CR or LF, or the end of STR if sooner. */
116 const char *
117 svn_cmdline__indent_string(const char *str,
118                            const char *indent,
119                            apr_pool_t *pool);
120
121 /* Print to stdout a hash PROP_HASH that maps property names (char *) to
122    property values (svn_string_t *).  The names are assumed to be in UTF-8
123    format; the values are either in UTF-8 (the special Subversion props) or
124    plain binary values.
125
126    If OUT is not NULL, then write to it rather than stdout.
127
128    If NAMES_ONLY is true, print just names, else print names and
129    values. */
130 svn_error_t *
131 svn_cmdline__print_prop_hash(svn_stream_t *out,
132                              apr_hash_t *prop_hash,
133                              svn_boolean_t names_only,
134                              apr_pool_t *pool);
135
136 /* Similar to svn_cmdline__print_prop_hash(), only output xml to *OUTSTR.
137    If INHERITED_PROPS is true, then PROP_HASH contains inherited properties,
138    otherwise PROP_HASH contains explicit properties.  If *OUTSTR is NULL,
139    allocate it first from POOL, otherwise append to it. */
140 svn_error_t *
141 svn_cmdline__print_xml_prop_hash(svn_stringbuf_t **outstr,
142                                  apr_hash_t *prop_hash,
143                                  svn_boolean_t names_only,
144                                  svn_boolean_t inherited_props,
145                                  apr_pool_t *pool);
146
147
148 /* Search for a text editor command in standard environment variables,
149    and invoke it to edit PATH.  Use POOL for all allocations.
150
151    If EDITOR_CMD is not NULL, it is the name of the external editor
152    command to use, overriding anything else that might determine the
153    editor.
154
155    CONFIG is a hash of svn_config_t * items keyed on a configuration
156    category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL.  */
157 svn_error_t *
158 svn_cmdline__edit_file_externally(const char *path,
159                                   const char *editor_cmd,
160                                   apr_hash_t *config,
161                                   apr_pool_t *pool);
162
163 /* Search for a text editor command in standard environment variables,
164    and invoke it to edit CONTENTS (using a temporary file created in
165    directory BASE_DIR).  Return the new contents in *EDITED_CONTENTS,
166    or set *EDITED_CONTENTS to NULL if no edit was performed.
167
168    If EDITOR_CMD is not NULL, it is the name of the external editor
169    command to use, overriding anything else that might determine the
170    editor.
171
172    If TMPFILE_LEFT is NULL, the temporary file will be destroyed.
173    Else, the file will be left on disk, and its path returned in
174    *TMPFILE_LEFT.
175
176    CONFIG is a hash of svn_config_t * items keyed on a configuration
177    category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL.
178
179    If AS_TEXT is TRUE, recode CONTENTS and convert to native eol-style before
180    editing and back again afterwards.  In this case, ENCODING determines the
181    encoding used during editing.  If non-NULL, use the named encoding, else
182    use the system encoding.  If AS_TEXT is FALSE, don't do any translation.
183    In that case, ENCODING is ignored.
184
185    Use POOL for all allocations.  Use PREFIX as the prefix for the
186    temporary file used by the editor.
187
188    If return error, *EDITED_CONTENTS is not touched. */
189 svn_error_t *
190 svn_cmdline__edit_string_externally(svn_string_t **edited_contents,
191                                     const char **tmpfile_left,
192                                     const char *editor_cmd,
193                                     const char *base_dir,
194                                     const svn_string_t *contents,
195                                     const char *prefix,
196                                     apr_hash_t *config,
197                                     svn_boolean_t as_text,
198                                     const char *encoding,
199                                     apr_pool_t *pool);
200
201
202 /** Wrapper for apr_getopt_init(), which see.
203  *
204  * @since New in 1.4.
205  */
206 svn_error_t *
207 svn_cmdline__getopt_init(apr_getopt_t **os,
208                          int argc,
209                          const char *argv[],
210                          apr_pool_t *pool);
211
212 /* Determine whether interactive mode should be enabled, based on whether
213  * the user passed the --non-interactive or --force-interactive options.
214  * If neither option was passed, interactivity is enabled if standard
215  * input is connected to a terminal device.
216  *
217  * @since New in 1.8.
218  */
219 svn_boolean_t
220 svn_cmdline__be_interactive(svn_boolean_t non_interactive,
221                             svn_boolean_t force_interactive);
222
223
224 #ifdef __cplusplus
225 }
226 #endif /* __cplusplus */
227
228 #endif /* SVN_CMDLINE_PRIVATE_H */