summaryrefslogtreecommitdiff
path: root/epan/wspython
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2009-09-21 21:28:11 +0000
committerJaap Keuter <jaap.keuter@xs4all.nl>2009-09-21 21:28:11 +0000
commitc09c7fd7cde8557909f735c352b891c668e48afd (patch)
tree980b818b036345753af42f159a31ac7ad4f6d421 /epan/wspython
parentf78265be265dde765ab492d76bdb6357b48eef40 (diff)
downloadwireshark-c09c7fd7cde8557909f735c352b891c668e48afd.tar.gz
Fix for bug 4034:
Fix for missing register file and cleanup of code in register_all_py_protocols_func(). svn path=/trunk/; revision=30058
Diffstat (limited to 'epan/wspython')
-rw-r--r--epan/wspython/wspy_register.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/epan/wspython/wspy_register.c b/epan/wspython/wspy_register.c
index c273bbf358..36e6415c9b 100644
--- a/epan/wspython/wspy_register.c
+++ b/epan/wspython/wspy_register.c
@@ -135,11 +135,18 @@ void register_all_py_protocols_func(register_cb cb, gpointer client_data)
nothing = cb;
nothing = client_data;
+ /* intialize the hash table where all the python dissectors are kept */
+ g_py_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
+
/* STA TODO : init only if prefs is enabled */
wspy_init();
/* load the python register module */
py_reg = fopen(get_py_register_file(), "r");
+ if (py_reg == NULL) {
+ printf("no register file %s\n", get_py_register_file());
+ return;
+ }
PyRun_SimpleFile(py_reg, get_py_register_file());
/* Getting the global symbols from the python register module */
@@ -153,7 +160,6 @@ void register_all_py_protocols_func(register_cb cb, gpointer client_data)
/* This function returns a sequence of python dissectors objects */
py_args = Py_BuildValue("(s)", get_wspython_dir());
py_dissectors = PyObject_CallObject(register_fn, py_args);
- //py_dissectors = PyObject_CallObject(register_fn, NULL);
/* Check that the py_dissectors is really a sequence */
if (!PySequence_Check(py_dissectors)) {
@@ -161,19 +167,12 @@ void register_all_py_protocols_func(register_cb cb, gpointer client_data)
return;
}
- /* intialize the hash table where all the python dissectors are kept */
- g_py_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
-
/**
* For each dissector, register it in cb and registers all fields, subtrees,
* protocol name, etc ...
*/
- for (index = 0; ; index++) {
- py_dissector = PySequence_GetItem(py_dissectors, index);
- if (!py_dissector)
- break;
- assert(py_dissector);
-
+ for (index = 0; (py_dissector = PySequence_GetItem(py_dissectors, index)); index++)
+ {
name = py_dissector_name(py_dissector);
py_dissector_register(py_dissector, name, cb, client_data);
g_hash_table_insert(g_py_dissectors, (gpointer*)name, py_dissector);