]> Cypherpunks repositories - keks.git/commitdiff
Move KEKSAtom definition to apropriate header
authorSergey Matveev <stargrave@stargrave.org>
Thu, 16 Jan 2025 12:55:24 +0000 (15:55 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 16 Jan 2025 12:55:24 +0000 (15:55 +0300)
c/cmd/deatomiser/deatomiser.c
c/cmd/for-fuzz/for-fuzz.c
c/cmd/pp/pp.c
c/cmd/test-vector/test-vector.c
c/lib/atom.h [new file with mode: 0644]
c/lib/atoms.h [deleted file]
c/lib/dec.c
c/lib/dec.h
c/lib/enc.c
c/lib/items.h
c/lib/pki/cer.c

index 118ce4a00b3a3d4bfc87c1edf935576d31d045bd851a6520a3f7c0461d8ae2f7..50c3966b6f702f758f1e6ee793140635eb07494cc3b5d1cbbe24cf3a8dfe05a2 100644 (file)
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <keks/atom.h>
 #include <keks/dec.h>
 #include <keks/err.h>
 
index 530cc266a24525b1ed690bad9800d9fc44279f80c673ed90e0628e91521d103e..6a79c56e66e5e6af6fbbab83bb236df0c9dfc4db92474c32710b810266369bbc 100644 (file)
@@ -18,7 +18,7 @@ main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
     struct KEKSItems items;
-    enum KEKSErr err = KEKSItemsInit(&items);
+    enum KEKSErr err = KEKSItemsInit(&items, 128);
     if (err != KEKSErrNo) {
         return EXIT_FAILURE;
     }
index e27db4115ee5c6e978da37e31c1bf5d115651108c6aa058da7e1296819e13e7d..25763e889db1e309ef89546d82f730235325430893928f6e93ef094709de32b1 100644 (file)
 #include <getopt.h>
 #include <math.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
 
-#include <keks/dec.h>
+#include <keks/atom.h>
 #include <keks/err.h>
 #include <keks/items.h>
 
index b436968dc579d7270c90337192db990fe2b6cca45e08ca59edb6df5f611135ba..d8251ed0f6eca37bb884bf9918aa4bb0d8a7ef2180454dcd7081ec4d99c9fd31 100644 (file)
@@ -6,7 +6,7 @@
 #include <time.h>
 #include <unistd.h>
 
-#include <keks/atoms.h>
+#include <keks/atom.h>
 #include <keks/enc.h>
 #include <keks/enctai.h>
 
diff --git a/c/lib/atom.h b/c/lib/atom.h
new file mode 100644 (file)
index 0000000..f747b18
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef KEKS_ATOM_H
+#define KEKS_ATOM_H
+
+#include <stdint.h>
+#include <stdlib.h>
+
+enum KEKSAtomType {
+    KEKSAtomEOC = 0x00,
+    KEKSAtomNIL = 0x01,
+    KEKSAtomFalse = 0x02,
+    KEKSAtomTrue = 0x03,
+    KEKSAtomUUID = 0x04,
+    KEKSAtomList = 0x08,
+    KEKSAtomMap = 0x09,
+    KEKSAtomBlob = 0x0B,
+    KEKSAtomPint = 0x0C,
+    KEKSAtomNint = 0x0D,
+    KEKSAtomFloat16 = 0x10,
+    KEKSAtomFloat32 = 0x11,
+    KEKSAtomFloat64 = 0x12,
+    KEKSAtomFloat128 = 0x13,
+    KEKSAtomFloat256 = 0x14,
+    KEKSAtomTAI64 = 0x18,
+    KEKSAtomTAI64N = 0x19,
+    KEKSAtomTAI64NA = 0x1A,
+
+    KEKSAtomStrings = 0x80,
+    KEKSAtomIsUTF8 = 0x40,
+};
+
+// TEXINFO: KEKSItemType
+// @deftp {Data type} {enum KEKSItemType}
+// High-level type of the atom.
+// @itemize
+// @item KEKSItemInvalid -- invalid item value, uninitialised
+// @item KEKSItemEOC
+// @item KEKSItemNIL
+// @item KEKSItemFalse
+// @item KEKSItemTrue
+// @item KEKSItemUUID
+// @item KEKSItemPint -- positive integer
+// @item KEKSItemNint -- negative integer
+// @item KEKSItemList
+// @item KEKSItemMap
+// @item KEKSItemBlob
+// @item KEKSItemFloat
+// @item KEKSItemTAI64
+// @item KEKSItemBin
+// @item KEKSItemStr
+// @item KEKSItemRaw -- raw value, non-decodable by the library
+// @end itemize
+// @end deftp
+enum KEKSItemType {
+    KEKSItemInvalid = 0,
+    KEKSItemEOC = 1,
+    KEKSItemNIL,
+    KEKSItemFalse,
+    KEKSItemTrue,
+    KEKSItemUUID,
+    KEKSItemPint,
+    KEKSItemNint,
+    KEKSItemList,
+    KEKSItemMap,
+    KEKSItemBlob,
+    KEKSItemFloat,
+    KEKSItemTAI64,
+    KEKSItemBin,
+    KEKSItemStr,
+    KEKSItemRaw,
+};
+
+// TEXINFO: KEKSAtom
+// @deftp {Data type} {struct KEKSAtom}
+// Basic unit of the library, describing single TLV-like value.
+// @table @code
+// @item .typ
+//     High level @ref{KEKSItemType, type} of the atom's value. As a rule
+//     you should look solely on it.
+// @item .v.uuid
+//     Pointer to 16-byte UUID value.
+// @item .v.pint
+//     Value of the positive integer.
+// @item .v.nint
+//     Value of the negative integer.
+// @item .v.list
+//     That value is filled only when dealing with @ref{Items, items}
+//     for lists and maps.
+//     Its @code{.head} is the index in items list to the first element
+//     inside the container. If equals to 0, then it is empty. Its
+//     @code{.len} contains number of the items (key-values pairs in
+//     case of map) inside it.
+// @item .v.blob
+//     That value is filled only when dealing with @ref{Items, items}.
+//     @code{.chunkLen} is the length of the chunk. @code{.chunks} is
+//     the number of chunks, including the terminating binary string.
+// @item .v.str
+//     @code{.ptr} points to the start of the binary/UTF-8/TAI64*
+//     string. @code{.len} is its length in bytes.
+//     Raw values use it as a payload.
+// @end table
+// @end deftp
+struct KEKSAtom {
+    union {
+        const unsigned char *uuid;
+        uint64_t pint;
+        int64_t nint;
+        struct {
+            size_t head;
+            size_t len;
+        } list;
+        struct {
+            size_t chunkLen;
+            size_t chunks;
+        } blob;
+        struct {
+            const unsigned char *ptr;
+            size_t len;
+        } str;
+    } v;
+    enum KEKSItemType typ;
+    char _pad[4];
+};
+
+#endif // KEKS_ATOM_H
diff --git a/c/lib/atoms.h b/c/lib/atoms.h
deleted file mode 100644 (file)
index 4581ed0..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef KEKS_ATOMS_H
-#define KEKS_ATOMS_H
-
-enum KEKSAtomType {
-    KEKSAtomEOC = 0x00,
-    KEKSAtomNIL = 0x01,
-    KEKSAtomFalse = 0x02,
-    KEKSAtomTrue = 0x03,
-    KEKSAtomUUID = 0x04,
-    KEKSAtomList = 0x08,
-    KEKSAtomMap = 0x09,
-    KEKSAtomBlob = 0x0B,
-    KEKSAtomPint = 0x0C,
-    KEKSAtomNint = 0x0D,
-    KEKSAtomFloat16 = 0x10,
-    KEKSAtomFloat32 = 0x11,
-    KEKSAtomFloat64 = 0x12,
-    KEKSAtomFloat128 = 0x13,
-    KEKSAtomFloat256 = 0x14,
-    KEKSAtomTAI64 = 0x18,
-    KEKSAtomTAI64N = 0x19,
-    KEKSAtomTAI64NA = 0x1A,
-
-    KEKSAtomStrings = 0x80,
-    KEKSAtomIsUTF8 = 0x40,
-};
-
-#endif // KEKS_ATOMS_H
index 22d0ae9fe355f2f88931df3b1fa8801d68d15857692b47f522be9ebcc0b1ff61..b844af380d3d42b751ce7d237cb2f8c8f150eaa971ab4664b5269034cf5c0a14 100644 (file)
@@ -19,7 +19,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "atoms.h"
+#include "atom.h"
 #include "dec.h"
 #include "err.h"
 #include "frombe.h"
index 507d48ec479952712fca479388a741b01eba39656dbc622658320239e4f429b9..f006492790c8f268da47908a7e8c11f9d16003c20fa0a2cea80b7e4de84368bc 100644 (file)
 #define KEKS_DEC_H
 
 #include <stddef.h>
-#include <stdint.h>
 
+#include "atom.h"
 #include "err.h"
 
-// TEXINFO: KEKSItemType
-// @deftp {Data type} {enum KEKSItemType}
-// High-level type of the atom.
-// @itemize
-// @item KEKSItemInvalid -- invalid item value, uninitialised
-// @item KEKSItemEOC
-// @item KEKSItemNIL
-// @item KEKSItemFalse
-// @item KEKSItemTrue
-// @item KEKSItemUUID
-// @item KEKSItemPint -- positive integer
-// @item KEKSItemNint -- negative integer
-// @item KEKSItemList
-// @item KEKSItemMap
-// @item KEKSItemBlob
-// @item KEKSItemFloat
-// @item KEKSItemTAI64
-// @item KEKSItemBin
-// @item KEKSItemStr
-// @item KEKSItemRaw -- raw value, non-decodable by the library
-// @end itemize
-// @end deftp
-enum KEKSItemType {
-    KEKSItemInvalid = 0,
-    KEKSItemEOC = 1,
-    KEKSItemNIL,
-    KEKSItemFalse,
-    KEKSItemTrue,
-    KEKSItemUUID,
-    KEKSItemPint,
-    KEKSItemNint,
-    KEKSItemList,
-    KEKSItemMap,
-    KEKSItemBlob,
-    KEKSItemFloat,
-    KEKSItemTAI64,
-    KEKSItemBin,
-    KEKSItemStr,
-    KEKSItemRaw,
-};
-
-// TEXINFO: KEKSAtom
-// @deftp {Data type} {struct KEKSAtom}
-// Basic unit of the library, describing single TLV-like value.
-// @table @code
-// @item .typ
-//     High level @ref{KEKSItemType, type} of the atom's value. As a rule
-//     you should look solely on it.
-// @item .v.uuid
-//     Pointer to 16-byte UUID value.
-// @item .v.pint
-//     Value of the positive integer.
-// @item .v.nint
-//     Value of the negative integer.
-// @item .v.list
-//     That value is filled only when dealing with @ref{Items, items}
-//     for lists and maps.
-//     Its @code{.head} is the index in items list to the first element
-//     inside the container. If equals to 0, then it is empty. Its
-//     @code{.len} contains number of the items (key-values pairs in
-//     case of map) inside it.
-// @item .v.blob
-//     That value is filled only when dealing with @ref{Items, items}.
-//     @code{.chunkLen} is the length of the chunk. @code{.chunks} is
-//     the number of chunks, including the terminating binary string.
-// @item .v.str
-//     @code{.ptr} points to the start of the binary/UTF-8/TAI64*
-//     string. @code{.len} is its length in bytes.
-//     Raw values use it as a payload.
-// @end table
-// @end deftp
-struct KEKSAtom {
-    union {
-        const unsigned char *uuid;
-        uint64_t pint;
-        int64_t nint;
-        struct {
-            size_t head;
-            size_t len;
-        } list;
-        struct {
-            size_t chunkLen;
-            size_t chunks;
-        } blob;
-        struct {
-            const unsigned char *ptr;
-            size_t len;
-        } str;
-    } v;
-    enum KEKSItemType typ;
-    char _pad[4];
-};
-
 // TEXINFO: KEKSAtomDecode
 // @deftypefun {enum KEKSErr} KEKSAtomDecode ( @
 //     size_t *got, @
index bf8e41843141113d3c199173b462e1c125e969ca5b037f6e3ab94345c35d2ecd..f18a92b6386b805b2ca822efe0d1bc2b532f4f1277bc621dedf3bec80ec4a1ad 100644 (file)
@@ -18,7 +18,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "atoms.h"
+#include "atom.h"
 #include "enc.h"
 #include "tobe.h"
 
index c085484ae28e8e3194e109031d9c354c2e4811123f956dba899d7ed688e77aa0..6f9b1bb66d6002079efc3965e346b298b10e41969b8c35a106d289ff3bd3d91c 100644 (file)
@@ -4,7 +4,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 
-#include "dec.h"
+#include "atom.h"
 #include "err.h"
 
 // TEXINFO: KEKSItem
index 81eb105108149b082b085e40bcc90ff3ddbb72654760d9b47213dd8c6483410d..81ce2563e4dda7083c038b734b4c0996d0b9ce72a0b14ff0424db49f889bcb56 100644 (file)
@@ -2,7 +2,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "../dec.h"
+#include "../atom.h"
 #include "../dectai.h"
 #include "../enc.h"
 #include "../err.h"