changeset 70:2c6dca514a20

fc-tmsh works like fc-shell and fc-fsio now, following the -p convention
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 23:33:21 +0000
parents 2159f260ed13
children 27c41e4b21ae
files rvinterf/tmsh/init.c rvinterf/tmsh/main.c
diffstat 2 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/tmsh/init.c	Wed Oct 26 23:17:03 2016 +0000
+++ b/rvinterf/tmsh/init.c	Wed Oct 26 23:33:21 2016 +0000
@@ -10,8 +10,6 @@
 #include "pktmux.h"
 #include "localsock.h"
 
-extern int sock;
-
 init()
 {
 	static u_char want_rvt_lost[9] = {CLI2RVI_WANT_RVTRACE,
@@ -22,8 +20,6 @@
 					  0x00, 0x1E, 0x00, 0x04};
 	static u_char want_etm_mux[2] = {CLI2RVI_WANT_MUXPROTO, RVT_TM_HEADER};
 
-	if (!sock)
-		connect_local_socket();
 	localsock_prep_for_length_rx();
 	send_init_command(want_rvt_lost, 9);
 	send_init_command(want_rvt_etm, 9);
--- a/rvinterf/tmsh/main.c	Wed Oct 26 23:17:03 2016 +0000
+++ b/rvinterf/tmsh/main.c	Wed Oct 26 23:33:21 2016 +0000
@@ -10,6 +10,7 @@
 #include "exitcodes.h"
 
 char *socket_pathname = "/tmp/rvinterf_socket";
+char *rvinterf_ttyport;
 int ttyhacks, dflag;
 
 int sock;
@@ -21,10 +22,10 @@
 {
 	extern int optind;
 	extern char *optarg;
-	int c;
+	int c, sopt = 0;
 	fd_set fds;
 
-	while ((c = getopt(argc, argv, "B:dl:s:w:")) != EOF)
+	while ((c = getopt(argc, argv, "B:dl:p:s:w:")) != EOF)
 		switch (c) {
 		case 'B':
 			rvinterf_Bopt = optarg;
@@ -35,8 +36,12 @@
 		case 'l':
 			rvinterf_lopt = optarg;
 			continue;
+		case 'p':
+			rvinterf_ttyport = optarg;
+			continue;
 		case 's':
 			socket_pathname = optarg;
+			sopt++;
 			continue;
 		case 'w':
 			rvinterf_wopt = optarg;
@@ -44,23 +49,25 @@
 		case '?':
 		default:
 usage:			fprintf(stderr,
-				"usage: %s [options] [ttyport]\n", argv[0]);
+				"usage: %s [options] [command]\n", argv[0]);
 			exit(ERROR_USAGE);
 		}
-	switch (argc - optind) {
-	case 0:
-		if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
+	if (rvinterf_ttyport) {
+		if (sopt) {
 			fprintf(stderr,
-      "%s: -B, -l and -w options are meaningful only when launching rvinterf\n",
+			"%s error: -p and -s options are mutually exclusive\n",
 				argv[0]);
 			exit(ERROR_USAGE);
 		}
-		break;
-	case 1:
-		launch_rvinterf(argv[optind]);
-		break;
-	default:
-		goto usage;
+		launch_rvinterf(rvinterf_ttyport);
+	} else {
+		if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
+			fprintf(stderr,
+"%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
+				argv[0]);
+			exit(ERROR_USAGE);
+		}
+		connect_local_socket();
 	}
 
 	ttyhacks = isatty(0) && !dflag;