Cleanup of -Wpointer-compare warnings.
[oweals/cde.git] / cde / lib / DtHelp / StringFuncsI.h
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
48 /* opaque handle of the iconv context */
49 typedef struct _DtHelpCeIconvContextRec * _DtHelpCeIconvContext;
50
51 /****************************************************************************
52  *                      Semi Public Macros
53  ****************************************************************************/
54 #define _DtHelpCeToLower(c) \
55                 (('A' <= (c) && (c) <= 'Z') ? (c) + 'a' - 'A' : (c))
56 /****************************************************************************
57  *                      Semi Public Re-defines
58  ****************************************************************************/
59 #if !defined(_AIX)
60 #define _DtHelpCeStrCaseCmp(s1,s2)      strcasecmp(s1,s2)
61 #endif /* _AIX */
62
63 /****************************************************************************
64  *                      Semi Public Routines
65  ****************************************************************************/
66 /******************************************************************************
67  * Function: _DtHelpCeCountChars (char *s1, max_len, ret_len)
68  *
69  *      Returns in 'ret_len' the number of characters (not bytes)
70  *      in string s1.
71  *
72  * Returns:
73  *      -1  If found an invalid character. 'ret_len' contains the
74  *          number of 'good' characters found.
75  *       0  If successful.
76  *****************************************************************************/
77
78 /******************************************************************************
79  * Function: _DtHelpCeStrcspn (const char *s1, const char *s2, max_len, &ret_len)
80  *
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.
83  *
84  * Returns:
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  *****************************************************************************/
89
90 /******************************************************************************
91  * Function: _DtHelpCeStrspn (const char *s1, const char *s2, max_len, &ret_len)
92  *
93  *      Returns in 'ret_len' the length of the initial segment of string
94  *      s1 which consists entirely of characters found in string s2.
95  *
96  * Returns:
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  *****************************************************************************/
101
102 /******************************************************************************
103  * Function: _DtHelpCeStrchr(const char *s1,const char *value, max_len, ret_ptr)
104  *
105  *      Returns in 'ret_ptr' the address of the first occurence of 'value'
106  *      in string s1.
107  *
108  * Returns:
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  *****************************************************************************/
114
115 /******************************************************************************
116  * Function: _DtHelpCeStrrchr(const char *s1,const char *value,max_len,ret_ptr)
117  *
118  *      Returns in 'ret_ptr' the address of the last occurence of 'value'
119  *      in string s1.
120  *
121  * Returns:
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  *****************************************************************************/
127
128 /*****************************************************************************
129  * Function: _DtHelpCeUpperCase
130  *
131  * Parameters:  string          Specifies the string to change into
132  *                              upper case.
133  *
134  * Return Value: Nothing
135  *
136  * Purpose:     To change all lower case characters into upper case.
137  *
138  *****************************************************************************/
139
140 /************************************************************************
141  * Function: _DtHelpCEStrHashToKey
142  *
143  * Parameters:  C-format string to hash
144  *
145  * Purpose:
146  *   Does a very simple hash operation on the string and returns the value
147  *
148  * Returns:  hash value
149  *
150  ************************************************************************/
151
152 /******************************************************************************
153  * Function:    _DtHelpCEGetStrcollProc
154  *
155  * Parameters:  none
156  *
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().
160  *
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
166  *              setting.
167  *
168  *****************************************************************************/
169
170 /*****************************************************************************
171  * Function:        String _DtHelpCeStripSpaces (string)
172  *
173  *
174  * Parameters:    String to process
175  *
176  * Return Value:  Processed string
177  *
178  * Purpose:       Strip all leading and trailing spaces.
179  *                Processing is in place
180  *
181  *****************************************************************************/
182
183 /*****************************************************************************
184  * Function:        void _DtHelpCeCompressSpace (string)
185  *
186  * Parameters:      string to process
187  *
188  * Return Value:    processed string
189  *
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   "
195  *
196  *                    would compress to:
197  *
198  *                    "First Middle Last"
199  *
200  *                     Processing is in place.
201  *
202  *****************************************************************************/
203
204 /*****************************************************************************
205  * Function: _DtHelpCeLowerCase - not_used, commented out
206  *
207  * Parameters:  string          Specifies the string to change into
208  *                              lower case.
209  *
210  * Return Value: Nothing
211  *
212  * Purpose:     To change all upper case characters into lower case.
213  *
214  *****************************************************************************/
215
216 typedef int (*_CEStrcollProc)(const char *,const char *);
217
218 extern  void  **_DtHelpCeAddPtrToArray (
219                         void            **array,
220                         void             *ptr );
221 extern  int     _DtHelpCeCountChars (
222                         char            *s1,
223                         int              max_len,
224                         int             *ret_len );
225 extern  int     _DtHelpCeFreeStringArray ( char **array);
226 #if     defined(_AIX)
227 extern  int     _DtHelpCeStrCaseCmp(
228                         const char      *s1,
229                         const char      *s2);
230 #endif /* _AIX */
231 extern  int     _DtHelpCeStrCaseCmpLatin1(
232                         const char      *s1,
233                         const char      *s2);
234 extern  int     _DtHelpCeStrNCaseCmpLatin1(
235                         const char      *s1,
236                         const char      *s2,
237                         size_t           n);
238 extern  int     _DtHelpCeStrchr (
239                         const char      *s1,
240                         const char      *value,
241                         int              max_len,
242                         char            **ret_ptr);
243 extern  int     _DtHelpCeStrrchr (
244                         const char      *s1,
245                         const char      *value,
246                         int              max_len,
247                         char            **ret_ptr);
248 extern  int     _DtHelpCeStrcspn (
249                         const char      *s1,
250                         const char      *s2,
251                         int              max_len,
252                         int             *ret_len );
253 extern  int     _DtHelpCeStrspn (
254                         char            *s1,
255                         char            *s2,
256                         int              max_len,
257                         int             *ret_len );
258 extern  void    _DtHelpCeUpperCase (char *string);
259 extern  int     _DtHelpCeStrHashToKey(
260                         const char *    str);
261 extern  _CEStrcollProc _DtHelpCeGetStrcollProc(void);
262 extern  char *  _DtHelpCeStripSpaces (
263                         char * string);
264 extern  void    _DtHelpCeCompressSpace (
265                         char * string);
266 extern  int _DtHelpCeIconvStr1Step(
267                         const char * fromCode,
268                         const char * fromStr,
269                         const char * toCode,
270                         char * *     ret_toStr,
271                         int          dflt1,
272                         int          dflt2);
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 */
286
287 extern void _DtHelpCeIconvClose(
288                         _DtHelpCeIconvContext * io_iconvContext);
289 extern int _DtHelpCeIconvContextSuitable(
290                         _DtHelpCeIconvContext iconvContext,
291                         const char *          fromCode,
292                         const char *          toCode);
293
294
295
296 #endif /* _DtHelpStringFuncsI_h */