summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 42c0cd1f..fd40f193 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -318,6 +318,8 @@ int SYMEXPORT alpm_option_set_root(const char *root)
ALPM_LOG_FUNC;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+
if(!root) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -358,6 +360,7 @@ int SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
ALPM_LOG_FUNC;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
if(!dbpath) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -396,6 +399,7 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
ALPM_LOG_FUNC;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
if(!cachedir) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -418,6 +422,7 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
void SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
if(handle->cachedirs) FREELIST(handle->cachedirs);
if(cachedirs) handle->cachedirs = cachedirs;
}
@@ -427,6 +432,7 @@ int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
char *vdata = NULL;
char *newcachedir;
size_t cachedirlen;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
/* verify cachedir ends in a '/' */
cachedirlen = strlen(cachedir);
if(cachedir[cachedirlen-1] != '/') {
@@ -450,6 +456,7 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile)
ALPM_LOG_FUNC;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
if(!logfile) {
pm_errno = PM_ERR_WRONG_ARGS;
return -1;
@@ -490,16 +497,19 @@ int SYMEXPORT alpm_option_set_signaturedir(const char *signaturedir)
void SYMEXPORT alpm_option_set_usesyslog(int usesyslog)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->usesyslog = usesyslog;
}
void SYMEXPORT alpm_option_add_noupgrade(const char *pkg)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
void SYMEXPORT alpm_option_set_noupgrades(alpm_list_t *noupgrade)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
if(handle->noupgrade) FREELIST(handle->noupgrade);
if(noupgrade) handle->noupgrade = noupgrade;
}
@@ -507,6 +517,7 @@ void SYMEXPORT alpm_option_set_noupgrades(alpm_list_t *noupgrade)
int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
{
char *vdata = NULL;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
handle->noupgrade = alpm_list_remove_str(handle->noupgrade, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -517,11 +528,13 @@ int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
void SYMEXPORT alpm_option_add_noextract(const char *pkg)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
}
void SYMEXPORT alpm_option_set_noextracts(alpm_list_t *noextract)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
if(handle->noextract) FREELIST(handle->noextract);
if(noextract) handle->noextract = noextract;
}
@@ -529,6 +542,7 @@ void SYMEXPORT alpm_option_set_noextracts(alpm_list_t *noextract)
int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
{
char *vdata = NULL;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -539,11 +553,13 @@ int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
void SYMEXPORT alpm_option_add_ignorepkg(const char *pkg)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
}
void SYMEXPORT alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
if(handle->ignorepkg) FREELIST(handle->ignorepkg);
if(ignorepkgs) handle->ignorepkg = ignorepkgs;
}
@@ -551,6 +567,7 @@ void SYMEXPORT alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
{
char *vdata = NULL;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
handle->ignorepkg = alpm_list_remove_str(handle->ignorepkg, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -561,11 +578,13 @@ int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
void SYMEXPORT alpm_option_add_ignoregrp(const char *grp)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp));
}
void SYMEXPORT alpm_option_set_ignoregrps(alpm_list_t *ignoregrps)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
if(handle->ignoregrp) FREELIST(handle->ignoregrp);
if(ignoregrps) handle->ignoregrp = ignoregrps;
}
@@ -573,6 +592,7 @@ void SYMEXPORT alpm_option_set_ignoregrps(alpm_list_t *ignoregrps)
int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
{
char *vdata = NULL;
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
if(vdata != NULL) {
FREE(vdata);
@@ -583,17 +603,20 @@ int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
void SYMEXPORT alpm_option_set_arch(const char *arch)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
if(handle->arch) FREE(handle->arch);
if(arch) handle->arch = strdup(arch);
}
void SYMEXPORT alpm_option_set_usedelta(int usedelta)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->usedelta = usedelta;
}
void SYMEXPORT alpm_option_set_checkspace(int checkspace)
{
+ ASSERT(handle != NULL, RET_ERR_VOID(PM_ERR_HANDLE_NULL));
handle->checkspace = checkspace;
}