Move to kernel style SPDX license identifiers
[lttng-ust.git] / snprintf / wcio.h
CommitLineData
bf0d695d
PMF
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
c0c0989a
MJ
4/*
5 * SPDX-License-Identifier: BSD-2-Clause
bf0d695d 6 *
c0c0989a
MJ
7 * Copyright (C)2001 Citrus Project,
8 * All rights reserved.
bf0d695d
PMF
9 *
10 * $Citrus$
11 */
12
13#ifndef _WCIO_H_
14#define _WCIO_H_
15
b4051ad8 16#include <stddef.h>
9f18918b 17#include <wchar.h>
b4051ad8 18
bf0d695d
PMF
19/* minimal requirement of SUSv2 */
20#define WCIO_UNGETWC_BUFSIZE 1
21
22struct 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
240578ad
PMF
35#define WCIO_GET_NONULL(fp) \
36 (&(_EXT(fp)->_wcio))
37
bf0d695d
PMF
38#define _SET_ORIENTATION(fp, mode) \
39do {\
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) \
49do {\
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) \
58do {\
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) \
240578ad 66 memset(WCIO_GET_NONULL(fp), 0, sizeof(struct wchar_io_data))
bf0d695d
PMF
67
68#endif /*_WCIO_H_*/
This page took 0.031971 seconds and 4 git commands to generate.