We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
[metze/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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #include "config.h"
26
27 #ifdef HAVE_PYTHON
28 #include <Python.h>
29
30 #include <glib.h>
31
32 #include <stdio.h>
33
34 #include "proto.h"
35
36
37 hf_register_info *hf_register_info_create(const guint8 size)
38 {
39   hf_register_info *hf = g_malloc0(sizeof(hf_register_info) * size);
40
41   /**STA TODO :
42    * if (!hf_register_info)
43    *  raise exception
44    */
45
46   return hf;
47 }
48
49 void hf_register_info_destroy(hf_register_info *hf)
50 {
51   if (hf) {
52     g_free(hf);
53   }
54 }
55
56 void hf_register_info_add(hf_register_info *hf, guint8 index,
57           int *p_id, const char *name, const char *abbrev,
58           enum ftenum type, int display, const void *strings,
59           guint32 bitmask, const char *blurb)
60 {
61   hf[index].p_id = p_id;
62   hf[index].hfinfo.name = name;
63   hf[index].hfinfo.abbrev = abbrev;
64   hf[index].hfinfo.type = type;
65   hf[index].hfinfo.display = display;
66   hf[index].hfinfo.strings = strings;
67   hf[index].hfinfo.bitmask = bitmask;
68   hf[index].hfinfo.blurb = blurb;
69   hf[index].hfinfo.id = 0;
70   hf[index].hfinfo.parent = 0;
71   hf[index].hfinfo.ref_type = HF_REF_TYPE_NONE;
72   hf[index].hfinfo.bitshift = 0;
73   hf[index].hfinfo.same_name_next = NULL;
74   hf[index].hfinfo.same_name_prev = NULL;
75 }
76
77 void hf_register_info_print(hf_register_info *hf, guint8 size)
78 {
79   guint8 c;
80   if (!hf)
81     return;
82
83   for (c = 0; c < size; c++) {
84     printf("%s : %s : %s\n", hf[c].hfinfo.name,
85                              hf[c].hfinfo.abbrev,
86                              hf[c].hfinfo.blurb);
87   }
88 }
89
90 #endif /* HAVE_PYTHON */