xref: /titanic_50/usr/src/lib/libast/amd64/include/ast/ccode.h (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
1da2e3ebdSchin 
2da2e3ebdSchin /* : : generated by proto : : */
3da2e3ebdSchin /***********************************************************************
4da2e3ebdSchin *                                                                      *
5da2e3ebdSchin *               This software is part of the ast package               *
6*3e14f97fSRoger A. Faulkner *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
7da2e3ebdSchin *                      and is licensed under the                       *
8da2e3ebdSchin *                  Common Public License, Version 1.0                  *
97c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
10da2e3ebdSchin *                                                                      *
11da2e3ebdSchin *                A copy of the License is available at                 *
12da2e3ebdSchin *            http://www.opensource.org/licenses/cpl1.0.txt             *
13da2e3ebdSchin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
14da2e3ebdSchin *                                                                      *
15da2e3ebdSchin *              Information and Software Systems Research               *
16da2e3ebdSchin *                            AT&T Research                             *
17da2e3ebdSchin *                           Florham Park NJ                            *
18da2e3ebdSchin *                                                                      *
19da2e3ebdSchin *                 Glenn Fowler <gsf@research.att.com>                  *
20da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
21da2e3ebdSchin *                   Phong Vo <kpv@research.att.com>                    *
22da2e3ebdSchin *                                                                      *
23da2e3ebdSchin ***********************************************************************/
24da2e3ebdSchin 
25da2e3ebdSchin 
26da2e3ebdSchin /*
27da2e3ebdSchin  * Glenn Fowler
28da2e3ebdSchin  * AT&T Research
29da2e3ebdSchin  *
30da2e3ebdSchin  * character code map interface
31da2e3ebdSchin  *
32da2e3ebdSchin  * NOTE: used for mapping between 8-bit character encodings
33da2e3ebdSchin  *	 ISO character sets are handled by sfio
34da2e3ebdSchin  */
35da2e3ebdSchin 
36da2e3ebdSchin #ifndef _CHARCODE_H
37da2e3ebdSchin #if !defined(__PROTO__)
38da2e3ebdSchin #include <prototyped.h>
39da2e3ebdSchin #endif
40da2e3ebdSchin #if !defined(__LINKAGE__)
41da2e3ebdSchin #define __LINKAGE__		/* 2004-08-11 transition */
42da2e3ebdSchin #endif
43da2e3ebdSchin 
44da2e3ebdSchin #define _CHARCODE_H	1
45da2e3ebdSchin 
46*3e14f97fSRoger A. Faulkner #include <ast_common.h>
47da2e3ebdSchin #include <ast_ccode.h>
48da2e3ebdSchin 
49da2e3ebdSchin typedef struct Ccmap_s
50da2e3ebdSchin {
51da2e3ebdSchin 	const char*	name;	/* code set name		*/
52da2e3ebdSchin 	const char*	match;	/* strmatch() pattern		*/
53da2e3ebdSchin 	const char*	desc;	/* code set description		*/
54da2e3ebdSchin 	const char*	canon;	/* canonical name format	*/
55da2e3ebdSchin 	const char*	index;	/* default index		*/
56da2e3ebdSchin 	int		ccode;	/* <ccode.h> code index		*/
57da2e3ebdSchin 	__V_*		data;	/* map specific data		*/
58da2e3ebdSchin } Ccmap_t;
59da2e3ebdSchin 
60da2e3ebdSchin #if _BLD_ast && defined(__EXPORT__)
61da2e3ebdSchin #undef __MANGLE__
62da2e3ebdSchin #define __MANGLE__ __LINKAGE__		__EXPORT__
63da2e3ebdSchin #endif
64da2e3ebdSchin 
65da2e3ebdSchin extern __MANGLE__ unsigned char*	_ccmap __PROTO__((int, int));
66da2e3ebdSchin extern __MANGLE__ __V_*		_ccmapcpy __PROTO__((unsigned char*, __V_*, const __V_*, size_t));
67da2e3ebdSchin extern __MANGLE__ __V_*		_ccmapstr __PROTO__((unsigned char*, __V_*, size_t));
68da2e3ebdSchin 
69da2e3ebdSchin extern __MANGLE__ int		ccmapid __PROTO__((const char*));
70da2e3ebdSchin extern __MANGLE__ char*		ccmapname __PROTO__((int));
71da2e3ebdSchin extern __MANGLE__ __V_*		ccnative __PROTO__((__V_*, const __V_*, size_t));
72da2e3ebdSchin extern __MANGLE__ Ccmap_t*		ccmaplist __PROTO__((Ccmap_t*));
73da2e3ebdSchin 
74da2e3ebdSchin #undef __MANGLE__
75da2e3ebdSchin #define __MANGLE__ __LINKAGE__
76da2e3ebdSchin 
77da2e3ebdSchin #define CCOP(i,o)		((i)==(o)?0:(((o)<<8)|(i)))
78da2e3ebdSchin #define CCIN(x)			((x)&0xFF)
79da2e3ebdSchin #define CCOUT(x)		(((x)>>8)&0xFF)
80da2e3ebdSchin #define CCCONVERT(x)		((x)&0xFF00)
81da2e3ebdSchin 
82da2e3ebdSchin #define CCCVT(x)		CCMAP(x,0)
83da2e3ebdSchin #define CCMAP(i,o)		((i)==(o)?(unsigned char*)0:_ccmap(i,o))
84da2e3ebdSchin #define CCMAPCHR(m,c)		((m)?(m)[c]:(c))
85da2e3ebdSchin #define CCMAPCPY(m,t,f,n)	((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
86da2e3ebdSchin #define CCMAPSTR(m,s,n)		((m)?_ccmapstr(m,s,n):(__V_*)(s))
87da2e3ebdSchin 
88da2e3ebdSchin #define ccmap(i,o)		CCMAP(i,o)
89da2e3ebdSchin #define ccmapchr(m,c)		CCMAPCHR(m,c)
90da2e3ebdSchin #define ccmapcpy(m,t,f,n)	CCMAPCPY(m,t,f,n)
91da2e3ebdSchin #define ccmapstr(m,s,n)		CCMAPSTR(m,s,n)
92da2e3ebdSchin 
93da2e3ebdSchin #define CCMAPC(c,i,o)		((i)==(o)?(c):CCMAP(i,o)[c])
94da2e3ebdSchin #define CCMAPM(t,f,n,i,o)	((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
95da2e3ebdSchin #define CCMAPS(s,n,i,o)		((i)==(o)?(__V_*)(s):_ccmapstr(CCMAP(i,o),s,n))
96da2e3ebdSchin 
97da2e3ebdSchin #define ccmapc(c,i,o)		CCMAPC(c,i,o)
98da2e3ebdSchin #define ccmapm(t,f,n,i,o)	CCMAPM(t,f,n,i,o)
99da2e3ebdSchin #define ccmaps(s,n,i,o)		CCMAPS(s,n,i,o)
100da2e3ebdSchin 
101da2e3ebdSchin #endif
102