Improve layout of listings and long URL's
[obnox/wireshark/wip.git] / print.c
diff --git a/print.c b/print.c
index fafacfe8edcb99e7f3e0ab89db9f92c9e79fadb1..6f733fbc713e63be304f6f597e26a2e5f6e1b555 100644 (file)
--- a/print.c
+++ b/print.c
@@ -154,11 +154,19 @@ void proto_tree_print_node(proto_node *node, gpointer data)
                proto_item_fill_label(fi, label_str);
        }
 
+       if (PROTO_ITEM_IS_GENERATED(node)) {
+               label_ptr = g_strdup_printf("[%s]", label_ptr);
+       }
+
        if (!print_line(pdata->stream, pdata->level, label_ptr)) {
                pdata->success = FALSE;
                return;
        }
 
+       if (PROTO_ITEM_IS_GENERATED(node)) {
+               g_free(label_ptr);
+       }
+
        /* If it's uninterpreted data, dump it (unless our caller will
           be printing the entire packet in hex). */
        if (fi->hfinfo->id == proto_data && pdata->print_hex_for_data) {
@@ -249,7 +257,9 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
                        label_ptr = "";
                }
 
-               fputs("<field show=\"", pdata->fh);
+               /* Show empty name since it is a required field */
+               fputs("<field name=\"", pdata->fh);
+               fputs("\" show=\"", pdata->fh);
                print_escaped_xml(pdata->fh, label_ptr);
 
                fprintf(pdata->fh, "\" size=\"%d", fi->length);
@@ -322,13 +332,19 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
                fprintf(pdata->fh, "\" pos=\"%d", fi->start);
 /*             fprintf(pdata->fh, "\" id=\"%d", fi->hfinfo->id);*/
 
-               if (fi->hfinfo->type != FT_PROTOCOL) {
-                       /* Field */
-
+               /* show, value, and unmaskedvalue attributes */
+               switch (fi->hfinfo->type)
+               {
+               case FT_PROTOCOL:
+                       break;
+               case FT_NONE:
+                       fputs("\" show=\"\" value=\"",  pdata->fh);
+                       break;
+               default:
                        /* XXX - this is a hack until we can just call
                         * fvalue_to_string_repr() for *all* FT_* types. */
-                       dfilter_string = proto_construct_dfilter_string(fi,
-                                       pdata->edt);
+                       dfilter_string = proto_construct_match_selected_string(fi,
+                           pdata->edt);
                        if (dfilter_string != NULL) {
                                chop_len = strlen(fi->hfinfo->abbrev) + 4; /* for " == " */
 
@@ -345,17 +361,25 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
                                fputs("\" show=\"", pdata->fh);
                                print_escaped_xml(pdata->fh, &dfilter_string[chop_len]);
                        }
+
+                       /*
+                        * XXX - should we omit "value" for any fields?
+                        * What should we do for fields whose length is 0?
+                        * They might come from a pseudo-header or from
+                        * the capture header (e.g., time stamps), or
+                        * they might be generated fields.
+                        */
                        if (fi->length > 0) {
                                fputs("\" value=\"", pdata->fh);
 
                                if (fi->hfinfo->bitmask!=0) {
-                                       fprintf(pdata->fh, "%X", fvalue_get_integer(&fi->value));
+                                       fprintf(pdata->fh, "%X", fvalue_get_uinteger(&fi->value));
                                        fputs("\" unmaskedvalue=\"", pdata->fh);
                                        write_pdml_field_hex_value(pdata, fi);
                                }
                                else {
-                    write_pdml_field_hex_value(pdata, fi);
-                }
+                                       write_pdml_field_hex_value(pdata, fi);
+                               }
                        }
                }
 
@@ -392,7 +416,7 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
 }
 
 /* Print info for a 'geninfo' pseudo-protocol. This is required by
- * the PDML spec. The information is contained in Ethereal's 'frame' protocol,
+ * the PDML spec. The information is contained in Wireshark's 'frame' protocol,
  * but we produce a 'geninfo' protocol in the PDML to conform to spec.
  * The 'frame' protocol follows the 'geninfo' protocol in the PDML. */
 static void
@@ -416,7 +440,7 @@ print_pdml_geninfo(proto_tree *tree, FILE *fh)
        if (g_ptr_array_len(finfo_array) < 1) {
                return;
        }
-       num = fvalue_get_integer(&((field_info*)finfo_array->pdata[0])->value);
+       num = fvalue_get_uinteger(&((field_info*)finfo_array->pdata[0])->value);
        g_ptr_array_free(finfo_array, FALSE);
 
        /* frame.pkt_len --> geninfo.len */
@@ -424,7 +448,7 @@ print_pdml_geninfo(proto_tree *tree, FILE *fh)
        if (g_ptr_array_len(finfo_array) < 1) {
                return;
        }
-       len = fvalue_get_integer(&((field_info*)finfo_array->pdata[0])->value);
+       len = fvalue_get_uinteger(&((field_info*)finfo_array->pdata[0])->value);
        g_ptr_array_free(finfo_array, FALSE);
 
        /* frame.cap_len --> geninfo.caplen */
@@ -432,7 +456,7 @@ print_pdml_geninfo(proto_tree *tree, FILE *fh)
        if (g_ptr_array_len(finfo_array) < 1) {
                return;
        }
-       caplen = fvalue_get_integer(&((field_info*)finfo_array->pdata[0])->value);
+       caplen = fvalue_get_uinteger(&((field_info*)finfo_array->pdata[0])->value);
        g_ptr_array_free(finfo_array, FALSE);
 
        /* frame.time --> geninfo.timestamp */
@@ -536,13 +560,13 @@ proto_tree_write_csv(epan_dissect_t *edt, FILE *fh)
         /* if this is the first packet, we have to write the CSV header */
         if(edt->pi.fd->num == 1) {
             for(i=0; i < edt->pi.cinfo->num_cols - 1; i++)
-               fprintf(fh, "\"%s\", ", edt->pi.cinfo->col_title[i]);
+               fprintf(fh, "\"%s\",", edt->pi.cinfo->col_title[i]);
 
             fprintf(fh, "\"%s\"\n", edt->pi.cinfo->col_title[i]);
         }
 
         for(i=0; i < edt->pi.cinfo->num_cols - 1; i++)
-            fprintf(fh, "\"%s\", ", edt->pi.cinfo->col_data[i]);
+            fprintf(fh, "\"%s\",", edt->pi.cinfo->col_data[i]);
 
         fprintf(fh, "\"%s\"\n", edt->pi.cinfo->col_data[i]);
 }
@@ -694,7 +718,7 @@ print_hex_data(print_stream_t *stream, epan_dissect_t *edt)
  * This routine is based on a routine created by Dan Lasley
  * <DLASLEY@PROMUS.com>.
  *
- * It was modified for Ethereal by Gilbert Ramirez and others.
+ * It was modified for Wireshark by Gilbert Ramirez and others.
  */
 
 #define MAX_OFFSET_LEN 8       /* max length of hex offset of bytes */
@@ -998,7 +1022,7 @@ print_preamble_ps(print_stream_t *self, gchar *filename)
        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 - Ethereal) def\n", psbuffer);
+       fprintf(output->fh, "/eth_pagetitle (%s - Wireshark) def\n", psbuffer);
        fputs("\n", output->fh);
        return !ferror(output->fh);
 }