File: dbprovider.h

package info (click to toggle)
gnubg 1.06.002-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,608 kB
  • sloc: ansic: 97,578; xml: 15,136; sh: 4,919; yacc: 700; makefile: 582; python: 573; lex: 297; sql: 238; awk: 26
file content (87 lines) | stat: -rw-r--r-- 2,751 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 3 or later of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: dbprovider.h,v 1.19 2018/07/31 20:15:11 plm Exp $
 */

#ifndef DBPROVIDER_H
#define DBPROVIDER_H

#include <stdio.h>
#include <glib.h>
extern int storeGameStats;

typedef struct _RowSet {
    size_t cols, rows;
    char ***data;
    size_t *widths;
} RowSet;

typedef struct _DBProvider {
    int (*Connect) (const char *database, const char *user, const char *password, const char *hostname);
    void (*Disconnect) (void);
    RowSet *(*Select) (const char *str);
    int (*UpdateCommand) (const char *str);
    void (*Commit) (void);
    GList *(*GetDatabaseList) (const char *user, const char *password, const char *hostname);
    int (*DeleteDatabase) (const char *database, const char *user, const char *password, const char *hostname);

    const char *name;
    const char *shortname;
    const char *desc;
    int HasUserDetails;
    int storeGameStats;
    const char *database;
    const char *username;
    const char *password;
    const char *hostname;
} DBProvider;

typedef enum _DBProviderType {
    INVALID_PROVIDER = -1,
#if defined(USE_SQLITE)
    SQLITE,
#endif
#if defined(USE_PYTHON)
#if !defined(USE_SQLITE)
    PYTHON_SQLITE,
#endif
    PYTHON_MYSQL,
    PYTHON_POSTGRES
#endif
} DBProviderType;

#if defined(USE_PYTHON)
#define NUM_PROVIDERS 3
#elif defined(USE_SQLITE)
#define NUM_PROVIDERS 1
#else
#define NUM_PROVIDERS 0
#endif

extern DBProviderType dbProviderType;
extern DBProvider *GetDBProvider(DBProviderType dbType);
extern const char *TestDB(DBProviderType dbType);
DBProvider *ConnectToDB(DBProviderType dbType);
void SetDBType(const char *type);
void SetDBSettings(DBProviderType dbType, const char *database, const char *user, const char *password,
                   const char *hostname);
void RelationalSaveSettings(FILE * pf);
void SetDBParam(const char *db, const char *key, const char *value);
extern int CreateDatabase(DBProvider * pdb);
const char *GetProviderName(int i);
extern RowSet *RunQuery(const char *sz);
extern int RunQueryValue(const DBProvider * pdb, const char *query);
extern void FreeRowset(RowSet * pRow);
#endif