mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 02:02:24 +00:00
Replacing regex library with PCRE
Update build scripts
This commit is contained in:
5 files changed
+90
-27
No files matched your search
+12
-12
@@ -3,7 +3,7 @@ mkdir obj
|
|||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
apk add gcc g++ build-base linux-headers cmake make autoconf automake libtool
|
apk add gcc g++ build-base linux-headers cmake make autoconf automake libtool
|
||||||
apk add libressl-dev zlib-dev rapidjson-dev libevent-dev libevent-static zlib-static
|
apk add libressl-dev zlib-dev rapidjson-dev libevent-dev libevent-static zlib-static pcre-dev
|
||||||
|
|
||||||
git clone https://github.com/curl/curl
|
git clone https://github.com/curl/curl
|
||||||
cd curl
|
cd curl
|
||||||
@@ -23,17 +23,17 @@ cd bzip2
|
|||||||
make install -j4 > /dev/null
|
make install -j4 > /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c logger.cpp -o obj/logger.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c logger.cpp -o obj/logger.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c main.cpp -o obj/main.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c main.cpp -o obj/main.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c misc.cpp -o obj/misc.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c misc.cpp -o obj/misc.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c multithread.cpp -o obj/multithread.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c multithread.cpp -o obj/multithread.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c nodemanip.cpp -o obj/nodemanip.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c nodemanip.cpp -o obj/nodemanip.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c rapidjson_extra.cpp -o obj/rapidjson_extra.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c rapidjson_extra.cpp -o obj/rapidjson_extra.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c speedtestutil.cpp -o obj/speedtestutil.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c speedtestutil.cpp -o obj/speedtestutil.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c subexport.cpp -o obj/subexport.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c subexport.cpp -o obj/subexport.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c webget.cpp -o obj/webget.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c webget.cpp -o obj/webget.o
|
||||||
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -c webserver_libevent.cpp -o obj/webserver_libevent.o
|
g++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -c webserver_libevent.cpp -o obj/webserver_libevent.o
|
||||||
g++ -o subconverter obj/logger.o obj/main.o obj/misc.o obj/multithread.o obj/nodemanip.o obj/rapidjson_extra.o obj/speedtestutil.o obj/subexport.o obj/webget.o obj/webserver_libevent.o -static -levent -lyaml-cpp -lcurl -lssl -lcrypto -lz -lbz2 -ldl -lpthread -O3 -s
|
g++ -o subconverter obj/logger.o obj/main.o obj/misc.o obj/multithread.o obj/nodemanip.o obj/rapidjson_extra.o obj/speedtestutil.o obj/subexport.o obj/webget.o obj/webserver_libevent.o -static -lpcrecpp -lpcre -levent -lyaml-cpp -lcurl -lssl -lcrypto -lz -lbz2 -ldl -lpthread -O3 -s
|
||||||
|
|
||||||
chmod +rx subconverter
|
chmod +rx subconverter
|
||||||
chmod +r pref.ini *.yml *.conf README* rules/*
|
chmod +r pref.ini *.yml *.conf README* rules/*
|
||||||
|
|||||||
+1
-1
@@ -13,6 +13,6 @@ c++ -std=c++17 -D_MACOS -Wall -fexceptions -c speedtestutil.cpp -o obj/speedtest
|
|||||||
c++ -std=c++17 -D_MACOS -Wall -fexceptions -c subexport.cpp -o obj/subexport.o
|
c++ -std=c++17 -D_MACOS -Wall -fexceptions -c subexport.cpp -o obj/subexport.o
|
||||||
c++ -std=c++17 -D_MACOS -Wall -fexceptions -c webget.cpp -o obj/webget.o
|
c++ -std=c++17 -D_MACOS -Wall -fexceptions -c webget.cpp -o obj/webget.o
|
||||||
c++ -std=c++17 -D_MACOS -Wall -fexceptions -c webserver_libevent.cpp -o obj/webserver_libevent.o
|
c++ -std=c++17 -D_MACOS -Wall -fexceptions -c webserver_libevent.cpp -o obj/webserver_libevent.o
|
||||||
c++ -o subconverter obj/logger.o obj/main.o obj/misc.o obj/multithread.o obj/nodemanip.o obj/rapidjson_extra.o obj/speedtestutil.o obj/subexport.o obj/webget.o obj/webserver_libevent.o -levent -lpthread -lyaml-cpp -lcurl -lssl -lcrypto -lz -O3 -s
|
c++ -o subconverter obj/logger.o obj/main.o obj/misc.o obj/multithread.o obj/nodemanip.o obj/rapidjson_extra.o obj/speedtestutil.o obj/subexport.o obj/webget.o obj/webserver_libevent.o -lpcrecpp -lpcre -levent -lpthread -lyaml-cpp -lcurl -lssl -lcrypto -lz -O3 -s
|
||||||
|
|
||||||
chmod +x subconverter
|
chmod +x subconverter
|
||||||
+14
-12
@@ -2,7 +2,7 @@
|
|||||||
mkdir obj
|
mkdir obj
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
brew reinstall yaml-cpp rapidjson libevent zlib
|
brew reinstall yaml-cpp rapidjson libevent zlib pcre
|
||||||
|
|
||||||
git clone https://github.com/curl/curl
|
git clone https://github.com/curl/curl
|
||||||
cd curl
|
cd curl
|
||||||
@@ -22,18 +22,20 @@ cp /usr/local/opt/zlib/lib/libz.a .
|
|||||||
cp /usr/local/opt/openssl@1.1/lib/libssl.a .
|
cp /usr/local/opt/openssl@1.1/lib/libssl.a .
|
||||||
cp /usr/local/opt/openssl@1.1/lib/libcrypto.a .
|
cp /usr/local/opt/openssl@1.1/lib/libcrypto.a .
|
||||||
cp /usr/local/lib/libyaml-cpp.a .
|
cp /usr/local/lib/libyaml-cpp.a .
|
||||||
|
cp /usr/local/lib/libpcre.a .
|
||||||
|
cp /usr/local/lib/libpcrecpp.a .
|
||||||
|
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c logger.cpp -o obj/logger.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c logger.cpp -o obj/logger.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c main.cpp -o obj/main.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c main.cpp -o obj/main.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c misc.cpp -o obj/misc.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c misc.cpp -o obj/misc.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c multithread.cpp -o obj/multithread.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c multithread.cpp -o obj/multithread.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c nodemanip.cpp -o obj/nodemanip.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c nodemanip.cpp -o obj/nodemanip.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c rapidjson_extra.cpp -o obj/rapidjson_extra.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c rapidjson_extra.cpp -o obj/rapidjson_extra.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c speedtestutil.cpp -o obj/speedtestutil.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c speedtestutil.cpp -o obj/speedtestutil.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c subexport.cpp -o obj/subexport.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c subexport.cpp -o obj/subexport.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c webget.cpp -o obj/webget.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c webget.cpp -o obj/webget.o
|
||||||
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c webserver_libevent.cpp -o obj/webserver_libevent.o
|
c++ -Wall -std=c++17 -fexceptions -DCURL_STATICLIB -DPCRE_STATIC -D_MACOS -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include -c webserver_libevent.cpp -o obj/webserver_libevent.o
|
||||||
c++ -Xlinker -unexported_symbol -Xlinker "*" -o subconverter obj/logger.o obj/main.o obj/misc.o obj/multithread.o obj/nodemanip.o obj/rapidjson_extra.o obj/speedtestutil.o obj/subexport.o obj/webget.o obj/webserver_libevent.o libevent.a curl/lib/.libs/libcurl.a libz.a libssl.a libcrypto.a libyaml-cpp.a bzip2-1.0.6/libbz2.a -ldl -lpthread -O3
|
c++ -Xlinker -unexported_symbol -Xlinker "*" -o subconverter obj/logger.o obj/main.o obj/misc.o obj/multithread.o obj/nodemanip.o obj/rapidjson_extra.o obj/speedtestutil.o obj/subexport.o obj/webget.o obj/webserver_libevent.o libpcrecpp.a libpcre.a libevent.a curl/lib/.libs/libcurl.a libz.a libssl.a libcrypto.a libyaml-cpp.a bzip2-1.0.6/libbz2.a -ldl -lpthread -O3
|
||||||
|
|
||||||
chmod +rx subconverter
|
chmod +rx subconverter
|
||||||
chmod +r pref.ini *.yml *.conf README* rules/*
|
chmod +r pref.ini *.yml *.conf README* rules/*
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ set -xe
|
|||||||
|
|
||||||
apt update
|
apt update
|
||||||
apt install git cmake clang
|
apt install git cmake clang
|
||||||
apt install libevent libcurl openssl
|
apt install libevent libcurl openssl pcre
|
||||||
|
|
||||||
git clone https://github.com/jbeder/yaml-cpp
|
git clone https://github.com/jbeder/yaml-cpp
|
||||||
cd yaml-cpp
|
cd yaml-cpp
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <regex>
|
//#include <regex>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
//#include <filesystem>
|
//#include <filesystem>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <pcrecpp.h>
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
|
|
||||||
@@ -446,6 +447,7 @@ std::string replace_all_distinct(std::string str, std::string old_value, std::st
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
bool regValid(std::string ®)
|
bool regValid(std::string ®)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -499,6 +501,65 @@ bool regMatch(std::string src, std::string match)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool regValid(std::string ®)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pcrecpp::RE r(reg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool regFind(std::string src, std::string target)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pcrecpp::RE reg(target);
|
||||||
|
return reg.PartialMatch(src);
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string regReplace(std::string src, std::string match, std::string rep)
|
||||||
|
{
|
||||||
|
std::string result = src;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(rep.find("$") != rep.npos)
|
||||||
|
rep = replace_all_distinct(rep, "$", "\\");
|
||||||
|
pcrecpp::RE reg(match);
|
||||||
|
if(TRUE == reg.Replace(rep, &result))
|
||||||
|
return result;
|
||||||
|
else
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool regMatch(std::string src, std::string match)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pcrecpp::RE reg(match);
|
||||||
|
return reg.FullMatch(src);
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string speedCalc(double speed)
|
std::string speedCalc(double speed)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user