Fix some bugs
This commit is contained in:
parent
494739c25b
commit
3cc09a70d4
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@ Debug
|
||||||
Release
|
Release
|
||||||
x64
|
x64
|
||||||
MMDVMHost
|
MMDVMHost
|
||||||
|
RemoteCommand
|
||||||
*.o
|
*.o
|
||||||
*.opendb
|
*.opendb
|
||||||
*.bak
|
*.bak
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -20,8 +20,8 @@ all: MMDVMHost RemoteCommand
|
||||||
MMDVMHost: GitVersion.h $(OBJECTS)
|
MMDVMHost: GitVersion.h $(OBJECTS)
|
||||||
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost
|
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost
|
||||||
|
|
||||||
RemoteCommand: RemoteCommand.o UDPSocket.o
|
RemoteCommand: Log.o RemoteCommand.o UDPSocket.o
|
||||||
$(CXX) RemoteCommand.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommand
|
$(CXX) Log.o RemoteCommand.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommand
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -30,16 +31,16 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int port = (unsigned int)::atoi(argv[1]);
|
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) {
|
if (port == 0U) {
|
||||||
::fprintf(stderr, "RemoteCommand: invalid port number - %s\n", argv[1]);
|
::fprintf(stderr, "RemoteCommand: invalid port number - %s\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRemoteCommand command(port);
|
CRemoteCommand* command = new CRemoteCommand(port);
|
||||||
|
|
||||||
return send(command);
|
return command->send(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRemoteCommand::CRemoteCommand(unsigned int port) :
|
CRemoteCommand::CRemoteCommand(unsigned int port) :
|
||||||
|
@ -61,7 +62,7 @@ int CRemoteCommand::send(const std::string& command)
|
||||||
|
|
||||||
in_addr address = CUDPSocket::lookup("localhost");
|
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) {
|
if (!ret) {
|
||||||
socket.close();
|
socket.close();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue