svn_cmdline_private.h revision 299742
11539Srgrimes/** 21539Srgrimes * @copyright 31539Srgrimes * ==================================================================== 41539Srgrimes * Licensed to the Apache Software Foundation (ASF) under one 51539Srgrimes * or more contributor license agreements. See the NOTICE file 61539Srgrimes * distributed with this work for additional information 71539Srgrimes * regarding copyright ownership. The ASF licenses this file 81539Srgrimes * to you under the Apache License, Version 2.0 (the 91539Srgrimes * "License"); you may not use this file except in compliance 101539Srgrimes * with the License. You may obtain a copy of the License at 111539Srgrimes * 121539Srgrimes * http://www.apache.org/licenses/LICENSE-2.0 131539Srgrimes * 141539Srgrimes * Unless required by applicable law or agreed to in writing, 151539Srgrimes * software distributed under the License is distributed on an 161539Srgrimes * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 171539Srgrimes * KIND, either express or implied. See the License for the 181539Srgrimes * specific language governing permissions and limitations 191539Srgrimes * under the License. 201539Srgrimes * ==================================================================== 211539Srgrimes * @endcopyright 221539Srgrimes * 231539Srgrimes * @file svn_cmdline_private.h 241539Srgrimes * @brief Private functions for Subversion cmdline. 251539Srgrimes */ 261539Srgrimes 271539Srgrimes#ifndef SVN_CMDLINE_PRIVATE_H 281539Srgrimes#define SVN_CMDLINE_PRIVATE_H 291539Srgrimes 301539Srgrimes#include <apr_pools.h> 311539Srgrimes#include <apr_hash.h> 321539Srgrimes 331539Srgrimes#include "svn_string.h" 341539Srgrimes#include "svn_error.h" 351539Srgrimes#include "svn_io.h" 362162Spaul 372162Spaul#ifdef __cplusplus 382162Spaulextern "C" { 391539Srgrimes#endif /* __cplusplus */ 401539Srgrimes 411539Srgrimes/** Write a property as an XML element into @a *outstr. 421539Srgrimes * 431539Srgrimes * If @a outstr is NULL, allocate @a *outstr in @a pool; else append to 441539Srgrimes * @a *outstr, allocating in @a outstr's pool 451539Srgrimes * 461539Srgrimes * @a propname is the property name. @a propval is the property value, which 471539Srgrimes * will be encoded if it contains unsafe bytes. 481539Srgrimes * 491539Srgrimes * If @a inherited_prop is TRUE then @a propname is an inherited property, 501539Srgrimes * otherwise @a propname is an explicit property. 511539Srgrimes */ 521539Srgrimesvoid 531539Srgrimessvn_cmdline__print_xml_prop(svn_stringbuf_t **outstr, 541539Srgrimes const char *propname, 551539Srgrimes svn_string_t *propval, 561539Srgrimes svn_boolean_t inherited_prop, 571539Srgrimes apr_pool_t *pool); 581539Srgrimes 591539Srgrimes 601539Srgrimes/** An implementation of @c svn_auth_gnome_keyring_unlock_prompt_func_t that 611539Srgrimes * prompts the user for default GNOME Keyring password. 621539Srgrimes * 631539Srgrimes * Expects a @c svn_cmdline_prompt_baton2_t to be passed as @a baton. 641539Srgrimes * 651539Srgrimes * @since New in 1.6. 661539Srgrimes */ 671539Srgrimessvn_error_t * 681539Srgrimessvn_cmdline__auth_gnome_keyring_unlock_prompt(char **keyring_password, 691539Srgrimes const char *keyring_name, 701539Srgrimes void *baton, 712162Spaul apr_pool_t *pool); 722162Spaul 73/** Container for config options parsed with svn_cmdline__parse_config_option 74 * 75 * @since New in 1.7. 76 */ 77typedef 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 1.9/1.10:] If the file, section, or option value is not recognized, 92 * warn to @c stderr, using @a prefix as in svn_handle_warning2(). 93 * 94 * @since New in 1.7. 95 */ 96svn_error_t * 97svn_cmdline__parse_config_option(apr_array_header_t *config_options, 98 const char *opt_arg, 99 const char *prefix, 100 apr_pool_t *pool); 101 102/** Sets the config options in @a config_options, an apr array containing 103 * @c svn_cmdline__config_argument_t* elements, to the configuration in @a cfg, 104 * a hash mapping of <tt>const char *</tt> configuration file names to 105 * @c svn_config_t *'s. Write warnings to stderr. 106 * 107 * Use @a prefix as prefix and @a argument_name in warning messages. 108 * 109 * @since New in 1.7. 110 */ 111svn_error_t * 112svn_cmdline__apply_config_options(apr_hash_t *config, 113 const apr_array_header_t *config_options, 114 const char *prefix, 115 const char *argument_name); 116 117/* Return a string allocated in POOL that is a copy of STR but with each 118 * line prefixed with INDENT. A line is all characters up to the first 119 * CR-LF, LF-CR, CR or LF, or the end of STR if sooner. */ 120const char * 121svn_cmdline__indent_string(const char *str, 122 const char *indent, 123 apr_pool_t *pool); 124 125/* Print to stdout a hash PROP_HASH that maps property names (char *) to 126 property values (svn_string_t *). The names are assumed to be in UTF-8 127 format; the values are either in UTF-8 (the special Subversion props) or 128 plain binary values. 129 130 If OUT is not NULL, then write to it rather than stdout. 131 132 If NAMES_ONLY is true, print just names, else print names and 133 values. */ 134svn_error_t * 135svn_cmdline__print_prop_hash(svn_stream_t *out, 136 apr_hash_t *prop_hash, 137 svn_boolean_t names_only, 138 apr_pool_t *pool); 139 140/* Similar to svn_cmdline__print_prop_hash(), only output xml to *OUTSTR. 141 If INHERITED_PROPS is true, then PROP_HASH contains inherited properties, 142 otherwise PROP_HASH contains explicit properties. If *OUTSTR is NULL, 143 allocate it first from POOL, otherwise append to it. */ 144svn_error_t * 145svn_cmdline__print_xml_prop_hash(svn_stringbuf_t **outstr, 146 apr_hash_t *prop_hash, 147 svn_boolean_t names_only, 148 svn_boolean_t inherited_props, 149 apr_pool_t *pool); 150 151 152/* Search for a text editor command in standard environment variables, 153 and invoke it to edit PATH. Use POOL for all allocations. 154 155 If EDITOR_CMD is not NULL, it is the name of the external editor 156 command to use, overriding anything else that might determine the 157 editor. 158 159 CONFIG is a hash of svn_config_t * items keyed on a configuration 160 category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL. */ 161svn_error_t * 162svn_cmdline__edit_file_externally(const char *path, 163 const char *editor_cmd, 164 apr_hash_t *config, 165 apr_pool_t *pool); 166 167/* Search for a text editor command in standard environment variables, 168 and invoke it to edit CONTENTS (using a temporary file created in 169 directory BASE_DIR). Return the new contents in *EDITED_CONTENTS, 170 or set *EDITED_CONTENTS to NULL if no edit was performed. 171 172 If EDITOR_CMD is not NULL, it is the name of the external editor 173 command to use, overriding anything else that might determine the 174 editor. 175 176 If TMPFILE_LEFT is NULL, the temporary file will be destroyed. 177 Else, the file will be left on disk, and its path returned in 178 *TMPFILE_LEFT. 179 180 CONFIG is a hash of svn_config_t * items keyed on a configuration 181 category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL. 182 183 If AS_TEXT is TRUE, recode CONTENTS and convert to native eol-style before 184 editing and back again afterwards. In this case, ENCODING determines the 185 encoding used during editing. If non-NULL, use the named encoding, else 186 use the system encoding. If AS_TEXT is FALSE, don't do any translation. 187 In that case, ENCODING is ignored. 188 189 Use POOL for all allocations. Use PREFIX as the prefix for the 190 temporary file used by the editor. 191 192 If return error, *EDITED_CONTENTS is not touched. */ 193svn_error_t * 194svn_cmdline__edit_string_externally(svn_string_t **edited_contents, 195 const char **tmpfile_left, 196 const char *editor_cmd, 197 const char *base_dir, 198 const svn_string_t *contents, 199 const char *prefix, 200 apr_hash_t *config, 201 svn_boolean_t as_text, 202 const char *encoding, 203 apr_pool_t *pool); 204 205 206/** Wrapper for apr_getopt_init(), which see. 207 * 208 * @since New in 1.4. 209 */ 210svn_error_t * 211svn_cmdline__getopt_init(apr_getopt_t **os, 212 int argc, 213 const char *argv[], 214 apr_pool_t *pool); 215 216/* Determine whether interactive mode should be enabled, based on whether 217 * the user passed the --non-interactive or --force-interactive options. 218 * If neither option was passed, interactivity is enabled if standard 219 * input is connected to a terminal device. 220 * 221 * @since New in 1.8. 222 */ 223svn_boolean_t 224svn_cmdline__be_interactive(svn_boolean_t non_interactive, 225 svn_boolean_t force_interactive); 226 227/* Parses the argument value of '--trust-server-cert-failures' OPT_ARG into 228 * the expected booleans for passing to svn_cmdline_create_auth_baton2() 229 * 230 * @since New in 1.9. 231 */ 232svn_error_t * 233svn_cmdline__parse_trust_options( 234 svn_boolean_t *trust_server_cert_unknown_ca, 235 svn_boolean_t *trust_server_cert_cn_mismatch, 236 svn_boolean_t *trust_server_cert_expired, 237 svn_boolean_t *trust_server_cert_not_yet_valid, 238 svn_boolean_t *trust_server_cert_other_failure, 239 const char *opt_arg, 240 apr_pool_t *scratch_pool); 241 242#ifdef __cplusplus 243} 244#endif /* __cplusplus */ 245 246#endif /* SVN_CMDLINE_PRIVATE_H */ 247