--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: ttylog: CRLF will cause two lines to be outputted
- From: "Klaus S. Madsen" <debian@hjernemadsen.org>
- Date: Wed, 10 Nov 2004 17:21:52 +0100
- Message-id: <20041110162152.39027B054180@localhost>
Package: ttylog
Version: 0.1.b-3
Severity: normal
Tags: patch
When the CRLF combination is recieved, ttylog ouputs 2 lines instead of
one. This is caused by the ICRNL option used to setup the connection.
The attatched patch fixes this problem, and all other outstanding
bugreports for this package. It also includes a new option to timestamp
the serial output. Lastly I have moved the binary from /usr/sbin to
/usr/bin, since normal users can have access to the serialports.
It also bumps the version number to 0.1.c.
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-rc4
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Versions of packages ttylog depends on:
ii libc6 2.3.2.ds1-18 GNU C Library: Shared libraries an
-- no debconf information
diff -ur ttylog-0.1.b/debian/changelog ttylog-0.1.c/debian/changelog
--- ttylog-0.1.b/debian/changelog 2002-11-04 16:20:12.000000000 +0100
+++ ttylog-0.1.c/debian/changelog 2004-11-10 16:42:09.000000000 +0100
@@ -1,3 +1,15 @@
+ttylog (0.1.c-1) unstable; urgency=low
+
+ * Added support for 4800 baud-rate - Closes: bug#203356
+ * -f no longer causes the program to output "flushed." - Closes: bug#267872
+ * Changed ICRNL to IGNCR, so \r\n don't become two lines. Allows the
+ removal of del1013, which fixes a memory-leak - Closes: bug#271098
+ * Added -t option which will add a timestamp at the beginning of each line
+ * Moved the binary from /usr/sbin to /usr/bin, so normal users can start the
+ program.
+
+ -- Klaus S. Madsen <ksm@hjernemadsen.org> Wed, 10 Nov 2004 16:24:24 +0100
+
ttylog (0.1.b-3) unstable; urgency=low
* Using optional output flush - Closes: bug#164778
diff -ur ttylog-0.1.b/Makefile ttylog-0.1.c/Makefile
--- ttylog-0.1.b/Makefile 2002-01-12 20:27:52.000000000 +0100
+++ ttylog-0.1.c/Makefile 2004-11-10 17:13:57.000000000 +0100
@@ -15,5 +15,6 @@
rm -f *.o ttylog core *~
install: ttylog
- $(INS) -o root -g root -m 0755 -s ttylog $(DESTDIR)/usr/sbin
- $(INS) -o root -g root -m 0444 ttylog.8 $(DESTDIR)/usr/share/man/man8
+ $(INS) -o root -g root -m 0755 -d $(DESTDIR)/usr/bin
+ $(INS) -o root -g root -m 0755 -s ttylog $(DESTDIR)/usr/bin/ttylog
+ $(INS) -o root -g root -m 0444 ttylog.8 $(DESTDIR)/usr/share/man/man8/ttylog.8
diff -ur ttylog-0.1.b/ttylog.8 ttylog-0.1.c/ttylog.8
--- ttylog-0.1.b/ttylog.8 1999-06-04 00:00:00.000000000 +0200
+++ ttylog-0.1.c/ttylog.8 2004-11-10 16:47:38.000000000 +0100
@@ -1,4 +1,4 @@
-.TH TTYLOG 8 "04 Jun 1999" "" ""
+.TH TTYLOG 8 "10 Nov 2004" "" ""
.SH NAME
ttylog \- serial device logger
.SH DESCRIPTION
@@ -16,12 +16,15 @@
.TP
.B -b, --baud
Baud rate of the device. Available baud rates:
-300, 1200, 2400, 9600, 19200, 38400, 57600 and 115200
+300, 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200
.TP
-.B -d --device
+.B -d, --device
The serial device. For example /dev/ttyS1
+.TP
+.B -t, --timestamp
+Put a timestamp in front of each recieved line.
.SH AUTHOR
This manual page was written by Tibor Koleszar <t.koleszar@somogy.hu>,
for the Debian GNU/Linux system.
-Last modify: Fri Jun 4 10:36:45 1999
+Last modify: Wed Nov 10 16:47:23 2004
diff -ur ttylog-0.1.b/ttylog.c ttylog-0.1.c/ttylog.c
--- ttylog-0.1.b/ttylog.c 2002-11-04 16:25:46.000000000 +0100
+++ ttylog-0.1.c/ttylog.c 2004-11-10 16:57:16.000000000 +0100
@@ -9,32 +9,17 @@
#include <sys/types.h>
#include <fcntl.h>
-#define VERSION "0.1.a"
-#define BAUDN 8
+#define VERSION "0.1.c"
+#define BAUDN 9
char flush = 0;
+char timestamp = 0;
char *BAUD_T[] =
-{"300", "1200", "2400", "9600", "19200", "38400", "57600", "115200"};
+{"300", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200"};
int BAUD_B[] =
-{B300, B1200, B2400, B9600, B19200, B38400, B57600, B115200};
-
-
-char *
-del1013 (char *str)
-{
- short i;
- char *dummy;
-
- dummy = (char *) malloc (1024);
- dummy[0] = 0;
- for (i = 0; i < strlen (str); i++)
- if (str[i] != 10 && str[i] != 13)
- sprintf (dummy, "%s%c", dummy, str[i]);
-
- return dummy;
-}
+{B300, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200};
int
main (int argc, char *argv[])
@@ -45,7 +30,7 @@
int fd;
char line[1024], modem_device[512];
time_t logdate;
- struct tm *logdate_s;
+ char *logdate_s;
struct termios oldtio, newtio;
@@ -65,6 +50,8 @@
printf ("ttylog version %s. Programmed by Tibor Koleszar <oldw@debian.org>\n", VERSION);
printf ("Usage: \n -h, --help This help\n -v, --version Version number\n");
printf (" -b, --baud Baud rate\n -d, --device Serial device (eg. /dev/ttyS1)\n -f, --flush Flush output\n");
+ printf (" -t, --time Time-stamp the output\n");
+
exit (0);
}
@@ -105,7 +92,10 @@
{
}
}
-
+ if (!strcmp (argv[i], "-t") || !strcmp (argv[i], "--timestamp"))
+ {
+ timestamp = 1;
+ }
}
@@ -128,7 +118,7 @@
bzero (&newtio, sizeof (newtio)); /* clear struct for new port settings */
newtio.c_cflag = BAUD_B[baud] | CRTSCTS | CS8 | CLOCAL | CREAD;
- newtio.c_iflag = IGNPAR | ICRNL;
+ newtio.c_iflag = IGNPAR | IGNCR;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
@@ -148,11 +138,20 @@
if (retval)
{
fgets (line, 1024, logfile);
- strcpy (line, del1013 (line));
- logdate = time (NULL);
- logdate_s = localtime (&logdate);
- printf ("%s\n", line);
- if (flush) { fflush(stdout); printf("flushed.");}
+ if (timestamp)
+ {
+ char* tmp;
+ logdate = time (NULL);
+ logdate_s = ctime(&logdate);
+ tmp = logdate_s;
+ while (*tmp != '\0' && *tmp != '\n')
+ tmp++;
+
+ *tmp = ':';
+ printf("%s ", logdate_s);
+ }
+ printf ("%s", line);
+ if (flush) { fflush(stdout); }
}
}
--- End Message ---