2 * Units to append to field values
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include <wsutil/utf8_entities.h>
26 #include <wsutil/str_util.h>
27 #include "unit_strings.h"
29 char* unit_name_string_get_value(guint32 value, unit_name_string* units)
31 if (units->plural == NULL)
32 return units->singular;
34 return plurality(value, units->singular, units->plural);
37 char* unit_name_string_get_value64(guint64 value, unit_name_string* units)
39 if (units->plural == NULL)
40 return units->singular;
42 return plurality(value, units->singular, units->plural);
46 * A default set of unit strings that dissectors can use for
47 * header fields. Some units intentionally have a space
48 * character in them for spacing between unit and value
50 const unit_name_string units_foot_feet = { " foot", " feet" };
51 const unit_name_string units_bit_bits = { " bit", " bits" };
52 const unit_name_string units_byte_bytes = { " byte", " bytes" };
53 const unit_name_string units_octet_octets = { " octet", " octets" };
54 const unit_name_string units_word_words = { " word", " words" };
55 const unit_name_string units_tick_ticks = { " tick", " ticks" };
56 const unit_name_string units_second_seconds = { " second", " seconds" };
57 const unit_name_string units_seconds = { "s", NULL };
58 const unit_name_string units_millisecond_milliseconds = { " millisecond", " milliseconds" };
59 const unit_name_string units_milliseconds = { "ms", NULL };
60 const unit_name_string units_microseconds = { UTF8_MICRO_SIGN "s", NULL };
61 const unit_name_string units_nanosecond_nanoseconds = { " nanosecond", " nanoseconds" };
62 const unit_name_string units_nanometers = { "nm", NULL };
63 const unit_name_string units_degree_degrees = { " degree", " degrees" };
64 const unit_name_string units_decibals = { "dB", NULL };
65 const unit_name_string units_percent = { "%", NULL };
66 const unit_name_string units_mhz = { "MHz", NULL };
67 const unit_name_string units_ghz = { "GHz", NULL };
68 const unit_name_string units_hz = { "Hz", NULL };
69 const unit_name_string units_hz_s = { "Hz/s", NULL };
70 const unit_name_string units_kbit = { "kbit", NULL };
71 const unit_name_string units_kbps = { "Kbps", NULL };
72 const unit_name_string units_bit_sec = { "bits/s", NULL };
73 const unit_name_string units_segment_remaining = { " segment remaining", " segments remaining" };
82 * indent-tabs-mode: nil
85 * ex: set shiftwidth=4 tabstop=8 expandtab:
86 * :indentSize=4:tabSize=8:noTabs=true: