summaryrefslogtreecommitdiff
path: root/userland/irc/sv.h
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-03-19 01:41:22 +0100
committerAnton Kling <anton@kling.gg>2024-03-19 01:41:22 +0100
commit553b43d2e563dcff74d4c86904fa3737e96d7365 (patch)
tree002b70c9d919b8a18a95bb5754c57db897b5977e /userland/irc/sv.h
parent0dccff86e50dfe1555b8bc29862dba2b972a3705 (diff)
IRC: Add the IRC client I am working on
Diffstat (limited to 'userland/irc/sv.h')
-rw-r--r--userland/irc/sv.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/userland/irc/sv.h b/userland/irc/sv.h
new file mode 100644
index 0000000..615af2c
--- /dev/null
+++ b/userland/irc/sv.h
@@ -0,0 +1,28 @@
+#ifndef SV_H
+#define SV_H
+#include "sb.h"
+#include <stddef.h>
+
+#define SB_TO_SV(_sb) \
+ (struct sv) { \
+ .s = (_sb).string, .length = (_sb).length \
+ }
+
+#define C_TO_SV(_c_string) \
+ ((struct sv){.length = strlen(_c_string), .s = (_c_string)})
+
+struct sv {
+ const char *s;
+ size_t length;
+};
+
+char *SV_TO_C(struct sv s);
+struct sv sv_split_delim(const struct sv input, struct sv *rest, char delim);
+struct sv sv_split_space(const struct sv input, struct sv *rest);
+int sv_isempty(struct sv s);
+char sv_peek(struct sv s);
+int sv_eq(struct sv a, struct sv b);
+struct sv sv_trim_left(struct sv s, size_t n);
+struct sv sv_clone(struct sv s);
+struct sv sv_clone_from_c(const char *s);
+#endif