udata->id_pri++;
cr_puts(udata->pri_f, (const char *) res.primary);
if (udata->pri_statements)
- cr_add_primary_pkg_db(udata->pri_statements, pkg);
+ cr_db_add_primary_pkg(udata->pri_statements, pkg);
g_mutex_unlock(udata->mutex_pri);
g_cond_broadcast(udata->cond_pri);
udata->id_fil++;
cr_puts(udata->fil_f, (const char *) res.filelists);
if (udata->fil_statements) {
- cr_add_filelists_pkg_db(udata->fil_statements, pkg);
+ cr_db_add_filelists_pkg(udata->fil_statements, pkg);
}
g_mutex_unlock(udata->mutex_fil);
g_cond_broadcast(udata->cond_fil);
udata->id_oth++;
cr_puts(udata->oth_f, (const char *) res.other);
if (udata->oth_statements) {
- cr_add_other_pkg_db(udata->oth_statements, pkg);
+ cr_db_add_other_pkg(udata->oth_statements, pkg);
}
g_mutex_unlock(udata->mutex_oth);
g_cond_broadcast(udata->cond_oth);
pri_db_filename = g_strconcat(tmp_out_repo, "/primary.sqlite", NULL);
fil_db_filename = g_strconcat(tmp_out_repo, "/filelists.sqlite", NULL);
oth_db_filename = g_strconcat(tmp_out_repo, "/other.sqlite", NULL);
- pri_db = cr_open_primary_db(pri_db_filename, NULL);
- fil_db = cr_open_filelists_db(fil_db_filename, NULL);
- oth_db = cr_open_other_db(oth_db_filename, NULL);
- pri_statements = cr_prepare_primary_db_statements(pri_db, NULL);
- fil_statements = cr_prepare_filelists_db_statements(fil_db, NULL);
- oth_statements = cr_prepare_other_db_statements(oth_db, NULL);
+ pri_db = cr_db_open_primary(pri_db_filename, NULL);
+ fil_db = cr_db_open_filelists(fil_db_filename, NULL);
+ oth_db = cr_db_open_other(oth_db_filename, NULL);
+ pri_statements = cr_db_prepare_primary_statements(pri_db, NULL);
+ fil_statements = cr_db_prepare_filelists_statements(fil_db, NULL);
+ oth_statements = cr_db_prepare_other_statements(oth_db, NULL);
}
gchar *oth_db_name = g_strconcat(oth_db_filename,
sqlite_compression_suffix, NULL);
- cr_dbinfo_update(pri_db, pri_xml_rec->checksum, NULL);
- cr_dbinfo_update(fil_db, fil_xml_rec->checksum, NULL);
- cr_dbinfo_update(oth_db, oth_xml_rec->checksum, NULL);
+ cr_db_dbinfo_update(pri_db, pri_xml_rec->checksum, NULL);
+ cr_db_dbinfo_update(fil_db, fil_xml_rec->checksum, NULL);
+ cr_db_dbinfo_update(oth_db, oth_xml_rec->checksum, NULL);
- cr_destroy_primary_db_statements(pri_statements);
- cr_destroy_filelists_db_statements(fil_statements);
- cr_destroy_other_db_statements(oth_statements);
+ cr_db_destroy_primary_statements(pri_statements);
+ cr_db_destroy_filelists_statements(fil_statements);
+ cr_db_destroy_other_statements(oth_statements);
- cr_close_primary_db(pri_db, NULL);
- cr_close_filelists_db(fil_db, NULL);
- cr_close_other_db(oth_db, NULL);
+ cr_db_close_primary(pri_db, NULL);
+ cr_db_close_filelists(fil_db, NULL);
+ cr_db_close_other(oth_db, NULL);
// Compress dbs
fil_db_filename = g_strconcat(cmd_options->tmp_out_repo, "/filelists.sqlite", NULL);
oth_db_filename = g_strconcat(cmd_options->tmp_out_repo, "/other.sqlite", NULL);
- pri_db = cr_open_primary_db(pri_db_filename, NULL);
- fil_db = cr_open_filelists_db(fil_db_filename, NULL);
- oth_db = cr_open_other_db(oth_db_filename, NULL);
+ pri_db = cr_db_open_primary(pri_db_filename, NULL);
+ fil_db = cr_db_open_filelists(fil_db_filename, NULL);
+ oth_db = cr_db_open_other(oth_db_filename, NULL);
g_free(pri_db_filename);
g_free(fil_db_filename);
g_free(oth_db_filename);
- pri_statements = cr_prepare_primary_db_statements(pri_db, NULL);
- fil_statements = cr_prepare_filelists_db_statements(fil_db, NULL);
- oth_statements = cr_prepare_other_db_statements(oth_db, NULL);
+ pri_statements = cr_db_prepare_primary_statements(pri_db, NULL);
+ fil_statements = cr_db_prepare_filelists_statements(fil_db, NULL);
+ oth_statements = cr_db_prepare_other_statements(oth_db, NULL);
}
cr_puts(oth_f, (const char *) res.other);
if (!cmd_options->no_database) {
- cr_add_primary_pkg_db(pri_statements, pkg);
- cr_add_filelists_pkg_db(fil_statements, pkg);
- cr_add_other_pkg_db(oth_statements, pkg);
+ cr_db_add_primary_pkg(pri_statements, pkg);
+ cr_db_add_filelists_pkg(fil_statements, pkg);
+ cr_db_add_other_pkg(oth_statements, pkg);
}
free(res.primary);
const char *db_suffix = cr_compression_suffix(cmd_options->db_compression_type);
// Insert XML checksums into the dbs
- cr_dbinfo_update(pri_db, pri_xml_rec->checksum, NULL);
- cr_dbinfo_update(fil_db, fil_xml_rec->checksum, NULL);
- cr_dbinfo_update(oth_db, oth_xml_rec->checksum, NULL);
+ cr_db_dbinfo_update(pri_db, pri_xml_rec->checksum, NULL);
+ cr_db_dbinfo_update(fil_db, fil_xml_rec->checksum, NULL);
+ cr_db_dbinfo_update(oth_db, oth_xml_rec->checksum, NULL);
// Close dbs
- cr_destroy_primary_db_statements(pri_statements);
- cr_destroy_filelists_db_statements(fil_statements);
- cr_destroy_other_db_statements(oth_statements);
+ cr_db_destroy_primary_statements(pri_statements);
+ cr_db_destroy_filelists_statements(fil_statements);
+ cr_db_destroy_other_statements(oth_statements);
- cr_close_primary_db(pri_db, NULL);
- cr_close_filelists_db(fil_db, NULL);
- cr_close_other_db(oth_db, NULL);
+ cr_db_close_primary(pri_db, NULL);
+ cr_db_close_filelists(fil_db, NULL);
+ cr_db_close_other(oth_db, NULL);
// Compress dbs
gchar *pri_db_filename = g_strconcat(cmd_options->tmp_out_repo, "/primary.sqlite", NULL);
GQuark
-cr_db_error_quark (void)
+cr_db_error_quark(void)
{
static GQuark quark;
sqlite3 *
-cr_open_db(const char *path, cr_DatabaseType db_type, GError **err)
+cr_db_open(const char *path, cr_DatabaseType db_type, GError **err)
{
GError *tmp_err = NULL;
sqlite3 *db = NULL;
void
-cr_close_db(sqlite3 *db, cr_DatabaseType db_type, GError **err)
+cr_db_close(sqlite3 *db, cr_DatabaseType db_type, GError **err)
{
GError *tmp_err = NULL;
void
-cr_dbinfo_update(sqlite3 *db, const char *checksum, GError **err)
+cr_db_dbinfo_update(sqlite3 *db, const char *checksum, GError **err)
{
int rc;
char *sql;
sql = g_strdup_printf
("INSERT INTO db_info (dbversion, checksum) VALUES (%d, '%s')",
- CR_SQLITE_CACHE_DBVERSION, checksum);
+ CR_DB_CACHE_DBVERSION, checksum);
rc = sqlite3_exec (db, sql, NULL, NULL, NULL);
if (rc != SQLITE_OK)
static void
-write_file (gpointer key, gpointer value, gpointer user_data)
+cr_db_write_file (gpointer key, gpointer value, gpointer user_data)
{
EncodedPackageFile *file = (EncodedPackageFile *) value;
FileWriteInfo *info = (FileWriteInfo *) user_data;
info.pkgKey = p->pkgKey;
hash = package_files_to_hash (p->files);
- g_hash_table_foreach (hash, write_file, &info);
+ g_hash_table_foreach (hash, cr_db_write_file, &info);
g_hash_table_destroy (hash);
}
// Primary.sqlite interface
cr_DbPrimaryStatements
-cr_prepare_primary_db_statements(sqlite3 *db, GError **err)
+cr_db_prepare_primary_statements(sqlite3 *db, GError **err)
{
GError *tmp_err = NULL;
cr_DbPrimaryStatements ret = malloc(sizeof(*ret));
void
-cr_destroy_primary_db_statements(cr_DbPrimaryStatements stmts)
+cr_db_destroy_primary_statements(cr_DbPrimaryStatements stmts)
{
if (!stmts)
return;
void
-cr_add_primary_pkg_db(cr_DbPrimaryStatements stmts, cr_Package *pkg)
+cr_db_add_primary_pkg(cr_DbPrimaryStatements stmts, cr_Package *pkg)
{
GSList *iter;
cr_DbFilelistsStatements
-cr_prepare_filelists_db_statements(sqlite3 *db, GError **err)
+cr_db_prepare_filelists_statements(sqlite3 *db, GError **err)
{
GError *tmp_err = NULL;
cr_DbFilelistsStatements ret = malloc(sizeof(*ret));
void
-cr_destroy_filelists_db_statements(cr_DbFilelistsStatements stmts)
+cr_db_destroy_filelists_statements(cr_DbFilelistsStatements stmts)
{
if (!stmts)
return;
void
-cr_add_filelists_pkg_db(cr_DbFilelistsStatements stmts, cr_Package *pkg)
+cr_db_add_filelists_pkg(cr_DbFilelistsStatements stmts, cr_Package *pkg)
{
// Add package record into the filelists.sqlite
db_package_ids_write(stmts->db, stmts->package_id_handle, pkg);
cr_DbOtherStatements
-cr_prepare_other_db_statements(sqlite3 *db, GError **err)
+cr_db_prepare_other_statements(sqlite3 *db, GError **err)
{
GError *tmp_err = NULL;
cr_DbOtherStatements ret = malloc(sizeof(*ret));
void
-cr_destroy_other_db_statements(cr_DbOtherStatements stmts)
+cr_db_destroy_other_statements(cr_DbOtherStatements stmts)
{
if (!stmts)
return;
void
-cr_add_other_pkg_db(cr_DbOtherStatements stmts, cr_Package *pkg)
+cr_db_add_other_pkg(cr_DbOtherStatements stmts, cr_Package *pkg)
{
GSList *iter;
cr_ChangelogEntry *entry;
#endif
/** \defgroup sqlite SQLite metadata API.
+ * \addtogroup sqlite
+ * @{
*/
-#define CR_SQLITE_CACHE_DBVERSION 10 /*!< Version of DB api */
+#define CR_DB_CACHE_DBVERSION 10 /*!< Version of DB api */
#define CR_DB_ERROR cr_db_error_quark()
GQuark cr_db_error_quark (void);
typedef struct _DbFilelistsStatements * cr_DbFilelistsStatements;
typedef struct _DbOtherStatements * cr_DbOtherStatements;
-/** \ingroup sqlite
- * Database type.
+/** Database type.
*/
typedef enum {
CR_DB_PRIMARY, /*!< primary */
CR_DB_OTHER /*!< other */
} cr_DatabaseType;
-/** \ingroup sqlite
- * Macro over cr_open_db function. Open (create new) primary sqlite sqlite db.
+/** Macro over cr_db_open function. Open (create new) primary sqlite sqlite db.
* - creates db file
* - creates primary tables
* - creates info table
* @param ERR **GError
* @return open db pointer
*/
-#define cr_open_primary_db(PATH, ERR) cr_open_db(PATH, CR_DB_PRIMARY, ERR)
+#define cr_db_open_primary(PATH, ERR) cr_db_open(PATH, CR_DB_PRIMARY, ERR)
-/** \ingroup sqlite
- * Macro over cr_open_db function. Open (create new) filelists sqlite sqlite db.
+/** Macro over cr_db_open function. Open (create new) filelists sqlite sqlite db.
* - creates db file
* - creates filelists tables
* - creates info table
* @param ERR **GError
* @return open db pointer
*/
-#define cr_open_filelists_db(PATH, ERR) cr_open_db(PATH, CR_DB_FILELISTS, ERR)
+#define cr_db_open_filelists(PATH, ERR) cr_db_open(PATH, CR_DB_FILELISTS, ERR)
-/** \ingroup sqlite
- * Macro over cr_open_db function. Open (create new) other sqlite sqlite db.
+/** Macro over cr_db_open function. Open (create new) other sqlite sqlite db.
* - creates db file
* - opens transaction
* - creates other tables
* @param ERR **GError
* @return open db connection
*/
-#define cr_open_other_db(PATH, ERR) cr_open_db(PATH, CR_DB_OTHER, ERR)
+#define cr_db_open_other(PATH, ERR) cr_db_open(PATH, CR_DB_OTHER, ERR)
-/** \ingroup sqlite
- * Macro over cr_close_db function. Close db.
+/** Macro over cr_db_close function. Close db.
* - creates indexes on tables
* - commits transaction
* - closes db
* @param DB open db connection
* @param ERR **GError
*/
-#define cr_close_primary_db(DB, ERR) cr_close_db(DB, CR_DB_PRIMARY, ERR)
+#define cr_db_close_primary(DB, ERR) cr_db_close(DB, CR_DB_PRIMARY, ERR)
-/** \ingroup sqlite
- * Macro over cr_close_db function. Close db.
+/** Macro over cr_db_close function. Close db.
* - creates indexes on tables
* - commits transaction
* - closes db
* @param DB open db connection
* @param ERR **GError
*/
-#define cr_close_filelists_db(DB, ERR) cr_close_db(DB, CR_DB_FILELISTS, ERR)
+#define cr_db_close_filelists(DB, ERR) cr_db_close(DB, CR_DB_FILELISTS, ERR)
-/** \ingroup sqlite
- * Macro over cr_close_db function. Close db.
+/** Macro over cr_db_close function. Close db.
* - creates indexes on tables
* - commits transaction
* - closes db
* @param DB open db connection
* @param ERR **GError
*/
-#define cr_close_other_db(DB, ERR) cr_close_db(DB, CR_DB_OTHER, ERR)
+#define cr_db_close_other(DB, ERR) cr_db_close(DB, CR_DB_OTHER, ERR)
-/** \ingroup sqlite
- * Open (create new) other sqlite sqlite db.
+/** Open (create new) other sqlite sqlite db.
* - creates db file
* - opens transaction
* - creates other tables
* @param err **GError
* @return open db connection
*/
-sqlite3 *cr_open_db(const char *path, cr_DatabaseType db_type, GError **err);
+sqlite3 *cr_db_open(const char *path, cr_DatabaseType db_type, GError **err);
-/** \ingroup sqlite
- * Prepare compiled statements for use in the cr_add_primary_pkg_db function.
+/** Prepare compiled statements for use in the cr_db_add_primary_pkg function.
* @param db Open db connection
* @param err **GError
* @return cr_DbPrimaryStatements object
*/
-cr_DbPrimaryStatements cr_prepare_primary_db_statements(sqlite3 *db,
+cr_DbPrimaryStatements cr_db_prepare_primary_statements(sqlite3 *db,
GError **err);
-/** \ingroup sqlite
- * Prepare compiled statements for use in the cr_add_filelists_pkg_db function.
+/** Prepare compiled statements for use in the cr_db_add_filelists_pkg function.
* @param db Open db connection
* @param err **GError
* @return cr_DbFilelistsStatements object
*/
-cr_DbFilelistsStatements cr_prepare_filelists_db_statements(sqlite3 *db,
+cr_DbFilelistsStatements cr_db_prepare_filelists_statements(sqlite3 *db,
GError **err);
-/** \ingroup sqlite
- * Prepare compiled statements for use in the cr_add_other_pkg_db function.
+/** Prepare compiled statements for use in the cr_db_add_other_pkg function.
* @param db Open db connection
* @param err **GError
* @return cr_DbOtherStatements object
*/
-cr_DbOtherStatements cr_prepare_other_db_statements(sqlite3 *db, GError **err);
+cr_DbOtherStatements cr_db_prepare_other_statements(sqlite3 *db, GError **err);
-/** \ingroup sqlite
- * Frees cr_DbPrimaryStatements object.
+/** Frees cr_DbPrimaryStatements object.
* @param stmts statements object
*/
-void cr_destroy_primary_db_statements(cr_DbPrimaryStatements stmts);
+void cr_db_destroy_primary_statements(cr_DbPrimaryStatements stmts);
-/** \ingroup sqlite
- * Frees cr_DbFilelistsStatements object.
+/** Frees cr_DbFilelistsStatements object.
* @param stmts statements object
*/
-void cr_destroy_filelists_db_statements(cr_DbFilelistsStatements stmts);
+void cr_db_destroy_filelists_statements(cr_DbFilelistsStatements stmts);
-/** \ingroup sqlite
- * Frees cr_DbOtherStatements object.
+/** Frees cr_DbOtherStatements object.
* @param stmts statements object
*/
-void cr_destroy_other_db_statements(cr_DbOtherStatements stmts);
+void cr_db_destroy_other_statements(cr_DbOtherStatements stmts);
-/** \ingroup sqlite
- * Add package into the database.
+/** Add package into the database.
* @param stmts object with compiled statements
* @param pkg package object
*/
-void cr_add_primary_pkg_db(cr_DbPrimaryStatements stmts, cr_Package *pkg);
+void cr_db_add_primary_pkg(cr_DbPrimaryStatements stmts, cr_Package *pkg);
-/** \ingroup sqlite
- * Add package into the database.
+/** Add package into the database.
* @param stmts object with compiled statements
* @param pkg package object
*/
-void cr_add_filelists_pkg_db(cr_DbFilelistsStatements stmts, cr_Package *pkg);
+void cr_db_add_filelists_pkg(cr_DbFilelistsStatements stmts, cr_Package *pkg);
-/** \ingroup sqlite
- * Add package into the database.
+/** Add package into the database.
* @param stmts object with compiled statements
* @param pkg package object
*/
-void cr_add_other_pkg_db(cr_DbOtherStatements stmts, cr_Package *pkg);
+void cr_db_add_other_pkg(cr_DbOtherStatements stmts, cr_Package *pkg);
-/** \ingroup sqlite
- * Insert record into the updateinfo table
+/** Insert record into the updateinfo table
* @param db open db connection
* @param checksum compressed xml file checksum
* @param err **GError
*/
-void cr_dbinfo_update(sqlite3 *db, const char *checksum, GError **err);
+void cr_db_dbinfo_update(sqlite3 *db, const char *checksum, GError **err);
-/** \ingroup sqlite
- * Close db.
+/** Close db.
* - creates indexes on tables
* - commits transaction
* - closes db
* @param db_type Type of database (primary, filelists, other)
* @param err **GError
*/
-void cr_close_db(sqlite3 *db, cr_DatabaseType db_type, GError **err);
+void cr_db_close(sqlite3 *db, cr_DatabaseType db_type, GError **err);
+
+/** @} */
#ifdef __cplusplus
}