forked from osmocom/wireshark
Give the time_[m]secs_to routines names that begin with "[un]signed_".
Indicate whether they take a signed time delta or an unsigned time delta. Export unsigned_time_secs_to_str() while we're at it. Change-Id: I0fbe87f1825efa886364caa61a3358b79d285947 Reviewed-on: https://code.wireshark.org/review/15324 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
4013776eec
commit
6febe27586
|
@ -57,7 +57,7 @@ UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE
|
|||
if(len == 4)
|
||||
{
|
||||
milliseconds = tvb_get_ntohl(tvb, offset);
|
||||
ptime = time_msecs_to_str(wmem_packet_scope(), milliseconds);
|
||||
ptime = signed_time_msecs_to_str(wmem_packet_scope(), milliseconds);
|
||||
|
||||
if(hf_index >= 0)
|
||||
{
|
||||
|
|
|
@ -472,7 +472,7 @@ dissect_response_pdu(tvbuff_t *tvb, proto_tree *tree, int offset, int len, guint
|
|||
|
||||
NORLEL(flags, r_uptime, tvb, offset);
|
||||
proto_tree_add_uint_format(subtree, hf_resp_uptime, tvb, offset, 4, r_uptime,
|
||||
"sysUptime: %s", time_msecs_to_str(wmem_packet_scope(), r_uptime));
|
||||
"sysUptime: %s", signed_time_msecs_to_str(wmem_packet_scope(), r_uptime));
|
||||
proto_tree_add_item(subtree, hf_resp_error, tvb, offset + 4, 2, encoding);
|
||||
proto_tree_add_item(subtree, hf_resp_index, tvb, offset + 6, 2, encoding);
|
||||
offset += 8;
|
||||
|
|
|
@ -1635,7 +1635,7 @@ bootp_handle_basic_types(packet_info *pinfo, proto_tree *tree, proto_item *item,
|
|||
if (hf != NULL) {
|
||||
time_s_secs = (gint32) tvb_get_ntohl(tvb, offset);
|
||||
proto_tree_add_int_format_value(tree, *hf,
|
||||
tvb, offset, 4, time_s_secs, "(%ds) %s", time_s_secs, time_secs_to_str(wmem_packet_scope(), time_s_secs));
|
||||
tvb, offset, 4, time_s_secs, "(%ds) %s", time_s_secs, signed_time_secs_to_str(wmem_packet_scope(), time_s_secs));
|
||||
}
|
||||
else if (hf_default->time_in_s_secs != NULL)
|
||||
proto_tree_add_item(tree, *hf_default->time_in_s_secs, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
|
@ -1653,7 +1653,7 @@ bootp_handle_basic_types(packet_info *pinfo, proto_tree *tree, proto_item *item,
|
|||
time_u_secs = tvb_get_ntohl(tvb, offset);
|
||||
proto_tree_add_uint_format_value(tree, *hf,
|
||||
tvb, offset, 4, time_u_secs, "(%us) %s", time_u_secs,
|
||||
((time_u_secs == 0xffffffff) ? "infinity" : time_secs_to_str_unsigned(wmem_packet_scope(), time_u_secs)));
|
||||
((time_u_secs == 0xffffffff) ? "infinity" : unsigned_time_secs_to_str(wmem_packet_scope(), time_u_secs)));
|
||||
}
|
||||
else if (hf_default->time_in_u_secs != NULL)
|
||||
proto_tree_add_item(tree, *hf_default->time_in_u_secs, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
|
|
|
@ -2992,7 +2992,7 @@ static gint dissect_dmp_envelope (tvbuff_t *tvb, packet_info *pinfo,
|
|||
if (secs == DMP_TIME_RESERVED) {
|
||||
proto_item_append_text (tf, "Reserved (0x%2.2x)", time_diff);
|
||||
} else {
|
||||
proto_item_append_text (tf, "%s", time_secs_to_str(wmem_packet_scope(), secs));
|
||||
proto_item_append_text (tf, "%s", signed_time_secs_to_str(wmem_packet_scope(), secs));
|
||||
}
|
||||
offset += 1;
|
||||
}
|
||||
|
@ -3313,9 +3313,9 @@ static gint dissect_dmp_report (tvbuff_t *tvb, packet_info *pinfo,
|
|||
proto_item_append_text (tf, "Reserved (0x%2.2x)", report);
|
||||
proto_item_append_text (ei, " (Reserved)");
|
||||
} else {
|
||||
proto_item_append_text (tf, "%s (%s)", time_secs_to_str(wmem_packet_scope(), secs),
|
||||
proto_item_append_text (tf, "%s (%s)", signed_time_secs_to_str(wmem_packet_scope(), secs),
|
||||
abs_time_secs_to_str (wmem_packet_scope(), dmp.subm_time - secs, ABSOLUTE_TIME_LOCAL, TRUE));
|
||||
proto_item_append_text (ei, " (%s from submission time)", time_secs_to_str(wmem_packet_scope(), secs));
|
||||
proto_item_append_text (ei, " (%s from submission time)", signed_time_secs_to_str(wmem_packet_scope(), secs));
|
||||
}
|
||||
} else {
|
||||
dmp.ndr = TRUE;
|
||||
|
@ -3427,9 +3427,9 @@ static gint dissect_dmp_notification (tvbuff_t *tvb, packet_info *pinfo _U_,
|
|||
proto_item_append_text (tf, "Reserved (0x%2.2x)", rec_time);
|
||||
proto_item_append_text (ei, " (Reserved)");
|
||||
} else {
|
||||
proto_item_append_text (tf, "%s (%s)", time_secs_to_str(wmem_packet_scope(), secs),
|
||||
proto_item_append_text (tf, "%s (%s)", signed_time_secs_to_str(wmem_packet_scope(), secs),
|
||||
abs_time_secs_to_str (wmem_packet_scope(), dmp.subm_time - secs, ABSOLUTE_TIME_LOCAL, TRUE));
|
||||
proto_item_append_text (ei, " (%s from submission time)", time_secs_to_str(wmem_packet_scope(), secs));
|
||||
proto_item_append_text (ei, " (%s from submission time)", signed_time_secs_to_str(wmem_packet_scope(), secs));
|
||||
}
|
||||
offset += 1;
|
||||
|
||||
|
@ -3837,9 +3837,9 @@ static gint dissect_dmp_content (tvbuff_t *tvb, packet_info *pinfo,
|
|||
proto_item_append_text (tf, "Reserved (0x%2.2x)", exp_time);
|
||||
proto_item_append_text (ei, " (Reserved)");
|
||||
} else {
|
||||
proto_item_append_text (tf, "%s (%s)", time_secs_to_str(wmem_packet_scope(), secs),
|
||||
proto_item_append_text (tf, "%s (%s)", signed_time_secs_to_str(wmem_packet_scope(), secs),
|
||||
abs_time_secs_to_str (wmem_packet_scope(), dmp.subm_time + secs, ABSOLUTE_TIME_LOCAL, TRUE));
|
||||
proto_item_append_text (ei, " (%s from submission time)", time_secs_to_str(wmem_packet_scope(), secs));
|
||||
proto_item_append_text (ei, " (%s from submission time)", signed_time_secs_to_str(wmem_packet_scope(), secs));
|
||||
}
|
||||
offset += 1;
|
||||
}
|
||||
|
@ -3861,7 +3861,7 @@ static gint dissect_dmp_content (tvbuff_t *tvb, packet_info *pinfo,
|
|||
dtg_sign.false_string,
|
||||
abs_time_secs_to_str (wmem_packet_scope(), dmp.subm_time, ABSOLUTE_TIME_LOCAL, TRUE));
|
||||
} else {
|
||||
proto_item_append_text (tf, "%s in the %s (%s)", time_secs_to_str(wmem_packet_scope(), secs),
|
||||
proto_item_append_text (tf, "%s in the %s (%s)", signed_time_secs_to_str(wmem_packet_scope(), secs),
|
||||
(dtg & 0x80) ? dtg_sign.true_string :
|
||||
dtg_sign.false_string, (dtg & 0x80) ?
|
||||
abs_time_secs_to_str (wmem_packet_scope(), dmp.subm_time + secs, ABSOLUTE_TIME_LOCAL, TRUE) :
|
||||
|
|
|
@ -1917,19 +1917,19 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
|
|||
cur_offset += 4;
|
||||
|
||||
ti_soa = proto_tree_add_item(rr_tree, hf_dns_soa_refresh_interval, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti_soa, " (%s)", time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
proto_item_append_text(ti_soa, " (%s)", signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
cur_offset += 4;
|
||||
|
||||
ti_soa = proto_tree_add_item(rr_tree, hf_dns_soa_retry_interval, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti_soa, " (%s)", time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
proto_item_append_text(ti_soa, " (%s)", signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
cur_offset += 4;
|
||||
|
||||
ti_soa = proto_tree_add_item(rr_tree, hf_dns_soa_expire_limit, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti_soa, " (%s)", time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
proto_item_append_text(ti_soa, " (%s)", signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
cur_offset += 4;
|
||||
|
||||
ti_soa = proto_tree_add_item(rr_tree, hf_dns_soa_minimum_ttl, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti_soa, " (%s)", time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
proto_item_append_text(ti_soa, " (%s)", signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -2972,7 +2972,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
|
|||
rr_len -= 1;
|
||||
|
||||
ti = proto_tree_add_item(rr_tree, hf_dns_rrsig_original_ttl, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti, " (%s)", time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
proto_item_append_text(ti, " (%s)", signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, cur_offset)));
|
||||
cur_offset += 4;
|
||||
rr_len -= 4;
|
||||
|
||||
|
|
|
@ -1366,7 +1366,7 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
|
|||
proto_tree_add_item_ret_uint(icmp_tree, hf_icmp_num_addrs, tvb, 4, 1, ENC_BIG_ENDIAN, &num_addrs);
|
||||
proto_tree_add_item_ret_uint(icmp_tree, hf_icmp_addr_entry_size, tvb, 5, 1, ENC_BIG_ENDIAN, &addr_entry_size);
|
||||
ti = proto_tree_add_item(icmp_tree, hf_icmp_lifetime, tvb, 6, 2, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti, " (%s)", time_secs_to_str(wmem_packet_scope(), tvb_get_ntohs(tvb, 6)));
|
||||
proto_item_append_text(ti, " (%s)", signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohs(tvb, 6)));
|
||||
break;
|
||||
|
||||
case ICMP_PARAMPROB:
|
||||
|
@ -1576,13 +1576,13 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
|
|||
|
||||
orig_ts = get_best_guess_mstimeofday(tvb, 8, frame_ts);
|
||||
ti = proto_tree_add_item(icmp_tree, hf_icmp_originate_timestamp, tvb, 8, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti, " (%s after midnight UTC)", time_msecs_to_str(wmem_packet_scope(), orig_ts));
|
||||
proto_item_append_text(ti, " (%s after midnight UTC)", signed_time_msecs_to_str(wmem_packet_scope(), orig_ts));
|
||||
|
||||
ti = proto_tree_add_item(icmp_tree, hf_icmp_receive_timestamp, tvb, 12, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti, " (%s after midnight UTC)", time_msecs_to_str(wmem_packet_scope(), get_best_guess_mstimeofday(tvb, 12, frame_ts)));
|
||||
proto_item_append_text(ti, " (%s after midnight UTC)", signed_time_msecs_to_str(wmem_packet_scope(), get_best_guess_mstimeofday(tvb, 12, frame_ts)));
|
||||
|
||||
ti = proto_tree_add_item(icmp_tree, hf_icmp_transmit_timestamp, tvb, 16, 4, ENC_BIG_ENDIAN);
|
||||
proto_item_append_text(ti, " (%s after midnight UTC)", time_msecs_to_str(wmem_packet_scope(), get_best_guess_mstimeofday(tvb, 16, frame_ts)));
|
||||
proto_item_append_text(ti, " (%s after midnight UTC)", signed_time_msecs_to_str(wmem_packet_scope(), get_best_guess_mstimeofday(tvb, 16, frame_ts)));
|
||||
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1065,7 +1065,7 @@ ipmi_add_timestamp(proto_tree *tree, gint hf, tvbuff_t *tvb, guint offset)
|
|||
} else if (ts <= 0x20000000) {
|
||||
proto_tree_add_uint_format_value(tree, hf, tvb, offset, 4,
|
||||
ts, "%s since SEL device's initialization",
|
||||
time_secs_to_str_unsigned(wmem_packet_scope(), ts));
|
||||
unsigned_time_secs_to_str(wmem_packet_scope(), ts));
|
||||
} else {
|
||||
proto_tree_add_uint_format_value(tree, hf, tvb, offset, 4,
|
||||
ts, "%s", abs_time_secs_to_str(wmem_packet_scope(), ts, ABSOLUTE_TIME_UTC, TRUE));
|
||||
|
|
|
@ -1845,7 +1845,7 @@ dissect_mms_TimeOfDay(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _
|
|||
if(len == 4)
|
||||
{
|
||||
milliseconds = tvb_get_ntohl(tvb, offset);
|
||||
ptime = time_msecs_to_str(wmem_packet_scope(), milliseconds);
|
||||
ptime = signed_time_msecs_to_str(wmem_packet_scope(), milliseconds);
|
||||
|
||||
if(hf_index >= 0)
|
||||
{
|
||||
|
|
|
@ -326,7 +326,7 @@ add_rr_to_tree(proto_tree *rr_tree, tvbuff_t *tvb, int offset,
|
|||
proto_tree_add_uint(rr_tree, hf_nbns_class, tvb, offset, 2, class_val);
|
||||
offset += 2;
|
||||
proto_tree_add_uint_format_value(rr_tree, hf_nbns_ttl, tvb, offset, 4, ttl, "%s",
|
||||
time_secs_to_str(wmem_packet_scope(), ttl));
|
||||
signed_time_secs_to_str(wmem_packet_scope(), ttl));
|
||||
offset += 4;
|
||||
proto_tree_add_uint(rr_tree, hf_nbns_data_length, tvb, offset, 2, data_len);
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ dissect_pktc_ap_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int o
|
|||
proto_tree_add_uint_format(tree, hf_pktc_sec_param_lifetime, tvb, offset, 4,
|
||||
tvb_get_ntohl(tvb, offset), "%s: %s",
|
||||
proto_registrar_get_name(hf_pktc_sec_param_lifetime),
|
||||
time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, offset)));
|
||||
signed_time_secs_to_str(wmem_packet_scope(), tvb_get_ntohl(tvb, offset)));
|
||||
offset+=4;
|
||||
|
||||
/* grace period */
|
||||
|
|
|
@ -2036,7 +2036,7 @@ dissect_fastmsg_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int o
|
|||
proto_tree_add_item(fastmsg_tree, hf_selfm_fastmsg_unsresp_doy, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(fastmsg_tree, hf_selfm_fastmsg_unsresp_year, tvb, offset+2, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_uint_format_value(fastmsg_tree, hf_selfm_fastmsg_unsresp_todms, tvb, offset+4, 4,
|
||||
tod_ms, "%s", time_msecs_to_str(wmem_packet_scope(), tod_ms));
|
||||
tod_ms, "%s", signed_time_msecs_to_str(wmem_packet_scope(), tod_ms));
|
||||
offset += 8;
|
||||
|
||||
/* Build element tree */
|
||||
|
@ -2077,7 +2077,7 @@ dissect_fastmsg_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int o
|
|||
proto_tree_add_item(fastmsg_element_tree, hf_selfm_fastmsg_unsresp_elmt_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(fastmsg_element_tree, hf_selfm_fastmsg_unsresp_elmt_ts_ofs, tvb, offset+1, 3, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_uint_format_value(fastmsg_element_tree, hf_selfm_fastmsg_unsresp_elmt_ts_ofs_decoded, tvb, offset+1, 3,
|
||||
tod_ms + (elmt_ts_offset/1000), "%s", time_msecs_to_str(wmem_packet_scope(), tod_ms + (elmt_ts_offset/1000)));
|
||||
tod_ms + (elmt_ts_offset/1000), "%s", signed_time_msecs_to_str(wmem_packet_scope(), tod_ms + (elmt_ts_offset/1000)));
|
||||
proto_tree_add_uint(fastmsg_element_tree, hf_selfm_fastmsg_unsresp_elmt_status, tvb, elmt_status32_ofs, 4, elmt_status);
|
||||
|
||||
offset += 4;
|
||||
|
|
|
@ -566,7 +566,7 @@ dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tr
|
|||
proto_tree_add_uint_format_value(tree, hf_periodicity, tvb, offset, 4,
|
||||
periodicity,
|
||||
"%s",
|
||||
time_msecs_to_str(wmem_packet_scope(), periodicity));
|
||||
signed_time_msecs_to_str(wmem_packet_scope(), periodicity));
|
||||
offset += 4;
|
||||
|
||||
/* server name */
|
||||
|
@ -663,7 +663,7 @@ dissect_mailslot_browse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tr
|
|||
proto_tree_add_uint_format_value(tree, hf_server_uptime,
|
||||
tvb, offset, 4, uptime,
|
||||
"%s",
|
||||
time_msecs_to_str(wmem_packet_scope(), uptime));
|
||||
signed_time_msecs_to_str(wmem_packet_scope(), uptime));
|
||||
offset += 4;
|
||||
|
||||
/* next 4 bytes must be zero */
|
||||
|
@ -810,7 +810,7 @@ dissect_mailslot_lanman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tr
|
|||
proto_tree_add_uint_format_value(tree, hf_periodicity, tvb, offset, 2,
|
||||
periodicity,
|
||||
"%s",
|
||||
time_msecs_to_str(wmem_packet_scope(), periodicity));
|
||||
signed_time_msecs_to_str(wmem_packet_scope(), periodicity));
|
||||
offset += 2;
|
||||
|
||||
/* server name */
|
||||
|
|
|
@ -509,7 +509,7 @@ add_reltime(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo _U_,
|
|||
nstime.nsecs = 0;
|
||||
proto_tree_add_time_format_value(tree, hf_index, tvb, offset, 4,
|
||||
&nstime, "%s",
|
||||
time_secs_to_str(wmem_packet_scope(), (gint32) nstime.secs));
|
||||
signed_time_secs_to_str(wmem_packet_scope(), (gint32) nstime.secs));
|
||||
offset += 4;
|
||||
return offset;
|
||||
}
|
||||
|
@ -651,11 +651,11 @@ add_tzoffset(tvbuff_t *tvb, int offset, int count _U_, packet_info *pinfo _U_,
|
|||
if (tzoffset < 0) {
|
||||
proto_tree_add_int_format_value(tree, hf_tzoffset, tvb, offset, 2,
|
||||
tzoffset, "%s east of UTC",
|
||||
time_secs_to_str(wmem_packet_scope(), -tzoffset*60));
|
||||
signed_time_secs_to_str(wmem_packet_scope(), -tzoffset*60));
|
||||
} else if (tzoffset > 0) {
|
||||
proto_tree_add_int_format_value(tree, hf_tzoffset, tvb, offset, 2,
|
||||
tzoffset, "%s west of UTC",
|
||||
time_secs_to_str(wmem_packet_scope(), tzoffset*60));
|
||||
signed_time_secs_to_str(wmem_packet_scope(), tzoffset*60));
|
||||
} else {
|
||||
proto_tree_add_int_format_value(tree, hf_tzoffset, tvb, offset, 2,
|
||||
tzoffset, "at UTC");
|
||||
|
|
|
@ -4836,7 +4836,7 @@ smbext20_timeout_msecs_to_str(gint32 timeout)
|
|||
return buf;
|
||||
}
|
||||
|
||||
return time_msecs_to_str(wmem_packet_scope(), timeout);
|
||||
return signed_time_msecs_to_str(wmem_packet_scope(), timeout);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -203,7 +203,7 @@ dissect_whoent(tvbuff_t *tvb, int offset, proto_tree *tree)
|
|||
idle_secs = tvb_get_ntohl(tvb, line_offset);
|
||||
proto_tree_add_uint_format(whoent_tree, hf_who_idle, tvb,
|
||||
line_offset, 4, idle_secs, "Idle: %s",
|
||||
time_secs_to_str(wmem_packet_scope(), idle_secs));
|
||||
signed_time_secs_to_str(wmem_packet_scope(), idle_secs));
|
||||
line_offset += 4;
|
||||
|
||||
whoent_num++;
|
||||
|
|
|
@ -9308,7 +9308,7 @@ decode_zcl_ota_req_time(gchar *s, guint32 value)
|
|||
}
|
||||
else {
|
||||
/* offset from now */
|
||||
gchar *tmp = time_secs_to_str(NULL, value);
|
||||
gchar *tmp = signed_time_secs_to_str(NULL, value);
|
||||
g_snprintf(s, ITEM_LABEL_LENGTH, "%s from now", tmp);
|
||||
wmem_free(NULL, tmp);
|
||||
}
|
||||
|
@ -9334,7 +9334,7 @@ decode_zcl_ota_upgr_time(gchar *s, guint32 value)
|
|||
}
|
||||
else {
|
||||
/* offset from now */
|
||||
gchar *tmp = time_secs_to_str(NULL, value);
|
||||
gchar *tmp = signed_time_secs_to_str(NULL, value);
|
||||
g_snprintf(s, ITEM_LABEL_LENGTH, "%s from now", tmp);
|
||||
wmem_free(NULL, tmp);
|
||||
}
|
||||
|
|
|
@ -733,7 +733,7 @@ display_signed_time(gchar *buf, int buflen, const gint32 sec, gint32 frac,
|
|||
* if false.
|
||||
*/
|
||||
static void
|
||||
time_secs_to_str_buf_unsigned(guint32 time_val, const guint32 frac,
|
||||
unsigned_time_secs_to_str_buf(guint32 time_val, const guint32 frac,
|
||||
const gboolean is_nsecs, wmem_strbuf_t *buf)
|
||||
{
|
||||
int hours, mins, secs;
|
||||
|
@ -770,7 +770,7 @@ time_secs_to_str_buf_unsigned(guint32 time_val, const guint32 frac,
|
|||
}
|
||||
|
||||
gchar *
|
||||
time_secs_to_str_unsigned(wmem_allocator_t *scope, const guint32 time_val)
|
||||
unsigned_time_secs_to_str(wmem_allocator_t *scope, const guint32 time_val)
|
||||
{
|
||||
wmem_strbuf_t *buf;
|
||||
|
||||
|
@ -780,7 +780,7 @@ time_secs_to_str_unsigned(wmem_allocator_t *scope, const guint32 time_val)
|
|||
|
||||
buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1, TIME_SECS_LEN+1);
|
||||
|
||||
time_secs_to_str_buf_unsigned(time_val, 0, FALSE, buf);
|
||||
unsigned_time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
||||
|
||||
return wmem_strbuf_finalize(buf);
|
||||
}
|
||||
|
@ -793,8 +793,8 @@ time_secs_to_str_unsigned(wmem_allocator_t *scope, const guint32 time_val)
|
|||
* if false.
|
||||
*/
|
||||
static void
|
||||
time_secs_to_str_buf(gint32 time_val, const guint32 frac, const gboolean is_nsecs,
|
||||
wmem_strbuf_t *buf)
|
||||
signed_time_secs_to_str_buf(gint32 time_val, const guint32 frac,
|
||||
const gboolean is_nsecs, wmem_strbuf_t *buf)
|
||||
{
|
||||
if(time_val < 0){
|
||||
wmem_strbuf_append_printf(buf, "-");
|
||||
|
@ -803,29 +803,29 @@ time_secs_to_str_buf(gint32 time_val, const guint32 frac, const gboolean is_nsec
|
|||
* You can't fit time_val's absolute value into
|
||||
* a 32-bit signed integer. Just directly
|
||||
* pass G_MAXUINT32, which is its absolute
|
||||
* value, directly to time_secs_to_str_buf_unsigned().
|
||||
* value, directly to unsigned_time_secs_to_str_buf().
|
||||
*
|
||||
* (XXX - does ISO C guarantee that -(-2^n),
|
||||
* when calculated and cast to an n-bit unsigned
|
||||
* integer type, will have the value 2^n?)
|
||||
*/
|
||||
time_secs_to_str_buf_unsigned(G_MAXUINT32, frac,
|
||||
unsigned_time_secs_to_str_buf(G_MAXUINT32, frac,
|
||||
is_nsecs, buf);
|
||||
} else {
|
||||
/*
|
||||
* We now know -secs will fit into a guint32;
|
||||
* negate it and pass that to
|
||||
* time_secs_to_str_buf_unsigned().
|
||||
* unsigned_time_secs_to_str_buf().
|
||||
*/
|
||||
time_secs_to_str_buf_unsigned(-time_val, frac,
|
||||
unsigned_time_secs_to_str_buf(-time_val, frac,
|
||||
is_nsecs, buf);
|
||||
}
|
||||
} else
|
||||
time_secs_to_str_buf_unsigned(time_val, frac, is_nsecs, buf);
|
||||
unsigned_time_secs_to_str_buf(time_val, frac, is_nsecs, buf);
|
||||
}
|
||||
|
||||
gchar *
|
||||
time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val)
|
||||
signed_time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val)
|
||||
{
|
||||
wmem_strbuf_t *buf;
|
||||
|
||||
|
@ -835,7 +835,7 @@ time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val)
|
|||
|
||||
buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1, TIME_SECS_LEN+1);
|
||||
|
||||
time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
||||
signed_time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
||||
|
||||
return wmem_strbuf_finalize(buf);
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val)
|
|||
* hours, minutes, and seconds, and put the result into a buffer.
|
||||
*/
|
||||
gchar *
|
||||
time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val)
|
||||
signed_time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val)
|
||||
{
|
||||
wmem_strbuf_t *buf;
|
||||
int msecs;
|
||||
|
@ -867,7 +867,7 @@ time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val)
|
|||
time_val /= 1000;
|
||||
}
|
||||
|
||||
time_secs_to_str_buf(time_val, msecs, FALSE, buf);
|
||||
signed_time_secs_to_str_buf(time_val, msecs, FALSE, buf);
|
||||
|
||||
return wmem_strbuf_finalize(buf);
|
||||
}
|
||||
|
@ -906,7 +906,7 @@ rel_time_to_str(wmem_allocator_t *scope, const nstime_t *rel_time)
|
|||
time_val = (gint) -rel_time->secs;
|
||||
}
|
||||
|
||||
time_secs_to_str_buf(time_val, nsec, TRUE, buf);
|
||||
signed_time_secs_to_str_buf(time_val, nsec, TRUE, buf);
|
||||
|
||||
return wmem_strbuf_finalize(buf);
|
||||
}
|
||||
|
|
|
@ -104,9 +104,9 @@ WS_DLL_PUBLIC void display_epoch_time(gchar *, int, const time_t, gint32, const
|
|||
|
||||
WS_DLL_PUBLIC void display_signed_time(gchar *, int, const gint32, gint32, const to_str_time_res_t);
|
||||
|
||||
WS_DLL_PUBLIC gchar* time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val);
|
||||
gchar* time_secs_to_str_unsigned(wmem_allocator_t *scope, const guint32);
|
||||
WS_DLL_PUBLIC gchar* time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val);
|
||||
WS_DLL_PUBLIC gchar* signed_time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val);
|
||||
WS_DLL_PUBLIC gchar* unsigned_time_secs_to_str(wmem_allocator_t *scope, const guint32);
|
||||
WS_DLL_PUBLIC gchar* signed_time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val);
|
||||
|
||||
extern void guint32_to_str_buf(guint32 u, gchar *buf, int buf_len);
|
||||
extern void guint64_to_str_buf(guint64 u, gchar *buf, int buf_len);
|
||||
|
|
Loading…
Reference in New Issue