summaryrefslogtreecommitdiff
path: root/dbmodule.h
blob: e3f8aa1245c3460474ccfe00c7872e045aa4e2fa (plain)
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
/* Dynamic loading of the database backend.
 * We use GLib's multiplatform dl() wrapper
 * to open up db_mysql.so, db_pgsql.so or db_sqlite.so
 * and populate the global 'db' structure.
 *
 * (c) 2005 Aaron Stone <aaron@serendipity.cx>
 */

#ifndef DBMODULE_H
#define DBMODULE_H

/* Prototypes must match with those in db.h
 * and in the database drivers. */
typedef struct {
	int (* connect)(void);
	int (* disconnect)(void);
	int (* check_connection)(void);
	int (* query)(const char *the_query);
	u64_t (* insert_result)(const char *sequence_identifier);
	unsigned (* num_rows)(void);
	unsigned (* num_fields)(void);
	const char * (* get_result)(unsigned row, unsigned field);
	void (* free_result)(void);
	unsigned long (* escape_string)(char *to,
	                    const char *from, unsigned long length );
	unsigned long (* escape_binary)(char *to,
	       	       const char *from, unsigned long length );
	int (* do_cleanup)(const char **tables, int num_tables);
	u64_t (* get_length)(unsigned row, unsigned field);
	u64_t (* get_affected_rows)(void);
	void (* use_msgbuf_result)(void);
	void (* store_msgbuf_result)(void);
	void (* set_result_set)(void *res);
	const char * (* get_sql)(sql_fragment_t frag);
} db_func_t;

#endif