os/ossrv/genericopenlibs/cstdlib/LSTDIO/PRINTF.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDIO/PRINTF.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,63 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#include <_ansi.h>
    1.24 +#include <stdio_r.h>
    1.25 +
    1.26 +#include <stdarg.h>
    1.27 +
    1.28 +/**
    1.29 +A reentrant version of printf().
    1.30 +*/
    1.31 +EXPORT_C int
    1.32 +_printf_r (struct _reent *ptr, const char *fmt, ...)
    1.33 +{
    1.34 +  int ret;
    1.35 +  va_list ap;
    1.36 +
    1.37 +  va_start (ap, fmt);
    1.38 +  ret = _vfprintf_r (ptr, _stdout_r(ptr), fmt, ap);
    1.39 +  va_end (ap);
    1.40 +  return ret;
    1.41 +}
    1.42 +
    1.43 +#ifndef _REENT_ONLY
    1.44 +
    1.45 +/**
    1.46 +Print formatted data to stdout.
    1.47 +Prints to standard output a sequence of arguments formatted as the format argument specifies.
    1.48 +@return On success, the total number of characters printed is returned.
    1.49 +On error, a negative number is returned.
    1.50 +@param fmt String that contains the text to be printed.
    1.51 +Optionally it can contain format tags that are substituted 
    1.52 +by the values specified in subsequent argument(s) and formatted as requested.
    1.53 +*/
    1.54 +EXPORT_C int
    1.55 +printf (const char *fmt, ...)
    1.56 +{
    1.57 +  int ret;
    1.58 +  va_list ap;
    1.59 +
    1.60 +  va_start (ap, fmt);
    1.61 +  ret = vfprintf (__stdout(), fmt, ap);
    1.62 +  va_end (ap);
    1.63 +  return ret;
    1.64 +}
    1.65 +
    1.66 +#endif /* ! _REENT_ONLY */