summary refs log tree commit diff
path: root/ingest.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-31 12:27:01 -0400
committerJune McEnroe <june@causal.agency>2019-07-31 12:27:01 -0400
commitf0f2fe362dbc50e9eacd03b2b3f1e1713470fe2c (patch)
treecfb9faef4cafaf6d3240ff14926c1936ca1b323d /ingest.c
parentPass original command to dispatch (diff)
downloadstream-f0f2fe362dbc50e9eacd03b2b3f1e1713470fe2c.tar.gz
stream-f0f2fe362dbc50e9eacd03b2b3f1e1713470fe2c.zip
Import terminal emulation from shotty
Diffstat (limited to 'ingest.c')
-rw-r--r--ingest.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/ingest.c b/ingest.c
index fba2435..27035af 100644
--- a/ingest.c
+++ b/ingest.c
@@ -17,6 +17,7 @@
 #include <assert.h>
 #include <err.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <poll.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -26,12 +27,17 @@
 #include <sys/un.h>
 #include <sysexits.h>
 #include <unistd.h>
+#include <wchar.h>
+
+#include "stream.h"
 
 int main(void) {
 	int error;
+	setlocale(LC_CTYPE, "");
 
 	// TODO: Read info from file.
 	const char *path = "example.sock";
+	termInit(24, 80);
 	
 	int server = socket(PF_LOCAL, SOCK_STREAM, 0);
 	if (server < 0) err(EX_OSERR, "socket");
@@ -78,15 +84,16 @@ int main(void) {
 		if (fds[1].revents) {
 			int client = accept(server, NULL, NULL);
 			if (client < 0) err(EX_IOERR, "accept");
-			maxClient++;
-			assert(client == maxClient);
+			fcntl(client, F_SETFL, O_NONBLOCK);
 
 			int yes = 1;
-			fcntl(client, F_SETFL, O_NONBLOCK);
 			error = setsockopt(client, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
 			if (error) err(EX_IOERR, "setsockopt");
 
 			// TODO: Send snapshot.
+
+			maxClient++;
+			assert(client == maxClient);
 		}
 	}
 	err(EX_IOERR, "poll");