diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pacman/conf.c | 2 | ||||
| -rw-r--r-- | src/pacman/package.c | 4 | ||||
| -rw-r--r-- | src/pacman/query.c | 28 | ||||
| -rw-r--r-- | src/pacman/remove.c | 10 | ||||
| -rw-r--r-- | src/pacman/sync.c | 32 | ||||
| -rw-r--r-- | src/pacman/upgrade.c | 6 | ||||
| -rw-r--r-- | src/pacman/util.c | 31 | ||||
| -rw-r--r-- | src/pacman/util.h | 2 | 
8 files changed, 52 insertions, 63 deletions
| diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 761c9a62..2d3009ec 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -45,7 +45,7 @@ config_t *config_new(void)  {  	config_t *newconfig = calloc(1, sizeof(config_t));  	if(!newconfig) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, +			pm_printf(ALPM_LOG_ERROR,  					_("malloc failure: could not allocate %zd bytes\n"),  					sizeof(config_t));  			return NULL; diff --git a/src/pacman/package.c b/src/pacman/package.c index f82be470..d4bbf886 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -187,7 +187,7 @@ static const char *get_backup_file_status(const char *root,  		char *md5sum = alpm_compute_md5sum(path);  		if(md5sum == NULL) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, +			pm_printf(ALPM_LOG_ERROR,  					_("could not calculate checksums for %s\n"), path);  			return NULL;  		} @@ -274,7 +274,7 @@ void dump_pkg_changelog(alpm_pkg_t *pkg)  	void *fp = NULL;  	if((fp = alpm_pkg_changelog_open(pkg)) == NULL) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("no changelog available for '%s'.\n"), +		pm_printf(ALPM_LOG_ERROR, _("no changelog available for '%s'.\n"),  				alpm_pkg_get_name(pkg));  		return;  	} else { diff --git a/src/pacman/query.c b/src/pacman/query.c index f3df9236..4c2ea817 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -118,7 +118,7 @@ static int query_fileowner(alpm_list_t *targets)  	/* This code is here for safety only */  	if(targets == NULL) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("no file was specified for --owns\n")); +		pm_printf(ALPM_LOG_ERROR, _("no file was specified for --owns\n"));  		return 1;  	} @@ -129,7 +129,7 @@ static int query_fileowner(alpm_list_t *targets)  	rootlen = strlen(root);  	if(rootlen + 1 > PATH_MAX) {  		/* we are in trouble here */ -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, ""); +		pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, "");  		return 1;  	}  	strcpy(path, root); @@ -149,14 +149,14 @@ static int query_fileowner(alpm_list_t *targets)  			/*  if it is not a path but a program name, then check in PATH */  			if(strchr(filename, '/') == NULL) {  				if(search_path(&filename, &buf) == -1) { -					pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"), +					pm_printf(ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"),  							filename, strerror(errno));  					ret++;  					free(filename);  					continue;  				}  			} else { -				pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to read file '%s': %s\n"), +				pm_printf(ALPM_LOG_ERROR, _("failed to read file '%s': %s\n"),  						filename, strerror(errno));  				ret++;  				free(filename); @@ -165,7 +165,7 @@ static int query_fileowner(alpm_list_t *targets)  		}  		if(S_ISDIR(buf.st_mode)) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, +			pm_printf(ALPM_LOG_ERROR,  				_("cannot determine ownership of directory '%s'\n"), filename);  			ret++;  			free(filename); @@ -181,7 +181,7 @@ static int query_fileowner(alpm_list_t *targets)  			rpath = resolve_path(dname);  			if(!rpath) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"), +				pm_printf(ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"),  						filename, strerror(errno));  				free(filename);  				free(dname); @@ -215,7 +215,7 @@ static int query_fileowner(alpm_list_t *targets)  				}  				if(rootlen + 1 + strlen(pkgfile) > PATH_MAX) { -					pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, pkgfile); +					pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, pkgfile);  				}  				/* concatenate our file and the root path */  				strcpy(path + rootlen, pkgfile); @@ -232,7 +232,7 @@ static int query_fileowner(alpm_list_t *targets)  			}  		}  		if(!found) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, _("No package owns %s\n"), filename); +			pm_printf(ALPM_LOG_ERROR, _("No package owns %s\n"), filename);  			ret++;  		}  		free(filename); @@ -334,7 +334,7 @@ static int query_group(alpm_list_t *targets)  					}  				}  			} else { -				pm_fprintf(stderr, ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname); +				pm_printf(ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname);  				ret++;  			}  		} @@ -416,7 +416,7 @@ static int check(alpm_pkg_t *pkg)  	rootlen = strlen(root);  	if(rootlen + 1 > PATH_MAX) {  		/* we are in trouble here */ -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, ""); +		pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, "");  		return 1;  	}  	strcpy(f, root); @@ -429,7 +429,7 @@ static int check(alpm_pkg_t *pkg)  		const char *path = file->name;  		if(rootlen + 1 + strlen(path) > PATH_MAX) { -			pm_fprintf(stderr, ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path); +			pm_printf(ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path);  			continue;  		}  		strcpy(f + rootlen, path); @@ -563,16 +563,16 @@ int pacman_query(alpm_list_t *targets)  		if(pkg == NULL) {  			switch(alpm_errno(config->handle)) {  				case ALPM_ERR_PKG_NOT_FOUND: -					pm_fprintf(stderr, ALPM_LOG_ERROR, +					pm_printf(ALPM_LOG_ERROR,  							_("package '%s' was not found\n"), strname);  					if(!config->op_q_isfile && access(strname, R_OK) == 0) { -						pm_fprintf(stderr, ALPM_LOG_WARNING, +						pm_printf(ALPM_LOG_WARNING,  								_("'%s' is a file, you might want to use %s.\n"),  								strname, "-p/--file");  					}  					break;  				default: -					pm_fprintf(stderr, ALPM_LOG_ERROR, +					pm_printf(ALPM_LOG_ERROR,  							_("could not load package '%s': %s\n"), strname,  							alpm_strerror(alpm_errno(config->handle)));  					break; diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 41957fe7..e63b5c42 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -39,7 +39,7 @@ static int remove_target(const char *target)  	if((pkg = alpm_db_get_pkg(db_local, target)) != NULL) {  		if(alpm_remove_pkg(config->handle, pkg) == -1) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target, +			pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target,  					alpm_strerror(alpm_errno(config->handle)));  			return -1;  		} @@ -50,13 +50,13 @@ static int remove_target(const char *target)  		/* fallback to group */  	alpm_group_t *grp = alpm_db_readgroup(db_local, target);  	if(grp == NULL) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': target not found\n", target); +		pm_printf(ALPM_LOG_ERROR, "'%s': target not found\n", target);  		return -1;  	}  	for(p = grp->packages; p; p = alpm_list_next(p)) {  		pkg = p->data;  		if(alpm_remove_pkg(config->handle, pkg) == -1) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target, +			pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target,  					alpm_strerror(alpm_errno(config->handle)));  			return -1;  		} @@ -105,7 +105,7 @@ int pacman_remove(alpm_list_t *targets)  	/* Step 2: prepare the transaction based on its type, targets and flags */  	if(alpm_trans_prepare(config->handle, &data) == -1) {  		enum _alpm_errno_t err = alpm_errno(config->handle); -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), +		pm_printf(ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),  		        alpm_strerror(err));  		switch(err) {  			case ALPM_ERR_PKG_INVALID_ARCH: @@ -166,7 +166,7 @@ int pacman_remove(alpm_list_t *targets)  	}  	if(alpm_trans_commit(config->handle, &data) == -1) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"), +		pm_printf(ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),  		        alpm_strerror(alpm_errno(config->handle)));  		retval = 1;  	} diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 925257ed..cc702031 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -47,7 +47,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)  	dir = opendir(dbpath);  	if(dir == NULL) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("could not access database directory\n")); +		pm_printf(ALPM_LOG_ERROR, _("could not access database directory\n"));  		return 1;  	} @@ -82,7 +82,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)  		len = strlen(path);  		if(S_ISDIR(buf.st_mode) || strcmp(path + len - 3, ".db") != 0) {  			if(rmrf(path)) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, +				pm_printf(ALPM_LOG_ERROR,  					_("could not remove %s\n"), path);  				closedir(dir);  				return 1; @@ -108,7 +108,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)  			}  			if(rmrf(path)) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, +				pm_printf(ALPM_LOG_ERROR,  					_("could not remove %s\n"), path);  				closedir(dir);  				return 1; @@ -188,7 +188,7 @@ static int sync_cleancache(int level)  		struct dirent *ent;  		if(dir == NULL) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, +			pm_printf(ALPM_LOG_ERROR,  					_("could not access cache directory %s\n"), cachedir);  			ret++;  			continue; @@ -292,7 +292,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)  		ret = alpm_db_update((level < 2 ? 0 : 1), db);  		if(ret < 0) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to update %s (%s)\n"), +			pm_printf(ALPM_LOG_ERROR, _("failed to update %s (%s)\n"),  					alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));  		} else if(ret == 1) {  			printf(_(" %s is up to date\n"), alpm_db_get_name(db)); @@ -307,7 +307,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)  	 * expected  	 */  	if(!success) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to synchronize any databases\n")); +		pm_printf(ALPM_LOG_ERROR, _("failed to synchronize any databases\n"));  		trans_init_error();  	}  	return (success > 0); @@ -482,12 +482,12 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)  			}  			if(!founddb) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, +				pm_printf(ALPM_LOG_ERROR,  						_("repository '%s' does not exist\n"), repo);  				ret++;  			}  			if(!foundpkg) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, +				pm_printf(ALPM_LOG_ERROR,  						_("package '%s' was not found\n"), target);  				ret++;  			} @@ -527,7 +527,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)  			}  			if(db == NULL) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, +				pm_printf(ALPM_LOG_ERROR,  					_("repository \"%s\" was not found.\n"),repo);  				alpm_list_free(ls);  				return 1; @@ -607,7 +607,7 @@ static int process_pkg(alpm_pkg_t *pkg)  			pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));  			return 0;  		} else { -			pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg), +			pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),  					alpm_strerror(err));  			return 1;  		} @@ -624,7 +624,7 @@ static int process_group(alpm_list_t *dbs, const char *group)  	int count = alpm_list_count(pkgs);  	if(!count) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("target not found: %s\n"), group); +		pm_printf(ALPM_LOG_ERROR, _("target not found: %s\n"), group);  		return 1;  	} @@ -705,7 +705,7 @@ static int process_target(const char *target)  		dbname = targstring;  		db = get_db(dbname);  		if(!db) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, _("database not found: %s\n"), +			pm_printf(ALPM_LOG_ERROR, _("database not found: %s\n"),  					dbname);  			ret = 1;  			goto cleanup; @@ -721,7 +721,7 @@ static int process_target(const char *target)  cleanup:  	free(targstring);  	if(ret && access(target, R_OK) == 0) { -		pm_fprintf(stderr, ALPM_LOG_WARNING, +		pm_printf(ALPM_LOG_WARNING,  				_("'%s' is a file, did you mean %s instead of %s?\n"),  				target, "-U/--upgrade", "-S/--sync");  	} @@ -750,7 +750,7 @@ static int sync_trans(alpm_list_t *targets)  		printf(_(":: Starting full system upgrade...\n"));  		alpm_logaction(config->handle, "starting full system upgrade\n");  		if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle))); +			pm_printf(ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle)));  			trans_release();  			return 1;  		} @@ -767,7 +767,7 @@ int sync_prepare_execute(void)  	/* Step 2: "compute" the transaction based on targets and flags */  	if(alpm_trans_prepare(config->handle, &data) == -1) {  		enum _alpm_errno_t err = alpm_errno(config->handle); -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), +		pm_printf(ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),  		        alpm_strerror(err));  		switch(err) {  			case ALPM_ERR_PKG_INVALID_ARCH: @@ -836,7 +836,7 @@ int sync_prepare_execute(void)  	if(alpm_trans_commit(config->handle, &data) == -1) {  		enum _alpm_errno_t err = alpm_errno(config->handle); -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"), +		pm_printf(ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),  		        alpm_strerror(err));  		switch(err) {  			case ALPM_ERR_FILE_CONFLICTS: diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 06afde78..0ca6fec8 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -55,7 +55,7 @@ int pacman_upgrade(alpm_list_t *targets)  		if(strstr(i->data, "://")) {  			char *str = alpm_fetch_pkgurl(config->handle, i->data);  			if(str == NULL) { -				pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", +				pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",  						(char *)i->data, alpm_strerror(alpm_errno(config->handle)));  				return 1;  			} else { @@ -77,13 +77,13 @@ int pacman_upgrade(alpm_list_t *targets)  		alpm_pkg_t *pkg;  		if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", +			pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",  					targ, alpm_strerror(alpm_errno(config->handle)));  			trans_release();  			return 1;  		}  		if(alpm_add_pkg(config->handle, pkg) == -1) { -			pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", +			pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",  					targ, alpm_strerror(alpm_errno(config->handle)));  			alpm_pkg_free(pkg);  			trans_release(); diff --git a/src/pacman/util.c b/src/pacman/util.c index f317223e..42f17eac 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -66,7 +66,7 @@ int trans_init(alpm_transflag_t flags, int check_valid)  void trans_init_error(void)  {  	enum _alpm_errno_t err = alpm_errno(config->handle); -	pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"), +	pm_printf(ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"),  			alpm_strerror(err));  	if(err == ALPM_ERR_HANDLE_LOCK) {  		fprintf(stderr, _("  if you're sure a package manager is not already\n" @@ -78,7 +78,7 @@ void trans_init_error(void)  int trans_release(void)  {  	if(alpm_trans_release(config->handle) == -1) { -		pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to release transaction (%s)\n"), +		pm_printf(ALPM_LOG_ERROR, _("failed to release transaction (%s)\n"),  				alpm_strerror(alpm_errno(config->handle)));  		return -1;  	} @@ -631,7 +631,8 @@ int table_display(const char *title, const alpm_list_t *header,  			&widths, &has_data);  	/* return -1 if terminal is not wide enough */  	if(totalwidth > getcols()) { -		fprintf(stderr, _("insufficient columns available for table display\n")); +		pm_printf(ALPM_LOG_WARNING, +				_("insufficient columns available for table display\n"));  		return -1;  	}  	if(!totalwidth || !widths || !has_data) { @@ -789,7 +790,7 @@ void signature_display(const char *title, alpm_siglist_t *siglist)  			ret = pm_asprintf(&sigline, _("%s, %s from \"%s\""),  					status, validity, name);  			if(ret == -1) { -				pm_fprintf(stderr, ALPM_LOG_ERROR,  _("failed to allocate string\n")); +				pm_printf(ALPM_LOG_ERROR,  _("failed to allocate string\n"));  				continue;  			}  			indentprint(sigline, len); @@ -1209,14 +1210,15 @@ static int parseindex(char *s, int *val, int min, int max)  	int n = strtol(s, &endptr, 10);  	if(*endptr == '\0') {  		if(n < min || n > max) { -			fprintf(stderr, _("Invalid value: %d is not between %d and %d\n"), +			pm_printf(ALPM_LOG_ERROR, +					_("invalid value: %d is not between %d and %d\n"),  					n, min, max);  			return -1;  		}  		*val = n;  		return 0;  	} else { -		fprintf(stderr, _("Invalid number: %s\n"), s); +		pm_printf(ALPM_LOG_ERROR, _("invalid number: %s\n"), s);  		return -1;  	}  } @@ -1468,20 +1470,7 @@ int pm_printf(alpm_loglevel_t level, const char *format, ...)  	/* print the message using va_arg list */  	va_start(args, format); -	ret = pm_vfprintf(stdout, level, format, args); -	va_end(args); - -	return ret; -} - -int pm_fprintf(FILE *stream, alpm_loglevel_t level, const char *format, ...) -{ -	int ret; -	va_list args; - -	/* print the message using va_arg list */ -	va_start(args, format); -	ret = pm_vfprintf(stream, level, format, args); +	ret = pm_vfprintf(stderr, level, format, args);  	va_end(args);  	return ret; @@ -1495,7 +1484,7 @@ int pm_asprintf(char **string, const char *format, ...)  	/* print the message using va_arg list */  	va_start(args, format);  	if(vasprintf(string, format, args) == -1) { -		pm_fprintf(stderr, ALPM_LOG_ERROR,  _("failed to allocate string\n")); +		pm_printf(ALPM_LOG_ERROR,  _("failed to allocate string\n"));  		ret = -1;  	}  	va_end(args); diff --git a/src/pacman/util.h b/src/pacman/util.h index dc6995ca..6ec962ff 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -75,8 +75,8 @@ int select_question(int count);  int multiselect_question(char *array, int count);  int yesno(char *fmt, ...);  int noyes(char *fmt, ...); +  int pm_printf(alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,2,3))); -int pm_fprintf(FILE *stream, alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));  int pm_asprintf(char **string, const char *format, ...);  int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));  int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0))); | 
