os/ossrv/genericopenlibs/cstdlib/LSTDIO/PRINTF.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 #include <_ansi.h>
    21 #include <stdio_r.h>
    22 
    23 #include <stdarg.h>
    24 
    25 /**
    26 A reentrant version of printf().
    27 */
    28 EXPORT_C int
    29 _printf_r (struct _reent *ptr, const char *fmt, ...)
    30 {
    31   int ret;
    32   va_list ap;
    33 
    34   va_start (ap, fmt);
    35   ret = _vfprintf_r (ptr, _stdout_r(ptr), fmt, ap);
    36   va_end (ap);
    37   return ret;
    38 }
    39 
    40 #ifndef _REENT_ONLY
    41 
    42 /**
    43 Print formatted data to stdout.
    44 Prints to standard output a sequence of arguments formatted as the format argument specifies.
    45 @return On success, the total number of characters printed is returned.
    46 On error, a negative number is returned.
    47 @param fmt String that contains the text to be printed.
    48 Optionally it can contain format tags that are substituted 
    49 by the values specified in subsequent argument(s) and formatted as requested.
    50 */
    51 EXPORT_C int
    52 printf (const char *fmt, ...)
    53 {
    54   int ret;
    55   va_list ap;
    56 
    57   va_start (ap, fmt);
    58   ret = vfprintf (__stdout(), fmt, ap);
    59   va_end (ap);
    60   return ret;
    61 }
    62 
    63 #endif /* ! _REENT_ONLY */