From ca095df52fdbcb7fa1da899ef26d464166b5ad90 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 7 Nov 2012 10:11:06 +0100 Subject: [PATCH] libxbps: some tweaks for struct xbps_state_cb_data. - Renamed args pkgname/version to arg0/arg1 to make them generic. - Update bins with this and make some tweaks in state_cb. Bumped API version. --- bin/xbps-install/state_cb.c | 33 ++++++++++++++++----------------- bin/xbps-reconfigure/main.c | 3 +-- bin/xbps-remove/main.c | 6 +++--- include/xbps_api.h.in | 23 ++++++++++------------- lib/cb_util.c | 10 +++++----- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/bin/xbps-install/state_cb.c b/bin/xbps-install/state_cb.c index b86df78c..5fd3b83c 100644 --- a/bin/xbps-install/state_cb.c +++ b/bin/xbps-install/state_cb.c @@ -61,36 +61,35 @@ state_cb(struct xbps_handle *xhp, printf("[*] Configuring unpacked packages\n"); break; case XBPS_STATE_REPOSYNC: - case XBPS_STATE_DOWNLOAD: + printf("[*] Updating `%s/%s' ...\n", + xscd->arg0, xscd->arg1); + break; case XBPS_STATE_VERIFY: case XBPS_STATE_CONFIG_FILE: if (xscd->desc != NULL) printf("%s\n", xscd->desc); break; case XBPS_STATE_REMOVE: - printf("Removing `%s-%s' ...\n", xscd->pkgname, xscd->version); + printf("Removing `%s-%s' ...\n", xscd->arg0, xscd->arg1); break; case XBPS_STATE_CONFIGURE: - printf("Configuring `%s-%s' ...\n", xscd->pkgname, - xscd->version); + printf("Configuring `%s-%s' ...\n", xscd->arg0, xscd->arg1); break; case XBPS_STATE_REGISTER: case XBPS_STATE_UNREGISTER: /* empty */ break; case XBPS_STATE_UNPACK: - printf("Unpacking `%s-%s' ...\n", xscd->pkgname, xscd->version); + printf("Unpacking `%s-%s' ...\n", xscd->arg0, xscd->arg1); break; case XBPS_STATE_INSTALL: - printf("Installing `%s-%s' ...\n", - xscd->pkgname, xscd->version); + printf("Installing `%s-%s' ...\n", xscd->arg0, xscd->arg1); break; case XBPS_STATE_UPDATE: - pkgd = xbps_find_pkg_dict_installed(xhp, - xscd->pkgname, false); + pkgd = xbps_find_pkg_dict_installed(xhp, xscd->arg0, false); prop_dictionary_get_cstring_nocopy(pkgd, "version", &version); - printf("Updating `%s' (`%s' to `%s') ...\n", xscd->pkgname, - version, xscd->version); + printf("Updating `%s' (`%s' to `%s') ...\n", xscd->arg0, + version, xscd->arg1); break; /* success */ case XBPS_STATE_REMOVE_FILE: @@ -104,26 +103,26 @@ state_cb(struct xbps_handle *xhp, break; case XBPS_STATE_INSTALL_DONE: printf("Installed `%s-%s' successfully.\n", - xscd->pkgname, xscd->version); + xscd->arg0, xscd->arg1); if (syslog_enabled) syslog(LOG_NOTICE, "Installed `%s-%s' successfully " - "(rootdir: %s).", xscd->pkgname, xscd->version, + "(rootdir: %s).", xscd->arg0, xscd->arg1, xhp->rootdir); break; case XBPS_STATE_UPDATE_DONE: printf("Updated `%s' to `%s' successfully.\n", - xscd->pkgname, xscd->version); + xscd->arg0, xscd->arg1); if (syslog_enabled) syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully " - "(rootdir: %s).", xscd->pkgname, xscd->version, + "(rootdir: %s).", xscd->arg0, xscd->arg1, xhp->rootdir); break; case XBPS_STATE_REMOVE_DONE: printf("Removed `%s-%s' successfully.\n", - xscd->pkgname, xscd->version); + xscd->arg0, xscd->arg1); if (syslog_enabled) syslog(LOG_NOTICE, "Removed `%s-%s' successfully " - "(rootdir: %s).", xscd->pkgname, xscd->version, + "(rootdir: %s).", xscd->arg0, xscd->arg1, xhp->rootdir); break; /* errors */ diff --git a/bin/xbps-reconfigure/main.c b/bin/xbps-reconfigure/main.c index 93944dab..c0bafe72 100644 --- a/bin/xbps-reconfigure/main.c +++ b/bin/xbps-reconfigure/main.c @@ -65,8 +65,7 @@ state_cb(struct xbps_handle *xhp, struct xbps_state_cb_data *xscd, void *cbd) switch (xscd->state) { /* notifications */ case XBPS_STATE_CONFIGURE: - printf("Configuring `%s-%s' ...\n", xscd->pkgname, - xscd->version); + printf("Configuring `%s-%s' ...\n", xscd->arg0, xscd->arg1); break; /* errors */ case XBPS_STATE_CONFIGURE_FAIL: diff --git a/bin/xbps-remove/main.c b/bin/xbps-remove/main.c index c5a4cc4c..884848f0 100644 --- a/bin/xbps-remove/main.c +++ b/bin/xbps-remove/main.c @@ -89,7 +89,7 @@ state_cb_rm(struct xbps_handle *xhp, switch (xscd->state) { /* notifications */ case XBPS_STATE_REMOVE: - printf("Removing `%s-%s' ...\n", xscd->pkgname, xscd->version); + printf("Removing `%s-%s' ...\n", xscd->arg0, xscd->arg1); break; /* success */ case XBPS_STATE_REMOVE_FILE: @@ -103,10 +103,10 @@ state_cb_rm(struct xbps_handle *xhp, break; case XBPS_STATE_REMOVE_DONE: printf("Removed `%s-%s' successfully.\n", - xscd->pkgname, xscd->version); + xscd->arg0, xscd->arg1); if (syslog_enabled) syslog(LOG_NOTICE, "Removed `%s-%s' successfully " - "(rootdir: %s).", xscd->pkgname, xscd->version, + "(rootdir: %s).", xscd->arg0, xscd->arg1, xhp->rootdir); break; /* errors */ diff --git a/include/xbps_api.h.in b/include/xbps_api.h.in index 8e58d89c..d5593add 100644 --- a/include/xbps_api.h.in +++ b/include/xbps_api.h.in @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.5" -#define XBPS_API_VERSION "20121026" +#define XBPS_API_VERSION "20121107" #ifndef XBPS_VERSION #define XBPS_VERSION "UNSET" @@ -298,36 +298,33 @@ typedef enum xbps_state { /** * @struct xbps_state_cb_data xbps_api.h "xbps_api.h" * @brief Structure to be passed as argument to the state function callback. + * All members are read-only and set internally by libxbps. */ struct xbps_state_cb_data { /** * @var state * - * Returned xbps state (set internally, read-only). + * Current state. */ xbps_state_t state; /** * @var desc * - * XBPS state string description (set internally, read-only). + * Current state string description. */ const char *desc; /** - * @var pkgname + * @var arg[0-1] * - * Package name string (set internally, read-only). + * State string arguments arg[0-1]. Strings set on these + * variables may change depending on \a state. */ - const char *pkgname; - /** - * @var version - * - * Package version string (set internally, read-only). - */ - const char *version; + const char *arg0; + const char *arg1; /** * @var err * - * XBPS state error value (set internally, read-only). + * Current state error value (set internally, read-only). */ int err; }; diff --git a/lib/cb_util.c b/lib/cb_util.c index a311c286..704b7ae6 100644 --- a/lib/cb_util.c +++ b/lib/cb_util.c @@ -69,8 +69,8 @@ void HIDDEN xbps_set_cb_state(struct xbps_handle *xhp, xbps_state_t state, int err, - const char *pkgname, - const char *version, + const char *arg0, + const char *arg1, const char *fmt, ...) { @@ -84,8 +84,8 @@ xbps_set_cb_state(struct xbps_handle *xhp, xscd.state = state; xscd.err = err; - xscd.pkgname = pkgname; - xscd.version = version; + xscd.arg0 = arg0; + xscd.arg1 = arg1; if (fmt != NULL) { va_start(va, fmt); retval = vasprintf(&buf, fmt, va); @@ -95,7 +95,7 @@ xbps_set_cb_state(struct xbps_handle *xhp, else xscd.desc = buf; } - (*xhp->state_cb)(xhp, &xscd, xhp->fetch_cb_data); + (*xhp->state_cb)(xhp, &xscd, xhp->state_cb_data); if (buf != NULL) free(buf); }