From 579db99ae203ada9ee1f618fa499c576bb1f22c1 Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Mon, 22 Mar 2021 20:16:35 +0100 Subject: [PATCH] Remove RemoteCommandDMRG, as RemoteCommand from MMDVMHost's PR now works with DMRGatway too. --- Makefile | 3 -- RemoteCommandDMRG.cpp | 111 ------------------------------------------ RemoteCommandDMRG.h | 36 -------------- 3 files changed, 150 deletions(-) delete mode 100644 RemoteCommandDMRG.cpp delete mode 100644 RemoteCommandDMRG.h diff --git a/Makefile b/Makefile index 6542001..f3b7b2c 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,6 @@ all: DMRGateway DMRGateway: GitVersion.h $(OBJECTS) $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o DMRGateway -RemoteCommandDMRG: Log.o RemoteCommandDMRG.o UDPSocket.o - $(CXX) Log.o RemoteCommandDMRG.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommandDMRG - %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< diff --git a/RemoteCommandDMRG.cpp b/RemoteCommandDMRG.cpp deleted file mode 100644 index fbcd39b..0000000 --- a/RemoteCommandDMRG.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2019,2020 by Jonathan Naylor G4KLX - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "RemoteCommandDMRG.h" - -#include "UDPSocket.h" -#include "Log.h" - -#include -#include -#include - -const unsigned int BUFFER_LENGTH = 100U; - -int main(int argc, char** argv) -{ - if (argc < 3) { - ::fprintf(stderr, "Usage: RemoteCommand \n"); - return 1; - } - - unsigned int port = (unsigned int)::atoi(argv[1]); - std::string cmd = std::string(argv[2]); - - for (int i = 3; i < argc; i++) { - cmd += " "; - cmd += std::string(argv[i]); - } - - if (port == 0U) { - ::fprintf(stderr, "RemoteCommand: invalid port number - %s\n", argv[1]); - return 1; - } - - CRemoteCommandDMRG* command = new CRemoteCommandDMRG(port); - - return command->send(cmd); -} - -CRemoteCommandDMRG::CRemoteCommandDMRG(unsigned int port) : -m_port(port) -{ - CUDPSocket::startup(); - - ::LogInitialise(false, ".", "RemoteCommand", 2U, 2U, false); -} - -CRemoteCommandDMRG::~CRemoteCommandDMRG() -{ - ::LogFinalise(); - - CUDPSocket::shutdown(); -} - -int CRemoteCommandDMRG::send(const std::string& command) -{ - sockaddr_storage addr; - unsigned int addrLen; - char buffer[BUFFER_LENGTH]; - int retStatus = 0; - - if (CUDPSocket::lookup("127.0.0.1", m_port, addr, addrLen) != 0) { - LogError("Unable to resolve the address of the host"); - return 1; - } - - CUDPSocket socket(0U); - - bool ret = socket.open(addr); - if (!ret) - return 1; - - ret = socket.write((unsigned char*)command.c_str(), command.length(), addr, addrLen); - if (!ret) { - socket.close(); - return 1; - } - - LogMessage("Command sent: \"%s\" to port: %u", command.c_str(), m_port); - - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - - int len = socket.read((unsigned char*)&buffer[0], BUFFER_LENGTH, addr, addrLen); - if (len > 0) { - buffer[len] = '\0'; - LogMessage("%s", buffer); - } - else - { - retStatus = 1; - } - - socket.close(); - - return retStatus; -} diff --git a/RemoteCommandDMRG.h b/RemoteCommandDMRG.h deleted file mode 100644 index cc74359..0000000 --- a/RemoteCommandDMRG.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 by Jonathan Naylor G4KLX - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef RemoteCommandDMRG_H -#define RemoteCommandDMRG_H - -#include - -class CRemoteCommandDMRG -{ -public: - CRemoteCommandDMRG(unsigned int port); - ~CRemoteCommandDMRG(); - - int send(const std::string& command); - -private: - unsigned int m_port; -}; - -#endif