xref: /freebsd/lib/libc/iconv/iconvctl.3 (revision 135bce2a9e632a7cedae2a42f5b2eef2b77d5e56)
1.\" Copyright (c) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" Portions of this text are reprinted and reproduced in electronic form
26.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
27.\" Portable Operating System Interface (POSIX), The Open Group Base
28.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
29.\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
30.\" event of any discrepancy between this version and the original IEEE and
31.\" The Open Group Standard, the original IEEE and The Open Group Standard is
32.\" the referee document.  The original Standard can be obtained online at
33.\"	http://www.opengroup.org/unix/online.html.
34.\"
35.\" $FreeBSD$
36.\"
37.Dd November 7, 2009
38.Dt ICONVCTL 3
39.Os
40.Sh NAME
41.Nm iconvctl
42.Nd controlling and diagnostical facility for
43.Xr iconv 3
44.Sh LIBRARY
45.Lb libc
46.Sh SYNOPSIS
47.In iconv.h
48.Ft int
49.Fn iconvctl "iconv_t cd" "int request" "void *argument"
50.Sh DESCRIPTION
51The
52.Fn iconvctl
53function can retrieve or set specific conversion
54setting from the
55.Fa cd
56conversion descriptor.
57The
58.Fa request
59parameter specifies the operation to accomplish and
60.Fa argument
61is an operation-specific argument.
62.Pp
63The possible operations are the following:
64.Bl -tag -width -indent
65.It ICONV_TRIVIALP
66In this case
67.Fa argument
68is an
69.Ft int *
70variable, which is set to 1 if the encoding is trivial one, i.e.
71the input and output encodings are the same.
72Otherwise, the variable will be 0.
73.It ICONV_GET_TRANSLITERATE
74Determines if transliteration is enabled.
75The answer is stored in
76.Fa argument ,
77which is of
78.Ft int * .
79It will be set to 1 if this feature is enabled or set to 0 otherwise.
80.It ICONV_SET_TRANSLITERATE
81Enables transliteration if
82.Fa argument ,
83which is of
84.Ft int *
85set to 1 or disables it if
86.Fa argument
87is set to 0.
88.It ICONV_GET_DISCARD_ILSEQ
89Determines if illegal sequences are discarded or not.
90The answer is stored in
91.Fa argument ,
92which is of
93.Ft int * .
94It will be set to 1 if this feature is enabled or set to 0 otherwise.
95.It ICONV_SET_DISCARD_ILSEQ
96Sets whether illegal sequences are discarded or not.
97.Fa argument ,
98which is of
99.Ft int *
100set to 1 or disables it if
101.Fa argument
102is set to 0.
103.It ICONV_SET_HOOKS
104Sets callback functions, which will be called back after successful
105conversions.
106The callback functions are stored in a
107.Ft struct iconv_hooks
108variable, which is passed to
109.Nm
110via
111.Fa argument
112by its address.
113.\" XXX: fallbacks are unimplemented and trying to set them will always
114.\"      return EOPNOTSUPP but definitions are provided for source-level
115.\"      compatibility.
116.\".It ICONV_SET_FALLBACKS
117.\"Sets callback functions, which will be called back after failed
118.\"conversions.
119.\"The callback functions are stored in a
120.\".Ft struct iconv_fallbacks
121.\"variable, which is passed to
122.\".Nm
123.\"via
124.\".Fa argument
125.\"by its address.
126.Sh RETURN VALUES
127Upon successful completion
128.Fn iconvctl ,
129returns 0.
130Otherwise, \-1 is returned and errno is set to
131specify the kind of error.
132.Sh ERRORS
133The
134.Fn iconvctl
135function may cause an error in the following cases:
136.Bl -tag -width Er
137.It Bq Er EINVAL
138Unknown or unimplemented operation.
139.It Bq Er EBADF
140The conversion descriptor specified by
141.Fa cd
142is invalid.
143.Sh SEE ALSO
144.Xr iconv 1 ,
145.Xr iconv 3
146.Sh STANDARDS
147The
148.Nm
149facility is a non-standard extension, which appeared in
150the GNU implementation and was adopted in
151.Fx 9
152for compatibility's sake.
153.Sh AUTHORS
154This manual page was written by
155.An Gabor Kovesdan Aq gabor@FreeBSD.org .
156.Sh BUGS
157Transliteration is enabled in this implementation by default, so it
158is impossible by design to turn it off.
159Accordingly, trying to turn it off will always fail and \-1 will be
160returned.
161Getting the transliteration state will always succeed and indicate
162that it is turned on, though.
163