Silly of me to overlook it: another obvious way you might like to
[sgt/charset] / slookup.c
CommitLineData
c6d25d8d 1/*
2 * slookup.c - static lookup of character sets.
3 */
4
5#include "charset.h"
6#include "internal.h"
7
8#define ENUM_CHARSET(x) extern charset_spec const charset_##x;
9#include "enum.c"
10#undef ENUM_CHARSET
11
12static charset_spec const *const cs_table[] = {
13
14#define ENUM_CHARSET(x) &charset_##x,
15#include "enum.c"
16#undef ENUM_CHARSET
17
18};
19
20charset_spec const *charset_find_spec(int charset)
21{
22 int i;
23
24 for (i = 0; i < (int)lenof(cs_table); i++)
25 if (cs_table[i]->charset == charset)
26 return cs_table[i];
27
28 return NULL;
29}
3e5305f1 30
31int charset_exists(int charset)
32{
33 return charset_find_spec(charset) != NULL;
34}