1 /* gpgsql.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 <https://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef GNUPG_GPGSQL_H 21 #define GNUPG_GPGSQL_H 22 23 #include <sqlite3.h> 24 25 enum gpgsql_arg_type 26 { 27 GPGSQL_ARG_END = 0xdead001, 28 GPGSQL_ARG_INT, 29 GPGSQL_ARG_LONG_LONG, 30 GPGSQL_ARG_STRING, 31 /* This takes two arguments: the blob as a void * and the length 32 of the blob as a long long. */ 33 GPGSQL_ARG_BLOB 34 }; 35 36 int gpgsql_exec_printf (sqlite3 *db, 37 int (*callback)(void*,int,char**,char**), void *cookie, 38 char **errmsg, 39 const char *sql, ...); 40 41 typedef int (*gpgsql_stepx_callback) (void *cookie, 42 /* number of columns. */ 43 int cols, 44 /* columns as text. */ 45 char **values, 46 /* column names. */ 47 char **names, 48 /* The prepared statement so 49 * that it is possible to use 50 * something like 51 * sqlite3_column_blob(). */ 52 sqlite3_stmt *statement); 53 54 int gpgsql_stepx (sqlite3 *db, 55 sqlite3_stmt **stmtp, 56 gpgsql_stepx_callback callback, 57 void *cookie, 58 char **errmsg, 59 const char *sql, ...); 60 61 #endif /*GNUPG_GPGSQL_H*/ 62