ts_locale.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*-------------------------------------------------------------------------
  2. *
  3. * ts_locale.h
  4. * locale compatibility layer for tsearch
  5. *
  6. * Copyright (c) 1998-2022, PostgreSQL Global Development Group
  7. *
  8. * src/include/tsearch/ts_locale.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef __TSLOCALE_H__
  13. #define __TSLOCALE_H__
  14. #include <ctype.h>
  15. #include <limits.h>
  16. #include "lib/stringinfo.h"
  17. #include "mb/pg_wchar.h"
  18. #include "utils/pg_locale.h"
  19. /*
  20. * towlower() and friends should be in <wctype.h>, but some pre-C99 systems
  21. * declare them in <wchar.h>, so include that too.
  22. */
  23. #include <wchar.h>
  24. #ifdef HAVE_WCTYPE_H
  25. #include <wctype.h>
  26. #endif
  27. /* working state for tsearch_readline (should be a local var in caller) */
  28. typedef struct
  29. {
  30. FILE *fp;
  31. const char *filename;
  32. int lineno;
  33. StringInfoData buf; /* current input line, in UTF-8 */
  34. char *curline; /* current input line, in DB's encoding */
  35. /* curline may be NULL, or equal to buf.data, or a palloc'd string */
  36. ErrorContextCallback cb;
  37. } tsearch_readline_state;
  38. #define TOUCHAR(x) (*((const unsigned char *) (x)))
  39. /* The second argument of t_iseq() must be a plain ASCII character */
  40. #define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c))
  41. #define COPYCHAR(d,s) memcpy(d, s, pg_mblen(s))
  42. extern int t_isdigit(const char *ptr);
  43. extern int t_isspace(const char *ptr);
  44. extern int t_isalpha(const char *ptr);
  45. extern int t_isprint(const char *ptr);
  46. extern char *lowerstr(const char *str);
  47. extern char *lowerstr_with_len(const char *str, int len);
  48. extern bool tsearch_readline_begin(tsearch_readline_state *stp,
  49. const char *filename);
  50. extern char *tsearch_readline(tsearch_readline_state *stp);
  51. extern void tsearch_readline_end(tsearch_readline_state *stp);
  52. #endif /* __TSLOCALE_H__ */