1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
28 * 8 bit character code map name/id lookup support
35 static const Ccmap_t maps
[] =
39 "a|ascii|?(iso)?(-)646|?(iso)?(-)8859|latin",
48 "e|ebcdic?(-)?([1e])",
57 "o|ebcdic?(-)[3o]|?(cp|ibm)1047|open?(-)edition",
58 "mvs OpenEdition ebcdic",
66 "h|ebcdic?(-)h|?(cp|ibm)?(00)37|[oa]s?(/-)400",
67 "ibm OS/400 AS/400 ebcdic",
75 "s|ebcdic?(-)s|siemens|posix-bc",
76 "siemens posix-bc ebcdic",
84 "i|ebcdic?(-)[2i]|ibm",
85 "X/Open ibm ebcdic (not idempotent)",
102 "u|ebcdic?(-)(u|mf)|microfocus",
103 "microfocus cobol ebcdic",
122 * ccode map list iterator
126 ccmaplist(Ccmap_t
* mp
)
128 return !mp
? (Ccmap_t
*)maps
: (++mp
)->name
? mp
: (Ccmap_t
*)0;
132 * return ccode map id given name
136 ccmapid(const char* name
)
138 register const Ccmap_t
* mp
;
146 for (mp
= maps
; mp
->name
; mp
++)
147 if (strgrpmatch(name
, mp
->match
, sub
, elementsof(sub
) / 2, STR_MAXIMAL
|STR_LEFT
|STR_ICASE
))
149 if (!(c
= name
[sub
[1]]))
151 if (sub
[1] > n
&& !isalpha(c
))
157 return bp
? bp
->ccode
: -1;
161 * return ccode map name given id
165 ccmapname(register int id
)
167 register const Ccmap_t
* mp
;
169 for (mp
= maps
; mp
->name
; mp
++)
171 return (char*)mp
->name
;