From: Maxim Mamontov Date: Mon, 19 Sep 2011 20:05:03 +0000 (+0300) Subject: Keep stglibs headers and libraries "at home" X-Git-Tag: 2.408-rc1~26 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/703ad5b9a14dc2a42849669d3618a8ba1136bb92?ds=sidebyside;hp=261442af210d652fc2c8a3d9197097982701bd16 Keep stglibs headers and libraries "at home" --- diff --git a/include/stg/raw_ip_packet.h b/include/stg/raw_ip_packet.h index 16e43402..f07bf228 100644 --- a/include/stg/raw_ip_packet.h +++ b/include/stg/raw_ip_packet.h @@ -10,9 +10,6 @@ #include -#include "const.h" -#include "common.h" - #define IPv4 (2) enum { pcktSize = 68 }; //60(max) ip + 8 udp or tcp (part of tcp or udp header to ports) diff --git a/include/stg/user_ips.h b/include/stg/user_ips.h index 250520b2..17bb59be 100644 --- a/include/stg/user_ips.h +++ b/include/stg/user_ips.h @@ -41,7 +41,7 @@ #include #include -#include "common.h" +#include "stg/common.h" #include "os_int.h" using namespace std; diff --git a/include/stg/user_property.h b/include/stg/user_property.h index 822bc0f9..bdad48b0 100644 --- a/include/stg/user_property.h +++ b/include/stg/user_property.h @@ -15,12 +15,13 @@ $Author: faust $ #include #include +#include "stg/logger.h" +#include "stg/locker.h" +#include "stg/scriptexecuter.h" + #include "store.h" #include "admin.h" #include "notifer.h" -#include "logger.h" -#include "locker.h" -#include "scriptexecuter.h" #include "noncopyable.h" extern const volatile time_t stgTime; diff --git a/stglibs/Makefile.in b/stglibs/Makefile.in index a016fed5..c0b4f2b9 100644 --- a/stglibs/Makefile.in +++ b/stglibs/Makefile.in @@ -6,20 +6,24 @@ include ../../Makefile.conf PROG = lib$(LIB_NAME).a +SEARCH_DIRS = -I $(DIR_INCLUDE) -I . -I ./include + ifeq ($(STG_TIME), yes) DEFS += -DSTG_TIME endif -ifneq ($(ADD_DEFS),) -DEFS += $(ADD_DEFS) +ifneq ($(LIB_DEFS),) +DEFS += $(LIB_DEFS) endif -SEARCH_DIRS = -I $(DIR_INCLUDE) -I ./ +ifneq ($(LIB_INCS),) +SEARCH_DIRS += $(LIB_INCS) +endif OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS)))) -INST_INCS = $(addprefix $(DIR_INCLUDE)/, $(notdir $(INCS))) -INST_LIBS = $(DIR_LIB)/lib$(LIB_NAME) +#INST_INCS = $(addprefix $(DIR_INCLUDE)/, $(notdir $(INCS))) +#INST_LIBS = $(DIR_LIB)/lib$(LIB_NAME) CXXFLAGS += -fPIC CFLAGS += -fPIC @@ -31,16 +35,16 @@ all: $(PROG) $(PROG): $(OBJS) $(STGLIBS) ar rc lib$(LIB_NAME).a $(OBJS) ranlib lib$(LIB_NAME).a - cp *.a $(DIR_LIB) + #cp *.a $(DIR_LIB) -includes: $(INCS) - cp -p $(INCS) $(DIR_INCLUDE)/stg +#includes: $(INCS) +# cp -p $(INCS) $(DIR_INCLUDE)/stg clean: rm -f deps $(PROG) *.o *.a *.so tags *.*~ - for file in $(INCS); do \ - rm -f $(DIR_INCLUDE)/stg/$$file; \ - done + #for file in $(INCS); do \ + # rm -f $(DIR_INCLUDE)/stg/$$file; \ + #done install: $(PROG) mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib/stg diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index 3361adb3..855c71d7 100644 --- a/stglibs/common.lib/common.cpp +++ b/stglibs/common.lib/common.cpp @@ -28,32 +28,6 @@ $Author: faust $ */ - -/*#include -#include -#include -#include -#include -#include -#include - - -#include - - -#include -#include - -#ifdef WIN32 -#include -#else -#include -#include -#include -#include -#include -#endif*/ - #ifdef FREE_BSD #include #endif @@ -76,7 +50,7 @@ #include #include -#include "common.h" +#include "stg/common.h" #ifndef INET_ADDRSTRLEN # define INET_ADDRSTRLEN 16 diff --git a/stglibs/conffiles.lib/conffiles.cpp b/stglibs/conffiles.lib/conffiles.cpp index ea51939a..263c9933 100644 --- a/stglibs/conffiles.lib/conffiles.cpp +++ b/stglibs/conffiles.lib/conffiles.cpp @@ -40,8 +40,7 @@ #include -#include "conffiles.h" -#include "stg/common.h" +#include "stg/conffiles.h" using namespace std; @@ -105,33 +104,13 @@ int e = error; error = 0; return e; } -/*//--------------------------------------------------------------------------- -int CONFIGFILE::ReadString(const string & param, char * str, int * maxLen, const char * defaultVal) const -{ -it = param_val.find(param); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ - -if (it != param_val.end()) - { - // þÔÏ-ÔÏ ÓÔÏÉÔ - strncpy(str, param_val[param].c_str(), *maxLen); - *maxLen = param_val[param].size(); - return 0; - } - -strncpy(str, defaultVal, *maxLen); -*maxLen = strlen(defaultVal); -return -1; -}*/ //--------------------------------------------------------------------------- int CONFIGFILE::ReadString(const string & param, string * val, const string & defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ *val = it->second; return 0; } @@ -169,11 +148,9 @@ return -1; int CONFIGFILE::ReadInt(const string & param, int * val, int defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtol(it->second.c_str(), &res, 10); if (*res != 0) @@ -191,11 +168,9 @@ return -1; int CONFIGFILE::ReadUInt(const string & param, unsigned int * val, unsigned int defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtoul(it->second.c_str(), &res, 10); if (*res != 0) @@ -213,11 +188,9 @@ return -1; int CONFIGFILE::ReadLongInt(const string & param, long int * val, long int defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtol(it->second.c_str(), &res, 10); if (*res != 0) @@ -235,11 +208,9 @@ return -1; int CONFIGFILE::ReadULongInt(const string & param, unsigned long int * val, unsigned long int defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtoul(it->second.c_str(), &res, 10); if (*res != 0) @@ -257,11 +228,9 @@ return -1; int CONFIGFILE::ReadLongLongInt(const string & param, int64_t * val, int64_t defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtoll(it->second.c_str(), &res, 10); if (*res != 0) @@ -279,11 +248,9 @@ return -1; int CONFIGFILE::ReadULongLongInt(const string & param, uint64_t * val, uint64_t defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtoull(it->second.c_str(), &res, 10); if (*res != 0) @@ -301,11 +268,9 @@ return -1; int CONFIGFILE::ReadShortInt(const string & param, short int * val, short int defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = (short)strtol(it->second.c_str(), &res, 10); if (*res != 0) @@ -323,11 +288,9 @@ return -1; int CONFIGFILE::ReadUShortInt(const string & param, unsigned short int * val, unsigned short int defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = (short)strtoul(it->second.c_str(), &res, 10); if (*res != 0) @@ -344,20 +307,18 @@ return -1; //--------------------------------------------------------------------------- void CONFIGFILE::WriteInt(const string & param, int64_t val) { -string s; -x2str(val, s); -param_val[param] = s; +char buf[32]; +snprintf(buf, sizeof(buf), "%lld", static_cast(val)); +param_val[param] = buf; changed = true; } //--------------------------------------------------------------------------- int CONFIGFILE::ReadDouble(const string & param, double * val, double defaultVal) const { const map::const_iterator it(param_val.find(param)); -// îÁÛÌÉ ÎÕÖÎÕÀ ÐÅÒÅÍÅÎÎÕÀ if (it != param_val.end()) { - // þÔÏ-ÔÏ ÓÔÏÉÔ char *res; *val = strtod(it->second.c_str(), &res); if (*res != 0) @@ -405,8 +366,8 @@ int CONFIGFILE::Flush() const if (!changed) return 0; -std::string pid; -x2str(getpid(), pid); +char pid[6]; +snprintf(pid, sizeof(pid), "%d", getpid()); if (Flush(fileName + "." + pid)) return -1; diff --git a/stglibs/crypto.lib/ag_md5.c b/stglibs/crypto.lib/ag_md5.c index fef284a5..a638c189 100644 --- a/stglibs/crypto.lib/ag_md5.c +++ b/stglibs/crypto.lib/ag_md5.c @@ -1,4 +1,3 @@ - #ifdef WIN32 #include #include @@ -11,8 +10,8 @@ #include #include #include -#include "ag_md5.h" +#include "stg/ag_md5.h" #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) @@ -22,7 +21,6 @@ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - int i64c(int i) { if (i <= 0) diff --git a/stglibs/crypto.lib/blowfish.c b/stglibs/crypto.lib/blowfish.c index 69c467bd..951f4816 100644 --- a/stglibs/crypto.lib/blowfish.c +++ b/stglibs/crypto.lib/blowfish.c @@ -8,7 +8,7 @@ #include #include "stg/const.h" -#include "blowfish.h" +#include "stg/blowfish.h" #define ENCRYPT 0 #define DECRYPT 1 diff --git a/stglibs/dotconfpp.lib/dotconfpp.cpp b/stglibs/dotconfpp.lib/dotconfpp.cpp index 8ac25440..41775256 100644 --- a/stglibs/dotconfpp.lib/dotconfpp.cpp +++ b/stglibs/dotconfpp.lib/dotconfpp.cpp @@ -19,7 +19,7 @@ #include // glob #include -#include "dotconfpp.h" +#include "stg/dotconfpp.h" #include "mempool.h" DOTCONFDocumentNode::DOTCONFDocumentNode():previousNode(NULL), nextNode(NULL), parentNode(NULL), childNode(NULL), diff --git a/stglibs/ia.lib/Makefile b/stglibs/ia.lib/Makefile index 15104cd2..3ab0306a 100644 --- a/stglibs/ia.lib/Makefile +++ b/stglibs/ia.lib/Makefile @@ -8,8 +8,11 @@ SRCS = ia.cpp INCS = ia.h -STGLIBS = -lstgcommon \ - -lstgcrypto +STGLIBS = -lstgcrypto + LIBS = $(LIB_THREAD) +LIB_INCS = -I ../crypto.lib/include \ + -I ../common.lib/include + include ../Makefile.in diff --git a/stglibs/ia.lib/ia.cpp b/stglibs/ia.lib/ia.cpp index 81bd75fb..dc8d553e 100644 --- a/stglibs/ia.lib/ia.cpp +++ b/stglibs/ia.lib/ia.cpp @@ -29,25 +29,26 @@ //--------------------------------------------------------------------------- +#ifdef WIN32 +#include +#include +#include +#include +#else +#include +#include +#include +#include +#include +#endif + #include #include #include #include -#ifdef WIN32 - #include - #include - #include - #include -#else - #include - #include - #include - #include -#endif - #include "stg/common.h" -#include "ia.h" +#include "stg/ia.h" #define IA_NONE (0) #define IA_CONNECT (1) @@ -61,13 +62,19 @@ //--------------------------------------------------------------------------- #ifndef WIN32 #include +void Sleep(int ms) +{ +long long res = ms * 1000000; +struct timespec ts = {res / 1000000000, res % 1000000000}; +nanosleep(&ts, NULL); +} +//--------------------------------------------------------------------------- void * RunL(void * data) { sigset_t signalSet; sigfillset(&signalSet); pthread_sigmask(SIG_BLOCK, &signalSet, NULL); - IA_CLIENT_PROT * c = (IA_CLIENT_PROT *)data; static int a = 0; @@ -84,13 +91,6 @@ while (c->GetNonstop()) return NULL; } //--------------------------------------------------------------------------- -void Sleep(int ms) -{ -long long res = ms * 1000000; -struct timespec ts = {res / 1000000000, res % 1000000000}; -nanosleep(&ts, NULL); -} -//--------------------------------------------------------------------------- long GetTickCount() { struct timeval tv; diff --git a/stglibs/ibpp.lib/Makefile b/stglibs/ibpp.lib/Makefile index b73c56d6..59eded2f 100644 --- a/stglibs/ibpp.lib/Makefile +++ b/stglibs/ibpp.lib/Makefile @@ -26,7 +26,7 @@ SRCS = array.cpp \ INCS = ibpp.h -ADD_DEFS = -DIBPP_LINUX +LIB_DEFS = -DIBPP_LINUX LIBS = -lfbclient diff --git a/stglibs/ibpp.lib/_ibpp.h b/stglibs/ibpp.lib/_ibpp.h index e7af2eaf..8284fe9b 100644 --- a/stglibs/ibpp.lib/_ibpp.h +++ b/stglibs/ibpp.lib/_ibpp.h @@ -31,7 +31,7 @@ #ifndef __INTERNAL_IBPP_H__ #define __INTERNAL_IBPP_H__ -#include "ibpp.h" +#include "stg/ibpp.h" #if defined(__BCPLUSPLUS__) || defined(_MSC_VER) || defined(__DMC__) #define HAS_HDRSTOP diff --git a/stglibs/locker.lib/locker.cpp b/stglibs/locker.lib/locker.cpp index 0d97fcb4..94ef026a 100644 --- a/stglibs/locker.lib/locker.cpp +++ b/stglibs/locker.lib/locker.cpp @@ -24,13 +24,11 @@ $Author: nobunaga $ */ - +#ifdef DEBUG_LOCKER #include -#include "locker.h" - -#ifdef DEBUG_LOCKER +#include "stg/locker.h" long long STG_LOCKER::id = 0; pthread_mutex_t STG_LOCKER::lockerMutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/stglibs/logger.lib/logger.cpp b/stglibs/logger.lib/logger.cpp index 215c6392..d8558199 100644 --- a/stglibs/logger.lib/logger.cpp +++ b/stglibs/logger.lib/logger.cpp @@ -2,7 +2,7 @@ #include #include -#include "logger.h" +#include "stg/logger.h" #ifdef STG_TIME extern const volatile time_t stgTime; diff --git a/stglibs/pinger.lib/Makefile b/stglibs/pinger.lib/Makefile index f0aac6d3..c8c09b3e 100644 --- a/stglibs/pinger.lib/Makefile +++ b/stglibs/pinger.lib/Makefile @@ -10,6 +10,9 @@ INCS = pinger.h LIBS = $(LIB_THREAD) +LIB_INCS = -I ../locker.lib/include \ + -I ../common.lib/include + include ../Makefile.in test: all diff --git a/stglibs/pinger.lib/pinger.cpp b/stglibs/pinger.lib/pinger.cpp index af761ffa..664367e8 100644 --- a/stglibs/pinger.lib/pinger.cpp +++ b/stglibs/pinger.lib/pinger.cpp @@ -18,7 +18,7 @@ #include "stg/common.h" #include "stg/locker.h" -#include "pinger.h" +#include "stg/pinger.h" #ifdef STG_TIME extern volatile time_t stgTime; diff --git a/stglibs/scriptexecuter.lib/scriptexecuter.c b/stglibs/scriptexecuter.lib/scriptexecuter.c index 021407dd..462d310b 100644 --- a/stglibs/scriptexecuter.lib/scriptexecuter.c +++ b/stglibs/scriptexecuter.lib/scriptexecuter.c @@ -1,15 +1,14 @@ #include #include #include + #include #include - #include #include #include -#include "scriptexecuter.h" - +#include "stg/scriptexecuter.h" #define MAX_SCRIPT_LEN (1100) diff --git a/stglibs/smux.lib/Makefile b/stglibs/smux.lib/Makefile index 9663b8cd..c5824be9 100644 --- a/stglibs/smux.lib/Makefile +++ b/stglibs/smux.lib/Makefile @@ -4,9 +4,11 @@ LIB_NAME = stgsmux SRCS = $(wildcard *.c) -INCS = $(wildcard *.h) +INCS = $(wildcard include/stg/*.h) -.PHONY: asn1 +LIB_INCS = -I ./include/stg + +#.PHONY: asn1 #ASN1_SOURCES = RFC1213-MIB.asn1 \ # RFC1155-SMI.asn1 \ diff --git a/stglibs/srvconf.lib/Makefile b/stglibs/srvconf.lib/Makefile index 328d8d33..e3bfa762 100644 --- a/stglibs/srvconf.lib/Makefile +++ b/stglibs/srvconf.lib/Makefile @@ -15,4 +15,7 @@ SRCS = netunit.cpp \ INCS = servconf.h \ netunit.h +LIB_INCS = -I ../common.lib/include \ + -I ../crypto.lib/include + include ../Makefile.in diff --git a/stglibs/srvconf.lib/netunit.cpp b/stglibs/srvconf.lib/netunit.cpp index 7f304e2a..9a653d5b 100644 --- a/stglibs/srvconf.lib/netunit.cpp +++ b/stglibs/srvconf.lib/netunit.cpp @@ -32,7 +32,7 @@ #include #include -#include "netunit.h" +#include "stg/netunit.h" #include "stg/common.h" //--------------------------------------------------------------------------- diff --git a/stglibs/srvconf.lib/parser.cpp b/stglibs/srvconf.lib/parser.cpp index 0038f03d..a87266eb 100644 --- a/stglibs/srvconf.lib/parser.cpp +++ b/stglibs/srvconf.lib/parser.cpp @@ -35,7 +35,7 @@ #include "stg/common.h" #include "stg/const.h" -#include "servconf.h" +#include "stg/servconf.h" using namespace std; diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index a28e2e86..ab386cf7 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -28,7 +28,7 @@ #include #include "stg/common.h" -#include "servconf.h" +#include "stg/servconf.h" using namespace std;