Subversion 1.6.16
|
Support functions for command line programs. More...
#include <apr_pools.h>
#include <apr_getopt.h>
#include <apr_want.h>
#include "svn_types.h"
#include "svn_auth.h"
#include "svn_config.h"
Go to the source code of this file.
Data Structures | |
struct | svn_cmdline_prompt_baton2_t |
A cancellation function/baton pair, and the path to the configuration directory. More... | |
struct | svn_cmdline_prompt_baton_t |
Like svn_cmdline_prompt_baton2_t, but without the path to the configuration directory. More... | |
Typedefs | |
typedef struct svn_cmdline_prompt_baton2_t | svn_cmdline_prompt_baton2_t |
A cancellation function/baton pair, and the path to the configuration directory. | |
typedef struct svn_cmdline_prompt_baton_t | svn_cmdline_prompt_baton_t |
Like svn_cmdline_prompt_baton2_t, but without the path to the configuration directory. | |
Functions | |
int | svn_cmdline_init (const char *progname, FILE *error_stream) |
Set up the locale for character conversion, and initialize APR. | |
svn_error_t * | svn_cmdline_cstring_from_utf8 (const char **dest, const char *src, apr_pool_t *pool) |
Set *dest to an output-encoded C string from UTF-8 C string src; allocate *dest in pool. | |
const char * | svn_cmdline_cstring_from_utf8_fuzzy (const char *src, apr_pool_t *pool) |
Like svn_utf_cstring_from_utf8_fuzzy(), but converts to an output-encoded C string. | |
svn_error_t * | svn_cmdline_cstring_to_utf8 (const char **dest, const char *src, apr_pool_t *pool) |
Set *dest to a UTF-8-encoded C string from input-encoded C string src; allocate *dest in pool. | |
svn_error_t * | svn_cmdline_path_local_style_from_utf8 (const char **dest, const char *src, apr_pool_t *pool) |
Set *dest to an output-encoded natively-formatted path string from canonical path src; allocate *dest in pool. | |
svn_error_t * | svn_cmdline_printf (apr_pool_t *pool, const char *fmt,...) |
Write to stdout, using a printf-like format string fmt, passed through apr_pvsprintf(). | |
svn_error_t * | svn_cmdline_fprintf (FILE *stream, apr_pool_t *pool, const char *fmt,...) |
Write to the stdio stream, using a printf-like format string fmt, passed through apr_pvsprintf(). | |
svn_error_t * | svn_cmdline_fputs (const char *string, FILE *stream, apr_pool_t *pool) |
Output the string to the stdio stream, converting from UTF-8 to the output encoding. | |
svn_error_t * | svn_cmdline_fflush (FILE *stream) |
Flush output buffers of the stdio stream, returning an error if that fails. | |
const char * | svn_cmdline_output_encoding (apr_pool_t *pool) |
Return the name of the output encoding allocated in pool, or APR_LOCALE_CHARSET if the output encoding is the same as the locale encoding. | |
int | svn_cmdline_handle_exit_error (svn_error_t *error, apr_pool_t *pool, const char *prefix) |
Handle error in preparation for immediate exit from a command-line client. | |
svn_error_t * | svn_cmdline_prompt_user2 (const char **result, const char *prompt_str, svn_cmdline_prompt_baton_t *baton, apr_pool_t *pool) |
Prompt the user for input, using prompt_str for the prompt and baton (which may be NULL ) for cancellation, and returning the user's response in result, allocated in pool. | |
svn_error_t * | svn_cmdline_prompt_user (const char **result, const char *prompt_str, apr_pool_t *pool) |
Similar to svn_cmdline_prompt_user2, but without cancellation support. | |
svn_error_t * | svn_cmdline_auth_simple_prompt (svn_auth_cred_simple_t **cred_p, void *baton, const char *realm, const char *username, svn_boolean_t may_save, apr_pool_t *pool) |
An implementation of svn_auth_simple_prompt_func_t that prompts the user for keyboard input on the command line. | |
svn_error_t * | svn_cmdline_auth_username_prompt (svn_auth_cred_username_t **cred_p, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool) |
An implementation of svn_auth_username_prompt_func_t that prompts the user for their username via the command line. | |
svn_error_t * | svn_cmdline_auth_ssl_server_trust_prompt (svn_auth_cred_ssl_server_trust_t **cred_p, void *baton, const char *realm, apr_uint32_t failures, const svn_auth_ssl_server_cert_info_t *cert_info, svn_boolean_t may_save, apr_pool_t *pool) |
An implementation of svn_auth_ssl_server_trust_prompt_func_t that asks the user if they trust a specific ssl server via the command line. | |
svn_error_t * | svn_cmdline_auth_ssl_client_cert_prompt (svn_auth_cred_ssl_client_cert_t **cred_p, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool) |
An implementation of svn_auth_ssl_client_cert_prompt_func_t that prompts the user for the filename of their SSL client certificate via the command line. | |
svn_error_t * | svn_cmdline_auth_ssl_client_cert_pw_prompt (svn_auth_cred_ssl_client_cert_pw_t **cred_p, void *baton, const char *realm, svn_boolean_t may_save, apr_pool_t *pool) |
An implementation of svn_auth_ssl_client_cert_pw_prompt_func_t that prompts the user for their SSL certificate password via the command line. | |
svn_error_t * | svn_cmdline_auth_plaintext_prompt (svn_boolean_t *may_save_plaintext, const char *realmstring, void *baton, apr_pool_t *pool) |
An implementation of svn_auth_plaintext_prompt_func_t that prompts the user whether storing unencypted passwords to disk is OK. | |
svn_error_t * | svn_cmdline_auth_plaintext_passphrase_prompt (svn_boolean_t *may_save_plaintext, const char *realmstring, void *baton, apr_pool_t *pool) |
An implementation of svn_auth_plaintext_passphrase_prompt_func_t that prompts the user whether storing unencypted passphrase to disk is OK. | |
svn_error_t * | svn_cmdline_create_auth_baton (svn_auth_baton_t **ab, svn_boolean_t non_interactive, const char *username, const char *password, const char *config_dir, svn_boolean_t no_auth_cache, svn_boolean_t trust_server_cert, svn_config_t *cfg, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool) |
Set *ab to an authentication baton allocated from pool and initialized with the standard set of authentication providers used by the command line client. | |
svn_error_t * | svn_cmdline_setup_auth_baton (svn_auth_baton_t **ab, svn_boolean_t non_interactive, const char *username, const char *password, const char *config_dir, svn_boolean_t no_auth_cache, svn_config_t *cfg, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool) |
Similar to svn_cmdline_create_auth_baton(), but with trust_server_cert always set to false. | |
svn_error_t * | svn_cmdline__getopt_init (apr_getopt_t **os, int argc, const char *argv[], apr_pool_t *pool) |
Wrapper for apr_getopt_init(), which see. |
Support functions for command line programs.
Definition in file svn_cmdline.h.
typedef struct svn_cmdline_prompt_baton2_t svn_cmdline_prompt_baton2_t |
A cancellation function/baton pair, and the path to the configuration directory.
To be passed as the baton argument to the svn_cmdline_*_prompt
functions.
typedef struct svn_cmdline_prompt_baton_t svn_cmdline_prompt_baton_t |
Like svn_cmdline_prompt_baton2_t, but without the path to the configuration directory.
svn_error_t* svn_cmdline__getopt_init | ( | apr_getopt_t ** | os, |
int | argc, | ||
const char * | argv[], | ||
apr_pool_t * | pool | ||
) |
Wrapper for apr_getopt_init(), which see.
This is a private API for Subversion's own use.
svn_error_t* svn_cmdline_auth_plaintext_passphrase_prompt | ( | svn_boolean_t * | may_save_plaintext, |
const char * | realmstring, | ||
void * | baton, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_plaintext_passphrase_prompt_func_t
that prompts the user whether storing unencypted passphrase to disk is OK.
Expects a svn_cmdline_prompt_baton2_t
to be passed as baton.
svn_error_t* svn_cmdline_auth_plaintext_prompt | ( | svn_boolean_t * | may_save_plaintext, |
const char * | realmstring, | ||
void * | baton, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_plaintext_prompt_func_t
that prompts the user whether storing unencypted passwords to disk is OK.
Expects a svn_cmdline_prompt_baton2_t
to be passed as baton.
svn_error_t* svn_cmdline_auth_simple_prompt | ( | svn_auth_cred_simple_t ** | cred_p, |
void * | baton, | ||
const char * | realm, | ||
const char * | username, | ||
svn_boolean_t | may_save, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_simple_prompt_func_t
that prompts the user for keyboard input on the command line.
Expects a svn_cmdline_prompt_baton_t
to be passed as baton.
svn_error_t* svn_cmdline_auth_ssl_client_cert_prompt | ( | svn_auth_cred_ssl_client_cert_t ** | cred_p, |
void * | baton, | ||
const char * | realm, | ||
svn_boolean_t | may_save, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_ssl_client_cert_prompt_func_t
that prompts the user for the filename of their SSL client certificate via the command line.
Records absolute path of the SSL client certificate file.
Expects a svn_cmdline_prompt_baton_t
to be passed as baton.
svn_error_t* svn_cmdline_auth_ssl_client_cert_pw_prompt | ( | svn_auth_cred_ssl_client_cert_pw_t ** | cred_p, |
void * | baton, | ||
const char * | realm, | ||
svn_boolean_t | may_save, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_ssl_client_cert_pw_prompt_func_t
that prompts the user for their SSL certificate password via the command line.
Expects a svn_cmdline_prompt_baton_t
to be passed as baton.
svn_error_t* svn_cmdline_auth_ssl_server_trust_prompt | ( | svn_auth_cred_ssl_server_trust_t ** | cred_p, |
void * | baton, | ||
const char * | realm, | ||
apr_uint32_t | failures, | ||
const svn_auth_ssl_server_cert_info_t * | cert_info, | ||
svn_boolean_t | may_save, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_ssl_server_trust_prompt_func_t
that asks the user if they trust a specific ssl server via the command line.
Expects a svn_cmdline_prompt_baton_t
to be passed as baton.
svn_error_t* svn_cmdline_auth_username_prompt | ( | svn_auth_cred_username_t ** | cred_p, |
void * | baton, | ||
const char * | realm, | ||
svn_boolean_t | may_save, | ||
apr_pool_t * | pool | ||
) |
An implementation of svn_auth_username_prompt_func_t
that prompts the user for their username via the command line.
Expects a svn_cmdline_prompt_baton_t
to be passed as baton.
svn_error_t* svn_cmdline_create_auth_baton | ( | svn_auth_baton_t ** | ab, |
svn_boolean_t | non_interactive, | ||
const char * | username, | ||
const char * | password, | ||
const char * | config_dir, | ||
svn_boolean_t | no_auth_cache, | ||
svn_boolean_t | trust_server_cert, | ||
svn_config_t * | cfg, | ||
svn_cancel_func_t | cancel_func, | ||
void * | cancel_baton, | ||
apr_pool_t * | pool | ||
) |
Set *ab to an authentication baton allocated from pool and initialized with the standard set of authentication providers used by the command line client.
non_interactive, username, password, config_dir, no_auth_cache, and trust_server_cert are the values of the command line options of the corresponding names.
cfg is the SVN_CONFIG_CATEGORY_CONFIG
configuration, and cancel_func and cancel_baton control the cancellation of the prompting providers that are initialized.
Use pool for all allocations.
const char* svn_cmdline_cstring_from_utf8_fuzzy | ( | const char * | src, |
apr_pool_t * | pool | ||
) |
Like svn_utf_cstring_from_utf8_fuzzy(), but converts to an output-encoded C string.
svn_error_t* svn_cmdline_fflush | ( | FILE * | stream | ) |
Flush output buffers of the stdio stream, returning an error if that fails.
This is just a wrapper for the standard fflush() function for consistent error handling.
svn_error_t* svn_cmdline_fprintf | ( | FILE * | stream, |
apr_pool_t * | pool, | ||
const char * | fmt, | ||
... | |||
) |
Write to the stdio stream, using a printf-like format string fmt, passed through apr_pvsprintf().
All string arguments are in UTF-8; the output is converted to the output encoding. Use pool for temporary allocation.
svn_error_t* svn_cmdline_fputs | ( | const char * | string, |
FILE * | stream, | ||
apr_pool_t * | pool | ||
) |
Output the string to the stdio stream, converting from UTF-8 to the output encoding.
Use pool for temporary allocation.
int svn_cmdline_handle_exit_error | ( | svn_error_t * | error, |
apr_pool_t * | pool, | ||
const char * | prefix | ||
) |
Handle error in preparation for immediate exit from a command-line client.
Specifically:
Call svn_handle_error2(error, stderr, FALSE, prefix), clear error, destroy pool iff it is non-NULL, and return EXIT_FAILURE.
int svn_cmdline_init | ( | const char * | progname, |
FILE * | error_stream | ||
) |
Set up the locale for character conversion, and initialize APR.
If error_stream is non-NULL, print error messages to the stream, using progname as the program name. Attempt to set stdout
to line-buffered mode, and error_stream to unbuffered mode. Return EXIT_SUCCESS
if successful, otherwise EXIT_FAILURE
.
const char* svn_cmdline_output_encoding | ( | apr_pool_t * | pool | ) |
Return the name of the output encoding allocated in pool, or APR_LOCALE_CHARSET
if the output encoding is the same as the locale encoding.
svn_error_t* svn_cmdline_printf | ( | apr_pool_t * | pool, |
const char * | fmt, | ||
... | |||
) |
Write to stdout, using a printf-like format string fmt, passed through apr_pvsprintf().
All string arguments are in UTF-8; the output is converted to the output encoding. Use pool for temporary allocation.
svn_error_t* svn_cmdline_prompt_user | ( | const char ** | result, |
const char * | prompt_str, | ||
apr_pool_t * | pool | ||
) |
Similar to svn_cmdline_prompt_user2, but without cancellation support.
svn_error_t* svn_cmdline_prompt_user2 | ( | const char ** | result, |
const char * | prompt_str, | ||
svn_cmdline_prompt_baton_t * | baton, | ||
apr_pool_t * | pool | ||
) |
Prompt the user for input, using prompt_str for the prompt and baton (which may be NULL
) for cancellation, and returning the user's response in result, allocated in pool.
svn_error_t* svn_cmdline_setup_auth_baton | ( | svn_auth_baton_t ** | ab, |
svn_boolean_t | non_interactive, | ||
const char * | username, | ||
const char * | password, | ||
const char * | config_dir, | ||
svn_boolean_t | no_auth_cache, | ||
svn_config_t * | cfg, | ||
svn_cancel_func_t | cancel_func, | ||
void * | cancel_baton, | ||
apr_pool_t * | pool | ||
) |
Similar to svn_cmdline_create_auth_baton(), but with trust_server_cert always set to false.