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

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

Lots of updates from the last week for conditional compiles and other stuff.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 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 "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 void XWPENTRY xstrInitCopy(PXSTRING pxstr, const char *pcszSource, ULONG ulExtraAllocate);
94 typedef void XWPENTRY XSTRINITCOPY(PXSTRING pxstr, const char *pcszSource, ULONG ulExtraAllocate);
95 typedef XSTRINITCOPY *PXSTRINITCOPY;
96
97 void XWPENTRY xstrClear(PXSTRING pxstr);
98 typedef void XWPENTRY XSTRCLEAR(PXSTRING pxstr);
99 typedef XSTRCLEAR *PXSTRCLEAR;
100
101 ULONG XWPENTRY xstrReserve(PXSTRING pxstr, ULONG ulBytes);
102 typedef ULONG XWPENTRY XSTRRESERVE(PXSTRING pxstr, ULONG ulBytes);
103 typedef XSTRRESERVE *PXSTRRESERVE;
104
105 void XWPENTRY xstrShrink(PXSTRING pxstr);
106 typedef void XWPENTRY XSTRSHRINK(PXSTRING pxstr);
107 typedef XSTRSHRINK *PXSTRSHRINK;
108
109 PXSTRING XWPENTRY xstrCreate(ULONG ulPreAllocate);
110 typedef PXSTRING XWPENTRY XSTRCREATE(ULONG ulPreAllocate);
111 typedef XSTRCREATE *PXSTRCREATE;
112
113 VOID XWPENTRY xstrFree(PXSTRING *ppxstr);
114 typedef VOID XWPENTRY XSTRFREE(PXSTRING *ppxstr);
115 typedef XSTRFREE *PXSTRFREE;
116
117 ULONG XWPENTRY xstrset(PXSTRING pxstr, PSZ pszNew);
118 typedef ULONG XWPENTRY XSTRSET(PXSTRING pxstr, PSZ pszNew);
119 typedef XSTRSET *PXSTRSET;
120
121 ULONG XWPENTRY xstrcpy(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
122 typedef ULONG XWPENTRY XSTRCPY(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
123 typedef XSTRCPY *PXSTRCPY;
124
125 ULONG XWPENTRY xstrcpys(PXSTRING pxstr, const XSTRING *pcstrSource);
126 typedef ULONG XWPENTRY XSTRCPYS(PXSTRING pxstr, const XSTRING *pcstrSource);
127 typedef XSTRCPYS *PXSTRCPYS;
128
129 ULONG XWPENTRY xstrcat(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
130 typedef ULONG XWPENTRY XSTRCAT(PXSTRING pxstr, const char *pcszSource, ULONG ulSourceLength);
131 typedef XSTRCAT *PXSTRCAT;
132
133 ULONG XWPENTRY xstrcatc(PXSTRING pxstr, CHAR c);
134 typedef ULONG XWPENTRY XSTRCATC(PXSTRING pxstr, CHAR c);
135 typedef XSTRCATC *PXSTRCATC;
136
137 ULONG XWPENTRY xstrcats(PXSTRING pxstr, const XSTRING *pcstrSource);
138 typedef ULONG XWPENTRY XSTRCATS(PXSTRING pxstr, const XSTRING *pcstrSource);
139 typedef XSTRCATS *PXSTRCATS;
140
141 /*
142 *@@ xstrIsString:
143 * returns TRUE if psz contains something.
144 *
145 *@@added V0.9.6 (2000-10-16) [umoeller]
146 */
147
148 #define xstrIsString(psz) ( (psz != 0) && (*(psz) != 0) )
149
150 ULONG XWPENTRY xstrrpl(PXSTRING pxstr,
151 ULONG ulFirstReplOfs,
152 ULONG cReplLen,
153 const char *pcszReplaceWith,
154 ULONG cReplaceWithLen);
155 typedef ULONG XWPENTRY XSTRRPL(PXSTRING pxstr,
156 ULONG ulFirstReplOfs,
157 ULONG cReplLen,
158 const char *pcszReplaceWith,
159 ULONG cReplaceWithLen);
160 typedef XSTRRPL *PXSTRRPL;
161
162 PSZ XWPENTRY xstrFindWord(const XSTRING *pxstr,
163 ULONG ulOfs,
164 const XSTRING *pstrFind,
165 size_t *pShiftTable,
166 PBOOL pfRepeatFind,
167 const char *pcszBeginChars,
168 const char *pcszEndChars);
169 typedef PSZ XWPENTRY XSTRFINDWORD(const XSTRING *pxstr,
170 ULONG ulOfs,
171 const XSTRING *pstrFind,
172 size_t *pShiftTable,
173 PBOOL pfRepeatFind,
174 const char *pcszBeginChars,
175 const char *pcszEndChars);
176 typedef XSTRFINDWORD *PXSTRFINDWORD;
177
178 ULONG XWPENTRY xstrFindReplace(PXSTRING pxstr,
179 PULONG pulOfs,
180 const XSTRING *pstrSearch,
181 const XSTRING *pstrReplace,
182 size_t *pShiftTable,
183 PBOOL pfRepeatFind);
184 typedef ULONG XWPENTRY XSTRFINDREPLACE(PXSTRING pxstr,
185 PULONG pulOfs,
186 const XSTRING *pstrSearch,
187 const XSTRING *pstrReplace,
188 size_t *pShiftTable,
189 PBOOL pfRepeatFind);
190 typedef XSTRFINDREPLACE *PXSTRFINDREPLACE;
191
192 ULONG XWPENTRY xstrFindReplaceC(PXSTRING pxstr,
193 PULONG pulOfs,
194 const char *pcszSearch,
195 const char *pcszReplace);
196 typedef ULONG XWPENTRY XSTRFINDREPLACEC(PXSTRING pxstr,
197 PULONG pulOfs,
198 const char *pcszSearch,
199 const char *pcszReplace);
200 typedef XSTRFINDREPLACEC *PXSTRFINDREPLACEC;
201
202 ULONG XWPENTRY xstrEncode(PXSTRING pxstr, const char *pcszEncode);
203 typedef ULONG XWPENTRY XSTRENCODE(PXSTRING pxstr, const char *pcszEncode);
204 typedef XSTRENCODE *PXSTRENCODE;
205
206 ULONG XWPENTRY xstrDecode(PXSTRING pxstr);
207 typedef ULONG XWPENTRY XSTRDECODE(PXSTRING pxstr);
208 typedef XSTRDECODE *PXSTRDECODE;
209
210 // V0.9.9 (2001-01-29) [lafaix]: constants added
211 #define CRLF2LF TRUE
212 #define LF2CRLF FALSE
213
214 VOID XWPENTRY xstrConvertLineFormat(PXSTRING pxstr, BOOL fToCFormat);
215 typedef VOID XWPENTRY XSTRCONVERTLINEFORMAT(PXSTRING pxstr, BOOL fToCFormat);
216 typedef XSTRCONVERTLINEFORMAT *PXSTRCONVERTLINEFORMAT;
217
218#endif
219
220#if __cplusplus
221}
222#endif
223
Note: See TracBrowser for help on using the repository browser.