blob: 6bb7fe919f68e3006823526202894b5bf1df8fcf [file] [log] [blame]
diff --git a/Makefile.in b/Makefile.in
index 6f41217..ee8f40c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -488,7 +488,8 @@ distdir: $(DISTFILES)
fi; \
done
-test -n "$(am__skip_mode_fix)" \
- || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+ || find "$(distdir)" -type d ! -perm -755 \
+ -exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
@@ -532,17 +533,17 @@ dist dist-all: distdir
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
- bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
- unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
diff --git a/configure b/configure
index f25c412..3b328b7 100755
--- a/configure
+++ b/configure
@@ -4837,6 +4837,54 @@ else
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
+$as_echo_n "checking for clock_gettime in -lrt... " >&6; }
+if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_rt_clock_gettime=yes
+else
+ ac_cv_lib_rt_clock_gettime=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
+$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
+if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRT 1
+_ACEOF
+
+ LIBS="-lrt $LIBS"
+
+else
+ as_fn_error "Could not find librt" "$LINENO" 5
+fi
+
+
ac_config_files="$ac_config_files Makefile"
diff --git a/configure.ac b/configure.ac
index d611b38..583cf97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,8 @@ LIBS="$LIBS -lsocket -lnsl"; break],[AC_MSG_ERROR([Could not find socket library
fi
AC_CHECK_FUNC([getaddrinfo],,[AC_MSG_ERROR([Could not find getaddrinfo library function])])
+AC_CHECK_LIB(rt, clock_gettime, , [AC_MSG_ERROR([Could not find librt])])
+
dnl AC_CHECK_HEADER(X11/X.h,[],[AC_MSG_ERROR([Could not find X11/X.h])])
dnl AC_CHECK_HEADER(X11/Xlib.h,[],[AC_MSG_ERROR([Could not find X11/Xlib.h])])
dnl AC_CHECK_HEADER(X11/extensions/security.h,[],[AC_MSG_ERROR([Could not find X11/extensions/secruity.h])],[#include <X11/Xlib.h>])
diff --git a/main.c b/main.c
index b6b27a6..a8e1725 100644
--- a/main.c
+++ b/main.c
@@ -45,6 +45,7 @@ bool denyallextensions = false;
bool interactive = false;
bool print_timestamps = false;
bool print_reltimestamps = false;
+bool print_uptime = false;
static bool buffered = false;
size_t maxshownlistlen = SIZE_MAX;
@@ -390,7 +391,7 @@ char *strndup(const char *str,size_t n) {
}
#endif
-enum {LO_DEFAULT=0, LO_TIMESTAMPS, LO_RELTIMESTAMPS, LO_VERSION, LO_HELP};
+enum {LO_DEFAULT=0, LO_TIMESTAMPS, LO_RELTIMESTAMPS, LO_UPTIME, LO_VERSION, LO_HELP};
static int long_only_option = 0;
static const struct option longoptions[] = {
{"display", required_argument, NULL, 'd'},
@@ -412,6 +413,7 @@ static const struct option longoptions[] = {
{"version", no_argument, &long_only_option, LO_VERSION},
{"timestamps", no_argument, &long_only_option, LO_TIMESTAMPS},
{"relative-timestamps", no_argument, &long_only_option, LO_RELTIMESTAMPS},
+ {"uptime", no_argument, &long_only_option, LO_UPTIME},
{NULL, 0, NULL, 0}
};
@@ -526,6 +528,9 @@ argv[0]);
case LO_RELTIMESTAMPS:
print_reltimestamps = true;
break;
+ case LO_UPTIME:
+ print_uptime = true;
+ break;
}
break;
case ':':
diff --git a/parse.c b/parse.c
index 8bdd363..b808766 100644
--- a/parse.c
+++ b/parse.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <stdlib.h>
#include <sys/select.h>
+#include <time.h>
#include <unistd.h>
#include "xtrace.h"
@@ -46,6 +47,7 @@ static inline unsigned int padded(unsigned int s) {
static void startline(struct connection *c, enum package_direction d, const char *format, ...) {
va_list ap;
struct timeval tv;
+ struct timespec ts;
if( (print_timestamps || print_reltimestamps)
&& gettimeofday(&tv, NULL) == 0 ) {
@@ -60,6 +62,10 @@ static void startline(struct connection *c, enum package_direction d, const char
(unsigned int)((tt - c->starttime)%1000));
}
}
+ if( print_uptime && clock_gettime(CLOCK_MONOTONIC, &ts ) == 0 ) {
+ fprintf(out, "%lu.%03u ", (unsigned long)ts.tv_sec,
+ (unsigned int)(ts.tv_nsec/1000000));
+ }
va_start(ap, format);
fprintf(out, "%03d:%c:", c->id, (d == TO_SERVER)?'<':'>');
vfprintf(out, format, ap);
@@ -1749,4 +1755,3 @@ const struct extension *find_extension(const uint8_t *name,size_t len) {
return NULL;
}
-
diff --git a/xtrace.h b/xtrace.h
index 95a725a..1c9bd4a 100644
--- a/xtrace.h
+++ b/xtrace.h
@@ -46,6 +46,7 @@ extern bool denyallextensions;
extern size_t maxshownlistlen;
extern bool print_timestamps;
extern bool print_reltimestamps;
+extern bool print_uptime;
#ifdef __GNUC__
#define UNUSED __attribute__ ((unused))