shithub: mez

Download patch

ref: a4d0372d0f1916d1d9df34c4fe4ae7a98c8de020
parent: df830dd2a611299eda94cadaf6e2d08a81ec2a59
author: spew <spew@cbza.org>
date: Tue Apr 15 09:56:57 EDT 2025

some changes

--- a/mez.c
+++ b/mez.c
@@ -67,11 +67,11 @@
 {
 	char *e;
 
-	e = vseprint(n->buf, n->buf+sizeof(n->buf), fmt, v);
+	e = vseprint(n->out, n->out+sizeof(n->out), fmt, v);
 	va_end(v);
 	*e++ = '\r';
 	*e++ = '\n';
-	write(n->fd, n->buf, e-n->buf);
+	write(n->fd, n->out, e-n->out);
 }
 
 void
@@ -88,10 +88,10 @@
 {
 	int bytes;
 
-	bytes = read(n->fd, n->buf, sizeof(n->buf));
-	n->buf[bytes-2] = '\n';
-	n->buf[bytes-1] = '\0';
-	return n->buf;
+	bytes = read(n->fd, n->in, sizeof(n->in));
+	n->in[bytes-2] = '\n';
+	n->in[bytes-1] = '\0';
+	return n->in;
 }
 
 char*
@@ -152,11 +152,16 @@
 	net = a;
 	for(;;){
 		in = rmsg(net);
-		if(strcmp(in, "PING") == 0){
+		if(strncmp(in, "PING", 4) == 0){
 			wmsg(net, "PONG%s", in+4);
 			continue;
 		}
 	}
+}
+
+Msg*
+parse(char *s)
+{
 }
 
 void
--- a/mez.h
+++ b/mez.h
@@ -2,6 +2,7 @@
 typedef struct Chan Chan;
 typedef struct Net Net;
 typedef struct Text Text;
+typedef struct Msg Msg;
 
 struct App {
 	char *host, *user, *passwd;
@@ -29,9 +30,22 @@
 	char *name, *host, *state, *nick, *user, *real;
 	Chan *channels;
 	int fd, id;
-	char buf[8192];
+	char in[8192], out[8192];
 };
 
+enum {
+	PRIVMSG = 1000,
+};
+
+struct Msg {
+	int t;
+	char *sender;
+	union {
+		char *dst;
+		char *msg;
+	}; // PRIVMSG
+};
+
 void error(char*);
 void *emallocz(ulong sz, int clr);
-void *erealloc(void *ptr, ulong size);
\ No newline at end of file
+void *erealloc(void *ptr, ulong size);