Project

General

Profile

« Previous | Next » 

Revision 2407

Added by stephane over 13 years ago

UTILS_G
- PCRE (regex)
- - add _pcreEasyMatch, _pcreEasySplit, _pcreEasyReplace
- - add _pcreNormalMatch, _pcreNormalSplit

View differences:

utils_g.cbp
1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2
<CodeBlocks_project_file>
3
	<FileVersion major="1" minor="6" />
4
	<Project>
5
		<Option title="utils_g" />
6
		<Option pch_mode="2" />
7
		<Option compiler="gcc" />
8
		<Build>
9
			<Target title="Debug">
10
				<Option output="bin\Debug\libutils_g" prefix_auto="1" extension_auto="1" />
11
				<Option object_output="obj\Debug\" />
12
				<Option type="3" />
13
				<Option compiler="gcc" />
14
				<Option createDefFile="1" />
15
				<Option createStaticLib="1" />
16
				<Compiler>
17
					<Add option="-g" />
18
				</Compiler>
19
			</Target>
20
			<Target title="Release">
21
				<Option output="bin\libutils_g" prefix_auto="1" extension_auto="1" />
22
				<Option object_output="obj\" />
23
				<Option type="3" />
24
				<Option compiler="gcc" />
25
				<Option createDefFile="1" />
26
				<Option createStaticLib="1" />
27
				<Compiler>
28
					<Add option="-O2" />
29
				</Compiler>
30
				<Linker>
31
					<Add option="-s" />
32
				</Linker>
33
			</Target>
34
		</Build>
35
		<Compiler>
36
			<Add option="-Wall" />
37
		</Compiler>
38
		<Unit filename="main.c">
39
			<Option compilerVar="CC" />
40
		</Unit>
41
		<Extensions>
42
			<code_completion />
43
			<debugger />
44
		</Extensions>
45
	</Project>
46
</CodeBlocks_project_file>
include/macros.h
68 68
/* #define CHAR2WCHAR(c)        (c == NIL ? NULL : (PtrObjWChar) MMstart (mm,((PtrObjVoid)MMstart(mm,c))->Buffer>>1))*/
69 69

  
70 70
/* $Iri : convert any string to utf-8 (should be used with gtk ...) Don't forget to free after used !*/
71
#define SCOLUTF8(string) g_locale_to_utf8 (string, -1, NULL, NULL, NULL)
71
#define SCOLUTF8(string, len) g_locale_to_utf8 (string, len, NULL, NULL, NULL)
72 72
/* $Iri : convert any string from utf-8 Don't forget to free after used !*/
73
#define UTF8SCOL(string) g_locale_from_utf8 (string, -1, NULL, NULL, NULL)
73
#define UTF8SCOL(string, len) g_locale_from_utf8 (string, len, NULL, NULL, NULL)
74 74
/* $Iri : length of the int (234 -> 3)*/
75 75
#define SIZEINT(x)  floor (log10 (x)) + 1
76 76
/* $ Iri : float support */
include/scol_glib_pregex.h
21 21
For others informations, please contact us from http://www.scolring.org/
22 22
*/
23 23

  
24
#ifndef __SCOL_GTK_MISC_H__
25
#define __SCOL_GTK_MISC_H__
24
#ifndef __SCOL_GLIB_PREGEX_H__
25
#define __SCOL_GLIB_PREGEX_H__
26 26

  
27
#include "main.h"
27
#include <stdio.h>
28
#include <stdlib.h>
29
#include <string.h>
30
#include <math.h>
31
#include <libgen.h>
32
#include <glib.h>
28 33

  
29
#define GLIB_PCRE_PKG_NB         1
34
#if ((defined __WIN32__) || (defined WIN32))
35
#include <windows.h>
36
#include "scol_plugin_win.h"
37
#else
38
#include "scol_plugin_lin.h"
39
#endif
40

  
41
#include "macros.h"
30 42

  
31
#endif  /* __SCOL_GTK_MISC_H__ */
43

  
44

  
45
#define bullshit int (__cdecl *)(struct Mmachine *)
46

  
47
#define GLIB_PCRE_PKG_NB         30
48
#define DEFAULT_STRING   "Untitle"
49

  
50

  
51
#define PCRE_MATCH_STANDARD     1
52
#define PCRE_MATCH_DFA          2
53

  
54
#define PCRE_MATCH_ANCHORED       1<<4
55
#define PCRE_MATCH_NOTBOL         1<<7
56
#define PCRE_MATCH_NOTEOL         1<<8
57
#define PCRE_MATCH_NOTEMPTY       1<<10
58
#define PCRE_MATCH_PARTIAL        1<<15
59
#define PCRE_MATCH_NEWLINE_CR     1<<20
60
#define PCRE_MATCH_NEWLINE_LF     1<<21
61
#define PCRE_MATCH_NEWLINE_CRLF   PCRE_MATCH_NEWLINE_CR | PCRE_MATCH_NEWLINE_LF
62
#define PCRE_MATCH_NEWLINE_ANY    1<<22
63

  
64
#define PCRE_REGEX_CASELESS          1 << 0
65
#define PCRE_REGEX_MULTILINE         1 << 1
66
#define PCRE_REGEX_DOTALL            1 << 2
67
#define PCRE_REGEX_EXTENDED          1 << 3
68
#define PCRE_REGEX_ANCHORED          1 << 4
69
#define PCRE_REGEX_DOLLAR_ENDONLY    1 << 5
70
#define PCRE_REGEX_UNGREEDY          1 << 9
71
#define PCRE_REGEX_RAW               1 << 11
72
#define PCRE_REGEX_NO_AUTO_CAPTURE   1 << 12
73
#define PCRE_REGEX_OPTIMIZE          1 << 13
74
#define PCRE_REGEX_DUPNAMES          1 << 19
75
#define PCRE_REGEX_NEWLINE_CR        1 << 20
76
#define PCRE_REGEX_NEWLINE_LF        1 << 21
77
#define PCRE_REGEX_NEWLINE_CRLF      PCRE_REGEX_NEWLINE_CR | PCRE_REGEX_NEWLINE_LF
78

  
79

  
80

  
81

  
82

  
83

  
84
int PcreRelease ();
85
int SCOLinitPcreClass (mmachine m);
86
int SCOL_pcreEasyMatch (mmachine m);
87
int SCOL_pcreEasySplit (mmachine m);
88
int SCOL_pcreEasyReplace (mmachine m);
89
int SCOL_pcreNormalMatch (mmachine m);
90
int SCOL_pcreNormalSplit (mmachine m);
91
int SCOL_pcreNormalReplace (mmachine m);
92

  
93
GRegex * scol_pcre_regex_new (const gchar * pattern, GRegexCompileFlags compile, GRegexMatchFlags match);
94
void scol_pcre_match_standard (mmachine m, const gchar *pattern, const gchar *string, GRegexCompileFlags compile, GRegexMatchFlags match, gint start);
95
void scol_pcre_match_DFA (mmachine m, const gchar *pattern, const gchar *string, GRegexCompileFlags compile, GRegexMatchFlags match, gint start);
96

  
97

  
98
#if ((defined _WIN32) || (defined __WIN32__))
99
__declspec (dllexport) int SCOLloadPCRE (mmachine m, cbmachine w);
100
__declspec (dllexport) int SCOLfreePCRE ();
101
#else
102
int SCOLloadPCRE (mmachine m);
103
int SCOLfreePCRE ();
104
#endif
105

  
106
#endif  /* __SCOL_GLIB_PREGEX_H__ */
pcre.layout
1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2
<CodeBlocks_layout_file>
3
	<ActiveTarget name="Release" />
4
	<File name="include\scol_glib_pregex.h" open="1" top="0" tabpos="1">
5
		<Cursor position="1425" topLine="24" />
6
	</File>
7
	<File name="src\scol_glib_pregex.c" open="1" top="1" tabpos="2">
8
		<Cursor position="2719" topLine="96" />
9
	</File>
10
</CodeBlocks_layout_file>
src/scol_glib_pregex.c
21 21
For others informations, please contact us from http://www.scolring.org/
22 22
*/
23 23

  
24
#ifdef __cplusplus
25
#error This source file is not C++ but rather C. Please use a C-compiler
26
#endif
24 27

  
28

  
29

  
25 30
#include "../include/scol_glib_pregex.h"
31

  
32
/* http://library.gnome.org/devel/glib/unstable/glib-Perl-compatible-regular-expressions.html */
33

  
34
#if ((defined _WIN32) || (defined __WIN32__))
35
cbmachine ww;
36
#endif
37
mmachine  mm;
38

  
39
/*
40
    Easy interface
41

  
42
    - SCOL_pcreEasyMatch
43
    - SCOL_pcreEasySplit
44
    - SCOL_pcreEasyReplace
45
*/
46

  
47

  
48
/**
49
 * \brief Scans for a match in string for pattern
50
 * \param : S : pattern : the regular expression
51
 * \param : S : string : the string to scan for matches
52
 * \return : I : 1 if matched, else 0 (or nil if string or pattern is nil)
53
 *
54
 * The compile options for the regular expression are at 0
55
 * The match options ara at 0 too
56
 */
57
int SCOL_pcreEasyMatch (mmachine m)
58
{
59
    int mpattern, mstring;
60
    gchar *pattern, *string;
61

  
62
    MMechostr (MSKDEBUG, "SCOL_pcreEasyMatch : entering\n");
63

  
64
    mstring = MTOP (MMpull (m));
65
    mpattern = MTOP (MMpull (m));
66

  
67
    if((mstring == NIL) || (mpattern == NIL))
68
    {
69
        MMechostr (0, "SCOL_pcreEasyMatch error : an argument is nil");
70
        MMpush (m, NIL);
71
        return 0;
72
    }
73
    pattern = SCOLUTF8 (MMstartstr (m, mpattern), MMsizestr (m, mpattern));
74
    string = SCOLUTF8 (MMstartstr (m, mstring), MMsizestr (m, mstring));
75

  
76
    MMpush (m, ITOM (g_regex_match_simple (pattern, string, 0, 0)));
77
    g_free (pattern);
78
    g_free (string);
79
    return 0;
80
}
81

  
82
/**
83
 * \brief Breaks the string on the pattern, and returns an list of the tokens.
84
 * \param : S : pattern : the regular expression
85
 * \param : S : string : the string to scan for matches
86
 * \return : [S r1] : a list of substrings or nil
87
 *
88
 * The compile options for the regular expression are at 0
89
 * The match options ara at 0 too
90
 */
91
int SCOL_pcreEasySplit (mmachine m)
92
{
93
    int mpattern, mstring;
94
    int i = 0;
95
    gchar *pattern, *string;
96
    gchar **result;
97

  
98
    MMechostr (MSKDEBUG, "SCOL_pcreEsaySplit : entering\n");
99

  
100
    mstring = MTOP (MMpull (m));
101
    mpattern = MTOP (MMpull (m));
102

  
103
    if (mstring == NIL)
104
    {
105
        MMechostr (0, "SCOL_pcreEsaySplit error : an argument is nil");
106
        MMpush (m, NIL);
107
        return 0;
108
    }
109
    if (mpattern == NIL)
110
    {
111
        Mpushstrbloc (m, MMstartstr (m, mstring));
112
        MMpush (m, NIL);
113
        MMpush (m, ITOM (2));
114
        MBdeftab (m);
115
        return 0;
116
    }
117

  
118
    pattern = SCOLUTF8 (MMstartstr (m, mpattern), MMsizestr (m, mpattern));
119
    string = SCOLUTF8 (MMstartstr (m, mstring), MMsizestr (m, mstring));
120

  
121
    result = g_regex_split_simple (pattern, string, 0, 0);
122
    while (result[i] != NULL)
123
    {
124
        Mpushstrbloc (m, UTF8SCOL (result[i], strlen (result[i])));
125
        i++;
126
    }
127
    g_strfreev (result);
128
    g_free (pattern);
129
    g_free (string);
130
    MMpush (m, NIL);
131
    for (; i > 0; i--)
132
    {
133
        MMpush (m, ITOM (2));
134
        MBdeftab (m);
135
    }
136
    return 0;
137
}
138

  
139
/**
140
 * \brief Replaces all occurrences of the pattern in string with a replacement text
141
 * \param S : pattern
142
 * \param S : string
143
 * \param S : replacement text
144
 * \return S : new string containing the replacements
145
 */
146
int SCOL_pcreEasyReplace (mmachine m)
147
{
148
    int mpattern, mstring, mreplace;
149
    GRegex *regex;
150
    gchar *result;
151
    gchar *pattern, *string, *replace;
152

  
153
    MMechostr (MSKDEBUG, "SCOL_pcreEasyReplace : entering\n");
154

  
155
    mreplace = MTOP (MMpull (m));
156
    mstring = MTOP (MMpull (m));
157
    mpattern = MTOP (MMpull (m));
158

  
159
    if(mstring == NIL)
160
    {
161
        MMechostr (0, "SCOL_pcreEasyReplace error : an argument is nil");
162
        MMpush (m, NIL);
163
        return 0;
164
    }
165
    if ((mreplace == NIL) || (mpattern == NIL))
166
    {
167
        Mpushstrbloc (m, MMstartstr (m, mstring));
168
        return 0;
169
    }
170

  
171
    pattern = SCOLUTF8 (MMstartstr (m, mpattern), MMsizestr (m, mpattern));
172
    string = SCOLUTF8 (MMstartstr (m, mstring), MMsizestr (m, mstring));
173
    replace = SCOLUTF8 (MMstartstr (m, mreplace), MMsizestr (m, mreplace));
174

  
175
    regex = scol_pcre_regex_new (pattern, 0, 0);
176
    result = g_regex_replace (regex, string, strlen (string), 0, replace, 0, NULL);
177
    result = UTF8SCOL (result, strlen (result));
178
    Mpushstrbloc (m, result);
179
    g_free (result);
180
    g_regex_unref (regex);
181
    g_free (pattern);
182
    g_free (string);
183
    g_free (replace);
184
    return 0;
185
}
186

  
187

  
188
/*
189
    Normal interface
190

  
191
    - SCOL_pcreNormalMatch
192
    - SCOL_pcreNormalSplit
193
*/
194

  
195
int SCOL_pcreNormalMatch (mmachine m)
196
{
197
    int mpattern, mstring, mcompile, mstart, mmatch, malgo;
198
    gchar * pattern, *string;
199

  
200
    MMechostr (MSKDEBUG, "SCOL_pcreNormalMatch : entering\n");
201

  
202
    malgo = MTOI (MMpull (m));
203
    mmatch = MMpull (m);
204
    mstart = MTOI (MMpull (m));
205
    mcompile = MMpull (m);
206
    mstring = MTOP (MMpull (m));
207
    mpattern = MTOP (MMpull (m));
208

  
209
    if ((mstring == NIL) || (mpattern == NIL))
210
    {
211
        MMechostr (0, "SCOL_pcreNormalMatch error : string or pattern is nil\n");
212
        MMpush (m, NIL);
213
        return 0;
214
    }
215

  
216
    if (mstart< 0)
217
        mstart = 0;
218

  
219
    if (malgo != PCRE_MATCH_DFA)
220
        malgo = PCRE_MATCH_STANDARD;
221

  
222
    if (mcompile == NIL)
223
        mcompile = 0;
224

  
225
    if (mmatch == NIL)
226
        mmatch = 0;
227

  
228
    pattern = SCOLUTF8 (MMstartstr (m, mpattern), MMsizestr (m, mpattern));
229
    string = SCOLUTF8 (MMstartstr (m, mstring), MMsizestr (m, mstring));
230

  
231
    if (malgo == PCRE_MATCH_STANDARD)
232
        scol_pcre_match_standard (m, pattern, string, mcompile, mmatch, mstart);
233
    else
234
        scol_pcre_match_DFA (m, pattern, string, mcompile, mmatch, mstart);
235

  
236
    g_free (pattern);
237
    g_free (string);
238
    return 0;
239
}
240

  
241
int SCOL_pcreNormalSplit (mmachine m)
242
{
243
    int mpattern, mstring, mcompile, mstart, mmax, mmatch;
244
    int i = 0;
245
    gchar *pattern, *string;
246
    GRegex *regex;
247
    GError *error = NULL;
248
    gchar **result;
249

  
250
    MMechostr (MSKDEBUG, "SCOL_pcreNormalSplit : entering\n");
251

  
252
    mmax = MTOI (MMpull (m));
253
    mmatch = MMpull (m);
254
    mstart = MTOI (MMpull (m));
255
    mcompile = MMpull (m);
256
    mstring = MTOP (MMpull (m));
257
    mpattern = MTOP (MMpull (m));
258

  
259
    if ((mstring == NIL) || (mpattern == NIL))
260
    {
261
        MMechostr (0, "SCOL_pcreNormalSplit error : string or pattern is nil\n");
262
        MMpush (m, NIL);
263
        return 0;
264
    }
265

  
266
    if (mstart < 0)
267
        mstart = 0;
268
    if (mcompile == NIL)
269
        mcompile = 0;
270
    if (mmatch == NIL)
271
        mmatch = 0;
272

  
273
    pattern = SCOLUTF8 (MMstartstr (m, mpattern), MMsizestr (m, mpattern));
274
    string = SCOLUTF8 (MMstartstr (m, mstring), MMsizestr (m, mstring));
275

  
276
    regex = scol_pcre_regex_new (pattern, mcompile, mmatch);
277
    result = g_regex_split_full (regex, string, strlen (string), mstart, mmatch, mmax, &error);
278
    g_regex_unref (regex);
279
    if (error != NULL)
280
    {
281
        MMechostr (0, "SCOL_pcreNormalSplit error : %s\n", error->message);
282
        MMpush (m, NIL);
283
        g_error_free (error);
284
    }
285

  
286
    while (result[i] != NULL)
287
    {
288
        Mpushstrbloc (m, UTF8SCOL (result[i], strlen (result[i])));
289
        i++;
290
    }
291
    g_strfreev (result);
292
    g_free (pattern);
293
    g_free (string);
294
    MMpush (m, NIL);
295
    for (; i > 0; i--)
296
    {
297
        MMpush (m, ITOM (2));
298
        MBdeftab (m);
299
    }
300
    return 0;
301
}
302

  
303
int SCOL_pcreNormalReplace (mmachine m)
304
{
305
    return 0;
306
}
307

  
308

  
309

  
310

  
311
/*
312
    Internals functions
313
    - scol_pcre_regex_new
314
        GRegex * scol_pcre_regex_new (const gchar *, GRegexCompileFlags, GRegexMatchFlags);
315
        Create a new regular expression
316

  
317
    - scol_pcre_match_standard
318
        void scol_pcre_match_full (mmachine, const gchar *, const gchar *, GRegexCompileFlags  GRegexMatchFlags, gint)
319

  
320
    - scol_pcre_match_DFA
321
        void scol_pcre_match_DFA (mmachine m, const gchar *pattern, const gchar *string, GRegexCompileFlags compile, GRegexMatchFlags match, gint start)
322

  
323
*/
324

  
325
GRegex * scol_pcre_regex_new (const gchar * pattern, GRegexCompileFlags compile, GRegexMatchFlags match)
326
{
327
    return g_regex_new (pattern, compile, match, NULL);
328
}
329

  
330

  
331
void scol_pcre_match_standard (mmachine m, const gchar *pattern, const gchar *string, GRegexCompileFlags compile, GRegexMatchFlags match, gint start)
332
{
333
    GRegex *regex;
334
    GMatchInfo *match_info;
335
    GError *error = NULL;
336
    gchar *word;
337
    gboolean r;
338
    int i, n = 0;
339
    gint pos1 = -1, pos2 = -1;
340

  
341
    regex = scol_pcre_regex_new (pattern, compile, match);
342

  
343
    r = g_regex_match_full (regex, string, strlen (string), start, match, &match_info, &error);
344
    while (g_match_info_matches (match_info))
345
    {
346
        word = g_match_info_fetch (match_info, 0);
347
        g_match_info_fetch_pos (match_info, 0, &pos1, &pos2);
348
        Mpushstrbloc (m, word);
349
        MMpush (m, ITOM (pos1));
350
        MMpush (m, ITOM (pos2));
351
        MMpush (m, ITOM (3));
352
        MBdeftab (m);
353
        g_free (word);
354
        pos1 = -1; pos2 = -1;
355
        g_match_info_next (match_info, &error);
356
        n++;
357
    }
358

  
359
    g_match_info_free (match_info);
360
    g_regex_unref (regex);
361
    if (error != NULL)
362
    {
363
        MMechostr (0, "scol_pcre_match_standard error : %s\n", error->message);
364
        g_error_free (error);
365
    }
366
    MMpush (m, NIL);
367
    for (i = 0; i < n; i++)
368
    {
369
        MMpush (m, ITOM (2));
370
        MBdeftab (m);
371
    }
372
    return;
373
}
374

  
375
void scol_pcre_match_DFA (mmachine m, const gchar *pattern, const gchar *string, GRegexCompileFlags compile, GRegexMatchFlags match, gint start)
376
{
377
    GRegex *regex;
378
    GMatchInfo *match_info;
379
    GError *error = NULL;
380
    gchar *word;
381
    gboolean r;
382
    int i, n = 0;
383
    gint pos1 = -1, pos2 = -1;
384

  
385
    regex = scol_pcre_regex_new (pattern, compile, match);
386

  
387
    r = g_regex_match_all_full (regex, string, strlen (string), start, match, &match_info, &error);
388
    while (g_match_info_matches (match_info))
389
    {
390
        word = g_match_info_fetch (match_info, 0);
391
        g_match_info_fetch_pos (match_info, 0, &pos1, &pos2);
392
        Mpushstrbloc (m, word);
393
        MMpush (m, ITOM (pos1));
394
        MMpush (m, ITOM (pos2));
395
        MMpush (m, ITOM (3));
396
        MBdeftab (m);
397
        g_free (word);
398
        pos1 = -1; pos2 = -1;
399
        g_match_info_next (match_info, &error);
400
        n++;
401
    }
402

  
403
    g_match_info_free (match_info);
404
    g_regex_unref (regex);
405
    if (error != NULL)
406
    {
407
        MMechostr (0, "scol_pcre_match_DFA error : %s\n", error->message);
408
        g_error_free (error);
409
    }
410
    MMpush (m, NIL);
411
    for (i = 0; i < n; i++)
412
    {
413
        MMpush (m, ITOM (2));
414
        MBdeftab (m);
415
    }
416
    return;
417
}
418

  
419

  
420

  
421

  
422
/* API definitions : */
423

  
424
char* glib_pcre_name[GLIB_PCRE_PKG_NB]=
425
{
426
    "PCRE_MATCH_STANDARD", "PCRE_MATCH_DFA",
427

  
428
    "PCRE_MATCH_ANCHORED", "PCRE_MATCH_NOTBOL", "PCRE_MATCH_NOTEOL",
429
    "PCRE_MATCH_NOTEMPTY", "PCRE_MATCH_PARTIAL", "PCRE_MATCH_NEWLINE_CR",
430
    "PCRE_MATCH_NEWLINE_LF", "PCRE_MATCH_NEWLINE_CRLF", "PCRE_MATCH_NEWLINE_ANY",
431

  
432
    "PCRE_REGEX_CASELESS", "PCRE_REGEX_MULTILINE", "PCRE_REGEX_DOTALL",
433
    "PCRE_REGEX_EXTENDED", "PCRE_REGEX_ANCHORED", "PCRE_REGEX_DOLLAR_ENDONLY",
434
    "PCRE_REGEX_UNGREEDY", "PCRE_REGEX_RAW", "PCRE_REGEX_NO_AUTO_CAPTURE",
435
    "PCRE_REGEX_OPTIMIZE", "PCRE_REGEX_DUPNAMES", "PCRE_REGEX_NEWLINE_CR",
436
    "PCRE_REGEX_NEWLINE_LF", "PCRE_REGEX_NEWLINE_CRLF",
437

  
438
    "_pcreEasyMatch",
439
    "_pcreEasySplit",
440
    "_pcreEasyReplace",
441

  
442
    "_pcreNormalMatch",
443
    "_pcreNormalSplit"
444
};
445

  
446
int (*glib_pcre_fun[GLIB_PCRE_PKG_NB])(mmachine m)=
447
{
448
    (bullshit) (1*2), (bullshit) (2*2),
449

  
450
    (bullshit) (1<<4), (bullshit) (1<<7), (bullshit) (1<<8),
451
    (bullshit) (1<<10), (bullshit) (1<<15), (bullshit) (1<<20),
452
    (bullshit) (1<<21), (bullshit) (1<<20|1<<21), (bullshit) (1<<22),
453

  
454
    (bullshit) (1<<0), (bullshit) (1<<1), (bullshit) (1<<2),
455
    (bullshit) (1<<3), (bullshit) (1<<4), (bullshit) (1<<5),
456
    (bullshit) (1<<9), (bullshit) (1<<11), (bullshit) (1<<12),
457
    (bullshit) (1<<13), (bullshit) (1<<19), (bullshit) (1<<20),
458
    (bullshit) (1<<21), (bullshit) (1<<20|1<<21),
459

  
460
    SCOL_pcreEasyMatch,
461
    SCOL_pcreEasySplit,
462
    SCOL_pcreEasyReplace,
463

  
464
    SCOL_pcreNormalMatch,
465
    SCOL_pcreNormalSplit
466
};
467

  
468
int glib_pcre_narg[GLIB_PCRE_PKG_NB]=
469
{
470
    TYPVAR, TYPVAR,
471

  
472
    TYPVAR, TYPVAR, TYPVAR,
473
    TYPVAR, TYPVAR, TYPVAR,
474
    TYPVAR, TYPVAR, TYPVAR,
475

  
476
    TYPVAR, TYPVAR, TYPVAR,
477
    TYPVAR, TYPVAR, TYPVAR,
478
    TYPVAR, TYPVAR, TYPVAR,
479
    TYPVAR, TYPVAR, TYPVAR,
480
    TYPVAR, TYPVAR,
481

  
482
    2,
483
    2,
484
    3,
485

  
486
    6,
487
    6
488
};
489

  
490
char* glib_pcre_type[GLIB_PCRE_PKG_NB]=
491
{
492
    "I", "I",
493

  
494
    "I", "I", "I",
495
    "I", "I", "I",
496
    "I", "I", "I",
497

  
498
    "I", "I", "I",
499
    "I", "I", "I",
500
    "I", "I", "I",
501
    "I", "I", "I",
502
    "I", "I",
503

  
504
    "fun [S S] I",
505
    "fun [S S] [S r1]",
506
    "fun [S S S] S",
507

  
508
    "fun [S S I I I I] [[S I I] r1]",
509
    "fun [S S I I I I] [S r1]"
510
};
511

  
512
/**
513
 * \brief Load the Scol api
514
 */
515
int SCOLinitPcreClass (mmachine m)
516
{
517
    int k;
518

  
519
    MMechostr (0, "SCOLinitPcreClass : entering\n");
520

  
521
    k = PKhardpak (m, "PCREengine", GLIB_PCRE_PKG_NB, glib_pcre_name, glib_pcre_fun, glib_pcre_narg, glib_pcre_type);
522
    return k;
523
}
524

  
525

  
526
/**
527
 * \brief Load and free the regular expression library
528
 * Plateforms supported : MS Windows and GNU / Linux
529
 */
530

  
531
int PcreRelease ()
532
{
533
    MMechostr (0, "\nPCRE library released !\n");
534
    return 0;
535
}
536

  
537
#if ((defined _WIN32) || (defined __WIN32__))
538

  
539
__declspec (dllexport) int SCOLloadPCRE (mmachine m, cbmachine w)
540
{
541
    int k = 0;
542
    ww = w;
543
    mm = m;
544

  
545
    MMechostr (MSKDEBUG, "\nPCRE library loading .... !\n");
546
    SCOLinitplugin (w);
547
    if ((k = SCOLinitPcreClass (m))) return k;
548
    MMechostr(MSKDEBUG, "\nPCRE library loaded !\n");
549
    return k;
550
}
551

  
552
__declspec (dllexport) int SCOLfreePCRE ()
553
{
554
    PcreRelease ();
555
    return 0;
556
}
557

  
558

  
559

  
560

  
561

  
562
/* Version GNU / Linux */
563
#elif ((defined linux) || (defined __linux))
564

  
565
int SCOLloadPCRE (mmachine m)
566
{
567
    int k = 0;
568
    mm = m;
569

  
570
    MMechostr (MSKDEBUG, "\nPCRE library loading !\n");
571
    if ((k = SCOLinitPcreClass (m))) return k;
572
    MMechostr (MSKDEBUG, "\nPCRE library loaded !\n");
573

  
574
    return k;
575
}
576

  
577
int SCOLfreePCRE ()
578
{
579
    MMechostr(MSKDEBUG, "\nPCRE library release !\n");
580

  
581
    PcreRelease ();
582
    return 0;
583
}
584

  
585
#else
586
#error no platform supported
587
#endif
pcre.depend
1
# depslib dependency file v1.0
2
1298416589 source:x:\utils_g\src\scol_glib_misc.c
3
	"../include/scol_glib_misc.h"
4

  
5
1298416599 x:\utils_g\include\scol_glib_misc.h
6
	<glib.h>
7

  
8
1293381426 c:\mingw\include\glib-2.0\glib.h
9
	<glib/galloca.h>
10
	<glib/garray.h>
11
	<glib/gasyncqueue.h>
12
	<glib/gatomic.h>
13
	<glib/gbacktrace.h>
14
	<glib/gbase64.h>
15
	<glib/gbitlock.h>
16
	<glib/gbookmarkfile.h>
17
	<glib/gcache.h>
18
	<glib/gchecksum.h>
19
	<glib/gcompletion.h>
20
	<glib/gconvert.h>
21
	<glib/gdataset.h>
22
	<glib/gdate.h>
23
	<glib/gdatetime.h>
24
	<glib/gdir.h>
25
	<glib/gerror.h>
26
	<glib/gfileutils.h>
27
	<glib/ghash.h>
28
	<glib/ghook.h>
29
	<glib/ghostutils.h>
30
	<glib/giochannel.h>
31
	<glib/gkeyfile.h>
32
	<glib/glist.h>
33
	<glib/gmacros.h>
34
	<glib/gmain.h>
35
	<glib/gmappedfile.h>
36
	<glib/gmarkup.h>
37
	<glib/gmem.h>
38
	<glib/gmessages.h>
39
	<glib/gnode.h>
40
	<glib/goption.h>
41
	<glib/gpattern.h>
42
	<glib/gpoll.h>
43
	<glib/gprimes.h>
44
	<glib/gqsort.h>
45
	<glib/gquark.h>
46
	<glib/gqueue.h>
47
	<glib/grand.h>
48
	<glib/grel.h>
49
	<glib/gregex.h>
50
	<glib/gscanner.h>
51
	<glib/gsequence.h>
52
	<glib/gshell.h>
53
	<glib/gslice.h>
54
	<glib/gslist.h>
55
	<glib/gspawn.h>
56
	<glib/gstrfuncs.h>
57
	<glib/gstring.h>
58
	<glib/gtestutils.h>
59
	<glib/gthread.h>
60
	<glib/gthreadpool.h>
61
	<glib/gtimer.h>
62
	<glib/gtimezone.h>
63
	<glib/gtree.h>
64
	<glib/gtypes.h>
65
	<glib/gunicode.h>
66
	<glib/gurifuncs.h>
67
	<glib/gutils.h>
68
	<glib/gvarianttype.h>
69
	<glib/gvariant.h>
70
	<glib/gwin32.h>
71

  
72
1293381427 c:\mingw\include\glib-2.0\glib\galloca.h
73
	<glib/gtypes.h>
74
	<alloca.h>
75
	<malloc.h>
76

  
77
1293381427 c:\mingw\include\glib-2.0\glib\gtypes.h
78
	<glibconfig.h>
79
	<glib/gmacros.h>
80

  
81
1293381426 c:\mingw\lib\glib-2.0\include\glibconfig.h
82
	<glib/gmacros.h>
83
	<limits.h>
84
	<float.h>
85

  
86
1293381427 c:\mingw\include\glib-2.0\glib\gmacros.h
87
	<stddef.h>
88

  
89
1293381427 c:\mingw\include\glib-2.0\glib\garray.h
90
	<glib/gtypes.h>
91

  
92
1293381427 c:\mingw\include\glib-2.0\glib\gasyncqueue.h
93
	<glib/gthread.h>
94

  
95
1293381427 c:\mingw\include\glib-2.0\glib\gthread.h
96
	<glib/gerror.h>
97
	<glib/gutils.h>
98
	<glib/gatomic.h>
99

  
100
1293381427 c:\mingw\include\glib-2.0\glib\gerror.h
101
	<stdarg.h>
102
	<glib/gquark.h>
103

  
104
1293381427 c:\mingw\include\glib-2.0\glib\gquark.h
105
	<glib/gtypes.h>
106

  
107
1293381427 c:\mingw\include\glib-2.0\glib\gutils.h
108
	<glib/gtypes.h>
109
	<stdarg.h>
110

  
111
1293381427 c:\mingw\include\glib-2.0\glib\gatomic.h
112
	<glib/gtypes.h>
113

  
114
1293381427 c:\mingw\include\glib-2.0\glib\gbacktrace.h
115
	<glib/gtypes.h>
116
	<signal.h>
117

  
118
1293381427 c:\mingw\include\glib-2.0\glib\gbase64.h
119
	<glib/gtypes.h>
120

  
121
1293381427 c:\mingw\include\glib-2.0\glib\gbitlock.h
122
	<glib/gtypes.h>
123

  
124
1293381427 c:\mingw\include\glib-2.0\glib\gbookmarkfile.h
125
	<glib/gerror.h>
126
	<time.h>
127

  
128
1293381427 c:\mingw\include\glib-2.0\glib\gcache.h
129
	<glib/glist.h>
130

  
131
1293381427 c:\mingw\include\glib-2.0\glib\glist.h
132
	<glib/gmem.h>
133

  
134
1293381427 c:\mingw\include\glib-2.0\glib\gmem.h
135
	<glib/gslice.h>
136
	<glib/gtypes.h>
137

  
138
1293381427 c:\mingw\include\glib-2.0\glib\gslice.h
139
	<glib/gtypes.h>
140

  
141
1293381427 c:\mingw\include\glib-2.0\glib\gchecksum.h
142
	<glib/gtypes.h>
143

  
144
1293381427 c:\mingw\include\glib-2.0\glib\gcompletion.h
145
	<glib/glist.h>
146

  
147
1293381427 c:\mingw\include\glib-2.0\glib\gconvert.h
148
	<glib/gerror.h>
149

  
150
1293381427 c:\mingw\include\glib-2.0\glib\gdataset.h
151
	<glib/gquark.h>
152

  
153
1293381427 c:\mingw\include\glib-2.0\glib\gdate.h
154
	<time.h>
155
	<glib/gtypes.h>
156
	<glib/gquark.h>
157

  
158
1293381427 c:\mingw\include\glib-2.0\glib\gdatetime.h
159
	<glib/gtimezone.h>
160

  
161
1293381427 c:\mingw\include\glib-2.0\glib\gtimezone.h
162
	<glib/gtypes.h>
163

  
164
1293381427 c:\mingw\include\glib-2.0\glib\gdir.h
165
	<glib/gerror.h>
166

  
167
1293381427 c:\mingw\include\glib-2.0\glib\gfileutils.h
168
	<glib/gerror.h>
169

  
170
1293381427 c:\mingw\include\glib-2.0\glib\ghash.h
171
	<glib/gtypes.h>
172
	<glib/glist.h>
173

  
174
1293381427 c:\mingw\include\glib-2.0\glib\ghook.h
175
	<glib/gmem.h>
176

  
177
1293381427 c:\mingw\include\glib-2.0\glib\ghostutils.h
178
	<glib/gtypes.h>
179

  
180
1293381427 c:\mingw\include\glib-2.0\glib\giochannel.h
181
	<glib/gconvert.h>
182
	<glib/gmain.h>
183
	<glib/gstring.h>
184

  
185
1293381427 c:\mingw\include\glib-2.0\glib\gmain.h
186
	<glib/gpoll.h>
187
	<glib/gslist.h>
188
	<glib/gthread.h>
189

  
190
1293381427 c:\mingw\include\glib-2.0\glib\gpoll.h
191
	<glib/gtypes.h>
192

  
193
1293381427 c:\mingw\include\glib-2.0\glib\gslist.h
194
	<glib/gmem.h>
195

  
196
1293381427 c:\mingw\include\glib-2.0\glib\gstring.h
197
	<glib/gtypes.h>
198
	<glib/gunicode.h>
199
	<glib/gutils.h>
200

  
201
1293381427 c:\mingw\include\glib-2.0\glib\gunicode.h
202
	<glib/gerror.h>
203
	<glib/gtypes.h>
204

  
205
1293381427 c:\mingw\include\glib-2.0\glib\gkeyfile.h
206
	<glib/gerror.h>
207

  
208
1293381427 c:\mingw\include\glib-2.0\glib\gmappedfile.h
209
	<glib/gerror.h>
210

  
211
1293381427 c:\mingw\include\glib-2.0\glib\gmarkup.h
212
	<stdarg.h>
213
	<glib/gerror.h>
214
	<glib/gslist.h>
215

  
216
1293381427 c:\mingw\include\glib-2.0\glib\gmessages.h
217
	<stdarg.h>
218
	<glib/gtypes.h>
219
	<glib/gmacros.h>
220

  
221
1293381427 c:\mingw\include\glib-2.0\glib\gnode.h
222
	<glib/gmem.h>
223

  
224
1293381427 c:\mingw\include\glib-2.0\glib\goption.h
225
	<glib/gerror.h>
226
	<glib/gquark.h>
227

  
228
1293381427 c:\mingw\include\glib-2.0\glib\gpattern.h
229
	<glib/gtypes.h>
230

  
231
1293381427 c:\mingw\include\glib-2.0\glib\gprimes.h
232
	<glib/gtypes.h>
233

  
234
1293381427 c:\mingw\include\glib-2.0\glib\gqsort.h
235
	<glib/gtypes.h>
236

  
237
1293381427 c:\mingw\include\glib-2.0\glib\gqueue.h
238
	<glib/glist.h>
239

  
240
1293381427 c:\mingw\include\glib-2.0\glib\grand.h
241
	<glib/gtypes.h>
242

  
243
1293381427 c:\mingw\include\glib-2.0\glib\grel.h
244
	<glib/gtypes.h>
245

  
246
1293381427 c:\mingw\include\glib-2.0\glib\gregex.h
247
	<glib/gerror.h>
248
	<glib/gstring.h>
249

  
250
1293381427 c:\mingw\include\glib-2.0\glib\gscanner.h
251
	<glib/gdataset.h>
252
	<glib/ghash.h>
253

  
254
1293381427 c:\mingw\include\glib-2.0\glib\gsequence.h
255
	<glib/gtypes.h>
256

  
257
1293381427 c:\mingw\include\glib-2.0\glib\gshell.h
258
	<glib/gerror.h>
259

  
260
1293381427 c:\mingw\include\glib-2.0\glib\gspawn.h
261
	<glib/gerror.h>
262

  
263
1293381427 c:\mingw\include\glib-2.0\glib\gstrfuncs.h
264
	<stdarg.h>
265
	<glib/gmacros.h>
266
	<glib/gtypes.h>
267

  
268
1293381427 c:\mingw\include\glib-2.0\glib\gtestutils.h
269
	<glib/gmessages.h>
270
	<glib/gstring.h>
271
	<glib/gerror.h>
272
	<glib/gslist.h>
273

  
274
1293381427 c:\mingw\include\glib-2.0\glib\gthreadpool.h
275
	<glib/gthread.h>
276

  
277
1293381427 c:\mingw\include\glib-2.0\glib\gtimer.h
278
	<glib/gtypes.h>
279

  
280
1293381427 c:\mingw\include\glib-2.0\glib\gtree.h
281
	<glib/gnode.h>
282

  
283
1293381427 c:\mingw\include\glib-2.0\glib\gurifuncs.h
284
	<glib/gtypes.h>
285

  
286
1293381427 c:\mingw\include\glib-2.0\glib\gvarianttype.h
287
	<glib/gmessages.h>
288
	<glib/gtypes.h>
289

  
290
1293381427 c:\mingw\include\glib-2.0\glib\gvariant.h
291
	<glib/gvarianttype.h>
292
	<glib/gstring.h>
293

  
294
1293381427 c:\mingw\include\glib-2.0\glib\gwin32.h
295
	<glib/gtypes.h>
296

  
297
1298498356 source:x:\utils_g\src\scol_glib_pregex.c
298
	"../include/scol_glib_pregex.h"
299

  
300
1298498380 x:\utils_g\include\scol_glib_pregex.h
301
	<stdio.h>
302
	<stdlib.h>
303
	<string.h>
304
	<math.h>
305
	<libgen.h>
306
	<glib.h>
307
	<windows.h>
308
	"scol_plugin_win.h"
309
	"scol_plugin_lin.h"
310
	"macros.h"
311

  
312
1298417439 x:\utils_g\include\main.h
313
	<stdio.h>
314
	<stdlib.h>
315
	<string.h>
316
	<math.h>
317
	<libgen.h>
318
	<glib.h>
319
	<windows.h>
320
	"scol_plugin_win.h"
321
	"scol_plugin_lin.h"
322
	"macros.h"
323

  
324
1297894138 x:\utils_g\include\scol_plugin_win.h
325
	<windows.h>
326
	<stdio.h>
327
	<stdlib.h>
328

  
329
1296481042 x:\utils_g\include\scol_plugin_lin.h
330
	<stdio.h>
331
	<stdlib.h>
332

  
333
1298486475 x:\utils_g\include\macros.h
334

  
bin/libpcre.dll.def
1
EXPORTS
2
    SCOLfreePCRE @1
3
    SCOLloadPCRE @2
pcre.cbp
1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2
<CodeBlocks_project_file>
3
	<FileVersion major="1" minor="6" />
4
	<Project>
5
		<Option title="pcre" />
6
		<Option pch_mode="2" />
7
		<Option compiler="gcc" />
8
		<Build>
9
			<Target title="Debug">
10
				<Option output="bin\Debug\pcre" prefix_auto="1" extension_auto="1" />
11
				<Option object_output="obj\Debug\" />
12
				<Option type="3" />
13
				<Option compiler="gcc" />
14
				<Option createDefFile="1" />
15
				<Option createStaticLib="1" />
16
				<Compiler>
17
					<Add option="-O1" />
18
					<Add option="-Wshadow" />
19
					<Add option="-Wredundant-decls" />
20
					<Add option="-Wcast-align" />
21
					<Add option="-Wundef" />
22
					<Add option="-Wfloat-equal" />
23
					<Add option="-Winline" />
24
					<Add option="-Wunreachable-code" />
25
					<Add option="-Wswitch-enum" />
26
					<Add option="-Wswitch-default" />
27
					<Add option="-pedantic" />
28
					<Add option="-pg" />
29
					<Add option="-g" />
30
					<Add directory="$(#gtk.include)\glib-2.0" />
31
					<Add directory="$(#gtk.lib)\glib-2.0\include" />
32
				</Compiler>
33
				<Linker>
34
					<Add option="-pg -lgmon" />
35
					<Add library="glib-2.0" />
36
				</Linker>
37
			</Target>
38
			<Target title="Release">
39
				<Option output="bin\pcre" prefix_auto="1" extension_auto="1" />
40
				<Option object_output="obj\" />
41
				<Option type="3" />
42
				<Option compiler="gcc" />
43
				<Option createDefFile="1" />
44
				<Option createStaticLib="1" />
45
				<Compiler>
46
					<Add option="-O1" />
47
					<Add option="-Wshadow" />
48
					<Add option="-Wredundant-decls" />
49
					<Add option="-Wcast-align" />
50
					<Add option="-Wundef" />
51
					<Add option="-Wfloat-equal" />
52
					<Add option="-Winline" />
53
					<Add option="-Wunreachable-code" />
54
					<Add option="-Wswitch-enum" />
55
					<Add option="-Wswitch-default" />
56
					<Add option="-pedantic" />
57
					<Add option="-Wfatal-errors" />
58
					<Add option="-Wextra" />
59
					<Add option="-Wall" />
60
					<Add directory="$(#gtk.include)\glib-2.0" />
61
					<Add directory="$(#gtk.lib)\glib-2.0\include" />
62
				</Compiler>
63
				<Linker>
64
					<Add option="-s" />
65
					<Add library="glib-2.0" />
66
				</Linker>
67
			</Target>
68
		</Build>
69
		<Compiler>
70
			<Add option="-O1" />
71
			<Add option="-Wshadow" />
72
			<Add option="-Winit-self" />
73
			<Add option="-Wredundant-decls" />
74
			<Add option="-Wcast-align" />
75
			<Add option="-Wundef" />
76
			<Add option="-Wfloat-equal" />
77
			<Add option="-Winline" />
78
			<Add option="-Wunreachable-code" />
79
			<Add option="-Wmissing-declarations" />
80
			<Add option="-Wswitch-enum" />
81
			<Add option="-Wswitch-default" />
82
			<Add option="-pedantic" />
83
			<Add option="-Wextra" />
84
			<Add option="-Wall" />
85
		</Compiler>
86
		<Unit filename="include\macros.h" />
87
		<Unit filename="include\scol_glib_pregex.h" />
88
		<Unit filename="include\scol_plugin_lin.h" />
89
		<Unit filename="include\scol_plugin_win.h" />
90
		<Unit filename="src\scol_glib_pregex.c">
91
			<Option compilerVar="CC" />
92
		</Unit>
93
		<Extensions>
94
			<code_completion />
95
			<debugger />
96
		</Extensions>
97
	</Project>
98
</CodeBlocks_project_file>

Also available in: Unified diff