StringFuncsI.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: StringFuncsI.h /main/5 1996/08/30 13:42:52 cde-hp $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. **
  27. ** File: StringFuncsI.h
  28. **
  29. ** Project: Cde DtHelp
  30. **
  31. ** Description: Header file for StringFuncs.c
  32. **
  33. **
  34. ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
  35. **
  36. ** (c) Copyright 1993, 1994 Hewlett-Packard Company
  37. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  38. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  39. ** (c) Copyright 1993, 1994 Novell, Inc.
  40. **
  41. **
  42. **
  43. ****************************************************************************
  44. ************************************<+>*************************************/
  45. #ifndef _DtHelpStringFuncsI_h
  46. #define _DtHelpStringFuncsI_h
  47. /* opaque handle of the iconv context */
  48. typedef struct _DtHelpCeIconvContextRec * _DtHelpCeIconvContext;
  49. /****************************************************************************
  50. * Semi Public Macros
  51. ****************************************************************************/
  52. #define _DtHelpCeToLower(c) \
  53. (('A' <= (c) && (c) <= 'Z') ? (c) + 'a' - 'A' : (c))
  54. /****************************************************************************
  55. * Semi Public Re-defines
  56. ****************************************************************************/
  57. #if !defined(_AIX)
  58. #define _DtHelpCeStrCaseCmp(s1,s2) strcasecmp(s1,s2)
  59. #endif /* _AIX */
  60. /****************************************************************************
  61. * Semi Public Routines
  62. ****************************************************************************/
  63. /******************************************************************************
  64. * Function: _DtHelpCeCountChars (char *s1, max_len, ret_len)
  65. *
  66. * Returns in 'ret_len' the number of characters (not bytes)
  67. * in string s1.
  68. *
  69. * Returns:
  70. * -1 If found an invalid character. 'ret_len' contains the
  71. * number of 'good' characters found.
  72. * 0 If successful.
  73. *****************************************************************************/
  74. /******************************************************************************
  75. * Function: _DtHelpCeStrcspn (const char *s1, const char *s2, max_len, &ret_len)
  76. *
  77. * Returns in 'ret_len' the length of the initial segment of string
  78. * s1 which consists entirely of characters not found in string s2.
  79. *
  80. * Returns:
  81. * -1 If found an invalid character.
  82. * 0 If found a character in string s2
  83. * 1 If found the null byte character.
  84. *****************************************************************************/
  85. /******************************************************************************
  86. * Function: _DtHelpCeStrspn (const char *s1, const char *s2, max_len, &ret_len)
  87. *
  88. * Returns in 'ret_len' the length of the initial segment of string
  89. * s1 which consists entirely of characters found in string s2.
  90. *
  91. * Returns:
  92. * -1 If found an invalid character.
  93. * 0 If found a character not in string s2
  94. * 1 If found the null byte character.
  95. *****************************************************************************/
  96. /******************************************************************************
  97. * Function: _DtHelpCeStrchr(const char *s1,const char *value, max_len, ret_ptr)
  98. *
  99. * Returns in 'ret_ptr' the address of the first occurence of 'value'
  100. * in string s1.
  101. *
  102. * Returns:
  103. * -1 If found an invalid character.
  104. * 0 If found value in string s2
  105. * 1 If found the null byte character without finding 'value'.
  106. * 'ret_ptr' will also be null in this case.
  107. *****************************************************************************/
  108. /******************************************************************************
  109. * Function: _DtHelpCeStrrchr(const char *s1,const char *value,max_len,ret_ptr)
  110. *
  111. * Returns in 'ret_ptr' the address of the last occurence of 'value'
  112. * in string s1.
  113. *
  114. * Returns:
  115. * -1 If found an invalid character.
  116. * 0 If found value in string s2
  117. * 1 If found the null byte character without finding 'value'.
  118. * 'ret_ptr' will also be null in this case.
  119. *****************************************************************************/
  120. /*****************************************************************************
  121. * Function: _DtHelpCeUpperCase
  122. *
  123. * Parameters: string Specifies the string to change into
  124. * upper case.
  125. *
  126. * Return Value: Nothing
  127. *
  128. * Purpose: To change all lower case characters into upper case.
  129. *
  130. *****************************************************************************/
  131. /************************************************************************
  132. * Function: _DtHelpCEStrHashToKey
  133. *
  134. * Parameters: C-format string to hash
  135. *
  136. * Purpose:
  137. * Does a very simple hash operation on the string and returns the value
  138. *
  139. * Returns: hash value
  140. *
  141. ************************************************************************/
  142. /******************************************************************************
  143. * Function: _DtHelpCEGetStrcollProc
  144. *
  145. * Parameters: none
  146. *
  147. * Returns: Ptr to the proper collation function to use
  148. * If the LANG="C", then it is strcasecmp().
  149. * If it's not, then it is strcoll().
  150. *
  151. * Purpose: When the LANG="C", strcoll() performs collation
  152. * identical to strcmp(), which is strictly bitwise.
  153. * To get case-insensitive collation, you need to use
  154. * strcasecmp() instead. If LANG != "C", then
  155. * strcoll() collates according to the language
  156. * setting.
  157. *
  158. *****************************************************************************/
  159. /*****************************************************************************
  160. * Function: String _DtHelpCeStripSpaces (string)
  161. *
  162. *
  163. * Parameters: String to process
  164. *
  165. * Return Value: Processed string
  166. *
  167. * Purpose: Strip all leading and trailing spaces.
  168. * Processing is in place
  169. *
  170. *****************************************************************************/
  171. /*****************************************************************************
  172. * Function: void _DtHelpCeCompressSpace (string)
  173. *
  174. * Parameters: string to process
  175. *
  176. * Return Value: processed string
  177. *
  178. * Purpose: This function strips all leading and trailing spaces
  179. * from the string; it also compresses any intervening
  180. * spaces into a single space. This is useful when
  181. * comparing name strings. For instance, the string:
  182. * " First Middle Last "
  183. *
  184. * would compress to:
  185. *
  186. * "First Middle Last"
  187. *
  188. * Processing is in place.
  189. *
  190. *****************************************************************************/
  191. /*****************************************************************************
  192. * Function: _DtHelpCeLowerCase - not_used, commented out
  193. *
  194. * Parameters: string Specifies the string to change into
  195. * lower case.
  196. *
  197. * Return Value: Nothing
  198. *
  199. * Purpose: To change all upper case characters into lower case.
  200. *
  201. *****************************************************************************/
  202. typedef int (*_CEStrcollProc)(const char *,const char *);
  203. extern void **_DtHelpCeAddPtrToArray (
  204. void **array,
  205. void *ptr );
  206. extern int _DtHelpCeCountChars (
  207. char *s1,
  208. int max_len,
  209. int *ret_len );
  210. extern int _DtHelpCeFreeStringArray ( char **array);
  211. #if defined(_AIX)
  212. extern int _DtHelpCeStrCaseCmp(
  213. const char *s1,
  214. const char *s2);
  215. #endif /* _AIX */
  216. extern int _DtHelpCeStrCaseCmpLatin1(
  217. const char *s1,
  218. const char *s2);
  219. extern int _DtHelpCeStrNCaseCmpLatin1(
  220. const char *s1,
  221. const char *s2,
  222. size_t n);
  223. extern int _DtHelpCeStrchr (
  224. const char *s1,
  225. const char *value,
  226. int max_len,
  227. char **ret_ptr);
  228. extern int _DtHelpCeStrrchr (
  229. const char *s1,
  230. const char *value,
  231. int max_len,
  232. char **ret_ptr);
  233. extern int _DtHelpCeStrcspn (
  234. const char *s1,
  235. const char *s2,
  236. int max_len,
  237. int *ret_len );
  238. extern int _DtHelpCeStrspn (
  239. char *s1,
  240. char *s2,
  241. int max_len,
  242. int *ret_len );
  243. extern void _DtHelpCeUpperCase (char *string);
  244. extern int _DtHelpCeStrHashToKey(
  245. const char * str);
  246. extern _CEStrcollProc _DtHelpCeGetStrcollProc(void);
  247. extern char * _DtHelpCeStripSpaces (
  248. char * string);
  249. extern void _DtHelpCeCompressSpace (
  250. char * string);
  251. extern int _DtHelpCeIconvStr1Step(
  252. const char * fromCode,
  253. const char * fromStr,
  254. const char * toCode,
  255. char * * ret_toStr,
  256. int dflt1,
  257. int dflt2);
  258. extern int _DtHelpCeIconvOpen(
  259. _DtHelpCeIconvContext * ret_iconvContext, /* iconv */
  260. const char * fromCode, /* codeset name */
  261. const char * toCode, /* codeset name */
  262. int dflt1, /* 1-byte default char */
  263. int dflt2); /* 2-byte default char */
  264. extern int _DtHelpCeIconvStr(
  265. _DtHelpCeIconvContext iconvContext, /* iconv */
  266. const char * fromStr, /* string to convert */
  267. char * * ret_toStr, /* converted str */
  268. size_t * ret_toStrLen, /* converted str */
  269. char * toStrBuf, /* can pass in a buf */
  270. size_t toStrBufLen); /* length of buf */
  271. extern void _DtHelpCeIconvClose(
  272. _DtHelpCeIconvContext * io_iconvContext);
  273. extern int _DtHelpCeIconvContextSuitable(
  274. _DtHelpCeIconvContext iconvContext,
  275. const char * fromCode,
  276. const char * toCode);
  277. #endif /* _DtHelpStringFuncsI_h */