summaryrefslogtreecommitdiffstats
path: root/wsutil/feature_list.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wsutil/feature_list.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/wsutil/feature_list.h b/wsutil/feature_list.h
new file mode 100644
index 0000000..a9c2d8e
--- /dev/null
+++ b/wsutil/feature_list.h
@@ -0,0 +1,77 @@
+/** @file
+ * Declarations of routines for gathering and handling lists of
+ * present/absent features (usually actually dependencies)
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WSUTIL_FEATURE_LIST_H__
+#define __WSUTIL_FEATURE_LIST_H__
+
+#include <glib.h>
+#include "ws_symbol_export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * Handle to a list of features/dependencies.
+ * Semi-opaque. Functions which gather the list of features
+ * will be passed one of these to use with
+ * `with_feature()`/`without_feature()` (below).
+ */
+typedef GList **feature_list;
+
+/*
+ * The format of entries in a feature_list is a char* starting with a
+ * '+' or '-' character indicating if the feature is respectively
+ * present or absent, followed by the unchanged feature description.
+ * This allows the insert order of features to be preserved,
+ * while still preserving the present/absent status in a simple way.
+ */
+
+
+/*
+ * Pointer to a function which gathers a list of features.
+ */
+typedef void(*gather_feature_func)(feature_list l);
+
+/*
+ * Add an indicator to the given feature_list that the named
+ * feature is present.
+ */
+WS_DLL_PUBLIC
+void with_feature(feature_list l, const char *fmt, ...) G_GNUC_PRINTF(2,3);
+
+/*
+ * Add an indicator to the given feature_list that the named
+ * feature is absent.
+ */
+WS_DLL_PUBLIC
+void without_feature(feature_list l, const char *fmt, ...) G_GNUC_PRINTF(2,3);
+
+/*
+ * Sort the given feature list, alphabetically by feature name.
+ * (The leading '+' or '-' is not factored into the sort.)
+ * Currently unused.
+ */
+WS_DLL_PUBLIC
+void sort_features(feature_list l);
+
+/*
+ * Free the memory used by the feature list,
+ * and reset its pointer to NULL.
+ */
+WS_DLL_PUBLIC
+void free_features(feature_list l);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __WSUTIL_FEATURE_LIST_H__ */