changeset 64:d43d82cbfb85

fc-shell: use the newly adopted exit code convention
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 22:25:18 +0000
parents 09b4fd9b3827
children 21a79f465d6a
files rvinterf/asyncshell/at.c rvinterf/asyncshell/main.c rvinterf/asyncshell/oneshot.c rvinterf/asyncshell/pktsort.c rvinterf/asyncshell/sendarb.c rvinterf/asyncshell/sendsp.c rvinterf/asyncshell/tchcmd.c
diffstat 7 files changed, 22 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/asyncshell/at.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/at.c	Wed Oct 26 22:25:18 2016 +0000
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include "pktmux.h"
 #include "limits.h"
+#include "exitcodes.h"
 
 send_string_to_ati(str)
 	char *str;
@@ -20,7 +21,7 @@
 	len = strlen(str);
 	if (len + 1 > MAX_PKT_TO_TARGET) {
 		printf("error: max pkt to target limit exceeded\n");
-		return(1);
+		return(ERROR_USAGE);
 	}
 	/* fill out the packet */
 	sendpkt[0] = RVT_AT_HEADER;
--- a/rvinterf/asyncshell/main.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/main.c	Wed Oct 26 22:25:18 2016 +0000
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "exitcodes.h"
 
 char *socket_pathname = "/tmp/rvinterf_socket";
 char *rvinterf_ttyport;
@@ -49,14 +50,14 @@
 		default:
 usage:			fprintf(stderr,
 				"usage: %s [options] [command]\n", argv[0]);
-			exit(1);
+			exit(ERROR_USAGE);
 		}
 	if (rvinterf_ttyport) {
 		if (sopt) {
 			fprintf(stderr,
 			"%s error: -p and -s options are mutually exclusive\n",
 				argv[0]);
-			exit(1);
+			exit(ERROR_USAGE);
 		}
 		launch_rvinterf(rvinterf_ttyport);
 	} else {
@@ -64,7 +65,7 @@
 			fprintf(stderr,
 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
 				argv[0]);
-			exit(1);
+			exit(ERROR_USAGE);
 		}
 		connect_local_socket();
 	}
@@ -85,7 +86,7 @@
 				continue;
 			tty_cleanup();
 			perror("select");
-			exit(1);
+			exit(ERROR_UNIX);
 		}
 		if (FD_ISSET(0, &fds))
 			handle_tty_input();
--- a/rvinterf/asyncshell/oneshot.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/oneshot.c	Wed Oct 26 22:25:18 2016 +0000
@@ -7,6 +7,7 @@
 #include <strings.h>
 #include <stdlib.h>
 #include "limits.h"
+#include "exitcodes.h"
 
 extern int cmd_poweroff();
 extern int cmd_send_oneshot();
@@ -40,15 +41,15 @@
 		fprintf(stderr,
 			"error: \"%s\" is not a valid one-shot command\n",
 			argv[0]);
-		exit(1);
+		exit(ERROR_USAGE);
 	}
 	if (argc - 1 > tp->maxargs) {
 		fprintf(stderr, "%s: too many arguments\n", tp->cmd);
-		exit(1);
+		exit(ERROR_USAGE);
 	}
 	if (argc - 1 < tp->minargs) {
 		fprintf(stderr, "%s: too few arguments\n", tp->cmd);
-		exit(1);
+		exit(ERROR_USAGE);
 	}
 	return tp->func(argc, argv);
 }
--- a/rvinterf/asyncshell/pktsort.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/pktsort.c	Wed Oct 26 22:25:18 2016 +0000
@@ -11,6 +11,7 @@
 #include "limits.h"
 #include "localsock.h"
 #include "localtypes.h"
+#include "exitcodes.h"
 
 extern u_char rvi_msg[];
 extern int rvi_msg_len;
@@ -23,7 +24,7 @@
 	if (rvi_msg_len < 7) {
 		tty_cleanup();
 		fprintf(stderr, "Error: rvinterf sent us an invalid RVT msg\n");
-		exit(1);
+		exit(ERROR_RVINTERF);
 	}
 	useid = rvi_msg[2] << 24 | rvi_msg[3] << 16 | rvi_msg[4] << 8
 		| rvi_msg[5];
@@ -35,7 +36,7 @@
 		tty_cleanup();
 		fprintf(stderr, "unexpected fwd of USEID %08X from rvinterf\n",
 			useid);
-		exit(1);
+		exit(ERROR_RVINTERF);
 	}
 }
 
@@ -78,6 +79,6 @@
 		tty_cleanup();
 		fprintf(stderr, "unexpected fwd of MUX %02X from rvinterf\n",
 			rvi_msg[1]);
-		exit(1);
+		exit(ERROR_RVINTERF);
 	}
 }
--- a/rvinterf/asyncshell/sendarb.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/sendarb.c	Wed Oct 26 22:25:18 2016 +0000
@@ -9,6 +9,7 @@
 #include <strings.h>
 #include <stdlib.h>
 #include "limits.h"
+#include "exitcodes.h"
 
 cmd_send_common(argc, argv)
 	char **argv;
@@ -22,7 +23,7 @@
 		if (*endp) {
 			printf(
 		"error: all arguments to send command must be hex bytes\n");
-			return(1);
+			return(ERROR_USAGE);
 		}
 	}
 	/* send it! */
--- a/rvinterf/asyncshell/sendsp.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/sendsp.c	Wed Oct 26 22:25:18 2016 +0000
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include "pktmux.h"
 #include "limits.h"
+#include "exitcodes.h"
 
 send_gpf_sysprim(stackdest, primstr)
 	char *stackdest, *primstr;
@@ -21,13 +22,13 @@
 	if (strlen(stackdest) > 4) {
 		printf(
 		  "error: stack destination arg may not exceed 4 characters\n");
-		return(1);
+		return(ERROR_USAGE);
 	}
 	intlen = 12 + strlen(primstr);
 	pktlen = intlen + 4;
 	if (pktlen > MAX_PKT_TO_TARGET) {
 		printf("error: max pkt to target limit exceeded\n");
-		return(1);
+		return(ERROR_USAGE);
 	}
 	/* fill out the packet */
 	sendpkt[0] = RVT_L23_HEADER;
--- a/rvinterf/asyncshell/tchcmd.c	Wed Oct 26 22:00:39 2016 +0000
+++ b/rvinterf/asyncshell/tchcmd.c	Wed Oct 26 22:25:18 2016 +0000
@@ -11,6 +11,7 @@
 #include "pktmux.h"
 #include "limits.h"
 #include "tch_feature.h"
+#include "exitcodes.h"
 
 extern u_char rvi_msg[];
 extern int rvi_msg_len;
@@ -42,7 +43,7 @@
 		config = 0;
 	else {
 		printf("error: boolean argument required\n");
-		return(1);
+		return(ERROR_USAGE);
 	}
 	return send_tch_config_req(config);
 }