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