00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __C_CREATEREPOLIB_SQLITE_H__
00021 #define __C_CREATEREPOLIB_SQLITE_H__
00022
00023 #include <glib.h>
00024 #include <sqlite3.h>
00025 #include "package.h"
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00034 #define CR_SQLITE_CACHE_DBVERSION 10
00036 #define CR_DB_ERROR cr_db_error_quark()
00037 GQuark cr_db_error_quark (void);
00038
00039 typedef struct _DbPrimaryStatements * cr_DbPrimaryStatements;
00040 typedef struct _DbFilelistsStatements * cr_DbFilelistsStatements;
00041 typedef struct _DbOtherStatements * cr_DbOtherStatements;
00042
00046 typedef enum {
00047 CR_DB_PRIMARY,
00048 CR_DB_FILELISTS,
00049 CR_DB_OTHER
00050 } cr_DatabaseType;
00051
00062 #define cr_open_primary_db(PATH, ERR) cr_open_db(PATH, CR_DB_PRIMARY, ERR)
00063
00074 #define cr_open_filelists_db(PATH, ERR) cr_open_db(PATH, CR_DB_FILELISTS, ERR)
00075
00087 #define cr_open_other_db(PATH, ERR) cr_open_db(PATH, CR_DB_OTHER, ERR)
00088
00097 #define cr_close_primary_db(DB, ERR) cr_close_db(DB, CR_DB_PRIMARY, ERR)
00098
00107 #define cr_close_filelists_db(DB, ERR) cr_close_db(DB, CR_DB_FILELISTS, ERR)
00108
00117 #define cr_close_other_db(DB, ERR) cr_close_db(DB, CR_DB_OTHER, ERR)
00118
00131 sqlite3 *cr_open_db(const char *path, cr_DatabaseType db_type, GError **err);
00132
00139 cr_DbPrimaryStatements cr_prepare_primary_db_statements(sqlite3 *db,
00140 GError **err);
00141
00148 cr_DbFilelistsStatements cr_prepare_filelists_db_statements(sqlite3 *db,
00149 GError **err);
00150
00157 cr_DbOtherStatements cr_prepare_other_db_statements(sqlite3 *db, GError **err);
00158
00163 void cr_destroy_primary_db_statements(cr_DbPrimaryStatements stmts);
00164
00169 void cr_destroy_filelists_db_statements(cr_DbFilelistsStatements stmts);
00170
00175 void cr_destroy_other_db_statements(cr_DbOtherStatements stmts);
00176
00182 void cr_add_primary_pkg_db(cr_DbPrimaryStatements stmts, cr_Package *pkg);
00183
00189 void cr_add_filelists_pkg_db(cr_DbFilelistsStatements stmts, cr_Package *pkg);
00190
00196 void cr_add_other_pkg_db(cr_DbOtherStatements stmts, cr_Package *pkg);
00197
00204 void cr_dbinfo_update(sqlite3 *db, const char *checksum, GError **err);
00205
00215 void cr_close_db(sqlite3 *db, cr_DatabaseType db_type, GError **err);
00216
00217 #ifdef __cplusplus
00218 }
00219 #endif
00220
00221 #endif