1 /* FILE * interface to a struct __*printf_buffer.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 /* Registered printf format specifier callbacks produce data via a
20 FILE * stream. struct __printf_buffer_as_file enables vfprintf to
21 create a suitable stdio stream. Likewise struct
22 __wprintf_buffer_as_file for vfwprintf. */
24 #ifndef PRINTF_BUFFER_AS_FILE_H
25 #define PRINTF_BUFFER_AS_FILE_H
27 #include <libio/libioP.h>
29 struct __printf_buffer
;
31 struct __printf_buffer_as_file
33 /* Interface to libio. */
35 const struct _IO_jump_t
*vtable
;
37 /* Pointer to the underlying buffer. */
38 struct __printf_buffer
*next
;
41 /* Initialization *FP so that data written to its FILE * stream ends
43 void __printf_buffer_as_file_init (struct __printf_buffer_as_file
*fp
,
44 struct __printf_buffer
*next
)
47 /* Returns the FILE * that can be used to write data to the
50 __printf_buffer_as_file_get (struct __printf_buffer_as_file
*file
)
55 /* Transfers all pending data from the FILE * to the underlying
56 buffer. Returns true if there have been no errors. */
57 bool __printf_buffer_as_file_terminate (struct __printf_buffer_as_file
*)
60 /* Wide variant follows. */
62 struct __wprintf_buffer
;
63 struct __wprintf_buffer_as_file
65 /* Interface to libio. */
67 const struct _IO_jump_t
*vtable
;
68 struct _IO_wide_data wide_stream
;
70 /* Pointer to the underlying buffer. */
71 struct __wprintf_buffer
*next
;
74 void __wprintf_buffer_as_file_init (struct __wprintf_buffer_as_file
*fp
,
75 struct __wprintf_buffer
*next
)
79 __wprintf_buffer_as_file_get (struct __wprintf_buffer_as_file
*file
)
84 bool __wprintf_buffer_as_file_terminate (struct __wprintf_buffer_as_file
*)
87 #endif /* PRINTF_BUFFER_AS_FILE_H */