ccode.h revision 1
1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* Glenn Fowler <gsf@research.att.com> *
1N/A* David Korn <dgk@research.att.com> *
1N/A* Phong Vo <kpv@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A
1N/A/*
1N/A * Glenn Fowler
1N/A * AT&T Research
1N/A *
1N/A * character code map interface
1N/A *
1N/A * NOTE: used for mapping between 8-bit character encodings
1N/A * ISO character sets are handled by sfio
1N/A */
1N/A
1N/A#ifndef _CHARCODE_H
1N/A#define _CHARCODE_H 1
1N/A
1N/A#include <ast_common.h>
1N/A#include <ast_ccode.h>
1N/A
1N/Atypedef struct Ccmap_s
1N/A{
1N/A const char* name; /* code set name */
1N/A const char* match; /* strmatch() pattern */
1N/A const char* desc; /* code set description */
1N/A const char* canon; /* canonical name format */
1N/A const char* index; /* default index */
1N/A int ccode; /* <ccode.h> code index */
1N/A void* data; /* map specific data */
1N/A} Ccmap_t;
1N/A
1N/A#if _BLD_ast && defined(__EXPORT__)
1N/A#define extern __EXPORT__
1N/A#endif
1N/A
1N/Aextern unsigned char* _ccmap(int, int);
1N/Aextern void* _ccmapcpy(unsigned char*, void*, const void*, size_t);
1N/Aextern void* _ccmapstr(unsigned char*, void*, size_t);
1N/A
1N/Aextern int ccmapid(const char*);
1N/Aextern char* ccmapname(int);
1N/Aextern void* ccnative(void*, const void*, size_t);
1N/Aextern Ccmap_t* ccmaplist(Ccmap_t*);
1N/A
1N/A#undef extern
1N/A
1N/A#define CCOP(i,o) ((i)==(o)?0:(((o)<<8)|(i)))
1N/A#define CCIN(x) ((x)&0xFF)
1N/A#define CCOUT(x) (((x)>>8)&0xFF)
1N/A#define CCCONVERT(x) ((x)&0xFF00)
1N/A
1N/A#define CCCVT(x) CCMAP(x,0)
1N/A#define CCMAP(i,o) ((i)==(o)?(unsigned char*)0:_ccmap(i,o))
1N/A#define CCMAPCHR(m,c) ((m)?(m)[c]:(c))
1N/A#define CCMAPCPY(m,t,f,n) ((m)?_ccmapcpy(m,t,f,n):memcpy(t,f,n))
1N/A#define CCMAPSTR(m,s,n) ((m)?_ccmapstr(m,s,n):(void*)(s))
1N/A
1N/A#define ccmap(i,o) CCMAP(i,o)
1N/A#define ccmapchr(m,c) CCMAPCHR(m,c)
1N/A#define ccmapcpy(m,t,f,n) CCMAPCPY(m,t,f,n)
1N/A#define ccmapstr(m,s,n) CCMAPSTR(m,s,n)
1N/A
1N/A#define CCMAPC(c,i,o) ((i)==(o)?(c):CCMAP(i,o)[c])
1N/A#define CCMAPM(t,f,n,i,o) ((i)==(o)?memcpy(t,f,n):_ccmapcpy(CCMAP(i,o),t,f,n))
1N/A#define CCMAPS(s,n,i,o) ((i)==(o)?(void*)(s):_ccmapstr(CCMAP(i,o),s,n))
1N/A
1N/A#define ccmapc(c,i,o) CCMAPC(c,i,o)
1N/A#define ccmapm(t,f,n,i,o) CCMAPM(t,f,n,i,o)
1N/A#define ccmaps(s,n,i,o) CCMAPS(s,n,i,o)
1N/A
1N/A#endif