/*
******************************************************************************
*
-* Copyright (C) 1998-2004, International Business Machines
+* Copyright (C) 1998-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
#include "uprintf.h"
#include "ufile.h"
+#include "ucln_io.h"
#include "locbund.h"
#include "cmemory.h"
+static UFILE *gStdOut = NULL;
+
+static UBool U_CALLCONV uprintf_cleanup(void)
+{
+ if (gStdOut != NULL) {
+ u_fclose(gStdOut);
+ gStdOut = NULL;
+ }
+ return TRUE;
+}
+
+U_CAPI UFILE * U_EXPORT2
+u_get_stdout()
+{
+ if (gStdOut == NULL) {
+ gStdOut = u_finit(stdout, NULL, NULL);
+ ucln_io_registerCleanup(UCLN_IO_PRINTF, &uprintf_cleanup);
+ }
+ return gStdOut;
+}
+
static int32_t U_EXPORT2
u_printf_write(void *context,
const UChar *str,
return count;
}
+U_CAPI int32_t U_EXPORT2
+u_printf(const char *patternSpecification,
+ ...)
+{
+ va_list ap;
+ int32_t count;
+ va_start(ap, patternSpecification);
+ count = u_vfprintf(u_get_stdout(), patternSpecification, ap);
+ va_end(ap);
+ return count;
+}
+
U_CAPI int32_t U_EXPORT2
u_fprintf_u( UFILE *f,
const UChar *patternSpecification,
return count;
}
+U_CAPI int32_t U_EXPORT2
+u_printf_u(const UChar *patternSpecification,
+ ...)
+{
+ va_list ap;
+ int32_t count;
+ va_start(ap, patternSpecification);
+ count = u_vfprintf_u(u_get_stdout(), patternSpecification, ap);
+ va_end(ap);
+ return count;
+}
+
U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
u_vfprintf( UFILE *f,
const char *patternSpecification,