diff --git a/cmake-build-debug/.cmake/api/v1/reply/index-2023-11-01T17-34-41-0672.json b/cmake-build-debug/.cmake/api/v1/reply/index-2023-11-02T19-30-51-0357.json similarity index 100% rename from cmake-build-debug/.cmake/api/v1/reply/index-2023-11-01T17-34-41-0672.json rename to cmake-build-debug/.cmake/api/v1/reply/index-2023-11-02T19-30-51-0357.json diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index 13962c0..456988f 100644 Binary files a/cmake-build-debug/.ninja_deps and b/cmake-build-debug/.ninja_deps differ diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index 66ac037..399ad75 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -1,16 +1,39 @@ # ninja log v5 -5 1875 1698859762131031423 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o ac96ce6eea552e98 +4 1469 1698953294073499706 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o ac96ce6eea552e98 5 2802 1698859763059011893 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/system.cpp.o 5500266fb1697520 6 4924 1698859765174967403 libraries/BLT/CMakeFiles/BLT.dir/src/blt/profiling/profiler_v2.cpp.o e7304896d85ed918 6 4372 1698859764618979088 libraries/BLT/CMakeFiles/BLT.dir/src/blt/profiling/profiler.cpp.o 3ccbe9961f7739c8 -2 1240 1698859761499044732 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 519d75b42539078d -5437 5557 1698859765810954042 AssignmentProject 4b71d2492f56ed6a +2 3571 1698953296169250965 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 519d75b42539078d +4717 4929 1698953297529090245 AssignmentProject c7d6a3a2040ef3aa +0 103 1698953451329703921 build.ninja a40327fdfd9abe67 3 2049 1698859762307027720 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/format.cpp.o 88acf1e13074560c -7 4454 1698859764694977491 libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o 63d9843266c3e3f8 -4924 5437 1698859765666957067 libraries/BLT/libBLT.a f5b601d9b774b003 +5 4206 1698953296797176680 libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o 63d9843266c3e3f8 +4206 4717 1698953297293118093 libraries/BLT/libBLT.a f5b601d9b774b003 4 4651 1698859764898973202 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/logging.cpp.o dd234ba43f752924 -4 2631 1698859762887015512 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o 4c619d81fe5732f0 +3 2435 1698953295037385140 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o 4c619d81fe5732f0 7 1229 1698859761487044985 libraries/BLT/CMakeFiles/BLT.dir/src/blt/nbt/nbt_block.cpp.o 5e7e643c13f0b103 6 3607 1698859763858995067 libraries/BLT/CMakeFiles/BLT.dir/src/blt/nbt/nbt.cpp.o 31fcb40edaba985e 3 1583 1698859761839037571 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/filesystem.cpp.o 7cd9697546f581 -2 1968 1698859762223029488 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o 9e9f104a693ca6f5 +3 2067 1698953294669428868 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o 9e9f104a693ca6f5 +4 1273 1698953656526732873 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o ac96ce6eea552e98 +3 1760 1698953657010702150 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o 9e9f104a693ca6f5 +4 2104 1698953657350680590 libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o 4c619d81fe5732f0 +5 3921 1698953659158566033 libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o 63d9843266c3e3f8 +2 2746 1698953700296017134 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +3 4037 1698953701583939017 libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o 63d9843266c3e3f8 +4038 4428 1698953701967915741 libraries/BLT/libBLT.a f5b601d9b774b003 +4428 4662 1698953702215900719 AssignmentProject c7d6a3a2040ef3aa +3 2557 1698953766652108154 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +2557 2786 1698953766884094865 AssignmentProject c7d6a3a2040ef3aa +2 2743 1698953804473972626 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +2743 2962 1698953804697960153 AssignmentProject c7d6a3a2040ef3aa +3 3660 1698956357737298841 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +3660 3882 1698956357961295064 AssignmentProject c7d6a3a2040ef3aa +3 3751 1698956437779991460 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +3751 3988 1698956438019987651 AssignmentProject c7d6a3a2040ef3aa +3 3685 1698956783816311852 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +3686 3912 1698956784048319538 AssignmentProject c7d6a3a2040ef3aa +3 3687 1698957622286652471 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +3687 3919 1698957622522652509 AssignmentProject c7d6a3a2040ef3aa +3 3747 1698957647482651805 CMakeFiles/AssignmentProject.dir/src/main.cpp.o 7b18e037a23b35ad +3747 4032 1698957647770651743 AssignmentProject c7d6a3a2040ef3aa diff --git a/cmake-build-debug/AssignmentProject b/cmake-build-debug/AssignmentProject index 4fb8b3c..7a4edd8 100755 Binary files a/cmake-build-debug/AssignmentProject and b/cmake-build-debug/AssignmentProject differ diff --git a/cmake-build-debug/CMakeFiles/AssignmentProject.dir/src/main.cpp.o b/cmake-build-debug/CMakeFiles/AssignmentProject.dir/src/main.cpp.o index 8be4d92..ef148dc 100644 Binary files a/cmake-build-debug/CMakeFiles/AssignmentProject.dir/src/main.cpp.o and b/cmake-build-debug/CMakeFiles/AssignmentProject.dir/src/main.cpp.o differ diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index 35fb350..2299319 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Nov 01 22:19 EDT +Start testing: Nov 02 16:40 EDT ---------------------------------------------------------- -End testing: Nov 01 22:19 EDT +End testing: Nov 02 16:40 EDT diff --git a/cmake-build-debug/bigdata.txt b/cmake-build-debug/bigdata.txt new file mode 100644 index 0000000..6978634 --- /dev/null +++ b/cmake-build-debug/bigdata.txt @@ -0,0 +1 @@ +hello this is big data how may i help you? \ No newline at end of file diff --git a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o index b75f9e9..a8d6e6f 100644 Binary files a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o and b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o differ diff --git a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o index c6c5a7a..4d3a6cd 100644 Binary files a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o and b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o differ diff --git a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o index c1d5401..21e2213 100644 Binary files a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o and b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o differ diff --git a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o index 8cd1e2e..7ab73a1 100644 Binary files a/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o and b/cmake-build-debug/libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o differ diff --git a/cmake-build-debug/libraries/BLT/libBLT.a b/cmake-build-debug/libraries/BLT/libBLT.a index 4cb8e10..0c3d234 100644 Binary files a/cmake-build-debug/libraries/BLT/libBLT.a and b/cmake-build-debug/libraries/BLT/libBLT.a differ diff --git a/libraries/BLT b/libraries/BLT index 1d8f9b4..15bcd37 160000 --- a/libraries/BLT +++ b/libraries/BLT @@ -1 +1 @@ -Subproject commit 1d8f9b4bbdb84647c8a96b1ef87d262afd7021cb +Subproject commit 15bcd37834628c941db5613fa62770426dff29e0 diff --git a/src/main.cpp b/src/main.cpp index 4f9de56..699d1a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,191 @@ +/* + * Mail file containing the program entry point. I really want to name all this all femboy themed + * Copyright (C) 2023 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +#include <blt/parse/argparse.h> +#include <blt/std/string.h> +#include <blt/std/logging.h> +#include <blt/std/memory.h> +#include <blt/std/random.h> +#include <blt/std/time.h> +#include <blt/std/assert.h> +#include <fstream> #include <iostream> +#include <ios> +#include <cstdint> +#include <memory> -int main() +constexpr size_t PACKET_SIZE = 512; + +class packet { - std::cout << "Hello, World!" << std::endl; - return 0; + private: + std::uint8_t* buffer = new std::uint8_t[PACKET_SIZE]; + public: + size_t used = 0; + + packet() = default; + + packet(const packet& copy) + { + for (size_t i = 0; i < PACKET_SIZE; i++) + buffer[i] = copy[i]; + used = copy.used; + } + + packet(packet&& move) noexcept + { + delete[] buffer; + buffer = move.buffer; + used = move.used; + move.buffer = nullptr; + } + + packet& operator=(const packet& copy) + { + if (© == this) + return *this; + for (size_t i = 0; i < PACKET_SIZE; i++) + buffer[i] = copy[i]; + used = copy.used; + return *this; + } + + packet& operator=(packet&& move) noexcept + { + delete[] buffer; + buffer = move.buffer; + move.buffer = nullptr; + used = move.used; + return *this; + } + + std::uint8_t* data() + { + return buffer; + } + + std::uint8_t& operator[](size_t index) + { + BLT_ASSERT(index < PACKET_SIZE); + return buffer[index]; + } + + [[nodiscard]] const std::uint8_t& operator[](size_t index) const + { + BLT_ASSERT(index < PACKET_SIZE); + return buffer[index]; + } + + [[nodiscard]] size_t size() const + { + return used; + } + + ~packet() + { + delete[] buffer; + } +}; + +void mangle(packet& packet) +{ + static std::random_device dev; + static std::mt19937_64 engine(dev()); + static std::uniform_real_distribution dist(0.0, 1.0); + static std::uniform_int_distribution randomizer(0, 7); + + // 50% chance to mangle 10% of the data. + if (dist(engine) < 0.5) + { + for (size_t i = 0; i < PACKET_SIZE; i++) + if (dist(engine) < 0.1) + { + // this is bad + auto pos = static_cast<uint8_t>(exp2(randomizer(engine))); + // flip the bit + auto bit = ~(packet[i] & pos); + // extra everything but the bit + auto data = packet[i] & ~pos; + // recombine bit + packet[i] = data | bit; + } + } } + +void process_packets(const std::vector<packet> packets) +{ + +} + +int main(int argc, const char** argv) +{ + + blt::arg_parse parser; + parser.addArgument( + blt::arg_builder{"-f", "--file"}.setNArgs(1).setHelp("Specify a file to read from instead of cin").setAction(blt::arg_action_t::STORE) + .build()); + + auto args = parser.parse_args(argc, argv); + + std::vector<packet> packets; + + if (args.contains("--file")) + { + auto& path = blt::arg_parse::get<std::string>(args.data["file"]); + + std::ifstream file(path); + + file.seekg(0, std::ifstream::end); + size_t length = file.tellg(); + file.seekg(0, std::ifstream::beg); + + blt::scoped_buffer<std::uint8_t> data(length); + + file.read(reinterpret_cast<char*>(data.data()), static_cast<long>(length)); + + if (file) + BLT_INFO("All bytes have been read from the file, parsing into packets"); + else + BLT_WARN("Only read %d characters, expected %d", file.gcount(), length); + file.close(); + + size_t rp = 0; + while (rp < length) + { + packet p; + if (rp + PACKET_SIZE < length) + p.used = PACKET_SIZE; + else + p.used = length - rp; + std::memcpy(p.data(), &data[rp], p.used); + rp += PACKET_SIZE; + packets.push_back(std::move(p)); + } + } else + { + do + { + packet p; + std::cin.read(reinterpret_cast<char*>(p.data()), PACKET_SIZE); + packets.push_back(std::move(p)); + } while (!std::cin.eof() && !std::cin.fail()); + } + + process_packets(packets); + + return 0; +} \ No newline at end of file