FreeCalypso > hg > fc-sim-tools
comparison libcommon/exit.c @ 9:c9ef9e91dd8e
new libcommon, initial version
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 06:55:38 +0000 |
parents | |
children | 812779459ddd |
comparison
equal
deleted
inserted
replaced
8:34bbb0585cab | 9:c9ef9e91dd8e |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <strings.h> | |
5 | |
6 extern unsigned calypso_fd; | |
7 extern FILE *cpipeF; | |
8 | |
9 good_exit() | |
10 { | |
11 if (calypso_fd) { | |
12 fputs("poweroff\n", cpipeF); | |
13 fflush(cpipeF); | |
14 } | |
15 exit(0); | |
16 } | |
17 | |
18 cmd_exit(argc, argv) | |
19 char **argv; | |
20 { | |
21 if (argc < 2) | |
22 good_exit(); | |
23 if (!calypso_fd) { | |
24 fprintf(stderr, | |
25 "error: exit arguments are only meaningful with Calypso back end\n"); | |
26 return(-1); | |
27 } | |
28 if (!strcmp(argv[1], "bare")) | |
29 exit(0); | |
30 if (!strcmp(argv[1], "iota-off")) { | |
31 fputs("poweroff\n", cpipeF); | |
32 fflush(cpipeF); | |
33 exit(0); | |
34 } | |
35 fprintf(stderr, "error: \"%s\" is not an understood exit mode\n", | |
36 argv[1]); | |
37 return(-1); | |
38 } |