diff --git a/2353080d29599b0f/Socket.ipch b/2353080d29599b0f/Socket.ipch new file mode 100644 index 0000000..8b04b9c Binary files /dev/null and b/2353080d29599b0f/Socket.ipch differ diff --git a/2353080d29599b0f/mmap_address.bin b/2353080d29599b0f/mmap_address.bin new file mode 100644 index 0000000..7e836c7 Binary files /dev/null and b/2353080d29599b0f/mmap_address.bin differ diff --git a/2727ac8b3b5f62c6/INotify.ipch b/2727ac8b3b5f62c6/INotify.ipch new file mode 100644 index 0000000..3dd247d Binary files /dev/null and b/2727ac8b3b5f62c6/INotify.ipch differ diff --git a/2727ac8b3b5f62c6/mmap_address.bin b/2727ac8b3b5f62c6/mmap_address.bin new file mode 100644 index 0000000..089ed3b Binary files /dev/null and b/2727ac8b3b5f62c6/mmap_address.bin differ diff --git a/7faa46ef9a084930/mmap_address.bin b/7faa46ef9a084930/mmap_address.bin new file mode 100644 index 0000000..a47c678 Binary files /dev/null and b/7faa46ef9a084930/mmap_address.bin differ diff --git a/83fc3f05cba9b549/ConsoleSession.ipch b/83fc3f05cba9b549/ConsoleSession.ipch new file mode 100644 index 0000000..ace7ddf Binary files /dev/null and b/83fc3f05cba9b549/ConsoleSession.ipch differ diff --git a/83fc3f05cba9b549/mmap_address.bin b/83fc3f05cba9b549/mmap_address.bin new file mode 100644 index 0000000..4978fb4 Binary files /dev/null and b/83fc3f05cba9b549/mmap_address.bin differ diff --git a/8f1abf40eef9b0f/TCPSession.ipch b/8f1abf40eef9b0f/TCPSession.ipch new file mode 100644 index 0000000..ae1ce6c Binary files /dev/null and b/8f1abf40eef9b0f/TCPSession.ipch differ diff --git a/8f1abf40eef9b0f/mmap_address.bin b/8f1abf40eef9b0f/mmap_address.bin new file mode 100644 index 0000000..eb2ceb7 Binary files /dev/null and b/8f1abf40eef9b0f/mmap_address.bin differ diff --git a/ConsoleSession.cpp b/ConsoleSession.cpp index 6ac48e8..b09694f 100644 --- a/ConsoleSession.cpp +++ b/ConsoleSession.cpp @@ -9,7 +9,8 @@ namespace core { ConsoleSession::~ConsoleSession() {} - void ConsoleSession::protocol(coreutils::ZString data) { + void ConsoleSession::protocol(coreutils::ZString &data) { + coreutils::ZString blank(""); coreutils::Log(coreutils::LOG_DEBUG_1) << "ConsoleSession protocol " << status; switch (status) { @@ -24,7 +25,7 @@ namespace core { setCursorLocation(2, 1); setBackColor(BG_BLACK); status = LOGIN; - protocol((char*)""); + protocol(blank); break; case LOGIN: @@ -35,7 +36,7 @@ namespace core { case WAIT_USER_PROFILE: status = PASSWORD; - protocol((char*)""); + protocol(blank); break; case PASSWORD: @@ -55,7 +56,7 @@ namespace core { setBackColor(BG_BLACK); scrollArea(2, 16); status = PROMPT; - protocol((char*)""); + protocol(blank); break; case PROMPT: @@ -68,13 +69,13 @@ namespace core { case INPUT: command = data; status = PROCESS; - protocol((char*)""); + protocol(blank); break; case PROCESS: doCommand(command); status = command.equals((char *)"exit") ? DONE: PROMPT; - protocol((char*)""); + protocol(blank); break; case DONE: diff --git a/ConsoleSession.h b/ConsoleSession.h index 330c178..0e261ea 100644 --- a/ConsoleSession.h +++ b/ConsoleSession.h @@ -24,7 +24,7 @@ namespace core { void writeLog(std::string data); protected: - void protocol(coreutils::ZString data) override; + void protocol(coreutils::ZString &data) override; private: enum Status {WELCOME, LOGIN, WAIT_USER_PROFILE, PASSWORD, WAIT_PASSWORD, PROMPT, INPUT, PROCESS, DONE}; diff --git a/INotify.cpp b/INotify.cpp index 1b4034e..da82e79 100644 --- a/INotify.cpp +++ b/INotify.cpp @@ -19,7 +19,7 @@ namespace core { inotify_rm_watch(getDescriptor(), wd); } - void INotify::onDataReceived(coreutils::ZString buffer) { + void INotify::onDataReceived(coreutils::ZString &buffer) { const struct inotify_event *event; char *ptr; for (ptr = buffer.getData(); ptr < buffer.getData() + buffer.getLength(); diff --git a/INotify.h b/INotify.h index a2e9650..b63abf9 100644 --- a/INotify.h +++ b/INotify.h @@ -15,7 +15,7 @@ namespace core { int addWatch(std::string watch); void removeWatch(int wd); - void onDataReceived(coreutils::ZString data) override; + void onDataReceived(coreutils::ZString &data) override; virtual void inAccess(std::string name) {} virtual void inAttrib(std::string name) {} diff --git a/Socket.cpp b/Socket.cpp index ca719e9..7e054fd 100644 --- a/Socket.cpp +++ b/Socket.cpp @@ -1,6 +1,7 @@ #include "EPoll.h" #include "Socket.h" #include "Exception.h" +#include "ZString.h" #include "Log.h" namespace core { @@ -23,8 +24,8 @@ namespace core { void Socket::setDescriptor(int descriptor) { if((descriptor == -1) && (errno == 24)) { - shutdown("Too many files open"); - coreutils::Exception("Too many files open. Refusing connection.");; + shutdown("Too many files open"); + coreutils::Exception("Too many files open. Refusing connection."); } lock.lock(); coreutils::Log(coreutils::LOG_DEBUG_3) << "Descriptor set to " << descriptor << " for Socket."; @@ -70,7 +71,8 @@ namespace core { } if(event.events & EPOLLIN) { - receiveData(buffer); + coreutils::ZString receive(buffer, length); + receiveData(receive); } if(event.events & EPOLLWRNORM) { @@ -93,11 +95,11 @@ namespace core { throw coreutils::Exception("Need to override onDataReceived.", __FILE__, __LINE__, -1); } - void Socket::onDataReceived(coreutils::ZString data) { + void Socket::onDataReceived(coreutils::ZString &data) { onDataReceived(std::string(data.getData(), data.getLength())); } - void Socket::receiveData(coreutils::ZString buffer) { + void Socket::receiveData(coreutils::ZString &buffer) { if(buffer.getLength() <= 0) throw coreutils::Exception("Request to receive data with a zero buffer length.", __FILE__, __LINE__, -1); @@ -106,7 +108,8 @@ namespace core { int error = -1; if((len = ::read(getDescriptor(), buffer.getData(), buffer.getLength())) >= 0) { - onDataReceived(buffer); + coreutils::ZString zbuffer(buffer.getData(), len); + onDataReceived(zbuffer); } else { diff --git a/Socket.h b/Socket.h index 87e799a..ddc26a8 100644 --- a/Socket.h +++ b/Socket.h @@ -31,7 +31,7 @@ namespace core { /// receiving the EPOLLOUT event then the buffer is written to the socket output. /// - class Socket : public core::Object { + class Socket { public: @@ -151,14 +151,14 @@ namespace core { /// /// - virtual void onDataReceived(coreutils::ZString data); + virtual void onDataReceived(coreutils::ZString &data); /// /// receiveData will read the data from the socket and place it in the socket buffer. /// TLS layer overrides this to be able to read from SSL. /// - virtual void receiveData(coreutils::ZString buffer); + virtual void receiveData(coreutils::ZString &buffer); private: diff --git a/TCPSession.cpp b/TCPSession.cpp index d52b09f..d26c2bf 100644 --- a/TCPSession.cpp +++ b/TCPSession.cpp @@ -14,15 +14,16 @@ namespace core { data << "|" << ipAddress.getClientAddressAndPort(); } - void TCPSession::protocol(coreutils::ZString data) { + void TCPSession::protocol(coreutils::ZString &data) { if(!server.commands.processRequest(data, *this)) if(data.getLength() != 0) server.sessionErrorHandler("Invalid data received.", out); } void TCPSession::onRegistered() { + coreutils::ZString blank(""); onConnected(); - protocol(coreutils::ZString("")); + protocol(blank); send(); if(term) shutdown("termination requested"); @@ -30,7 +31,7 @@ namespace core { void TCPSession::onConnected() {} - void TCPSession::onDataReceived(coreutils::ZString data) { + void TCPSession::onDataReceived(coreutils::ZString &data) { if(data.getLength() > 0) { lineBuffer = (char *)realloc(lineBuffer, lineBufferSize + data.getLength()); memcpy(lineBuffer + lineBufferSize, data.getData(), data.getLength()); diff --git a/TCPSession.h b/TCPSession.h index b0e7be4..515cf12 100644 --- a/TCPSession.h +++ b/TCPSession.h @@ -79,7 +79,7 @@ namespace core { /// received. If you need data split by line termination characters then /// override the onLineReceived method instead. /// - virtual void onDataReceived(coreutils::ZString data) override; + virtual void onDataReceived(coreutils::ZString &data) override; /// /// Override the onLineReceived method to receive a string of characters that @@ -117,7 +117,7 @@ namespace core { /// data through the protocol method: LINE or BLOCK. /// - virtual void protocol(coreutils::ZString data); + virtual void protocol(coreutils::ZString &data); /// /// Use setBlockSize to set the amount of data that should be read at once from the diff --git a/TLSSession.cpp b/TLSSession.cpp index 52094e0..54e0a8a 100644 --- a/TLSSession.cpp +++ b/TLSSession.cpp @@ -80,9 +80,9 @@ namespace core { TLSSession::~TLSSession() {} - void TLSSession::protocol(coreutils::ZString data) {} + void TLSSession::protocol(coreutils::ZString &data) {} - void TLSSession::receiveData(coreutils::ZString buffer) { + void TLSSession::receiveData(coreutils::ZString &buffer) { int len; // int error = -1; diff --git a/TLSSession.h b/TLSSession.h index 715d34e..741a0f7 100644 --- a/TLSSession.h +++ b/TLSSession.h @@ -35,10 +35,10 @@ namespace core { /// virtual void output(std::stringstream &out); - virtual void protocol(coreutils::ZString data) override; + virtual void protocol(coreutils::ZString &data) override; protected: - void receiveData(coreutils::ZString buffer) override; + void receiveData(coreutils::ZString &buffer) override; void onRegister(); void onRegistered(); diff --git a/compile b/compile index a07a0ec..1acbbad 100755 --- a/compile +++ b/compile @@ -31,3 +31,4 @@ echo -n "Building library documentation manual..." doxygen docs/latex/doxygen.sty >/dev/null 2>/dev/null echo "OK" +rm *.o \ No newline at end of file diff --git a/d46db2862aa65619/TLSSession.ipch b/d46db2862aa65619/TLSSession.ipch new file mode 100644 index 0000000..c156416 Binary files /dev/null and b/d46db2862aa65619/TLSSession.ipch differ diff --git a/d46db2862aa65619/mmap_address.bin b/d46db2862aa65619/mmap_address.bin new file mode 100644 index 0000000..1fb4c79 Binary files /dev/null and b/d46db2862aa65619/mmap_address.bin differ diff --git a/ea542d94897942cc/mmap_address.bin b/ea542d94897942cc/mmap_address.bin new file mode 100644 index 0000000..a27bf56 Binary files /dev/null and b/ea542d94897942cc/mmap_address.bin differ diff --git a/fddc56a344f3ae05/Command.ipch b/fddc56a344f3ae05/Command.ipch new file mode 100644 index 0000000..513ba31 Binary files /dev/null and b/fddc56a344f3ae05/Command.ipch differ diff --git a/fddc56a344f3ae05/mmap_address.bin b/fddc56a344f3ae05/mmap_address.bin new file mode 100644 index 0000000..75d21ab Binary files /dev/null and b/fddc56a344f3ae05/mmap_address.bin differ diff --git a/output/main b/output/main index 99f2acb..3b68dd8 100755 Binary files a/output/main and b/output/main differ