view rvinterf/etm/main.c @ 193:f9ac53d8e999

gsm-fw/services/etm: etm_get16(): fix for bad C (sequence points violation) while at it, fixed echo and dieid as well
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 25 Nov 2013 06:12:19 +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);
	}
}