Compare commits
46
Commits
25916051e6
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6719b8c9a3 | ||
|
|
f5aee23f5e | ||
|
|
2cea81c996 | ||
|
|
05374bdb15 | ||
|
|
694c6b80a4 | ||
|
|
a0cef8077d | ||
|
|
29db853706 | ||
|
|
78c45d378c | ||
|
|
d7057ebb00 | ||
|
|
6b188fbee5 | ||
|
|
cb845efe69 | ||
|
|
6e4e463a96 | ||
|
|
3e6e410fe8 | ||
|
|
5b6d4ea8ab | ||
|
|
bf6810b781 | ||
|
|
a033cc6718 | ||
|
|
94d4a30e88 | ||
|
|
28feaff3d7 | ||
|
|
14697e2af2 | ||
|
|
4082e82466 | ||
|
|
29c9a5b855 | ||
|
|
ba85c5f2e5 | ||
|
|
d79697775b | ||
|
|
b5652e26cc | ||
|
|
d415e0abd3 | ||
|
|
ccfab5aecf | ||
|
|
0243468d44 | ||
|
|
d54aec1f06 | ||
|
|
1542fbe218 | ||
|
|
ab748802ee | ||
|
|
ffa3361fd2 | ||
|
|
4988f98223 | ||
|
|
829dc1a3c7 | ||
|
|
11d6f00bfb | ||
|
|
72c1286053 | ||
|
|
a87ce0bab7 | ||
|
|
9cd8381845 | ||
|
|
bd5223ca36 | ||
|
|
b774e50b59 | ||
|
|
a3d5a4f93f | ||
|
|
2866056072 | ||
|
|
fd7a9ed860 | ||
|
|
f35fa12902 | ||
|
|
96f5c02435 | ||
|
|
11f396a749 | ||
|
|
3f0a541e80 |
No files matched your search
@@ -9,3 +9,4 @@ build/
|
|||||||
.history/
|
.history/
|
||||||
testing/mstring_test
|
testing/mstring_test
|
||||||
testing/zstring_test
|
testing/zstring_test
|
||||||
|
testing/http_test
|
||||||
Binary file not shown.
Binary file not shown.
+187
@@ -0,0 +1,187 @@
|
|||||||
|
#include "CGIFormData.h"
|
||||||
|
#include "CGIFormattedData.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
CGIFormData::CGIFormData(StreamReader &reader, ZString contentType, int contentLength, ZString boundary)
|
||||||
|
: Parser(reader), contentType(contentType), contentLength(contentLength), boundary(boundary) {
|
||||||
|
if (contentType.startsWith("application/x-www-form-urlencoded"))
|
||||||
|
mode = URLENCODED;
|
||||||
|
else if (contentType.startsWith("multipart/form-data"))
|
||||||
|
mode = MULTIPART;
|
||||||
|
else
|
||||||
|
mode = UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGIFormData::~CGIFormData() {
|
||||||
|
delete headerParser;
|
||||||
|
delete boundaryParser;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGIFormData::extractPartName(IMFHeader &header) {
|
||||||
|
auto &fields = header.getHeaders();
|
||||||
|
MString disposition = fields[MString("Content-Disposition")];
|
||||||
|
ZString dz(disposition.getData(), disposition.getLength());
|
||||||
|
|
||||||
|
int namePos = dz.find(ZString("name=\""));
|
||||||
|
if (namePos != -1) {
|
||||||
|
ZString afterName = dz.substring(namePos + 6);
|
||||||
|
int nameEnd = afterName.find(ZString("\""));
|
||||||
|
if (nameEnd != -1)
|
||||||
|
currentName = MString(afterName.substring(0, nameEnd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Parser::Status CGIFormData::parse() {
|
||||||
|
MString &buffer = reader.getBuffer();
|
||||||
|
|
||||||
|
if (mode == UNKNOWN) {
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
|
||||||
|
case INIT:
|
||||||
|
if (mode == URLENCODED) {
|
||||||
|
state = URLENCODED_BODY;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
// MULTIPART: the very first boundary line has no leading CRLF
|
||||||
|
// (RFC 2046) - handled here directly rather than via IMFBoundary,
|
||||||
|
// which always expects the CRLF that terminates a PRECEDING part.
|
||||||
|
// Split into two states (find+consume the marker, then separately
|
||||||
|
// disambiguate -- vs CRLF) so that if the marker is consumed but
|
||||||
|
// there isn't yet enough data to tell -- from CRLF, retrying does
|
||||||
|
// not re-search for (and skip past) a marker that is already
|
||||||
|
// behind the cursor - the exact bug class already fixed once in
|
||||||
|
// IMFBoundary's PREFIX/TAIL split.
|
||||||
|
{
|
||||||
|
MString marker;
|
||||||
|
marker << "--";
|
||||||
|
marker << boundary;
|
||||||
|
int pos = buffer.find(marker);
|
||||||
|
if (pos < 0)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (!buffer.ifNext(marker))
|
||||||
|
throw coreutils::Exception("CGIFormData: opening boundary vanished between find and ifNext.");
|
||||||
|
state = OPENING_TAIL;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OPENING_TAIL:
|
||||||
|
if (buffer.getLength() < 2)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (buffer.ifNext(ZString("--"))) {
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
if (!buffer.ifNext(ZString("\r\n")))
|
||||||
|
throw coreutils::Exception("CGIFormData: malformed opening boundary line.");
|
||||||
|
state = PART_HEADERS;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
|
||||||
|
case URLENCODED_BODY:
|
||||||
|
if ((int)buffer.getLength() < contentLength)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
{
|
||||||
|
ZString body(buffer.getCursor(), contentLength);
|
||||||
|
buffer.setCursor(buffer.getCursor() + contentLength);
|
||||||
|
CGIFormattedData parsed(body);
|
||||||
|
for (auto &pair : parsed.data)
|
||||||
|
storeValue(pair.first, pair.second);
|
||||||
|
}
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
|
||||||
|
case PART_HEADERS:
|
||||||
|
if (!headerParser)
|
||||||
|
headerParser = new IMFHeader(reader);
|
||||||
|
if (!checkParse(*headerParser))
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
extractPartName(*headerParser);
|
||||||
|
delete headerParser;
|
||||||
|
headerParser = NULL;
|
||||||
|
state = PART_BODY;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
|
||||||
|
case PART_BODY: {
|
||||||
|
MString marker;
|
||||||
|
marker << "\r\n--";
|
||||||
|
marker << boundary;
|
||||||
|
char *bodyStart = buffer.getCursor();
|
||||||
|
// parse() runs again for every 4KB TLS read, and searching the
|
||||||
|
// whole part from bodyStart each time (buffer.find(), one
|
||||||
|
// character at a time) made uploads quadratic: 1MB took a
|
||||||
|
// minute and a camera JPEG never finished. memmem() from where
|
||||||
|
// the last call stopped (less the marker length, in case the
|
||||||
|
// marker straddles two reads) keeps it linear.
|
||||||
|
size_t avail = buffer.getLength();
|
||||||
|
size_t markerLength = marker.getLength();
|
||||||
|
size_t from = partScanned >= markerLength ? partScanned - markerLength + 1 : 0;
|
||||||
|
void *hit = from < avail ? memmem(bodyStart + from, avail - from, marker.getData(), markerLength) : NULL;
|
||||||
|
if (!hit) {
|
||||||
|
partScanned = avail;
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
}
|
||||||
|
partScanned = 0;
|
||||||
|
char *bodyEnd = (char *)hit;
|
||||||
|
buffer.setCursor(bodyEnd);
|
||||||
|
// A part whose Content-Disposition includes filename="..."
|
||||||
|
// (a real <input type="file">) used to be silently discarded
|
||||||
|
// here (currentSkip) rather than stored like any other part -
|
||||||
|
// every existing <field type="file"> upload (track audio,
|
||||||
|
// presets, project icons) has therefore never actually
|
||||||
|
// received real file content via $[fieldname], only ever an
|
||||||
|
// empty value. Storing it the same way as any other part is
|
||||||
|
// exactly what those call sites already assume.
|
||||||
|
if (currentName.getLength() > 0)
|
||||||
|
storeValue(currentName, MString(ZString(bodyStart, bodyEnd - bodyStart)));
|
||||||
|
currentName = MString();
|
||||||
|
state = PART_BOUNDARY;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PART_BOUNDARY:
|
||||||
|
if (!boundaryParser)
|
||||||
|
boundaryParser = new IMFBoundary(reader, boundary);
|
||||||
|
if (!checkParse(*boundaryParser))
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
{
|
||||||
|
bool last = boundaryParser->isLast();
|
||||||
|
delete boundaryParser;
|
||||||
|
boundaryParser = NULL;
|
||||||
|
if (last) {
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
state = PART_HEADERS;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case DONE:
|
||||||
|
return Status::COMPLETE;
|
||||||
|
|
||||||
|
}
|
||||||
|
throw coreutils::Exception("CGIFormData: unreachable state.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGIFormData::storeValue(MString name, MString value) {
|
||||||
|
int index = nameCounts[name]++;
|
||||||
|
MString key = name;
|
||||||
|
key << ":";
|
||||||
|
key << MString(std::to_string(index));
|
||||||
|
data[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
MString CGIFormData::operator[](ZString name) {
|
||||||
|
MString key(name);
|
||||||
|
if (key.find(ZString(":")) == -1) {
|
||||||
|
key << ":0";
|
||||||
|
}
|
||||||
|
return data[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
#ifndef __CGIFormData_h__
|
||||||
|
# define __CGIFormData_h__
|
||||||
|
|
||||||
|
#include "Parser.h"
|
||||||
|
#include "IMFHeader.h"
|
||||||
|
#include "IMFBoundary.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// CGIFormData parses a CGI request body (application/x-www-form-urlencoded
|
||||||
|
/// or multipart/form-data) from the shared StreamReader and exposes the
|
||||||
|
/// resulting name/value pairs via operator[] - the object a caller (e.g.
|
||||||
|
/// JetCore's Tag::getVariable, for its $[:name] CGI variable syntax) holds
|
||||||
|
/// onto and indexes by variable name once doParse() reports COMPLETE.
|
||||||
|
///
|
||||||
|
/// Resumable like every other Parser here: for multipart/form-data, each
|
||||||
|
/// part's boundary line and header block are parsed via IMFBoundary/
|
||||||
|
/// IMFHeader (chained through checkParse(), sharing this same
|
||||||
|
/// StreamReader), so a part - or even its boundary marker - can straddle
|
||||||
|
/// any number of feed() calls without losing state. File-upload parts
|
||||||
|
/// (Content-Disposition with a filename= parameter) are recognized and
|
||||||
|
/// skipped - matching this codebase's existing convention that uploads
|
||||||
|
/// get a separate mechanism, not buffered through here.
|
||||||
|
///
|
||||||
|
|
||||||
|
class CGIFormData : public Parser {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
CGIFormData(StreamReader &reader, ZString contentType, int contentLength, ZString boundary);
|
||||||
|
virtual ~CGIFormData();
|
||||||
|
|
||||||
|
MString operator[](ZString name);
|
||||||
|
|
||||||
|
// Every parsed field, keyed as "name:N" (see storeValue's own doc
|
||||||
|
// comment below) - lets a caller (ApiSession::handleComplete, to
|
||||||
|
// merge POST body fields into jet::Global::variables the same way
|
||||||
|
// path params/query string already are - see its own doc comment)
|
||||||
|
// iterate every field without knowing its name in advance, which
|
||||||
|
// operator[] alone doesn't support.
|
||||||
|
const std::map<MString, MString> &fields() const { return data; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Status parse() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
enum Mode { URLENCODED, MULTIPART, UNKNOWN } mode;
|
||||||
|
enum State { INIT, OPENING_TAIL, PART_HEADERS, PART_BODY, PART_BOUNDARY, URLENCODED_BODY, DONE } state = INIT;
|
||||||
|
|
||||||
|
ZString contentType;
|
||||||
|
int contentLength;
|
||||||
|
ZString boundary;
|
||||||
|
std::map<MString, MString> data;
|
||||||
|
|
||||||
|
IMFHeader *headerParser = NULL;
|
||||||
|
IMFBoundary *boundaryParser = NULL;
|
||||||
|
MString currentName;
|
||||||
|
std::map<MString, int> nameCounts;
|
||||||
|
/// How many bytes of the current part's body (from the cursor) have
|
||||||
|
/// already been searched for the closing boundary, so each new 4KB
|
||||||
|
/// TLS read only searches the new bytes (see PART_BODY).
|
||||||
|
size_t partScanned = 0;
|
||||||
|
|
||||||
|
void extractPartName(IMFHeader &header);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Stores value under "name:N", where N is how many values have
|
||||||
|
/// already been stored under this same base name (0 for the first,
|
||||||
|
/// 1 for the second, etc.) - matches the indexed key format
|
||||||
|
/// JetCore's Tag::getVariable's $[:name] syntax looks up by
|
||||||
|
/// (defaulting to :0 when the caller doesn't specify an index),
|
||||||
|
/// supporting repeated field names (checkboxes, multi-select) the
|
||||||
|
/// same way.
|
||||||
|
///
|
||||||
|
|
||||||
|
void storeValue(MString name, MString value);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+21
-12
@@ -6,22 +6,31 @@ namespace coreutils {
|
|||||||
CGIFormattedData::CGIFormattedData() {}
|
CGIFormattedData::CGIFormattedData() {}
|
||||||
|
|
||||||
CGIFormattedData::CGIFormattedData(ZString cgiData) {
|
CGIFormattedData::CGIFormattedData(ZString cgiData) {
|
||||||
cgiData.split("&");
|
parse(cgiData);
|
||||||
for(int ix = 1; ix < cgiData.getList().size(); ++ix) {
|
}
|
||||||
cgiData[0].split("=");
|
|
||||||
data[cgiData[0]] = cgiData[1];
|
CGIFormattedData::CGIFormattedData(ZString cgiData, ZString delimiter) : delimiter(delimiter) {
|
||||||
data[cgiData[0]].fromCGI();
|
parse(cgiData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGIFormattedData::setDelimiter(ZString delimiter) {
|
||||||
|
this->delimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGIFormattedData::parse(ZString cgiData) {
|
||||||
|
if(cgiData != "") {
|
||||||
|
cgiData.split(delimiter);
|
||||||
|
for(int ix = 0; ix < cgiData.getList().size(); ++ix) {
|
||||||
|
ZString pair = cgiData[ix].trim();
|
||||||
|
pair.split("=");
|
||||||
|
data[pair[0]] = pair[1];
|
||||||
|
data[pair[0]] = data[pair[0]].fromCGI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZString CGIFormattedData::operator=(ZString cgiData) {
|
ZString CGIFormattedData::operator=(ZString cgiData) {
|
||||||
cgiData.split("&");
|
parse(cgiData);
|
||||||
for(int ix = 1; ix < cgiData.getList().size(); ++ix) {
|
|
||||||
cgiData[0].split("=");
|
|
||||||
data[cgiData[0]] = cgiData[1];
|
|
||||||
data[cgiData[0]].fromCGI();
|
|
||||||
}
|
|
||||||
return cgiData;
|
return cgiData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,18 @@ namespace coreutils {
|
|||||||
public:
|
public:
|
||||||
CGIFormattedData();
|
CGIFormattedData();
|
||||||
CGIFormattedData(ZString cgiData);
|
CGIFormattedData(ZString cgiData);
|
||||||
|
CGIFormattedData(ZString cgiData, ZString delimiter);
|
||||||
|
|
||||||
ZString operator=(ZString cgiData);
|
ZString operator=(ZString cgiData);
|
||||||
|
void setDelimiter(ZString delimiter);
|
||||||
|
|
||||||
std::map<MString, MString> data;
|
std::map<MString, MString> data;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parse(ZString cgiData);
|
||||||
|
|
||||||
|
ZString delimiter = "&";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-372
@@ -1,372 +0,0 @@
|
|||||||
# This is the CMakeCache file.
|
|
||||||
# For build in directory: /home/bradarant/barant/CoreUtils
|
|
||||||
# It was generated by CMake: /usr/bin/cmake
|
|
||||||
# You can edit this file to change values found and used by cmake.
|
|
||||||
# If you do not want to change any of the values, simply exit the editor.
|
|
||||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
|
||||||
# The syntax for the file is as follows:
|
|
||||||
# KEY:TYPE=VALUE
|
|
||||||
# KEY is the name of a variable in the cache.
|
|
||||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
|
||||||
# VALUE is the current value for the KEY.
|
|
||||||
|
|
||||||
########################
|
|
||||||
# EXTERNAL cache entries
|
|
||||||
########################
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_ADDR2LINE:FILEPATH=/usr/bin/addr2line
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_AR:FILEPATH=/usr/bin/ar
|
|
||||||
|
|
||||||
//Choose the type of build, options are: None Debug Release RelWithDebInfo
|
|
||||||
// MinSizeRel ...
|
|
||||||
CMAKE_BUILD_TYPE:STRING=
|
|
||||||
|
|
||||||
//Enable/Disable color output during build.
|
|
||||||
CMAKE_COLOR_MAKEFILE:BOOL=ON
|
|
||||||
|
|
||||||
//CXX compiler
|
|
||||||
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
|
|
||||||
|
|
||||||
//A wrapper around 'ar' adding the appropriate '--plugin' option
|
|
||||||
// for the GCC compiler
|
|
||||||
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-9
|
|
||||||
|
|
||||||
//A wrapper around 'ranlib' adding the appropriate '--plugin' option
|
|
||||||
// for the GCC compiler
|
|
||||||
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-9
|
|
||||||
|
|
||||||
//Flags used by the CXX compiler during all build types.
|
|
||||||
CMAKE_CXX_FLAGS:STRING=
|
|
||||||
|
|
||||||
//Flags used by the CXX compiler during DEBUG builds.
|
|
||||||
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
|
|
||||||
|
|
||||||
//Flags used by the CXX compiler during MINSIZEREL builds.
|
|
||||||
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
|
||||||
|
|
||||||
//Flags used by the CXX compiler during RELEASE builds.
|
|
||||||
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
|
||||||
|
|
||||||
//Flags used by the CXX compiler during RELWITHDEBINFO builds.
|
|
||||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
|
||||||
|
|
||||||
//C compiler
|
|
||||||
CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
|
|
||||||
|
|
||||||
//A wrapper around 'ar' adding the appropriate '--plugin' option
|
|
||||||
// for the GCC compiler
|
|
||||||
CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-9
|
|
||||||
|
|
||||||
//A wrapper around 'ranlib' adding the appropriate '--plugin' option
|
|
||||||
// for the GCC compiler
|
|
||||||
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-9
|
|
||||||
|
|
||||||
//Flags used by the C compiler during all build types.
|
|
||||||
CMAKE_C_FLAGS:STRING=
|
|
||||||
|
|
||||||
//Flags used by the C compiler during DEBUG builds.
|
|
||||||
CMAKE_C_FLAGS_DEBUG:STRING=-g
|
|
||||||
|
|
||||||
//Flags used by the C compiler during MINSIZEREL builds.
|
|
||||||
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
|
||||||
|
|
||||||
//Flags used by the C compiler during RELEASE builds.
|
|
||||||
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
|
||||||
|
|
||||||
//Flags used by the C compiler during RELWITHDEBINFO builds.
|
|
||||||
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_DLLTOOL:FILEPATH=CMAKE_DLLTOOL-NOTFOUND
|
|
||||||
|
|
||||||
//Flags used by the linker during all build types.
|
|
||||||
CMAKE_EXE_LINKER_FLAGS:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during DEBUG builds.
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during MINSIZEREL builds.
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during RELEASE builds.
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during RELWITHDEBINFO builds.
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
|
||||||
|
|
||||||
//Enable/Disable output of compile commands during generation.
|
|
||||||
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
|
|
||||||
|
|
||||||
//Install path prefix, prepended onto install directories.
|
|
||||||
CMAKE_INSTALL_PREFIX:PATH=/usr/local
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_LINKER:FILEPATH=/usr/bin/ld
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of modules during
|
|
||||||
// all build types.
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of modules during
|
|
||||||
// DEBUG builds.
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of modules during
|
|
||||||
// MINSIZEREL builds.
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of modules during
|
|
||||||
// RELEASE builds.
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of modules during
|
|
||||||
// RELWITHDEBINFO builds.
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_NM:FILEPATH=/usr/bin/nm
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
CMAKE_PROJECT_NAME:STATIC=CoreUtils
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_READELF:FILEPATH=/usr/bin/readelf
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of shared libraries
|
|
||||||
// during all build types.
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of shared libraries
|
|
||||||
// during DEBUG builds.
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of shared libraries
|
|
||||||
// during MINSIZEREL builds.
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of shared libraries
|
|
||||||
// during RELEASE builds.
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of shared libraries
|
|
||||||
// during RELWITHDEBINFO builds.
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
|
||||||
|
|
||||||
//If set, runtime paths are not added when installing shared libraries,
|
|
||||||
// but are added when building.
|
|
||||||
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
|
|
||||||
|
|
||||||
//If set, runtime paths are not added when using shared libraries.
|
|
||||||
CMAKE_SKIP_RPATH:BOOL=NO
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of static libraries
|
|
||||||
// during all build types.
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of static libraries
|
|
||||||
// during DEBUG builds.
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of static libraries
|
|
||||||
// during MINSIZEREL builds.
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of static libraries
|
|
||||||
// during RELEASE builds.
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
|
|
||||||
|
|
||||||
//Flags used by the linker during the creation of static libraries
|
|
||||||
// during RELWITHDEBINFO builds.
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
|
||||||
|
|
||||||
//Path to a program.
|
|
||||||
CMAKE_STRIP:FILEPATH=/usr/bin/strip
|
|
||||||
|
|
||||||
//If this value is on, makefiles will be generated without the
|
|
||||||
// .SILENT directive, and all commands will be echoed to the console
|
|
||||||
// during the make. This is useful for debugging only. With Visual
|
|
||||||
// Studio IDE projects all commands are done without /nologo.
|
|
||||||
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
CoreUtils_BINARY_DIR:STATIC=/home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
CoreUtils_SOURCE_DIR:STATIC=/home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
Project_BINARY_DIR:STATIC=/home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
//Value Computed by CMake
|
|
||||||
Project_SOURCE_DIR:STATIC=/home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
|
|
||||||
########################
|
|
||||||
# INTERNAL cache entries
|
|
||||||
########################
|
|
||||||
|
|
||||||
//ADVANCED property for variable: CMAKE_ADDR2LINE
|
|
||||||
CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_AR
|
|
||||||
CMAKE_AR-ADVANCED:INTERNAL=1
|
|
||||||
//This is the directory where this CMakeCache.txt was created
|
|
||||||
CMAKE_CACHEFILE_DIR:INTERNAL=/home/bradarant/barant/CoreUtils
|
|
||||||
//Major version of cmake used to create the current loaded cache
|
|
||||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
|
||||||
//Minor version of cmake used to create the current loaded cache
|
|
||||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=16
|
|
||||||
//Patch version of cmake used to create the current loaded cache
|
|
||||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=3
|
|
||||||
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
|
|
||||||
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
|
|
||||||
//Path to CMake executable.
|
|
||||||
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
|
|
||||||
//Path to cpack program executable.
|
|
||||||
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
|
|
||||||
//Path to ctest program executable.
|
|
||||||
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER
|
|
||||||
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER_AR
|
|
||||||
CMAKE_CXX_COMPILER_AR-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER_RANLIB
|
|
||||||
CMAKE_CXX_COMPILER_RANLIB-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS
|
|
||||||
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
|
|
||||||
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
|
|
||||||
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
|
|
||||||
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_COMPILER
|
|
||||||
CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_COMPILER_AR
|
|
||||||
CMAKE_C_COMPILER_AR-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_COMPILER_RANLIB
|
|
||||||
CMAKE_C_COMPILER_RANLIB-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_FLAGS
|
|
||||||
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
|
|
||||||
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
|
|
||||||
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
|
|
||||||
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_DLLTOOL
|
|
||||||
CMAKE_DLLTOOL-ADVANCED:INTERNAL=1
|
|
||||||
//Executable file format
|
|
||||||
CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
|
|
||||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
|
|
||||||
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
|
|
||||||
CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
|
|
||||||
//Name of external makefile project generator.
|
|
||||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
|
||||||
//Name of generator.
|
|
||||||
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
|
|
||||||
//Generator instance identifier.
|
|
||||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
|
||||||
//Name of generator platform.
|
|
||||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
|
||||||
//Name of generator toolset.
|
|
||||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
|
||||||
//Source directory with the top level CMakeLists.txt file for this
|
|
||||||
// project
|
|
||||||
CMAKE_HOME_DIRECTORY:INTERNAL=/home/bradarant/barant/CoreUtils
|
|
||||||
//Install .so files without execute permission.
|
|
||||||
CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_LINKER
|
|
||||||
CMAKE_LINKER-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
|
|
||||||
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_NM
|
|
||||||
CMAKE_NM-ADVANCED:INTERNAL=1
|
|
||||||
//number of local generators
|
|
||||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_OBJCOPY
|
|
||||||
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_OBJDUMP
|
|
||||||
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
|
|
||||||
//Platform information initialized
|
|
||||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_RANLIB
|
|
||||||
CMAKE_RANLIB-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_READELF
|
|
||||||
CMAKE_READELF-ADVANCED:INTERNAL=1
|
|
||||||
//Path to CMake installation.
|
|
||||||
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.16
|
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
|
|
||||||
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_SKIP_RPATH
|
|
||||||
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
|
||||||
//ADVANCED property for variable: CMAKE_STRIP
|
|
||||||
CMAKE_STRIP-ADVANCED:INTERNAL=1
|
|
||||||
//uname command
|
|
||||||
CMAKE_UNAME:INTERNAL=/bin/uname
|
|
||||||
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
|
|
||||||
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
|
|
||||||
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
set(CMAKE_C_COMPILER "/usr/bin/cc")
|
|
||||||
set(CMAKE_C_COMPILER_ARG1 "")
|
|
||||||
set(CMAKE_C_COMPILER_ID "GNU")
|
|
||||||
set(CMAKE_C_COMPILER_VERSION "9.3.0")
|
|
||||||
set(CMAKE_C_COMPILER_VERSION_INTERNAL "")
|
|
||||||
set(CMAKE_C_COMPILER_WRAPPER "")
|
|
||||||
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11")
|
|
||||||
set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert")
|
|
||||||
set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
|
|
||||||
set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros")
|
|
||||||
set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert")
|
|
||||||
|
|
||||||
set(CMAKE_C_PLATFORM_ID "Linux")
|
|
||||||
set(CMAKE_C_SIMULATE_ID "")
|
|
||||||
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
|
|
||||||
set(CMAKE_C_SIMULATE_VERSION "")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_AR "/usr/bin/ar")
|
|
||||||
set(CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-9")
|
|
||||||
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
|
||||||
set(CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-9")
|
|
||||||
set(CMAKE_LINKER "/usr/bin/ld")
|
|
||||||
set(CMAKE_MT "")
|
|
||||||
set(CMAKE_COMPILER_IS_GNUCC 1)
|
|
||||||
set(CMAKE_C_COMPILER_LOADED 1)
|
|
||||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
|
||||||
set(CMAKE_C_ABI_COMPILED TRUE)
|
|
||||||
set(CMAKE_COMPILER_IS_MINGW )
|
|
||||||
set(CMAKE_COMPILER_IS_CYGWIN )
|
|
||||||
if(CMAKE_COMPILER_IS_CYGWIN)
|
|
||||||
set(CYGWIN 1)
|
|
||||||
set(UNIX 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_C_COMPILER_ENV_VAR "CC")
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_MINGW)
|
|
||||||
set(MINGW 1)
|
|
||||||
endif()
|
|
||||||
set(CMAKE_C_COMPILER_ID_RUN 1)
|
|
||||||
set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
|
|
||||||
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
|
||||||
set(CMAKE_C_LINKER_PREFERENCE 10)
|
|
||||||
|
|
||||||
# Save compiler ABI information.
|
|
||||||
set(CMAKE_C_SIZEOF_DATA_PTR "8")
|
|
||||||
set(CMAKE_C_COMPILER_ABI "ELF")
|
|
||||||
set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
|
|
||||||
|
|
||||||
if(CMAKE_C_SIZEOF_DATA_PTR)
|
|
||||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ABI)
|
|
||||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_C_LIBRARY_ARCHITECTURE)
|
|
||||||
set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "")
|
|
||||||
if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
|
|
||||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include")
|
|
||||||
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "gcc;gcc_s;c;gcc;gcc_s")
|
|
||||||
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib")
|
|
||||||
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
set(CMAKE_CXX_COMPILER "/usr/bin/c++")
|
|
||||||
set(CMAKE_CXX_COMPILER_ARG1 "")
|
|
||||||
set(CMAKE_CXX_COMPILER_ID "GNU")
|
|
||||||
set(CMAKE_CXX_COMPILER_VERSION "9.3.0")
|
|
||||||
set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
|
|
||||||
set(CMAKE_CXX_COMPILER_WRAPPER "")
|
|
||||||
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")
|
|
||||||
set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17;cxx_std_20")
|
|
||||||
set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
|
|
||||||
set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
|
|
||||||
set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
|
|
||||||
set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
|
|
||||||
set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20")
|
|
||||||
|
|
||||||
set(CMAKE_CXX_PLATFORM_ID "Linux")
|
|
||||||
set(CMAKE_CXX_SIMULATE_ID "")
|
|
||||||
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "")
|
|
||||||
set(CMAKE_CXX_SIMULATE_VERSION "")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_AR "/usr/bin/ar")
|
|
||||||
set(CMAKE_CXX_COMPILER_AR "/usr/bin/gcc-ar-9")
|
|
||||||
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
|
||||||
set(CMAKE_CXX_COMPILER_RANLIB "/usr/bin/gcc-ranlib-9")
|
|
||||||
set(CMAKE_LINKER "/usr/bin/ld")
|
|
||||||
set(CMAKE_MT "")
|
|
||||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
|
||||||
set(CMAKE_CXX_COMPILER_LOADED 1)
|
|
||||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
|
||||||
set(CMAKE_CXX_ABI_COMPILED TRUE)
|
|
||||||
set(CMAKE_COMPILER_IS_MINGW )
|
|
||||||
set(CMAKE_COMPILER_IS_CYGWIN )
|
|
||||||
if(CMAKE_COMPILER_IS_CYGWIN)
|
|
||||||
set(CYGWIN 1)
|
|
||||||
set(UNIX 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_MINGW)
|
|
||||||
set(MINGW 1)
|
|
||||||
endif()
|
|
||||||
set(CMAKE_CXX_COMPILER_ID_RUN 1)
|
|
||||||
set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP)
|
|
||||||
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
|
||||||
|
|
||||||
foreach (lang C OBJC OBJCXX)
|
|
||||||
if (CMAKE_${lang}_COMPILER_ID_RUN)
|
|
||||||
foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
|
|
||||||
list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_LINKER_PREFERENCE 30)
|
|
||||||
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
|
|
||||||
|
|
||||||
# Save compiler ABI information.
|
|
||||||
set(CMAKE_CXX_SIZEOF_DATA_PTR "8")
|
|
||||||
set(CMAKE_CXX_COMPILER_ABI "ELF")
|
|
||||||
set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
|
|
||||||
|
|
||||||
if(CMAKE_CXX_SIZEOF_DATA_PTR)
|
|
||||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ABI)
|
|
||||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
|
|
||||||
set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
|
|
||||||
if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
|
|
||||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "/usr/include/c++/9;/usr/include/x86_64-linux-gnu/c++/9;/usr/include/c++/9/backward;/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include")
|
|
||||||
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;gcc_s;gcc;c;gcc_s;gcc")
|
|
||||||
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib")
|
|
||||||
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,15 +0,0 @@
|
|||||||
set(CMAKE_HOST_SYSTEM "Linux-5.4.0-65-generic")
|
|
||||||
set(CMAKE_HOST_SYSTEM_NAME "Linux")
|
|
||||||
set(CMAKE_HOST_SYSTEM_VERSION "5.4.0-65-generic")
|
|
||||||
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_SYSTEM "Linux-5.4.0-65-generic")
|
|
||||||
set(CMAKE_SYSTEM_NAME "Linux")
|
|
||||||
set(CMAKE_SYSTEM_VERSION "5.4.0-65-generic")
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
|
|
||||||
|
|
||||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
|
||||||
|
|
||||||
set(CMAKE_SYSTEM_LOADED 1)
|
|
||||||
@@ -1,671 +0,0 @@
|
|||||||
#ifdef __cplusplus
|
|
||||||
# error "A C++ compiler has been selected for C."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__18CXX)
|
|
||||||
# define ID_VOID_MAIN
|
|
||||||
#endif
|
|
||||||
#if defined(__CLASSIC_C__)
|
|
||||||
/* cv-qualifiers did not exist in K&R C */
|
|
||||||
# define const
|
|
||||||
# define volatile
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Version number components: V=Version, R=Revision, P=Patch
|
|
||||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
|
||||||
|
|
||||||
#if defined(__INTEL_COMPILER) || defined(__ICC)
|
|
||||||
# define COMPILER_ID "Intel"
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define SIMULATE_ID "MSVC"
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC__)
|
|
||||||
# define SIMULATE_ID "GNU"
|
|
||||||
# endif
|
|
||||||
/* __INTEL_COMPILER = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
|
||||||
# if defined(__INTEL_COMPILER_UPDATE)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
|
||||||
# else
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
|
||||||
# endif
|
|
||||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
|
||||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
|
||||||
# endif
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC__)
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
|
||||||
# elif defined(__GNUG__)
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_MINOR__)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_PATCHLEVEL__)
|
|
||||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__PATHCC__)
|
|
||||||
# define COMPILER_ID "PathScale"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
|
||||||
# if defined(__PATHCC_PATCHLEVEL__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
|
||||||
# define COMPILER_ID "Embarcadero"
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
|
||||||
|
|
||||||
#elif defined(__BORLANDC__)
|
|
||||||
# define COMPILER_ID "Borland"
|
|
||||||
/* __BORLANDC__ = 0xVRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
|
||||||
# define COMPILER_ID "Watcom"
|
|
||||||
/* __WATCOMC__ = VVRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
|
||||||
# if (__WATCOMC__ % 10) > 0
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__)
|
|
||||||
# define COMPILER_ID "OpenWatcom"
|
|
||||||
/* __WATCOMC__ = VVRP + 1100 */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
|
||||||
# if (__WATCOMC__ % 10) > 0
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__SUNPRO_C)
|
|
||||||
# define COMPILER_ID "SunPro"
|
|
||||||
# if __SUNPRO_C >= 0x5100
|
|
||||||
/* __SUNPRO_C = 0xVRRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
|
|
||||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
|
|
||||||
# else
|
|
||||||
/* __SUNPRO_CC = 0xVRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
|
|
||||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__HP_cc)
|
|
||||||
# define COMPILER_ID "HP"
|
|
||||||
/* __HP_cc = VVRRPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
|
|
||||||
|
|
||||||
#elif defined(__DECC)
|
|
||||||
# define COMPILER_ID "Compaq"
|
|
||||||
/* __DECC_VER = VVRRTPPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
|
|
||||||
|
|
||||||
#elif defined(__IBMC__) && defined(__COMPILER_VER__)
|
|
||||||
# define COMPILER_ID "zOS"
|
|
||||||
/* __IBMC__ = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
|
||||||
|
|
||||||
#elif defined(__ibmxl__) && defined(__clang__)
|
|
||||||
# define COMPILER_ID "XLClang"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
|
|
||||||
# define COMPILER_ID "XL"
|
|
||||||
/* __IBMC__ = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
|
||||||
|
|
||||||
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
|
|
||||||
# define COMPILER_ID "VisualAge"
|
|
||||||
/* __IBMC__ = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
|
||||||
|
|
||||||
#elif defined(__PGI)
|
|
||||||
# define COMPILER_ID "PGI"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
|
||||||
# if defined(__PGIC_PATCHLEVEL__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(_CRAYC)
|
|
||||||
# define COMPILER_ID "Cray"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
|
||||||
|
|
||||||
#elif defined(__TI_COMPILER_VERSION__)
|
|
||||||
# define COMPILER_ID "TI"
|
|
||||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
|
||||||
|
|
||||||
#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
|
|
||||||
# define COMPILER_ID "Fujitsu"
|
|
||||||
|
|
||||||
#elif defined(__ghs__)
|
|
||||||
# define COMPILER_ID "GHS"
|
|
||||||
/* __GHS_VERSION_NUMBER = VVVVRP */
|
|
||||||
# ifdef __GHS_VERSION_NUMBER
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__TINYC__)
|
|
||||||
# define COMPILER_ID "TinyCC"
|
|
||||||
|
|
||||||
#elif defined(__BCC__)
|
|
||||||
# define COMPILER_ID "Bruce"
|
|
||||||
|
|
||||||
#elif defined(__SCO_VERSION__)
|
|
||||||
# define COMPILER_ID "SCO"
|
|
||||||
|
|
||||||
#elif defined(__ARMCC_VERSION) && !defined(__clang__)
|
|
||||||
# define COMPILER_ID "ARMCC"
|
|
||||||
#if __ARMCC_VERSION >= 1000000
|
|
||||||
/* __ARMCC_VERSION = VRRPPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
|
||||||
#else
|
|
||||||
/* __ARMCC_VERSION = VRPPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
|
||||||
# define COMPILER_ID "AppleClang"
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define SIMULATE_ID "MSVC"
|
|
||||||
# endif
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# endif
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
|
||||||
|
|
||||||
#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
|
|
||||||
# define COMPILER_ID "ARMClang"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
|
|
||||||
# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
|
|
||||||
|
|
||||||
#elif defined(__clang__)
|
|
||||||
# define COMPILER_ID "Clang"
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define SIMULATE_ID "MSVC"
|
|
||||||
# endif
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
# define COMPILER_ID "GNU"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
|
||||||
# if defined(__GNUC_MINOR__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_PATCHLEVEL__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
# define COMPILER_ID "MSVC"
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# if defined(_MSC_FULL_VER)
|
|
||||||
# if _MSC_VER >= 1400
|
|
||||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
|
||||||
# else
|
|
||||||
/* _MSC_FULL_VER = VVRRPPPP */
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# if defined(_MSC_BUILD)
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
|
||||||
# define COMPILER_ID "ADSP"
|
|
||||||
#if defined(__VISUALDSPVERSION__)
|
|
||||||
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
|
||||||
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
|
||||||
# define COMPILER_ID "IAR"
|
|
||||||
# if defined(__VER__) && defined(__ICCARM__)
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
|
|
||||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
|
||||||
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__))
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
|
|
||||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
|
|
||||||
# define COMPILER_ID "SDCC"
|
|
||||||
# if defined(__SDCC_VERSION_MAJOR)
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
|
|
||||||
# else
|
|
||||||
/* SDCC = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(SDCC/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(SDCC % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
/* These compilers are either not known or too old to define an
|
|
||||||
identification macro. Try to identify the platform and guess that
|
|
||||||
it is the native compiler. */
|
|
||||||
#elif defined(__hpux) || defined(__hpua)
|
|
||||||
# define COMPILER_ID "HP"
|
|
||||||
|
|
||||||
#else /* unknown compiler */
|
|
||||||
# define COMPILER_ID ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct the string literal in pieces to prevent the source from
|
|
||||||
getting matched. Store it in a pointer rather than an array
|
|
||||||
because some compilers will just produce instructions to fill the
|
|
||||||
array rather than assigning a pointer to a static array. */
|
|
||||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
|
||||||
#ifdef SIMULATE_ID
|
|
||||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __QNXNTO__
|
|
||||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
|
||||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define STRINGIFY_HELPER(X) #X
|
|
||||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
|
||||||
|
|
||||||
/* Identify known platforms by name. */
|
|
||||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
|
||||||
# define PLATFORM_ID "Linux"
|
|
||||||
|
|
||||||
#elif defined(__CYGWIN__)
|
|
||||||
# define PLATFORM_ID "Cygwin"
|
|
||||||
|
|
||||||
#elif defined(__MINGW32__)
|
|
||||||
# define PLATFORM_ID "MinGW"
|
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
# define PLATFORM_ID "Darwin"
|
|
||||||
|
|
||||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
|
||||||
# define PLATFORM_ID "Windows"
|
|
||||||
|
|
||||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
|
||||||
# define PLATFORM_ID "FreeBSD"
|
|
||||||
|
|
||||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
|
||||||
# define PLATFORM_ID "NetBSD"
|
|
||||||
|
|
||||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
|
||||||
# define PLATFORM_ID "OpenBSD"
|
|
||||||
|
|
||||||
#elif defined(__sun) || defined(sun)
|
|
||||||
# define PLATFORM_ID "SunOS"
|
|
||||||
|
|
||||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
|
||||||
# define PLATFORM_ID "AIX"
|
|
||||||
|
|
||||||
#elif defined(__hpux) || defined(__hpux__)
|
|
||||||
# define PLATFORM_ID "HP-UX"
|
|
||||||
|
|
||||||
#elif defined(__HAIKU__)
|
|
||||||
# define PLATFORM_ID "Haiku"
|
|
||||||
|
|
||||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
|
||||||
# define PLATFORM_ID "BeOS"
|
|
||||||
|
|
||||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
|
||||||
# define PLATFORM_ID "QNX"
|
|
||||||
|
|
||||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
|
||||||
# define PLATFORM_ID "Tru64"
|
|
||||||
|
|
||||||
#elif defined(__riscos) || defined(__riscos__)
|
|
||||||
# define PLATFORM_ID "RISCos"
|
|
||||||
|
|
||||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
|
||||||
# define PLATFORM_ID "SINIX"
|
|
||||||
|
|
||||||
#elif defined(__UNIX_SV__)
|
|
||||||
# define PLATFORM_ID "UNIX_SV"
|
|
||||||
|
|
||||||
#elif defined(__bsdos__)
|
|
||||||
# define PLATFORM_ID "BSDOS"
|
|
||||||
|
|
||||||
#elif defined(_MPRAS) || defined(MPRAS)
|
|
||||||
# define PLATFORM_ID "MP-RAS"
|
|
||||||
|
|
||||||
#elif defined(__osf) || defined(__osf__)
|
|
||||||
# define PLATFORM_ID "OSF1"
|
|
||||||
|
|
||||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
|
||||||
# define PLATFORM_ID "SCO_SV"
|
|
||||||
|
|
||||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
|
||||||
# define PLATFORM_ID "ULTRIX"
|
|
||||||
|
|
||||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
|
||||||
# define PLATFORM_ID "Xenix"
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__)
|
|
||||||
# if defined(__LINUX__)
|
|
||||||
# define PLATFORM_ID "Linux"
|
|
||||||
|
|
||||||
# elif defined(__DOS__)
|
|
||||||
# define PLATFORM_ID "DOS"
|
|
||||||
|
|
||||||
# elif defined(__OS2__)
|
|
||||||
# define PLATFORM_ID "OS2"
|
|
||||||
|
|
||||||
# elif defined(__WINDOWS__)
|
|
||||||
# define PLATFORM_ID "Windows3x"
|
|
||||||
|
|
||||||
# else /* unknown platform */
|
|
||||||
# define PLATFORM_ID
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__INTEGRITY)
|
|
||||||
# if defined(INT_178B)
|
|
||||||
# define PLATFORM_ID "Integrity178"
|
|
||||||
|
|
||||||
# else /* regular Integrity */
|
|
||||||
# define PLATFORM_ID "Integrity"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#else /* unknown platform */
|
|
||||||
# define PLATFORM_ID
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For windows compilers MSVC and Intel we can determine
|
|
||||||
the architecture of the compiler being used. This is because
|
|
||||||
the compilers do not have flags that can change the architecture,
|
|
||||||
but rather depend on which compiler is being used
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
|
||||||
# if defined(_M_IA64)
|
|
||||||
# define ARCHITECTURE_ID "IA64"
|
|
||||||
|
|
||||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
|
||||||
# define ARCHITECTURE_ID "x64"
|
|
||||||
|
|
||||||
# elif defined(_M_IX86)
|
|
||||||
# define ARCHITECTURE_ID "X86"
|
|
||||||
|
|
||||||
# elif defined(_M_ARM64)
|
|
||||||
# define ARCHITECTURE_ID "ARM64"
|
|
||||||
|
|
||||||
# elif defined(_M_ARM)
|
|
||||||
# if _M_ARM == 4
|
|
||||||
# define ARCHITECTURE_ID "ARMV4I"
|
|
||||||
# elif _M_ARM == 5
|
|
||||||
# define ARCHITECTURE_ID "ARMV5I"
|
|
||||||
# else
|
|
||||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# elif defined(_M_MIPS)
|
|
||||||
# define ARCHITECTURE_ID "MIPS"
|
|
||||||
|
|
||||||
# elif defined(_M_SH)
|
|
||||||
# define ARCHITECTURE_ID "SHx"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__)
|
|
||||||
# if defined(_M_I86)
|
|
||||||
# define ARCHITECTURE_ID "I86"
|
|
||||||
|
|
||||||
# elif defined(_M_IX86)
|
|
||||||
# define ARCHITECTURE_ID "X86"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
|
||||||
# if defined(__ICCARM__)
|
|
||||||
# define ARCHITECTURE_ID "ARM"
|
|
||||||
|
|
||||||
# elif defined(__ICCRX__)
|
|
||||||
# define ARCHITECTURE_ID "RX"
|
|
||||||
|
|
||||||
# elif defined(__ICCRH850__)
|
|
||||||
# define ARCHITECTURE_ID "RH850"
|
|
||||||
|
|
||||||
# elif defined(__ICCRL78__)
|
|
||||||
# define ARCHITECTURE_ID "RL78"
|
|
||||||
|
|
||||||
# elif defined(__ICCRISCV__)
|
|
||||||
# define ARCHITECTURE_ID "RISCV"
|
|
||||||
|
|
||||||
# elif defined(__ICCAVR__)
|
|
||||||
# define ARCHITECTURE_ID "AVR"
|
|
||||||
|
|
||||||
# elif defined(__ICC430__)
|
|
||||||
# define ARCHITECTURE_ID "MSP430"
|
|
||||||
|
|
||||||
# elif defined(__ICCV850__)
|
|
||||||
# define ARCHITECTURE_ID "V850"
|
|
||||||
|
|
||||||
# elif defined(__ICC8051__)
|
|
||||||
# define ARCHITECTURE_ID "8051"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__ghs__)
|
|
||||||
# if defined(__PPC64__)
|
|
||||||
# define ARCHITECTURE_ID "PPC64"
|
|
||||||
|
|
||||||
# elif defined(__ppc__)
|
|
||||||
# define ARCHITECTURE_ID "PPC"
|
|
||||||
|
|
||||||
# elif defined(__ARM__)
|
|
||||||
# define ARCHITECTURE_ID "ARM"
|
|
||||||
|
|
||||||
# elif defined(__x86_64__)
|
|
||||||
# define ARCHITECTURE_ID "x64"
|
|
||||||
|
|
||||||
# elif defined(__i386__)
|
|
||||||
# define ARCHITECTURE_ID "X86"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define ARCHITECTURE_ID
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convert integer to decimal digit literals. */
|
|
||||||
#define DEC(n) \
|
|
||||||
('0' + (((n) / 10000000)%10)), \
|
|
||||||
('0' + (((n) / 1000000)%10)), \
|
|
||||||
('0' + (((n) / 100000)%10)), \
|
|
||||||
('0' + (((n) / 10000)%10)), \
|
|
||||||
('0' + (((n) / 1000)%10)), \
|
|
||||||
('0' + (((n) / 100)%10)), \
|
|
||||||
('0' + (((n) / 10)%10)), \
|
|
||||||
('0' + ((n) % 10))
|
|
||||||
|
|
||||||
/* Convert integer to hex digit literals. */
|
|
||||||
#define HEX(n) \
|
|
||||||
('0' + ((n)>>28 & 0xF)), \
|
|
||||||
('0' + ((n)>>24 & 0xF)), \
|
|
||||||
('0' + ((n)>>20 & 0xF)), \
|
|
||||||
('0' + ((n)>>16 & 0xF)), \
|
|
||||||
('0' + ((n)>>12 & 0xF)), \
|
|
||||||
('0' + ((n)>>8 & 0xF)), \
|
|
||||||
('0' + ((n)>>4 & 0xF)), \
|
|
||||||
('0' + ((n) & 0xF))
|
|
||||||
|
|
||||||
/* Construct a string literal encoding the version number components. */
|
|
||||||
#ifdef COMPILER_VERSION_MAJOR
|
|
||||||
char const info_version[] = {
|
|
||||||
'I', 'N', 'F', 'O', ':',
|
|
||||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
|
||||||
COMPILER_VERSION_MAJOR,
|
|
||||||
# ifdef COMPILER_VERSION_MINOR
|
|
||||||
'.', COMPILER_VERSION_MINOR,
|
|
||||||
# ifdef COMPILER_VERSION_PATCH
|
|
||||||
'.', COMPILER_VERSION_PATCH,
|
|
||||||
# ifdef COMPILER_VERSION_TWEAK
|
|
||||||
'.', COMPILER_VERSION_TWEAK,
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
']','\0'};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct a string literal encoding the internal version number. */
|
|
||||||
#ifdef COMPILER_VERSION_INTERNAL
|
|
||||||
char const info_version_internal[] = {
|
|
||||||
'I', 'N', 'F', 'O', ':',
|
|
||||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
|
|
||||||
'i','n','t','e','r','n','a','l','[',
|
|
||||||
COMPILER_VERSION_INTERNAL,']','\0'};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct a string literal encoding the version number components. */
|
|
||||||
#ifdef SIMULATE_VERSION_MAJOR
|
|
||||||
char const info_simulate_version[] = {
|
|
||||||
'I', 'N', 'F', 'O', ':',
|
|
||||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
|
||||||
SIMULATE_VERSION_MAJOR,
|
|
||||||
# ifdef SIMULATE_VERSION_MINOR
|
|
||||||
'.', SIMULATE_VERSION_MINOR,
|
|
||||||
# ifdef SIMULATE_VERSION_PATCH
|
|
||||||
'.', SIMULATE_VERSION_PATCH,
|
|
||||||
# ifdef SIMULATE_VERSION_TWEAK
|
|
||||||
'.', SIMULATE_VERSION_TWEAK,
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
']','\0'};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct the string literal in pieces to prevent the source from
|
|
||||||
getting matched. Store it in a pointer rather than an array
|
|
||||||
because some compilers will just produce instructions to fill the
|
|
||||||
array rather than assigning a pointer to a static array. */
|
|
||||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
|
||||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__STDC__)
|
|
||||||
# if (defined(_MSC_VER) && !defined(__clang__)) \
|
|
||||||
|| (defined(__ibmxl__) || defined(__IBMC__))
|
|
||||||
# define C_DIALECT "90"
|
|
||||||
# else
|
|
||||||
# define C_DIALECT
|
|
||||||
# endif
|
|
||||||
#elif __STDC_VERSION__ >= 201000L
|
|
||||||
# define C_DIALECT "11"
|
|
||||||
#elif __STDC_VERSION__ >= 199901L
|
|
||||||
# define C_DIALECT "99"
|
|
||||||
#else
|
|
||||||
# define C_DIALECT "90"
|
|
||||||
#endif
|
|
||||||
const char* info_language_dialect_default =
|
|
||||||
"INFO" ":" "dialect_default[" C_DIALECT "]";
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifdef ID_VOID_MAIN
|
|
||||||
void main() {}
|
|
||||||
#else
|
|
||||||
# if defined(__CLASSIC_C__)
|
|
||||||
int main(argc, argv) int argc; char *argv[];
|
|
||||||
# else
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
int require = 0;
|
|
||||||
require += info_compiler[argc];
|
|
||||||
require += info_platform[argc];
|
|
||||||
require += info_arch[argc];
|
|
||||||
#ifdef COMPILER_VERSION_MAJOR
|
|
||||||
require += info_version[argc];
|
|
||||||
#endif
|
|
||||||
#ifdef COMPILER_VERSION_INTERNAL
|
|
||||||
require += info_version_internal[argc];
|
|
||||||
#endif
|
|
||||||
#ifdef SIMULATE_ID
|
|
||||||
require += info_simulate[argc];
|
|
||||||
#endif
|
|
||||||
#ifdef SIMULATE_VERSION_MAJOR
|
|
||||||
require += info_simulate_version[argc];
|
|
||||||
#endif
|
|
||||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
|
||||||
require += info_cray[argc];
|
|
||||||
#endif
|
|
||||||
require += info_language_dialect_default[argc];
|
|
||||||
(void)argv;
|
|
||||||
return require;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Binary file not shown.
@@ -1,660 +0,0 @@
|
|||||||
/* This source file must have a .cpp extension so that all C++ compilers
|
|
||||||
recognize the extension without flags. Borland does not know .cxx for
|
|
||||||
example. */
|
|
||||||
#ifndef __cplusplus
|
|
||||||
# error "A C compiler has been selected for C++."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Version number components: V=Version, R=Revision, P=Patch
|
|
||||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
|
||||||
|
|
||||||
#if defined(__COMO__)
|
|
||||||
# define COMPILER_ID "Comeau"
|
|
||||||
/* __COMO_VERSION__ = VRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
|
|
||||||
|
|
||||||
#elif defined(__INTEL_COMPILER) || defined(__ICC)
|
|
||||||
# define COMPILER_ID "Intel"
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define SIMULATE_ID "MSVC"
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC__)
|
|
||||||
# define SIMULATE_ID "GNU"
|
|
||||||
# endif
|
|
||||||
/* __INTEL_COMPILER = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
|
||||||
# if defined(__INTEL_COMPILER_UPDATE)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
|
||||||
# else
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
|
||||||
# endif
|
|
||||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
|
||||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
|
||||||
# endif
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC__)
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
|
||||||
# elif defined(__GNUG__)
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_MINOR__)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_PATCHLEVEL__)
|
|
||||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__PATHCC__)
|
|
||||||
# define COMPILER_ID "PathScale"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
|
||||||
# if defined(__PATHCC_PATCHLEVEL__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
|
||||||
# define COMPILER_ID "Embarcadero"
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
|
||||||
|
|
||||||
#elif defined(__BORLANDC__)
|
|
||||||
# define COMPILER_ID "Borland"
|
|
||||||
/* __BORLANDC__ = 0xVRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
|
||||||
# define COMPILER_ID "Watcom"
|
|
||||||
/* __WATCOMC__ = VVRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
|
||||||
# if (__WATCOMC__ % 10) > 0
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__)
|
|
||||||
# define COMPILER_ID "OpenWatcom"
|
|
||||||
/* __WATCOMC__ = VVRP + 1100 */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
|
||||||
# if (__WATCOMC__ % 10) > 0
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__SUNPRO_CC)
|
|
||||||
# define COMPILER_ID "SunPro"
|
|
||||||
# if __SUNPRO_CC >= 0x5100
|
|
||||||
/* __SUNPRO_CC = 0xVRRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
|
|
||||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
|
||||||
# else
|
|
||||||
/* __SUNPRO_CC = 0xVRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
|
|
||||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__HP_aCC)
|
|
||||||
# define COMPILER_ID "HP"
|
|
||||||
/* __HP_aCC = VVRRPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
|
|
||||||
|
|
||||||
#elif defined(__DECCXX)
|
|
||||||
# define COMPILER_ID "Compaq"
|
|
||||||
/* __DECCXX_VER = VVRRTPPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
|
|
||||||
|
|
||||||
#elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
|
|
||||||
# define COMPILER_ID "zOS"
|
|
||||||
/* __IBMCPP__ = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
|
||||||
|
|
||||||
#elif defined(__ibmxl__) && defined(__clang__)
|
|
||||||
# define COMPILER_ID "XLClang"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800
|
|
||||||
# define COMPILER_ID "XL"
|
|
||||||
/* __IBMCPP__ = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
|
||||||
|
|
||||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
|
|
||||||
# define COMPILER_ID "VisualAge"
|
|
||||||
/* __IBMCPP__ = VRP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
|
||||||
|
|
||||||
#elif defined(__PGI)
|
|
||||||
# define COMPILER_ID "PGI"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
|
||||||
# if defined(__PGIC_PATCHLEVEL__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(_CRAYC)
|
|
||||||
# define COMPILER_ID "Cray"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
|
||||||
|
|
||||||
#elif defined(__TI_COMPILER_VERSION__)
|
|
||||||
# define COMPILER_ID "TI"
|
|
||||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
|
||||||
|
|
||||||
#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
|
|
||||||
# define COMPILER_ID "Fujitsu"
|
|
||||||
|
|
||||||
#elif defined(__ghs__)
|
|
||||||
# define COMPILER_ID "GHS"
|
|
||||||
/* __GHS_VERSION_NUMBER = VVVVRP */
|
|
||||||
# ifdef __GHS_VERSION_NUMBER
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__SCO_VERSION__)
|
|
||||||
# define COMPILER_ID "SCO"
|
|
||||||
|
|
||||||
#elif defined(__ARMCC_VERSION) && !defined(__clang__)
|
|
||||||
# define COMPILER_ID "ARMCC"
|
|
||||||
#if __ARMCC_VERSION >= 1000000
|
|
||||||
/* __ARMCC_VERSION = VRRPPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
|
||||||
#else
|
|
||||||
/* __ARMCC_VERSION = VRPPPP */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
|
||||||
# define COMPILER_ID "AppleClang"
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define SIMULATE_ID "MSVC"
|
|
||||||
# endif
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# endif
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
|
||||||
|
|
||||||
#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
|
|
||||||
# define COMPILER_ID "ARMClang"
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
|
|
||||||
# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
|
|
||||||
|
|
||||||
#elif defined(__clang__)
|
|
||||||
# define COMPILER_ID "Clang"
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define SIMULATE_ID "MSVC"
|
|
||||||
# endif
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
|
||||||
# define COMPILER_ID "GNU"
|
|
||||||
# if defined(__GNUC__)
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
|
||||||
# else
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(__GNUG__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_MINOR__)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
|
||||||
# endif
|
|
||||||
# if defined(__GNUC_PATCHLEVEL__)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
# define COMPILER_ID "MSVC"
|
|
||||||
/* _MSC_VER = VVRR */
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
|
||||||
# if defined(_MSC_FULL_VER)
|
|
||||||
# if _MSC_VER >= 1400
|
|
||||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
|
||||||
# else
|
|
||||||
/* _MSC_FULL_VER = VVRRPPPP */
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# if defined(_MSC_BUILD)
|
|
||||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
|
||||||
# define COMPILER_ID "ADSP"
|
|
||||||
#if defined(__VISUALDSPVERSION__)
|
|
||||||
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
|
||||||
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
|
||||||
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
|
||||||
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
|
||||||
# define COMPILER_ID "IAR"
|
|
||||||
# if defined(__VER__) && defined(__ICCARM__)
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
|
|
||||||
# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
|
|
||||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
|
||||||
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__))
|
|
||||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
|
|
||||||
# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
|
|
||||||
# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
|
|
||||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
/* These compilers are either not known or too old to define an
|
|
||||||
identification macro. Try to identify the platform and guess that
|
|
||||||
it is the native compiler. */
|
|
||||||
#elif defined(__hpux) || defined(__hpua)
|
|
||||||
# define COMPILER_ID "HP"
|
|
||||||
|
|
||||||
#else /* unknown compiler */
|
|
||||||
# define COMPILER_ID ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct the string literal in pieces to prevent the source from
|
|
||||||
getting matched. Store it in a pointer rather than an array
|
|
||||||
because some compilers will just produce instructions to fill the
|
|
||||||
array rather than assigning a pointer to a static array. */
|
|
||||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
|
||||||
#ifdef SIMULATE_ID
|
|
||||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __QNXNTO__
|
|
||||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
|
||||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define STRINGIFY_HELPER(X) #X
|
|
||||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
|
||||||
|
|
||||||
/* Identify known platforms by name. */
|
|
||||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
|
||||||
# define PLATFORM_ID "Linux"
|
|
||||||
|
|
||||||
#elif defined(__CYGWIN__)
|
|
||||||
# define PLATFORM_ID "Cygwin"
|
|
||||||
|
|
||||||
#elif defined(__MINGW32__)
|
|
||||||
# define PLATFORM_ID "MinGW"
|
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
# define PLATFORM_ID "Darwin"
|
|
||||||
|
|
||||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
|
||||||
# define PLATFORM_ID "Windows"
|
|
||||||
|
|
||||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
|
||||||
# define PLATFORM_ID "FreeBSD"
|
|
||||||
|
|
||||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
|
||||||
# define PLATFORM_ID "NetBSD"
|
|
||||||
|
|
||||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
|
||||||
# define PLATFORM_ID "OpenBSD"
|
|
||||||
|
|
||||||
#elif defined(__sun) || defined(sun)
|
|
||||||
# define PLATFORM_ID "SunOS"
|
|
||||||
|
|
||||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
|
||||||
# define PLATFORM_ID "AIX"
|
|
||||||
|
|
||||||
#elif defined(__hpux) || defined(__hpux__)
|
|
||||||
# define PLATFORM_ID "HP-UX"
|
|
||||||
|
|
||||||
#elif defined(__HAIKU__)
|
|
||||||
# define PLATFORM_ID "Haiku"
|
|
||||||
|
|
||||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
|
||||||
# define PLATFORM_ID "BeOS"
|
|
||||||
|
|
||||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
|
||||||
# define PLATFORM_ID "QNX"
|
|
||||||
|
|
||||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
|
||||||
# define PLATFORM_ID "Tru64"
|
|
||||||
|
|
||||||
#elif defined(__riscos) || defined(__riscos__)
|
|
||||||
# define PLATFORM_ID "RISCos"
|
|
||||||
|
|
||||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
|
||||||
# define PLATFORM_ID "SINIX"
|
|
||||||
|
|
||||||
#elif defined(__UNIX_SV__)
|
|
||||||
# define PLATFORM_ID "UNIX_SV"
|
|
||||||
|
|
||||||
#elif defined(__bsdos__)
|
|
||||||
# define PLATFORM_ID "BSDOS"
|
|
||||||
|
|
||||||
#elif defined(_MPRAS) || defined(MPRAS)
|
|
||||||
# define PLATFORM_ID "MP-RAS"
|
|
||||||
|
|
||||||
#elif defined(__osf) || defined(__osf__)
|
|
||||||
# define PLATFORM_ID "OSF1"
|
|
||||||
|
|
||||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
|
||||||
# define PLATFORM_ID "SCO_SV"
|
|
||||||
|
|
||||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
|
||||||
# define PLATFORM_ID "ULTRIX"
|
|
||||||
|
|
||||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
|
||||||
# define PLATFORM_ID "Xenix"
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__)
|
|
||||||
# if defined(__LINUX__)
|
|
||||||
# define PLATFORM_ID "Linux"
|
|
||||||
|
|
||||||
# elif defined(__DOS__)
|
|
||||||
# define PLATFORM_ID "DOS"
|
|
||||||
|
|
||||||
# elif defined(__OS2__)
|
|
||||||
# define PLATFORM_ID "OS2"
|
|
||||||
|
|
||||||
# elif defined(__WINDOWS__)
|
|
||||||
# define PLATFORM_ID "Windows3x"
|
|
||||||
|
|
||||||
# else /* unknown platform */
|
|
||||||
# define PLATFORM_ID
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__INTEGRITY)
|
|
||||||
# if defined(INT_178B)
|
|
||||||
# define PLATFORM_ID "Integrity178"
|
|
||||||
|
|
||||||
# else /* regular Integrity */
|
|
||||||
# define PLATFORM_ID "Integrity"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#else /* unknown platform */
|
|
||||||
# define PLATFORM_ID
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For windows compilers MSVC and Intel we can determine
|
|
||||||
the architecture of the compiler being used. This is because
|
|
||||||
the compilers do not have flags that can change the architecture,
|
|
||||||
but rather depend on which compiler is being used
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
|
||||||
# if defined(_M_IA64)
|
|
||||||
# define ARCHITECTURE_ID "IA64"
|
|
||||||
|
|
||||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
|
||||||
# define ARCHITECTURE_ID "x64"
|
|
||||||
|
|
||||||
# elif defined(_M_IX86)
|
|
||||||
# define ARCHITECTURE_ID "X86"
|
|
||||||
|
|
||||||
# elif defined(_M_ARM64)
|
|
||||||
# define ARCHITECTURE_ID "ARM64"
|
|
||||||
|
|
||||||
# elif defined(_M_ARM)
|
|
||||||
# if _M_ARM == 4
|
|
||||||
# define ARCHITECTURE_ID "ARMV4I"
|
|
||||||
# elif _M_ARM == 5
|
|
||||||
# define ARCHITECTURE_ID "ARMV5I"
|
|
||||||
# else
|
|
||||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# elif defined(_M_MIPS)
|
|
||||||
# define ARCHITECTURE_ID "MIPS"
|
|
||||||
|
|
||||||
# elif defined(_M_SH)
|
|
||||||
# define ARCHITECTURE_ID "SHx"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__WATCOMC__)
|
|
||||||
# if defined(_M_I86)
|
|
||||||
# define ARCHITECTURE_ID "I86"
|
|
||||||
|
|
||||||
# elif defined(_M_IX86)
|
|
||||||
# define ARCHITECTURE_ID "X86"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
|
||||||
# if defined(__ICCARM__)
|
|
||||||
# define ARCHITECTURE_ID "ARM"
|
|
||||||
|
|
||||||
# elif defined(__ICCRX__)
|
|
||||||
# define ARCHITECTURE_ID "RX"
|
|
||||||
|
|
||||||
# elif defined(__ICCRH850__)
|
|
||||||
# define ARCHITECTURE_ID "RH850"
|
|
||||||
|
|
||||||
# elif defined(__ICCRL78__)
|
|
||||||
# define ARCHITECTURE_ID "RL78"
|
|
||||||
|
|
||||||
# elif defined(__ICCRISCV__)
|
|
||||||
# define ARCHITECTURE_ID "RISCV"
|
|
||||||
|
|
||||||
# elif defined(__ICCAVR__)
|
|
||||||
# define ARCHITECTURE_ID "AVR"
|
|
||||||
|
|
||||||
# elif defined(__ICC430__)
|
|
||||||
# define ARCHITECTURE_ID "MSP430"
|
|
||||||
|
|
||||||
# elif defined(__ICCV850__)
|
|
||||||
# define ARCHITECTURE_ID "V850"
|
|
||||||
|
|
||||||
# elif defined(__ICC8051__)
|
|
||||||
# define ARCHITECTURE_ID "8051"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined(__ghs__)
|
|
||||||
# if defined(__PPC64__)
|
|
||||||
# define ARCHITECTURE_ID "PPC64"
|
|
||||||
|
|
||||||
# elif defined(__ppc__)
|
|
||||||
# define ARCHITECTURE_ID "PPC"
|
|
||||||
|
|
||||||
# elif defined(__ARM__)
|
|
||||||
# define ARCHITECTURE_ID "ARM"
|
|
||||||
|
|
||||||
# elif defined(__x86_64__)
|
|
||||||
# define ARCHITECTURE_ID "x64"
|
|
||||||
|
|
||||||
# elif defined(__i386__)
|
|
||||||
# define ARCHITECTURE_ID "X86"
|
|
||||||
|
|
||||||
# else /* unknown architecture */
|
|
||||||
# define ARCHITECTURE_ID ""
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# define ARCHITECTURE_ID
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convert integer to decimal digit literals. */
|
|
||||||
#define DEC(n) \
|
|
||||||
('0' + (((n) / 10000000)%10)), \
|
|
||||||
('0' + (((n) / 1000000)%10)), \
|
|
||||||
('0' + (((n) / 100000)%10)), \
|
|
||||||
('0' + (((n) / 10000)%10)), \
|
|
||||||
('0' + (((n) / 1000)%10)), \
|
|
||||||
('0' + (((n) / 100)%10)), \
|
|
||||||
('0' + (((n) / 10)%10)), \
|
|
||||||
('0' + ((n) % 10))
|
|
||||||
|
|
||||||
/* Convert integer to hex digit literals. */
|
|
||||||
#define HEX(n) \
|
|
||||||
('0' + ((n)>>28 & 0xF)), \
|
|
||||||
('0' + ((n)>>24 & 0xF)), \
|
|
||||||
('0' + ((n)>>20 & 0xF)), \
|
|
||||||
('0' + ((n)>>16 & 0xF)), \
|
|
||||||
('0' + ((n)>>12 & 0xF)), \
|
|
||||||
('0' + ((n)>>8 & 0xF)), \
|
|
||||||
('0' + ((n)>>4 & 0xF)), \
|
|
||||||
('0' + ((n) & 0xF))
|
|
||||||
|
|
||||||
/* Construct a string literal encoding the version number components. */
|
|
||||||
#ifdef COMPILER_VERSION_MAJOR
|
|
||||||
char const info_version[] = {
|
|
||||||
'I', 'N', 'F', 'O', ':',
|
|
||||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
|
||||||
COMPILER_VERSION_MAJOR,
|
|
||||||
# ifdef COMPILER_VERSION_MINOR
|
|
||||||
'.', COMPILER_VERSION_MINOR,
|
|
||||||
# ifdef COMPILER_VERSION_PATCH
|
|
||||||
'.', COMPILER_VERSION_PATCH,
|
|
||||||
# ifdef COMPILER_VERSION_TWEAK
|
|
||||||
'.', COMPILER_VERSION_TWEAK,
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
']','\0'};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct a string literal encoding the internal version number. */
|
|
||||||
#ifdef COMPILER_VERSION_INTERNAL
|
|
||||||
char const info_version_internal[] = {
|
|
||||||
'I', 'N', 'F', 'O', ':',
|
|
||||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
|
|
||||||
'i','n','t','e','r','n','a','l','[',
|
|
||||||
COMPILER_VERSION_INTERNAL,']','\0'};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct a string literal encoding the version number components. */
|
|
||||||
#ifdef SIMULATE_VERSION_MAJOR
|
|
||||||
char const info_simulate_version[] = {
|
|
||||||
'I', 'N', 'F', 'O', ':',
|
|
||||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
|
||||||
SIMULATE_VERSION_MAJOR,
|
|
||||||
# ifdef SIMULATE_VERSION_MINOR
|
|
||||||
'.', SIMULATE_VERSION_MINOR,
|
|
||||||
# ifdef SIMULATE_VERSION_PATCH
|
|
||||||
'.', SIMULATE_VERSION_PATCH,
|
|
||||||
# ifdef SIMULATE_VERSION_TWEAK
|
|
||||||
'.', SIMULATE_VERSION_TWEAK,
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
']','\0'};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Construct the string literal in pieces to prevent the source from
|
|
||||||
getting matched. Store it in a pointer rather than an array
|
|
||||||
because some compilers will just produce instructions to fill the
|
|
||||||
array rather than assigning a pointer to a static array. */
|
|
||||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
|
||||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
|
|
||||||
# if defined(__INTEL_CXX11_MODE__)
|
|
||||||
# if defined(__cpp_aggregate_nsdmi)
|
|
||||||
# define CXX_STD 201402L
|
|
||||||
# else
|
|
||||||
# define CXX_STD 201103L
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define CXX_STD 199711L
|
|
||||||
# endif
|
|
||||||
#elif defined(_MSC_VER) && defined(_MSVC_LANG)
|
|
||||||
# define CXX_STD _MSVC_LANG
|
|
||||||
#else
|
|
||||||
# define CXX_STD __cplusplus
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
|
|
||||||
#if CXX_STD > 201703L
|
|
||||||
"20"
|
|
||||||
#elif CXX_STD >= 201703L
|
|
||||||
"17"
|
|
||||||
#elif CXX_STD >= 201402L
|
|
||||||
"14"
|
|
||||||
#elif CXX_STD >= 201103L
|
|
||||||
"11"
|
|
||||||
#else
|
|
||||||
"98"
|
|
||||||
#endif
|
|
||||||
"]";
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
int require = 0;
|
|
||||||
require += info_compiler[argc];
|
|
||||||
require += info_platform[argc];
|
|
||||||
#ifdef COMPILER_VERSION_MAJOR
|
|
||||||
require += info_version[argc];
|
|
||||||
#endif
|
|
||||||
#ifdef COMPILER_VERSION_INTERNAL
|
|
||||||
require += info_version_internal[argc];
|
|
||||||
#endif
|
|
||||||
#ifdef SIMULATE_ID
|
|
||||||
require += info_simulate[argc];
|
|
||||||
#endif
|
|
||||||
#ifdef SIMULATE_VERSION_MAJOR
|
|
||||||
require += info_simulate_version[argc];
|
|
||||||
#endif
|
|
||||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
|
||||||
require += info_cray[argc];
|
|
||||||
#endif
|
|
||||||
require += info_language_dialect_default[argc];
|
|
||||||
(void)argv;
|
|
||||||
return require;
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
# Relative path conversion top directories.
|
|
||||||
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/bradarant/barant/CoreUtils")
|
|
||||||
set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/bradarant/barant/CoreUtils")
|
|
||||||
|
|
||||||
# Force unix paths in dependencies.
|
|
||||||
set(CMAKE_FORCE_UNIX_PATHS 1)
|
|
||||||
|
|
||||||
|
|
||||||
# The C and CXX include file regular expressions for this directory.
|
|
||||||
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
|
|
||||||
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
|
|
||||||
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
|
|
||||||
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
|
|
||||||
@@ -1,463 +0,0 @@
|
|||||||
The system is: Linux - 5.4.0-65-generic - x86_64
|
|
||||||
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
|
|
||||||
Compiler: /usr/bin/cc
|
|
||||||
Build flags:
|
|
||||||
Id flags:
|
|
||||||
|
|
||||||
The output was:
|
|
||||||
0
|
|
||||||
|
|
||||||
|
|
||||||
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"
|
|
||||||
|
|
||||||
The C compiler identification is GNU, found in "/home/bradarant/barant/CoreUtils/CMakeFiles/3.16.3/CompilerIdC/a.out"
|
|
||||||
|
|
||||||
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
|
|
||||||
Compiler: /usr/bin/c++
|
|
||||||
Build flags:
|
|
||||||
Id flags:
|
|
||||||
|
|
||||||
The output was:
|
|
||||||
0
|
|
||||||
|
|
||||||
|
|
||||||
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
|
|
||||||
|
|
||||||
The CXX compiler identification is GNU, found in "/home/bradarant/barant/CoreUtils/CMakeFiles/3.16.3/CompilerIdCXX/a.out"
|
|
||||||
|
|
||||||
Determining if the C compiler works passed with the following output:
|
|
||||||
Change Dir: /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp
|
|
||||||
|
|
||||||
Run Build Command(s):/usr/bin/make cmTC_c3f4d/fast && /usr/bin/make -f CMakeFiles/cmTC_c3f4d.dir/build.make CMakeFiles/cmTC_c3f4d.dir/build
|
|
||||||
make[1]: Entering directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
Building C object CMakeFiles/cmTC_c3f4d.dir/testCCompiler.c.o
|
|
||||||
/usr/bin/cc -o CMakeFiles/cmTC_c3f4d.dir/testCCompiler.c.o -c /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp/testCCompiler.c
|
|
||||||
Linking C executable cmTC_c3f4d
|
|
||||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c3f4d.dir/link.txt --verbose=1
|
|
||||||
/usr/bin/cc -rdynamic CMakeFiles/cmTC_c3f4d.dir/testCCompiler.c.o -o cmTC_c3f4d
|
|
||||||
make[1]: Leaving directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Detecting C compiler ABI info compiled with the following output:
|
|
||||||
Change Dir: /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp
|
|
||||||
|
|
||||||
Run Build Command(s):/usr/bin/make cmTC_a9eed/fast && /usr/bin/make -f CMakeFiles/cmTC_a9eed.dir/build.make CMakeFiles/cmTC_a9eed.dir/build
|
|
||||||
make[1]: Entering directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
Building C object CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o
|
|
||||||
/usr/bin/cc -v -o CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c
|
|
||||||
Using built-in specs.
|
|
||||||
COLLECT_GCC=/usr/bin/cc
|
|
||||||
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
|
|
||||||
OFFLOAD_TARGET_DEFAULT=1
|
|
||||||
Target: x86_64-linux-gnu
|
|
||||||
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
|
|
||||||
Thread model: posix
|
|
||||||
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/9/cc1 -quiet -v -imultiarch x86_64-linux-gnu /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccGssNWR.s
|
|
||||||
GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
|
|
||||||
compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
|
|
||||||
|
|
||||||
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
|
|
||||||
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
|
|
||||||
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"
|
|
||||||
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
|
|
||||||
#include "..." search starts here:
|
|
||||||
#include <...> search starts here:
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/9/include
|
|
||||||
/usr/local/include
|
|
||||||
/usr/include/x86_64-linux-gnu
|
|
||||||
/usr/include
|
|
||||||
End of search list.
|
|
||||||
GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
|
|
||||||
compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
|
|
||||||
|
|
||||||
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
|
|
||||||
Compiler executable checksum: bbf13931d8de1abe14040c9909cb6969
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
|
|
||||||
as -v --64 -o CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o /tmp/ccGssNWR.s
|
|
||||||
GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34
|
|
||||||
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
|
|
||||||
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
|
|
||||||
Linking C executable cmTC_a9eed
|
|
||||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9eed.dir/link.txt --verbose=1
|
|
||||||
/usr/bin/cc -v -rdynamic CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -o cmTC_a9eed
|
|
||||||
Using built-in specs.
|
|
||||||
COLLECT_GCC=/usr/bin/cc
|
|
||||||
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
|
|
||||||
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
|
|
||||||
OFFLOAD_TARGET_DEFAULT=1
|
|
||||||
Target: x86_64-linux-gnu
|
|
||||||
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
|
|
||||||
Thread model: posix
|
|
||||||
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
|
|
||||||
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
|
|
||||||
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_a9eed' '-mtune=generic' '-march=x86-64'
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccTcwCUh.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_a9eed /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_a9eed' '-mtune=generic' '-march=x86-64'
|
|
||||||
make[1]: Leaving directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Parsed C implicit include dir info from above output: rv=done
|
|
||||||
found start of include info
|
|
||||||
found start of implicit include info
|
|
||||||
add: [/usr/lib/gcc/x86_64-linux-gnu/9/include]
|
|
||||||
add: [/usr/local/include]
|
|
||||||
add: [/usr/include/x86_64-linux-gnu]
|
|
||||||
add: [/usr/include]
|
|
||||||
end of search list found
|
|
||||||
collapse include dir [/usr/lib/gcc/x86_64-linux-gnu/9/include] ==> [/usr/lib/gcc/x86_64-linux-gnu/9/include]
|
|
||||||
collapse include dir [/usr/local/include] ==> [/usr/local/include]
|
|
||||||
collapse include dir [/usr/include/x86_64-linux-gnu] ==> [/usr/include/x86_64-linux-gnu]
|
|
||||||
collapse include dir [/usr/include] ==> [/usr/include]
|
|
||||||
implicit include dirs: [/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include]
|
|
||||||
|
|
||||||
|
|
||||||
Parsed C implicit link information from above output:
|
|
||||||
link line regex: [^( *|.*[/\])(ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\]+-)?ld|collect2)[^/\]*( |$)]
|
|
||||||
ignore line: [Change Dir: /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp]
|
|
||||||
ignore line: []
|
|
||||||
ignore line: [Run Build Command(s):/usr/bin/make cmTC_a9eed/fast && /usr/bin/make -f CMakeFiles/cmTC_a9eed.dir/build.make CMakeFiles/cmTC_a9eed.dir/build]
|
|
||||||
ignore line: [make[1]: Entering directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp']
|
|
||||||
ignore line: [Building C object CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o]
|
|
||||||
ignore line: [/usr/bin/cc -v -o CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c]
|
|
||||||
ignore line: [Using built-in specs.]
|
|
||||||
ignore line: [COLLECT_GCC=/usr/bin/cc]
|
|
||||||
ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
|
|
||||||
ignore line: [OFFLOAD_TARGET_DEFAULT=1]
|
|
||||||
ignore line: [Target: x86_64-linux-gnu]
|
|
||||||
ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
|
|
||||||
ignore line: [Thread model: posix]
|
|
||||||
ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64']
|
|
||||||
ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/cc1 -quiet -v -imultiarch x86_64-linux-gnu /usr/share/cmake-3.16/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/ccGssNWR.s]
|
|
||||||
ignore line: [GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
|
|
||||||
ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
|
|
||||||
ignore line: []
|
|
||||||
ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
|
|
||||||
ignore line: [ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"]
|
|
||||||
ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"]
|
|
||||||
ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"]
|
|
||||||
ignore line: [#include "..." search starts here:]
|
|
||||||
ignore line: [#include <...> search starts here:]
|
|
||||||
ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/include]
|
|
||||||
ignore line: [ /usr/local/include]
|
|
||||||
ignore line: [ /usr/include/x86_64-linux-gnu]
|
|
||||||
ignore line: [ /usr/include]
|
|
||||||
ignore line: [End of search list.]
|
|
||||||
ignore line: [GNU C17 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
|
|
||||||
ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
|
|
||||||
ignore line: []
|
|
||||||
ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
|
|
||||||
ignore line: [Compiler executable checksum: bbf13931d8de1abe14040c9909cb6969]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64']
|
|
||||||
ignore line: [ as -v --64 -o CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o /tmp/ccGssNWR.s]
|
|
||||||
ignore line: [GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34]
|
|
||||||
ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
|
|
||||||
ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64']
|
|
||||||
ignore line: [Linking C executable cmTC_a9eed]
|
|
||||||
ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9eed.dir/link.txt --verbose=1]
|
|
||||||
ignore line: [/usr/bin/cc -v -rdynamic CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -o cmTC_a9eed ]
|
|
||||||
ignore line: [Using built-in specs.]
|
|
||||||
ignore line: [COLLECT_GCC=/usr/bin/cc]
|
|
||||||
ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper]
|
|
||||||
ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
|
|
||||||
ignore line: [OFFLOAD_TARGET_DEFAULT=1]
|
|
||||||
ignore line: [Target: x86_64-linux-gnu]
|
|
||||||
ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
|
|
||||||
ignore line: [Thread model: posix]
|
|
||||||
ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
|
|
||||||
ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
|
|
||||||
ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_a9eed' '-mtune=generic' '-march=x86-64']
|
|
||||||
link line: [ /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccTcwCUh.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_a9eed /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o]
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/collect2] ==> ignore
|
|
||||||
arg [-plugin] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so] ==> ignore
|
|
||||||
arg [-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper] ==> ignore
|
|
||||||
arg [-plugin-opt=-fresolution=/tmp/ccTcwCUh.res] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lc] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
|
||||||
arg [--build-id] ==> ignore
|
|
||||||
arg [--eh-frame-hdr] ==> ignore
|
|
||||||
arg [-m] ==> ignore
|
|
||||||
arg [elf_x86_64] ==> ignore
|
|
||||||
arg [--hash-style=gnu] ==> ignore
|
|
||||||
arg [--as-needed] ==> ignore
|
|
||||||
arg [-export-dynamic] ==> ignore
|
|
||||||
arg [-dynamic-linker] ==> ignore
|
|
||||||
arg [/lib64/ld-linux-x86-64.so.2] ==> ignore
|
|
||||||
arg [-pie] ==> ignore
|
|
||||||
arg [-znow] ==> ignore
|
|
||||||
arg [-zrelro] ==> ignore
|
|
||||||
arg [-o] ==> ignore
|
|
||||||
arg [cmTC_a9eed] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o] ==> ignore
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9]
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu]
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib]
|
|
||||||
arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu]
|
|
||||||
arg [-L/lib/../lib] ==> dir [/lib/../lib]
|
|
||||||
arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu]
|
|
||||||
arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib]
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..]
|
|
||||||
arg [CMakeFiles/cmTC_a9eed.dir/CMakeCCompilerABI.c.o] ==> ignore
|
|
||||||
arg [-lgcc] ==> lib [gcc]
|
|
||||||
arg [--push-state] ==> ignore
|
|
||||||
arg [--as-needed] ==> ignore
|
|
||||||
arg [-lgcc_s] ==> lib [gcc_s]
|
|
||||||
arg [--pop-state] ==> ignore
|
|
||||||
arg [-lc] ==> lib [c]
|
|
||||||
arg [-lgcc] ==> lib [gcc]
|
|
||||||
arg [--push-state] ==> ignore
|
|
||||||
arg [--as-needed] ==> ignore
|
|
||||||
arg [-lgcc_s] ==> lib [gcc_s]
|
|
||||||
arg [--pop-state] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o] ==> ignore
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9] ==> [/usr/lib/gcc/x86_64-linux-gnu/9]
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> [/usr/lib]
|
|
||||||
collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu]
|
|
||||||
collapse library dir [/lib/../lib] ==> [/lib]
|
|
||||||
collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
|
|
||||||
collapse library dir [/usr/lib/../lib] ==> [/usr/lib]
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> [/usr/lib]
|
|
||||||
implicit libs: [gcc;gcc_s;c;gcc;gcc_s]
|
|
||||||
implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib]
|
|
||||||
implicit fwks: []
|
|
||||||
|
|
||||||
|
|
||||||
Determining if the CXX compiler works passed with the following output:
|
|
||||||
Change Dir: /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp
|
|
||||||
|
|
||||||
Run Build Command(s):/usr/bin/make cmTC_ae6e5/fast && /usr/bin/make -f CMakeFiles/cmTC_ae6e5.dir/build.make CMakeFiles/cmTC_ae6e5.dir/build
|
|
||||||
make[1]: Entering directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
Building CXX object CMakeFiles/cmTC_ae6e5.dir/testCXXCompiler.cxx.o
|
|
||||||
/usr/bin/c++ -o CMakeFiles/cmTC_ae6e5.dir/testCXXCompiler.cxx.o -c /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
|
|
||||||
Linking CXX executable cmTC_ae6e5
|
|
||||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ae6e5.dir/link.txt --verbose=1
|
|
||||||
/usr/bin/c++ -rdynamic CMakeFiles/cmTC_ae6e5.dir/testCXXCompiler.cxx.o -o cmTC_ae6e5
|
|
||||||
make[1]: Leaving directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Detecting CXX compiler ABI info compiled with the following output:
|
|
||||||
Change Dir: /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp
|
|
||||||
|
|
||||||
Run Build Command(s):/usr/bin/make cmTC_ae9d6/fast && /usr/bin/make -f CMakeFiles/cmTC_ae9d6.dir/build.make CMakeFiles/cmTC_ae9d6.dir/build
|
|
||||||
make[1]: Entering directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
Building CXX object CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o
|
|
||||||
/usr/bin/c++ -v -o CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp
|
|
||||||
Using built-in specs.
|
|
||||||
COLLECT_GCC=/usr/bin/c++
|
|
||||||
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
|
|
||||||
OFFLOAD_TARGET_DEFAULT=1
|
|
||||||
Target: x86_64-linux-gnu
|
|
||||||
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
|
|
||||||
Thread model: posix
|
|
||||||
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/cc4s8sNO.s
|
|
||||||
GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
|
|
||||||
compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
|
|
||||||
|
|
||||||
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
|
|
||||||
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"
|
|
||||||
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
|
|
||||||
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"
|
|
||||||
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
|
|
||||||
#include "..." search starts here:
|
|
||||||
#include <...> search starts here:
|
|
||||||
/usr/include/c++/9
|
|
||||||
/usr/include/x86_64-linux-gnu/c++/9
|
|
||||||
/usr/include/c++/9/backward
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/9/include
|
|
||||||
/usr/local/include
|
|
||||||
/usr/include/x86_64-linux-gnu
|
|
||||||
/usr/include
|
|
||||||
End of search list.
|
|
||||||
GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
|
|
||||||
compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
|
|
||||||
|
|
||||||
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
|
|
||||||
Compiler executable checksum: 466f818abe2f30ba03783f22bd12d815
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
||||||
as -v --64 -o CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o /tmp/cc4s8sNO.s
|
|
||||||
GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34
|
|
||||||
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
|
|
||||||
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
||||||
Linking CXX executable cmTC_ae9d6
|
|
||||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ae9d6.dir/link.txt --verbose=1
|
|
||||||
/usr/bin/c++ -v -rdynamic CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_ae9d6
|
|
||||||
Using built-in specs.
|
|
||||||
COLLECT_GCC=/usr/bin/c++
|
|
||||||
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
|
|
||||||
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
|
|
||||||
OFFLOAD_TARGET_DEFAULT=1
|
|
||||||
Target: x86_64-linux-gnu
|
|
||||||
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
|
|
||||||
Thread model: posix
|
|
||||||
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
|
|
||||||
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
|
|
||||||
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_ae9d6' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccK8qtji.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_ae9d6 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
|
|
||||||
COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_ae9d6' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
|
||||||
make[1]: Leaving directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Parsed CXX implicit include dir info from above output: rv=done
|
|
||||||
found start of include info
|
|
||||||
found start of implicit include info
|
|
||||||
add: [/usr/include/c++/9]
|
|
||||||
add: [/usr/include/x86_64-linux-gnu/c++/9]
|
|
||||||
add: [/usr/include/c++/9/backward]
|
|
||||||
add: [/usr/lib/gcc/x86_64-linux-gnu/9/include]
|
|
||||||
add: [/usr/local/include]
|
|
||||||
add: [/usr/include/x86_64-linux-gnu]
|
|
||||||
add: [/usr/include]
|
|
||||||
end of search list found
|
|
||||||
collapse include dir [/usr/include/c++/9] ==> [/usr/include/c++/9]
|
|
||||||
collapse include dir [/usr/include/x86_64-linux-gnu/c++/9] ==> [/usr/include/x86_64-linux-gnu/c++/9]
|
|
||||||
collapse include dir [/usr/include/c++/9/backward] ==> [/usr/include/c++/9/backward]
|
|
||||||
collapse include dir [/usr/lib/gcc/x86_64-linux-gnu/9/include] ==> [/usr/lib/gcc/x86_64-linux-gnu/9/include]
|
|
||||||
collapse include dir [/usr/local/include] ==> [/usr/local/include]
|
|
||||||
collapse include dir [/usr/include/x86_64-linux-gnu] ==> [/usr/include/x86_64-linux-gnu]
|
|
||||||
collapse include dir [/usr/include] ==> [/usr/include]
|
|
||||||
implicit include dirs: [/usr/include/c++/9;/usr/include/x86_64-linux-gnu/c++/9;/usr/include/c++/9/backward;/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include]
|
|
||||||
|
|
||||||
|
|
||||||
Parsed CXX implicit link information from above output:
|
|
||||||
link line regex: [^( *|.*[/\])(ld|CMAKE_LINK_STARTFILE-NOTFOUND|([^/\]+-)?ld|collect2)[^/\]*( |$)]
|
|
||||||
ignore line: [Change Dir: /home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp]
|
|
||||||
ignore line: []
|
|
||||||
ignore line: [Run Build Command(s):/usr/bin/make cmTC_ae9d6/fast && /usr/bin/make -f CMakeFiles/cmTC_ae9d6.dir/build.make CMakeFiles/cmTC_ae9d6.dir/build]
|
|
||||||
ignore line: [make[1]: Entering directory '/home/bradarant/barant/CoreUtils/CMakeFiles/CMakeTmp']
|
|
||||||
ignore line: [Building CXX object CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o]
|
|
||||||
ignore line: [/usr/bin/c++ -v -o CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp]
|
|
||||||
ignore line: [Using built-in specs.]
|
|
||||||
ignore line: [COLLECT_GCC=/usr/bin/c++]
|
|
||||||
ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
|
|
||||||
ignore line: [OFFLOAD_TARGET_DEFAULT=1]
|
|
||||||
ignore line: [Target: x86_64-linux-gnu]
|
|
||||||
ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
|
|
||||||
ignore line: [Thread model: posix]
|
|
||||||
ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
|
|
||||||
ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/share/cmake-3.16/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o /tmp/cc4s8sNO.s]
|
|
||||||
ignore line: [GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
|
|
||||||
ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
|
|
||||||
ignore line: []
|
|
||||||
ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
|
|
||||||
ignore line: [ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/9"]
|
|
||||||
ignore line: [ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"]
|
|
||||||
ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/include-fixed"]
|
|
||||||
ignore line: [ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"]
|
|
||||||
ignore line: [#include "..." search starts here:]
|
|
||||||
ignore line: [#include <...> search starts here:]
|
|
||||||
ignore line: [ /usr/include/c++/9]
|
|
||||||
ignore line: [ /usr/include/x86_64-linux-gnu/c++/9]
|
|
||||||
ignore line: [ /usr/include/c++/9/backward]
|
|
||||||
ignore line: [ /usr/lib/gcc/x86_64-linux-gnu/9/include]
|
|
||||||
ignore line: [ /usr/local/include]
|
|
||||||
ignore line: [ /usr/include/x86_64-linux-gnu]
|
|
||||||
ignore line: [ /usr/include]
|
|
||||||
ignore line: [End of search list.]
|
|
||||||
ignore line: [GNU C++14 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)]
|
|
||||||
ignore line: [ compiled by GNU C version 9.3.0 GMP version 6.2.0 MPFR version 4.0.2 MPC version 1.1.0 isl version isl-0.22.1-GMP]
|
|
||||||
ignore line: []
|
|
||||||
ignore line: [GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072]
|
|
||||||
ignore line: [Compiler executable checksum: 466f818abe2f30ba03783f22bd12d815]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
|
|
||||||
ignore line: [ as -v --64 -o CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o /tmp/cc4s8sNO.s]
|
|
||||||
ignore line: [GNU assembler version 2.34 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.34]
|
|
||||||
ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
|
|
||||||
ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
|
|
||||||
ignore line: [Linking CXX executable cmTC_ae9d6]
|
|
||||||
ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ae9d6.dir/link.txt --verbose=1]
|
|
||||||
ignore line: [/usr/bin/c++ -v -rdynamic CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_ae9d6 ]
|
|
||||||
ignore line: [Using built-in specs.]
|
|
||||||
ignore line: [COLLECT_GCC=/usr/bin/c++]
|
|
||||||
ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper]
|
|
||||||
ignore line: [OFFLOAD_TARGET_NAMES=nvptx-none:hsa]
|
|
||||||
ignore line: [OFFLOAD_TARGET_DEFAULT=1]
|
|
||||||
ignore line: [Target: x86_64-linux-gnu]
|
|
||||||
ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c ada c++ go brig d fortran objc obj-c++ gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32 m64 mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu]
|
|
||||||
ignore line: [Thread model: posix]
|
|
||||||
ignore line: [gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) ]
|
|
||||||
ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/]
|
|
||||||
ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/]
|
|
||||||
ignore line: [COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_ae9d6' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
|
|
||||||
link line: [ /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccK8qtji.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_ae9d6 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o]
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/collect2] ==> ignore
|
|
||||||
arg [-plugin] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so] ==> ignore
|
|
||||||
arg [-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper] ==> ignore
|
|
||||||
arg [-plugin-opt=-fresolution=/tmp/ccK8qtji.res] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lc] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
|
||||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
|
||||||
arg [--build-id] ==> ignore
|
|
||||||
arg [--eh-frame-hdr] ==> ignore
|
|
||||||
arg [-m] ==> ignore
|
|
||||||
arg [elf_x86_64] ==> ignore
|
|
||||||
arg [--hash-style=gnu] ==> ignore
|
|
||||||
arg [--as-needed] ==> ignore
|
|
||||||
arg [-export-dynamic] ==> ignore
|
|
||||||
arg [-dynamic-linker] ==> ignore
|
|
||||||
arg [/lib64/ld-linux-x86-64.so.2] ==> ignore
|
|
||||||
arg [-pie] ==> ignore
|
|
||||||
arg [-znow] ==> ignore
|
|
||||||
arg [-zrelro] ==> ignore
|
|
||||||
arg [-o] ==> ignore
|
|
||||||
arg [cmTC_ae9d6] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o] ==> ignore
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9]
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu]
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib]
|
|
||||||
arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu]
|
|
||||||
arg [-L/lib/../lib] ==> dir [/lib/../lib]
|
|
||||||
arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu]
|
|
||||||
arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib]
|
|
||||||
arg [-L/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..]
|
|
||||||
arg [CMakeFiles/cmTC_ae9d6.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore
|
|
||||||
arg [-lstdc++] ==> lib [stdc++]
|
|
||||||
arg [-lm] ==> lib [m]
|
|
||||||
arg [-lgcc_s] ==> lib [gcc_s]
|
|
||||||
arg [-lgcc] ==> lib [gcc]
|
|
||||||
arg [-lc] ==> lib [c]
|
|
||||||
arg [-lgcc_s] ==> lib [gcc_s]
|
|
||||||
arg [-lgcc] ==> lib [gcc]
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o] ==> ignore
|
|
||||||
arg [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o] ==> ignore
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9] ==> [/usr/lib/gcc/x86_64-linux-gnu/9]
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib] ==> [/usr/lib]
|
|
||||||
collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu]
|
|
||||||
collapse library dir [/lib/../lib] ==> [/lib]
|
|
||||||
collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu]
|
|
||||||
collapse library dir [/usr/lib/../lib] ==> [/usr/lib]
|
|
||||||
collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/9/../../..] ==> [/usr/lib]
|
|
||||||
implicit libs: [stdc++;m;gcc_s;gcc;c;gcc_s;gcc]
|
|
||||||
implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib]
|
|
||||||
implicit fwks: []
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
#IncludeRegexLine: ^[ ]*[#%][ ]*(include|import)[ ]*[<"]([^">]+)([">])
|
|
||||||
|
|
||||||
#IncludeRegexScan: ^.*$
|
|
||||||
|
|
||||||
#IncludeRegexComplain: ^$
|
|
||||||
|
|
||||||
#IncludeRegexTransform:
|
|
||||||
|
|
||||||
/home/bradarant/barant/CoreUtils/File.h
|
|
||||||
includes
|
|
||||||
/home/bradarant/barant/CoreUtils/includes
|
|
||||||
|
|
||||||
/home/bradarant/barant/CoreUtils/Log.h
|
|
||||||
includes
|
|
||||||
/home/bradarant/barant/CoreUtils/includes
|
|
||||||
File.h
|
|
||||||
/home/bradarant/barant/CoreUtils/File.h
|
|
||||||
LogListener.h
|
|
||||||
/home/bradarant/barant/CoreUtils/LogListener.h
|
|
||||||
|
|
||||||
/home/bradarant/barant/CoreUtils/LogListener.h
|
|
||||||
|
|
||||||
/home/bradarant/barant/CoreUtils/ZString.cpp
|
|
||||||
ZString.h
|
|
||||||
/home/bradarant/barant/CoreUtils/ZString.h
|
|
||||||
Log.h
|
|
||||||
/home/bradarant/barant/CoreUtils/Log.h
|
|
||||||
|
|
||||||
/home/bradarant/barant/CoreUtils/ZString.h
|
|
||||||
includes
|
|
||||||
/home/bradarant/barant/CoreUtils/includes
|
|
||||||
|
|
||||||
/home/bradarant/barant/CoreUtils/includes
|
|
||||||
iostream
|
|
||||||
-
|
|
||||||
vector
|
|
||||||
-
|
|
||||||
thread
|
|
||||||
-
|
|
||||||
map
|
|
||||||
-
|
|
||||||
string
|
|
||||||
-
|
|
||||||
cstring
|
|
||||||
-
|
|
||||||
sys/types.h
|
|
||||||
-
|
|
||||||
sys/epoll.h
|
|
||||||
-
|
|
||||||
unistd.h
|
|
||||||
-
|
|
||||||
fcntl.h
|
|
||||||
-
|
|
||||||
pthread.h
|
|
||||||
-
|
|
||||||
iostream
|
|
||||||
-
|
|
||||||
sstream
|
|
||||||
-
|
|
||||||
chrono
|
|
||||||
-
|
|
||||||
ctime
|
|
||||||
-
|
|
||||||
queue
|
|
||||||
-
|
|
||||||
mutex
|
|
||||||
-
|
|
||||||
string.h
|
|
||||||
-
|
|
||||||
netdb.h
|
|
||||||
-
|
|
||||||
sys/types.h
|
|
||||||
-
|
|
||||||
sys/socket.h
|
|
||||||
-
|
|
||||||
netinet/in.h
|
|
||||||
-
|
|
||||||
arpa/inet.h
|
|
||||||
-
|
|
||||||
sys/timerfd.h
|
|
||||||
-
|
|
||||||
math.h
|
|
||||||
-
|
|
||||||
sys/stat.h
|
|
||||||
-
|
|
||||||
sys/syscall.h
|
|
||||||
-
|
|
||||||
sys/ioctl.h
|
|
||||||
-
|
|
||||||
openssl/ssl.h
|
|
||||||
-
|
|
||||||
openssl/rand.h
|
|
||||||
-
|
|
||||||
openssl/err.h
|
|
||||||
-
|
|
||||||
dirent.h
|
|
||||||
-
|
|
||||||
iomanip
|
|
||||||
-
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# The set of languages for which implicit dependencies are needed:
|
|
||||||
set(CMAKE_DEPENDS_LANGUAGES
|
|
||||||
"CXX"
|
|
||||||
)
|
|
||||||
# The set of files for implicit dependencies of each language:
|
|
||||||
set(CMAKE_DEPENDS_CHECK_CXX
|
|
||||||
"/home/bradarant/barant/CoreUtils/ZString.cpp" "/home/bradarant/barant/CoreUtils/CMakeFiles/CoreUtils.dir/ZString.cpp.o"
|
|
||||||
)
|
|
||||||
set(CMAKE_CXX_COMPILER_ID "GNU")
|
|
||||||
|
|
||||||
# The include file search paths:
|
|
||||||
set(CMAKE_CXX_TARGET_INCLUDE_PATH
|
|
||||||
)
|
|
||||||
|
|
||||||
# Targets to which this target links.
|
|
||||||
set(CMAKE_TARGET_LINKED_INFO_FILES
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fortran module output directory.
|
|
||||||
set(CMAKE_Fortran_TARGET_MODULE_DIR "")
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
# Delete rule output on recipe failure.
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Special targets provided by cmake.
|
|
||||||
|
|
||||||
# Disable implicit rules so canonical targets will work.
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
|
|
||||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
|
||||||
SUFFIXES =
|
|
||||||
|
|
||||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
|
||||||
|
|
||||||
|
|
||||||
# Suppress display of executed commands.
|
|
||||||
$(VERBOSE).SILENT:
|
|
||||||
|
|
||||||
|
|
||||||
# A target that is always out of date.
|
|
||||||
cmake_force:
|
|
||||||
|
|
||||||
.PHONY : cmake_force
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Set environment variables for the build.
|
|
||||||
|
|
||||||
# The shell in which to execute make rules.
|
|
||||||
SHELL = /bin/sh
|
|
||||||
|
|
||||||
# The CMake executable.
|
|
||||||
CMAKE_COMMAND = /usr/bin/cmake
|
|
||||||
|
|
||||||
# The command to remove a file.
|
|
||||||
RM = /usr/bin/cmake -E remove -f
|
|
||||||
|
|
||||||
# Escaping for special characters.
|
|
||||||
EQUALS = =
|
|
||||||
|
|
||||||
# The top-level source directory on which CMake was run.
|
|
||||||
CMAKE_SOURCE_DIR = /home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
# The top-level build directory on which CMake was run.
|
|
||||||
CMAKE_BINARY_DIR = /home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
# Include any dependencies generated for this target.
|
|
||||||
include CMakeFiles/CoreUtils.dir/depend.make
|
|
||||||
|
|
||||||
# Include the progress variables for this target.
|
|
||||||
include CMakeFiles/CoreUtils.dir/progress.make
|
|
||||||
|
|
||||||
# Include the compile flags for this target's objects.
|
|
||||||
include CMakeFiles/CoreUtils.dir/flags.make
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: CMakeFiles/CoreUtils.dir/flags.make
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: ZString.cpp
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/bradarant/barant/CoreUtils/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/CoreUtils.dir/ZString.cpp.o"
|
|
||||||
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/CoreUtils.dir/ZString.cpp.o -c /home/bradarant/barant/CoreUtils/ZString.cpp
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.i: cmake_force
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/CoreUtils.dir/ZString.cpp.i"
|
|
||||||
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/bradarant/barant/CoreUtils/ZString.cpp > CMakeFiles/CoreUtils.dir/ZString.cpp.i
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.s: cmake_force
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/CoreUtils.dir/ZString.cpp.s"
|
|
||||||
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/bradarant/barant/CoreUtils/ZString.cpp -o CMakeFiles/CoreUtils.dir/ZString.cpp.s
|
|
||||||
|
|
||||||
# Object files for target CoreUtils
|
|
||||||
CoreUtils_OBJECTS = \
|
|
||||||
"CMakeFiles/CoreUtils.dir/ZString.cpp.o"
|
|
||||||
|
|
||||||
# External object files for target CoreUtils
|
|
||||||
CoreUtils_EXTERNAL_OBJECTS =
|
|
||||||
|
|
||||||
libCoreUtils.a: CMakeFiles/CoreUtils.dir/ZString.cpp.o
|
|
||||||
libCoreUtils.a: CMakeFiles/CoreUtils.dir/build.make
|
|
||||||
libCoreUtils.a: CMakeFiles/CoreUtils.dir/link.txt
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/bradarant/barant/CoreUtils/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX static library libCoreUtils.a"
|
|
||||||
$(CMAKE_COMMAND) -P CMakeFiles/CoreUtils.dir/cmake_clean_target.cmake
|
|
||||||
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/CoreUtils.dir/link.txt --verbose=$(VERBOSE)
|
|
||||||
|
|
||||||
# Rule to build all files generated by this target.
|
|
||||||
CMakeFiles/CoreUtils.dir/build: libCoreUtils.a
|
|
||||||
|
|
||||||
.PHONY : CMakeFiles/CoreUtils.dir/build
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/clean:
|
|
||||||
$(CMAKE_COMMAND) -P CMakeFiles/CoreUtils.dir/cmake_clean.cmake
|
|
||||||
.PHONY : CMakeFiles/CoreUtils.dir/clean
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/depend:
|
|
||||||
cd /home/bradarant/barant/CoreUtils && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/bradarant/barant/CoreUtils /home/bradarant/barant/CoreUtils /home/bradarant/barant/CoreUtils /home/bradarant/barant/CoreUtils /home/bradarant/barant/CoreUtils/CMakeFiles/CoreUtils.dir/DependInfo.cmake --color=$(COLOR)
|
|
||||||
.PHONY : CMakeFiles/CoreUtils.dir/depend
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
file(REMOVE_RECURSE
|
|
||||||
"CMakeFiles/CoreUtils.dir/ZString.cpp.o"
|
|
||||||
"libCoreUtils.a"
|
|
||||||
"libCoreUtils.pdb"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Per-language clean rules from dependency scanning.
|
|
||||||
foreach(lang CXX)
|
|
||||||
include(CMakeFiles/CoreUtils.dir/cmake_clean_${lang}.cmake OPTIONAL)
|
|
||||||
endforeach()
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
file(REMOVE_RECURSE
|
|
||||||
"libCoreUtils.a"
|
|
||||||
)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o
|
|
||||||
/home/bradarant/barant/CoreUtils/File.h
|
|
||||||
/home/bradarant/barant/CoreUtils/Log.h
|
|
||||||
/home/bradarant/barant/CoreUtils/LogListener.h
|
|
||||||
/home/bradarant/barant/CoreUtils/ZString.cpp
|
|
||||||
/home/bradarant/barant/CoreUtils/ZString.h
|
|
||||||
/home/bradarant/barant/CoreUtils/includes
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: File.h
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: Log.h
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: LogListener.h
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: ZString.cpp
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: ZString.h
|
|
||||||
CMakeFiles/CoreUtils.dir/ZString.cpp.o: includes
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
# compile CXX with /usr/bin/c++
|
|
||||||
CXX_FLAGS =
|
|
||||||
|
|
||||||
CXX_DEFINES =
|
|
||||||
|
|
||||||
CXX_INCLUDES =
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/usr/bin/ar qc libCoreUtils.a CMakeFiles/CoreUtils.dir/ZString.cpp.o
|
|
||||||
/usr/bin/ranlib libCoreUtils.a
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
CMAKE_PROGRESS_1 = 1
|
|
||||||
CMAKE_PROGRESS_2 = 2
|
|
||||||
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
# The generator used is:
|
|
||||||
set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles")
|
|
||||||
|
|
||||||
# The top level Makefile was generated from the following files:
|
|
||||||
set(CMAKE_MAKEFILE_DEPENDS
|
|
||||||
"CMakeCache.txt"
|
|
||||||
"CMakeFiles/3.16.3/CMakeCCompiler.cmake"
|
|
||||||
"CMakeFiles/3.16.3/CMakeCXXCompiler.cmake"
|
|
||||||
"CMakeFiles/3.16.3/CMakeSystem.cmake"
|
|
||||||
"CMakeLists.txt"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeCInformation.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeCXXInformation.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeCommonLanguageInclude.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeGenericSystem.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeInitializeConfigs.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeLanguageInformation.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeSystemSpecificInformation.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/CMakeSystemSpecificInitialize.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Compiler/GNU-C.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Compiler/GNU-CXX.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Compiler/GNU.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Internal/CMakeCheckCompilerFlag.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Platform/Linux-GNU-C.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Platform/Linux-GNU-CXX.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Platform/Linux-GNU.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Platform/Linux.cmake"
|
|
||||||
"/usr/share/cmake-3.16/Modules/Platform/UnixPaths.cmake"
|
|
||||||
)
|
|
||||||
|
|
||||||
# The corresponding makefile is:
|
|
||||||
set(CMAKE_MAKEFILE_OUTPUTS
|
|
||||||
"Makefile"
|
|
||||||
"CMakeFiles/cmake.check_cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Byproducts of CMake generate step:
|
|
||||||
set(CMAKE_MAKEFILE_PRODUCTS
|
|
||||||
"CMakeFiles/CMakeDirectoryInformation.cmake"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Dependency information for all targets:
|
|
||||||
set(CMAKE_DEPEND_INFO_FILES
|
|
||||||
"CMakeFiles/CoreUtils.dir/DependInfo.cmake"
|
|
||||||
)
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
# Default target executed when no arguments are given to make.
|
|
||||||
default_target: all
|
|
||||||
|
|
||||||
.PHONY : default_target
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Special targets provided by cmake.
|
|
||||||
|
|
||||||
# Disable implicit rules so canonical targets will work.
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
|
|
||||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
|
||||||
SUFFIXES =
|
|
||||||
|
|
||||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
|
||||||
|
|
||||||
|
|
||||||
# Suppress display of executed commands.
|
|
||||||
$(VERBOSE).SILENT:
|
|
||||||
|
|
||||||
|
|
||||||
# A target that is always out of date.
|
|
||||||
cmake_force:
|
|
||||||
|
|
||||||
.PHONY : cmake_force
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Set environment variables for the build.
|
|
||||||
|
|
||||||
# The shell in which to execute make rules.
|
|
||||||
SHELL = /bin/sh
|
|
||||||
|
|
||||||
# The CMake executable.
|
|
||||||
CMAKE_COMMAND = /usr/bin/cmake
|
|
||||||
|
|
||||||
# The command to remove a file.
|
|
||||||
RM = /usr/bin/cmake -E remove -f
|
|
||||||
|
|
||||||
# Escaping for special characters.
|
|
||||||
EQUALS = =
|
|
||||||
|
|
||||||
# The top-level source directory on which CMake was run.
|
|
||||||
CMAKE_SOURCE_DIR = /home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
# The top-level build directory on which CMake was run.
|
|
||||||
CMAKE_BINARY_DIR = /home/bradarant/barant/CoreUtils
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Directory level rules for the build root directory
|
|
||||||
|
|
||||||
# The main recursive "all" target.
|
|
||||||
all: CMakeFiles/CoreUtils.dir/all
|
|
||||||
|
|
||||||
.PHONY : all
|
|
||||||
|
|
||||||
# The main recursive "preinstall" target.
|
|
||||||
preinstall:
|
|
||||||
|
|
||||||
.PHONY : preinstall
|
|
||||||
|
|
||||||
# The main recursive "clean" target.
|
|
||||||
clean: CMakeFiles/CoreUtils.dir/clean
|
|
||||||
|
|
||||||
.PHONY : clean
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Target rules for target CMakeFiles/CoreUtils.dir
|
|
||||||
|
|
||||||
# All Build rule for target.
|
|
||||||
CMakeFiles/CoreUtils.dir/all:
|
|
||||||
$(MAKE) -f CMakeFiles/CoreUtils.dir/build.make CMakeFiles/CoreUtils.dir/depend
|
|
||||||
$(MAKE) -f CMakeFiles/CoreUtils.dir/build.make CMakeFiles/CoreUtils.dir/build
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/bradarant/barant/CoreUtils/CMakeFiles --progress-num=1,2 "Built target CoreUtils"
|
|
||||||
.PHONY : CMakeFiles/CoreUtils.dir/all
|
|
||||||
|
|
||||||
# Build rule for subdir invocation for target.
|
|
||||||
CMakeFiles/CoreUtils.dir/rule: cmake_check_build_system
|
|
||||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/bradarant/barant/CoreUtils/CMakeFiles 2
|
|
||||||
$(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/CoreUtils.dir/all
|
|
||||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/bradarant/barant/CoreUtils/CMakeFiles 0
|
|
||||||
.PHONY : CMakeFiles/CoreUtils.dir/rule
|
|
||||||
|
|
||||||
# Convenience name for target.
|
|
||||||
CoreUtils: CMakeFiles/CoreUtils.dir/rule
|
|
||||||
|
|
||||||
.PHONY : CoreUtils
|
|
||||||
|
|
||||||
# clean rule for target.
|
|
||||||
CMakeFiles/CoreUtils.dir/clean:
|
|
||||||
$(MAKE) -f CMakeFiles/CoreUtils.dir/build.make CMakeFiles/CoreUtils.dir/clean
|
|
||||||
.PHONY : CMakeFiles/CoreUtils.dir/clean
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Special targets to cleanup operation of make.
|
|
||||||
|
|
||||||
# Special rule to run CMake to check the build system integrity.
|
|
||||||
# No rule that depends on this can have commands that come from listfiles
|
|
||||||
# because they might be regenerated.
|
|
||||||
cmake_check_build_system:
|
|
||||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
|
||||||
.PHONY : cmake_check_build_system
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
empty
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
2
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/home/bradarant/barant/CoreUtils/CMakeFiles/rebuild_cache.dir
|
|
||||||
/home/bradarant/barant/CoreUtils/CMakeFiles/edit_cache.dir
|
|
||||||
/home/bradarant/barant/CoreUtils/CMakeFiles/CoreUtils.dir
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
2
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
project(CoreUtils)
|
|
||||||
add_library(CoreUtils STATIC target_sources_local())
|
|
||||||
+15
-1
@@ -4,6 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <source_location>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
@@ -15,7 +16,20 @@ namespace coreutils {
|
|||||||
class Exception {
|
class Exception {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Exception(std::string text, std::string file = __FILE__, int line = __LINE__, int errorNumber = errno);
|
///
|
||||||
|
/// file/line default to the caller's actual location. std::source_location::current()
|
||||||
|
/// is specifically defined by the standard to evaluate at the call site when used as a
|
||||||
|
/// default argument - unlike __FILE__/__LINE__ (preprocessor macros, which were used
|
||||||
|
/// here previously and always expanded to this header's own declaration line instead
|
||||||
|
/// of the real throw site, since macro expansion happens before the compiler even sees
|
||||||
|
/// "default argument" as a concept). Explicit callers (e.g. throw Exception(msg,
|
||||||
|
/// __FILE__, __LINE__)) are unaffected - the signature is unchanged.
|
||||||
|
///
|
||||||
|
|
||||||
|
Exception(std::string text,
|
||||||
|
std::string file = std::source_location::current().file_name(),
|
||||||
|
int line = std::source_location::current().line(),
|
||||||
|
int errorNumber = errno);
|
||||||
|
|
||||||
std::string className;
|
std::string className;
|
||||||
std::string file;
|
std::string file;
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
@@ -16,20 +19,37 @@ namespace coreutils {
|
|||||||
void File::open(coreutils::ZString fileName, int mode, int authority) {
|
void File::open(coreutils::ZString fileName, int mode, int authority) {
|
||||||
|
|
||||||
this->fileName = fileName;
|
this->fileName = fileName;
|
||||||
|
this->mode = mode;
|
||||||
struct stat status;
|
this->authority = authority;
|
||||||
stat(fileName.c_str(), &status);
|
|
||||||
|
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
|
|
||||||
setBufferSize(status.st_size);
|
|
||||||
|
|
||||||
fd = ::open(fileName.c_str(), mode, authority);
|
fd = ::open(fileName.c_str(), mode, authority);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
std::stringstream temp;
|
std::stringstream temp;
|
||||||
temp << "Error opening file " << fileName << ".";
|
temp << "Error opening file " << fileName << ".";
|
||||||
throw Exception(temp.str(), __FILE__, __LINE__);
|
throw Exception(temp.str(), __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stat() only after a successful open(), and only used to size the
|
||||||
|
// read buffer - previously this ran BEFORE the open()/fd check with
|
||||||
|
// its return value ignored, so a missing file left the stat struct fully
|
||||||
|
// uninitialized and fed that garbage st_size straight into
|
||||||
|
// setBufferSize()'s realloc(), before the open-failure path ever
|
||||||
|
// got a chance to throw its clean Exception. Found while adding a
|
||||||
|
// static-asset route (GET /assets/{filename}) that legitimately
|
||||||
|
// hits this path on every request for a nonexistent file - a
|
||||||
|
// garbage-sized realloc there could abort/crash the whole
|
||||||
|
// long-running APIServer process (shared with every other live
|
||||||
|
// route) instead of cleanly 500ing just that one request.
|
||||||
|
struct stat status;
|
||||||
|
if (fstat(fd, &status) != 0) {
|
||||||
|
std::stringstream temp;
|
||||||
|
temp << "Error statting file " << fileName << ".";
|
||||||
|
throw Exception(temp.str(), __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
|
setBufferSize(status.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
File::~File() {
|
File::~File() {
|
||||||
@@ -74,6 +94,63 @@ namespace coreutils {
|
|||||||
int len = ::write(fd, data.getData(), data.getLength());
|
int len = ::write(fd, data.getData(), data.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t File::currentSize() {
|
||||||
|
struct stat status;
|
||||||
|
if (fstat(fd, &status) != 0) {
|
||||||
|
std::stringstream temp;
|
||||||
|
temp << "Error statting file " << fileName << ".";
|
||||||
|
throw Exception(temp.str(), __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
return (size_t)status.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void File::rotate(int maxBackups) {
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
// Resolve through fileName first, not its raw configured spelling -
|
||||||
|
// rename() never follows symlinks for either its source or
|
||||||
|
// destination path. BARANTMail's own "barantmail.log" is a symlink
|
||||||
|
// into /var/log/ on purpose (keeps a large, fast-growing log off
|
||||||
|
// the same filesystem/tree as the source checkout) - renaming that
|
||||||
|
// SYMLINK's own path to ".1" below, then recreating a plain file
|
||||||
|
// at the original (now-empty) path via open()'s O_CREAT, would
|
||||||
|
// silently sever the symlink and start a brand new file right back
|
||||||
|
// in the source tree, undoing that setup the very first time
|
||||||
|
// rotation ever fires on a symlinked path. Confirmed live: exactly
|
||||||
|
// this happened to BARANTMail's real log on this code's first
|
||||||
|
// real trigger (a 23GB pre-existing file, already far past the
|
||||||
|
// configured threshold, rotated on the very next size check after
|
||||||
|
// a fresh process started logging to it). realpath() requires the
|
||||||
|
// target to already exist, which it does here (this object has it
|
||||||
|
// open) - falls back to the configured path unresolved only if
|
||||||
|
// that somehow isn't true (e.g. the target was deleted out from
|
||||||
|
// under it), matching plain (non-symlink) File usage exactly as
|
||||||
|
// before.
|
||||||
|
char resolved[PATH_MAX];
|
||||||
|
std::string configuredPath(fileName.c_str());
|
||||||
|
std::string base = realpath(configuredPath.c_str(), resolved) ?
|
||||||
|
std::string(resolved) : configuredPath;
|
||||||
|
|
||||||
|
// Oldest-first: delete what's about to fall off the end, then
|
||||||
|
// shift each remaining backup up by one, working from the
|
||||||
|
// highest number down so a lower-numbered file is never
|
||||||
|
// clobbered before it's been moved out of the way.
|
||||||
|
std::string oldest = base + "." + std::to_string(maxBackups);
|
||||||
|
::remove(oldest.c_str());
|
||||||
|
for (int i = maxBackups - 1; i >= 1; i--) {
|
||||||
|
std::string from = base + "." + std::to_string(i);
|
||||||
|
std::string to = base + "." + std::to_string(i + 1);
|
||||||
|
::rename(from.c_str(), to.c_str());
|
||||||
|
}
|
||||||
|
::rename(base.c_str(), (base + ".1").c_str());
|
||||||
|
|
||||||
|
// Reopens via the ORIGINAL (possibly symlinked) fileName, not the
|
||||||
|
// resolved `base` - the symlink itself was never touched above
|
||||||
|
// (only its target was renamed away), so this correctly follows it
|
||||||
|
// again and creates a fresh file at the real target location.
|
||||||
|
open(fileName, mode, authority);
|
||||||
|
}
|
||||||
|
|
||||||
std::string File::asString() {
|
std::string File::asString() {
|
||||||
return std::string(buffer, size);
|
return std::string(buffer, size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,34 @@ namespace coreutils {
|
|||||||
size_t size;
|
size_t size;
|
||||||
bool eof();
|
bool eof();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Real, on-disk size of this file right now, queried directly
|
||||||
|
/// from the OS via fstat() - not the "size" member above, which
|
||||||
|
/// is only ever set at open()/read() time and goes stale the
|
||||||
|
/// moment anything else appends to this fd (exactly the case for
|
||||||
|
/// a long-lived, append-mode file such as Log's static logFile).
|
||||||
|
///
|
||||||
|
|
||||||
|
size_t currentSize();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Close this file, shift any existing ".1" .. ".maxBackups-1"
|
||||||
|
/// backups up by one (deleting whatever already sits at
|
||||||
|
/// ".maxBackups"), rename the current file to ".1", then reopen
|
||||||
|
/// a fresh file at the original path/mode/authority. Meant for a
|
||||||
|
/// long-lived, append-mode file that needs a size cap - not
|
||||||
|
/// meaningful for a file opened for reading.
|
||||||
|
///
|
||||||
|
|
||||||
|
void rotate(int maxBackups);
|
||||||
|
|
||||||
coreutils::ZString fileName;
|
coreutils::ZString fileName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void open(coreutils::ZString fileName, int mode, int authority);
|
void open(coreutils::ZString fileName, int mode, int authority);
|
||||||
int fd;
|
int fd;
|
||||||
|
int mode;
|
||||||
|
int authority;
|
||||||
coreutils::ZString zstring;
|
coreutils::ZString zstring;
|
||||||
bool mEof = false;
|
bool mEof = false;
|
||||||
|
|
||||||
|
|||||||
+179
@@ -0,0 +1,179 @@
|
|||||||
|
#include "HTTPRequest.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
HTTPRequest::HTTPRequest(StreamReader &reader) : Parser(reader) {}
|
||||||
|
|
||||||
|
HTTPRequest::~HTTPRequest() {
|
||||||
|
delete lineParser;
|
||||||
|
delete headerParser;
|
||||||
|
delete formParser;
|
||||||
|
}
|
||||||
|
|
||||||
|
Parser::Status HTTPRequest::parse() {
|
||||||
|
MString &buffer = reader.getBuffer();
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
|
||||||
|
case REQUEST_LINE: {
|
||||||
|
if (!lineParser)
|
||||||
|
lineParser = new LineParser(reader);
|
||||||
|
if (!checkParse(*lineParser))
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
{
|
||||||
|
// line is a view into reader's own buffer (see
|
||||||
|
// LineParser::parse()), not into lineParser itself - safe to
|
||||||
|
// delete lineParser immediately, before the parts.size()
|
||||||
|
// check below can throw. Previously this delete sat AFTER
|
||||||
|
// that check, so a malformed request line (any count other
|
||||||
|
// than exactly 3 space-separated parts - confirmed live via
|
||||||
|
// real scanner/bot traffic hitting this daily) leaked
|
||||||
|
// lineParser and left the member non-NULL. Since state is
|
||||||
|
// never advanced past REQUEST_LINE on this throw, ANY later
|
||||||
|
// reentry into this same case (state itself surviving the
|
||||||
|
// exception, e.g. if this HTTPRequest is ever driven again
|
||||||
|
// before its owning session tears down) would see a
|
||||||
|
// non-NULL lineParser and skip allocating a fresh one,
|
||||||
|
// reusing an already-completed, now-stale parser instance
|
||||||
|
// instead - a real invariant violation that a heap-
|
||||||
|
// corruption crash (munmap_chunk(): invalid pointer) was
|
||||||
|
// traced back to.
|
||||||
|
ZString line = lineParser->getLine();
|
||||||
|
delete lineParser;
|
||||||
|
lineParser = NULL;
|
||||||
|
ZString sp(" ");
|
||||||
|
std::vector<ZString> &parts = line.split(sp);
|
||||||
|
if (parts.size() != 3)
|
||||||
|
throw coreutils::Exception("HTTPRequest: malformed request line "
|
||||||
|
"(expected \"METHOD /path HTTP/1.1\").");
|
||||||
|
method = MString(parts[0]);
|
||||||
|
path = MString(parts[1]);
|
||||||
|
version = MString(parts[2]);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// Split the query string off before anything else sees `path` -
|
||||||
|
// a route table (see the APIServer plan) should never have to
|
||||||
|
// deal with a trailing "?a=1&b=2" itself.
|
||||||
|
int qpos = path.find(ZString("?"));
|
||||||
|
if (qpos != -1) {
|
||||||
|
queryString = MString(path.substring(qpos + 1));
|
||||||
|
path = MString(path.substring(0, qpos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state = HEADERS;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case HEADERS: {
|
||||||
|
if (!headerParser)
|
||||||
|
headerParser = new IMFHeader(reader);
|
||||||
|
// The actual throw for a malformed header (e.g. a header line
|
||||||
|
// with no ':') happens deep inside checkParse() -> IMFHeader::
|
||||||
|
// parse(), well before headerParser->getHeaders() below ever
|
||||||
|
// runs - same leaked-pointer/stale-reentry hazard as
|
||||||
|
// REQUEST_LINE above, confirmed as the other half of the same
|
||||||
|
// real crash. Cleaning up here before rethrowing keeps
|
||||||
|
// headerParser NULL on every exit path, matching the
|
||||||
|
// REQUEST_LINE fix.
|
||||||
|
bool complete;
|
||||||
|
try {
|
||||||
|
complete = checkParse(*headerParser);
|
||||||
|
} catch (...) {
|
||||||
|
delete headerParser;
|
||||||
|
headerParser = NULL;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
if (!complete)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
headers = headerParser->getHeaders();
|
||||||
|
delete headerParser;
|
||||||
|
headerParser = NULL;
|
||||||
|
state = BODY;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case BODY: {
|
||||||
|
MString contentLengthHeader = getHeader("Content-Length");
|
||||||
|
if (contentLengthHeader.getLength() == 0) {
|
||||||
|
if (getHeader("Transfer-Encoding").getLength() > 0)
|
||||||
|
throw coreutils::Exception("HTTPRequest: chunked Transfer-Encoding "
|
||||||
|
"is not supported (Content-Length only).");
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
int contentLength = contentLengthHeader.asInteger();
|
||||||
|
// asInteger() accumulates digits into a plain 32-bit int with no
|
||||||
|
// overflow check - a Content-Length long enough to overflow it
|
||||||
|
// (confirmed live via real scanner/bot traffic: a request for
|
||||||
|
// "/sra_{...}/' claiming "Content-Length: 18446744073709551615",
|
||||||
|
// a classic SSTP vulnerability-probe pattern) silently wraps to a
|
||||||
|
// garbage value, observed as -1. That negative value then passed
|
||||||
|
// the "(int)buffer.getLength() < contentLength" check below for
|
||||||
|
// every real buffer length (nothing is ever less than -1), so
|
||||||
|
// execution fell through to "ZString(buffer.getCursor(),
|
||||||
|
// contentLength)" with a negative length - reinterpreted as a
|
||||||
|
// huge size_t, this read far past the real buffer and corrupted
|
||||||
|
// the heap, crashing (sometimes immediately, sometimes much
|
||||||
|
// later, in a wholly unrelated MString's destructor) on every
|
||||||
|
// production apiserver this scanner traffic reached. Rejecting
|
||||||
|
// a negative Content-Length here, before it is ever used, closes
|
||||||
|
// this off at the only place that actually needs to care.
|
||||||
|
if (contentLength < 0)
|
||||||
|
throw coreutils::Exception("HTTPRequest: invalid Content-Length.");
|
||||||
|
MString contentType = getHeader("Content-Type");
|
||||||
|
if (contentType.startsWith("application/x-www-form-urlencoded") ||
|
||||||
|
contentType.startsWith("multipart/form-data")) {
|
||||||
|
if (!formParser) {
|
||||||
|
// Mirrors __jet.cpp's identical CGI-path fix: find() leaves
|
||||||
|
// contentType's own cursor at the match, and CGIFormData's
|
||||||
|
// constructor copy-constructs its own contentType member
|
||||||
|
// from whatever we pass, inheriting that same moved cursor
|
||||||
|
// - its startsWith() dispatch checks are cursor-relative
|
||||||
|
// and would silently miss (falling through to UNKNOWN)
|
||||||
|
// without the reset().
|
||||||
|
int boundaryPos = contentType.find(ZString("boundary="));
|
||||||
|
if (boundaryPos != -1)
|
||||||
|
boundary = MString(contentType.substring(boundaryPos + 9));
|
||||||
|
contentType.reset();
|
||||||
|
formParser = new CGIFormData(reader, contentType, contentLength, boundary);
|
||||||
|
}
|
||||||
|
if (!checkParse(*formParser))
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
if ((int)buffer.getLength() < contentLength)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
body = MString(ZString(buffer.getCursor(), contentLength));
|
||||||
|
buffer.setCursor(buffer.getCursor() + contentLength);
|
||||||
|
state = DONE;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case DONE:
|
||||||
|
return Status::COMPLETE;
|
||||||
|
|
||||||
|
}
|
||||||
|
throw coreutils::Exception("HTTPRequest: unreachable state.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MString HTTPRequest::getMethod() { return method; }
|
||||||
|
MString HTTPRequest::getPath() { return path; }
|
||||||
|
MString HTTPRequest::getQueryString() { return queryString; }
|
||||||
|
MString HTTPRequest::getVersion() { return version; }
|
||||||
|
MString HTTPRequest::getBody() { return body; }
|
||||||
|
std::map<MString, MString> &HTTPRequest::getHeaders() { return headers; }
|
||||||
|
CGIFormData *HTTPRequest::getFormData() { return formParser; }
|
||||||
|
|
||||||
|
MString HTTPRequest::getHeader(const char *name) {
|
||||||
|
for (auto &pair : headers) {
|
||||||
|
MString key = pair.first;
|
||||||
|
if (strcasecmp(key.c_str(), name) == 0)
|
||||||
|
return pair.second;
|
||||||
|
}
|
||||||
|
return MString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
#ifndef __HTTPRequest_h__
|
||||||
|
#define __HTTPRequest_h__
|
||||||
|
|
||||||
|
#include "Parser.h"
|
||||||
|
#include "LineParser.h"
|
||||||
|
#include "IMFHeader.h"
|
||||||
|
#include "CGIFormData.h"
|
||||||
|
#include "MString.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// HTTPRequest parses a full HTTP/1.1 request - request line, headers,
|
||||||
|
/// and (for a Content-Length body) either a raw body or, for
|
||||||
|
/// application/x-www-form-urlencoded / multipart/form-data, a parsed
|
||||||
|
/// CGIFormData - off a shared StreamReader. Resumable across any number
|
||||||
|
/// of StreamReader::feed() calls, exactly like every other Parser in
|
||||||
|
/// this subsystem: built by chaining LineParser (request line) and
|
||||||
|
/// IMFHeader (headers) via checkParse(), the same way CGIFormData itself
|
||||||
|
/// chains IMFHeader/IMFBoundary over one shared StreamReader.
|
||||||
|
///
|
||||||
|
/// This codebase predates ever parsing raw HTTP off a socket (it has
|
||||||
|
/// only ever sat behind a CGI gateway) - IMFRequest/IMFResponse/
|
||||||
|
/// IMFMessage are stubs from before this Parser/StreamReader subsystem
|
||||||
|
/// existed and are not built on here.
|
||||||
|
///
|
||||||
|
/// v1 limitations, deliberately not addressed (flagged, not fixed -
|
||||||
|
/// matching the standard already set by other Parser subclasses here for
|
||||||
|
/// known-but-out-of-scope gaps):
|
||||||
|
/// - chunked Transfer-Encoding is not supported, only Content-Length.
|
||||||
|
/// - repeated header names (e.g. multiple Cookie: lines) last-wins -
|
||||||
|
/// the same limitation IMFHeader's std::map already has, inherited
|
||||||
|
/// here since HEADERS delegates to IMFHeader directly.
|
||||||
|
///
|
||||||
|
|
||||||
|
class HTTPRequest : public Parser {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
HTTPRequest(StreamReader &reader);
|
||||||
|
virtual ~HTTPRequest();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Valid once doParse() has returned Status::COMPLETE.
|
||||||
|
///
|
||||||
|
|
||||||
|
MString getMethod();
|
||||||
|
MString getPath();
|
||||||
|
MString getQueryString();
|
||||||
|
MString getVersion();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Case-insensitive header lookup (HTTP header names are
|
||||||
|
/// case-insensitive per RFC 7230, unlike IMFHeader's underlying
|
||||||
|
/// std::map, which compares byte-for-byte) - returns an empty
|
||||||
|
/// MString if the header wasn't present. Valid once the HEADERS
|
||||||
|
/// state has completed (i.e. from BODY parsing onward).
|
||||||
|
///
|
||||||
|
|
||||||
|
MString getHeader(const char *name);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Every header as parsed, keyed exactly as received (not
|
||||||
|
/// case-normalized) - prefer getHeader() for lookups.
|
||||||
|
///
|
||||||
|
|
||||||
|
std::map<MString, MString> &getHeaders();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Valid once doParse() reports COMPLETE. Populated only when the
|
||||||
|
/// request had a body that was neither application/
|
||||||
|
/// x-www-form-urlencoded nor multipart/form-data (e.g. a raw JSON
|
||||||
|
/// body) - empty otherwise, including when there was no body at all.
|
||||||
|
///
|
||||||
|
|
||||||
|
MString getBody();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Valid once doParse() reports COMPLETE, when the body's
|
||||||
|
/// Content-Type was application/x-www-form-urlencoded or
|
||||||
|
/// multipart/form-data - NULL otherwise (including no body at all).
|
||||||
|
/// Owned by this HTTPRequest - do not delete.
|
||||||
|
///
|
||||||
|
|
||||||
|
CGIFormData *getFormData();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Status parse() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
enum State { REQUEST_LINE, HEADERS, BODY, DONE } state = REQUEST_LINE;
|
||||||
|
|
||||||
|
MString method, path, queryString, version;
|
||||||
|
std::map<MString, MString> headers;
|
||||||
|
MString body;
|
||||||
|
MString boundary;
|
||||||
|
|
||||||
|
LineParser *lineParser = NULL;
|
||||||
|
IMFHeader *headerParser = NULL;
|
||||||
|
CGIFormData *formParser = NULL;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#include "HTTPResponse.h"
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
HTTPResponse::HTTPResponse() {
|
||||||
|
statusText = "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTTPResponse::setStatus(int code, ZString text) {
|
||||||
|
statusCode = code;
|
||||||
|
statusText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTTPResponse::setHeader(ZString name, ZString value) {
|
||||||
|
headers[MString(name)] = MString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTTPResponse::setBody(ZString bodyIn) {
|
||||||
|
body = bodyIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
MString HTTPResponse::serialize() {
|
||||||
|
bool hasContentLength = false;
|
||||||
|
for (auto &pair : headers) {
|
||||||
|
MString key = pair.first;
|
||||||
|
if (strcasecmp(key.c_str(), "Content-Length") == 0)
|
||||||
|
hasContentLength = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MString out;
|
||||||
|
out << "HTTP/1.1 ";
|
||||||
|
out << MString(std::to_string(statusCode));
|
||||||
|
out << " ";
|
||||||
|
out << statusText;
|
||||||
|
out << "\r\n";
|
||||||
|
for (auto &pair : headers) {
|
||||||
|
out << pair.first;
|
||||||
|
out << ": ";
|
||||||
|
out << pair.second;
|
||||||
|
out << "\r\n";
|
||||||
|
}
|
||||||
|
if (!hasContentLength) {
|
||||||
|
out << "Content-Length: ";
|
||||||
|
out << MString(std::to_string(body.getLength()));
|
||||||
|
out << "\r\n";
|
||||||
|
}
|
||||||
|
out << "\r\n";
|
||||||
|
out << body;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __HTTPResponse_h__
|
||||||
|
#define __HTTPResponse_h__
|
||||||
|
|
||||||
|
#include "MString.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// HTTPResponse builds a raw HTTP/1.1 response (status line + headers +
|
||||||
|
/// body) ready to write to a socket. Output-only, not a Parser - there's
|
||||||
|
/// nothing to resume here, the whole thing is built and serialized in
|
||||||
|
/// one pass once a handler has finished producing its body.
|
||||||
|
///
|
||||||
|
/// Deliberately new rather than built on/patched from IMFResponse -
|
||||||
|
/// IMFResponse's own header-emission code is dead (calls addHeader()/
|
||||||
|
/// output(), neither of which exist on that class) and it never grew a
|
||||||
|
/// real headers container, so there's nothing there safe to extend.
|
||||||
|
///
|
||||||
|
|
||||||
|
class HTTPResponse {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
HTTPResponse();
|
||||||
|
|
||||||
|
void setStatus(int code, ZString text);
|
||||||
|
void setHeader(ZString name, ZString value);
|
||||||
|
void setBody(ZString body);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Serializes the full response - status line, headers (an explicit
|
||||||
|
/// Content-Length header is respected as-is; otherwise one is
|
||||||
|
/// computed from the body automatically), the blank line, and the
|
||||||
|
/// body - ready to write to a socket.
|
||||||
|
///
|
||||||
|
|
||||||
|
MString serialize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int statusCode = 200;
|
||||||
|
MString statusText;
|
||||||
|
std::map<MString, MString> headers;
|
||||||
|
MString body;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#include "IMFBoundary.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
IMFBoundary::IMFBoundary(StreamReader &reader, ZString boundary) : Parser(reader), boundary(boundary) {}
|
||||||
|
|
||||||
|
Parser::Status IMFBoundary::parse() {
|
||||||
|
MString &buffer = reader.getBuffer();
|
||||||
|
switch (state) {
|
||||||
|
|
||||||
|
case PREFIX: {
|
||||||
|
MString marker;
|
||||||
|
marker << "\r\n--";
|
||||||
|
marker << boundary;
|
||||||
|
int pos = buffer.find(marker);
|
||||||
|
if (pos < 0)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (!buffer.ifNext(marker))
|
||||||
|
throw coreutils::Exception("IMFBoundary: boundary marker vanished between find and ifNext.");
|
||||||
|
state = TAIL;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TAIL:
|
||||||
|
// ZString::getLength() is already cursor-relative (bytes remaining
|
||||||
|
// from the cursor to the end) - do not subtract the cursor offset
|
||||||
|
// again here.
|
||||||
|
if (buffer.getLength() < 2)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (buffer.ifNext(ZString("--"))) {
|
||||||
|
last = true;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
if (buffer.ifNext(ZString("\r\n"))) {
|
||||||
|
last = false;
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
throw coreutils::Exception("IMFBoundary: malformed boundary line - expected CRLF or trailing --.");
|
||||||
|
|
||||||
|
}
|
||||||
|
throw coreutils::Exception("IMFBoundary: unreachable state.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IMFBoundary::isLast() {
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#ifndef __IMFBoundary_h__
|
||||||
|
# define __IMFBoundary_h__
|
||||||
|
|
||||||
|
#include "Parser.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// IMFBoundary detects a MIME multipart boundary line in the shared
|
||||||
|
/// StreamReader - either an ordinary boundary ("\r\n--" + boundary +
|
||||||
|
/// "\r\n", meaning another part follows) or the closing boundary
|
||||||
|
/// ("\r\n--" + boundary + "--", meaning this was the last part).
|
||||||
|
/// Resumable: if the boundary text has been seen but there isn't yet
|
||||||
|
/// enough buffered data to tell an ordinary boundary from the closing
|
||||||
|
/// one, parse() reports INCOMPLETE without committing the cursor past
|
||||||
|
/// the ambiguous point.
|
||||||
|
///
|
||||||
|
|
||||||
|
class IMFBoundary : public Parser {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
IMFBoundary(StreamReader &reader, ZString boundary);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Valid once doParse() has returned Status::COMPLETE - true if this
|
||||||
|
/// was the closing boundary (no further parts follow).
|
||||||
|
///
|
||||||
|
|
||||||
|
bool isLast();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Status parse() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
enum State { PREFIX, TAIL } state = PREFIX;
|
||||||
|
ZString boundary;
|
||||||
|
bool last = false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+10
-13
@@ -1,21 +1,18 @@
|
|||||||
#include "IMFFormData.h"
|
#include "IMFFormData.h"
|
||||||
#include "IMFMessage.h"
|
#include "IMFMessage.h"
|
||||||
#include "IMFPlainText.h"
|
#include "IMFText.h"
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFFormData::IMFFormData() {}
|
IMFFormData::IMFFormData(int fd, ZString boundary) {
|
||||||
|
// TODO: IMFHeader now reads through a StreamReader (see the Parser/
|
||||||
IMFFormData::IMFFormData(ZString &in, ZString &boundary) : IMFMultipart(in, boundary) {}
|
// StreamReader redesign) instead of a raw fd. This constructor - and
|
||||||
|
// IMFMultipart, which still constructs IMFFormData from a bare fd -
|
||||||
ZString IMFFormData::getByName(ZString &name) {
|
// needs migrating to StreamReader together before header parsing can
|
||||||
for(ZString section: sections) {
|
// be wired back in here. Out of scope for that redesign pass; this
|
||||||
IMFMessage message(section);
|
// class was already an unfinished stub (constructed objects were
|
||||||
if(message.getHeaderKeyPairValue("Content-Disposition", ("name")).equals(name)) {
|
// discarded, nothing was stored) before this change.
|
||||||
return message.multipart;
|
IMFText text(fd, boundary);
|
||||||
}
|
|
||||||
}
|
|
||||||
return ZString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-8
@@ -1,22 +1,17 @@
|
|||||||
#ifndef __IMFFormData_h__
|
#ifndef __IMFFormData_h__
|
||||||
# define __IMFFormData_h__
|
# define __IMFFormData_h__
|
||||||
|
|
||||||
# include "IMFMultipart.h"
|
#include "ZString.h"
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
class IMFFormData: public IMFMultipart {
|
class IMFFormData {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFFormData();
|
IMFFormData(int fd, ZString boundary);
|
||||||
IMFFormData(ZString &in, ZString &boundary);
|
|
||||||
|
|
||||||
ZString getByName(ZString &name);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
+67
-23
@@ -1,37 +1,81 @@
|
|||||||
#include "IMFHeader.h"
|
#include "IMFHeader.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Log.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFHeader::IMFHeader(ZString &in) : ZString(in) {
|
IMFHeader::IMFHeader(StreamReader &reader) : Parser(reader) {}
|
||||||
|
|
||||||
|
Parser::Status IMFHeader::parse() {
|
||||||
|
MString &buffer = reader.getBuffer();
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
|
||||||
|
case NAME: {
|
||||||
|
if (buffer.eod())
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (buffer.getChar() == '\r') {
|
||||||
|
// ZString::getLength() is already cursor-relative.
|
||||||
|
if (buffer.getLength() < 2)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (!buffer.ifNext(ZString("\r\n")))
|
||||||
|
throw coreutils::Exception("IMFHeader: expected CRLF at end of header block.");
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
name << buffer.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789");
|
||||||
|
if (buffer.eod())
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (!buffer.ifNext(ZString(":")))
|
||||||
|
throw coreutils::Exception("IMFHeader: expected ':' in header name.");
|
||||||
|
state = SKIP_SPACE;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SKIP_SPACE:
|
||||||
|
while (!buffer.eod() && buffer.getChar() == ' ')
|
||||||
|
buffer.nextChar();
|
||||||
|
if (buffer.eod())
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
state = FIELD;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
|
||||||
|
case FIELD:
|
||||||
|
field << buffer.getTokenExclude("\r\n");
|
||||||
|
// Need 2 bytes buffered to reliably test for "\r\n" - eod() (a
|
||||||
|
// 1-byte check) would wrongly treat a lone trailing \r as
|
||||||
|
// malformed instead of "wait for the \n". Same bug class already
|
||||||
|
// fixed once in IMFBoundary's TAIL state.
|
||||||
|
if (buffer.getLength() < 2)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (!buffer.ifNext(ZString("\r\n")))
|
||||||
|
throw coreutils::Exception("IMFHeader: expected CRLF at end of header field.");
|
||||||
|
state = FOLD_CHECK;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
|
||||||
|
case FOLD_CHECK:
|
||||||
|
if (buffer.eod())
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
if (buffer.getChar() == ' ' || buffer.getChar() == '\t') {
|
||||||
|
buffer.nextChar();
|
||||||
|
field << " ";
|
||||||
|
state = SKIP_SPACE;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
}
|
||||||
|
commitField();
|
||||||
|
state = NAME;
|
||||||
|
return Status::DATA_AVAIL;
|
||||||
|
|
||||||
key = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789");
|
|
||||||
std::cout << "key: [" << key << "]" << std::endl;
|
|
||||||
if(key.getLength() != 0) {
|
|
||||||
if(!in.ifNext(":"))
|
|
||||||
throw coreutils::Exception("Invalid character in expected header token.");
|
|
||||||
in.skipWhitespace();
|
|
||||||
value = in.goeolwithContinuation();
|
|
||||||
std::cout << "header: [" << value << "]" << std::endl;
|
|
||||||
}
|
}
|
||||||
else if(in.skipWhitespace() > 0) {}
|
throw coreutils::Exception("IMFHeader: unreachable state.");
|
||||||
else if(in.str() == "") {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMFHeader::IMFHeader(ZString key, ZString value) : ZString(), key(key), value(value) {}
|
void IMFHeader::commitField() {
|
||||||
|
headers[name] = field;
|
||||||
ZString IMFHeader::getKey() {
|
name = MString();
|
||||||
return key;
|
field = MString();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZString IMFHeader::getValue() {
|
std::map<MString, MString> &IMFHeader::getHeaders() {
|
||||||
return value;
|
return headers;
|
||||||
}
|
|
||||||
|
|
||||||
void IMFHeader::output(std::stringstream &out) {
|
|
||||||
out << key << ": " << value << "\r\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+33
-11
@@ -1,25 +1,47 @@
|
|||||||
#ifndef __IMFHeader_h__
|
#ifndef __IMFHeader_h__
|
||||||
#define __IMFHeader_h__
|
# define __IMFHeader_h__
|
||||||
|
|
||||||
#include "ZString.h"
|
# include "Parser.h"
|
||||||
#include <sstream>
|
# include "MString.h"
|
||||||
|
# include <map>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
class IMFHeader : public ZString {
|
///
|
||||||
|
/// IMFHeader parses a full block of IMF/MIME-style headers (RFC 5322
|
||||||
|
/// "name: value" pairs, one per line, with folded continuation lines -
|
||||||
|
/// any line starting with a space or tab is appended to the previous
|
||||||
|
/// field's value) from the shared StreamReader, stopping at the blank
|
||||||
|
/// line that terminates the header block. Resumable across any number of
|
||||||
|
/// StreamReader::feed() calls - partially-read names/values accumulate
|
||||||
|
/// in the name/field members rather than being discarded between calls.
|
||||||
|
///
|
||||||
|
|
||||||
|
class IMFHeader : public Parser {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFHeader(ZString &in);
|
|
||||||
IMFHeader(ZString key, ZString value);
|
|
||||||
|
|
||||||
ZString getKey();
|
IMFHeader(StreamReader &reader);
|
||||||
ZString getValue();
|
|
||||||
|
|
||||||
void output(std::stringstream &out);
|
///
|
||||||
|
/// Valid once doParse() has returned Status::COMPLETE - every header
|
||||||
|
/// field parsed, keyed by field name.
|
||||||
|
///
|
||||||
|
|
||||||
|
std::map<MString, MString> &getHeaders();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Status parse() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ZString key;
|
|
||||||
ZString value;
|
enum State { NAME, SKIP_SPACE, FIELD, FOLD_CHECK } state = NAME;
|
||||||
|
MString name;
|
||||||
|
MString field;
|
||||||
|
std::map<MString, MString> headers;
|
||||||
|
|
||||||
|
void commitField();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#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
|
||||||
+2
-77
@@ -1,87 +1,12 @@
|
|||||||
#include "IMFMessage.h"
|
#include "IMFMessage.h"
|
||||||
#include "IMFHeader.h"
|
#include "IMFHeader.h"
|
||||||
#include "IMFMultipart.h"
|
#include "IMFMultipart.h"
|
||||||
#include "IMFPlainText.h"
|
#include "IMFText.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFMessage::IMFMessage() : ZString() {}
|
IMFMessage::IMFMessage(int fd) {}
|
||||||
|
|
||||||
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() {}
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+8
-15
@@ -15,28 +15,21 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
class IMFMessage : public ZString {
|
class IMFMessage {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFMessage();
|
IMFMessage(int fd);
|
||||||
IMFMessage(ZString &in);
|
|
||||||
virtual ~IMFMessage();
|
virtual ~IMFMessage();
|
||||||
|
|
||||||
void output(std::stringstream &out);
|
// void output(std::stringstream &out);
|
||||||
|
|
||||||
void addHeader(IMFHeader header);
|
// IMFMultipart multipart;
|
||||||
|
// ZString block;
|
||||||
ZString getHeader(ZString key, bool valueOnly = true);
|
// char contentLength[8];
|
||||||
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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+27
-25
@@ -1,35 +1,37 @@
|
|||||||
#include "IMFMultipart.h"
|
#include "IMFMultipart.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
IMFMultipart::IMFMultipart() {}
|
IMFMultipart::IMFMultipart(int fd, MString boundary) {
|
||||||
|
char ch = 0;
|
||||||
|
int rc = 0;
|
||||||
|
while((ch != '\r') && (ch != '\n')) {
|
||||||
|
rc = ::read(fd, &ch, 1);
|
||||||
|
if((ch != '\r') && (ch != '\n'))
|
||||||
|
boundary.write(ch);
|
||||||
|
}
|
||||||
|
if(ch == '\r') {
|
||||||
|
rc = ::read(fd, &ch, 1);
|
||||||
|
}
|
||||||
|
while(1) {
|
||||||
|
IMFFormData *formData = new IMFFormData(fd, boundary);
|
||||||
|
|
||||||
IMFMultipart::IMFMultipart(ZString &in, ZString &boundary) {
|
rc = ::read(fd, &ch, 1);
|
||||||
Log(LOG_DEBUG_1) << in;
|
if(ch == '-') {
|
||||||
std::stringstream temp;
|
rc = ::read(fd, &ch, 1);
|
||||||
temp << "--" << boundary;
|
if(ch == '-') {
|
||||||
sections = in.split(temp.str().c_str());
|
break;
|
||||||
for(int ix = 0; ix < sections.size(); ++ix) {
|
}
|
||||||
sections[ix].ifNext("\r\n");
|
} else if(ch == '\r') {
|
||||||
sections[ix].trimCRLF();
|
rc = ::read(fd, &ch, 1);
|
||||||
Log(LOG_DEBUG_1) << "[" << sections[ix] << "].";
|
if(ch != '\n')
|
||||||
if(sections[ix].equals("--"))
|
coreutils::Exception("expecting '\n' in data stream.");
|
||||||
sections[ix] = ZString("");
|
}
|
||||||
sections[ix].ifNext("\r\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IMFMultipart::toString() {
|
|
||||||
return std::string(getData(), getLength());
|
|
||||||
}
|
|
||||||
|
|
||||||
int IMFMultipart::getCount() {
|
|
||||||
return sections.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
ZString IMFMultipart::getSectionAt(int index) {
|
|
||||||
return sections[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+7
-12
@@ -1,25 +1,20 @@
|
|||||||
#ifndef __IMFMultipart_h__
|
#ifndef __IMFMultipart_h__
|
||||||
#define __IMFMultipart_h__
|
#define __IMFMultipart_h__
|
||||||
|
|
||||||
#include "ZString.h"
|
#include "MString.h"
|
||||||
|
#include "IMFFormData.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
class IMFMultipart: public ZString {
|
class IMFMultipart {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IMFMultipart();
|
IMFMultipart(int fd, MString boundary);
|
||||||
IMFMultipart(ZString &in, ZString &boundary);
|
|
||||||
|
|
||||||
std::string toString();
|
|
||||||
int getCount();
|
|
||||||
ZString getSectionAt(int index);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::vector<ZString> sections;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *boundary;
|
MString boundary;
|
||||||
|
std::vector<IMFFormData> sections;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#include "IMFPlainText.h"
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
IMFPlainText::IMFPlainText() {
|
|
||||||
}
|
|
||||||
|
|
||||||
IMFPlainText::IMFPlainText(ZString &in) : ZString(in.str().c_str()) {}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#ifndef __IMFPlainText_h__
|
|
||||||
#define __IMFPlainText_h__
|
|
||||||
|
|
||||||
#include "ZString.h"
|
|
||||||
|
|
||||||
namespace coreutils {
|
|
||||||
|
|
||||||
class IMFPlainText: public ZString {
|
|
||||||
|
|
||||||
public:
|
|
||||||
IMFPlainText();
|
|
||||||
IMFPlainText(ZString &in);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+4
-4
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -14,7 +14,7 @@ namespace coreutils {
|
|||||||
/// and responses as the main communications protocol.
|
/// and responses as the main communications protocol.
|
||||||
///
|
///
|
||||||
|
|
||||||
class IMFResponse : public IMFMessage {
|
class IMFResponse {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -87,6 +87,7 @@ namespace coreutils {
|
|||||||
ZString code;
|
ZString code;
|
||||||
ZString text;
|
ZString text;
|
||||||
|
|
||||||
|
char contentLength[32];
|
||||||
const char *CRLF = "\r\n";
|
const char *CRLF = "\r\n";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
#ifndef __IMFText_h__
|
||||||
|
#define __IMFText_h__
|
||||||
|
|
||||||
|
#include "MString.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
class IMFText : public MString {
|
||||||
|
|
||||||
|
public:
|
||||||
|
IMFText(int fd, ZString boundary);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include "JFile.h"
|
||||||
|
#include "ZString.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
// MFile and JString share a single virtual MString base (the diamond:
|
||||||
|
// both "MFile : virtual public MString" and "JString : virtual public
|
||||||
|
// MString"), and a virtual base is initialized only by the *most
|
||||||
|
// derived* class's constructor - so JString's own "{}" default
|
||||||
|
// initializer never runs here. Left alone, a JFile backed by a new or
|
||||||
|
// empty file starts as a raw empty string instead of a valid empty JSON
|
||||||
|
// object, and every subsequent locate()/set() call silently misbehaves
|
||||||
|
// (no leading "{" for ifNext("{") to match, so writes end up inserted
|
||||||
|
// at offset 0 with no braces or separators at all). Detect that case
|
||||||
|
// here and seed valid JSON explicitly.
|
||||||
|
JFile::JFile(ZString filename) : MFile(filename) {
|
||||||
|
if(getLength() == 0) {
|
||||||
|
*this << "{}";
|
||||||
|
} else {
|
||||||
|
// MFile's own file-loading reads the raw bytes straight into the
|
||||||
|
// shared MString buffer - it never goes through JString::operator=,
|
||||||
|
// which is the only other place this class normally strips
|
||||||
|
// whitespace before parsing (removeWhitespace()). Without this, a
|
||||||
|
// JFile backed by a hand-written or pretty-printed JSON file (any
|
||||||
|
// whitespace between tokens - indentation, newlines, spaces after
|
||||||
|
// ':'/',') fails every locate()/exists()/get*() call, since
|
||||||
|
// JString's parser expects compact JSON with no whitespace at all
|
||||||
|
// between structural tokens. In-memory JSON built via operator=
|
||||||
|
// never hit this because it already goes through the same
|
||||||
|
// normalization - loading from disk just missed it.
|
||||||
|
removeWhitespace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef __JFile_h__
|
||||||
|
#define __JFile_h__
|
||||||
|
|
||||||
|
#include "JString.h"
|
||||||
|
#include "MFile.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Use the JFile object to create a JSON object that uses a file for its backing store.
|
||||||
|
/// The file name is provided at construction time. Contents of the file are updated
|
||||||
|
/// when the object is changed or the at the end of scope for the object.
|
||||||
|
///
|
||||||
|
|
||||||
|
class JFile : public MFile, public JString {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
JFile(ZString filename);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
#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
|
|
||||||
+555
-125
@@ -1,5 +1,7 @@
|
|||||||
#include "JString.h"
|
#include "JString.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
@@ -10,140 +12,551 @@ namespace coreutils {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MString &operator<<(MString &ms, const JString::Proxy &proxy) {
|
||||||
|
ZString tempkey = proxy.key;
|
||||||
|
ZString temp = proxy.jstring.find(tempkey);
|
||||||
|
ms << temp;
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
JString::JString() : MString("{}") {}
|
JString::JString() : MString("{}") {}
|
||||||
|
|
||||||
void JString::set(ZString &path, ZString &value) {
|
// ---------------------------------------------------------------------
|
||||||
reset();
|
// Structural helpers - escape/type aware skipping so JSON-significant
|
||||||
if(locate(path)) {
|
// characters (", {, }, [, ]) appearing inside string literals never
|
||||||
push();
|
// desync the parse position.
|
||||||
if(ifNext("\"")) {
|
// ---------------------------------------------------------------------
|
||||||
ZString old = getTokenExclude("\"");
|
|
||||||
pop();
|
JSONType JString::typeAtCursor() {
|
||||||
remove(offset(), old.getLength() + 2);
|
if (startsWith("\""))
|
||||||
MString key;
|
return JSONType::STRING;
|
||||||
if(value.startsWith("["))
|
if (startsWith("{"))
|
||||||
key << value;
|
return JSONType::OBJECT;
|
||||||
else if(value.startsWith("{"))
|
if (startsWith("["))
|
||||||
key << value;
|
return JSONType::ARRAY;
|
||||||
else
|
if (startsWith("true") || startsWith("false"))
|
||||||
key << "\"" << value << "\"";
|
return JSONType::BOOLEAN;
|
||||||
insert(key, offset());
|
if (startsWith("null"))
|
||||||
} else {
|
return JSONType::JNULL;
|
||||||
pop();
|
if (startsWithNumber())
|
||||||
throw coreutils::Exception("Fix me to accept integer type.");
|
return JSONType::NUMBER;
|
||||||
|
return JSONType::NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Captures the raw (still-escaped) content between a pair of quotes, cursor
|
||||||
|
// must be positioned on the opening quote. Leaves the cursor just past the
|
||||||
|
// closing quote. Correctly treats \" and \\ as escaped, not structural, so
|
||||||
|
// a string containing an escaped quote is captured in full rather than
|
||||||
|
// truncated early.
|
||||||
|
ZString JString::captureString() {
|
||||||
|
if (!ifNext("\""))
|
||||||
|
throw coreutils::Exception("Expected '\"' at start of JSON string.");
|
||||||
|
char *start = getCursor();
|
||||||
|
while (!eod()) {
|
||||||
|
char ch = getChar();
|
||||||
|
if (ch == '\\') {
|
||||||
|
nextChar();
|
||||||
|
if (!eod())
|
||||||
|
nextChar();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
if (ch == '"') {
|
||||||
// std::cout << "[" << unparsed() << "] >" << value << "<" << std::endl;
|
ZString result(start, getCursor() - start);
|
||||||
MString key;
|
nextChar();
|
||||||
if(notfirst)
|
return result;
|
||||||
key << ",";
|
}
|
||||||
// TODO: The value added must be parsed down to remove all whitespace.
|
nextChar();
|
||||||
if(value.startsWith("["))
|
}
|
||||||
key << "\"" << path << "\":" << value;
|
throw coreutils::Exception("Unterminated JSON string.");
|
||||||
else if(value.startsWith("{"))
|
}
|
||||||
key << "\"" << path << "\":" << value;
|
|
||||||
else
|
void JString::skipString() {
|
||||||
key << "\"" << path << "\":" << "\"" << value << "\"";
|
captureString();
|
||||||
insert(key, offset());
|
}
|
||||||
|
|
||||||
|
ZString JString::captureContainer() {
|
||||||
|
char *start = getCursor();
|
||||||
|
skipContainer();
|
||||||
|
return ZString(start, getCursor() - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::skipContainer() {
|
||||||
|
char open = getChar();
|
||||||
|
char close = (open == '{') ? '}' : ']';
|
||||||
|
int depth = 0;
|
||||||
|
do {
|
||||||
|
if (eod())
|
||||||
|
throw coreutils::Exception("Unterminated JSON object/array.");
|
||||||
|
if (startsWith("\"")) {
|
||||||
|
skipString();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char ch = nextChar();
|
||||||
|
if (ch == open)
|
||||||
|
++depth;
|
||||||
|
else if (ch == close)
|
||||||
|
--depth;
|
||||||
|
} while (depth > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::skipNumber() {
|
||||||
|
ifNext("-");
|
||||||
|
if (!((getChar() >= '0') && (getChar() <= '9')))
|
||||||
|
throw coreutils::Exception("Invalid JSON number.");
|
||||||
|
while (!eod() && (getChar() >= '0') && (getChar() <= '9'))
|
||||||
|
nextChar();
|
||||||
|
if (!eod() && (getChar() == '.')) {
|
||||||
|
nextChar();
|
||||||
|
while (!eod() && (getChar() >= '0') && (getChar() <= '9'))
|
||||||
|
nextChar();
|
||||||
|
}
|
||||||
|
if (!eod() && ((getChar() == 'e') || (getChar() == 'E'))) {
|
||||||
|
nextChar();
|
||||||
|
if (!eod() && ((getChar() == '+') || (getChar() == '-')))
|
||||||
|
nextChar();
|
||||||
|
while (!eod() && (getChar() >= '0') && (getChar() <= '9'))
|
||||||
|
nextChar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JString::skipValue() {
|
||||||
|
switch (typeAtCursor()) {
|
||||||
|
case JSONType::STRING:
|
||||||
|
skipString();
|
||||||
|
break;
|
||||||
|
case JSONType::OBJECT:
|
||||||
|
case JSONType::ARRAY:
|
||||||
|
skipContainer();
|
||||||
|
break;
|
||||||
|
case JSONType::BOOLEAN:
|
||||||
|
if (!ifNext("true") && !ifNext("false"))
|
||||||
|
throw coreutils::Exception("Invalid JSON boolean.");
|
||||||
|
break;
|
||||||
|
case JSONType::JNULL:
|
||||||
|
ifNext("null");
|
||||||
|
break;
|
||||||
|
case JSONType::NUMBER:
|
||||||
|
skipNumber();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw coreutils::Exception("Unrecognized JSON value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JString::isLiteralValue(ZString value) {
|
||||||
|
// True for text that is already valid, complete JSON on its own (an
|
||||||
|
// object, array, number, boolean, or null) - i.e. text that should be
|
||||||
|
// inserted as-is rather than quoted and escaped as a JSON string.
|
||||||
|
if (value.startsWith("{") || value.startsWith("["))
|
||||||
|
return true;
|
||||||
|
if (value.equals("true") || value.equals("false") || value.equals("null"))
|
||||||
|
return true;
|
||||||
|
if (value.startsWithNumber())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// JSON string escape / unescape
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
std::string JString::jsonEscape(ZString value) {
|
||||||
|
std::string result;
|
||||||
|
ZString v = value;
|
||||||
|
v.reset();
|
||||||
|
while (!v.eod()) {
|
||||||
|
char ch = v.nextChar();
|
||||||
|
switch (ch) {
|
||||||
|
case '"': result += "\\\""; break;
|
||||||
|
case '\\': result += "\\\\"; break;
|
||||||
|
case '\b': result += "\\b"; break;
|
||||||
|
case '\f': result += "\\f"; break;
|
||||||
|
case '\n': result += "\\n"; break;
|
||||||
|
case '\r': result += "\\r"; break;
|
||||||
|
case '\t': result += "\\t"; break;
|
||||||
|
default:
|
||||||
|
if ((unsigned char)ch < 0x20) {
|
||||||
|
char buf[8];
|
||||||
|
snprintf(buf, sizeof(buf), "\\u%04x", (unsigned char)ch);
|
||||||
|
result += buf;
|
||||||
|
} else {
|
||||||
|
result += ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void appendUTF8(std::string &out, unsigned int codepoint) {
|
||||||
|
if (codepoint <= 0x7F) {
|
||||||
|
out += (char)codepoint;
|
||||||
|
} else if (codepoint <= 0x7FF) {
|
||||||
|
out += (char)(0xC0 | (codepoint >> 6));
|
||||||
|
out += (char)(0x80 | (codepoint & 0x3F));
|
||||||
|
} else if (codepoint <= 0xFFFF) {
|
||||||
|
out += (char)(0xE0 | (codepoint >> 12));
|
||||||
|
out += (char)(0x80 | ((codepoint >> 6) & 0x3F));
|
||||||
|
out += (char)(0x80 | (codepoint & 0x3F));
|
||||||
|
} else {
|
||||||
|
out += (char)(0xF0 | (codepoint >> 18));
|
||||||
|
out += (char)(0x80 | ((codepoint >> 12) & 0x3F));
|
||||||
|
out += (char)(0x80 | ((codepoint >> 6) & 0x3F));
|
||||||
|
out += (char)(0x80 | (codepoint & 0x3F));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int readHex4(ZString &v) {
|
||||||
|
if (v.getLength() < 4)
|
||||||
|
throw coreutils::Exception("Truncated \\u escape in JSON string.");
|
||||||
|
unsigned int value = 0;
|
||||||
|
for (int ix = 0; ix < 4; ++ix) {
|
||||||
|
char ch = v.nextChar();
|
||||||
|
value <<= 4;
|
||||||
|
if ((ch >= '0') && (ch <= '9')) value |= (ch - '0');
|
||||||
|
else if ((ch >= 'a') && (ch <= 'f')) value |= (ch - 'a' + 10);
|
||||||
|
else if ((ch >= 'A') && (ch <= 'F')) value |= (ch - 'A' + 10);
|
||||||
|
else throw coreutils::Exception("Invalid hex digit in \\u escape.");
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string JString::jsonUnescape(ZString raw) {
|
||||||
|
std::string result;
|
||||||
|
ZString v = raw;
|
||||||
|
v.reset();
|
||||||
|
while (!v.eod()) {
|
||||||
|
char ch = v.nextChar();
|
||||||
|
if ((ch != '\\') || v.eod()) {
|
||||||
|
result += ch;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char esc = v.nextChar();
|
||||||
|
switch (esc) {
|
||||||
|
case '"': result += '"'; break;
|
||||||
|
case '\\': result += '\\'; break;
|
||||||
|
case '/': result += '/'; break;
|
||||||
|
case 'b': result += '\b'; break;
|
||||||
|
case 'f': result += '\f'; break;
|
||||||
|
case 'n': result += '\n'; break;
|
||||||
|
case 'r': result += '\r'; break;
|
||||||
|
case 't': result += '\t'; break;
|
||||||
|
case 'u': {
|
||||||
|
unsigned int codepoint = readHex4(v);
|
||||||
|
// High surrogate? consume the paired low surrogate and combine.
|
||||||
|
if ((codepoint >= 0xD800) && (codepoint <= 0xDBFF) &&
|
||||||
|
(v.getLength() >= 6) && (v.getChar() == '\\')) {
|
||||||
|
char *mark = v.getCursor();
|
||||||
|
v.nextChar();
|
||||||
|
if (v.getChar() == 'u') {
|
||||||
|
v.nextChar();
|
||||||
|
unsigned int low = readHex4(v);
|
||||||
|
if ((low >= 0xDC00) && (low <= 0xDFFF)) {
|
||||||
|
codepoint = 0x10000 + ((codepoint - 0xD800) << 10) + (low - 0xDC00);
|
||||||
|
} else {
|
||||||
|
v.setCursor(mark); // not a valid low surrogate, back out
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
v.setCursor(mark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
appendUTF8(result, codepoint);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
// Not a legal JSON escape - lenient: keep the literal character.
|
||||||
|
result += esc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Typed read access
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
JSONType JString::getType(ZString path) {
|
||||||
|
reset();
|
||||||
|
if (!locate(path))
|
||||||
|
return JSONType::NOT_FOUND;
|
||||||
|
return typeAtCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JString::exists(ZString path) {
|
||||||
|
return getType(path) != JSONType::NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JString::isNull(ZString path) {
|
||||||
|
return getType(path) == JSONType::JNULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string JString::getString(ZString path) {
|
||||||
|
reset();
|
||||||
|
if (!locate(path))
|
||||||
|
throw coreutils::Exception("Path not found.");
|
||||||
|
if (typeAtCursor() != JSONType::STRING)
|
||||||
|
throw coreutils::Exception("Value at path is not a JSON string.");
|
||||||
|
return jsonUnescape(captureString());
|
||||||
|
}
|
||||||
|
|
||||||
|
double JString::getNumber(ZString path) {
|
||||||
|
reset();
|
||||||
|
if (!locate(path))
|
||||||
|
throw coreutils::Exception("Path not found.");
|
||||||
|
if (typeAtCursor() != JSONType::NUMBER)
|
||||||
|
throw coreutils::Exception("Value at path is not a JSON number.");
|
||||||
|
char *start = getCursor();
|
||||||
|
skipNumber();
|
||||||
|
return atof(std::string(start, getCursor() - start).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
long JString::getInt(ZString path) {
|
||||||
|
return (long)getNumber(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JString::getBool(ZString path) {
|
||||||
|
reset();
|
||||||
|
if (!locate(path))
|
||||||
|
throw coreutils::Exception("Path not found.");
|
||||||
|
if (ifNext("true"))
|
||||||
|
return true;
|
||||||
|
if (ifNext("false"))
|
||||||
|
return false;
|
||||||
|
throw coreutils::Exception("Value at path is not a JSON boolean.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// find() - kept for callers that want the raw (still-escaped for strings)
|
||||||
|
// span rather than a fully typed/decoded value.
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
ZString JString::find(ZString path) {
|
ZString JString::find(ZString path) {
|
||||||
reset();
|
reset();
|
||||||
if(locate(path)) {
|
return findRelative(path);
|
||||||
if(ifNext("\""))
|
|
||||||
return getTokenExclude("\"");
|
|
||||||
// TODO: Handle numbers that are not in double quotes.
|
|
||||||
|
|
||||||
else if(startsWith("["))
|
|
||||||
return getContainer();
|
|
||||||
|
|
||||||
else if(startsWith("{"))
|
|
||||||
return getContainer();
|
|
||||||
}
|
|
||||||
return ZString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same as find(), but searches from the cursor's current position rather than
|
||||||
|
// resetting to the start of the whole document first. Needed by the array
|
||||||
|
// selector logic in locate() below, which must check a subkey *within the
|
||||||
|
// array element currently under the cursor* - calling find() there (which
|
||||||
|
// always resets to the document root) would search the wrong object entirely.
|
||||||
|
ZString JString::findRelative(ZString path) {
|
||||||
|
if (!locate(path))
|
||||||
|
return ZString();
|
||||||
|
switch (typeAtCursor()) {
|
||||||
|
case JSONType::STRING:
|
||||||
|
return captureString();
|
||||||
|
case JSONType::ARRAY:
|
||||||
|
case JSONType::OBJECT:
|
||||||
|
return captureContainer();
|
||||||
|
default: {
|
||||||
|
char *start = getCursor();
|
||||||
|
skipValue();
|
||||||
|
return ZString(start, getCursor() - start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// locate() - path navigation. Structurally unchanged except that skipping
|
||||||
|
// past a key's value (when it isn't the one being searched for) now goes
|
||||||
|
// through skipValue() so every JSON type is handled, not just
|
||||||
|
// string/array/object, and strings are skipped escape-aware.
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
bool JString::locate(ZString path) {
|
bool JString::locate(ZString path) {
|
||||||
// std::cout << "path locate: " << path << std::endl;
|
|
||||||
path.getTokenExclude("[.");
|
path.getTokenExclude("[.");
|
||||||
notfirst = false;
|
notfirst = false;
|
||||||
if(ifNext("{")) {
|
if (ifNext("{")) {
|
||||||
while(startsWith("\"")) {
|
while (startsWith("\"")) {
|
||||||
notfirst = true;
|
notfirst = true;
|
||||||
ZString label;
|
ZString label;
|
||||||
ZString value;
|
if (ifNext("\"")) {
|
||||||
if(ifNext("\"")) {
|
label = getTokenExclude("\"");
|
||||||
label = getTokenExclude("\"");
|
ifNext("\"");
|
||||||
ifNext("\"");
|
} else
|
||||||
} else
|
throw coreutils::Exception("Labels must be contained in double quotes.");
|
||||||
throw coreutils::Exception("Labels must be contained in double quotes.");
|
if (ifNext(":")) {
|
||||||
if(ifNext(":")) {
|
if (label == path.parsed()) {
|
||||||
// std::cout << "path: (" << path.parsed() << ") (" << label << ") " << (label == path.parsed()) << std::endl;
|
if (path.unparsed() == "") {
|
||||||
if(label == path.parsed()) {
|
|
||||||
if(path.unparsed() == "") {
|
|
||||||
// std::cout << "found cursor: " << unparsed() << std::endl;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(path.ifNext("."))
|
if (path.ifNext("."))
|
||||||
return locate(path.unparsed());
|
return locate(path.unparsed());
|
||||||
if(path.ifNext("[")) {
|
if (path.ifNext("[")) {
|
||||||
int index = path.asInteger();
|
bool found = true;
|
||||||
if(!path.ifNext("]"))
|
if (path.startsWithNumber()) {
|
||||||
throw coreutils::Exception("expecting ] after index value in array selector.");
|
// Numeric index: label[N]
|
||||||
if(ifNext("[")) {
|
int index = path.asInteger();
|
||||||
while(index > 0) {
|
if (!path.ifNext("]"))
|
||||||
getContainer();
|
throw coreutils::Exception("expecting ] after index value in array selector.");
|
||||||
if(!ifNext(","))
|
if (!ifNext("["))
|
||||||
|
throw coreutils::Exception("Path is expecting an array for selector value.");
|
||||||
|
while (index > 0) {
|
||||||
|
skipValue();
|
||||||
|
// Reaching the array's closing bracket here means the
|
||||||
|
// caller asked for an index past the last real element -
|
||||||
|
// a legitimate "does this exist" probe (see exists()'s own
|
||||||
|
// doc comment), not malformed JSON, and the one real
|
||||||
|
// caller of this shape (BARANTMailConfig::getDkimEntries(),
|
||||||
|
// walking a "dkim" array of unknown length ascending until
|
||||||
|
// exists() first returns false) depends on getting a clean
|
||||||
|
// "not found" back rather than an uncaught exception.
|
||||||
|
// Confirmed live: querying one index past a real 2-element
|
||||||
|
// array threw this unconditionally before, crashing server
|
||||||
|
// startup outright instead of the config simply reporting
|
||||||
|
// "no more entries".
|
||||||
|
if (ifNext("]"))
|
||||||
|
return false;
|
||||||
|
if (!ifNext(","))
|
||||||
throw coreutils::Exception("expecting comma to seperate array elements.");
|
throw coreutils::Exception("expecting comma to seperate array elements.");
|
||||||
--index;
|
--index;
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
} else
|
// Selector: label[key=value] - find the array element whose subkey
|
||||||
throw coreutils::Exception("Path is expecting an array for selector value.");
|
// matches the given value.
|
||||||
if(path.eod())
|
ZString key = path.getTokenExclude("=");
|
||||||
|
if (!path.ifNext("="))
|
||||||
|
throw coreutils::Exception("expecting '=' in array selector.");
|
||||||
|
ZString value = path.getTokenExclude("]");
|
||||||
|
if (!path.ifNext("]"))
|
||||||
|
throw coreutils::Exception("expecting ']' after array selector value.");
|
||||||
|
if (!ifNext("["))
|
||||||
|
throw coreutils::Exception("Path is expecting an array for selector value.");
|
||||||
|
found = false;
|
||||||
|
while (!ifNext("]")) {
|
||||||
|
push();
|
||||||
|
ZString check = findRelative(key);
|
||||||
|
pop();
|
||||||
|
if (check.equals(value)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
skipValue();
|
||||||
|
ifNext(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Landed on the target array element (index or selector match) - if the
|
||||||
|
// path continues past it (e.g. "b[2].c" or "items[id=x].val"), descend
|
||||||
|
// into it; otherwise this element itself is the target. Previously the
|
||||||
|
// numeric-index case always returned true immediately after reaching the
|
||||||
|
// index, so any further path segment was silently ignored, and the
|
||||||
|
// selector case was never reachable from a nested path at all - both
|
||||||
|
// now share this same continuation logic.
|
||||||
|
if (!found)
|
||||||
return false;
|
return false;
|
||||||
else if(path.ifNext("."))
|
if (path.eod())
|
||||||
|
return true;
|
||||||
|
if (path.ifNext("."))
|
||||||
return locate(path.unparsed());
|
return locate(path.unparsed());
|
||||||
throw coreutils::Exception("expecting '.' in path.");
|
throw coreutils::Exception("expecting '.' in path.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// std::cout << "+++" << unparsed() << std::endl;
|
skipValue();
|
||||||
if(startsWith("\"")) {
|
ifNext(",");
|
||||||
getContainer();
|
} else
|
||||||
} else if(startsWith("[")) {
|
throw coreutils::Exception("Expected colon after label.");
|
||||||
getContainer();
|
}
|
||||||
} else if(startsWith("{")) {
|
} else if (ifNext("[")) {
|
||||||
getContainer();
|
ZString label = path.getTokenExclude("[");
|
||||||
} else {
|
path.ifNext("[");
|
||||||
throw coreutils::Exception("Unrecognized data type.");
|
ZString key = path.getTokenExclude("=");
|
||||||
}
|
path.ifNext("=");
|
||||||
ifNext(",");
|
ZString value = path.getTokenExclude("]");
|
||||||
} else
|
while (!ifNext("]")) {
|
||||||
throw coreutils::Exception("Expected colon after label.");
|
push();
|
||||||
}
|
ZString check = findRelative(key);
|
||||||
} else if(ifNext("[")) {
|
pop();
|
||||||
ZString label = path[0].getTokenExclude("[");
|
if (check.equals(value)) {
|
||||||
path.ifNext("[");
|
return locate(label);
|
||||||
ZString key = path[0].getTokenExclude("=");
|
} else {
|
||||||
path.ifNext("=");
|
skipValue();
|
||||||
ZString value = path[0].getTokenExclude("]");
|
ifNext(",");
|
||||||
while(!ifNext("]")) {
|
}
|
||||||
push();
|
}
|
||||||
ZString check = find(key);
|
|
||||||
pop();
|
|
||||||
if(check.equals(value)) {
|
|
||||||
return locate(label);
|
|
||||||
} else {
|
|
||||||
getContainer();
|
|
||||||
ifNext(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// std::cout << "not found cursor: " << unparsed() << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Writing values
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
void JString::set(ZString &path, ZString &value) {
|
||||||
|
reset();
|
||||||
|
MString formatted;
|
||||||
|
if (isLiteralValue(value))
|
||||||
|
formatted << value;
|
||||||
|
else
|
||||||
|
formatted << "\"" << jsonEscape(value).c_str() << "\"";
|
||||||
|
setFormatted(path, formatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::setFormatted(ZString path, MString formatted) {
|
||||||
|
reset();
|
||||||
|
if (locate(path)) {
|
||||||
|
int startOffset = offset();
|
||||||
|
skipValue();
|
||||||
|
int len = offset() - startOffset;
|
||||||
|
remove(startOffset, len);
|
||||||
|
insert(formatted, startOffset);
|
||||||
|
} else {
|
||||||
|
MString key;
|
||||||
|
if (notfirst)
|
||||||
|
key << ",";
|
||||||
|
key << "\"" << path << "\":" << formatted;
|
||||||
|
insert(key, offset());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::setString(ZString path, std::string value) {
|
||||||
|
// Deliberately NOT routed through set() (which calls isLiteralValue()
|
||||||
|
// to guess whether the raw text should be quoted) - setString() is
|
||||||
|
// explicitly, unambiguously a string setter, so the value must
|
||||||
|
// ALWAYS be quoted+escaped regardless of what it looks like.
|
||||||
|
// isLiteralValue() classifies anything ZString::startsWithNumber()
|
||||||
|
// accepts as a bare numeric literal - true for "42", but ALSO true
|
||||||
|
// for a string that merely STARTS with digits, like a UUID
|
||||||
|
// ("00146df8-e42c-11e7-9c78-525400b869dc"). Going through set()
|
||||||
|
// wrote that UUID completely unquoted; skipValue() then only
|
||||||
|
// recognizes the JSON-number PREFIX ("00146") as the value's real
|
||||||
|
// span when locating it for a later update, so the next setString()
|
||||||
|
// call spliced its own new key/value pair in right after "00146",
|
||||||
|
// leaving "df8-e42c-...-869dc" as orphaned text outside the object
|
||||||
|
// entirely - malformed JSON, confirmed via a real corrupted session
|
||||||
|
// file (jet-2.0's own native $[@name] session variables, backed by
|
||||||
|
// this class - see Global.h). Every other setString() caller
|
||||||
|
// sitewide was silently exposed to the same risk for any string
|
||||||
|
// value that happens to start with a digit.
|
||||||
|
MString v(value);
|
||||||
|
MString formatted;
|
||||||
|
formatted << "\"" << jsonEscape(v).c_str() << "\"";
|
||||||
|
setFormatted(path, formatted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::setNumber(ZString path, double value) {
|
||||||
|
char buf[64];
|
||||||
|
snprintf(buf, sizeof(buf), "%g", value);
|
||||||
|
MString v(buf);
|
||||||
|
set(path, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::setInt(ZString path, long value) {
|
||||||
|
char buf[32];
|
||||||
|
snprintf(buf, sizeof(buf), "%ld", value);
|
||||||
|
MString v(buf);
|
||||||
|
set(path, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::setBool(ZString path, bool value) {
|
||||||
|
MString v(value ? "true" : "false");
|
||||||
|
set(path, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JString::setNull(ZString path) {
|
||||||
|
MString v("null");
|
||||||
|
set(path, v);
|
||||||
|
}
|
||||||
|
|
||||||
JString & JString::operator=(coreutils:: ZString value) {
|
JString & JString::operator=(coreutils:: ZString value) {
|
||||||
setSize(value.getLength());
|
setSize(value.getLength());
|
||||||
memcpy(data, value.getData(), value.getLength());
|
memcpy(data, value.getData(), value.getLength());
|
||||||
@@ -153,17 +566,17 @@ namespace coreutils {
|
|||||||
|
|
||||||
void JString::removeWhitespace() {
|
void JString::removeWhitespace() {
|
||||||
reset();
|
reset();
|
||||||
while(!eod()) {
|
while (!eod()) {
|
||||||
if(*cursor == ' ')
|
if (*cursor == ' ')
|
||||||
remove(1);
|
remove(1);
|
||||||
else if(*cursor == '\r')
|
else if (*cursor == '\r')
|
||||||
remove(1);
|
remove(1);
|
||||||
else if(*cursor == '\t')
|
else if (*cursor == '\t')
|
||||||
remove(1);
|
remove(1);
|
||||||
else if(*cursor == '\n')
|
else if (*cursor == '\n')
|
||||||
remove(1);
|
remove(1);
|
||||||
else if(startsWith("\""))
|
else if (startsWith("\""))
|
||||||
getContainer();
|
skipString();
|
||||||
else
|
else
|
||||||
++cursor;
|
++cursor;
|
||||||
}
|
}
|
||||||
@@ -175,42 +588,59 @@ namespace coreutils {
|
|||||||
reset();
|
reset();
|
||||||
char ch;
|
char ch;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while(!eod()) {
|
while (!eod()) {
|
||||||
ch = nextChar();
|
ch = nextChar();
|
||||||
if(ch == '{') {
|
if (ch == '{') {
|
||||||
index += 3;
|
index += 3;
|
||||||
output << ch << '\n';
|
output << ch << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for (int ix = 0; ix < index; ++ix)
|
||||||
output << ' ';
|
output << ' ';
|
||||||
}
|
}
|
||||||
else if(ch == '[') {
|
else if (ch == '[') {
|
||||||
index += 3;
|
index += 3;
|
||||||
output << ch << '\n';
|
output << ch << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for (int ix = 0; ix < index; ++ix)
|
||||||
output << ' ';
|
output << ' ';
|
||||||
}
|
}
|
||||||
else if(ch == ':') {
|
else if (ch == ':') {
|
||||||
output << ": ";
|
output << ": ";
|
||||||
}
|
}
|
||||||
else if(ch == '}') {
|
else if (ch == '}') {
|
||||||
index -= 3;
|
index -= 3;
|
||||||
output << '\n';
|
output << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for (int ix = 0; ix < index; ++ix)
|
||||||
output << ' ';
|
output << ' ';
|
||||||
output << ch;
|
output << ch;
|
||||||
}
|
}
|
||||||
else if(ch == ']') {
|
else if (ch == ']') {
|
||||||
index -= 3;
|
index -= 3;
|
||||||
output << '\n';
|
output << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for (int ix = 0; ix < index; ++ix)
|
||||||
output << ' ';
|
output << ' ';
|
||||||
output << ch;
|
output << ch;
|
||||||
}
|
}
|
||||||
else if(ch == ',') {
|
else if (ch == ',') {
|
||||||
output << ch << '\n';
|
output << ch << '\n';
|
||||||
for(int ix = 0; ix < index; ++ix)
|
for (int ix = 0; ix < index; ++ix)
|
||||||
output << ' ';
|
output << ' ';
|
||||||
}
|
}
|
||||||
|
else if (ch == '"') {
|
||||||
|
output << ch;
|
||||||
|
// Stream the rest of the string literal through untouched, including
|
||||||
|
// escapes, without the pretty-printer's structural-character logic
|
||||||
|
// firing on a { } [ ] , or : that happens to appear inside it.
|
||||||
|
while (!eod()) {
|
||||||
|
char sch = nextChar();
|
||||||
|
output << sch;
|
||||||
|
if (sch == '\\') {
|
||||||
|
if (!eod())
|
||||||
|
output << nextChar();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (sch == '"')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
output << ch;
|
output << ch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace coreutils {
|
|||||||
/// access the objects elements using a named path as the index to the items.
|
/// access the objects elements using a named path as the index to the items.
|
||||||
///
|
///
|
||||||
/// JString default constructor will create an empty JString object pointing
|
/// JString default constructor will create an empty JString object pointing
|
||||||
/// to an empty string.
|
/// to an empty object ("{}").
|
||||||
///
|
///
|
||||||
/// Use a constructor or assignment operator to initialize a JString to an
|
/// Use a constructor or assignment operator to initialize a JString to an
|
||||||
/// initial JSON string.
|
/// initial JSON string.
|
||||||
@@ -23,12 +23,32 @@ namespace coreutils {
|
|||||||
/// object to initialize the JSON string. On destruction the file is saved back.
|
/// object to initialize the JSON string. On destruction the file is saved back.
|
||||||
///
|
///
|
||||||
/// The [] operator can be used to access elements within the JSON string.
|
/// The [] operator can be used to access elements within the JSON string.
|
||||||
/// Use:
|
/// Assigning a value dispatches on the C++ type of the right-hand side, so the
|
||||||
/// jstring["key"] = "value";
|
/// resulting JSON is correctly typed rather than always being a quoted string:
|
||||||
/// std::cout << jstring["key"];
|
///
|
||||||
|
/// jstring["name"] = "value"; // JSON string, escaped correctly
|
||||||
|
/// jstring["count"] = 42; // JSON number (integer)
|
||||||
|
/// jstring["price"] = 19.95; // JSON number
|
||||||
|
/// jstring["active"] = true; // JSON boolean
|
||||||
|
/// jstring["notes"].setNull(); // JSON null
|
||||||
|
///
|
||||||
|
/// std::cout << jstring["name"];
|
||||||
|
///
|
||||||
|
/// Typed read access is available directly on the path (no need to go through
|
||||||
|
/// operator[] first):
|
||||||
|
///
|
||||||
|
/// std::string name = jstring.getString("name");
|
||||||
|
/// double price = jstring.getNumber("price");
|
||||||
|
/// bool active = jstring.getBool("active");
|
||||||
|
/// bool missing = !jstring.exists("notfound");
|
||||||
|
/// JSONType t = jstring.getType("count"); // JSONType::NUMBER
|
||||||
///
|
///
|
||||||
|
|
||||||
class JString : public MString {
|
enum class JSONType {
|
||||||
|
STRING, NUMBER, BOOLEAN, JNULL, ARRAY, OBJECT, NOT_FOUND
|
||||||
|
};
|
||||||
|
|
||||||
|
class JString : virtual public MString {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -36,10 +56,24 @@ namespace coreutils {
|
|||||||
|
|
||||||
void set(ZString &path, ZString &value);
|
void set(ZString &path, ZString &value);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Inserts/replaces path with already-formatted, valid JSON text
|
||||||
|
/// (a quoted+escaped string, or a bare number/bool/null literal) -
|
||||||
|
/// the locate()/skipValue()/insert() mechanics set() and setString()
|
||||||
|
/// both share, factored out so setString() can force string quoting
|
||||||
|
/// unconditionally instead of going through set()'s own
|
||||||
|
/// isLiteralValue() guess (see setString()'s own comment in the
|
||||||
|
/// .cpp for why that guess is wrong for a string setter).
|
||||||
|
///
|
||||||
|
|
||||||
|
void setFormatted(ZString path, MString formatted);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Use the find method to look through an object for member specified by
|
/// Use the find method to look through an object for member specified by
|
||||||
/// the key in parameter 1. The cursor must be pointing to the { character
|
/// the key in parameter 1. The cursor must be pointing to the { character
|
||||||
/// that begins the object's list.
|
/// that begins the object's list. Returns the raw (still-escaped, for
|
||||||
|
/// strings) span of the value - use getString()/getNumber()/getBool()/
|
||||||
|
/// isNull() for decoded, typed access instead.
|
||||||
///
|
///
|
||||||
|
|
||||||
ZString find(ZString path);
|
ZString find(ZString path);
|
||||||
@@ -48,6 +82,34 @@ namespace coreutils {
|
|||||||
bool notfirst;
|
bool notfirst;
|
||||||
ZString path;
|
ZString path;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Type-aware access. All of these call locate() internally, so path uses
|
||||||
|
/// the same dotted/bracketed syntax as find()/set() (e.g. "a.b[2].c").
|
||||||
|
///
|
||||||
|
|
||||||
|
JSONType getType(ZString path);
|
||||||
|
bool exists(ZString path);
|
||||||
|
bool isNull(ZString path);
|
||||||
|
|
||||||
|
std::string getString(ZString path); ///< Escape-decoded string content.
|
||||||
|
double getNumber(ZString path);
|
||||||
|
long getInt(ZString path);
|
||||||
|
bool getBool(ZString path);
|
||||||
|
|
||||||
|
void setString(ZString path, std::string value); ///< Escapes value automatically.
|
||||||
|
void setNumber(ZString path, double value);
|
||||||
|
void setInt(ZString path, long value);
|
||||||
|
void setBool(ZString path, bool value);
|
||||||
|
void setNull(ZString path);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// JSON string escape/unescape helpers (exposed as static utilities since
|
||||||
|
/// they operate on plain text, not on this object's own JSON document).
|
||||||
|
///
|
||||||
|
|
||||||
|
static std::string jsonEscape(ZString value);
|
||||||
|
static std::string jsonUnescape(ZString raw);
|
||||||
|
|
||||||
class Proxy {
|
class Proxy {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -55,6 +117,23 @@ namespace coreutils {
|
|||||||
|
|
||||||
friend std::ostream &operator<<(std::ostream &os, const Proxy &proxy);
|
friend std::ostream &operator<<(std::ostream &os, const Proxy &proxy);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Proxy offers several implicit conversion operators below (to
|
||||||
|
/// ZString, MString, std::string, double, bool) so a single $[...]-
|
||||||
|
/// style access can be used wherever any of those types is expected.
|
||||||
|
/// That flexibility makes "MString << Proxy" genuinely ambiguous on
|
||||||
|
/// its own - operator ZString() and operator MString() (via its own
|
||||||
|
/// implicit upcast to ZString) both satisfy MString::operator<<(ZString),
|
||||||
|
/// and operator double()/operator bool() both satisfy
|
||||||
|
/// MString::operator<<(int) via a standard numeric conversion - so
|
||||||
|
/// the compiler has no way to prefer one path over another. This
|
||||||
|
/// exact-match overload (mirroring the ostream one above, which
|
||||||
|
/// solves the same problem for std::cout << proxy) resolves it by
|
||||||
|
/// giving MString a candidate that needs no conversion at all.
|
||||||
|
///
|
||||||
|
|
||||||
|
friend MString &operator<<(MString &ms, const Proxy &proxy);
|
||||||
|
|
||||||
operator coreutils::ZString () {
|
operator coreutils::ZString () {
|
||||||
return jstring.find(key);
|
return jstring.find(key);
|
||||||
}
|
}
|
||||||
@@ -64,15 +143,53 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator std::string () {
|
operator std::string () {
|
||||||
return jstring.find(key).str();
|
return jstring.getString(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
operator double () {
|
||||||
|
return jstring.getNumber(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
operator bool () {
|
||||||
|
return jstring.getBool(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
Proxy& operator=(coreutils::MString value) {
|
Proxy& operator=(coreutils::MString value) {
|
||||||
jstring.set(key, value);
|
jstring.setString(key, value.str());
|
||||||
jstring.changed(key, value);
|
jstring.changed(key, value);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Proxy& operator=(const char *value) {
|
||||||
|
jstring.setString(key, std::string(value));
|
||||||
|
jstring.changed(key, ZString(value));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Proxy& operator=(double value) {
|
||||||
|
jstring.setNumber(key, value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Proxy& operator=(int value) {
|
||||||
|
jstring.setInt(key, value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Proxy& operator=(long value) {
|
||||||
|
jstring.setInt(key, value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Proxy& operator=(bool value) {
|
||||||
|
jstring.setBool(key, value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setNull() {
|
||||||
|
jstring.setNull(key);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JString &jstring;
|
JString &jstring;
|
||||||
ZString key;
|
ZString key;
|
||||||
@@ -88,9 +205,38 @@ namespace coreutils {
|
|||||||
|
|
||||||
virtual void changed(ZString key, ZString value);
|
virtual void changed(ZString key, ZString value);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Strips whitespace between JSON structural tokens (indentation,
|
||||||
|
/// newlines, spaces after ':'/',') - the parser expects compact JSON
|
||||||
|
/// internally. operator=(ZString) already calls this for in-memory
|
||||||
|
/// assignment; JFile's constructor also calls it after loading a
|
||||||
|
/// file's raw bytes, which otherwise bypasses this entirely (see
|
||||||
|
/// JFile.cpp). Protected rather than private specifically so JFile
|
||||||
|
/// can reach it.
|
||||||
|
///
|
||||||
|
|
||||||
void removeWhitespace();
|
void removeWhitespace();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Structural helpers used internally by locate()/set() to correctly skip
|
||||||
|
/// past a value of any JSON type without being confused by JSON-structural
|
||||||
|
/// characters (quotes, braces, brackets) appearing inside string literals.
|
||||||
|
///
|
||||||
|
|
||||||
|
ZString findRelative(ZString path);
|
||||||
|
JSONType typeAtCursor();
|
||||||
|
void skipValue();
|
||||||
|
void skipString();
|
||||||
|
void skipContainer();
|
||||||
|
void skipNumber();
|
||||||
|
ZString captureString();
|
||||||
|
ZString captureContainer();
|
||||||
|
bool isLiteralValue(ZString value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include "LineParser.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
LineParser::LineParser(StreamReader &reader) : Parser(reader) {}
|
||||||
|
|
||||||
|
Parser::Status LineParser::parse() {
|
||||||
|
MString &buffer = reader.getBuffer();
|
||||||
|
char *lineStart = buffer.getCursor();
|
||||||
|
ZString term("\n");
|
||||||
|
int pos = buffer.find(term);
|
||||||
|
if (pos < 0)
|
||||||
|
return Status::INCOMPLETE;
|
||||||
|
char *lineEnd = buffer.getCursor();
|
||||||
|
if (lineEnd > lineStart && *(lineEnd - 1) == '\r')
|
||||||
|
--lineEnd;
|
||||||
|
line = ZString(lineStart, lineEnd - lineStart);
|
||||||
|
buffer.setCursor(buffer.getCursor() + 1);
|
||||||
|
return Status::COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZString LineParser::getLine() {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef __LineParser_h__
|
||||||
|
# define __LineParser_h__
|
||||||
|
|
||||||
|
#include "Parser.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// LineParser builds one line of text at a time from the shared
|
||||||
|
/// StreamReader - terminated by LF or CRLF, either accepted, the
|
||||||
|
/// terminator itself is not included in getLine(). Resumable: if no
|
||||||
|
/// terminator has arrived yet, parse() reports INCOMPLETE and leaves the
|
||||||
|
/// cursor exactly where it started, so the same unconsumed bytes are
|
||||||
|
/// re-scanned (along with whatever new data arrived) on the next call.
|
||||||
|
///
|
||||||
|
|
||||||
|
class LineParser : public Parser {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
LineParser(StreamReader &reader);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Valid once doParse() has returned Status::COMPLETE - the line that
|
||||||
|
/// was parsed, with its terminator stripped.
|
||||||
|
///
|
||||||
|
|
||||||
|
ZString getLine();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Status parse() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
ZString line;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -11,6 +11,9 @@ namespace coreutils {
|
|||||||
LogListener *Log::logListener = NULL;
|
LogListener *Log::logListener = NULL;
|
||||||
File *Log::logFile = NULL;
|
File *Log::logFile = NULL;
|
||||||
int Log::seq = 0;
|
int Log::seq = 0;
|
||||||
|
std::mutex Log::mtx;
|
||||||
|
size_t Log::maxLogSize = 100 * 1024 * 1024;
|
||||||
|
int Log::maxLogBackups = 5;
|
||||||
|
|
||||||
Log::Log(LogListener *logListener) {
|
Log::Log(LogListener *logListener) {
|
||||||
this->logListener = logListener;
|
this->logListener = logListener;
|
||||||
@@ -71,20 +74,39 @@ namespace coreutils {
|
|||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << this->str() << std::endl;
|
out << this->str() << std::endl;
|
||||||
;
|
std::string text = out.str();
|
||||||
|
|
||||||
mtx.lock();
|
mtx.lock();
|
||||||
|
|
||||||
if (logListener)
|
if (logFile) {
|
||||||
logListener->logSend(out.str());
|
logFile->write(text);
|
||||||
|
if (maxLogSize > 0 && logFile->currentSize() >= maxLogSize)
|
||||||
|
logFile->rotate(maxLogBackups);
|
||||||
|
}
|
||||||
|
|
||||||
if (logFile)
|
// std::cout << text;
|
||||||
logFile->write(out.str());
|
|
||||||
|
|
||||||
// std::cout << out.str();
|
|
||||||
++seq;
|
++seq;
|
||||||
|
|
||||||
mtx.unlock();
|
mtx.unlock();
|
||||||
|
|
||||||
|
// Called AFTER releasing mtx - a real, confirmed (via gdb thread
|
||||||
|
// dump on a hung production BARANTMail) lock-order inversion:
|
||||||
|
// ConsoleServer::logSend() takes TCPServer's own `lock`
|
||||||
|
// (recursive_mutex) to echo this line to connected console
|
||||||
|
// sessions, but TCPServer::connectionRequest() holds that SAME
|
||||||
|
// lock for the whole span of accepting+TLS-handshaking a new
|
||||||
|
// connection - during which another Log() call (e.g. from TLS's
|
||||||
|
// own handshake-complete callback, on a DIFFERENT thread) needs
|
||||||
|
// mtx. One thread held mtx and waited on TCPServer::lock; another
|
||||||
|
// held TCPServer::lock and waited on mtx - neither the
|
||||||
|
// recursive_mutex fix (which only helps the SAME thread re-enter
|
||||||
|
// TCPServer::lock) nor anything else here prevented it, since
|
||||||
|
// that's a same-thread-only guarantee and this is a two-thread,
|
||||||
|
// two-different-mutex inversion. logListener->logSend() only
|
||||||
|
// relays an already-built string and touches no other Log state,
|
||||||
|
// so it doesn't need mtx held at all.
|
||||||
|
if (logListener)
|
||||||
|
logListener->logSend(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,34 @@ namespace coreutils {
|
|||||||
|
|
||||||
static int seq;
|
static int seq;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Rotation threshold for the static logFile, in bytes - checked
|
||||||
|
/// after every write that reaches it. Default 100MB. Change it
|
||||||
|
/// any time (takes effect on the next log call); 0 disables
|
||||||
|
/// rotation entirely.
|
||||||
|
///
|
||||||
|
|
||||||
|
static size_t maxLogSize;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// How many rotated-out backups (logFile.1, logFile.2, ...) to
|
||||||
|
/// keep once maxLogSize is hit - the oldest beyond this count is
|
||||||
|
/// deleted outright, not just renamed away. Default 5.
|
||||||
|
///
|
||||||
|
|
||||||
|
static int maxLogBackups;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex mtx;
|
// Static, not per-instance - every Log(level) call constructs
|
||||||
|
// and destructs its own temporary Log object, so a per-instance
|
||||||
|
// mutex (the original declaration here) provided no actual
|
||||||
|
// mutual exclusion between concurrent threads at all, each
|
||||||
|
// locking a separate mutex of their own. Only became load-bearing
|
||||||
|
// once rotation was added: two threads racing between "check
|
||||||
|
// size" and "close/rename/reopen" on the one shared logFile
|
||||||
|
// could otherwise write to a stale fd mid-rotation or rotate out
|
||||||
|
// from under an in-flight write.
|
||||||
|
static std::mutex mtx;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#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();
|
||||||
|
}
|
||||||
|
|
||||||
|
MFile::~MFile() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MFile::update() {
|
||||||
|
outFile.open(fileName.c_str());
|
||||||
|
outFile << *this;
|
||||||
|
outFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#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 : virtual public MString {
|
||||||
|
|
||||||
|
public:
|
||||||
|
MFile(MString fileName);
|
||||||
|
virtual ~MFile();
|
||||||
|
|
||||||
|
coreutils::MString fileName;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::ifstream inFile;
|
||||||
|
std::ofstream outFile;
|
||||||
|
|
||||||
|
// void onChange() override;
|
||||||
|
void update();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+157
-21
@@ -11,6 +11,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
@@ -27,6 +28,24 @@ namespace coreutils {
|
|||||||
cursor = this->data;
|
cursor = this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Declared alongside MString(const char *data) but never implemented -
|
||||||
|
// invisible until a real executable actually needed this symbol
|
||||||
|
// resolved (a static library archive never checks for unresolved
|
||||||
|
// references, only the final link of a real binary does). Stores the
|
||||||
|
// raw pointer VALUE itself (not a dereference of it) as the string's
|
||||||
|
// bytes, matching how void* aliases are compared everywhere else in
|
||||||
|
// this codebase - by pointer identity, not by string content (e.g.
|
||||||
|
// TCPServer::getSessionByAlias() and TCPSession::compareAlias() both
|
||||||
|
// compare void* aliases directly) - so two MStrings built from the
|
||||||
|
// same alias value compare equal, and one built from an arbitrary
|
||||||
|
// (possibly non-string, possibly not even null-terminated) alias
|
||||||
|
// pointer never risks reading past it.
|
||||||
|
MString::MString(void *alias) {
|
||||||
|
setSize(sizeof(void *));
|
||||||
|
memcpy(this->data, &alias, sizeof(void *));
|
||||||
|
cursor = this->data;
|
||||||
|
}
|
||||||
|
|
||||||
MString::MString(char *data, size_t length) {
|
MString::MString(char *data, size_t length) {
|
||||||
setSize(length);
|
setSize(length);
|
||||||
memcpy(this->data, data, length);
|
memcpy(this->data, data, length);
|
||||||
@@ -47,13 +66,13 @@ namespace coreutils {
|
|||||||
|
|
||||||
MString::MString(const ZString &zstring) {
|
MString::MString(const ZString &zstring) {
|
||||||
setSize(zstring.getLength());
|
setSize(zstring.getLength());
|
||||||
memcpy(data, zstring.getData(), zstring.getLength());
|
memcpy(data, zstring.getCursor(), zstring.getLength());
|
||||||
cursor = data;
|
cursor = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
MString::MString(ZString &zstring) {
|
MString::MString(ZString &zstring) {
|
||||||
setSize(zstring.getLength());
|
setSize(zstring.getLength());
|
||||||
memcpy(data, zstring.getData(), zstring.getLength());
|
memcpy(data, zstring.getCursor(), zstring.getLength());
|
||||||
cursor = data;
|
cursor = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +84,7 @@ namespace coreutils {
|
|||||||
|
|
||||||
MString::MString(MString &mstring) {
|
MString::MString(MString &mstring) {
|
||||||
setSize(mstring.getLength());
|
setSize(mstring.getLength());
|
||||||
memcpy(data, mstring.getData(), mstring.getLength());
|
memcpy(data, mstring.getCursor(), mstring.getLength());
|
||||||
cursor = data;
|
cursor = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,29 +124,37 @@ namespace coreutils {
|
|||||||
|
|
||||||
MString &MString::operator=(coreutils::MString value) {
|
MString &MString::operator=(coreutils::MString value) {
|
||||||
setSize(value.getLength());
|
setSize(value.getLength());
|
||||||
memcpy(data, value.getData(), value.getLength());
|
memcpy(data, value.getCursor(), value.getLength());
|
||||||
length = value.getLength();
|
length = value.getLength();
|
||||||
|
cursor = data;
|
||||||
|
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.getCursor(), value.getLength());
|
||||||
length = value.getLength();
|
length = value.getLength();
|
||||||
return *this;
|
cursor = data;
|
||||||
}
|
onChange();
|
||||||
|
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();
|
||||||
return *this;
|
cursor = data;
|
||||||
|
onChange();
|
||||||
|
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);
|
||||||
|
cursor = data;
|
||||||
|
onChange();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +162,8 @@ namespace coreutils {
|
|||||||
int len = 1;
|
int len = 1;
|
||||||
setSize(1);
|
setSize(1);
|
||||||
*data = value;
|
*data = value;
|
||||||
|
cursor = data;
|
||||||
|
onChange();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +175,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +184,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +193,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +202,7 @@ namespace coreutils {
|
|||||||
temp << value;
|
temp << value;
|
||||||
MString temp2 = temp.str();
|
MString temp2 = temp.str();
|
||||||
write(temp2);
|
write(temp2);
|
||||||
|
onChange();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,13 +218,15 @@ namespace coreutils {
|
|||||||
int temp = length;
|
int temp = length;
|
||||||
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.getCursor(), 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,18 +240,31 @@ namespace coreutils {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MString &MString::operator<<(std::ifstream &pf) {
|
||||||
|
std::string line;
|
||||||
|
while(std::getline(pf, line))
|
||||||
|
*this << line << '\n';
|
||||||
|
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) {
|
||||||
setSize(length + value.getLength());
|
setSize(length + value.getLength());
|
||||||
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.getCursor(), value.getLength());
|
||||||
|
onChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void MString::insert(std::string value, int offset) {
|
// void MString::insert(std::string value, int offset) {
|
||||||
@@ -236,28 +284,43 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MString::remove(int length) {
|
void MString::remove(int length) {
|
||||||
|
// Shifts the tail (everything after the removed range) down to close
|
||||||
|
// the gap. The loop must stop once ix + length reaches the end of the
|
||||||
|
// valid data - reading cursor[ix + length] past that point is a
|
||||||
|
// heap-buffer-overflow (confirmed via AddressSanitizer under
|
||||||
|
// concurrent APIServer load: a completely full MString hit exactly
|
||||||
|
// this on the final iteration, reading 1 byte past the allocation).
|
||||||
|
// The old condition `ix < len` let the loop run `length` iterations
|
||||||
|
// too far.
|
||||||
int len = (data + this->length - cursor);
|
int len = (data + this->length - cursor);
|
||||||
for (int ix = 0; ix < len; ix++)
|
for (int ix = 0; ix < len - length; 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++)
|
// Same off-by-one as the single-argument overload above - the loop
|
||||||
|
// must stop once ix + length reaches this->length, not run all the
|
||||||
|
// way to this->length itself.
|
||||||
|
for (int ix = offset; ix < this->length - 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
MString &MString::write(ZString value) {
|
MString &MString::write(ZString value) {
|
||||||
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.getCursor(), value.getLength());
|
||||||
|
onChange();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,9 +336,36 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MString &MString::read(int fd) {
|
MString &MString::read(int fd) {
|
||||||
|
// ::read() returns 0 on EOF, a positive byte count on success, or
|
||||||
|
// -1 on error (EINTR - a signal interrupting the call, most
|
||||||
|
// plausibly, but any read() error) - the old `while(::read(...))`
|
||||||
|
// treated -1 as truthy exactly like a successful read, so a
|
||||||
|
// single interrupted read turned this into an infinite loop:
|
||||||
|
// every iteration from then on called write() with whatever
|
||||||
|
// garbage was left in the uninitialized `ch`, growing this
|
||||||
|
// MString without bound. Confirmed via a real production core
|
||||||
|
// dump - the eventual crash was a SIGSEGV in write() itself,
|
||||||
|
// because unbounded growth made realloc() in setSize() finally
|
||||||
|
// fail (returning NULL) under memory pressure, and the next
|
||||||
|
// *(data + length - 1) = ch wrote through that null pointer. The
|
||||||
|
// actual trigger was <call>'s own out.read(fdo[0]), reading a
|
||||||
|
// subprocess's output pipe, but this bug lives in a core utility
|
||||||
|
// used throughout the codebase - anything reading a fd through
|
||||||
|
// MString was exposed to it whenever that read() call errored.
|
||||||
char ch;
|
char ch;
|
||||||
while(::read(fd, &ch, 1))
|
ssize_t n;
|
||||||
|
while((n = ::read(fd, &ch, 1)) > 0)
|
||||||
write(ch);
|
write(ch);
|
||||||
|
onChange();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
MString &MString::read(int fd, int count) {
|
||||||
|
char ch;
|
||||||
|
ssize_t n;
|
||||||
|
while(count-- && (n = ::read(fd, &ch, 1)) > 0)
|
||||||
|
write(ch);
|
||||||
|
onChange();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +442,7 @@ namespace coreutils {
|
|||||||
ch1 <<= 4;
|
ch1 <<= 4;
|
||||||
ch1 &= 240;
|
ch1 &= 240;
|
||||||
if(eod())
|
if(eod())
|
||||||
coreutils::Exception("conversion from hex requires even number of characters.");
|
throw coreutils::Exception("conversion from hex requires even number of characters.");
|
||||||
char ch2 = nextChar();
|
char ch2 = nextChar();
|
||||||
ch2 -= 48;
|
ch2 -= 48;
|
||||||
if(ch2 > 9)
|
if(ch2 > 9)
|
||||||
@@ -394,13 +484,57 @@ namespace coreutils {
|
|||||||
|
|
||||||
|
|
||||||
MString MString::toCGI() {
|
MString MString::toCGI() {
|
||||||
|
push();
|
||||||
|
reset();
|
||||||
MString target;
|
MString target;
|
||||||
|
while(!eod()) {
|
||||||
|
char ch = nextChar();
|
||||||
|
if(ch == ' ') {
|
||||||
|
target.write('+');
|
||||||
|
} else if(isalnum((unsigned char)ch) || ch == '-' || ch == '_' || ch == '.' || ch == '~') {
|
||||||
|
target.write(ch);
|
||||||
|
} else {
|
||||||
|
target.write('%');
|
||||||
|
target.write(hexChar((ch >> 4) & 15));
|
||||||
|
target.write(hexChar(ch & 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pop();
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MString MString::fromCGI() {
|
MString MString::fromCGI() {
|
||||||
|
push();
|
||||||
|
reset();
|
||||||
MString target;
|
MString target;
|
||||||
|
while(!eod()) {
|
||||||
|
char ch = nextChar();
|
||||||
|
if(ch == '+') {
|
||||||
|
target.write(' ');
|
||||||
|
} else if(ch == '%' && !eod()) {
|
||||||
|
char ch1 = nextChar();
|
||||||
|
ch1 -= 48;
|
||||||
|
if(ch1 > 9)
|
||||||
|
ch1 -= 7;
|
||||||
|
ch1 <<= 4;
|
||||||
|
ch1 &= 240;
|
||||||
|
if(!eod()) {
|
||||||
|
char ch2 = nextChar();
|
||||||
|
ch2 -= 48;
|
||||||
|
if(ch2 > 9)
|
||||||
|
ch2 -= 7;
|
||||||
|
ch2 &= 15;
|
||||||
|
ch1 |= ch2;
|
||||||
|
target.write(ch1);
|
||||||
|
} else {
|
||||||
|
target.write(ch1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target.write(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pop();
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,4 +546,6 @@ namespace coreutils {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MString::onChange() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -170,6 +170,18 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
|
MString &operator<<(std::ifstream &pf);
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
|
MString &operator<<(std::ostream &out);
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
void insert(char ch, int offset);
|
void insert(char ch, int offset);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -231,6 +243,7 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
|
|
||||||
MString &read(int fd);
|
MString &read(int fd);
|
||||||
|
MString &read(int fd, int len);
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@@ -302,6 +315,12 @@ 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;
|
||||||
char hexChar(char c);
|
char hexChar(char c);
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
#include "Parser.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
Parser::Parser(StreamReader &reader) : reader(reader) {}
|
||||||
|
|
||||||
|
Parser::~Parser() {}
|
||||||
|
|
||||||
|
Parser::Status Parser::doParse() {
|
||||||
|
Status status;
|
||||||
|
do {
|
||||||
|
status = parse();
|
||||||
|
} while (status == Status::DATA_AVAIL);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Parser::checkParse(Parser &parser) {
|
||||||
|
return parser.doParse() == Status::COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#ifndef __Parser_h__
|
||||||
|
#define __Parser_h__
|
||||||
|
|
||||||
|
#include "StreamReader.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Parser is the base class for building a protocol/object parser that reads
|
||||||
|
/// from a shared StreamReader's buffer. A subclass implements parse() as a
|
||||||
|
/// resumable state machine (typically a switch on an internal state member)
|
||||||
|
/// that consumes as much of the buffer as it currently can and reports how
|
||||||
|
/// the parse should proceed via Status:
|
||||||
|
///
|
||||||
|
/// - COMPLETE: the object this Parser builds is fully parsed and ready.
|
||||||
|
/// - INCOMPLETE: not enough data is currently buffered to make more
|
||||||
|
/// progress; the caller should wait for more data
|
||||||
|
/// (StreamReader::feed()) before calling doParse() again.
|
||||||
|
/// The subclass's state member must reflect exactly where
|
||||||
|
/// parsing should resume - and must NOT have consumed any
|
||||||
|
/// cursor position it can't yet commit to (see individual
|
||||||
|
/// Parser subclasses for how they guarantee this).
|
||||||
|
/// - DATA_AVAIL: this call made progress and there is more buffered data
|
||||||
|
/// this Parser can still work through right now, without
|
||||||
|
/// waiting for new data to arrive.
|
||||||
|
///
|
||||||
|
/// Call doParse() (not parse() directly) to drive a Parser - it loops on
|
||||||
|
/// DATA_AVAIL automatically and returns once the result is COMPLETE or
|
||||||
|
/// INCOMPLETE.
|
||||||
|
///
|
||||||
|
|
||||||
|
class Parser {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Parser(StreamReader &reader);
|
||||||
|
|
||||||
|
enum class Status {
|
||||||
|
COMPLETE,
|
||||||
|
INCOMPLETE,
|
||||||
|
DATA_AVAIL
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual ~Parser();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// doParse is the entry and re-entry point method to continue the
|
||||||
|
/// parsing process. Safe to call repeatedly (e.g. once per
|
||||||
|
/// StreamReader::feed()) - each call resumes exactly where the
|
||||||
|
/// previous one left off.
|
||||||
|
///
|
||||||
|
|
||||||
|
Status doParse();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Inside of parse() you can call another parser object with the
|
||||||
|
/// checkParse method to attempt parsing with a candidate sub-parser
|
||||||
|
/// sharing the same StreamReader. Returns true only once that
|
||||||
|
/// sub-parser fully completes - retain the same sub-parser instance
|
||||||
|
/// across re-entries into your own parse() (e.g. as a member) so it
|
||||||
|
/// can resume, rather than constructing a new one on every call.
|
||||||
|
///
|
||||||
|
|
||||||
|
bool checkParse(Parser &parser);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
///
|
||||||
|
/// parse() performs one resumable step of parsing against reader's
|
||||||
|
/// buffer. Must be implemented by every concrete Parser to build its
|
||||||
|
/// specific object.
|
||||||
|
///
|
||||||
|
|
||||||
|
virtual Status parse() = 0;
|
||||||
|
|
||||||
|
StreamReader &reader;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "StreamReader.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
StreamReader::StreamReader() {}
|
||||||
|
|
||||||
|
void StreamReader::feed(ZString &data) {
|
||||||
|
buffer.write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
MString &StreamReader::getBuffer() {
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamReader::compact() {
|
||||||
|
int parsedLength = buffer.getCursor() - buffer.getData();
|
||||||
|
if (parsedLength > 0) {
|
||||||
|
buffer.remove(0, parsedLength);
|
||||||
|
buffer.setCursor(buffer.getData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StreamReader::hasUnparsedData() {
|
||||||
|
return !buffer.eod();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#ifndef __StreamReader_h__
|
||||||
|
#define __StreamReader_h__
|
||||||
|
|
||||||
|
#include "MString.h"
|
||||||
|
|
||||||
|
namespace coreutils {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// StreamReader accumulates data delivered in arbitrary-sized chunks (e.g. from
|
||||||
|
/// core::Socket::onDataReceived) into one continuous, growable buffer, and exposes
|
||||||
|
/// it to a chain of Parser objects so they can build higher-level protocol objects
|
||||||
|
/// (a header, a line, a MIME part, etc.) without needing to worry about where one
|
||||||
|
/// network packet ended and the next began - a "complete" unit may span any number
|
||||||
|
/// of feed() calls.
|
||||||
|
///
|
||||||
|
/// Parsers consume data through the ZString-style cursor on getBuffer(). Once a
|
||||||
|
/// Parser has fully consumed a unit (advanced the cursor past it), call compact()
|
||||||
|
/// to drop the already-parsed prefix so the buffer doesn't grow unboundedly for the
|
||||||
|
/// life of a long-running connection.
|
||||||
|
///
|
||||||
|
|
||||||
|
class StreamReader {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
StreamReader();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Append newly-arrived data to the end of the buffer. Does not affect the
|
||||||
|
/// cursor - existing parse position is preserved across a feed().
|
||||||
|
///
|
||||||
|
|
||||||
|
void feed(ZString &data);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The accumulated buffer Parsers read from and advance the cursor over.
|
||||||
|
///
|
||||||
|
|
||||||
|
MString &getBuffer();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Drop the already-parsed prefix (everything before the cursor) and reset
|
||||||
|
/// the cursor to the new start of the buffer. Call this once a Parser has
|
||||||
|
/// completed a unit and before waiting for more data, so the buffer only
|
||||||
|
/// ever grows by the amount of not-yet-parsed data.
|
||||||
|
///
|
||||||
|
|
||||||
|
void compact();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// True if there is unparsed data currently sitting in the buffer that a
|
||||||
|
/// Parser hasn't consumed yet (i.e. more progress may be possible without
|
||||||
|
/// waiting for the next feed()).
|
||||||
|
///
|
||||||
|
|
||||||
|
bool hasUnparsedData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
MString buffer;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+68
-20
@@ -70,11 +70,16 @@ namespace coreutils {
|
|||||||
free(cdata);
|
free(cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All four relational operators compare from each side's current cursor position to its
|
||||||
|
// own true buffer end (data+length), not from data alone - this class is a cursor/view
|
||||||
|
// over a buffer (see parsed()/unparsed()), so "less than" means "the remaining, unparsed
|
||||||
|
// content compares less than", consistently across <, <=, >=, and >.
|
||||||
|
|
||||||
bool ZString::operator<(const ZString &valuex) const {
|
bool ZString::operator<(const ZString &valuex) const {
|
||||||
char *end1 = data + length;
|
char *end1 = data + length;
|
||||||
char *end2 = valuex.getData() + valuex.getLength();
|
char *end2 = valuex.data + valuex.length;
|
||||||
char *cursor1 = cursor;
|
char *cursor1 = cursor;
|
||||||
char *cursor2 = valuex.getCursor();
|
char *cursor2 = valuex.cursor;
|
||||||
while((cursor1 < end1) && (cursor2 < end2)) {
|
while((cursor1 < end1) && (cursor2 < end2)) {
|
||||||
if(*cursor1 < *cursor2)
|
if(*cursor1 < *cursor2)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -90,18 +95,16 @@ namespace coreutils {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix the following comparison operators to handle the length problem appropriately.
|
|
||||||
|
|
||||||
bool ZString::operator<=(const ZString &valuex) const {
|
bool ZString::operator<=(const ZString &valuex) const {
|
||||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) <= 0);
|
return !(valuex < *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::operator>=(const ZString &valuex) const {
|
bool ZString::operator>=(const ZString &valuex) const {
|
||||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) >= 0);
|
return !(*this < valuex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::operator>(const ZString &valuex) const {
|
bool ZString::operator>(const ZString &valuex) const {
|
||||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) > 0);
|
return (valuex < *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::operator==(const ZString valuex) {
|
bool ZString::operator==(const ZString valuex) {
|
||||||
@@ -117,9 +120,16 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::operator!=(const char *valuex) const {
|
bool ZString::operator!=(const char *valuex) const {
|
||||||
if(strlen(valuex) != length)
|
if(valuex == NULL) {
|
||||||
return true;
|
if(length == 0)
|
||||||
return (strncmp(data, valuex, length) != 0);
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if(strlen(valuex) != length)
|
||||||
|
return true;
|
||||||
|
return (strncmp(data, valuex, length) != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ZString> &ZString::getList() {
|
std::vector<ZString> &ZString::getList() {
|
||||||
@@ -254,7 +264,12 @@ namespace coreutils {
|
|||||||
char *end = data + length;
|
char *end = data + length;
|
||||||
char *startChar = data + start;
|
char *startChar = data + start;
|
||||||
char *endChar = startChar + len;
|
char *endChar = startChar + len;
|
||||||
char newlen = endChar > end ? endChar - end: len;
|
// Clamp to the remaining valid length (end - startChar) when the requested
|
||||||
|
// length would overrun the buffer - previously computed endChar - end (the
|
||||||
|
// overrun amount itself) instead, handing back a length far past what's
|
||||||
|
// actually there. size_t also fixes a latent overflow for strings > 127
|
||||||
|
// bytes that the old `char newlen` would have silently wrapped.
|
||||||
|
size_t newlen = endChar > end ? (size_t)(end - startChar) : (size_t)len;
|
||||||
if(startChar < end)
|
if(startChar < end)
|
||||||
return ZString(startChar, newlen);
|
return ZString(startChar, newlen);
|
||||||
return ZString();
|
return ZString();
|
||||||
@@ -313,16 +328,24 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZString ZString::getTokenExclude(const char *exclude) {
|
ZString ZString::getTokenExclude(const char *exclude) {
|
||||||
char previous = 0;
|
// Scans up to the first character in exclude that is not escaped.
|
||||||
|
// A terminator is escaped only by an odd run of backslashes before
|
||||||
|
// it, so "a\\" ends at its closing quote while "a\"b" does not.
|
||||||
|
// Escapes are left in the returned token as written. Stops at the
|
||||||
|
// end of the data - previously a token ending in a backslash looped
|
||||||
|
// forever there.
|
||||||
char *start = cursor;
|
char *start = cursor;
|
||||||
do {
|
char *end = data + length;
|
||||||
while ((cursor < (data + length)) && !isCharacter(*cursor, exclude)) {
|
while(cursor < end) {
|
||||||
previous = *cursor;
|
if(isCharacter(*cursor, exclude)) {
|
||||||
++cursor;
|
size_t backslashes = 0;
|
||||||
|
for(char *p = cursor; (p > start) && (p[-1] == '\\'); --p)
|
||||||
|
++backslashes;
|
||||||
|
if((backslashes % 2) == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
++cursor;
|
++cursor;
|
||||||
} while(previous == '\\');
|
}
|
||||||
--cursor;
|
|
||||||
return ZString(start, cursor - start);
|
return ZString(start, cursor - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,6 +378,22 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZString &ZString::operator[](int index) {
|
ZString &ZString::operator[](int index) {
|
||||||
|
// Previously an unchecked std::vector index - a single
|
||||||
|
// malformed/short line (a port scanner, a bot probing the port,
|
||||||
|
// or any client sending fewer colon-delimited fields than a
|
||||||
|
// given handler indexes) reaches every command handler across
|
||||||
|
// every server built on this class via request[N] with no
|
||||||
|
// length check first. Depending on build flags that was either
|
||||||
|
// undefined behavior or - confirmed live, crashing a real game
|
||||||
|
// server - a hard process abort (libstdc++'s own vector bounds
|
||||||
|
// assertion). Throwing here instead lets it be caught: every
|
||||||
|
// caller that dispatches a parsed request already wraps that
|
||||||
|
// dispatch in a try/catch (see CommandList::processRequest()),
|
||||||
|
// so this turns "one bad line takes down the whole server" into
|
||||||
|
// "that one line is cleanly rejected."
|
||||||
|
if (index < 0 || (size_t)index >= list.size())
|
||||||
|
throw coreutils::Exception("ZString::operator[]: index " + std::to_string(index) +
|
||||||
|
" out of range (have " + std::to_string(list.size()) + ")");
|
||||||
return list[index];
|
return list[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,6 +412,8 @@ namespace coreutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::startsWithNumber() {
|
bool ZString::startsWithNumber() {
|
||||||
|
if(*cursor == '-')
|
||||||
|
return true;
|
||||||
return ((*cursor >= '0') && (*cursor <= '9'));
|
return ((*cursor >= '0') && (*cursor <= '9'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,6 +617,11 @@ namespace coreutils {
|
|||||||
return ZString(cursor, data + length - cursor);
|
return ZString(cursor, data + length - cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZString::setParsed() {
|
||||||
|
cursor = data + length;
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
void ZString::reset() {
|
void ZString::reset() {
|
||||||
cursor = data;
|
cursor = data;
|
||||||
}
|
}
|
||||||
@@ -586,9 +632,11 @@ namespace coreutils {
|
|||||||
|
|
||||||
bool ZString::trimCRLF() {
|
bool ZString::trimCRLF() {
|
||||||
int len = length;
|
int len = length;
|
||||||
if (*(data + length - 1) == '\n')
|
// Guard both checks against an empty string - previously read *(data - 1)
|
||||||
|
// (one byte before the buffer) when length was already 0.
|
||||||
|
if ((length > 0) && (*(data + length - 1) == '\n'))
|
||||||
--length;
|
--length;
|
||||||
if (*(data + length - 1) == '\r')
|
if ((length > 0) && (*(data + length - 1) == '\r'))
|
||||||
--length;
|
--length;
|
||||||
if (cursor >= (data + length))
|
if (cursor >= (data + length))
|
||||||
cursor = data + length;
|
cursor = data + length;
|
||||||
|
|||||||
@@ -414,6 +414,12 @@ namespace coreutils {
|
|||||||
|
|
||||||
ZString unparsed();
|
ZString unparsed();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the ZString cursor to the end of the ZString.
|
||||||
|
///
|
||||||
|
|
||||||
|
int setParsed();
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -2,3 +2,6 @@
|
|||||||
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 -lb64
|
||||||
g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils
|
g++ -o jstring_test jstring_test.cpp -I.. -L.. -lCoreUtils
|
||||||
|
g++ -g -std=c++20 -o mfile_test mfile_test.cpp -I.. -L.. -lCoreUtils
|
||||||
|
g++ -g -std=c++20 -o jfile_test jfile_test.cpp -I.. -L.. -lCoreUtils
|
||||||
|
g++ -g -std=c++23 -o http_test http_test.cpp -I.. -L.. -lCoreUtils
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include "../StreamReader.h"
|
||||||
|
#include "../HTTPRequest.h"
|
||||||
|
#include "../HTTPResponse.h"
|
||||||
|
|
||||||
|
using namespace coreutils;
|
||||||
|
|
||||||
|
static int checks = 0;
|
||||||
|
#define CHECK(cond) do { checks++; if(!(cond)) { std::cerr << "FAIL line " << __LINE__ << ": " #cond << std::endl; return 1; } } while(0)
|
||||||
|
|
||||||
|
// Feeds a StreamReader one byte at a time and drives a Parser's doParse()
|
||||||
|
// after every single byte - the harshest fragmentation test used elsewhere
|
||||||
|
// in this subsystem (see CGIFormData's byte-at-a-time stress test) - to
|
||||||
|
// prove HTTPRequest is genuinely resumable across arbitrary split points,
|
||||||
|
// not just "works when handed the whole request at once".
|
||||||
|
static Parser::Status feedByteAtATime(StreamReader &reader, Parser &parser, const std::string &data) {
|
||||||
|
Parser::Status status = Parser::Status::INCOMPLETE;
|
||||||
|
for (size_t i = 0; i < data.size() && status != Parser::Status::COMPLETE; ++i) {
|
||||||
|
ZString chunk((char *)data.data() + i, 1);
|
||||||
|
reader.feed(chunk);
|
||||||
|
status = parser.doParse();
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_get_request_byte_at_a_time() {
|
||||||
|
StreamReader reader;
|
||||||
|
HTTPRequest req(reader);
|
||||||
|
std::string raw =
|
||||||
|
"GET /hello?x=1&y=two HTTP/1.1\r\n"
|
||||||
|
"Host: example.com\r\n"
|
||||||
|
"cookie: session=abc123\r\n"
|
||||||
|
"\r\n";
|
||||||
|
CHECK(feedByteAtATime(reader, req, raw) == Parser::Status::COMPLETE);
|
||||||
|
CHECK(req.getMethod() == "GET");
|
||||||
|
CHECK(req.getPath() == "/hello");
|
||||||
|
CHECK(req.getQueryString() == "x=1&y=two");
|
||||||
|
CHECK(req.getVersion() == "HTTP/1.1");
|
||||||
|
CHECK(req.getHeader("Host") == "example.com");
|
||||||
|
// Case-insensitive lookup: header arrived lowercase ("cookie:"), looked
|
||||||
|
// up with the canonical HTTP capitalization ("Cookie") - real clients
|
||||||
|
// and servers disagree on casing constantly, this must not care.
|
||||||
|
CHECK(req.getHeader("Cookie") == "session=abc123");
|
||||||
|
CHECK(req.getBody().getLength() == 0);
|
||||||
|
CHECK(req.getFormData() == NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_get_request_no_query_string() {
|
||||||
|
StreamReader reader;
|
||||||
|
HTTPRequest req(reader);
|
||||||
|
std::string raw = "GET /plain HTTP/1.1\r\nHost: h\r\n\r\n";
|
||||||
|
CHECK(feedByteAtATime(reader, req, raw) == Parser::Status::COMPLETE);
|
||||||
|
CHECK(req.getPath() == "/plain");
|
||||||
|
CHECK(req.getQueryString().getLength() == 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_post_urlencoded_body_split_across_feeds() {
|
||||||
|
StreamReader reader;
|
||||||
|
HTTPRequest req(reader);
|
||||||
|
std::string raw =
|
||||||
|
"POST /submit HTTP/1.1\r\n"
|
||||||
|
"Host: example.com\r\n"
|
||||||
|
"Content-Type: application/x-www-form-urlencoded\r\n"
|
||||||
|
"Content-Length: 14\r\n"
|
||||||
|
"\r\n"
|
||||||
|
"name=A%20B&x=1";
|
||||||
|
// Split mid-body, not just mid-header - the whole point of building this
|
||||||
|
// on the same StreamReader/checkParse() chain CGIFormData already uses.
|
||||||
|
size_t splitAt = raw.size() - 5;
|
||||||
|
ZString part1((char *)raw.data(), splitAt);
|
||||||
|
reader.feed(part1);
|
||||||
|
CHECK(req.doParse() == Parser::Status::INCOMPLETE);
|
||||||
|
ZString part2((char *)raw.data() + splitAt, raw.size() - splitAt);
|
||||||
|
reader.feed(part2);
|
||||||
|
CHECK(req.doParse() == Parser::Status::COMPLETE);
|
||||||
|
CHECK(req.getMethod() == "POST");
|
||||||
|
CHECK(req.getFormData() != NULL);
|
||||||
|
MString name = (*req.getFormData())["name"];
|
||||||
|
CHECK(name == "A B");
|
||||||
|
MString x = (*req.getFormData())["x"];
|
||||||
|
CHECK(x == "1");
|
||||||
|
CHECK(req.getBody().getLength() == 0); // consumed by the form parser, not the raw-body path
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_post_raw_json_body() {
|
||||||
|
StreamReader reader;
|
||||||
|
HTTPRequest req(reader);
|
||||||
|
std::string body = "{\"a\":1}";
|
||||||
|
std::string raw =
|
||||||
|
"POST /api HTTP/1.1\r\n"
|
||||||
|
"Host: example.com\r\n"
|
||||||
|
"Content-Type: application/json\r\n"
|
||||||
|
"Content-Length: " + std::to_string(body.size()) + "\r\n"
|
||||||
|
"\r\n" + body;
|
||||||
|
CHECK(feedByteAtATime(reader, req, raw) == Parser::Status::COMPLETE);
|
||||||
|
CHECK(req.getFormData() == NULL);
|
||||||
|
CHECK(req.getBody() == body.c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_real_fixture_file() {
|
||||||
|
// testing/http_request.data is a real captured request, but stored with
|
||||||
|
// plain LF line endings (a text-editing convenience, confirmed via
|
||||||
|
// `file`/`xxd` - not a literal wire capture); real HTTP requires CRLF
|
||||||
|
// per RFC 7230, and IMFHeader (which HTTPRequest's HEADERS state reuses
|
||||||
|
// as-is) enforces that strictly. Normalize LF -> CRLF before feeding,
|
||||||
|
// same as any real client would actually send it.
|
||||||
|
std::ifstream in("http_request.data");
|
||||||
|
CHECK((bool)in);
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << in.rdbuf();
|
||||||
|
std::string raw = ss.str();
|
||||||
|
std::string crlf;
|
||||||
|
crlf.reserve(raw.size() + 16);
|
||||||
|
for (char c : raw) {
|
||||||
|
if (c == '\n') crlf += '\r';
|
||||||
|
crlf += c;
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamReader reader;
|
||||||
|
HTTPRequest req(reader);
|
||||||
|
CHECK(feedByteAtATime(reader, req, crlf) == Parser::Status::COMPLETE);
|
||||||
|
CHECK(req.getMethod() == "GET");
|
||||||
|
CHECK(req.getPath() == "/");
|
||||||
|
CHECK(req.getHeader("Host") == "localhost:8080");
|
||||||
|
CHECK(req.getHeader("Cookie") == "_ga=GA1.1.1017526412.1628195401");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_http_response_serialize() {
|
||||||
|
HTTPResponse resp;
|
||||||
|
resp.setStatus(200, "OK");
|
||||||
|
resp.setHeader("Content-Type", "text/plain");
|
||||||
|
resp.setBody("hello");
|
||||||
|
MString out = resp.serialize();
|
||||||
|
std::string s(out.getData(), out.getLength());
|
||||||
|
CHECK(s.find("HTTP/1.1 200 OK\r\n") == 0);
|
||||||
|
CHECK(s.find("Content-Type: text/plain\r\n") != std::string::npos);
|
||||||
|
CHECK(s.find("Content-Length: 5\r\n") != std::string::npos);
|
||||||
|
CHECK(s.find("\r\n\r\nhello") != std::string::npos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_http_response_explicit_content_length_respected() {
|
||||||
|
HTTPResponse resp;
|
||||||
|
resp.setStatus(404, "Not Found");
|
||||||
|
resp.setHeader("Content-Length", "0");
|
||||||
|
resp.setBody("");
|
||||||
|
MString out = resp.serialize();
|
||||||
|
std::string s(out.getData(), out.getLength());
|
||||||
|
CHECK(s.find("HTTP/1.1 404 Not Found\r\n") == 0);
|
||||||
|
int firstCL = s.find("Content-Length:");
|
||||||
|
int lastCL = s.rfind("Content-Length:");
|
||||||
|
CHECK(firstCL == lastCL); // no duplicate Content-Length header
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int rc = 0;
|
||||||
|
rc |= test_get_request_byte_at_a_time();
|
||||||
|
rc |= test_get_request_no_query_string();
|
||||||
|
rc |= test_post_urlencoded_body_split_across_feeds();
|
||||||
|
rc |= test_post_raw_json_body();
|
||||||
|
rc |= test_real_fixture_file();
|
||||||
|
rc |= test_http_response_serialize();
|
||||||
|
rc |= test_http_response_explicit_content_length_respected();
|
||||||
|
if (rc == 0)
|
||||||
|
std::cout << "ALL " << checks << " CHECKS PASSED" << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "SOME CHECKS FAILED (see above)" << std::endl;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,48 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "../JString.h"
|
||||||
|
#include "../JFile.h"
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
coreutils::JFile test1("jfile_test.data");
|
||||||
|
std::cout << test1 << std::endl;
|
||||||
|
|
||||||
|
test1["name"] = "Cohen";
|
||||||
|
|
||||||
|
std::cout << test1 << std::endl;
|
||||||
|
|
||||||
|
test1["health"] = "100";
|
||||||
|
test1["comment"] = "this is a comment";
|
||||||
|
test1["racex"] = "elvin";
|
||||||
|
test1["race"] = "human";
|
||||||
|
test1["array"] = "[\"test1\",\"test2\",\"test3\"]";
|
||||||
|
test1["tester"] = "test field";
|
||||||
|
test1["object1"] = "{\"attr1\":\"value1\",\"attr2\":\"value2\",\"attr3\":\"value3\"}";
|
||||||
|
test1["object1.attr2"] = "{\"xattr1\":\"xvalue1\",\"xattr2\":\"xvalue2\",\"xattr3\":\"xvalue3\"}";
|
||||||
|
test1["object1.attr3"] = "Im not an object";
|
||||||
|
// test1["age"] = 64; future
|
||||||
|
|
||||||
|
std::cout << test1 << std::endl;
|
||||||
|
|
||||||
|
std::cout << test1["name"] << std::endl;
|
||||||
|
std::cout << test1["health"] << std::endl;
|
||||||
|
std::cout << test1["comment"] << std::endl;
|
||||||
|
std::cout << test1["racex"] << std::endl;
|
||||||
|
std::cout << test1["race"] << std::endl;
|
||||||
|
std::cout << test1["array"] << std::endl;
|
||||||
|
std::cout << test1["tester"] << std::endl;
|
||||||
|
std::cout << test1["object1"] << std::endl;
|
||||||
|
std::cout << test1["object1.attr2"] << std::endl;
|
||||||
|
std::cout << test1["object1.attr2.xattr3"] << std::endl;
|
||||||
|
std::cout << test1["object1.attr3"] << std::endl;
|
||||||
|
std::cout << test1["array[0]"] << std::endl;
|
||||||
|
std::cout << test1["array[1]"] << std::endl;
|
||||||
|
std::cout << test1["array[2]"] << std::endl;
|
||||||
|
|
||||||
|
std::cout << test1.pretty() << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"name":"Cohen","health":"100","comment":"this is a comment","racex":"elvin","race":"human","array":["test1","test2","test3"],"tester":"test field","object1":{"attr1":"value1","attr2":{"xattr1":"xvalue1","xattr2":"xvalue2","xattr3":"xvalue3"},"attr3":"Im not an object"}}
|
||||||
Whitespace-only changes.
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "../MFile.h"
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
coreutils::MFile data("testdata.data");
|
||||||
|
std::cout << data << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../MString.h"
|
#include "../MString.h"
|
||||||
|
|
||||||
|
coreutils::ZString testcast(coreutils::ZString data) {
|
||||||
|
std::cout << "in proc: " << data << std::endl;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
// Literal string assignment tests.
|
// Literal string assignment tests.
|
||||||
@@ -109,6 +114,12 @@ int main(int argc, char **argv) {
|
|||||||
coreutils::MString test33 = test32.toBase64();
|
coreutils::MString test33 = test32.toBase64();
|
||||||
std::cout << test33 << " from base64 " << test33.fromBase64() << std::endl;
|
std::cout << test33 << " from base64 " << test33.fromBase64() << std::endl;
|
||||||
|
|
||||||
|
coreutils::ZString test34 = test31;
|
||||||
|
std::cout << test31 << " to zstring " << test34 << std::endl;
|
||||||
|
|
||||||
|
test34 = testcast(test31);
|
||||||
|
std::cout << test31 << " to zstring " << test34 << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
#include "../StreamReader.h"
|
||||||
|
#include "../LineParser.h"
|
||||||
|
#include "../IMFHeader.h"
|
||||||
|
#include "../IMFBoundary.h"
|
||||||
|
|
||||||
|
using namespace coreutils;
|
||||||
|
|
||||||
|
static int checks = 0;
|
||||||
|
#define CHECK(cond) do { checks++; if(!(cond)) { std::cerr << "FAIL line " << __LINE__ << ": " #cond << std::endl; return 1; } } while(0)
|
||||||
|
|
||||||
|
void feedStr(StreamReader &r, const char *s) {
|
||||||
|
ZString z((char *)s, strlen(s));
|
||||||
|
r.feed(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The whole point of StreamReader/Parser: a "line" (or header, or boundary)
|
||||||
|
// can arrive split across any number of socket packets, and parsing must
|
||||||
|
// resume cleanly from wherever it left off once more data shows up.
|
||||||
|
|
||||||
|
int test_lineparser_split_across_feeds() {
|
||||||
|
StreamReader reader;
|
||||||
|
feedStr(reader, "partial li");
|
||||||
|
LineParser lp(reader);
|
||||||
|
CHECK(lp.doParse() == Parser::Status::INCOMPLETE);
|
||||||
|
feedStr(reader, "ne\r\n");
|
||||||
|
CHECK(lp.doParse() == Parser::Status::COMPLETE);
|
||||||
|
ZString line = lp.getLine();
|
||||||
|
CHECK(line.getLength() == 12);
|
||||||
|
CHECK(strncmp(line.getData(), "partial line", 12) == 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_imfheader_folding_and_split_feeds() {
|
||||||
|
StreamReader reader;
|
||||||
|
IMFHeader header(reader);
|
||||||
|
feedStr(reader, "Subject: line one\r\n ");
|
||||||
|
CHECK(header.doParse() == Parser::Status::INCOMPLETE);
|
||||||
|
feedStr(reader, "line two\r\n\r\n");
|
||||||
|
CHECK(header.doParse() == Parser::Status::COMPLETE);
|
||||||
|
auto &fields = header.getHeaders();
|
||||||
|
CHECK(fields.size() == 1);
|
||||||
|
MString subj = fields[MString("Subject")];
|
||||||
|
CHECK(subj.getLength() == 17);
|
||||||
|
CHECK(strncmp(subj.getData(), "line one line two", subj.getLength()) == 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_imfboundary_split_across_feeds() {
|
||||||
|
ZString b((char *)"XYZ", 3);
|
||||||
|
StreamReader reader;
|
||||||
|
IMFBoundary bound(reader, b);
|
||||||
|
feedStr(reader, "\r\n--X");
|
||||||
|
CHECK(bound.doParse() == Parser::Status::INCOMPLETE);
|
||||||
|
feedStr(reader, "YZ--");
|
||||||
|
CHECK(bound.doParse() == Parser::Status::COMPLETE);
|
||||||
|
CHECK(bound.isLast() == true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int rc = 0;
|
||||||
|
rc |= test_lineparser_split_across_feeds();
|
||||||
|
rc |= test_imfheader_folding_and_split_feeds();
|
||||||
|
rc |= test_imfboundary_split_across_feeds();
|
||||||
|
if (rc == 0)
|
||||||
|
std::cout << "ALL " << checks << " CHECKS PASSED" << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "SOME CHECKS FAILED (see above)" << std::endl;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "../MFile.h"
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
coreutils::MFile data("testdata.data");
|
||||||
|
std::cout << data << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user