-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpcre.pas
1145 lines (1052 loc) · 43.5 KB
/
pcre.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is pcre.pas. }
{ }
{ The Initial Developer of the Original Code is Peter Thornqvist. }
{ Portions created by Peter Thornqvist are Copyright (C) of Peter Thornqvist. All rights reserved. }
{ Portions created by University of Cambridge are }
{ Copyright (C) 1997-2001 by University of Cambridge. }
{ }
{ Contributor(s): }
{ Robert Rossmair (rrossmair) }
{ Mario R. Carro }
{ Florent Ouchet (outchy) }
{ }
{ The latest release of PCRE is always available from }
{ ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.gz }
{ }
{ Modified by Jan Goyvaerts for use with TPerlRegEx }
{ TPerlRegEx is available at http://www.regular-expressions.info/delphi.html }
{ }
{**************************************************************************************************}
{ }
{ Header conversion of pcre.h }
{ }
{**************************************************************************************************}
unit pcre;
interface
(*************************************************
* Perl-Compatible Regular Expressions *
*************************************************)
{$WEAKPACKAGEUNIT ON}
// Define PCRE_STATICLINK to link the OBJ files with PCRE 7.9.
{$DEFINE PCRE_STATICLINK}
// Define PCRE_LINKDLL to use pcrelib.dll
{.$DEFINE PCRE_LINKDLL}
// The supplied pcrelib.dll compiled PCRE 7.9 using the C calling convention
{$IFDEF PCRE_LINKDLL}
{$DEFINE PCRE_EXPORT_CDECL}
{$ENDIF}
(*$HPPEMIT '#include "pcre.h"'*)
const
MAX_PATTERN_LENGTH = $10003;
{$EXTERNALSYM MAX_PATTERN_LENGTH}
MAX_QUANTIFY_REPEAT = $10000;
{$EXTERNALSYM MAX_QUANTIFY_REPEAT}
MAX_CAPTURE_COUNT = $FFFF;
{$EXTERNALSYM MAX_CAPTURE_COUNT}
MAX_NESTING_DEPTH = 200;
{$EXTERNALSYM MAX_NESTING_DEPTH}
const
(* Options *)
PCRE_CASELESS = $00000001;
{$EXTERNALSYM PCRE_CASELESS}
PCRE_MULTILINE = $00000002;
{$EXTERNALSYM PCRE_MULTILINE}
PCRE_DOTALL = $00000004;
{$EXTERNALSYM PCRE_DOTALL}
PCRE_EXTENDED = $00000008;
{$EXTERNALSYM PCRE_EXTENDED}
PCRE_ANCHORED = $00000010;
{$EXTERNALSYM PCRE_ANCHORED}
PCRE_DOLLAR_ENDONLY = $00000020;
{$EXTERNALSYM PCRE_DOLLAR_ENDONLY}
PCRE_EXTRA = $00000040;
{$EXTERNALSYM PCRE_EXTRA}
PCRE_NOTBOL = $00000080;
{$EXTERNALSYM PCRE_NOTBOL}
PCRE_NOTEOL = $00000100;
{$EXTERNALSYM PCRE_NOTEOL}
PCRE_UNGREEDY = $00000200;
{$EXTERNALSYM PCRE_UNGREEDY}
PCRE_NOTEMPTY = $00000400;
{$EXTERNALSYM PCRE_NOTEMPTY}
PCRE_UTF8 = $00000800;
{$EXTERNALSYM PCRE_UTF8}
PCRE_NO_AUTO_CAPTURE = $00001000;
{$EXTERNALSYM PCRE_NO_AUTO_CAPTURE}
PCRE_NO_UTF8_CHECK = $00002000;
{$EXTERNALSYM PCRE_NO_UTF8_CHECK}
PCRE_AUTO_CALLOUT = $00004000;
{$EXTERNALSYM PCRE_AUTO_CALLOUT}
PCRE_PARTIAL = $00008000;
{$EXTERNALSYM PCRE_PARTIAL}
PCRE_DFA_SHORTEST = $00010000;
{$EXTERNALSYM PCRE_DFA_SHORTEST}
PCRE_DFA_RESTART = $00020000;
{$EXTERNALSYM PCRE_DFA_RESTART}
PCRE_FIRSTLINE = $00040000;
{$EXTERNALSYM PCRE_FIRSTLINE}
PCRE_DUPNAMES = $00080000;
{$EXTERNALSYM PCRE_DUPNAMES}
PCRE_NEWLINE_CR = $00100000;
{$EXTERNALSYM PCRE_NEWLINE_CR}
PCRE_NEWLINE_LF = $00200000;
{$EXTERNALSYM PCRE_NEWLINE_LF}
PCRE_NEWLINE_CRLF = $00300000;
{$EXTERNALSYM PCRE_NEWLINE_CRLF}
PCRE_NEWLINE_ANY = $00400000;
{$EXTERNALSYM PCRE_NEWLINE_ANY}
PCRE_NEWLINE_ANYCRLF = $00500000;
{$EXTERNALSYM PCRE_NEWLINE_ANYCRLF}
PCRE_BSR_ANYCRLF = $00800000;
{$EXTERNALSYM PCRE_BSR_ANYCRLF}
PCRE_BSR_UNICODE = $01000000;
{$EXTERNALSYM PCRE_BSR_UNICODE}
PCRE_JAVASCRIPT_COMPAT = $02000000;
{$EXTERNALSYM PCRE_JAVASCRIPT_COMPAT}
PCRE_NO_START_OPTIMIZE = $04000000;
{$EXTERNALSYM PCRE_NO_START_OPTIMIZE}
PCRE_NO_START_OPTIMISE = $04000000;
{$EXTERNALSYM PCRE_NO_START_OPTIMISE}
(* Exec-time and get-time error codes *)
PCRE_ERROR_NOMATCH = -1;
{$EXTERNALSYM PCRE_ERROR_NOMATCH}
PCRE_ERROR_NULL = -2;
{$EXTERNALSYM PCRE_ERROR_NULL}
PCRE_ERROR_BADOPTION = -3;
{$EXTERNALSYM PCRE_ERROR_BADOPTION}
PCRE_ERROR_BADMAGIC = -4;
{$EXTERNALSYM PCRE_ERROR_BADMAGIC}
PCRE_ERROR_UNKNOWN_NODE = -5;
{$EXTERNALSYM PCRE_ERROR_UNKNOWN_NODE}
PCRE_ERROR_NOMEMORY = -6;
{$EXTERNALSYM PCRE_ERROR_NOMEMORY}
PCRE_ERROR_NOSUBSTRING = -7;
{$EXTERNALSYM PCRE_ERROR_NOSUBSTRING}
PCRE_ERROR_MATCHLIMIT = -8;
{$EXTERNALSYM PCRE_ERROR_MATCHLIMIT}
PCRE_ERROR_CALLOUT = -9; (* Never used by PCRE itself *)
{$EXTERNALSYM PCRE_ERROR_CALLOUT}
PCRE_ERROR_BADUTF8 = -10;
{$EXTERNALSYM PCRE_ERROR_BADUTF8}
PCRE_ERROR_BADUTF8_OFFSET = -11;
{$EXTERNALSYM PCRE_ERROR_BADUTF8_OFFSET}
PCRE_ERROR_PARTIAL = -12;
{$EXTERNALSYM PCRE_ERROR_PARTIAL}
PCRE_ERROR_BADPARTIAL = -13;
{$EXTERNALSYM PCRE_ERROR_BADPARTIAL}
PCRE_ERROR_INTERNAL = -14;
{$EXTERNALSYM PCRE_ERROR_INTERNAL}
PCRE_ERROR_BADCOUNT = -15;
{$EXTERNALSYM PCRE_ERROR_BADCOUNT}
PCRE_ERROR_DFA_UITEM = -16;
{$EXTERNALSYM PCRE_ERROR_DFA_UITEM}
PCRE_ERROR_DFA_UCOND = -17;
{$EXTERNALSYM PCRE_ERROR_DFA_UCOND}
PCRE_ERROR_DFA_UMLIMIT = -18;
{$EXTERNALSYM PCRE_ERROR_DFA_UMLIMIT}
PCRE_ERROR_DFA_WSSIZE = -19;
{$EXTERNALSYM PCRE_ERROR_DFA_WSSIZE}
PCRE_ERROR_DFA_RECURSE = -20;
{$EXTERNALSYM PCRE_ERROR_DFA_RECURSE}
PCRE_ERROR_RECURSIONLIMIT = -21;
{$EXTERNALSYM PCRE_ERROR_RECURSIONLIMIT}
PCRE_ERROR_NULLWSLIMIT = -22; (* No longer actually used *)
{$EXTERNALSYM PCRE_ERROR_NULLWSLIMIT}
PCRE_ERROR_BADNEWLINE = -23;
{$EXTERNALSYM PCRE_ERROR_BADNEWLINE}
(* Request types for pcre_fullinfo() *)
PCRE_INFO_OPTIONS = 0;
{$EXTERNALSYM PCRE_INFO_OPTIONS}
PCRE_INFO_SIZE = 1;
{$EXTERNALSYM PCRE_INFO_SIZE}
PCRE_INFO_CAPTURECOUNT = 2;
{$EXTERNALSYM PCRE_INFO_CAPTURECOUNT}
PCRE_INFO_BACKREFMAX = 3;
{$EXTERNALSYM PCRE_INFO_BACKREFMAX}
PCRE_INFO_FIRSTCHAR = 4;
{$EXTERNALSYM PCRE_INFO_FIRSTCHAR}
PCRE_INFO_FIRSTTABLE = 5;
{$EXTERNALSYM PCRE_INFO_FIRSTTABLE}
PCRE_INFO_LASTLITERAL = 6;
{$EXTERNALSYM PCRE_INFO_LASTLITERAL}
PCRE_INFO_NAMEENTRYSIZE = 7;
{$EXTERNALSYM PCRE_INFO_NAMEENTRYSIZE}
PCRE_INFO_NAMECOUNT = 8;
{$EXTERNALSYM PCRE_INFO_NAMECOUNT}
PCRE_INFO_NAMETABLE = 9;
{$EXTERNALSYM PCRE_INFO_NAMETABLE}
PCRE_INFO_STUDYSIZE = 10;
{$EXTERNALSYM PCRE_INFO_STUDYSIZE}
PCRE_INFO_DEFAULT_TABLES = 11;
{$EXTERNALSYM PCRE_INFO_DEFAULT_TABLES}
PCRE_INFO_OKPARTIAL = 12;
{$EXTERNALSYM PCRE_INFO_OKPARTIAL}
PCRE_INFO_JCHANGED = 13;
{$EXTERNALSYM PCRE_INFO_JCHANGED}
PCRE_INFO_HASCRORLF = 14;
{$EXTERNALSYM PCRE_INFO_HASCRORLF}
(* Request types for pcre_config() *)
PCRE_CONFIG_UTF8 = 0;
{$EXTERNALSYM PCRE_CONFIG_UTF8}
PCRE_CONFIG_NEWLINE = 1;
{$EXTERNALSYM PCRE_CONFIG_NEWLINE}
PCRE_CONFIG_LINK_SIZE = 2;
{$EXTERNALSYM PCRE_CONFIG_LINK_SIZE}
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD = 3;
{$EXTERNALSYM PCRE_CONFIG_POSIX_MALLOC_THRESHOLD}
PCRE_CONFIG_MATCH_LIMIT = 4;
{$EXTERNALSYM PCRE_CONFIG_MATCH_LIMIT}
PCRE_CONFIG_STACKRECURSE = 5;
{$EXTERNALSYM PCRE_CONFIG_STACKRECURSE}
PCRE_CONFIG_UNICODE_PROPERTIES = 6;
{$EXTERNALSYM PCRE_CONFIG_UNICODE_PROPERTIES}
PCRE_CONFIG_MATCH_LIMIT_RECURSION = 7;
{$EXTERNALSYM PCRE_CONFIG_MATCH_LIMIT_RECURSION}
PCRE_CONFIG_BSR = 8;
{$EXTERNALSYM PCRE_CONFIG_BSR}
(* Bit flags for the pcre_extra structure *)
PCRE_EXTRA_STUDY_DATA = $0001;
{$EXTERNALSYM PCRE_EXTRA_STUDY_DATA}
PCRE_EXTRA_MATCH_LIMIT = $0002;
{$EXTERNALSYM PCRE_EXTRA_MATCH_LIMIT}
PCRE_EXTRA_CALLOUT_DATA = $0004;
{$EXTERNALSYM PCRE_EXTRA_CALLOUT_DATA}
PCRE_EXTRA_TABLES = $0008;
{$EXTERNALSYM PCRE_EXTRA_TABLES}
PCRE_EXTRA_MATCH_LIMIT_RECURSION = $0010;
{$EXTERNALSYM PCRE_EXTRA_MATCH_LIMIT_RECURSION}
type
(* Types *)
PPAnsiChar = ^PAnsiChar;
{$EXTERNALSYM PPAnsiChar}
PPPAnsiChar = ^PPAnsiChar;
{$EXTERNALSYM PPPAnsiChar}
PInteger = ^Integer;
{$EXTERNALSYM PInteger}
real_pcre = packed record
{magic_number: Longword;
size: Integer;
tables: PAnsiChar;
options: Longword;
top_bracket: Word;
top_backref: word;
first_char: PAnsiChar;
req_char: PAnsiChar;
code: array [0..0] of AnsiChar;}
end;
TPCRE = real_pcre;
PPCRE = ^TPCRE;
real_pcre_extra = packed record
{options: PAnsiChar;
start_bits: array [0..31] of AnsiChar;}
flags: Cardinal; (* Bits for which fields are set *)
study_data: Pointer; (* Opaque data from pcre_study() *)
match_limit: Cardinal; (* Maximum number of calls to match() *)
callout_data: Pointer; (* Data passed back in callouts *)
tables: PAnsiChar; (* Pointer to character tables *)
match_limit_recursion: Cardinal; (* Max recursive calls to match() *)
end;
TPCREExtra = real_pcre_extra;
PPCREExtra = ^TPCREExtra;
pcre_callout_block = packed record
version: Integer; (* Identifies version of block *)
(* ------------------------ Version 0 ------------------------------- *)
callout_number: Integer; (* Number compiled into pattern *)
offset_vector: PInteger; (* The offset vector *)
subject: PAnsiChar; (* The subject being matched *)
subject_length: Integer; (* The length of the subject *)
start_match: Integer; (* Offset to start of this match attempt *)
current_position: Integer; (* Where we currently are in the subject *)
capture_top: Integer; (* Max current capture *)
capture_last: Integer; (* Most recently closed capture *)
callout_data: Pointer; (* Data passed in with the call *)
(* ------------------- Added for Version 1 -------------------------- *)
pattern_position: Integer; (* Offset to next item in the pattern *)
next_item_length: Integer; (* Length of next item in the pattern *)
(* ------------------------------------------------------------------ *)
end;
pcre_malloc_callback = function(Size: Integer): Pointer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_malloc_callback}
pcre_free_callback = procedure(P: Pointer); {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_free_callback}
pcre_stack_malloc_callback = function(Size: Integer): Pointer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_stack_malloc_callback}
pcre_stack_free_callback = procedure(P: Pointer); {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_stack_free_callback}
pcre_callout_callback = function(var callout_block: pcre_callout_block): Integer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_callout_callback}
var
// renamed from "pcre_X" to "pcre_X_func" to allow functions with name "pcre_X" to be
// declared in implementation when static linked
pcre_malloc_func: ^pcre_malloc_callback = nil;
{$EXTERNALSYM pcre_malloc_func}
pcre_free_func: ^pcre_free_callback = nil;
{$EXTERNALSYM pcre_free_func}
pcre_stack_malloc_func: ^pcre_stack_malloc_callback = nil;
{$EXTERNALSYM pcre_stack_malloc_func}
pcre_stack_free_func: ^pcre_stack_free_callback = nil;
{$EXTERNALSYM pcre_stack_free_func}
pcre_callout_func: ^pcre_callout_callback = nil;
{$EXTERNALSYM pcre_callout_func}
procedure SetPCREMallocCallback(const Value: pcre_malloc_callback);
{$EXTERNALSYM SetPCREMallocCallback}
function GetPCREMallocCallback: pcre_malloc_callback;
{$EXTERNALSYM GetPCREMallocCallback}
function CallPCREMalloc(Size: Integer): Pointer;
{$EXTERNALSYM CallPCREMalloc}
procedure SetPCREFreeCallback(const Value: pcre_free_callback);
{$EXTERNALSYM SetPCREFreeCallback}
function GetPCREFreeCallback: pcre_free_callback;
{$EXTERNALSYM GetPCREFreeCallback}
procedure CallPCREFree(P: Pointer);
{$EXTERNALSYM CallPCREFree}
procedure SetPCREStackMallocCallback(const Value: pcre_stack_malloc_callback);
{$EXTERNALSYM SetPCREStackMallocCallback}
function GetPCREStackMallocCallback: pcre_stack_malloc_callback;
{$EXTERNALSYM GetPCREStackMallocCallback}
function CallPCREStackMalloc(Size: Integer): Pointer;
{$EXTERNALSYM CallPCREStackMalloc}
procedure SetPCREStackFreeCallback(const Value: pcre_stack_free_callback);
{$EXTERNALSYM SetPCREStackFreeCallback}
function GetPCREStackFreeCallback: pcre_stack_free_callback;
{$EXTERNALSYM GetPCREStackFreeCallback}
procedure CallPCREStackFree(P: Pointer);
{$EXTERNALSYM CallPCREStackFree}
procedure SetPCRECalloutCallback(const Value: pcre_callout_callback);
{$EXTERNALSYM SetPCRECalloutCallback}
function GetPCRECalloutCallback: pcre_callout_callback;
{$EXTERNALSYM GetPCRECalloutCallback}
function CallPCRECallout(var callout_block: pcre_callout_block): Integer;
{$EXTERNALSYM CallPCRECallout}
type
TPCRELibNotLoadedHandler = procedure; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
var
// Value to initialize function pointers below with, in case LoadPCRE fails
// or UnloadPCRE is called. Typically the handler will raise an exception.
LibNotLoadedHandler: TPCRELibNotLoadedHandler = nil;
(* Functions *)
{$IFNDEF PCRE_LINKONREQUEST}
// static link and static dll import
function pcre_compile(const pattern: PAnsiChar; options: Integer;
const errptr: PPAnsiChar; erroffset: PInteger; const tableptr: PAnsiChar): PPCRE;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_compile}
function pcre_compile2(const pattern: PAnsiChar; options: Integer;
const errorcodeptr: PInteger; const errorptr: PPAnsiChar; erroroffset: PInteger;
const tables: PAnsiChar): PPCRE;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_compile2}
function pcre_config(what: Integer; where: Pointer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_config}
function pcre_copy_named_substring(const code: PPCRE; const subject: PAnsiChar;
ovector: PInteger; stringcount: Integer; const stringname: PAnsiChar;
buffer: PAnsiChar; size: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_copy_named_substring}
function pcre_copy_substring(const subject: PAnsiChar; ovector: PInteger;
stringcount, stringnumber: Integer; buffer: PAnsiChar; buffersize: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_copy_substring}
function pcre_dfa_exec(const argument_re: PPCRE; const extra_data: PPCREExtra;
const subject: PAnsiChar; length: Integer; start_offset: Integer;
options: Integer; offsets: PInteger; offsetcount: Integer; workspace: PInteger;
wscount: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_dfa_exec}
function pcre_exec(const code: PPCRE; const extra: PPCREExtra; const subject: PAnsiChar;
length, startoffset, options: Integer; ovector: PInteger; ovecsize: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_exec}
procedure pcre_free_substring(stringptr: PAnsiChar);
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_free_substring}
procedure pcre_free_substring_list(stringlistptr: PPAnsiChar);
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_free_substring_list}
function pcre_fullinfo(const code: PPCRE; const extra: PPCREExtra;
what: Integer; where: Pointer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_fullinfo}
function pcre_get_named_substring(const code: PPCRE; const subject: PAnsiChar;
ovector: PInteger; stringcount: Integer; const stringname: PAnsiChar;
const stringptr: PPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_named_substring}
function pcre_get_stringnumber(const code: PPCRE; const stringname: PAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_stringnumber}
function pcre_get_stringtable_entries(const code: PPCRE; const stringname: PAnsiChar;
firstptr: PPAnsiChar; lastptr: PPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_stringtable_entries}
function pcre_get_substring(const subject: PAnsiChar; ovector: PInteger;
stringcount, stringnumber: Integer; const stringptr: PPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_substring}
function pcre_get_substring_list(const subject: PAnsiChar; ovector: PInteger;
stringcount: Integer; listptr: PPPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_substring_list}
function pcre_info(const code: PPCRE; optptr, firstcharptr: PInteger): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_info}
function pcre_maketables: PAnsiChar;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_maketables}
function pcre_refcount(argument_re: PPCRE; adjust: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_refcount}
function pcre_study(const code: PPCRE; options: Integer; const errptr: PPAnsiChar): PPCREExtra;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_study}
function pcre_version: PAnsiChar; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_version}
// Calling pcre_free in the DLL causes an access violation error; use pcre_dispose instead
procedure pcre_dispose(pattern, hints, chartable: Pointer); {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$ELSE}
// dynamic dll import
type
pcre_compile_func = function(const pattern: PAnsiChar; options: Integer;
const errptr: PPAnsiChar; erroffset: PInteger; const tableptr: PAnsiChar): PPCRE;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_compile_func}
pcre_compile2_func = function(const pattern: PAnsiChar; options: Integer;
const errorcodeptr: PInteger; const errorptr: PPAnsiChar; erroroffset: PInteger;
const tables: PAnsiChar): PPCRE; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_compile2_func}
pcre_config_func = function(what: Integer; where: Pointer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_config_func}
pcre_copy_named_substring_func = function(const code: PPCRE; const subject: PAnsiChar;
ovector: PInteger; stringcount: Integer; const stringname: PAnsiChar;
buffer: PAnsiChar; size: Integer): Integer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_copy_named_substring_func}
pcre_copy_substring_func = function(const subject: PAnsiChar; ovector: PInteger;
stringcount, stringnumber: Integer; buffer: PAnsiChar; buffersize: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_copy_substring_func}
pcre_dfa_exec_func = function(const argument_re: PPCRE; const extra_data: PPCREExtra;
const subject: PAnsiChar; length: Integer; start_offset: Integer;
options: Integer; offsets: PInteger; offsetcount: Integer; workspace: PInteger;
wscount: Integer): Integer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_dfa_exec_func}
pcre_exec_func = function(const code: PPCRE; const extra: PPCREExtra; const subject: PAnsiChar;
length, startoffset, options: Integer; ovector: PInteger; ovecsize: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_exec_func}
pcre_free_substring_func = procedure(stringptr: PAnsiChar);
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_free_substring_func}
pcre_free_substring_list_func = procedure(stringptr: PPAnsiChar);
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_free_substring_list_func}
pcre_fullinfo_func = function(const code: PPCRE; const extra: PPCREExtra;
what: Integer; where: Pointer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_fullinfo_func}
pcre_get_named_substring_func = function(const code: PPCRE; const subject: PAnsiChar;
ovector: PInteger; stringcount: Integer; const stringname: PAnsiChar;
const stringptr: PPAnsiChar): Integer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_named_substring_func}
pcre_get_stringnumber_func = function(const code: PPCRE;
const stringname: PAnsiChar): Integer; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_stringnumber_func}
pcre_get_stringtable_entries_func = function(const code: PPCRE; const stringname: PAnsiChar;
firstptr: PPAnsiChar; lastptr: PPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_stringtable_entries_func}
pcre_get_substring_func = function(const subject: PAnsiChar; ovector: PInteger;
stringcount, stringnumber: Integer; const stringptr: PPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_substring_func}
pcre_get_substring_list_func = function(const subject: PAnsiChar; ovector: PInteger;
stringcount: Integer; listptr: PPPAnsiChar): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_get_substring_list_func}
pcre_info_func = function(const code: PPCRE; optptr, firstcharptr: PInteger): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_info_func}
pcre_maketables_func = function: PAnsiChar; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_maketables_func}
pcre_refcount_func = function(argument_re: PPCRE; adjust: Integer): Integer;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_refcount_func}
pcre_study_func = function(const code: PPCRE; options: Integer; const errptr: PPAnsiChar): PPCREExtra;
{$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_study_func}
pcre_version_func = function: PAnsiChar; {$IFDEF PCRE_EXPORT_CDECL} cdecl; {$ENDIF PCRE_EXPORT_CDECL}
{$EXTERNALSYM pcre_version_func}
var
pcre_compile: pcre_compile_func = nil;
{$EXTERNALSYM pcre_compile}
pcre_compile2: pcre_compile2_func = nil;
{$EXTERNALSYM pcre_compile2}
pcre_config: pcre_config_func = nil;
{$EXTERNALSYM pcre_config}
pcre_copy_named_substring: pcre_copy_named_substring_func = nil;
{$EXTERNALSYM pcre_copy_named_substring}
pcre_copy_substring: pcre_copy_substring_func = nil;
{$EXTERNALSYM pcre_copy_substring}
pcre_dfa_exec: pcre_dfa_exec_func = nil;
{$EXTERNALSYM pcre_dfa_exec}
pcre_exec: pcre_exec_func = nil;
{$EXTERNALSYM pcre_exec}
pcre_free_substring: pcre_free_substring_func = nil;
{$EXTERNALSYM pcre_free_substring}
pcre_free_substring_list: pcre_free_substring_list_func = nil;
{$EXTERNALSYM pcre_free_substring_list}
pcre_fullinfo: pcre_fullinfo_func = nil;
{$EXTERNALSYM pcre_fullinfo}
pcre_get_named_substring: pcre_get_named_substring_func = nil;
{$EXTERNALSYM pcre_get_named_substring}
pcre_get_stringnumber: pcre_get_stringnumber_func = nil;
{$EXTERNALSYM pcre_get_stringnumber}
pcre_get_stringtable_entries: pcre_get_stringtable_entries_func = nil;
{$EXTERNALSYM pcre_get_stringtable_entries}
pcre_get_substring: pcre_get_substring_func = nil;
{$EXTERNALSYM pcre_get_substring}
pcre_get_substring_list: pcre_get_substring_list_func = nil;
{$EXTERNALSYM pcre_get_substring_list}
pcre_info: pcre_info_func = nil;
{$EXTERNALSYM pcre_info}
pcre_maketables: pcre_maketables_func = nil;
{$EXTERNALSYM pcre_maketables}
pcre_refcount: pcre_refcount_func = nil;
{$EXTERNALSYM pcre_refcount}
pcre_study: pcre_study_func = nil;
{$EXTERNALSYM pcre_study}
pcre_version: pcre_version_func = nil;
{$EXTERNALSYM pcre_version}
{$ENDIF ~PCRE_LINKONREQUEST}
function IsPCRELoaded: Boolean;
function LoadPCRE: Boolean;
procedure UnloadPCRE;
implementation
uses
SysUtils,
{$IFDEF MSWINDOWS}
Windows;
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
{$IFDEF HAS_UNIT_TYPES}
Types,
{$ENDIF HAS_UNIT_TYPES}
{$IFDEF HAS_UNIT_LIBC}
Libc;
{$ELSE ~HAS_UNIT_LIBC}
dl;
{$ENDIF ~HAS_UNIT_LIBC}
{$ENDIF UNIX}
{$IFDEF PCRE_STATICLINK}
{$LINK pcre\pcre_compile.obj}
{$LINK pcre\pcre_config.obj}
{$LINK pcre\pcre_dfa_exec.obj}
{$LINK pcre\pcre_exec.obj}
{$LINK pcre\pcre_fullinfo.obj}
{$LINK pcre\pcre_get.obj}
{$LINK pcre\pcre_globals.obj}
{$LINK pcre\pcre_info.obj}
{$LINK pcre\pcre_maketables.obj}
{$LINK pcre\pcre_newline.obj}
{$LINK pcre\pcre_ord2utf8.obj}
{$LINK pcre\pcre_refcount.obj}
{$LINK pcre\pcre_study.obj}
{$LINK pcre\pcre_tables.obj}
{$LINK pcre\pcre_try_flipped.obj}
{$LINK pcre\pcre_ucd.obj}
{$LINK pcre\pcre_valid_utf8.obj}
{$LINK pcre\pcre_version.obj}
{$LINK pcre\pcre_xclass.obj}
{$LINK pcre\pcre_default_tables.obj}
// user's defined callbacks
var
pcre_malloc_user: pcre_malloc_callback;
pcre_free_user: pcre_free_callback;
pcre_stack_malloc_user: pcre_stack_malloc_callback;
pcre_stack_free_user: pcre_stack_free_callback;
pcre_callout_user: pcre_callout_callback;
function pcre_compile; external;
function pcre_compile2; external;
function pcre_config; external;
function pcre_copy_named_substring; external;
function pcre_copy_substring; external;
function pcre_dfa_exec; external;
function pcre_exec; external;
procedure pcre_free_substring; external;
procedure pcre_free_substring_list; external;
function pcre_fullinfo; external;
function pcre_get_named_substring; external;
function pcre_get_stringnumber; external;
function pcre_get_stringtable_entries; external;
function pcre_get_substring; external;
function pcre_get_substring_list; external;
function pcre_info; external;
function pcre_maketables; external;
function pcre_refcount; external;
function pcre_study; external;
function pcre_version; external;
type
size_t = Longint;
const
szMSVCRT = 'MSVCRT.DLL';
function _memcpy(dest, src: Pointer; count: size_t): Pointer; cdecl; external szMSVCRT name 'memcpy';
function _memmove(dest, src: Pointer; count: size_t): Pointer; cdecl; external szMSVCRT name 'memmove';
function _memset(dest: Pointer; val: Integer; count: size_t): Pointer; cdecl; external szMSVCRT name 'memset';
function _strncmp(s1: PAnsiChar; s2: PAnsiChar; n: size_t): Integer; cdecl; external szMSVCRT name 'strncmp';
function _memcmp(s1: Pointer; s2: Pointer; n: size_t): Integer; cdecl; external szMSVCRT name 'memcmp';
function _strlen(s: PAnsiChar): size_t; cdecl; external szMSVCRT name 'strlen';
function __ltolower(__ch: Integer): Integer; cdecl; external szMSVCRT name 'tolower';
function __ltoupper(__ch: Integer): Integer; cdecl; external szMSVCRT name 'toupper';
function _isalnum(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isalnum';
function _isalpha(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isalpha';
function _iscntrl(__ch: Integer): Integer; cdecl; external szMSVCRT name 'iscntrl';
function _isdigit(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isdigit';
function _isgraph(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isgraph';
function _islower(__ch: Integer): Integer; cdecl; external szMSVCRT name 'islower';
function _isprint(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isprint';
function _ispunct(__ch: Integer): Integer; cdecl; external szMSVCRT name 'ispunct';
function _isspace(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isspace';
function _isupper(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isupper';
function _isxdigit(__ch: Integer): Integer; cdecl; external szMSVCRT name 'isxdigit';
function _strchr(__s: PAnsiChar; __c: Integer): PAnsiChar; cdecl; external szMSVCRT name 'strchr';
function malloc(size: size_t): Pointer; cdecl; external szMSVCRT name 'malloc';
function pcre_malloc(Size: Integer): Pointer;
begin
if Assigned(pcre_malloc_user) then
Result := pcre_malloc_user(Size)
else
Result := malloc(Size);
end;
function pcre_stack_malloc(Size: Integer): Pointer;
begin
if Assigned(pcre_stack_malloc_user) then
Result := pcre_stack_malloc_user(Size)
else
Result := malloc(Size);
end;
function _malloc(size: size_t): Pointer;
begin
Result := pcre_malloc(size);
end;
procedure free(pBlock: Pointer); cdecl; external szMSVCRT name 'free';
procedure pcre_free(P: Pointer);
begin
if Assigned(pcre_free_user) then
pcre_free_user(P)
else
free(P);
end;
procedure pcre_stack_free(P: Pointer);
begin
if Assigned(pcre_stack_free_user) then
pcre_stack_free_user(P)
else
free(P);
end;
procedure _free(pBlock: Pointer);
begin
pcre_free(pBlock);
end;
function pcre_callout(var callout_block: pcre_callout_block): Integer; cdecl;
begin
if Assigned(pcre_callout_user) then
Result := pcre_callout_user(callout_block)
else
Result := 0;
end;
{$ELSE ~PCRE_STATICLINK}
type
{$IFDEF MSWINDOWS}
TModuleHandle = HINST;
{$ENDIF MSWINDOWS}
{$IFDEF LINUX}
TModuleHandle = Pointer;
{$ENDIF LINUX}
const
{$IFDEF MSWINDOWS}
libpcremodulename = 'pcrelib.dll';
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
libpcremodulename = 'libpcre.so.0';
{$ENDIF UNIX}
PCRECompileExportName = 'pcre_compile';
PCRECompile2ExportName = 'pcre_compile2';
PCREConfigExportName = 'pcre_config';
PCRECopyNamedSubstringExportName = 'pcre_copy_named_substring';
PCRECopySubStringExportName = 'pcre_copy_substring';
PCREDfaExecExportName = 'pcre_dfa_exec';
PCREExecExportName = 'pcre_exec';
PCREFreeSubStringExportName = 'pcre_free_substring';
PCREFreeSubStringListExportName = 'pcre_free_substring_list';
PCREFullInfoExportName = 'pcre_fullinfo';
PCREGetNamedSubstringExportName = 'pcre_get_named_substring';
PCREGetStringNumberExportName = 'pcre_get_stringnumber';
PCREGetStringTableEntriesExportName = 'pcre_get_stringtable_entries';
PCREGetSubStringExportName = 'pcre_get_substring';
PCREGetSubStringListExportName = 'pcre_get_substring_list';
PCREInfoExportName = 'pcre_info';
PCREMakeTablesExportName = 'pcre_maketables';
PCRERefCountExportName = 'pcre_refcount';
PCREStudyExportName = 'pcre_study';
PCREVersionExportName = 'pcre_version';
PCREMallocExportName = 'pcre_malloc';
PCREFreeExportName = 'pcre_free';
PCREStackMallocExportName = 'pcre_stack_malloc';
PCREStackFreeExportName = 'pcre_stack_free';
PCRECalloutExportName = 'pcre_callout';
INVALID_MODULEHANDLE_VALUE = TModuleHandle(0);
var
PCRELib: TModuleHandle = INVALID_MODULEHANDLE_VALUE;
{$ENDIF ~PCRE_STATICLINK}
procedure SetPCREMallocCallback(const Value: pcre_malloc_callback);
begin
{$IFDEF PCRE_STATICLINK}
pcre_malloc_user := Value;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_malloc_func) then
LoadPCRE;
if Assigned(pcre_malloc_func) then
pcre_malloc_func^ := Value
else if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
{$ENDIF ~PCRE_STATICLINK}
end;
function GetPCREMallocCallback: pcre_malloc_callback;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_malloc_user;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_malloc_func) then
LoadPCRE;
if not Assigned(pcre_malloc_func) then
begin
Result := nil;
if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
end
else
Result := pcre_malloc_func^;
{$ENDIF ~PCRE_STATICLINK}
end;
function CallPCREMalloc(Size: Integer): Pointer;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_malloc(Size);
{$ELSE ~PCRE_STATICLINK}
Result := pcre_malloc_func^(Size);
{$ENDIF ~PCRE_STATICLINK}
end;
procedure SetPCREFreeCallback(const Value: pcre_free_callback);
begin
{$IFDEF PCRE_STATICLINK}
pcre_free_user := Value;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_free_func) then
LoadPCRE;
if Assigned(pcre_free_func) then
pcre_free_func^ := Value
else if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
{$ENDIF ~PCRE_STATICLINK}
end;
function GetPCREFreeCallback: pcre_free_callback;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_free_user;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_free_func) then
LoadPCRE;
if not Assigned(pcre_free_func) then
begin
Result := nil;
if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
end
else
Result := pcre_free_func^
{$ENDIF ~PCRE_STATICLINK}
end;
procedure CallPCREFree(P: Pointer);
begin
{$IFDEF PCRE_STATICLINK}
pcre_free(P);
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_free_func) then
LoadPCRE;
pcre_free_func^(P);
{$ENDIF ~PCRE_STATICLINK}
end;
procedure SetPCREStackMallocCallback(const Value: pcre_stack_malloc_callback);
begin
{$IFDEF PCRE_STATICLINK}
pcre_stack_malloc_user := Value;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_stack_malloc_func) then
LoadPCRE;
if Assigned(pcre_stack_malloc_func) then
pcre_stack_malloc_func^ := Value
else if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
{$ENDIF ~PCRE_STATICLINK}
end;
function GetPCREStackMallocCallback: pcre_stack_malloc_callback;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_stack_malloc_user;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_stack_malloc_func) then
LoadPCRE;
if not Assigned(pcre_stack_malloc_func) then
begin
Result := nil;
if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
end
else
Result := pcre_stack_malloc_func^;
{$ENDIF ~PCRE_STATICLINK}
end;
function CallPCREStackMalloc(Size: Integer): Pointer;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_stack_malloc(Size);
{$ELSE ~PCRE_STATICLINK}
Result := pcre_stack_malloc_func^(Size);
{$ENDIF ~PCRE_STATICLINK}
end;
procedure SetPCREStackFreeCallback(const Value: pcre_stack_free_callback);
begin
{$IFDEF PCRE_STATICLINK}
pcre_stack_free_user := Value;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_stack_free_func) then
LoadPCRE;
if Assigned(pcre_stack_free_func) then
pcre_stack_free_func^ := Value
else if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
{$ENDIF ~PCRE_STATICLINK}
end;
function GetPCREStackFreeCallback: pcre_stack_free_callback;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_stack_free_user;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_stack_free_func) then
LoadPCRE;
if not Assigned(pcre_stack_free_func) then
begin
Result := nil;
if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
end
else
Result := pcre_stack_free_func^;
{$ENDIF ~PCRE_STATICLINK}
end;
procedure CallPCREStackFree(P: Pointer);
begin
{$IFDEF PCRE_STATICLINK}
pcre_stack_free(P);
{$ELSE ~PCRE_STATICLINK}
pcre_stack_free_func^(P);
{$ENDIF ~PCRE_STATICLINK}
end;
procedure SetPCRECalloutCallback(const Value: pcre_callout_callback);
begin
{$IFDEF PCRE_STATICLINK}
pcre_callout_user := Value;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_callout_func) then
LoadPCRE;
if Assigned(pcre_callout_func) then
pcre_callout_func^ := Value
else if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
{$ENDIF ~PCRE_STATICLINK}
end;
function GetPCRECalloutCallback: pcre_callout_callback;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_callout_user;
{$ELSE ~PCRE_STATICLINK}
if not Assigned(pcre_callout_func) then
LoadPCRE;
if not Assigned(pcre_callout_func) then
begin
Result := nil;
if Assigned(LibNotLoadedHandler) then
LibNotLoadedHandler;
end
else
Result := pcre_callout_func^;
{$ENDIF ~PCRE_STATICLINK}
end;
function CallPCRECallout(var callout_block: pcre_callout_block): Integer;
begin
{$IFDEF PCRE_STATICLINK}
Result := pcre_callout(callout_block);
{$ELSE ~PCRE_STATICLINK}
Result := pcre_callout_func^(callout_block);
{$ENDIF ~PCRE_STATICLINK}
end;
{$IFNDEF PCRE_STATICLINK}
procedure InitPCREFuncPtrs(const Value: Pointer);
begin
{$IFDEF PCRE_LINKONREQUEST}
@pcre_compile := Value;
@pcre_compile2 := Value;
@pcre_config := Value;
@pcre_copy_named_substring := Value;
@pcre_copy_substring := Value;
@pcre_dfa_exec := Value;
@pcre_exec := Value;