Get rid of a Clist and move the functon to display floats with two decimals to gui_utils.
[metze/wireshark/wip.git] / print.c
diff --git a/print.c b/print.c
index 999d0d6506b82b6e4125b6b20701f985e6630e7f..a8c3f7527910cb70acfb836348c7491766e2ef5f 100644 (file)
--- a/print.c
+++ b/print.c
@@ -40,7 +40,8 @@
 #include "packet-range.h"
 #include "print.h"
 #include "ps.h"
-#include "file_util.h"
+#include "version_info.h"
+#include <wsutil/file_util.h>
 #include <epan/charsets.h>
 #include <epan/dissectors/packet-data.h>
 #include <epan/dissectors/packet-frame.h>
@@ -103,7 +104,7 @@ open_print_dest(int to_file, const char *dest)
 
        /* Open the file or command for output */
        if (to_file)
-               fh = eth_fopen(dest, "w");
+               fh = ws_fopen(dest, "w");
        else
                fh = popen(dest, "w");
 
@@ -334,7 +335,7 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
                print_escaped_xml(pdata->fh, fi->hfinfo->abbrev);
 
 #if 0
-       /* PDML spec, see: 
+       /* PDML spec, see:
         * http://analyzer.polito.it/30alpha/docs/dissectors/PDMLSpec.htm
         *
         * the show fields contains things in 'human readable' format
@@ -343,9 +344,9 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
         * showdtl: contains additional details of the field data
         * showmap: contains mappings of the field data (e.g. the hostname to an IP address)
         *
-        * XXX - the showname shouldn't contain the field data itself 
-        * (like it's contained in the fi->rep->representation). 
-        * Unfortunately, we don't have the field data representation for 
+        * XXX - the showname shouldn't contain the field data itself
+        * (like it's contained in the fi->rep->representation).
+        * Unfortunately, we don't have the field data representation for
         * all fields, so this isn't currently possible */
                fputs("\" showname=\"", pdata->fh);
                print_escaped_xml(pdata->fh, fi->hfinfo->name);
@@ -494,8 +495,8 @@ print_pdml_geninfo(proto_tree *tree, FILE *fh)
        num = fvalue_get_uinteger(&((field_info*)finfo_array->pdata[0])->value);
        g_ptr_array_free(finfo_array, FALSE);
 
-       /* frame.pkt_len --> geninfo.len */
-       finfo_array = proto_find_finfo(tree, hf_frame_packet_len);
+       /* frame.frame_len --> geninfo.len */
+       finfo_array = proto_find_finfo(tree, hf_frame_len);
        if (g_ptr_array_len(finfo_array) < 1) {
                return;
        }
@@ -530,7 +531,7 @@ print_pdml_geninfo(proto_tree *tree, FILE *fh)
 
        /* Print geninfo.len */
        fprintf(fh,
-"    <field name=\"len\" pos=\"0\" show=\"%u\" showname=\"Packet Length\" value=\"%x\" size=\"%u\"/>\n",
+"    <field name=\"len\" pos=\"0\" show=\"%u\" showname=\"Frame Length\" value=\"%x\" size=\"%u\"/>\n",
                len, len, frame_finfo->length);
 
        /* Print geninfo.caplen */
@@ -744,6 +745,9 @@ write_pdml_field_hex_value(write_pdml_data *pdata, field_info *fi)
        int i;
        const guint8 *pd;
 
+       if (!fi->ds_tvb)
+               return;
+
        if (fi->length > tvb_length_remaining(fi->ds_tvb, fi->start)) {
                fprintf(pdata->fh, "field length invalid!");
                return;
@@ -1105,12 +1109,12 @@ print_preamble_ps(print_stream_t *self, gchar *filename)
 
        print_ps_preamble(output->fh);
 
-       fputs("%% Set the font to 10 point\n", output->fh);
-       fputs("/Courier findfont 10 scalefont setfont\n", output->fh);
+       fputs("%% Set the font to 8 point\n", output->fh);
+       fputs("/Courier findfont 8 scalefont setfont\n", output->fh);
        fputs("\n", output->fh);
        fputs("%% the page title\n", output->fh);
        ps_clean_string(psbuffer, filename, MAX_PS_LINE_LENGTH);
-       fprintf(output->fh, "/eth_pagetitle (%s - Wireshark) def\n", psbuffer);
+       fprintf(output->fh, "/ws_pagetitle (%s - Wireshark " VERSION "%s) def\n", psbuffer, wireshark_svnversion);
        fputs("\n", output->fh);
        return !ferror(output->fh);
 }
@@ -1240,7 +1244,7 @@ output_fields_t* output_fields_new()
     fields->fields = NULL; /*Do lazy initialisation */
     fields->field_indicies = NULL;
     fields->field_values = NULL;
-    fields->quote='\0'; 
+    fields->quote='\0';
     return fields;
 }
 
@@ -1274,7 +1278,7 @@ void output_fields_free(output_fields_t* fields)
         g_ptr_array_free(fields->fields, TRUE);
     }
 
-    g_free(fields);    
+    g_free(fields);
 }
 
 void output_fields_add(output_fields_t* fields, const gchar* field)
@@ -1341,7 +1345,7 @@ gboolean output_fields_set_option(output_fields_t* info, gchar* option)
             info->separator = *option_value;
             break;
         }
-        return TRUE;       
+        return TRUE;
     }
 
     if(0 == strcmp(option_name, "quote")) {
@@ -1360,7 +1364,7 @@ gboolean output_fields_set_option(output_fields_t* info, gchar* option)
             info->quote='\0';
             break;
         }
-        return TRUE;        
+        return TRUE;
     }
 
     return FALSE;
@@ -1392,11 +1396,11 @@ void write_fields_preamble(output_fields_t* fields, FILE *fh)
             fputc(fields->separator, fh);
         }
        fputs(field, fh);
-    }    
+    }
     fputc('\n', fh);
 }
 
-static void proto_tree_get_node_field_values(proto_node *node, gpointer data) 
+static void proto_tree_get_node_field_values(proto_node *node, gpointer data)
 {
     write_field_data_t *call_data;
     field_info *fi;
@@ -1418,7 +1422,7 @@ static void proto_tree_get_node_field_values(proto_node *node, gpointer data)
             call_data->fields->field_values[actual_index - 1] = value;
         }
     }
-    
+
     /* Recurse here. */
     if (node->first_child != NULL) {
         proto_tree_children_foreach(node, proto_tree_get_node_field_values,
@@ -1446,17 +1450,17 @@ void proto_tree_write_fields(output_fields_t* fields, epan_dissect_t *edt, FILE
         i = 0;
         while( i < fields->fields->len) {
             gchar* field = g_ptr_array_index(fields->fields, i);
-             /* Store field indicies +1 so that zero is not a valid value, 
+             /* Store field indicies +1 so that zero is not a valid value,
               * and can be distinguished from NULL as a pointer.
               */
             ++i;
-            g_hash_table_insert(fields->field_indicies, field, GUINT_TO_POINTER(i));            
+            g_hash_table_insert(fields->field_indicies, field, GUINT_TO_POINTER(i));
         }
     }
 
     /* Buffer to store values for this packet */
     fields->field_values = ep_alloc_array0(const gchar*, fields->fields->len);
-    
+
     proto_tree_children_foreach(edt->tree, proto_tree_get_node_field_values,
                                 &data);
 
@@ -1549,6 +1553,9 @@ get_field_hex_value(GSList* src_list, field_info *fi)
 {
     const guint8 *pd;
 
+    if (!fi->ds_tvb)
+        return NULL;
+
     if (fi->length > tvb_length_remaining(fi->ds_tvb, fi->start)) {
         return "field length invalid!";
     }