4 * User Accessible Tables
5 * Maintain an array of user accessible data structures
8 * (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 2001 Gerald Combs
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.
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.
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.
33 #include "ws_symbol_export.h"
37 #endif /* __cplusplus */
39 typedef struct _uat_fld_rep_t uat_fld_rep_t;
40 typedef struct _uat_rep_t uat_rep_t;
42 typedef void (*uat_rep_fld_free_cb_t)(uat_fld_rep_t*);
43 typedef void (*uat_rep_free_cb_t)(uat_rep_t*);
45 typedef struct _fld_data_t {
48 uat_rep_fld_free_cb_t free_rep;
55 gboolean from_profile;
58 void** user_ptr; /**< Pointer to a dissector variable where an array of valid records are stored. */
59 guint* nrows_p; /**< Pointer to a dissector variable where the number of valid records in user_ptr are written. */
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;
67 GArray* user_data; /**< An array of valid records that will be exposed to the dissector. */
68 GArray* raw_data; /**< An array of records containing possibly invalid data. For internal use only. */
69 GArray* valid_data; /**< An array of booleans describing whether the records in 'raw_data' are valid or not. */
72 uat_rep_free_cb_t free_rep;
78 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
85 * Clones the given record and stores it internally in the UAT. If it is
86 * considered a valid record, then it will also be cloned and stored in the
87 * externally visible list.
90 void* uat_add_record(uat_t *uat, const void *orig_rec_ptr, gboolean valid_rec);
93 * Marks the internal record in the UAT as valid or invalid. The record must
97 void uat_update_record(uat_t *uat, const void *record, gboolean valid_rec);
100 * Changes the order of two internal UAT records.
103 void uat_swap(uat_t *uat, guint idx_a, guint idx_b);
106 * Removes the record with the given index from the internal record list.
109 void uat_remove_record_idx(uat_t *uat, guint rec_idx);
111 void uat_destroy(uat_t *uat);
114 * Removes and destroys all records from the UAT.
117 void uat_clear(uat_t *uat);
120 * Saves the records from an UAT to file.
121 * Returns TRUE on success and FALSE on failure, storing the reason in 'error'
122 * (which must be freed using g_free).
125 gboolean uat_save(uat_t *uat, char **error);
128 * Loads the records for all registered UATs from file.
130 void uat_load_all(void);
133 * Exposes the array of valid records to the UAT consumer (dissectors), updating
134 * the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
136 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
138 * Get a record from the array of all UAT entries, whether they are semantically
139 * valid or not. This memory must only be used internally in the UAT core and
140 * must not be exposed to dissectors.
142 #define UAT_INDEX_PTR(uat,idx) (uat->raw_data->data + (uat->record_size * (idx)))
144 * Get a record from the array of all valid entries. These records will be
145 * shared with UAT consumers (dissectors).
147 #define UAT_USER_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
151 #endif /* __cplusplus */
153 #endif /* __UAT_INT_H__ */
156 * Editor modelines - http://www.wireshark.org/tools/modelines.html
161 * indent-tabs-mode: nil
164 * vi: set shiftwidth=4 tabstop=8 expandtab:
165 * :indentSize=4:tabSize=8:noTabs=true: