From d94805d59bbd3a4ceb725f5fc4c6e6778dc25709 Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Sun, 13 Jan 2008 16:07:43 +0000 Subject: add NFCT_OF_TIME output flag to nfct_snprintf --- src/conntrack/snprintf_xml.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/conntrack/snprintf_xml.c') diff --git a/src/conntrack/snprintf_xml.c b/src/conntrack/snprintf_xml.c index 1415e0d..9f7f388 100644 --- a/src/conntrack/snprintf_xml.c +++ b/src/conntrack/snprintf_xml.c @@ -341,6 +341,46 @@ int __snprintf_conntrack_xml(char *buf, BUFFER_SIZE(ret, size, len, offset); } + if (flags & NFCT_OF_TIME) { + time_t t; + struct tm tm; + + t = time(NULL); + if (localtime_r(&t, &tm) == NULL) + goto err_out; + + ret = snprintf(buf+offset, len, ""); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%d", tm.tm_hour); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%02d", tm.tm_min); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%02d", tm.tm_sec); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%d", + tm.tm_wday + 1); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%d", tm.tm_mday); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%d", + tm.tm_mon + 1); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "%d", + 1900 + tm.tm_year); + BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, ""); + BUFFER_SIZE(ret, size, len, offset); + } + +err_out: ret = snprintf(buf+offset, len, ""); BUFFER_SIZE(ret, size, len, offset); -- cgit v1.2.3