view libcommon/exit.c @ 103:3477438b5706 default tip

new fc-simtool command script: oper-sim-test
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Aug 2022 16:34:43 +0000
parents 812779459ddd
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

extern unsigned calypso_fd;
extern FILE *cpipeF, *rpipeF;

calypso_poweroff()
{
	int c;

	fputs("poweroff\n", cpipeF);
	fflush(cpipeF);
	while ((c = getc(rpipeF)) != EOF)
		putchar(c);
	exit(0);
}

good_exit()
{
	if (calypso_fd)
		calypso_poweroff();
	exit(0);
}

cmd_exit(argc, argv)
	char **argv;
{
	if (argc < 2)
		good_exit();
	if (!calypso_fd) {
		fprintf(stderr,
	"error: exit arguments are only meaningful with Calypso back end\n");
		return(-1);
	}
	if (!strcmp(argv[1], "bare"))
		exit(0);
	if (!strcmp(argv[1], "iota-off"))
		calypso_poweroff();
	fprintf(stderr, "error: \"%s\" is not an understood exit mode\n",
		argv[1]);
	return(-1);
}