Continue to remove $Id$ from top of file
[metze/wireshark/wip.git] / epan / uat-int.h
1 /*
2  *  uat-int.h
3  *
4  *  User Accessible Tables
5  *  Mantain an array of user accessible data strucures
6  *  Internal interface
7  *
8  * (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 2001 Gerald Combs
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27  *
28  */
29 #ifndef __UAT_INT_H__
30 #define __UAT_INT_H__
31
32 #include "uat.h"
33 #include "ws_symbol_export.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 typedef struct _uat_fld_rep_t uat_fld_rep_t;
40 typedef struct _uat_rep_t uat_rep_t;
41
42 typedef void (*uat_rep_fld_free_cb_t)(uat_fld_rep_t*);
43 typedef void (*uat_rep_free_cb_t)(uat_rep_t*);
44
45 typedef struct _fld_data_t {
46     guint colnum;
47     uat_fld_rep_t* rep;
48     uat_rep_fld_free_cb_t free_rep;
49 } fld_data_t;
50
51 struct epan_uat {
52     const char* name;
53     size_t record_size;
54     const char* filename;
55     gboolean from_profile;
56     const char* help;
57     guint flags;
58     void** user_ptr;
59     guint* nrows_p;
60     uat_copy_cb_t copy_cb;
61     uat_update_cb_t update_cb;
62     uat_free_cb_t free_cb;
63     uat_post_update_cb_t post_update_cb;
64
65     uat_field_t* fields;
66     guint ncols;
67     GArray* user_data;
68     GArray* raw_data;
69     GArray* valid_data;
70     gboolean changed;
71     uat_rep_t* rep;
72     uat_rep_free_cb_t free_rep;
73     gboolean loaded;
74     gboolean from_global;
75 };
76
77 WS_DLL_PUBLIC
78 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
79
80 void uat_init(void);
81
82 void uat_reset(void);
83
84 WS_DLL_PUBLIC
85 void* uat_add_record(uat_t*, const void* orig_rec_ptr, gboolean valid_rec);
86
87 WS_DLL_PUBLIC
88 void uat_swap(uat_t*, guint idx_a, guint idx_b);
89
90 WS_DLL_PUBLIC
91 void uat_remove_record_idx(uat_t*, guint rec_idx);
92
93 void uat_destroy(uat_t*);
94
95 WS_DLL_PUBLIC
96 void uat_clear(uat_t*);
97
98 WS_DLL_PUBLIC
99 gboolean uat_save(uat_t* , const char** );
100
101 void uat_load_all(void);
102
103 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
104 #define UAT_INDEX_PTR(uat,idx) (uat->raw_data->data + (uat->record_size * (idx)))
105 #define UAT_USER_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
106
107 #ifdef __cplusplus
108 }
109 #endif /* __cplusplus */
110
111 #endif /* __UAT_INT_H__ */
112
113 /*
114  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
115  *
116  * Local variables:
117  * c-basic-offset: 4
118  * tab-width: 8
119  * indent-tabs-mode: nil
120  * End:
121  *
122  * vi: set shiftwidth=4 tabstop=8 expandtab:
123  * :indentSize=4:tabSize=8:noTabs=true:
124  */