Update to FindGTK2 from cmake 2.8.3. Add back quartz options which
[obnox/wireshark/wip.git] / print.c
diff --git a/print.c b/print.c
index aedcb2f88e1d1ed4d44b6f7f4abc46a9c43894cc..bc5b5ac05a99cd2993ee1cf2a4d984565ee6931a 100644 (file)
--- a/print.c
+++ b/print.c
@@ -31,6 +31,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <glib.h>
+
 #include <epan/epan.h>
 #include <epan/epan_dissect.h>
 #include <epan/tvbuff.h>
@@ -83,6 +85,8 @@ struct _output_fields {
     gchar quote;
 };
 
+GHashTable *output_only_tables = NULL;
+
 static gboolean write_headers = FALSE;
 
 static const gchar* get_field_hex_value(GSList* src_list, field_info *fi);
@@ -188,6 +192,19 @@ void proto_tree_print_node(proto_node *node, gpointer data)
                return;
        }
 
+       /*
+        * If -O is specified, only display the protocols which are in the
+        * lookup table.  Only check on the first level: once we start printing
+        * a tree, print the rest of the subtree.  Otherwise we won't print
+        * subitems whose abbreviation doesn't match the protocol--for example
+        * text items (whose abbreviation is simply "text").
+        */
+       if (output_only_tables != NULL && pdata->level == 0
+        && g_hash_table_lookup(output_only_tables, fi->hfinfo->abbrev) == NULL) {
+         pdata->success = TRUE;
+         return;
+       }
+
        if (PROTO_ITEM_IS_GENERATED(node)) {
                g_free(label_ptr);
        }
@@ -634,7 +651,7 @@ static void csv_write_str(const char *str, char sep, FILE *fh)
     csv_str = csv_massage_str(str, NULL);
     fprintf(fh, "\"%s\"%c", csv_str, sep);
     g_free(csv_str);
-}    
+}
 
 void
 proto_tree_write_csv(epan_dissect_t *edt, FILE *fh)
@@ -1344,6 +1361,9 @@ gboolean output_fields_set_option(output_fields_t* info, gchar* option)
         return FALSE; /* Is this guarded against by option parsing? */
     }
     option_name = strtok(option,"=");
+    if (!option_name) {
+        return FALSE;
+    }
     option_value = option + strlen(option_name) + 1;
     if(0 == strcmp(option_name, "header")) {
         switch(NULL == option_value ? '\0' : *option_value) {