diff options
author | Bill Meier <wmeier@newsguy.com> | 2008-11-04 21:42:02 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2008-11-04 21:42:02 +0000 |
commit | f35324d0fd73a8fbbfc922e91823ef6b3a1ae4ec (patch) | |
tree | a93ec5381270aa4229984585ea3ec7320ccdcf33 /asn1/h501 | |
parent | a3d5cbf5d82252d097dc4e637fc218a491d30bc5 (diff) | |
download | wireshark-f35324d0fd73a8fbbfc922e91823ef6b3a1ae4ec.tar.gz wireshark-f35324d0fd73a8fbbfc922e91823ef6b3a1ae4ec.tar.bz2 wireshark-f35324d0fd73a8fbbfc922e91823ef6b3a1ae4ec.zip |
Minor cleanup mostly related to proto_reg_handoff
Remove code for unused handles;
Localize handles (in proto_reg_handoff) which need not be global;
Localize (in proto_reg_handoff) "saved prefs";
Use find_dissector instead of create_dissector_handle as appropriate;
Use gboolean for "initialized" flag in proto_reg_handoff.
svn path=/trunk/; revision=26693
Diffstat (limited to 'asn1/h501')
-rw-r--r-- | asn1/h501/packet-h501-template.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/asn1/h501/packet-h501-template.c b/asn1/h501/packet-h501-template.c index 4c40ecf868..9c237d892c 100644 --- a/asn1/h501/packet-h501-template.c +++ b/asn1/h501/packet-h501-template.c @@ -55,19 +55,13 @@ static int ett_h501 = -1; #include "packet-h501-ett.c" /* Dissectors */ -static dissector_handle_t h501_pdu_handle = NULL; -static dissector_handle_t h501_udp_handle = NULL; -static dissector_handle_t h501_tcp_handle = NULL; +static dissector_handle_t h501_pdu_handle; /* Preferences */ static guint h501_udp_port = 2099; static guint h501_tcp_port = 2099; static gboolean h501_desegment_tcp = TRUE; -/* Gloabl variables */ -static guint saved_h501_udp_port; -static guint saved_h501_tcp_port; - void proto_reg_handoff_h501(void); #include "packet-h501-fn.c" @@ -124,10 +118,6 @@ void proto_register_h501(void) { proto_register_subtree_array(ett, array_length(ett)); new_register_dissector(PFNAME, dissect_h501_pdu, proto_h501); - h501_pdu_handle = find_dissector(PFNAME); - - h501_udp_handle = new_create_dissector_handle(dissect_h501_udp, proto_h501); - h501_tcp_handle = new_create_dissector_handle(dissect_h501_tcp, proto_h501); h501_module = prefs_register_protocol(proto_h501, proto_reg_handoff_h501); prefs_register_uint_preference(h501_module, "udp.port", @@ -149,12 +139,19 @@ void proto_register_h501(void) { void proto_reg_handoff_h501(void) { static gboolean h501_prefs_initialized = FALSE; - - if (h501_prefs_initialized) { + static dissector_handle_t h501_udp_handle; + static dissector_handle_t h501_tcp_handle; + static guint saved_h501_udp_port; + static guint saved_h501_tcp_port; + + if (!h501_prefs_initialized) { + h501_pdu_handle = find_dissector(PFNAME); + h501_udp_handle = new_create_dissector_handle(dissect_h501_udp, proto_h501); + h501_tcp_handle = new_create_dissector_handle(dissect_h501_tcp, proto_h501); + h501_prefs_initialized = TRUE; + } else { dissector_delete("udp.port", saved_h501_udp_port, h501_udp_handle); dissector_delete("tcp.port", saved_h501_tcp_port, h501_tcp_handle); - } else { - h501_prefs_initialized = TRUE; } /* Set our port number for future use */ |