Newsgroups: alt.sources,comp.os.linux.announce
From: uknf@rzstud1.rz.uni-karlsruhe.de (Olaf Titz)
Subject: Corrections and new feature for term 1.14
Message-ID: <1994Mar30.174923.22512@cs.cornell.edu>
Date: Wed, 30 Mar 1994 17:49:23 GMT
Approved: linux-announce@tc.cornell.edu (Matt Welsh)

Archive-name: term1.14.patch-ot-1a
Submitted-by: Olaf Titz <uknf@rz.uni-karlsruhe.de>

[Term allows you to multiplex your serial line, allowing multiple
processes to communicate on the same dialup connection.]

This patch fixes some minor errors in term 1.14 and adds an additional
feature: you can use "tshutdown" to shut down both local and remote
term daemon at once. Makes use of the defined but not implemented
C_QUIT protocol. The other fixes are mostly format strings, library
functions (thanks gcc -Wall) and corrections to get it to compile w/o
modifications under HPUX, and the right version number. :-)

Olaf

(I really want to clean up the Makefile sometimes...)

--- term114/Makefile	Mon Feb 14 04:16:14 1994
+++ term114p1/Makefile	Wed Mar 30 13:59:36 1994
@@ -55,6 +55,7 @@
 XCONNOBJS=xconn.o client.a
 STATOBJS=tmon.o client.a
+SHUTDOWNOBJS=shutdown.o client.a
 
-PROGS=term trsh tupload txconn tredir tmon
+PROGS=term trsh tupload txconn tredir tmon tshutdown
 
 MANPAGES=term.1 term_clients.1 term_setup.1 tupload.1 tredir.1 \
@@ -99,8 +100,9 @@
 		$(DO)
 
+# you can use gcc on hp instead of c89
 hpux:
 	$(MAKE) CC="c89" \
 		OSLINK=" -Aa -s" \
-		RANLIB=ranlib \
+		RANLIB=echo \
 		INSTALL=cp \
 		INSTPGMFLAGS="" \
@@ -128,5 +130,5 @@
 	for i in $(PROGS);\
 	do \
-	$(INSTALL) -c $(INSTPGMFLAGS)  $$i $(DESTDIR)$(BINDIR);\
+	$(INSTALL)  $(INSTPGMFLAGS)  $$i $(DESTDIR)$(BINDIR);\
 	done
 
@@ -166,4 +168,7 @@
 	$(CC) $(LINKFLAGS) -o txconn $(XCONNOBJS) $(LIBS)
 
+tshutdown: $(SHUTDOWNOBJS)
+	$(CC) $(LINKFLAGS) -o tshutdown $(SHUTDOWNOBJS) $(LIBS)
+
 tmon: $(STATOBJS)
 	$(CC) $(LINKFLAGS) -o tmon $(STATOBJS) $(CURSES) $(LIBS)
--- term114/client.c	Tue Mar  9 06:12:19 1993
+++ term114p1/client.c	Mon Mar 28 18:46:59 1994
@@ -104,5 +104,5 @@
 				/* If the command is C_DUMB, then no */
 				/* reply will be forthcoming. */
-  if (comm == C_DUMB) return 1;
+  if ((comm == C_DUMB) || (comm == C_QUIT)) return 1;
 
   i = 0;
--- term114/compress.c	Mon Feb  7 07:58:05 1994
+++ term114p1/compress.c	Wed Mar 30 13:47:58 1994
@@ -136,5 +136,5 @@
     ret = ret & unc_token_mask;
     *curr += unc_token_bits;
-    DEBUG_C(stderr, "c_got: %d\n", ret);
+    DEBUG_C(stderr, "c_got: %ld\n", ret);
     return (unsigned int) ret;
 }
--- term114/link.c	Mon Feb 14 04:19:55 1994
+++ term114p1/link.c	Wed Mar 30 13:48:01 1994
@@ -49,5 +49,5 @@
 /*-----------------------------------------------------------------------*/
 void do_link_out(void) {
-  int len, n;
+  int len;
   /* Add another packet to the out packet list */
   
@@ -643,5 +643,5 @@
       }
       
-      DEBUG_FP(stderr, "%s:sockname returned %u,%u\n", term_server,
+      DEBUG_FP(stderr, "%s:sockname returned %lX,%lu\n", term_server,
              addr.sin_addr.s_addr, addr.sin_port);
       ret_ok(cl, local);
@@ -665,4 +665,10 @@
     }
     break;
+
+  case C_QUIT:
+    DEBUG_FP(stderr, "%s: C_QUIT\n", term_server);
+    do_shutdown = 1;
+    ret_ok(cl, local);
+    break;
 
   default:
--- term114/main.c	Thu Feb 24 06:26:03 1994
+++ term114p1/main.c	Wed Mar 30 13:48:07 1994
@@ -265,5 +265,5 @@
       packet_timeout = atoi(file + 8);
       if (packet_timeout < 10 || packet_timeout > 240) {
-	fprintf(stderr, "Invalid timeout value (%u). Must be in [10..240]\n", packet_timeout);
+	fprintf(stderr, "Invalid timeout value (%lu). Must be in [10..240]\n", packet_timeout);
 	packet_timeout = 50;
       }
@@ -396,5 +396,5 @@
       packet_timeout = atoi(optarg);
       if (packet_timeout < 10 || packet_timeout > 240) {
-	fprintf(stderr, "Invalid timeout value (%u).\n", packet_timeout);
+	fprintf(stderr, "Invalid timeout value (%lu).\n", packet_timeout);
 	packet_timeout = 50;
       }
@@ -653,9 +653,10 @@
 				/* This is only for my own purposes. */
 
+#if 0
 /* Set the timeout value for select(). */
     timeout.tv_sec = 0;
     timeout.tv_usec = 20000; /* 0.02 seconds */
     select(0, 0, 0, 0, &timeout);
-
+#endif
 
 /* Set the timeout value for select(). */
--- term114/pty.c	Mon Feb 14 04:33:56 1994
+++ term114p1/pty.c	Wed Mar 30 13:49:04 1994
@@ -2,4 +2,5 @@
 #define I_SOCKET
 #define I_ERRNO
+#define I_STRING
 #define I_SYS
 #include "includes.h"
@@ -239,6 +240,6 @@
     progname = a[0];
     if (loginshell) {
-	sprintf(argv0, "-%s", strrchr(a[0], '/') ? strrchr(a[0], '/') + 1 :
-	a[0]);
+        char *ae = strrchr(a[0], '/');
+	sprintf(argv0, "-%s", (ae) ? ++ae : a[0]);
 	a[0] = argv0;
 	}
--- term114/select.c	Mon Feb  7 08:02:45 1994
+++ term114p1/select.c	Wed Mar 30 13:48:00 1994
@@ -1,4 +1,5 @@
 #define I_SYS
 #define I_ERRNO
+#define I_STRING
 #include "includes.h"
 
--- term114/serial.c	Mon Feb  7 08:02:45 1994
+++ term114p1/serial.c	Wed Mar 30 13:56:11 1994
@@ -236,5 +236,5 @@
   put_serial((j >> 8) & 255);
   if (p_out[l].timeout)
-    WARNING(stderr, "%s:timed out at %d trans %d\n", term_server, 
+    WARNING(stderr, "%s:timed out at %ld trans %d\n", term_server, 
 	    current_time - p_out[l].timeout, p_out[l].trans);
   p_out[l].timeout = current_time;
--- term114/term.h	Sat Feb  5 09:53:56 1994
+++ term114p1/term.h	Sat Mar 26 00:23:13 1994
@@ -1,5 +1,5 @@
 
 
-#define VERSION "1.12"
+#define VERSION "1.14"
 
 #include "config.h"
--- /dev/null	Wed Mar 30 17:03:32 1994
+++ term114p1/shutdown.c	Mon Mar 28 19:00:45 1994
@@ -0,0 +1,38 @@
+#include "includes.h"
+#include "client.h"
+
+int debug = 0;
+int verbose = 0;
+
+static int local_options ( char opt, char *optarg )
+{
+  switch(opt)
+  {
+  case 'v' :
+    verbose = 1; 
+    break;
+  default:
+    return -1;
+  }
+  return 0;
+}
+
+void main(int argc, char *argv[]) {
+  int s;
+
+  (void) client_options(argc, argv,"v",local_options);
+
+  if ((s = connect_server(term_server)) <0) {
+    perror("Couldn't open term");
+    exit(1);
+  }
+
+  if (verbose) 
+    printf ("Shutting down remote...\n");
+  if (send_command(s, C_QUIT, 0, 0) < 0)
+    fprintf(stderr,"Couldn't shutdown remote: %u\n", term_errno);
+  if (verbose)
+    printf ("Shutting down local...\n");
+  if (send_command(s, C_QUIT, 1, 0) < 0)
+    fprintf(stderr,"Couldn't shutdown local: %u\n", term_errno);
+}
-- 
        olaf titz     o       olaf@bigred.ka.sub.org          praetorius@irc
  comp.sc.student    _>\ _         s_titz@ira.uka.de      LINUX - the choice
karlsruhe germany   (_)<(_)      uknf@dkauni2.bitnet     of a GNU generation
what good is a photograph of you? everytime i look at it it makes me feel blue
