sd: remove 'ssd' driver support
[unleashed/tickless.git] / usr / src / lib / libast / common / string / ccmapid.c
blob89ca51c5889636b18e2af467889f5a47b2f866e9
1 /***********************************************************************
2 * *
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 *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
25 * Glenn Fowler
26 * AT&T Research
28 * 8 bit character code map name/id lookup support
31 #include <ast.h>
32 #include <ccode.h>
33 #include <ctype.h>
35 static const Ccmap_t maps[] =
38 "ascii",
39 "a|ascii|?(iso)?(-)646|?(iso)?(-)8859|latin",
40 "8 bit ascii",
41 "ISO-8859-%s",
42 "1",
43 CC_ASCII,
47 "ebcdic",
48 "e|ebcdic?(-)?([1e])",
49 "X/Open ebcdic",
50 "EBCDIC",
52 CC_EBCDIC_E,
56 "ebcdic-o",
57 "o|ebcdic?(-)[3o]|?(cp|ibm)1047|open?(-)edition",
58 "mvs OpenEdition ebcdic",
59 "EBCDIC-O",
61 CC_EBCDIC_O,
65 "ebcdic-h",
66 "h|ebcdic?(-)h|?(cp|ibm)?(00)37|[oa]s?(/-)400",
67 "ibm OS/400 AS/400 ebcdic",
68 "EBCDIC-H",
70 CC_EBCDIC_H,
74 "ebcdic-s",
75 "s|ebcdic?(-)s|siemens|posix-bc",
76 "siemens posix-bc ebcdic",
77 "EBCDIC-S",
79 CC_EBCDIC_S,
83 "ebcdic-i",
84 "i|ebcdic?(-)[2i]|ibm",
85 "X/Open ibm ebcdic (not idempotent)",
86 "EBCDIC-I",
88 CC_EBCDIC_I,
92 "ebcdic-m",
93 "m|ebcdic?(-)m|mvs",
94 "mvs ebcdic",
95 "EBCDIC-M",
97 CC_EBCDIC_M,
101 "ebcdic-u",
102 "u|ebcdic?(-)(u|mf)|microfocus",
103 "microfocus cobol ebcdic",
104 "EBCDIC-U",
106 CC_EBCDIC_U,
110 "native",
111 "n|native|local",
112 "native code set",
115 CC_NATIVE,
118 { 0 },
122 * ccode map list iterator
125 Ccmap_t*
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;
139 register int c;
140 const Ccmap_t* bp;
141 int n;
142 int sub[2];
144 bp = 0;
145 n = 0;
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]]))
150 return mp->ccode;
151 if (sub[1] > n && !isalpha(c))
153 n = sub[1];
154 bp = mp;
157 return bp ? bp->ccode : -1;
161 * return ccode map name given id
164 char*
165 ccmapname(register int id)
167 register const Ccmap_t* mp;
169 for (mp = maps; mp->name; mp++)
170 if (id == mp->ccode)
171 return (char*)mp->name;
172 return 0;