Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
phl0 committed Jan 8, 2019
1 parent 494739c commit 3cc09a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Debug
Release
x64
MMDVMHost
RemoteCommand
*.o
*.opendb
*.bak
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ all: MMDVMHost RemoteCommand
MMDVMHost: GitVersion.h $(OBJECTS)
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost

RemoteCommand: RemoteCommand.o UDPSocket.o
$(CXX) RemoteCommand.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommand
RemoteCommand: Log.o RemoteCommand.o UDPSocket.o
$(CXX) Log.o RemoteCommand.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommand

%.o: %.cpp
$(CXX) $(CFLAGS) -c -o $@ $<
Expand Down
9 changes: 5 additions & 4 deletions RemoteCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "UDPSocket.h"

#include <cstdio>
#include <cstring>

int main(int argc, char** argv)
{
Expand All @@ -30,16 +31,16 @@ int main(int argc, char** argv)
}

unsigned int port = (unsigned int)::atoi(argv[1]);
std::string command = std::string(argv[2]);
std::string cmd = std::string(argv[2]);

if (port == 0U) {
::fprintf(stderr, "RemoteCommand: invalid port number - %s\n", argv[1]);
return 1;
}

CRemoteCommand command(port);
CRemoteCommand* command = new CRemoteCommand(port);

return send(command);
return command->send(cmd);
}

CRemoteCommand::CRemoteCommand(unsigned int port) :
Expand All @@ -61,7 +62,7 @@ int CRemoteCommand::send(const std::string& command)

in_addr address = CUDPSocket::lookup("localhost");

ret = socket.write(command.c_str(), command.len(), address, m_port);
ret = socket.write((const unsigned char* )command.c_str(), command.length(), address, m_port);
if (!ret) {
socket.close();
return 1;
Expand Down

0 comments on commit 3cc09a7

Please sign in to comment.