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 * SPDX-License-Identifier: GPL-2.0-or-later
21 #include "ws_symbol_export.h"
25 #endif /* __cplusplus */
27 typedef struct _uat_fld_rep_t uat_fld_rep_t;
28 typedef struct _uat_rep_t uat_rep_t;
30 typedef void (*uat_rep_fld_free_cb_t)(uat_fld_rep_t*);
31 typedef void (*uat_rep_free_cb_t)(uat_rep_t*);
33 typedef struct _fld_data_t {
36 uat_rep_fld_free_cb_t free_rep;
43 gboolean from_profile;
46 void** user_ptr; /**< Pointer to a dissector variable where an array of valid records are stored. */
47 guint* nrows_p; /**< Pointer to a dissector variable where the number of valid records in user_ptr are written. */
48 uat_copy_cb_t copy_cb;
49 uat_update_cb_t update_cb;
50 uat_free_cb_t free_cb;
51 uat_post_update_cb_t post_update_cb;
52 uat_reset_cb_t reset_cb;
56 GArray* user_data; /**< An array of valid records that will be exposed to the dissector. */
57 GArray* raw_data; /**< An array of records containing possibly invalid data. For internal use only. */
58 GArray* valid_data; /**< An array of booleans describing whether the records in 'raw_data' are valid or not. */
61 uat_rep_free_cb_t free_rep;
67 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
70 * Clones the given record and stores it internally in the UAT. If it is
71 * considered a valid record, then it will also be cloned and stored in the
72 * externally visible list.
75 void* uat_add_record(uat_t *uat, const void *orig_rec_ptr, gboolean valid_rec);
78 * Marks the internal record in the UAT as valid or invalid. The record must
82 void uat_update_record(uat_t *uat, const void *record, gboolean valid_rec);
85 * Changes the order of two internal UAT records.
88 void uat_swap(uat_t *uat, guint idx_a, guint idx_b);
91 * Inserts the record at the given index in the internal record list.
94 void uat_insert_record_idx(uat_t *uat, guint rec_idx, const void *src_record);
97 * Removes the record with the given index from the internal record list.
100 void uat_remove_record_idx(uat_t *uat, guint rec_idx);
103 * Moves the entry from the old position to the new one
106 void uat_move_index(uat_t *uat, guint old_idx, guint new_idx);
109 * Removes and destroys all records from the UAT.
112 void uat_clear(uat_t *uat);
115 * Saves the records from an UAT to file.
116 * Returns TRUE on success and FALSE on failure, storing the reason in 'error'
117 * (which must be freed using g_free).
120 gboolean uat_save(uat_t *uat, char **error);
123 * Loads the records for all registered UATs from file.
125 void uat_load_all(void);
128 * Dump given UAT record to string in form, which can be later loaded with uat_load_str().
131 char *uat_fld_tostr(void *rec, uat_field_t *f);
134 * Exposes the array of valid records to the UAT consumer (dissectors), updating
135 * the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
137 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
139 * Get a record from the array of all UAT entries, whether they are semantically
140 * valid or not. This memory must only be used internally in the UAT core and
141 * must not be exposed to dissectors.
143 #define UAT_INDEX_PTR(uat,idx) (uat->raw_data->data + (uat->record_size * (idx)))
145 * Get a record from the array of all valid entries. These records will be
146 * shared with UAT consumers (dissectors).
148 #define UAT_USER_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
152 #endif /* __cplusplus */
154 #endif /* __UAT_INT_H__ */
157 * Editor modelines - http://www.wireshark.org/tools/modelines.html
162 * indent-tabs-mode: nil
165 * vi: set shiftwidth=4 tabstop=8 expandtab:
166 * :indentSize=4:tabSize=8:noTabs=true: