Compare commits
No commits in common. "develop" and "master" have entirely different histories.
46
Base64.cpp
46
Base64.cpp
@ -12,12 +12,9 @@ namespace coreutils {
|
|||||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
MString Base64::encode(ZString data) {
|
std::string Base64::encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||||
|
|
||||||
data.push();
|
std::string ret;
|
||||||
data.reset();
|
|
||||||
MString ret;
|
|
||||||
int in_len = data.getLength();
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
unsigned char char_array_3[3];
|
unsigned char char_array_3[3];
|
||||||
@ -25,7 +22,7 @@ namespace coreutils {
|
|||||||
|
|
||||||
while (in_len--) {
|
while (in_len--) {
|
||||||
|
|
||||||
char_array_3[i++] = data.nextChar();
|
char_array_3[i++] = *(bytes_to_encode++);
|
||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
|
|
||||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||||
@ -34,9 +31,10 @@ namespace coreutils {
|
|||||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||||
|
|
||||||
for(i = 0; (i <4) ; i++)
|
for(i = 0; (i <4) ; i++)
|
||||||
ret.write(base64_chars[char_array_4[i]]);
|
ret += base64_chars[char_array_4[i]];
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i) {
|
if (i) {
|
||||||
@ -49,28 +47,29 @@ namespace coreutils {
|
|||||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||||
|
|
||||||
for (j = 0; (j < i + 1); j++)
|
for (j = 0; (j < i + 1); j++)
|
||||||
ret.write(base64_chars[char_array_4[j]]);
|
ret += base64_chars[char_array_4[j]];
|
||||||
|
|
||||||
while((i++ < 3))
|
while((i++ < 3))
|
||||||
ret.write('=');
|
ret += '=';
|
||||||
|
|
||||||
}
|
}
|
||||||
data.pop();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
MString Base64::decode(ZString b64data) {
|
std::string Base64::decode(std::string const& encoded_string) {
|
||||||
|
|
||||||
b64data.push();
|
int in_len = encoded_string.size();
|
||||||
b64data.reset();
|
|
||||||
int in_len = b64data.getLength();
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
int in_ = 0;
|
||||||
unsigned char char_array_4[4], char_array_3[3];
|
unsigned char char_array_4[4], char_array_3[3];
|
||||||
MString ret;
|
std::string ret;
|
||||||
|
|
||||||
while (in_len-- && (b64data.getChar() != '=') && isBase64(b64data.getChar())) {
|
while (in_len-- && ( encoded_string[in_] != '=') && isBase64(encoded_string[in_])) {
|
||||||
|
|
||||||
char_array_4[i++] = b64data.nextChar();
|
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||||
if (i ==4) {
|
if (i ==4) {
|
||||||
|
|
||||||
for (i = 0; i <4; i++)
|
for (i = 0; i <4; i++)
|
||||||
@ -81,7 +80,7 @@ namespace coreutils {
|
|||||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
for (i = 0; (i < 3); i++)
|
for (i = 0; (i < 3); i++)
|
||||||
ret.write(char_array_3[i]);
|
ret += char_array_3[i];
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +94,9 @@ namespace coreutils {
|
|||||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
|
|
||||||
for (j = 0; (j < i - 1); j++)
|
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||||
ret.write(char_array_3[j]);
|
|
||||||
}
|
}
|
||||||
b64data.pop();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
Base64.h
10
Base64.h
@ -1,22 +1,20 @@
|
|||||||
#ifndef __Base64_h__
|
#ifndef __Base64_h__
|
||||||
#define __Base64_h__
|
#define __Base64_h__
|
||||||
|
|
||||||
#include "ZString.h"
|
#include <string>
|
||||||
#include "MString.h"
|
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Use the Base64 object when you need to translate character string
|
///
|
||||||
/// to/from base64 encoded strings.
|
|
||||||
///
|
///
|
||||||
|
|
||||||
class Base64 {
|
class Base64 {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isBase64(unsigned char c);
|
bool isBase64(unsigned char c);
|
||||||
MString encode(ZString data);
|
std::string encode(unsigned char const* bytes_to_encode, unsigned int in_len);
|
||||||
MString decode(ZString b64data);
|
std::string decode(std::string const& encoded_string);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
#include "CGIFormattedData.h"
|
|
||||||
#include "ZString.h"
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
CGIFormattedData::CGIFormattedData() {}
|
|
||||||
|
|
||||||
CGIFormattedData::CGIFormattedData(ZString cgiData) {
|
|
||||||
cgiData.split("&");
|
|
||||||
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
|
|
||||||
cgiData[ix].split("=");
|
|
||||||
data[cgiData[ix][0]] = cgiData[ix][1];
|
|
||||||
data[cgiData[ix][0]].fromCGI();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ZString CGIFormattedData::operator=(ZString cgiData) {
|
|
||||||
cgiData.split("&");
|
|
||||||
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
|
|
||||||
cgiData[ix].split("=");
|
|
||||||
data[cgiData[ix][0]] = cgiData[ix][1];
|
|
||||||
data[cgiData[ix][0]].fromCGI();
|
|
||||||
}
|
|
||||||
return cgiData;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#ifndef __CGIFormattedData_h__
|
|
||||||
# define __CGIFormattedData_h__
|
|
||||||
|
|
||||||
# include "MString.h"
|
|
||||||
# include <map>
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Use the CGIFormattedData object to store and process data that
|
|
||||||
/// interfaces to the CGI format. Value pairs are accessible using
|
|
||||||
/// a common map interface.
|
|
||||||
///
|
|
||||||
|
|
||||||
class CGIFormattedData {
|
|
||||||
|
|
||||||
public:
|
|
||||||
CGIFormattedData();
|
|
||||||
CGIFormattedData(ZString cgiData);
|
|
||||||
|
|
||||||
ZString operator=(ZString cgiData);
|
|
||||||
|
|
||||||
std::map<MString, MString> data;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,12 +1,21 @@
|
|||||||
#include "IMFFormData.h"
|
#include "IMFFormData.h"
|
||||||
#include "IMFMessage.h"
|
#include "IMFMessage.h"
|
||||||
#include "IMFText.h"
|
#include "IMFPlainText.h"
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFFormData::IMFFormData(int fd, ZString boundary) {
|
IMFFormData::IMFFormData() {}
|
||||||
IMFHeader header(fd);
|
|
||||||
IMFText text(fd, boundary);
|
IMFFormData::IMFFormData(ZString &in, ZString &boundary) : IMFMultipart(in, boundary) {}
|
||||||
|
|
||||||
|
ZString IMFFormData::getByName(ZString &name) {
|
||||||
|
for(ZString section: sections) {
|
||||||
|
IMFMessage message(section);
|
||||||
|
if(message.getHeaderKeyPairValue("Content-Disposition", ("name")).equals(name)) {
|
||||||
|
return message.multipart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ZString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
#ifndef __IMFFormData_h__
|
#ifndef __IMFFormData_h__
|
||||||
# define __IMFFormData_h__
|
# define __IMFFormData_h__
|
||||||
|
|
||||||
#include "ZString.h"
|
# include "IMFMultipart.h"
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
class IMFFormData {
|
class IMFFormData: public IMFMultipart {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFFormData(int fd, ZString boundary);
|
IMFFormData();
|
||||||
|
IMFFormData(ZString &in, ZString &boundary);
|
||||||
|
|
||||||
|
ZString getByName(ZString &name);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,18 +1,37 @@
|
|||||||
#include "IMFHeader.h"
|
#include "IMFHeader.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include <unistd.h>
|
#include <iostream>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFHeader::IMFHeader(int fd) {
|
IMFHeader::IMFHeader(ZString &in) : ZString(in) {
|
||||||
char ch;
|
|
||||||
int rc = ::read(fd, &ch, 1);
|
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789");
|
||||||
while(ch != '\r') {
|
std::cout << "key: [" << key << "]" << std::endl;
|
||||||
IMFHeaderField *headerField = new IMFHeaderField(ch, fd);
|
if(key.getLength() != 0) {
|
||||||
headers.push_back(headerField);
|
if(!in.ifNext(":"))
|
||||||
|
throw coreutils::Exception("Invalid character in expected header token.");
|
||||||
|
in.skipWhitespace();
|
||||||
|
value = in.goeolwithContinuation();
|
||||||
|
std::cout << "header: [" << value << "]" << std::endl;
|
||||||
}
|
}
|
||||||
rc = ::read(fd, &ch, 1);
|
else if(in.skipWhitespace() > 0) {}
|
||||||
|
else if(in.str() == "") {}
|
||||||
|
}
|
||||||
|
|
||||||
|
IMFHeader::IMFHeader(ZString key, ZString value) : ZString(), key(key), value(value) {}
|
||||||
|
|
||||||
|
ZString IMFHeader::getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZString IMFHeader::getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMFHeader::output(std::stringstream &out) {
|
||||||
|
out << key << ": " << value << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
27
IMFHeader.h
27
IMFHeader.h
@ -1,19 +1,26 @@
|
|||||||
#ifndef __IMFHeader_h__
|
#ifndef __IMFHeader_h__
|
||||||
# define __IMFHeader_h__
|
#define __IMFHeader_h__
|
||||||
|
|
||||||
# include "IMFHeaderField.h"
|
#include "ZString.h"
|
||||||
# include <vector>
|
#include <sstream>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
class IMFHeader {
|
class IMFHeader : public ZString {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFHeader(int fd);
|
IMFHeader(ZString &in);
|
||||||
|
IMFHeader(ZString key, ZString value);
|
||||||
|
|
||||||
|
ZString getKey();
|
||||||
|
ZString getValue();
|
||||||
|
|
||||||
|
void output(std::stringstream &out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<IMFHeaderField*> headers;
|
ZString key;
|
||||||
|
ZString value;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
#include "IMFHeaderField.h"
|
|
||||||
#include "Exception.h"
|
|
||||||
#include "Log.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
IMFHeaderField::IMFHeaderField(char &ch, int fd) {
|
|
||||||
int rc = 0;
|
|
||||||
while(((ch >= 'A') && (ch <= 'Z')) ||
|
|
||||||
((ch >= 'a') && (ch <= 'z')) ||
|
|
||||||
((ch >= '0') && (ch <= '9')) ||
|
|
||||||
(ch == '-') || (ch == '_')) {
|
|
||||||
key.write(ch);
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
}
|
|
||||||
if(ch != ':')
|
|
||||||
throw coreutils::Exception("expecting ':' in data stream.");
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
while(ch == ' ')
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
while(ch != '\r') {
|
|
||||||
value.write(ch);
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
}
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
if(ch != '\n')
|
|
||||||
throw coreutils::Exception("expecting '\n' in data stream.");
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
#ifndef __IMFHeaderField_h__
|
|
||||||
# define __IMFHeaderField_h__
|
|
||||||
|
|
||||||
# include "MString.h"
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
class IMFHeaderField {
|
|
||||||
|
|
||||||
public:
|
|
||||||
IMFHeaderField(char &ch, int fd);
|
|
||||||
|
|
||||||
private:
|
|
||||||
MString key;
|
|
||||||
MString value;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,11 +1,87 @@
|
|||||||
#include "IMFMessage.h"
|
#include "IMFMessage.h"
|
||||||
#include "IMFHeader.h"
|
#include "IMFHeader.h"
|
||||||
#include "IMFMultipart.h"
|
#include "IMFMultipart.h"
|
||||||
#include "IMFText.h"
|
#include "IMFPlainText.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFMessage::IMFMessage(int fd) {}
|
IMFMessage::IMFMessage() : ZString() {}
|
||||||
|
|
||||||
|
IMFMessage::IMFMessage(ZString &in) : ZString(in) {
|
||||||
|
|
||||||
|
while (!in.ifNext("\r\n") && in.ifNext("\n"))
|
||||||
|
headers.emplace_back(in);
|
||||||
|
|
||||||
|
ZString type = getHeader("Content-Type");
|
||||||
|
|
||||||
|
int len = getHeader("Content-Length").asInteger();
|
||||||
|
if(len > 0) {
|
||||||
|
block = in.readBlock(len);
|
||||||
|
if(type.equals("multipart/form-data")) {
|
||||||
|
ZString boundary(getHeaderKeyPairValue("Content-Type", "boundary"));
|
||||||
|
multipart = IMFMultipart(block, boundary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IMFMessage::~IMFMessage() {}
|
||||||
|
|
||||||
|
void IMFMessage::output(std::stringstream &out) {
|
||||||
|
// for(IMFHeader header: headers) {
|
||||||
|
// out << header.getKey() << ": " << header.getValue() << "\r\n";
|
||||||
|
// }
|
||||||
|
out << newHeaders.str() << "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMFMessage::addHeader(IMFHeader header) {
|
||||||
|
std::stringstream out;
|
||||||
|
header.output(out);
|
||||||
|
newHeaders << out.str() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZString IMFMessage::getHeader(ZString key, bool valueOnly) {
|
||||||
|
for(IMFHeader header: headers) {
|
||||||
|
if(header.getKey().equals(key)) {
|
||||||
|
ZString value = header.getValue();
|
||||||
|
if(valueOnly) {
|
||||||
|
std::vector<ZString> split = ZString(value).split(";");
|
||||||
|
value = split[0];
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ZString();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZString IMFMessage::getHeaderKeyPairValue(const char *headerKey, const char *key) {
|
||||||
|
return getHeaderKeyPairValue(ZString(headerKey), ZString(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
ZString IMFMessage::getHeaderKeyPairValue(ZString headerKey, ZString key) {
|
||||||
|
ZString value;
|
||||||
|
ZString psource(getHeader(headerKey, false));
|
||||||
|
for(ZString work: psource.split(";")) {
|
||||||
|
work.skipWhitespace();
|
||||||
|
ZString token = work.getTokenExclude("=");
|
||||||
|
if(work.ifNext("=")) {
|
||||||
|
if(token.equals(key)) {
|
||||||
|
if(work.ifNext("\""))
|
||||||
|
value = work.getTokenExclude("\"");
|
||||||
|
else
|
||||||
|
value = work;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
} else if (work.ifNext(";") || work.ifNext(" ")) {
|
||||||
|
if(token.equals(key))
|
||||||
|
return ZString("true");
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ZString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
23
IMFMessage.h
23
IMFMessage.h
@ -15,21 +15,28 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
class IMFMessage {
|
class IMFMessage : public ZString {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFMessage(int fd);
|
IMFMessage();
|
||||||
|
IMFMessage(ZString &in);
|
||||||
virtual ~IMFMessage();
|
virtual ~IMFMessage();
|
||||||
|
|
||||||
// void output(std::stringstream &out);
|
void output(std::stringstream &out);
|
||||||
|
|
||||||
// IMFMultipart multipart;
|
void addHeader(IMFHeader header);
|
||||||
// ZString block;
|
|
||||||
// char contentLength[8];
|
ZString getHeader(ZString key, bool valueOnly = true);
|
||||||
|
ZString getHeaderKeyPairValue(const char *headerKey, const char *key);
|
||||||
|
ZString getHeaderKeyPairValue(ZString headerKey, ZString key);
|
||||||
|
|
||||||
|
IMFMultipart multipart;
|
||||||
|
ZString block;
|
||||||
|
char contentLength[8];
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// std::vector<IMFHeader> headers;
|
std::vector<IMFHeader> headers;
|
||||||
// std::stringstream newHeaders;
|
std::stringstream newHeaders;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,37 +1,35 @@
|
|||||||
#include "IMFMultipart.h"
|
#include "IMFMultipart.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Exception.h"
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFMultipart::IMFMultipart(int fd, MString boundary) {
|
IMFMultipart::IMFMultipart() {}
|
||||||
char ch = 0;
|
|
||||||
int rc = 0;
|
IMFMultipart::IMFMultipart(ZString &in, ZString &boundary) {
|
||||||
while((ch != '\r') && (ch != '\n')) {
|
Log(LOG_DEBUG_1) << in;
|
||||||
rc = ::read(fd, &ch, 1);
|
std::stringstream temp;
|
||||||
if((ch != '\r') && (ch != '\n'))
|
temp << "--" << boundary;
|
||||||
boundary.write(ch);
|
sections = in.split(temp.str().c_str());
|
||||||
}
|
for(int ix = 0; ix < sections.size(); ++ix) {
|
||||||
if(ch == '\r') {
|
sections[ix].ifNext("\r\n");
|
||||||
rc = ::read(fd, &ch, 1);
|
sections[ix].trimCRLF();
|
||||||
}
|
Log(LOG_DEBUG_1) << "[" << sections[ix] << "].";
|
||||||
while(1) {
|
if(sections[ix].equals("--"))
|
||||||
IMFFormData *formData = new IMFFormData(fd, boundary);
|
sections[ix] = ZString("");
|
||||||
|
sections[ix].ifNext("\r\n");
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
if(ch == '-') {
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
if(ch == '-') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if(ch == '\r') {
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
if(ch != '\n')
|
|
||||||
coreutils::Exception("expecting '\n' in data stream.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string IMFMultipart::toString() {
|
||||||
|
return std::string(getData(), getLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
int IMFMultipart::getCount() {
|
||||||
|
return sections.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZString IMFMultipart::getSectionAt(int index) {
|
||||||
|
return sections[index];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
#ifndef __IMFMultipart_h__
|
#ifndef __IMFMultipart_h__
|
||||||
#define __IMFMultipart_h__
|
#define __IMFMultipart_h__
|
||||||
|
|
||||||
#include "MString.h"
|
#include "ZString.h"
|
||||||
#include "IMFFormData.h"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
class IMFMultipart {
|
class IMFMultipart: public ZString {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFMultipart(int fd, MString boundary);
|
IMFMultipart();
|
||||||
|
IMFMultipart(ZString &in, ZString &boundary);
|
||||||
|
|
||||||
|
std::string toString();
|
||||||
|
int getCount();
|
||||||
|
ZString getSectionAt(int index);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<ZString> sections;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MString boundary;
|
char *boundary;
|
||||||
std::vector<IMFFormData> sections;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
10
IMFPlainText.cpp
Normal file
10
IMFPlainText.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "IMFPlainText.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
IMFPlainText::IMFPlainText() {
|
||||||
|
}
|
||||||
|
|
||||||
|
IMFPlainText::IMFPlainText(ZString &in) : ZString(in.str().c_str()) {}
|
||||||
|
|
||||||
|
}
|
18
IMFPlainText.h
Normal file
18
IMFPlainText.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __IMFPlainText_h__
|
||||||
|
#define __IMFPlainText_h__
|
||||||
|
|
||||||
|
#include "ZString.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
class IMFPlainText: public ZString {
|
||||||
|
|
||||||
|
public:
|
||||||
|
IMFPlainText();
|
||||||
|
IMFPlainText(ZString &in);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -18,14 +18,14 @@ namespace coreutils {
|
|||||||
if(mode == LENGTH) {
|
if(mode == LENGTH) {
|
||||||
sprintf(contentLength, "%li", content.str().length());
|
sprintf(contentLength, "%li", content.str().length());
|
||||||
ZString conlen(contentLength);
|
ZString conlen(contentLength);
|
||||||
// addHeader(IMFHeader("Content-Length", conlen));
|
addHeader(IMFHeader("Content-Length", conlen));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// addHeader(IMFHeader("Transfer-Encoding", "chunked"));
|
addHeader(IMFHeader("Transfer-Encoding", "chunked"));
|
||||||
|
|
||||||
// addHeader(IMFHeader("Server", "JETServer v0.0.1"));
|
addHeader(IMFHeader("Server", "JETServer v0.0.1"));
|
||||||
|
|
||||||
// output(response);
|
output(response);
|
||||||
response << content.str();
|
response << content.str();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace coreutils {
|
|||||||
/// and responses as the main communications protocol.
|
/// and responses as the main communications protocol.
|
||||||
///
|
///
|
||||||
|
|
||||||
class IMFResponse {
|
class IMFResponse : public IMFMessage {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -87,7 +87,6 @@ namespace coreutils {
|
|||||||
ZString code;
|
ZString code;
|
||||||
ZString text;
|
ZString text;
|
||||||
|
|
||||||
char contentLength[32];
|
|
||||||
const char *CRLF = "\r\n";
|
const char *CRLF = "\r\n";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
27
IMFText.cpp
27
IMFText.cpp
@ -1,27 +0,0 @@
|
|||||||
#include "IMFText.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
IMFText::IMFText(int fd, ZString boundary) : MString() {
|
|
||||||
char ch = 0;
|
|
||||||
int rc = 0;
|
|
||||||
boundary.reset();
|
|
||||||
int blen = boundary.getLength() + 1;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
rc = ::read(fd, &ch, 1);
|
|
||||||
if(boundary.nextChar() == ch) {
|
|
||||||
if(boundary.eod()) {
|
|
||||||
length -= blen;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
boundary.reset();
|
|
||||||
}
|
|
||||||
write(ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
18
IMFText.h
18
IMFText.h
@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
#ifndef __IMFText_h__
|
|
||||||
#define __IMFText_h__
|
|
||||||
|
|
||||||
#include "MString.h"
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
class IMFText : public MString {
|
|
||||||
|
|
||||||
public:
|
|
||||||
IMFText(int fd, ZString boundary);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
33
JSONFile.h
Normal file
33
JSONFile.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __JSONFile_h__
|
||||||
|
#define __JSONFile_h__
|
||||||
|
|
||||||
|
#include "JString.h"
|
||||||
|
#include "File.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Use the JSONFile object where you need a file based persistent backing store
|
||||||
|
/// for the JString style object.
|
||||||
|
///
|
||||||
|
|
||||||
|
class JSONFile : public JString : public File {
|
||||||
|
|
||||||
|
public:
|
||||||
|
JSONFile(ZString path): JString(), File(path, O_RDWR, 0644) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~JSONFile() {
|
||||||
|
write(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void changed(ZString key, ZString value) overide;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
20
MFile.cpp
20
MFile.cpp
@ -1,20 +0,0 @@
|
|||||||
#include "MFile.h"
|
|
||||||
#include "Exception.h"
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
MFile::MFile(coreutils::MString fileName) : fileName(fileName) {
|
|
||||||
inFile.open(fileName.c_str());
|
|
||||||
// *this << inFile;
|
|
||||||
inFile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MFile::update() {
|
|
||||||
outFile.open(fileName.c_str());
|
|
||||||
outFile << *this;
|
|
||||||
outFile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
35
MFile.h
35
MFile.h
@ -1,35 +0,0 @@
|
|||||||
#ifndef __MFile_h__
|
|
||||||
#define __MFile_h__
|
|
||||||
|
|
||||||
#include "MString.h"
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
///
|
|
||||||
/// MFile
|
|
||||||
///
|
|
||||||
/// An MString with a file backing store.
|
|
||||||
///
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
class MFile : public MString {
|
|
||||||
|
|
||||||
public:
|
|
||||||
MFile(MString fileName);
|
|
||||||
virtual ~MFile();
|
|
||||||
|
|
||||||
coreutils::MString fileName;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::ifstream inFile;
|
|
||||||
std::ofstream outFile;
|
|
||||||
|
|
||||||
void onChange() override;
|
|
||||||
void update();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
70
MString.cpp
70
MString.cpp
@ -2,7 +2,6 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "uuid/uuid.h"
|
#include "uuid/uuid.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Base64.h"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <format>
|
#include <format>
|
||||||
@ -10,7 +9,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
@ -107,31 +105,27 @@ namespace coreutils {
|
|||||||
setSize(value.getLength());
|
setSize(value.getLength());
|
||||||
memcpy(data, value.getData(), value.getLength());
|
memcpy(data, value.getData(), value.getLength());
|
||||||
length = value.getLength();
|
length = value.getLength();
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MString &MString::operator=(coreutils::ZString value) {
|
MString &MString::operator=(coreutils::ZString value) {
|
||||||
setSize(value.getLength());
|
setSize(value.getLength());
|
||||||
memcpy(data, value.getData(), value.getLength());
|
memcpy(data, value.getData(), value.getLength());
|
||||||
length = value.getLength();
|
length = value.getLength();
|
||||||
onChange();
|
return *this;
|
||||||
return *this;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MString &MString::operator=(std::string value) {
|
MString &MString::operator=(std::string value) {
|
||||||
setSize(value.length());
|
setSize(value.length());
|
||||||
memcpy(data, value.c_str(), value.length());
|
memcpy(data, value.c_str(), value.length());
|
||||||
length = value.length();
|
length = value.length();
|
||||||
onChange();
|
return *this;
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MString &MString::operator=(const char *value) {
|
MString &MString::operator=(const char *value) {
|
||||||
int len = strlen(value);
|
int len = strlen(value);
|
||||||
setSize(len);
|
setSize(len);
|
||||||
memcpy(data, value, len);
|
memcpy(data, value, len);
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +133,6 @@ namespace coreutils {
|
|||||||
int len = 1;
|
int len = 1;
|
||||||
setSize(1);
|
setSize(1);
|
||||||
*data = value;
|
*data = value;
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +144,6 @@ namespace coreutils {
|
|||||||
setSize(temp.length());
|
setSize(temp.length());
|
||||||
memcpy(this->data, (char *)temp.data(), temp.length());
|
memcpy(this->data, (char *)temp.data(), temp.length());
|
||||||
cursor = this->data;
|
cursor = this->data;
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +152,6 @@ namespace coreutils {
|
|||||||
setSize(temp.length());
|
setSize(temp.length());
|
||||||
memcpy(this->data, (char *)temp.data(), temp.length());
|
memcpy(this->data, (char *)temp.data(), temp.length());
|
||||||
cursor = this->data;
|
cursor = this->data;
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +160,6 @@ namespace coreutils {
|
|||||||
int len = strlen(value);
|
int len = strlen(value);
|
||||||
setSize(len + length);
|
setSize(len + length);
|
||||||
memcpy(data + temp, value, len);
|
memcpy(data + temp, value, len);
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +168,6 @@ namespace coreutils {
|
|||||||
temp << value;
|
temp << value;
|
||||||
MString temp2 = temp.str();
|
MString temp2 = temp.str();
|
||||||
write(temp2);
|
write(temp2);
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,14 +184,12 @@ namespace coreutils {
|
|||||||
int len = length + zstring.getLength();
|
int len = length + zstring.getLength();
|
||||||
setSize(len);
|
setSize(len);
|
||||||
memcpy(data + temp, zstring.getData(), zstring.getLength());
|
memcpy(data + temp, zstring.getData(), zstring.getLength());
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MString &MString::operator<<(char value) {
|
MString &MString::operator<<(char value) {
|
||||||
setSize(length + 1);
|
setSize(length + 1);
|
||||||
data[length - 1] = value;
|
data[length - 1] = value;
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,17 +202,12 @@ namespace coreutils {
|
|||||||
std::cout << "xxx" << std::endl;
|
std::cout << "xxx" << std::endl;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MString &operator<<(std::ostream &out) {
|
|
||||||
// *this << out;
|
|
||||||
// }
|
|
||||||
|
|
||||||
void MString::insert(char ch, int offset) {
|
void MString::insert(char ch, int offset) {
|
||||||
setSize(length + 1);
|
setSize(length + 1);
|
||||||
for (int ix = length; ix >= offset; ix--)
|
for (int ix = length; ix >= offset; ix--)
|
||||||
getData()[ix + 1] = getData()[ix];
|
getData()[ix + 1] = getData()[ix];
|
||||||
data[offset] = ch;
|
data[offset] = ch;
|
||||||
onChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MString::insert(ZString value, int offset) {
|
void MString::insert(ZString value, int offset) {
|
||||||
@ -233,7 +215,6 @@ namespace coreutils {
|
|||||||
for (int ix = length; ix >= offset; ix--)
|
for (int ix = length; ix >= offset; ix--)
|
||||||
getData()[ix] = getData()[ix - value.getLength()];
|
getData()[ix] = getData()[ix - value.getLength()];
|
||||||
std::memcpy(data + offset, value.getData(), value.getLength());
|
std::memcpy(data + offset, value.getData(), value.getLength());
|
||||||
onChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void MString::insert(std::string value, int offset) {
|
// void MString::insert(std::string value, int offset) {
|
||||||
@ -257,20 +238,17 @@ namespace coreutils {
|
|||||||
for (int ix = 0; ix < len; ix++)
|
for (int ix = 0; ix < len; ix++)
|
||||||
cursor[ix] = cursor[ix + length];
|
cursor[ix] = cursor[ix + length];
|
||||||
setSize(this->length - length);
|
setSize(this->length - length);
|
||||||
onChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MString::remove(int offset, int length) {
|
void MString::remove(int offset, int length) {
|
||||||
for (int ix = offset; ix < this->length; ix++)
|
for (int ix = offset; ix < this->length; ix++)
|
||||||
getData()[ix] = getData()[ix + length];
|
getData()[ix] = getData()[ix + length];
|
||||||
setSize(this->length - length);
|
setSize(this->length - length);
|
||||||
onChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MString &MString::write(char ch) {
|
MString &MString::write(char ch) {
|
||||||
setSize(length + 1);
|
setSize(length + 1);
|
||||||
*(data + length - 1) = ch;
|
*(data + length - 1) = ch;
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +256,6 @@ namespace coreutils {
|
|||||||
int len = length;
|
int len = length;
|
||||||
setSize(length + value.getLength());
|
setSize(length + value.getLength());
|
||||||
memcpy(data + len, value.getData(), value.getLength());
|
memcpy(data + len, value.getData(), value.getLength());
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,15 +274,6 @@ namespace coreutils {
|
|||||||
char ch;
|
char ch;
|
||||||
while(::read(fd, &ch, 1))
|
while(::read(fd, &ch, 1))
|
||||||
write(ch);
|
write(ch);
|
||||||
onChange();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
MString &MString::read(int fd, int count) {
|
|
||||||
char ch;
|
|
||||||
while(count-- && ::read(fd, &ch, 1))
|
|
||||||
write(ch);
|
|
||||||
onChange();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,29 +364,25 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MString MString::toBase64() {
|
MString MString::toBase64() {
|
||||||
Base64 b64;
|
MString target;
|
||||||
return b64.encode(*this);
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MString MString::fromBase64() {
|
MString MString::fromBase64() {
|
||||||
Base64 b64;
|
MString target;
|
||||||
return b64.decode(*this);
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MString MString::toUpper() {
|
MString MString::toUpper() {
|
||||||
MString target;
|
MString target;
|
||||||
for(int ix = 0; ix < length; ++ix)
|
|
||||||
target.write(std::toupper(data[ix]));
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MString MString::toLower() {
|
MString MString::toLower() {
|
||||||
MString target;
|
MString target;
|
||||||
for(int ix = 0; ix < length; ++ix)
|
|
||||||
target.write(std::tolower(data[ix]));
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +405,5 @@ namespace coreutils {
|
|||||||
c += 7;
|
c += 7;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MString::onChange() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
15
MString.h
15
MString.h
@ -165,12 +165,6 @@ namespace coreutils {
|
|||||||
|
|
||||||
// MString &operator<<(std::ostream (*f)(std::ostream&) );
|
// MString &operator<<(std::ostream (*f)(std::ostream&) );
|
||||||
MString &operator<<(std::basic_ostream<char> (*pf)(std::basic_ostream<char>&));
|
MString &operator<<(std::basic_ostream<char> (*pf)(std::basic_ostream<char>&));
|
||||||
|
|
||||||
///
|
|
||||||
///
|
|
||||||
///
|
|
||||||
|
|
||||||
MString &operator<<(std::ostream &out);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@ -237,8 +231,7 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
|
|
||||||
MString &read(int fd);
|
MString &read(int fd);
|
||||||
MString &read(int fd, int len);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@ -308,12 +301,6 @@ namespace coreutils {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setSize(int size);
|
void setSize(int size);
|
||||||
|
|
||||||
///
|
|
||||||
/// This method is called whenever a change is made to the MString storage.
|
|
||||||
///
|
|
||||||
|
|
||||||
virtual void onChange();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int bufferSize = 0;
|
int bufferSize = 0;
|
||||||
|
@ -614,11 +614,7 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
char ZString::getChar() {
|
|
||||||
return *cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
char ZString::nextChar() {
|
char ZString::nextChar() {
|
||||||
char temp = 0;
|
char temp = 0;
|
||||||
if(!eod())
|
if(!eod())
|
||||||
|
@ -434,12 +434,6 @@ namespace coreutils {
|
|||||||
|
|
||||||
bool trimCRLF();
|
bool trimCRLF();
|
||||||
|
|
||||||
///
|
|
||||||
/// Returns the character at the cursor and returns. Cursor is not changed.
|
|
||||||
///
|
|
||||||
|
|
||||||
char getChar();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the character at the cursor and advances the cursor one
|
/// Returns the character at the cursor and advances the cursor one
|
||||||
/// position until end of data.
|
/// position until end of data.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
g++ -g -std=c++20 -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
|
g++ -g -std=c++20 -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
|
||||||
g++ -g -std=c++20 -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils -lb64
|
g++ -g -std=c++20 -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
|
||||||
g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils
|
g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils
|
||||||
|
Binary file not shown.
@ -95,19 +95,8 @@ int main(int argc, char **argv) {
|
|||||||
test28 = test29;
|
test28 = test29;
|
||||||
std::cout << "int: " << test28 << std::endl;
|
std::cout << "int: " << test28 << std::endl;
|
||||||
|
|
||||||
coreutils::MString test30 = "ABCDEF0123";
|
coreutils::MString test30 = "ABCDEF";
|
||||||
std::cout << test30 << " to hex " << test30.toHex() << " from hex " << test30.toHex().fromHex() << std::endl;
|
std::cout << test30 << " to hex " << test30.toHex() << " from hex " << test30.toHex().fromHex() << std::endl;
|
||||||
|
|
||||||
std::cout << test30 << " to lower " << test30.toLower() << std::endl;
|
|
||||||
|
|
||||||
coreutils::MString test31 = "abcdef0123";
|
|
||||||
std::cout << test31 << " to upper " << test31.toUpper() << std::endl;
|
|
||||||
|
|
||||||
coreutils::MString test32 = "This is a test of converting this string to base64";
|
|
||||||
std::cout << test32 << " to base64 " << test32.toBase64() << std::endl;
|
|
||||||
|
|
||||||
coreutils::MString test33 = test32.toBase64();
|
|
||||||
std::cout << test33 << " from base64 " << test33.fromBase64() << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user