curl_ctype.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef HEADER_CURL_CTYPE_H
  2. #define HEADER_CURL_CTYPE_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #ifdef CURL_DOES_CONVERSIONS
  26. /*
  27. * Uppercase macro versions of ANSI/ISO is*() functions/macros which
  28. * avoid negative number inputs with argument byte codes > 127.
  29. *
  30. * For non-ASCII platforms the C library character classification routines
  31. * are used despite being locale-dependent, because this is better than
  32. * not to work at all.
  33. */
  34. #include <ctype.h>
  35. #define ISSPACE(x) (isspace((int) ((unsigned char)x)))
  36. #define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
  37. #define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
  38. #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
  39. #define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
  40. #define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
  41. #define ISPRINT(x) (isprint((int) ((unsigned char)x)))
  42. #define ISUPPER(x) (isupper((int) ((unsigned char)x)))
  43. #define ISLOWER(x) (islower((int) ((unsigned char)x)))
  44. #define ISCNTRL(x) (iscntrl((int) ((unsigned char)x)))
  45. #define ISASCII(x) (isascii((int) ((unsigned char)x)))
  46. #else
  47. int Curl_isspace(int c);
  48. int Curl_isdigit(int c);
  49. int Curl_isalnum(int c);
  50. int Curl_isxdigit(int c);
  51. int Curl_isgraph(int c);
  52. int Curl_isprint(int c);
  53. int Curl_isalpha(int c);
  54. int Curl_isupper(int c);
  55. int Curl_islower(int c);
  56. int Curl_iscntrl(int c);
  57. #define ISSPACE(x) (Curl_isspace((int) ((unsigned char)x)))
  58. #define ISDIGIT(x) (Curl_isdigit((int) ((unsigned char)x)))
  59. #define ISALNUM(x) (Curl_isalnum((int) ((unsigned char)x)))
  60. #define ISXDIGIT(x) (Curl_isxdigit((int) ((unsigned char)x)))
  61. #define ISGRAPH(x) (Curl_isgraph((int) ((unsigned char)x)))
  62. #define ISALPHA(x) (Curl_isalpha((int) ((unsigned char)x)))
  63. #define ISPRINT(x) (Curl_isprint((int) ((unsigned char)x)))
  64. #define ISUPPER(x) (Curl_isupper((int) ((unsigned char)x)))
  65. #define ISLOWER(x) (Curl_islower((int) ((unsigned char)x)))
  66. #define ISCNTRL(x) (Curl_iscntrl((int) ((unsigned char)x)))
  67. #define ISASCII(x) (((x) >= 0) && ((x) <= 0x80))
  68. #endif
  69. #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
  70. (((unsigned char)x) == '\t'))
  71. #endif /* HEADER_CURL_CTYPE_H */