xbps_handle: remove debug, install_*, syslog_enabled members.

Replaced by definitions that can be set to xbps_handle::flags.
This commit is contained in:
Juan RP
2012-01-22 10:52:35 +01:00
parent c884634a62
commit 791f1d40b2
9 changed files with 70 additions and 69 deletions

View File

@@ -64,20 +64,18 @@ main(int argc, char **argv)
struct sigaction sa;
const char *rootdir, *cachedir, *conffile, *option;
int i, c, flags, rv;
bool yes, debug, reqby_force, force_rm_with_deps, recursive_rm;
bool install_auto, install_manual, show_download_pkglist_url;
bool reinstall;
bool yes, reqby_force, force_rm_with_deps, recursive_rm;
bool reinstall, show_download_pkglist_url;
rootdir = cachedir = conffile = option = NULL;
flags = rv = 0;
reqby_force = yes = force_rm_with_deps = false;
recursive_rm = debug = reinstall = false;
install_auto = install_manual = show_download_pkglist_url = false;
recursive_rm = reinstall = show_download_pkglist_url = false;
while ((c = getopt(argc, argv, "AC:c:dDFfMo:Rr:Vvy")) != -1) {
switch (c) {
case 'A':
install_auto = true;
flags |= XBPS_FLAG_INSTALL_AUTO;
break;
case 'C':
conffile = optarg;
@@ -86,7 +84,7 @@ main(int argc, char **argv)
cachedir = optarg;
break;
case 'd':
debug = true;
flags |= XBPS_FLAG_DEBUG;
break;
case 'D':
show_download_pkglist_url = true;
@@ -100,7 +98,7 @@ main(int argc, char **argv)
flags |= XBPS_FLAG_FORCE_REMOVE_FILES;
break;
case 'M':
install_manual = true;
flags |= XBPS_FLAG_INSTALL_MANUAL;
break;
case 'o':
option = optarg;
@@ -134,7 +132,8 @@ main(int argc, char **argv)
usage();
/* Specifying -A and -M is illegal */
if (install_manual && install_auto) {
if ((flags & XBPS_FLAG_INSTALL_AUTO) &&
(flags & XBPS_FLAG_INSTALL_MANUAL)) {
xbps_error_printf("xbps-bin: -A and -M options cannot be "
"used together!\n");
exit(EXIT_FAILURE);
@@ -144,7 +143,6 @@ main(int argc, char **argv)
* Initialize libxbps.
*/
memset(&xh, 0, sizeof(xh));
xh.debug = debug;
xh.state_cb = state_cb;
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;
@@ -152,8 +150,6 @@ main(int argc, char **argv)
xh.cachedir = cachedir;
xh.conffile = conffile;
xh.flags = flags;
xh.install_reason_manual = install_manual;
xh.install_reason_auto = install_auto;
if (flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb_verbose;
else

View File

@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2011 Juan Romero Pardines.
* Copyright (c) 2011-2012 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,11 +36,14 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
const struct xbps_handle *xhp = xbps_handle_get();
prop_dictionary_t pkgd;
const char *version;
bool syslog_enabled;
(void)cbdata;
if (xhp->syslog_enabled)
if (xhp->flags & XBPS_FLAG_SYSLOG) {
syslog_enabled = true;
openlog("xbps-bin", LOG_CONS, LOG_USER);
}
switch (xscd->state) {
/* notifications */
@@ -101,7 +104,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
case XBPS_STATE_INSTALL_DONE:
printf("Installed `%s-%s' successfully.\n",
xscd->pkgname, xscd->version);
if (xhp->syslog_enabled)
if (syslog_enabled)
syslog(LOG_NOTICE, "Installed `%s-%s' successfully "
"(rootdir: %s).", xscd->pkgname, xscd->version,
xhp->rootdir);
@@ -109,7 +112,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
case XBPS_STATE_UPDATE_DONE:
printf("Updated `%s' to `%s' successfully.\n",
xscd->pkgname, xscd->version);
if (xhp->syslog_enabled)
if (syslog_enabled)
syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully "
"(rootdir: %s).", xscd->pkgname, xscd->version,
xhp->rootdir);
@@ -117,7 +120,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
case XBPS_STATE_REMOVE_DONE:
printf("Removed `%s-%s' successfully.\n",
xscd->pkgname, xscd->version);
if (xhp->syslog_enabled)
if (syslog_enabled)
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
"(rootdir: %s).", xscd->pkgname, xscd->version,
xhp->rootdir);
@@ -134,7 +137,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
case XBPS_STATE_REPOSYNC_FAIL:
case XBPS_STATE_CONFIG_FILE_FAIL:
xbps_error_printf("%s\n", xscd->desc);
if (xhp->syslog_enabled)
if (syslog_enabled)
syslog(LOG_ERR, "%s", xscd->desc);
break;
case XBPS_STATE_REMOVE_FILE_FAIL:
@@ -145,7 +148,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
return;
xbps_error_printf("%s\n", xscd->desc);
if (xhp->syslog_enabled)
if (syslog_enabled)
syslog(LOG_ERR, "%s", xscd->desc);
break;
default:

View File

@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2009-2011 Juan Romero Pardines.
* Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -56,8 +56,7 @@ main(int argc, char **argv)
struct repo_search_data *rsd = NULL;
prop_dictionary_t pkgd;
const char *rootdir, *cachedir, *conffile, *option;
int c, rv = 0;
bool debug = false;
int flags = 0, c, rv = 0;
rootdir = cachedir = conffile = option = NULL;
@@ -70,7 +69,7 @@ main(int argc, char **argv)
cachedir = optarg;
break;
case 'd':
debug = true;
flags |= XBPS_FLAG_DEBUG;
break;
case 'o':
option = optarg;
@@ -98,7 +97,7 @@ main(int argc, char **argv)
* Initialize XBPS subsystems.
*/
memset(&xh, 0, sizeof(xh));
xh.debug = debug;
xh.flags = flags;
xh.state_cb = state_cb;
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;

View File

@@ -118,8 +118,8 @@ main(int argc, char **argv)
struct xferstat xfer;
const char *pkgn, *version, *rootdir = NULL, *confdir = NULL;
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
bool debug = false, in_chroot = false;
int i, c, rv = 0;
bool in_chroot = false;
int flags = 0, i, c, rv = 0;
while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
switch (c) {
@@ -131,7 +131,7 @@ main(int argc, char **argv)
rootdir = optarg;
break;
case 'd':
debug = true;
flags |= XBPS_FLAG_DEBUG;
break;
case 'V':
printf("%s\n", XBPS_RELVER);
@@ -157,7 +157,7 @@ main(int argc, char **argv)
* Initialize libxbps.
*/
memset(&xh, 0, sizeof(xh));
xh.debug = debug;
xh.flags = flags;
xh.fetch_cb = fetch_file_progress_cb;
xh.fetch_cb_data = &xfer;
xh.rootdir = rootdir;