python binding for wireshark (first commit)
[obnox/wireshark/wip.git] / epan / wspython / wspy_proto.c
1 /* wspy_proto.c
2  *
3  * $Id: $
4  *
5  * Wireshark Protocol Python Binding
6  *
7  * Copyright (c) 2009 by Sebastien Tandel <sebastien [AT] tandel [dot] be>
8  * Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org>
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 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #ifdef HAVE_PYTHON
30 #include <Python.h>
31
32 #include <glib.h>
33
34 #include <stdio.h>
35
36 #include "proto.h"
37
38
39 hf_register_info *hf_register_info_create(const guint8 size)
40 {
41   hf_register_info *hf = g_malloc0(sizeof(hf_register_info) * size);
42
43   /**STA TODO :
44    * if (!hf_register_info)
45    *  raise exception
46    */
47
48   return hf;
49 }
50
51 void hf_register_info_destroy(hf_register_info *hf)
52 {
53   if (hf) {
54     g_free(hf);
55   }
56 }
57
58 void hf_register_info_add(hf_register_info *hf, guint8 index,
59           int *p_id, const char *name, const char *abbrev,
60           enum ftenum type, int display, const void *strings,
61           guint32 bitmask, const char *blurb)
62 {
63   hf[index].p_id = p_id;
64   hf[index].hfinfo.name = name;
65   hf[index].hfinfo.abbrev = abbrev;
66   hf[index].hfinfo.type = type;
67   hf[index].hfinfo.display = display;
68   hf[index].hfinfo.strings = strings;
69   hf[index].hfinfo.bitmask = bitmask;
70   hf[index].hfinfo.blurb = blurb;
71   hf[index].hfinfo.id = 0;
72   hf[index].hfinfo.parent = 0;
73   hf[index].hfinfo.ref_count = 0;
74   hf[index].hfinfo.bitshift = 0;
75   hf[index].hfinfo.same_name_next = NULL;
76   hf[index].hfinfo.same_name_prev = NULL;
77 }
78
79 void hf_register_info_print(hf_register_info *hf, guint8 size)
80 {
81   guint8 c;
82   if (!hf)
83     return;
84
85   for (c = 0; c < size; c++) {
86     printf("%s : %s : %s\n", hf[c].hfinfo.name,
87                              hf[c].hfinfo.abbrev,
88                              hf[c].hfinfo.blurb);
89   }
90 }
91
92 #endif /* HAVE_PYTHON */