2016-12-12 00:16:52 +00:00
|
|
|
/* unit_strings.c
|
|
|
|
* Units to append to field values
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2016-12-12 00:16:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2016-12-13 19:26:27 +00:00
|
|
|
#include <wsutil/utf8_entities.h>
|
2016-12-12 00:16:52 +00:00
|
|
|
#include <wsutil/str_util.h>
|
|
|
|
#include "unit_strings.h"
|
|
|
|
|
2018-02-21 05:34:04 +00:00
|
|
|
const char* unit_name_string_get_value(guint32 value, const unit_name_string* units)
|
2016-12-12 00:16:52 +00:00
|
|
|
{
|
|
|
|
if (units->plural == NULL)
|
|
|
|
return units->singular;
|
|
|
|
|
|
|
|
return plurality(value, units->singular, units->plural);
|
|
|
|
}
|
|
|
|
|
2018-02-21 05:34:04 +00:00
|
|
|
const char* unit_name_string_get_value64(guint64 value, const unit_name_string* units)
|
2016-12-12 00:16:52 +00:00
|
|
|
{
|
|
|
|
if (units->plural == NULL)
|
|
|
|
return units->singular;
|
|
|
|
|
|
|
|
return plurality(value, units->singular, units->plural);
|
|
|
|
}
|
|
|
|
|
2018-02-21 05:34:04 +00:00
|
|
|
const char* unit_name_string_get_double(double value, const unit_name_string* units)
|
2017-05-14 00:05:52 +00:00
|
|
|
{
|
|
|
|
if (units->plural == NULL)
|
|
|
|
return units->singular;
|
|
|
|
|
|
|
|
return plurality(value, units->singular, units->plural);
|
|
|
|
}
|
|
|
|
|
2016-12-12 00:16:52 +00:00
|
|
|
/*
|
|
|
|
* A default set of unit strings that dissectors can use for
|
|
|
|
* header fields. Some units intentionally have a space
|
|
|
|
* character in them for spacing between unit and value
|
|
|
|
*/
|
|
|
|
const unit_name_string units_foot_feet = { " foot", " feet" };
|
|
|
|
const unit_name_string units_bit_bits = { " bit", " bits" };
|
|
|
|
const unit_name_string units_byte_bytes = { " byte", " bytes" };
|
2017-06-13 15:31:21 +00:00
|
|
|
const unit_name_string units_byte_bytespsecond = { " byte/s", " bytes/s" };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_octet_octets = { " octet", " octets" };
|
2016-12-12 00:16:52 +00:00
|
|
|
const unit_name_string units_word_words = { " word", " words" };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_tick_ticks = { " tick", " ticks" };
|
2016-12-16 22:33:49 +00:00
|
|
|
const unit_name_string units_meters = { "m", NULL };
|
2016-12-15 18:01:27 +00:00
|
|
|
const unit_name_string units_meter_meters = { " meter", " meters" };
|
2016-12-17 14:53:40 +00:00
|
|
|
const unit_name_string units_week_weeks = { " week", " weeks" };
|
|
|
|
const unit_name_string units_day_days = { " day", " days" };
|
2016-12-16 22:33:49 +00:00
|
|
|
const unit_name_string units_hour_hours = { " hour", " hours" };
|
|
|
|
const unit_name_string units_hours = { "h", NULL };
|
|
|
|
const unit_name_string units_minute_minutes = { " minute", " minutes" };
|
|
|
|
const unit_name_string units_minutes = { "min", NULL };
|
2016-12-12 00:16:52 +00:00
|
|
|
const unit_name_string units_second_seconds = { " second", " seconds" };
|
|
|
|
const unit_name_string units_seconds = { "s", NULL };
|
|
|
|
const unit_name_string units_millisecond_milliseconds = { " millisecond", " milliseconds" };
|
|
|
|
const unit_name_string units_milliseconds = { "ms", NULL };
|
2016-12-15 18:01:27 +00:00
|
|
|
const unit_name_string units_microsecond_microseconds = { " microsecond", " microseconds" };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_microseconds = { UTF8_MICRO_SIGN "s", NULL };
|
2016-12-12 18:22:05 +00:00
|
|
|
const unit_name_string units_nanosecond_nanoseconds = { " nanosecond", " nanoseconds" };
|
2016-12-16 22:33:49 +00:00
|
|
|
const unit_name_string units_nanoseconds = { "ns", NULL };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_nanometers = { "nm", NULL };
|
2016-12-12 18:22:05 +00:00
|
|
|
const unit_name_string units_degree_degrees = { " degree", " degrees" };
|
2017-05-07 20:00:06 +00:00
|
|
|
const unit_name_string units_degree_celsius = { UTF8_DEGREE_SIGN "C", NULL };
|
2018-01-04 08:26:20 +00:00
|
|
|
const unit_name_string units_degree_bearing = { UTF8_DEGREE_SIGN, NULL };
|
2016-12-16 07:54:56 +00:00
|
|
|
const unit_name_string units_decibels = { "dB", NULL };
|
2016-12-14 22:34:56 +00:00
|
|
|
const unit_name_string units_dbm = { "dBm", NULL };
|
2016-12-16 22:33:49 +00:00
|
|
|
const unit_name_string units_dbi = { "dBi", NULL };
|
2017-04-14 08:14:09 +00:00
|
|
|
const unit_name_string units_mbm = { "mBm", NULL };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_percent = { "%", NULL };
|
2016-12-15 18:01:27 +00:00
|
|
|
const unit_name_string units_khz = { "kHz", NULL };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_mhz = { "MHz", NULL };
|
2016-12-12 18:22:05 +00:00
|
|
|
const unit_name_string units_ghz = { "GHz", NULL };
|
|
|
|
const unit_name_string units_hz = { "Hz", NULL };
|
|
|
|
const unit_name_string units_hz_s = { "Hz/s", NULL };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_kbit = { "kbit", NULL };
|
|
|
|
const unit_name_string units_kbps = { "Kbps", NULL };
|
2016-12-15 18:01:27 +00:00
|
|
|
const unit_name_string units_kibps = { "KiB/s", NULL };
|
2017-05-07 20:00:06 +00:00
|
|
|
const unit_name_string units_km = { "km", NULL };
|
2016-12-15 18:01:27 +00:00
|
|
|
const unit_name_string units_kmh = { "km/h", NULL };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_bit_sec = { "bits/s", NULL };
|
2017-05-07 20:00:06 +00:00
|
|
|
const unit_name_string units_milliamps = { "mA", NULL };
|
2016-12-16 20:35:13 +00:00
|
|
|
const unit_name_string units_microwatts = { UTF8_MICRO_SIGN "W", NULL };
|
2017-05-07 20:00:06 +00:00
|
|
|
const unit_name_string units_volt = { "V", NULL };
|
|
|
|
const unit_name_string units_grams_per_second = { "g/s", NULL };
|
2016-12-16 20:35:13 +00:00
|
|
|
const unit_name_string units_meter_sec = { "m/s", NULL };
|
|
|
|
const unit_name_string units_meter_sec_squared = { "m/s" UTF8_SUPERSCRIPT_TWO , NULL };
|
2016-12-13 19:26:27 +00:00
|
|
|
const unit_name_string units_segment_remaining = { " segment remaining", " segments remaining" };
|
2017-01-17 16:35:36 +00:00
|
|
|
const unit_name_string units_frame_frames = { " frame", " frames" };
|
2017-05-07 20:00:06 +00:00
|
|
|
const unit_name_string units_revolutions_per_minute = { "rpm", NULL };
|
|
|
|
const unit_name_string units_kilopascal = { "kPa", NULL };
|
|
|
|
const unit_name_string units_newton_metre = { "Nm", NULL };
|
|
|
|
const unit_name_string units_liter_per_hour = { "L/h", NULL };
|
2017-09-22 09:24:05 +00:00
|
|
|
const unit_name_string units_amp = { "A", NULL };
|
|
|
|
const unit_name_string units_watthour = { "Wh", NULL };
|
|
|
|
const unit_name_string units_watt = { "W", NULL };
|
2016-12-12 18:22:05 +00:00
|
|
|
|
2016-12-12 00:16:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
2016-12-16 07:54:56 +00:00
|
|
|
*/
|