]>
Commit | Line | Data |
---|---|---|
659fe9fd | 1 | /* Flush a struct __printf_buffer. Multibyte version. |
dff8da6b | 2 | Copyright (C) 2022-2024 Free Software Foundation, Inc. |
659fe9fd FW |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
e88b9f0e | 19 | #include <errno.h> |
659fe9fd FW |
20 | #include <printf_buffer.h> |
21 | ||
22 | #include "printf_buffer-char.h" | |
23 | #include "Xprintf_buffer_flush.c" | |
24 | ||
25 | /* The __printf_buffer_flush_* functions are defined together with | |
26 | functions that are pulled in by strong references. */ | |
27 | #ifndef SHARED | |
e88b9f0e | 28 | # pragma weak __printf_buffer_flush_snprintf |
659fe9fd | 29 | # pragma weak __printf_buffer_flush_to_file |
af7f4165 | 30 | # pragma weak __printf_buffer_flush_asprintf |
8ece45e4 | 31 | # pragma weak __printf_buffer_flush_dprintf |
e88b9f0e FW |
32 | # pragma weak __printf_buffer_flush_fp |
33 | # pragma weak __printf_buffer_flush_fp_to_wide | |
34 | # pragma weak __printf_buffer_flush_fphex_to_wide | |
5365acc5 | 35 | # pragma weak __printf_buffer_flush_obstack |
659fe9fd FW |
36 | #endif /* !SHARED */ |
37 | ||
38 | static void | |
39 | __printf_buffer_do_flush (struct __printf_buffer *buf) | |
40 | { | |
41 | switch (buf->mode) | |
42 | { | |
43 | case __printf_buffer_mode_failed: | |
fb9bd841 | 44 | case __printf_buffer_mode_sprintf: |
659fe9fd | 45 | return; |
e88b9f0e FW |
46 | case __printf_buffer_mode_snprintf: |
47 | __printf_buffer_flush_snprintf ((struct __printf_buffer_snprintf *) buf); | |
48 | return; | |
fb9bd841 FW |
49 | case __printf_buffer_mode_sprintf_chk: |
50 | __chk_fail (); | |
51 | break; | |
659fe9fd FW |
52 | case __printf_buffer_mode_to_file: |
53 | __printf_buffer_flush_to_file ((struct __printf_buffer_to_file *) buf); | |
54 | return; | |
af7f4165 FW |
55 | case __printf_buffer_mode_asprintf: |
56 | __printf_buffer_flush_asprintf ((struct __printf_buffer_asprintf *) buf); | |
57 | return; | |
8ece45e4 FW |
58 | case __printf_buffer_mode_dprintf: |
59 | __printf_buffer_flush_dprintf ((struct __printf_buffer_dprintf *) buf); | |
60 | return; | |
e88b9f0e FW |
61 | case __printf_buffer_mode_strfmon: |
62 | __set_errno (E2BIG); | |
63 | __printf_buffer_mark_failed (buf); | |
64 | return; | |
65 | case __printf_buffer_mode_fp: | |
66 | __printf_buffer_flush_fp ((struct __printf_buffer_fp *) buf); | |
67 | return; | |
68 | case __printf_buffer_mode_fp_to_wide: | |
69 | __printf_buffer_flush_fp_to_wide | |
70 | ((struct __printf_buffer_fp_to_wide *) buf); | |
71 | return; | |
72 | case __printf_buffer_mode_fphex_to_wide: | |
73 | __printf_buffer_flush_fphex_to_wide | |
74 | ((struct __printf_buffer_fphex_to_wide *) buf); | |
75 | return; | |
5365acc5 FW |
76 | case __printf_buffer_mode_obstack: |
77 | __printf_buffer_flush_obstack ((struct __printf_buffer_obstack *) buf); | |
78 | return; | |
659fe9fd FW |
79 | } |
80 | __builtin_trap (); | |
81 | } |