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;
64 uat_reset_cb_t reset_cb;
68 GArray* user_data; /**< An array of valid records that will be exposed to the dissector. */
69 GArray* raw_data; /**< An array of records containing possibly invalid data. For internal use only. */
70 GArray* valid_data; /**< An array of booleans describing whether the records in 'raw_data' are valid or not. */
73 uat_rep_free_cb_t free_rep;
79 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
82 * Clones the given record and stores it internally in the UAT. If it is
83 * considered a valid record, then it will also be cloned and stored in the
84 * externally visible list.
87 void* uat_add_record(uat_t *uat, const void *orig_rec_ptr, gboolean valid_rec);
90 * Marks the internal record in the UAT as valid or invalid. The record must
94 void uat_update_record(uat_t *uat, const void *record, gboolean valid_rec);
97 * Changes the order of two internal UAT records.
100 void uat_swap(uat_t *uat, guint idx_a, guint idx_b);
103 * Inserts the record at the given index in the internal record list.
106 void uat_insert_record_idx(uat_t *uat, guint rec_idx, const void *src_record);
109 * Removes the record with the given index from the internal record list.
112 void uat_remove_record_idx(uat_t *uat, guint rec_idx);
115 * Removes and destroys all records from the UAT.
118 void uat_clear(uat_t *uat);
121 * Saves the records from an UAT to file.
122 * Returns TRUE on success and FALSE on failure, storing the reason in 'error'
123 * (which must be freed using g_free).
126 gboolean uat_save(uat_t *uat, char **error);
129 * Loads the records for all registered UATs from file.
131 void uat_load_all(void);
134 * Dump given UAT record to string in form, which can be later loaded with uat_load_str().
137 char *uat_fld_tostr(void *rec, uat_field_t *f);
140 * Exposes the array of valid records to the UAT consumer (dissectors), updating
141 * the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
143 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
145 * Get a record from the array of all UAT entries, whether they are semantically
146 * valid or not. This memory must only be used internally in the UAT core and
147 * must not be exposed to dissectors.
149 #define UAT_INDEX_PTR(uat,idx) (uat->raw_data->data + (uat->record_size * (idx)))
151 * Get a record from the array of all valid entries. These records will be
152 * shared with UAT consumers (dissectors).
154 #define UAT_USER_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
158 #endif /* __cplusplus */
160 #endif /* __UAT_INT_H__ */
163 * Editor modelines - http://www.wireshark.org/tools/modelines.html
168 * indent-tabs-mode: nil
171 * vi: set shiftwidth=4 tabstop=8 expandtab:
172 * :indentSize=4:tabSize=8:noTabs=true: