view pircharge/main.c @ 402:1b83d07576bf

compal/boot/c123-boot.disasm: missed vector branch at 0x1c
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jan 2023 00:06:59 +0000
parents fec90990f613
children
line wrap: on
line source

#include <sys/types.h>
#include <sys/errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <rvinterf/exitcodes.h>

char *socket_pathname = "/tmp/rvinterf_socket";
int sock;

int adccal_a, adccal_b;

main(argc, argv)
	char **argv;
{
	extern int optind;
	extern char *optarg;
	int c, sopt = 0;
	fd_set fds;

	while ((c = getopt(argc, argv, "s:")) != EOF)
		switch (c) {
		case 's':
			socket_pathname = optarg;
			sopt++;
			continue;
		case '?':
		default:
			/* error msg already printed */
			exit(ERROR_USAGE);
		}
	if (argc != optind + 2) {
		fprintf(stderr, "usage: %s adccal-a adccal-b\n", argv[0]);
		exit(ERROR_USAGE);
	}
	adccal_a = atoi(argv[optind]);
	adccal_b = atoi(argv[optind+1]);

	connect_local_socket();
	init();
	for (;;) {
		FD_ZERO(&fds);
		FD_SET(sock, &fds);
		c = select(sock+1, &fds, 0, 0, 0);
		if (c < 0) {
			if (errno == EINTR)
				continue;
			perror("select");
			exit(ERROR_UNIX);
		}
		if (FD_ISSET(sock, &fds))
			handle_rvinterf_input();
		fflush(stdout);
	}
}