Many additions and changes.

This commit is contained in:
Brad Arant 2019-09-13 10:29:36 -07:00
parent 50f6e972de
commit 08169b1c3d
30 changed files with 451 additions and 63 deletions

View File

@ -5,22 +5,22 @@
## Debug
ProjectName :=CoreUtils
ConfigurationName :=Debug
WorkspacePath :=/home/barant/Development/BMA/server_core
ProjectPath :=/home/barant/Development/BMA/server_core/CoreUtils
WorkspacePath :=/home/bradarant/barant
ProjectPath :=/home/bradarant/barant/CoreUtils
IntermediateDirectory :=./Debug
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Brad Arant
Date :=02/08/19
CodeLitePath :=/home/barant/.codelite
LinkerName :=g++
SharedObjectLinkerName :=g++ -shared -fPIC
Date :=12/09/19
CodeLitePath :=/home/bradarant/.codelite
LinkerName :=/usr/bin/x86_64-linux-gnu-g++
SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC
ObjectSuffix :=.o
DependSuffix :=.o.d
PreprocessSuffix :=.o.i
DebugSwitch :=-gstab
PreprocessSuffix :=.i
DebugSwitch :=-g
IncludeSwitch :=-I
LibrarySwitch :=-l
OutputSwitch :=-o
@ -47,20 +47,21 @@ LibPath := $(LibraryPathSwitch).
## Common variables
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
##
AR := ar rcus
CXX := g++
CC := gcc
AR := /usr/bin/x86_64-linux-gnu-ar rcu
CXX := /usr/bin/x86_64-linux-gnu-g++
CC := /usr/bin/x86_64-linux-gnu-gcc
CXXFLAGS := -g $(Preprocessors)
CFLAGS := -g $(Preprocessors)
ASFLAGS :=
AS := as
AS := /usr/bin/x86_64-linux-gnu-as
##
## User defined environment variables
##
CodeLiteDir:=/usr/share/codelite
Objects0=$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix)
Objects0=$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix) $(IntermediateDirectory)/File.cpp$(ObjectSuffix) $(IntermediateDirectory)/Log.cpp$(ObjectSuffix) \
$(IntermediateDirectory)/Exception.cpp$(ObjectSuffix)
@ -77,8 +78,8 @@ $(OutputFile): $(Objects)
@echo "" > $(IntermediateDirectory)/.d
@echo $(Objects0) > $(ObjectsFileList)
$(AR) $(ArchiveOutputSwitch)$(OutputFile) @$(ObjectsFileList) $(ArLibs)
@$(MakeDirCommand) "/home/barant/Development/BMA/server_core/.build-debug"
@echo rebuilt > "/home/barant/Development/BMA/server_core/.build-debug/CoreUtils"
@$(MakeDirCommand) "/home/bradarant/barant/.build-debug"
@echo rebuilt > "/home/bradarant/barant/.build-debug/CoreUtils"
MakeIntermediateDirs:
@test -d ./Debug || $(MakeDirCommand) ./Debug
@ -94,7 +95,7 @@ PreBuild:
## Objects
##
$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix): IMFHeader.cpp $(IntermediateDirectory)/IMFHeader.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFHeader.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFHeader.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFHeader.cpp$(DependSuffix): IMFHeader.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFHeader.cpp$(DependSuffix) -MM IMFHeader.cpp
@ -102,7 +103,7 @@ $(IntermediateDirectory)/IMFHeader.cpp$(PreprocessSuffix): IMFHeader.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFHeader.cpp$(PreprocessSuffix) IMFHeader.cpp
$(IntermediateDirectory)/PString.cpp$(ObjectSuffix): PString.cpp $(IntermediateDirectory)/PString.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/PString.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/PString.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/PString.cpp$(DependSuffix): PString.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/PString.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/PString.cpp$(DependSuffix) -MM PString.cpp
@ -110,7 +111,7 @@ $(IntermediateDirectory)/PString.cpp$(PreprocessSuffix): PString.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/PString.cpp$(PreprocessSuffix) PString.cpp
$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix): IMFMultipart.cpp $(IntermediateDirectory)/IMFMultipart.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFMultipart.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFMultipart.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFMultipart.cpp$(DependSuffix): IMFMultipart.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFMultipart.cpp$(DependSuffix) -MM IMFMultipart.cpp
@ -118,7 +119,7 @@ $(IntermediateDirectory)/IMFMultipart.cpp$(PreprocessSuffix): IMFMultipart.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFMultipart.cpp$(PreprocessSuffix) IMFMultipart.cpp
$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix): IMFMessage.cpp $(IntermediateDirectory)/IMFMessage.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFMessage.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFMessage.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFMessage.cpp$(DependSuffix): IMFMessage.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFMessage.cpp$(DependSuffix) -MM IMFMessage.cpp
@ -126,7 +127,7 @@ $(IntermediateDirectory)/IMFMessage.cpp$(PreprocessSuffix): IMFMessage.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFMessage.cpp$(PreprocessSuffix) IMFMessage.cpp
$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix): IMFRequest.cpp $(IntermediateDirectory)/IMFRequest.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFRequest.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFRequest.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFRequest.cpp$(DependSuffix): IMFRequest.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFRequest.cpp$(DependSuffix) -MM IMFRequest.cpp
@ -134,7 +135,7 @@ $(IntermediateDirectory)/IMFRequest.cpp$(PreprocessSuffix): IMFRequest.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFRequest.cpp$(PreprocessSuffix) IMFRequest.cpp
$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix): IMFResponse.cpp $(IntermediateDirectory)/IMFResponse.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFResponse.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFResponse.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFResponse.cpp$(DependSuffix): IMFResponse.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFResponse.cpp$(DependSuffix) -MM IMFResponse.cpp
@ -142,7 +143,7 @@ $(IntermediateDirectory)/IMFResponse.cpp$(PreprocessSuffix): IMFResponse.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFResponse.cpp$(PreprocessSuffix) IMFResponse.cpp
$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix): IMFFormData.cpp $(IntermediateDirectory)/IMFFormData.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFFormData.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFFormData.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFFormData.cpp$(DependSuffix): IMFFormData.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFFormData.cpp$(DependSuffix) -MM IMFFormData.cpp
@ -150,13 +151,37 @@ $(IntermediateDirectory)/IMFFormData.cpp$(PreprocessSuffix): IMFFormData.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFFormData.cpp$(PreprocessSuffix) IMFFormData.cpp
$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix): IMFPlainText.cpp $(IntermediateDirectory)/IMFPlainText.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFPlainText.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix) $(IncludePath)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFPlainText.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/IMFPlainText.cpp$(DependSuffix): IMFPlainText.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFPlainText.cpp$(DependSuffix) -MM IMFPlainText.cpp
$(IntermediateDirectory)/IMFPlainText.cpp$(PreprocessSuffix): IMFPlainText.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFPlainText.cpp$(PreprocessSuffix) IMFPlainText.cpp
$(IntermediateDirectory)/File.cpp$(ObjectSuffix): File.cpp $(IntermediateDirectory)/File.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/File.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/File.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/File.cpp$(DependSuffix): File.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/File.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/File.cpp$(DependSuffix) -MM File.cpp
$(IntermediateDirectory)/File.cpp$(PreprocessSuffix): File.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/File.cpp$(PreprocessSuffix) File.cpp
$(IntermediateDirectory)/Log.cpp$(ObjectSuffix): Log.cpp $(IntermediateDirectory)/Log.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/Log.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/Log.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/Log.cpp$(DependSuffix): Log.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/Log.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/Log.cpp$(DependSuffix) -MM Log.cpp
$(IntermediateDirectory)/Log.cpp$(PreprocessSuffix): Log.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/Log.cpp$(PreprocessSuffix) Log.cpp
$(IntermediateDirectory)/Exception.cpp$(ObjectSuffix): Exception.cpp $(IntermediateDirectory)/Exception.cpp$(DependSuffix)
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/Exception.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/Exception.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/Exception.cpp$(DependSuffix): Exception.cpp
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/Exception.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/Exception.cpp$(DependSuffix) -MM Exception.cpp
$(IntermediateDirectory)/Exception.cpp$(PreprocessSuffix): Exception.cpp
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/Exception.cpp$(PreprocessSuffix) Exception.cpp
-include $(IntermediateDirectory)/*$(DependSuffix)
##

View File

@ -23,6 +23,13 @@
<File Name="IMFFormData.cpp"/>
<File Name="IMFPlainText.h"/>
<File Name="IMFPlainText.cpp"/>
<File Name="File.cpp"/>
<File Name="File.h"/>
<File Name="Log.cpp"/>
<File Name="Log.h"/>
<File Name="Exception.cpp"/>
<File Name="Exception.h"/>
<File Name="LogListener.h"/>
</VirtualDirectory>
<Settings Type="Static Library">
<GlobalSettings>

View File

@ -1 +1 @@
./Debug/IMFHeader.cpp.o ./Debug/PString.cpp.o ./Debug/IMFMultipart.cpp.o ./Debug/IMFMessage.cpp.o ./Debug/IMFRequest.cpp.o ./Debug/IMFResponse.cpp.o ./Debug/IMFFormData.cpp.o ./Debug/IMFPlainText.cpp.o
./Debug/IMFHeader.cpp.o ./Debug/PString.cpp.o ./Debug/IMFMultipart.cpp.o ./Debug/IMFMessage.cpp.o ./Debug/IMFRequest.cpp.o ./Debug/IMFResponse.cpp.o ./Debug/IMFFormData.cpp.o ./Debug/IMFPlainText.cpp.o ./Debug/File.cpp.o ./Debug/Log.cpp.o ./Debug/Exception.cpp.o

Binary file not shown.

View File

@ -1,5 +1,5 @@
Debug/IMFHeader.cpp.o: IMFHeader.cpp IMFHeader.h PString.h includes \
../ServerCore/Exception.h ../ServerCore/includes
Exception.h
IMFHeader.h:
@ -7,6 +7,4 @@ PString.h:
includes:
../ServerCore/Exception.h:
../ServerCore/includes:
Exception.h:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
Debug/IMFRequest.cpp.o: IMFRequest.cpp IMFRequest.h PString.h includes \
../ServerCore/Exception.h ../ServerCore/includes
Exception.h
IMFRequest.h:
@ -7,6 +7,4 @@ PString.h:
includes:
../ServerCore/Exception.h:
../ServerCore/includes:
Exception.h:

Binary file not shown.

View File

@ -1,7 +1,6 @@
Debug/IMFResponse.cpp.o: IMFResponse.cpp IMFResponse.h includes \
IMFMessage.h PString.h IMFHeader.h IMFRequest.h IMFBody.h \
../ServerCore/Log.h ../ServerCore/includes ../ServerCore/File.h \
../ServerCore/Object.h
IMFMessage.h PString.h IMFHeader.h IMFRequest.h IMFBody.h Log.h File.h \
../ServerCore/Object.h ../ServerCore/includes LogListener.h
IMFResponse.h:
@ -17,10 +16,12 @@ IMFRequest.h:
IMFBody.h:
../ServerCore/Log.h:
Log.h:
File.h:
../ServerCore/Object.h:
../ServerCore/includes:
../ServerCore/File.h:
../ServerCore/Object.h:
LogListener.h:

Binary file not shown.

View File

@ -1,14 +1,16 @@
Debug/PString.cpp.o: PString.cpp PString.h includes ../ServerCore/Log.h \
../ServerCore/includes ../ServerCore/File.h ../ServerCore/Object.h
Debug/PString.cpp.o: PString.cpp PString.h includes Log.h File.h \
../ServerCore/Object.h ../ServerCore/includes LogListener.h
PString.h:
includes:
../ServerCore/Log.h:
Log.h:
File.h:
../ServerCore/Object.h:
../ServerCore/includes:
../ServerCore/File.h:
../ServerCore/Object.h:
LogListener.h:

Binary file not shown.

View File

@ -10,21 +10,38 @@ namespace coreutils {
public:
Directory(std::string path) {
dir = opendir(path);
dir = opendir(path.c_str());
if(dir) {
struct dirent entry = readdir(dir);
struct dirent *entry = readdir(dir);
while(entry) {
directory.emplace(std::string(entry->d_name), entry);
entry = readdir(dir)
entry = readdir(dir);
}
}
if(directory.size() > 0)
cursor = directory.begin();
}
~Directory() {}
bool eod() {
return cursor == directory.end();
}
DirectoryEntry get() {
if(cursor == directory.end())
return NULL;
return cursor->second;
}
void next() {
++cursor;
}
private:
DIR *dir;
std::map<std::string, DirectoryEntry> directory;
std::map<std::string, DirectoryEntry>::iterator cursor;

View File

@ -9,13 +9,13 @@ namespace coreutils {
public:
DirectoryEntry(struct dirent *entry) {
memcpy(this->entry, entry, sizeof(struct dirent));
memcpy(&this->entry, entry, sizeof(struct dirent));
}
~DirectoryEntry() {}
std::string getName() {
return std::string(entry->d_name);
return std::string(entry.d_name);
}
private:

20
Exception.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "Exception.h"
#include "Log.h"
namespace coreutils {
Exception::Exception(std::string text, std::string file, int line, int errorNumber) {
this->text = text;
this->file = file;
this->line = line;
if(errorNumber == -1)
this->errorNumber = errno;
else
this->errorNumber = errorNumber;
Log(LOG_EXCEPT) << text;
}
Exception::~Exception() {}
}

24
Exception.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef __Exception_h__
#define __Exception_h__
#include "includes"
namespace coreutils {
class Exception {
public:
Exception(std::string text, std::string file = __FILE__, int line = __LINE__, int errorNumber = -1);
~Exception();
std::string className;
std::string file;
int line;
std::string text;
int errorNumber;
};
}
#endif

43
File.cpp Normal file
View File

@ -0,0 +1,43 @@
#include "File.h"
#include "Exception.h"
namespace coreutils {
File::File(std::string fileName, int mode, int authority) {
this->fileName = fileName;
struct stat status;
stat(fileName.c_str(), &status);
buffer = NULL;
setBufferSize(status.st_size);
fd = open(fileName.c_str(), mode, authority);
if(fd < 0) {
std::stringstream temp;
temp << "Error opening file " << fileName << ".";
throw Exception(temp.str(), __FILE__, __LINE__);
}
}
File::~File() {
}
void File::setBufferSize(size_t size) {
buffer = (char *)realloc(buffer, size);
this->size = size;
}
void File::read() {
size = ::read(fd, buffer, size);
setBufferSize(size);
}
void File::write(std::string data) {
::write(fd, data.c_str(), data.length());
}
}

35
File.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef __File_h__
#define __File_h__
#include "includes"
///
/// File
///
/// File abstraction class for accessing local file system files.
///
namespace coreutils {
class File {
public:
File(std::string fileName, int mode = O_RDONLY, int authority = 0664);
~File();
void setBufferSize(size_t size);
void read();
void write(std::string data);
char *buffer;
size_t size;
std::string fileName;
private:
int fd;
};
}
#endif

View File

@ -12,10 +12,13 @@ namespace coreutils {
std::string value;
for(PString section: sections) {
IMFMessage message(section);
if(message.getHeaderKeyPairValue("Content-Disposition", "name") == name) {
IMFPlainText *text = (IMFPlainText *)message.getBody();
std::cout << text->toString();
}
return value;
return text->toString();
}
}
return "";
}
}

View File

@ -10,11 +10,11 @@ namespace coreutils {
IMFHeader::IMFHeader(PString &in) {
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-");
if(!in.ifNext(":"))
throw core::Exception("Invalid character in expected header token.");
throw coreutils::Exception("Invalid character in expected header token.");
in.skipWhitespace();
value = in.getTokenExclude("\r\n");
if(!in.ifNext("\r\n"))
throw core::Exception("Expected CRLF.");
throw coreutils::Exception("Expected CRLF.");
}
IMFHeader::IMFHeader(std::string key, std::string value) {

View File

@ -12,6 +12,9 @@ namespace coreutils {
}
void IMFMessage::parse(PString &in) {
if(in.size() == 0)
return;
while(!in.ifNext("\r\n"))
headers.emplace_back(in);
@ -55,17 +58,27 @@ namespace coreutils {
}
std::string IMFMessage::getHeaderKeyPairValue(std::string headerKey, std::string key) {
std::string value;
coreutils::PString psource(getHeader(headerKey, false));
std::vector<PString> sourcep = psource.split(";");
for(PString work: sourcep) {
work.skipWhitespace();
std::string token = work.getTokenExclude("=");
if(work.ifNext("=")) {
if(token == key)
return work.str();
if(token == key) {
if(work.ifNext("\"")) {
value = work.getTokenExclude("\"");
return value;
}
else {
value = work.str();
return value;
}
}
else
continue;
} else if (work.ifNext(";") || work.ifNext(" ")) {
if(token == key)
return std::string("true");

View File

@ -1,4 +1,5 @@
#include "IMFMultipart.h"
#include "PString.h"
namespace coreutils {
@ -10,7 +11,12 @@ namespace coreutils {
buffer = in.str();
in.cursor -= 2;
sections = in.split("\r\n--" + boundary);
for(int ix = 0; ix < sections.size(); ++ix) {
if(sections[ix].str() == "--\r\n")
sections[ix] = PString("");
if(sections[ix].str().substr(0, 2) == "\r\n")
sections[ix].cursor += 2;
}
}
std::string IMFMultipart::toString() {

View File

@ -8,13 +8,13 @@ namespace coreutils {
IMFRequest::IMFRequest(PString &in) {
method = in.getTokenExclude(" ");
if(!in.ifNext(" "))
throw core::Exception("Expecting space after method.");
throw coreutils::Exception("Expecting space after method.");
uri = in.getTokenExclude(" ");
if(!in.ifNext(" "))
throw core::Exception("Expecting space after URI.");
throw coreutils::Exception("Expecting space after URI.");
protocol = in.getTokenExclude("\r\n");
if(!in.ifNext("\r\n"))
throw core::Exception("Expecting CRLF after protocol.");
throw coreutils::Exception("Expecting CRLF after protocol.");
}
std::string IMFRequest::getMethod() {

81
Log.cpp Normal file
View File

@ -0,0 +1,81 @@
#include "ConsoleSession.h"
#include "Log.h"
#include "LogListener.h"
#include "ConsoleServer.h"
namespace coreutils {
LogListener *Log::logListener = NULL;
File *Log::logFile = NULL;
int Log::seq = 0;
Log::Log(LogListener *logListener) {
this->logListener = logListener;
}
Log::Log(File *logFile) {
this->logFile = logFile;
}
Log::Log(int level) {
output = true;
auto clock = std::chrono::system_clock::now();
time_t theTime = std::chrono::system_clock::to_time_t(clock);
std::string timeOut = std::string(ctime(&theTime));
timeOut = timeOut.substr(0, timeOut.length() - 1);
*this << timeOut;
*this << " ";
switch(level) {
case LOG_NONE:
*this << "[NONE] :";
break;
case LOG_INFO:
*this << "[INFO] :";
break;
case LOG_WARN:
*this << "[WARN] :";
break;
case LOG_EXCEPT:
*this << "[EXCEPT]: ";
break;
case LOG_DEBUG_1:
*this << "[DEBUG1]: ";
break;
case LOG_DEBUG_2:
*this << "[DEBUG2]: ";
break;
case LOG_DEBUG_3:
*this << "[DEBUG3]: ";
break;
case LOG_DEBUG_4:
*this << "[DEBUG4]: ";
break;
default:
*this << "[?] ?";
break;
};
}
Log::~Log() {
if(output) {
std::stringstream out;
out << seq << "." << this->str() << std::endl;;
if(logListener)
logListener->logSend(out.str());
if(logFile)
logFile->write(out.str());
std::cout << out.str();
++seq;
}
}
}

95
Log.h Normal file
View File

@ -0,0 +1,95 @@
#ifndef __Log_h__
#define __Log_h__
#include "includes"
#include "File.h"
#include "Object.h"
#include "LogListener.h"
namespace coreutils {
class ConsoleServer;
static const int LOG_NONE = 0;
static const int LOG_INFO = 1;
static const int LOG_WARN = 2;
static const int LOG_EXCEPT = 4;
static const int LOG_DEBUG_1 = 8;
static const int LOG_DEBUG_2 = 16;
static const int LOG_DEBUG_3 = 32;
static const int LOG_DEBUG_4 = 64;
///
/// Log
///
/// Provides easy to access and use logging features to maintain a
/// history of activity and provide information for activity debugging.
///
class Log : public std::ostringstream {
public:
///
/// Constructor method that accepts a pointer to a log listener
/// This enables the Log object to send new log
/// messages to the connected listener.
///
/// @param consoleServer a pointer to the console server that will
/// be used to echo log entries.
///
Log(LogListener *logListener);
///
/// Constructor method accepts a file object that will be used to
/// echo all log entries. This provides a permanent disk file record
/// of all logged activity.
///
Log(File *logFile);
///
/// Constructor method that is used to send a message to the log.
///
/// @param level the logging level to associate with this message.
///
/// To send log message: Log(LOG_INFO) << "This is a log message.";
///
Log(int level);
///
/// The destructor for the log object.
///
~Log();
bool output = false;
///
/// Set the logListener to point to the instantiated LogListener
/// object for the application.
///
static LogListener *logListener;
///
/// Specify a File object where the log entries will be written as
/// a permanent record to disk.
///
static File *logFile;
///
/// A meaningless sequenctial number that starts from - at the
/// beginning of the logging process.
///
static int seq;
};
}
#endif

15
LogListener.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __LogListener_h__
#define __LogListener_h__
namespace coreutils {
class LogListener {
public:
virtual void logSend(std::string entry) {}
};
}
#endif

View File

@ -61,4 +61,8 @@ namespace coreutils {
cursor = pstring.find_first_not_of(" \t", cursor);
}
int PString::size() {
return pstring.size() - cursor;
}
}

View File

@ -18,6 +18,7 @@ namespace coreutils {
bool ifNext(std::string value);
void skipWhitespace();
int cursor = 0;
int size();
private:
std::string pstring;