Implement new functions for printf, fprintf and fputs for use in
command line programs.

* subversion/include/svn_cmdline.h:
* subversion/libsvn_subr/cmdline.c:
  (svn_cmdline_printf, svn_cmdline_fprintf, svn_cmdline_fputs):
  New functions.

Index: subversion/include/svn_cmdline.h
===================================================================
--- subversion/include/svn_cmdline.h	(revision 9692)
+++ subversion/include/svn_cmdline.h	(arbetskopia)
@@ -74,6 +74,37 @@
                                                      const char *src,
                                                      apr_pool_t *pool);
 
+/** Write to stdout, using a printf-like format string @a fmt, passed
+ * through @c apr_pvsprintf.  All string arguments are in UTF-8; the output
+ * is converted to the output encoding.  Use @a pool for temporary
+ * allocation.
+ */
+
+svn_error_t *svn_cmdline_printf (apr_pool_t *pool,
+                                 const char *fmt,
+                                 ...)
+       __attribute__((format(printf, 2, 3)));
+
+/** Write to the stdio @a stream, using a printf-like format string @a fmt,
+ * passed through @c apr_pvsprintf.  All string arguments are in UTF-8;
+ * the output is converted to the output encoding.  Use @a pool for
+ * temporary allocation.
+ */
+
+svn_error_t *svn_cmdline_fprintf (FILE *stream,
+                                  apr_pool_t *pool,
+                                  const char *fmt,
+                                  ...)
+       __attribute__((format(printf, 3, 4)));
+
+/** Output the @a string to the stdio @a stream, converting from UTF-8
+ * to the output encoding.  Use @a pool for temporary allocation.
+ */
+
+svn_error_t *svn_cmdline_fputs (const char *string,
+                                FILE *stream,
+                                apr_pool_t *pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c	(revision 9692)
+++ subversion/libsvn_subr/cmdline.c	(arbetskopia)
@@ -217,3 +217,58 @@
                                         svn_path_local_style (src, pool),
                                         pool);
 }
+
+svn_error_t *
+svn_cmdline_printf (apr_pool_t *pool, const char *fmt, ...)
+{
+  const char *message;
+  va_list ap;
+
+  /* A note about encoding issues:
+   * APR uses the execution character set, but here we give it UTF-8 strings,
+   * both the fmt argument and any other string arguments.  Since apr_pvsprintf
+   * only cares about and produces ASCII characters, this works under the
+   * assumption that all supported platforms use an execution character set
+   * with ASCII as a subset.
+   */
+
+  va_start (ap, fmt);
+  message = apr_pvsprintf (pool, fmt, ap);
+  va_end (ap);
+
+  return svn_cmdline_fputs(message, stdout, pool);
+}
+
+svn_error_t *
+svn_cmdline_fprintf (FILE *stream, apr_pool_t *pool, const char *fmt, ...)
+{
+  const char *message;
+  va_list ap;
+
+  /* See svn_cmdline_printf () for a note about character encoding issues. */
+
+  va_start (ap, fmt);
+  message = apr_pvsprintf (pool, fmt, ap);
+  va_end (ap);
+
+  return svn_cmdline_fputs(message, stream, pool);
+}
+
+svn_error_t *
+svn_cmdline_fputs (const char *string, FILE* stream, apr_pool_t *pool)
+{
+  svn_error_t *err;
+  const char *out;
+
+  err = svn_cmdline_cstring_from_utf8 (&out, string, pool);
+
+  if (err)
+    {
+      svn_error_clear (err);
+      out = svn_cmdline_cstring_from_utf8_fuzzy (string, pool);
+    }
+
+  fputs (out, stream);
+
+  return SVN_NO_ERROR;
+}
