solving char* to const char* issue

master
Denes Matetelki 12 years ago
parent 571db654dd
commit 7ba50957fa

@ -40,7 +40,7 @@ void setUpArgs(ArgParse &argParse)
} }
void getArgs( int argc, char* argv[], void getArgs( int argc, const char* argv[],
ArgParse &argParse, ArgParse &argParse,
std::string &host, std::string &host,
std::string &user, std::string &user,
@ -61,7 +61,7 @@ void getArgs( int argc, char* argv[],
} }
bool checkArgs( int argc, char* argv[], bool checkArgs( int argc, const char* argv[],
ArgParse &argParse, ArgParse &argParse,
std::string &host, std::string &host,
std::string &user, std::string &user,
@ -108,7 +108,7 @@ void printResults(std::list<std::string> &results)
} }
int main(int argc, char* argv[] ) int main(int argc, const char* argv[] )
{ {
Logger::createInstance(); Logger::createInstance();
Logger::init(std::cout); Logger::init(std::cout);

@ -1,12 +1,12 @@
// gpp sslclient_main.cpp -o sslclient -I../include ../src/Logger.cpp ../src/Thread.cpp ../src/Socket.cpp -lpthread ../src/SocketClient.cpp ../src/Poll.cpp ../src/Connection.cpp ../src/SslConnection.cpp -lssl -lcrypto ../src/TcpConnection.cpp ../src/Addrinfo.cpp
#include "Logger.hpp" #include "Logger.hpp"
#include "Message.hpp" #include "Message.hpp"
#include "SslConnection.hpp" #include "SslConnection.hpp"
#include "SocketClient.hpp" #include "SocketClient.hpp"
#include "../test/SimpleMessage.hpp"
#include <unistd.h>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -15,53 +15,6 @@
#include <Common.hpp> #include <Common.hpp>
class SimpleMessage : public Message
{
public:
SimpleMessage( void *msgParam = 0)
: Message(msgParam)
{
TRACE;
}
bool buildMessage( const void *msgPart,
const size_t msgLen )
{
TRACE;
m_buffer = std::string( (const char*) msgPart, msgLen );
onMessageReady();
return true;
}
void onMessageReady()
{
TRACE;
LOG( Logger::INFO, std::string("Got reply from server: ").
append(m_buffer).c_str() );
*( static_cast<bool*>(m_param) ) = true;
}
Message* clone()
{
TRACE;
return new SimpleMessage(m_param);
}
protected:
size_t getExpectedLength()
{
TRACE;
return 0;
}
};
int main(int argc, char* argv[] ) int main(int argc, char* argv[] )
{ {
if ( argc != 4 ) { if ( argc != 4 ) {

@ -1,6 +1,3 @@
// gpp tcpclient_main.cpp -o client -I../include ../src/Logger.cpp ../src/Thread.cpp ../src/Socket.cpp -lpthread ../src/SocketClient.cpp ../src/Poll.cpp ../src/SocketConnection.cpp ../src/TcpConnection.cpp
#include "Logger.hpp" #include "Logger.hpp"
#include "Common.hpp" #include "Common.hpp"
@ -76,7 +73,6 @@ int main(int argc, char* argv[] )
Logger::setLogLevel(Logger::FINEST); Logger::setLogLevel(Logger::FINEST);
bool finished = false; bool finished = false;
SimpleMessage msg(&finished); SimpleMessage msg(&finished);
TcpConnection conn(argv[1], argv[2], &msg); TcpConnection conn(argv[1], argv[2], &msg);

@ -1,6 +1,3 @@
// gpp tcpserver_main.cpp -o server -I../include ../src/Logger.cpp ../src/Socket.cpp -ggdb ../src/SocketServer.cpp ../src/SocketConnection.cpp ../src/Poll.cpp ../src/TcpConnection.cpp
#include "Logger.hpp" #include "Logger.hpp"
#include "Common.hpp" #include "Common.hpp"

@ -72,7 +72,7 @@ void ArgParse::addArgument(const std::string arg,
void ArgParse::parseArgs(int argc, void ArgParse::parseArgs(int argc,
char* argv[]) const char* argv[])
{ {
std::list<std::string> argList; std::list<std::string> argList;
for (int i = 0; i < argc; ++i ) for (int i = 0; i < argc; ++i )

@ -61,9 +61,9 @@ public:
ArgParse::STRING ); ArgParse::STRING );
int argc = 3; int argc = 3;
char *argv[] = { (char*)"test", const char *argv[] = { "test",
(char*)"-u", "-u",
(char*)"username" }; "username" };
argParse.parseArgs(argc, argv); argParse.parseArgs(argc, argv);
@ -102,12 +102,12 @@ public:
argParse.addArgument("-b", "bool", ArgParse::BOOL); argParse.addArgument("-b", "bool", ArgParse::BOOL);
int argc = 10; int argc = 10;
char *argv[] = { (char*)"test", const char *argv[] = { "test",
(char*)"-i", (char*)"12", "-i", "12",
(char*)"-f", (char*)"12.12", "-f", "12.12",
(char*)"-n", "-n",
(char*)"-s", (char*)"forever", "-s", "forever",
(char*)"-b", (char*)"false" }; "-b", "false" };
argParse.parseArgs(argc, argv); argParse.parseArgs(argc, argv);

Loading…
Cancel
Save