diff rvinterf/etm/main.c @ 182:13a0348ffce4

rvinterf/etm: checkpointing not-yet-compilable code
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 24 Nov 2013 06:59:09 +0000
parents
children fa7174faa9aa
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etm/main.c	Sun Nov 24 06:59:09 2013 +0000
@@ -0,0 +1,56 @@
+/*
+ * This module contains the main() function for fc-tmsh.
+ */
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+char *socket_pathname = "/tmp/rvinterf_socket";
+int ttyhacks, dflag;
+
+int sock;
+
+main(argc, argv)
+	char **argv;
+{
+	extern char *optarg;
+	int c;
+	fd_set fds;
+
+	while ((c = getopt(argc, argv, "ds:")) != EOF)
+		switch (c) {
+		case 'd':
+			dflag++;
+			continue;
+		case 's':
+			socket_pathname = optarg;
+			continue;
+		case '?':
+		default:
+			exit(1);
+		}
+	ttyhacks = isatty(0) && !dflag;
+	init();
+	tty_init();
+	for (;;) {
+		FD_ZERO(&fds);
+		FD_SET(0, &fds);
+		FD_SET(sock, &fds);
+		c = select(sock+1, &fds, 0, 0, 0);
+		if (c < 0) {
+			if (errno == EINTR)
+				continue;
+			tty_cleanup();
+			perror("select");
+			exit(1);
+		}
+		if (FD_ISSET(0, &fds))
+			handle_tty_input();
+		if (FD_ISSET(sock, &fds))
+			handle_rvinterf_input();
+		fflush(stdout);
+	}
+}