summaryrefslogtreecommitdiffhomepage
path: root/lib/libsteps/include/steps
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 02:42:00 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 02:43:45 +0100
commitfc5bab30ba4d77a5c040f2c461aa8b2dd5361482 (patch)
tree9aa34c2bcf93b869238e8499245e5afb0cc5c36f /lib/libsteps/include/steps
parent88089b7dc28e47bb94de6e6de123e1be58f7dd5f (diff)
feat: system and CI improvements.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'lib/libsteps/include/steps')
-rw-r--r--lib/libsteps/include/steps/config.hpp17
-rw-r--r--lib/libsteps/include/steps/steps.hpp71
2 files changed, 88 insertions, 0 deletions
diff --git a/lib/libsteps/include/steps/config.hpp b/lib/libsteps/include/steps/config.hpp
new file mode 100644
index 0000000..6eefe3c
--- /dev/null
+++ b/lib/libsteps/include/steps/config.hpp
@@ -0,0 +1,17 @@
+/* -------------------------------------------
+
+Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+------------------------------------------- */
+
+#pragma once
+
+#ifdef OCL_USE_UTF8
+#undef OCL_USE_UTF8
+#endif
+
+#include <core/includes.hpp>
+
+#include <cstring>
+#include <fstream>
+
diff --git a/lib/libsteps/include/steps/steps.hpp b/lib/libsteps/include/steps/steps.hpp
new file mode 100644
index 0000000..c524149
--- /dev/null
+++ b/lib/libsteps/include/steps/steps.hpp
@@ -0,0 +1,71 @@
+/* -------------------------------------------
+
+Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <steps/config.hpp>
+
+#define kStepsExtension ".stp"
+#define kStepsStrLen (256U)
+
+#define kStepsMagic " pls"
+#define kStepsMagicLen (4U)
+#define kStepsVersion (0x0100)
+
+#ifdef __GNUC__
+#define STEPS_PACKED __attribute__((packed))
+#else
+#define STEPS_PACKED
+#endif
+
+namespace ocl::steps {
+struct STEPS_PACKED record final {
+ ocl::char_type magic[kStepsMagicLen] = {kStepsMagic[0], kStepsMagic[1],
+ kStepsMagic[2], kStepsMagic[3]};
+ ocl::char_type name[kStepsStrLen] = "";
+ ocl::char_type company[kStepsStrLen] = "";
+ ocl::char_type author[kStepsStrLen] = "";
+ int32_t version = 0;
+ int32_t pages = 0;
+ int32_t check_page = 0, eula_page = 0;
+};
+
+inline bool is_valid(record& r) noexcept {
+ return r.pages > 1 && r.version > 0 && strcmp(r.magic, kStepsMagic) == 0;
+}
+
+namespace operators {
+/// =========================================================== ///
+/// @brief Read operator for steps records.
+/// =========================================================== ///
+inline std::ifstream &operator>>(std::ifstream &f, record &r) {
+ f.read((char *)&r, sizeof(r));
+ return f;
+}
+
+/// =========================================================== ///
+/// @brief Write operator for steps records.
+/// =========================================================== ///
+inline std::ofstream &operator<<(std::ofstream &f, record &r) {
+ f.write((char *)&r, sizeof(r));
+ return f;
+}
+
+/// =========================================================== ///
+/// @brief Equal operator for steps records.
+/// =========================================================== ///
+inline bool operator==(const record &r, const record &l) {
+ return (std::strncmp(r.magic, l.magic, kStepsMagicLen) == 0);
+}
+
+/// =========================================================== ///
+/// @brief Not equal operator for steps records.
+/// =========================================================== ///
+inline bool operator!=(const record &r, const record &l) {
+ return (std::strncmp(r.magic, l.magic, kStepsMagicLen) > 0);
+}
+} // namespace operators
+} // namespace ocl::steps