createrepo_c library
C library for metadata manipulation
src/sqlite.h
00001 /* createrepo_c - Library of routines for manipulation with repodata
00002  * Copyright (C) 2012  Tomas Mlcoch
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00017  * USA.
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 /* __C_CREATEREPOLIB_SQLITE_H__ */