#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#include "db.h"
#include "alpm_list.h"
#include "log.h"
#include "util.h"
#include "handle.h"
#include "alpm.h"
#include "package.h"
#include "group.h"
alpm_db_t SYMEXPORT *alpm_db_register_sync(alpm_handle_t *handle,
const char *treename, alpm_siglevel_t level)
{
CHECK_HANDLE(handle, return NULL);
ASSERT(treename != NULL && strlen(treename) != 0,
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL));
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, NULL));
return _alpm_db_register_sync(handle, treename, level);
}
void _alpm_db_unregister(alpm_db_t *db)
{
if(db == NULL) {
return;
}
_alpm_log(db->handle, ALPM_LOG_DEBUG, "unregistering database '%s'\n", db->treename);
_alpm_db_free(db);
}
int SYMEXPORT alpm_db_unregister_all(alpm_handle_t *handle)
{
alpm_list_t *i;
alpm_db_t *db;
CHECK_HANDLE(handle, return -1);
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
for(i = handle->dbs_sync; i; i = i->next) {
db = i->data;
db->ops->unregister(db);
i->data = NULL;
}
FREELIST(handle->dbs_sync);
return 0;
}
int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
{
int found = 0;
alpm_handle_t *handle;
ASSERT(db != NULL, return -1);
handle = db->handle;
handle->pm_errno = 0;
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
if(db == handle->db_local) {
handle->db_local = NULL;
found = 1;
} else {
void *data;
handle->dbs_sync = alpm_list_remove(handle->dbs_sync,
db, _alpm_db_cmp, &data);
if(data) {
found = 1;
}
}
if(!found) {
RET_ERR(handle, ALPM_ERR_DB_NOT_FOUND, -1);
}
db->ops->unregister(db);
return 0;
}
alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db)
{
|