xref: /titanic_52/usr/src/lib/iconv_modules/zh/common/UTF-8%zh_CN-cp935.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) 1998 Sun Microsystems, Inc.
23  * All rights reserved.
24  */
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <errno.h>
28 #include <sys/types.h>
29 
30 #include "tab_lookup.h"   	/* table lookup data types */
31 #include <unicode_cp935.h>   	/* Unicode to CP935 mapping table */
32 
33 
34 /*
35  * Open; called from iconv_open()
36  */
37 void *
38 _icv_open()
39 {
40 
41         _icv_state *st;
42 
43         if ((st = (_icv_state *)malloc(sizeof(_icv_state))) == NULL) {
44                 errno = ENOMEM;
45                 return ((void *) -1);
46         }
47 
48         st->left_to_right = B_TRUE;
49         st->right_to_left = B_FALSE;
50         st->left_code_size = 2; /* byte */
51         st->right_code_size = 2; /* byte */
52         st->table = &ucs2_cp935_tab[0];
53         st->table_size =  MAX_UCS_NUM;
54 	st->shift = SHIFT_IN;
55 
56 	st->ustate = 0;
57 	st->_errno = 0;
58         return ((void *)st);
59 }
60 
61 
62 /*
63  * Close; called from iconv_close()
64  */
65 void
66 _icv_close(_icv_state *st)
67 {
68         if (st == NULL)
69                 errno = EBADF;
70         else
71                 free(st);
72 }
73