diff options
Diffstat (limited to 'wsutil/feature_list.c')
-rw-r--r-- | wsutil/feature_list.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/wsutil/feature_list.c b/wsutil/feature_list.c new file mode 100644 index 00000000..f0c30d66 --- /dev/null +++ b/wsutil/feature_list.c @@ -0,0 +1,56 @@ +/* feature_list.c + * Routines for gathering and handling lists of present/absent features + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include <stdbool.h> + +#include "config.h" + +#include <wsutil/feature_list.h> + +void +with_feature(feature_list l, const char *fmt, ...) +{ + va_list arg; + GString *msg = g_string_new("+"); + va_start(arg, fmt); + g_string_append_vprintf(msg, fmt, arg); + va_end(arg); + *l = g_list_prepend(*l, g_string_free(msg, false)); +} + +void +without_feature(feature_list l, const char *fmt, ...) +{ + va_list arg; + GString *msg = g_string_new("-"); + va_start(arg, fmt); + g_string_append_vprintf(msg, fmt, arg); + va_end(arg); + *l = g_list_prepend(*l, g_string_free(msg, false)); +} + +static int +feature_sort_alpha(gconstpointer a, gconstpointer b) +{ + return g_ascii_strcasecmp((char *)a + 1, (char *)b + 1); +} + +void +sort_features(feature_list l) +{ + *l = g_list_sort(*l, feature_sort_alpha); +} + +void +free_features(feature_list l) +{ + g_list_free_full(*l, g_free); + *l = NULL; +} |