summary refs log tree commit diff
path: root/bounce.h
diff options
context:
space:
mode:
Diffstat (limited to 'bounce.h')
-rw-r--r--bounce.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/bounce.h b/bounce.h
index e81ed8f..491616b 100644
--- a/bounce.h
+++ b/bounce.h
@@ -16,6 +16,7 @@
 
 #include <stdbool.h>
 #include <stdlib.h>
+#include <string.h>
 #include <tls.h>
 
 #ifndef DEFAULT_CERT_PATH
@@ -30,6 +31,29 @@ struct Client {
 	struct tls *tls;
 };
 
+#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
+
+enum { ParamCap = 15 };
+struct Command {
+	const char *origin;
+	const char *name;
+	const char *params[ParamCap];
+};
+
+static inline struct Command parse(char *line) {
+	struct Command cmd = {0};
+	if (line[0] == ':') cmd.origin = 1 + strsep(&line, " ");
+	cmd.name = strsep(&line, " ");
+	for (size_t i = 0; line && i < ParamCap; ++i) {
+		if (line[0] == ':') {
+			cmd.params[i] = &line[1];
+			break;
+		}
+		cmd.params[i] = strsep(&line, " ");
+	}
+	return cmd;
+}
+
 bool verbose;
 
 void listenConfig(const char *cert, const char *priv);