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.
This commit is contained in:
Juan RP 2012-11-07 10:11:06 +01:00
parent 89d892d98f
commit ca095df52f
5 changed files with 35 additions and 40 deletions

View File

@ -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 */

View File

@ -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:

View File

@ -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 */

View File

@ -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;
};

View File

@ -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);
}