aboutsummaryrefslogtreecommitdiffstats
path: root/epan/column-utils.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-10-04 13:34:52 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-10-04 13:34:52 +0000
commit4e4f6d67fa9e7d529f615abd131feed552b1c76a (patch)
tree9dbe874173fd47f37671f2ee53054f4a2de298d8 /epan/column-utils.c
parent494b806bfcd5f356a178f1c8801c49c402bd5fb4 (diff)
downloadwireshark-4e4f6d67fa9e7d529f615abd131feed552b1c76a.tar.gz
wireshark-4e4f6d67fa9e7d529f615abd131feed552b1c76a.tar.bz2
wireshark-4e4f6d67fa9e7d529f615abd131feed552b1c76a.zip
in svn 15335 the tcp analysis was changed to do its stuff and to populate (prepend to) COL_INFO before callking the subdissectors
instead of calling the tcp analysis (and prepend colingo) eitehr after the subdissector returned normally or if an exception caused by a subdissector was rised. this as a sideffect caused tcp analysis data to be overwritten if the subdissector caused any output to the info column. (and made tcp analysis suboptimal) this change adds a new function col_prepend_fence_fstr() that will prepend the info column with the string and also, if there was no fence already defined, create a fence and set it after the prepended col info text. This way, even if the subdissectors generate and rewrite col info, the tcp analysis data will still be displayed on the info column. svn path=/trunk/; revision=16116
Diffstat (limited to 'epan/column-utils.c')
-rw-r--r--epan/column-utils.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c
index de134a7e03..109ecbdc7f 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -380,6 +380,51 @@ col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
}
va_end(ap);
}
+void
+col_prepend_fence_fstr(column_info *cinfo, gint el, const gchar *format, ...)
+{
+ va_list ap;
+ int i;
+ char orig_buf[COL_BUF_MAX_LEN];
+ const char *orig;
+ size_t max_len;
+
+ g_assert(cinfo->col_first[el] >= 0);
+ if (el == COL_INFO)
+ max_len = COL_MAX_INFO_LEN;
+ else
+ max_len = COL_MAX_LEN;
+
+ va_start(ap, format);
+ for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
+ if (cinfo->fmt_matx[i][el]) {
+ if (cinfo->col_data[i] != cinfo->col_buf[i]) {
+ /* This was set with "col_set_str()"; which is effectively const */
+ orig = cinfo->col_data[i];
+ } else {
+ strncpy(orig_buf, cinfo->col_buf[i], max_len);
+ orig_buf[max_len - 1] = '\0';
+ orig = orig_buf;
+ }
+ g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
+ cinfo->col_buf[i][max_len - 1] = '\0';
+
+ /*
+ * Move the fence if it exists, else create a new fence at the
+ * end of the prepended data.
+ */
+ if (cinfo->col_fence[i] > 0) {
+ cinfo->col_fence[i] += strlen(cinfo->col_buf[i]);
+ } else {
+ cinfo->col_fence[i] = strlen(cinfo->col_buf[i]);
+ }
+ strncat(cinfo->col_buf[i], orig, max_len);
+ cinfo->col_buf[i][max_len - 1] = '\0';
+ cinfo->col_data[i] = cinfo->col_buf[i];
+ }
+ }
+ va_end(ap);
+}
/* Use this if "str" points to something that won't stay around (and
must thus be copied). */