createrepo_c library 1.2.1 C library for metadata manipulation

sqlite.h
1 /* createrepo_c - Library of routines for manipulation with repodata
2 * Copyright (C) 2012 Tomas Mlcoch
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 * USA.
18 */
19
20 #ifndef __C_CREATEREPOLIB_SQLITE_H__
21 #define __C_CREATEREPOLIB_SQLITE_H__
22
23 #include <glib.h>
24 #include <sqlite3.h>
25 #include "package.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
59 #define CR_DB_CACHE_DBVERSION 10
63 typedef enum {
64 CR_DB_PRIMARY,
65 CR_DB_FILELISTS,
66 CR_DB_FILELISTS_EXT,
67 CR_DB_OTHER,
68 CR_DB_SENTINEL,
69 } cr_DatabaseType;
70
71 typedef struct _DbPrimaryStatements * cr_DbPrimaryStatements;
73 typedef struct _DbFilelistsStatements * cr_DbFilelistsStatements;
75 typedef struct _DbOtherStatements * cr_DbOtherStatements;
80 typedef union {
81 cr_DbPrimaryStatements pri;
82 cr_DbFilelistsStatements fil;
83 cr_DbOtherStatements oth;
84 } cr_Statements;
85
88 typedef struct {
89 sqlite3 *db;
91 cr_DatabaseType type;
93 cr_Statements statements;
95 } cr_SqliteDb;
96
106 #define cr_db_open_primary(PATH, ERR) cr_db_open(PATH, CR_DB_PRIMARY, ERR)
107
117 #define cr_db_open_filelists(PATH, ERR) cr_db_open(PATH, CR_DB_FILELISTS, ERR)
118
129 #define cr_db_open_other(PATH, ERR) cr_db_open(PATH, CR_DB_OTHER, ERR)
130
142 cr_SqliteDb *cr_db_open(const char *path,
143 cr_DatabaseType db_type,
144 GError **err);
145
152 int cr_db_add_pkg(cr_SqliteDb *sqlitedb,
153 cr_Package *pkg,
154 GError **err);
155
162 int cr_db_dbinfo_update(cr_SqliteDb *sqlitedb,
163 const char *checksum,
164 GError **err);
165
174 int cr_db_close(cr_SqliteDb *sqlitedb, GError **err);
175
178 #ifdef __cplusplus
179 }
180 #endif
181
182 #endif /* __C_CREATEREPOLIB_SQLITE_H__ */
cr_SqliteDb::type
cr_DatabaseType type
Definition: sqlite.h:91
cr_db_dbinfo_update
int cr_db_dbinfo_update(cr_SqliteDb *sqlitedb, const char *checksum, GError **err)
cr_DbFilelistsStatements
struct _DbFilelistsStatements * cr_DbFilelistsStatements
Definition: sqlite.h:73
CR_DB_SENTINEL
@ CR_DB_SENTINEL
Definition: sqlite.h:68
CR_DB_OTHER
@ CR_DB_OTHER
Definition: sqlite.h:67
cr_db_close
int cr_db_close(cr_SqliteDb *sqlitedb, GError **err)
cr_DatabaseType
cr_DatabaseType
Definition: sqlite.h:63
cr_DbOtherStatements
struct _DbOtherStatements * cr_DbOtherStatements
Definition: sqlite.h:75
cr_Statements::fil
cr_DbFilelistsStatements fil
Definition: sqlite.h:82
cr_DbPrimaryStatements
struct _DbPrimaryStatements * cr_DbPrimaryStatements
Definition: sqlite.h:71
cr_Statements::pri
cr_DbPrimaryStatements pri
Definition: sqlite.h:81
cr_Statements::oth
cr_DbOtherStatements oth
Definition: sqlite.h:83
cr_db_add_pkg
int cr_db_add_pkg(cr_SqliteDb *sqlitedb, cr_Package *pkg, GError **err)
CR_DB_FILELISTS
@ CR_DB_FILELISTS
Definition: sqlite.h:65
CR_DB_FILELISTS_EXT
@ CR_DB_FILELISTS_EXT
Definition: sqlite.h:66
cr_SqliteDb::db
sqlite3 * db
Definition: sqlite.h:89
cr_SqliteDb::statements
cr_Statements statements
Definition: sqlite.h:93
cr_SqliteDb
Definition: sqlite.h:88
cr_Statements
Definition: sqlite.h:80
CR_DB_PRIMARY
@ CR_DB_PRIMARY
Definition: sqlite.h:64
cr_Package
Definition: package.h:84
cr_db_open
cr_SqliteDb * cr_db_open(const char *path, cr_DatabaseType db_type, GError **err)