Create a more modular type system for the FT_* types. Put them
[obnox/wireshark/wip.git] / epan / epan.c
1 /* epan.h
2  *
3  * $Id: epan.c,v 1.6 2001/02/01 20:21:16 gram Exp $
4  *
5  * Ethereal Protocol Analyzer Library
6  *
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12
13 #include <glib.h>
14 #include <epan.h>
15
16 #include "conversation.h"
17 #include "dfilter/dfilter.h"
18 #include "except.h"
19 #include "packet.h"
20 #include "proto.h"
21 #include "tvbuff.h"
22
23 /*
24  * XXX - this takes the plugin directory as an argument, because
25  * libethereal now has its own configure script and "config.h" file,
26  * which is what code in the "epan" directory includes, but we need
27  * to define PLUGIN_DIR in the top-level directory, as it's used by,
28  * for example, the Makefile for the Gryphon plugin, so it knows
29  * where to install the plugin.
30  *
31  * Eventually, we should probably have an "epan-configure" script
32  * (or "libethereal-configure", or whatever), along the lines of what
33  * GTK+ and GLib have, that can print, among other things, the directory
34  * into which plugins should be installed.  That way, only libethereal
35  * need know what directory that is; programs using it won't, *and*
36  * Makefiles for plugins can just use "epan-configure" to figure out
37  * where to install the plugins.
38  *
39  * (Would that *more* libraries had configure scripts like that, so
40  * that configure scripts didn't have to go through various contortions
41  * to figure out where the header files and libraries for various
42  * libraries are located.)
43  */
44 void
45 epan_init(const char *plugin_dir)
46 {
47         except_init();
48         tvbuff_init();
49         packet_init();
50         proto_init(plugin_dir);
51         dfilter_init();
52 }
53
54 void
55 epan_cleanup(void)
56 {
57         dfilter_cleanup();
58         proto_cleanup();
59         packet_cleanup();
60         tvbuff_cleanup();
61         except_deinit();
62 }
63
64
65 void
66 epan_conversation_init(void)
67 {
68         conversation_init();
69 }
70
71
72
73 epan_dissect_t*
74 epan_dissect_new(void* pseudo_header, const guint8* data, frame_data *fd, proto_tree *tree)
75 {
76         epan_dissect_t  *edt;
77
78         edt = g_new(epan_dissect_t, 1);
79
80         /* XXX - init tree */
81         edt->tree = tree;
82
83         dissect_packet(&edt->tvb, pseudo_header, data, fd, tree);
84
85         return edt;
86 }
87
88
89 void
90 epan_dissect_free(epan_dissect_t* edt)
91 {
92         /* Free all tvb's created from this tvb, unless dissector
93          * wanted to store the pointer (in which case, the dissector
94          * would have incremented the usage count on that tvbuff_t*) */
95         tvb_free_chain(edt->tvb);
96
97         g_free(edt);
98 }