openbsd-ports/net/icb/patches/patch-at
brad 47d4e04482 add a feature which allows icb to print the current time in front of every
line by setting the option printtime to true.

From: NetBSD
2000-01-16 11:29:54 +00:00

43 lines
862 B
Plaintext

--- icb/print.c.orig Sun Jan 16 05:27:01 2000
+++ icb/print.c Sun Jan 16 05:32:24 2000
@@ -5,6 +5,7 @@
#include "icb.h"
#include "externs.h"
+#include <time.h>
extern FILE *logfp;
@@ -17,12 +18,22 @@
char printbuf[1024];
char *p = printbuf;
char *t = s;
+ struct tm *tm, *localtime();
+ char timestamp[9];
if (continued) {
linenumber = 0;
continued = 0;
}
+ /* If requested, prepare timestamp */
+ if (gv.printtime) {
+ gettime();
+ tm = localtime(&curtime);
+ snprintf(timestamp, sizeof(timestamp), "[%02d:%02d] ",
+ tm->tm_hour, tm->tm_min);
+ }
+
if (flags & PL_SCR) {
/* if paging in effect, do paging */
if (gv.pagesize && (++linenumber >= gv.pagesize)) {
@@ -35,6 +46,8 @@
*p++ = *t++;
*p++ = '\r';
*p++ = '\n';
+ if (gv.printtime)
+ write(1, timestamp, 8);
write(1, printbuf, p - printbuf);
}