less(1): Upgrade from version 458 to 471
[dragonfly.git] / include / iconv.h
CommitLineData
0d5acd74
JM
1/* $FreeBSD: head/include/iconv.h 255297 2013-09-06 09:46:44Z theraven $ */
2/* $NetBSD: iconv.h,v 1.6 2005/02/03 04:39:32 perry Exp $ */
2180e8af
JS
3
4/*-
0d5acd74
JM
5 * Copyright (c) 2003 Citrus Project,
6 * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org>
2180e8af
JS
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32#ifndef _ICONV_H_
33#define _ICONV_H_
34
0d5acd74 35#include <sys/cdefs.h>
2180e8af
JS
36#include <sys/types.h>
37
0d5acd74
JM
38#include <wchar.h>
39#include <sys/types.h>
40
0d5acd74
JM
41#ifdef __cplusplus
42typedef bool __iconv_bool;
43#elif __STDC_VERSION__ >= 199901L
44typedef _Bool __iconv_bool;
45#else
46typedef int __iconv_bool;
47#endif
48
2180e8af
JS
49struct __tag_iconv_t;
50typedef struct __tag_iconv_t *iconv_t;
51
52__BEGIN_DECLS
53iconv_t iconv_open(const char *, const char *);
0d5acd74
JM
54size_t iconv(iconv_t, const char ** __restrict,
55 size_t * __restrict, char ** __restrict,
56 size_t * __restrict);
2180e8af
JS
57int iconv_close(iconv_t);
58/*
59 * non-portable interfaces for iconv
60 */
0d5acd74 61int __iconv_get_list(char ***, size_t *, __iconv_bool);
2180e8af 62void __iconv_free_list(char **, size_t);
0d5acd74
JM
63size_t __iconv(iconv_t, const char **, size_t *, char **,
64 size_t *, __uint32_t, size_t *);
2180e8af 65#define __ICONV_F_HIDE_INVALID 0x0001
0d5acd74
JM
66
67/*
68 * GNU interfaces for iconv
69 */
0d5acd74
JM
70/* We have iconvctl() */
71#define _ICONV_VERSION 0x0108
72extern int _iconv_version;
73
0d5acd74
JM
74typedef struct {
75 void *spaceholder[64];
76} iconv_allocation_t;
77
78int iconv_open_into(const char *, const char *, iconv_allocation_t *);
79void iconv_set_relocation_prefix(const char *orig_prefix,
80 const char *curr_prefix);
81
82/*
83 * iconvctl() request macros
84 */
85#define ICONV_TRIVIALP 0
86#define ICONV_GET_TRANSLITERATE 1
87#define ICONV_SET_TRANSLITERATE 2
88#define ICONV_GET_DISCARD_ILSEQ 3
89#define ICONV_SET_DISCARD_ILSEQ 4
90#define ICONV_SET_HOOKS 5
91#define ICONV_SET_FALLBACKS 6
9d944071
JM
92#define ICONV_GET_ILSEQ_INVALID 128
93#define ICONV_SET_ILSEQ_INVALID 129
0d5acd74
JM
94
95typedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data);
96typedef void (*iconv_wide_char_hook) (wchar_t wc, void *data);
97
98struct iconv_hooks {
99 iconv_unicode_char_hook uc_hook;
100 iconv_wide_char_hook wc_hook;
101 void *data;
102};
103
104/*
105 * Fallbacks aren't supported but type definitions are provided for
106 * source compatibility.
107 */
108typedef void (*iconv_unicode_mb_to_uc_fallback) (const char*,
109 size_t, void (*write_replacement) (const unsigned int *,
110 size_t, void*), void*, void*);
111typedef void (*iconv_unicode_uc_to_mb_fallback) (unsigned int,
112 void (*write_replacement) (const char *, size_t, void*),
113 void*, void*);
114typedef void (*iconv_wchar_mb_to_wc_fallback) (const char*, size_t,
115 void (*write_replacement) (const wchar_t *, size_t, void*),
116 void*, void*);
117typedef void (*iconv_wchar_wc_to_mb_fallback) (wchar_t,
118 void (*write_replacement) (const char *, size_t, void*),
119 void*, void*);
120
121struct iconv_fallbacks {
122 iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
123 iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
124 iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
125 iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
126 void *data;
127};
128
129
130void iconvlist(int (*do_one) (unsigned int, const char * const *,
131 void *), void *);
132const char *iconv_canonicalize(const char *);
133int iconvctl(iconv_t, int, void *);
2180e8af
JS
134__END_DECLS
135
136#endif /* !_ICONV_H_ */