xref: /titanic_52/usr/src/lib/iconv_modules/zh/common/zh_TW-cp937%UTF-8.c (revision 91e1e26ac6a73ce959289cf7d3d96c4baedbe0b8)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
8  * You can obtain a copy of the license at 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.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at 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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1997, by Sun Microsystems, Inc.
23  * All rights reserved.
24  */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <errno.h>
29 #include <sys/types.h>
30 
31 #include "tab_lookup.h"   	/* table lookup data types */
32 #include "cp937_unicode.h"   	/* Cp937 to Unicode mapping table */
33 
34 
35 /*
36  * Open; called from iconv_open()
37  */
38 void *
39 _icv_open()
40 {
41 
42         _icv_state *st;
43 
44         if ((st = (_icv_state *)malloc(sizeof(_icv_state))) == NULL) {
45                 errno = ENOMEM;
46                 return ((void *) -1);
47         }
48 
49         st->left_to_right = B_FALSE;
50         st->right_to_left = B_TRUE;
51         st->left_code_size = 2; /* byte */
52         st->right_code_size = 2; /* byte */
53         st->table = &cp937_ucs2_tab[0];
54         st->table_size =  MAX_UCS_NUM;
55 	st->shift = SHIFT_IN;
56 
57 	st->ustate = 0;
58 	st->_errno = 0;
59         return ((void *)st);
60 }
61 
62 
63 /*
64  * Close; called from iconv_close()
65  */
66 void
67 _icv_close(_icv_state *st)
68 {
69         if (st == NULL)
70                 errno = EBADF;
71         else
72                 free(st);
73 }
74