Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
/home/wireshark/builders/wireshark-master/ubuntu-16.04-x64/build/conditions.h
1 /* conditions.h
2  * Header for condition handler.
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef CONDITIONS_H
12 #define CONDITIONS_H
13 
14 #include <stdarg.h>
15 
16 #include <glib.h>
17 
18 /* forward declaration for type 'condition' */
19 typedef struct condition condition;
20 
21 /* condition evaluation handler type */
22 typedef gboolean (*_cnd_eval)(condition *, va_list);
23 
24 /* condition reset handler type */
25 typedef void (*_cnd_reset)(condition *);
26 
27 /* condition class constructor type */
28 typedef condition *(*_cnd_constr)(condition *, va_list);
29 
30 /* condition class destructor type */
31 typedef void (*_cnd_destr)(condition *);
32 
33 /*
34  * Conditions must be created with this function. They can be created for
35  * registered classes only.
36  *
37  * parameter: const char * - Identification of a registered condition class.
38  * ... - Any number of class specific initial values.
39  * returns: Pointer to a initialized condition of the particular class on
40  * success or NULL on failure.
41  */
42 condition *cnd_new(const char *, ...);
43 
44 /*
45  * Conditions must be deleted with this function when not used anymore.
46  *
47  * parameter: condition * - Pointer to a condition created with 'cnd_new()'.
48  * returns: -
49  */
50 void cnd_delete(condition *);
51 
52 /*
53  * Call this function to check whether or not a particular condition is true.
54  *
55  * parameter: condition * - Pointer to an initialized condition.
56  * ... - Any number of condition specific arguments.
57  * returns: TRUE - Condition is true.
58  * FALSE - Condition is false.
59  */
60 gboolean cnd_eval(condition *, ...);
61 
62 /*
63  * Call this function to reset this condition to its initial state, i.e. the
64  * state it was in right after creation.
65  *
66  * parameter: condition * - Pointer to an initialized condition.
67  * returns: -
68  */
69 void cnd_reset(condition *);
70 
71 /*
72  * Register a new conditon class.
73  * New conditions of this class can be created by calling 'cnd_new()' and
74  * supplying the appropriate class id.
75  *
76  * parameter: const char * - The class id.
77  * _cnd_constr - User supplied constructor function for this
78  * class.
79  * _cnd_destr - User supplied destructor function for this
80  * class.
81  * _cnd_eval - User supplied evaluation handler function for this
82  class.
83  * _cnd_reset - User supplied reset handler for this class.
84  * returns: TRUE - Success.
85  * FALSE - Failure.
86  */
87 gboolean cnd_register_class(const char *,
88  _cnd_constr,
89  _cnd_destr,
90  _cnd_eval,
91  _cnd_reset);
92 
93 /*
94  * Unregister a previously registered conditon class. After unregistration
95  * of a class it is no longer possible to create conditions of this kind by
96  * calling 'cnd_new()'.
97  *
98  * parameter: const char * - An identification for this condition class.
99  * returns: -
100  */
101 void cnd_unregister_class(const char *);
102 
103 /*
104  * This function returns the user data of the condition.
105  *
106  * parameter: condition * - Pointer to an initialized condition.
107  * returns: void * - Pointer to user data of this condition.
108  */
109 void* cnd_get_user_data(condition*);
110 
111 /*
112  * This function sets the user data of the condition.
113  *
114  * parameter: condition * - Pointer to an initialized condition.
115  * void * - Pointer to user specified data structure.
116  * returns: -
117  */
118 void cnd_set_user_data(condition *, void *);
119 
120 #endif /* CONDITIONS_H */
121 
122 /*
123  * Editor modelines - http://www.wireshark.org/tools/modelines.html
124  *
125  * Local variables:
126  * c-basic-offset: 4
127  * tab-width: 8
128  * indent-tabs-mode: nil
129  * End:
130  *
131  * vi: set shiftwidth=4 tabstop=8 expandtab:
132  * :indentSize=4:tabSize=8:noTabs=true:
133  */
Definition: conditions.c:23