add PROFINET Multicast OUI 01:0E:CF (in addition to the unicast 00:0E:CF)
[metze/wireshark/wip.git] / conditions.h
1 /* conditions.h
2  * Header for condition handler.
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef CONDITIONS_H
26 #define CONDITIONS_H
27
28 #include <stdarg.h>
29
30 #include <glib.h>
31
32 /* forward declaration for type 'condition' */
33 typedef struct condition condition;
34
35 /* condition evaluation handler type */
36 typedef gboolean (*_cnd_eval)(condition*, va_list);
37
38 /* condition reset handler type */
39 typedef void (*_cnd_reset)(condition*);
40
41 /* condition class constructor type */
42 typedef condition* (*_cnd_constr)(condition*, va_list);
43
44 /* condition class destructor type */
45 typedef void (*_cnd_destr)(condition*);
46
47 /*
48  * Conditions must be created with this function. They can be created for
49  * registered classes only.
50  *
51  * parameter: const char* - Identification of a registered condition class.
52  *            ...         - Any number of class specific initial values.
53  * returns:   Pointer to a initialized condition of the particular class on
54  *            success or NULL on failure.
55  */
56 condition* cnd_new(const char*, ...);
57
58 /*
59  * Conditions must be deleted with this function when not used anymore.
60  *
61  * parameter: condition* - Pointer to a condition created with 'cnd_new()'.
62  * returns:   -
63  */
64 void cnd_delete(condition*);
65
66 /*
67  * Call this function to check whether or not a particular condition is true.
68  *
69  * parameter: condition* - Pointer to an initialized condition.
70  *            ...        - Any number of condition specific arguments.
71  * returns:   TRUE  - Condition is true.
72  *            FALSE - Condition is false.
73  */
74 gboolean cnd_eval(condition*, ...);
75
76 /*
77  * Call this function to reset this condition to its initial state, i.e. the
78  * state it was in right after creation.
79  *
80  * parameter: condition* - Pointer to an initialized condition.
81  * returns:   -
82  */
83 void cnd_reset(condition*);
84
85 /*
86  * Register a new conditon class.
87  * New conditions of this class can be created by calling 'cnd_new()' and
88  * supplying the appropriate class id.
89  *
90  * parameter: const char*  - The class id.
91  *            _cnd_constr  - User supplied constructor function for this
92  *                           class.
93  *            _cnd_destr   - User supplied destructor function for this
94  *                           class.
95  *            _cnd_eval    - User supplied evaluation handler function for this
96                              class.
97  *            _cnd_reset   - User supplied reset handler for this class.
98  * returns:   TRUE  - Success.
99  *            FALSE - Failure.
100  */
101 gboolean cnd_register_class(const char*,
102                             _cnd_constr,
103                             _cnd_destr,
104                             _cnd_eval,
105                             _cnd_reset);
106
107 /*
108  * Unregister a previously registered conditon class. After unregistration
109  * of a class it is no longer possible to create conditions of this kind by
110  * calling 'cnd_new()'.
111  *
112  * parameter: const char* - An identification for this condition class.
113  * returns:   -
114  */
115 void cnd_unregister_class(const char*);
116
117 /*
118  * This function returns the user data of the condition.
119  *
120  * parameter: condition* - Pointer to an initialized condition.
121  * returns:   void*      - Pointer to user data of this condition.
122  */
123 void* cnd_get_user_data(condition*);
124
125 /*
126  * This function sets the user data of the condition.
127  *
128  * parameter: condition* - Pointer to an initialized condition.
129  *            void*      - Pointer to user specified data structure.
130  * returns:   -
131  */
132 void cnd_set_user_data(condition*, void*);
133
134 #endif /* CONDITIONS_H */