math: Fix exp10 undefined left shift
[glibc.git] / stdio-common / printf_buffer_as_file.h
blobc0d65b9ee5f286c42e9d979c717dcb6022b4f92e
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. */
34 FILE stream;
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
42 up in NEXT. */
43 void __printf_buffer_as_file_init (struct __printf_buffer_as_file *fp,
44 struct __printf_buffer *next)
45 attribute_hidden;
47 /* Returns the FILE * that can be used to write data to the
48 buffer. */
49 static inline FILE *
50 __printf_buffer_as_file_get (struct __printf_buffer_as_file *file)
52 return &file->stream;
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 *)
58 attribute_hidden;
60 /* Wide variant follows. */
62 struct __wprintf_buffer;
63 struct __wprintf_buffer_as_file
65 /* Interface to libio. */
66 FILE stream;
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)
76 attribute_hidden;
78 static inline FILE *
79 __wprintf_buffer_as_file_get (struct __wprintf_buffer_as_file *file)
81 return &file->stream;
84 bool __wprintf_buffer_as_file_terminate (struct __wprintf_buffer_as_file *)
85 attribute_hidden;
87 #endif /* PRINTF_BUFFER_AS_FILE_H */