From 043f0dd8abf1f9ce2676d84a486970f7cb875bff Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Thu, 30 Apr 2026 18:51:12 +0300 Subject: [PATCH] Move pcre code to 3proxy --- CMakeLists.txt | 49 +++++++++++++--- Makefile.FreeBSD | 3 +- Makefile.Linux | 3 +- Makefile.Solaris | 3 +- Makefile.msvc | 14 ++--- Makefile.unix | 3 +- Makefile.watcom | 3 +- Makefile.win | 3 +- src/3proxy.c | 6 ++ src/Makefile.inc | 7 ++- src/conf.c | 11 ++++ .../PCREPlugin/pcre_plugin.c => pcre.c} | 19 ++----- src/pcre.h | 6 ++ src/plugins/PCREPlugin/CMakeLists.txt | 56 ------------------- src/plugins/PCREPlugin/Makefile | 1 - src/plugins/PCREPlugin/Makefile.inc | 8 --- 16 files changed, 94 insertions(+), 101 deletions(-) rename src/{plugins/PCREPlugin/pcre_plugin.c => pcre.c} (97%) create mode 100644 src/pcre.h delete mode 100644 src/plugins/PCREPlugin/CMakeLists.txt delete mode 100644 src/plugins/PCREPlugin/Makefile delete mode 100644 src/plugins/PCREPlugin/Makefile.inc diff --git a/CMakeLists.txt b/CMakeLists.txt index 635c664..0b8f8b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,9 +267,10 @@ set(PCRE2_FOUND FALSE) if(3PROXY_USE_PCRE2) find_package(PCRE2 QUIET) if(PCRE2_FOUND) + add_compile_definitions(WITH_PCRE) message(STATUS "PCRE2 found: ${PCRE2_VERSION}") else() - message(STATUS "PCRE2 not found, PCREPlugin will not be built") + message(STATUS "PCRE2 not found, PCRE support will not be built") endif() endif() @@ -410,6 +411,10 @@ if(OpenSSL_FOUND) target_sources(3proxy PRIVATE src/ssllib.c src/ssl.c) endif() +if(PCRE2_FOUND) + target_sources(3proxy PRIVATE src/pcre.c) +endif() + target_include_directories(3proxy PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/libs @@ -417,6 +422,9 @@ target_include_directories(3proxy PRIVATE if(OpenSSL_FOUND) target_include_directories(3proxy PRIVATE ${OPENSSL_INCLUDE_DIR}) endif() +if(PCRE2_FOUND) + target_include_directories(3proxy PRIVATE ${PCRE2_INCLUDE_DIRS}) +endif() target_link_libraries(3proxy PRIVATE Threads::Threads) @@ -432,6 +440,38 @@ if(OpenSSL_FOUND) target_link_libraries(3proxy PRIVATE OpenSSL::SSL OpenSSL::Crypto) endif() +# PCRE2 linking (static on Linux/FreeBSD, dynamic on other platforms) +if(PCRE2_FOUND) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR + CMAKE_SYSTEM_NAME MATCHES "FreeBSD|OpenBSD|NetBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "Unix") + # Static linking for Linux/BSD + find_library(PCRE2_STATIC_LIB + NAMES pcre2-8 libpcre2-8.a pcre2-8.a + PATHS ${PC_PCRE2_LIBRARY_DIRS} + /usr/lib + /usr/local/lib + /lib + ) + if(PCRE2_STATIC_LIB) + target_link_libraries(3proxy PRIVATE + -Wl,-Bstatic + ${PCRE2_STATIC_LIB} + -Wl,-Bdynamic + ) + message(STATUS "Using static PCRE2: ${PCRE2_STATIC_LIB}") + elseif(TARGET PCRE2::PCRE2) + target_link_libraries(3proxy PRIVATE PCRE2::PCRE2) + else() + target_link_libraries(3proxy PRIVATE ${PCRE2_LIBRARIES}) + endif() + elseif(TARGET PCRE2::PCRE2) + target_link_libraries(3proxy PRIVATE PCRE2::PCRE2) + else() + target_link_libraries(3proxy PRIVATE ${PCRE2_LIBRARIES}) + endif() +endif() + if(WIN32) target_link_libraries(3proxy PRIVATE ${WINDOWS_LIBS}) if(COMPILER_IS_MSVC AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3proxy.rc) @@ -542,19 +582,12 @@ foreach(PLUGIN ${DEFAULT_PLUGINS}) add_subdirectory(src/plugins/${PLUGIN}) endforeach() -if(PCRE2_FOUND) - add_subdirectory(src/plugins/PCREPlugin) -endif() - if(PAM_FOUND) add_subdirectory(src/plugins/PamAuth) endif() # Build full list of plugins to be built set(ALL_PLUGINS ${DEFAULT_PLUGINS}) -if(PCRE2_FOUND) - list(APPEND ALL_PLUGINS PCREPlugin) -endif() if(PAM_FOUND) list(APPEND ALL_PLUGINS PamAuth) endif() diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index 6d3c3f9..2883896 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -41,7 +41,8 @@ ifeq ($(OPENSSL_CHECK), true) endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpcre.o - 2>/dev/null && $(CC) -o testpcre testpcre.o $(LDFLAGS) -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic 2>/dev/null && rm testpcre testpcre.o && echo true||echo false) ifeq ($(PCRE_CHECK), true) - PLUGINS += PCREPlugin + CFLAGS += -DWITH_PCRE + PCRE_OBJS = pcre$(OBJSUFFICS) PCRE_LIBS = -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic endif PAM_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpam.o - 2>/dev/null && $(CC) $(LDFLAGS) -o testpam testpam.o -lpam 2>/dev/null && rm testpam testpam.o && echo true||echo false) diff --git a/Makefile.Linux b/Makefile.Linux index 9d98336..64e976a 100644 --- a/Makefile.Linux +++ b/Makefile.Linux @@ -43,7 +43,8 @@ ifeq ($(OPENSSL_CHECK), true) endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpcre.o - 2>/dev/null && $(CC) -o testpcre testpcre.o $(LDFLAGS) -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic 2>/dev/null && rm testpcre testpcre.o && echo true||echo false) ifeq ($(PCRE_CHECK), true) - PLUGINS += PCREPlugin + CFLAGS += -DWITH_PCRE + PCRE_OBJS = pcre$(OBJSUFFICS) PCRE_LIBS = -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic endif PAM_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpam.o - 2>/dev/null && $(CC) $(LDFLAGS) -o testpam testpam.o -lpam 2>/dev/null && rm testpam testpam.o && echo true||echo false) diff --git a/Makefile.Solaris b/Makefile.Solaris index 54636c8..c58b072 100644 --- a/Makefile.Solaris +++ b/Makefile.Solaris @@ -37,7 +37,8 @@ ifeq ($(OPENSSL_CHECK), true) endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpcre.o - 2>/dev/null && $(CC) -o testpcre testpcre.o $(LDFLAGS) -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic 2>/dev/null && rm testpcre testpcre.o && echo true||echo false) ifeq ($(PCRE_CHECK), true) - PLUGINS += PCREPlugin + CFLAGS += -DWITH_PCRE + PCRE_OBJS = pcre$(OBJSUFFICS) PCRE_LIBS = -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic endif diff --git a/Makefile.msvc b/Makefile.msvc index 283fed0..031af74 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -8,28 +8,28 @@ BUILDDIR = ../bin/ CC = cl VERSION = $(VERSION) BUILDDATE = $(BUILDDATE) -CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c $(BUILDDATE) $(VERSION) +CFLAGS = /nologo /MT /W3 /Ox /GS /EHs- /GA /GF /D "MSVC" /D "WITH_WSAPOLL" /D "NDEBUG" /D "WIN32" /D "WITH_SSL" /D "WITH_PCRE" /D "_CONSOLE" /D "_MBCS" /D "_WIN32" /Fp"proxy.pch" /FD /c $(BUILDDATE) $(VERSION) COUT = /Fo LN = link LDFLAGS = /nologo /subsystem:console /incremental:no DLFLAGS = /DLL DLSUFFICS = .dll -LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib Crypt32.lib libcrypto.lib libssl.lib -LIBSPREFIX = +LIBS = ws2_32.lib advapi32.lib odbc32.lib user32.lib kernel32.lib Gdi32.lib Crypt32.lib libcrypto.lib libssl.lib pcre2-8.lib +LIBSPREFIX = LIBSSUFFIX = .lib -LIBEXT = .lib +LIBEXT = .lib LNOUT = /out: EXESUFFICS = .exe OBJSUFFICS = .obj -DEFINEOPTION = /D +DEFINEOPTION = /D COMPFILES = *.pch *.idb REMOVECOMMAND = del TYPECOMMAND = type COMPATLIBS = MAKEFILE = Makefile.msvc -PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin FilePlugin PCREPlugin +PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin FilePlugin SSL_OBJS = ssllib$(OBJSUFFICS) ssl$(OBJSUFFICS) -PCRE_LIBS = pcre2-8.lib +PCRE_OBJS = pcre$(OBJSUFFICS) VERFILE = 3proxy.res $(VERFILE) VERSIONDEP = 3proxy.res $(VERSIONDEP) AFTERCLEAN = if exist src\*.res (del src\*.res) && if exist src\*.err (del src\*.err) diff --git a/Makefile.unix b/Makefile.unix index 2440b91..9a9c664 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -43,7 +43,8 @@ ifeq ($(OPENSSL_CHECK), true) endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpcre.o - 2>/dev/null && $(CC) -o testpcre testpcre.o $(LDFLAGS) -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic 2>/dev/null && rm testpcre testpcre.o && echo true||echo false) ifeq ($(PCRE_CHECK), true) - PLUGINS += PCREPlugin + CFLAGS += -DWITH_PCRE + PCRE_OBJS = pcre$(OBJSUFFICS) PCRE_LIBS = -Wl,-Bstatic -lpcre2-8 -Wl,-Bdynamic endif PAM_CHECK = $(shell echo "\#include \\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testpam.o - 2>/dev/null && $(CC) $(LDFLAGS) -o testpam testpam.o -lpam 2>/dev/null && rm testpam testpam.o && echo true||echo false) diff --git a/Makefile.watcom b/Makefile.watcom index c9c501d..ee6908c 100644 --- a/Makefile.watcom +++ b/Makefile.watcom @@ -27,7 +27,8 @@ TYPECOMMAND = type COMPATLIBS = MAKEFILE = Makefile.watcom PLUGINS = utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin -PCRE_LIBS = pcre2-8.lib +SSL_OBJS = ssllib$(OBJSUFFICS) ssl$(OBJSUFFICS) +PCRE_OBJS = pcre$(OBJSUFFICS) VERFILE = $(VERFILE) VERSION = $(VERSION) VERSIONDEP = 3proxy.res $(VERSIONDEP) diff --git a/Makefile.win b/Makefile.win index ba8995e..486e41d 100644 --- a/Makefile.win +++ b/Makefile.win @@ -46,7 +46,8 @@ ifeq ($(PAM_CHECK), true) endif PCRE_CHECK = $(shell echo "\#define PCRE2_CODE_UNIT_WIDTH 8\\n#include \\n int main(){return 0;}" | tr -d '\\\\' | cc -x c $(CFLAGS) $(LDFLAGS) -lpcre2-8 -o testpcre - 2>/dev/null && rm testpcre && echo true||echo false) ifeq ($(PCRE_CHECK), true) - PLUGINS += PCREPlugin + CFLAGS += -DWITH_PCRE + PCRE_OBJS = pcre$(OBJSUFFICS) PCRE_LIBS = -lpcre2-8 endif endif diff --git a/src/3proxy.c b/src/3proxy.c index 38b566c..8270b86 100644 --- a/src/3proxy.c +++ b/src/3proxy.c @@ -10,6 +10,9 @@ #ifdef WITH_SSL void ssl_install(void); #endif +#ifdef WITH_PCRE +void pcre_install(void); +#endif #ifndef _WIN32 #include #ifndef NOPLUGINS @@ -529,6 +532,9 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int #ifdef WITH_SSL ssl_install(); #endif +#ifdef WITH_PCRE + pcre_install(); +#endif freeconf(&conf); res = readconfig(fp); diff --git a/src/Makefile.inc b/src/Makefile.inc index 14c982d..c08651c 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -167,6 +167,9 @@ ssllib$(OBJSUFFICS): ssllib.c ssl$(OBJSUFFICS): ssl.c $(CC) $(COUT)ssl$(OBJSUFFICS) $(CFLAGS) ssl.c -$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) hashtables$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) log$(OBJSUFFICS) datatypes$(OBJSUFFICS) blake2$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(SSL_OBJS) $(COMPATLIBS) $(VERSIONDEP) - $(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) hashtables$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) blake2$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(SSL_OBJS) $(COMPATLIBS) $(LIBS) +pcre$(OBJSUFFICS): pcre.c + $(CC) $(COUT)pcre$(OBJSUFFICS) $(CFLAGS) $(DEFINEOPTION)WITH_PCRE pcre.c + +$(BUILDDIR)3proxy$(EXESUFFICS): 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) hashtables$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) log$(OBJSUFFICS) datatypes$(OBJSUFFICS) blake2$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(SSL_OBJS) $(PCRE_OBJS) $(COMPATLIBS) $(VERSIONDEP) + $(LN) $(LNOUT)$(BUILDDIR)3proxy$(EXESUFFICS) $(LDFLAGS) $(VERFILE) 3proxy$(OBJSUFFICS) mainfunc$(OBJSUFFICS) auth$(OBJSUFFICS) acl$(OBJSUFFICS) limiter$(OBJSUFFICS) redirect$(OBJSUFFICS) authradius$(OBJSUFFICS) hash$(OBJSUFFICS) hashtables$(OBJSUFFICS) resolve$(OBJSUFFICS) sql$(OBJSUFFICS) conf$(OBJSUFFICS) datatypes$(OBJSUFFICS) srvauto$(OBJSUFFICS) srvproxy$(OBJSUFFICS) srvpop3p$(OBJSUFFICS) srvsmtpp$(OBJSUFFICS) srvftppr$(OBJSUFFICS) srvsocks$(OBJSUFFICS) srvtcppm$(OBJSUFFICS) srvtlspr$(OBJSUFFICS) srvudppm$(OBJSUFFICS) sockmap$(OBJSUFFICS) sockgetchar$(OBJSUFFICS) common$(OBJSUFFICS) log$(OBJSUFFICS) 3proxy_crypt$(OBJSUFFICS) blake2$(OBJSUFFICS) base64$(OBJSUFFICS) ftp$(OBJSUFFICS) stringtable$(OBJSUFFICS) srvwebadmin$(OBJSUFFICS) srvdnspr$(OBJSUFFICS) plugins$(OBJSUFFICS) $(SSL_OBJS) $(PCRE_OBJS) $(COMPATLIBS) $(LIBS) $(PCRE_LIBS) diff --git a/src/conf.c b/src/conf.c index 7ff54e3..5455b46 100644 --- a/src/conf.c +++ b/src/conf.c @@ -10,6 +10,9 @@ #ifdef WITH_SSL void ssl_install(void); #endif +#ifdef WITH_PCRE +void pcre_install(void); +#endif #ifndef _WIN32 #include #include @@ -1457,6 +1460,11 @@ static int h_plugin(int argc, unsigned char **argv){ return 0; } #endif +#ifdef WITH_PCRE + if(argc >= 3 && !strcmp((char *)argv[2], "pcre_plugin")){ + return 0; + } +#endif #ifdef NOPLUGINS return 999; #else @@ -1960,6 +1968,9 @@ int reload (void){ _3proxy_mutex_lock(&config_mutex); #ifdef WITH_SSL ssl_install(); +#endif +#ifdef WITH_PCRE + pcre_install(); #endif conf.paused++; freeconf(&conf); diff --git a/src/plugins/PCREPlugin/pcre_plugin.c b/src/pcre.c similarity index 97% rename from src/plugins/PCREPlugin/pcre_plugin.c rename to src/pcre.c index fa6438c..dfaf921 100644 --- a/src/plugins/PCREPlugin/pcre_plugin.c +++ b/src/pcre.c @@ -5,7 +5,7 @@ */ -#include "../../structures.h" +#include "structures.h" #include #define PCRE2_CODE_UNIT_WIDTH 8 #define PCRE2_STATIC @@ -261,7 +261,7 @@ static int h_pcre(int argc, unsigned char **argv){ PCRE2_SIZE erroffset; struct pcre_filter_data *flt; struct filter *newf; - char *replace = NULL; + char * replace = NULL; if(!strncmp((char *)argv[2], "allow",5)) action = PASS; else if(!strncmp((char *)argv[2], "deny",4)) action = REJECT; @@ -368,7 +368,7 @@ static int h_pcre_rewrite(int argc, unsigned char **argv){ PCRE2_SIZE erroffset; struct pcre_filter_data *flt; struct filter *newf; - char *replace = NULL; + char * replace = NULL; if(!strncmp((char *)argv[2], "allow",5)) action = PASS; else if(!strncmp((char *)argv[2], "deny",4)) action = REJECT; @@ -503,17 +503,11 @@ static struct symbol regexp_symbols[] = { {NULL, "pcre_options", (void *)&pcre_options}, }; -#ifdef WATCOM -#pragma aux pcre_plugin "*" parm caller [ ] value struct float struct routine [eax] modify [eax ecx edx] -#undef PLUGINCALL -#define PLUGINCALL -#endif -PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink, - int argc, char** argv){ +void pcre_install(void){ struct filter *flt, *tmpflt; - pl = pluginlink; + pl = &pluginlink; pcre_options = 0; if(!pcre_loaded){ pcre_loaded = 1; @@ -537,9 +531,8 @@ PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink, } } pcre_last_filter = NULL; - return 0; - } + #ifdef __cplusplus } #endif diff --git a/src/pcre.h b/src/pcre.h new file mode 100644 index 0000000..539b7f6 --- /dev/null +++ b/src/pcre.h @@ -0,0 +1,6 @@ +#ifndef __pcre_h__ +#define __pcre_h__ + +void pcre_install(void); + +#endif /* __pcre_h__ */ diff --git a/src/plugins/PCREPlugin/CMakeLists.txt b/src/plugins/PCREPlugin/CMakeLists.txt deleted file mode 100644 index 1632f3b..0000000 --- a/src/plugins/PCREPlugin/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# PCREPlugin - requires PCRE2 - -if(NOT PCRE2_FOUND) - message(STATUS "PCREPlugin requires PCRE2, skipping") - return() -endif() - -add_3proxy_plugin(PCREPlugin - SOURCES pcre_plugin.c - COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8 -) - -# Helper function to link PCRE2 with static linking on Linux/FreeBSD -function(link_pcre2_static TARGET_NAME) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR - CMAKE_SYSTEM_NAME MATCHES "FreeBSD|OpenBSD|NetBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "Unix") - # Try to find static PCRE2 library - find_library(PCRE2_STATIC_LIBRARY - NAMES pcre2-8 libpcre2-8.a pcre2-8.a - PATHS ${PC_PCRE2_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - /lib - ) - if(PCRE2_STATIC_LIBRARY) - # Use static linking with GNU ld - target_link_libraries(${TARGET_NAME} PRIVATE - -Wl,-Bstatic - ${PCRE2_STATIC_LIBRARY} - -Wl,-Bdynamic - ) - message(STATUS "Using static PCRE2: ${PCRE2_STATIC_LIBRARY}") - else() - # Fallback to dynamic linking if static library not found - if(TARGET PCRE2::PCRE2) - target_link_libraries(${TARGET_NAME} PRIVATE PCRE2::PCRE2) - else() - target_link_libraries(${TARGET_NAME} PRIVATE ${PCRE2_LIBRARIES}) - endif() - message(STATUS "Static PCRE2 not found, using dynamic linking") - endif() - else() - # Other platforms (macOS, Windows) - use standard linking - if(TARGET PCRE2::PCRE2) - target_link_libraries(${TARGET_NAME} PRIVATE PCRE2::PCRE2) - else() - target_link_libraries(${TARGET_NAME} PRIVATE ${PCRE2_LIBRARIES}) - if(PCRE2_INCLUDE_DIRS) - target_include_directories(${TARGET_NAME} PRIVATE ${PCRE2_INCLUDE_DIRS}) - endif() - endif() - endif() -endfunction() - -link_pcre2_static(PCREPlugin) diff --git a/src/plugins/PCREPlugin/Makefile b/src/plugins/PCREPlugin/Makefile deleted file mode 100644 index e7c51ad..0000000 --- a/src/plugins/PCREPlugin/Makefile +++ /dev/null @@ -1 +0,0 @@ -include Makefile.var diff --git a/src/plugins/PCREPlugin/Makefile.inc b/src/plugins/PCREPlugin/Makefile.inc deleted file mode 100644 index 00dc0f6..0000000 --- a/src/plugins/PCREPlugin/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -all: $(BUILDDIR)PCREPlugin$(DLSUFFICS) - -pcre_plugin$(OBJSUFFICS): pcre_plugin.c - $(CC) $(DCFLAGS) $(CFLAGS) pcre_plugin.c - -$(BUILDDIR)PCREPlugin$(DLSUFFICS): pcre_plugin$(OBJSUFFICS) - $(LN) $(LNOUT)../../$(BUILDDIR)PCREPlugin$(DLSUFFICS) $(LDFLAGS) $(DLFLAGS) pcre_plugin$(OBJSUFFICS) $(PCRE_LIBS) -