diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-06-19 15:29:19 +0200 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-06-19 15:29:19 +0200 |
commit | ead2881be92d33076c2104dbd75bad3561f26088 (patch) | |
tree | 75ed0217a40a1321ce22ca7b675f4d148ce29161 /include/str.h | |
parent | f19e329254d89ddf6d946410b56975a5c550c3f4 (diff) | |
download | silly_game-ead2881be92d33076c2104dbd75bad3561f26088.tar.xz |
server: implement auth and sending nodes
Diffstat (limited to 'include/str.h')
-rw-r--r-- | include/str.h | 12 |
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 |