Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / uts / common / kiconv / kiconv_emea / kiconv_emea.c
blob2d1a0b7ef1e723e66f1b76fb41f573b3aab05b75
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Kernel iconv code conversion module (kiconv_emea) for Europe, Middle East,
30 * and South East Asia (PSARC/2007/173).
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/sysmacros.h>
36 #include <sys/systm.h>
37 #include <sys/debug.h>
38 #include <sys/kmem.h>
39 #include <sys/cmn_err.h>
40 #include <sys/ddi.h>
41 #include <sys/sunddi.h>
42 #include <sys/ksynch.h>
43 #include <sys/modctl.h>
44 #include <sys/byteorder.h>
45 #include <sys/errno.h>
46 #include <sys/kiconv.h>
47 #include <sys/kiconv_emea1.h>
48 #include <sys/kiconv_emea2.h>
52 * The following macros indicate ids to the correct code conversion mapping
53 * data tables to use. The actual tables are coming from <sys/kiconv_emea1.h>
54 * and <sys/kiconv_emea2.h>. If you update the header files, then, you might
55 * also need to update the table ids at below.
57 * The table for KICONV_TBLID_720 is a special case and should come from
58 * a separate header file than others at <sys/kiconv_emea1.h> hence it has
59 * an id that is rather unusual distinguishing itself from others. (And,
60 * the ids much be of uint8_t.)
62 #define KICONV_TBLID_720 (0xFFU)
63 #define KICONV_TBLID_RANGE1_START KICONV_TBLID_720
64 #define KICONV_TBLID_RANGE1_END KICONV_TBLID_720
66 #define KICONV_TBLID_737 (0)
67 #define KICONV_TBLID_852 (1)
68 #define KICONV_TBLID_857 (2)
69 #define KICONV_TBLID_862 (3)
70 #define KICONV_TBLID_866 (4)
71 #define KICONV_TBLID_1250 (5)
72 #define KICONV_TBLID_1251 (6)
73 #define KICONV_TBLID_1253 (7)
74 #define KICONV_TBLID_1254 (8)
75 #define KICONV_TBLID_1255 (9)
76 #define KICONV_TBLID_1256 (10)
77 #define KICONV_TBLID_1257 (11)
78 #define KICONV_TBLID_8859_2 (12)
79 #define KICONV_TBLID_8859_3 (13)
80 #define KICONV_TBLID_8859_4 (14)
81 #define KICONV_TBLID_8859_5 (15)
82 #define KICONV_TBLID_8859_6 (16)
83 #define KICONV_TBLID_8859_7 (17)
84 #define KICONV_TBLID_8859_8 (18)
85 #define KICONV_TBLID_8859_9 (19)
86 #define KICONV_TBLID_8859_10 (20)
87 #define KICONV_TBLID_8859_11 (21)
88 #define KICONV_TBLID_8859_13 (22)
89 #define KICONV_TBLID_KOI8_R (23)
91 #define KICONV_MAX_MAPPING_TBLID KICONV_TBLID_KOI8_R
94 * The following tables are coming from u8_textprep.c. We use them to
95 * check on validity of UTF-8 characters and their bytes.
97 extern const int8_t u8_number_of_bytes[];
98 extern const uint8_t u8_valid_min_2nd_byte[];
99 extern const uint8_t u8_valid_max_2nd_byte[];
103 * The following 25 open_to_xxxx() functions are kiconv_open functions for
104 * the conversions from UTF-8 to xxxx single byte codesets.
106 static void *
107 open_to_720()
109 kiconv_state_t s;
111 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
112 s->id = KICONV_TBLID_720;
113 s->bom_processed = 0;
115 return ((void *)s);
118 static void *
119 open_to_737()
121 kiconv_state_t s;
123 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
124 s->id = KICONV_TBLID_737;
125 s->bom_processed = 0;
127 return ((void *)s);
130 static void *
131 open_to_852()
133 kiconv_state_t s;
135 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
136 s->id = KICONV_TBLID_852;
137 s->bom_processed = 0;
139 return ((void *)s);
142 static void *
143 open_to_857()
145 kiconv_state_t s;
147 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
148 s->id = KICONV_TBLID_857;
149 s->bom_processed = 0;
151 return ((void *)s);
154 static void *
155 open_to_862()
157 kiconv_state_t s;
159 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
160 s->id = KICONV_TBLID_862;
161 s->bom_processed = 0;
163 return ((void *)s);
166 static void *
167 open_to_866()
169 kiconv_state_t s;
171 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
172 s->id = KICONV_TBLID_866;
173 s->bom_processed = 0;
175 return ((void *)s);
178 static void *
179 open_to_1250()
181 kiconv_state_t s;
183 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
184 s->id = KICONV_TBLID_1250;
185 s->bom_processed = 0;
187 return ((void *)s);
190 static void *
191 open_to_1251()
193 kiconv_state_t s;
195 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
196 s->id = KICONV_TBLID_1251;
197 s->bom_processed = 0;
199 return ((void *)s);
202 static void *
203 open_to_1253()
205 kiconv_state_t s;
207 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
208 s->id = KICONV_TBLID_1253;
209 s->bom_processed = 0;
211 return ((void *)s);
214 static void *
215 open_to_1254()
217 kiconv_state_t s;
219 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
220 s->id = KICONV_TBLID_1254;
221 s->bom_processed = 0;
223 return ((void *)s);
226 static void *
227 open_to_1255()
229 kiconv_state_t s;
231 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
232 s->id = KICONV_TBLID_1255;
233 s->bom_processed = 0;
235 return ((void *)s);
238 static void *
239 open_to_1256()
241 kiconv_state_t s;
243 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
244 s->id = KICONV_TBLID_1256;
245 s->bom_processed = 0;
247 return ((void *)s);
250 static void *
251 open_to_1257()
253 kiconv_state_t s;
255 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
256 s->id = KICONV_TBLID_1257;
257 s->bom_processed = 0;
259 return ((void *)s);
262 static void *
263 open_to_88592()
265 kiconv_state_t s;
267 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
268 s->id = KICONV_TBLID_8859_2;
269 s->bom_processed = 0;
271 return ((void *)s);
274 static void *
275 open_to_88593()
277 kiconv_state_t s;
279 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
280 s->id = KICONV_TBLID_8859_3;
281 s->bom_processed = 0;
283 return ((void *)s);
286 static void *
287 open_to_88594()
289 kiconv_state_t s;
291 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
292 s->id = KICONV_TBLID_8859_4;
293 s->bom_processed = 0;
295 return ((void *)s);
298 static void *
299 open_to_88595()
301 kiconv_state_t s;
303 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
304 s->id = KICONV_TBLID_8859_5;
305 s->bom_processed = 0;
307 return ((void *)s);
310 static void *
311 open_to_88596()
313 kiconv_state_t s;
315 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
316 s->id = KICONV_TBLID_8859_6;
317 s->bom_processed = 0;
319 return ((void *)s);
322 static void *
323 open_to_88597()
325 kiconv_state_t s;
327 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
328 s->id = KICONV_TBLID_8859_7;
329 s->bom_processed = 0;
331 return ((void *)s);
334 static void *
335 open_to_88598()
337 kiconv_state_t s;
339 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
340 s->id = KICONV_TBLID_8859_8;
341 s->bom_processed = 0;
343 return ((void *)s);
346 static void *
347 open_to_88599()
349 kiconv_state_t s;
351 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
352 s->id = KICONV_TBLID_8859_9;
353 s->bom_processed = 0;
355 return ((void *)s);
358 static void *
359 open_to_885910()
361 kiconv_state_t s;
363 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
364 s->id = KICONV_TBLID_8859_10;
365 s->bom_processed = 0;
367 return ((void *)s);
370 static void *
371 open_to_885911()
373 kiconv_state_t s;
375 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
376 s->id = KICONV_TBLID_8859_11;
377 s->bom_processed = 0;
379 return ((void *)s);
382 static void *
383 open_to_885913()
385 kiconv_state_t s;
387 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
388 s->id = KICONV_TBLID_8859_13;
389 s->bom_processed = 0;
391 return ((void *)s);
394 static void *
395 open_to_koi8r()
397 kiconv_state_t s;
399 s = (kiconv_state_t)kmem_alloc(sizeof (kiconv_state_data_t), KM_SLEEP);
400 s->id = KICONV_TBLID_KOI8_R;
401 s->bom_processed = 0;
403 return ((void *)s);
407 * The following 25 open_fr_xxxx() functions are kiconv_open functions for
408 * the conversions from xxxx single byte codeset to UTF-8.
410 static void *
411 open_fr_720()
413 return ((void *)KICONV_TBLID_720);
416 static void *
417 open_fr_737()
419 return ((void *)KICONV_TBLID_737);
422 static void *
423 open_fr_852()
425 return ((void *)KICONV_TBLID_852);
428 static void *
429 open_fr_857()
431 return ((void *)KICONV_TBLID_857);
434 static void *
435 open_fr_862()
437 return ((void *)KICONV_TBLID_862);
440 static void *
441 open_fr_866()
443 return ((void *)KICONV_TBLID_866);
446 static void *
447 open_fr_1250()
449 return ((void *)KICONV_TBLID_1250);
452 static void *
453 open_fr_1251()
455 return ((void *)KICONV_TBLID_1251);
458 static void *
459 open_fr_1253()
461 return ((void *)KICONV_TBLID_1253);
464 static void *
465 open_fr_1254()
467 return ((void *)KICONV_TBLID_1254);
470 static void *
471 open_fr_1255()
473 return ((void *)KICONV_TBLID_1255);
476 static void *
477 open_fr_1256()
479 return ((void *)KICONV_TBLID_1256);
482 static void *
483 open_fr_1257()
485 return ((void *)KICONV_TBLID_1257);
488 static void *
489 open_fr_88592()
491 return ((void *)KICONV_TBLID_8859_2);
494 static void *
495 open_fr_88593()
497 return ((void *)KICONV_TBLID_8859_3);
500 static void *
501 open_fr_88594()
503 return ((void *)KICONV_TBLID_8859_4);
506 static void *
507 open_fr_88595()
509 return ((void *)KICONV_TBLID_8859_5);
512 static void *
513 open_fr_88596()
515 return ((void *)KICONV_TBLID_8859_6);
518 static void *
519 open_fr_88597()
521 return ((void *)KICONV_TBLID_8859_7);
524 static void *
525 open_fr_88598()
527 return ((void *)KICONV_TBLID_8859_8);
530 static void *
531 open_fr_88599()
533 return ((void *)KICONV_TBLID_8859_9);
536 static void *
537 open_fr_885910()
539 return ((void *)KICONV_TBLID_8859_10);
542 static void *
543 open_fr_885911()
545 return ((void *)KICONV_TBLID_8859_11);
548 static void *
549 open_fr_885913()
551 return ((void *)KICONV_TBLID_8859_13);
554 static void *
555 open_fr_koi8r()
557 return ((void *)KICONV_TBLID_KOI8_R);
561 * The following is the common kiconv_close function for the conversions from
562 * UTF-8 to single byte codesets.
564 static int
565 close_to_sb(void *s)
567 if (! s || s == (void *)-1)
568 return (EBADF);
570 kmem_free(s, sizeof (kiconv_state_data_t));
572 return (0);
576 * The following is the common kiconv_close function for the conversions from
577 * single byte codesets to UTF-8.
579 static int
580 close_fr_sb(void *s)
582 if ((ulong_t)s > KICONV_MAX_MAPPING_TBLID &&
583 ((ulong_t)s < KICONV_TBLID_RANGE1_START ||
584 (ulong_t)s > KICONV_TBLID_RANGE1_END))
585 return (EBADF);
587 return (0);
591 * The following is the common kiconv function for the conversions from
592 * UTF-8 to single byte codesets. (This may look a lot similar to
593 * kiconvstr_to_sb() but they do have different features to cover and
594 * it's not really worth to try to merge them into a single function since
595 * you'll have to add performance penalty for both per each character
596 * conversion as you will have to figure out if this is kiconv_to_sb() or
597 * kiconvstr_to_sb().)
599 static size_t
600 kiconv_to_sb(void *kcd, char **inbuf, size_t *inbytesleft, char **outbuf,
601 size_t *outbytesleft, int *errno)
603 kiconv_to_sb_tbl_comp_t *tbl;
604 size_t id;
605 size_t ret_val;
606 uchar_t *ib;
607 uchar_t *oldib;
608 uchar_t *ob;
609 uchar_t *ibtail;
610 uchar_t *obtail;
611 uint32_t u8;
612 size_t i;
613 size_t l;
614 size_t h;
615 size_t init_h;
616 int8_t sz;
617 boolean_t second;
619 /* Check on the kiconv code conversion descriptor. */
620 if (! kcd || kcd == (void *)-1) {
621 *errno = EBADF;
622 return ((size_t)-1);
625 /* Get the table id and check on it. */
626 id = ((kiconv_state_t)kcd)->id;
627 if (id > KICONV_MAX_MAPPING_TBLID &&
628 (id < KICONV_TBLID_RANGE1_START || id > KICONV_TBLID_RANGE1_END)) {
629 *errno = EBADF;
630 return ((size_t)-1);
633 /* If this is a state reset request, process and return. */
634 if (! inbuf || ! (*inbuf)) {
635 ((kiconv_state_t)kcd)->bom_processed = 0;
636 return ((size_t)0);
639 ret_val = 0;
640 ib = (uchar_t *)*inbuf;
641 ob = (uchar_t *)*outbuf;
642 ibtail = ib + *inbytesleft;
643 obtail = ob + *outbytesleft;
646 * Get the table we want to use and also calculate the "init_h"
647 * which is the initial high index for the binary search that we will
648 * use. While the table sizes are all the same at the moment, to be
649 * ready for future cases where tables could be in different sizes,
650 * we separately calculate the init_h at here.
652 if (id == KICONV_TBLID_720) {
653 tbl = (kiconv_to_sb_tbl_comp_t *)u8_to_cp720_tbl;
654 init_h = sizeof (u8_to_cp720_tbl);
655 } else {
656 tbl = (kiconv_to_sb_tbl_comp_t *)to_sb_tbl[id];
657 init_h = sizeof (to_sb_tbl[id]);
659 init_h = init_h / sizeof (kiconv_to_sb_tbl_comp_t) - 1;
662 * If we haven't checked on the UTF-8 signature BOM character in
663 * the beginning of the conversion data stream, we check it and if
664 * find one, we skip it since we have no use for it.
666 if (((kiconv_state_t)kcd)->bom_processed == 0 && (ibtail - ib) >= 3 &&
667 *ib == 0xef && *(ib + 1) == 0xbb && *(ib + 2) == 0xbf)
668 ib += 3;
669 ((kiconv_state_t)kcd)->bom_processed = 1;
671 while (ib < ibtail) {
672 sz = u8_number_of_bytes[*ib];
673 if (sz <= 0) {
674 *errno = EILSEQ;
675 ret_val = (size_t)-1;
676 break;
680 * If there is no room to write at the output buffer,
681 * we issue E2BIG and let the caller knows about it.
683 if (ob >= obtail) {
684 *errno = E2BIG;
685 ret_val = (size_t)-1;
686 break;
690 * If it is a 7-bit ASCII character, we don't need to
691 * process further and we just copy the character over.
693 * If not, we collect the character bytes up to four bytes,
694 * validate the bytes, and binary search for the corresponding
695 * single byte codeset character byte. If we find it from
696 * the mapping table, we put that into the output buffer;
697 * otherwise, we put a replacement character instead as
698 * a non-identical conversion.
700 if (sz == 1) {
701 *ob++ = *ib++;
702 continue;
706 * Issue EINVAL if the last character at the input buffer
707 * is an incomplete character missing a byte or more.
709 if ((ibtail - ib) < sz) {
710 *errno = EINVAL;
711 ret_val = (size_t)-1;
712 break;
716 * We collect UTF-8 character bytes and at the same time,
717 * check on if the bytes are valid bytes or not. This follows
718 * the latest UTF-8 byte representation.
720 oldib = ib;
721 u8 = *ib++;
722 second = B_TRUE;
723 for (i = 1; i < sz; i++) {
724 if (second) {
725 if (*ib < u8_valid_min_2nd_byte[u8] ||
726 *ib > u8_valid_max_2nd_byte[u8]) {
727 *errno = EILSEQ;
728 ret_val = (size_t)-1;
729 ib = oldib;
730 goto TO_SB_ILLEGAL_CHAR_ERR;
732 second = B_FALSE;
733 } else if (*ib < 0x80 || *ib > 0xbf) {
734 *errno = EILSEQ;
735 ret_val = (size_t)-1;
736 ib = oldib;
737 goto TO_SB_ILLEGAL_CHAR_ERR;
739 u8 = (u8 << 8) | ((uint32_t)*ib);
740 ib++;
743 i = l = 0;
744 h = init_h;
745 while (l <= h) {
746 i = (l + h) / 2;
747 if (tbl[i].u8 == u8)
748 break;
749 else if (tbl[i].u8 < u8)
750 l = i + 1;
751 else
752 h = i - 1;
755 if (tbl[i].u8 == u8) {
756 *ob++ = tbl[i].sb;
757 } else {
759 * What this means is that we encountered
760 * a non-identical conversion. In other words,
761 * input buffer contains a valid character in
762 * the fromcode but the tocode doesn't have
763 * any character that can be mapped to.
765 * In this case, we insert an ASCII replacement
766 * character instead at the output buffer and
767 * count such non-identical conversions by
768 * increasing the ret_val.
770 * If the return value of the function is bigger
771 * than zero, that means we had such non-identical
772 * conversion(s).
774 *ob++ = KICONV_ASCII_REPLACEMENT_CHAR;
775 ret_val++;
779 TO_SB_ILLEGAL_CHAR_ERR:
780 *inbuf = (char *)ib;
781 *inbytesleft = ibtail - ib;
782 *outbuf = (char *)ob;
783 *outbytesleft = obtail - ob;
785 return (ret_val);
789 * The following is the common kiconv function for the conversions from
790 * single byte codesets to UTf-8.
792 static size_t
793 kiconv_fr_sb(void *kcd, char **inbuf, size_t *inbytesleft, char **outbuf,
794 size_t *outbytesleft, int *errno)
796 kiconv_to_utf8_tbl_comp_t *tbl;
797 size_t ret_val;
798 uchar_t *ib;
799 uchar_t *ob;
800 uchar_t *ibtail;
801 uchar_t *obtail;
802 size_t i;
803 size_t k;
804 int8_t sz;
806 /* Validate the kiconv code conversion descriptor. */
807 if ((ulong_t)kcd > KICONV_MAX_MAPPING_TBLID &&
808 ((ulong_t)kcd < KICONV_TBLID_RANGE1_START ||
809 (ulong_t)kcd > KICONV_TBLID_RANGE1_END)) {
810 *errno = EBADF;
811 return ((size_t)-1);
815 * If this is a state reset request, there is nothing to do and so
816 * we just return.
818 if (! inbuf || ! (*inbuf))
819 return ((size_t)0);
821 ret_val = 0;
822 ib = (uchar_t *)*inbuf;
823 ob = (uchar_t *)*outbuf;
824 ibtail = ib + *inbytesleft;
825 obtail = ob + *outbytesleft;
827 tbl = ((ulong_t)kcd == KICONV_TBLID_720) ?
828 (kiconv_to_utf8_tbl_comp_t *)cp720_to_u8_tbl :
829 (kiconv_to_utf8_tbl_comp_t *)to_u8_tbl[(ulong_t)kcd];
831 while (ib < ibtail) {
833 * If this is a 7-bit ASCII character, we just copy over and
834 * that's all we need to do for this character.
836 if (*ib < 0x80) {
837 if (ob >= obtail) {
838 *errno = E2BIG;
839 ret_val = (size_t)-1;
840 break;
843 *ob++ = *ib++;
844 continue;
848 * Otherwise, we get the corresponding UTF-8 character bytes
849 * from the mapping table and copy them over.
851 * We don't need to worry about if the UTF-8 character bytes
852 * at the mapping tables are valid or not since they are good.
854 k = *ib - 0x80;
855 sz = u8_number_of_bytes[tbl[k].u8[0]];
858 * If (sz <= 0), that means the character in the input buffer
859 * is an illegal character possibly unassigned or non-character
860 * at the fromcode single byte codeset.
862 if (sz <= 0) {
863 *errno = EILSEQ;
864 ret_val = (size_t)-1;
865 break;
868 if ((obtail - ob) < sz) {
869 *errno = E2BIG;
870 ret_val = (size_t)-1;
871 break;
874 for (i = 0; i < sz; i++)
875 *ob++ = tbl[k].u8[i];
877 ib++;
880 *inbuf = (char *)ib;
881 *inbytesleft = ibtail - ib;
882 *outbuf = (char *)ob;
883 *outbytesleft = obtail - ob;
885 return (ret_val);
889 * The following is the common kiconvstr function for the conversions from
890 * UTF-8 to single byte codeset.
892 static size_t
893 kiconvstr_to_sb(size_t id, uchar_t *ib, size_t *inlen, uchar_t *ob,
894 size_t *outlen, int flag, int *errno)
896 kiconv_to_sb_tbl_comp_t *tbl;
897 size_t ret_val;
898 uchar_t *oldib;
899 uchar_t *ibtail;
900 uchar_t *obtail;
901 uint32_t u8;
902 size_t i;
903 size_t l;
904 size_t h;
905 size_t init_h;
906 int8_t sz;
907 boolean_t second;
908 boolean_t do_not_ignore_null;
910 /* Let's double check on the table id. */
911 if (id > KICONV_MAX_MAPPING_TBLID &&
912 (id < KICONV_TBLID_RANGE1_START || id > KICONV_TBLID_RANGE1_END)) {
913 *errno = EBADF;
914 return ((size_t)-1);
917 ret_val = 0;
918 ibtail = ib + *inlen;
919 obtail = ob + *outlen;
920 do_not_ignore_null = ((flag & KICONV_IGNORE_NULL) == 0);
922 if (id == KICONV_TBLID_720) {
923 tbl = (kiconv_to_sb_tbl_comp_t *)u8_to_cp720_tbl;
924 init_h = sizeof (u8_to_cp720_tbl);
925 } else {
926 tbl = (kiconv_to_sb_tbl_comp_t *)to_sb_tbl[id];
927 init_h = sizeof (to_sb_tbl[id]);
929 init_h = init_h / sizeof (kiconv_to_sb_tbl_comp_t) - 1;
931 /* Skip any UTF-8 signature BOM character in the beginning. */
932 if ((ibtail - ib) >= 3 && *ib == 0xef && *(ib + 1) == 0xbb &&
933 *(ib + 2) == 0xbf)
934 ib += 3;
937 * Basically this is pretty much the same as kiconv_to_sb() except
938 * that we are now accepting two flag values and doing the processing
939 * accordingly.
941 while (ib < ibtail) {
942 sz = u8_number_of_bytes[*ib];
943 if (sz <= 0) {
944 if (flag & KICONV_REPLACE_INVALID) {
945 if (ob >= obtail) {
946 *errno = E2BIG;
947 ret_val = (size_t)-1;
948 break;
951 ib++;
952 goto STR_TO_SB_REPLACE_INVALID;
955 *errno = EILSEQ;
956 ret_val = (size_t)-1;
957 break;
960 if (*ib == '\0' && do_not_ignore_null)
961 break;
963 if (ob >= obtail) {
964 *errno = E2BIG;
965 ret_val = (size_t)-1;
966 break;
969 if (sz == 1) {
970 *ob++ = *ib++;
971 continue;
974 if ((ibtail - ib) < sz) {
975 if (flag & KICONV_REPLACE_INVALID) {
976 ib = ibtail;
977 goto STR_TO_SB_REPLACE_INVALID;
980 *errno = EINVAL;
981 ret_val = (size_t)-1;
982 break;
985 oldib = ib;
986 u8 = *ib++;
987 second = B_TRUE;
988 for (i = 1; i < sz; i++) {
989 if (second) {
990 if (*ib < u8_valid_min_2nd_byte[u8] ||
991 *ib > u8_valid_max_2nd_byte[u8]) {
992 if (flag & KICONV_REPLACE_INVALID) {
993 ib = oldib + sz;
994 goto STR_TO_SB_REPLACE_INVALID;
997 *errno = EILSEQ;
998 ret_val = (size_t)-1;
999 ib = oldib;
1000 goto STR_TO_SB_ILLEGAL_CHAR_ERR;
1002 second = B_FALSE;
1003 } else if (*ib < 0x80 || *ib > 0xbf) {
1004 if (flag & KICONV_REPLACE_INVALID) {
1005 ib = oldib + sz;
1006 goto STR_TO_SB_REPLACE_INVALID;
1009 *errno = EILSEQ;
1010 ret_val = (size_t)-1;
1011 ib = oldib;
1012 goto STR_TO_SB_ILLEGAL_CHAR_ERR;
1014 u8 = (u8 << 8) | ((uint32_t)*ib);
1015 ib++;
1018 i = l = 0;
1019 h = init_h;
1020 while (l <= h) {
1021 i = (l + h) / 2;
1022 if (tbl[i].u8 == u8)
1023 break;
1024 else if (tbl[i].u8 < u8)
1025 l = i + 1;
1026 else
1027 h = i - 1;
1030 if (tbl[i].u8 == u8) {
1031 *ob++ = tbl[i].sb;
1032 } else {
1033 STR_TO_SB_REPLACE_INVALID:
1034 *ob++ = KICONV_ASCII_REPLACEMENT_CHAR;
1035 ret_val++;
1039 STR_TO_SB_ILLEGAL_CHAR_ERR:
1040 *inlen = ibtail - ib;
1041 *outlen = obtail - ob;
1043 return (ret_val);
1047 * The following 25 functions are the real entry points that will be
1048 * given to the kiconv framework at the genunix.
1050 static size_t
1051 kiconvstr_to_720(char *inarray, size_t *inlen, char *outarray,
1052 size_t *outlen, int flag, int *errno)
1054 return (kiconvstr_to_sb(KICONV_TBLID_720, (uchar_t *)inarray,
1055 inlen, (uchar_t *)outarray, outlen, flag, errno));
1058 static size_t
1059 kiconvstr_to_737(char *inarray, size_t *inlen, char *outarray,
1060 size_t *outlen, int flag, int *errno)
1062 return (kiconvstr_to_sb(KICONV_TBLID_737, (uchar_t *)inarray,
1063 inlen, (uchar_t *)outarray, outlen, flag, errno));
1066 static size_t
1067 kiconvstr_to_852(char *inarray, size_t *inlen, char *outarray,
1068 size_t *outlen, int flag, int *errno)
1070 return (kiconvstr_to_sb(KICONV_TBLID_852, (uchar_t *)inarray,
1071 inlen, (uchar_t *)outarray, outlen, flag, errno));
1074 static size_t
1075 kiconvstr_to_857(char *inarray, size_t *inlen, char *outarray,
1076 size_t *outlen, int flag, int *errno)
1078 return (kiconvstr_to_sb(KICONV_TBLID_857, (uchar_t *)inarray,
1079 inlen, (uchar_t *)outarray, outlen, flag, errno));
1082 static size_t
1083 kiconvstr_to_862(char *inarray, size_t *inlen, char *outarray,
1084 size_t *outlen, int flag, int *errno)
1086 return (kiconvstr_to_sb(KICONV_TBLID_862, (uchar_t *)inarray,
1087 inlen, (uchar_t *)outarray, outlen, flag, errno));
1090 static size_t
1091 kiconvstr_to_866(char *inarray, size_t *inlen, char *outarray,
1092 size_t *outlen, int flag, int *errno)
1094 return (kiconvstr_to_sb(KICONV_TBLID_866, (uchar_t *)inarray,
1095 inlen, (uchar_t *)outarray, outlen, flag, errno));
1098 static size_t
1099 kiconvstr_to_1250(char *inarray, size_t *inlen, char *outarray,
1100 size_t *outlen, int flag, int *errno)
1102 return (kiconvstr_to_sb(KICONV_TBLID_1250, (uchar_t *)inarray,
1103 inlen, (uchar_t *)outarray, outlen, flag, errno));
1106 static size_t
1107 kiconvstr_to_1251(char *inarray, size_t *inlen, char *outarray,
1108 size_t *outlen, int flag, int *errno)
1110 return (kiconvstr_to_sb(KICONV_TBLID_1251, (uchar_t *)inarray,
1111 inlen, (uchar_t *)outarray, outlen, flag, errno));
1114 static size_t
1115 kiconvstr_to_1253(char *inarray, size_t *inlen, char *outarray,
1116 size_t *outlen, int flag, int *errno)
1118 return (kiconvstr_to_sb(KICONV_TBLID_1253, (uchar_t *)inarray,
1119 inlen, (uchar_t *)outarray, outlen, flag, errno));
1122 static size_t
1123 kiconvstr_to_1254(char *inarray, size_t *inlen, char *outarray,
1124 size_t *outlen, int flag, int *errno)
1126 return (kiconvstr_to_sb(KICONV_TBLID_1254, (uchar_t *)inarray,
1127 inlen, (uchar_t *)outarray, outlen, flag, errno));
1130 static size_t
1131 kiconvstr_to_1255(char *inarray, size_t *inlen, char *outarray,
1132 size_t *outlen, int flag, int *errno)
1134 return (kiconvstr_to_sb(KICONV_TBLID_1255, (uchar_t *)inarray,
1135 inlen, (uchar_t *)outarray, outlen, flag, errno));
1138 static size_t
1139 kiconvstr_to_1256(char *inarray, size_t *inlen, char *outarray,
1140 size_t *outlen, int flag, int *errno)
1142 return (kiconvstr_to_sb(KICONV_TBLID_1256, (uchar_t *)inarray,
1143 inlen, (uchar_t *)outarray, outlen, flag, errno));
1146 static size_t
1147 kiconvstr_to_1257(char *inarray, size_t *inlen, char *outarray,
1148 size_t *outlen, int flag, int *errno)
1150 return (kiconvstr_to_sb(KICONV_TBLID_1257, (uchar_t *)inarray,
1151 inlen, (uchar_t *)outarray, outlen, flag, errno));
1154 static size_t
1155 kiconvstr_to_88592(char *inarray, size_t *inlen, char *outarray,
1156 size_t *outlen, int flag, int *errno)
1158 return (kiconvstr_to_sb(KICONV_TBLID_8859_2, (uchar_t *)inarray,
1159 inlen, (uchar_t *)outarray, outlen, flag, errno));
1162 static size_t
1163 kiconvstr_to_88593(char *inarray, size_t *inlen, char *outarray,
1164 size_t *outlen, int flag, int *errno)
1166 return (kiconvstr_to_sb(KICONV_TBLID_8859_3, (uchar_t *)inarray,
1167 inlen, (uchar_t *)outarray, outlen, flag, errno));
1170 static size_t
1171 kiconvstr_to_88594(char *inarray, size_t *inlen, char *outarray,
1172 size_t *outlen, int flag, int *errno)
1174 return (kiconvstr_to_sb(KICONV_TBLID_8859_4, (uchar_t *)inarray,
1175 inlen, (uchar_t *)outarray, outlen, flag, errno));
1178 static size_t
1179 kiconvstr_to_88595(char *inarray, size_t *inlen, char *outarray,
1180 size_t *outlen, int flag, int *errno)
1182 return (kiconvstr_to_sb(KICONV_TBLID_8859_5, (uchar_t *)inarray,
1183 inlen, (uchar_t *)outarray, outlen, flag, errno));
1186 static size_t
1187 kiconvstr_to_88596(char *inarray, size_t *inlen, char *outarray,
1188 size_t *outlen, int flag, int *errno)
1190 return (kiconvstr_to_sb(KICONV_TBLID_8859_6, (uchar_t *)inarray,
1191 inlen, (uchar_t *)outarray, outlen, flag, errno));
1194 static size_t
1195 kiconvstr_to_88597(char *inarray, size_t *inlen, char *outarray,
1196 size_t *outlen, int flag, int *errno)
1198 return (kiconvstr_to_sb(KICONV_TBLID_8859_7, (uchar_t *)inarray,
1199 inlen, (uchar_t *)outarray, outlen, flag, errno));
1202 static size_t
1203 kiconvstr_to_88598(char *inarray, size_t *inlen, char *outarray,
1204 size_t *outlen, int flag, int *errno)
1206 return (kiconvstr_to_sb(KICONV_TBLID_8859_8, (uchar_t *)inarray,
1207 inlen, (uchar_t *)outarray, outlen, flag, errno));
1210 static size_t
1211 kiconvstr_to_88599(char *inarray, size_t *inlen, char *outarray,
1212 size_t *outlen, int flag, int *errno)
1214 return (kiconvstr_to_sb(KICONV_TBLID_8859_9, (uchar_t *)inarray,
1215 inlen, (uchar_t *)outarray, outlen, flag, errno));
1218 static size_t
1219 kiconvstr_to_885910(char *inarray, size_t *inlen, char *outarray,
1220 size_t *outlen, int flag, int *errno)
1222 return (kiconvstr_to_sb(KICONV_TBLID_8859_10, (uchar_t *)inarray,
1223 inlen, (uchar_t *)outarray, outlen, flag, errno));
1226 static size_t
1227 kiconvstr_to_885911(char *inarray, size_t *inlen, char *outarray,
1228 size_t *outlen, int flag, int *errno)
1230 return (kiconvstr_to_sb(KICONV_TBLID_8859_11, (uchar_t *)inarray,
1231 inlen, (uchar_t *)outarray, outlen, flag, errno));
1234 static size_t
1235 kiconvstr_to_885913(char *inarray, size_t *inlen, char *outarray,
1236 size_t *outlen, int flag, int *errno)
1238 return (kiconvstr_to_sb(KICONV_TBLID_8859_13, (uchar_t *)inarray,
1239 inlen, (uchar_t *)outarray, outlen, flag, errno));
1242 static size_t
1243 kiconvstr_to_koi8r(char *inarray, size_t *inlen, char *outarray,
1244 size_t *outlen, int flag, int *errno)
1246 return (kiconvstr_to_sb(KICONV_TBLID_KOI8_R, (uchar_t *)inarray,
1247 inlen, (uchar_t *)outarray, outlen, flag, errno));
1251 * The following is the common kiconvstr function for the conversions from
1252 * single byte codeset to UTF-8.
1254 static size_t
1255 kiconvstr_fr_sb(size_t id, uchar_t *ib, size_t *inlen, uchar_t *ob,
1256 size_t *outlen, int flag, int *errno)
1258 kiconv_to_utf8_tbl_comp_t *tbl;
1259 size_t ret_val;
1260 uchar_t *ibtail;
1261 uchar_t *obtail;
1262 size_t i;
1263 size_t k;
1264 int8_t sz;
1265 boolean_t do_not_ignore_null;
1267 if (id > KICONV_MAX_MAPPING_TBLID &&
1268 (id < KICONV_TBLID_RANGE1_START || id > KICONV_TBLID_RANGE1_END)) {
1269 *errno = EBADF;
1270 return ((size_t)-1);
1273 ret_val = 0;
1274 ibtail = ib + *inlen;
1275 obtail = ob + *outlen;
1276 do_not_ignore_null = ((flag & KICONV_IGNORE_NULL) == 0);
1278 tbl = (id == KICONV_TBLID_720) ?
1279 (kiconv_to_utf8_tbl_comp_t *)cp720_to_u8_tbl :
1280 (kiconv_to_utf8_tbl_comp_t *)to_u8_tbl[id];
1282 while (ib < ibtail) {
1283 if (*ib == '\0' && do_not_ignore_null)
1284 break;
1286 if (*ib < 0x80) {
1287 if (ob >= obtail) {
1288 *errno = E2BIG;
1289 ret_val = (size_t)-1;
1290 break;
1292 *ob++ = *ib++;
1293 continue;
1296 k = *ib - 0x80;
1297 sz = u8_number_of_bytes[tbl[k].u8[0]];
1299 if (sz <= 0) {
1300 if (flag & KICONV_REPLACE_INVALID) {
1301 if ((obtail - ob) < 3) {
1302 *errno = E2BIG;
1303 ret_val = (size_t)-1;
1304 break;
1307 /* Save KICONV_UTF8_REPLACEMENT_CHAR. */
1308 *ob++ = 0xef;
1309 *ob++ = 0xbf;
1310 *ob++ = 0xbd;
1311 ret_val++;
1312 ib++;
1314 continue;
1317 *errno = EILSEQ;
1318 ret_val = (size_t)-1;
1319 break;
1322 if ((obtail - ob) < sz) {
1323 *errno = E2BIG;
1324 ret_val = (size_t)-1;
1325 break;
1328 for (i = 0; i < sz; i++)
1329 *ob++ = tbl[k].u8[i];
1331 ib++;
1334 *inlen = ibtail - ib;
1335 *outlen = obtail - ob;
1337 return (ret_val);
1341 * The following 25 functions are the real entry points that will be
1342 * given to kiconv framework at the genunix.
1344 static size_t
1345 kiconvstr_fr_720(char *inarray, size_t *inlen, char *outarray,
1346 size_t *outlen, int flag, int *errno)
1348 return (kiconvstr_fr_sb(KICONV_TBLID_720, (uchar_t *)inarray,
1349 inlen, (uchar_t *)outarray, outlen, flag, errno));
1352 static size_t
1353 kiconvstr_fr_737(char *inarray, size_t *inlen, char *outarray,
1354 size_t *outlen, int flag, int *errno)
1356 return (kiconvstr_fr_sb(KICONV_TBLID_737, (uchar_t *)inarray,
1357 inlen, (uchar_t *)outarray, outlen, flag, errno));
1360 static size_t
1361 kiconvstr_fr_852(char *inarray, size_t *inlen, char *outarray,
1362 size_t *outlen, int flag, int *errno)
1364 return (kiconvstr_fr_sb(KICONV_TBLID_852, (uchar_t *)inarray,
1365 inlen, (uchar_t *)outarray, outlen, flag, errno));
1368 static size_t
1369 kiconvstr_fr_857(char *inarray, size_t *inlen, char *outarray,
1370 size_t *outlen, int flag, int *errno)
1372 return (kiconvstr_fr_sb(KICONV_TBLID_857, (uchar_t *)inarray,
1373 inlen, (uchar_t *)outarray, outlen, flag, errno));
1376 static size_t
1377 kiconvstr_fr_862(char *inarray, size_t *inlen, char *outarray,
1378 size_t *outlen, int flag, int *errno)
1380 return (kiconvstr_fr_sb(KICONV_TBLID_862, (uchar_t *)inarray,
1381 inlen, (uchar_t *)outarray, outlen, flag, errno));
1384 static size_t
1385 kiconvstr_fr_866(char *inarray, size_t *inlen, char *outarray,
1386 size_t *outlen, int flag, int *errno)
1388 return (kiconvstr_fr_sb(KICONV_TBLID_866, (uchar_t *)inarray,
1389 inlen, (uchar_t *)outarray, outlen, flag, errno));
1392 static size_t
1393 kiconvstr_fr_1250(char *inarray, size_t *inlen, char *outarray,
1394 size_t *outlen, int flag, int *errno)
1396 return (kiconvstr_fr_sb(KICONV_TBLID_1250, (uchar_t *)inarray,
1397 inlen, (uchar_t *)outarray, outlen, flag, errno));
1400 static size_t
1401 kiconvstr_fr_1251(char *inarray, size_t *inlen, char *outarray,
1402 size_t *outlen, int flag, int *errno)
1404 return (kiconvstr_fr_sb(KICONV_TBLID_1251, (uchar_t *)inarray,
1405 inlen, (uchar_t *)outarray, outlen, flag, errno));
1408 static size_t
1409 kiconvstr_fr_1253(char *inarray, size_t *inlen, char *outarray,
1410 size_t *outlen, int flag, int *errno)
1412 return (kiconvstr_fr_sb(KICONV_TBLID_1253, (uchar_t *)inarray,
1413 inlen, (uchar_t *)outarray, outlen, flag, errno));
1416 static size_t
1417 kiconvstr_fr_1254(char *inarray, size_t *inlen, char *outarray,
1418 size_t *outlen, int flag, int *errno)
1420 return (kiconvstr_fr_sb(KICONV_TBLID_1254, (uchar_t *)inarray,
1421 inlen, (uchar_t *)outarray, outlen, flag, errno));
1424 static size_t
1425 kiconvstr_fr_1255(char *inarray, size_t *inlen, char *outarray,
1426 size_t *outlen, int flag, int *errno)
1428 return (kiconvstr_fr_sb(KICONV_TBLID_1255, (uchar_t *)inarray,
1429 inlen, (uchar_t *)outarray, outlen, flag, errno));
1432 static size_t
1433 kiconvstr_fr_1256(char *inarray, size_t *inlen, char *outarray,
1434 size_t *outlen, int flag, int *errno)
1436 return (kiconvstr_fr_sb(KICONV_TBLID_1256, (uchar_t *)inarray,
1437 inlen, (uchar_t *)outarray, outlen, flag, errno));
1440 static size_t
1441 kiconvstr_fr_1257(char *inarray, size_t *inlen, char *outarray,
1442 size_t *outlen, int flag, int *errno)
1444 return (kiconvstr_fr_sb(KICONV_TBLID_1257, (uchar_t *)inarray,
1445 inlen, (uchar_t *)outarray, outlen, flag, errno));
1448 static size_t
1449 kiconvstr_fr_88592(char *inarray, size_t *inlen, char *outarray,
1450 size_t *outlen, int flag, int *errno)
1452 return (kiconvstr_fr_sb(KICONV_TBLID_8859_2, (uchar_t *)inarray,
1453 inlen, (uchar_t *)outarray, outlen, flag, errno));
1456 static size_t
1457 kiconvstr_fr_88593(char *inarray, size_t *inlen, char *outarray,
1458 size_t *outlen, int flag, int *errno)
1460 return (kiconvstr_fr_sb(KICONV_TBLID_8859_3, (uchar_t *)inarray,
1461 inlen, (uchar_t *)outarray, outlen, flag, errno));
1464 static size_t
1465 kiconvstr_fr_88594(char *inarray, size_t *inlen, char *outarray,
1466 size_t *outlen, int flag, int *errno)
1468 return (kiconvstr_fr_sb(KICONV_TBLID_8859_4, (uchar_t *)inarray,
1469 inlen, (uchar_t *)outarray, outlen, flag, errno));
1472 static size_t
1473 kiconvstr_fr_88595(char *inarray, size_t *inlen, char *outarray,
1474 size_t *outlen, int flag, int *errno)
1476 return (kiconvstr_fr_sb(KICONV_TBLID_8859_5, (uchar_t *)inarray,
1477 inlen, (uchar_t *)outarray, outlen, flag, errno));
1480 static size_t
1481 kiconvstr_fr_88596(char *inarray, size_t *inlen, char *outarray,
1482 size_t *outlen, int flag, int *errno)
1484 return (kiconvstr_fr_sb(KICONV_TBLID_8859_6, (uchar_t *)inarray,
1485 inlen, (uchar_t *)outarray, outlen, flag, errno));
1488 static size_t
1489 kiconvstr_fr_88597(char *inarray, size_t *inlen, char *outarray,
1490 size_t *outlen, int flag, int *errno)
1492 return (kiconvstr_fr_sb(KICONV_TBLID_8859_7, (uchar_t *)inarray,
1493 inlen, (uchar_t *)outarray, outlen, flag, errno));
1496 static size_t
1497 kiconvstr_fr_88598(char *inarray, size_t *inlen, char *outarray,
1498 size_t *outlen, int flag, int *errno)
1500 return (kiconvstr_fr_sb(KICONV_TBLID_8859_8, (uchar_t *)inarray,
1501 inlen, (uchar_t *)outarray, outlen, flag, errno));
1504 static size_t
1505 kiconvstr_fr_88599(char *inarray, size_t *inlen, char *outarray,
1506 size_t *outlen, int flag, int *errno)
1508 return (kiconvstr_fr_sb(KICONV_TBLID_8859_9, (uchar_t *)inarray,
1509 inlen, (uchar_t *)outarray, outlen, flag, errno));
1512 static size_t
1513 kiconvstr_fr_885910(char *inarray, size_t *inlen, char *outarray,
1514 size_t *outlen, int flag, int *errno)
1516 return (kiconvstr_fr_sb(KICONV_TBLID_8859_10, (uchar_t *)inarray,
1517 inlen, (uchar_t *)outarray, outlen, flag, errno));
1520 static size_t
1521 kiconvstr_fr_885911(char *inarray, size_t *inlen, char *outarray,
1522 size_t *outlen, int flag, int *errno)
1524 return (kiconvstr_fr_sb(KICONV_TBLID_8859_11, (uchar_t *)inarray,
1525 inlen, (uchar_t *)outarray, outlen, flag, errno));
1528 static size_t
1529 kiconvstr_fr_885913(char *inarray, size_t *inlen, char *outarray,
1530 size_t *outlen, int flag, int *errno)
1532 return (kiconvstr_fr_sb(KICONV_TBLID_8859_13, (uchar_t *)inarray,
1533 inlen, (uchar_t *)outarray, outlen, flag, errno));
1536 static size_t
1537 kiconvstr_fr_koi8r(char *inarray, size_t *inlen, char *outarray,
1538 size_t *outlen, int flag, int *errno)
1540 return (kiconvstr_fr_sb(KICONV_TBLID_KOI8_R, (uchar_t *)inarray,
1541 inlen, (uchar_t *)outarray, outlen, flag, errno));
1546 * The following are the supported code conversions that will be passed to
1547 * and registered from this module. The tocode and fromcode names are
1548 * normalized.
1550 #define KICONV_MAX_EMEA_OPS 50
1552 static kiconv_ops_t kiconv_emea_ops[KICONV_MAX_EMEA_OPS] = {
1554 "utf8", "cp1250",
1555 open_fr_1250, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1250
1558 "cp1250", "utf8",
1559 open_to_1250, kiconv_to_sb, close_to_sb, kiconvstr_to_1250
1562 "utf8", "iso88592",
1563 open_fr_88592, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88592
1566 "iso88592", "utf8",
1567 open_to_88592, kiconv_to_sb, close_to_sb, kiconvstr_to_88592
1570 "utf8", "cp852",
1571 open_fr_852, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_852
1574 "cp852", "utf8",
1575 open_to_852, kiconv_to_sb, close_to_sb, kiconvstr_to_852
1578 "utf8", "cp1251",
1579 open_fr_1251, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1251
1582 "cp1251", "utf8",
1583 open_to_1251, kiconv_to_sb, close_to_sb, kiconvstr_to_1251
1586 "utf8", "iso88595",
1587 open_fr_88595, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88595
1590 "iso88595", "utf8",
1591 open_to_88595, kiconv_to_sb, close_to_sb, kiconvstr_to_88595
1594 "utf8", "koi8r",
1595 open_fr_koi8r, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_koi8r
1598 "koi8r", "utf8",
1599 open_to_koi8r, kiconv_to_sb, close_to_sb, kiconvstr_to_koi8r
1602 "utf8", "cp866",
1603 open_fr_866, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_866
1606 "cp866", "utf8",
1607 open_to_866, kiconv_to_sb, close_to_sb, kiconvstr_to_866
1610 "utf8", "cp1253",
1611 open_fr_1253, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1253
1614 "cp1253", "utf8",
1615 open_to_1253, kiconv_to_sb, close_to_sb, kiconvstr_to_1253
1618 "utf8", "iso88597",
1619 open_fr_88597, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88597
1622 "iso88597", "utf8",
1623 open_to_88597, kiconv_to_sb, close_to_sb, kiconvstr_to_88597
1626 "utf8", "cp737",
1627 open_fr_737, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_737
1630 "cp737", "utf8",
1631 open_to_737, kiconv_to_sb, close_to_sb, kiconvstr_to_737
1634 "utf8", "cp1254",
1635 open_fr_1254, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1254
1638 "cp1254", "utf8",
1639 open_to_1254, kiconv_to_sb, close_to_sb, kiconvstr_to_1254
1642 "utf8", "iso88599",
1643 open_fr_88599, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88599
1646 "iso88599", "utf8",
1647 open_to_88599, kiconv_to_sb, close_to_sb, kiconvstr_to_88599
1650 "utf8", "cp857",
1651 open_fr_857, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_857
1654 "cp857", "utf8",
1655 open_to_857, kiconv_to_sb, close_to_sb, kiconvstr_to_857
1658 "utf8", "cp1256",
1659 open_fr_1256, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1256
1662 "cp1256", "utf8",
1663 open_to_1256, kiconv_to_sb, close_to_sb, kiconvstr_to_1256
1666 "utf8", "iso88596",
1667 open_fr_88596, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88596
1670 "iso88596", "utf8",
1671 open_to_88596, kiconv_to_sb, close_to_sb, kiconvstr_to_88596
1674 "utf8", "cp720",
1675 open_fr_720, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_720
1678 "cp720", "utf8",
1679 open_to_720, kiconv_to_sb, close_to_sb, kiconvstr_to_720
1682 "utf8", "cp1255",
1683 open_fr_1255, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1255
1686 "cp1255", "utf8",
1687 open_to_1255, kiconv_to_sb, close_to_sb, kiconvstr_to_1255
1690 "utf8", "iso88598",
1691 open_fr_88598, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88598
1694 "iso88598", "utf8",
1695 open_to_88598, kiconv_to_sb, close_to_sb, kiconvstr_to_88598
1698 "utf8", "cp862",
1699 open_fr_862, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_862
1702 "cp862", "utf8",
1703 open_to_862, kiconv_to_sb, close_to_sb, kiconvstr_to_862
1706 "utf8", "cp1257",
1707 open_fr_1257, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_1257
1710 "cp1257", "utf8",
1711 open_to_1257, kiconv_to_sb, close_to_sb, kiconvstr_to_1257
1714 "utf8", "iso885913",
1715 open_fr_885913, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_885913
1718 "iso885913", "utf8",
1719 open_to_885913, kiconv_to_sb, close_to_sb, kiconvstr_to_885913
1722 "utf8", "iso885910",
1723 open_fr_885910, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_885910
1726 "iso885910", "utf8",
1727 open_to_885910, kiconv_to_sb, close_to_sb, kiconvstr_to_885910
1730 "utf8", "iso885911",
1731 open_fr_885911, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_885911
1734 "iso885911", "utf8",
1735 open_to_885911, kiconv_to_sb, close_to_sb, kiconvstr_to_885911
1738 "utf8", "iso88593",
1739 open_fr_88593, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88593
1742 "iso88593", "utf8",
1743 open_to_88593, kiconv_to_sb, close_to_sb, kiconvstr_to_88593
1746 "utf8", "iso88594",
1747 open_fr_88594, kiconv_fr_sb, close_fr_sb, kiconvstr_fr_88594
1750 "iso88594", "utf8",
1751 open_to_88594, kiconv_to_sb, close_to_sb, kiconvstr_to_88594
1755 static kiconv_module_info_t kiconv_emea_modinfo = {
1756 "kiconv_emea", /* Must be the same as in kiconv framework. */
1757 KICONV_MAX_EMEA_OPS, /* size_t kiconv_num_convs */
1758 kiconv_emea_ops, /* kiconv_ops_t *kiconv_ops_tbl */
1759 0, /* size_t kiconv_num_aliases */
1760 NULL, /* char **aliases */
1761 NULL, /* char **canonicals */
1762 0 /* int nowait */
1765 static struct modlkiconv kiconv_emea = {
1766 &mod_kiconvops,
1767 "kiconv module for EMEA",
1768 &kiconv_emea_modinfo
1771 static struct modlinkage linkage = {
1772 MODREV_1,
1773 (void *)&kiconv_emea,
1774 NULL
1778 _init()
1780 int err;
1782 err = mod_install(&linkage);
1783 if (err)
1784 cmn_err(CE_WARN, "kiconv_emea: failed to load kernel module");
1786 return (err);
1790 _info(struct modinfo *modinfop)
1792 return (mod_info(&linkage, modinfop));
1796 _fini()
1798 int err;
1801 * If this module is being used, then, we cannot remove the module.
1802 * The following checking will catch pretty much all usual cases.
1804 * Any remaining will be catached by the kiconv_unregister_module()
1805 * during mod_remove() at below.
1807 if (kiconv_module_ref_count(KICONV_MODULE_ID_EMEA))
1808 return (EBUSY);
1810 err = mod_remove(&linkage);
1811 if (err)
1812 cmn_err(CE_WARN, "kiconv_emea: failed to remove kernel module");
1814 return (err);