2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: StringFuncsI.h /main/5 1996/08/30 13:42:52 cde-hp $ */
24 /************************************<+>*************************************
25 ****************************************************************************
27 ** File: StringFuncsI.h
29 ** Project: Cde DtHelp
31 ** Description: Header file for StringFuncs.c
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
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.
43 ****************************************************************************
44 ************************************<+>*************************************/
45 #ifndef _DtHelpStringFuncsI_h
46 #define _DtHelpStringFuncsI_h
48 /* opaque handle of the iconv context */
49 typedef struct _DtHelpCeIconvContextRec * _DtHelpCeIconvContext;
51 /****************************************************************************
53 ****************************************************************************/
54 #define _DtHelpCeToLower(c) \
55 (('A' <= (c) && (c) <= 'Z') ? (c) + 'a' - 'A' : (c))
56 /****************************************************************************
57 * Semi Public Re-defines
58 ****************************************************************************/
60 #define _DtHelpCeStrCaseCmp(s1,s2) strcasecmp(s1,s2)
63 /****************************************************************************
64 * Semi Public Routines
65 ****************************************************************************/
66 /******************************************************************************
67 * Function: _DtHelpCeCountChars (char *s1, max_len, ret_len)
69 * Returns in 'ret_len' the number of characters (not bytes)
73 * -1 If found an invalid character. 'ret_len' contains the
74 * number of 'good' characters found.
76 *****************************************************************************/
78 /******************************************************************************
79 * Function: _DtHelpCeStrcspn (const char *s1, const char *s2, max_len, &ret_len)
81 * Returns in 'ret_len' the length of the initial segment of string
82 * s1 which consists entirely of characters not found in string s2.
85 * -1 If found an invalid character.
86 * 0 If found a character in string s2
87 * 1 If found the null byte character.
88 *****************************************************************************/
90 /******************************************************************************
91 * Function: _DtHelpCeStrspn (const char *s1, const char *s2, max_len, &ret_len)
93 * Returns in 'ret_len' the length of the initial segment of string
94 * s1 which consists entirely of characters found in string s2.
97 * -1 If found an invalid character.
98 * 0 If found a character not in string s2
99 * 1 If found the null byte character.
100 *****************************************************************************/
102 /******************************************************************************
103 * Function: _DtHelpCeStrchr(const char *s1,const char *value, max_len, ret_ptr)
105 * Returns in 'ret_ptr' the address of the first occurence of 'value'
109 * -1 If found an invalid character.
110 * 0 If found value in string s2
111 * 1 If found the null byte character without finding 'value'.
112 * 'ret_ptr' will also be null in this case.
113 *****************************************************************************/
115 /******************************************************************************
116 * Function: _DtHelpCeStrrchr(const char *s1,const char *value,max_len,ret_ptr)
118 * Returns in 'ret_ptr' the address of the last occurence of 'value'
122 * -1 If found an invalid character.
123 * 0 If found value in string s2
124 * 1 If found the null byte character without finding 'value'.
125 * 'ret_ptr' will also be null in this case.
126 *****************************************************************************/
128 /*****************************************************************************
129 * Function: _DtHelpCeUpperCase
131 * Parameters: string Specifies the string to change into
134 * Return Value: Nothing
136 * Purpose: To change all lower case characters into upper case.
138 *****************************************************************************/
140 /************************************************************************
141 * Function: _DtHelpCEStrHashToKey
143 * Parameters: C-format string to hash
146 * Does a very simple hash operation on the string and returns the value
148 * Returns: hash value
150 ************************************************************************/
152 /******************************************************************************
153 * Function: _DtHelpCEGetStrcollProc
157 * Returns: Ptr to the proper collation function to use
158 * If the LANG="C", then it is strcasecmp().
159 * If it's not, then it is strcoll().
161 * Purpose: When the LANG="C", strcoll() performs collation
162 * identical to strcmp(), which is strictly bitwise.
163 * To get case-insensitive collation, you need to use
164 * strcasecmp() instead. If LANG != "C", then
165 * strcoll() collates according to the language
168 *****************************************************************************/
170 /*****************************************************************************
171 * Function: String _DtHelpCeStripSpaces (string)
174 * Parameters: String to process
176 * Return Value: Processed string
178 * Purpose: Strip all leading and trailing spaces.
179 * Processing is in place
181 *****************************************************************************/
183 /*****************************************************************************
184 * Function: void _DtHelpCeCompressSpace (string)
186 * Parameters: string to process
188 * Return Value: processed string
190 * Purpose: This function strips all leading and trailing spaces
191 * from the string; it also compresses any intervening
192 * spaces into a single space. This is useful when
193 * comparing name strings. For instance, the string:
194 * " First Middle Last "
198 * "First Middle Last"
200 * Processing is in place.
202 *****************************************************************************/
204 /*****************************************************************************
205 * Function: _DtHelpCeLowerCase - not_used, commented out
207 * Parameters: string Specifies the string to change into
210 * Return Value: Nothing
212 * Purpose: To change all upper case characters into lower case.
214 *****************************************************************************/
216 typedef int (*_CEStrcollProc)(const char *,const char *);
218 extern void **_DtHelpCeAddPtrToArray (
221 extern int _DtHelpCeCountChars (
225 extern int _DtHelpCeFreeStringArray ( char **array);
227 extern int _DtHelpCeStrCaseCmp(
231 extern int _DtHelpCeStrCaseCmpLatin1(
234 extern int _DtHelpCeStrNCaseCmpLatin1(
238 extern int _DtHelpCeStrchr (
243 extern int _DtHelpCeStrrchr (
248 extern int _DtHelpCeStrcspn (
253 extern int _DtHelpCeStrspn (
258 extern void _DtHelpCeUpperCase (char *string);
259 extern int _DtHelpCeStrHashToKey(
261 extern _CEStrcollProc _DtHelpCeGetStrcollProc(void);
262 extern char * _DtHelpCeStripSpaces (
264 extern void _DtHelpCeCompressSpace (
266 extern int _DtHelpCeIconvStr1Step(
267 const char * fromCode,
268 const char * fromStr,
273 extern int _DtHelpCeIconvOpen(
274 _DtHelpCeIconvContext * ret_iconvContext, /* iconv */
275 const char * fromCode, /* codeset name */
276 const char * toCode, /* codeset name */
277 int dflt1, /* 1-byte default char */
278 int dflt2); /* 2-byte default char */
279 extern int _DtHelpCeIconvStr(
280 _DtHelpCeIconvContext iconvContext, /* iconv */
281 const char * fromStr, /* string to convert */
282 char * * ret_toStr, /* converted str */
283 size_t * ret_toStrLen, /* converted str */
284 char * toStrBuf, /* can pass in a buf */
285 size_t toStrBufLen); /* length of buf */
287 extern void _DtHelpCeIconvClose(
288 _DtHelpCeIconvContext * io_iconvContext);
289 extern int _DtHelpCeIconvContextSuitable(
290 _DtHelpCeIconvContext iconvContext,
291 const char * fromCode,
292 const char * toCode);
296 #endif /* _DtHelpStringFuncsI_h */