Move all sources to 'src/'
[lttng-ust.git] / src / snprintf / wcio.h
1 /* $OpenBSD: wcio.h,v 1.1 2005/06/17 20:40:32 espie Exp $ */
2 /* $NetBSD: wcio.h,v 1.3 2003/01/18 11:30:00 thorpej Exp $ */
3
4 /*
5 * SPDX-License-Identifier: BSD-2-Clause
6 *
7 * Copyright (C)2001 Citrus Project,
8 * All rights reserved.
9 *
10 * $Citrus$
11 */
12
13 #ifndef _WCIO_H_
14 #define _WCIO_H_
15
16 #include <stddef.h>
17 #include <wchar.h>
18
19 /* minimal requirement of SUSv2 */
20 #define WCIO_UNGETWC_BUFSIZE 1
21
22 struct wchar_io_data {
23 mbstate_t wcio_mbstate_in;
24 mbstate_t wcio_mbstate_out;
25
26 wchar_t wcio_ungetwc_buf[WCIO_UNGETWC_BUFSIZE];
27 size_t wcio_ungetwc_inbuf;
28
29 int wcio_mode; /* orientation */
30 };
31
32 #define WCIO_GET(fp) \
33 (_EXT(fp) ? &(_EXT(fp)->_wcio) : (struct wchar_io_data *)0)
34
35 #define WCIO_GET_NONULL(fp) \
36 (&(_EXT(fp)->_wcio))
37
38 #define _SET_ORIENTATION(fp, mode) \
39 do {\
40 struct wchar_io_data *_wcio = WCIO_GET(fp); \
41 if (_wcio && _wcio->wcio_mode == 0) \
42 _wcio->wcio_mode = (mode);\
43 } while (0)
44
45 /*
46 * WCIO_FREE should be called by fclose
47 */
48 #define WCIO_FREE(fp) \
49 do {\
50 struct wchar_io_data *_wcio = WCIO_GET(fp); \
51 if (_wcio) { \
52 _wcio->wcio_mode = 0;\
53 _wcio->wcio_ungetwc_inbuf = 0;\
54 } \
55 } while (0)
56
57 #define WCIO_FREEUB(fp) \
58 do {\
59 struct wchar_io_data *_wcio = WCIO_GET(fp); \
60 if (_wcio) { \
61 _wcio->wcio_ungetwc_inbuf = 0;\
62 } \
63 } while (0)
64
65 #define WCIO_INIT(fp) \
66 memset(WCIO_GET_NONULL(fp), 0, sizeof(struct wchar_io_data))
67
68 #endif /*_WCIO_H_*/
This page took 0.030804 seconds and 4 git commands to generate.