From 6fe4d1c2e5626a47773f12c9f620f512cb21e1c9 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 10:18:58 +0800 Subject: [PATCH 01/25] create tun on linux only --- Common/DDHandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/DDHandler.cpp b/Common/DDHandler.cpp index cab79e6..0663450 100644 --- a/Common/DDHandler.cpp +++ b/Common/DDHandler.cpp @@ -27,8 +27,10 @@ #include #include #include +#if defined(__linux__) #include #include +#endif #include #endif @@ -103,7 +105,7 @@ void CDDHandler::initialise(unsigned int maxRoutes, const wxString& name) // Add a dummy entry for "DX-Cluster" multicast m_list[2] = new CEthernet(DX_MULTICAST_ADDRESS, wxT("CQCQCQ ")); -#if !defined(WIN32) +#if defined(__linux__) m_fd = ::open("/dev/net/tun", O_RDWR); if (m_fd < 0) { wxLogError(wxT("Cannot open /dev/net/tun")); From 828fd275a7a0b50d4f366c1bf9cf6825956f7199 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 10:50:39 +0800 Subject: [PATCH 02/25] Config naming fix --- ircDDBGateway/IRCDDBGatewayDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ircDDBGateway/IRCDDBGatewayDefs.h b/ircDDBGateway/IRCDDBGatewayDefs.h index 9eac8a0..db5a10c 100644 --- a/ircDDBGateway/IRCDDBGatewayDefs.h +++ b/ircDDBGateway/IRCDDBGatewayDefs.h @@ -23,7 +23,7 @@ const wxString APPLICATION_NAME = wxT("ircDDB Gateway"); -const wxString CONFIG_FILE_NAME = wxT("ircddbgateway"); +const wxString CONFIG_FILE_NAME = wxT("ircDDBGateway.ini"); const wxString STATUS1_FILE_NAME = wxT("status1.txt"); const wxString STATUS2_FILE_NAME = wxT("status2.txt"); From 3cf02e25bdee38baf182cfafcc0be4a5607c0f3f Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 11:07:56 +0800 Subject: [PATCH 03/25] patch for openwrt --- Common/Makefile | 2 ++ Makefile | 17 ++--------------- common.mk | 27 +++++++++++++++++++++++++++ ircDDB/Makefile | 2 ++ ircDDBGateway/Makefile | 2 ++ 5 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 common.mk diff --git a/Common/Makefile b/Common/Makefile index 8643148..a71fdbf 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,3 +1,5 @@ +include ../common.mk + OBJECTS = AMBEData.o AnnouncementUnit.o APRSCollector.o APRSWriter.o APRSWriterThread.o AudioUnit.o CacheManager.o CallsignList.o \ CallsignServer.o CCITTChecksum.o CCSData.o CCSHandler.o CCSProtocolHandler.o ConnectData.o DCSHandler.o DCSProtocolHandler.o \ DCSProtocolHandlerPool.o DDData.o DDHandler.o DExtraHandler.o DExtraProtocolHandler.o DExtraProtocolHandlerPool.o \ diff --git a/Makefile b/Makefile index e3c3283..fb7e425 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,6 @@ -export DATADIR := "/usr/share/ircddbgateway" -export LOGDIR := "/var/log" -export CONFDIR := "/etc" -export BINDIR := "/usr/bin" +include common.mk -# Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet -# Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet - -export CXX := $(shell wx-config --cxx) -export CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' -export GUILIBS := $(shell wx-config --libs adv,core,base) -export LIBS := $(shell wx-config --libs base) -export LDFLAGS := - -all: ircDDBGateway/ircddbgatewayd ircDDBGatewayConfig/ircddbgatewayconfig APRSTransmit/aprstransmitd RemoteControl/remotecontrold \ - StarNetServer/starnetserverd TextTransmit/texttransmitd TimerControl/timercontrold TimeServer/timeserverd VoiceTransmit/voicetransmitd +all: ircDDBGateway/ircddbgatewayd ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a make -C ircDDBGateway diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..16e0902 --- /dev/null +++ b/common.mk @@ -0,0 +1,27 @@ + +# Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet +# Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet + +ifeq ($(OPENWRT),1) +DATADIR := "/etc/mmdvm/ircddbgateway" +LOGDIR := "/var/log/mmdvm" +CONFDIR := "/etc" +BINDIR := "/usr/bin" + +CFLAGS += -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' +LIBS += -lwxbase_u +LDFLAGS := + +else +DATADIR := "/usr/share/ircddbgateway" +LOGDIR := "/var/log" +CONFDIR := "/etc" +BINDIR := "/usr/bin" + +CXX := $(shell wx-config --cxx) +CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' +GUILIBS := $(shell wx-config --libs adv,core,base) +LIBS := $(shell wx-config --libs base) +LDFLAGS := + +endif diff --git a/ircDDB/Makefile b/ircDDB/Makefile index b841a5e..f93728e 100644 --- a/ircDDB/Makefile +++ b/ircDDB/Makefile @@ -1,3 +1,5 @@ +include ../common.mk + OBJECTS = IRCClient.o IRCDDBApp.o IRCDDBClient.o IRCDDB.o IRCDDBMultiClient.o IRCMessage.o IRCMessageQueue.o IRCProtocol.o IRCReceiver.o \ IRCutils.o diff --git a/ircDDBGateway/Makefile b/ircDDBGateway/Makefile index 3bf974e..62016ab 100644 --- a/ircDDBGateway/Makefile +++ b/ircDDBGateway/Makefile @@ -1,3 +1,5 @@ +include ../common.mk + OBJECTS = IRCDDBGatewayAppD.o IRCDDBGatewayStatusData.o IRCDDBGatewayThread.o IRCDDBGatewayThreadHelper.o all: ircddbgatewayd From 633d972ec4d8236b41b8907e783b262ae4985697 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 12:12:24 +0800 Subject: [PATCH 04/25] Fix link parameters --- common.mk | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/common.mk b/common.mk index 16e0902..e2a7724 100644 --- a/common.mk +++ b/common.mk @@ -2,26 +2,25 @@ # Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet # Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet -ifeq ($(OPENWRT),1) DATADIR := "/etc/mmdvm/ircddbgateway" LOGDIR := "/var/log/mmdvm" CONFDIR := "/etc" BINDIR := "/usr/bin" CFLAGS += -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' -LIBS += -lwxbase_u +LIBS += LDFLAGS := -else -DATADIR := "/usr/share/ircddbgateway" -LOGDIR := "/var/log" -CONFDIR := "/etc" -BINDIR := "/usr/bin" +# else +# DATADIR := "/usr/share/ircddbgateway" +# LOGDIR := "/var/log" +# CONFDIR := "/etc" +# BINDIR := "/usr/bin" -CXX := $(shell wx-config --cxx) -CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' -GUILIBS := $(shell wx-config --libs adv,core,base) -LIBS := $(shell wx-config --libs base) -LDFLAGS := +# CXX := $(shell wx-config --cxx) +# CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' +# GUILIBS := $(shell wx-config --libs adv,core,base) +# LIBS := $(shell wx-config --libs base) +# LDFLAGS := -endif +# endif From fef8348052e650fa2f139c7ab834428f35aa176f Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 12:13:41 +0800 Subject: [PATCH 05/25] Fix compile error under openwrt --- Common/APRSWriterThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/APRSWriterThread.cpp b/Common/APRSWriterThread.cpp index 6c97d62..1a769ba 100644 --- a/Common/APRSWriterThread.cpp +++ b/Common/APRSWriterThread.cpp @@ -216,7 +216,7 @@ bool CAPRSWriterThread::connect() m_socket.close(); return false; } - wxLogMessage(wxT("Received login banner : ") + serverResponse); + wxLogMessage(wxT("Received login banner : %s") + serverResponse.c_str()); wxString filter(m_filter); if (filter.Length() > 0) filter.Prepend(wxT(" filter ")); @@ -242,7 +242,7 @@ bool CAPRSWriterThread::connect() return false; } - wxLogMessage(wxT("Response from APRS server: ") + serverResponse); + wxLogMessage(wxT("Response from APRS server: %s") + serverResponse.c_str()); wxLogMessage(wxT("Connected to the APRS server")); From 5e86cdb93a4660fe817dae9dad9822c5255c44fa Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 12:17:13 +0800 Subject: [PATCH 06/25] fix the fix --- Common/APRSWriterThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/APRSWriterThread.cpp b/Common/APRSWriterThread.cpp index 1a769ba..240974b 100644 --- a/Common/APRSWriterThread.cpp +++ b/Common/APRSWriterThread.cpp @@ -216,7 +216,7 @@ bool CAPRSWriterThread::connect() m_socket.close(); return false; } - wxLogMessage(wxT("Received login banner : %s") + serverResponse.c_str()); + wxLogMessage(wxT("Received login banner : %s"), serverResponse.c_str()); wxString filter(m_filter); if (filter.Length() > 0) filter.Prepend(wxT(" filter ")); @@ -242,7 +242,7 @@ bool CAPRSWriterThread::connect() return false; } - wxLogMessage(wxT("Response from APRS server: %s") + serverResponse.c_str()); + wxLogMessage(wxT("Response from APRS server: %s"), serverResponse.c_str()); wxLogMessage(wxT("Connected to the APRS server")); From 67e45b1bf1888b5c132052e38fe1453ab5fcbd2e Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 12:40:34 +0800 Subject: [PATCH 07/25] Try to work --- Common/DStarDefines.h | 1 + GlobalDefines.h | 11 +++++++++++ Makefile | 7 ++++++- common.mk | 26 -------------------------- 4 files changed, 18 insertions(+), 27 deletions(-) create mode 100644 GlobalDefines.h diff --git a/Common/DStarDefines.h b/Common/DStarDefines.h index 8ea9ae6..9a0b1f0 100644 --- a/Common/DStarDefines.h +++ b/Common/DStarDefines.h @@ -15,6 +15,7 @@ #define DStarDefines_H #include +#include "GlobalDefines.h" const unsigned int DSTAR_GMSK_SYMBOL_RATE = 4800U; const float DSTAR_GMSK_BT = 0.5F; diff --git a/GlobalDefines.h b/GlobalDefines.h new file mode 100644 index 0000000..c83a798 --- /dev/null +++ b/GlobalDefines.h @@ -0,0 +1,11 @@ +#ifndef __GLOBAL_DEFS__ +#define __GLOBAL_DEFS__ + +#ifndef DATA_DIR +#define DATA_DIR "/etc/mmdvm/ircddbgateway" +#define LOG_DIR "/var/log/mmdvm" +#define CONF_DIR "/etc" +#define BIN_DIR "/usr/bin" +#endif + +#endif diff --git a/Makefile b/Makefile index fb7e425..e14b3d3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,9 @@ -include common.mk + +# CXX := $(shell wx-config --cxx) +# CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' +# GUILIBS := $(shell wx-config --libs adv,core,base) +# LIBS := $(shell wx-config --libs base) +# LDFLAGS := all: ircDDBGateway/ircddbgatewayd diff --git a/common.mk b/common.mk index e2a7724..e69de29 100644 --- a/common.mk +++ b/common.mk @@ -1,26 +0,0 @@ - -# Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet -# Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet - -DATADIR := "/etc/mmdvm/ircddbgateway" -LOGDIR := "/var/log/mmdvm" -CONFDIR := "/etc" -BINDIR := "/usr/bin" - -CFLAGS += -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' -LIBS += -LDFLAGS := - -# else -# DATADIR := "/usr/share/ircddbgateway" -# LOGDIR := "/var/log" -# CONFDIR := "/etc" -# BINDIR := "/usr/bin" - -# CXX := $(shell wx-config --cxx) -# CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' -# GUILIBS := $(shell wx-config --libs adv,core,base) -# LIBS := $(shell wx-config --libs base) -# LDFLAGS := - -# endif From 169db8e466d33d60ee58adef112adde875e82be8 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 20:18:42 +0800 Subject: [PATCH 08/25] extract file names to global defs --- Common/DStarDefines.h | 2 +- GlobalDefines.h | 22 ++++++++++++++++++---- Makefile | 11 +++++------ ircDDBGateway/IRCDDBGatewayAppD.cpp | 4 +++- ircDDBGateway/IRCDDBGatewayDefs.h | 3 ++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Common/DStarDefines.h b/Common/DStarDefines.h index 9a0b1f0..e624cd1 100644 --- a/Common/DStarDefines.h +++ b/Common/DStarDefines.h @@ -15,7 +15,7 @@ #define DStarDefines_H #include -#include "GlobalDefines.h" +#include "../GlobalDefines.h" const unsigned int DSTAR_GMSK_SYMBOL_RATE = 4800U; const float DSTAR_GMSK_BT = 0.5F; diff --git a/GlobalDefines.h b/GlobalDefines.h index c83a798..d9a8a8c 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -1,11 +1,25 @@ #ifndef __GLOBAL_DEFS__ #define __GLOBAL_DEFS__ -#ifndef DATA_DIR -#define DATA_DIR "/etc/mmdvm/ircddbgateway" +#if defined(__APPLE__) +#define DATA_DIR "/etc/mmdvm/dstar" #define LOG_DIR "/var/log/mmdvm" #define CONF_DIR "/etc" -#define BIN_DIR "/usr/bin" -#endif +#define CONF_FILE "ircDDBGateway.ini" +#define LOG_BASE "ircDDBGateway" + +#elif defined(OPENWRT) && OPENWRT == 1 +#define DATA_DIR "/etc/mmdvm/dstar" +#define LOG_DIR "/var/log/mmdvm" +#define CONF_DIR "/etc" +#define CONF_FILE "ircDDBGateway.ini" +#define LOG_BASE "ircDDBGateway" + +#else +#define DATA_DIR "/usr/share/ircddbgateway" +#define LOG_DIR "/tmp" +#define CONF_DIR "/etc" +#define CONF_FILE "ircddbgateway" +#define LOG_BASE "ircddbgateway" #endif diff --git a/Makefile b/Makefile index e14b3d3..670c12d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,8 @@ - -# CXX := $(shell wx-config --cxx) -# CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' -# GUILIBS := $(shell wx-config --libs adv,core,base) -# LIBS := $(shell wx-config --libs base) -# LDFLAGS := +# export CXX ?= $(shell wx-config --cxx) +# export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) +# export GUILIBS ?= $(shell wx-config --libs adv,core,base) +# export LIBS ?= $(shell wx-config --libs base) +# export LDFLAGS ?= all: ircDDBGateway/ircddbgatewayd diff --git a/ircDDBGateway/IRCDDBGatewayAppD.cpp b/ircDDBGateway/IRCDDBGatewayAppD.cpp index 0132c92..556280b 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.cpp +++ b/ircDDBGateway/IRCDDBGatewayAppD.cpp @@ -42,13 +42,15 @@ #include #include +#include "../GlobalDefines.h" + const wxChar* NAME_PARAM = wxT("Gateway Name"); const wxChar* NOLOGGING_SWITCH = wxT("nolog"); const wxChar* LOGDIR_OPTION = wxT("logdir"); const wxChar* CONFDIR_OPTION = wxT("confdir"); const wxChar* DAEMON_SWITCH = wxT("daemon"); -const wxString LOG_BASE_NAME = wxT("ircddbgatewayd"); +const wxString LOG_BASE_NAME = wxT("LOG_BASE"); static CIRCDDBGatewayAppD* m_gateway = NULL; diff --git a/ircDDBGateway/IRCDDBGatewayDefs.h b/ircDDBGateway/IRCDDBGatewayDefs.h index db5a10c..7806c3b 100644 --- a/ircDDBGateway/IRCDDBGatewayDefs.h +++ b/ircDDBGateway/IRCDDBGatewayDefs.h @@ -20,10 +20,11 @@ #define IRCDDBGatewayDefs_H #include +#include "../GlobalDefines.h" const wxString APPLICATION_NAME = wxT("ircDDB Gateway"); -const wxString CONFIG_FILE_NAME = wxT("ircDDBGateway.ini"); +const wxString CONFIG_FILE_NAME = wxT(CONF_FILE); const wxString STATUS1_FILE_NAME = wxT("status1.txt"); const wxString STATUS2_FILE_NAME = wxT("status2.txt"); From 69f5532e4582f516b5e347cbff2c1f388bbe27f5 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 20:21:05 +0800 Subject: [PATCH 09/25] Fix broken ifdef --- GlobalDefines.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GlobalDefines.h b/GlobalDefines.h index d9a8a8c..b70ff1d 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -23,3 +23,5 @@ #define LOG_BASE "ircddbgateway" #endif + +#endif From c4641b035602d7a2497691e010b22603408f47d8 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 20:31:35 +0800 Subject: [PATCH 10/25] Fix LOG_BASE def --- ircDDBGateway/IRCDDBGatewayAppD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ircDDBGateway/IRCDDBGatewayAppD.cpp b/ircDDBGateway/IRCDDBGatewayAppD.cpp index 556280b..b9ce115 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.cpp +++ b/ircDDBGateway/IRCDDBGatewayAppD.cpp @@ -50,7 +50,7 @@ const wxChar* LOGDIR_OPTION = wxT("logdir"); const wxChar* CONFDIR_OPTION = wxT("confdir"); const wxChar* DAEMON_SWITCH = wxT("daemon"); -const wxString LOG_BASE_NAME = wxT("LOG_BASE"); +const wxString LOG_BASE_NAME = wxT(LOG_BASE); static CIRCDDBGatewayAppD* m_gateway = NULL; From 1e933b412093ca1528299eefebb12bcdbf27954b Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 5 Oct 2018 21:31:34 +0800 Subject: [PATCH 11/25] Clean up --- Common/Makefile | 2 -- GlobalDefines.h | 8 ++++---- common.mk | 0 ircDDB/Makefile | 2 -- ircDDBGateway/Makefile | 2 -- 5 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 common.mk diff --git a/Common/Makefile b/Common/Makefile index a71fdbf..8643148 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,5 +1,3 @@ -include ../common.mk - OBJECTS = AMBEData.o AnnouncementUnit.o APRSCollector.o APRSWriter.o APRSWriterThread.o AudioUnit.o CacheManager.o CallsignList.o \ CallsignServer.o CCITTChecksum.o CCSData.o CCSHandler.o CCSProtocolHandler.o ConnectData.o DCSHandler.o DCSProtocolHandler.o \ DCSProtocolHandlerPool.o DDData.o DDHandler.o DExtraHandler.o DExtraProtocolHandler.o DExtraProtocolHandlerPool.o \ diff --git a/GlobalDefines.h b/GlobalDefines.h index b70ff1d..c5317a5 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -2,9 +2,9 @@ #define __GLOBAL_DEFS__ #if defined(__APPLE__) -#define DATA_DIR "/etc/mmdvm/dstar" -#define LOG_DIR "/var/log/mmdvm" -#define CONF_DIR "/etc" +#define DATA_DIR "/opt/mmdvm/conf/dstar" +#define LOG_DIR "/opt/mmdvm/logs" +#define CONF_DIR "/opt/mmdvm/conf" #define CONF_FILE "ircDDBGateway.ini" #define LOG_BASE "ircDDBGateway" @@ -20,7 +20,7 @@ #define LOG_DIR "/tmp" #define CONF_DIR "/etc" #define CONF_FILE "ircddbgateway" -#define LOG_BASE "ircddbgateway" +#define LOG_BASE "ircddbgatewayd" #endif diff --git a/common.mk b/common.mk deleted file mode 100644 index e69de29..0000000 diff --git a/ircDDB/Makefile b/ircDDB/Makefile index f93728e..b841a5e 100644 --- a/ircDDB/Makefile +++ b/ircDDB/Makefile @@ -1,5 +1,3 @@ -include ../common.mk - OBJECTS = IRCClient.o IRCDDBApp.o IRCDDBClient.o IRCDDB.o IRCDDBMultiClient.o IRCMessage.o IRCMessageQueue.o IRCProtocol.o IRCReceiver.o \ IRCutils.o diff --git a/ircDDBGateway/Makefile b/ircDDBGateway/Makefile index 62016ab..3bf974e 100644 --- a/ircDDBGateway/Makefile +++ b/ircDDBGateway/Makefile @@ -1,5 +1,3 @@ -include ../common.mk - OBJECTS = IRCDDBGatewayAppD.o IRCDDBGatewayStatusData.o IRCDDBGatewayThread.o IRCDDBGatewayThreadHelper.o all: ircddbgatewayd From e3facce658b0edd9514c79e7e44d37266723904c Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Sun, 7 Oct 2018 00:47:15 +0800 Subject: [PATCH 12/25] add debug param to reduce logs --- Common/Logger.cpp | 8 +++++++- Common/XLXHostsFileDownloader.cpp | 1 + ircDDBGateway/IRCDDBGatewayAppD.cpp | 16 +++++++++++++--- ircDDBGateway/IRCDDBGatewayAppD.h | 3 ++- ircDDBGateway/IRCDDBGatewayThread.cpp | 16 ++++++++-------- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index 8edd3b1..26f5422 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -80,7 +80,13 @@ void CLogger::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogReco default: letter = wxT("U"); break; } - struct tm* tm = ::gmtime(&info.timestamp); + bool utc = false; + struct tm* tm; + if (utc){ + tm = ::gmtime(&info.timestamp); + }else{ + tm = ::localtime(&info.timestamp); + } wxString message; message.Printf(wxT("%s: %04d-%02d-%02d %02d:%02d:%02d: %s\n"), letter.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msg.c_str()); diff --git a/Common/XLXHostsFileDownloader.cpp b/Common/XLXHostsFileDownloader.cpp index bcf86de..633d9f8 100644 --- a/Common/XLXHostsFileDownloader.cpp +++ b/Common/XLXHostsFileDownloader.cpp @@ -29,6 +29,7 @@ wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL) { #ifdef XLX_USE_WGET wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_")); + wxLogMessage(_T("Downloading XLX host file...")); wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL; bool execResult = wxShell(commandLine); diff --git a/ircDDBGateway/IRCDDBGatewayAppD.cpp b/ircDDBGateway/IRCDDBGatewayAppD.cpp index b9ce115..741763c 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.cpp +++ b/ircDDBGateway/IRCDDBGatewayAppD.cpp @@ -49,6 +49,7 @@ const wxChar* NOLOGGING_SWITCH = wxT("nolog"); const wxChar* LOGDIR_OPTION = wxT("logdir"); const wxChar* CONFDIR_OPTION = wxT("confdir"); const wxChar* DAEMON_SWITCH = wxT("daemon"); +const wxChar* DEBUG_SWITCH = wxT("debug"); const wxString LOG_BASE_NAME = wxT(LOG_BASE); @@ -70,6 +71,7 @@ int main(int argc, char** argv) wxCmdLineParser parser(argc, argv); parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL); parser.AddSwitch(DAEMON_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL); + parser.AddSwitch(DEBUG_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL); parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddParam(NAME_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); @@ -82,6 +84,7 @@ int main(int argc, char** argv) bool nolog = parser.Found(NOLOGGING_SWITCH); bool daemon = parser.Found(DAEMON_SWITCH); + bool debug = parser.Found(DEBUG_SWITCH); wxString logDir; bool found = parser.Found(LOGDIR_OPTION, &logDir); @@ -137,7 +140,7 @@ int main(int argc, char** argv) ::fclose(fp); } - m_gateway = new CIRCDDBGatewayAppD(nolog, logDir, confDir, name); + m_gateway = new CIRCDDBGatewayAppD(nolog, debug, logDir, confDir, name); if (!m_gateway->init()) { ::wxUninitialize(); return 1; @@ -156,9 +159,10 @@ int main(int argc, char** argv) return 0; } -CIRCDDBGatewayAppD::CIRCDDBGatewayAppD(bool nolog, const wxString& logDir, const wxString& confDir, const wxString& name) : +CIRCDDBGatewayAppD::CIRCDDBGatewayAppD(bool nolog, bool debug, const wxString& logDir, const wxString& confDir, const wxString& name) : m_name(name), m_nolog(nolog), +m_debug(debug), m_logDir(logDir), m_confDir(confDir), m_thread(NULL), @@ -184,7 +188,13 @@ bool CIRCDDBGatewayAppD::init() wxLog* log = new CLogger(m_logDir, logBaseName); wxLog::SetActiveTarget(log); - wxLog::SetVerbose(); + if (m_debug){ + wxLog::SetVerbose(); + wxLog::SetLogLevel(wxLOG_Debug); + }else{ + wxLog::SetVerbose(false); + wxLog::SetLogLevel(wxLOG_Message); + } } else { new wxLogNull; } diff --git a/ircDDBGateway/IRCDDBGatewayAppD.h b/ircDDBGateway/IRCDDBGatewayAppD.h index bee1aa4..d3bbff7 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.h +++ b/ircDDBGateway/IRCDDBGatewayAppD.h @@ -28,7 +28,7 @@ class CIRCDDBGatewayAppD { public: - CIRCDDBGatewayAppD(bool nolog, const wxString& logDir, const wxString& confDir, const wxString& name); + CIRCDDBGatewayAppD(bool nolog, bool debug, const wxString& logDir, const wxString& confDir, const wxString& name); ~CIRCDDBGatewayAppD(); bool init(); @@ -40,6 +40,7 @@ public: private: wxString m_name; bool m_nolog; + bool m_debug; wxString m_logDir; wxString m_confDir; CIRCDDBGatewayThread* m_thread; diff --git a/ircDDBGateway/IRCDDBGatewayThread.cpp b/ircDDBGateway/IRCDDBGatewayThread.cpp index 268a04d..b138d75 100644 --- a/ircDDBGateway/IRCDDBGatewayThread.cpp +++ b/ircDDBGateway/IRCDDBGatewayThread.cpp @@ -684,19 +684,19 @@ void CIRCDDBGatewayThread::processIrcDDB() case 0: case 10: if (m_lastStatus != IS_DISCONNECTED) { - wxLogInfo(wxT("Disconnected from ircDDB")); + wxLogMessage(wxT("Disconnected from ircDDB")); m_lastStatus = IS_DISCONNECTED; } break; case 7: if (m_lastStatus != IS_CONNECTED) { - wxLogInfo(wxT("Connected to ircDDB")); + wxLogMessage(wxT("Connected to ircDDB")); m_lastStatus = IS_CONNECTED; } break; default: if (m_lastStatus != IS_CONNECTING) { - wxLogInfo(wxT("Connecting to ircDDB")); + wxLogMessage(wxT("Connecting to ircDDB")); m_lastStatus = IS_CONNECTING; } break; @@ -717,10 +717,10 @@ void CIRCDDBGatewayThread::processIrcDDB() break; if (!address.IsEmpty()) { - wxLogMessage(wxT("USER: %s %s %s %s"), user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str()); + wxLogInfo(wxT("USER: %s %s %s %s"), user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str()); m_cache.updateUser(user, repeater, gateway, address, timestamp, DP_DEXTRA, false, false); } else { - wxLogMessage(wxT("USER: %s NOT FOUND"), user.c_str()); + wxLogInfo(wxT("USER: %s NOT FOUND"), user.c_str()); } } break; @@ -733,7 +733,7 @@ void CIRCDDBGatewayThread::processIrcDDB() CRepeaterHandler::resolveRepeater(repeater, gateway, address, DP_DEXTRA); if (!address.IsEmpty()) { - wxLogMessage(wxT("REPEATER: %s %s %s"), repeater.c_str(), gateway.c_str(), address.c_str()); + wxLogInfo(wxT("REPEATER: %s %s %s"), repeater.c_str(), gateway.c_str(), address.c_str()); m_cache.updateRepeater(repeater, gateway, address, DP_DEXTRA, false, false); } else { wxLogMessage(wxT("REPEATER: %s NOT FOUND"), repeater.c_str()); @@ -750,7 +750,7 @@ void CIRCDDBGatewayThread::processIrcDDB() CDExtraHandler::gatewayUpdate(gateway, address); CDPlusHandler::gatewayUpdate(gateway, address); if (!address.IsEmpty()) { - wxLogMessage(wxT("GATEWAY: %s %s"), gateway.c_str(), address.c_str()); + wxLogInfo(wxT("GATEWAY: %s %s"), gateway.c_str(), address.c_str()); m_cache.updateGateway(gateway, address, DP_DEXTRA, false, false); } else { wxLogMessage(wxT("GATEWAY: %s NOT FOUND"), gateway.c_str()); @@ -794,7 +794,7 @@ void CIRCDDBGatewayThread::processRepeater(IRepeaterProtocolHandler* handler) if (!repeater.IsSameAs(user)) { CRepeaterHandler* handler = CRepeaterHandler::findDVRepeater(repeater); if (handler == NULL) - wxLogMessage(wxT("Heard received from unknown repeater, %s"), repeater.c_str()); + wxLogInfo(wxT("Heard received from unknown repeater, %s"), repeater.c_str()); else handler->processRepeater(*heard); From dcb1a8a5660ef170f4b79b6491acab961572712b Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 13:40:06 +0800 Subject: [PATCH 13/25] Update DStarGateway Global Defs --- Common/Defs.h | 1 + GlobalDefines.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Common/Defs.h b/Common/Defs.h index f2c5c31..ca9d950 100644 --- a/Common/Defs.h +++ b/Common/Defs.h @@ -20,6 +20,7 @@ #define Defs_H #include +#include "../GlobalDefines.h" const wxString DEXTRA_HOSTS_FILE_NAME = wxT("DExtra_Hosts.txt"); const wxString DPLUS_HOSTS_FILE_NAME = wxT("DPlus_Hosts.txt"); diff --git a/GlobalDefines.h b/GlobalDefines.h index c5317a5..fbfa10b 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -6,21 +6,18 @@ #define LOG_DIR "/opt/mmdvm/logs" #define CONF_DIR "/opt/mmdvm/conf" #define CONF_FILE "ircDDBGateway.ini" -#define LOG_BASE "ircDDBGateway" #elif defined(OPENWRT) && OPENWRT == 1 #define DATA_DIR "/etc/mmdvm/dstar" #define LOG_DIR "/var/log/mmdvm" #define CONF_DIR "/etc" #define CONF_FILE "ircDDBGateway.ini" -#define LOG_BASE "ircDDBGateway" #else #define DATA_DIR "/usr/share/ircddbgateway" #define LOG_DIR "/tmp" #define CONF_DIR "/etc" #define CONF_FILE "ircddbgateway" -#define LOG_BASE "ircddbgatewayd" #endif From dc1f555ceb7593fff5c6d426285caf48276d052e Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 16:43:30 +0800 Subject: [PATCH 14/25] Support local time format on log --- Common/Logger.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index 1976f79..de6bd8f 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -18,6 +18,8 @@ #include "Logger.h" +static bool utc = false; + CLogger::CLogger(const wxString& directory, const wxString& name) : wxLog(), m_name(name), @@ -32,7 +34,12 @@ m_day(0) time_t timestamp; ::time(×tamp); - struct tm* tm = ::gmtime(×tamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(×tamp); + }else{ + tm = ::localtime(×tamp); + } wxString text; text.Printf(wxT("%s-%04d-%02d-%02d"), m_name.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); @@ -75,7 +82,6 @@ void CLogger::DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp) default: letter = wxT("U"); break; } - bool utc = false; struct tm* tm; if (utc){ tm = ::gmtime(×tamp); @@ -98,7 +104,12 @@ void CLogger::DoLogString(const wxChar* msg, time_t timestamp) wxASSERT(m_file->IsOpened()); wxASSERT(msg != NULL); - struct tm* tm = ::gmtime(×tamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(×tamp); + }else{ + tm = ::localtime(×tamp); + } int day = tm->tm_yday; if (day != m_day) { From f8947805a3533932f63ea13ff9fdece312ef5b0b Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 17:18:11 +0800 Subject: [PATCH 15/25] Fix no log issue under openwrt --- Common/Logger.cpp | 3 +++ Common/Logger.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index de6bd8f..936bf37 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -132,3 +132,6 @@ void CLogger::DoLogString(const wxChar* msg, time_t timestamp) m_file->Flush(); } +void CLogger::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) { + DoLog(level, msg.c_str(), info.timestamp); +} \ No newline at end of file diff --git a/Common/Logger.h b/Common/Logger.h index 29523df..8c5c6e3 100644 --- a/Common/Logger.h +++ b/Common/Logger.h @@ -31,6 +31,8 @@ public: virtual void DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp); virtual void DoLogString(const wxChar* msg, time_t timestamp); + virtual void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info); + private: wxString m_name; wxFFile* m_file; From 1ca7e0a24bb3cd0c56aa278e79e85c34a37d3b41 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 17:39:12 +0800 Subject: [PATCH 16/25] Add new makefiles --- Makefile.openwrt | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.osx | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 Makefile.openwrt create mode 100644 Makefile.osx diff --git a/Makefile.openwrt b/Makefile.openwrt new file mode 100644 index 0000000..8e07cf3 --- /dev/null +++ b/Makefile.openwrt @@ -0,0 +1,70 @@ +# export CXX ?= $(shell wx-config --cxx) +# export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) +# export GUILIBS ?= $(shell wx-config --libs adv,core,base) +# export LIBS ?= $(shell wx-config --libs base) +# export LDFLAGS ?= + +all: ircDDBGateway/ircddbgatewayd + +ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C ircDDBGateway + +ircDDBGatewayConfig/ircddbgatewayconfig: GUICommon/GUICommon.a Common/Common.a + $(MAKE) -C ircDDBGatewayConfig + +APRSTransmit/aprstransmitd: Common/Common.a + $(MAKE) -C APRSTransmit + +RemoteControl/remotecontrold: Common/Common.a + $(MAKE) -C RemoteControl + +StarNetServer/starnetserverd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C StarNetServer + +TextTransmit/texttransmitd: Common/Common.a + $(MAKE) -C TextTransmit + +TimerControl/timercontrold: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimerControl + +TimeServer/timeserverd: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimeServer + +VoiceTransmit/voicetransmitd: Common/Common.a + $(MAKE) -C VoiceTransmit + +GUICommon/GUICommon.a: + $(MAKE) -C GUICommon + +Common/Common.a: + $(MAKE) -C Common + +ircDDB/IRCDDB.a: + $(MAKE) -C ircDDB + +install: all + $(MAKE) -C Data install + $(MAKE) -C APRSTransmit install + $(MAKE) -C ircDDBGateway install + $(MAKE) -C RemoteControl install + $(MAKE) -C StarNetServer install + $(MAKE) -C TextTransmit install + $(MAKE) -C TimerControl install + $(MAKE) -C TimeServer install + $(MAKE) -C VoiceTransmit install + $(MAKE) -C ircDDBGatewayConfig install + +clean: + $(MAKE) -C Common clean + $(MAKE) -C ircDDB clean + $(MAKE) -C GUICommon clean + $(MAKE) -C APRSTransmit clean + $(MAKE) -C ircDDBGateway clean + $(MAKE) -C RemoteControl clean + $(MAKE) -C StarNetServer clean + $(MAKE) -C TextTransmit clean + $(MAKE) -C TimerControl clean + $(MAKE) -C TimeServer clean + $(MAKE) -C VoiceTransmit clean + $(MAKE) -C ircDDBGatewayConfig clean + diff --git a/Makefile.osx b/Makefile.osx new file mode 100644 index 0000000..ac25bae --- /dev/null +++ b/Makefile.osx @@ -0,0 +1,70 @@ +export CXX ?= $(shell wx-config --cxx) +export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) +export GUILIBS ?= $(shell wx-config --libs adv,core,base) +export LIBS ?= $(shell wx-config --libs base) +export LDFLAGS ?= + +all: ircDDBGateway/ircddbgatewayd ircDDBGatewayConfig/ircddbgatewayconfig + +ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C ircDDBGateway + +ircDDBGatewayConfig/ircddbgatewayconfig: GUICommon/GUICommon.a Common/Common.a + $(MAKE) -C ircDDBGatewayConfig + +APRSTransmit/aprstransmitd: Common/Common.a + $(MAKE) -C APRSTransmit + +RemoteControl/remotecontrold: Common/Common.a + $(MAKE) -C RemoteControl + +StarNetServer/starnetserverd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C StarNetServer + +TextTransmit/texttransmitd: Common/Common.a + $(MAKE) -C TextTransmit + +TimerControl/timercontrold: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimerControl + +TimeServer/timeserverd: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimeServer + +VoiceTransmit/voicetransmitd: Common/Common.a + $(MAKE) -C VoiceTransmit + +GUICommon/GUICommon.a: + $(MAKE) -C GUICommon + +Common/Common.a: + $(MAKE) -C Common + +ircDDB/IRCDDB.a: + $(MAKE) -C ircDDB + +install: all + $(MAKE) -C Data install + $(MAKE) -C APRSTransmit install + $(MAKE) -C ircDDBGateway install + $(MAKE) -C RemoteControl install + $(MAKE) -C StarNetServer install + $(MAKE) -C TextTransmit install + $(MAKE) -C TimerControl install + $(MAKE) -C TimeServer install + $(MAKE) -C VoiceTransmit install + $(MAKE) -C ircDDBGatewayConfig install + +clean: + $(MAKE) -C Common clean + $(MAKE) -C ircDDB clean + $(MAKE) -C GUICommon clean + $(MAKE) -C APRSTransmit clean + $(MAKE) -C ircDDBGateway clean + $(MAKE) -C RemoteControl clean + $(MAKE) -C StarNetServer clean + $(MAKE) -C TextTransmit clean + $(MAKE) -C TimerControl clean + $(MAKE) -C TimeServer clean + $(MAKE) -C VoiceTransmit clean + $(MAKE) -C ircDDBGatewayConfig clean + From cf22bb061a1caf0b0f92d1f6eca6c6cd3fad4a50 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 17:53:16 +0800 Subject: [PATCH 17/25] Revert the default Makefile --- Makefile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8e07cf3..979fa73 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,19 @@ -# export CXX ?= $(shell wx-config --cxx) -# export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -# export GUILIBS ?= $(shell wx-config --libs adv,core,base) -# export LIBS ?= $(shell wx-config --libs base) -# export LDFLAGS ?= +export DATADIR := "/usr/share/ircddbgateway" +export LOGDIR := "/var/log" +export CONFDIR := "/etc" +export BINDIR := "/usr/bin" -all: ircDDBGateway/ircddbgatewayd +# Add -DDCS_LINK to the end of the CFLAGS line below to add DCS linking to StarNet +# Add -DDEXTRA_LINK to the end of the CFLAGS line below to add DExtra linking to StarNet + +export CXX := $(shell wx-config --cxx) +export CFLAGS := -O2 -Wall $(shell wx-config --cxxflags) -DLOG_DIR='$(LOGDIR)' -DCONF_DIR='$(CONFDIR)' -DDATA_DIR='$(DATADIR)' +export GUILIBS := $(shell wx-config --libs adv,core,base) +export LIBS := $(shell wx-config --libs base) +export LDFLAGS := + +all: ircDDBGateway/ircddbgatewayd ircDDBGatewayConfig/ircddbgatewayconfig APRSTransmit/aprstransmitd RemoteControl/remotecontrold \ + StarNetServer/starnetserverd TextTransmit/texttransmitd TimerControl/timercontrold TimeServer/timeserverd VoiceTransmit/voicetransmitd ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a $(MAKE) -C ircDDBGateway @@ -67,4 +76,3 @@ clean: $(MAKE) -C TimeServer clean $(MAKE) -C VoiceTransmit clean $(MAKE) -C ircDDBGatewayConfig clean - From 970d57b99778684907925c41ac9e414c279db8e7 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 18:00:11 +0800 Subject: [PATCH 18/25] Add compile switch for log in local time --- Common/Logger.cpp | 6 +++++- Makefile.osx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index 936bf37..c64685b 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -18,7 +18,11 @@ #include "Logger.h" -static bool utc = false; +#if defined(LOG_LOCALTIME) && LOG_LOCAL_TIME == 1 +static const bool utc = false; +#else +static const bool utc = true; +#endif CLogger::CLogger(const wxString& directory, const wxString& name) : wxLog(), diff --git a/Makefile.osx b/Makefile.osx index ac25bae..66755cd 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -1,5 +1,5 @@ export CXX ?= $(shell wx-config --cxx) -export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) +export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -DLOG_LOCALTIME=1 export GUILIBS ?= $(shell wx-config --libs adv,core,base) export LIBS ?= $(shell wx-config --libs base) export LDFLAGS ?= From 17af032279a2ef387c459b3ae8501615750d1ce1 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 18:10:05 +0800 Subject: [PATCH 19/25] Fix log issue --- Common/Logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index c64685b..9931f33 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -18,7 +18,7 @@ #include "Logger.h" -#if defined(LOG_LOCALTIME) && LOG_LOCAL_TIME == 1 +#if defined(LOG_LOCALTIME) && LOG_LOCALTIME == 1 static const bool utc = false; #else static const bool utc = true; From 95b7e51c30bd380af948a8469956625a810692bc Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 18:29:09 +0800 Subject: [PATCH 20/25] Extract pid file name to global defs --- GlobalDefines.h | 30 +++++++++++++++++------------ ircDDBGateway/IRCDDBGatewayAppD.cpp | 4 ++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/GlobalDefines.h b/GlobalDefines.h index fbfa10b..08c68ba 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -2,22 +2,28 @@ #define __GLOBAL_DEFS__ #if defined(__APPLE__) -#define DATA_DIR "/opt/mmdvm/conf/dstar" -#define LOG_DIR "/opt/mmdvm/logs" -#define CONF_DIR "/opt/mmdvm/conf" -#define CONF_FILE "ircDDBGateway.ini" +#define DATA_DIR "/opt/mmdvm/conf/dstar" +#define LOG_DIR "/opt/mmdvm/logs" +#define CONF_DIR "/opt/mmdvm/conf" +#define CONF_FILE "ircDDBGateway.ini" +#define PID_FILE "/tmp/ircDDBGateway.pid" +#define PID_FILE_T "/tmp/ircDDBGateway_%s.pid" #elif defined(OPENWRT) && OPENWRT == 1 -#define DATA_DIR "/etc/mmdvm/dstar" -#define LOG_DIR "/var/log/mmdvm" -#define CONF_DIR "/etc" -#define CONF_FILE "ircDDBGateway.ini" +#define DATA_DIR "/etc/mmdvm/dstar" +#define LOG_DIR "/var/log/mmdvm" +#define CONF_DIR "/etc" +#define CONF_FILE "ircDDBGateway.ini" +#define PID_FILE "/tmp/ircDDBGateway.pid" +#define PID_FILE_T "/tmp/ircDDBGateway_%s.pid" #else -#define DATA_DIR "/usr/share/ircddbgateway" -#define LOG_DIR "/tmp" -#define CONF_DIR "/etc" -#define CONF_FILE "ircddbgateway" +#define DATA_DIR "/usr/share/ircddbgateway" +#define LOG_DIR "/tmp" +#define CONF_DIR "/etc" +#define CONF_FILE "ircddbgateway" +#define PID_FILE "/tmp/ircddbgateway.pid" +#define PID_FILE_T "/tmp/ircddbgateway_%s.pid" #endif diff --git a/ircDDBGateway/IRCDDBGatewayAppD.cpp b/ircDDBGateway/IRCDDBGatewayAppD.cpp index a391c52..df485e3 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.cpp +++ b/ircDDBGateway/IRCDDBGatewayAppD.cpp @@ -124,9 +124,9 @@ int main(int argc, char** argv) wxString pidFileName; if (!name.IsEmpty()) - pidFileName.Printf(wxT("/var/run/opendv/ircddbgateway_%s.pid"), name.c_str()); + pidFileName.Printf(wxT(PID_FILE_T), name.c_str()); else - pidFileName = wxT("/var/run/opendv/ircddbgateway.pid"); + pidFileName = wxT(PID_FILE); pidFileName.Replace(wxT(" "), wxT("_")); char fileName[128U]; From 8b70ae399da4b9727f1028cd36a4049683ab56c9 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 18:31:18 +0800 Subject: [PATCH 21/25] Revert the default pid file path to /var/run/ircddbgateway.pid --- GlobalDefines.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GlobalDefines.h b/GlobalDefines.h index 08c68ba..adc4397 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -22,8 +22,8 @@ #define LOG_DIR "/tmp" #define CONF_DIR "/etc" #define CONF_FILE "ircddbgateway" -#define PID_FILE "/tmp/ircddbgateway.pid" -#define PID_FILE_T "/tmp/ircddbgateway_%s.pid" +#define PID_FILE "/var/run/ircddbgateway.pid" +#define PID_FILE_T "/var/run/ircddbgateway_%s.pid" #endif From 75bc1d3488e398ff33c0c90d5caa2b23926a47d5 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 18:45:08 +0800 Subject: [PATCH 22/25] Don't check single instance under OpenWrt --- ircDDBGateway/IRCDDBGatewayAppD.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ircDDBGateway/IRCDDBGatewayAppD.cpp b/ircDDBGateway/IRCDDBGatewayAppD.cpp index df485e3..07d5d35 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.cpp +++ b/ircDDBGateway/IRCDDBGatewayAppD.cpp @@ -199,6 +199,7 @@ bool CIRCDDBGatewayAppD::init() new wxLogNull; } +#if !defined(OPENWRT) || OPENWRT != 1 wxString appName; if (!m_name.IsEmpty()) appName = APPLICATION_NAME + wxT(" ") + m_name; @@ -212,6 +213,7 @@ bool CIRCDDBGatewayAppD::init() wxLogError(wxT("Another copy of the ircDDB Gateway is running, exiting")); return false; } +#endif wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" daemon - ") + VERSION); From 5f0c5993e162a61f52a19feb689e8b17e3c95410 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Thu, 4 Jul 2019 19:12:29 +0800 Subject: [PATCH 23/25] fix merge error --- Common/Logger.cpp | 8 ++------ Common/Logger.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index abe3da9..3747b1b 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -87,9 +87,9 @@ void CLogger::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogReco struct tm* tm; if (utc){ - tm = ::gmtime(×tamp); + tm = ::gmtime(&info.timestamp); }else{ - tm = ::localtime(×tamp); + tm = ::localtime(&info.timestamp); } wxString message; @@ -133,8 +133,4 @@ void CLogger::writeLog(const wxChar* msg, time_t timestamp) m_file->Write(wxString(msg)); m_file->Flush(); -} - -void CLogger::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) { - DoLog(level, msg.c_str(), info.timestamp); } \ No newline at end of file diff --git a/Common/Logger.h b/Common/Logger.h index e95ea32..b9ca2c2 100644 --- a/Common/Logger.h +++ b/Common/Logger.h @@ -30,8 +30,6 @@ public: virtual void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info); - virtual void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info); - private: wxString m_name; wxFFile* m_file; From d8192a9c7f761ff9b96d5269f7353a66bbb4f3bd Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Mon, 9 Dec 2019 14:36:43 +0800 Subject: [PATCH 24/25] add linux server compile --- GlobalDefines.h | 2 +- Makefile.linux | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Makefile.linux diff --git a/GlobalDefines.h b/GlobalDefines.h index adc4397..e17c85a 100644 --- a/GlobalDefines.h +++ b/GlobalDefines.h @@ -1,7 +1,7 @@ #ifndef __GLOBAL_DEFS__ #define __GLOBAL_DEFS__ -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(LINUX) #define DATA_DIR "/opt/mmdvm/conf/dstar" #define LOG_DIR "/opt/mmdvm/logs" #define CONF_DIR "/opt/mmdvm/conf" diff --git a/Makefile.linux b/Makefile.linux new file mode 100644 index 0000000..08e14e1 --- /dev/null +++ b/Makefile.linux @@ -0,0 +1,70 @@ +# export CXX ?= $(shell wx-config --cxx) +# export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -DLOG_LOCALTIME=1 -DLINUX=1 +# export GUILIBS ?= $(shell wx-config --libs adv,core,base) +# export LIBS ?= $(shell wx-config --libs base) +# export LDFLAGS ?= + +all: ircDDBGateway/ircddbgatewayd + +ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C ircDDBGateway + +ircDDBGatewayConfig/ircddbgatewayconfig: GUICommon/GUICommon.a Common/Common.a + $(MAKE) -C ircDDBGatewayConfig + +APRSTransmit/aprstransmitd: Common/Common.a + $(MAKE) -C APRSTransmit + +RemoteControl/remotecontrold: Common/Common.a + $(MAKE) -C RemoteControl + +StarNetServer/starnetserverd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C StarNetServer + +TextTransmit/texttransmitd: Common/Common.a + $(MAKE) -C TextTransmit + +TimerControl/timercontrold: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimerControl + +TimeServer/timeserverd: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimeServer + +VoiceTransmit/voicetransmitd: Common/Common.a + $(MAKE) -C VoiceTransmit + +GUICommon/GUICommon.a: + $(MAKE) -C GUICommon + +Common/Common.a: + $(MAKE) -C Common + +ircDDB/IRCDDB.a: + $(MAKE) -C ircDDB + +install: all + $(MAKE) -C Data install + $(MAKE) -C APRSTransmit install + $(MAKE) -C ircDDBGateway install + $(MAKE) -C RemoteControl install + $(MAKE) -C StarNetServer install + $(MAKE) -C TextTransmit install + $(MAKE) -C TimerControl install + $(MAKE) -C TimeServer install + $(MAKE) -C VoiceTransmit install + $(MAKE) -C ircDDBGatewayConfig install + +clean: + $(MAKE) -C Common clean + $(MAKE) -C ircDDB clean + $(MAKE) -C GUICommon clean + $(MAKE) -C APRSTransmit clean + $(MAKE) -C ircDDBGateway clean + $(MAKE) -C RemoteControl clean + $(MAKE) -C StarNetServer clean + $(MAKE) -C TextTransmit clean + $(MAKE) -C TimerControl clean + $(MAKE) -C TimeServer clean + $(MAKE) -C VoiceTransmit clean + $(MAKE) -C ircDDBGatewayConfig clean + From b51f6435c574d6251aeb55e081ac4b95f5a13041 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Mon, 9 Dec 2019 14:41:07 +0800 Subject: [PATCH 25/25] fix linux compile --- Makefile.linux | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.linux b/Makefile.linux index 08e14e1..e6be2ea 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,8 +1,8 @@ -# export CXX ?= $(shell wx-config --cxx) -# export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -DLOG_LOCALTIME=1 -DLINUX=1 -# export GUILIBS ?= $(shell wx-config --libs adv,core,base) -# export LIBS ?= $(shell wx-config --libs base) -# export LDFLAGS ?= +export CXX ?= $(shell wx-config --cxx) +export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -DLOG_LOCALTIME=1 -DLINUX=1 +export GUILIBS ?= $(shell wx-config --libs adv,core,base) +export LIBS ?= $(shell wx-config --libs base) +export LDFLAGS ?= all: ircDDBGateway/ircddbgatewayd