aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/wtap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-11-16 02:15:47 -0800
committerGuy Harris <guy@alum.mit.edu>2018-11-16 12:21:00 +0000
commitb894c53d5ea1395e042bb05e471d651af486dfab (patch)
tree9bd6a6c5168fe4c4594508c912765a342ab9afe0 /wiretap/wtap.c
parenteea4997f7e52e0126448225dfd04da840f73ec0c (diff)
Add an API to get a description of a compression type, and use it.
Add wtap_compression_type_description(), which returns NULL for WTAP_UNCOMPRESSED and a descriptive string for other compression types. Instead of checking for WTAP_GZIP_COMPRESSED and appending "(gzip compressed)", just pass the compression type to wtap_compression_type_description() and, if the result is non-null, append its result, wrapped in parentheses, with a space before the left parenthesis. Change-Id: I79a999c7838a883953795d5cbab009966e14b65e Reviewed-on: https://code.wireshark.org/review/30666 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/wtap.c')
-rw-r--r--wiretap/wtap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 3b7c31891f..a9ee84c3eb 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -86,6 +86,18 @@ wtap_get_compression_type(wtap *wth)
return is_compressed ? WTAP_GZIP_COMPRESSED : WTAP_UNCOMPRESSED;
}
+static const char *compression_type_descriptions[WTAP_NUM_COMPRESSION_TYPES] = {
+ NULL, /* uncompressed */
+ "gzip compressed"
+};
+
+const char *
+wtap_compression_type_description(wtap_compression_type compression_type)
+{
+ g_assert(compression_type >= 0 && compression_type < WTAP_NUM_COMPRESSION_TYPES);
+ return compression_type_descriptions[compression_type];
+}
+
guint
wtap_snapshot_length(wtap *wth)
{