HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / column-utils.h
blobe2edd5641aeaee699d29f19e943e437c42cd7250
1 /* column-utils.h
2 * Definitions for column utility structures and routines
4 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __COLUMN_UTILS_H__
26 #define __COLUMN_UTILS_H__
28 #include <glib.h>
30 #include "column-info.h"
31 #include "packet_info.h"
32 #include <epan/epan.h>
33 #include "ws_symbol_export.h"
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
39 /** @file
40 * Helper routines for column utility structures and routines.
43 /** Allocate all the data structures for constructing column data, given
44 * the number of columns.
46 * Internal, don't use this in dissectors!
48 WS_DLL_PUBLIC void col_setup(column_info *cinfo, const gint num_cols);
50 /** Cleanup all the data structures for constructing column data;
51 * undoes the alocations that col_setup() does.
53 * Internal, don't use this in dissectors!
55 WS_DLL_PUBLIC void col_cleanup(column_info *cinfo);
57 /** Initialize the data structures for constructing column data.
59 * Internal, don't use this in dissectors!
61 extern void col_init(column_info *cinfo, const struct epan_session *epan);
63 /** Fill in all columns of the given packet which are based on values from frame_data.
65 * Internal, don't use this in dissectors!
67 WS_DLL_PUBLIC void col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, gboolean const fill_col_exprs);
69 /** Fill in all columns of the given packet.
71 * Internal, don't use this in dissectors!
73 WS_DLL_PUBLIC void col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
75 /** Fill in columns if we got an error reading the packet.
76 * We set most columns to "???", and set the Info column to an error
77 * message.
79 * Internal, don't use this in dissectors!
81 WS_DLL_PUBLIC void col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
83 /* Utility routines used by packet*.c */
85 /** Are the columns writable?
87 * @param cinfo the current packet row
88 * @return TRUE if it's writable, FALSE if not
90 WS_DLL_PUBLIC gboolean col_get_writable(column_info *cinfo);
92 /** Set the columns writable.
94 * @param cinfo the current packet row
95 * @param writable TRUE if it's writable, FALSE if not
97 WS_DLL_PUBLIC void col_set_writable(column_info *cinfo, const gboolean writable);
99 /** Sets a fence for the current column content,
100 * so this content won't be affected by further col_... function calls.
102 * This can be useful if a protocol is more than once in a single packet,
103 * e.g. multiple HTTP calls in a single TCP packet.
105 * @param cinfo the current packet row
106 * @param col the column to use, e.g. COL_INFO
108 WS_DLL_PUBLIC void col_set_fence(column_info *cinfo, const gint col);
110 /** Gets the text of a column element.
112 * @param cinfo the current packet row
113 * @param col the column to use, e.g. COL_INFO
115 * @return the text string
117 extern const gchar *col_get_text(column_info *cinfo, const gint col);
119 /** Clears the text of a column element.
121 * @param cinfo the current packet row
122 * @param col the column to use, e.g. COL_INFO
124 WS_DLL_PUBLIC void col_clear(column_info *cinfo, const gint col);
126 /** Set (replace) the text of a column element, the text won't be copied.
128 * Usually used to set const strings!
130 * @param cinfo the current packet row
131 * @param col the column to use, e.g. COL_INFO
132 * @param str the string to set
134 WS_DLL_PUBLIC void col_set_str(column_info *cinfo, const gint col, const gchar * str);
136 /** Add (replace) the text of a column element, the text will be copied.
138 * @param cinfo the current packet row
139 * @param col the column to use, e.g. COL_INFO
140 * @param str the string to add
142 WS_DLL_PUBLIC void col_add_str(column_info *cinfo, const gint col, const gchar *str);
144 /** Add (replace) the text of a column element, the text will be formatted and copied.
146 * Same function as col_add_str() but using a printf-like format string.
148 * @param cinfo the current packet row
149 * @param col the column to use, e.g. COL_INFO
150 * @param format the format string
151 * @param ... the variable number of parameters
153 WS_DLL_PUBLIC void col_add_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
154 G_GNUC_PRINTF(3, 4);
156 /** For internal Wireshark use only. Not to be called from dissectors. */
157 void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo);
159 /** For internal Wireshark use only. Not to be called from dissectors. */
160 WS_DLL_PUBLIC
161 void col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo);
163 /** For internal Wireshark use only. Not to be called from dissectors. */
164 WS_DLL_PUBLIC
165 gboolean have_custom_cols(column_info *cinfo);
166 /** For internal Wireshark use only. Not to be called from dissectors. */
167 WS_DLL_PUBLIC
168 gboolean col_has_time_fmt(column_info *cinfo, const gint col);
169 /** For internal Wireshark use only. Not to be called from dissectors. */
170 WS_DLL_PUBLIC
171 gboolean col_based_on_frame_data(column_info *cinfo, const gint col);
173 /** Append the given text to a column element, the text will be copied.
175 * @param cinfo the current packet row
176 * @param col the column to use, e.g. COL_INFO
177 * @param str the string to append
179 WS_DLL_PUBLIC void col_append_str(column_info *cinfo, const gint col, const gchar *str);
181 /** Append the given text to a column element, the text will be formatted and copied.
183 * Same function as col_append_str() but using a printf-like format string.
185 * @param cinfo the current packet row
186 * @param col the column to use, e.g. COL_INFO
187 * @param format the format string
188 * @param ... the variable number of parameters
190 WS_DLL_PUBLIC void col_append_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
191 G_GNUC_PRINTF(3, 4);
193 /** Prepend the given text to a column element, the text will be formatted and copied.
195 * @param cinfo the current packet row
196 * @param col the column to use, e.g. COL_INFO
197 * @param format the format string
198 * @param ... the variable number of parameters
200 WS_DLL_PUBLIC void col_prepend_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
201 G_GNUC_PRINTF(3, 4);
203 /**Prepend the given text to a column element, the text will be formatted and copied.
204 * This function is similar to col_prepend_fstr() but this function will
205 * unconditionally set a fence to the end of the prepended data even if there
206 * were no fence before.
207 * The col_prepend_fstr() will only prepend the data before the fence IF
208 * there is already a fence created. This function will create a fence in case
209 * it does not yet exist.
211 WS_DLL_PUBLIC void col_prepend_fence_fstr(column_info *cinfo, const gint col, const gchar *format, ...)
212 G_GNUC_PRINTF(3, 4);
214 /** Append the given text (prepended by a separator) to a column element.
216 * Much like col_append_str() but will prepend the given separator if the column isn't empty.
218 * @param cinfo the current packet row
219 * @param col the column to use, e.g. COL_INFO
220 * @param sep the separator string or NULL for default: ", "
221 * @param str the string to append
223 WS_DLL_PUBLIC void col_append_sep_str(column_info *cinfo, const gint col, const gchar *sep,
224 const gchar *str);
226 /** Append the given text (prepended by a separator) to a column element.
228 * Much like col_append_fstr() but will prepend the given separator if the column isn't empty.
230 * @param cinfo the current packet row
231 * @param col the column to use, e.g. COL_INFO
232 * @param sep the separator string or NULL for default: ", "
233 * @param format the format string
234 * @param ... the variable number of parameters
236 WS_DLL_PUBLIC void col_append_sep_fstr(column_info *cinfo, const gint col, const gchar *sep,
237 const gchar *format, ...)
238 G_GNUC_PRINTF(4, 5);
240 /** Set the given (relative) time to a column element.
242 * Used by multiple dissectors to set the time in the column
243 * COL_DELTA_CONV_TIME
245 * @param cinfo the current packet row
246 * @param col the column to use, e.g. COL_INFO
247 * @param ts the time to set in the column
248 * @param fieldname the fieldname to use for creating a filter (when
249 * applying/preparing/copying as filter)
251 WS_DLL_PUBLIC void col_set_time(column_info *cinfo, const int col,
252 const nstime_t *ts, const char *fieldname);
254 WS_DLL_PUBLIC void set_fd_time(const struct epan_session *epan, frame_data *fd, gchar *buf);
256 #ifdef __cplusplus
258 #endif /* __cplusplus */
260 #endif /* __COLUMN_UTILS_H__ */