move AcceptBaseParser to utils directory

This commit is contained in:
Tomasz Sowa 2022-02-02 17:11:46 +01:00
parent f7b5ac0dc8
commit d0d2cfb22c
12 changed files with 389 additions and 557 deletions

View File

@ -64,13 +64,14 @@ winix.so: $(winix.src.files)
@cd models ; $(MAKE) -e @cd models ; $(MAKE) -e
@cd db ; $(MAKE) -e @cd db ; $(MAKE) -e
@cd functions ; $(MAKE) -e @cd functions ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd templates ; $(MAKE) -e @cd templates ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd utils ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e @cd $(GLOBAL_WORKING_DIR)/ezc/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e @cd $(GLOBAL_WORKING_DIR)/tito/src ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e @cd $(GLOBAL_WORKING_DIR)/pikotools ; $(MAKE) -e
@cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e @cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o models/*.o functions/*.o templates/*.o notify/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/src/pikotools.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -lmagic -Wl,-no-whole-archive $(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(winix_include_paths) core/*.o db/*.o models/*.o functions/*.o templates/*.o notify/*.o utils/*.o $(GLOBAL_WORKING_DIR)/ezc/src/ezc.a $(GLOBAL_WORKING_DIR)/tito/src/tito.a $(GLOBAL_WORKING_DIR)/pikotools/src/pikotools.a $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -lmagic -Wl,-no-whole-archive
winix: winix.so $(winix.src.files) winix: winix.so $(winix.src.files)
@ -101,6 +102,7 @@ clean:
@cd functions ; $(MAKE) -e clean @cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean @cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean @cd notify ; $(MAKE) -e clean
@cd utils ; $(MAKE) -e clean
@cd plugins/stats ; $(MAKE) -e clean @cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean @cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean @cd plugins/ticket ; $(MAKE) -e clean
@ -129,6 +131,7 @@ depend:
@cd functions ; $(MAKE) -e depend @cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend @cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend @cd notify ; $(MAKE) -e depend
@cd utils ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend @cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend @cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend @cd plugins/ticket ; $(MAKE) -e depend

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
o = acceptbaseparser.o app.o basethread.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o httpsimpleparser.o image.o ipbancontainer.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o users.o winixbase.o winixmodeldeprecated.o winixrequest.o winixsystem.o o = app.o basethread.o compress.o config.o crypt.o dircontainer.o dirs.o filelog.o groups.o httpsimpleparser.o image.o ipbancontainer.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o users.o winixbase.o winixmodeldeprecated.o winixrequest.o winixsystem.o

View File

@ -35,7 +35,7 @@
#ifndef headerfile_winix_core_acceptencodingparser #ifndef headerfile_winix_core_acceptencodingparser
#define headerfile_winix_core_acceptencodingparser #define headerfile_winix_core_acceptencodingparser
#include "acceptbaseparser.h" #include "utils/acceptbaseparser.h"
#include "log.h" #include "log.h"
@ -62,7 +62,7 @@ public:
void ParseAndLog(const wchar_t * str) void ParseAndLog(const wchar_t * str)
{ {
Parse(str); parse(str);
if( accept_deflate || accept_gzip ) if( accept_deflate || accept_gzip )
{ {
@ -92,7 +92,7 @@ public:
private: private:
void Init() void init()
{ {
accept_deflate = false; accept_deflate = false;
accept_gzip = false; accept_gzip = false;

View File

@ -35,7 +35,7 @@
#ifndef headerfile_winix_core_acceptparser #ifndef headerfile_winix_core_acceptparser
#define headerfile_winix_core_acceptparser #define headerfile_winix_core_acceptparser
#include "acceptbaseparser.h" #include "utils/acceptbaseparser.h"
#include "log.h" #include "log.h"
#include "header.h" #include "header.h"
@ -67,7 +67,7 @@ public:
header_values.clear(); header_values.clear();
this->header_values = &header_values; this->header_values = &header_values;
AcceptBaseParser::Parse(str); AcceptBaseParser::parse(str);
std::sort(header_values.begin(), header_values.end(), [](HeaderValue & h1, HeaderValue & h2) -> bool { std::sort(header_values.begin(), header_values.end(), [](HeaderValue & h1, HeaderValue & h2) -> bool {
return h1.weight > h2.weight; return h1.weight > h2.weight;

View File

@ -183,7 +183,6 @@ main.o: ../../../winix/winixd/core/httpsimpleparser.h
main.o: ../../../winix/winixd/core/cookieparser.h main.o: ../../../winix/winixd/core/cookieparser.h
main.o: ../../../winix/winixd/core/postmultiparser.h main.o: ../../../winix/winixd/core/postmultiparser.h
main.o: ../../../winix/winixd/core/acceptencodingparser.h main.o: ../../../winix/winixd/core/acceptencodingparser.h
main.o: ../../../winix/winixd/core/acceptbaseparser.h
main.o: ../../../winix/winixd/core/acceptparser.h main.o: ../../../winix/winixd/core/acceptparser.h
main.o: ../../../winix/winixd/core/winixrequest.h main.o: ../../../winix/winixd/core/winixrequest.h
main.o: ../../../winix/winixd/core/version.h main.o: ../../../winix/winixd/core/version.h

24
winixd/utils/Makefile Normal file
View File

@ -0,0 +1,24 @@
include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools/src
all: $(o)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(winix_include_paths) $<
depend:
makedepend -Y. $(winix_include_paths) -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
clean:
rm -f *.o
include Makefile.dep

View File

@ -0,0 +1,3 @@
# DO NOT DELETE
acceptbaseparser.o: acceptbaseparser.h ../../../tito/src/misc.h

View File

@ -0,0 +1 @@
o = acceptbaseparser.o

View File

@ -34,7 +34,7 @@
#include <wchar.h> #include <wchar.h>
#include "acceptbaseparser.h" #include "acceptbaseparser.h"
#include "misc.h" #include "core/misc.h"
@ -53,7 +53,7 @@ return false;
} }
void AcceptBaseParser::SkipWhite() void AcceptBaseParser::skip_white()
{ {
while( IsWhite(*text) ) while( IsWhite(*text) )
++text; ++text;
@ -62,10 +62,10 @@ void AcceptBaseParser::SkipWhite()
void AcceptBaseParser::ReadParameter() void AcceptBaseParser::read_parameter()
{ {
param.clear(); param.clear();
SkipWhite(); skip_white();
while( *text!=0 && *text!=',' && *text!=';' ) while( *text!=0 && *text!=',' && *text!=';' )
{ {
@ -80,7 +80,7 @@ void AcceptBaseParser::ReadParameter()
void AcceptBaseParser::ReadQ() void AcceptBaseParser::ReadQ()
{ {
q = 1.0; q = 1.0;
SkipWhite(); skip_white();
if( *text != ';' ) if( *text != ';' )
return; return;
@ -96,14 +96,14 @@ void AcceptBaseParser::ReadQ()
++text; // skipping '=' ++text; // skipping '='
SkipWhite(); skip_white();
q = wcstod(text, (wchar_t**)&text); q = wcstod(text, (wchar_t**)&text);
} }
void AcceptBaseParser::SkipParam() void AcceptBaseParser::SkipParam()
{ {
SkipWhite(); skip_white();
if( *text == ',' ) if( *text == ',' )
++text; ++text;
@ -111,14 +111,14 @@ void AcceptBaseParser::SkipParam()
void AcceptBaseParser::Parse(const wchar_t * str) void AcceptBaseParser::parse(const wchar_t * str)
{ {
text = str; text = str;
Init(); init();
while( *text != 0 ) while( *text != 0 )
{ {
ReadParameter(); read_parameter();
ReadQ(); ReadQ();
SkipParam(); SkipParam();
Param(param, q); Param(param, q);
@ -127,9 +127,9 @@ void AcceptBaseParser::Parse(const wchar_t * str)
void AcceptBaseParser::Parse(const std::wstring & str) void AcceptBaseParser::parse(const std::wstring & str)
{ {
Parse(str.c_str()); parse(str.c_str());
} }

View File

@ -36,7 +36,7 @@
#define headerfile_winix_core_acceptbaseparser #define headerfile_winix_core_acceptbaseparser
#include <string> #include <string>
#include "winixbase.h" #include "core/winixbase.h"
namespace Winix namespace Winix
@ -46,23 +46,23 @@ namespace Winix
// sample (you must create your own class derived from this one): // sample (you must create your own class derived from this one):
// object.Parse(L" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 "); // object.parse(L" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
class AcceptBaseParser : public WinixBase class AcceptBaseParser : public WinixBase
{ {
public: public:
void Parse(const wchar_t * str); void parse(const wchar_t * str);
void Parse(const std::wstring & str); void parse(const std::wstring & str);
private: private:
virtual void Init() {} ; virtual void init() {} ;
virtual void Param(const std::wstring & param, double q) = 0; virtual void Param(const std::wstring & param, double q) = 0;
bool IsWhite(int c); bool IsWhite(int c);
void SkipWhite(); void skip_white();
void ReadParameter(); void read_parameter();
void ReadQ(); void ReadQ();
void SkipParam(); void SkipParam();