source: trunk/include/helpers/xstring.h@ 131

Last change on this file since 131 was 129, checked in by umoeller, 24 years ago

Executable updates, mostly.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 10.4 KB
Line 
1
2/*
3 *@@sourcefile xstring.h:
4 * header file for xstring.c. See notes there.
5 *
6 * Note: Version numbering in this file relates to XWorkplace version
7 * numbering.
8 *
9 *@@include #define INCL_DOSDATETIME
10 *@@include #include <os2.h>
11 *@@include #include "helpers\xstring.h"
12 */
13
14/*
15 * Copyright (C) 1999-2000 Ulrich M”ller.
16 * This file is part of the "XWorkplace helpers" source package.
17 * This is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published
19 * by the Free Software Foundation, in version 2 as it comes in the
20 * "COPYING" file of the XWorkplace main distribution.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 */
26
27#if __cplusplus
28extern "C" {
29#endif
30
31#ifndef XSTRING_HEADER_INCLUDED
32 #define XSTRING_HEADER_INCLUDED
33
34 #ifndef XWPENTRY
35 #error You must define XWPENTRY to contain the standard linkage for the XWPHelpers.
36 #endif
37
38 /*
39 *@@ XSTRING:
40 *
41 *@@added V0.9.6 (2000-11-01) [umoeller]
42 */
43
44 typedef struct _XSTRING
45 {
46 PSZ psz; // ptr to string or NULL
47 ULONG ulLength; // length of *psz
48 ULONG cbAllocated; // memory allocated in *psz
49 // (>= ulLength + 1)
50 ULONG ulDelta; // allocation delta (0 = none)
51 // V0.9.9 (2001-03-07) [umoeller]
52
53 // if memory debugging is enabled, enable the following
54 // extra fields globally... even if the caller doesn't
55 // want the replacement calls, the xstr* implementations
56 // are compiled with these fields, so they must always be
57 // present V0.9.14 (2001-08-01) [umoeller]
58 #if defined(__XWPMEMDEBUG__) // setup.h only
59 const char *file;
60 unsigned long line;
61 const char *function;
62 #endif
63
64 } XSTRING, *PXSTRING;
65
66 #if defined(__DEBUG_MALLOC_ENABLED__) && !defined(DONT_REPLACE_XSTR_MALLOC) // setup.h, helpers\memdebug.c
67 #define xstrInit(a, b) xstrInitDebug((a), (b), __FILE__, __LINE__, __FUNCTION__)
68 void XWPENTRY xstrInitDebug(PXSTRING pxstr,
69 ULONG ulPreAllocate,
70 const char *file,
71 unsigned long line,
72 const char *function);
73 typedef void XWPENTRY XSTRINITDEBUG(PXSTRING pxstr,
74 ULONG ulPreAllocate,
75 const char *file,
76 unsigned long line,
77 const char *function);
78 typedef XSTRINITDEBUG *PXSTRINITDEBUG;
79 #else
80 void XWPENTRY xstrInit(PXSTRING pxstr, ULONG ulPreAllocate);
81 typedef void XWPENTRY XSTRINIT(PXSTRING pxstr, ULONG ulPreAllocate);
82 typedef XSTRINIT *PXSTRINIT;
83 #endif
84
85 /* void XWPENTRY xstrInit(PXSTRING pxstr, ULONG ulPreAllocate);
86 typedef void XWPENTRY XSTRINIT(PXSTRING pxstr, ULONG ulPreAllocate);
87 typedef XSTRINIT *PXSTRINIT; */
88
89 void XWPENTRY xstrInitSet(PXSTRING pxstr, PSZ pszNew);
90 typedef void XWPENTRY XSTRINITSET(PXSTRING pxstr, PSZ pszNew);
91 typedef XSTRINITSET *PXSTRINITSET;
92
93 #if defined(__DEBUG_MALLOC_ENABLED__) && !defined(DONT_REPLACE_XSTR_MALLOC) // setup.h, helpers\memdebug.c
94 #define xstrInitCopy(a, b, c) xstrInitCopyDebug((a), (b), (c), __FILE__, __LINE__, __FUNCTION__)
95 void XWPENTRY xstrInitCopyDebug(PXSTRING pxstr,
96 const char *pcszSource,
97 ULONG ulExtraAllocate,
98 const char *file,
99 unsigned long line,
100 const char *function);
101 typedef void XWPENTRY XSTRINITCOPYDEBUG(PXSTRING pxstr,
102 const char *pcszSource,
103 ULONG ulExtraAllocate,
104 const char *file,
105 unsigned long line,
106 const char *function);
107 typedef XSTRINITCOPYDEBUG *PXSTRINITCOPYDEBUG;
108 #else
109 void XWPENTRY xstrInitCopy(PXSTRING pxstr, const char *pcszSource, ULONG ulExtraAllocate);
110 typedef void XWPENTRY XSTRINITCOPY(PXSTRING pxstr, const char *pcszSource, ULONG ulExtraAllocate);
111 typedef XSTRINITCOPY *PXSTRINITCOPY;
112 #endif
113
114 void XWPENTRY xstrClear(PXSTRING pxstr);
115 typedef void XWPENTRY XSTRCLEAR(PXSTRING pxstr);
116 typedef XSTRCLEAR *PXSTRCLEAR;
117
118 ULONG XWPENTRY xstrReserve(PXSTRING pxstr, ULONG ulBytes);
119 typedef ULONG XWPENTRY XSTRRESERVE(PXSTRING pxstr, ULONG ulBytes);
120 typedef XSTRRESERVE *PXSTRRESERVE;
121
122 void XWPENTRY xstrShrink(PXSTRING pxstr);
123 typedef void XWPENTRY XSTRSHRINK(PXSTRING pxstr);
124 typedef XSTRSHRINK *PXSTRSHRINK;
125
126 PXSTRING XWPENTRY xstrCreate(ULONG ulPreAllocate);
127 typedef PXSTRING XWPENTRY XSTRCREATE(ULONG ulPreAllocate);
128 typedef XSTRCREATE *PXSTRCREATE;
129
130 VOID XWPENTRY xstrFree(PXSTRING *ppxstr);
131 typedef VOID XWPENTRY XSTRFREE(PXSTRING *ppxstr);
132 typedef XSTRFREE *PXSTRFREE;
133
134 ULONG XWPENTRY xstrset(PXSTRING pxstr, PSZ pszNew);
135 typedef ULONG XWPENTRY XSTRSET(PXSTRING pxstr, PSZ pszNew);
136 typedef XSTRSET *PXSTRSET;
137
138 ULONG XWPENTRY xstrcpy(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
139 typedef ULONG XWPENTRY XSTRCPY(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
140 typedef XSTRCPY *PXSTRCPY;
141
142 ULONG XWPENTRY xstrcpys(PXSTRING pxstr, const XSTRING *pcstrSource);
143 typedef ULONG XWPENTRY XSTRCPYS(PXSTRING pxstr, const XSTRING *pcstrSource);
144 typedef XSTRCPYS *PXSTRCPYS;
145
146 ULONG XWPENTRY xstrcat(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
147 typedef ULONG XWPENTRY XSTRCAT(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
148 typedef XSTRCAT *PXSTRCAT;
149
150 ULONG XWPENTRY xstrcatc(PXSTRING pxstr, CHAR c);
151 typedef ULONG XWPENTRY XSTRCATC(PXSTRING pxstr, CHAR c);
152 typedef XSTRCATC *PXSTRCATC;
153
154 ULONG XWPENTRY xstrcats(PXSTRING pxstr, const XSTRING *pcstrSource);
155 typedef ULONG XWPENTRY XSTRCATS(PXSTRING pxstr, const XSTRING *pcstrSource);
156 typedef XSTRCATS *PXSTRCATS;
157
158 /*
159 *@@ xstrIsString:
160 * returns TRUE if psz contains something.
161 *
162 *@@added V0.9.6 (2000-10-16) [umoeller]
163 */
164
165 #define xstrIsString(psz) ( (psz != 0) && (*(psz) != 0) )
166
167 ULONG XWPENTRY xstrrpl(PXSTRING pxstr,
168 ULONG ulFirstReplOfs,
169 ULONG cReplLen,
170 const char *pcszReplaceWith,
171 ULONG cReplaceWithLen);
172 typedef ULONG XWPENTRY XSTRRPL(PXSTRING pxstr,
173 ULONG ulFirstReplOfs,
174 ULONG cReplLen,
175 const char *pcszReplaceWith,
176 ULONG cReplaceWithLen);
177 typedef XSTRRPL *PXSTRRPL;
178
179 PSZ XWPENTRY xstrFindWord(const XSTRING *pxstr,
180 ULONG ulOfs,
181 const XSTRING *pstrFind,
182 size_t *pShiftTable,
183 PBOOL pfRepeatFind,
184 const char *pcszBeginChars,
185 const char *pcszEndChars);
186 typedef PSZ XWPENTRY XSTRFINDWORD(const XSTRING *pxstr,
187 ULONG ulOfs,
188 const XSTRING *pstrFind,
189 size_t *pShiftTable,
190 PBOOL pfRepeatFind,
191 const char *pcszBeginChars,
192 const char *pcszEndChars);
193 typedef XSTRFINDWORD *PXSTRFINDWORD;
194
195 ULONG XWPENTRY xstrFindReplace(PXSTRING pxstr,
196 PULONG pulOfs,
197 const XSTRING *pstrSearch,
198 const XSTRING *pstrReplace,
199 size_t *pShiftTable,
200 PBOOL pfRepeatFind);
201 typedef ULONG XWPENTRY XSTRFINDREPLACE(PXSTRING pxstr,
202 PULONG pulOfs,
203 const XSTRING *pstrSearch,
204 const XSTRING *pstrReplace,
205 size_t *pShiftTable,
206 PBOOL pfRepeatFind);
207 typedef XSTRFINDREPLACE *PXSTRFINDREPLACE;
208
209 ULONG XWPENTRY xstrFindReplaceC(PXSTRING pxstr,
210 PULONG pulOfs,
211 const char *pcszSearch,
212 const char *pcszReplace);
213 typedef ULONG XWPENTRY XSTRFINDREPLACEC(PXSTRING pxstr,
214 PULONG pulOfs,
215 const char *pcszSearch,
216 const char *pcszReplace);
217 typedef XSTRFINDREPLACEC *PXSTRFINDREPLACEC;
218
219 ULONG XWPENTRY xstrEncode(PXSTRING pxstr, const char *pcszEncode);
220 typedef ULONG XWPENTRY XSTRENCODE(PXSTRING pxstr, const char *pcszEncode);
221 typedef XSTRENCODE *PXSTRENCODE;
222
223 ULONG XWPENTRY xstrDecode(PXSTRING pxstr);
224 typedef ULONG XWPENTRY XSTRDECODE(PXSTRING pxstr);
225 typedef XSTRDECODE *PXSTRDECODE;
226
227 // V0.9.9 (2001-01-29) [lafaix]: constants added
228 #define CRLF2LF TRUE
229 #define LF2CRLF FALSE
230
231 VOID XWPENTRY xstrConvertLineFormat(PXSTRING pxstr, BOOL fToCFormat);
232 typedef VOID XWPENTRY XSTRCONVERTLINEFORMAT(PXSTRING pxstr, BOOL fToCFormat);
233 typedef XSTRCONVERTLINEFORMAT *PXSTRCONVERTLINEFORMAT;
234
235#endif
236
237#if __cplusplus
238}
239#endif
240
Note: See TracBrowser for help on using the repository browser.