os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/printf.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/printf.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,148 @@
     1.4 +/************************************************************************
     1.5 + *
     1.6 + * printf.h - declarations of the rw_printf family of functions
     1.7 + *
     1.8 + * $Id: printf.h 278837 2005-09-05 20:57:44Z sebor $
     1.9 + *
    1.10 + ************************************************************************
    1.11 + *
    1.12 + * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
    1.13 + * Software division. Licensed under the Apache License, Version 2.0 (the
    1.14 + * "License");  you may  not use this file except  in compliance with the
    1.15 + * License.    You    may   obtain   a   copy   of    the   License    at
    1.16 + * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
    1.17 + * applicable law  or agreed to  in writing,  software  distributed under
    1.18 + * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
    1.19 + * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
    1.20 + * for the specific language governing permissions  and limitations under
    1.21 + * the License.
    1.22 + * 
    1.23 + **************************************************************************/
    1.24 +
    1.25 +#ifndef RW_PRINTF_H_INCLUDED
    1.26 +#define RW_PRINTF_H_INCLUDED
    1.27 +
    1.28 +#include <testdefs.h>
    1.29 +
    1.30 +struct rw_file;
    1.31 +
    1.32 +// the equivalent of stdout and stderr
    1.33 +extern _TEST_EXPORT rw_file* const rw_stdout;
    1.34 +extern _TEST_EXPORT rw_file* const rw_stderr;
    1.35 +
    1.36 +
    1.37 +/************************************************************************
    1.38 + * Formatted file output.
    1.39 + ************************************************************************/
    1.40 +
    1.41 +/**
    1.42 + *  Prints to rw_stdout.
    1.43 + */
    1.44 +_TEST_EXPORT int
    1.45 +rw_printf (const char*, ...);
    1.46 +
    1.47 +/**
    1.48 + * Prints to a file.
    1.49 + */
    1.50 +_TEST_EXPORT int
    1.51 +rw_fprintf (rw_file*, const char*, ...);
    1.52 +
    1.53 +
    1.54 +/************************************************************************
    1.55 + * Formatted string output.
    1.56 + ************************************************************************/
    1.57 +
    1.58 +/**
    1.59 + * Prints to a character buffer.
    1.60 + */
    1.61 +_TEST_EXPORT int
    1.62 +rw_sprintf (char*, const char*, ...);
    1.63 +
    1.64 +/**
    1.65 + * Prints to a character buffer of given size.
    1.66 + */
    1.67 +_TEST_EXPORT int
    1.68 +rw_snprintf (char*, _RWSTD_SIZE_T, const char*, ...);
    1.69 +
    1.70 +
    1.71 +/************************************************************************
    1.72 + * Formatted string output into a dynamically allocated buffer.
    1.73 + ************************************************************************/
    1.74 +
    1.75 +/**
    1.76 + * Prints to a dynamically allocated character buffer.
    1.77 + *
    1.78 + * @param fmt  Format specifier.
    1.79 + *
    1.80 + * @return  On success, returns a pointer to the dynamically allocated
    1.81 + *          character buffer. Otherwise, returns 0.
    1.82 + */
    1.83 +_TEST_EXPORT char*
    1.84 +rw_sprintfa (const char* fmt, ...);
    1.85 +
    1.86 +
    1.87 +/**
    1.88 + * Prints to a dynamically allocated character buffer.
    1.89 + *
    1.90 + * @param buf  A pointer to character buffer where the function should
    1.91 + *        store its output.
    1.92 + * @param bufise  The size of the character buffer in bytes.
    1.93 + *
    1.94 + * @return  On success, if the size of the supplied buffer was sufficient
    1.95 + *          to format all characters including the terminating NUL, returns
    1.96 + *          buf. Otherwise, if the size of the supplied buffer was not
    1.97 + *          sufficient, returns a pointer to the newly allocated character
    1.98 + *          buffer of sufficient size. Returns 0 on failure.
    1.99 + */
   1.100 +_TEST_EXPORT char*
   1.101 +rw_snprintfa (char *buf, _RWSTD_SIZE_T bufsize, const char* fmt, ...);
   1.102 +
   1.103 +
   1.104 +/**
   1.105 + * Prints to a dynamically allocated character buffer of sufficient size.
   1.106 + * Provided for portability with the BSD and GNU C libraries:
   1.107 + *
   1.108 + * http://www.freebsd.org/cgi/man.cgi?query=asprintf
   1.109 + * http://www.openbsd.org/cgi-bin/man.cgi?query=asprintf
   1.110 + * http://netbsd.gw.com/cgi-bin/man-cgi?asprintf++NetBSD-current
   1.111 + * http://www.gnu.org/software/libc/manual/html_node/Dynamic-Output.html
   1.112 + *
   1.113 + * @param pbuf  Pointer to a pointer to character set by the caller to
   1.114 + *        to address of the inital character buffer, or 0 of no such
   1.115 + *        buffer exists. The function sets the pointer to a the address
   1.116 + *        of the dynamically allocated character buffer, or leaves it
   1.117 + *        unchanged if it doesn't allocate any buffer.
   1.118 + * @param pbufsize  Pointer to a size_t set by the caller to the size of
   1.119 + *        the inital character buffer. The function sets the value pointed
   1.120 + *        to by this argument to the size of the dynamically allocated
   1.121 + *        character buffer, or leaves it unchanged if it doesn't allocate
   1.122 + *        any buffer.
   1.123 + * @param fmt  Format specifier.
   1.124 + *        The format specifier string has the same syntax as C99 sprintf
   1.125 + *        (see 7.19.6.1 of ISO/IEC 9899:1999) with the following extensions:
   1.126 + *
   1.127 + *        %n$          where n is a integer (see IEEE Std 1003.1)
   1.128 + *        %m           the value of strerror(errno)
   1.129 + *
   1.130 + *        %{?}         if clause (extracts an int)
   1.131 + *        %{:}         else clause
   1.132 + *        %{;}         end of if/else clause
   1.133 + *        %{#s}        quoted narrow character string
   1.134 + *        %{#ls}       quoted wide character string
   1.135 + *        %{$envvar}   value of an environment variable envvar
   1.136 + *        %{f}         function pointer
   1.137 + *        %{M}         member pointer
   1.138 + *        %{#m}        name of the errno constant (such as EINVAL)
   1.139 + *        %{n}         buffer size
   1.140 + *        %{S}         pointer to std::string
   1.141 + *        %{lS}        pointer to std::wstring
   1.142 + *        %{tm}        pointer to struct tm
   1.143 + *        %{InJ}       where n is one of { 8, 16, 32, 64 } and J { d, o, x, X }
   1.144 + *
   1.145 + * @return  On success, returns the number of characters formatted into
   1.146 + *          the buffer, otherwise -1.
   1.147 + */
   1.148 +_TEST_EXPORT int
   1.149 +rw_asnprintf (char** pbuf, _RWSTD_SIZE_T *pbufsize, const char *fmt, ...);
   1.150 +
   1.151 +#endif   // RW_PRINTF_H_INCLUDED