Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / uat-int.h
blob56e717f31e6f734e13c860d59c408b32650d8884
1 /** @file
3 * User Accessible Tables
4 * Maintain an array of user accessible data structures
5 * Internal interface
7 * (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 2001 Gerald Combs
13 * SPDX-License-Identifier: GPL-2.0-or-later
16 #ifndef __UAT_INT_H__
17 #define __UAT_INT_H__
19 #include <glib.h>
21 #include "uat.h"
22 #include "ws_symbol_export.h"
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
28 typedef struct _uat_fld_rep_t uat_fld_rep_t;
29 typedef struct _uat_rep_t uat_rep_t;
31 typedef void (*uat_rep_fld_free_cb_t)(uat_fld_rep_t*);
32 typedef void (*uat_rep_free_cb_t)(uat_rep_t*);
34 typedef struct _fld_data_t {
35 unsigned colnum;
36 uat_fld_rep_t* rep;
37 uat_rep_fld_free_cb_t free_rep;
38 } fld_data_t;
40 struct epan_uat {
41 char* name;
42 size_t record_size;
43 char* filename;
44 bool from_profile;
45 char* help;
46 unsigned flags;
47 void** user_ptr; /**< Pointer to a dissector variable where an array of valid records are stored. */
48 unsigned* nrows_p; /**< Pointer to a dissector variable where the number of valid records in user_ptr are written. */
49 uat_copy_cb_t copy_cb;
50 uat_update_cb_t update_cb;
51 uat_free_cb_t free_cb;
52 uat_post_update_cb_t post_update_cb;
53 uat_reset_cb_t reset_cb;
55 uat_field_t* fields;
56 const char** default_values;
57 unsigned ncols;
58 GArray* user_data; /**< An array of valid records that will be exposed to the dissector. */
59 GArray* raw_data; /**< An array of records containing possibly invalid data. For internal use only. */
60 GArray* valid_data; /**< An array of booleans describing whether the records in 'raw_data' are valid or not. */
61 bool changed;
62 uat_rep_t* rep;
63 uat_rep_free_cb_t free_rep;
64 bool loaded;
67 WS_DLL_PUBLIC
68 char* uat_get_actual_filename(uat_t* uat, bool for_writing);
70 /**
71 * Clones the given record and stores it internally in the UAT. If it is
72 * considered a valid record, then it will also be cloned and stored in the
73 * externally visible list.
75 WS_DLL_PUBLIC
76 void* uat_add_record(uat_t *uat, const void *orig_rec_ptr, bool valid_rec);
78 /**
79 * Marks the internal record in the UAT as valid or invalid. The record must
80 * exist in the UAT.
82 WS_DLL_PUBLIC
83 void uat_update_record(uat_t *uat, const void *record, bool valid_rec);
85 /**
86 * Changes the order of two internal UAT records.
88 WS_DLL_PUBLIC
89 void uat_swap(uat_t *uat, unsigned idx_a, unsigned idx_b);
91 /**
92 * Inserts the record at the given index in the internal record list.
94 WS_DLL_PUBLIC
95 void uat_insert_record_idx(uat_t *uat, unsigned rec_idx, const void *src_record);
97 /**
98 * Removes the record with the given index from the internal record list.
99 * If the UAT has a free_cb it is called for the removed record.
101 WS_DLL_PUBLIC
102 void uat_remove_record_idx(uat_t *uat, unsigned rec_idx);
105 * Removes the given number of records starting with the given index from
106 * the internal record list. If the UAT has a free_cb it is called for
107 * the removed records.
109 WS_DLL_PUBLIC
110 void uat_remove_record_range(uat_t *uat, unsigned rec_idx, unsigned count);
113 * Moves the entry from the old position to the new one
115 WS_DLL_PUBLIC
116 void uat_move_index(uat_t *uat, unsigned old_idx, unsigned new_idx);
119 * Removes and destroys all records from the UAT.
121 WS_DLL_PUBLIC
122 void uat_clear(uat_t *uat);
125 * Saves the records from an UAT to file.
126 * Returns true on success and false on failure, storing the reason in 'error'
127 * (which must be freed using g_free).
129 WS_DLL_PUBLIC
130 bool uat_save(uat_t *uat, char **error);
133 * Loads the records for all registered UATs from file.
135 void uat_load_all(void);
138 * Dump given UAT record to string in form which can be later loaded with uat_load_str().
139 * XXX - In fact this only dumps a single field. To produce the format for
140 * uat_load_str(), join all the fields as CSV records, escaping and double-
141 * quoting field types other than PT_TXTMOD_HEXBYTES. Perhaps we should have
142 * a function that dumps the entire record.
144 WS_DLL_PUBLIC
145 char *uat_fld_tostr(void *rec, uat_field_t *f);
148 * Exposes the array of valid records to the UAT consumer (dissectors), updating
149 * the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
151 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
153 * Get a record from the array of all UAT entries, whether they are semantically
154 * valid or not. This memory must only be used internally in the UAT core and
155 * must not be exposed to dissectors.
157 #define UAT_INDEX_PTR(uat,idx) (uat->raw_data->data + (uat->record_size * (idx)))
159 * Get a record from the array of all valid entries. These records will be
160 * shared with UAT consumers (dissectors).
162 #define UAT_USER_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
164 #ifdef __cplusplus
166 #endif /* __cplusplus */
168 #endif /* __UAT_INT_H__ */
171 * Editor modelines - https://www.wireshark.org/tools/modelines.html
173 * Local variables:
174 * c-basic-offset: 4
175 * tab-width: 8
176 * indent-tabs-mode: nil
177 * End:
179 * vi: set shiftwidth=4 tabstop=8 expandtab:
180 * :indentSize=4:tabSize=8:noTabs=true: