📄 pcre.pas
字号:
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}
{$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_ucp_searchfuncs.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 = 'pcre3.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';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -