Added an option to uat_new() to set if configuration shall be saved in the
[obnox/wireshark/wip.git] / epan / uat-int.h
1 /*
2  *  uat-int.h
3  *
4  *  $Id$
5  *
6  *  User Accessible Tables
7  *  Mantain an array of user accessible data strucures
8  *  Internal interface
9  *
10  * (c) 2007, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
11  *
12  * Wireshark - Network traffic analyzer
13  * By Gerald Combs <gerald@wireshark.org>
14  * Copyright 2001 Gerald Combs
15  * 
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * 
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29  *
30  */
31 #ifndef _UAT_INT_H_
32 #define _UAT_INT_H_
33
34 #include "uat.h"
35
36 typedef struct _uat_fld_rep_t uat_fld_rep_t;
37 typedef struct _uat_rep_t uat_rep_t;
38
39 typedef void (*uat_rep_fld_free_cb_t)(uat_fld_rep_t*);
40 typedef void (*uat_rep_free_cb_t)(uat_rep_t*);
41
42 typedef struct _fld_data_t {
43         guint colnum;
44         uat_fld_rep_t* rep;
45         uat_rep_fld_free_cb_t free_rep;
46 } fld_data_t;
47
48 struct _uat_t {
49         const char* name;       
50         size_t record_size;
51         const char* filename;
52         gboolean from_profile;
53         const char* help;
54         const char* category;
55         void** user_ptr;
56         guint* nrows_p;
57         uat_copy_cb_t copy_cb;
58         uat_update_cb_t update_cb;
59         uat_free_cb_t free_cb;
60
61         uat_field_t* fields;
62         guint ncols;
63         GArray* user_data;
64         gboolean changed;
65         uat_rep_t* rep;
66         uat_rep_free_cb_t free_rep;
67         gboolean loaded;
68 };
69
70 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
71
72 void uat_init(void);
73
74 void uat_reset(void);
75
76 void* uat_add_record(uat_t*, const void* orig_rec_ptr);
77
78 void uat_swap(uat_t*, guint idx_a, guint idx_b);
79
80 void uat_remove_record_idx(uat_t*, guint rec_idx);
81
82 void uat_destroy(uat_t*);
83
84 void uat_clear(uat_t*);
85
86 gboolean uat_save(uat_t* , char** );
87
88 void uat_load_all(void);
89
90 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
91 #define UAT_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
92 #endif