Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libast/include/ccode.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1985-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* David Korn <[email protected]> *
19
* Phong Vo <[email protected]> *
20
* *
21
***********************************************************************/
22
#pragma prototyped
23
24
/*
25
* Glenn Fowler
26
* AT&T Research
27
*
28
* character code map interface
29
*
30
* NOTE: used for mapping between 8-bit character encodings
31
* ISO character sets are handled by sfio
32
*/
33
34
#ifndef _CHARCODE_H
35
#define _CHARCODE_H 1
36
37
#include <ast_common.h>
38
#include <ast_ccode.h>
39
40
typedef struct Ccmap_s
41
{
42
const char* name; /* code set name */
43
const char* match; /* strmatch() pattern */
44
const char* desc; /* code set description */
45
const char* canon; /* canonical name format */
46
const char* index; /* default index */
47
int ccode; /* <ccode.h> code index */
48
void* data; /* map specific data */
49
} Ccmap_t;
50
51
#if _BLD_ast && defined(__EXPORT__)
52
#define extern __EXPORT__
53
#endif
54
55
extern unsigned char* _ccmap(int, int);
56
extern void* _ccmapcpy(unsigned char*, void*, const void*, size_t);
57
extern void* _ccmapstr(unsigned char*, void*, size_t);
58
59
extern int ccmapid(const char*);
60
extern char* ccmapname(int);
61
extern void* ccnative(void*, const void*, size_t);
62
extern Ccmap_t* ccmaplist(Ccmap_t*);
63
64
#undef extern
65
66
#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
67
#define CCIN(x) ((x)&0xFF)
68
#define CCOUT(x) (((x)>>8)&0xFF)
69
#define CCCONVERT(x) ((x)&0xFF00)
70
71
#define CCCVT(x) CCMAP(x,0)
72
#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
73
#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
74
#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
75
#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(void*)(s))
76
77
#define ccmap(i,o) CCMAP(i,o)
78
#define ccmapchr(m,c) CCMAPCHR(m,c)
79
#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
80
#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
81
82
#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
83
#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
84
#define CCMAPS(s,n,i,o) ((i)==(o)?(void*)(s):_ccmapstr(CCMAP(i,o),s,n))
85
86
#define ccmapc(c,i,o) CCMAPC(c,i,o)
87
#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
88
#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
89
90
#endif
91
92