Fixed 'help' and opts.
authorviric@llimona
Sat, 09 Jun 2007 18:07:06 +0200
changeset 2 f08014d5d89f
parent 1 942500ee5032
child 3 01ec0b3b1135
Fixed 'help' and opts.
tcpscript.c
--- a/tcpscript.c	Sat Jun 09 18:01:31 2007 +0200
+++ b/tcpscript.c	Sat Jun 09 18:07:06 2007 +0200
@@ -43,13 +43,11 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
-#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include <sys/file.h>
 #include <sys/signal.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -90,11 +88,8 @@
 #ifndef HAVE_openpty
 char	line[] = "/dev/ptyXX";
 #endif
-int	aflg = 0;
 char	*cflg = NULL;
-int	fflg = 0;
 int	qflg = 0;
-int	tflg = 0;
 int	tcp_port = 4000;
 
 enum {
@@ -140,36 +135,27 @@
 
 	if (argc == 2) {
 		if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {
-			printf("%s from %s\n",
-			       progname, "viric 2007");
+			printf("%s, modification of 'script', by %s\n",
+			       progname, "Lluis Batlle i Rossell 2007");
 			return 0;
 		}
 	}
 
-	while ((ch = getopt(argc, argv, "ac:fqtp:")) != -1)
+	while ((ch = getopt(argc, argv, "c:qp:")) != -1)
 		switch((char)ch) {
-		case 'a':
-			aflg++;
-			break;
 		case 'c':
 			cflg = optarg;
 			break;
 		case 'p':
 			tcp_port = atoi(optarg);
 			break;
-		case 'f':
-			fflg++;
-			break;
 		case 'q':
 			qflg++;
 			break;
-		case 't':
-			tflg++;
-			break;
 		case '?':
 		default:
 			fprintf(stderr,
-				"usage: script [-a] [-f] [-q] [-t] [file]\n");
+				"usage: script [-p port] [-q] [-t] \n");
 			exit(1);
 		}
 	argc -= optind;
@@ -180,8 +166,6 @@
 		shell = _PATH_BSHELL;
 
 	getmaster();
-	if (!qflg)
-		printf("Script started, file is %s\n", fname);
 	fixtty();
 
 	(void) signal(SIGCHLD, finish);
@@ -242,15 +226,6 @@
 	kill(child, SIGWINCH);
 }
 
-/*
- * Stop extremely silly gcc complaint on %c:
- *  warning: `%c' yields only last 2 digits of year in some locales
- */
-static void
-my_strftime(char *buf, size_t len, const char *fmt, const struct tm *tm) {
-	strftime(buf, len, fmt, tm);
-}
-
 void fatal()
 {
     exit(-1);
@@ -277,7 +252,8 @@
     if (s != 0)
         perror("Failed listen()"), fatal();
 
-    printf("Listening on port %i\n", tcp_port);
+    if (!qflg)
+        printf("Listening on port %i\n", tcp_port);
     return s;
 }