diff options
author | Werner Koch <wk@gnupg.org> | 2003-12-16 17:31:42 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2003-12-16 17:31:42 +0100 |
commit | d27fc828d7beca6dad0ccc83a06824e987bd4018 (patch) | |
tree | 6a75c5aa5ed6dba5551b6d45a0e12cfd51f6e989 /tools/watchgnupg.c | |
parent | * gpgsm.c (main): Set the prefixes for assuan logging. (diff) | |
download | gnupg2-d27fc828d7beca6dad0ccc83a06824e987bd4018.tar.xz gnupg2-d27fc828d7beca6dad0ccc83a06824e987bd4018.zip |
print the time.
Diffstat (limited to '')
-rw-r--r-- | tools/watchgnupg.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/watchgnupg.c b/tools/watchgnupg.c index d74119a1a..63daab11e 100644 --- a/tools/watchgnupg.c +++ b/tools/watchgnupg.c @@ -28,7 +28,7 @@ #include <unistd.h> #include <sys/socket.h> #include <sys/un.h> - +#include <time.h> #define PGM "watchgnupg" @@ -107,6 +107,20 @@ typedef struct client_s *client_t; +static void +print_fd_and_time (int fd) +{ + struct tm *tp; + time_t atime = time (NULL); + + tp = localtime (&atime); + printf ("%3d - %04d-%02d-%02d %02d:%02d:%02d ", + fd, + 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, + tp->tm_hour, tp->tm_min, tp->tm_sec ); +} + + /* Print LINE for the client identified by C. Calling this function witgh LINE set to NULL, will flush the internal buffer. */ static void @@ -119,7 +133,7 @@ print_line (client_t c, const char *line) { if (c->buffer && c->len) { - printf ("%3d - ", c->fd); + print_fd_and_time (c->fd); fwrite (c->buffer, c->len, 1, stdout); putc ('\n', stdout); c->len = 0; @@ -129,7 +143,7 @@ print_line (client_t c, const char *line) while ((s = strchr (line, '\n'))) { - printf ("%3d - ", c->fd); + print_fd_and_time (c->fd); if (c->buffer && c->len) { fwrite (c->buffer, c->len, 1, stdout); |