2 * Definitions for column utility structures and routines
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifndef __COLUMN_UTILS_H__
26 #define __COLUMN_UTILS_H__
30 #include "gnuc_format_check.h"
31 #include "column_info.h"
32 #include "packet_info.h"
36 #endif /* __cplusplus */
38 /** Maximum length of columns (except COL_INFO).
39 * Internal, don't use this in dissectors!
42 #define COL_MAX_LEN 256
43 /** Maximum length of info columns (COL_INFO only).
44 * Internal, don't use this in dissectors!
46 #define COL_MAX_INFO_LEN 4096
49 /** Allocate all the data structures for constructing column data, given
50 * the number of columns.
52 * Internal, don't use this in dissectors!
54 extern void col_setup(column_info *cinfo, gint num_cols);
56 /** Initialize the data structures for constructing column data.
58 * Internal, don't use this in dissectors!
60 extern void col_init(column_info *cinfo);
62 /** Set the format of the "variable time format".
64 * Internal, don't use this in dissectors!
66 extern void col_set_cls_time(frame_data *, column_info *cinfo, gint col);
68 /** Fill in all columns of the given packet.
70 * Internal, don't use this in dissectors!
72 extern void col_fill_in(packet_info *pinfo);
74 /* Utility routines used by packet*.c */
76 /** Are the columns writable?
78 * @param cinfo the current packet row
79 * @return TRUE if it's writable, FALSE if not
81 extern gboolean col_get_writable(column_info *cinfo);
83 /** Set the columns writable.
85 * @param cinfo the current packet row
86 * @param writable TRUE if it's writable, FALSE if not
88 extern void col_set_writable(column_info *cinfo, gboolean writable);
90 /** Check if the given column be filled with data.
92 * @param cinfo the current packet row
93 * @param col the column to use, e.g. COL_INFO
95 extern gint check_col(column_info *cinfo, gint col);
97 /** Sets a fence for the current column content,
98 * so this content won't be affected by further col_... function calls.
100 * This can be useful if a protocol is more than once in a single packet,
101 * e.g. multiple HTTP calls in a single TCP packet.
103 * @param cinfo the current packet row
104 * @param col the column to use, e.g. COL_INFO
106 extern void col_set_fence(column_info *cinfo, gint col);
108 /** Clears the text of a column element.
110 * @param cinfo the current packet row
111 * @param col the column to use, e.g. COL_INFO
113 extern void col_clear(column_info *cinfo, gint col);
115 /** Set (replace) the text of a column element, the text won't be copied.
117 * Usually used to set const strings!
119 * @param cinfo the current packet row
120 * @param col the column to use, e.g. COL_INFO
121 * @param str the string to set
123 extern void col_set_str(column_info *cinfo, gint col, const gchar * str);
125 /** Add (replace) the text of a column element, the text will be copied.
127 * @param cinfo the current packet row
128 * @param col the column to use, e.g. COL_INFO
129 * @param str the string to add
131 extern void col_add_str(column_info *cinfo, gint col, const gchar *str);
133 /** Add (replace) the text of a column element, the text will be formatted and copied.
135 * Same function as col_add_str() but using a printf-like format string.
137 * @param cinfo the current packet row
138 * @param col the column to use, e.g. COL_INFO
139 * @param format the format string
140 * @param ... the variable number of parameters
142 extern void col_add_fstr(column_info *cinfo, gint col, const gchar *format, ...)
143 GNUC_FORMAT_CHECK(printf, 3, 4);
145 /** Append the given text to a column element, the text will be copied.
147 * @param cinfo the current packet row
148 * @param col the column to use, e.g. COL_INFO
149 * @param str the string to append
151 extern void col_append_str(column_info *cinfo, gint col, const gchar *str);
153 /** Append the given text to a column element, the text will be formatted and copied.
155 * Same function as col_append_str() but using a printf-like format string.
157 * @param cinfo the current packet row
158 * @param col the column to use, e.g. COL_INFO
159 * @param format the format string
160 * @param ... the variable number of parameters
162 extern void col_append_fstr(column_info *cinfo, gint col, const gchar *format, ...)
163 GNUC_FORMAT_CHECK(printf, 3, 4);
165 /** Prepend the given text to a column element, the text will be formatted and copied.
167 * @param cinfo the current packet row
168 * @param col the column to use, e.g. COL_INFO
169 * @param format the format string
170 * @param ... the variable number of parameters
172 extern void col_prepend_fstr(column_info *cinfo, gint col, const gchar *format, ...)
173 GNUC_FORMAT_CHECK(printf, 3, 4);
175 /**Prepend the given text to a column element, the text will be formatted and copied.
176 * This function is similar to col_prepend_fstr() but this function will
177 * unconditionally set a fence to the end of the prepended data even if there
178 * were no fence before.
179 * The col_prepend_fstr() will only prepend the data before the fence IFF
180 * there is already a fence created. This function will create a fence in case
181 * it does not yet exist.
183 extern void col_prepend_fence_fstr(column_info *cinfo, gint col, const gchar *format, ...)
184 GNUC_FORMAT_CHECK(printf, 3, 4);
186 /** Append the given text (prepended by a separator) to a column element.
188 * Much like col_append_str() but will prepend the given separator if the column isn't empty.
190 * @param cinfo the current packet row
191 * @param col the column to use, e.g. COL_INFO
192 * @param sep the separator string or NULL for default: ", "
193 * @param str the string to append
195 extern void col_append_sep_str(column_info *cinfo, gint col, const gchar *sep,
198 /** Append the given text (prepended by a separator) to a column element.
200 * Much like col_append_fstr() but will prepend the given separator if the column isn't empty.
202 * @param cinfo the current packet row
203 * @param col the column to use, e.g. COL_INFO
204 * @param sep the separator string or NULL for default: ", "
205 * @param format the format string
206 * @param ... the variable number of parameters
208 extern void col_append_sep_fstr(column_info *cinfo, gint col, const gchar *sep,
209 const gchar *format, ...)
210 GNUC_FORMAT_CHECK(printf, 4, 5);
214 #endif /* __cplusplus */
216 #endif /* __COLUMN_UTILS_H__ */