ctype.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * ctype.h
  4. * Character classification and conversion
  5. *
  6. * Copyright (C) 2000 by Lineo, inc.
  7. * Copyright (C) 2000,2001 Erik Andersen <andersee@debian.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Library General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU Library General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #ifndef __CTYPE_H
  25. #define __CTYPE_H
  26. #include <features.h>
  27. __BEGIN_DECLS
  28. /* function prototpes */
  29. extern int isalnum(int c);
  30. extern int isalpha(int c);
  31. extern int isascii(int c);
  32. extern int isblank(int c);
  33. extern int iscntrl(int c);
  34. extern int isdigit(int c);
  35. extern int isgraph(int c);
  36. extern int islower(int c);
  37. extern int isprint(int c);
  38. extern int ispunct(int c);
  39. extern int isspace(int c);
  40. extern int isupper(int c);
  41. extern int isxdigit(int c);
  42. extern int isxlower(int c);
  43. extern int isxupper(int c);
  44. extern int toascii(int c);
  45. extern int tolower(int c);
  46. extern int toupper(int c);
  47. /* Locale-compatible macros/inlines have yet to be implemented. */
  48. #if defined(__USE_CTYPE_MACROS) && !defined __UCLIBC_HAS_LOCALE__
  49. /* macro definitions */
  50. #define isalnum(c) (isalpha(c) || isdigit(c))
  51. #define isalpha(c) (isupper(c) || islower(c))
  52. #define isascii(c) (c > 0 && c <= 0x7f)
  53. #define isblank(c) (c == ' ' || c == '\t')
  54. #define iscntrl(c) ((c >= 0) && ((c <= 0x1F) || (c == 0x7f)))
  55. #define isdigit(c) (c >= '0' && c <= '9')
  56. #define isgraph(c) (c != ' ' && isprint(c))
  57. #define islower(c) (c >= 'a' && c <= 'z')
  58. #define isprint(c) (c >= ' ' && c <= '~')
  59. #define ispunct(c) ((c > ' ' && c <= '~') && !isalnum(c))
  60. #define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||\
  61. c == '\t' || c == '\v')
  62. #define isupper(c) (c >= 'A' && c <= 'Z')
  63. #define isxdigit(c) (isxupper(c) || isxlower(c))
  64. #define isxlower(c) (isdigit(c) || (c >= 'a' && c <= 'f'))
  65. #define isxupper(c) (isdigit(c) || (c >= 'A' && c <= 'F'))
  66. #define toascii(c) (c & 0x7f)
  67. #define tolower(c) (isupper(c) ? ( c - 'A' + 'a') : (c))
  68. #define toupper(c) (islower(c) ? (c - 'a' + 'A') : (c))
  69. #endif
  70. __END_DECLS
  71. #endif /* __CTYPE_H */