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
00059 #define CR_DB_CACHE_DBVERSION 10
00063 typedef enum {
00064 CR_DB_PRIMARY,
00065 CR_DB_FILELISTS,
00066 CR_DB_OTHER,
00067 CR_DB_SENTINEL,
00068 } cr_DatabaseType;
00069
00070 typedef struct _DbPrimaryStatements * cr_DbPrimaryStatements;
00072 typedef struct _DbFilelistsStatements * cr_DbFilelistsStatements;
00074 typedef struct _DbOtherStatements * cr_DbOtherStatements;
00079 typedef union {
00080 cr_DbPrimaryStatements pri;
00081 cr_DbFilelistsStatements fil;
00082 cr_DbOtherStatements oth;
00083 } cr_Statements;
00084
00087 typedef struct {
00088 sqlite3 *db;
00090 cr_DatabaseType type;
00092 cr_Statements statements;
00094 } cr_SqliteDb;
00095
00105 #define cr_db_open_primary(PATH, ERR) cr_db_open(PATH, CR_DB_PRIMARY, ERR)
00106
00116 #define cr_db_open_filelists(PATH, ERR) cr_db_open(PATH, CR_DB_FILELISTS, ERR)
00117
00128 #define cr_db_open_other(PATH, ERR) cr_db_open(PATH, CR_DB_OTHER, ERR)
00129
00141 cr_SqliteDb *cr_db_open(const char *path,
00142 cr_DatabaseType db_type,
00143 GError **err);
00144
00151 int cr_db_add_pkg(cr_SqliteDb *sqlitedb,
00152 cr_Package *pkg,
00153 GError **err);
00154
00161 int cr_db_dbinfo_update(cr_SqliteDb *sqlitedb,
00162 const char *checksum,
00163 GError **err);
00164
00173 int cr_db_close(cr_SqliteDb *sqlitedb, GError **err);
00174
00177 #ifdef __cplusplus
00178 }
00179 #endif
00180
00181 #endif