Debian Codegraph @

src/bnetd/sql_common.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002,2003,2005 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 INCLUDED_SQL_COMMON_TYPES
20 #define INCLUDED_SQL_COMMON_TYPES
21
22 namespace pvpgn
23 {
24
25 namespace bnetd
26 {
27
28 typedef unsigned int t_sql_info;
29
30 /* used as a pointer to it */
31 #define t_sql_res void
32
33 typedef char * t_sql_row;
34
35 typedef char * t_sql_field;
36
37 typedef struct {
38 int(*init)(const char *host, const char *port, const char *socket, const char *name, const char *user, const char *pass);
39 int(*close)(void);
40 t_sql_res * (*query_res)(const char *);
41 int(*query)(const char *);
42 t_sql_row * (*fetch_row)(t_sql_res *);
43 void(*free_result)(t_sql_res *);
44 unsigned int(*num_rows)(t_sql_res *);
45 unsigned int(*num_fields)(t_sql_res *);
46 unsigned int(*affected_rows)(void);
47 t_sql_field * (*fetch_fields)(t_sql_res *);
48 int(*free_fields)(t_sql_field *);
49 void(*escape_string)(char *, const char *, int);
50 } t_sql_engine;
51
52 }
53
54 }
55
56 #endif /* INCLUDED_SQL_COMMON_TYPES */
57
58 #ifndef JUST_NEED_TYPES
59 #ifndef INCLUDED_SQL_COMMON_PROTOS
60 #define INCLUDED_SQL_COMMON_PROTOS
61
62 #include "storage.h"
63
64 namespace pvpgn
65 {
66
67 namespace bnetd
68 {
69
70 extern t_storage storage_sql;
71
72 #ifdef SQL_INTERNAL
73
74 #define CURRENT_DB_VERSION 150
75
76 #define DB_MAX_ATTRKEY 128
77 #define DB_MAX_ATTRVAL 180
78 #define DB_MAX_TAB 64
79
80 #define SQL_UID_FIELD "uid"
81 #define STORAGE_SQL_DEFAULT_UID 0
82 #define SQL_DEFAULT_PREFIX ""
83
84 /* FIXME: (HarpyWar) do not define SQL_ON_DEMAND - instead it will cause a lot of sql queries (one attribute selection = one query)
85 https://github.com/pvpgn/pvpgn-server/issues/85 */
86 //#define SQL_ON_DEMAND 1
87
88 extern t_sql_engine *sql;
89 extern unsigned int sql_defacct;
90 extern const char* tab_prefix;
91
92 #ifndef SQL_ON_DEMAND
93 extern char const *sql_tables[];
94 #endif /* SQL_ON_DEMAND */
95
96 extern int sql_init(const char *);
97 extern int sql_close(void);
98 extern unsigned sql_read_maxuserid(void);
99 extern int sql_read_accounts(int flag, t_read_accounts_func cb, void *data);
100 extern int sql_cmp_info(t_storage_info * info1, t_storage_info * info2);
101 extern int sql_free_info(t_storage_info * info);
102 extern t_storage_info *sql_get_defacct(void);
103 extern int sql_load_clans(t_load_clans_func cb);
104 extern int sql_write_clan(void *data);
105 extern int sql_remove_clan(int clantag);
106 extern int sql_remove_clanmember(int uid);
107 extern int sql_load_teams(t_load_teams_func cb);
108 extern int sql_write_team(void *data);
109 extern int sql_remove_team(unsigned int teamid);
110
111 #endif /* SQL_INTERNAL */
112
113 }
114
115 }
116
117 #endif /* INCLUDED_SQL_COMMON_PROTOS */
118 #endif /* JUST_NEED_TYPES */