os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/printf.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/************************************************************************
sl@0
     2
 *
sl@0
     3
 * printf.h - declarations of the rw_printf family of functions
sl@0
     4
 *
sl@0
     5
 * $Id: printf.h 278837 2005-09-05 20:57:44Z sebor $
sl@0
     6
 *
sl@0
     7
 ************************************************************************
sl@0
     8
 *
sl@0
     9
 * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
sl@0
    10
 * Software division. Licensed under the Apache License, Version 2.0 (the
sl@0
    11
 * "License");  you may  not use this file except  in compliance with the
sl@0
    12
 * License.    You    may   obtain   a   copy   of    the   License    at
sl@0
    13
 * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
sl@0
    14
 * applicable law  or agreed to  in writing,  software  distributed under
sl@0
    15
 * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
sl@0
    16
 * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
sl@0
    17
 * for the specific language governing permissions  and limitations under
sl@0
    18
 * the License.
sl@0
    19
 * 
sl@0
    20
 **************************************************************************/
sl@0
    21
sl@0
    22
#ifndef RW_PRINTF_H_INCLUDED
sl@0
    23
#define RW_PRINTF_H_INCLUDED
sl@0
    24
sl@0
    25
#include <testdefs.h>
sl@0
    26
sl@0
    27
struct rw_file;
sl@0
    28
sl@0
    29
// the equivalent of stdout and stderr
sl@0
    30
extern _TEST_EXPORT rw_file* const rw_stdout;
sl@0
    31
extern _TEST_EXPORT rw_file* const rw_stderr;
sl@0
    32
sl@0
    33
sl@0
    34
/************************************************************************
sl@0
    35
 * Formatted file output.
sl@0
    36
 ************************************************************************/
sl@0
    37
sl@0
    38
/**
sl@0
    39
 *  Prints to rw_stdout.
sl@0
    40
 */
sl@0
    41
_TEST_EXPORT int
sl@0
    42
rw_printf (const char*, ...);
sl@0
    43
sl@0
    44
/**
sl@0
    45
 * Prints to a file.
sl@0
    46
 */
sl@0
    47
_TEST_EXPORT int
sl@0
    48
rw_fprintf (rw_file*, const char*, ...);
sl@0
    49
sl@0
    50
sl@0
    51
/************************************************************************
sl@0
    52
 * Formatted string output.
sl@0
    53
 ************************************************************************/
sl@0
    54
sl@0
    55
/**
sl@0
    56
 * Prints to a character buffer.
sl@0
    57
 */
sl@0
    58
_TEST_EXPORT int
sl@0
    59
rw_sprintf (char*, const char*, ...);
sl@0
    60
sl@0
    61
/**
sl@0
    62
 * Prints to a character buffer of given size.
sl@0
    63
 */
sl@0
    64
_TEST_EXPORT int
sl@0
    65
rw_snprintf (char*, _RWSTD_SIZE_T, const char*, ...);
sl@0
    66
sl@0
    67
sl@0
    68
/************************************************************************
sl@0
    69
 * Formatted string output into a dynamically allocated buffer.
sl@0
    70
 ************************************************************************/
sl@0
    71
sl@0
    72
/**
sl@0
    73
 * Prints to a dynamically allocated character buffer.
sl@0
    74
 *
sl@0
    75
 * @param fmt  Format specifier.
sl@0
    76
 *
sl@0
    77
 * @return  On success, returns a pointer to the dynamically allocated
sl@0
    78
 *          character buffer. Otherwise, returns 0.
sl@0
    79
 */
sl@0
    80
_TEST_EXPORT char*
sl@0
    81
rw_sprintfa (const char* fmt, ...);
sl@0
    82
sl@0
    83
sl@0
    84
/**
sl@0
    85
 * Prints to a dynamically allocated character buffer.
sl@0
    86
 *
sl@0
    87
 * @param buf  A pointer to character buffer where the function should
sl@0
    88
 *        store its output.
sl@0
    89
 * @param bufise  The size of the character buffer in bytes.
sl@0
    90
 *
sl@0
    91
 * @return  On success, if the size of the supplied buffer was sufficient
sl@0
    92
 *          to format all characters including the terminating NUL, returns
sl@0
    93
 *          buf. Otherwise, if the size of the supplied buffer was not
sl@0
    94
 *          sufficient, returns a pointer to the newly allocated character
sl@0
    95
 *          buffer of sufficient size. Returns 0 on failure.
sl@0
    96
 */
sl@0
    97
_TEST_EXPORT char*
sl@0
    98
rw_snprintfa (char *buf, _RWSTD_SIZE_T bufsize, const char* fmt, ...);
sl@0
    99
sl@0
   100
sl@0
   101
/**
sl@0
   102
 * Prints to a dynamically allocated character buffer of sufficient size.
sl@0
   103
 * Provided for portability with the BSD and GNU C libraries:
sl@0
   104
 *
sl@0
   105
 * http://www.freebsd.org/cgi/man.cgi?query=asprintf
sl@0
   106
 * http://www.openbsd.org/cgi-bin/man.cgi?query=asprintf
sl@0
   107
 * http://netbsd.gw.com/cgi-bin/man-cgi?asprintf++NetBSD-current
sl@0
   108
 * http://www.gnu.org/software/libc/manual/html_node/Dynamic-Output.html
sl@0
   109
 *
sl@0
   110
 * @param pbuf  Pointer to a pointer to character set by the caller to
sl@0
   111
 *        to address of the inital character buffer, or 0 of no such
sl@0
   112
 *        buffer exists. The function sets the pointer to a the address
sl@0
   113
 *        of the dynamically allocated character buffer, or leaves it
sl@0
   114
 *        unchanged if it doesn't allocate any buffer.
sl@0
   115
 * @param pbufsize  Pointer to a size_t set by the caller to the size of
sl@0
   116
 *        the inital character buffer. The function sets the value pointed
sl@0
   117
 *        to by this argument to the size of the dynamically allocated
sl@0
   118
 *        character buffer, or leaves it unchanged if it doesn't allocate
sl@0
   119
 *        any buffer.
sl@0
   120
 * @param fmt  Format specifier.
sl@0
   121
 *        The format specifier string has the same syntax as C99 sprintf
sl@0
   122
 *        (see 7.19.6.1 of ISO/IEC 9899:1999) with the following extensions:
sl@0
   123
 *
sl@0
   124
 *        %n$          where n is a integer (see IEEE Std 1003.1)
sl@0
   125
 *        %m           the value of strerror(errno)
sl@0
   126
 *
sl@0
   127
 *        %{?}         if clause (extracts an int)
sl@0
   128
 *        %{:}         else clause
sl@0
   129
 *        %{;}         end of if/else clause
sl@0
   130
 *        %{#s}        quoted narrow character string
sl@0
   131
 *        %{#ls}       quoted wide character string
sl@0
   132
 *        %{$envvar}   value of an environment variable envvar
sl@0
   133
 *        %{f}         function pointer
sl@0
   134
 *        %{M}         member pointer
sl@0
   135
 *        %{#m}        name of the errno constant (such as EINVAL)
sl@0
   136
 *        %{n}         buffer size
sl@0
   137
 *        %{S}         pointer to std::string
sl@0
   138
 *        %{lS}        pointer to std::wstring
sl@0
   139
 *        %{tm}        pointer to struct tm
sl@0
   140
 *        %{InJ}       where n is one of { 8, 16, 32, 64 } and J { d, o, x, X }
sl@0
   141
 *
sl@0
   142
 * @return  On success, returns the number of characters formatted into
sl@0
   143
 *          the buffer, otherwise -1.
sl@0
   144
 */
sl@0
   145
_TEST_EXPORT int
sl@0
   146
rw_asnprintf (char** pbuf, _RWSTD_SIZE_T *pbufsize, const char *fmt, ...);
sl@0
   147
sl@0
   148
#endif   // RW_PRINTF_H_INCLUDED