Ethereal-dev: [Ethereal-dev] idl2eth update
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Frank Singleton <frank.singleton@xxxxxxxxxxxx>
Date: Thu, 25 Oct 2001 14:53:58 -0500
Hi, Here is a patch for idl2eth for the following improvements. - Handle "short" as a union discriminant type - Handle case where union discriminant may be a typedef - Change integer template to long template - Initial code for \n and \t as union case labels. Thanks to Paul for his observations. Twas diffed against 2001-10-24 nightly tarball. Cheers / Frank.. -- EUS/SV/Z Frank Singleton ASO Americas BSS Office : +1 972 583 3251 ECN 800 33251 Mobile : +1 214 228 0874 Amateur Radio: VK3FCS/KM5WS Email : frank.singleton@xxxxxxxxxxxx Hardware: HP Omnibook 4150 running Redhat Linux 7.1 (2.4.3-12 kernel).
--- ../ethereal-2001-10-24/ethereal_gen.py Thu Oct 18 16:49:58 2001
+++ ../ethereal-2001-10-24.updated/ethereal_gen.py Thu Oct 25 14:27:42 2001
@@ -1,6 +1,6 @@
# -*- python -*-
#
-# $Id: ethereal_gen.py,v 1.13 2001/10/18 21:49:58 guy Exp $
+# $Id: ethereal_gen.py,v 1.4 2001/10/25 19:27:42 frank Exp $
#
# ethereal_gen.py (part of idl2eth)
#
@@ -1099,9 +1099,7 @@
sys.stderr.write( "Error: idl2eth does not handle recursive unions yet \n")
sys.exit(1)
- st = ntype.switchType()
-
-
+ st = ntype.switchType().unalias() # may be typedef switch type, so find real type
#std = st.decl()
@@ -1133,7 +1131,11 @@
self.addvar(self.c_s_disc + pn + ";")
elif (st.kind() == idltype.tk_long):
- self.st.out(self.template_union_code_save_discriminant_integer, discname=pn )
+ self.st.out(self.template_union_code_save_discriminant_long, discname=pn )
+ self.addvar(self.c_s_disc + pn + ";")
+
+ elif (st.kind() == idltype.tk_short):
+ self.st.out(self.template_union_code_save_discriminant_short, discname=pn )
self.addvar(self.c_s_disc + pn + ";")
elif (st.kind() == idltype.tk_boolean):
@@ -1176,9 +1178,18 @@
#
# if char, dont convert to int, but put inside single quotes so that it is understood by C.
# eg: if (disc == 'b')..
+ #
+ # TODO : handle \xxx chars generically from a function or table lookup rather than
+ # a whole bunch of "if" statements. -- FS
+
- if (st.kind() == idltype.tk_char):
- string_clv = "'" + clv + "'"
+ if (st.kind() == idltype.tk_char):
+ if (clv == '\n'): # newline
+ string_clv = "'\\n'"
+ elif (clv == '\t'): # tab
+ string_clv = "'\\t'"
+ else:
+ string_clv = "'" + clv + "'"
else:
string_clv = '%i ' % clv
@@ -2523,9 +2534,13 @@
disc_s_@discname@ = (gint32) u_octet4; /* save Enum Value discriminant and cast to gint32 */
"""
- template_union_code_save_discriminant_integer = """\
+ template_union_code_save_discriminant_long = """\
disc_s_@discname@ = (gint32) s_octet4; /* save gint32 discriminant and cast to gint32 */
"""
+
+ template_union_code_save_discriminant_short = """\
+disc_s_@discname@ = (gint32) s_octet2; /* save gint16 discriminant and cast to gint32 */
+"""
template_union_code_save_discriminant_char = """\
disc_s_@discname@ = (gint32) u_octet1; /* save guint1 discriminant and cast to gint32 */
- Follow-Ups:
- Re: [Ethereal-dev] idl2eth update
- From: Guy Harris
- Re: [Ethereal-dev] idl2eth update
- Prev by Date: [Ethereal-dev] Parsing error for ISAKMP QM proposals
- Next by Date: Re: [Ethereal-dev] idl2eth update
- Previous by thread: Re: [Ethereal-dev] Parsing error for ISAKMP QM proposals
- Next by thread: Re: [Ethereal-dev] idl2eth update
- Index(es):





