ctype.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * ctype.h
  3. */
  4. /**
  5. \ingroup lub
  6. \defgroup lub_ctype ctype
  7. @{
  8. \brief The ANSI-C standard <ctype.h> interface works fine for strings
  9. containing characters encoded with the ASCII 7-bit coding. However
  10. when you use characters outside this range things start to get ambiguous.
  11. The default manner in which to represent a string in C is to use a
  12. "char *". (NB. this is a signed type) The interfaces presented
  13. in <ctype.h> take signed integers. When a character greater than 128 is
  14. passed as a "char" to isspace() (e.g. the british pound sign "£") then
  15. a negative value is passed into the function/macro. A typical
  16. implementation (e.g. VxWorks) may use the passed argument as an offset
  17. into a lookup table, negative values in this case cause problems...
  18. This utility provides an interface which avoids this ambiguity by passing
  19. "char" characters directly rather than converting to "int".
  20. This component currently only contains those operations which are required
  21. by the current CLISH/LUB implementations. It can be extended on an as needed
  22. basis.
  23. */
  24. /*---------------------------------------------------------------
  25. * HISTORY
  26. * 4-Sep-2006 Graeme McKerrell
  27. * Initial Version
  28. *---------------------------------------------------------------
  29. * Copyright (C) 2006 Newport Networks. All Rights Reserved.
  30. *--------------------------------------------------------------- */
  31. #ifndef _lub_ctype_h
  32. #define _lub_ctype_h
  33. #include <ctype.h>
  34. #include "lub/types.h"
  35. #include "lub/c_decl.h"
  36. _BEGIN_C_DECL
  37. /**
  38. * This operation identifies whether a character is a decimal digit
  39. * or not.
  40. *
  41. * \pre
  42. * - none
  43. *
  44. * \return
  45. * BOOL_TRUE - if the character is a decimal digit
  46. * BOOL_FALSE - if the character is not a decimal digit
  47. *
  48. * \post
  49. * - none
  50. */
  51. bool_t lub_ctype_isdigit(
  52. /**
  53. * The character to check
  54. */
  55. char c);
  56. /**
  57. * This operation identifies whether a character is a standard white space
  58. * character. (space, tab, carriage-return, vertical tab, form-feed)
  59. *
  60. * \pre
  61. * - none
  62. *
  63. * \return
  64. * BOOL_TRUE - if the character is white space
  65. * BOOL_FALSE - if the character is not white space
  66. *
  67. * \post
  68. * - none
  69. */
  70. bool_t lub_ctype_isspace(
  71. /**
  72. * The character to check
  73. */
  74. char c);
  75. /**
  76. * This operation converts an uppercase letter to the corresponding
  77. * lowercase letter.
  78. *
  79. * \pre
  80. * - none
  81. *
  82. * \return
  83. * If the parameter is a character for which lub_ctype_isupper() is true
  84. * and there is a corresponding character for which lub_ctype_islower() is true
  85. * then the corresponding character is returned. Otherwise the parameter is
  86. * returned unchanged.
  87. *
  88. * \post
  89. * - none
  90. */
  91. char lub_ctype_tolower(
  92. /**
  93. * The character to convert
  94. */
  95. char c);
  96. /**
  97. * This operation converts a lowercase letter to the corresponding
  98. * uppercase letter.
  99. *
  100. * \pre
  101. * - none
  102. *
  103. * \return
  104. * If the parameter is a character for which lub_ctype_islower() is true
  105. * and there is a corresponding character for which lub_ctype_isupper() is true
  106. * then the corresponding character is returned. Otherwise the parameter is
  107. * returned unchanged.
  108. *
  109. * \post
  110. * - none
  111. */
  112. char lub_ctype_toupper(
  113. /**
  114. * The character to convert
  115. */
  116. char c);
  117. _END_C_DECL
  118. #endif /* _lub_ctype_h */
  119. /** @} */