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