2 * Routines for handling column preferences
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.
36 #include <epan/timestamp.h>
37 #include <epan/prefs.h>
38 #include <epan/dfilter/dfilter.h>
39 #include <epan/column.h>
40 #include <epan/packet.h>
42 /* Given a format number (as defined in column-info.h), returns its equivalent
45 col_format_to_string(const gint fmt
) {
46 static const gchar
*const slist
[NUM_COL_FMTS
] = {
47 "%q", /* 0) COL_8021Q_VLAN_ID */
48 "%Yt", /* 1) COL_ABS_YMD_TIME */
49 "%YDOYt", /* 2) COL_ABS_YDOY_TIME */
50 "%At", /* 3) COL_ABS_TIME */
51 "%c", /* 4) COL_CIRCUIT_ID */
52 "%Xd", /* 5) COL_DSTIDX - !! DEPRECATED !!*/
53 "%Xs", /* 6) COL_SRCIDX - !! DEPRECATED !!*/
54 "%V", /* 7) COL_VSAN - !! DEPRECATED !!*/
55 "%B", /* 8) COL_CUMULATIVE_BYTES */
56 "%Cus", /* 9) COL_CUSTOM */
57 "%y", /* 10) COL_DCE_CALL */
58 "%z", /* 11) COL_DCE_CTX */
59 "%Tt", /* 12) COL_DELTA_TIME */
60 "%dct", /* 13) COL_DELTA_CONV_TIME */
61 "%Gt", /* 14) COL_DELTA_TIME_DIS */
62 "%rd", /* 15) COL_RES_DST */
63 "%ud", /* 16) COL_UNRES_DST */
64 "%rD", /* 17) COL_RES_DST_PORT */
65 "%uD", /* 18) COL_UNRES_DST_PORT */
66 "%d", /* 19) COL_DEF_DST */
67 "%D", /* 20) COL_DEF_DST_PORT */
68 "%a", /* 21) COL_EXPERT */
69 "%I", /* 22) COL_IF_DIR */
70 "%XO", /* 23) COL_OXID */
71 "%XR", /* 24) COL_RXID */
72 "%C", /* 25) !! DEPRECATED !! - COL_FR_DLCI */
73 "%F", /* 26) COL_FREQ_CHAN */
74 "%l", /* 27) !! DEPRECATED !! - COL_BSSGP_TLLI */
75 "%P", /* 28) !! DEPRECATED !! - COL_HPUX_DEVID */
76 "%H", /* 29) !! DEPRECATED !! - COL_HPUX_SUBSYS */
77 "%hd", /* 30) COL_DEF_DL_DST */
78 "%hs", /* 31) COL_DEF_DL_SRC */
79 "%rhd", /* 32) COL_RES_DL_DST */
80 "%uhd", /* 33) COL_UNRES_DL_DST */
81 "%rhs", /* 34) COL_RES_DL_SRC*/
82 "%uhs", /* 35) COL_UNRES_DL_SRC */
83 "%e", /* 36) COL_RSSI */
84 "%x", /* 37) COL_TX_RATE */
85 "%f", /* 38) COL_DSCP_VALUE */
86 "%i", /* 39) COL_INFO */
87 "%U", /* 40) !! DEPRECATED !! - COL_COS_VALUE */
88 "%rnd", /* 41) COL_RES_NET_DST */
89 "%und", /* 42) COL_UNRES_NET_DST */
90 "%rns", /* 43) COL_RES_NET_SRC */
91 "%uns", /* 44) COL_UNRES_NET_SRC */
92 "%nd", /* 45) COL_DEF_NET_DST */
93 "%ns", /* 46) COL_DEF_NET_SRC */
94 "%m", /* 47) COL_NUMBER */
95 "%L", /* 48) COL_PACKET_LENGTH */
96 "%p", /* 49) COL_PROTOCOL */
97 "%Rt", /* 50) COL_REL_TIME */
98 "%rct", /* 51) !! DEPRECATED !! - COL_REL_CONV_TIME */
99 "%s", /* 52) COL_DEF_SRC */
100 "%S", /* 53) COL_DEF_SRC_PORT */
101 "%rs", /* 54) COL_RES_SRC */
102 "%us", /* 55) COL_UNRES_SRC */
103 "%rS", /* 56) COL_RES_SRC_PORT */
104 "%uS", /* 57) COL_UNRES_SRC_PORT */
105 "%E", /* 58) COL_TEI */
106 "%Yut", /* 59) COL_UTC_YMD_TIME */
107 "%YDOYut", /* 60) COL_UTC_YDOY_TIME */
108 "%Aut", /* 61) COL_UTC_TIME */
109 "%t" /* 62) COL_CLS_TIME */
112 if (fmt
< 0 || fmt
>= NUM_COL_FMTS
)
118 /* Given a format number (as defined in column-info.h), returns its
121 col_format_desc(const gint fmt
) {
122 static const gchar
*const dlist
[NUM_COL_FMTS
] = {
123 "802.1Q VLAN id", /* 0) COL_8021Q_VLAN_ID */
124 "Absolute date, as YYYY-MM-DD, and time", /* 1) COL_ABS_YMD_TIME */
125 "Absolute date, as YYYY/DOY, and time", /* 2) COL_ABS_YDOY_TIME */
126 "Absolute time", /* 3) COL_ABS_TIME */
127 "Circuit ID", /* 4) COL_CIRCUIT_ID */
128 "Cisco Dst PortIdx", /* 5) COL_DSTIDX */
129 "Cisco Src PortIdx", /* 6) COL_SRCIDX */
130 "Cisco VSAN", /* 7) COL_VSAN */
131 "Cumulative Bytes" , /* 8) COL_CUMULATIVE_BYTES */
132 "Custom", /* 9) COL_CUSTOM */
133 "DCE/RPC call (cn_call_id / dg_seqnum)", /* 10) COL_DCE_CALL */
134 "DCE/RPC context ID (cn_ctx_id)", /* 11) COL_DCE_CTX */
135 "Delta time", /* 12) COL_DELTA_TIME */
136 "Delta time (conversation)", /* 13) COL_DELTA_CONV_TIME */
137 "Delta time displayed", /* 14) COL_DELTA_TIME_DIS */
138 "Dest addr (resolved)", /* 15) COL_RES_DST */
139 "Dest addr (unresolved)", /* 16) COL_UNRES_DST */
140 "Dest port (resolved)", /* 17) COL_RES_DST_PORT */
141 "Dest port (unresolved)", /* 18) COL_UNRES_DST_PORT */
142 "Destination address", /* 19) COL_DEF_DST */
143 "Destination port", /* 20) COL_DEF_DST_PORT */
144 "Expert Info Severity", /* 21) COL_EXPERT */
145 "FW-1 monitor if/direction", /* 22) COL_IF_DIR */
146 "Fibre Channel OXID", /* 23) COL_OXID */
147 "Fibre Channel RXID", /* 24) COL_RXID */
148 "Frame Relay DLCI", /* 25) !! DEPRECATED !! - COL_FR_DLCI */
149 "Frequency/Channel", /* 26) COL_FREQ_CHAN */
150 "GPRS BSSGP TLLI", /* 27) !! DEPRECATED !! - COL_BSSGP_TLLI */
151 "HP-UX Device ID", /* 28) !! DEPRECATED !! - COL_HPUX_DEVID */
152 "HP-UX Subsystem", /* 29) !! DEPRECATED !! - COL_HPUX_SUBSYS */
153 "Hardware dest addr", /* 30) COL_DEF_DL_DST */
154 "Hardware src addr", /* 31) COL_DEF_DL_SRC */
155 "Hw dest addr (resolved)", /* 32) COL_RES_DL_DST */
156 "Hw dest addr (unresolved)", /* 33) COL_UNRES_DL_DST */
157 "Hw src addr (resolved)", /* 34) COL_RES_DL_SRC*/
158 "Hw src addr (unresolved)", /* 35) COL_UNRES_DL_SRC */
159 "IEEE 802.11 RSSI", /* 36) COL_RSSI */
160 "IEEE 802.11 TX rate", /* 37) COL_TX_RATE */
161 "IP DSCP Value", /* 38) COL_DSCP_VALUE */
162 "Information", /* 39) COL_INFO */
163 "L2 COS Value (802.1p)", /* 40) !! DEPRECATED !! - COL_COS_VALUE */
164 "Net dest addr (resolved)", /* 41) COL_RES_NET_DST */
165 "Net dest addr (unresolved)", /* 42) COL_UNRES_NET_DST */
166 "Net src addr (resolved)", /* 43) COL_RES_NET_SRC */
167 "Net src addr (unresolved)", /* 44) COL_UNRES_NET_SRC */
168 "Network dest addr", /* 45) COL_DEF_NET_DST */
169 "Network src addr", /* 46) COL_DEF_NET_SRC */
170 "Number", /* 47) COL_NUMBER */
171 "Packet length (bytes)" , /* 48) COL_PACKET_LENGTH */
172 "Protocol", /* 49) COL_PROTOCOL */
173 "Relative time", /* 50) COL_REL_TIME */
174 "Relative time (conversation)", /* 51) !! DEPRECATED !! - COL_REL_CONV_TIME */
175 "Source address", /* 52) COL_DEF_SRC */
176 "Source port", /* 53) COL_DEF_SRC_PORT */
177 "Src addr (resolved)", /* 54) COL_RES_SRC */
178 "Src addr (unresolved)", /* 55) COL_UNRES_SRC */
179 "Src port (resolved)", /* 56) COL_RES_SRC_PORT */
180 "Src port (unresolved)", /* 57) COL_UNRES_SRC_PORT */
181 "TEI", /* 58) COL_TEI */
182 "UTC date, as YYYY-MM-DD, and time", /* 59) COL_UTC_YMD_TIME */
183 "UTC date, as YYYY/DOY, and time", /* 60) COL_UTC_YDOY_TIME */
184 "UTC time", /* 61) COL_UTC_TIME */
185 "Time (format as specified)" /* 62) COL_CLS_TIME */
188 g_assert((fmt
>= 0) && (fmt
< NUM_COL_FMTS
));
193 column_dump_column_formats(void)
197 for (fmt
= 0; fmt
< NUM_COL_FMTS
; fmt
++) {
198 printf("%s\t%s\n", col_format_to_string(fmt
), col_format_desc(fmt
));
201 printf("\nFor example, to print Wireshark's default columns with tshark:\n\n"
203 "tshark.exe -o \"gui.column.format:"
204 "\\\"No.\\\",\\\"%%m\\\","
205 "\\\"Time\\\",\\\"%%t\\\","
206 "\\\"Source\\\",\\\"%%s\\\","
207 "\\\"Destination\\\",\\\"%%d\\\","
208 "\\\"Protocol\\\",\\\"%%p\\\","
209 "\\\"Length\\\",\\\"%%L\\\","
210 "\\\"Info\\\",\\\"%%i\\\"\"\n");
212 "tshark -o 'gui.column.format:"
215 "\"Source\",\"%%s\","
216 "\"Destination\",\"%%d\","
217 "\"Protocol\",\"%%p\","
218 "\"Length\",\"%%L\","
219 "\"Info\",\"%%i\"'\n");
223 /* Marks each array element true if it can be substituted for the given
226 get_column_format_matches(gboolean
*fmt_list
, const gint format
) {
228 /* Get the obvious: the format itself */
229 if ((format
>= 0) && (format
< NUM_COL_FMTS
))
230 fmt_list
[format
] = TRUE
;
232 /* Get any formats lower down on the chain */
235 fmt_list
[COL_RES_DL_SRC
] = TRUE
;
236 fmt_list
[COL_RES_NET_SRC
] = TRUE
;
239 fmt_list
[COL_RES_DL_SRC
] = TRUE
;
240 fmt_list
[COL_RES_NET_SRC
] = TRUE
;
243 fmt_list
[COL_UNRES_DL_SRC
] = TRUE
;
244 fmt_list
[COL_UNRES_NET_SRC
] = TRUE
;
247 fmt_list
[COL_RES_DL_DST
] = TRUE
;
248 fmt_list
[COL_RES_NET_DST
] = TRUE
;
251 fmt_list
[COL_RES_DL_DST
] = TRUE
;
252 fmt_list
[COL_RES_NET_DST
] = TRUE
;
255 fmt_list
[COL_UNRES_DL_DST
] = TRUE
;
256 fmt_list
[COL_UNRES_NET_DST
] = TRUE
;
259 fmt_list
[COL_RES_DL_SRC
] = TRUE
;
262 fmt_list
[COL_RES_DL_DST
] = TRUE
;
264 case COL_DEF_NET_SRC
:
265 fmt_list
[COL_RES_NET_SRC
] = TRUE
;
267 case COL_DEF_NET_DST
:
268 fmt_list
[COL_RES_NET_DST
] = TRUE
;
270 case COL_DEF_SRC_PORT
:
271 fmt_list
[COL_RES_SRC_PORT
] = TRUE
;
273 case COL_DEF_DST_PORT
:
274 fmt_list
[COL_RES_DST_PORT
] = TRUE
;
281 /* Returns a string representing the longest possible value for
282 a timestamp column type. */
284 get_timestamp_column_longest_string(const gint type
, const gint precision
)
288 case(TS_ABSOLUTE_WITH_YMD
):
289 case(TS_UTC_WITH_YMD
):
291 case(TS_PREC_AUTO_SEC
):
292 case(TS_PREC_FIXED_SEC
):
293 return "0000-00-00 00:00:00";
295 case(TS_PREC_AUTO_DSEC
):
296 case(TS_PREC_FIXED_DSEC
):
297 return "0000-00-00 00:00:00.0";
299 case(TS_PREC_AUTO_CSEC
):
300 case(TS_PREC_FIXED_CSEC
):
301 return "0000-00-00 00:00:00.00";
303 case(TS_PREC_AUTO_MSEC
):
304 case(TS_PREC_FIXED_MSEC
):
305 return "0000-00-00 00:00:00.000";
307 case(TS_PREC_AUTO_USEC
):
308 case(TS_PREC_FIXED_USEC
):
309 return "0000-00-00 00:00:00.000000";
311 case(TS_PREC_AUTO_NSEC
):
312 case(TS_PREC_FIXED_NSEC
):
313 return "0000-00-00 00:00:00.000000000";
316 g_assert_not_reached();
319 case(TS_ABSOLUTE_WITH_YDOY
):
320 case(TS_UTC_WITH_YDOY
):
322 case(TS_PREC_AUTO_SEC
):
323 case(TS_PREC_FIXED_SEC
):
324 return "0000/000 00:00:00";
326 case(TS_PREC_AUTO_DSEC
):
327 case(TS_PREC_FIXED_DSEC
):
328 return "0000/000 00:00:00.0";
330 case(TS_PREC_AUTO_CSEC
):
331 case(TS_PREC_FIXED_CSEC
):
332 return "0000/000 00:00:00.00";
334 case(TS_PREC_AUTO_MSEC
):
335 case(TS_PREC_FIXED_MSEC
):
336 return "0000/000 00:00:00.000";
338 case(TS_PREC_AUTO_USEC
):
339 case(TS_PREC_FIXED_USEC
):
340 return "0000/000 00:00:00.000000";
342 case(TS_PREC_AUTO_NSEC
):
343 case(TS_PREC_FIXED_NSEC
):
344 return "0000/000 00:00:00.000000000";
347 g_assert_not_reached();
353 case(TS_PREC_AUTO_SEC
):
354 case(TS_PREC_FIXED_SEC
):
357 case(TS_PREC_AUTO_DSEC
):
358 case(TS_PREC_FIXED_DSEC
):
361 case(TS_PREC_AUTO_CSEC
):
362 case(TS_PREC_FIXED_CSEC
):
363 return "00:00:00.00";
365 case(TS_PREC_AUTO_MSEC
):
366 case(TS_PREC_FIXED_MSEC
):
367 return "00:00:00.000";
369 case(TS_PREC_AUTO_USEC
):
370 case(TS_PREC_FIXED_USEC
):
371 return "00:00:00.000000";
373 case(TS_PREC_AUTO_NSEC
):
374 case(TS_PREC_FIXED_NSEC
):
375 return "00:00:00.000000000";
378 g_assert_not_reached();
381 case(TS_RELATIVE
): /* fallthrough */
385 case(TS_PREC_AUTO_SEC
):
386 case(TS_PREC_FIXED_SEC
):
389 case(TS_PREC_AUTO_DSEC
):
390 case(TS_PREC_FIXED_DSEC
):
393 case(TS_PREC_AUTO_CSEC
):
394 case(TS_PREC_FIXED_CSEC
):
397 case(TS_PREC_AUTO_MSEC
):
398 case(TS_PREC_FIXED_MSEC
):
401 case(TS_PREC_AUTO_USEC
):
402 case(TS_PREC_FIXED_USEC
):
403 return "0000.000000";
405 case(TS_PREC_AUTO_NSEC
):
406 case(TS_PREC_FIXED_NSEC
):
407 return "0000.000000000";
410 g_assert_not_reached();
414 /* This is enough to represent 2^63 (signed 64-bit integer) + fractions */
416 case(TS_PREC_AUTO_SEC
):
417 case(TS_PREC_FIXED_SEC
):
418 return "0000000000000000000";
420 case(TS_PREC_AUTO_DSEC
):
421 case(TS_PREC_FIXED_DSEC
):
422 return "0000000000000000000.0";
424 case(TS_PREC_AUTO_CSEC
):
425 case(TS_PREC_FIXED_CSEC
):
426 return "0000000000000000000.00";
428 case(TS_PREC_AUTO_MSEC
):
429 case(TS_PREC_FIXED_MSEC
):
430 return "0000000000000000000.000";
432 case(TS_PREC_AUTO_USEC
):
433 case(TS_PREC_FIXED_USEC
):
434 return "0000000000000000000.000000";
436 case(TS_PREC_AUTO_NSEC
):
437 case(TS_PREC_FIXED_NSEC
):
438 return "0000000000000000000.000000000";
441 g_assert_not_reached();
445 return "0000.000000";
448 g_assert_not_reached();
451 /* never reached, satisfy compiler */
455 /* Returns the longer string of the column title or the hard-coded width of
456 * its contents for building the packet list layout. */
458 get_column_width_string(const gint format
, const gint col
)
460 if(strlen(get_column_longest_string(format
)) >
461 strlen(get_column_title(col
)))
462 return get_column_longest_string(format
);
464 return get_column_title(col
);
467 /* Returns a string representing the longest possible value for a
468 particular column type. See also get_column_width_string() above.
470 Except for the COL...SRC and COL...DST columns, these are used
471 only when a capture is being displayed while it's taking place;
472 they are arguably somewhat fragile, as changes to the code that
473 generates them don't cause these widths to change, but that's
474 probably not too big a problem, given that the sizes are
475 recomputed based on the actual data in the columns when the capture
476 is done, and given that the width for COL...SRC and COL...DST columns
477 is somewhat arbitrary in any case. We should probably clean
478 that up eventually, though. */
480 get_column_longest_string(const gint format
)
487 return get_timestamp_column_longest_string(timestamp_get_type(), timestamp_get_precision());
489 case COL_ABS_YMD_TIME
:
490 return get_timestamp_column_longest_string(TS_ABSOLUTE_WITH_YMD
, timestamp_get_precision());
492 case COL_ABS_YDOY_TIME
:
493 return get_timestamp_column_longest_string(TS_ABSOLUTE_WITH_YDOY
, timestamp_get_precision());
495 case COL_UTC_YMD_TIME
:
496 return get_timestamp_column_longest_string(TS_UTC_WITH_YMD
, timestamp_get_precision());
498 case COL_UTC_YDOY_TIME
:
499 return get_timestamp_column_longest_string(TS_UTC_WITH_YDOY
, timestamp_get_precision());
502 return get_timestamp_column_longest_string(TS_ABSOLUTE
, timestamp_get_precision());
505 return get_timestamp_column_longest_string(TS_UTC
, timestamp_get_precision());
508 return get_timestamp_column_longest_string(TS_RELATIVE
, timestamp_get_precision());
511 return get_timestamp_column_longest_string(TS_DELTA
, timestamp_get_precision());
513 case COL_DELTA_TIME_DIS
:
514 return get_timestamp_column_longest_string(TS_DELTA_DIS
, timestamp_get_precision());
516 case COL_REL_CONV_TIME
: /* 'abuse' TS_RELATIVE to set the time format */
517 case COL_DELTA_CONV_TIME
: /* for the conversation related time columns */
518 return get_timestamp_column_longest_string(TS_RELATIVE
, timestamp_get_precision());
525 case COL_UNRES_DL_SRC
:
526 case COL_DEF_NET_SRC
:
527 case COL_RES_NET_SRC
:
528 case COL_UNRES_NET_SRC
:
534 case COL_UNRES_DL_DST
:
535 case COL_DEF_NET_DST
:
536 case COL_RES_NET_DST
:
537 case COL_UNRES_NET_DST
:
538 return "00000000.000000000000"; /* IPX-style */
540 case COL_DEF_SRC_PORT
:
541 case COL_RES_SRC_PORT
:
542 case COL_UNRES_SRC_PORT
:
543 case COL_DEF_DST_PORT
:
544 case COL_RES_DST_PORT
:
545 case COL_UNRES_DST_PORT
:
549 return "Protocol"; /* not the longest, but the longest is too long */
551 case COL_PACKET_LENGTH
:
554 case COL_CUMULATIVE_BYTES
:
562 return "i 00000000 I";
580 case COL_HPUX_SUBSYS
:
581 return "OTS9000-TRANSPORT";
592 case COL_8021Q_VLAN_ID
:
614 return "9999 MHz [A 999]";
617 return "0000000000"; /* not the longest, but the longest is too long */
619 default: /* COL_INFO */
620 return "Source port: kerberos-master Destination port: kerberos-master";
625 /* Returns the longest possible width, in characters, for a particular
628 get_column_char_width(const gint format
)
630 return (gint
)strlen(get_column_longest_string(format
));
634 get_column_format(const gint col
)
636 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
639 if (!clp
) /* Invalid column requested */
642 cfmt
= (fmt_data
*) clp
->data
;
648 set_column_format(const gint col
, const gint fmt
)
650 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
653 if (!clp
) /* Invalid column requested */
656 cfmt
= (fmt_data
*) clp
->data
;
662 get_column_format_from_str(const gchar
*str
)
666 for (i
= 0; i
< NUM_COL_FMTS
; i
++) {
667 if (strcmp(str
, col_format_to_string(i
)) == 0)
670 return -1; /* illegal */
674 get_column_title(const gint col
)
676 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
679 if (!clp
) /* Invalid column requested */
682 cfmt
= (fmt_data
*) clp
->data
;
688 set_column_title(const gint col
, const gchar
*title
)
690 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
693 if (!clp
) /* Invalid column requested */
696 cfmt
= (fmt_data
*) clp
->data
;
698 g_free (cfmt
->title
);
699 cfmt
->title
= g_strdup (title
);
703 get_column_visible(const gint col
)
705 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
708 if (!clp
) /* Invalid column requested */
711 cfmt
= (fmt_data
*) clp
->data
;
713 return(cfmt
->visible
);
717 set_column_visible(const gint col
, gboolean visible
)
719 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
722 if (!clp
) /* Invalid column requested */
725 cfmt
= (fmt_data
*) clp
->data
;
727 cfmt
->visible
= visible
;
731 get_column_resolved(const gint col
)
733 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
736 if (!clp
) /* Invalid column requested */
739 cfmt
= (fmt_data
*) clp
->data
;
741 return(cfmt
->resolved
);
745 set_column_resolved(const gint col
, gboolean resolved
)
747 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
750 if (!clp
) /* Invalid column requested */
753 cfmt
= (fmt_data
*) clp
->data
;
755 cfmt
->resolved
= resolved
;
759 get_column_custom_field(const gint col
)
761 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
764 if (!clp
) /* Invalid column requested */
767 cfmt
= (fmt_data
*) clp
->data
;
769 return(cfmt
->custom_field
);
773 set_column_custom_field(const gint col
, const char *custom_field
)
775 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
778 if (!clp
) /* Invalid column requested */
781 cfmt
= (fmt_data
*) clp
->data
;
783 g_free (cfmt
->custom_field
);
784 cfmt
->custom_field
= g_strdup (custom_field
);
788 get_column_custom_occurrence(const gint col
)
790 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
793 if (!clp
) /* Invalid column requested */
796 cfmt
= (fmt_data
*) clp
->data
;
798 return(cfmt
->custom_occurrence
);
802 set_column_custom_occurrence(const gint col
, const gint custom_occurrence
)
804 GList
*clp
= g_list_nth(prefs
.col_list
, col
);
807 if (!clp
) /* Invalid column requested */
810 cfmt
= (fmt_data
*) clp
->data
;
812 cfmt
->custom_occurrence
= custom_occurrence
;
816 build_column_format_array(column_info
*cinfo
, const gint num_cols
, const gboolean reset_fences
)
820 /* Build the column format array */
821 col_setup(cinfo
, num_cols
);
823 for (i
= 0; i
< cinfo
->num_cols
; i
++) {
824 cinfo
->col_fmt
[i
] = get_column_format(i
);
825 cinfo
->col_title
[i
] = g_strdup(get_column_title(i
));
827 if (cinfo
->col_fmt
[i
] == COL_CUSTOM
) {
828 cinfo
->col_custom_field
[i
] = g_strdup(get_column_custom_field(i
));
829 cinfo
->col_custom_occurrence
[i
] = get_column_custom_occurrence(i
);
830 if(!dfilter_compile(cinfo
->col_custom_field
[i
], &cinfo
->col_custom_dfilter
[i
])) {
831 /* XXX: Should we issue a warning? */
832 g_free(cinfo
->col_custom_field
[i
]);
833 cinfo
->col_custom_field
[i
] = NULL
;
834 cinfo
->col_custom_occurrence
[i
] = 0;
835 cinfo
->col_custom_dfilter
[i
] = NULL
;
838 cinfo
->col_custom_field
[i
] = NULL
;
839 cinfo
->col_custom_occurrence
[i
] = 0;
840 cinfo
->col_custom_dfilter
[i
] = NULL
;
843 cinfo
->fmt_matx
[i
] = (gboolean
*) g_malloc0(sizeof(gboolean
) * NUM_COL_FMTS
);
844 get_column_format_matches(cinfo
->fmt_matx
[i
], cinfo
->col_fmt
[i
]);
845 cinfo
->col_data
[i
] = NULL
;
847 if (cinfo
->col_fmt
[i
] == COL_INFO
)
848 cinfo
->col_buf
[i
] = (gchar
*) g_malloc(sizeof(gchar
) * COL_MAX_INFO_LEN
);
850 cinfo
->col_buf
[i
] = (gchar
*) g_malloc(sizeof(gchar
) * COL_MAX_LEN
);
853 cinfo
->col_fence
[i
] = 0;
855 cinfo
->col_expr
.col_expr
[i
] = (gchar
*) g_malloc(sizeof(gchar
) * COL_MAX_LEN
);
856 cinfo
->col_expr
.col_expr_val
[i
] = (gchar
*) g_malloc(sizeof(gchar
) * COL_MAX_LEN
);
859 cinfo
->col_expr
.col_expr
[i
] = NULL
;
860 cinfo
->col_expr
.col_expr_val
[i
] = NULL
;
862 for (i
= 0; i
< cinfo
->num_cols
; i
++) {
865 for (j
= 0; j
< NUM_COL_FMTS
; j
++) {
866 if (!cinfo
->fmt_matx
[i
][j
])
869 if (cinfo
->col_first
[j
] == -1)
870 cinfo
->col_first
[j
] = i
;
872 cinfo
->col_last
[j
] = i
;
878 * Editor modelines - http://www.wireshark.org/tools/modelines.html
883 * indent-tabs-mode: nil
886 * vi: set shiftwidth=2 tabstop=2 expandtab:
887 * :indentSize=2:tabSize=2:noTabs=true: