diff options
author | jake <jake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2007-05-06 19:25:14 +0000 |
---|---|---|
committer | jake <jake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2007-05-06 19:25:14 +0000 |
commit | e64d424c26b3d9845ae702d5374a1d2a8221a6ab (patch) | |
tree | 22dbdcfd9e937e672feb972498825834dd6847f9 /docbook | |
parent | 20a28a7bf10b4217281794ea3db487ac7de5e07f (diff) |
Improve readability of code samples and program output
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@21701 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'docbook')
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_dissection.xml | 112 | ||||
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_tools.xml | 39 |
2 files changed, 73 insertions, 78 deletions
diff --git a/docbook/wsdg_src/WSDG_chapter_dissection.xml b/docbook/wsdg_src/WSDG_chapter_dissection.xml index 69d229a0d0..19cd6a78b5 100644 --- a/docbook/wsdg_src/WSDG_chapter_dissection.xml +++ b/docbook/wsdg_src/WSDG_chapter_dissection.xml @@ -144,20 +144,19 @@ plugin_reg_handoff(void){ </para> <example><title>Plugin Initialisation.</title> <programlisting> - <![CDATA[ -void +<![CDATA[void proto_register_foo(void) { module_t *foo_module; if (proto_foo == -1) { proto_foo = proto_register_protocol ( - "FOO Protocol", /* name */ + "FOO Protocol", /* name */ "FOO", /* short name */ "foo" /* abbrev */ ); } - foo_module = prefs_register_protocol(proto_foo, proto_reg_handoff_foo); + foo_module = prefs_register_protocol(proto_foo, proto_reg_handoff_foo); }]]> </programlisting></example> <para> @@ -174,8 +173,7 @@ proto_register_foo(void) </para> <example><title>Plugin Handoff.</title> <programlisting> - <![CDATA[ -void +<![CDATA[void proto_reg_handoff_foo(void) { static int Initialized=FALSE; @@ -200,15 +198,14 @@ proto_reg_handoff_foo(void) </para> <example><title>Plugin Dissection.</title> <programlisting> - <![CDATA[ -static void +<![CDATA[static void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "FOO"); /* Clear out stuff in the info column */ - if(check_col(pinfo->cinfo,COL_INFO)){ + if (check_col(pinfo->cinfo,COL_INFO)) { col_clear(pinfo->cinfo,COL_INFO); } }]]> @@ -241,7 +238,7 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) <example><title>Makefile.nmake for Windows.</title> <programlisting> - <![CDATA[ +<![CDATA[ include ..\..\config.nmake ############### no need to modify below this line ######### @@ -272,7 +269,7 @@ maintainer-clean: distclean]]> </programlisting></example> <example><title>Makefile.am for unix/linux.</title> <programlisting> - <![CDATA[ +<![CDATA[ INCLUDES = -I$(top_srcdir) plugindir = @plugindir@ @@ -316,7 +313,7 @@ EXTRA_DIST = \ </para> <example><title>Plugin Packet Dissection.</title> <programlisting> - <![CDATA[ +<![CDATA[ static void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { @@ -360,33 +357,27 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) </para> <example><title>Plugin Registering data structures.</title> <programlisting> - <![CDATA[ -static hf_register_info hf[] = { +<![CDATA[static hf_register_info hf[] = { { &hf_foo_pdu_type, - { "FOO PDU Type", "foo.type", - FT_UINT8, BASE_DEC, NULL, 0x0, - "", HFILL } - }, - + { "FOO PDU Type", "foo.type", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + } }; - /* Setup protocol subtree array */ static gint *ett[] = { - &ett_foo, -}; -]]> + &ett_foo +};]]> </programlisting></example> <para> Then, after the registration code, we register these arrays. </para> <example><title>Plugin Registering data structures.</title> <programlisting> - <![CDATA[ - - proto_register_field_array(proto_foo, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); -]]> +<![CDATA[proto_register_field_array(proto_foo, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett));]]> </programlisting></example> <para> The variables hf_foo_pdu_type and ett_foo also need to be declared @@ -476,30 +467,32 @@ static int hf_foo_sequenceno = -1; static int hf_foo_initialip = -1; ... { &hf_foo_flags, - { "FOO PDU Flags", "foo.flags", - FT_UINT8, BASE_HEX, NULL, 0x0, - "", HFILL } + { "FOO PDU Flags", "foo.flags", + FT_UINT8, BASE_HEX, + NULL, 0x0, + NULL, HFILL } }, { &hf_foo_sequenceno, - { "FOO PDU Sequence Number", "foo.seqn", - FT_UINT16, BASE_DEC, NULL, 0x0, - "", HFILL } + { "FOO PDU Sequence Number", "foo.seqn", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } }, { &hf_foo_initialip, - { "FOO PDU Initial IP", "foo.initialip", - FT_IPv4, BASE_NONE, NULL, 0x0, - "", HFILL } + { "FOO PDU Initial IP", "foo.initialip", + FT_IPv4, BASE_NONE, + NULL, 0x0, + NULL, HFILL } }, -... - gint offset = 0; - ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, FALSE); - foo_tree = proto_item_add_subtree(ti, ett_foo); - proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, FALSE); offset += 1; - proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, FALSE); offset += 1; - proto_tree_add_item(foo_tree, hf_foo_sequenceno, tvb, offset, 2, FALSE); offset += 2; - proto_tree_add_item(foo_tree, hf_foo_initialip, tvb, offset, 4, FALSE); offset += 4; + gint offset = 0; + ti = proto_tree_add_item(tree, proto_foo, tvb, 0, -1, FALSE); + foo_tree = proto_item_add_subtree(ti, ett_foo); + proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, FALSE); offset += 1; + proto_tree_add_item(foo_tree, hf_foo_flags, tvb, offset, 1, FALSE); offset += 1; + proto_tree_add_item(foo_tree, hf_foo_sequenceno, tvb, offset, 2, FALSE); offset += 2; + proto_tree_add_item(foo_tree, hf_foo_initialip, tvb, offset, 4, FALSE); offset += 4; ]]> </programlisting></example> <para> @@ -540,7 +533,7 @@ static const value_string packettypenames[] = { FT_UINT8, BASE_DEC, VALS(packettypenames), 0x0, NULL, HFILL } - }, + } ]]> </programlisting></example> <para> @@ -605,8 +598,7 @@ static int hf_foo_priorityflag = -1; </para> <example><title>Enhancing the display.</title> <programlisting> - <![CDATA[ -static void +<![CDATA[static void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 packet_type = tvb_get_guint8(tvb, 0); @@ -614,7 +606,7 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "FOO"); /* Clear out stuff in the info column */ - if(check_col(pinfo->cinfo,COL_INFO)){ + if (check_col(pinfo->cinfo,COL_INFO)) { col_clear(pinfo->cinfo,COL_INFO); } if (check_col(pinfo->cinfo, COL_INFO)) { @@ -631,7 +623,8 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item_append_text(ti, ", Type %s", val_to_str(packet_type, packettypenames, "Unknown (0x%02x)")); foo_tree = proto_item_add_subtree(ti, ett_foo); - proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, FALSE); offset += 1; + proto_tree_add_item(foo_tree, hf_foo_pdu_type, tvb, offset, 1, FALSE); + offset += 1; ... ]]> </programlisting></example> @@ -671,12 +664,14 @@ dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) <example><title>Decompressing data packets for dissection.</title> <programlisting> <![CDATA[ - guint8 flags = tvb_get_guint8(tvb, offset); offset ++; + guint8 flags = tvb_get_guint8(tvb, offset); + offset ++; if (flags & FLAG_COMPRESSED) { /* the remainder of the packet is compressed */ - guint16 orig_size = tvb_get_ntohs(tvb, offset); offset += 2; - guchar *decompressed_buffer; /* Buffers for decompression */ - decompressed_buffer = (guchar*) g_malloc (orig_size); - decompress_packet (tvb_get_ptr(tvb, offset, -1), tvb_length_remaining(tvb, offset), + guint16 orig_size = tvb_get_ntohs(tvb, offset); + guchar *decompressed_buffer = (guchar*)g_malloc(orig_size); + offset += 2; + decompress_packet(tvb_get_ptr(tvb, offset, -1), + tvb_length_remaining(tvb, offset), decompressed_buffer, orig_size); /* Now re-setup the tvb buffer to have the new data */ next_tvb = tvb_new_real_data(decompressed_buffer, orig_size, orig_size); @@ -861,7 +856,7 @@ else { /* Not fragmented */ ..... pinfo->fragmented = save_fragmented; - ]]> +]]> </programlisting></example> <para> Having passed the fragment data to the reassembly handler, we can @@ -1213,7 +1208,7 @@ static int st_node_packet_types = -1; static void foo_stats_tree_init(stats_tree* st) { st_node_packets = stats_tree_create_node(st, st_str_packets, 0, TRUE); - st_node_packet_types = stats_tree_create_pivot(st, st_str_packet_types, st_node_packets); + st_node_packet_types = stats_tree_create_pivot(st, st_str_packet_types, st_node_packets); } ]]> </programlisting></example> @@ -1225,7 +1220,8 @@ static void foo_stats_tree_init(stats_tree* st) { <example><title>Generating the stats</title> <programlisting> <![CDATA[ -static int foo_stats_tree_packet(stats_tree* st, packet_info* pinfo , epan_dissect_t* edt , const void* p) { +static int foo_stats_tree_packet(stats_tree* st, packet_info* pinfo, +epan_dissect_t* edt, const void* p) { struct FooTap *pi = (struct FooTap *)p; tick_stat_node(st, st_str_packets, 0, FALSE); stats_tree_tick_pivot(st, st_node_packet_types, diff --git a/docbook/wsdg_src/WSDG_chapter_tools.xml b/docbook/wsdg_src/WSDG_chapter_tools.xml index 0b3dd0496e..54d1e4e1cb 100644 --- a/docbook/wsdg_src/WSDG_chapter_tools.xml +++ b/docbook/wsdg_src/WSDG_chapter_tools.xml @@ -143,7 +143,7 @@ </para> <para>should result in something like: <programlisting> - <![CDATA[gcc (GCC) 3.4.4 (cygwin special) (gdc 0.12, using dmd 0.125) +<![CDATA[gcc (GCC) 3.4.4 (cygwin special) (gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.]]> @@ -168,7 +168,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[GNU gdb 6.5.50.20060706-cvs (cygwin-special) +<![CDATA[GNU gdb 6.5.50.20060706-cvs (cygwin-special) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. @@ -209,7 +209,7 @@ This GDB was configured as "i686-pc-cygwin".]]> </para> <para>should result in something like: <programlisting> - <![CDATA[GNU Make 3.81 +<![CDATA[GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A @@ -776,7 +776,7 @@ PARTICULAR PURPOSE.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 +<![CDATA[Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. usage: cl [ option... ] filename... [ /link linkoption... ]]> @@ -802,7 +802,7 @@ usage: cl [ option... ] filename... [ /link linkoption... ]]> </para> <para>should result in something like: <programlisting> - <![CDATA[Microsoft (R) Program Maintenance Utility Version 6.00.9782.0 +<![CDATA[Microsoft (R) Program Maintenance Utility Version 6.00.9782.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. NMAKE : fatal error U1064: MAKEFILE not found and no target specified @@ -1050,7 +1050,7 @@ Stop.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[GNU bash, version 3.1.17(6)-release (i686-pc-cygwin) +<![CDATA[GNU bash, version 3.1.17(6)-release (i686-pc-cygwin) Copyright (C) 2005 Free Software Foundation, Inc.]]> </programlisting>However, the version string may vary.</para> </section> @@ -1102,7 +1102,7 @@ Copyright (C) 2005 Free Software Foundation, Inc.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[Python 2.5]]> +<![CDATA[Python 2.5]]> </programlisting>However, the version string may vary.</para> </section> </section> @@ -1129,7 +1129,7 @@ Copyright (C) 2005 Free Software Foundation, Inc.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[This is perl, v5.8.7 built for cygwin-thread-multi-64int +<![CDATA[This is perl, v5.8.7 built for cygwin-thread-multi-64int (with 1 registered patch, see perl -V for more detail) Copyright 1987-2005, Larry Wall @@ -1155,7 +1155,7 @@ Internet, point your browser at http://www.perl.com/, the Perl Home Page.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[This is perl, v5.8.0 built for MSWin32-x86-multi-thread +<![CDATA[This is perl, v5.8.0 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2002, Larry Wall @@ -1189,7 +1189,7 @@ Built 18:08:02 Feb 4 2003 </para> <para>should result in something like: <programlisting> - <![CDATA[GNU sed version 4.1.5 +<![CDATA[GNU sed version 4.1.5 Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, @@ -1222,7 +1222,7 @@ to the extent permitted by law.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[bison (GNU Bison) 2.3 +<![CDATA[bison (GNU Bison) 2.3 Written by Robert Corbett and Richard Stallman. Copyright (C) 2006 Free Software Foundation, Inc. @@ -1256,7 +1256,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[flex version 2.5.4]]> +<![CDATA[flex version 2.5.4]]> </programlisting>However, the version string may vary.</para> </section> <section id="ChToolsWin32Lexx"> @@ -1299,7 +1299,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[svn, version 1.0.5 (r9954) +<![CDATA[svn, version 1.0.5 (r9954) compiled Jun 20 2004, 23:28:30 Copyright (C) 2000-2004 CollabNet. @@ -1324,7 +1324,7 @@ This product includes software developed by CollabNet (http://www.Collab.Net/). </para> <para>should result in something like: <programlisting> - <![CDATA[svn, Version 1.4.0 (r21228) +<![CDATA[svn, Version 1.4.0 (r21228) Copyright (C) 2000-2006 CollabNet. ...]]> @@ -1387,7 +1387,7 @@ Copyright (C) 2000-2006 CollabNet. </para> <para>should result in something like: <programlisting> - <![CDATA[diff (GNU diffutils) 2.8.7 +<![CDATA[diff (GNU diffutils) 2.8.7 Written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and Len Tower. @@ -1440,7 +1440,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.]]> </para> <para>should result in something like: <programlisting> - <![CDATA[patch 2.5.8 +<![CDATA[patch 2.5.8 Copyright (C) 1988 Larry Wall Copyright (C) 2002 Free Software Foundation, Inc. @@ -1479,15 +1479,14 @@ written by Larry Wall and Paul Eggert]]> available as a Cygwin package), you can get it at: <ulink url="http://www.gnu.org/software/wget/wget.html" />.</para> <para>If wget is trying to download files but fails to do so, - your internet connection might use a HTTP proxy. Some Internet + your Internet connection might use a HTTP proxy. Some Internet providers using such a proxy and it is common for company networks today. In this case, you must set the environment - variable http_proxy before using wget. For example, if you are + variable HTTP_PROXY before using wget. For example, if you are behind proxy.com which is listening on port 8080, you have to set it to something like:</para> <para> - <programlisting>set - HTTP_PROXY=http://proxy.com:8080/</programlisting> + <programlisting>set HTTP_PROXY=http://proxy.com:8080/</programlisting> </para> <para>If you are unsure about the settings, you might ask your system administrator.</para> |