Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
/* to_str.c
|
|
|
|
* Routines for utilities to convert various other types to strings.
|
2001-04-01 02:47:56 +00:00
|
|
|
*
|
2001-09-14 07:23:34 +00:00
|
|
|
* $Id: to_str.c,v 1.13 2001/09/14 07:23:33 guy Exp $
|
2001-04-01 02:47:56 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
2001-04-01 02:47:56 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-02 09:59:41 +00:00
|
|
|
#include <stdlib.h>
|
2001-04-02 10:44:09 +00:00
|
|
|
#include <string.h>
|
2001-04-02 09:59:41 +00:00
|
|
|
|
2001-04-02 02:30:06 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-02 10:44:09 +00:00
|
|
|
#ifdef HAVE_WINSOCK_H
|
2001-09-14 07:10:13 +00:00
|
|
|
# include <winsock.h> /* for "u_char" */
|
2001-04-02 10:44:09 +00:00
|
|
|
#endif
|
|
|
|
|
2001-04-01 02:47:56 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-02 02:30:06 +00:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-01 02:47:56 +00:00
|
|
|
#ifdef NEED_INET_V6DEFS_H
|
|
|
|
# include "inet_v6defs.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "to_str.h"
|
|
|
|
#include "resolv.h"
|
|
|
|
#include "pint.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2001-04-01 17:35:21 +00:00
|
|
|
|
2001-04-01 02:47:56 +00:00
|
|
|
/* Wrapper for the most common case of asking
|
|
|
|
* for a string using a colon as the hex-digit separator.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
ether_to_str(const guint8 *ad)
|
|
|
|
{
|
|
|
|
return ether_to_str_punct(ad, ':');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Places char punct in the string as the hex-digit separator.
|
|
|
|
* If punct is '\0', no punctuation is applied (and thus
|
|
|
|
* the resulting string is 5 bytes shorter)
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
ether_to_str_punct(const guint8 *ad, char punct) {
|
|
|
|
static gchar str[3][18];
|
|
|
|
static gchar *cur;
|
|
|
|
gchar *p;
|
|
|
|
int i;
|
|
|
|
guint32 octet;
|
|
|
|
static const gchar hex_digits[16] = "0123456789abcdef";
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
p = &cur[18];
|
|
|
|
*--p = '\0';
|
|
|
|
i = 5;
|
|
|
|
for (;;) {
|
|
|
|
octet = ad[i];
|
|
|
|
*--p = hex_digits[octet&0xF];
|
|
|
|
octet >>= 4;
|
|
|
|
*--p = hex_digits[octet&0xF];
|
|
|
|
if (i == 0)
|
|
|
|
break;
|
|
|
|
if (punct)
|
|
|
|
*--p = punct;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
ip_to_str(const guint8 *ad) {
|
2001-05-28 20:12:30 +00:00
|
|
|
static gchar str[4][16];
|
2001-04-01 02:47:56 +00:00
|
|
|
static gchar *cur;
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
2001-05-28 20:12:30 +00:00
|
|
|
} else if (cur == &str[1][0]) {
|
2001-04-01 02:47:56 +00:00
|
|
|
cur = &str[2][0];
|
2001-05-28 20:12:30 +00:00
|
|
|
} else if (cur == &str[2][0]) {
|
|
|
|
cur = &str[3][0];
|
2001-04-01 02:47:56 +00:00
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
ip_to_str_buf(ad, cur);
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ip_to_str_buf(const guint8 *ad, gchar *buf)
|
|
|
|
{
|
|
|
|
gchar *p;
|
|
|
|
int i;
|
|
|
|
guint32 octet;
|
|
|
|
guint32 digit;
|
|
|
|
gboolean saw_nonzero;
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
i = 0;
|
|
|
|
for (;;) {
|
|
|
|
saw_nonzero = FALSE;
|
|
|
|
octet = ad[i];
|
|
|
|
digit = octet/100;
|
|
|
|
if (digit != 0) {
|
|
|
|
*p++ = digit + '0';
|
|
|
|
saw_nonzero = TRUE;
|
|
|
|
}
|
|
|
|
octet %= 100;
|
|
|
|
digit = octet/10;
|
|
|
|
if (saw_nonzero || digit != 0)
|
|
|
|
*p++ = digit + '0';
|
|
|
|
digit = octet%10;
|
|
|
|
*p++ = digit + '0';
|
|
|
|
if (i == 3)
|
|
|
|
break;
|
|
|
|
*p++ = '.';
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
ip6_to_str(struct e_in6_addr *ad) {
|
|
|
|
#ifndef INET6_ADDRSTRLEN
|
|
|
|
#define INET6_ADDRSTRLEN 46
|
|
|
|
#endif
|
|
|
|
static gchar buf[INET6_ADDRSTRLEN];
|
|
|
|
|
|
|
|
inet_ntop(AF_INET6, (u_char*)ad, (gchar*)buf, sizeof(buf));
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar*
|
|
|
|
ipx_addr_to_str(guint32 net, const guint8 *ad)
|
|
|
|
{
|
|
|
|
static gchar str[3][8+1+MAXNAMELEN+1]; /* 8 digits, 1 period, NAME, 1 null */
|
|
|
|
static gchar *cur;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
|
|
|
name = get_ether_name_if_known(ad);
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
sprintf(cur, "%s.%s", get_ipxnet_name(net), name);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(cur, "%s.%s", get_ipxnet_name(net), ether_to_str_punct(ad, '\0'));
|
|
|
|
}
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar*
|
|
|
|
ipxnet_to_string(const guint8 *ad)
|
|
|
|
{
|
|
|
|
guint32 addr = pntohl(ad);
|
|
|
|
return ipxnet_to_str_punct(addr, ' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
ipxnet_to_str_punct(const guint32 ad, char punct)
|
|
|
|
{
|
|
|
|
static gchar str[3][12];
|
|
|
|
static gchar *cur;
|
|
|
|
gchar *p;
|
|
|
|
int i;
|
|
|
|
guint32 octet;
|
|
|
|
static const gchar hex_digits[16] = "0123456789ABCDEF";
|
|
|
|
static const guint32 octet_mask[4] =
|
|
|
|
{ 0xff000000 , 0x00ff0000, 0x0000ff00, 0x000000ff };
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
p = &cur[12];
|
|
|
|
*--p = '\0';
|
|
|
|
i = 3;
|
|
|
|
for (;;) {
|
|
|
|
octet = (ad & octet_mask[i]) >> ((3 - i) * 8);
|
|
|
|
*--p = hex_digits[octet&0xF];
|
|
|
|
octet >>= 4;
|
|
|
|
*--p = hex_digits[octet&0xF];
|
|
|
|
if (i == 0)
|
|
|
|
break;
|
|
|
|
if (punct)
|
|
|
|
*--p = punct;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2001-04-01 06:32:10 +00:00
|
|
|
gchar *
|
|
|
|
vines_addr_to_str(const guint8 *addrp)
|
|
|
|
{
|
|
|
|
static gchar str[3][214];
|
|
|
|
static gchar *cur;
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(cur, "%08x.%04x", pntohl(&addrp[0]), pntohs(&addrp[4]));
|
|
|
|
return cur;
|
|
|
|
}
|
2001-04-01 02:47:56 +00:00
|
|
|
|
|
|
|
#define PLURALIZE(n) (((n) > 1) ? "s" : "")
|
|
|
|
#define COMMA(do_it) ((do_it) ? ", " : "")
|
|
|
|
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
/*
|
|
|
|
* Maximum length of a string showing days/hours/minutes/seconds.
|
|
|
|
* (Does not include the terminating '\0'.)
|
|
|
|
*/
|
|
|
|
#define TIME_SECS_LEN (8+1+4+2+2+5+2+2+7+2+2+7)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a value in seconds and fractions of a second to a string,
|
|
|
|
* giving time in days, hours, minutes, and seconds, and put the result
|
|
|
|
* into a buffer.
|
2001-09-14 07:10:13 +00:00
|
|
|
* "is_nsecs" says that "frac" is microseconds if true and milliseconds
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
* if false.
|
|
|
|
*/
|
|
|
|
static void
|
2001-09-14 07:10:13 +00:00
|
|
|
time_secs_to_str_buf(guint32 time, guint32 frac, gboolean is_nsecs,
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
gchar *buf)
|
2001-04-01 02:47:56 +00:00
|
|
|
{
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
static gchar *p;
|
2001-04-01 02:47:56 +00:00
|
|
|
int hours, mins, secs;
|
|
|
|
int do_comma;
|
|
|
|
|
|
|
|
secs = time % 60;
|
|
|
|
time /= 60;
|
|
|
|
mins = time % 60;
|
|
|
|
time /= 60;
|
|
|
|
hours = time % 24;
|
|
|
|
time /= 24;
|
|
|
|
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
p = buf;
|
2001-04-01 02:47:56 +00:00
|
|
|
if (time != 0) {
|
|
|
|
sprintf(p, "%u day%s", time, PLURALIZE(time));
|
|
|
|
p += strlen(p);
|
|
|
|
do_comma = 1;
|
|
|
|
} else
|
|
|
|
do_comma = 0;
|
|
|
|
if (hours != 0) {
|
|
|
|
sprintf(p, "%s%u hour%s", COMMA(do_comma), hours, PLURALIZE(hours));
|
|
|
|
p += strlen(p);
|
|
|
|
do_comma = 1;
|
|
|
|
} else
|
|
|
|
do_comma = 0;
|
|
|
|
if (mins != 0) {
|
|
|
|
sprintf(p, "%s%u minute%s", COMMA(do_comma), mins, PLURALIZE(mins));
|
|
|
|
p += strlen(p);
|
|
|
|
do_comma = 1;
|
|
|
|
} else
|
|
|
|
do_comma = 0;
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
if (secs != 0 || frac != 0) {
|
|
|
|
if (frac != 0) {
|
2001-09-14 07:10:13 +00:00
|
|
|
if (is_nsecs)
|
|
|
|
sprintf(p, "%s%u.%09u seconds", COMMA(do_comma), secs, frac);
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
else
|
|
|
|
sprintf(p, "%s%u.%03u seconds", COMMA(do_comma), secs, frac);
|
|
|
|
} else
|
|
|
|
sprintf(p, "%s%u second%s", COMMA(do_comma), secs, PLURALIZE(secs));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
time_secs_to_str(guint32 time)
|
|
|
|
{
|
|
|
|
static gchar str[3][TIME_SECS_LEN+1];
|
|
|
|
static gchar *cur;
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time == 0) {
|
|
|
|
sprintf(cur, "0 time");
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
time_secs_to_str_buf(time, 0, FALSE, cur);
|
2001-04-01 02:47:56 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2001-07-13 00:27:51 +00:00
|
|
|
gchar *
|
|
|
|
time_msecs_to_str(guint32 time)
|
|
|
|
{
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
static gchar str[3][TIME_SECS_LEN+1+3+1];
|
|
|
|
static gchar *cur;
|
2001-07-13 00:27:51 +00:00
|
|
|
int msecs;
|
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time == 0) {
|
|
|
|
sprintf(cur, "0 time");
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
msecs = time % 1000;
|
|
|
|
time /= 1000;
|
|
|
|
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
time_secs_to_str_buf(time, msecs, FALSE, cur);
|
2001-07-13 00:27:51 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2001-04-01 02:47:56 +00:00
|
|
|
static const char *mon_names[12] = {
|
|
|
|
"Jan",
|
|
|
|
"Feb",
|
|
|
|
"Mar",
|
|
|
|
"Apr",
|
|
|
|
"May",
|
|
|
|
"Jun",
|
|
|
|
"Jul",
|
|
|
|
"Aug",
|
|
|
|
"Sep",
|
|
|
|
"Oct",
|
|
|
|
"Nov",
|
|
|
|
"Dec"
|
|
|
|
};
|
|
|
|
|
|
|
|
gchar *
|
2001-09-14 07:10:13 +00:00
|
|
|
abs_time_to_str(nstime_t *abs_time)
|
2001-04-01 02:47:56 +00:00
|
|
|
{
|
|
|
|
struct tm *tmp;
|
|
|
|
static gchar *cur;
|
2001-05-31 06:48:00 +00:00
|
|
|
static char str[3][3+1+2+2+4+1+2+1+2+1+2+1+6+1 + 5 /* extra */];
|
2001-04-01 02:47:56 +00:00
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
tmp = localtime(&abs_time->secs);
|
2001-07-15 19:14:03 +00:00
|
|
|
if (tmp) {
|
2001-09-14 07:10:13 +00:00
|
|
|
sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%09ld",
|
2001-07-15 19:14:03 +00:00
|
|
|
mon_names[tmp->tm_mon],
|
|
|
|
tmp->tm_mday,
|
|
|
|
tmp->tm_year + 1900,
|
|
|
|
tmp->tm_hour,
|
|
|
|
tmp->tm_min,
|
|
|
|
tmp->tm_sec,
|
2001-09-14 07:10:13 +00:00
|
|
|
(long)abs_time->nsecs);
|
2001-07-15 19:14:03 +00:00
|
|
|
} else {
|
|
|
|
strncpy(cur, "Not representable", sizeof(str[0]));
|
|
|
|
}
|
2001-04-01 02:47:56 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-14 07:10:13 +00:00
|
|
|
display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 frac,
|
|
|
|
time_res_t units)
|
2001-04-01 02:47:56 +00:00
|
|
|
{
|
|
|
|
char *sign;
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
/* If the fractional part of the time stamp is negative,
|
2001-04-01 02:47:56 +00:00
|
|
|
print its absolute value and, if the seconds part isn't
|
|
|
|
(the seconds part should be zero in that case), stick
|
|
|
|
a "-" in front of the entire time stamp. */
|
|
|
|
sign = "";
|
2001-09-14 07:10:13 +00:00
|
|
|
if (frac < 0) {
|
|
|
|
frac = -frac;
|
2001-04-01 02:47:56 +00:00
|
|
|
if (sec >= 0)
|
|
|
|
sign = "-";
|
|
|
|
}
|
2001-09-14 07:10:13 +00:00
|
|
|
switch (units) {
|
|
|
|
|
|
|
|
case MSECS:
|
|
|
|
snprintf(buf, buflen, "%s%d.%03d", sign, sec, frac);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USECS:
|
|
|
|
snprintf(buf, buflen, "%s%d.%06d", sign, sec, frac);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSECS:
|
|
|
|
snprintf(buf, buflen, "%s%d.%09d", sign, sec, frac);
|
|
|
|
break;
|
|
|
|
}
|
2001-04-01 02:47:56 +00:00
|
|
|
}
|
|
|
|
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
/*
|
|
|
|
* Display a relative time as days/hours/minutes/seconds.
|
|
|
|
*/
|
2001-04-01 02:47:56 +00:00
|
|
|
gchar *
|
2001-09-14 07:10:13 +00:00
|
|
|
rel_time_to_str(nstime_t *rel_time)
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
{
|
|
|
|
static gchar *cur;
|
|
|
|
static char str[3][1+TIME_SECS_LEN+1+6+1];
|
|
|
|
char *p;
|
|
|
|
char *sign;
|
|
|
|
guint32 time;
|
2001-09-14 07:10:13 +00:00
|
|
|
gint32 nsec;
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
p = cur;
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
/* If the nanoseconds part of the time stamp is negative,
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
print its absolute value and, if the seconds part isn't
|
|
|
|
(the seconds part should be zero in that case), stick
|
|
|
|
a "-" in front of the entire time stamp. */
|
|
|
|
sign = "";
|
2001-09-14 07:10:13 +00:00
|
|
|
time = rel_time->secs;
|
|
|
|
nsec = rel_time->nsecs;
|
|
|
|
if (time == 0 && nsec == 0) {
|
|
|
|
sprintf(cur, "0.000000000 seconds");
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
return cur;
|
|
|
|
}
|
2001-09-14 07:10:13 +00:00
|
|
|
if (nsec < 0) {
|
|
|
|
nsec = -nsec;
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
*p++ = '-';
|
|
|
|
|
|
|
|
/*
|
2001-09-14 07:10:13 +00:00
|
|
|
* We assume here that "rel_time->secs" is negative
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
* or zero; if it's not, the time stamp is bogus,
|
|
|
|
* with a positive seconds and negative microseconds.
|
|
|
|
*/
|
2001-09-14 07:10:13 +00:00
|
|
|
time = -rel_time->secs;
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
time_secs_to_str_buf(time, nsec, TRUE, p);
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
#define REL_TIME_SECS_LEN (1+10+1+9+1)
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Display a relative time as seconds.
|
|
|
|
*/
|
|
|
|
gchar *
|
2001-09-14 07:10:13 +00:00
|
|
|
rel_time_to_secs_str(nstime_t *rel_time)
|
2001-04-01 02:47:56 +00:00
|
|
|
{
|
|
|
|
static gchar *cur;
|
Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it. Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).
Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()". Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).
svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
|
|
|
static char str[3][REL_TIME_SECS_LEN];
|
2001-04-01 02:47:56 +00:00
|
|
|
|
|
|
|
if (cur == &str[0][0]) {
|
|
|
|
cur = &str[1][0];
|
|
|
|
} else if (cur == &str[1][0]) {
|
|
|
|
cur = &str[2][0];
|
|
|
|
} else {
|
|
|
|
cur = &str[0][0];
|
|
|
|
}
|
|
|
|
|
2001-09-14 07:10:13 +00:00
|
|
|
display_signed_time(cur, REL_TIME_SECS_LEN, rel_time->secs,
|
|
|
|
rel_time->nsecs, NSECS);
|
2001-04-01 02:47:56 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate, into "buf", a string showing the bits of a bitfield.
|
|
|
|
Return a pointer to the character after that string. */
|
|
|
|
char *
|
|
|
|
decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
guint32 bit;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
p = buf;
|
|
|
|
bit = 1 << (width - 1);
|
|
|
|
for (;;) {
|
|
|
|
if (mask & bit) {
|
|
|
|
/* This bit is part of the field. Show its value. */
|
|
|
|
if (val & bit)
|
|
|
|
*p++ = '1';
|
|
|
|
else
|
|
|
|
*p++ = '0';
|
|
|
|
} else {
|
|
|
|
/* This bit is not part of the field. */
|
|
|
|
*p++ = '.';
|
|
|
|
}
|
|
|
|
bit >>= 1;
|
|
|
|
i++;
|
|
|
|
if (i >= width)
|
|
|
|
break;
|
|
|
|
if (i % 4 == 0)
|
|
|
|
*p++ = ' ';
|
|
|
|
}
|
|
|
|
strcpy(p, " = ");
|
|
|
|
p += 3;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a string describing a Boolean bitfield (a one-bit field that
|
|
|
|
says something is either true of false). */
|
|
|
|
const char *
|
|
|
|
decode_boolean_bitfield(guint32 val, guint32 mask, int width,
|
|
|
|
const char *truedesc, const char *falsedesc)
|
|
|
|
{
|
|
|
|
static char buf[1025];
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = decode_bitfield_value(buf, val, mask, width);
|
|
|
|
if (val & mask)
|
|
|
|
strcpy(p, truedesc);
|
|
|
|
else
|
|
|
|
strcpy(p, falsedesc);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a string describing a numeric bitfield (an N-bit field whose
|
|
|
|
value is just a number). */
|
|
|
|
const char *
|
|
|
|
decode_numeric_bitfield(guint32 val, guint32 mask, int width,
|
|
|
|
const char *fmt)
|
|
|
|
{
|
|
|
|
static char buf[1025];
|
|
|
|
char *p;
|
|
|
|
int shift = 0;
|
|
|
|
|
|
|
|
/* Compute the number of bits we have to shift the bitfield right
|
|
|
|
to extract its value. */
|
|
|
|
while ((mask & (1<<shift)) == 0)
|
|
|
|
shift++;
|
|
|
|
|
|
|
|
p = decode_bitfield_value(buf, val, mask, width);
|
|
|
|
sprintf(p, fmt, (val & mask) >> shift);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|