svn:ignore uat_load.c
[metze/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 _uat_fld_t {
43         char* name;
44         uat_text_mode_t mode;
45         uat_fld_chk_cb_t chk_cb;
46         uat_fld_set_cb_t set_cb;
47         uat_fld_tostr_cb_t tostr_cb;
48         
49         guint colnum;
50         uat_fld_rep_t* rep;
51         uat_rep_fld_free_cb_t free_rep;
52         
53         struct _uat_fld_t* next;
54 } uat_fld_t;
55
56 struct _uat_t {
57         char* name;     
58         size_t record_size;
59         char* filename;
60         void** user_ptr;
61         guint* nrows_p;
62         uat_copy_cb_t copy_cb;
63         uat_update_cb_t update_cb;
64         uat_free_cb_t free_cb;
65
66         uat_fld_t* fields;
67         guint ncols;
68         GArray* user_data;
69         gboolean finalized;
70         
71         uat_rep_t* rep;
72         uat_rep_free_cb_t free_rep;
73 };
74
75 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
76 void uat_init(void);
77 void uat_reset(void);
78 void* uat_add_record(uat_t*, const void* orig_rec_ptr);
79 void uat_remove_record_idx(uat_t*, guint rec_idx);
80 void uat_destroy(uat_t*);
81 gboolean uat_save(uat_t* dt, char** error);
82 gboolean uat_load(uat_t* dt, char** error);
83
84 #define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
85
86 #endif