aboutsummaryrefslogtreecommitdiffstats
path: root/epan/column.c
diff options
context:
space:
mode:
authorGerasimos Dimitriadis <dimeg@intracom.gr>2010-01-24 22:25:40 +0000
committerGerasimos Dimitriadis <dimeg@intracom.gr>2010-01-24 22:25:40 +0000
commit11e340038fdf325794fc38efd323605af7a02ffa (patch)
tree8450ba6c2369cf5db736f361e7d95e7c137708c3 /epan/column.c
parent9106b7351a934173fc26edca2b981aeb614b4499 (diff)
downloadwireshark-11e340038fdf325794fc38efd323605af7a02ffa.tar.gz
wireshark-11e340038fdf325794fc38efd323605af7a02ffa.tar.bz2
wireshark-11e340038fdf325794fc38efd323605af7a02ffa.zip
Handle underscore escaping/unescaping of the column titles
under the new packet list svn path=/trunk/; revision=31649
Diffstat (limited to 'epan/column.c')
-rw-r--r--epan/column.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/epan/column.c b/epan/column.c
index 164855aee4..b944b227c7 100644
--- a/epan/column.c
+++ b/epan/column.c
@@ -727,3 +727,59 @@ build_column_format_array(column_info *cinfo, gint num_cols, gboolean reset_fenc
}
}
}
+
+/*
+ * This function takes a string and copies it, inserting an underscore before
+ * every underscore in it.
+ */
+gchar*
+g_strdup_escape_underscore (const gchar *str)
+{
+ gchar *p, *q, *new_str;
+
+ if(!str)
+ return NULL;
+
+ p = (gchar *)str;
+ /* Worst case: A string that is full of underscores */
+ q = new_str = g_malloc (strlen(str) * 2 + 1);
+
+ while(*p != 0)
+ {
+ if(*p == '_')
+ *q++ = '_';
+
+ *q++ = *p++;
+ }
+ *q++ = '\0';
+
+ return new_str;
+}
+
+gchar*
+g_strdup_unescape_underscore (const gchar *str)
+{
+ gchar *p, *q, *new_str;
+
+ if(!str)
+ return NULL;
+
+ p = (gchar *)str;
+ /* Worst case: A string that contains no underscores */
+ q = new_str = g_malloc (strlen(str) + 1);
+
+ while(*p != 0)
+ {
+ if(*p == '_')
+ {
+ *q++ = '_';
+ p += 2;
+ continue;
+ }
+
+ *q++ = *p++;
+ }
+ *q++ = '\0';
+
+ return new_str;
+}