summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2018-07-03 19:45:13 -0400
committerJason Woodward2018-07-03 19:52:10 -0400
commit61ea36db7970d743aedc0d9abc9325883617bb4c (patch)
tree4450e86535d9d567bb9582011b0fb0f5fd25acc2
parent57f63030713f73556b4afb8f9f072f8693a46075 (diff)
downloadslapt-get-61ea36db7970d743aedc0d9abc9325883617bb4c.tar.gz
use bool instead of ints
-rw-r--r--doc/libslapt.312
-rw-r--r--src/action.c6
-rw-r--r--src/gpgme.c13
-rw-r--r--src/gpgme.h4
-rw-r--r--src/package.c27
-rw-r--r--src/package.h14
-rw-r--r--t/test_packages.c2
7 files changed, 38 insertions, 40 deletions
diff --git a/doc/libslapt.3 b/doc/libslapt.3
index a80bab9..d772698 100644
--- a/doc/libslapt.3
+++ b/doc/libslapt.3
@@ -391,14 +391,14 @@ The following functions download the PACKAGES.TXT, the patches/PACKAGES.TXT, CHE
.nf
.B "slapt_pkg_list_t *"
.B "slapt_get_pkg_source_packages (const slapt_rc_config *global_config,"
-.B " const char *url, unsigned int *compressed);"
+.B " const char *url, bool *compressed);"
.B "slapt_pkg_list_t *"
.B "slapt_get_pkg_source_patches (const slapt_rc_config *global_config,"
-.B " const char *url, unsigned int *compressed);"
+.B " const char *url, bool *compressed);"
.B "FILE *slapt_get_pkg_source_checksums (const slapt_rc_config *global_config,"
-.B " const char *url, unsigned int *compressed);"
+.B " const char *url, bool *compressed);"
.B "int slapt_get_pkg_source_changelog (const slapt_rc_config *global_config,"
-.B " const char *url, unsigned int *compressed);"
+.B " const char *url, bool *compressed);"
.fi
.sp
.TP
@@ -511,7 +511,7 @@ Retrieve the signature file for CHECKSUMS.md5 (or the signature for CHECKSUMS.md
.nf
.B "FILE *slapt_get_pkg_source_checksums_signature (const slapt_rc_config *global_config,"
.B " const char *url,"
-.B " unsigned int *compressed);"
+.B " bool *compressed);"
.fi
.sp
.TP
@@ -519,7 +519,7 @@ Retrieve the GPG-KEY file from the package source, if available. Returns NULL i
.nf
.B "FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,"
.B " const char *url,"
-.B " unsigned int *compressed);"
+.B " bool *compressed);"
.fi
.sp
.TP
diff --git a/src/action.c b/src/action.c
index b094e4e..49fb02e 100644
--- a/src/action.c
+++ b/src/action.c
@@ -394,7 +394,7 @@ void slapt_pkg_action_show(const char *pkg_name)
slapt_pkg_list_t *avail_pkgs = NULL;
slapt_pkg_list_t *installed_pkgs = NULL;
slapt_regex_t *pkg_regex = NULL;
- unsigned int bool_installed = 0;
+ bool installed = false;
slapt_pkg_info_t *pkg = NULL;
avail_pkgs = slapt_get_available_pkgs();
@@ -442,7 +442,7 @@ void slapt_pkg_action_show(const char *pkg_name)
slapt_clean_description(description, pkg->name);
if (slapt_get_exact_pkg(installed_pkgs, pkg->name, pkg->version) != NULL)
- bool_installed = 1;
+ installed = true;
printf(gettext("Package Name: %s\n"), pkg->name);
printf(gettext("Package Mirror: %s\n"), pkg->mirror);
@@ -465,7 +465,7 @@ void slapt_pkg_action_show(const char *pkg_name)
}
printf(gettext("Package Installed: %s\n"),
- bool_installed == 1
+ installed
? gettext("yes")
: gettext("no"));
diff --git a/src/gpgme.c b/src/gpgme.c
index 89c9510..563cc46 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -51,7 +51,7 @@ static void _slapt_free_gpgme_ctx(gpgme_ctx_t *ctx)
FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_config,
const char *url,
- unsigned int *compressed)
+ bool *compressed)
{
FILE *tmp_checksum_f = NULL;
char *checksum_head = NULL;
@@ -61,14 +61,13 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
char *filename = NULL;
char *local_head = NULL;
char *location;
- int checksums_compressed = *compressed;
- if (checksums_compressed == 1) {
+ if (*compressed) {
location = location_compressed;
- *compressed = 1;
+ *compressed = true;
} else {
location = location_uncompressed;
- *compressed = 0;
+ *compressed = false;
}
filename = slapt_gen_filename_from_url(url, location);
@@ -138,7 +137,7 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,
const char *url,
- unsigned int *compressed)
+ bool *compressed)
{
FILE *tmp_key_f = NULL;
char *key_head = NULL;
@@ -148,7 +147,7 @@ FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,
? true
: false;
- *compressed = 0;
+ *compressed = false;
key_head = slapt_head_mirror_data(url, SLAPT_GPG_KEY);
if (key_head == NULL) {
diff --git a/src/gpgme.h b/src/gpgme.h
index f61872b..38db7f3 100644
--- a/src/gpgme.h
+++ b/src/gpgme.h
@@ -29,11 +29,11 @@
/* retrieve the signature of the CHECKSUMS.md5 file */
FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_config,
const char *url,
- unsigned int *compressed);
+ bool *compressed);
/* retrieve the package sources GPG-KEY */
FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,
const char *url,
- unsigned int *compressed);
+ bool *compressed);
/* Add the GPG-KEY to the local keyring */
slapt_code_t slapt_add_pkg_source_gpg_key(FILE *key);
/* Verify the signature is valid for the checksum file */
diff --git a/src/package.c b/src/package.c
index 267c725..f4a2dcb 100644
--- a/src/package.c
+++ b/src/package.c
@@ -869,26 +869,25 @@ void slapt_free_pkg_list(slapt_pkg_list_t *list)
free(list);
}
-int slapt_is_excluded(const slapt_rc_config *global_config,
+bool slapt_is_excluded(const slapt_rc_config *global_config,
slapt_pkg_info_t *pkg)
{
unsigned int i, pkg_not_excluded = 0, pkg_slapt_is_excluded = 1;
int name_reg_ret = -1, version_reg_ret = -1, location_reg_ret = -1;
if (global_config->ignore_excludes == true)
- return pkg_not_excluded;
+ return false;
/* maybe EXCLUDE= isn't defined in our rc? */
if (global_config->exclude_list->count == 0)
- return pkg_not_excluded;
+ return false;
for (i = 0; i < global_config->exclude_list->count; i++) {
slapt_regex_t *exclude_reg = NULL;
/* return if its an exact match */
- if ((strncmp(global_config->exclude_list->items[i],
- pkg->name, strlen(pkg->name)) == 0))
- return pkg_slapt_is_excluded;
+ if ((strncmp(exclude, pkg->name, strlen(pkg->name)) == 0))
+ return true;
/*
this regex has to be init'd and free'd within the loop b/c the regex is pulled
@@ -912,11 +911,11 @@ int slapt_is_excluded(const slapt_rc_config *global_config,
slapt_free_regex(exclude_reg);
if (name_reg_ret == 0 || version_reg_ret == 0 || location_reg_ret == 0) {
- return pkg_slapt_is_excluded;
+ return true;
}
}
- return pkg_not_excluded;
+ return false;
}
void slapt_get_md5sums(slapt_pkg_list_t *pkgs, FILE *checksum_file)
@@ -1918,7 +1917,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
tmp_signature_f = slapt_get_pkg_source_checksums_signature(global_config, source_url, &compressed);
/* if we downloaded the compressed checksums, open it raw (w/o gunzipping) */
- if (compressed == 1) {
+ if (compressed) {
char *filename = slapt_gen_filename_from_url(source_url, SLAPT_CHECKSUM_FILE_GZ);
tmp_checksum_to_verify_f = slapt_open_file(filename, "r");
free(filename);
@@ -1948,7 +1947,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
fclose(tmp_signature_f);
/* if we opened the raw gzipped checksums, close it here */
- if (compressed == 1) {
+ if (compressed) {
fclose(tmp_checksum_to_verify_f);
} else {
if (tmp_checksum_f)
@@ -2564,7 +2563,7 @@ static FILE *slapt_gunzip_file(const char *file_name, FILE *dest_file)
}
slapt_pkg_list_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed)
+ const char *url, bool *compressed)
{
slapt_pkg_list_t *available_pkgs = NULL;
char *pkg_head = NULL;
@@ -2757,7 +2756,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_co
}
slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed)
+ const char *url, bool *compressed)
{
slapt_pkg_list_t *patch_pkgs = NULL;
char *patch_head = NULL;
@@ -2901,7 +2900,7 @@ slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_con
}
FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed)
+ const char *url, bool *compressed)
{
FILE *tmp_checksum_f = NULL;
char *checksum_head = NULL;
@@ -3036,7 +3035,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
}
int slapt_get_pkg_source_changelog(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed)
+ const char *url, bool *compressed)
{
char *changelog_head = NULL;
char *filename = NULL;
diff --git a/src/package.h b/src/package.h
index 54b6fb5..03f341c 100644
--- a/src/package.h
+++ b/src/package.h
@@ -197,7 +197,7 @@ char *slapt_gen_pkg_url(slapt_pkg_info_t *pkg);
exclude pkg based on pkg name
returns 1 if package is present in the exclude list, 0 if not present
*/
-int slapt_is_excluded(const slapt_rc_config *, slapt_pkg_info_t *);
+bool slapt_is_excluded(const slapt_rc_config *, slapt_pkg_info_t *);
/*
package is already downloaded and cached, md5sum if applicable is ok
returns slapt_code_t.
@@ -275,22 +275,22 @@ slapt_pkg_info_t *slapt_copy_pkg(slapt_pkg_info_t *dst, slapt_pkg_info_t *src);
slapt_pkg_err_list_t *slapt_init_pkg_err_list(void);
void slapt_add_pkg_err_to_list(slapt_pkg_err_list_t *l,
const char *pkg, const char *err);
-int slapt_search_pkg_err_list(slapt_pkg_err_list_t *l,
+bool slapt_search_pkg_err_list(slapt_pkg_err_list_t *l,
const char *pkg, const char *err);
void slapt_free_pkg_err_list(slapt_pkg_err_list_t *l);
/*
download the PACKAGES.TXT and CHECKSUMS.md5 files
- compressed is set to 1 if the compressed version was downloaded.
+ compressed is set if the compressed version was downloaded.
*/
slapt_pkg_list_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed);
+ const char *url, bool *compressed);
slapt_pkg_list_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed);
+ const char *url, bool *compressed);
FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed);
+ const char *url, bool *compressed);
int slapt_get_pkg_source_changelog(const slapt_rc_config *global_config,
- const char *url, unsigned int *compressed);
+ const char *url, bool *compressed);
/* clean package name from package description */
void slapt_clean_description(char *description, const char *name);
diff --git a/t/test_packages.c b/t/test_packages.c
index 407e57f..087cf8e 100644
--- a/t/test_packages.c
+++ b/t/test_packages.c
@@ -59,7 +59,7 @@ START_TEST(test_pkg_info)
string = NULL;
slapt_add_list_item(rc->exclude_list, "^gslapt$");
- fail_if(slapt_is_excluded(rc, &pkg) == 0);
+ fail_if(!slapt_is_excluded(rc, &pkg));
slapt_remove_list_item(rc->exclude_list, "^gslapt$");
fail_unless(slapt_download_pkg(rc, &pkg, NULL) == 0);