libxbps: require a pointer to xbps_handle in functions that need it.

This removes 2 global vars from lib/initend.c and easier to know
what functions require access to xbps_handle.
This commit is contained in:
Juan RP
2012-06-14 08:22:11 +02:00
parent a3adbcda95
commit 3e9e87fc2a
60 changed files with 1143 additions and 901 deletions

19
lib/external/dewey.c vendored
View File

@ -137,19 +137,12 @@ mkcomponent(arr_t *ap, const char *num)
if (ap->c == ap->size) {
if (ap->size == 0) {
ap->size = 62;
if ((ap->v = malloc(ap->size * sizeof(int))) == NULL) {
xbps_dbg_printf("%s: malloc ENOMEM\n",
__func__);
exit(EXIT_FAILURE);
}
ap->v = malloc(ap->size * sizeof(int));
assert(ap->v != NULL);
} else {
ap->size *= 2;
ap->v = realloc(ap->v, ap->size * sizeof(int));
if (ap->v == NULL) {
xbps_dbg_printf("%s: realloc ENOMEM\n",
__func__);
exit(EXIT_FAILURE);
}
assert(ap->v != NULL);
}
}
if (isdigit((unsigned char)*num)) {
@ -177,10 +170,8 @@ mkcomponent(arr_t *ap, const char *num)
cp = strchr(alphas, tolower((unsigned char)*num));
if (ap->c == ap->size) {
ap->size *= 2;
if ((ap->v = realloc(ap->v, ap->size * sizeof(int))) == NULL) {
xbps_dbg_printf("%s: ENOMEM!\n", __func__);
exit(EXIT_FAILURE);
}
ap->v = realloc(ap->v, ap->size * sizeof(int));
assert(ap->v != NULL);
}
ap->v[ap->c++] = (int)(cp - alphas) + 1;
return 1;

12
lib/external/fexec.c vendored
View File

@ -38,9 +38,8 @@
#include "xbps_api_impl.h"
static int
pfcexec(const char *file, const char **argv)
pfcexec(struct xbps_handle *xhp, const char *file, const char **argv)
{
struct xbps_handle *xhp;
pid_t child;
int status;
@ -53,7 +52,6 @@ pfcexec(const char *file, const char **argv)
*
* It's assumed that cwd is the target rootdir.
*/
xhp = xbps_handle_get();
if (strcmp(xhp->rootdir, "/")) {
if (getuid() == 0 && access("bin/sh", X_OK) == 0) {
if (chroot(xhp->rootdir) == -1)
@ -81,7 +79,7 @@ pfcexec(const char *file, const char **argv)
}
static int
vfcexec(const char *arg, va_list ap)
vfcexec(struct xbps_handle *xhp, const char *arg, va_list ap)
{
const char **argv;
size_t argv_size, argc;
@ -111,20 +109,20 @@ vfcexec(const char *arg, va_list ap)
} while (arg != NULL);
retval = pfcexec(argv[0], argv);
retval = pfcexec(xhp, argv[0], argv);
free(argv);
return retval;
}
int HIDDEN
xbps_file_exec(const char *arg, ...)
xbps_file_exec(struct xbps_handle *xhp, const char *arg, ...)
{
va_list ap;
int result;
va_start(ap, arg);
result = vfcexec(arg, ap);
result = vfcexec(xhp, arg, ap);
va_end(ap);
return result;