gwenhywfar 5.12.0
text.h
Go to the documentation of this file.
1/***************************************************************************
2 begin : Sat Jun 28 2003
3 copyright : (C) 2003 by Martin Preuss
4 email : martin@libchipcard.de
5
6 ***************************************************************************
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 * *
23 ***************************************************************************/
24
25
26
27#ifndef GWENHYWFAR_TEXT_H
28#define GWENHYWFAR_TEXT_H
29
31#include <gwenhywfar/types.h>
32#include <gwenhywfar/logger.h>
33#include <gwenhywfar/buffer.h>
34#include <stdio.h>
35
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#define GWEN_TEXT_FUZZY_SHIFT 10
42
43
44#define GWEN_TEXT_FLAGS_DEL_LEADING_BLANKS 0x00000001
45#define GWEN_TEXT_FLAGS_DEL_TRAILING_BLANKS 0x00000002
46#define GWEN_TEXT_FLAGS_DEL_MULTIPLE_BLANKS 0x00000004
47#define GWEN_TEXT_FLAGS_NEED_DELIMITER 0x00000008
48#define GWEN_TEXT_FLAGS_NULL_IS_DELIMITER 0x00000010
49#define GWEN_TEXT_FLAGS_DEL_QUOTES 0x00000020
50#define GWEN_TEXT_FLAGS_CHECK_BACKSLASH 0x00000040
51
52
70char *GWEN_Text_GetWord(const char *src,
71 const char *delims,
72 char *buffer,
73 unsigned int maxsize,
74 uint32_t flags,
75 const char **next);
76
78int GWEN_Text_GetWordToBuffer(const char *src,
79 const char *delims,
80 GWEN_BUFFER *buf,
81 uint32_t flags,
82 const char **next);
83
84
91char *GWEN_Text_Escape(const char *src,
92 char *buffer,
93 unsigned int maxsize);
94
96char *GWEN_Text_Unescape(const char *src,
97 char *buffer,
98 unsigned int maxsize);
99
101char *GWEN_Text_UnescapeN(const char *src,
102 unsigned int srclen,
103 char *buffer,
104 unsigned int maxsize);
105
107char *GWEN_Text_EscapeTolerant(const char *src,
108 char *buffer,
109 unsigned int maxsize);
110
112char *GWEN_Text_UnescapeTolerant(const char *src,
113 char *buffer,
114 unsigned int maxsize);
115
117char *GWEN_Text_UnescapeTolerantN(const char *src,
118 unsigned int srclen,
119 char *buffer,
120 unsigned int maxsize);
121
122
124int GWEN_Text_EscapeToBuffer(const char *src, GWEN_BUFFER *buf);
125
127int GWEN_Text_UnescapeToBuffer(const char *src, GWEN_BUFFER *buf);
128
136
139
140
147
148
150char *GWEN_Text_ToHex(const char *src, unsigned l, char *buffer,
151 unsigned int maxsize);
152
161int GWEN_Text_ToHexBuffer(const char *src, unsigned l,
162 GWEN_BUFFER *buf,
163 unsigned int groupsize,
164 char delimiter,
165 int skipLeadingZeroes);
166
172char *GWEN_Text_ToHexGrouped(const char *src,
173 unsigned l,
174 char *buffer,
175 unsigned maxsize,
176 unsigned int groupsize,
177 char delimiter,
178 int skipLeadingZeros);
179
181int GWEN_Text_FromHex(const char *src, char *buffer, unsigned maxsize);
182
187int GWEN_Text_FromHexBuffer(const char *src, GWEN_BUFFER *buf);
188
189
194int GWEN_Text_FromBcdBuffer(const char *src, GWEN_BUFFER *buf);
195
196
205int GWEN_Text_ToBcdBuffer(const char *src, unsigned l,
206 GWEN_BUFFER *buf,
207 unsigned int groupsize,
208 char delimiter,
209 int skipLeadingZeroes);
210
211
218int GWEN_Text_NumToString(int num, char *buffer, unsigned int bufsize,
219 int fillchar);
220
229
237int GWEN_Text_StringToDouble(const char *s, double *num);
238
239
247int GWEN_Text_Compare(const char *s1, const char *s2, int ign);
248
249
255const char *GWEN_Text_StrCaseStr(const char *haystack, const char *needle);
256
257
263char *GWEN_Text_strndup(const char *s, size_t n);
264
265
274int GWEN_Text_ComparePattern(const char *w, const char *p, int sensecase);
275
276
282void GWEN_Text_DumpString(const char *s, unsigned int l,
283 unsigned int insert);
284
285
287void GWEN_Text_DumpString2Buffer(const char *s, unsigned int l,
288 GWEN_BUFFER *mbuf,
289 unsigned int insert);
290
292void GWEN_Text_LogString(const char *s, unsigned int l,
293 const char *logDomain,
295
296
303
304
312int GWEN_Text_CountUtf8Chars(const char *s, int len);
313
314
320int GWEN_Text_EscapeXmlToBuffer(const char *src, GWEN_BUFFER *buf);
321
327
328
345double GWEN_Text_CheckSimilarity(const char *s1, const char *s2, int ign);
346
347
359int GWEN_Text_ConvertCharset(const char *fromCharset,
360 const char *toCharset,
361 const char *text, int len,
362 GWEN_BUFFER *tbuf);
363
364
365
366
367
368typedef int GWENHYWFAR_CB(*GWEN_TEXT_REPLACE_VARS_CB)(void *cbPtr, const char *name, int index, int maxLen,
369 GWEN_BUFFER *dstBuf);
370
371
377int GWEN_Text_ReplaceVars(const char *s, GWEN_BUFFER *dbuf, GWEN_TEXT_REPLACE_VARS_CB fn, void *ptr);
378
379
380
381#ifdef __cplusplus
382}
383#endif
384
385
386#endif
387
388
389
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
#define GWENHYWFAR_API
Definition: gwenhywfarapi.h:67
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
GWEN_LOGGER_LEVEL
Definition: logger.h:64
GWENHYWFAR_API int GWEN_Text_ToHexBuffer(const char *src, unsigned l, GWEN_BUFFER *buf, unsigned int groupsize, char delimiter, int skipLeadingZeroes)
GWENHYWFAR_API int GWEN_Text_FromHexBuffer(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API int GWEN_Text_NumToString(int num, char *buffer, unsigned int bufsize, int fillchar)
GWENHYWFAR_API int GWEN_Text_EscapeToBufferTolerant2(GWEN_BUFFER *src, GWEN_BUFFER *buf)
GWENHYWFAR_API const char * GWEN_Text_StrCaseStr(const char *haystack, const char *needle)
GWENHYWFAR_API char * GWEN_Text_Unescape(const char *src, char *buffer, unsigned int maxsize)
GWENHYWFAR_API char * GWEN_Text_UnescapeTolerantN(const char *src, unsigned int srclen, char *buffer, unsigned int maxsize)
GWENHYWFAR_API int GWEN_Text_ToBcdBuffer(const char *src, unsigned l, GWEN_BUFFER *buf, unsigned int groupsize, char delimiter, int skipLeadingZeroes)
GWENHYWFAR_API int GWEN_Text_ComparePattern(const char *w, const char *p, int sensecase)
int GWENHYWFAR_CB(* GWEN_TEXT_REPLACE_VARS_CB)(void *cbPtr, const char *name, int index, int maxLen, GWEN_BUFFER *dstBuf)
Definition: text.h:368
GWENHYWFAR_API int GWEN_Text_ReplaceVars(const char *s, GWEN_BUFFER *dbuf, GWEN_TEXT_REPLACE_VARS_CB fn, void *ptr)
GWENHYWFAR_API int GWEN_Text_UnescapeToBufferTolerant(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API int GWEN_Text_Compare(const char *s1, const char *s2, int ign)
GWENHYWFAR_API int GWEN_Text_ConvertCharset(const char *fromCharset, const char *toCharset, const char *text, int len, GWEN_BUFFER *tbuf)
GWENHYWFAR_API int GWEN_Text_GetWordToBuffer(const char *src, const char *delims, GWEN_BUFFER *buf, uint32_t flags, const char **next)
GWENHYWFAR_API int GWEN_Text_StringToDouble(const char *s, double *num)
GWENHYWFAR_API char * GWEN_Text_GetWord(const char *src, const char *delims, char *buffer, unsigned int maxsize, uint32_t flags, const char **next)
GWENHYWFAR_API char * GWEN_Text_strndup(const char *s, size_t n)
GWENHYWFAR_API int GWEN_Text_UnescapeToBuffer(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API int GWEN_Text_EscapeToBufferTolerant(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API char * GWEN_Text_ToHex(const char *src, unsigned l, char *buffer, unsigned int maxsize)
GWENHYWFAR_API void GWEN_Text_DumpString(const char *s, unsigned int l, unsigned int insert)
GWENHYWFAR_API double GWEN_Text_CheckSimilarity(const char *s1, const char *s2, int ign)
GWENHYWFAR_API char * GWEN_Text_UnescapeN(const char *src, unsigned int srclen, char *buffer, unsigned int maxsize)
GWENHYWFAR_API void GWEN_Text_DumpString2Buffer(const char *s, unsigned int l, GWEN_BUFFER *mbuf, unsigned int insert)
GWENHYWFAR_API int GWEN_Text_DoubleToBuffer(double num, GWEN_BUFFER *buf)
GWENHYWFAR_API int GWEN_Text_EscapeXmlToBuffer(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API char * GWEN_Text_ToHexGrouped(const char *src, unsigned l, char *buffer, unsigned maxsize, unsigned int groupsize, char delimiter, int skipLeadingZeros)
GWENHYWFAR_API void GWEN_Text_CondenseBuffer(GWEN_BUFFER *buf)
GWENHYWFAR_API int GWEN_Text_FromBcdBuffer(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API char * GWEN_Text_UnescapeTolerant(const char *src, char *buffer, unsigned int maxsize)
GWENHYWFAR_API void GWEN_Text_LogString(const char *s, unsigned int l, const char *logDomain, GWEN_LOGGER_LEVEL lv)
GWENHYWFAR_API int GWEN_Text_CountUtf8Chars(const char *s, int len)
GWENHYWFAR_API char * GWEN_Text_EscapeTolerant(const char *src, char *buffer, unsigned int maxsize)
GWENHYWFAR_API int GWEN_Text_UnescapeXmlToBuffer(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API char * GWEN_Text_Escape(const char *src, char *buffer, unsigned int maxsize)
GWENHYWFAR_API int GWEN_Text_EscapeToBuffer(const char *src, GWEN_BUFFER *buf)
GWENHYWFAR_API int GWEN_Text_FromHex(const char *src, char *buffer, unsigned maxsize)