gpg: Change sqlite3_stepx to pass the sqlite3_stmt * to the callback.
[gnupg.git] / g10 / sqlite.h
1 /* sqlite.h - SQLite helper functions.
2  * Copyright (C) 2015 g10 Code GmbH
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GnuPG is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef GNUPG_SQLITE_H
21 #define GNUPG_SQLITE_H
22
23 #include <sqlite3.h>
24
25 enum sqlite_arg_type
26   {
27     SQLITE_ARG_END = 0xdead001,
28     SQLITE_ARG_INT,
29     SQLITE_ARG_LONG_LONG,
30     SQLITE_ARG_STRING,
31     /* This takes two arguments: the blob as a void * and the length
32        of the blob as a long long.  */
33     SQLITE_ARG_BLOB
34   };
35
36
37 int sqlite3_exec_printf (sqlite3 *db,
38                          int (*callback)(void*,int,char**,char**), void *cookie,
39                          char **errmsg,
40                          const char *sql, ...);
41
42 typedef int (*sqlite3_stepx_callback) (void *cookie,
43                                        /* number of columns.  */
44                                        int cols,
45                                        /* columns as text.  */
46                                        char **values,
47                                        /* column names.  */
48                                        char **names,
49                                        /* The prepared statement so
50                                           that it is possible to use
51                                           something like
52                                           sqlite3_column_blob().  */
53                                        sqlite3_stmt *statement);
54
55 int sqlite3_stepx (sqlite3 *db,
56                    sqlite3_stmt **stmtp,
57                    sqlite3_stepx_callback callback,
58                    void *cookie,
59                    char **errmsg,
60                    const char *sql, ...);
61
62 #endif