aboutsummaryrefslogtreecommitdiffstats
path: root/epan/to_str.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-02-11 19:42:38 +0000
committerGuy Harris <guy@alum.mit.edu>2003-02-11 19:42:38 +0000
commit1ad3b70b4b761525a789a091308dd7b487b79617 (patch)
tree06d7e070f252e1446aebb636a8a0b4e635cfd0d3 /epan/to_str.c
parentc684f70d833cca4af79663a59694680c9c5ef0ea (diff)
Add a "abs_time_secs_to_str()" routine that takes a UNIX time-since-the-
epoch-in-seconds value and converts it to a string. Use that routine in the RADIUS dissector, rather than using "ctime()" and "tzname[]" - "tzname[]" strings might contain non-ASCII characters, which currently give the GTK+ 1.3[.x] used on Windows, and also, I think, GTK+ 2.x, heartburn, as they expect UTF-8, not, for example, ISO 8859/1. Fix the string length in "abs_time_to_str()". svn path=/trunk/; revision=7124
Diffstat (limited to 'epan/to_str.c')
-rw-r--r--epan/to_str.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/epan/to_str.c b/epan/to_str.c
index a7a7b5d958..a0315c30de 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -1,7 +1,7 @@
/* to_str.c
* Routines for utilities to convert various other types to strings.
*
- * $Id: to_str.c,v 1.23 2003/01/21 05:04:07 guy Exp $
+ * $Id: to_str.c,v 1.24 2003/02/11 19:42:38 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -416,7 +416,7 @@ abs_time_to_str(nstime_t *abs_time)
{
struct tm *tmp;
static gchar *cur;
- static char str[3][3+1+2+2+4+1+2+1+2+1+2+1+6+1 + 5 /* extra */];
+ static char str[3][3+1+2+2+4+1+2+1+2+1+2+1+9+1];
if (cur == &str[0][0]) {
cur = &str[1][0];
@@ -428,17 +428,45 @@ abs_time_to_str(nstime_t *abs_time)
tmp = localtime(&abs_time->secs);
if (tmp) {
- sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%09ld",
- mon_names[tmp->tm_mon],
- tmp->tm_mday,
- tmp->tm_year + 1900,
- tmp->tm_hour,
- tmp->tm_min,
- tmp->tm_sec,
- (long)abs_time->nsecs);
+ sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%09ld",
+ mon_names[tmp->tm_mon],
+ tmp->tm_mday,
+ tmp->tm_year + 1900,
+ tmp->tm_hour,
+ tmp->tm_min,
+ tmp->tm_sec,
+ (long)abs_time->nsecs);
+ } else
+ strncpy(cur, "Not representable", sizeof(str[0]));
+ return cur;
+}
+
+gchar *
+abs_time_secs_to_str(guint32 abs_time)
+{
+ struct tm *tmp;
+ static gchar *cur;
+ static char str[3][3+1+2+2+4+1+2+1+2+1+2+1];
+
+ if (cur == &str[0][0]) {
+ cur = &str[1][0];
+ } else if (cur == &str[1][0]) {
+ cur = &str[2][0];
} else {
- strncpy(cur, "Not representable", sizeof(str[0]));
+ cur = &str[0][0];
}
+
+ tmp = localtime(&abs_time);
+ if (tmp) {
+ sprintf(cur, "%s %2d, %d %02d:%02d:%02d",
+ mon_names[tmp->tm_mon],
+ tmp->tm_mday,
+ tmp->tm_year + 1900,
+ tmp->tm_hour,
+ tmp->tm_min,
+ tmp->tm_sec);
+ } else
+ strncpy(cur, "Not representable", sizeof(str[0]));
return cur;
}