ctype.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * Written by Erik Andersen <andersen@lineo.com>, <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 iscntrl(int c);
  33. extern int isdigit(int c);
  34. extern int isgraph(int c);
  35. extern int islower(int c);
  36. extern int isprint(int c);
  37. extern int ispunct(int c);
  38. extern int isspace(int c);
  39. extern int isupper(int c);
  40. extern int isxdigit(int c);
  41. extern int isxlower(int c);
  42. extern int isxupper(int c);
  43. extern int toascii(int c);
  44. extern int tolower(int c);
  45. extern int toupper(int c);
  46. /* Locale-compatible macros/inlines have yet to be implemented. */
  47. #if defined(__USE_CTYPE_MACROS) && !defined __UCLIBC_HAS_LOCALE__
  48. /* macro definitions */
  49. #define isalnum(c) (isalpha(c) || isdigit(c))
  50. #define isalpha(c) (isupper(c) || islower(c))
  51. #define isascii(c) (c > 0 && c <= 0x7f)
  52. #define iscntrl(c) ((c >= 0) && ((c <= 0x1F) || (c == 0x7f)))
  53. #define isdigit(c) (c >= '0' && c <= '9')
  54. #define isgraph(c) (c != ' ' && isprint(c))
  55. #define islower(c) (c >= 'a' && c <= 'z')
  56. #define isprint(c) (c >= ' ' && c <= '~')
  57. #define ispunct(c) ((c > ' ' && c <= '~') && !isalnum(c))
  58. #define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||\
  59. c == '\t' || c == '\v')
  60. #define isupper(c) (c >= 'A' && c <= 'Z')
  61. #define isxdigit(c) (isxupper(c) || isxlower(c))
  62. #define isxlower(c) (isdigit(c) || (c >= 'a' && c <= 'f'))
  63. #define isxupper(c) (isdigit(c) || (c >= 'A' && c <= 'F'))
  64. #define toascii(c) (c & 0x7f)
  65. #define tolower(c) (isupper(c) ? ( c - 'A' + 'a') : (c))
  66. #define toupper(c) (islower(c) ? (c - 'a' + 'A') : (c))
  67. #endif
  68. __END_DECLS
  69. #endif /* __CTYPE_H */