slookup.c 541 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * slookup.c - static lookup of character sets.
  3. */
  4. #include "charset.h"
  5. #include "internal.h"
  6. #define ENUM_CHARSET(x) extern charset_spec const charset_##x;
  7. #include "enum.c"
  8. #undef ENUM_CHARSET
  9. static charset_spec const *const cs_table[] = {
  10. #define ENUM_CHARSET(x) &charset_##x,
  11. #include "enum.c"
  12. #undef ENUM_CHARSET
  13. };
  14. charset_spec const *charset_find_spec(int charset)
  15. {
  16. int i;
  17. for (i = 0; i < (int)lenof(cs_table); i++)
  18. if (cs_table[i]->charset == charset)
  19. return cs_table[i];
  20. return NULL;
  21. }