Compare commits

...
43 Commits
Author SHA1 Message Date
Brad Arant 29db853706 Fix CGIFormData to actually store file-upload part content
File-upload parts (Content-Disposition with filename=) were
unconditionally flagged currentSkip and discarded at PART_BOUNDARY,
so every <field type="file"> upload site (track audio, presets,
project icons) only ever received an empty value via $[fieldname],
never the real uploaded bytes.
2026-09-06 04:04:48 +00:00
Brad Arant 78c45d378c Fix File stat-before-open crash risk, JSON string-quoting bug, and MString buffer overflow
- File: stat() only after a successful open() (previously ran first with
  its result ignored, feeding a missing file's garbage st_size into a
  realloc - could crash the whole APIServer on a request for a
  nonexistent static asset)
- JString::setString(): always quote+escape the value instead of going
  through set()'s literal-value guess, which misclassified any string
  starting with digits (e.g. a UUID) as a bare numeric literal and wrote
  it unquoted, corrupting later edits to the same JSON document
- MString::remove() (both overloads): fixed an off-by-one that read one
  byte past the buffer on a completely full string (found via ASan under
  concurrent load)
- CGIFormData: added fields() so callers can iterate every parsed field
  without knowing names in advance (used to merge POST body into
  jet::Global::variables the same way query-string params already are)
2026-09-03 05:14:24 +00:00
Brad Arant d7057ebb00 Fix JFile to normalize whitespace when loading JSON from disk
JString::operator=(ZString) already stripped whitespace between JSON
structural tokens before parsing, but JFile constructed via MFile file-
loading bypassed that path entirely, so any pretty-printed/hand-edited
JSON file silently failed every locate()/exists()/get*() call. Widen
removeWhitespace() to protected and call it from JFile constructor.
2026-08-25 19:14:14 -07:00
Brad ArantandClaude Sonnet 5 6b188fbee5 Restore execute bit on testing/compile (lost via UNC-path edit)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-25 10:42:48 -07:00
Brad ArantandClaude Sonnet 5 cb845efe69 Add HTTPRequest/HTTPResponse: real HTTP parsing on the Parser/StreamReader stack
Stage 2 of the APIServer plan. This codebase has only ever sat behind a
CGI gateway - IMFRequest/IMFResponse/IMFMessage predate the
StreamReader/Parser rebuild and are stubs (IMFResponse's header-emission
calls addHeader()/output(), neither of which exist on the class;
IMFRequest is a fragile non-resumable 3-token line split). Nothing in
this repo has ever actually parsed a raw HTTP request off a socket.

HTTPRequest : public Parser fills that gap the same way every other
Parser here is built: REQUEST_LINE -> HEADERS -> BODY -> DONE, chaining
LineParser (request line) and IMFHeader (headers, reused as-is - HTTP
header syntax is IMF-derived, nothing email-specific in IMFHeader
itself) via checkParse() over one shared StreamReader, exactly the
pattern CGIFormData already established for chaining IMFHeader/
IMFBoundary. The BODY state dispatches on Content-Type as CGIFormData
itself does for CGI bodies - application/x-www-form-urlencoded and
multipart/form-data delegate directly to CGIFormData (reused, not
reimplemented), anything else is captured as a raw body (e.g. JSON).
Query string is split off the path before anything else sees it.
getHeader() does a case-insensitive lookup (HTTP header names are
case-insensitive per RFC 7230, unlike IMFHeader's own std::map, which
compares byte-for-byte) since a route handler constantly needs this and
getting it wrong would be a silent framing bug, not a cosmetic one.

The boundary-extraction code mirrors __jet.cpp's own fix exactly (same
cursor-mutation trap: ZString::find() leaves the searched string's
cursor at the match, and CGIFormData's constructor copy-constructs its
own contentType member from whatever's passed in, inheriting that same
moved cursor unless reset() first - would otherwise silently miss its
own startsWith() dispatch checks).

HTTPResponse is a small, new, output-only builder (status line + a real
headers container + body, Content-Length auto-computed unless set
explicitly) - deliberately not patched from IMFResponse, which has
nothing safe to extend.

v1 limitations, flagged not fixed (matching the standard already set by
other Parser subclasses here for known-but-out-of-scope gaps): chunked
Transfer-Encoding isn't supported, and repeated header names last-wins
(inherited from IMFHeader's own std::map).

Verified live via testing/http_test.cpp (34 assertions, new - now wired
into testing/compile): byte-at-a-time GET with a query string and
case-insensitive header lookup; a GET with no query string; a POST with
an urlencoded body deliberately split mid-body (not just mid-header)
across two feed() calls, confirming the CGIFormData delegation resumes
correctly; a raw JSON POST body; testing/http_request.data (a real
fixture, previously unused - normalized from its stored LF line endings
to real CRLF, since HTTP requires CRLF and IMFHeader enforces that
strictly) fed byte-at-a-time; and HTTPResponse::serialize() both with an
auto-computed and an explicitly-set Content-Length (no duplicate
header). Also reran the full existing testing/compile suite
(zstring/mstring/jstring/mfile/jfile) against the rebuilt libCoreUtils.a
to confirm no regression from the two new files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-25 10:42:34 -07:00
Brad ArantandClaude Sonnet 5 6e4e463a96 Fix MString assignment operators leaving cursor at its old (stale) offset
operator=(MString)/operator=(ZString)/operator=(std::string)/operator=(const
char*)/operator=(char) all replaced the buffer's content via setSize()+
memcpy() but never reset cursor back to the start - setSize() preserves
the *offset* the cursor was already at (correct for its own use, growing
a buffer while keeping a read position stable), so a full content
replacement left the cursor sitting at whatever offset it had into the
*previous* content, not the new content. operator=(double)/operator=(int)
already did `cursor = data;` after the same setSize()+memcpy() pattern,
confirming this was the intended behavior everywhere - just missing from
the other five overloads.

This is invisible to JetCore's interpreter, which never reassigns an
already-read-from MString (each tag is a freshly parsed C++ object every
time its container is scanned, so a keyword's MString is never both read
and then reassigned on the same instance). It surfaced in a prototype JET
compiler (JetCore/jetc) built this session, which intentionally reuses
one persistent keyword slot across loop iterations instead of
reconstructing everything from text every pass - exactly the case this
bug needed. A <while expr="..."> loop reusing a slot for its condition
worked for two iterations (matching a decoy pattern: the second
assignment happened to land the stale cursor at the exact end of the
new, same-length content) and threw "operand is not valid" on the third,
since a keyword reassigned inside the loop body left the cursor already
at eod() from the read.

Verified via jstring_test/mstring_test/zstring_test/parser_test (no
regressions), JetCore's tests/posttest.sh and the two-process JSON
session persistence test (no regressions), and the jetc prototype's two
demo templates - both now produce byte-identical output to jet-2.0's
interpreter, including a <while> loop that mutates and rereads the same
keyword slot every iteration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 19:18:17 -07:00
Brad ArantandClaude Sonnet 5 3e6e410fe8 Fix JFile empty-document seed and MString's ZString-source pointer/length mismatch
JFile.cpp: JFile and MFile both "virtual public MString" a single shared
base, so a virtual base is initialized only by the *most derived* class's
constructor. JFile's own constructor never mentions MString, so
JString's own "{}" default initializer never ran - a JFile backed by a
new or nonexistent file started as a raw empty string instead of a valid
empty JSON object. Every subsequent locate()/set() call then silently
misbehaved (no leading "{" for ifNext("{") to match, so writes landed at
offset 0 with no braces or separators - fields ended up prepended in
reverse order, concatenated with no delimiters at all). Fixed by seeding
"{}" via append (matching MFile's own load pattern) whenever the loaded
content is empty.

MString.cpp: several ZString-source copy paths (the ZString/MString copy
constructors, both assignment operators, operator<<(ZString), insert(),
write()) called zstring.getData() (the object's absolute start) paired
with zstring.getLength() (which is documented/implemented as "remaining
bytes from cursor to end", i.e. length - (cursor - data)). Pairing an
absolute start with a cursor-relative length silently corrupts any
cursor-advanced source: the copy starts from the wrong (too-early)
position but is truncated by exactly the amount the cursor had already
advanced, keeping unwanted leading bytes while dropping trailing ones.
Found via the CGIFormData-style resumability testing pattern used
elsewhere this session, triggered by JetCore's new "@name" session
variable feature stripping a sigil prefix via ifNext() before streaming
the remainder into an MString. Fixed by pairing zstring.getCursor()
(cursor-relative start) with zstring.getLength() consistently everywhere
this pattern appeared.

Verified via the existing jstring_test/mstring_test/zstring_test/
parser_test suites (all pass, no output changes) plus a new isolated
JFile round-trip test proving persistence across two separate process
instances sharing one file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 18:44:59 -07:00
Brad ArantandClaude Sonnet 5 5b6d4ea8ab Fix ambiguous MString << JString::Proxy overload resolution
JString::Proxy offers several implicit conversion operators (ZString,
MString, std::string, double, bool) so a single $[...]-style access can
be used wherever any of those types is expected. That flexibility made
"MString << Proxy" genuinely ambiguous: 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 had no basis to prefer one conversion path over another.

Fixed the same way Proxy already solves this exact problem for
std::cout << proxy - a dedicated friend operator<<(MString&, const
Proxy&) that needs no conversion at all, so it's always the preferred
candidate. Verified by actually running testing/jstring_test.cpp (not
just compiling it) - the line that used to fail to compile now correctly
prints "this is a test: this is a comment".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 15:11:56 -07:00
Brad ArantandClaude Sonnet 5 bf6810b781 Rebuild CGIFormData on Parser/StreamReader, fix a 2-byte-lookahead bug
CGIFormData now inherits Parser instead of MString and parses a CGI
request body (urlencoded or multipart/form-data) resumably against the
shared StreamReader, exposing the result via operator[] - matching every
other Parser in this redesign. multipart/form-data reuses IMFBoundary and
IMFHeader via checkParse() (chained through the same StreamReader) for
each part's boundary line and header block; urlencoded bodies wait for
the full Content-Length before delegating to the existing
CGIFormattedData parser. File-upload parts (Content-Disposition with a
filename= parameter) are recognized and skipped, matching this
codebase's convention that uploads get a separate mechanism.

Values are stored under an indexed "name:N" key (N = 0-based occurrence
count for that name), matching the :N-suffix convention JetCore's
Tag::getVariable already applies to its $[:name] CGI variable syntax
(defaulting to :0) - this also naturally supports repeated field names
(checkboxes, multi-select). operator[] applies the same :0 default so a
bare name still works when called directly, not just through that
convention layer.

Two real resumability bugs found and fixed via a byte-at-a-time test
(feeding one byte per StreamReader::feed() call, the harshest possible
fragmentation):
- CGIFormData's opening boundary marker ("--boundary", no leading CRLF
  per RFC 2046 for the first boundary) crammed "find+consume the marker"
  and "disambiguate -- vs CRLF" into one state; when the disambiguation
  needed more data, INCOMPLETE was returned without recording that the
  marker was already consumed, so retrying re-searched for it past where
  it had already been consumed, silently skipping content forever. Split
  into two states (INIT / OPENING_TAIL), the same fix already applied
  once to IMFBoundary's PREFIX/TAIL split.
- IMFHeader's FIELD state checked eod() (a 1-byte availability check)
  immediately before an ifNext("\r\n") call that needs 2 bytes - a lone
  trailing \r with no \n yet available was wrongly treated as malformed
  instead of "wait for more data". Fixed to check getLength() < 2.

Verified via a dedicated test (64 assertions total across this and the
earlier Parser/StreamReader test) covering urlencoded, multipart with a
skipped file upload, and the byte-at-a-time stress case - plus a real
end-to-end run through jet-2.0 with a simulated CGI multipart POST
request (see the matching JetCore commit).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 15:07:09 -07:00
Brad ArantandClaude Sonnet 5 a033cc6718 Add StreamReader and rebuild Parser/LineParser/IMFHeader/IMFBoundary on it
Introduces StreamReader to accumulate socket data delivered in arbitrary
chunks into one buffer, so a Parser can build an object (a line, a header
block, a MIME boundary) that spans any number of packets without losing
its place. Parser is redesigned around this: no longer inherits MString
(was redundant with its own buffer member), takes a StreamReader&, and
drives a resumable COMPLETE/INCOMPLETE/DATA_AVAIL state-machine protocol
via doParse(). LineParser, IMFHeader, and IMFBoundary are rewritten as
real, working resumable parsers against the shared buffer instead of the
previous non-compiling stubs (mismatched constructors/return types, a
syntax error, checkParse() never implemented).

IMFFormData is left as the stub it already was, just restored to
compiling against the new IMFHeader signature - fully wiring it up needs
IMFMultipart/IMFText migrated to StreamReader too, out of scope here.

Verified with real runtime tests (not just compilation) covering data
split mid-line, mid-CRLF, mid-header-fold, and mid-boundary-marker across
separate feed() calls, plus StreamReader::compact(). Along the way fixed
a header-value bug (space after ':' wasn't skipped) and a double
cursor-offset subtraction bug in two places caused by forgetting that
ZString::getLength() is already cursor-relative, not the raw buffer size.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 14:25:58 -07:00
Brad ArantandClaude Sonnet 5 94d4a30e88 Fix CGI form/cookie data handling and CGI URL encode/decode
- CGIFormData: fix broken setSize()+read() double-length bug that
  corrupted every parsed body with a leading run of garbage bytes
  (setSize(contentLength) pre-set length before read()/write()
  appended on top of it); switch content-type checks from exact
  equality to startsWith() since a real multipart Content-Type
  always carries a boundary= parameter; implement the previously
  empty multipart/form-data branch (ordinary fields only, file
  uploads deferred to a separate upload mechanism per TODO.txt);
  restore operator[] real lookup logic (was hardcoded to echo the
  key back); default-initialize formdata to NULL; fix mismatched
  include guard (leftover from an IMFFormData.h copy-paste); drop
  the unused IMFHeader.h include that pulled in a broken,
  unrelated StreamReader.h dependency.
- CGIFormattedData: parameterize the split delimiter (was hardcoded
  to &, which silently broke cookie parsing since HTTP_COOKIE uses
  ; not &) and trim whitespace on each split token.
- MString::toCGI()/fromCGI(): were unimplemented stubs (always
  returned an empty string); implemented proper CGI percent-encode
  / percent-decode + space plus-encoding, and fixed the one caller
  that discarded fromCGIs return value instead of using it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 21:37:10 -07:00
Brad Arant 28feaff3d7 Rewrite JString for real JSON compliance
The previous implementation was a narrow path-accessor, not a JSON parser:
numbers/booleans/null were unhandled entirely (self-acknowledged by a
// TODO: Handle numbers... comment), string escape sequences were never
encoded or decoded, updating an existing non-string-valued key threw a
hard-coded Fix me exception, and skipping past an uninteresting key threw
Unrecognized data type for anything but string/array/object. Full
analysis given to the user before this rewrite; nothing here was guessed.

Added:
- JSONType enum + getType()/exists()/isNull() for type introspection.
- Typed read access: getString() (escape-decoded), getNumber(), getInt(),
  getBool() - each validates the value at the path is actually that type.
- Typed write access: setString() (escapes automatically), setNumber(),
  setInt(), setBool(), setNull() - and Proxy operator= overloads for
  double/int/long/bool so  produces a real JSON number, not
  a quoted string the way the old single MString-typed operator= did.
- jsonEscape()/jsonUnescape(): full escape codec including \uXXXX and
  UTF-16 surrogate pairs (astral characters, e.g. emoji) decoded to
  correct UTF-8.
- skipValue()/skipString()/skipContainer()/skipNumber() and their
  capture (span-returning) counterparts: escape-aware structural
  skipping, so a string value containing a literal { } [ ] , or : can
  no longer desync object/array nesting depth - this affected both
  locate()s internal key-skipping and find()s array/object extraction
  (the latter still relied on the base ZString::getContainer(), which
  has this exact bug and was not touched - see the ZString commit in
  this same session - so a JString-specific escape-aware capture was
  added instead of depending on it for this purpose).
- set() rewritten to use skipValue() to correctly locate and replace an
  EXISTING values full span regardless of its current type, instead of
  only handling the case where the existing value was already a quoted
  string.

Bugs found and fixed along the way, surfaced by writing real tests
against realistic JSON rather than just getting it to compile:
- The array-index-then-further-path case (e.g. b[2].c) always returned
  true immediately after reaching the index, so any path segment past
  the index was silently ignored - dead code after an unconditional
  return/throw meant the intended continuation logic could never run.
- The array selector syntax (label[key=value]) was only reachable as a
  top-level special case, never as part of a normal nested path (e.g.
  items[id=x].val) - unified both under the same bracket handling.
- Once reachable, the selector-match subkey check (find(key) on each
  array element) always searched from the document root, not the
  current array element, because find() unconditionally calls reset().
  Split into public find() (resets) and internal findRelative() (does
  not), and pointed both selector-matching call sites at the latter.
- path[0].getTokenExclude(...) in the array-selector path parser
  indexed into a list vector that split() never populated - undefined
  behavior. Removed the erroneous [0].

Verified via a dedicated test program (not included in this commit)
covering: string escape round-trip, numbers, booleans, null, exists(),
\uXXXX including a real surrogate pair decoded to correct 4-byte UTF-8,
nested dotted+bracketed navigation, a string value containing every
structural JSON character, replacing an existing key with a different
type, multi-key documents, pretty() not corrupting structural characters
inside a string, and the array selector syntax on both a matching first
and second element - 30/30 assertions pass. Full CoreUtils compile pass
unchanged apart from JString.cpp itself now succeeding (14/20 clean, same
7 pre-existing StreamReader.h-blocked failures as always, nothing new
broken).
2026-08-22 20:53:54 -07:00
Brad Arant 14697e2af2 Fix three real bugs found during a full ZString review
operator< computed end2 as valuex.getData() + valuex.getLength() - mixing
an absolute pointer (getData(), the buffer start) with a cursor-relative
length (getLength(), remaining-from-cursor). For any ZString with a
non-zero cursor offset this produces an end pointer short of the true
buffer end by exactly the amount already consumed, truncating the
comparison early. Fixed to use valuex.data + valuex.length (the true
end), matching how end1 was already computed for *this. operator<=,
>=, and > were separately broken (flagged by the codes own TODO
comment) - they compared via strncmp from data (ignoring cursor
entirely), inconsistent with operator< and with each other. Replaced
all three with derivations from the now-correct operator< (a <= b is
!(b < a), etc.) - guarantees trichotomy by construction instead of
three independently-written comparison loops.

substring(start, len): when the requested length overran the buffer,
computed newlen as endChar - end (the overrun amount) instead of
end - startChar (the actual remaining valid length) - backwards, and
stored into a char (max 127), silently wrapping for longer strings.
Fixed the formula and widened to size_t.

trimCRLF(): read *(data + length - 1) unconditionally, including when
length is already 0 - one byte before the buffer on an empty string.
Guarded both checks on length > 0.

Verified: full local compile (identical result to before - 13/20 clean,
same pre-existing StreamReader.h-blocked failures, nothing new broken);
a dedicated runtime test exercising all three fixes plus a trichotomy
check across multiple cursor offsets - all 13 assertions pass. Test
file not included in this commit.
2026-08-22 20:11:13 -07:00
Brad Arant 4082e82466 Fix Exception default file/line always reporting Exception.h itself
__FILE__/__LINE__ are preprocessor macros - as default argument values
in the header they expand once, at the header declaration site, not at
each call site. Every throw relying on the defaults (all but File.cpp,
which passed them explicitly) reported Exception.h itself instead of
the real error location.

Switched the defaults to std::source_location::current(), which the
C++20 standard specifically defines to evaluate at the call site when
used as a default argument - unlike macros. Kept the same 4-parameter
signature so every existing call site, including ones that pass
__FILE__/__LINE__ explicitly, is unaffected.

Verified two ways: full-repo compile pass (identical result to before,
13/20 clean, same pre-existing StreamReader.h-blocked failures, nothing
new broken); a real runtime test - a throw relying on defaults from a
known line correctly reported that exact file/line via the caught
exceptions .file/.line members. Test file not included in this commit.
2026-08-22 19:52:44 -07:00
Brad Arant 29c9a5b855 Fix MString::fromHex() silently swallowing the odd-length-input error
The Exception on the odd-length-input path was constructed but never
thrown (missing throw keyword) - the temporary was destroyed with no
effect, so execution fell through to an out-of-bounds nextChar() read
past the exhausted buffer instead of raising an error. Added the
missing throw.

Verified via full local compile: MString.cpp builds clean standalone;
a full-repo pass shows only the pre-existing, already-known
StreamReader.h-missing failures (7 files, unrelated to this change),
confirmed via each error log individually.
2026-08-22 19:52:35 -07:00
Brad Arant ba85c5f2e5 Still parsing work. 2026-01-05 16:49:41 -08:00
Brad Arant d79697775b Continued work on parsing... 2025-12-31 16:56:00 -08:00
Brad Arant b5652e26cc Still working out parsing buffer stuff. 2025-12-29 16:09:57 -08:00
Brad Arant d415e0abd3 Still working out parsing buffer stuff. 2025-12-18 15:40:37 -08:00
Brad Arant ccfab5aecf Still working out parsing buffer stuff. 2025-12-17 17:07:14 -08:00
Brad Arant 0243468d44 Continued work on Parser. 2025-12-16 16:51:44 -08:00
Brad Arant d54aec1f06 Beginning parser work. 2025-12-15 16:53:49 -08:00
Brad Arant 1542fbe218 Still working out cgi variable stuff. 2025-12-10 16:47:53 -08:00
Brad Arant ab748802ee JFile seems to work well now. 2025-12-09 08:46:33 -08:00
Brad Arant ffa3361fd2 CGIFormData work in progress. 2025-12-08 16:35:15 -08:00
Brad Arant 4988f98223 Started work on JFile. 2025-12-04 17:04:55 -08:00
Brad Arant 829dc1a3c7 Fixed MString and MFile. 2025-12-04 16:40:11 -08:00
Brad Arant 11d6f00bfb Allow - to trigger the number check. 2025-11-25 15:28:31 -08:00
Brad Arant 72c1286053 MFile stuff. 2025-06-20 00:42:24 +00:00
brad Arant a87ce0bab7 JSON file changes 2025-05-17 20:47:09 -07:00
Brad Arant 9cd8381845 significant work on cookies and cgi formdata variables. 2025-03-18 16:46:20 -07:00
Brad Arant bd5223ca36 more cgi processing multiform work. 2025-03-17 16:45:34 -07:00
brad Arant b774e50b59 more session work. 2025-03-17 07:45:02 -07:00
Brad Arant a3d5a4f93f more smartbuffer work. 2025-03-12 09:30:56 -07:00
Brad Arant 2866056072 more IMF work. 2025-03-11 16:59:16 -07:00
brad Arant fd7a9ed860 some smart buffer work. 2025-03-11 07:34:17 -07:00
brad Arant f35fa12902 Merge branch 'develop' of ssh://barant.com/git/CoreUtils into develop 2025-03-07 12:40:56 -08:00
Brad Arant 96f5c02435 Merge branch 'develop' of ssh://barant.com/git/CoreUtils into develop 2025-03-06 14:53:56 -08:00
Brad Arant 25916051e6 added CGIFormattedData object. 2025-03-06 14:47:57 -08:00
brad Arant 11f396a749 worked on IMF smartbuffers. 2025-02-21 13:22:57 -08:00
brad Arant 3f0a541e80 added byte count limiter for read on MString. 2025-02-14 11:56:11 -08:00
Brad Arant 5e6d162a05 added b64 encode/decode to MString. 2025-02-06 14:34:11 -08:00
Brad Arant d1c450fe48 added logic for toupper and tolower on MString. 2025-02-04 15:43:17 -08:00
92 changed files with 2749 additions and 3282 deletions

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ build/
.history/
testing/mstring_test
testing/zstring_test
testing/http_test
Binary file not shown.
Binary file not shown.
+24 -22
View File
@@ -12,9 +12,12 @@ namespace coreutils {
return (isalnum(c) || (c == '+') || (c == '/'));
}
std::string Base64::encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
std::string ret;
MString Base64::encode(ZString data) {
data.push();
data.reset();
MString ret;
int in_len = data.getLength();
int i = 0;
int j = 0;
unsigned char char_array_3[3];
@@ -22,7 +25,7 @@ namespace coreutils {
while (in_len--) {
char_array_3[i++] = *(bytes_to_encode++);
char_array_3[i++] = data.nextChar();
if (i == 3) {
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
@@ -31,10 +34,9 @@ namespace coreutils {
char_array_4[3] = char_array_3[2] & 0x3f;
for(i = 0; (i <4) ; i++)
ret += base64_chars[char_array_4[i]];
ret.write(base64_chars[char_array_4[i]]);
i = 0;
}
}
}
if (i) {
@@ -47,29 +49,28 @@ namespace coreutils {
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
for (j = 0; (j < i + 1); j++)
ret += base64_chars[char_array_4[j]];
ret.write(base64_chars[char_array_4[j]]);
while((i++ < 3))
ret += '=';
ret.write('=');
}
data.pop();
return ret;
}
std::string Base64::decode(std::string const& encoded_string) {
int in_len = encoded_string.size();
MString Base64::decode(ZString b64data) {
b64data.push();
b64data.reset();
int in_len = b64data.getLength();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::string ret;
MString ret;
while (in_len-- && ( encoded_string[in_] != '=') && isBase64(encoded_string[in_])) {
while (in_len-- && (b64data.getChar() != '=') && isBase64(b64data.getChar())) {
char_array_4[i++] = encoded_string[in_]; in_++;
char_array_4[i++] = b64data.nextChar();
if (i ==4) {
for (i = 0; i <4; i++)
@@ -80,7 +81,7 @@ namespace coreutils {
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (i = 0; (i < 3); i++)
ret += char_array_3[i];
ret.write(char_array_3[i]);
i = 0;
}
@@ -94,9 +95,10 @@ namespace coreutils {
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
for (j = 0; (j < i - 1); j++)
ret.write(char_array_3[j]);
}
b64data.pop();
return ret;
}
+6 -4
View File
@@ -1,20 +1,22 @@
#ifndef __Base64_h__
#define __Base64_h__
#include <string>
#include "ZString.h"
#include "MString.h"
namespace coreutils {
///
///
/// Use the Base64 object when you need to translate character string
/// to/from base64 encoded strings.
///
class Base64 {
public:
bool isBase64(unsigned char c);
std::string encode(unsigned char const* bytes_to_encode, unsigned int in_len);
std::string decode(std::string const& encoded_string);
MString encode(ZString data);
MString decode(ZString b64data);
};
+173
View File
@@ -0,0 +1,173 @@
#include "CGIFormData.h"
#include "CGIFormattedData.h"
#include "Exception.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();
int pos = buffer.find(marker);
if (pos < 0)
return Status::INCOMPLETE;
char *bodyEnd = buffer.getCursor();
// 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];
}
}
+82
View File
@@ -0,0 +1,82 @@
#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;
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
+36
View File
@@ -0,0 +1,36 @@
#include "CGIFormattedData.h"
#include "ZString.h"
namespace coreutils {
CGIFormattedData::CGIFormattedData() {}
CGIFormattedData::CGIFormattedData(ZString cgiData) {
parse(cgiData);
}
CGIFormattedData::CGIFormattedData(ZString cgiData, ZString delimiter) : delimiter(delimiter) {
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) {
parse(cgiData);
return cgiData;
}
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef __CGIFormattedData_h__
# define __CGIFormattedData_h__
# include "MString.h"
# include <map>
namespace coreutils {
///
/// Use the CGIFormattedData object to store and process data that
/// interfaces to the CGI format. Value pairs are accessible using
/// a common map interface.
///
class CGIFormattedData {
public:
CGIFormattedData();
CGIFormattedData(ZString cgiData);
CGIFormattedData(ZString cgiData, ZString delimiter);
ZString operator=(ZString cgiData);
void setDelimiter(ZString delimiter);
std::map<MString, MString> data;
private:
void parse(ZString cgiData);
ZString delimiter = "&";
};
}
#endif
-372
View File
@@ -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
-76
View File
@@ -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 "")
-88
View File
@@ -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.
-15
View File
@@ -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})
-463
View File
@@ -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: []
-100
View File
@@ -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
-
-20
View File
@@ -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 "")
-99
View File
@@ -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"
)
-10
View File
@@ -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
-10
View File
@@ -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
-10
View File
@@ -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 =
-2
View File
@@ -1,2 +0,0 @@
/usr/bin/ar qc libCoreUtils.a CMakeFiles/CoreUtils.dir/ZString.cpp.o
/usr/bin/ranlib libCoreUtils.a
-3
View File
@@ -1,3 +0,0 @@
CMAKE_PROGRESS_1 = 1
CMAKE_PROGRESS_2 = 2
-49
View File
@@ -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"
)
-106
View File
@@ -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
View File
@@ -1 +0,0 @@
empty
-1
View File
@@ -1 +0,0 @@
2
-3
View File
@@ -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
View File
@@ -1 +0,0 @@
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
-1
View File
@@ -1 +0,0 @@
2
-2
View File
@@ -1,2 +0,0 @@
project(CoreUtils)
add_library(CoreUtils STATIC target_sources_local())
+15 -1
View File
@@ -4,6 +4,7 @@
#include <string.h>
#include <string>
#include <errno.h>
#include <source_location>
namespace coreutils {
@@ -15,7 +16,20 @@ namespace coreutils {
class Exception {
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 file;
+20 -5
View File
@@ -17,19 +17,34 @@ namespace coreutils {
this->fileName = fileName;
struct stat status;
stat(fileName.c_str(), &status);
buffer = NULL;
setBufferSize(status.st_size);
fd = ::open(fileName.c_str(), mode, authority);
if(fd < 0) {
std::stringstream temp;
temp << "Error opening file " << fileName << ".";
throw Exception(temp.str(), __FILE__, __LINE__);
}
// 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() {
+127
View File
@@ -0,0 +1,127 @@
#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;
{
ZString line = lineParser->getLine();
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]);
}
delete lineParser;
lineParser = NULL;
{
// 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);
if (!checkParse(*headerParser))
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();
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
View File
@@ -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
+53
View File
@@ -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;
}
}
+51
View File
@@ -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
+49
View File
@@ -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;
}
}
+46
View File
@@ -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
View File
@@ -1,21 +1,18 @@
#include "IMFFormData.h"
#include "IMFMessage.h"
#include "IMFPlainText.h"
#include "IMFText.h"
namespace coreutils {
IMFFormData::IMFFormData() {}
IMFFormData::IMFFormData(ZString &in, ZString &boundary) : IMFMultipart(in, boundary) {}
ZString IMFFormData::getByName(ZString &name) {
for(ZString section: sections) {
IMFMessage message(section);
if(message.getHeaderKeyPairValue("Content-Disposition", ("name")).equals(name)) {
return message.multipart;
}
}
return ZString();
IMFFormData::IMFFormData(int fd, ZString boundary) {
// TODO: IMFHeader now reads through a StreamReader (see the Parser/
// StreamReader redesign) instead of a raw fd. This constructor - and
// IMFMultipart, which still constructs IMFFormData from a bare fd -
// needs migrating to StreamReader together before header parsing can
// be wired back in here. Out of scope for that redesign pass; this
// class was already an unfinished stub (constructed objects were
// discarded, nothing was stored) before this change.
IMFText text(fd, boundary);
}
}
+3 -8
View File
@@ -1,22 +1,17 @@
#ifndef __IMFFormData_h__
# define __IMFFormData_h__
# include "IMFMultipart.h"
#include "ZString.h"
namespace coreutils {
class IMFFormData: public IMFMultipart {
class IMFFormData {
public:
IMFFormData();
IMFFormData(ZString &in, ZString &boundary);
ZString getByName(ZString &name);
IMFFormData(int fd, ZString boundary);
};
}
#endif
+69 -25
View File
@@ -1,37 +1,81 @@
#include "IMFHeader.h"
#include "Exception.h"
#include "Log.h"
#include <iostream>
namespace coreutils {
IMFHeader::IMFHeader(ZString &in) : ZString(in) {
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;
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;
}
else if(in.skipWhitespace() > 0) {}
else if(in.str() == "") {}
throw coreutils::Exception("IMFHeader: unreachable state.");
}
IMFHeader::IMFHeader(ZString key, ZString value) : ZString(), key(key), value(value) {}
ZString IMFHeader::getKey() {
return key;
void IMFHeader::commitField() {
headers[name] = field;
name = MString();
field = MString();
}
ZString IMFHeader::getValue() {
return value;
std::map<MString, MString> &IMFHeader::getHeaders() {
return headers;
}
void IMFHeader::output(std::stringstream &out) {
out << key << ": " << value << "\r\n";
}
}
}
+33 -11
View File
@@ -1,25 +1,47 @@
#ifndef __IMFHeader_h__
#define __IMFHeader_h__
# define __IMFHeader_h__
#include "ZString.h"
#include <sstream>
# include "Parser.h"
# include "MString.h"
# include <map>
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:
IMFHeader(ZString &in);
IMFHeader(ZString key, ZString value);
ZString getKey();
ZString getValue();
IMFHeader(StreamReader &reader);
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:
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();
};
+33
View File
@@ -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);
}
}
+21
View File
@@ -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
View File
@@ -1,87 +1,12 @@
#include "IMFMessage.h"
#include "IMFHeader.h"
#include "IMFMultipart.h"
#include "IMFPlainText.h"
#include "IMFText.h"
#include "Log.h"
namespace coreutils {
IMFMessage::IMFMessage() : ZString() {}
IMFMessage::IMFMessage(ZString &in) : ZString(in) {
while (!in.ifNext("\r\n") && in.ifNext("\n"))
headers.emplace_back(in);
ZString type = getHeader("Content-Type");
int len = getHeader("Content-Length").asInteger();
if(len > 0) {
block = in.readBlock(len);
if(type.equals("multipart/form-data")) {
ZString boundary(getHeaderKeyPairValue("Content-Type", "boundary"));
multipart = IMFMultipart(block, boundary);
}
}
}
IMFMessage::IMFMessage(int fd) {}
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
View File
@@ -15,28 +15,21 @@ namespace coreutils {
///
///
class IMFMessage : public ZString {
class IMFMessage {
public:
IMFMessage();
IMFMessage(ZString &in);
IMFMessage(int fd);
virtual ~IMFMessage();
void output(std::stringstream &out);
// void output(std::stringstream &out);
void addHeader(IMFHeader header);
ZString getHeader(ZString key, bool valueOnly = true);
ZString getHeaderKeyPairValue(const char *headerKey, const char *key);
ZString getHeaderKeyPairValue(ZString headerKey, ZString key);
IMFMultipart multipart;
ZString block;
char contentLength[8];
// IMFMultipart multipart;
// ZString block;
// char contentLength[8];
protected:
std::vector<IMFHeader> headers;
std::stringstream newHeaders;
// std::vector<IMFHeader> headers;
// std::stringstream newHeaders;
};
+29 -27
View File
@@ -1,35 +1,37 @@
#include "IMFMultipart.h"
#include "Log.h"
#include "Exception.h"
#include <unistd.h>
namespace coreutils {
IMFMultipart::IMFMultipart() {}
IMFMultipart::IMFMultipart(ZString &in, ZString &boundary) {
Log(LOG_DEBUG_1) << in;
std::stringstream temp;
temp << "--" << boundary;
sections = in.split(temp.str().c_str());
for(int ix = 0; ix < sections.size(); ++ix) {
sections[ix].ifNext("\r\n");
sections[ix].trimCRLF();
Log(LOG_DEBUG_1) << "[" << sections[ix] << "].";
if(sections[ix].equals("--"))
sections[ix] = ZString("");
sections[ix].ifNext("\r\n");
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);
rc = ::read(fd, &ch, 1);
if(ch == '-') {
rc = ::read(fd, &ch, 1);
if(ch == '-') {
break;
}
} else if(ch == '\r') {
rc = ::read(fd, &ch, 1);
if(ch != '\n')
coreutils::Exception("expecting '\n' in data stream.");
}
}
}
std::string IMFMultipart::toString() {
return std::string(getData(), getLength());
}
int IMFMultipart::getCount() {
return sections.size();
}
ZString IMFMultipart::getSectionAt(int index) {
return sections[index];
}
}
+8 -13
View File
@@ -1,26 +1,21 @@
#ifndef __IMFMultipart_h__
#define __IMFMultipart_h__
#include "ZString.h"
#include "MString.h"
#include "IMFFormData.h"
#include <vector>
namespace coreutils {
class IMFMultipart: public ZString {
class IMFMultipart {
public:
IMFMultipart();
IMFMultipart(ZString &in, ZString &boundary);
std::string toString();
int getCount();
ZString getSectionAt(int index);
protected:
std::vector<ZString> sections;
IMFMultipart(int fd, MString boundary);
private:
char *boundary;
MString boundary;
std::vector<IMFFormData> sections;
};
}
-10
View File
@@ -1,10 +0,0 @@
#include "IMFPlainText.h"
namespace coreutils {
IMFPlainText::IMFPlainText() {
}
IMFPlainText::IMFPlainText(ZString &in) : ZString(in.str().c_str()) {}
}
-18
View File
@@ -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
View File
@@ -18,14 +18,14 @@ namespace coreutils {
if(mode == LENGTH) {
sprintf(contentLength, "%li", content.str().length());
ZString conlen(contentLength);
addHeader(IMFHeader("Content-Length", conlen));
// addHeader(IMFHeader("Content-Length", conlen));
}
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();
return response;
}
+2 -1
View File
@@ -14,7 +14,7 @@ namespace coreutils {
/// and responses as the main communications protocol.
///
class IMFResponse : public IMFMessage {
class IMFResponse {
public:
@@ -87,6 +87,7 @@ namespace coreutils {
ZString code;
ZString text;
char contentLength[32];
const char *CRLF = "\r\n";
};
+27
View File
@@ -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);
}
}
}
+18
View File
@@ -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
+37
View File
@@ -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();
}
}
}
+25
View File
@@ -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
View File
@@ -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
+551 -135
View File
@@ -1,5 +1,7 @@
#include "JString.h"
#include "Exception.h"
#include <cstdio>
#include <cstdlib>
namespace coreutils {
@@ -9,161 +11,558 @@ namespace coreutils {
os << temp;
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("{}") {}
void JString::set(ZString &path, ZString &value) {
reset();
if(locate(path)) {
push();
if(ifNext("\"")) {
ZString old = getTokenExclude("\"");
pop();
remove(offset(), old.getLength() + 2);
MString key;
if(value.startsWith("["))
key << value;
else if(value.startsWith("{"))
key << value;
else
key << "\"" << value << "\"";
insert(key, offset());
} else {
pop();
throw coreutils::Exception("Fix me to accept integer type.");
// ---------------------------------------------------------------------
// Structural helpers - escape/type aware skipping so JSON-significant
// characters (", {, }, [, ]) appearing inside string literals never
// desync the parse position.
// ---------------------------------------------------------------------
JSONType JString::typeAtCursor() {
if (startsWith("\""))
return JSONType::STRING;
if (startsWith("{"))
return JSONType::OBJECT;
if (startsWith("["))
return JSONType::ARRAY;
if (startsWith("true") || startsWith("false"))
return JSONType::BOOLEAN;
if (startsWith("null"))
return JSONType::JNULL;
if (startsWithNumber())
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 {
// std::cout << "[" << unparsed() << "] >" << value << "<" << std::endl;
MString key;
if(notfirst)
key << ",";
// TODO: The value added must be parsed down to remove all whitespace.
if(value.startsWith("["))
key << "\"" << path << "\":" << value;
else if(value.startsWith("{"))
key << "\"" << path << "\":" << value;
else
key << "\"" << path << "\":" << "\"" << value << "\"";
insert(key, offset());
if (ch == '"') {
ZString result(start, getCursor() - start);
nextChar();
return result;
}
nextChar();
}
throw coreutils::Exception("Unterminated JSON string.");
}
void JString::skipString() {
captureString();
}
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) {
reset();
if(locate(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();
return findRelative(path);
}
// 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) {
// std::cout << "path locate: " << path << std::endl;
path.getTokenExclude("[.");
notfirst = false;
if(ifNext("{")) {
while(startsWith("\"")) {
if (ifNext("{")) {
while (startsWith("\"")) {
notfirst = true;
ZString label;
ZString value;
if(ifNext("\"")) {
label = getTokenExclude("\"");
ifNext("\"");
} else
throw coreutils::Exception("Labels must be contained in double quotes.");
if(ifNext(":")) {
// std::cout << "path: (" << path.parsed() << ") (" << label << ") " << (label == path.parsed()) << std::endl;
if(label == path.parsed()) {
if(path.unparsed() == "") {
// std::cout << "found cursor: " << unparsed() << std::endl;
ZString label;
if (ifNext("\"")) {
label = getTokenExclude("\"");
ifNext("\"");
} else
throw coreutils::Exception("Labels must be contained in double quotes.");
if (ifNext(":")) {
if (label == path.parsed()) {
if (path.unparsed() == "") {
return true;
}
if(path.ifNext("."))
if (path.ifNext("."))
return locate(path.unparsed());
if(path.ifNext("[")) {
int index = path.asInteger();
if(!path.ifNext("]"))
throw coreutils::Exception("expecting ] after index value in array selector.");
if(ifNext("[")) {
while(index > 0) {
getContainer();
if(!ifNext(","))
if (path.ifNext("[")) {
bool found = true;
if (path.startsWithNumber()) {
// Numeric index: label[N]
int index = path.asInteger();
if (!path.ifNext("]"))
throw coreutils::Exception("expecting ] after index value in array selector.");
if (!ifNext("["))
throw coreutils::Exception("Path is expecting an array for selector value.");
while (index > 0) {
skipValue();
if (!ifNext(","))
throw coreutils::Exception("expecting comma to seperate array elements.");
--index;
}
return true;
} else
throw coreutils::Exception("Path is expecting an array for selector value.");
if(path.eod())
}
} else {
// Selector: label[key=value] - find the array element whose subkey
// matches the given value.
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;
else if(path.ifNext("."))
if (path.eod())
return true;
if (path.ifNext("."))
return locate(path.unparsed());
throw coreutils::Exception("expecting '.' in path.");
}
}
// std::cout << "+++" << unparsed() << std::endl;
if(startsWith("\"")) {
getContainer();
} else if(startsWith("[")) {
getContainer();
} else if(startsWith("{")) {
getContainer();
} else {
throw coreutils::Exception("Unrecognized data type.");
}
ifNext(",");
} else
throw coreutils::Exception("Expected colon after label.");
}
} else if(ifNext("[")) {
ZString label = path[0].getTokenExclude("[");
path.ifNext("[");
ZString key = path[0].getTokenExclude("=");
path.ifNext("=");
ZString value = path[0].getTokenExclude("]");
while(!ifNext("]")) {
push();
ZString check = find(key);
pop();
if(check.equals(value)) {
return locate(label);
} else {
getContainer();
ifNext(",");
}
}
}
}
skipValue();
ifNext(",");
} else
throw coreutils::Exception("Expected colon after label.");
}
} else if (ifNext("[")) {
ZString label = path.getTokenExclude("[");
path.ifNext("[");
ZString key = path.getTokenExclude("=");
path.ifNext("=");
ZString value = path.getTokenExclude("]");
while (!ifNext("]")) {
push();
ZString check = findRelative(key);
pop();
if (check.equals(value)) {
return locate(label);
} else {
skipValue();
ifNext(",");
}
}
}
// std::cout << "not found cursor: " << unparsed() << std::endl;
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) {
setSize(value.getLength());
memcpy(data, value.getData(), value.getLength());
removeWhitespace();
return *this;
}
void JString::removeWhitespace() {
reset();
while(!eod()) {
if(*cursor == ' ')
while (!eod()) {
if (*cursor == ' ')
remove(1);
else if(*cursor == '\r')
else if (*cursor == '\r')
remove(1);
else if(*cursor == '\t')
else if (*cursor == '\t')
remove(1);
else if(*cursor == '\n')
else if (*cursor == '\n')
remove(1);
else if(startsWith("\""))
getContainer();
else if (startsWith("\""))
skipString();
else
++cursor;
}
@@ -175,48 +574,65 @@ namespace coreutils {
reset();
char ch;
int index = 0;
while(!eod()) {
while (!eod()) {
ch = nextChar();
if(ch == '{') {
if (ch == '{') {
index += 3;
output << ch << '\n';
for(int ix = 0; ix < index; ++ix)
for (int ix = 0; ix < index; ++ix)
output << ' ';
}
else if(ch == '[') {
else if (ch == '[') {
index += 3;
output << ch << '\n';
for(int ix = 0; ix < index; ++ix)
for (int ix = 0; ix < index; ++ix)
output << ' ';
}
else if(ch == ':') {
else if (ch == ':') {
output << ": ";
}
else if(ch == '}') {
}
else if (ch == '}') {
index -= 3;
output << '\n';
for(int ix = 0; ix < index; ++ix)
for (int ix = 0; ix < index; ++ix)
output << ' ';
output << ch;
}
else if(ch == ']') {
}
else if (ch == ']') {
index -= 3;
output << '\n';
for(int ix = 0; ix < index; ++ix)
for (int ix = 0; ix < index; ++ix)
output << ' ';
output << ch;
}
else if(ch == ',') {
}
else if (ch == ',') {
output << ch << '\n';
for(int ix = 0; ix < index; ++ix)
for (int ix = 0; ix < index; ++ix)
output << ' ';
}
else
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
output << ch;
}
return output;
return output;
}
void JString::changed(ZString key, ZString value) {}
}
+162 -16
View File
@@ -14,7 +14,7 @@ namespace coreutils {
/// access the objects elements using a named path as the index to the items.
///
/// 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
/// initial JSON string.
@@ -22,32 +22,94 @@ namespace coreutils {
/// Several constructors are available including a handle to a std::FILE
/// 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.
/// Use:
/// jstring["key"] = "value";
/// std::cout << jstring["key"];
/// The [] operator can be used to access elements within the JSON string.
/// Assigning a value dispatches on the C++ type of the right-hand side, so the
/// resulting JSON is correctly typed rather than always being a quoted string:
///
/// 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:
JString();
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
/// 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);
bool locate(ZString path);
bool notfirst;
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 {
public:
@@ -55,6 +117,23 @@ namespace coreutils {
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 () {
return jstring.find(key);
}
@@ -64,15 +143,53 @@ namespace coreutils {
}
operator std::string () {
return jstring.find(key).str();
return jstring.getString(key);
}
Proxy& operator=(coreutils::MString value) {
jstring.set(key, value);
operator double () {
return jstring.getNumber(key);
}
operator bool () {
return jstring.getBool(key);
}
Proxy& operator=(coreutils::MString value) {
jstring.setString(key, value.str());
jstring.changed(key, value);
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:
JString &jstring;
ZString key;
@@ -81,16 +198,45 @@ namespace coreutils {
Proxy operator[](coreutils::ZString key) {
return Proxy(*this, key);
}
JString & operator=(coreutils:: ZString value);
MString pretty();
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();
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);
};
}
+26
View File
@@ -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;
}
}
+42
View File
@@ -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
+23
View File
@@ -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();
}
}
+35
View File
@@ -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
+136 -30
View File
@@ -2,6 +2,7 @@
#include "Log.h"
#include "uuid/uuid.h"
#include "Exception.h"
#include "Base64.h"
#include <cstring>
#include <string>
#include <format>
@@ -9,6 +10,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <cctype>
#include <fstream>
namespace coreutils {
@@ -45,13 +48,13 @@ namespace coreutils {
MString::MString(const ZString &zstring) {
setSize(zstring.getLength());
memcpy(data, zstring.getData(), zstring.getLength());
cursor = data;
}
memcpy(data, zstring.getCursor(), zstring.getLength());
cursor = data;
}
MString::MString(ZString &zstring) {
setSize(zstring.getLength());
memcpy(data, zstring.getData(), zstring.getLength());
memcpy(data, zstring.getCursor(), zstring.getLength());
cursor = data;
}
@@ -63,7 +66,7 @@ namespace coreutils {
MString::MString(MString &mstring) {
setSize(mstring.getLength());
memcpy(data, mstring.getData(), mstring.getLength());
memcpy(data, mstring.getCursor(), mstring.getLength());
cursor = data;
}
@@ -103,36 +106,46 @@ namespace coreutils {
MString &MString::operator=(coreutils::MString value) {
setSize(value.getLength());
memcpy(data, value.getData(), value.getLength());
memcpy(data, value.getCursor(), value.getLength());
length = value.getLength();
cursor = data;
onChange();
return *this;
}
MString &MString::operator=(coreutils::ZString value) {
setSize(value.getLength());
memcpy(data, value.getData(), value.getLength());
length = value.getLength();
return *this;
}
MString &MString::operator=(coreutils::ZString value) {
setSize(value.getLength());
memcpy(data, value.getCursor(), value.getLength());
length = value.getLength();
cursor = data;
onChange();
return *this;
}
MString &MString::operator=(std::string value) {
setSize(value.length());
memcpy(data, value.c_str(), value.length());
length = value.length();
return *this;
setSize(value.length());
memcpy(data, value.c_str(), value.length());
length = value.length();
cursor = data;
onChange();
return *this;
}
MString &MString::operator=(const char *value) {
int len = strlen(value);
setSize(len);
memcpy(data, value, len);
cursor = data;
onChange();
return *this;
}
MString &MString::operator=(char value) {
int len = 1;
setSize(1);
*data = value;
cursor = data;
onChange();
return *this;
}
@@ -144,6 +157,7 @@ namespace coreutils {
setSize(temp.length());
memcpy(this->data, (char *)temp.data(), temp.length());
cursor = this->data;
onChange();
return *this;
}
@@ -152,6 +166,7 @@ namespace coreutils {
setSize(temp.length());
memcpy(this->data, (char *)temp.data(), temp.length());
cursor = this->data;
onChange();
return *this;
}
@@ -160,6 +175,7 @@ namespace coreutils {
int len = strlen(value);
setSize(len + length);
memcpy(data + temp, value, len);
onChange();
return *this;
}
@@ -168,6 +184,7 @@ namespace coreutils {
temp << value;
MString temp2 = temp.str();
write(temp2);
onChange();
return *this;
}
@@ -183,13 +200,15 @@ namespace coreutils {
int temp = length;
int len = length + zstring.getLength();
setSize(len);
memcpy(data + temp, zstring.getData(), zstring.getLength());
memcpy(data + temp, zstring.getCursor(), zstring.getLength());
onChange();
return *this;
}
MString &MString::operator<<(char value) {
setSize(length + 1);
data[length - 1] = value;
onChange();
return *this;
}
@@ -202,19 +221,32 @@ namespace coreutils {
std::cout << "xxx" << std::endl;
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) {
setSize(length + 1);
for (int ix = length; ix >= offset; ix--)
getData()[ix + 1] = getData()[ix];
data[offset] = ch;
onChange();
}
void MString::insert(ZString value, int offset) {
setSize(length + value.getLength());
for (int ix = length; ix >= offset; ix--)
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) {
@@ -234,28 +266,43 @@ namespace coreutils {
}
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);
for (int ix = 0; ix < len; ix++)
for (int ix = 0; ix < len - length; ix++)
cursor[ix] = cursor[ix + length];
setSize(this->length - length);
onChange();
}
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];
setSize(this->length - length);
onChange();
}
MString &MString::write(char ch) {
setSize(length + 1);
*(data + length - 1) = ch;
onChange();
return *this;
}
MString &MString::write(ZString value) {
int len = length;
setSize(length + value.getLength());
memcpy(data + len, value.getData(), value.getLength());
memcpy(data + len, value.getCursor(), value.getLength());
onChange();
return *this;
}
@@ -274,6 +321,15 @@ namespace coreutils {
char ch;
while(::read(fd, &ch, 1))
write(ch);
onChange();
return *this;
}
MString &MString::read(int fd, int count) {
char ch;
while(count-- && ::read(fd, &ch, 1))
write(ch);
onChange();
return *this;
}
@@ -350,7 +406,7 @@ namespace coreutils {
ch1 <<= 4;
ch1 &= 240;
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();
ch2 -= 48;
if(ch2 > 9)
@@ -364,37 +420,85 @@ namespace coreutils {
}
MString MString::toBase64() {
MString target;
return target;
Base64 b64;
return b64.encode(*this);
}
MString MString::fromBase64() {
MString target;
return target;
Base64 b64;
return b64.decode(*this);
}
MString MString::toUpper() {
MString target;
for(int ix = 0; ix < length; ++ix)
target.write(std::toupper(data[ix]));
return target;
}
MString MString::toLower() {
MString target;
for(int ix = 0; ix < length; ++ix)
target.write(std::tolower(data[ix]));
return target;
}
MString MString::toCGI() {
push();
reset();
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;
}
MString MString::fromCGI() {
push();
reset();
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;
}
@@ -405,5 +509,7 @@ namespace coreutils {
c += 7;
return c;
}
void MString::onChange() {}
}
+20 -1
View File
@@ -165,6 +165,18 @@ namespace coreutils {
// MString &operator<<(std::ostream (*f)(std::ostream&) );
MString &operator<<(std::basic_ostream<char> (*pf)(std::basic_ostream<char>&));
///
///
///
MString &operator<<(std::ifstream &pf);
///
///
///
MString &operator<<(std::ostream &out);
///
///
@@ -231,7 +243,8 @@ namespace coreutils {
///
MString &read(int fd);
MString &read(int fd, int len);
///
///
///
@@ -301,6 +314,12 @@ namespace coreutils {
protected:
void setSize(int size);
///
/// This method is called whenever a change is made to the MString storage.
///
virtual void onChange();
private:
int bufferSize = 0;
+21
View File
@@ -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;
}
}
+82
View File
@@ -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
+27
View File
@@ -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();
}
}
+66
View File
@@ -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
+47 -19
View File
@@ -70,11 +70,16 @@ namespace coreutils {
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 {
char *end1 = data + length;
char *end2 = valuex.getData() + valuex.getLength();
char *end2 = valuex.data + valuex.length;
char *cursor1 = cursor;
char *cursor2 = valuex.getCursor();
char *cursor2 = valuex.cursor;
while((cursor1 < end1) && (cursor2 < end2)) {
if(*cursor1 < *cursor2)
return 1;
@@ -87,21 +92,19 @@ namespace coreutils {
return 1;
if((cursor2 == end2) && (cursor1 != end1))
return 0;
return 0;
return 0;
}
// TODO: Fix the following comparison operators to handle the length problem appropriately.
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 {
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) >= 0);
return !(*this < valuex);
}
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) {
@@ -117,11 +120,18 @@ namespace coreutils {
}
bool ZString::operator!=(const char *valuex) const {
if(strlen(valuex) != length)
return true;
return (strncmp(data, valuex, length) != 0);
if(valuex == NULL) {
if(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() {
return list;
}
@@ -254,8 +264,13 @@ namespace coreutils {
char *end = data + length;
char *startChar = data + start;
char *endChar = startChar + len;
char newlen = endChar > end ? endChar - end: len;
if(startChar < end)
// 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)
return ZString(startChar, newlen);
return ZString();
}
@@ -373,6 +388,8 @@ namespace coreutils {
}
bool ZString::startsWithNumber() {
if(*cursor == '-')
return true;
return ((*cursor >= '0') && (*cursor <= '9'));
}
@@ -576,6 +593,11 @@ namespace coreutils {
return ZString(cursor, data + length - cursor);
}
int ZString::setParsed() {
cursor = data + length;
return length;
}
void ZString::reset() {
cursor = data;
}
@@ -586,9 +608,11 @@ namespace coreutils {
bool ZString::trimCRLF() {
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;
if (*(data + length - 1) == '\r')
if ((length > 0) && (*(data + length - 1) == '\r'))
--length;
if (cursor >= (data + length))
cursor = data + length;
@@ -614,7 +638,11 @@ namespace coreutils {
}
return *this;
}
char ZString::getChar() {
return *cursor;
}
char ZString::nextChar() {
char temp = 0;
if(!eod())
+12
View File
@@ -413,6 +413,12 @@ namespace coreutils {
///
ZString unparsed();
///
/// Set the ZString cursor to the end of the ZString.
///
int setParsed();
///
///
@@ -434,6 +440,12 @@ namespace coreutils {
bool trimCRLF();
///
/// Returns the character at the cursor and returns. Cursor is not changed.
///
char getChar();
///
/// Returns the character at the cursor and advances the cursor one
/// position until end of data.
+4 -1
View File
@@ -1,4 +1,7 @@
#!/bin/bash
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
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++ -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
+179
View File
@@ -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;
}
BIN
View File
Binary file not shown.
+48
View File
@@ -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;
}
+1
View File
@@ -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"}}
View File
Whitespace-only changes.
Binary file not shown.
BIN
View File
Binary file not shown.
+7
View File
@@ -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;
}
+23 -1
View File
@@ -1,6 +1,11 @@
#include <iostream>
#include "../MString.h"
coreutils::ZString testcast(coreutils::ZString data) {
std::cout << "in proc: " << data << std::endl;
return data;
}
int main(int argc, char **argv) {
// Literal string assignment tests.
@@ -95,8 +100,25 @@ int main(int argc, char **argv) {
test28 = test29;
std::cout << "int: " << test28 << std::endl;
coreutils::MString test30 = "ABCDEF";
coreutils::MString test30 = "ABCDEF0123";
std::cout << test30 << " to hex " << test30.toHex() << " from hex " << test30.toHex().fromHex() << std::endl;
std::cout << test30 << " to lower " << test30.toLower() << std::endl;
coreutils::MString test31 = "abcdef0123";
std::cout << test31 << " to upper " << test31.toUpper() << std::endl;
coreutils::MString test32 = "This is a test of converting this string to base64";
std::cout << test32 << " to base64 " << test32.toBase64() << std::endl;
coreutils::MString test33 = test32.toBase64();
std::cout << test33 << " from base64 " << test33.fromBase64() << std::endl;
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;
}
+73
View File
@@ -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;
}
+7
View File
@@ -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;
}