summaryrefslogtreecommitdiff
path: root/include/str.h
diff options
context:
space:
mode:
authorLizzy Fleckenstein <lizzy@vlhl.dev>2024-06-19 15:29:19 +0200
committerLizzy Fleckenstein <lizzy@vlhl.dev>2024-06-19 15:29:19 +0200
commitead2881be92d33076c2104dbd75bad3561f26088 (patch)
tree75ed0217a40a1321ce22ca7b675f4d148ce29161 /include/str.h
parentf19e329254d89ddf6d946410b56975a5c550c3f4 (diff)
downloadsilly_game-ead2881be92d33076c2104dbd75bad3561f26088.tar.xz
server: implement auth and sending nodes
Diffstat (limited to 'include/str.h')
-rw-r--r--include/str.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/include/str.h b/include/str.h
index b208515..277a6f3 100644
--- a/include/str.h
+++ b/include/str.h
@@ -7,20 +7,18 @@
#include <stddef.h>
#include <stdbool.h>
+#include "array.h"
// string library taken from cuddlesOS:
// https://github.com/cuddlesOS/cuddles/blob/master/stage3/string.c
-// arr
-#define len(X) (sizeof X / sizeof *X)
-#define array(T) struct { size_t len; T *data; }
-
typedef array(char) str;
-#define S(X) ((str) { len(X)-1, X })
#define NILS ((str) { 0, NULL })
+#define S(X) ((str) { len(X)-1, X })
+#define PSTR(X) (int) (X).len, (X).data
-typedef struct { size_t cap; str buf; } strbuf;
-#define NILSBUF ((strbuf) { 0, NILS })
+typedef arraybuf(char) strbuf;
+#define NILSBUF ((strbuf) { 0, 0, NULL })
// compares two strings by length and ASCII values. return value:
// < 0 if s1 < s2