As pointed by Evan: don't leak memory when the string pointer is NULL.
[metze/wireshark/wip.git] / epan / column.h
1 /* column.h
2  * Definitions for column handling routines
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifndef __COLUMN_H__
26 #define __COLUMN_H__
27
28 #include "ws_symbol_export.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 typedef struct _fmt_data {
35   gchar *title;            /* title of the column */
36   int fmt;                 /* format of column */
37   gchar *custom_field;     /* field name for COL_CUSTOM */
38   gint custom_occurrence;  /* optional ordinal of occurrence of that field */
39   gboolean visible;        /* if FALSE, hide this column */
40   gboolean resolved;       /* if TRUE, show a more human-readable name */
41 } fmt_data;
42
43 WS_DLL_PUBLIC
44 const gchar         *col_format_to_string(const gint);
45 WS_DLL_PUBLIC
46 const gchar         *col_format_desc(const gint);
47 WS_DLL_PUBLIC
48 gint                 get_column_format(const gint);
49 WS_DLL_PUBLIC
50 void                 set_column_format(const gint, const gint);
51 WS_DLL_PUBLIC
52 void                 get_column_format_matches(gboolean *, const gint);
53 WS_DLL_PUBLIC
54 gint                 get_column_format_from_str(const gchar *);
55 WS_DLL_PUBLIC
56 gchar               *get_column_title(const gint);
57 WS_DLL_PUBLIC
58 void                 set_column_title(const gint, const gchar *);
59 WS_DLL_PUBLIC
60 gboolean             get_column_visible(const gint);
61 WS_DLL_PUBLIC
62 void                 set_column_visible(const gint, gboolean);
63 WS_DLL_PUBLIC
64 gboolean             get_column_resolved(const gint);
65 WS_DLL_PUBLIC
66 void                 set_column_resolved(const gint, gboolean);
67 WS_DLL_PUBLIC
68 const gchar         *get_column_custom_field(const gint);
69 WS_DLL_PUBLIC
70 void                 set_column_custom_field(const gint, const char *);
71 WS_DLL_PUBLIC
72 gint                 get_column_custom_occurrence(const gint);
73 WS_DLL_PUBLIC
74 void                 set_column_custom_occurrence(const gint, const gint);
75 WS_DLL_PUBLIC
76 const gchar         *get_column_width_string(const gint, const gint);
77 WS_DLL_PUBLIC
78 const char          *get_column_longest_string(const gint);
79 WS_DLL_PUBLIC
80 gint                 get_column_char_width(const gint format);
81
82 WS_DLL_PUBLIC
83 void
84 build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences);
85
86 WS_DLL_PUBLIC
87 void                 column_dump_column_formats(void);
88
89 #ifdef __cplusplus
90 }
91 #endif /* __cplusplus */
92
93 #endif /* column.h */