view rvinterf/etm/main.c @ 184:4714fdfca39c

fc-tmsh compiles!
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 24 Nov 2013 08:40:44 +0000
parents 13a0348ffce4
children fa7174faa9aa
line wrap: on
line source

/*
 * 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);
	}
}