Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dfilter / dfunctions.h
blob9139001ba6018ad2c9391674379999eeebd77bbf
1 /** @file
3 * Wireshark - Network traffic analyzer
5 * Copyright 2006 Gilbert Ramirez <gram@alumni.rice.edu>
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef DFUNCTIONS_H
11 #define DFUNCTIONS_H
13 #include <glib.h>
14 #include <epan/ftypes/ftypes.h>
15 #include <epan/dfilter/syntax-tree.h>
16 #include <epan/dfilter/dfilter-int.h>
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
22 /* Functions take any number of arguments and return 1. */
24 #define dfunc_fail(dfw, node, ...) \
25 do { \
26 ws_noisy("Semantic check failed here."); \
27 dfilter_fail_throw(dfw, DF_ERROR_GENERIC, stnode_location(node), __VA_ARGS__); \
28 } while (0)
30 /* The run-time logic of the dfilter function */
31 typedef bool (*DFFuncType)(GSList *stack, uint32_t arg_count, df_cell_t *retval);
33 /* The semantic check for the dfilter function */
34 typedef ftenum_t (*DFSemCheckType)(dfwork_t *dfw, const char *func_name, ftenum_t lhs_ftype,
35 GSList *param_list, df_loc_t func_loc);
37 /* This is a "function definition" record, holding everything
38 * we need to know about a function */
39 typedef struct {
40 const char *name;
41 DFFuncType function;
42 unsigned min_nargs;
43 unsigned max_nargs; /* 0 for no limit */
44 ftenum_t return_ftype; /* Can be FT_NONE if the function returns the same type
45 * as its arguments. */
46 DFSemCheckType semcheck_param_function;
47 } df_func_def_t;
49 WS_DLL_PUBLIC
50 ftenum_t
51 df_semcheck_param(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype,
52 stnode_t *param, df_loc_t func_loc);
54 void df_func_init(void);
56 /* Returns false if the function name already exists. */
57 WS_DLL_PUBLIC
58 bool df_func_register(df_func_def_t *func);
60 WS_DLL_PUBLIC
61 bool df_func_deregister(df_func_def_t *func);
63 /* Return the function definition record for a function of named "name" */
64 WS_DLL_PUBLIC
65 df_func_def_t* df_func_lookup(const char *name);
67 /* You must call g_ptr_array_unref() when you are done. */
68 WS_DLL_PUBLIC
69 GPtrArray *df_func_name_list(void);
71 void df_func_cleanup(void);
73 #ifdef __cplusplus
75 #endif /* __cplusplus */
77 #endif