00001 /**
00002 * @copyright
00003 * ====================================================================
00004 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
00005 *
00006 * This software is licensed as described in the file COPYING, which
00007 * you should have received as part of this distribution. The terms
00008 * are also available at http://subversion.tigris.org/license-1.html.
00009 * If newer versions of this license are posted there, you may use a
00010 * newer version instead, at your option.
00011 *
00012 * This software consists of voluntary contributions made by many
00013 * individuals. For exact contribution history, see the revision
00014 * history and logs, available at http://subversion.tigris.org/.
00015 * ====================================================================
00016 * @endcopyright
00017 *
00018 * @file svn_cmdline.h
00019 * @brief Support functions for command line programs
00020 */
00021
00022
00023
00024
00025 #ifndef SVN_CMDLINE_H
00026 #define SVN_CMDLINE_H
00027
00028 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00029 #define APR_WANT_STDIO
00030 #endif
00031 #include <apr_want.h>
00032
00033 #include "svn_utf.h"
00034
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif /* __cplusplus */
00038
00039
00040 /** Set up the locale for character conversion, and initialize APR.
00041 * If @a error_stream is non-null, print error messages to the stream,
00042 * using @a progname as the program name. Return @c EXIT_SUCCESS if
00043 * successful, otherwise @c EXIT_FAILURE.
00044 *
00045 * @note This function should be called exactly once at program startup,
00046 * before calling any other APR or Subversion functions.
00047 */
00048 int svn_cmdline_init (const char *progname, FILE *error_stream);
00049
00050
00051 /** Set @a *dest to an output-encoded C string from UTF-8 C string @a
00052 * src; allocate @a *dest in @a pool.
00053 */
00054 svn_error_t *svn_cmdline_cstring_from_utf8 (const char **dest,
00055 const char *src,
00056 apr_pool_t *pool);
00057
00058 /** Like svn_utf_cstring_from_utf8_fuzzy(), but converts to an
00059 * output-encoded C string. */
00060 const char *svn_cmdline_cstring_from_utf8_fuzzy (const char *src,
00061 apr_pool_t *pool);
00062
00063 /** Set @a *dest to a UTF-8-encoded C string from input-encoded C
00064 * string @a src; allocate @a *dest in @a pool.
00065 */
00066 svn_error_t * svn_cmdline_cstring_to_utf8 (const char **dest,
00067 const char *src,
00068 apr_pool_t *pool);
00069
00070 /** Set @a *dest to an output-encoded natively-formatted path string
00071 * from canonical path @a src; allocate @a *dest in @a pool.
00072 */
00073 svn_error_t *svn_cmdline_path_local_style_from_utf8 (const char **dest,
00074 const char *src,
00075 apr_pool_t *pool);
00076
00077 /** Write to stdout, using a printf-like format string @a fmt, passed
00078 * through apr_pvsprintf(). All string arguments are in UTF-8; the output
00079 * is converted to the output encoding. Use @a pool for temporary
00080 * allocation.
00081 *
00082 * @since New in 1.1.
00083 */
00084 svn_error_t *svn_cmdline_printf (apr_pool_t *pool,
00085 const char *fmt,
00086 ...)
00087 __attribute__((format(printf, 2, 3)));
00088
00089 /** Write to the stdio @a stream, using a printf-like format string @a fmt,
00090 * passed through apr_pvsprintf(). All string arguments are in UTF-8;
00091 * the output is converted to the output encoding. Use @a pool for
00092 * temporary allocation.
00093 *
00094 * @since New in 1.1.
00095 */
00096 svn_error_t *svn_cmdline_fprintf (FILE *stream,
00097 apr_pool_t *pool,
00098 const char *fmt,
00099 ...)
00100 __attribute__((format(printf, 3, 4)));
00101
00102 /** Output the @a string to the stdio @a stream, converting from UTF-8
00103 * to the output encoding. Use @a pool for temporary allocation.
00104 *
00105 * @since New in 1.1.
00106 */
00107 svn_error_t *svn_cmdline_fputs (const char *string,
00108 FILE *stream,
00109 apr_pool_t *pool);
00110
00111 /** Flush output buffers of the stdio @a stream, returning an error if that
00112 * fails. This is just a wrapper for the standard fflush() function for
00113 * consistent error handling.
00114 *
00115 * @since New in 1.1.
00116 */
00117 svn_error_t *svn_cmdline_fflush (FILE *stream);
00118
00119 /** Return the name of the output encoding allocated in @a pool, or @c
00120 * APR_LOCALE_CHARSET if the output encoding is the same as the locale
00121 * encoding.
00122 *
00123 * @since New in 1.3.
00124 */
00125 const char *svn_cmdline_output_encoding (apr_pool_t *pool);
00126
00127 /** Handle @a error in preparation for immediate exit from a
00128 * command-line client. Specifically:
00129 *
00130 * Call svn_handle_error2(@a error, stderr, FALSE, @a prefix), clear
00131 * @a error, destroy @a pool iff it is non-NULL, and return EXIT_FAILURE.
00132 *
00133 * @since New in 1.3.
00134 */
00135 int svn_cmdline_handle_exit_error (svn_error_t *error,
00136 apr_pool_t *pool,
00137 const char *prefix);
00138
00139 #ifdef __cplusplus
00140 }
00141 #endif /* __cplusplus */
00142
00143 #endif /* SVN_CMDLINE_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002