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 @c 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
00083 svn_error_t *svn_cmdline_printf (apr_pool_t *pool,
00084 const char *fmt,
00085 ...)
00086 __attribute__((format(printf, 2, 3)));
00087
00088 /** Write to the stdio @a stream, using a printf-like format string @a fmt,
00089 * passed through @c apr_pvsprintf. All string arguments are in UTF-8;
00090 * the output is converted to the output encoding. Use @a pool for
00091 * temporary allocation.
00092 */
00093
00094 svn_error_t *svn_cmdline_fprintf (FILE *stream,
00095 apr_pool_t *pool,
00096 const char *fmt,
00097 ...)
00098 __attribute__((format(printf, 3, 4)));
00099
00100 /** Output the @a string to the stdio @a stream, converting from UTF-8
00101 * to the output encoding. Use @a pool for temporary allocation.
00102 */
00103
00104 svn_error_t *svn_cmdline_fputs (const char *string,
00105 FILE *stream,
00106 apr_pool_t *pool);
00107
00108 /** Flush output buffers of the stdio @a stream, returning an error if that
00109 * fails. This is just a wrapper for the standard fflush function for
00110 * consistent error handling. */
00111
00112 svn_error_t *svn_cmdline_fflush (FILE *stream);
00113
00114 #ifdef __cplusplus
00115 }
00116 #endif /* __cplusplus */
00117
00118 #endif /* SVN_POOLS_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002