Debian Codegraph @

src/bnetd/attrgroup.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2004 Dizzy
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #ifndef __ATTRGROUP_H_INCLUDED__
20 #define __ATTRGROUP_H_INCLUDED__
21
22 #include <ctime>
23 #include "common/elist.h"
24
25 #ifndef JUST_NEED_TYPES
26 #define JUST_NEED_TYPES
27 #include "storage.h"
28 #include <vector>
29 #undef JUST_NEED_TYPES
30 #else
31 #include "storage.h"
32 #endif
33
34 #define ATTRGROUP_FLAG_NONE 0
35 #define ATTRGROUP_FLAG_LOADED 1
36 #define ATTRGROUP_FLAG_ACCESSED 2
37 #define ATTRGROUP_FLAG_DIRTY 4
38
39 namespace pvpgn
40 {
41
42 namespace bnetd
43 {
44
45 /* attrgroup represents a group of attributes which are read/saved/flush together
46 * ex: each account stores it's data into a attrgroup */
47 typedef struct attrgroup_struct
48 #ifdef ATTRGROUP_INTERNAL_ACCESS
49 {
50 t_hlist list;
51 t_storage_info *storage;
52 int flags;
53 std::time_t lastaccess;
54 std::time_t dirtytime;
55 t_elist loadedlist;
56 t_elist dirtylist;
57 #ifdef WITH_SQL
58 std::vector<const char*> *loadedtabs; /* sql table names that were loaded */
59 #endif
60 }
61 #endif
62 t_attrgroup;
63
64 typedef int(*t_attr_cb)(t_attrgroup *, void *);
65
66 extern t_attrgroup *attrgroup_create_storage(t_storage_info *storage);
67 extern t_attrgroup *attrgroup_create_newuser(const char *name);
68 extern t_attrgroup *attrgroup_create_nameuid(const char *name, unsigned uid);
69 extern int attrgroup_destroy(t_attrgroup *attrgroup);
70 extern int attrgroup_load(t_attrgroup *attrgroup, const char *tab);
71 extern int attrgroup_unload(t_attrgroup *attrgroup);
72 extern int attrgroup_read_accounts(int flag, t_attr_cb cb, void *data);
73 extern const char *attrgroup_get_attr(t_attrgroup *attrgroup, const char *key);
74 extern int attrgroup_set_attr(t_attrgroup *attrgroup, const char *key, const char *val, bool set_dirty = true);
75 extern int attrgroup_save(t_attrgroup *attrgroup, int flags);
76 extern int attrgroup_flush(t_attrgroup *attrgroup, int flags);
77
78 }
79
80 }
81
82 #endif /* __ATTRGROUP_H_INCLUDED__ */