aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-01-16 23:18:02 +0000
committerJason Woodward2005-01-16 23:18:02 +0000
commit93791e95a1a8cfd3270e93880cfa0cc567d609f2 (patch)
tree375f7f41fa5a9f3f5f491f84ab12fde7b0ca5a47 /src
parent8523d1c37edddcda27b96c77483c19e6469b89f0 (diff)
downloadslapt-get-93791e95a1a8cfd3270e93880cfa0cc567d609f2.tar.gz
changed global_config unsigned integers to bool typedef
Diffstat (limited to 'src')
-rw-r--r--src/action.c10
-rw-r--r--src/configuration.c26
-rw-r--r--src/configuration.h22
-rw-r--r--src/curl.c4
-rw-r--r--src/main.c24
-rw-r--r--src/package.c26
-rw-r--r--src/transaction.c20
7 files changed, 66 insertions, 66 deletions
diff --git a/src/action.c b/src/action.c
index 02f1c6f..b7b4cb5 100644
--- a/src/action.c
+++ b/src/action.c
@@ -107,7 +107,7 @@ void pkg_action_install(const rc_config *global_config,const pkg_action_args_t *
/* it is already installed, attempt an upgrade */
if(
((cmp_pkg_versions(installed_pkg->version,pkg->version)) < 0) ||
- (global_config->re_install == 1)
+ (global_config->re_install == TRUE)
){
if( add_deps_to_trans(global_config,&tran,avail_pkgs,installed_pkgs,pkg) == 0 ){
@@ -394,7 +394,7 @@ void pkg_action_upgrade_all(const rc_config *global_config){
printf(_("Done\n"));
init_transaction(&tran);
- if( global_config->dist_upgrade == 1 ){
+ if( global_config->dist_upgrade == TRUE ){
struct pkg_list *matches = search_pkg_list(avail_pkgs,SLACK_BASE_SET_REGEX);
for(i = 0; i < matches->pkg_count; i++){
@@ -465,7 +465,7 @@ void pkg_action_upgrade_all(const rc_config *global_config){
free_pkg_list(matches);
/* remove obsolete packages if prompted to */
- if( global_config->remove_obsolete == 1 ){
+ if( global_config->remove_obsolete == TRUE ){
unsigned int r;
for(r = 0; r < installed_pkgs->pkg_count; r++){
@@ -525,10 +525,10 @@ void pkg_action_upgrade_all(const rc_config *global_config){
cmp_r = cmp_pkg_versions(installed_pkgs->pkgs[i]->version,update_pkg->version);
if(
/* either it's greater, or we want to reinstall */
- cmp_r < 0 || (global_config->re_install == 1) ||
+ cmp_r < 0 || (global_config->re_install == TRUE) ||
/* or this is a dist upgrade and the versions are the save except for the arch */
(
- global_config->dist_upgrade == 1 &&
+ global_config->dist_upgrade == TRUE &&
cmp_r == 0 &&
strcmp(installed_pkgs->pkgs[i]->version,update_pkg->version) != 0
)
diff --git a/src/configuration.c b/src/configuration.c
index 5125d5b..4188876 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -30,21 +30,21 @@ rc_config *read_rc_config(const char *file_name){
global_config = slapt_malloc( sizeof *global_config );
/* initialize */
- global_config->sources.count = 0;
- global_config->download_only = 0;
- global_config->simulate = 0;
- global_config->ignore_excludes = 0;
- global_config->no_md5_check = 0;
- global_config->dist_upgrade = 0;
- global_config->ignore_dep = 0;
- global_config->disable_dep_check = 0;
- global_config->print_uris = 0;
- global_config->dl_stats = 0;
- global_config->no_prompt = 0;
- global_config->re_install = 0;
+ global_config->sources.count = FALSE;
+ global_config->download_only = FALSE;
+ global_config->simulate = FALSE;
+ global_config->ignore_excludes = FALSE;
+ global_config->no_md5_check = FALSE;
+ global_config->dist_upgrade = FALSE;
+ global_config->ignore_dep = FALSE;
+ global_config->disable_dep_check = FALSE;
+ global_config->print_uris = FALSE;
+ global_config->dl_stats = FALSE;
+ global_config->no_prompt = FALSE;
+ global_config->re_install = FALSE;
global_config->exclude_list = NULL;
global_config->working_dir[0] = '\0';
- global_config->remove_obsolete = 0;
+ global_config->remove_obsolete = FALSE;
rc = open_file(file_name,"r");
if( rc == NULL ) exit(1);
diff --git a/src/configuration.h b/src/configuration.h
index cb04fa1..56cba9e 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -36,19 +36,19 @@ struct source_list {
typedef struct {
struct source_list sources;
char working_dir[WORKINGDIR_TOKEN_LEN];
- unsigned int download_only;
- unsigned int dist_upgrade;
- unsigned int simulate;
- unsigned int no_prompt;
+ bool download_only;
+ bool dist_upgrade;
+ bool simulate;
+ bool no_prompt;
unsigned int re_install;
struct exclude_list *exclude_list;
- unsigned int ignore_excludes;
- unsigned int no_md5_check;
- unsigned int ignore_dep;
- unsigned int disable_dep_check;
- unsigned int print_uris;
- unsigned int dl_stats;
- unsigned int remove_obsolete;
+ bool ignore_excludes;
+ bool no_md5_check;
+ bool ignore_dep;
+ bool disable_dep_check;
+ bool print_uris;
+ bool dl_stats;
+ bool remove_obsolete;
} rc_config;
rc_config *read_rc_config(const char *file_name);
diff --git a/src/curl.c b/src/curl.c
index e8be171..16c70d0 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -180,7 +180,7 @@ int download_pkg(const rc_config *global_config,pkg_info_t *pkg){
file_name = gen_pkg_file_name(global_config,pkg);
f_size = get_pkg_file_size(global_config,pkg);
- if( global_config->dl_stats == 1 ){
+ if( global_config->dl_stats == TRUE ){
printf(_("Downloading %s %s %s [%dK]...\n"),pkg->mirror,pkg->name,pkg->version,pkg->size_c - (f_size/1024));
}else{
printf(_("Downloading %s %s %s [%dK]..."),pkg->mirror,pkg->name,pkg->version,pkg->size_c - (f_size/1024));
@@ -197,7 +197,7 @@ int download_pkg(const rc_config *global_config,pkg_info_t *pkg){
/* download the file to our file handle */
dl_return = download_data(fh,url,f_size,global_config->dl_stats);
if( dl_return == 0 ){
- if( global_config->dl_stats != 1 ) printf(_("Done\n"));
+ if( global_config->dl_stats == FALSE ) printf(_("Done\n"));
}else if( dl_return == CURLE_HTTP_RANGE_ERROR ){
/*
* this is for errors trying to resume. unlink the file and
diff --git a/src/main.c b/src/main.c
index d701cc5..434f0b6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -109,44 +109,44 @@ int main( int argc, char *argv[] ){
do_action = UPGRADE;
break;
case DOWNLOAD_ONLY_OPT: /* download only flag */
- global_config->download_only = 1;
+ global_config->download_only = TRUE;
break;
case SIMULATE_OPT: /* simulate */
- global_config->simulate = 1;
+ global_config->simulate = TRUE;
break;
case VERSION_OPT: /* version */
do_action = SHOWVERSION;
break;
case NO_PROMPT_OPT: /* auto */
- global_config->no_prompt = 1;
+ global_config->no_prompt = TRUE;
break;
case REINSTALL_OPT: /* reinstall */
- global_config->re_install = 1;
+ global_config->re_install = TRUE;
break;
case IGNORE_EXCLUDES_OPT: /* ignore-excludes */
- global_config->ignore_excludes = 1;
+ global_config->ignore_excludes = TRUE;
break;
case NO_MD5_OPT: /* no-md5 */
- global_config->no_md5_check = 1;
+ global_config->no_md5_check = TRUE;
break;
case DIST_UPGRADE_OPT: /* dist-upgrade */
- global_config->dist_upgrade = 1;
+ global_config->dist_upgrade = TRUE;
do_action = UPGRADE;
break;
case HELP_OPT: /* help */
usage();
exit(1);
case IGNORE_DEP_OPT: /* ignore-dep */
- global_config->ignore_dep = 1;
+ global_config->ignore_dep = TRUE;
break;
case NO_DEP_OPT: /* no-dep */
- global_config->disable_dep_check = 1;
+ global_config->disable_dep_check = TRUE;
break;
case PRINT_URIS_OPT: /* print-uris */
- global_config->print_uris = 1;
+ global_config->print_uris = TRUE;
break;
case SHOW_STATS_OPT: /* download-stats */
- global_config->dl_stats = 1;
+ global_config->dl_stats = TRUE;
break;
case CONFIG_OPT: /* override rc location */
{
@@ -174,7 +174,7 @@ int main( int argc, char *argv[] ){
do_action = AUTOCLEAN;
break;
case OBSOLETE_OPT: /* remove obsolete packages */
- global_config->remove_obsolete = 1;
+ global_config->remove_obsolete = TRUE;
break;
default:
usage();
diff --git a/src/package.c b/src/package.c
index 16d9cd9..265cee2 100644
--- a/src/package.c
+++ b/src/package.c
@@ -715,7 +715,7 @@ int is_excluded(const rc_config *global_config,pkg_info_t *pkg){
int name_reg_ret = -1,version_reg_ret = -1,location_reg_ret = -1;
sg_regex exclude_reg;
- if( global_config->ignore_excludes == 1 )
+ if( global_config->ignore_excludes == TRUE )
return pkg_not_excluded;
/* maybe EXCLUDE= isn't defined in our rc? */
@@ -1086,7 +1086,7 @@ int get_pkg_dependencies(const rc_config *global_config,struct pkg_list *avail_p
* don't go any further if the required member is empty
* or disable_dep_check is set
*/
- if( global_config->disable_dep_check == 1 ||
+ if( global_config->disable_dep_check == TRUE ||
strcmp(pkg->required,"") == 0 ||
strcmp(pkg->required," ") == 0 ||
strcmp(pkg->required," ") == 0
@@ -1164,7 +1164,7 @@ int get_pkg_dependencies(const rc_config *global_config,struct pkg_list *avail_p
}
/* if this pkg is excluded */
- if( (is_excluded(global_config,tmp_pkg) == 1) && (global_config->ignore_dep == 0) ){
+ if( (is_excluded(global_config,tmp_pkg) == 1) && (global_config->ignore_dep == FALSE) ){
if( get_exact_pkg(installed_pkgs,tmp_pkg->name,tmp_pkg->version) == NULL ){
printf(_("%s, which is required by %s, is excluded\n"),tmp_pkg->name,pkg->name);
return -1;
@@ -1177,7 +1177,7 @@ int get_pkg_dependencies(const rc_config *global_config,struct pkg_list *avail_p
/* now check to see if tmp_pkg has dependencies */
dep_check_return = get_pkg_dependencies(global_config,avail_pkgs,installed_pkgs,tmp_pkg,deps);
- if( dep_check_return == -1 && global_config->ignore_dep == 0 ){
+ if( dep_check_return == -1 && global_config->ignore_dep == FALSE ){
return -1;
}
@@ -1437,7 +1437,7 @@ static struct pkg_list *required_by(const rc_config *global_config,struct pkg_li
/*
* don't go any further if disable_dep_check is set
*/
- if( global_config->disable_dep_check == 1)
+ if( global_config->disable_dep_check == TRUE)
return required_by_list;
for(i = 0, escaped_ptr = escapedName; i < NAME_LEN && pkg->name[i]; i++){
@@ -1652,12 +1652,12 @@ int update_pkg_cache(const rc_config *global_config){
tmp_pkg_f = fopen(pkg_filename,"r");
available_pkgs = parse_packages_txt(tmp_pkg_f);
}else{
- if( global_config->dl_stats == 1 ) printf("\n");
+ if( global_config->dl_stats == TRUE ) printf("\n");
tmp_pkg_f = fopen(pkg_filename,"w+b");
if( get_mirror_data_from_source(tmp_pkg_f,global_config->dl_stats,global_config->sources.url[i],PKG_LIST) == 0 ){
rewind(tmp_pkg_f); /* make sure we are back at the front of the file */
available_pkgs = parse_packages_txt(tmp_pkg_f);
- if( global_config->dl_stats != 1 ) printf(_("Done\n"));
+ if( global_config->dl_stats == FALSE ) printf(_("Done\n"));
}else{
source_dl_failed = 1;
clear_head_cache(pkg_filename);
@@ -1689,12 +1689,12 @@ int update_pkg_cache(const rc_config *global_config){
tmp_patch_f = fopen(patch_filename,"r");
patch_pkgs = parse_packages_txt(tmp_patch_f);
}else{
- if( global_config->dl_stats == 1 ) printf("\n");
+ if( global_config->dl_stats == TRUE ) printf("\n");
tmp_patch_f = fopen(patch_filename,"w+b");
if( get_mirror_data_from_source(tmp_patch_f,global_config->dl_stats,global_config->sources.url[i],PATCHES_LIST) == 0 ){
rewind(tmp_patch_f); /* make sure we are back at the front of the file */
patch_pkgs = parse_packages_txt(tmp_patch_f);
- if( global_config->dl_stats != 1 ) printf(_("Done\n"));
+ if( global_config->dl_stats == FALSE ) printf(_("Done\n"));
}else{
/* we don't care if the patch fails, for example current doesn't have patches */
/* source_dl_failed = 1; */
@@ -1720,7 +1720,7 @@ int update_pkg_cache(const rc_config *global_config){
printf(_("Cached\n"));
tmp_checksum_f = fopen(checksum_filename,"r");
}else{
- if( global_config->dl_stats == 1 ) printf("\n");
+ if( global_config->dl_stats == TRUE ) printf("\n");
tmp_checksum_f = fopen(checksum_filename,"w+b");
if( get_mirror_data_from_source(
tmp_checksum_f,global_config->dl_stats,global_config->sources.url[i],CHECKSUM_FILE
@@ -1729,7 +1729,7 @@ int update_pkg_cache(const rc_config *global_config){
source_dl_failed = 1;
clear_head_cache(checksum_filename);
}else{
- if( global_config->dl_stats != 1 ) printf(_("Done\n"));
+ if( global_config->dl_stats == FALSE ) printf(_("Done\n"));
}
rewind(tmp_checksum_f); /* make sure we are back at the front of the file */
}
@@ -1949,7 +1949,7 @@ int verify_downloaded_pkg(const rc_config *global_config,pkg_info_t *pkg){
return not_verified;
}
/* if not checking the md5 checksum and the sizes match, assume its good */
- if( global_config->no_md5_check == 1 ) return is_verified;
+ if( global_config->no_md5_check == TRUE ) return is_verified;
/* check to see that we actually have an md5 checksum */
if( strcmp(pkg->md5,"") == 0){
@@ -2068,7 +2068,7 @@ void purge_old_cached_pkgs(const rc_config *global_config,char *dir_name,struct
tmp_pkg = get_exact_pkg(avail_pkgs,tmp_pkg_name,tmp_pkg_version);
if( tmp_pkg == NULL ){
- if(global_config->no_prompt == 1 ){
+ if(global_config->no_prompt == TRUE ){
unlink(file->d_name);
}else{
if( ask_yes_no(_("Delete %s ? [y/N]"), file->d_name) == 1 )
diff --git a/src/transaction.c b/src/transaction.c
index 50e9732..d71ea35 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -127,7 +127,7 @@ int handle_transaction(const rc_config *global_config, transaction_t *tran){
if( tran->upgrade_pkgs->pkg_count > 0 || tran->remove_pkgs->pkg_count > 0 ||
tran->install_pkgs->pkg_count > 0 ){
- if( global_config->download_only == 0 ){
+ if( global_config->download_only == FALSE ){
if( (int)uncompressed_size < 0 ){
printf(_("After unpacking %dK disk space will be freed.\n"),
uncompressed_size * -1
@@ -143,9 +143,9 @@ int handle_transaction(const rc_config *global_config, transaction_t *tran){
/* prompt */
if(
(tran->upgrade_pkgs->pkg_count > 0 || tran->remove_pkgs->pkg_count > 0 ||
- ( tran->install_pkgs->pkg_count > 0 && global_config->dist_upgrade != 0 ) ) &&
- (global_config->no_prompt == 0 && global_config->download_only == 0 &&
- global_config->simulate == 0 && global_config->print_uris == 0 )
+ ( tran->install_pkgs->pkg_count > 0 && global_config->dist_upgrade == TRUE ) ) &&
+ (global_config->no_prompt == FALSE && global_config->download_only == FALSE &&
+ global_config->simulate == FALSE && global_config->print_uris == FALSE )
) {
if( ask_yes_no(_("Do you want to continue? [y/N] ")) != 1 ){
printf(_("Abort.\n"));
@@ -153,7 +153,7 @@ int handle_transaction(const rc_config *global_config, transaction_t *tran){
}
}
- if ( global_config->print_uris == 1 ){
+ if ( global_config->print_uris == TRUE ){
for(i = 0; i < tran->install_pkgs->pkg_count;i++) {
const pkg_info_t *info = tran->install_pkgs->pkgs[i];
const char *location = info->location + strspn(info->location, "./");
@@ -168,7 +168,7 @@ int handle_transaction(const rc_config *global_config, transaction_t *tran){
}
/* if simulate is requested, just show what could happen and return */
- if( global_config->simulate == 1 ){
+ if( global_config->simulate == TRUE ){
for(i = 0; i < tran->install_pkgs->pkg_count;i++){
printf(_("%s-%s is to be installed\n"),
tran->install_pkgs->pkgs[i]->name,tran->install_pkgs->pkgs[i]->version
@@ -200,11 +200,11 @@ int handle_transaction(const rc_config *global_config, transaction_t *tran){
/* run transaction, install, upgrade, and remove */
for(i = 0; i < tran->install_pkgs->pkg_count;i++){
- if( global_config->download_only == 0 )
+ if( global_config->download_only == FALSE )
if( install_pkg(global_config,tran->install_pkgs->pkgs[i]) == -1 ) exit(1);
}
for(i = 0; i < tran->upgrade_pkgs->pkg_count;i++){
- if( global_config->download_only == 0 ){
+ if( global_config->download_only == FALSE ){
if( upgrade_pkg( global_config,
tran->upgrade_pkgs->pkgs[i]->installed,
tran->upgrade_pkgs->pkgs[i]->upgrade
@@ -486,7 +486,7 @@ int add_deps_to_trans(const rc_config *global_config, transaction_t *tran, struc
int dep_return = -1;
struct pkg_list *deps;
- if( global_config->disable_dep_check == 1) return -1;
+ if( global_config->disable_dep_check == TRUE ) return -1;
deps = init_pkg_list();
@@ -494,7 +494,7 @@ int add_deps_to_trans(const rc_config *global_config, transaction_t *tran, struc
/* check to see if there where issues with dep checking */
/* exclude the package if dep check barfed */
- if( (dep_return == -1) && (global_config->ignore_dep == 0) ){
+ if( (dep_return == -1) && (global_config->ignore_dep == FALSE) ){
printf("Excluding %s, use --ignore-dep to override\n",pkg->name);
add_exclude_to_transaction(tran,pkg);
free_pkg_list(deps);