Get rid of libfetch and proplib external dependencies.

The list of required external deps is now confuse, libarchive and openssl.

libxbps now includes a wrapper for proplib prefixed with xbps_ rather than prop_.
This commit is contained in:
Juan RP
2013-06-20 10:26:12 +02:00
parent 31efece727
commit 42c0766c00
67 changed files with 3004 additions and 1487 deletions

View File

@@ -59,7 +59,7 @@ static TAILQ_HEAD(xentry_head, xentry) xentry_list =
TAILQ_HEAD_INITIALIZER(xentry_list); TAILQ_HEAD_INITIALIZER(xentry_list);
static uint64_t instsize; static uint64_t instsize;
static prop_dictionary_t pkg_propsd, pkg_filesd; static xbps_dictionary_t pkg_propsd, pkg_filesd;
static const char *destdir; static const char *destdir;
static void __attribute__((noreturn)) static void __attribute__((noreturn))
@@ -122,7 +122,7 @@ die(const char *fmt, ...)
static void static void
process_array(const char *key, const char *val) process_array(const char *key, const char *val)
{ {
prop_array_t array; xbps_array_t array;
char *args, *p = NULL, *saveptr; char *args, *p = NULL, *saveptr;
assert(key); assert(key);
@@ -130,11 +130,11 @@ process_array(const char *key, const char *val)
if (val == NULL) if (val == NULL)
return; return;
array = prop_array_create(); array = xbps_array_create();
assert(array); assert(array);
if (strchr(val, ' ') == NULL) { if (strchr(val, ' ') == NULL) {
prop_array_add_cstring_nocopy(array, val); xbps_array_add_cstring_nocopy(array, val);
goto out; goto out;
} }
@@ -145,29 +145,29 @@ process_array(const char *key, const char *val)
(p = strtok_r(NULL, " ", &saveptr))) { (p = strtok_r(NULL, " ", &saveptr))) {
if (p == NULL) if (p == NULL)
continue; continue;
prop_array_add_cstring(array, p); xbps_array_add_cstring(array, p);
} }
free(args); free(args);
out: out:
prop_dictionary_set(pkg_propsd, key, array); xbps_dictionary_set(pkg_propsd, key, array);
prop_object_release(array); xbps_object_release(array);
} }
static bool static bool
entry_is_conf_file(const char *file) entry_is_conf_file(const char *file)
{ {
prop_array_t a; xbps_array_t a;
const char *curfile; const char *curfile;
unsigned int i; unsigned int i;
assert(file); assert(file);
a = prop_dictionary_get(pkg_propsd, "conf_files"); a = xbps_dictionary_get(pkg_propsd, "conf_files");
if (a == NULL || prop_array_count(a) == 0) if (a == NULL || xbps_array_count(a) == 0)
return false; return false;
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
prop_array_get_cstring_nocopy(a, i, &curfile); xbps_array_get_cstring_nocopy(a, i, &curfile);
if (strcmp(file, curfile) == 0) if (strcmp(file, curfile) == 0)
return true; return true;
} }
@@ -292,13 +292,13 @@ out:
static void static void
process_xentry(const char *key, const char *mutable_files) process_xentry(const char *key, const char *mutable_files)
{ {
prop_array_t a; xbps_array_t a;
prop_dictionary_t d; xbps_dictionary_t d;
struct xentry *xe; struct xentry *xe;
char *p, *saveptr, *args, *tok; char *p, *saveptr, *args, *tok;
bool found = false, mutable_found = false; bool found = false, mutable_found = false;
a = prop_array_create(); a = xbps_array_create();
assert(a); assert(a);
TAILQ_FOREACH_REVERSE(xe, &xentry_list, xentry_head, entries) { TAILQ_FOREACH_REVERSE(xe, &xentry_list, xentry_head, entries) {
@@ -306,7 +306,7 @@ process_xentry(const char *key, const char *mutable_files)
continue; continue;
found = true; found = true;
d = prop_dictionary_create(); d = xbps_dictionary_create();
assert(d); assert(d);
/* sanitize file path */ /* sanitize file path */
p = strchr(xe->file, '.') + 1; p = strchr(xe->file, '.') + 1;
@@ -316,7 +316,7 @@ process_xentry(const char *key, const char *mutable_files)
if (mutable_files) { if (mutable_files) {
if ((strchr(mutable_files, ' ') == NULL) && if ((strchr(mutable_files, ' ') == NULL) &&
(strcmp(mutable_files, p) == 0)) (strcmp(mutable_files, p) == 0))
prop_dictionary_set_bool(d, "mutable", true); xbps_dictionary_set_bool(d, "mutable", true);
else { else {
args = strdup(mutable_files); args = strdup(mutable_files);
assert(args); assert(args);
@@ -329,24 +329,24 @@ process_xentry(const char *key, const char *mutable_files)
} }
free(args); free(args);
if (mutable_found) { if (mutable_found) {
prop_dictionary_set_bool(d, "mutable", xbps_dictionary_set_bool(d, "mutable",
true); true);
mutable_found = false; mutable_found = false;
} }
} }
} }
prop_dictionary_set_cstring(d, "file", p); xbps_dictionary_set_cstring(d, "file", p);
if (xe->target) if (xe->target)
prop_dictionary_set_cstring(d, "target", xe->target); xbps_dictionary_set_cstring(d, "target", xe->target);
else if (xe->hash) else if (xe->hash)
prop_dictionary_set_cstring(d, "sha256", xe->hash); xbps_dictionary_set_cstring(d, "sha256", xe->hash);
prop_array_add(a, d); xbps_array_add(a, d);
prop_object_release(d); xbps_object_release(d);
} }
if (found) if (found)
prop_dictionary_set(pkg_filesd, key, a); xbps_dictionary_set(pkg_filesd, key, a);
prop_object_release(a); xbps_object_release(a);
} }
static void static void
@@ -485,17 +485,17 @@ process_archive(struct archive *ar,
/* /*
* Add the installed-size object. * Add the installed-size object.
*/ */
prop_dictionary_set_uint64(pkg_propsd, "installed_size", instsize); xbps_dictionary_set_uint64(pkg_propsd, "installed_size", instsize);
/* Add props.plist metadata file */ /* Add props.plist metadata file */
xml = prop_dictionary_externalize(pkg_propsd); xml = xbps_dictionary_externalize(pkg_propsd);
assert(xml); assert(xml);
xbps_archive_append_buf(ar, xml, strlen(xml), "./props.plist", xbps_archive_append_buf(ar, xml, strlen(xml), "./props.plist",
0644, "root", "root"); 0644, "root", "root");
free(xml); free(xml);
/* Add files.plist metadata file */ /* Add files.plist metadata file */
xml = prop_dictionary_externalize(pkg_filesd); xml = xbps_dictionary_externalize(pkg_filesd);
assert(xml); assert(xml);
xbps_archive_append_buf(ar, xml, strlen(xml), "./files.plist", xbps_archive_append_buf(ar, xml, strlen(xml), "./files.plist",
0644, "root", "root"); 0644, "root", "root");
@@ -530,7 +530,7 @@ set_build_date(void)
if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", tmp) == 0) if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", tmp) == 0)
die("failed to set build-date object (strftime):"); die("failed to set build-date object (strftime):");
if (!prop_dictionary_set_cstring(pkg_propsd, "build-date", outstr)) if (!xbps_dictionary_set_cstring(pkg_propsd, "build-date", outstr))
die("failed to add build-date object:"); die("failed to add build-date object:");
} }
@@ -687,40 +687,40 @@ main(int argc, char **argv)
/* /*
* Process XBPS_PKGPROPS metadata file. * Process XBPS_PKGPROPS metadata file.
*/ */
pkg_propsd = prop_dictionary_create(); pkg_propsd = xbps_dictionary_create();
assert(pkg_propsd); assert(pkg_propsd);
/* Required properties */ /* Required properties */
prop_dictionary_set_cstring_nocopy(pkg_propsd, "architecture", arch); xbps_dictionary_set_cstring_nocopy(pkg_propsd, "architecture", arch);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "pkgname", pkgname); xbps_dictionary_set_cstring_nocopy(pkg_propsd, "pkgname", pkgname);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "version", version); xbps_dictionary_set_cstring_nocopy(pkg_propsd, "version", version);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "pkgver", pkgver); xbps_dictionary_set_cstring_nocopy(pkg_propsd, "pkgver", pkgver);
prop_dictionary_set_cstring_nocopy(pkg_propsd, "short_desc", desc); xbps_dictionary_set_cstring_nocopy(pkg_propsd, "short_desc", desc);
set_build_date(); set_build_date();
/* Optional properties */ /* Optional properties */
if (homepage) if (homepage)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"homepage", homepage); "homepage", homepage);
if (license) if (license)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"license", license); "license", license);
if (maint) if (maint)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"maintainer", maint); "maintainer", maint);
if (ldesc) if (ldesc)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"long_desc", ldesc); "long_desc", ldesc);
if (bwith) if (bwith)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"packaged-with", bwith); "packaged-with", bwith);
if (srcrevs) if (srcrevs)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"source-revisions", srcrevs); "source-revisions", srcrevs);
if (preserve) if (preserve)
prop_dictionary_set_bool(pkg_propsd, "preserve", true); xbps_dictionary_set_bool(pkg_propsd, "preserve", true);
if (buildopts) if (buildopts)
prop_dictionary_set_cstring_nocopy(pkg_propsd, xbps_dictionary_set_cstring_nocopy(pkg_propsd,
"build-options", buildopts); "build-options", buildopts);
/* Optional arrays */ /* Optional arrays */
@@ -742,7 +742,7 @@ main(int argc, char **argv)
/* /*
* Process XBPS_PKGFILES metadata file. * Process XBPS_PKGFILES metadata file.
*/ */
pkg_filesd = prop_dictionary_create(); pkg_filesd = xbps_dictionary_create();
assert(pkg_filesd); assert(pkg_filesd);
process_destdir(mutable_files); process_destdir(mutable_files);

View File

@@ -117,22 +117,22 @@ usage(void)
} }
static const char * static const char *
convert_proptype_to_string(prop_object_t obj) convert_proptype_to_string(xbps_object_t obj)
{ {
switch (prop_object_type(obj)) { switch (xbps_object_type(obj)) {
case PROP_TYPE_ARRAY: case XBPS_TYPE_ARRAY:
return "array"; return "array";
case PROP_TYPE_BOOL: case XBPS_TYPE_BOOL:
return "bool"; return "bool";
case PROP_TYPE_DICTIONARY: case XBPS_TYPE_DICTIONARY:
return "dictionary"; return "dictionary";
case PROP_TYPE_DICT_KEYSYM: case XBPS_TYPE_DICT_KEYSYM:
return "dictionary key"; return "dictionary key";
case PROP_TYPE_NUMBER: case XBPS_TYPE_NUMBER:
return "integer"; return "integer";
case PROP_TYPE_STRING: case XBPS_TYPE_STRING:
return "string"; return "string";
case PROP_TYPE_DATA: case XBPS_TYPE_DATA:
return "data"; return "data";
default: default:
return NULL; return NULL;
@@ -142,77 +142,77 @@ convert_proptype_to_string(prop_object_t obj)
static void static void
generate_conf_file(void) generate_conf_file(void)
{ {
prop_dictionary_t d, d2; xbps_dictionary_t d, d2;
struct defprops *dfp; struct defprops *dfp;
size_t i; size_t i;
const char *outfile = "xbps-dgraph.conf"; const char *outfile = "xbps-dgraph.conf";
d = prop_dictionary_create(); d = xbps_dictionary_create();
d2 = prop_dictionary_create(); d2 = xbps_dictionary_create();
prop_dictionary_set(d, "graph", d2); xbps_dictionary_set(d, "graph", d2);
prop_object_release(d2); xbps_object_release(d2);
d2 = prop_dictionary_create(); d2 = xbps_dictionary_create();
prop_dictionary_set(d, "edge", d2); xbps_dictionary_set(d, "edge", d2);
prop_object_release(d2); xbps_object_release(d2);
d2 = prop_dictionary_create(); d2 = xbps_dictionary_create();
prop_dictionary_set(d, "node", d2); xbps_dictionary_set(d, "node", d2);
prop_object_release(d2); xbps_object_release(d2);
d2 = prop_dictionary_create(); d2 = xbps_dictionary_create();
prop_dictionary_set(d, "node-sub", d2); xbps_dictionary_set(d, "node-sub", d2);
prop_object_release(d2); xbps_object_release(d2);
for (i = 0; i < __arraycount(dfprops); i++) { for (i = 0; i < __arraycount(dfprops); i++) {
dfp = &dfprops[i]; dfp = &dfprops[i];
d2 = prop_dictionary_get(d, dfp->sect); d2 = xbps_dictionary_get(d, dfp->sect);
prop_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val); xbps_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val);
} }
if (prop_dictionary_externalize_to_file(d, outfile) == false) { if (xbps_dictionary_externalize_to_file(d, outfile) == false) {
prop_object_release(d); xbps_object_release(d);
die("couldn't write conf_file to %s", outfile); die("couldn't write conf_file to %s", outfile);
} }
prop_object_release(d); xbps_object_release(d);
printf("Wrote configuration file: %s\n", _DGRAPH_CFFILE); printf("Wrote configuration file: %s\n", _DGRAPH_CFFILE);
} }
static void static void
write_conf_property_on_stream(FILE *f, write_conf_property_on_stream(FILE *f,
const char *section, const char *section,
prop_dictionary_t confd) xbps_dictionary_t confd)
{ {
prop_array_t allkeys, allkeys2; xbps_array_t allkeys, allkeys2;
prop_dictionary_keysym_t dksym, dksym2; xbps_dictionary_keysym_t dksym, dksym2;
prop_object_t keyobj, keyobj2; xbps_object_t keyobj, keyobj2;
size_t i, x; size_t i, x;
const char *cf_val, *keyname, *keyname2; const char *cf_val, *keyname, *keyname2;
/* /*
* Iterate over the main dictionary. * Iterate over the main dictionary.
*/ */
allkeys = prop_dictionary_all_keys(confd); allkeys = xbps_dictionary_all_keys(confd);
for (i = 0; i < prop_array_count(allkeys); i++) { for (i = 0; i < xbps_array_count(allkeys); i++) {
dksym = prop_array_get(allkeys, i); dksym = xbps_array_get(allkeys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(dksym); keyname = xbps_dictionary_keysym_cstring_nocopy(dksym);
keyobj = prop_dictionary_get_keysym(confd, dksym); keyobj = xbps_dictionary_get_keysym(confd, dksym);
if (strcmp(keyname, section)) if (strcmp(keyname, section))
continue; continue;
/* /*
* Iterate over the dictionary sections [edge/graph/node]. * Iterate over the dictionary sections [edge/graph/node].
*/ */
allkeys2 = prop_dictionary_all_keys(keyobj); allkeys2 = xbps_dictionary_all_keys(keyobj);
for (x = 0; x < prop_array_count(allkeys2); x++) { for (x = 0; x < xbps_array_count(allkeys2); x++) {
dksym2 = prop_array_get(allkeys2, x); dksym2 = xbps_array_get(allkeys2, x);
keyname2 = prop_dictionary_keysym_cstring_nocopy(dksym2); keyname2 = xbps_dictionary_keysym_cstring_nocopy(dksym2);
keyobj2 = prop_dictionary_get_keysym(keyobj, dksym2); keyobj2 = xbps_dictionary_get_keysym(keyobj, dksym2);
cf_val = prop_string_cstring_nocopy(keyobj2); cf_val = xbps_string_cstring_nocopy(keyobj2);
fprintf(f, "%s=\"%s\"", keyname2, cf_val); fprintf(f, "%s=\"%s\"", keyname2, cf_val);
if (x + 1 >= prop_array_count(allkeys2)) if (x + 1 >= xbps_array_count(allkeys2))
continue; continue;
fprintf(f, ","); fprintf(f, ",");
@@ -238,19 +238,19 @@ strip_dashes_from_key(const char *str)
} }
static void static void
parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd, parse_array_in_pkg_dictionary(FILE *f, xbps_dictionary_t plistd,
prop_dictionary_t sub_confd, xbps_dictionary_t sub_confd,
prop_array_t allkeys) xbps_array_t allkeys)
{ {
prop_dictionary_keysym_t dksym; xbps_dictionary_keysym_t dksym;
prop_object_t keyobj, sub_keyobj; xbps_object_t keyobj, sub_keyobj;
unsigned int i, x; unsigned int i, x;
const char *tmpkeyname, *cfprop, *optnodetmp; const char *tmpkeyname, *cfprop, *optnodetmp;
char *optnode, *keyname; char *optnode, *keyname;
for (i = 0; i < prop_array_count(allkeys); i++) { for (i = 0; i < xbps_array_count(allkeys); i++) {
dksym = prop_array_get(allkeys, i); dksym = xbps_array_get(allkeys, i);
tmpkeyname = prop_dictionary_keysym_cstring_nocopy(dksym); tmpkeyname = xbps_dictionary_keysym_cstring_nocopy(dksym);
/* Ignore these objects */ /* Ignore these objects */
if ((strcmp(tmpkeyname, "source-revisions") == 0) || if ((strcmp(tmpkeyname, "source-revisions") == 0) ||
(strcmp(tmpkeyname, "files") == 0) || (strcmp(tmpkeyname, "files") == 0) ||
@@ -259,14 +259,14 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
(strcmp(tmpkeyname, "links") == 0)) (strcmp(tmpkeyname, "links") == 0))
continue; continue;
keyobj = prop_dictionary_get_keysym(plistd, dksym); keyobj = xbps_dictionary_get_keysym(plistd, dksym);
keyname = strip_dashes_from_key(tmpkeyname); keyname = strip_dashes_from_key(tmpkeyname);
optnode = NULL; optnode = NULL;
fprintf(f, " main -> %s [label=\"%s\"];\n", fprintf(f, " main -> %s [label=\"%s\"];\n",
keyname, convert_proptype_to_string(keyobj)); keyname, convert_proptype_to_string(keyobj));
prop_dictionary_get_cstring_nocopy(sub_confd, "opt-style", &cfprop); xbps_dictionary_get_cstring_nocopy(sub_confd, "opt-style", &cfprop);
/* Check if object is optional and fill it in */ /* Check if object is optional and fill it in */
for (x = 0; x < __arraycount(optional_objs); x++) { for (x = 0; x < __arraycount(optional_objs); x++) {
if (strcmp(keyname, optional_objs[x]) == 0) { if (strcmp(keyname, optional_objs[x]) == 0) {
@@ -280,30 +280,30 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
/* /*
* Process array objects. * Process array objects.
*/ */
prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop); xbps_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
if (prop_object_type(keyobj) == PROP_TYPE_ARRAY) { if (xbps_object_type(keyobj) == XBPS_TYPE_ARRAY) {
if (optnodetmp) if (optnodetmp)
fprintf(f, " %s %s];\n", keyname, fprintf(f, " %s %s];\n", keyname,
optnodetmp); optnodetmp);
for (x = 0; x < prop_array_count(keyobj); x++) { for (x = 0; x < xbps_array_count(keyobj); x++) {
sub_keyobj = prop_array_get(keyobj, x); sub_keyobj = xbps_array_get(keyobj, x);
if (prop_object_type(sub_keyobj) == PROP_TYPE_STRING) { if (xbps_object_type(sub_keyobj) == XBPS_TYPE_STRING) {
/* /*
* Process arrays of strings. * Process arrays of strings.
*/ */
fprintf(f, " %s -> %s_%u_string " fprintf(f, " %s -> %s_%u_string "
"[label=\"string\"];\n", "[label=\"string\"];\n",
keyname, keyname, x); keyname, keyname, x);
prop_dictionary_get_cstring_nocopy(sub_confd, xbps_dictionary_get_cstring_nocopy(sub_confd,
"style", &cfprop); "style", &cfprop);
fprintf(f, " %s_%u_string [style=\"%s\",", fprintf(f, " %s_%u_string [style=\"%s\",",
keyname, x, cfprop); keyname, x, cfprop);
prop_dictionary_get_cstring_nocopy(sub_confd, xbps_dictionary_get_cstring_nocopy(sub_confd,
"fillcolor", &cfprop); "fillcolor", &cfprop);
fprintf(f, "fillcolor=\"%s\"," fprintf(f, "fillcolor=\"%s\","
"label=\"%s\"];\n", cfprop, "label=\"%s\"];\n", cfprop,
prop_string_cstring_nocopy(sub_keyobj)); xbps_string_cstring_nocopy(sub_keyobj));
} }
} }
if (optnode) if (optnode)
@@ -319,28 +319,28 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
} else } else
fprintf(f, " %s -> %s_value;\n", keyname, keyname); fprintf(f, " %s -> %s_value;\n", keyname, keyname);
prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop); xbps_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop);
fprintf(f, " %s_value [style=\"%s\",", keyname, cfprop); fprintf(f, " %s_value [style=\"%s\",", keyname, cfprop);
prop_dictionary_get_cstring_nocopy(sub_confd, xbps_dictionary_get_cstring_nocopy(sub_confd,
"fillcolor", &cfprop); "fillcolor", &cfprop);
fprintf(f, "fillcolor=\"%s\"", cfprop); fprintf(f, "fillcolor=\"%s\"", cfprop);
/* /*
* Process all other object types... * Process all other object types...
*/ */
switch (prop_object_type(keyobj)) { switch (xbps_object_type(keyobj)) {
case PROP_TYPE_BOOL: case XBPS_TYPE_BOOL:
fprintf(f, ",label=\"%s\"", fprintf(f, ",label=\"%s\"",
prop_bool_true(keyobj) ? "true" : "false"); xbps_bool_true(keyobj) ? "true" : "false");
break; break;
case PROP_TYPE_DATA: case XBPS_TYPE_DATA:
fprintf(f, ",label=\"%zu bytes\"", prop_data_size(keyobj)); fprintf(f, ",label=\"%zu bytes\"", xbps_data_size(keyobj));
break; break;
case PROP_TYPE_NUMBER: case XBPS_TYPE_NUMBER:
fprintf(f, ",label=\"%"PRIu64" bytes\"", fprintf(f, ",label=\"%"PRIu64" bytes\"",
prop_number_unsigned_integer_value(keyobj)); xbps_number_unsigned_integer_value(keyobj));
break; break;
case PROP_TYPE_STRING: case XBPS_TYPE_STRING:
if (strcmp(keyname, "long_desc") == 0) { if (strcmp(keyname, "long_desc") == 0) {
/* /*
* Do not print this obj, too large! * Do not print this obj, too large!
@@ -348,7 +348,7 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
fprintf(f, ",label=\"...\""); fprintf(f, ",label=\"...\"");
} else { } else {
fprintf(f, ",label=\"%s\"", fprintf(f, ",label=\"%s\"",
prop_string_cstring_nocopy(keyobj)); xbps_string_cstring_nocopy(keyobj));
} }
break; break;
default: default:
@@ -365,15 +365,15 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
static void static void
create_dot_graph(struct xbps_handle *xhp, create_dot_graph(struct xbps_handle *xhp,
FILE *f, FILE *f,
prop_dictionary_t plistd, xbps_dictionary_t plistd,
prop_dictionary_t confd, xbps_dictionary_t confd,
bool revdeps) bool revdeps)
{ {
prop_dictionary_t sub_confd; xbps_dictionary_t sub_confd;
prop_array_t allkeys, rdeps; xbps_array_t allkeys, rdeps;
const char *pkgver, *cfprop; const char *pkgver, *cfprop;
prop_dictionary_get_cstring_nocopy(plistd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(plistd, "pkgver", &pkgver);
/* /*
* Start filling the output file... * Start filling the output file...
@@ -407,11 +407,11 @@ create_dot_graph(struct xbps_handle *xhp,
* Process the node-sub section in config file. * Process the node-sub section in config file.
*/ */
fprintf(f, " main ["); fprintf(f, " main [");
sub_confd = prop_dictionary_get(confd, "node-sub"); sub_confd = xbps_dictionary_get(confd, "node-sub");
prop_dictionary_get_cstring_nocopy(sub_confd, "main-style", &cfprop); xbps_dictionary_get_cstring_nocopy(sub_confd, "main-style", &cfprop);
if (cfprop) if (cfprop)
fprintf(f, "style=%s,", cfprop); fprintf(f, "style=%s,", cfprop);
prop_dictionary_get_cstring_nocopy(sub_confd, "main-fillcolor", &cfprop); xbps_dictionary_get_cstring_nocopy(sub_confd, "main-fillcolor", &cfprop);
if (cfprop) if (cfprop)
fprintf(f, "fillcolor=\"%s\",", cfprop); fprintf(f, "fillcolor=\"%s\",", cfprop);
fprintf(f, "label=\"Dictionary\"];\n"); fprintf(f, "label=\"Dictionary\"];\n");
@@ -422,10 +422,10 @@ create_dot_graph(struct xbps_handle *xhp,
*/ */
if (revdeps) { if (revdeps) {
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver); rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver);
if (prop_array_count(rdeps)) if (xbps_array_count(rdeps))
prop_dictionary_set(plistd, "requiredby", rdeps); xbps_dictionary_set(plistd, "requiredby", rdeps);
} }
allkeys = prop_dictionary_all_keys(plistd); allkeys = xbps_dictionary_all_keys(plistd);
parse_array_in_pkg_dictionary(f, plistd, sub_confd, allkeys); parse_array_in_pkg_dictionary(f, plistd, sub_confd, allkeys);
/* /*
* Terminate the stream... * Terminate the stream...
@@ -438,7 +438,7 @@ create_dot_graph(struct xbps_handle *xhp,
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
prop_dictionary_t plistd, confd = NULL; xbps_dictionary_t plistd, confd = NULL;
struct xbps_handle xh; struct xbps_handle xh;
FILE *f = NULL; FILE *f = NULL;
char *outfile = NULL; char *outfile = NULL;
@@ -502,7 +502,7 @@ main(int argc, char **argv)
/* /*
* Internalize the configuration file. * Internalize the configuration file.
*/ */
confd = prop_dictionary_internalize_from_zfile(conf_file); confd = xbps_dictionary_internalize_from_zfile(conf_file);
if (confd == NULL) if (confd == NULL)
die("cannot read conf file `%s'", conf_file); die("cannot read conf file `%s'", conf_file);

View File

@@ -34,7 +34,7 @@
void void
state_cb(struct xbps_state_cb_data *xscd, void *cbdata) state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *instver, *newver; const char *instver, *newver;
char *pkgname; char *pkgname;
bool syslog_enabled = false; bool syslog_enabled = false;
@@ -90,7 +90,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
assert(pkgname); assert(pkgname);
newver = xbps_pkg_version(xscd->arg); newver = xbps_pkg_version(xscd->arg);
pkgd = xbps_pkgdb_get_pkg(xscd->xhp, pkgname); pkgd = xbps_pkgdb_get_pkg(xscd->xhp, pkgname);
prop_dictionary_get_cstring_nocopy(pkgd, "version", &instver); xbps_dictionary_get_cstring_nocopy(pkgd, "version", &instver);
printf("%s-%s: updating to %s ...\n", pkgname, instver, newver); printf("%s-%s: updating to %s ...\n", pkgname, instver, newver);
free(pkgname); free(pkgname);
break; break;

View File

@@ -37,8 +37,8 @@
#include "defs.h" #include "defs.h"
struct transaction { struct transaction {
prop_dictionary_t d; xbps_dictionary_t d;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
uint32_t inst_pkgcnt; uint32_t inst_pkgcnt;
uint32_t up_pkgcnt; uint32_t up_pkgcnt;
uint32_t cf_pkgcnt; uint32_t cf_pkgcnt;
@@ -46,45 +46,45 @@ struct transaction {
}; };
static void static void
show_missing_deps(prop_array_t a) show_missing_deps(xbps_array_t a)
{ {
unsigned int i; unsigned int i;
const char *str; const char *str;
fprintf(stderr, "Unable to locate some required packages:\n"); fprintf(stderr, "Unable to locate some required packages:\n");
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
prop_array_get_cstring_nocopy(a, i, &str); xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, " %s\n", str); fprintf(stderr, " %s\n", str);
} }
} }
static void static void
show_conflicts(prop_array_t a) show_conflicts(xbps_array_t a)
{ {
unsigned int i; unsigned int i;
const char *str; const char *str;
fprintf(stderr, "Conflicting packages were found:\n"); fprintf(stderr, "Conflicting packages were found:\n");
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
prop_array_get_cstring_nocopy(a, i, &str); xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, " %s\n", str); fprintf(stderr, " %s\n", str);
} }
} }
static void static void
show_actions(prop_object_iterator_t iter) show_actions(xbps_object_iterator_t iter)
{ {
prop_object_t obj; xbps_object_t obj;
const char *repoloc, *trans, *pkgver, *arch; const char *repoloc, *trans, *pkgver, *arch;
repoloc = trans = pkgver = arch = NULL; repoloc = trans = pkgver = arch = NULL;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s %s", pkgver, trans); printf("%s %s", pkgver, trans);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
if (repoloc && arch) if (repoloc && arch)
printf(" %s %s", arch, repoloc); printf(" %s %s", arch, repoloc);
@@ -93,19 +93,19 @@ show_actions(prop_object_iterator_t iter)
} }
static void static void
show_package_list(prop_object_iterator_t iter, const char *match, int cols) show_package_list(xbps_object_iterator_t iter, const char *match, int cols)
{ {
prop_object_t obj; xbps_object_t obj;
const char *pkgver, *tract; const char *pkgver, *tract;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
if (strcmp(match, tract)) if (strcmp(match, tract))
continue; continue;
print_package_line(pkgver, cols, false); print_package_line(pkgver, cols, false);
} }
prop_object_iterator_reset(iter); xbps_object_iterator_reset(iter);
print_package_line(NULL, cols, true); print_package_line(NULL, cols, true);
} }
@@ -118,28 +118,28 @@ show_transaction_sizes(struct transaction *trans, int cols)
/* /*
* Show the list of packages that will be installed. * Show the list of packages that will be installed.
*/ */
if (prop_dictionary_get_uint32(trans->d, "total-install-pkgs", if (xbps_dictionary_get_uint32(trans->d, "total-install-pkgs",
&trans->inst_pkgcnt)) { &trans->inst_pkgcnt)) {
printf("%u package%s will be installed:\n", printf("%u package%s will be installed:\n",
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s"); trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
show_package_list(trans->iter, "install", cols); show_package_list(trans->iter, "install", cols);
printf("\n"); printf("\n");
} }
if (prop_dictionary_get_uint32(trans->d, "total-update-pkgs", if (xbps_dictionary_get_uint32(trans->d, "total-update-pkgs",
&trans->up_pkgcnt)) { &trans->up_pkgcnt)) {
printf("%u package%s will be updated:\n", printf("%u package%s will be updated:\n",
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s"); trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
show_package_list(trans->iter, "update", cols); show_package_list(trans->iter, "update", cols);
printf("\n"); printf("\n");
} }
if (prop_dictionary_get_uint32(trans->d, "total-configure-pkgs", if (xbps_dictionary_get_uint32(trans->d, "total-configure-pkgs",
&trans->cf_pkgcnt)) { &trans->cf_pkgcnt)) {
printf("%u package%s will be configured:\n", printf("%u package%s will be configured:\n",
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s"); trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
show_package_list(trans->iter, "configure", cols); show_package_list(trans->iter, "configure", cols);
printf("\n"); printf("\n");
} }
if (prop_dictionary_get_uint32(trans->d, "total-remove-pkgs", if (xbps_dictionary_get_uint32(trans->d, "total-remove-pkgs",
&trans->rm_pkgcnt)) { &trans->rm_pkgcnt)) {
printf("%u package%s will be removed:\n", printf("%u package%s will be removed:\n",
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s"); trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
@@ -149,10 +149,10 @@ show_transaction_sizes(struct transaction *trans, int cols)
/* /*
* Show total download/installed/removed size for all required packages. * Show total download/installed/removed size for all required packages.
*/ */
prop_dictionary_get_uint64(trans->d, "total-download-size", &dlsize); xbps_dictionary_get_uint64(trans->d, "total-download-size", &dlsize);
prop_dictionary_get_uint64(trans->d, "total-installed-size", xbps_dictionary_get_uint64(trans->d, "total-installed-size",
&instsize); &instsize);
prop_dictionary_get_uint64(trans->d, "total-removed-size", &rmsize); xbps_dictionary_get_uint64(trans->d, "total-removed-size", &rmsize);
if (dlsize || instsize || rmsize) if (dlsize || instsize || rmsize)
printf("\n"); printf("\n");
@@ -258,7 +258,7 @@ update_pkg(struct xbps_handle *xhp, const char *pkgname)
int int
exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun) exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
{ {
prop_array_t mdeps, cflicts; xbps_array_t mdeps, cflicts;
struct transaction *trans; struct transaction *trans;
int rv = 0; int rv = 0;
@@ -269,13 +269,13 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
if ((rv = xbps_transaction_prepare(xhp)) != 0) { if ((rv = xbps_transaction_prepare(xhp)) != 0) {
if (rv == ENODEV) { if (rv == ENODEV) {
mdeps = mdeps =
prop_dictionary_get(xhp->transd, "missing_deps"); xbps_dictionary_get(xhp->transd, "missing_deps");
/* missing packages */ /* missing packages */
show_missing_deps(mdeps); show_missing_deps(mdeps);
goto out; goto out;
} else if (rv == EAGAIN) { } else if (rv == EAGAIN) {
/* conflicts */ /* conflicts */
cflicts = prop_dictionary_get(xhp->transd, "conflicts"); cflicts = xbps_dictionary_get(xhp->transd, "conflicts");
show_conflicts(cflicts); show_conflicts(cflicts);
goto out; goto out;
} }
@@ -285,7 +285,7 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
} }
xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n"); xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n");
xbps_dbg_printf_append(xhp, "%s", xbps_dbg_printf_append(xhp, "%s",
prop_dictionary_externalize(xhp->transd)); xbps_dictionary_externalize(xhp->transd));
trans->d = xhp->transd; trans->d = xhp->transd;
trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages"); trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages");
@@ -321,7 +321,7 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
} }
out: out:
if (trans->iter) if (trans->iter)
prop_object_iterator_release(trans->iter); xbps_object_iterator_release(trans->iter);
if (trans) if (trans)
free(trans); free(trans);

View File

@@ -47,23 +47,23 @@ struct thread_data {
static void * static void *
pkgdb_thread_worker(void *arg) pkgdb_thread_worker(void *arg)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_array_t array; xbps_array_t array;
prop_object_t obj; xbps_object_t obj;
struct thread_data *thd = arg; struct thread_data *thd = arg;
const char *pkgver; const char *pkgver;
char *pkgname; char *pkgname;
unsigned int i; unsigned int i;
int rv; int rv;
array = prop_dictionary_all_keys(thd->xhp->pkgdb); array = xbps_dictionary_all_keys(thd->xhp->pkgdb);
assert(array); assert(array);
/* process pkgs from start until end */ /* process pkgs from start until end */
for (i = thd->start; i < thd->end; i++) { for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
pkgd = prop_dictionary_get_keysym(thd->xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(thd->xhp->pkgdb, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
if (thd->xhp->flags & XBPS_FLAG_VERBOSE) if (thd->xhp->flags & XBPS_FLAG_VERBOSE)
printf("Checking %s ...\n", pkgver); printf("Checking %s ...\n", pkgver);
@@ -75,7 +75,7 @@ pkgdb_thread_worker(void *arg)
fprintf(stderr, "pkgdb[%d] failed for %s: %s\n", fprintf(stderr, "pkgdb[%d] failed for %s: %s\n",
thd->thread_num, pkgver, strerror(rv)); thd->thread_num, pkgver, strerror(rv));
} }
prop_object_release(array); xbps_object_release(array);
return NULL; return NULL;
} }
@@ -94,7 +94,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
thd = calloc(maxthreads, sizeof(*thd)); thd = calloc(maxthreads, sizeof(*thd));
assert(thd); assert(thd);
slicecount = prop_dictionary_count(xhp->pkgdb) / maxthreads; slicecount = xbps_dictionary_count(xhp->pkgdb) / maxthreads;
pkgcount = 0; pkgcount = 0;
for (i = 0; i < maxthreads; i++) { for (i = 0; i < maxthreads; i++) {
@@ -102,7 +102,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
thd[i].xhp = xhp; thd[i].xhp = xhp;
thd[i].start = pkgcount; thd[i].start = pkgcount;
if (i + 1 >= maxthreads) if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(xhp->pkgdb); thd[i].end = xbps_dictionary_count(xhp->pkgdb);
else else
thd[i].end = pkgcount + slicecount; thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, pthread_create(&thd[i].thread, NULL,
@@ -124,10 +124,10 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
int int
check_pkg_integrity(struct xbps_handle *xhp, check_pkg_integrity(struct xbps_handle *xhp,
prop_dictionary_t pkgd, xbps_dictionary_t pkgd,
const char *pkgname) const char *pkgname)
{ {
prop_dictionary_t opkgd, propsd; xbps_dictionary_t opkgd, propsd;
const char *sha256; const char *sha256;
char *buf; char *buf;
int rv = 0; int rv = 0;
@@ -147,27 +147,27 @@ check_pkg_integrity(struct xbps_handle *xhp,
* Check for props.plist metadata file. * Check for props.plist metadata file.
*/ */
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
propsd = prop_dictionary_internalize_from_file(buf); propsd = xbps_dictionary_internalize_from_file(buf);
free(buf); free(buf);
if (propsd == NULL) { if (propsd == NULL) {
xbps_error_printf("%s: unexistent metafile!\n", pkgname); xbps_error_printf("%s: unexistent metafile!\n", pkgname);
return EINVAL; return EINVAL;
} else if (prop_dictionary_count(propsd) == 0) { } else if (xbps_dictionary_count(propsd) == 0) {
xbps_error_printf("%s: incomplete metadata file.\n", pkgname); xbps_error_printf("%s: incomplete metadata file.\n", pkgname);
prop_object_release(propsd); xbps_object_release(propsd);
return 1; return 1;
} }
/* /*
* Check pkg metadata signature. * Check pkg metadata signature.
*/ */
prop_dictionary_get_cstring_nocopy(opkgd, "metafile-sha256", &sha256); xbps_dictionary_get_cstring_nocopy(opkgd, "metafile-sha256", &sha256);
if (sha256 != NULL) { if (sha256 != NULL) {
buf = xbps_xasprintf("%s/.%s.plist", buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, pkgname); xhp->metadir, pkgname);
rv = xbps_file_hash_check(buf, sha256); rv = xbps_file_hash_check(buf, sha256);
free(buf); free(buf);
if (rv == ERANGE) { if (rv == ERANGE) {
prop_object_release(propsd); xbps_object_release(propsd);
fprintf(stderr, "%s: metadata file has been " fprintf(stderr, "%s: metadata file has been "
"modified!\n", pkgname); "modified!\n", pkgname);
return 1; return 1;
@@ -190,7 +190,7 @@ do { \
RUN_PKG_CHECK(xhp, rundeps, propsd); RUN_PKG_CHECK(xhp, rundeps, propsd);
RUN_PKG_CHECK(xhp, unneeded, opkgd); RUN_PKG_CHECK(xhp, unneeded, opkgd);
prop_object_release(propsd); xbps_object_release(propsd);
#undef RUN_PKG_CHECK #undef RUN_PKG_CHECK

View File

@@ -48,25 +48,25 @@
int int
check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
{ {
prop_array_t array; xbps_array_t array;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_dictionary_t pkg_filesd = arg; xbps_dictionary_t pkg_filesd = arg;
const char *file, *sha256; const char *file, *sha256;
char *path; char *path;
bool mutable, broken = false, test_broken = false; bool mutable, broken = false, test_broken = false;
int rv; int rv;
array = prop_dictionary_get(pkg_filesd, "files"); array = xbps_dictionary_get(pkg_filesd, "files");
if (array != NULL && prop_array_count(array) > 0) { if (array != NULL && xbps_array_count(array) > 0) {
iter = xbps_array_iter_from_dict(pkg_filesd, "files"); iter = xbps_array_iter_from_dict(pkg_filesd, "files");
if (iter == NULL) if (iter == NULL)
return -1; return -1;
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file); xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file); path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256); "sha256", &sha256);
rv = xbps_file_hash_check(path, sha256); rv = xbps_file_hash_check(path, sha256);
free(path); free(path);
@@ -80,7 +80,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
break; break;
case ERANGE: case ERANGE:
mutable = false; mutable = false;
prop_dictionary_get_bool(obj, xbps_dictionary_get_bool(obj,
"mutable", &mutable); "mutable", &mutable);
if (!mutable) { if (!mutable) {
xbps_error_printf("%s: hash mismatch " xbps_error_printf("%s: hash mismatch "
@@ -95,7 +95,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
break; break;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
} }
if (test_broken) { if (test_broken) {
xbps_error_printf("%s: files check FAILED.\n", pkgname); xbps_error_printf("%s: files check FAILED.\n", pkgname);
@@ -106,14 +106,14 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
/* /*
* Check for missing configuration files. * Check for missing configuration files.
*/ */
array = prop_dictionary_get(pkg_filesd, "conf_files"); array = xbps_dictionary_get(pkg_filesd, "conf_files");
if (array != NULL && prop_array_count(array) > 0) { if (array != NULL && xbps_array_count(array) > 0) {
iter = xbps_array_iter_from_dict(pkg_filesd, "conf_files"); iter = xbps_array_iter_from_dict(pkg_filesd, "conf_files");
if (iter == NULL) if (iter == NULL)
return -1; return -1;
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file); xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file); path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
if (access(path, R_OK) == -1) { if (access(path, R_OK) == -1) {
if (errno == ENOENT) { if (errno == ENOENT) {
@@ -129,7 +129,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
} }
free(path); free(path);
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
} }
if (test_broken) { if (test_broken) {
xbps_error_printf("%s: conf files check FAILED.\n", pkgname); xbps_error_printf("%s: conf files check FAILED.\n", pkgname);

View File

@@ -47,8 +47,8 @@
int int
check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg) check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
{ {
prop_dictionary_t pkg_propsd = arg; xbps_dictionary_t pkg_propsd = arg;
prop_array_t array; xbps_array_t array;
unsigned int i; unsigned int i;
const char *reqpkg; const char *reqpkg;
bool test_broken = false; bool test_broken = false;
@@ -56,9 +56,9 @@ check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
if (!xbps_pkg_has_rundeps(pkg_propsd)) if (!xbps_pkg_has_rundeps(pkg_propsd))
return 0; return 0;
array = prop_dictionary_get(pkg_propsd, "run_depends"); array = xbps_dictionary_get(pkg_propsd, "run_depends");
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
prop_array_get_cstring_nocopy(array, i, &reqpkg); xbps_array_get_cstring_nocopy(array, i, &reqpkg);
if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) { if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) {
xbps_error_printf("%s: dependency not satisfied: %s\n", xbps_error_printf("%s: dependency not satisfied: %s\n",
pkgname, reqpkg); pkgname, reqpkg);

View File

@@ -74,27 +74,27 @@ symlink_target(const char *pkgname, const char *path)
int int
check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg) check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
{ {
prop_array_t array; xbps_array_t array;
prop_object_t obj; xbps_object_t obj;
prop_dictionary_t filesd = arg; xbps_dictionary_t filesd = arg;
unsigned int i; unsigned int i;
const char *file, *tgt = NULL; const char *file, *tgt = NULL;
char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path; char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path;
int rv; int rv;
bool broken = false; bool broken = false;
array = prop_dictionary_get(filesd, "links"); array = xbps_dictionary_get(filesd, "links");
if (array == NULL) if (array == NULL)
return false; return false;
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
if (!prop_dictionary_get_cstring_nocopy(obj, "target", &tgt)) { if (!xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt)) {
xbps_warn_printf("%s: `%s' symlink with " xbps_warn_printf("%s: `%s' symlink with "
"empty target object!\n", pkgname, file); "empty target object!\n", pkgname, file);
continue; continue;
} }
prop_dictionary_get_cstring_nocopy(obj, "file", &file); xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
if (strcmp(tgt, "") == 0) { if (strcmp(tgt, "") == 0) {
xbps_warn_printf("%s: `%s' symlink with " xbps_warn_printf("%s: `%s' symlink with "
"empty target object!\n", pkgname, file); "empty target object!\n", pkgname, file);

View File

@@ -45,19 +45,19 @@
int int
check_pkg_unneeded(struct xbps_handle *xhp, const char *pkgname, void *arg) check_pkg_unneeded(struct xbps_handle *xhp, const char *pkgname, void *arg)
{ {
prop_dictionary_t pkgd = arg; xbps_dictionary_t pkgd = arg;
(void)xhp; (void)xhp;
(void)pkgname; (void)pkgname;
if (prop_dictionary_get(pkgd, "remove-and-update")) if (xbps_dictionary_get(pkgd, "remove-and-update"))
prop_dictionary_remove(pkgd, "remove-and-update"); xbps_dictionary_remove(pkgd, "remove-and-update");
if (prop_dictionary_get(pkgd, "transaction")) if (xbps_dictionary_get(pkgd, "transaction"))
prop_dictionary_remove(pkgd, "transaction"); xbps_dictionary_remove(pkgd, "transaction");
if (prop_dictionary_get(pkgd, "skip-obsoletes")) if (xbps_dictionary_get(pkgd, "skip-obsoletes"))
prop_dictionary_remove(pkgd, "skip-obsoletes"); xbps_dictionary_remove(pkgd, "skip-obsoletes");
return 0; return 0;
} }

View File

@@ -44,8 +44,8 @@
static void static void
pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new) pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
{ {
prop_array_t array, rdeps; xbps_array_t array, rdeps;
prop_dictionary_t pkgdb, pkgd; xbps_dictionary_t pkgdb, pkgd;
unsigned int i; unsigned int i;
char *pkgname, *plist; char *pkgname, *plist;
@@ -61,45 +61,45 @@ pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
array = prop_array_internalize_from_zfile(plist); array = xbps_array_internalize_from_zfile(plist);
if (prop_object_type(array) != PROP_TYPE_ARRAY) { if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
xbps_error_printf("unknown object type for %s\n", xbps_error_printf("unknown object type for %s\n",
plist, strerror(errno)); plist, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
pkgdb = prop_dictionary_create(); pkgdb = xbps_dictionary_create();
assert(pkgdb); assert(pkgdb);
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
pkgd = prop_array_get(array, i); pkgd = xbps_array_get(array, i);
prop_dictionary_get_cstring(pkgd, "pkgname", &pkgname); xbps_dictionary_get_cstring(pkgd, "pkgname", &pkgname);
rdeps = prop_dictionary_get(pkgd, "run_depends"); rdeps = xbps_dictionary_get(pkgd, "run_depends");
/* remove unneeded objs */ /* remove unneeded objs */
prop_dictionary_remove(pkgd, "pkgname"); xbps_dictionary_remove(pkgd, "pkgname");
prop_dictionary_remove(pkgd, "version"); xbps_dictionary_remove(pkgd, "version");
if (prop_array_count(rdeps) == 0) if (xbps_array_count(rdeps) == 0)
prop_dictionary_remove(pkgd, "run_depends"); xbps_dictionary_remove(pkgd, "run_depends");
prop_dictionary_set(pkgdb, pkgname, pkgd); xbps_dictionary_set(pkgdb, pkgname, pkgd);
free(pkgname); free(pkgname);
} }
if (prop_array_count(array) != prop_dictionary_count(pkgdb)) { if (xbps_array_count(array) != xbps_dictionary_count(pkgdb)) {
xbps_error_printf("failed conversion! unmatched obj count " xbps_error_printf("failed conversion! unmatched obj count "
"(got %zu, need %zu)\n", prop_dictionary_count(pkgdb), "(got %zu, need %zu)\n", xbps_dictionary_count(pkgdb),
prop_array_count(array)); xbps_array_count(array));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!prop_dictionary_externalize_to_file(pkgdb, plist_new)) { if (!xbps_dictionary_externalize_to_file(pkgdb, plist_new)) {
xbps_error_printf("failed to write %s: %s\n", xbps_error_printf("failed to write %s: %s\n",
plist_new, strerror(errno)); plist_new, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
prop_object_release(array); xbps_object_release(array);
prop_object_release(pkgdb); xbps_object_release(pkgdb);
free(plist); free(plist);
printf("Conversion to 0.21 pkgdb format successfully\n"); printf("Conversion to 0.21 pkgdb format successfully\n");

View File

@@ -30,7 +30,7 @@
#include <xbps_api.h> #include <xbps_api.h>
/* from check.c */ /* from check.c */
int check_pkg_integrity(struct xbps_handle *, prop_dictionary_t, const char *); int check_pkg_integrity(struct xbps_handle *, xbps_dictionary_t, const char *);
int check_pkg_integrity_all(struct xbps_handle *); int check_pkg_integrity_all(struct xbps_handle *);
#define CHECK_PKG_DECL(type) \ #define CHECK_PKG_DECL(type) \

View File

@@ -57,7 +57,7 @@ change_pkg_instmode(struct xbps_handle *xhp,
const char *pkgname, const char *pkgname,
const char *modestr) const char *modestr)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
bool mode = false; bool mode = false;
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname); pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
@@ -67,7 +67,7 @@ change_pkg_instmode(struct xbps_handle *xhp,
if (strcmp(modestr, "auto") == 0) if (strcmp(modestr, "auto") == 0)
mode = true; mode = true;
prop_dictionary_set_bool(pkgd, "automatic-install", mode); xbps_dictionary_set_bool(pkgd, "automatic-install", mode);
return xbps_pkgdb_update(xhp, true); return xbps_pkgdb_update(xhp, true);
} }

View File

@@ -41,15 +41,15 @@ int repo_show_pkg_deps(struct xbps_handle *, const char *, bool);
int repo_show_pkg_revdeps(struct xbps_handle *, const char *); int repo_show_pkg_revdeps(struct xbps_handle *, const char *);
/* from show-info-files.c */ /* from show-info-files.c */
void show_pkg_info(prop_dictionary_t); void show_pkg_info(xbps_dictionary_t);
void show_pkg_info_one(prop_dictionary_t, const char *); void show_pkg_info_one(xbps_dictionary_t, const char *);
int show_pkg_info_from_metadir(struct xbps_handle *, const char *, int show_pkg_info_from_metadir(struct xbps_handle *, const char *,
const char *); const char *);
int show_pkg_files(prop_dictionary_t); int show_pkg_files(xbps_dictionary_t);
int show_pkg_files_from_metadir(struct xbps_handle *, const char *); int show_pkg_files_from_metadir(struct xbps_handle *, const char *);
int repo_show_pkg_files(struct xbps_handle *, const char *); int repo_show_pkg_files(struct xbps_handle *, const char *);
int repo_show_pkg_info(struct xbps_handle *, const char *, const char *); int repo_show_pkg_info(struct xbps_handle *, const char *, const char *);
int repo_show_pkg_namedesc(struct xbps_handle *, prop_object_t, void *, int repo_show_pkg_namedesc(struct xbps_handle *, xbps_object_t, void *,
bool *); bool *);
/* from ownedby.c */ /* from ownedby.c */
@@ -57,10 +57,10 @@ int ownedby(struct xbps_handle *, int, char **);
int repo_ownedby(struct xbps_handle *, int, char **); int repo_ownedby(struct xbps_handle *, int, char **);
/* From list.c */ /* From list.c */
unsigned int find_longest_pkgver(struct xbps_handle *, prop_object_t); unsigned int find_longest_pkgver(struct xbps_handle *, xbps_object_t);
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *); int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, prop_object_t, void *, bool *); int list_manual_pkgs(struct xbps_handle *, xbps_object_t, void *, bool *);
int list_orphans(struct xbps_handle *); int list_orphans(struct xbps_handle *);
int list_pkgs_pkgdb(struct xbps_handle *); int list_pkgs_pkgdb(struct xbps_handle *);

View File

@@ -40,7 +40,7 @@ struct list_pkgver_cb {
int int
list_pkgs_in_dict(struct xbps_handle *xhp, list_pkgs_in_dict(struct xbps_handle *xhp,
prop_object_t obj, xbps_object_t obj,
void *arg, void *arg,
bool *loop_done) bool *loop_done)
{ {
@@ -53,8 +53,8 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
(void)xhp; (void)xhp;
(void)loop_done; (void)loop_done;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc); xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc);
if (!pkgver || !short_desc) if (!pkgver || !short_desc)
return EINVAL; return EINVAL;
@@ -92,7 +92,7 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
int int
list_manual_pkgs(struct xbps_handle *xhp, list_manual_pkgs(struct xbps_handle *xhp,
prop_object_t obj, xbps_object_t obj,
void *arg, void *arg,
bool *loop_done) bool *loop_done)
{ {
@@ -103,9 +103,9 @@ list_manual_pkgs(struct xbps_handle *xhp,
(void)arg; (void)arg;
(void)loop_done; (void)loop_done;
prop_dictionary_get_bool(obj, "automatic-install", &automatic); xbps_dictionary_get_bool(obj, "automatic-install", &automatic);
if (automatic == false) { if (automatic == false) {
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver); printf("%s\n", pkgver);
} }
@@ -115,24 +115,24 @@ list_manual_pkgs(struct xbps_handle *xhp,
int int
list_orphans(struct xbps_handle *xhp) list_orphans(struct xbps_handle *xhp)
{ {
prop_array_t orphans; xbps_array_t orphans;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_object_t obj; xbps_object_t obj;
const char *pkgver; const char *pkgver;
orphans = xbps_find_pkg_orphans(xhp, NULL); orphans = xbps_find_pkg_orphans(xhp, NULL);
if (orphans == NULL) if (orphans == NULL)
return EINVAL; return EINVAL;
if (prop_array_count(orphans) == 0) if (xbps_array_count(orphans) == 0)
return 0; return 0;
iter = prop_array_iterator(orphans); iter = xbps_array_iterator(orphans);
if (iter == NULL) if (iter == NULL)
return ENOMEM; return ENOMEM;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver); printf("%s\n", pkgver);
} }
@@ -157,7 +157,7 @@ repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done)
(void)done; (void)done;
printf("%s (%u packages)\n", repo->uri, printf("%s (%u packages)\n", repo->uri,
prop_dictionary_count(repo->idx)); xbps_dictionary_count(repo->idx));
return 0; return 0;
} }
@@ -177,30 +177,30 @@ repo_list(struct xbps_handle *xhp)
} }
struct fflongest { struct fflongest {
prop_dictionary_t d; xbps_dictionary_t d;
unsigned int len; unsigned int len;
}; };
static int static int
_find_longest_pkgver_cb(struct xbps_handle *xhp, _find_longest_pkgver_cb(struct xbps_handle *xhp,
prop_object_t obj, xbps_object_t obj,
void *arg, void *arg,
bool *loop_done) bool *loop_done)
{ {
struct fflongest *ffl = arg; struct fflongest *ffl = arg;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *pkgver; const char *pkgver;
unsigned int len; unsigned int len;
(void)xhp; (void)xhp;
(void)loop_done; (void)loop_done;
if (prop_object_type(obj) == PROP_TYPE_DICT_KEYSYM) if (xbps_object_type(obj) == XBPS_TYPE_DICT_KEYSYM)
pkgd = prop_dictionary_get_keysym(ffl->d, obj); pkgd = xbps_dictionary_get_keysym(ffl->d, obj);
else else
pkgd = obj; pkgd = obj;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
len = strlen(pkgver); len = strlen(pkgver);
if (ffl->len == 0 || len > ffl->len) if (ffl->len == 0 || len > ffl->len)
ffl->len = len; ffl->len = len;
@@ -209,20 +209,20 @@ _find_longest_pkgver_cb(struct xbps_handle *xhp,
} }
unsigned int unsigned int
find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o) find_longest_pkgver(struct xbps_handle *xhp, xbps_object_t o)
{ {
struct fflongest ffl; struct fflongest ffl;
ffl.d = o; ffl.d = o;
ffl.len = 0; ffl.len = 0;
if (prop_object_type(o) == PROP_TYPE_DICTIONARY) { if (xbps_object_type(o) == XBPS_TYPE_DICTIONARY) {
prop_array_t array; xbps_array_t array;
array = prop_dictionary_all_keys(o); array = xbps_dictionary_all_keys(o);
(void)xbps_callback_array_iter(xhp, array, (void)xbps_callback_array_iter(xhp, array,
_find_longest_pkgver_cb, &ffl); _find_longest_pkgver_cb, &ffl);
prop_object_release(array); xbps_object_release(array);
} else { } else {
(void)xbps_pkgdb_foreach_cb(xhp, (void)xbps_pkgdb_foreach_cb(xhp,
_find_longest_pkgver_cb, &ffl); _find_longest_pkgver_cb, &ffl);

View File

@@ -42,18 +42,18 @@ struct ffdata {
}; };
static void static void
match_files_by_pattern(prop_dictionary_t pkg_filesd, match_files_by_pattern(xbps_dictionary_t pkg_filesd,
prop_dictionary_keysym_t key, xbps_dictionary_keysym_t key,
struct ffdata *ffd, struct ffdata *ffd,
const char *pkgver) const char *pkgver)
{ {
prop_array_t array; xbps_array_t array;
prop_object_t obj; xbps_object_t obj;
const char *keyname, *filestr, *typestr; const char *keyname, *filestr, *typestr;
unsigned int i; unsigned int i;
int x; int x;
keyname = prop_dictionary_keysym_cstring_nocopy(key); keyname = xbps_dictionary_keysym_cstring_nocopy(key);
if (strcmp(keyname, "files") == 0) if (strcmp(keyname, "files") == 0)
typestr = "regular file"; typestr = "regular file";
@@ -66,10 +66,10 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
else else
return; return;
array = prop_dictionary_get_keysym(pkg_filesd, key); array = xbps_dictionary_get_keysym(pkg_filesd, key);
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr); xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr);
if (filestr == NULL) if (filestr == NULL)
continue; continue;
for (x = 0; x < ffd->npatterns; x++) { for (x = 0; x < ffd->npatterns; x++) {
@@ -82,24 +82,24 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
} }
static int static int
ownedby_pkgdb_cb(struct xbps_handle *xhp, prop_object_t obj, void *arg, bool *done) ownedby_pkgdb_cb(struct xbps_handle *xhp, xbps_object_t obj, void *arg, bool *done)
{ {
prop_dictionary_t pkgmetad; xbps_dictionary_t pkgmetad;
prop_array_t files_keys; xbps_array_t files_keys;
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
unsigned int i; unsigned int i;
const char *pkgver; const char *pkgver;
(void)done; (void)done;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
pkgmetad = xbps_pkgdb_get_pkg_metadata(xhp, pkgver); pkgmetad = xbps_pkgdb_get_pkg_metadata(xhp, pkgver);
assert(pkgmetad); assert(pkgmetad);
files_keys = prop_dictionary_all_keys(pkgmetad); files_keys = xbps_dictionary_all_keys(pkgmetad);
for (i = 0; i < prop_array_count(files_keys); i++) { for (i = 0; i < xbps_array_count(files_keys); i++) {
match_files_by_pattern(pkgmetad, match_files_by_pattern(pkgmetad,
prop_array_get(files_keys, i), ffd, pkgver); xbps_array_get(files_keys, i), ffd, pkgver);
} }
return 0; return 0;
} }
@@ -123,7 +123,7 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
} }
static void static void
repo_match_files_by_pattern(prop_array_t files, repo_match_files_by_pattern(xbps_array_t files,
const char *pkgver, const char *pkgver,
struct ffdata *ffd) struct ffdata *ffd)
{ {
@@ -131,8 +131,8 @@ repo_match_files_by_pattern(prop_array_t files,
unsigned int i; unsigned int i;
int x; int x;
for (i = 0; i < prop_array_count(files); i++) { for (i = 0; i < xbps_array_count(files); i++) {
prop_array_get_cstring_nocopy(files, i, &filestr); xbps_array_get_cstring_nocopy(files, i, &filestr);
for (x = 0; x < ffd->npatterns; x++) { for (x = 0; x < ffd->npatterns; x++) {
if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) { if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) {
printf("%s: %s (%s)\n", printf("%s: %s (%s)\n",
@@ -145,9 +145,9 @@ repo_match_files_by_pattern(prop_array_t files,
static int static int
repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done) repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done)
{ {
prop_array_t allkeys, pkgar; xbps_array_t allkeys, pkgar;
prop_dictionary_t filesd; xbps_dictionary_t filesd;
prop_dictionary_keysym_t ksym; xbps_dictionary_keysym_t ksym;
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
const char *pkgver; const char *pkgver;
unsigned int i; unsigned int i;
@@ -156,12 +156,12 @@ repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done)
filesd = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES); filesd = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
ffd->repouri = repo->uri; ffd->repouri = repo->uri;
allkeys = prop_dictionary_all_keys(filesd); allkeys = xbps_dictionary_all_keys(filesd);
for (i = 0; i < prop_array_count(allkeys); i++) { for (i = 0; i < xbps_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i); ksym = xbps_array_get(allkeys, i);
pkgar = prop_dictionary_get_keysym(filesd, ksym); pkgar = xbps_dictionary_get_keysym(filesd, ksym);
pkgver = prop_dictionary_keysym_cstring_nocopy(ksym); pkgver = xbps_dictionary_keysym_cstring_nocopy(ksym);
repo_match_files_by_pattern(pkgar, pkgver, ffd); repo_match_files_by_pattern(pkgar, pkgver, ffd);
} }

View File

@@ -48,7 +48,7 @@ struct search_data {
int npatterns; int npatterns;
char **patterns; char **patterns;
int maxcols; int maxcols;
prop_array_t results; xbps_array_t results;
}; };
static void static void
@@ -59,16 +59,16 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
unsigned int i, j, tlen = 0, len = 0; unsigned int i, j, tlen = 0, len = 0;
/* Iterate over results array and find out largest pkgver string */ /* Iterate over results array and find out largest pkgver string */
for (i = 0; i < prop_array_count(sd->results); i++) { for (i = 0; i < xbps_array_count(sd->results); i++) {
prop_array_get_cstring_nocopy(sd->results, i, &pkgver); xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
len = strlen(pkgver); len = strlen(pkgver);
if (tlen == 0 || len > tlen) if (tlen == 0 || len > tlen)
tlen = len; tlen = len;
i++; i++;
} }
for (i = 0; i < prop_array_count(sd->results); i++) { for (i = 0; i < xbps_array_count(sd->results); i++) {
prop_array_get_cstring_nocopy(sd->results, i, &pkgver); xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
prop_array_get_cstring_nocopy(sd->results, i+1, &desc); xbps_array_get_cstring_nocopy(sd->results, i+1, &desc);
strncpy(tmp, pkgver, sizeof(tmp)); strncpy(tmp, pkgver, sizeof(tmp));
for (j = strlen(tmp); j < tlen; j++) for (j = strlen(tmp); j < tlen; j++)
tmp[j] = ' '; tmp[j] = ' ';
@@ -98,9 +98,9 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
static int static int
search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done) search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
{ {
prop_array_t allkeys; xbps_array_t allkeys;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_dictionary_keysym_t ksym; xbps_dictionary_keysym_t ksym;
struct search_data *sd = arg; struct search_data *sd = arg;
const char *pkgver, *desc; const char *pkgver, *desc;
unsigned int i; unsigned int i;
@@ -108,13 +108,13 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
(void)done; (void)done;
allkeys = prop_dictionary_all_keys(repo->idx); allkeys = xbps_dictionary_all_keys(repo->idx);
for (i = 0; i < prop_array_count(allkeys); i++) { for (i = 0; i < xbps_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i); ksym = xbps_array_get(allkeys, i);
pkgd = prop_dictionary_get_keysym(repo->idx, ksym); pkgd = xbps_dictionary_get_keysym(repo->idx, ksym);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc); xbps_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc);
for (x = 0; x < sd->npatterns; x++) { for (x = 0; x < sd->npatterns; x++) {
bool vpkgfound = false; bool vpkgfound = false;
@@ -125,12 +125,12 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
if ((xbps_pkgpattern_match(pkgver, sd->patterns[x])) || if ((xbps_pkgpattern_match(pkgver, sd->patterns[x])) ||
(strcasestr(pkgver, sd->patterns[x])) || (strcasestr(pkgver, sd->patterns[x])) ||
(strcasestr(desc, sd->patterns[x])) || vpkgfound) { (strcasestr(desc, sd->patterns[x])) || vpkgfound) {
prop_array_add_cstring_nocopy(sd->results, pkgver); xbps_array_add_cstring_nocopy(sd->results, pkgver);
prop_array_add_cstring_nocopy(sd->results, desc); xbps_array_add_cstring_nocopy(sd->results, desc);
} }
} }
} }
prop_object_release(allkeys); xbps_object_release(allkeys);
return 0; return 0;
} }
@@ -144,7 +144,7 @@ repo_search(struct xbps_handle *xhp, int npatterns, char **patterns)
sd.npatterns = npatterns; sd.npatterns = npatterns;
sd.patterns = patterns; sd.patterns = patterns;
sd.maxcols = get_maxcols(); sd.maxcols = get_maxcols();
sd.results = prop_array_create(); sd.results = xbps_array_create();
rv = xbps_rpool_foreach(xhp, search_pkgs_cb, &sd); rv = xbps_rpool_foreach(xhp, search_pkgs_cb, &sd);
if (rv != 0 && rv != ENOTSUP) if (rv != 0 && rv != ENOTSUP)

View File

@@ -34,11 +34,11 @@
#include "defs.h" #include "defs.h"
static void static void
print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps, print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps,
bool full, bool repo, bool origin, int *indent) bool full, bool repo, bool origin, int *indent)
{ {
prop_array_t currdeps; xbps_array_t currdeps;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *pkgdep; const char *pkgdep;
unsigned int i; unsigned int i;
int j; int j;
@@ -46,8 +46,8 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
if (!origin) if (!origin)
(*indent)++; (*indent)++;
for (i = 0; i < prop_array_count(rdeps); i++) { for (i = 0; i < xbps_array_count(rdeps); i++) {
prop_array_get_cstring_nocopy(rdeps, i, &pkgdep); xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep);
if (!origin || !full) if (!origin || !full)
for (j = 0; j < *indent; j++) for (j = 0; j < *indent; j++)
putchar(' '); putchar(' ');
@@ -66,7 +66,7 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgdep); pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgdep);
} }
if (pkgd != NULL) { if (pkgd != NULL) {
currdeps = prop_dictionary_get(pkgd, "run_depends"); currdeps = xbps_dictionary_get(pkgd, "run_depends");
if (currdeps != NULL) if (currdeps != NULL)
print_rdeps(xhp, currdeps, print_rdeps(xhp, currdeps,
full, repo, false, indent); full, repo, false, indent);
@@ -78,15 +78,15 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
int int
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full) show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full)
{ {
prop_array_t rdeps; xbps_array_t rdeps;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
int indent = 0; int indent = 0;
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname); pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
if (pkgd == NULL) if (pkgd == NULL)
return ENOENT; return ENOENT;
rdeps = prop_dictionary_get(pkgd, "run_depends"); rdeps = xbps_dictionary_get(pkgd, "run_depends");
if (rdeps != NULL) if (rdeps != NULL)
print_rdeps(xhp, rdeps, full, false, true, &indent); print_rdeps(xhp, rdeps, full, false, true, &indent);
@@ -96,13 +96,13 @@ show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full)
int int
show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
prop_array_t reqby; xbps_array_t reqby;
const char *pkgdep; const char *pkgdep;
unsigned int i; unsigned int i;
if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) { if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) {
for (i = 0; i < prop_array_count(reqby); i++) { for (i = 0; i < xbps_array_count(reqby); i++) {
prop_array_get_cstring_nocopy(reqby, i, &pkgdep); xbps_array_get_cstring_nocopy(reqby, i, &pkgdep);
printf("%s\n", pkgdep); printf("%s\n", pkgdep);
} }
} }
@@ -112,15 +112,15 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
int int
repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full) repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
{ {
prop_array_t rdeps; xbps_array_t rdeps;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
int indent = 0; int indent = 0;
if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) && if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL)) ((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
return errno; return errno;
rdeps = prop_dictionary_get(pkgd, "run_depends"); rdeps = xbps_dictionary_get(pkgd, "run_depends");
if (rdeps != NULL) if (rdeps != NULL)
print_rdeps(xhp, rdeps, full, true, true, &indent); print_rdeps(xhp, rdeps, full, true, true, &indent);
@@ -130,7 +130,7 @@ repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
int int
repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
prop_array_t revdeps; xbps_array_t revdeps;
const char *pkgver; const char *pkgver;
unsigned int i; unsigned int i;
int rv; int rv;
@@ -138,8 +138,8 @@ repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
revdeps = xbps_rpool_get_pkg_revdeps(xhp, pkg); revdeps = xbps_rpool_get_pkg_revdeps(xhp, pkg);
rv = errno; rv = errno;
for (i = 0; i < prop_array_count(revdeps); i++) { for (i = 0; i < xbps_array_count(revdeps); i++) {
prop_array_get_cstring_nocopy(revdeps, i, &pkgver); xbps_array_get_cstring_nocopy(revdeps, i, &pkgver);
printf("%s\n", pkgver); printf("%s\n", pkgver);
} }

View File

@@ -37,11 +37,11 @@
#include "defs.h" #include "defs.h"
static void static void
print_value_obj(const char *keyname, prop_object_t obj, print_value_obj(const char *keyname, xbps_object_t obj,
const char *indent, bool raw) const char *indent, bool raw)
{ {
prop_array_t allkeys; xbps_array_t allkeys;
prop_object_t obj2, keysym; xbps_object_t obj2, keysym;
const char *ksymname, *value; const char *ksymname, *value;
unsigned int i; unsigned int i;
char size[8]; char size[8];
@@ -49,34 +49,34 @@ print_value_obj(const char *keyname, prop_object_t obj,
if (indent == NULL) if (indent == NULL)
indent = ""; indent = "";
switch (prop_object_type(obj)) { switch (xbps_object_type(obj)) {
case PROP_TYPE_STRING: case XBPS_TYPE_STRING:
if (!raw) if (!raw)
printf("%s%s: ", indent, keyname); printf("%s%s: ", indent, keyname);
printf("%s\n", prop_string_cstring_nocopy(obj)); printf("%s\n", xbps_string_cstring_nocopy(obj));
break; break;
case PROP_TYPE_NUMBER: case XBPS_TYPE_NUMBER:
if (!raw) if (!raw)
printf("%s%s: ", indent, keyname); printf("%s%s: ", indent, keyname);
if (xbps_humanize_number(size, if (xbps_humanize_number(size,
(int64_t)prop_number_unsigned_integer_value(obj)) == -1) (int64_t)xbps_number_unsigned_integer_value(obj)) == -1)
printf("%ju\n", printf("%ju\n",
prop_number_unsigned_integer_value(obj)); xbps_number_unsigned_integer_value(obj));
else else
printf("%s\n", size); printf("%s\n", size);
break; break;
case PROP_TYPE_BOOL: case XBPS_TYPE_BOOL:
if (!raw) if (!raw)
printf("%s%s: ", indent, keyname); printf("%s%s: ", indent, keyname);
printf("%s\n", prop_bool_true(obj) ? "yes" : "no"); printf("%s\n", xbps_bool_true(obj) ? "yes" : "no");
break; break;
case PROP_TYPE_ARRAY: case XBPS_TYPE_ARRAY:
if (!raw) if (!raw)
printf("%s%s:\n", indent, keyname); printf("%s%s:\n", indent, keyname);
for (i = 0; i < prop_array_count(obj); i++) { for (i = 0; i < xbps_array_count(obj); i++) {
obj2 = prop_array_get(obj, i); obj2 = xbps_array_get(obj, i);
if (prop_object_type(obj2) == PROP_TYPE_STRING) { if (xbps_object_type(obj2) == XBPS_TYPE_STRING) {
value = prop_string_cstring_nocopy(obj2); value = xbps_string_cstring_nocopy(obj2);
printf("%s%s%s\n", indent, !raw ? "\t" : "", printf("%s%s%s\n", indent, !raw ? "\t" : "",
value); value);
} else { } else {
@@ -84,29 +84,29 @@ print_value_obj(const char *keyname, prop_object_t obj,
} }
} }
break; break;
case PROP_TYPE_DICTIONARY: case XBPS_TYPE_DICTIONARY:
allkeys = prop_dictionary_all_keys(obj); allkeys = xbps_dictionary_all_keys(obj);
for (i = 0; i < prop_array_count(allkeys); i++) { for (i = 0; i < xbps_array_count(allkeys); i++) {
keysym = prop_array_get(allkeys, i); keysym = xbps_array_get(allkeys, i);
ksymname = prop_dictionary_keysym_cstring_nocopy(keysym); ksymname = xbps_dictionary_keysym_cstring_nocopy(keysym);
obj2 = prop_dictionary_get_keysym(obj, keysym); obj2 = xbps_dictionary_get_keysym(obj, keysym);
print_value_obj(ksymname, obj2, " ", raw); print_value_obj(ksymname, obj2, " ", raw);
} }
prop_object_release(allkeys); xbps_object_release(allkeys);
if (raw) if (raw)
printf("\n"); printf("\n");
break; break;
case PROP_TYPE_DATA: case XBPS_TYPE_DATA:
if (!raw) { if (!raw) {
xbps_humanize_number(size, (int64_t)prop_data_size(obj)); xbps_humanize_number(size, (int64_t)xbps_data_size(obj));
printf("%s%s: %s\n", indent, keyname, size); printf("%s%s: %s\n", indent, keyname, size);
} else { } else {
FILE *f; FILE *f;
char buf[BUFSIZ-1]; char buf[BUFSIZ-1];
void *data; void *data;
data = prop_data_data(obj); data = xbps_data_data(obj);
f = fmemopen(data, prop_data_size(obj), "r"); f = fmemopen(data, xbps_data_size(obj), "r");
assert(f); assert(f);
while (fgets(buf, BUFSIZ-1, f)) while (fgets(buf, BUFSIZ-1, f))
printf("%s", buf); printf("%s", buf);
@@ -122,13 +122,13 @@ print_value_obj(const char *keyname, prop_object_t obj,
} }
void void
show_pkg_info_one(prop_dictionary_t d, const char *keys) show_pkg_info_one(xbps_dictionary_t d, const char *keys)
{ {
prop_object_t obj; xbps_object_t obj;
char *key, *p, *saveptr; char *key, *p, *saveptr;
if (strchr(keys, ',') == NULL) { if (strchr(keys, ',') == NULL) {
obj = prop_dictionary_get(d, keys); obj = xbps_dictionary_get(d, keys);
if (obj == NULL) if (obj == NULL)
return; return;
print_value_obj(keys, obj, NULL, true); print_value_obj(keys, obj, NULL, true);
@@ -139,7 +139,7 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
abort(); abort();
for ((p = strtok_r(key, ",", &saveptr)); p; for ((p = strtok_r(key, ",", &saveptr)); p;
(p = strtok_r(NULL, ",", &saveptr))) { (p = strtok_r(NULL, ",", &saveptr))) {
obj = prop_dictionary_get(d, p); obj = xbps_dictionary_get(d, p);
if (obj == NULL) if (obj == NULL)
continue; continue;
print_value_obj(p, obj, NULL, true); print_value_obj(p, obj, NULL, true);
@@ -148,9 +148,9 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
} }
static void static void
print_srcrevs(const char *keyname, prop_string_t obj) print_srcrevs(const char *keyname, xbps_string_t obj)
{ {
const char *str = prop_string_cstring_nocopy(obj); const char *str = xbps_string_cstring_nocopy(obj);
unsigned int i; unsigned int i;
/* parse string appending a \t after EOL */ /* parse string appending a \t after EOL */
@@ -165,18 +165,18 @@ print_srcrevs(const char *keyname, prop_string_t obj)
} }
void void
show_pkg_info(prop_dictionary_t dict) show_pkg_info(xbps_dictionary_t dict)
{ {
prop_array_t all_keys; xbps_array_t all_keys;
prop_object_t obj, keysym; xbps_object_t obj, keysym;
const char *keyname; const char *keyname;
unsigned int i; unsigned int i;
all_keys = prop_dictionary_all_keys(dict); all_keys = xbps_dictionary_all_keys(dict);
for (i = 0; i < prop_array_count(all_keys); i++) { for (i = 0; i < xbps_array_count(all_keys); i++) {
keysym = prop_array_get(all_keys, i); keysym = xbps_array_get(all_keys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(keysym); keyname = xbps_dictionary_keysym_cstring_nocopy(keysym);
obj = prop_dictionary_get_keysym(dict, keysym); obj = xbps_dictionary_get_keysym(dict, keysym);
/* ignore objs shown by other targets */ /* ignore objs shown by other targets */
if ((strcmp(keyname, "run_depends") == 0) || if ((strcmp(keyname, "run_depends") == 0) ||
(strcmp(keyname, "files") == 0) || (strcmp(keyname, "files") == 0) ||
@@ -195,37 +195,37 @@ show_pkg_info(prop_dictionary_t dict)
} }
int int
show_pkg_files(prop_dictionary_t filesd) show_pkg_files(xbps_dictionary_t filesd)
{ {
prop_array_t array, allkeys; xbps_array_t array, allkeys;
prop_object_t obj; xbps_object_t obj;
prop_dictionary_keysym_t ksym; xbps_dictionary_keysym_t ksym;
const char *keyname, *file; const char *keyname, *file;
unsigned int i, x; unsigned int i, x;
if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY) if (xbps_object_type(filesd) != XBPS_TYPE_DICTIONARY)
return EINVAL; return EINVAL;
allkeys = prop_dictionary_all_keys(filesd); allkeys = xbps_dictionary_all_keys(filesd);
for (i = 0; i < prop_array_count(allkeys); i++) { for (i = 0; i < xbps_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i); ksym = xbps_array_get(allkeys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(ksym); keyname = xbps_dictionary_keysym_cstring_nocopy(ksym);
if ((strcmp(keyname, "files") && if ((strcmp(keyname, "files") &&
(strcmp(keyname, "conf_files") && (strcmp(keyname, "conf_files") &&
(strcmp(keyname, "links"))))) (strcmp(keyname, "links")))))
continue; continue;
array = prop_dictionary_get(filesd, keyname); array = xbps_dictionary_get(filesd, keyname);
if (array == NULL || prop_array_count(array) == 0) if (array == NULL || xbps_array_count(array) == 0)
continue; continue;
for (x = 0; x < prop_array_count(array); x++) { for (x = 0; x < xbps_array_count(array); x++) {
obj = prop_array_get(array, x); obj = xbps_array_get(array, x);
if (prop_object_type(obj) != PROP_TYPE_DICTIONARY) if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY)
continue; continue;
prop_dictionary_get_cstring_nocopy(obj, "file", &file); xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
printf("%s", file); printf("%s", file);
if (prop_dictionary_get_cstring_nocopy(obj, if (xbps_dictionary_get_cstring_nocopy(obj,
"target", &file)) "target", &file))
printf(" -> %s", file); printf(" -> %s", file);
@@ -241,7 +241,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
const char *pkg, const char *pkg,
const char *option) const char *option)
{ {
prop_dictionary_t d, pkgdb_d; xbps_dictionary_t d, pkgdb_d;
const char *instdate; const char *instdate;
bool autoinst; bool autoinst;
pkg_state_t state; pkg_state_t state;
@@ -254,13 +254,13 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
if (d == NULL) if (d == NULL)
return ENOENT; return ENOENT;
if (prop_dictionary_get_cstring_nocopy(pkgdb_d, if (xbps_dictionary_get_cstring_nocopy(pkgdb_d,
"install-date", &instdate)) "install-date", &instdate))
prop_dictionary_set_cstring_nocopy(d, "install-date", xbps_dictionary_set_cstring_nocopy(d, "install-date",
instdate); instdate);
if (prop_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst)) if (xbps_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst))
prop_dictionary_set_bool(d, "automatic-install", autoinst); xbps_dictionary_set_bool(d, "automatic-install", autoinst);
xbps_pkg_state_dictionary(pkgdb_d, &state); xbps_pkg_state_dictionary(pkgdb_d, &state);
xbps_set_pkg_state_dictionary(d, state); xbps_set_pkg_state_dictionary(d, state);
@@ -276,7 +276,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
int int
show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkg) show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkg)
{ {
prop_dictionary_t d; xbps_dictionary_t d;
int rv = 0; int rv = 0;
d = xbps_pkgdb_get_pkg_metadata(xhp, pkg); d = xbps_pkgdb_get_pkg_metadata(xhp, pkg);
@@ -293,7 +293,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
const char *pattern, const char *pattern,
const char *option) const char *option)
{ {
prop_dictionary_t ipkgd, bpkgd; xbps_dictionary_t ipkgd, bpkgd;
if (((ipkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) && if (((ipkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
((ipkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL)) ((ipkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
@@ -302,10 +302,10 @@ repo_show_pkg_info(struct xbps_handle *xhp,
if ((bpkgd = xbps_repo_get_pkg_plist(xhp, ipkgd, "./props.plist")) == NULL) if ((bpkgd = xbps_repo_get_pkg_plist(xhp, ipkgd, "./props.plist")) == NULL)
return errno; return errno;
prop_dictionary_set(bpkgd, "filename-sha256", xbps_dictionary_set(bpkgd, "filename-sha256",
prop_dictionary_get(ipkgd, "filename-sha256")); xbps_dictionary_get(ipkgd, "filename-sha256"));
prop_dictionary_set(bpkgd, "filename-size", xbps_dictionary_set(bpkgd, "filename-size",
prop_dictionary_get(ipkgd, "filename-size")); xbps_dictionary_get(ipkgd, "filename-size"));
if (option) if (option)
show_pkg_info_one(bpkgd, option); show_pkg_info_one(bpkgd, option);
@@ -318,7 +318,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
int int
repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg) repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "./files.plist"); pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "./files.plist");
if (pkgd == NULL) { if (pkgd == NULL) {

View File

@@ -119,7 +119,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
static int static int
cachedir_clean(struct xbps_handle *xhp) cachedir_clean(struct xbps_handle *xhp)
{ {
prop_dictionary_t pkg_propsd, repo_pkgd; xbps_dictionary_t pkg_propsd, repo_pkgd;
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;
const char *pkgver, *rsha256; const char *pkgver, *rsha256;
@@ -152,14 +152,14 @@ cachedir_clean(struct xbps_handle *xhp)
rv = errno; rv = errno;
break; break;
} }
prop_dictionary_get_cstring_nocopy(pkg_propsd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkg_propsd, "pkgver", &pkgver);
/* /*
* Remove binary pkg if it's not registered in any repository * Remove binary pkg if it's not registered in any repository
* or if hash doesn't match. * or if hash doesn't match.
*/ */
repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver); repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver);
if (repo_pkgd) { if (repo_pkgd) {
prop_dictionary_get_cstring_nocopy(repo_pkgd, xbps_dictionary_get_cstring_nocopy(repo_pkgd,
"filename-sha256", &rsha256); "filename-sha256", &rsha256);
if (xbps_file_hash_check(binpkg, rsha256) == ERANGE) { if (xbps_file_hash_check(binpkg, rsha256) == ERANGE) {
printf("Removed %s from cachedir (sha256 mismatch)\n", printf("Removed %s from cachedir (sha256 mismatch)\n",
@@ -186,7 +186,7 @@ static int
remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols, remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
bool recursive) bool recursive)
{ {
prop_array_t reqby; xbps_array_t reqby;
const char *pkgver; const char *pkgver;
unsigned int x; unsigned int x;
int rv; int rv;
@@ -196,10 +196,10 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
/* pkg has revdeps */ /* pkg has revdeps */
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname);
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n", printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
pkgname, prop_array_count(reqby), pkgname, xbps_array_count(reqby),
prop_array_count(reqby) > 1 ? "S" : ""); xbps_array_count(reqby) > 1 ? "S" : "");
for (x = 0; x < prop_array_count(reqby); x++) { for (x = 0; x < xbps_array_count(reqby); x++) {
prop_array_get_cstring_nocopy(reqby, x, &pkgver); xbps_array_get_cstring_nocopy(reqby, x, &pkgver);
print_package_line(pkgver, cols, false); print_package_line(pkgver, cols, false);
} }
printf("\n\n"); printf("\n\n");

View File

@@ -43,6 +43,6 @@ int remove_obsoletes(struct xbps_handle *, const char *);
/* From repoflush.c */ /* From repoflush.c */
int repodata_flush(struct xbps_handle *, const char *, int repodata_flush(struct xbps_handle *, const char *,
prop_dictionary_t, prop_dictionary_t); xbps_dictionary_t, xbps_dictionary_t);
#endif /* !_XBPS_RINDEX_DEFS_H_ */ #endif /* !_XBPS_RINDEX_DEFS_H_ */

View File

@@ -44,9 +44,9 @@
int int
index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
{ {
prop_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles; xbps_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles;
prop_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd; xbps_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd;
prop_object_t obj, fileobj; xbps_object_t obj, fileobj;
struct xbps_repo *repo; struct xbps_repo *repo;
struct stat st; struct stat st;
const char *oldpkgver, *arch, *oldarch; const char *oldpkgver, *arch, *oldarch;
@@ -72,9 +72,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
idxfiles = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES); idxfiles = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
} }
if (idx == NULL) if (idx == NULL)
idx = prop_dictionary_create(); idx = xbps_dictionary_create();
if (idxfiles == NULL) if (idxfiles == NULL)
idxfiles = prop_dictionary_create(); idxfiles = xbps_dictionary_create();
if (repo != NULL) if (repo != NULL)
xbps_repo_close(repo); xbps_repo_close(repo);
@@ -92,13 +92,13 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
" skipping!\n", XBPS_PKGPROPS, argv[i]); " skipping!\n", XBPS_PKGPROPS, argv[i]);
continue; continue;
} }
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture", xbps_dictionary_get_cstring_nocopy(newpkgd, "architecture",
&arch); &arch);
prop_dictionary_get_cstring(newpkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring(newpkgd, "pkgver", &pkgver);
if (!xbps_pkg_arch_match(xhp, arch, NULL)) { if (!xbps_pkg_arch_match(xhp, arch, NULL)) {
fprintf(stderr, "index: ignoring %s, unmatched " fprintf(stderr, "index: ignoring %s, unmatched "
"arch (%s)\n", pkgver, arch); "arch (%s)\n", pkgver, arch);
prop_object_release(newpkgd); xbps_object_release(newpkgd);
continue; continue;
} }
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
@@ -109,7 +109,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
* than current registered package, update the index; otherwise * than current registered package, update the index; otherwise
* pass to the next one. * pass to the next one.
*/ */
curpkgd = prop_dictionary_get(idx, pkgname); curpkgd = xbps_dictionary_get(idx, pkgname);
if (curpkgd == NULL) { if (curpkgd == NULL) {
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
free(pkgver); free(pkgver);
@@ -118,9 +118,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
} }
} else if (!force) { } else if (!force) {
/* Only check version if !force */ /* Only check version if !force */
prop_dictionary_get_cstring_nocopy(curpkgd, xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &oldpkgver); "pkgver", &oldpkgver);
prop_dictionary_get_cstring_nocopy(curpkgd, xbps_dictionary_get_cstring_nocopy(curpkgd,
"architecture", &oldarch); "architecture", &oldarch);
ret = xbps_cmpver(pkgver, oldpkgver); ret = xbps_cmpver(pkgver, oldpkgver);
if (ret <= 0) { if (ret <= 0) {
@@ -128,7 +128,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
fprintf(stderr, "index: skipping `%s' " fprintf(stderr, "index: skipping `%s' "
"(%s), already registered.\n", "(%s), already registered.\n",
pkgver, arch); pkgver, arch);
prop_object_release(newpkgd); xbps_object_release(newpkgd);
free(pkgver); free(pkgver);
free(pkgname); free(pkgname);
continue; continue;
@@ -138,7 +138,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
* index version. * index version.
*/ */
buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch); buf = xbps_xasprintf("`%s' (%s)", oldpkgver, oldarch);
prop_dictionary_remove(idx, pkgname); xbps_dictionary_remove(idx, pkgname);
printf("index: removed obsolete entry %s.\n", buf); printf("index: removed obsolete entry %s.\n", buf);
free(buf); free(buf);
} }
@@ -151,7 +151,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
free(pkgname); free(pkgname);
return errno; return errno;
} }
if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256", if (!xbps_dictionary_set_cstring(newpkgd, "filename-sha256",
sha256)) { sha256)) {
free(pkgver); free(pkgver);
free(pkgname); free(pkgname);
@@ -165,7 +165,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
return errno; return errno;
} }
if (!prop_dictionary_set_uint64(newpkgd, "filename-size", if (!xbps_dictionary_set_uint64(newpkgd, "filename-size",
(uint64_t)st.st_size)) { (uint64_t)st.st_size)) {
free(pkgver); free(pkgver);
free(pkgname); free(pkgname);
@@ -174,23 +174,23 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
/* /*
* Remove obsolete package objects. * Remove obsolete package objects.
*/ */
prop_dictionary_remove(newpkgd, "archive-compression-type"); xbps_dictionary_remove(newpkgd, "archive-compression-type");
prop_dictionary_remove(newpkgd, "build-date"); xbps_dictionary_remove(newpkgd, "build-date");
prop_dictionary_remove(newpkgd, "build_date"); xbps_dictionary_remove(newpkgd, "build_date");
prop_dictionary_remove(newpkgd, "conf_files"); xbps_dictionary_remove(newpkgd, "conf_files");
prop_dictionary_remove(newpkgd, "filename"); xbps_dictionary_remove(newpkgd, "filename");
prop_dictionary_remove(newpkgd, "homepage"); xbps_dictionary_remove(newpkgd, "homepage");
prop_dictionary_remove(newpkgd, "license"); xbps_dictionary_remove(newpkgd, "license");
prop_dictionary_remove(newpkgd, "maintainer"); xbps_dictionary_remove(newpkgd, "maintainer");
prop_dictionary_remove(newpkgd, "packaged-with"); xbps_dictionary_remove(newpkgd, "packaged-with");
prop_dictionary_remove(newpkgd, "source-revisions"); xbps_dictionary_remove(newpkgd, "source-revisions");
prop_dictionary_remove(newpkgd, "long_desc"); xbps_dictionary_remove(newpkgd, "long_desc");
prop_dictionary_remove(newpkgd, "pkgname"); xbps_dictionary_remove(newpkgd, "pkgname");
prop_dictionary_remove(newpkgd, "version"); xbps_dictionary_remove(newpkgd, "version");
/* /*
* Add new pkg dictionary into the index. * Add new pkg dictionary into the index.
*/ */
if (!prop_dictionary_set(idx, pkgname, newpkgd)) { if (!xbps_dictionary_set(idx, pkgname, newpkgd)) {
free(pkgname); free(pkgname);
return EINVAL; return EINVAL;
} }
@@ -209,68 +209,68 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
} }
/* Find out if binary pkg stored in index contain any file */ /* Find out if binary pkg stored in index contain any file */
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files"); pkg_cffiles = xbps_dictionary_get(newpkgfilesd, "conf_files");
if (prop_array_count(pkg_cffiles)) if (xbps_array_count(pkg_cffiles))
found = true; found = true;
else else
pkg_cffiles = NULL; pkg_cffiles = NULL;
pkg_files = prop_dictionary_get(newpkgfilesd, "files"); pkg_files = xbps_dictionary_get(newpkgfilesd, "files");
if (prop_array_count(pkg_files)) if (xbps_array_count(pkg_files))
found = true; found = true;
else else
pkg_files = NULL; pkg_files = NULL;
pkg_links = prop_dictionary_get(newpkgfilesd, "links"); pkg_links = xbps_dictionary_get(newpkgfilesd, "links");
if (prop_array_count(pkg_links)) if (xbps_array_count(pkg_links))
found = true; found = true;
else else
pkg_links = NULL; pkg_links = NULL;
/* If pkg does not contain any file, ignore it */ /* If pkg does not contain any file, ignore it */
if (!found) { if (!found) {
prop_object_release(newpkgfilesd); xbps_object_release(newpkgfilesd);
prop_object_release(newpkgd); xbps_object_release(newpkgd);
free(pkgver); free(pkgver);
free(pkgname); free(pkgname);
continue; continue;
} }
/* create pkg files array */ /* create pkg files array */
filespkgar = prop_array_create(); filespkgar = xbps_array_create();
assert(filespkgar); assert(filespkgar);
/* add conf_files in pkg files array */ /* add conf_files in pkg files array */
if (pkg_cffiles != NULL) { if (pkg_cffiles != NULL) {
for (x = 0; x < prop_array_count(pkg_cffiles); x++) { for (x = 0; x < xbps_array_count(pkg_cffiles); x++) {
obj = prop_array_get(pkg_cffiles, x); obj = xbps_array_get(pkg_cffiles, x);
fileobj = prop_dictionary_get(obj, "file"); fileobj = xbps_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj); xbps_array_add(filespkgar, fileobj);
} }
} }
/* add files array in pkg array */ /* add files array in pkg array */
if (pkg_files != NULL) { if (pkg_files != NULL) {
for (x = 0; x < prop_array_count(pkg_files); x++) { for (x = 0; x < xbps_array_count(pkg_files); x++) {
obj = prop_array_get(pkg_files, x); obj = xbps_array_get(pkg_files, x);
fileobj = prop_dictionary_get(obj, "file"); fileobj = xbps_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj); xbps_array_add(filespkgar, fileobj);
} }
} }
/* add links array in pkgd */ /* add links array in pkgd */
if (pkg_links != NULL) { if (pkg_links != NULL) {
for (x = 0; x < prop_array_count(pkg_links); x++) { for (x = 0; x < xbps_array_count(pkg_links); x++) {
obj = prop_array_get(pkg_links, x); obj = xbps_array_get(pkg_links, x);
fileobj = prop_dictionary_get(obj, "file"); fileobj = xbps_dictionary_get(obj, "file");
prop_array_add(filespkgar, fileobj); xbps_array_add(filespkgar, fileobj);
} }
} }
prop_object_release(newpkgfilesd); xbps_object_release(newpkgfilesd);
/* add pkg files array into index-files */ /* add pkg files array into index-files */
prop_dictionary_set(idxfiles, pkgver, filespkgar); xbps_dictionary_set(idxfiles, pkgver, filespkgar);
prop_object_release(filespkgar); xbps_object_release(filespkgar);
printf("index-files: added `%s' (%s)\n", pkgver, arch); printf("index-files: added `%s' (%s)\n", pkgver, arch);
prop_object_release(newpkgd); xbps_object_release(newpkgd);
free(pkgver); free(pkgver);
free(pkgname); free(pkgname);
} }
@@ -283,12 +283,12 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
return rv; return rv;
} }
printf("index: %u packages registered.\n", printf("index: %u packages registered.\n",
prop_dictionary_count(idx)); xbps_dictionary_count(idx));
printf("index-files: %u packages registered.\n", printf("index-files: %u packages registered.\n",
prop_dictionary_count(idxfiles)); xbps_dictionary_count(idxfiles));
prop_object_release(idx); xbps_object_release(idx);
prop_object_release(idxfiles); xbps_object_release(idxfiles);
return 0; return 0;
} }

View File

@@ -40,10 +40,10 @@
struct thread_data { struct thread_data {
pthread_t thread; pthread_t thread;
prop_dictionary_t idx; xbps_dictionary_t idx;
prop_dictionary_t idxfiles; xbps_dictionary_t idxfiles;
prop_array_t result; xbps_array_t result;
prop_array_t result_files; xbps_array_t result_files;
struct xbps_handle *xhp; struct xbps_handle *xhp;
unsigned int start; unsigned int start;
unsigned int end; unsigned int end;
@@ -53,22 +53,22 @@ struct thread_data {
static void * static void *
cleaner_thread(void *arg) cleaner_thread(void *arg)
{ {
prop_object_t obj; xbps_object_t obj;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_array_t array; xbps_array_t array;
struct thread_data *thd = arg; struct thread_data *thd = arg;
char *filen; char *filen;
const char *pkgver, *arch, *sha256; const char *pkgver, *arch, *sha256;
unsigned int i; unsigned int i;
/* process pkgs from start until end */ /* process pkgs from start until end */
array = prop_dictionary_all_keys(thd->idx); array = xbps_dictionary_all_keys(thd->idx);
for (i = thd->start; i < thd->end; i++) { for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
pkgd = prop_dictionary_get_keysym(thd->idx, obj); pkgd = xbps_dictionary_get_keysym(thd->idx, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
filen = xbps_xasprintf("%s.%s.xbps", pkgver, arch); filen = xbps_xasprintf("%s.%s.xbps", pkgver, arch);
xbps_dbg_printf(thd->xhp, "thread[%d] checking %s\n", xbps_dbg_printf(thd->xhp, "thread[%d] checking %s\n",
thd->thread_num, pkgver); thd->thread_num, pkgver);
@@ -77,20 +77,20 @@ cleaner_thread(void *arg)
* File cannot be read, might be permissions, * File cannot be read, might be permissions,
* broken or simply unexistent; either way, remove it. * broken or simply unexistent; either way, remove it.
*/ */
prop_array_add_cstring_nocopy(thd->result, pkgver); xbps_array_add_cstring_nocopy(thd->result, pkgver);
free(filen); free(filen);
continue; continue;
} }
/* /*
* File can be read; check its hash. * File can be read; check its hash.
*/ */
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"filename-sha256", &sha256); "filename-sha256", &sha256);
if (xbps_file_hash_check(filen, sha256) != 0) if (xbps_file_hash_check(filen, sha256) != 0)
prop_array_add_cstring_nocopy(thd->result, pkgver); xbps_array_add_cstring_nocopy(thd->result, pkgver);
free(filen); free(filen);
} }
prop_object_release(array); xbps_object_release(array);
return NULL; return NULL;
} }
@@ -98,35 +98,35 @@ cleaner_thread(void *arg)
static void * static void *
cleaner_files_thread(void *arg) cleaner_files_thread(void *arg)
{ {
prop_object_t obj; xbps_object_t obj;
prop_array_t array; xbps_array_t array;
prop_dictionary_t ipkgd; xbps_dictionary_t ipkgd;
struct thread_data *thd = arg; struct thread_data *thd = arg;
const char *pkgver, *ipkgver; const char *pkgver, *ipkgver;
char *pkgname; char *pkgname;
unsigned int i; unsigned int i;
/* process pkgs from start until end */ /* process pkgs from start until end */
array = prop_dictionary_all_keys(thd->idxfiles); array = xbps_dictionary_all_keys(thd->idxfiles);
for (i = thd->start; i < thd->end; i++) { for (i = thd->start; i < thd->end; i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
pkgver = prop_dictionary_keysym_cstring_nocopy(obj); pkgver = xbps_dictionary_keysym_cstring_nocopy(obj);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
ipkgd = prop_dictionary_get(thd->idx, pkgname); ipkgd = xbps_dictionary_get(thd->idx, pkgname);
/* If pkg is not registered in index, remove it */ /* If pkg is not registered in index, remove it */
if (ipkgd == NULL) if (ipkgd == NULL)
prop_array_add_cstring_nocopy(thd->result_files, pkgver); xbps_array_add_cstring_nocopy(thd->result_files, pkgver);
/* if another version is registered in index, remove it */ /* if another version is registered in index, remove it */
else { else {
prop_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver); xbps_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver);
if (strcmp(ipkgver, pkgver)) if (strcmp(ipkgver, pkgver))
prop_array_add_cstring_nocopy(thd->result_files, pkgver); xbps_array_add_cstring_nocopy(thd->result_files, pkgver);
} }
free(pkgname); free(pkgname);
} }
prop_object_release(array); xbps_object_release(array);
return NULL; return NULL;
} }
@@ -140,7 +140,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
{ {
struct xbps_repo *repo; struct xbps_repo *repo;
struct thread_data *thd; struct thread_data *thd;
prop_dictionary_t idx, idxfiles; xbps_dictionary_t idx, idxfiles;
const char *keyname; const char *keyname;
char *pkgname; char *pkgname;
unsigned int x, pkgcount, slicecount; unsigned int x, pkgcount, slicecount;
@@ -171,18 +171,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
thd = calloc(maxthreads, sizeof(*thd)); thd = calloc(maxthreads, sizeof(*thd));
slicecount = prop_dictionary_count(idx) / maxthreads; slicecount = xbps_dictionary_count(idx) / maxthreads;
pkgcount = 0; pkgcount = 0;
/* Setup threads to cleanup index and index-files */ /* Setup threads to cleanup index and index-files */
for (i = 0; i < maxthreads; i++) { for (i = 0; i < maxthreads; i++) {
thd[i].thread_num = i; thd[i].thread_num = i;
thd[i].idx = idx; thd[i].idx = idx;
thd[i].result = prop_array_create(); thd[i].result = xbps_array_create();
thd[i].xhp = xhp; thd[i].xhp = xhp;
thd[i].start = pkgcount; thd[i].start = pkgcount;
if (i + 1 >= maxthreads) if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(idx); thd[i].end = xbps_dictionary_count(idx);
else else
thd[i].end = pkgcount + slicecount; thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]); pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]);
@@ -193,18 +193,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_join(thd[i].thread, NULL); pthread_join(thd[i].thread, NULL);
/* Setup threads to cleanup index-files */ /* Setup threads to cleanup index-files */
slicecount = prop_dictionary_count(idxfiles) / maxthreads; slicecount = xbps_dictionary_count(idxfiles) / maxthreads;
pkgcount = 0; pkgcount = 0;
for (i = 0; i < maxthreads; i++) { for (i = 0; i < maxthreads; i++) {
thd[i].thread_num = i; thd[i].thread_num = i;
thd[i].idx = idx; thd[i].idx = idx;
thd[i].idxfiles = idxfiles; thd[i].idxfiles = idxfiles;
thd[i].result_files = prop_array_create(); thd[i].result_files = xbps_array_create();
thd[i].xhp = xhp; thd[i].xhp = xhp;
thd[i].start = pkgcount; thd[i].start = pkgcount;
if (i + 1 >= maxthreads) if (i + 1 >= maxthreads)
thd[i].end = prop_dictionary_count(idxfiles); thd[i].end = xbps_dictionary_count(idxfiles);
else else
thd[i].end = pkgcount + slicecount; thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_files_thread, &thd[i]); pthread_create(&thd[i].thread, NULL, cleaner_files_thread, &thd[i]);
@@ -215,21 +215,21 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_join(thd[i].thread, NULL); pthread_join(thd[i].thread, NULL);
for (i = 0; i < maxthreads; i++) { for (i = 0; i < maxthreads; i++) {
for (x = 0; x < prop_array_count(thd[i].result); x++) { for (x = 0; x < xbps_array_count(thd[i].result); x++) {
prop_array_get_cstring_nocopy(thd[i].result, xbps_array_get_cstring_nocopy(thd[i].result,
x, &keyname); x, &keyname);
printf("index: removed entry %s\n", keyname); printf("index: removed entry %s\n", keyname);
pkgname = xbps_pkg_name(keyname); pkgname = xbps_pkg_name(keyname);
prop_dictionary_remove(idx, pkgname); xbps_dictionary_remove(idx, pkgname);
prop_dictionary_remove(idxfiles, keyname); xbps_dictionary_remove(idxfiles, keyname);
free(pkgname); free(pkgname);
flush = true; flush = true;
} }
for (x = 0; x < prop_array_count(thd[i].result_files); x++) { for (x = 0; x < xbps_array_count(thd[i].result_files); x++) {
prop_array_get_cstring_nocopy(thd[i].result_files, xbps_array_get_cstring_nocopy(thd[i].result_files,
x, &keyname); x, &keyname);
printf("index-files: removed entry %s\n", keyname); printf("index-files: removed entry %s\n", keyname);
prop_dictionary_remove(idxfiles, keyname); xbps_dictionary_remove(idxfiles, keyname);
flush = true; flush = true;
} }
} }
@@ -239,11 +239,11 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
return rv; return rv;
} }
printf("index: %u packages registered.\n", printf("index: %u packages registered.\n",
prop_dictionary_count(idx)); xbps_dictionary_count(idx));
printf("index-files: %u packages registered.\n", printf("index-files: %u packages registered.\n",
prop_dictionary_count(idxfiles)); xbps_dictionary_count(idxfiles));
prop_object_release(idx); xbps_object_release(idx);
prop_object_release(idxfiles); xbps_object_release(idxfiles);
return rv; return rv;
} }

View File

@@ -39,7 +39,7 @@
struct thread_data { struct thread_data {
pthread_t thread; pthread_t thread;
prop_array_t array; xbps_array_t array;
struct xbps_repo *repo; struct xbps_repo *repo;
unsigned int start; unsigned int start;
unsigned int end; unsigned int end;
@@ -84,7 +84,7 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
static void * static void *
cleaner_thread(void *arg) cleaner_thread(void *arg)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
struct thread_data *thd = arg; struct thread_data *thd = arg;
const char *binpkg, *pkgver, *arch; const char *binpkg, *pkgver, *arch;
unsigned int i; unsigned int i;
@@ -92,21 +92,21 @@ cleaner_thread(void *arg)
/* process pkgs from start until end */ /* process pkgs from start until end */
for (i = thd->start; i < thd->end; i++) { for (i = thd->start; i < thd->end; i++) {
prop_array_get_cstring_nocopy(thd->array, i, &binpkg); xbps_array_get_cstring_nocopy(thd->array, i, &binpkg);
pkgd = xbps_get_pkg_plist_from_binpkg(binpkg, "./props.plist"); pkgd = xbps_get_pkg_plist_from_binpkg(binpkg, "./props.plist");
if (pkgd == NULL) { if (pkgd == NULL) {
rv = remove_pkg(thd->repo->uri, arch, binpkg); rv = remove_pkg(thd->repo->uri, arch, binpkg);
if (rv != 0) { if (rv != 0) {
prop_object_release(pkgd); xbps_object_release(pkgd);
continue; continue;
} }
printf("Removed broken package `%s'.\n", binpkg); printf("Removed broken package `%s'.\n", binpkg);
} }
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
/* ignore pkgs from other archs */ /* ignore pkgs from other archs */
if (!xbps_pkg_arch_match(thd->repo->xhp, arch, NULL)) { if (!xbps_pkg_arch_match(thd->repo->xhp, arch, NULL)) {
prop_object_release(pkgd); xbps_object_release(pkgd);
continue; continue;
} }
xbps_dbg_printf(thd->repo->xhp, "thread[%d] checking %s (%s)\n", xbps_dbg_printf(thd->repo->xhp, "thread[%d] checking %s (%s)\n",
@@ -117,12 +117,12 @@ cleaner_thread(void *arg)
if (!xbps_repo_get_pkg(thd->repo, pkgver)) { if (!xbps_repo_get_pkg(thd->repo, pkgver)) {
rv = remove_pkg(thd->repo->uri, arch, binpkg); rv = remove_pkg(thd->repo->uri, arch, binpkg);
if (rv != 0) { if (rv != 0) {
prop_object_release(pkgd); xbps_object_release(pkgd);
continue; continue;
} }
printf("Removed obsolete package `%s'.\n", binpkg); printf("Removed obsolete package `%s'.\n", binpkg);
} }
prop_object_release(pkgd); xbps_object_release(pkgd);
} }
return NULL; return NULL;
@@ -131,7 +131,7 @@ cleaner_thread(void *arg)
int int
remove_obsoletes(struct xbps_handle *xhp, const char *repodir) remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
{ {
prop_array_t array = NULL; xbps_array_t array = NULL;
struct xbps_repo *repo; struct xbps_repo *repo;
struct thread_data *thd; struct thread_data *thd;
DIR *dirp; DIR *dirp;
@@ -171,16 +171,16 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
if (strcmp(ext, ".xbps")) if (strcmp(ext, ".xbps"))
continue; continue;
if (array == NULL) if (array == NULL)
array = prop_array_create(); array = xbps_array_create();
prop_array_add_cstring(array, dp->d_name); xbps_array_add_cstring(array, dp->d_name);
} }
(void)closedir(dirp); (void)closedir(dirp);
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
thd = calloc(maxthreads, sizeof(*thd)); thd = calloc(maxthreads, sizeof(*thd));
slicecount = prop_array_count(array) / maxthreads; slicecount = xbps_array_count(array) / maxthreads;
pkgcount = 0; pkgcount = 0;
for (i = 0; i < maxthreads; i++) { for (i = 0; i < maxthreads; i++) {
@@ -189,7 +189,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
thd[i].repo = repo; thd[i].repo = repo;
thd[i].start = pkgcount; thd[i].start = pkgcount;
if (i + 1 >= maxthreads) if (i + 1 >= maxthreads)
thd[i].end = prop_array_count(array); thd[i].end = xbps_array_count(array);
else else
thd[i].end = pkgcount + slicecount; thd[i].end = pkgcount + slicecount;
pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]); pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]);

View File

@@ -39,7 +39,7 @@
int int
repodata_flush(struct xbps_handle *xhp, const char *repodir, repodata_flush(struct xbps_handle *xhp, const char *repodir,
prop_dictionary_t idx, prop_dictionary_t idxfiles) xbps_dictionary_t idx, xbps_dictionary_t idxfiles)
{ {
struct archive *ar; struct archive *ar;
mode_t myumask; mode_t myumask;
@@ -60,7 +60,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
archive_write_set_options(ar, "compression-level=9"); archive_write_set_options(ar, "compression-level=9");
archive_write_open_fd(ar, repofd); archive_write_open_fd(ar, repofd);
xml = prop_dictionary_externalize(idx); xml = xbps_dictionary_externalize(idx);
assert(xml); assert(xml);
if (xbps_archive_append_buf(ar, xml, strlen(xml), if (xbps_archive_append_buf(ar, xml, strlen(xml),
XBPS_PKGINDEX, 0644, "root", "root") != 0) { XBPS_PKGINDEX, 0644, "root", "root") != 0) {
@@ -69,7 +69,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
} }
free(xml); free(xml);
xml = prop_dictionary_externalize(idxfiles); xml = xbps_dictionary_externalize(idxfiles);
assert(xml); assert(xml);
if (xbps_archive_append_buf(ar, xml, strlen(xml), if (xbps_archive_append_buf(ar, xml, strlen(xml),
XBPS_PKGINDEX_FILES, 0644, "root", "root") != 0) { XBPS_PKGINDEX_FILES, 0644, "root", "root") != 0) {

View File

@@ -37,12 +37,12 @@
#include "../xbps-install/defs.h" #include "../xbps-install/defs.h"
static void static void
write_plist_file(prop_dictionary_t dict, const char *file) write_plist_file(xbps_dictionary_t dict, const char *file)
{ {
assert(dict != NULL || file != NULL); assert(dict != NULL || file != NULL);
if (!prop_dictionary_externalize_to_zfile(dict, file)) { if (!xbps_dictionary_externalize_to_zfile(dict, file)) {
prop_object_release(dict); xbps_object_release(dict);
xbps_error_printf("xbps-uhelper: couldn't write to %s: %s\n", xbps_error_printf("xbps-uhelper: couldn't write to %s: %s\n",
file, strerror(errno)); file, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -97,7 +97,7 @@ usage(void)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
prop_dictionary_t dict; xbps_dictionary_t dict;
struct xbps_handle xh; struct xbps_handle xh;
struct xferstat xfer; struct xferstat xfer;
const char *version, *rootdir = NULL, *confdir = NULL; const char *version, *rootdir = NULL, *confdir = NULL;
@@ -159,14 +159,14 @@ main(int argc, char **argv)
(((dict = xbps_pkgdb_get_virtualpkg(&xh, argv[1])) == NULL))) (((dict = xbps_pkgdb_get_virtualpkg(&xh, argv[1])) == NULL)))
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
prop_dictionary_get_cstring_nocopy(dict, "pkgver", &version); xbps_dictionary_get_cstring_nocopy(dict, "pkgver", &version);
printf("%s\n", xbps_pkg_version(version)); printf("%s\n", xbps_pkg_version(version));
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) { } else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
/* Sanitize a plist file (properly indent the file) */ /* Sanitize a plist file (properly indent the file) */
if (argc != 2) if (argc != 2)
usage(); usage();
dict = prop_dictionary_internalize_from_zfile(argv[1]); dict = xbps_dictionary_internalize_from_zfile(argv[1]);
if (dict == NULL) { if (dict == NULL) {
fprintf(stderr, fprintf(stderr,
"=> ERROR: couldn't sanitize %s plist file " "=> ERROR: couldn't sanitize %s plist file "

67
configure vendored
View File

@@ -311,6 +311,17 @@ else
BUILD_PIE_VALUE=no BUILD_PIE_VALUE=no
fi fi
# libfetch
echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK
echo "LDFLAGS += -lssl" >>$CONFIG_MK
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a" >>$CONFIG_MK
# proplib
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib" >>$CONFIG_MK
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib/prop" >>$CONFIG_MK
echo "LDFLAGS += -lpthread" >>$CONFIG_MK
echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
# #
# Check for vasprintf(). # Check for vasprintf().
# #
@@ -469,60 +480,6 @@ else
fi fi
rm -f _$func.c _$func rm -f _$func.c _$func
#
# Check for libfetch's fetchIO_read().
#
func=fetchIO_read
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <fetch.h>
int main(void) {
fetchIO_read(NULL, NULL, 0);
return 0;
}
EOF
if $XCC -lfetch _$func.c -o _$func 2>/dev/null; then
LIBFETCH=yes
echo "USE_EXTERNAL_LIBFETCH = 1" >>$CONFIG_MK
echo "LDFLAGS += -lfetch" >>$CONFIG_MK
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a -lfetch" >>$CONFIG_MK
else
LIBFETCH=no
echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK
echo "LDFLAGS += -lssl" >>$CONFIG_MK
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a" >>$CONFIG_MK
fi
rm -f _$func.c _$func
echo "${LIBFETCH}."
#
# Check for prop_dictionary_internalize_from_zfile().
#
func=prop_dictionary_internalize_from_zfile
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <stdio.h>
#include <prop/proplib.h>
int main(void) {
prop_dictionary_internalize_from_zfile(NULL);
return 0;
}
EOF
if $XCC -lprop _$func.c -o _$func 2>/dev/null; then
PROPLIB=yes
echo "USE_EXTERNAL_PROPLIB = 1" >>$CONFIG_MK
echo "LDFLAGS += -lz -lpthread -lprop" >>$CONFIG_MK
echo "STATIC_LIBS += -lprop -lz -lpthread" >>$CONFIG_MK
else
PROPLIB=no
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib" >>$CONFIG_MK
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib/prop" >>$CONFIG_MK
echo "LDFLAGS += -lpthread" >>$CONFIG_MK
echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
fi
rm -f _$func.c _$func
echo "${PROPLIB}."
# #
# Check for clock_gettime(3). # Check for clock_gettime(3).
# #
@@ -744,8 +701,6 @@ echo " Build Kyua test suite = $BUILD_TESTS_VALUE"
echo " Build programs as PIE = $BUILD_PIE_VALUE" echo " Build programs as PIE = $BUILD_PIE_VALUE"
echo " Build static programs = $BUILD_STATIC_VALUE" echo " Build static programs = $BUILD_STATIC_VALUE"
echo " Build with debug = $DEBUG" echo " Build with debug = $DEBUG"
echo " Use external proplib = $PROPLIB"
echo " Use external libfetch = $LIBFETCH"
if [ -n "$HAVE_VISIBILITY" ]; then if [ -n "$HAVE_VISIBILITY" ]; then
echo " Symbol visibility = $HAVE_VISIBILITY" echo " Symbol visibility = $HAVE_VISIBILITY"
fi fi

View File

@@ -8,8 +8,11 @@ all:
.PHONY: install .PHONY: install
install: install:
install -d $(DESTDIR)$(INCLUDEDIR) install -d $(DESTDIR)$(INCLUDEDIR)/xbps
install -m 644 $(INCS) $(DESTDIR)$(INCLUDEDIR) install -m 644 $(INCS) $(DESTDIR)$(INCLUDEDIR)
for f in array bool data dictionary number object string; do \
install -m 644 xbps/xbps_$${f}.h $(DESTDIR)$(INCLUDEDIR)/xbps; \
done
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:

150
include/xbps/xbps_array.h Normal file
View File

@@ -0,0 +1,150 @@
/* $NetBSD: prop_array.h,v 1.8 2008/09/11 13:15:13 haad Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_ARRAY_H_
#define _XBPS_ARRAY_H_
#include <stdint.h>
#include <xbps/xbps_object.h>
typedef struct _prop_array *xbps_array_t;
#ifdef __cplusplus
extern "C" {
#endif
xbps_array_t xbps_array_create(void);
xbps_array_t xbps_array_create_with_capacity(unsigned int);
xbps_array_t xbps_array_copy(xbps_array_t);
xbps_array_t xbps_array_copy_mutable(xbps_array_t);
unsigned int xbps_array_capacity(xbps_array_t);
unsigned int xbps_array_count(xbps_array_t);
bool xbps_array_ensure_capacity(xbps_array_t, unsigned int);
void xbps_array_make_immutable(xbps_array_t);
bool xbps_array_mutable(xbps_array_t);
xbps_object_iterator_t xbps_array_iterator(xbps_array_t);
xbps_object_t xbps_array_get(xbps_array_t, unsigned int);
bool xbps_array_set(xbps_array_t, unsigned int, xbps_object_t);
bool xbps_array_add(xbps_array_t, xbps_object_t);
void xbps_array_remove(xbps_array_t, unsigned int);
bool xbps_array_equals(xbps_array_t, xbps_array_t);
char * xbps_array_externalize(xbps_array_t);
xbps_array_t xbps_array_internalize(const char *);
bool xbps_array_externalize_to_file(xbps_array_t, const char *);
bool xbps_array_externalize_to_zfile(xbps_array_t, const char *);
xbps_array_t xbps_array_internalize_from_file(const char *);
xbps_array_t xbps_array_internalize_from_zfile(const char *);
/*
* Utility routines to make it more convenient to work with values
* stored in dictionaries.
*/
bool xbps_array_get_bool(xbps_array_t, unsigned int,
bool *);
bool xbps_array_set_bool(xbps_array_t, unsigned int,
bool);
bool xbps_array_get_int8(xbps_array_t, unsigned int,
int8_t *);
bool xbps_array_get_uint8(xbps_array_t, unsigned int,
uint8_t *);
bool xbps_array_set_int8(xbps_array_t, unsigned int,
int8_t);
bool xbps_array_set_uint8(xbps_array_t, unsigned int,
uint8_t);
bool xbps_array_get_int16(xbps_array_t, unsigned int,
int16_t *);
bool xbps_array_get_uint16(xbps_array_t, unsigned int,
uint16_t *);
bool xbps_array_set_int16(xbps_array_t, unsigned int,
int16_t);
bool xbps_array_set_uint16(xbps_array_t, unsigned int,
uint16_t);
bool xbps_array_get_int32(xbps_array_t, unsigned int,
int32_t *);
bool xbps_array_get_uint32(xbps_array_t, unsigned int,
uint32_t *);
bool xbps_array_set_int32(xbps_array_t, unsigned int,
int32_t);
bool xbps_array_set_uint32(xbps_array_t, unsigned int,
uint32_t);
bool xbps_array_get_int64(xbps_array_t, unsigned int,
int64_t *);
bool xbps_array_get_uint64(xbps_array_t, unsigned int,
uint64_t *);
bool xbps_array_set_int64(xbps_array_t, unsigned int,
int64_t);
bool xbps_array_set_uint64(xbps_array_t, unsigned int,
uint64_t);
bool xbps_array_add_int8(xbps_array_t, int8_t);
bool xbps_array_add_uint8(xbps_array_t, uint8_t);
bool xbps_array_add_int16(xbps_array_t, int16_t);
bool xbps_array_add_uint16(xbps_array_t, uint16_t);
bool xbps_array_add_int32(xbps_array_t, int32_t);
bool xbps_array_add_uint32(xbps_array_t, uint32_t);
bool xbps_array_add_int64(xbps_array_t, int64_t);
bool xbps_array_add_uint64(xbps_array_t, uint64_t);
bool xbps_array_get_cstring(xbps_array_t, unsigned int,
char **);
bool xbps_array_set_cstring(xbps_array_t, unsigned int,
const char *);
bool xbps_array_add_cstring(xbps_array_t, const char *);
bool xbps_array_add_cstring_nocopy(xbps_array_t,
const char *);
bool xbps_array_get_cstring_nocopy(xbps_array_t,
unsigned int,
const char **);
bool xbps_array_set_cstring_nocopy(xbps_array_t,
unsigned int,
const char *);
bool xbps_array_add_and_rel(xbps_array_t, xbps_object_t);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_ARRAY_H_ */

55
include/xbps/xbps_bool.h Normal file
View File

@@ -0,0 +1,55 @@
/* $NetBSD: prop_bool.h,v 1.4 2008/04/28 20:22:51 martin Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_BOOL_H_
#define _XBPS_BOOL_H_
#include <stdbool.h>
#include <xbps/xbps_object.h>
typedef struct _prop_bool *xbps_bool_t;
#ifdef __cplusplus
extern "C" {
#endif
xbps_bool_t xbps_bool_create(bool);
xbps_bool_t xbps_bool_copy(xbps_bool_t);
bool xbps_bool_true(xbps_bool_t);
bool xbps_bool_equals(xbps_bool_t, xbps_bool_t);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_BOOL_H_ */

62
include/xbps/xbps_data.h Normal file
View File

@@ -0,0 +1,62 @@
/* $NetBSD: prop_data.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_DATA_H_
#define _XBPS_DATA_H_
#include <stdint.h>
#include <sys/types.h>
#include <xbps/xbps_object.h>
typedef struct _prop_data *xbps_data_t;
#ifdef __cplusplus
extern "C" {
#endif
xbps_data_t xbps_data_create_data(const void *, size_t);
xbps_data_t xbps_data_create_data_nocopy(const void *, size_t);
xbps_data_t xbps_data_copy(xbps_data_t);
size_t xbps_data_size(xbps_data_t);
void * xbps_data_data(xbps_data_t);
const void * xbps_data_data_nocopy(xbps_data_t);
bool xbps_data_equals(xbps_data_t, xbps_data_t);
bool xbps_data_equals_data(xbps_data_t, const void *, size_t);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_DATA_H_ */

View File

@@ -0,0 +1,157 @@
/* $NetBSD: prop_dictionary.h,v 1.9 2008/04/28 20:22:51 martin Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_DICTIONARY_H_
#define _XBPS_DICTIONARY_H_
#include <stdint.h>
#include <xbps/xbps_object.h>
#include <xbps/xbps_array.h>
typedef struct _prop_dictionary *xbps_dictionary_t;
typedef struct _prop_dictionary_keysym *xbps_dictionary_keysym_t;
#ifdef __cplusplus
extern "C" {
#endif
xbps_dictionary_t xbps_dictionary_create(void);
xbps_dictionary_t xbps_dictionary_create_with_capacity(unsigned int);
xbps_dictionary_t xbps_dictionary_copy(xbps_dictionary_t);
xbps_dictionary_t xbps_dictionary_copy_mutable(xbps_dictionary_t);
unsigned int xbps_dictionary_count(xbps_dictionary_t);
bool xbps_dictionary_ensure_capacity(xbps_dictionary_t,
unsigned int);
void xbps_dictionary_make_immutable(xbps_dictionary_t);
xbps_object_iterator_t xbps_dictionary_iterator(xbps_dictionary_t);
xbps_array_t xbps_dictionary_all_keys(xbps_dictionary_t);
xbps_object_t xbps_dictionary_get(xbps_dictionary_t, const char *);
bool xbps_dictionary_set(xbps_dictionary_t, const char *,
xbps_object_t);
void xbps_dictionary_remove(xbps_dictionary_t, const char *);
xbps_object_t xbps_dictionary_get_keysym(xbps_dictionary_t,
xbps_dictionary_keysym_t);
bool xbps_dictionary_set_keysym(xbps_dictionary_t,
xbps_dictionary_keysym_t,
xbps_object_t);
void xbps_dictionary_remove_keysym(xbps_dictionary_t,
xbps_dictionary_keysym_t);
bool xbps_dictionary_equals(xbps_dictionary_t, xbps_dictionary_t);
char * xbps_dictionary_externalize(xbps_dictionary_t);
xbps_dictionary_t xbps_dictionary_internalize(const char *);
bool xbps_dictionary_externalize_to_file(xbps_dictionary_t,
const char *);
bool xbps_dictionary_externalize_to_zfile(xbps_dictionary_t,
const char *);
xbps_dictionary_t xbps_dictionary_internalize_from_file(const char *);
xbps_dictionary_t xbps_dictionary_internalize_from_zfile(const char *);
const char * xbps_dictionary_keysym_cstring_nocopy(xbps_dictionary_keysym_t);
bool xbps_dictionary_keysym_equals(xbps_dictionary_keysym_t,
xbps_dictionary_keysym_t);
/*
* Utility routines to make it more convenient to work with values
* stored in dictionaries.
*/
bool xbps_dictionary_get_dict(xbps_dictionary_t, const char *,
xbps_dictionary_t *);
bool xbps_dictionary_get_bool(xbps_dictionary_t, const char *,
bool *);
bool xbps_dictionary_set_bool(xbps_dictionary_t, const char *,
bool);
bool xbps_dictionary_get_int8(xbps_dictionary_t, const char *,
int8_t *);
bool xbps_dictionary_get_uint8(xbps_dictionary_t, const char *,
uint8_t *);
bool xbps_dictionary_set_int8(xbps_dictionary_t, const char *,
int8_t);
bool xbps_dictionary_set_uint8(xbps_dictionary_t, const char *,
uint8_t);
bool xbps_dictionary_get_int16(xbps_dictionary_t, const char *,
int16_t *);
bool xbps_dictionary_get_uint16(xbps_dictionary_t, const char *,
uint16_t *);
bool xbps_dictionary_set_int16(xbps_dictionary_t, const char *,
int16_t);
bool xbps_dictionary_set_uint16(xbps_dictionary_t, const char *,
uint16_t);
bool xbps_dictionary_get_int32(xbps_dictionary_t, const char *,
int32_t *);
bool xbps_dictionary_get_uint32(xbps_dictionary_t, const char *,
uint32_t *);
bool xbps_dictionary_set_int32(xbps_dictionary_t, const char *,
int32_t);
bool xbps_dictionary_set_uint32(xbps_dictionary_t, const char *,
uint32_t);
bool xbps_dictionary_get_int64(xbps_dictionary_t, const char *,
int64_t *);
bool xbps_dictionary_get_uint64(xbps_dictionary_t, const char *,
uint64_t *);
bool xbps_dictionary_set_int64(xbps_dictionary_t, const char *,
int64_t);
bool xbps_dictionary_set_uint64(xbps_dictionary_t, const char *,
uint64_t);
bool xbps_dictionary_get_cstring(xbps_dictionary_t, const char *,
char **);
bool xbps_dictionary_set_cstring(xbps_dictionary_t, const char *,
const char *);
bool xbps_dictionary_get_cstring_nocopy(xbps_dictionary_t,
const char *,
const char **);
bool xbps_dictionary_set_cstring_nocopy(xbps_dictionary_t,
const char *,
const char *);
bool xbps_dictionary_set_and_rel(xbps_dictionary_t,
const char *,
xbps_object_t);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_DICTIONARY_H_ */

View File

@@ -0,0 +1,63 @@
/* $NetBSD: prop_number.h,v 1.6 2008/04/28 20:22:51 martin Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_NUMBER_H_
#define _XBPS_NUMBER_H_
#include <stdint.h>
#include <xbps/xbps_object.h>
typedef struct _prop_number *xbps_number_t;
#ifdef __cplusplus
extern "C" {
#endif
xbps_number_t xbps_number_create_integer(int64_t);
xbps_number_t xbps_number_create_unsigned_integer(uint64_t);
xbps_number_t xbps_number_copy(xbps_number_t);
int xbps_number_size(xbps_number_t);
bool xbps_number_unsigned(xbps_number_t);
int64_t xbps_number_integer_value(xbps_number_t);
uint64_t xbps_number_unsigned_integer_value(xbps_number_t);
bool xbps_number_equals(xbps_number_t, xbps_number_t);
bool xbps_number_equals_integer(xbps_number_t, int64_t);
bool xbps_number_equals_unsigned_integer(xbps_number_t, uint64_t);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_NUMBER_H_ */

View File

@@ -0,0 +1,73 @@
/* $NetBSD: prop_object.h,v 1.7 2008/04/28 20:22:51 martin Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_OBJECT_H_
#define _XBPS_OBJECT_H_
#include <stdint.h>
#include <stdbool.h>
typedef void *xbps_object_t;
typedef enum {
XBPS_TYPE_UNKNOWN = 0x00000000,
XBPS_TYPE_BOOL = 0x626f6f6c, /* 'bool' */
XBPS_TYPE_NUMBER = 0x6e6d6272, /* 'nmbr' */
XBPS_TYPE_STRING = 0x73746e67, /* 'stng' */
XBPS_TYPE_DATA = 0x64617461, /* 'data' */
XBPS_TYPE_ARRAY = 0x61726179, /* 'aray' */
XBPS_TYPE_DICTIONARY = 0x64696374, /* 'dict' */
XBPS_TYPE_DICT_KEYSYM = 0x646b6579 /* 'dkey' */
} xbps_type_t;
#ifdef __cplusplus
extern "C" {
#endif
void xbps_object_retain(xbps_object_t);
void xbps_object_release(xbps_object_t);
xbps_type_t xbps_object_type(xbps_object_t);
bool xbps_object_equals(xbps_object_t, xbps_object_t);
bool xbps_object_equals_with_error(xbps_object_t, xbps_object_t, bool *);
typedef struct _prop_object_iterator *xbps_object_iterator_t;
xbps_object_t xbps_object_iterator_next(xbps_object_iterator_t);
void xbps_object_iterator_reset(xbps_object_iterator_t);
void xbps_object_iterator_release(xbps_object_iterator_t);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_OBJECT_H_ */

View File

@@ -0,0 +1,68 @@
/* $NetBSD: prop_string.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _XBPS_STRING_H_
#define _XBPS_STRING_H_
#include <stdint.h>
#include <sys/types.h>
#include <xbps/xbps_object.h>
typedef struct _prop_string *xbps_string_t;
#ifdef __cplusplus
extern "C" {
#endif
xbps_string_t xbps_string_create(void);
xbps_string_t xbps_string_create_cstring(const char *);
xbps_string_t xbps_string_create_cstring_nocopy(const char *);
xbps_string_t xbps_string_copy(xbps_string_t);
xbps_string_t xbps_string_copy_mutable(xbps_string_t);
size_t xbps_string_size(xbps_string_t);
bool xbps_string_mutable(xbps_string_t);
char * xbps_string_cstring(xbps_string_t);
const char * xbps_string_cstring_nocopy(xbps_string_t);
bool xbps_string_append(xbps_string_t, xbps_string_t);
bool xbps_string_append_cstring(xbps_string_t, const char *);
bool xbps_string_equals(xbps_string_t, xbps_string_t);
bool xbps_string_equals_cstring(xbps_string_t, const char *);
#ifdef __cplusplus
}
#endif
#endif /* _XBPS_STRING_H_ */

View File

@@ -30,9 +30,15 @@
#include <stdio.h> #include <stdio.h>
#include <inttypes.h> #include <inttypes.h>
#include <xbps/xbps_array.h>
#include <xbps/xbps_bool.h>
#include <xbps/xbps_data.h>
#include <xbps/xbps_dictionary.h>
#include <xbps/xbps_number.h>
#include <xbps/xbps_string.h>
#include <archive.h> #include <archive.h>
#include <archive_entry.h> #include <archive_entry.h>
#include <prop/proplib.h>
/** /**
* @file include/xbps_api.h * @file include/xbps_api.h
@@ -40,7 +46,7 @@
* *
* This header documents the full API for the XBPS Library. * This header documents the full API for the XBPS Library.
*/ */
#define XBPS_API_VERSION "20130614-1" #define XBPS_API_VERSION "20130620"
#ifndef XBPS_VERSION #ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET" #define XBPS_VERSION "UNSET"
@@ -452,22 +458,22 @@ struct xbps_handle {
* Internalized proplib dictionary with the master package database * Internalized proplib dictionary with the master package database
* stored in XBPS_META_PATH/XBPS_PKGDB. * stored in XBPS_META_PATH/XBPS_PKGDB.
*/ */
prop_dictionary_t pkgdb; xbps_dictionary_t pkgdb;
/** /**
* @private * @private
*/ */
prop_dictionary_t pkg_metad; xbps_dictionary_t pkg_metad;
/** /**
* @private * @private
*/ */
prop_dictionary_t pkgdb_revdeps; xbps_dictionary_t pkgdb_revdeps;
/** /**
* @var transd * @var transd
* *
* Proplib dictionary with transaction details, required by * Proplib dictionary with transaction details, required by
* xbps_transaction_commit(). * xbps_transaction_commit().
*/ */
prop_dictionary_t transd; xbps_dictionary_t transd;
/** /**
* Pointer to the supplifed function callback to be used * Pointer to the supplifed function callback to be used
* in the XBPS possible states. * in the XBPS possible states.
@@ -670,7 +676,7 @@ const char *xbps_fetch_error_string(void);
* @return A proplib array of dictionaries with all orphans found, * @return A proplib array of dictionaries with all orphans found,
* on error NULL is returned and errno is set appropiately. * on error NULL is returned and errno is set appropiately.
*/ */
prop_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans); xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans);
/** /**
* @ingroup pkg_obsoletes * @ingroup pkg_obsoletes
@@ -684,9 +690,9 @@ prop_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans
* *
* @return A proplib array of strings with a sorted list of obsolete files. * @return A proplib array of strings with a sorted list of obsolete files.
*/ */
prop_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp, xbps_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
prop_dictionary_t instd, xbps_dictionary_t instd,
prop_dictionary_t newd); xbps_dictionary_t newd);
/** @addtogroup pkgdb */ /** @addtogroup pkgdb */
/*@{*/ /*@{*/
@@ -703,7 +709,7 @@ prop_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
* the value returned by the function callback. * the value returned by the function callback.
*/ */
int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp, int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg); void *arg);
/** /**
@@ -719,7 +725,7 @@ int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
*/ */
int xbps_pkgdb_foreach_reverse_cb( int xbps_pkgdb_foreach_reverse_cb(
struct xbps_handle *xhp, struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg); void *arg);
/** /**
@@ -731,7 +737,7 @@ int xbps_pkgdb_foreach_reverse_cb(
* *
* @return The matching proplib package dictionary, NULL otherwise. * @return The matching proplib package dictionary, NULL otherwise.
*/ */
prop_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp,
const char *pkg); const char *pkg);
/** /**
@@ -743,7 +749,7 @@ prop_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp,
* *
* @return The matching proplib package dictionary, NULL otherwise. * @return The matching proplib package dictionary, NULL otherwise.
*/ */
prop_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp,
const char *pkg); const char *pkg);
/** /**
@@ -754,7 +760,7 @@ prop_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp,
* *
* @return The matching package metadata dictionary, NULL otherwise. * @return The matching package metadata dictionary, NULL otherwise.
*/ */
prop_dictionary_t xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp, xbps_dictionary_t xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp,
const char *pkg); const char *pkg);
/** /**
@@ -767,7 +773,7 @@ prop_dictionary_t xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp,
* *
* @return A proplib array of strings with reverse dependencies for \a pkg. * @return A proplib array of strings with reverse dependencies for \a pkg.
*/ */
prop_array_t xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, xbps_array_t xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp,
const char *pkg); const char *pkg);
/** /**
@@ -813,7 +819,7 @@ int xbps_pkg_exec_buffer(struct xbps_handle *xhp,
* @return 0 on success, or an errno value otherwise. * @return 0 on success, or an errno value otherwise.
*/ */
int xbps_pkg_exec_script(struct xbps_handle *xhp, int xbps_pkg_exec_script(struct xbps_handle *xhp,
prop_dictionary_t d, xbps_dictionary_t d,
const char *script, const char *script,
const char *action, const char *action,
bool update); bool update);
@@ -838,8 +844,8 @@ int xbps_pkg_exec_script(struct xbps_handle *xhp,
* callback. * callback.
*/ */
int xbps_callback_array_iter(struct xbps_handle *xhp, int xbps_callback_array_iter(struct xbps_handle *xhp,
prop_array_t array, xbps_array_t array,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg); void *arg);
/** /**
@@ -857,8 +863,8 @@ int xbps_callback_array_iter(struct xbps_handle *xhp,
* callback. * callback.
*/ */
int xbps_callback_array_iter_reverse(struct xbps_handle *xhp, int xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
prop_array_t array, xbps_array_t array,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg); void *arg);
/** /**
@@ -878,9 +884,9 @@ int xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
* the value returned by the function callback. * the value returned by the function callback.
*/ */
int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *key, const char *key,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg); void *arg);
/** /**
@@ -900,9 +906,9 @@ int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
* the value returned by the function callback. * the value returned by the function callback.
*/ */
int xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp, int xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *key, const char *key,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg); void *arg);
/** /**
@@ -917,7 +923,7 @@ int xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
* @return True if \a str matches a virtual package in \a pkgd, false * @return True if \a str matches a virtual package in \a pkgd, false
* otherwise. * otherwise.
*/ */
bool xbps_match_virtual_pkg_in_dict(prop_dictionary_t pkgd, bool xbps_match_virtual_pkg_in_dict(xbps_dictionary_t pkgd,
const char *str, const char *str,
bool bypattern); bool bypattern);
@@ -931,8 +937,8 @@ bool xbps_match_virtual_pkg_in_dict(prop_dictionary_t pkgd,
* *
* @return True if \a any virtualpkg has been matched, false otherwise. * @return True if \a any virtualpkg has been matched, false otherwise.
*/ */
bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps, bool xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps,
prop_array_t provides); xbps_array_t provides);
/** /**
* Match a package name in the specified array of strings. * Match a package name in the specified array of strings.
@@ -942,7 +948,7 @@ bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
* *
* @return true on success, false otherwise and errno is set appropiately. * @return true on success, false otherwise and errno is set appropiately.
*/ */
bool xbps_match_pkgname_in_array(prop_array_t array, const char *pkgname); bool xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname);
/** /**
* Match a package pattern in the specified array of strings. * Match a package pattern in the specified array of strings.
@@ -952,7 +958,7 @@ bool xbps_match_pkgname_in_array(prop_array_t array, const char *pkgname);
* *
* @return true on success, false otherwise and errno is set appropiately. * @return true on success, false otherwise and errno is set appropiately.
*/ */
bool xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern); bool xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern);
/** /**
* Match a package dependency against any package pattern in the specified * Match a package dependency against any package pattern in the specified
@@ -963,7 +969,7 @@ bool xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern);
* *
* @return true on success, false otherwise and errno is set appropiately. * @return true on success, false otherwise and errno is set appropiately.
*/ */
bool xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver); bool xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver);
/** /**
* Match a string (exact match) in the specified array of strings. * Match a string (exact match) in the specified array of strings.
@@ -973,7 +979,7 @@ bool xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver);
* *
* @return true on success, false otherwise and errno is set appropiately. * @return true on success, false otherwise and errno is set appropiately.
*/ */
bool xbps_match_string_in_array(prop_array_t array, const char *val); bool xbps_match_string_in_array(xbps_array_t array, const char *val);
/** /**
* Returns a proplib object iterator associated with an array, contained * Returns a proplib object iterator associated with an array, contained
@@ -985,7 +991,7 @@ bool xbps_match_string_in_array(prop_array_t array, const char *val);
* @return A proplib object iterator on success, NULL otherwise and * @return A proplib object iterator on success, NULL otherwise and
* errno is set appropiately. * errno is set appropiately.
*/ */
prop_object_iterator_t xbps_array_iter_from_dict(prop_dictionary_t dict, xbps_object_iterator_t xbps_array_iter_from_dict(xbps_dictionary_t dict,
const char *key); const char *key);
/*@}*/ /*@}*/
@@ -1115,7 +1121,7 @@ int xbps_transaction_commit(struct xbps_handle *xhp);
* @return An internalized proplib dictionary, otherwise NULL and * @return An internalized proplib dictionary, otherwise NULL and
* errno is set appropiately. * errno is set appropiately.
*/ */
prop_dictionary_t xbps_get_pkg_plist_from_binpkg(const char *fname, xbps_dictionary_t xbps_get_pkg_plist_from_binpkg(const char *fname,
const char *plistf); const char *plistf);
/*@}*/ /*@}*/
@@ -1140,13 +1146,13 @@ struct xbps_repo {
* *
* Proplib dictionary associated with the repository index. * Proplib dictionary associated with the repository index.
*/ */
prop_dictionary_t idx; xbps_dictionary_t idx;
/** /**
* @var idxfiles * @var idxfiles
* *
* Proplib dictionary associated with the repository index files. * Proplib dictionary associated with the repository index files.
*/ */
prop_dictionary_t idxfiles; xbps_dictionary_t idxfiles;
/** /**
* @var uri * @var uri
* *
@@ -1204,9 +1210,9 @@ int xbps_rpool_foreach(struct xbps_handle *xhp,
* *
* @return The package dictionary if found, NULL otherwise. * @return The package dictionary if found, NULL otherwise.
* @note When returned dictionary is no longer needed, you must release it * @note When returned dictionary is no longer needed, you must release it
* with prop_object_release(3). * with xbps_object_release(3).
*/ */
prop_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg); xbps_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg);
/** /**
* Finds a package dictionary in repository pool by specifying a * Finds a package dictionary in repository pool by specifying a
@@ -1217,9 +1223,9 @@ prop_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg);
* *
* @return The package dictionary if found, NULL otherwise. * @return The package dictionary if found, NULL otherwise.
* @note When returned dictionary is no longer needed, you must release it * @note When returned dictionary is no longer needed, you must release it
* with prop_object_release(3). * with xbps_object_release(3).
*/ */
prop_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, xbps_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp,
const char *pkg); const char *pkg);
/** /**
@@ -1232,7 +1238,7 @@ prop_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp,
* @return The array of strings on success, NULL otherwise and errno is * @return The array of strings on success, NULL otherwise and errno is
* set appropiately. * set appropiately.
*/ */
prop_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg); xbps_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg);
/** /**
* Iterate over the the repository pool and search for a metadata plist * Iterate over the the repository pool and search for a metadata plist
@@ -1253,7 +1259,7 @@ prop_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg
* binary package file has been found but the plist file could not * binary package file has been found but the plist file could not
* be found. * be found.
*/ */
prop_dictionary_t xbps_rpool_get_pkg_plist(struct xbps_handle *xhp, xbps_dictionary_t xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
const char *pattern, const char *pattern,
const char *plistf); const char *plistf);
@@ -1281,7 +1287,7 @@ struct xbps_repo *xbps_repo_open(struct xbps_handle *xhp, const char *url);
* *
* @return The matching proplib dictionary on success, NULL otherwise. * @return The matching proplib dictionary on success, NULL otherwise.
*/ */
prop_dictionary_t xbps_repo_get_plist(struct xbps_repo *repo, const char *file); xbps_dictionary_t xbps_repo_get_plist(struct xbps_repo *repo, const char *file);
/** /**
* Closes a repository object and releases resources. * Closes a repository object and releases resources.
@@ -1310,7 +1316,7 @@ char *xbps_repo_path(struct xbps_handle *xhp, const char *url);
* *
* @return The pkg dictionary on success, NULL otherwise. * @return The pkg dictionary on success, NULL otherwise.
*/ */
prop_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg); xbps_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg);
/** /**
* Returns a pkg dictionary from a repository \a repo matching * Returns a pkg dictionary from a repository \a repo matching
@@ -1322,7 +1328,7 @@ prop_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg);
* *
* @return The pkg dictionary on success, NULL otherwise. * @return The pkg dictionary on success, NULL otherwise.
*/ */
prop_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, xbps_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo,
const char *pkg); const char *pkg);
/** /**
@@ -1335,8 +1341,8 @@ prop_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo,
* *
* @return The pkg dictionary on success, NULL otherwise. * @return The pkg dictionary on success, NULL otherwise.
*/ */
prop_dictionary_t xbps_repo_get_pkg_plist(struct xbps_handle *xhp, xbps_dictionary_t xbps_repo_get_pkg_plist(struct xbps_handle *xhp,
prop_dictionary_t pkgd, xbps_dictionary_t pkgd,
const char *plist); const char *plist);
/** /**
@@ -1349,7 +1355,7 @@ prop_dictionary_t xbps_repo_get_pkg_plist(struct xbps_handle *xhp,
* @return The array of strings on success, NULL otherwise and errno is * @return The array of strings on success, NULL otherwise and errno is
* set appropiately. * set appropiately.
*/ */
prop_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg); xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg);
/*@}*/ /*@}*/
@@ -1364,7 +1370,7 @@ prop_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg);
* *
* @return The internalized proplib dictionary, NULL otherwise. * @return The internalized proplib dictionary, NULL otherwise.
*/ */
prop_dictionary_t xbps_archive_get_dictionary(struct archive *ar, xbps_dictionary_t xbps_archive_get_dictionary(struct archive *ar,
struct archive_entry *entry); struct archive_entry *entry);
/** /**
@@ -1437,7 +1443,7 @@ int xbps_pkg_state_installed(struct xbps_handle *xhp,
* *
* @return 0 on success, otherwise an errno value. * @return 0 on success, otherwise an errno value.
*/ */
int xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state); int xbps_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t *state);
/** /**
* Sets package state \a state in package \a pkgname. * Sets package state \a state in package \a pkgname.
@@ -1460,7 +1466,7 @@ int xbps_set_pkg_state_installed(struct xbps_handle *xhp,
* *
* @return 0 on success, otherwise an errno value. * @return 0 on success, otherwise an errno value.
*/ */
int xbps_set_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t state); int xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state);
/*@}*/ /*@}*/
@@ -1612,7 +1618,7 @@ const char *xbps_pkg_revision(const char *pkg);
* *
* @return True if package has run dependencies, false otherwise. * @return True if package has run dependencies, false otherwise.
*/ */
bool xbps_pkg_has_rundeps(prop_dictionary_t dict); bool xbps_pkg_has_rundeps(xbps_dictionary_t dict);
/** /**
* Returns true if provided string is valid for target architecture. * Returns true if provided string is valid for target architecture.

View File

@@ -35,6 +35,7 @@
#include <confuse.h> #include <confuse.h>
#define LIBXBPS_PRIVATE #define LIBXBPS_PRIVATE
#include <xbps_api.h> #include <xbps_api.h>
/* /*
* By default all public functions have default visibility, unless * By default all public functions have default visibility, unless
* visibility has been detected by configure and the HIDDEN definition * visibility has been detected by configure and the HIDDEN definition
@@ -103,32 +104,32 @@ void HIDDEN xbps_pkgdb_release(struct xbps_handle *);
* @private * @private
* From lib/plist.c * From lib/plist.c
*/ */
bool HIDDEN xbps_add_obj_to_dict(prop_dictionary_t, bool HIDDEN xbps_add_obj_to_dict(xbps_dictionary_t,
prop_object_t, const char *); xbps_object_t, const char *);
bool HIDDEN xbps_add_obj_to_array(prop_array_t, prop_object_t); bool HIDDEN xbps_add_obj_to_array(xbps_array_t, xbps_object_t);
int HIDDEN xbps_array_replace_dict_by_name(prop_array_t, int HIDDEN xbps_array_replace_dict_by_name(xbps_array_t,
prop_dictionary_t, xbps_dictionary_t,
const char *); const char *);
int HIDDEN xbps_array_replace_dict_by_pattern(prop_array_t, int HIDDEN xbps_array_replace_dict_by_pattern(xbps_array_t,
prop_dictionary_t, xbps_dictionary_t,
const char *); const char *);
/** /**
* @private * @private
* From lib/plist_remove.c * From lib/plist_remove.c
*/ */
bool HIDDEN xbps_remove_pkg_from_array_by_name(prop_array_t, const char *); bool HIDDEN xbps_remove_pkg_from_array_by_name(xbps_array_t, const char *);
bool HIDDEN xbps_remove_pkg_from_array_by_pattern(prop_array_t, const char *); bool HIDDEN xbps_remove_pkg_from_array_by_pattern(xbps_array_t, const char *);
bool HIDDEN xbps_remove_pkg_from_array_by_pkgver(prop_array_t, const char *); bool HIDDEN xbps_remove_pkg_from_array_by_pkgver(xbps_array_t, const char *);
bool HIDDEN xbps_remove_pkgname_from_array(prop_array_t, const char *); bool HIDDEN xbps_remove_pkgname_from_array(xbps_array_t, const char *);
bool HIDDEN xbps_remove_string_from_array(prop_array_t, const char *); bool HIDDEN xbps_remove_string_from_array(xbps_array_t, const char *);
/** /**
* @private * @private
* From lib/util.c * From lib/util.c
*/ */
char HIDDEN *xbps_repository_pkg_path(struct xbps_handle *, prop_dictionary_t); char HIDDEN *xbps_repository_pkg_path(struct xbps_handle *, xbps_dictionary_t);
/** /**
* @private * @private
@@ -148,9 +149,9 @@ void HIDDEN xbps_fetch_unset_cache_connection(void);
* @private * @private
* From lib/package_config_files.c * From lib/package_config_files.c
*/ */
int HIDDEN xbps_entry_is_a_conf_file(prop_dictionary_t, const char *); int HIDDEN xbps_entry_is_a_conf_file(xbps_dictionary_t, const char *);
int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *, int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *,
prop_dictionary_t, xbps_dictionary_t,
struct archive_entry *, struct archive_entry *,
const char *, const char *,
const char *, const char *,
@@ -160,20 +161,20 @@ int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *,
* From lib/repo_pkgdeps.c * From lib/repo_pkgdeps.c
*/ */
int HIDDEN xbps_repository_find_deps(struct xbps_handle *, int HIDDEN xbps_repository_find_deps(struct xbps_handle *,
prop_array_t, xbps_array_t,
prop_dictionary_t); xbps_dictionary_t);
/** /**
* @private * @private
* From lib/plist_find.c * From lib/plist_find.c
*/ */
prop_dictionary_t HIDDEN xbps_find_pkg_in_array(prop_array_t, const char *); xbps_dictionary_t HIDDEN xbps_find_pkg_in_array(xbps_array_t, const char *);
prop_dictionary_t HIDDEN xbps_dictionary_t HIDDEN
xbps_find_virtualpkg_in_array(struct xbps_handle *, prop_array_t, xbps_find_virtualpkg_in_array(struct xbps_handle *, xbps_array_t,
const char *); const char *);
prop_dictionary_t HIDDEN xbps_find_pkg_in_dict(prop_dictionary_t, const char *); xbps_dictionary_t HIDDEN xbps_find_pkg_in_dict(xbps_dictionary_t, const char *);
prop_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *,
prop_dictionary_t, xbps_dictionary_t,
const char *); const char *);
/** /**
* @private * @private
@@ -199,7 +200,7 @@ int HIDDEN xbps_repo_sync(struct xbps_handle *, const char *);
* From lib/util_hash.c * From lib/util_hash.c
*/ */
int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *, int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *,
prop_dictionary_t d, xbps_dictionary_t d,
const char *, const char *,
const char *); const char *);
@@ -222,7 +223,7 @@ void HIDDEN xbps_set_cb_state(struct xbps_handle *, xbps_state_t, int,
* @private * @private
* From lib/package_unpack.c * From lib/package_unpack.c
*/ */
int HIDDEN xbps_unpack_binary_pkg(struct xbps_handle *, prop_dictionary_t); int HIDDEN xbps_unpack_binary_pkg(struct xbps_handle *, xbps_dictionary_t);
int HIDDEN xbps_transaction_package_replace(struct xbps_handle *); int HIDDEN xbps_transaction_package_replace(struct xbps_handle *);
@@ -231,22 +232,22 @@ int HIDDEN xbps_transaction_package_replace(struct xbps_handle *);
* From lib/package_remove.c * From lib/package_remove.c
*/ */
int HIDDEN xbps_remove_pkg(struct xbps_handle *, const char *, bool, bool); int HIDDEN xbps_remove_pkg(struct xbps_handle *, const char *, bool, bool);
int HIDDEN xbps_remove_pkg_files(struct xbps_handle *, prop_dictionary_t, int HIDDEN xbps_remove_pkg_files(struct xbps_handle *, xbps_dictionary_t,
const char *, const char *); const char *, const char *);
/** /**
* @private * @private
* From lib/package_register.c * From lib/package_register.c
*/ */
int HIDDEN xbps_register_pkg(struct xbps_handle *, prop_dictionary_t); int HIDDEN xbps_register_pkg(struct xbps_handle *, xbps_dictionary_t);
/** /**
* @private * @private
* From lib/package_conflicts.c * From lib/package_conflicts.c
*/ */
void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *, void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *,
prop_array_t, xbps_array_t,
prop_dictionary_t); xbps_dictionary_t);
/** /**
* @private * @private
* From lib/plist_find.c * From lib/plist_find.c

View File

@@ -16,10 +16,7 @@ LIBPROP_OBJS += portableproplib/prop_dictionary_util.o portableproplib/prop_zlib
LIBPROP_OBJS += portableproplib/prop_data.o LIBPROP_OBJS += portableproplib/prop_data.o
LIBPROP_CPPFLAGS = -D_GNU_SOURCE LIBPROP_CPPFLAGS = -D_GNU_SOURCE
LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter
LIBPROP_CFLAGS += -fvisibility=hidden
ifdef USE_EXTERNAL_PROPLIB
LIBPROP_OBJS =
endif
# libfetch # libfetch
LIBFETCH_OBJS = fetch/common.o fetch/fetch.o fetch/file.o LIBFETCH_OBJS = fetch/common.o fetch/fetch.o fetch/file.o
@@ -32,10 +29,6 @@ endif
LIBFETCH_INCS = fetch/common.h LIBFETCH_INCS = fetch/common.h
LIBFETCH_GEN = fetch/ftperr.h fetch/httperr.h LIBFETCH_GEN = fetch/ftperr.h fetch/httperr.h
ifdef USE_EXTERNAL_LIBFETCH
LIBFETCH_OBJS =
endif
# External code used by libxbps # External code used by libxbps
EXTOBJS = external/dewey.o external/fexec.o external/mkpath.o EXTOBJS = external/dewey.o external/fexec.o external/mkpath.o
@@ -49,7 +42,7 @@ OBJS += download.o initend.o pkgdb.o package_conflicts.o
OBJS += plist.o plist_find.o plist_match.o archive.o OBJS += plist.o plist_find.o plist_match.o archive.o
OBJS += plist_remove.o plist_fetch.o util.o util_hash.o OBJS += plist_remove.o plist_fetch.o util.o util_hash.o
OBJS += repo.o repo_pkgdeps.o repo_sync.o OBJS += repo.o repo_pkgdeps.o repo_sync.o
OBJS += rpool.o rpool_get.o cb_util.o OBJS += rpool.o rpool_get.o cb_util.o proplib_wrapper.o
OBJS += $(EXTOBJS) $(COMPAT_SRCS) OBJS += $(EXTOBJS) $(COMPAT_SRCS)
.PHONY: all .PHONY: all
@@ -77,13 +70,13 @@ $(OBJS): %.o: %.c
@printf " [CC]\t\t$@\n" @printf " [CC]\t\t$@\n"
${SILENT}$(CC) $(CPPFLAGS) $(CFLAGS) $(SHAREDLIB_CFLAGS) -c $< -o $@ ${SILENT}$(CC) $(CPPFLAGS) $(CFLAGS) $(SHAREDLIB_CFLAGS) -c $< -o $@
libxbps.so: $(OBJS) $(LIBFETCH_OBJS) $(LIBPROP_OBJS) libxbps.so: $(LIBFETCH_OBJS) $(LIBPROP_OBJS) $(OBJS)
@printf " [CCLD]\t\t$@\n" @printf " [CCLD]\t\t$@\n"
${SILENT}$(CC) $^ $(LDFLAGS) -o $(LIBXBPS_SHLIB) ${SILENT}$(CC) $^ $(LDFLAGS) -o $(LIBXBPS_SHLIB)
@-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBXBPS_MAJOR) @-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBXBPS_MAJOR)
@-ln -sf $(LIBXBPS_SHLIB) libxbps.so @-ln -sf $(LIBXBPS_SHLIB) libxbps.so
libxbps.a: $(OBJS) $(LIBFETCH_OBJS) $(LIBPROP_OBJS) libxbps.a: $(LIBFETCH_OBJS) $(LIBPROP_OBJS) $(OBJS)
@printf " [AR]\t\t$@\n" @printf " [AR]\t\t$@\n"
${SILENT}$(AR) rcs $@ $^ ${SILENT}$(AR) rcs $@ $^
@printf " [RANLIB]\t$@\n" @printf " [RANLIB]\t$@\n"

View File

@@ -108,10 +108,10 @@ uncompress_plist_data(char *xml, size_t len)
} }
#undef _READ_CHUNK #undef _READ_CHUNK
prop_dictionary_t HIDDEN xbps_dictionary_t HIDDEN
xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry) xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
{ {
prop_dictionary_t d = NULL; xbps_dictionary_t d = NULL;
size_t buflen; size_t buflen;
ssize_t nbytes = -1; ssize_t nbytes = -1;
char *buf, *uncomp_buf; char *buf, *uncomp_buf;
@@ -131,8 +131,8 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
} }
/* If blob is already a dictionary we are done */ /* If blob is already a dictionary we are done */
d = prop_dictionary_internalize(buf); d = xbps_dictionary_internalize(buf);
if (prop_object_type(d) == PROP_TYPE_DICTIONARY) if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY)
goto out; goto out;
/* Try to uncompress blob */ /* Try to uncompress blob */
@@ -143,7 +143,7 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
return NULL; return NULL;
} else { } else {
/* We have the uncompressed data */ /* We have the uncompressed data */
d = prop_dictionary_internalize(uncomp_buf); d = xbps_dictionary_internalize(uncomp_buf);
free(uncomp_buf); free(uncomp_buf);
} }

View File

@@ -257,7 +257,7 @@ xbps_end(struct xbps_handle *xhp)
xbps_rpool_release(xhp); xbps_rpool_release(xhp);
xbps_fetch_unset_cache_connection(); xbps_fetch_unset_cache_connection();
if (xhp->pkgdb_revdeps != NULL) if (xhp->pkgdb_revdeps != NULL)
prop_object_release(xhp->pkgdb_revdeps); xbps_object_release(xhp->pkgdb_revdeps);
cfg_free(xhp->cfg); cfg_free(xhp->cfg);
free(xhp->cachedir_priv); free(xhp->cachedir_priv);

View File

@@ -34,22 +34,22 @@
* Returns true if entry is a configuration file, false otherwise. * Returns true if entry is a configuration file, false otherwise.
*/ */
int HIDDEN int HIDDEN
xbps_entry_is_a_conf_file(prop_dictionary_t propsd, xbps_entry_is_a_conf_file(xbps_dictionary_t propsd,
const char *entry_pname) const char *entry_pname)
{ {
prop_array_t array; xbps_array_t array;
const char *cffile; const char *cffile;
unsigned int i; unsigned int i;
assert(prop_object_type(propsd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY);
assert(entry_pname != NULL); assert(entry_pname != NULL);
array = prop_dictionary_get(propsd, "conf_files"); array = xbps_dictionary_get(propsd, "conf_files");
if (prop_array_count(array) == 0) if (xbps_array_count(array) == 0)
return false; return false;
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
prop_array_get_cstring_nocopy(array, i, &cffile); xbps_array_get_cstring_nocopy(array, i, &cffile);
if (strcmp(cffile, entry_pname) == 0) if (strcmp(cffile, entry_pname) == 0)
return true; return true;
} }
@@ -61,20 +61,20 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd,
*/ */
int HIDDEN int HIDDEN
xbps_entry_install_conf_file(struct xbps_handle *xhp, xbps_entry_install_conf_file(struct xbps_handle *xhp,
prop_dictionary_t filesd, xbps_dictionary_t filesd,
struct archive_entry *entry, struct archive_entry *entry,
const char *entry_pname, const char *entry_pname,
const char *pkgver, const char *pkgver,
const char *pkgname) const char *pkgname)
{ {
prop_dictionary_t forigd; xbps_dictionary_t forigd;
prop_object_t obj, obj2; xbps_object_t obj, obj2;
prop_object_iterator_t iter, iter2; xbps_object_iterator_t iter, iter2;
const char *cffile, *sha256_new = NULL; const char *cffile, *sha256_new = NULL;
char *buf, *sha256_cur = NULL, *sha256_orig = NULL; char *buf, *sha256_cur = NULL, *sha256_orig = NULL;
int rv = 0; int rv = 0;
assert(prop_object_type(filesd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(filesd) == XBPS_TYPE_DICTIONARY);
assert(entry != NULL); assert(entry != NULL);
assert(entry_pname != NULL); assert(entry_pname != NULL);
assert(pkgver != NULL); assert(pkgver != NULL);
@@ -100,12 +100,12 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
iter2 = xbps_array_iter_from_dict(forigd, "conf_files"); iter2 = xbps_array_iter_from_dict(forigd, "conf_files");
if (iter2 != NULL) { if (iter2 != NULL) {
while ((obj2 = prop_object_iterator_next(iter2))) { while ((obj2 = xbps_object_iterator_next(iter2))) {
prop_dictionary_get_cstring_nocopy(obj2, xbps_dictionary_get_cstring_nocopy(obj2,
"file", &cffile); "file", &cffile);
buf = xbps_xasprintf(".%s", cffile); buf = xbps_xasprintf(".%s", cffile);
if (strcmp(entry_pname, buf) == 0) { if (strcmp(entry_pname, buf) == 0) {
prop_dictionary_get_cstring(obj2, "sha256", xbps_dictionary_get_cstring(obj2, "sha256",
&sha256_orig); &sha256_orig);
free(buf); free(buf);
break; break;
@@ -113,7 +113,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
free(buf); free(buf);
buf = NULL; buf = NULL;
} }
prop_object_iterator_release(iter2); xbps_object_iterator_release(iter2);
} }
/* /*
* First case: original hash not found, install new file. * First case: original hash not found, install new file.
@@ -128,8 +128,8 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
/* /*
* Compare original, installed and new hash for current file. * Compare original, installed and new hash for current file.
*/ */
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &cffile); xbps_dictionary_get_cstring_nocopy(obj, "file", &cffile);
buf = xbps_xasprintf(".%s", cffile); buf = xbps_xasprintf(".%s", cffile);
if (strcmp(entry_pname, buf)) { if (strcmp(entry_pname, buf)) {
free(buf); free(buf);
@@ -138,7 +138,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
} }
sha256_cur = xbps_file_hash(buf); sha256_cur = xbps_file_hash(buf);
free(buf); free(buf);
prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256_new); xbps_dictionary_get_cstring_nocopy(obj, "sha256", &sha256_new);
if (sha256_cur == NULL) { if (sha256_cur == NULL) {
if (errno == ENOENT) { if (errno == ENOENT) {
/* /*
@@ -239,7 +239,7 @@ out:
if (sha256_cur) if (sha256_cur)
free(sha256_cur); free(sha256_cur);
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
xbps_dbg_printf(xhp, "%s: conf_file %s returned %d\n", xbps_dbg_printf(xhp, "%s: conf_file %s returned %d\n",
pkgver, entry_pname, rv); pkgver, entry_pname, rv);

View File

@@ -49,20 +49,20 @@
int int
xbps_configure_packages(struct xbps_handle *xhp, bool flush) xbps_configure_packages(struct xbps_handle *xhp, bool flush)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkgver; const char *pkgver;
int rv; int rv;
if ((rv = xbps_pkgdb_init(xhp)) != 0) if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv; return rv;
iter = prop_dictionary_iterator(xhp->pkgdb); iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
rv = xbps_configure_pkg(xhp, pkgver, true, false, false); rv = xbps_configure_pkg(xhp, pkgver, true, false, false);
if (rv != 0) { if (rv != 0) {
xbps_dbg_printf(xhp, "%s: failed to configure %s: %s\n", xbps_dbg_printf(xhp, "%s: failed to configure %s: %s\n",
@@ -70,7 +70,7 @@ xbps_configure_packages(struct xbps_handle *xhp, bool flush)
break; break;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
if ((rv == 0) && flush) if ((rv == 0) && flush)
rv = xbps_pkgdb_update(xhp, true); rv = xbps_pkgdb_update(xhp, true);
@@ -85,7 +85,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
bool update, bool update,
bool flush) bool flush)
{ {
prop_dictionary_t pkgd, pkgmetad; xbps_dictionary_t pkgd, pkgmetad;
char *pkgname, *plist; char *pkgname, *plist;
int rv = 0; int rv = 0;
pkg_state_t state = 0; pkg_state_t state = 0;
@@ -122,7 +122,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
free(pkgname); free(pkgname);
pkgmetad = prop_dictionary_internalize_from_file(plist); pkgmetad = xbps_dictionary_internalize_from_file(plist);
if (pkgmetad == NULL) { if (pkgmetad == NULL) {
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL, xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
errno, pkgver, errno, pkgver,
@@ -143,7 +143,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
return rv; return rv;
} }
if (state == XBPS_PKG_STATE_INSTALLED) { if (state == XBPS_PKG_STATE_INSTALLED) {
prop_object_release(pkgmetad); xbps_object_release(pkgmetad);
return rv; return rv;
} }
@@ -161,7 +161,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
pkgver, strerror(rv)); pkgver, strerror(rv));
} }
} }
prop_object_release(pkgmetad); xbps_object_release(pkgmetad);
if (rv == 0) if (rv == 0)
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_DONE, 0, pkgver, NULL); xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_DONE, 0, pkgver, NULL);

View File

@@ -33,37 +33,37 @@
void HIDDEN void HIDDEN
xbps_pkg_find_conflicts(struct xbps_handle *xhp, xbps_pkg_find_conflicts(struct xbps_handle *xhp,
prop_array_t unsorted, xbps_array_t unsorted,
prop_dictionary_t pkg_repod) xbps_dictionary_t pkg_repod)
{ {
prop_array_t pkg_cflicts, trans_cflicts; xbps_array_t pkg_cflicts, trans_cflicts;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *cfpkg, *repopkgver, *pkgver; const char *cfpkg, *repopkgver, *pkgver;
char *pkgname, *repopkgname, *buf; char *pkgname, *repopkgname, *buf;
pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts"); pkg_cflicts = xbps_dictionary_get(pkg_repod, "conflicts");
if (prop_array_count(pkg_cflicts) == 0) if (xbps_array_count(pkg_cflicts) == 0)
return; return;
trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts"); trans_cflicts = xbps_dictionary_get(xhp->transd, "conflicts");
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
repopkgname = xbps_pkg_name(repopkgver); repopkgname = xbps_pkg_name(repopkgver);
assert(repopkgname); assert(repopkgname);
iter = prop_array_iterator(pkg_cflicts); iter = xbps_array_iterator(pkg_cflicts);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
cfpkg = prop_string_cstring_nocopy(obj); cfpkg = xbps_string_cstring_nocopy(obj);
/* /*
* Check if current pkg conflicts with an installed package. * Check if current pkg conflicts with an installed package.
*/ */
if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) || if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) ||
(pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) { (pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) {
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver); "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
@@ -77,7 +77,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
repopkgver); repopkgver);
buf = xbps_xasprintf("%s conflicts with " buf = xbps_xasprintf("%s conflicts with "
"installed pkg %s", repopkgver, pkgver); "installed pkg %s", repopkgver, pkgver);
prop_array_add_cstring(trans_cflicts, buf); xbps_array_add_cstring(trans_cflicts, buf);
free(buf); free(buf);
continue; continue;
} }
@@ -86,7 +86,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
*/ */
if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) || if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) ||
(pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) { (pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) {
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver); "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
@@ -99,11 +99,11 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
"transaction %s <-> %s\n", pkgver, repopkgver); "transaction %s <-> %s\n", pkgver, repopkgver);
buf = xbps_xasprintf("%s conflicts with " buf = xbps_xasprintf("%s conflicts with "
"%s in transaction", repopkgver, pkgver); "%s in transaction", repopkgver, pkgver);
prop_array_add_cstring(trans_cflicts, buf); xbps_array_add_cstring(trans_cflicts, buf);
free(buf); free(buf);
continue; continue;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
free(repopkgname); free(repopkgname);
} }

View File

@@ -32,68 +32,68 @@
#include "xbps_api_impl.h" #include "xbps_api_impl.h"
static prop_array_t static xbps_array_t
merge_filelist(prop_dictionary_t d) merge_filelist(xbps_dictionary_t d)
{ {
prop_array_t a, result; xbps_array_t a, result;
prop_dictionary_t filed; xbps_dictionary_t filed;
unsigned int i; unsigned int i;
result = prop_array_create(); result = xbps_array_create();
assert(result); assert(result);
if ((a = prop_dictionary_get(d, "files"))) { if ((a = xbps_dictionary_get(d, "files"))) {
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
filed = prop_array_get(a, i); filed = xbps_array_get(a, i);
prop_array_add(result, filed); xbps_array_add(result, filed);
} }
} }
if ((a = prop_dictionary_get(d, "links"))) { if ((a = xbps_dictionary_get(d, "links"))) {
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
filed = prop_array_get(a, i); filed = xbps_array_get(a, i);
prop_array_add(result, filed); xbps_array_add(result, filed);
} }
} }
if ((a = prop_dictionary_get(d, "conf_files"))) { if ((a = xbps_dictionary_get(d, "conf_files"))) {
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
filed = prop_array_get(a, i); filed = xbps_array_get(a, i);
prop_array_add(result, filed); xbps_array_add(result, filed);
} }
} }
if ((a = prop_dictionary_get(d, "dirs"))) { if ((a = xbps_dictionary_get(d, "dirs"))) {
for (i = 0; i < prop_array_count(a); i++) { for (i = 0; i < xbps_array_count(a); i++) {
filed = prop_array_get(a, i); filed = xbps_array_get(a, i);
prop_array_add(result, filed); xbps_array_add(result, filed);
} }
} }
return result; return result;
} }
prop_array_t xbps_array_t
xbps_find_pkg_obsoletes(struct xbps_handle *xhp, xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
prop_dictionary_t instd, xbps_dictionary_t instd,
prop_dictionary_t newd) xbps_dictionary_t newd)
{ {
prop_array_t instfiles, newfiles, obsoletes; xbps_array_t instfiles, newfiles, obsoletes;
prop_object_t obj, obj2; xbps_object_t obj, obj2;
prop_string_t oldstr, newstr; xbps_string_t oldstr, newstr;
unsigned int i, x; unsigned int i, x;
const char *oldhash; const char *oldhash;
char *file; char *file;
int rv = 0; int rv = 0;
bool found; bool found;
assert(prop_object_type(instd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(instd) == XBPS_TYPE_DICTIONARY);
assert(prop_object_type(newd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(newd) == XBPS_TYPE_DICTIONARY);
obsoletes = prop_array_create(); obsoletes = xbps_array_create();
assert(obsoletes); assert(obsoletes);
instfiles = merge_filelist(instd); instfiles = merge_filelist(instd);
if (prop_array_count(instfiles) == 0) { if (xbps_array_count(instfiles) == 0) {
/* nothing to check if current pkg does not own any file */ /* nothing to check if current pkg does not own any file */
prop_object_release(instfiles); xbps_object_release(instfiles);
return obsoletes; return obsoletes;
} }
newfiles = merge_filelist(newd); newfiles = merge_filelist(newd);
@@ -101,22 +101,22 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/* /*
* Iterate over files list from installed package. * Iterate over files list from installed package.
*/ */
for (i = 0; i < prop_array_count(instfiles); i++) { for (i = 0; i < xbps_array_count(instfiles); i++) {
found = false; found = false;
obj = prop_array_get(instfiles, i); obj = xbps_array_get(instfiles, i);
if (prop_object_type(obj) != PROP_TYPE_DICTIONARY) { if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) {
/* ignore unexistent files */ /* ignore unexistent files */
continue; continue;
} }
oldstr = prop_dictionary_get(obj, "file"); oldstr = xbps_dictionary_get(obj, "file");
if (oldstr == NULL) if (oldstr == NULL)
continue; continue;
file = xbps_xasprintf(".%s", file = xbps_xasprintf(".%s",
prop_string_cstring_nocopy(oldstr)); xbps_string_cstring_nocopy(oldstr));
oldhash = NULL; oldhash = NULL;
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &oldhash); "sha256", &oldhash);
if (oldhash) { if (oldhash) {
rv = xbps_file_hash_check(file, oldhash); rv = xbps_file_hash_check(file, oldhash);
@@ -132,14 +132,14 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/* /*
* Check if current file is available in new pkg filelist. * Check if current file is available in new pkg filelist.
*/ */
for (x = 0; x < prop_array_count(newfiles); x++) { for (x = 0; x < xbps_array_count(newfiles); x++) {
obj2 = prop_array_get(newfiles, x); obj2 = xbps_array_get(newfiles, x);
newstr = prop_dictionary_get(obj2, "file"); newstr = xbps_dictionary_get(obj2, "file");
assert(newstr); assert(newstr);
/* /*
* Skip files with same path. * Skip files with same path.
*/ */
if (prop_string_equals(oldstr, newstr)) { if (xbps_string_equals(oldstr, newstr)) {
found = true; found = true;
break; break;
} }
@@ -167,11 +167,11 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
* Obsolete found, add onto the array. * Obsolete found, add onto the array.
*/ */
xbps_dbg_printf(xhp, "found obsolete: %s\n", file); xbps_dbg_printf(xhp, "found obsolete: %s\n", file);
prop_array_add_cstring(obsoletes, file); xbps_array_add_cstring(obsoletes, file);
free(file); free(file);
} }
prop_object_release(instfiles); xbps_object_release(instfiles);
prop_object_release(newfiles); xbps_object_release(newfiles);
return obsoletes; return obsoletes;
} }

View File

@@ -59,13 +59,13 @@
* dictionary. * dictionary.
*/ */
prop_array_t xbps_array_t
xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user) xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user)
{ {
prop_array_t rdeps, reqby, array = NULL; xbps_array_t rdeps, reqby, array = NULL;
prop_dictionary_t pkgd, deppkgd; xbps_dictionary_t pkgd, deppkgd;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *curpkgver, *deppkgver, *reqbydep; const char *curpkgver, *deppkgver, *reqbydep;
bool automatic = false; bool automatic = false;
unsigned int i, x, j, cnt, reqbycnt; unsigned int i, x, j, cnt, reqbycnt;
@@ -74,64 +74,64 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user)
if (xbps_pkgdb_init(xhp) != 0) if (xbps_pkgdb_init(xhp) != 0)
return NULL; return NULL;
if ((array = prop_array_create()) == NULL) if ((array = xbps_array_create()) == NULL)
return NULL; return NULL;
/* /*
* Add all packages specified by the client. * Add all packages specified by the client.
*/ */
for (i = 0; i < prop_array_count(orphans_user); i++) { for (i = 0; i < xbps_array_count(orphans_user); i++) {
prop_array_get_cstring_nocopy(orphans_user, i, &curpkgver); xbps_array_get_cstring_nocopy(orphans_user, i, &curpkgver);
pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver); pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver);
if (pkgd == NULL) if (pkgd == NULL)
continue; continue;
prop_array_add(array, pkgd); xbps_array_add(array, pkgd);
} }
if (prop_array_count(array)) if (xbps_array_count(array))
goto find_orphans; goto find_orphans;
iter = prop_dictionary_iterator(xhp->pkgdb); iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter); assert(iter);
/* /*
* First pass: track pkgs that were installed manually and * First pass: track pkgs that were installed manually and
* without reverse dependencies. * without reverse dependencies.
*/ */
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
/* /*
* Skip packages that were not installed automatically. * Skip packages that were not installed automatically.
*/ */
prop_dictionary_get_bool(pkgd, "automatic-install", &automatic); xbps_dictionary_get_bool(pkgd, "automatic-install", &automatic);
if (!automatic) if (!automatic)
continue; continue;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, curpkgver); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, curpkgver);
if (prop_array_count(reqby) == 0) { if (xbps_array_count(reqby) == 0) {
/* /*
* Add packages with empty revdeps. * Add packages with empty revdeps.
*/ */
prop_array_add(array, pkgd); xbps_array_add(array, pkgd);
continue; continue;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
find_orphans: find_orphans:
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
pkgd = prop_array_get(array, i); pkgd = xbps_array_get(array, i);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
rdeps = prop_dictionary_get(pkgd, "run_depends"); rdeps = xbps_dictionary_get(pkgd, "run_depends");
for (x = 0; x < prop_array_count(rdeps); x++) { for (x = 0; x < xbps_array_count(rdeps); x++) {
cnt = 0; cnt = 0;
prop_array_get_cstring_nocopy(rdeps, x, &deppkgver); xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
if (reqby == NULL) if (reqby == NULL)
continue; continue;
reqbycnt = prop_array_count(reqby); reqbycnt = xbps_array_count(reqby);
for (j = 0; j < reqbycnt; j++) { for (j = 0; j < reqbycnt; j++) {
prop_array_get_cstring_nocopy(reqby, j, &reqbydep); xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
if (xbps_find_pkg_in_array(array, reqbydep)) { if (xbps_find_pkg_in_array(array, reqbydep)) {
cnt++; cnt++;
continue; continue;
@@ -140,7 +140,7 @@ find_orphans:
if (cnt == reqbycnt) { if (cnt == reqbycnt) {
deppkgd = xbps_pkgdb_get_pkg(xhp, deppkgver); deppkgd = xbps_pkgdb_get_pkg(xhp, deppkgver);
if (!xbps_find_pkg_in_array(array, deppkgver)) if (!xbps_find_pkg_in_array(array, deppkgver))
prop_array_add(array, deppkgd); xbps_array_add(array, deppkgd);
} }
} }
} }

View File

@@ -32,10 +32,10 @@
#include "xbps_api_impl.h" #include "xbps_api_impl.h"
int HIDDEN int HIDDEN
xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd) xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_array_t provides, rundeps; xbps_array_t provides, rundeps;
char outstr[64]; char outstr[64];
time_t t; time_t t;
struct tm *tmp; struct tm *tmp;
@@ -44,13 +44,13 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
int rv = 0; int rv = 0;
bool autoinst = false; bool autoinst = false;
assert(prop_object_type(pkgrd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(pkgrd) == XBPS_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); xbps_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
prop_dictionary_get_bool(pkgrd, "automatic-install", &autoinst); xbps_dictionary_get_bool(pkgrd, "automatic-install", &autoinst);
provides = prop_dictionary_get(pkgrd, "provides"); provides = xbps_dictionary_get(pkgrd, "provides");
rundeps = prop_dictionary_get(pkgrd, "run_depends"); rundeps = xbps_dictionary_get(pkgrd, "run_depends");
assert(pkgver != NULL); assert(pkgver != NULL);
assert(desc != NULL); assert(desc != NULL);
@@ -60,14 +60,14 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
rv = ENOENT; rv = ENOENT;
goto out; goto out;
} }
if (!prop_dictionary_set_cstring_nocopy(pkgd, if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) { "pkgver", pkgver)) {
xbps_dbg_printf(xhp, "%s: invalid pkgver for %s\n", xbps_dbg_printf(xhp, "%s: invalid pkgver for %s\n",
__func__, pkgver); __func__, pkgver);
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (!prop_dictionary_set_cstring_nocopy(pkgd, if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"short_desc", desc)) { "short_desc", desc)) {
xbps_dbg_printf(xhp, "%s: invalid short_desc for %s\n", xbps_dbg_printf(xhp, "%s: invalid short_desc for %s\n",
__func__, pkgver); __func__, pkgver);
@@ -77,7 +77,7 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
if (xhp->flags & XBPS_FLAG_INSTALL_AUTO) if (xhp->flags & XBPS_FLAG_INSTALL_AUTO)
autoinst = true; autoinst = true;
if (!prop_dictionary_set_bool(pkgd, if (!xbps_dictionary_set_bool(pkgd,
"automatic-install", autoinst)) { "automatic-install", autoinst)) {
xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n", xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n",
__func__, pkgver); __func__, pkgver);
@@ -100,19 +100,19 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (!prop_dictionary_set_cstring(pkgd, "install-date", outstr)) { if (!xbps_dictionary_set_cstring(pkgd, "install-date", outstr)) {
xbps_dbg_printf(xhp, "%s: install-date set failed!\n", pkgver); xbps_dbg_printf(xhp, "%s: install-date set failed!\n", pkgver);
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (provides && !prop_dictionary_set(pkgd, "provides", provides)) { if (provides && !xbps_dictionary_set(pkgd, "provides", provides)) {
xbps_dbg_printf(xhp, "%s: failed to set provides for %s\n", xbps_dbg_printf(xhp, "%s: failed to set provides for %s\n",
__func__, pkgver); __func__, pkgver);
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (rundeps && !prop_dictionary_set(pkgd, "run_depends", rundeps)) { if (rundeps && !xbps_dictionary_set(pkgd, "run_depends", rundeps)) {
xbps_dbg_printf(xhp, "%s: failed to set rundeps for %s\n", xbps_dbg_printf(xhp, "%s: failed to set rundeps for %s\n",
__func__, pkgver); __func__, pkgver);
rv = EINVAL; rv = EINVAL;
@@ -127,17 +127,17 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
sha256 = xbps_file_hash(buf); sha256 = xbps_file_hash(buf);
assert(sha256); assert(sha256);
prop_dictionary_set_cstring(pkgd, "metafile-sha256", sha256); xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
free(sha256); free(sha256);
free(buf); free(buf);
/* /*
* Remove unneeded objs from pkg dictionary. * Remove unneeded objs from pkg dictionary.
*/ */
prop_dictionary_remove(pkgd, "remove-and-update"); xbps_dictionary_remove(pkgd, "remove-and-update");
prop_dictionary_remove(pkgd, "transaction"); xbps_dictionary_remove(pkgd, "transaction");
prop_dictionary_remove(pkgd, "skip-obsoletes"); xbps_dictionary_remove(pkgd, "skip-obsoletes");
if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
xbps_dbg_printf(xhp, xbps_dbg_printf(xhp,
"%s: failed to set pkgd for %s\n", __func__, pkgver); "%s: failed to set pkgd for %s\n", __func__, pkgver);
goto out; goto out;

View File

@@ -35,24 +35,24 @@
int HIDDEN int HIDDEN
xbps_remove_pkg_files(struct xbps_handle *xhp, xbps_remove_pkg_files(struct xbps_handle *xhp,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *key, const char *key,
const char *pkgver) const char *pkgver)
{ {
struct stat st; struct stat st;
prop_array_t array; xbps_array_t array;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_object_t obj; xbps_object_t obj;
const char *file, *sha256, *curobj = NULL; const char *file, *sha256, *curobj = NULL;
char *path = NULL, *pkgname = NULL; char *path = NULL, *pkgname = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
int rv = 0; int rv = 0;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(key != NULL); assert(key != NULL);
array = prop_dictionary_get(dict, key); array = xbps_dictionary_get(dict, key);
if (prop_array_count(array) == 0) if (xbps_array_count(array) == 0)
return 0; return 0;
iter = xbps_array_iter_from_dict(dict, key); iter = xbps_array_iter_from_dict(dict, key);
@@ -71,8 +71,8 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file); xbps_dictionary_get_cstring_nocopy(obj, "file", &file);
path = xbps_xasprintf("%s/%s", xhp->rootdir, file); path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
if ((strcmp(key, "files") == 0) || if ((strcmp(key, "files") == 0) ||
@@ -81,7 +81,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
* Check SHA256 hash in regular files and * Check SHA256 hash in regular files and
* configuration files. * configuration files.
*/ */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256); "sha256", &sha256);
rv = xbps_file_hash_check(path, sha256); rv = xbps_file_hash_check(path, sha256);
if (rv == ENOENT) { if (rv == ENOENT) {
@@ -157,7 +157,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
} }
free(path); free(path);
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
free(pkgname); free(pkgname);
return rv; return rv;
@@ -169,7 +169,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
bool update, bool update,
bool soft_replace) bool soft_replace)
{ {
prop_dictionary_t pkgd = NULL; xbps_dictionary_t pkgd = NULL;
char *pkgname, *buf = NULL; char *pkgname, *buf = NULL;
int rv = 0; int rv = 0;
pkg_state_t state = 0; pkg_state_t state = 0;
@@ -200,7 +200,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
/* internalize pkg dictionary from metadir */ /* internalize pkg dictionary from metadir */
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
pkgd = prop_dictionary_internalize_from_file(buf); pkgd = xbps_dictionary_internalize_from_file(buf);
free(buf); free(buf);
if (pkgd == NULL) if (pkgd == NULL)
xbps_dbg_printf(xhp, "WARNING: metaplist for %s " xbps_dbg_printf(xhp, "WARNING: metaplist for %s "
@@ -231,7 +231,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
*/ */
if (update) { if (update) {
if (pkgd) if (pkgd)
prop_object_release(pkgd); xbps_object_release(pkgd);
free(pkgname); free(pkgname);
return 0; return 0;
} else if (soft_replace) { } else if (soft_replace) {
@@ -297,7 +297,7 @@ purge:
"purge ACTION: %s", pkgver, strerror(rv)); "purge ACTION: %s", pkgver, strerror(rv));
goto out; goto out;
} }
prop_object_release(pkgd); xbps_object_release(pkgd);
} }
/* /*
* Remove package metadata plist. * Remove package metadata plist.
@@ -315,7 +315,7 @@ purge:
/* /*
* Unregister package from pkgdb. * Unregister package from pkgdb.
*/ */
prop_dictionary_remove(xhp->pkgdb, pkgname); xbps_dictionary_remove(xhp->pkgdb, pkgname);
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
goto out; goto out;

View File

@@ -109,12 +109,12 @@ out:
int int
xbps_pkg_exec_script(struct xbps_handle *xhp, xbps_pkg_exec_script(struct xbps_handle *xhp,
prop_dictionary_t d, xbps_dictionary_t d,
const char *script, const char *script,
const char *action, const char *action,
bool update) bool update)
{ {
prop_data_t data; xbps_data_t data;
void *buf; void *buf;
size_t buflen; size_t buflen;
const char *pkgver; const char *pkgver;
@@ -125,14 +125,14 @@ xbps_pkg_exec_script(struct xbps_handle *xhp,
assert(script); assert(script);
assert(action); assert(action);
data = prop_dictionary_get(d, script); data = xbps_dictionary_get(d, script);
if (data == NULL) if (data == NULL)
return 0; return 0;
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
buf = prop_data_data(data); buf = xbps_data_data(data);
buflen = prop_data_size(data); buflen = xbps_data_size(data);
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, action, update); rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, action, update);
free(buf); free(buf);

View File

@@ -53,11 +53,11 @@ static const struct state states[] = {
*/ */
static int static int
set_new_state(prop_dictionary_t dict, pkg_state_t state) set_new_state(xbps_dictionary_t dict, pkg_state_t state)
{ {
const struct state *stp; const struct state *stp;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
for (stp = states; stp->string != NULL; stp++) for (stp = states; stp->string != NULL; stp++)
if (state == stp->number) if (state == stp->number)
@@ -66,21 +66,21 @@ set_new_state(prop_dictionary_t dict, pkg_state_t state)
if (stp->string == NULL) if (stp->string == NULL)
return EINVAL; return EINVAL;
if (!prop_dictionary_set_cstring_nocopy(dict, "state", stp->string)) if (!xbps_dictionary_set_cstring_nocopy(dict, "state", stp->string))
return EINVAL; return EINVAL;
return 0; return 0;
} }
static pkg_state_t static pkg_state_t
get_state(prop_dictionary_t dict) get_state(xbps_dictionary_t dict)
{ {
const struct state *stp; const struct state *stp;
const char *state_str; const char *state_str;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
if (!prop_dictionary_get_cstring_nocopy(dict, if (!xbps_dictionary_get_cstring_nocopy(dict,
"state", &state_str)) "state", &state_str))
return 0; return 0;
@@ -96,7 +96,7 @@ xbps_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgver, const char *pkgver,
pkg_state_t *state) pkg_state_t *state)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
assert(pkgver != NULL); assert(pkgver != NULL);
assert(state != NULL); assert(state != NULL);
@@ -113,9 +113,9 @@ xbps_pkg_state_installed(struct xbps_handle *xhp,
} }
int int
xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state) xbps_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t *state)
{ {
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(state != NULL); assert(state != NULL);
if ((*state = get_state(dict)) == 0) if ((*state = get_state(dict)) == 0)
@@ -125,9 +125,9 @@ xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state)
} }
int int
xbps_set_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t state) xbps_set_pkg_state_dictionary(xbps_dictionary_t dict, pkg_state_t state)
{ {
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
return set_new_state(dict, state); return set_new_state(dict, state);
} }
@@ -137,7 +137,7 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgver, const char *pkgver,
pkg_state_t state) pkg_state_t state)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
char *pkgname; char *pkgname;
int rv = 0; int rv = 0;
@@ -145,35 +145,35 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
pkgd = xbps_pkgdb_get_pkg(xhp, pkgver); pkgd = xbps_pkgdb_get_pkg(xhp, pkgver);
if (pkgd == NULL) { if (pkgd == NULL) {
pkgd = prop_dictionary_create(); pkgd = xbps_dictionary_create();
if (pkgd == NULL) if (pkgd == NULL)
return ENOMEM; return ENOMEM;
if (!prop_dictionary_set_cstring_nocopy(pkgd, if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) { "pkgver", pkgver)) {
prop_object_release(pkgd); xbps_object_release(pkgd);
return EINVAL; return EINVAL;
} }
if ((rv = set_new_state(pkgd, state)) != 0) { if ((rv = set_new_state(pkgd, state)) != 0) {
prop_object_release(pkgd); xbps_object_release(pkgd);
return rv; return rv;
} }
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
prop_object_release(pkgd); xbps_object_release(pkgd);
free(pkgname); free(pkgname);
return EINVAL; return EINVAL;
} }
free(pkgname); free(pkgname);
prop_object_release(pkgd); xbps_object_release(pkgd);
} else { } else {
if ((rv = set_new_state(pkgd, state)) != 0) if ((rv = set_new_state(pkgd, state)) != 0)
return rv; return rv;
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
free(pkgname); free(pkgname);
return EINVAL; return EINVAL;
} }

View File

@@ -53,23 +53,23 @@ set_extract_flags(uid_t euid)
} }
static const char * static const char *
find_pkg_symlink_target(prop_dictionary_t d, const char *file) find_pkg_symlink_target(xbps_dictionary_t d, const char *file)
{ {
prop_array_t links; xbps_array_t links;
prop_object_t obj; xbps_object_t obj;
unsigned int i; unsigned int i;
const char *pkgfile, *tgt = NULL; const char *pkgfile, *tgt = NULL;
char *rfile; char *rfile;
assert(d); assert(d);
links = prop_dictionary_get(d, "links"); links = xbps_dictionary_get(d, "links");
for (i = 0; i < prop_array_count(links); i++) { for (i = 0; i < xbps_array_count(links); i++) {
rfile = strchr(file, '.') + 1; rfile = strchr(file, '.') + 1;
obj = prop_array_get(links, i); obj = xbps_array_get(links, i);
prop_dictionary_get_cstring_nocopy(obj, "file", &pkgfile); xbps_dictionary_get_cstring_nocopy(obj, "file", &pkgfile);
if (strcmp(rfile, pkgfile) == 0) { if (strcmp(rfile, pkgfile) == 0) {
prop_dictionary_get_cstring_nocopy(obj, "target", &tgt); xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt);
break; break;
} }
} }
@@ -79,52 +79,52 @@ find_pkg_symlink_target(prop_dictionary_t d, const char *file)
static int static int
create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *pkgver, create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *pkgver,
prop_dictionary_t propsd, prop_dictionary_t filesd, xbps_dictionary_t propsd, xbps_dictionary_t filesd,
const void *instbuf, const size_t instbufsiz, const void *instbuf, const size_t instbufsiz,
const void *rembuf, const size_t rembufsiz) const void *rembuf, const size_t rembufsiz)
{ {
prop_array_t array; xbps_array_t array;
prop_dictionary_t pkg_metad; xbps_dictionary_t pkg_metad;
prop_data_t data; xbps_data_t data;
char *buf; char *buf;
int rv = 0; int rv = 0;
prop_dictionary_make_immutable(propsd); xbps_dictionary_make_immutable(propsd);
pkg_metad = prop_dictionary_copy_mutable(propsd); pkg_metad = xbps_dictionary_copy_mutable(propsd);
/* Add objects from XBPS_PKGFILES */ /* Add objects from XBPS_PKGFILES */
array = prop_dictionary_get(filesd, "files"); array = xbps_dictionary_get(filesd, "files");
if (prop_array_count(array)) if (xbps_array_count(array))
prop_dictionary_set(pkg_metad, "files", array); xbps_dictionary_set(pkg_metad, "files", array);
array = prop_dictionary_get(filesd, "conf_files"); array = xbps_dictionary_get(filesd, "conf_files");
if (prop_array_count(array)) if (xbps_array_count(array))
prop_dictionary_set(pkg_metad, "conf_files", array); xbps_dictionary_set(pkg_metad, "conf_files", array);
array = prop_dictionary_get(filesd, "links"); array = xbps_dictionary_get(filesd, "links");
if (prop_array_count(array)) if (xbps_array_count(array))
prop_dictionary_set(pkg_metad, "links", array); xbps_dictionary_set(pkg_metad, "links", array);
array = prop_dictionary_get(filesd, "dirs"); array = xbps_dictionary_get(filesd, "dirs");
if (prop_array_count(array)) if (xbps_array_count(array))
prop_dictionary_set(pkg_metad, "dirs", array); xbps_dictionary_set(pkg_metad, "dirs", array);
/* Add install/remove scripts data objects */ /* Add install/remove scripts data objects */
if (instbuf != NULL) { if (instbuf != NULL) {
data = prop_data_create_data(instbuf, instbufsiz); data = xbps_data_create_data(instbuf, instbufsiz);
assert(data); assert(data);
prop_dictionary_set(pkg_metad, "install-script", data); xbps_dictionary_set(pkg_metad, "install-script", data);
prop_object_release(data); xbps_object_release(data);
} }
if (rembuf != NULL) { if (rembuf != NULL) {
data = prop_data_create_data(rembuf, rembufsiz); data = xbps_data_create_data(rembuf, rembufsiz);
assert(data); assert(data);
prop_dictionary_set(pkg_metad, "remove-script", data); xbps_dictionary_set(pkg_metad, "remove-script", data);
prop_object_release(data); xbps_object_release(data);
} }
/* Remove unneeded objs from transaction */ /* Remove unneeded objs from transaction */
prop_dictionary_remove(pkg_metad, "remove-and-update"); xbps_dictionary_remove(pkg_metad, "remove-and-update");
prop_dictionary_remove(pkg_metad, "transaction"); xbps_dictionary_remove(pkg_metad, "transaction");
prop_dictionary_remove(pkg_metad, "state"); xbps_dictionary_remove(pkg_metad, "state");
prop_dictionary_remove(pkg_metad, "pkgname"); xbps_dictionary_remove(pkg_metad, "pkgname");
prop_dictionary_remove(pkg_metad, "version"); xbps_dictionary_remove(pkg_metad, "version");
/* /*
* Externalize pkg dictionary to metadir. * Externalize pkg dictionary to metadir.
@@ -137,7 +137,7 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p
} }
} }
buf = xbps_xasprintf("%s/.%s.plist", XBPS_META_PATH, pkgname); buf = xbps_xasprintf("%s/.%s.plist", XBPS_META_PATH, pkgname);
if (!prop_dictionary_externalize_to_file(pkg_metad, buf)) { if (!xbps_dictionary_externalize_to_file(pkg_metad, buf)) {
rv = errno; rv = errno;
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
errno, pkgver, errno, pkgver,
@@ -145,21 +145,21 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p
pkgver, buf, strerror(errno)); pkgver, buf, strerror(errno));
} }
free(buf); free(buf);
prop_object_release(pkg_metad); xbps_object_release(pkg_metad);
return rv; return rv;
} }
static int static int
unpack_archive(struct xbps_handle *xhp, unpack_archive(struct xbps_handle *xhp,
prop_dictionary_t pkg_repod, xbps_dictionary_t pkg_repod,
const char *pkgver, const char *pkgver,
const char *fname, const char *fname,
struct archive *ar) struct archive *ar)
{ {
prop_dictionary_t propsd, filesd, old_filesd; xbps_dictionary_t propsd, filesd, old_filesd;
prop_array_t array, obsoletes; xbps_array_t array, obsoletes;
prop_object_t obj; xbps_object_t obj;
void *instbuf = NULL, *rembuf = NULL; void *instbuf = NULL, *rembuf = NULL;
struct stat st; struct stat st;
struct xbps_unpack_cb_data xucd; struct xbps_unpack_cb_data xucd;
@@ -173,17 +173,17 @@ unpack_archive(struct xbps_handle *xhp,
bool softreplace, skip_extract, force, metafile; bool softreplace, skip_extract, force, metafile;
uid_t euid; uid_t euid;
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
assert(ar != NULL); assert(ar != NULL);
propsd = filesd = old_filesd = NULL; propsd = filesd = old_filesd = NULL;
force = preserve = update = conf_file = file_exists = false; force = preserve = update = conf_file = file_exists = false;
skip_obsoletes = softreplace = metafile = false; skip_obsoletes = softreplace = metafile = false;
prop_dictionary_get_bool(pkg_repod, "preserve", &preserve); xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
prop_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes); xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes);
prop_dictionary_get_bool(pkg_repod, "softreplace", &softreplace); xbps_dictionary_get_bool(pkg_repod, "softreplace", &softreplace);
prop_dictionary_get_cstring_nocopy(pkg_repod, xbps_dictionary_get_cstring_nocopy(pkg_repod,
"transaction", &transact); "transaction", &transact);
euid = geteuid(); euid = geteuid();
@@ -350,15 +350,15 @@ unpack_archive(struct xbps_handle *xhp,
*/ */
if (xhp->unpack_cb != NULL) { if (xhp->unpack_cb != NULL) {
xucd.entry_total_count = 0; xucd.entry_total_count = 0;
array = prop_dictionary_get(filesd, "files"); array = xbps_dictionary_get(filesd, "files");
xucd.entry_total_count += xucd.entry_total_count +=
(ssize_t)prop_array_count(array); (ssize_t)xbps_array_count(array);
array = prop_dictionary_get(filesd, "conf_files"); array = xbps_dictionary_get(filesd, "conf_files");
xucd.entry_total_count += xucd.entry_total_count +=
(ssize_t)prop_array_count(array); (ssize_t)xbps_array_count(array);
array = prop_dictionary_get(filesd, "links"); array = xbps_dictionary_get(filesd, "links");
xucd.entry_total_count += xucd.entry_total_count +=
(ssize_t)prop_array_count(array); (ssize_t)xbps_array_count(array);
} }
/* /*
* Always check that extracted file exists and hash * Always check that extracted file exists and hash
@@ -589,9 +589,9 @@ unpack_archive(struct xbps_handle *xhp,
goto out; goto out;
obsoletes = xbps_find_pkg_obsoletes(xhp, old_filesd, filesd); obsoletes = xbps_find_pkg_obsoletes(xhp, old_filesd, filesd);
for (i = 0; i < prop_array_count(obsoletes); i++) { for (i = 0; i < xbps_array_count(obsoletes); i++) {
obj = prop_array_get(obsoletes, i); obj = xbps_array_get(obsoletes, i);
file = prop_string_cstring_nocopy(obj); file = xbps_string_cstring_nocopy(obj);
if (remove(file) == -1) { if (remove(file) == -1) {
xbps_set_cb_state(xhp, xbps_set_cb_state(xhp,
XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL, XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
@@ -603,14 +603,14 @@ unpack_archive(struct xbps_handle *xhp,
xbps_set_cb_state(xhp, xbps_set_cb_state(xhp,
XBPS_STATE_REMOVE_FILE_OBSOLETE, XBPS_STATE_REMOVE_FILE_OBSOLETE,
0, pkgver, "%s: removed obsolete entry: %s", pkgver, file); 0, pkgver, "%s: removed obsolete entry: %s", pkgver, file);
prop_object_release(obj); xbps_object_release(obj);
} }
out: out:
if (prop_object_type(filesd) == PROP_TYPE_DICTIONARY) if (xbps_object_type(filesd) == XBPS_TYPE_DICTIONARY)
prop_object_release(filesd); xbps_object_release(filesd);
if (prop_object_type(propsd) == PROP_TYPE_DICTIONARY) if (xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY)
prop_object_release(propsd); xbps_object_release(propsd);
if (pkgname != NULL) if (pkgname != NULL)
free(pkgname); free(pkgname);
if (instbuf != NULL) if (instbuf != NULL)
@@ -622,16 +622,16 @@ out:
} }
int HIDDEN int HIDDEN
xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod) xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
{ {
struct archive *ar = NULL; struct archive *ar = NULL;
const char *pkgver; const char *pkgver;
char *bpkg; char *bpkg;
int pkg_fd, rv = 0; int pkg_fd, rv = 0;
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK, 0, pkgver, NULL); xbps_set_cb_state(xhp, XBPS_STATE_UNPACK, 0, pkgver, NULL);
bpkg = xbps_repository_pkg_path(xhp, pkg_repod); bpkg = xbps_repository_pkg_path(xhp, pkg_repod);

View File

@@ -79,7 +79,7 @@ xbps_pkgdb_init(struct xbps_handle *xhp)
int int
xbps_pkgdb_update(struct xbps_handle *xhp, bool flush) xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
{ {
prop_dictionary_t pkgdb_storage; xbps_dictionary_t pkgdb_storage;
char *plist; char *plist;
static int cached_rv; static int cached_rv;
int rv = 0; int rv = 0;
@@ -89,26 +89,26 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB); plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
if (xhp->pkgdb && flush) { if (xhp->pkgdb && flush) {
pkgdb_storage = prop_dictionary_internalize_from_file(plist); pkgdb_storage = xbps_dictionary_internalize_from_file(plist);
if (pkgdb_storage == NULL || if (pkgdb_storage == NULL ||
!prop_dictionary_equals(xhp->pkgdb, pkgdb_storage)) { !xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
/* flush dictionary to storage */ /* flush dictionary to storage */
if (!prop_dictionary_externalize_to_file(xhp->pkgdb, plist)) { if (!xbps_dictionary_externalize_to_file(xhp->pkgdb, plist)) {
free(plist); free(plist);
return errno; return errno;
} }
} }
if (pkgdb_storage) if (pkgdb_storage)
prop_object_release(pkgdb_storage); xbps_object_release(pkgdb_storage);
prop_object_release(xhp->pkgdb); xbps_object_release(xhp->pkgdb);
xhp->pkgdb = NULL; xhp->pkgdb = NULL;
cached_rv = 0; cached_rv = 0;
} }
/* update copy in memory */ /* update copy in memory */
if ((xhp->pkgdb = prop_dictionary_internalize_from_file(plist)) == NULL) { if ((xhp->pkgdb = xbps_dictionary_internalize_from_file(plist)) == NULL) {
if (errno == ENOENT) if (errno == ENOENT)
xhp->pkgdb = prop_dictionary_create(); xhp->pkgdb = xbps_dictionary_create();
else else
xbps_error_printf("cannot access to pkgdb: %s\n", strerror(errno)); xbps_error_printf("cannot access to pkgdb: %s\n", strerror(errno));
@@ -127,22 +127,22 @@ xbps_pkgdb_release(struct xbps_handle *xhp)
if (xhp->pkgdb == NULL) if (xhp->pkgdb == NULL)
return; return;
if (prop_object_type(xhp->pkg_metad) == PROP_TYPE_DICTIONARY) if (xbps_object_type(xhp->pkg_metad) == XBPS_TYPE_DICTIONARY)
prop_object_release(xhp->pkg_metad); xbps_object_release(xhp->pkg_metad);
prop_object_release(xhp->pkgdb); xbps_object_release(xhp->pkgdb);
xhp->pkgdb = NULL; xhp->pkgdb = NULL;
xbps_dbg_printf(xhp, "[pkgdb] released ok.\n"); xbps_dbg_printf(xhp, "[pkgdb] released ok.\n");
} }
int int
xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp, xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg) void *arg)
{ {
prop_array_t allkeys; xbps_array_t allkeys;
prop_object_t obj; xbps_object_t obj;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
unsigned int i; unsigned int i;
int rv; int rv;
bool done = false; bool done = false;
@@ -150,45 +150,45 @@ xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
if ((rv = xbps_pkgdb_init(xhp)) != 0) if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv; return rv;
allkeys = prop_dictionary_all_keys(xhp->pkgdb); allkeys = xbps_dictionary_all_keys(xhp->pkgdb);
for (i = prop_array_count(allkeys); i > 0; i--) { for (i = xbps_array_count(allkeys); i > 0; i--) {
obj = prop_array_get(allkeys, i); obj = xbps_array_get(allkeys, i);
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rv = (*fn)(xhp, pkgd, arg, &done); rv = (*fn)(xhp, pkgd, arg, &done);
if (rv != 0 || done) if (rv != 0 || done)
break; break;
} }
prop_object_release(allkeys); xbps_object_release(allkeys);
return rv; return rv;
} }
int int
xbps_pkgdb_foreach_cb(struct xbps_handle *xhp, xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg) void *arg)
{ {
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
int rv; int rv;
bool done = false; bool done = false;
if ((rv = xbps_pkgdb_init(xhp)) != 0) if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv; return rv;
iter = prop_dictionary_iterator(xhp->pkgdb); iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rv = (*fn)(xhp, pkgd, arg, &done); rv = (*fn)(xhp, pkgd, arg, &done);
if (rv != 0 || done) if (rv != 0 || done)
break; break;
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return rv; return rv;
} }
prop_dictionary_t xbps_dictionary_t
xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg) xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
{ {
if (xbps_pkgdb_init(xhp) != 0) if (xbps_pkgdb_init(xhp) != 0)
@@ -197,7 +197,7 @@ xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg)
return xbps_find_pkg_in_dict(xhp->pkgdb, pkg); return xbps_find_pkg_in_dict(xhp->pkgdb, pkg);
} }
prop_dictionary_t xbps_dictionary_t
xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg) xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg)
{ {
if (xbps_pkgdb_init(xhp) != 0) if (xbps_pkgdb_init(xhp) != 0)
@@ -206,23 +206,23 @@ xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg)
return xbps_find_virtualpkg_in_dict(xhp, xhp->pkgdb, vpkg); return xbps_find_virtualpkg_in_dict(xhp, xhp->pkgdb, vpkg);
} }
static prop_dictionary_t static xbps_dictionary_t
get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd) get_pkg_metadata(struct xbps_handle *xhp, xbps_dictionary_t pkgd)
{ {
prop_dictionary_t pkg_metad; xbps_dictionary_t pkg_metad;
const char *pkgver; const char *pkgver;
char *pkgname, *plist; char *pkgname, *plist;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
if ((pkg_metad = prop_dictionary_get(xhp->pkg_metad, pkgname)) != NULL) { if ((pkg_metad = xbps_dictionary_get(xhp->pkg_metad, pkgname)) != NULL) {
free(pkgname); free(pkgname);
return pkg_metad; return pkg_metad;
} }
plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); plist = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
pkg_metad = prop_dictionary_internalize_from_file(plist); pkg_metad = xbps_dictionary_internalize_from_file(plist);
free(plist); free(plist);
if (pkg_metad == NULL) { if (pkg_metad == NULL) {
@@ -233,10 +233,10 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd)
} }
if (xhp->pkg_metad == NULL) if (xhp->pkg_metad == NULL)
xhp->pkg_metad = prop_dictionary_create(); xhp->pkg_metad = xbps_dictionary_create();
prop_dictionary_set(xhp->pkg_metad, pkgname, pkg_metad); xbps_dictionary_set(xhp->pkg_metad, pkgname, pkg_metad);
prop_object_release(pkg_metad); xbps_object_release(pkg_metad);
free(pkgname); free(pkgname);
return pkg_metad; return pkg_metad;
@@ -245,10 +245,10 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd)
static void static void
generate_full_revdeps_tree(struct xbps_handle *xhp) generate_full_revdeps_tree(struct xbps_handle *xhp)
{ {
prop_array_t rundeps, pkg; xbps_array_t rundeps, pkg;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkgver, *pkgdep, *vpkgname; const char *pkgver, *pkgdep, *vpkgname;
char *curpkgname; char *curpkgname;
unsigned int i; unsigned int i;
@@ -257,20 +257,20 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (xhp->pkgdb_revdeps) if (xhp->pkgdb_revdeps)
return; return;
xhp->pkgdb_revdeps = prop_dictionary_create(); xhp->pkgdb_revdeps = xbps_dictionary_create();
iter = prop_dictionary_iterator(xhp->pkgdb); iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
rundeps = prop_dictionary_get(pkgd, "run_depends"); rundeps = xbps_dictionary_get(pkgd, "run_depends");
if (!prop_array_count(rundeps)) if (!xbps_array_count(rundeps))
continue; continue;
for (i = 0; i < prop_array_count(rundeps); i++) { for (i = 0; i < xbps_array_count(rundeps); i++) {
alloc = false; alloc = false;
prop_array_get_cstring_nocopy(rundeps, i, &pkgdep); xbps_array_get_cstring_nocopy(rundeps, i, &pkgdep);
curpkgname = xbps_pkgpattern_name(pkgdep); curpkgname = xbps_pkgpattern_name(pkgdep);
if (curpkgname == NULL) if (curpkgname == NULL)
curpkgname = xbps_pkg_name(pkgdep); curpkgname = xbps_pkg_name(pkgdep);
@@ -279,29 +279,29 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (vpkgname == NULL) if (vpkgname == NULL)
vpkgname = curpkgname; vpkgname = curpkgname;
pkg = prop_dictionary_get(xhp->pkgdb_revdeps, vpkgname); pkg = xbps_dictionary_get(xhp->pkgdb_revdeps, vpkgname);
if (pkg == NULL) { if (pkg == NULL) {
alloc = true; alloc = true;
pkg = prop_array_create(); pkg = xbps_array_create();
} }
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
if (!xbps_match_string_in_array(pkg, pkgver)) { if (!xbps_match_string_in_array(pkg, pkgver)) {
prop_array_add_cstring_nocopy(pkg, pkgver); xbps_array_add_cstring_nocopy(pkg, pkgver);
prop_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg); xbps_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg);
} }
free(curpkgname); free(curpkgname);
if (alloc) if (alloc)
prop_object_release(pkg); xbps_object_release(pkg);
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
} }
prop_array_t xbps_array_t
xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
prop_array_t res; xbps_array_t res;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *pkgver; const char *pkgver;
char *pkgname; char *pkgname;
@@ -309,18 +309,18 @@ xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
return NULL; return NULL;
generate_full_revdeps_tree(xhp); generate_full_revdeps_tree(xhp);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
res = prop_dictionary_get(xhp->pkgdb_revdeps, pkgname); res = xbps_dictionary_get(xhp->pkgdb_revdeps, pkgname);
free(pkgname); free(pkgname);
return res; return res;
} }
prop_dictionary_t xbps_dictionary_t
xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp, const char *pkg) xbps_pkgdb_get_pkg_metadata(struct xbps_handle *xhp, const char *pkg)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
pkgd = xbps_pkgdb_get_pkg(xhp, pkg); pkgd = xbps_pkgdb_get_pkg(xhp, pkg);
if (pkgd == NULL) if (pkgd == NULL)

View File

@@ -40,88 +40,88 @@
* all library functions. * all library functions.
*/ */
bool HIDDEN bool HIDDEN
xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj, xbps_add_obj_to_dict(xbps_dictionary_t dict, xbps_object_t obj,
const char *key) const char *key)
{ {
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(obj != NULL); assert(obj != NULL);
assert(key != NULL); assert(key != NULL);
if (!prop_dictionary_set(dict, key, obj)) { if (!xbps_dictionary_set(dict, key, obj)) {
prop_object_release(dict); xbps_object_release(dict);
errno = EINVAL; errno = EINVAL;
return false; return false;
} }
prop_object_release(obj); xbps_object_release(obj);
return true; return true;
} }
bool HIDDEN bool HIDDEN
xbps_add_obj_to_array(prop_array_t array, prop_object_t obj) xbps_add_obj_to_array(xbps_array_t array, xbps_object_t obj)
{ {
assert(prop_object_type(array) == PROP_TYPE_ARRAY); assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(obj != NULL); assert(obj != NULL);
if (!prop_array_add(array, obj)) { if (!xbps_array_add(array, obj)) {
prop_object_release(array); xbps_object_release(array);
errno = EINVAL; errno = EINVAL;
return false; return false;
} }
prop_object_release(obj); xbps_object_release(obj);
return true; return true;
} }
int int
xbps_callback_array_iter(struct xbps_handle *xhp, xbps_callback_array_iter(struct xbps_handle *xhp,
prop_array_t array, xbps_array_t array,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg) void *arg)
{ {
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
int rv = 0; int rv = 0;
bool loop_done = false; bool loop_done = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY); assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(fn != NULL); assert(fn != NULL);
iter = prop_array_iterator(array); iter = xbps_array_iterator(array);
if (iter == NULL) if (iter == NULL)
return ENOMEM; return ENOMEM;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
rv = (*fn)(xhp, obj, arg, &loop_done); rv = (*fn)(xhp, obj, arg, &loop_done);
if (rv != 0 || loop_done) if (rv != 0 || loop_done)
break; break;
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return rv; return rv;
} }
int int
xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *key, const char *key,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg) void *arg)
{ {
prop_object_t obj; xbps_object_t obj;
prop_array_t array; xbps_array_t array;
unsigned int i; unsigned int i;
int rv = 0; int rv = 0;
bool cbloop_done = false; bool cbloop_done = false;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(xhp != NULL); assert(xhp != NULL);
assert(key != NULL); assert(key != NULL);
assert(fn != NULL); assert(fn != NULL);
array = prop_dictionary_get(dict, key); array = xbps_dictionary_get(dict, key);
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
if (obj == NULL) if (obj == NULL)
continue; continue;
rv = (*fn)(xhp, obj, arg, &cbloop_done); rv = (*fn)(xhp, obj, arg, &cbloop_done);
@@ -134,24 +134,24 @@ xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
int int
xbps_callback_array_iter_reverse(struct xbps_handle *xhp, xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
prop_array_t array, xbps_array_t array,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg) void *arg)
{ {
prop_object_t obj; xbps_object_t obj;
unsigned int cnt; unsigned int cnt;
int rv = 0; int rv = 0;
bool loop_done = false; bool loop_done = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY); assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(fn != NULL); assert(fn != NULL);
assert(xhp != NULL); assert(xhp != NULL);
if ((cnt = prop_array_count(array)) == 0) if ((cnt = xbps_array_count(array)) == 0)
return 0; return 0;
while (cnt--) { while (cnt--) {
obj = prop_array_get(array, cnt); obj = xbps_array_get(array, cnt);
if (obj == NULL) if (obj == NULL)
continue; continue;
rv = (*fn)(xhp, obj, arg, &loop_done); rv = (*fn)(xhp, obj, arg, &loop_done);
@@ -164,20 +164,20 @@ xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
int int
xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp, xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *key, const char *key,
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *),
void *arg) void *arg)
{ {
prop_array_t array; xbps_array_t array;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(key != NULL); assert(key != NULL);
assert(fn != NULL); assert(fn != NULL);
assert(xhp != NULL); assert(xhp != NULL);
array = prop_dictionary_get(dict, key); array = xbps_dictionary_get(dict, key);
if (prop_object_type(array) != PROP_TYPE_ARRAY) { if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
xbps_dbg_printf(xhp, "invalid key '%s' for dictionary", key); xbps_dbg_printf(xhp, "invalid key '%s' for dictionary", key);
return EINVAL; return EINVAL;
} }
@@ -185,60 +185,60 @@ xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
return xbps_callback_array_iter_reverse(xhp, array, fn, arg); return xbps_callback_array_iter_reverse(xhp, array, fn, arg);
} }
prop_object_iterator_t xbps_object_iterator_t
xbps_array_iter_from_dict(prop_dictionary_t dict, const char *key) xbps_array_iter_from_dict(xbps_dictionary_t dict, const char *key)
{ {
prop_array_t array; xbps_array_t array;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(key != NULL); assert(key != NULL);
array = prop_dictionary_get(dict, key); array = xbps_dictionary_get(dict, key);
if (prop_object_type(array) != PROP_TYPE_ARRAY) { if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
} }
return prop_array_iterator(array); return xbps_array_iterator(array);
} }
static int static int
array_replace_dict(prop_array_t array, array_replace_dict(xbps_array_t array,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *str, const char *str,
bool bypattern) bool bypattern)
{ {
prop_object_t obj; xbps_object_t obj;
unsigned int i; unsigned int i;
const char *curpkgver; const char *curpkgver;
char *curpkgname; char *curpkgname;
assert(prop_object_type(array) == PROP_TYPE_ARRAY); assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(str != NULL); assert(str != NULL);
for (i = 0; i < prop_array_count(array); i++) { for (i = 0; i < xbps_array_count(array); i++) {
obj = prop_array_get(array, i); obj = xbps_array_get(array, i);
if (obj == NULL) if (obj == NULL)
continue; continue;
if (bypattern) { if (bypattern) {
/* pkgpattern match */ /* pkgpattern match */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curpkgver); "pkgver", &curpkgver);
if (xbps_pkgpattern_match(curpkgver, str)) { if (xbps_pkgpattern_match(curpkgver, str)) {
if (!prop_array_set(array, i, dict)) if (!xbps_array_set(array, i, dict))
return EINVAL; return EINVAL;
return 0; return 0;
} }
} else { } else {
/* pkgname match */ /* pkgname match */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curpkgver); "pkgver", &curpkgver);
curpkgname = xbps_pkg_name(curpkgver); curpkgname = xbps_pkg_name(curpkgver);
assert(curpkgname); assert(curpkgname);
if (strcmp(curpkgname, str) == 0) { if (strcmp(curpkgname, str) == 0) {
if (!prop_array_set(array, i, dict)) { if (!xbps_array_set(array, i, dict)) {
free(curpkgname); free(curpkgname);
return EINVAL; return EINVAL;
} }
@@ -253,16 +253,16 @@ array_replace_dict(prop_array_t array,
} }
int HIDDEN int HIDDEN
xbps_array_replace_dict_by_name(prop_array_t array, xbps_array_replace_dict_by_name(xbps_array_t array,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *pkgver) const char *pkgver)
{ {
return array_replace_dict(array, dict, pkgver, false); return array_replace_dict(array, dict, pkgver, false);
} }
int HIDDEN int HIDDEN
xbps_array_replace_dict_by_pattern(prop_array_t array, xbps_array_replace_dict_by_pattern(xbps_array_t array,
prop_dictionary_t dict, xbps_dictionary_t dict,
const char *pattern) const char *pattern)
{ {
return array_replace_dict(array, dict, pattern, true); return array_replace_dict(array, dict, pattern, true);

View File

@@ -145,10 +145,10 @@ open_archive(const char *url)
return a; return a;
} }
prop_dictionary_t xbps_dictionary_t
xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf) xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf)
{ {
prop_dictionary_t plistd = NULL; xbps_dictionary_t plistd = NULL;
struct archive *a; struct archive *a;
struct archive_entry *entry; struct archive_entry *entry;
const char *curpath, *comptype; const char *curpath, *comptype;
@@ -185,7 +185,7 @@ xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf)
errno = EINVAL; errno = EINVAL;
break; break;
} }
prop_dictionary_set_cstring_nocopy(plistd, xbps_dictionary_set_cstring_nocopy(plistd,
"archive-compression-type", comptype); "archive-compression-type", comptype);
break; break;

View File

@@ -37,19 +37,19 @@
static pthread_mutex_t cfg_mtx = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t cfg_mtx = PTHREAD_MUTEX_INITIALIZER;
static bool cfg_vpkgs_init; static bool cfg_vpkgs_init;
static prop_dictionary_t static xbps_dictionary_t
get_pkg_in_array(prop_array_t array, const char *str, bool virtual) get_pkg_in_array(xbps_array_t array, const char *str, bool virtual)
{ {
prop_object_t obj = NULL; xbps_object_t obj = NULL;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkgver; const char *pkgver;
char *dpkgn; char *dpkgn;
bool found = false; bool found = false;
iter = prop_array_iterator(array); iter = xbps_array_iterator(array);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
if (virtual) { if (virtual) {
/* /*
* Check if package pattern matches * Check if package pattern matches
@@ -64,7 +64,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
break; break;
} else if (xbps_pkgpattern_version(str)) { } else if (xbps_pkgpattern_version(str)) {
/* ,atch by pattern against pkgver */ /* ,atch by pattern against pkgver */
if (!prop_dictionary_get_cstring_nocopy(obj, if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver)) "pkgver", &pkgver))
continue; continue;
if (xbps_pkgpattern_match(pkgver, str)) { if (xbps_pkgpattern_match(pkgver, str)) {
@@ -73,7 +73,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
} }
} else if (xbps_pkg_version(str)) { } else if (xbps_pkg_version(str)) {
/* match by exact pkgver */ /* match by exact pkgver */
if (!prop_dictionary_get_cstring_nocopy(obj, if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver)) "pkgver", &pkgver))
continue; continue;
if (strcmp(str, pkgver) == 0) { if (strcmp(str, pkgver) == 0) {
@@ -82,7 +82,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
} }
} else { } else {
/* match by pkgname */ /* match by pkgname */
if (!prop_dictionary_get_cstring_nocopy(obj, if (!xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver)) "pkgver", &pkgver))
continue; continue;
dpkgn = xbps_pkg_name(pkgver); dpkgn = xbps_pkg_name(pkgver);
@@ -95,31 +95,31 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
free(dpkgn); free(dpkgn);
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return found ? obj : NULL; return found ? obj : NULL;
} }
prop_dictionary_t HIDDEN xbps_dictionary_t HIDDEN
xbps_find_pkg_in_array(prop_array_t a, const char *s) xbps_find_pkg_in_array(xbps_array_t a, const char *s)
{ {
assert(prop_object_type(a) == PROP_TYPE_ARRAY); assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
assert(s); assert(s);
return get_pkg_in_array(a, s, false); return get_pkg_in_array(a, s, false);
} }
prop_dictionary_t HIDDEN xbps_dictionary_t HIDDEN
xbps_find_virtualpkg_in_array(struct xbps_handle *x, xbps_find_virtualpkg_in_array(struct xbps_handle *x,
prop_array_t a, xbps_array_t a,
const char *s) const char *s)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *vpkg; const char *vpkg;
bool bypattern = false; bool bypattern = false;
assert(x); assert(x);
assert(prop_object_type(a) == PROP_TYPE_ARRAY); assert(xbps_object_type(a) == XBPS_TYPE_ARRAY);
assert(s); assert(s);
if (xbps_pkgpattern_version(s)) if (xbps_pkgpattern_version(s))
@@ -133,10 +133,10 @@ xbps_find_virtualpkg_in_array(struct xbps_handle *x,
return get_pkg_in_array(a, s, true); return get_pkg_in_array(a, s, true);
} }
static prop_dictionary_t static xbps_dictionary_t
match_pkg_by_pkgver(prop_dictionary_t repod, const char *p) match_pkg_by_pkgver(xbps_dictionary_t repod, const char *p)
{ {
prop_dictionary_t d = NULL; xbps_dictionary_t d = NULL;
const char *pkgver; const char *pkgver;
char *pkgname; char *pkgname;
@@ -144,9 +144,9 @@ match_pkg_by_pkgver(prop_dictionary_t repod, const char *p)
if ((pkgname = xbps_pkg_name(p)) == NULL) if ((pkgname = xbps_pkg_name(p)) == NULL)
return NULL; return NULL;
d = prop_dictionary_get(repod, pkgname); d = xbps_dictionary_get(repod, pkgname);
if (d) { if (d) {
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
if (strcmp(pkgver, p)) if (strcmp(pkgver, p))
d = NULL; d = NULL;
} }
@@ -155,10 +155,10 @@ match_pkg_by_pkgver(prop_dictionary_t repod, const char *p)
return d; return d;
} }
static prop_dictionary_t static xbps_dictionary_t
match_pkg_by_pattern(prop_dictionary_t repod, const char *p) match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
{ {
prop_dictionary_t d = NULL; xbps_dictionary_t d = NULL;
const char *pkgver; const char *pkgver;
char *pkgname; char *pkgname;
@@ -170,9 +170,9 @@ match_pkg_by_pattern(prop_dictionary_t repod, const char *p)
return NULL; return NULL;
} }
d = prop_dictionary_get(repod, pkgname); d = xbps_dictionary_get(repod, pkgname);
if (d) { if (d) {
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
assert(pkgver); assert(pkgver);
if (!xbps_pkgpattern_match(pkgver, p)) if (!xbps_pkgpattern_match(pkgver, p))
d = NULL; d = NULL;
@@ -289,14 +289,14 @@ vpkg_user_conf(struct xbps_handle *xhp,
return pkg; return pkg;
} }
prop_dictionary_t xbps_dictionary_t
xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
prop_dictionary_t d, xbps_dictionary_t d,
const char *pkg) const char *pkg)
{ {
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_dictionary_t pkgd = NULL; xbps_dictionary_t pkgd = NULL;
const char *vpkg; const char *vpkg;
bool found = false, bypattern = false; bool found = false, bypattern = false;
@@ -311,7 +311,7 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
else if (xbps_pkg_version(vpkg)) else if (xbps_pkg_version(vpkg))
pkgd = match_pkg_by_pkgver(d, vpkg); pkgd = match_pkg_by_pkgver(d, vpkg);
else else
pkgd = prop_dictionary_get(d, vpkg); pkgd = xbps_dictionary_get(d, vpkg);
if (pkgd) { if (pkgd) {
found = true; found = true;
@@ -320,17 +320,17 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
} }
/* ... otherwise match the first one in dictionary */ /* ... otherwise match the first one in dictionary */
iter = prop_dictionary_iterator(d); iter = xbps_dictionary_iterator(d);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(d, obj); pkgd = xbps_dictionary_get_keysym(d, obj);
if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) { if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) {
found = true; found = true;
break; break;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
out: out:
if (found) if (found)
@@ -339,17 +339,17 @@ out:
return NULL; return NULL;
} }
prop_dictionary_t xbps_dictionary_t
xbps_find_pkg_in_dict(prop_dictionary_t d, const char *pkg) xbps_find_pkg_in_dict(xbps_dictionary_t d, const char *pkg)
{ {
prop_dictionary_t pkgd = NULL; xbps_dictionary_t pkgd = NULL;
if (xbps_pkgpattern_version(pkg)) if (xbps_pkgpattern_version(pkg))
pkgd = match_pkg_by_pattern(d, pkg); pkgd = match_pkg_by_pattern(d, pkg);
else if (xbps_pkg_version(pkg)) else if (xbps_pkg_version(pkg))
pkgd = match_pkg_by_pkgver(d, pkg); pkgd = match_pkg_by_pkgver(d, pkg);
else else
pkgd = prop_dictionary_get(d, pkg); pkgd = xbps_dictionary_get(d, pkg);
return pkgd; return pkgd;
} }

View File

@@ -40,16 +40,16 @@
* all library functions. * all library functions.
*/ */
bool bool
xbps_match_virtual_pkg_in_dict(prop_dictionary_t d, xbps_match_virtual_pkg_in_dict(xbps_dictionary_t d,
const char *str, const char *str,
bool bypattern) bool bypattern)
{ {
prop_array_t provides; xbps_array_t provides;
bool found = false; bool found = false;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY);
if ((provides = prop_dictionary_get(d, "provides"))) { if ((provides = xbps_dictionary_get(d, "provides"))) {
if (bypattern) if (bypattern)
found = xbps_match_pkgpattern_in_array(provides, str); found = xbps_match_pkgpattern_in_array(provides, str);
else { else {
@@ -62,72 +62,72 @@ xbps_match_virtual_pkg_in_dict(prop_dictionary_t d,
} }
bool bool
xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps, xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps,
prop_array_t provides) xbps_array_t provides)
{ {
prop_object_t obj, obj2; xbps_object_t obj, obj2;
prop_object_iterator_t iter, iter2; xbps_object_iterator_t iter, iter2;
const char *vpkgver, *pkgpattern; const char *vpkgver, *pkgpattern;
char *tmp; char *tmp;
iter = prop_array_iterator(provides); iter = xbps_array_iterator(provides);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
tmp = NULL; tmp = NULL;
vpkgver = prop_string_cstring_nocopy(obj); vpkgver = xbps_string_cstring_nocopy(obj);
if (strchr(vpkgver, '_') == NULL) { if (strchr(vpkgver, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", vpkgver); tmp = xbps_xasprintf("%s_1", vpkgver);
vpkgver = tmp; vpkgver = tmp;
} }
iter2 = prop_array_iterator(rundeps); iter2 = xbps_array_iterator(rundeps);
assert(iter2); assert(iter2);
while ((obj2 = prop_object_iterator_next(iter2))) { while ((obj2 = xbps_object_iterator_next(iter2))) {
pkgpattern = prop_string_cstring_nocopy(obj2); pkgpattern = xbps_string_cstring_nocopy(obj2);
if (xbps_pkgpattern_match(vpkgver, pkgpattern)) { if (xbps_pkgpattern_match(vpkgver, pkgpattern)) {
if (tmp != NULL) if (tmp != NULL)
free(tmp); free(tmp);
prop_object_iterator_release(iter2); xbps_object_iterator_release(iter2);
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return true; return true;
} }
} }
prop_object_iterator_release(iter2); xbps_object_iterator_release(iter2);
if (tmp != NULL) if (tmp != NULL)
free(tmp); free(tmp);
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return false; return false;
} }
static bool static bool
match_string_in_array(prop_array_t array, const char *str, int mode) match_string_in_array(xbps_array_t array, const char *str, int mode)
{ {
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_object_t obj; xbps_object_t obj;
const char *pkgdep; const char *pkgdep;
char *curpkgname, *tmp; char *curpkgname, *tmp;
bool found = false; bool found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY); assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
assert(str != NULL); assert(str != NULL);
iter = prop_array_iterator(array); iter = xbps_array_iterator(array);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
tmp = NULL; tmp = NULL;
if (mode == 0) { if (mode == 0) {
/* match by string */ /* match by string */
if (prop_string_equals_cstring(obj, str)) { if (xbps_string_equals_cstring(obj, str)) {
found = true; found = true;
break; break;
} }
} else if (mode == 1) { } else if (mode == 1) {
/* match by pkgname */ /* match by pkgname */
pkgdep = prop_string_cstring_nocopy(obj); pkgdep = xbps_string_cstring_nocopy(obj);
if (strchr(pkgdep, '_') == NULL) { if (strchr(pkgdep, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", pkgdep); tmp = xbps_xasprintf("%s_1", pkgdep);
curpkgname = xbps_pkg_name(tmp); curpkgname = xbps_pkg_name(tmp);
@@ -145,7 +145,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
free(curpkgname); free(curpkgname);
} else if (mode == 2) { } else if (mode == 2) {
/* match pkgpattern against pkgdep */ /* match pkgpattern against pkgdep */
pkgdep = prop_string_cstring_nocopy(obj); pkgdep = xbps_string_cstring_nocopy(obj);
if (strchr(pkgdep, '_') == NULL) { if (strchr(pkgdep, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", pkgdep); tmp = xbps_xasprintf("%s_1", pkgdep);
pkgdep = tmp; pkgdep = tmp;
@@ -161,7 +161,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
} else if (mode == 3) { } else if (mode == 3) {
/* match pkgdep against pkgpattern */ /* match pkgdep against pkgpattern */
pkgdep = prop_string_cstring_nocopy(obj); pkgdep = xbps_string_cstring_nocopy(obj);
if (strchr(pkgdep, '_') == NULL) { if (strchr(pkgdep, '_') == NULL) {
tmp = xbps_xasprintf("%s_1", pkgdep); tmp = xbps_xasprintf("%s_1", pkgdep);
pkgdep = tmp; pkgdep = tmp;
@@ -176,31 +176,31 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
free(tmp); free(tmp);
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return found; return found;
} }
bool bool
xbps_match_string_in_array(prop_array_t array, const char *str) xbps_match_string_in_array(xbps_array_t array, const char *str)
{ {
return match_string_in_array(array, str, 0); return match_string_in_array(array, str, 0);
} }
bool bool
xbps_match_pkgname_in_array(prop_array_t array, const char *pkgname) xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname)
{ {
return match_string_in_array(array, pkgname, 1); return match_string_in_array(array, pkgname, 1);
} }
bool bool
xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern) xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern)
{ {
return match_string_in_array(array, pattern, 2); return match_string_in_array(array, pattern, 2);
} }
bool bool
xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver) xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver)
{ {
return match_string_in_array(array, pkgver, 3); return match_string_in_array(array, pkgver, 3);
} }

View File

@@ -32,31 +32,31 @@
#include "xbps_api_impl.h" #include "xbps_api_impl.h"
static bool static bool
remove_obj_from_array(prop_array_t array, const char *str, int mode) remove_obj_from_array(xbps_array_t array, const char *str, int mode)
{ {
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_object_t obj; xbps_object_t obj;
const char *curname, *pkgdep; const char *curname, *pkgdep;
char *curpkgname; char *curpkgname;
unsigned int idx = 0; unsigned int idx = 0;
bool found = false; bool found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY); assert(xbps_object_type(array) == XBPS_TYPE_ARRAY);
iter = prop_array_iterator(array); iter = xbps_array_iterator(array);
if (iter == NULL) if (iter == NULL)
return false; return false;
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
if (mode == 0) { if (mode == 0) {
/* exact match, obj is a string */ /* exact match, obj is a string */
if (prop_string_equals_cstring(obj, str)) { if (xbps_string_equals_cstring(obj, str)) {
found = true; found = true;
break; break;
} }
} else if (mode == 1) { } else if (mode == 1) {
/* match by pkgname, obj is a string */ /* match by pkgname, obj is a string */
pkgdep = prop_string_cstring_nocopy(obj); pkgdep = xbps_string_cstring_nocopy(obj);
curpkgname = xbps_pkg_name(pkgdep); curpkgname = xbps_pkg_name(pkgdep);
if (curpkgname == NULL) if (curpkgname == NULL)
break; break;
@@ -68,7 +68,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
free(curpkgname); free(curpkgname);
} else if (mode == 2) { } else if (mode == 2) {
/* match by pkgname, obj is a dictionary */ /* match by pkgname, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"pkgname", &curname); "pkgname", &curname);
if (strcmp(curname, str) == 0) { if (strcmp(curname, str) == 0) {
found = true; found = true;
@@ -76,7 +76,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
} }
} else if (mode == 3) { } else if (mode == 3) {
/* match by pkgver, obj is a dictionary */ /* match by pkgver, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname); "pkgver", &curname);
if (strcmp(curname, str) == 0) { if (strcmp(curname, str) == 0) {
found = true; found = true;
@@ -84,7 +84,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
} }
} else if (mode == 4) { } else if (mode == 4) {
/* match by pattern, obj is a dictionary */ /* match by pattern, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname); "pkgver", &curname);
if (xbps_pkgpattern_match(curname, str)) { if (xbps_pkgpattern_match(curname, str)) {
found = true; found = true;
@@ -93,43 +93,43 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
} }
idx++; idx++;
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
if (!found) { if (!found) {
errno = ENOENT; errno = ENOENT;
return false; return false;
} }
prop_array_remove(array, idx); xbps_array_remove(array, idx);
return true; return true;
} }
bool HIDDEN bool HIDDEN
xbps_remove_string_from_array(prop_array_t array, const char *str) xbps_remove_string_from_array(xbps_array_t array, const char *str)
{ {
return remove_obj_from_array(array, str, 0); return remove_obj_from_array(array, str, 0);
} }
bool HIDDEN bool HIDDEN
xbps_remove_pkgname_from_array(prop_array_t array, const char *str) xbps_remove_pkgname_from_array(xbps_array_t array, const char *str)
{ {
return remove_obj_from_array(array, str, 1); return remove_obj_from_array(array, str, 1);
} }
bool HIDDEN bool HIDDEN
xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *str) xbps_remove_pkg_from_array_by_name(xbps_array_t array, const char *str)
{ {
return remove_obj_from_array(array, str, 2); return remove_obj_from_array(array, str, 2);
} }
bool HIDDEN bool HIDDEN
xbps_remove_pkg_from_array_by_pkgver(prop_array_t array, const char *str) xbps_remove_pkg_from_array_by_pkgver(xbps_array_t array, const char *str)
{ {
return remove_obj_from_array(array, str, 3); return remove_obj_from_array(array, str, 3);
} }
bool HIDDEN bool HIDDEN
xbps_remove_pkg_from_array_by_pattern(prop_array_t array, const char *str) xbps_remove_pkg_from_array_by_pattern(xbps_array_t array, const char *str)
{ {
return remove_obj_from_array(array, str, 4); return remove_obj_from_array(array, str, 4);
} }

View File

@@ -29,6 +29,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <prop/prop_object.h> #include <prop/prop_object.h>
#include "prop_object_impl.h" #include "prop_object_impl.h"
@@ -834,7 +838,7 @@ _prop_object_externalize_write_file(const char *fname, const char *xml,
return (false); return (false);
} }
#else #else
otname = strncat(tname, "/.plistXXXXXX", sizeof(tname)); otname = strncat(tname, "/.plistXXXXXX", sizeof(tname) - strlen(tname) - 1);
if (sizeof(*otname) >= sizeof(tname)) { if (sizeof(*otname) >= sizeof(tname)) {
errno = ENAMETOOLONG; errno = ENAMETOOLONG;

927
lib/proplib_wrapper.c Normal file
View File

@@ -0,0 +1,927 @@
/*-
* Copyright (c) 2013 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "xbps_api_impl.h"
#include <prop/proplib.h>
/* prop_array */
xbps_array_t
xbps_array_create(void)
{
return prop_array_create();
}
xbps_array_t
xbps_array_create_with_capacity(unsigned int capacity)
{
return prop_array_create_with_capacity(capacity);
}
xbps_array_t
xbps_array_copy(xbps_array_t a)
{
return prop_array_copy(a);
}
xbps_array_t
xbps_array_copy_mutable(xbps_array_t a)
{
return prop_array_copy_mutable(a);
}
unsigned int
xbps_array_capacity(xbps_array_t a)
{
return prop_array_capacity(a);
}
unsigned int
xbps_array_count(xbps_array_t a)
{
return prop_array_count(a);
}
bool
xbps_array_ensure_capacity(xbps_array_t a, unsigned int i)
{
return prop_array_ensure_capacity(a, i);
}
void
xbps_array_make_immutable(xbps_array_t a)
{
return prop_array_make_immutable(a);
}
bool
xbps_array_mutable(xbps_array_t a)
{
return prop_array_mutable(a);
}
xbps_object_iterator_t
xbps_array_iterator(xbps_array_t a)
{
return prop_array_iterator(a);
}
xbps_object_t
xbps_array_get(xbps_array_t a, unsigned int i)
{
return prop_array_get(a, i);
}
bool
xbps_array_set(xbps_array_t a, unsigned int i, xbps_object_t obj)
{
return prop_array_set(a, i, obj);
}
bool
xbps_array_add(xbps_array_t a, xbps_object_t obj)
{
return prop_array_add(a, obj);
}
void
xbps_array_remove(xbps_array_t a, unsigned int i)
{
return prop_array_remove(a, i);
}
bool
xbps_array_equals(xbps_array_t a, xbps_array_t b)
{
return prop_array_equals(a, b);
}
char *
xbps_array_externalize(xbps_array_t a)
{
return prop_array_externalize(a);
}
xbps_array_t
xbps_array_internalize(const char *s)
{
return prop_array_internalize(s);
}
bool
xbps_array_externalize_to_file(xbps_array_t a, const char *s)
{
return prop_array_externalize_to_file(a, s);
}
bool
xbps_array_externalize_to_zfile(xbps_array_t a, const char *s)
{
return prop_array_externalize_to_zfile(a, s);
}
xbps_array_t
xbps_array_internalize_from_file(const char *s)
{
return prop_array_internalize_from_file(s);
}
xbps_array_t
xbps_array_internalize_from_zfile(const char *s)
{
return prop_array_internalize_from_zfile(s);
}
/*
* Utility routines to make it more convenient to work with values
* stored in dictionaries.
*/
bool
xbps_array_get_bool(xbps_array_t a, unsigned int i, bool *b)
{
return prop_array_get_bool(a, i, b);
}
bool
xbps_array_set_bool(xbps_array_t a, unsigned int i, bool b)
{
return prop_array_set_bool(a, i, b);
}
bool
xbps_array_get_int8(xbps_array_t a, unsigned int i, int8_t *v)
{
return prop_array_get_int8(a, i, v);
}
bool
xbps_array_get_uint8(xbps_array_t a, unsigned int i, uint8_t *v)
{
return prop_array_get_uint8(a, i, v);
}
bool
xbps_array_set_int8(xbps_array_t a, unsigned int i, int8_t v)
{
return prop_array_set_int8(a, i, v);
}
bool
xbps_array_set_uint8(xbps_array_t a, unsigned int i, uint8_t v)
{
return prop_array_set_uint8(a, i, v);
}
bool
xbps_array_get_int16(xbps_array_t a, unsigned int i, int16_t *v)
{
return prop_array_get_int16(a, i, v);
}
bool
xbps_array_get_uint16(xbps_array_t a, unsigned int i, uint16_t *v)
{
return prop_array_get_uint16(a, i, v);
}
bool
xbps_array_set_int16(xbps_array_t a, unsigned int i, int16_t v)
{
return prop_array_set_int16(a, i, v);
}
bool
xbps_array_set_uint16(xbps_array_t a, unsigned int i, uint16_t v)
{
return prop_array_set_uint16(a, i, v);
}
bool
xbps_array_get_int32(xbps_array_t a, unsigned int i, int32_t *v)
{
return prop_array_get_int32(a, i, v);
}
bool
xbps_array_get_uint32(xbps_array_t a, unsigned int i, uint32_t *v)
{
return prop_array_get_uint32(a, i, v);
}
bool
xbps_array_set_int32(xbps_array_t a, unsigned int i, int32_t v)
{
return prop_array_set_int32(a, i, v);
}
bool
xbps_array_set_uint32(xbps_array_t a, unsigned int i, uint32_t v)
{
return prop_array_set_uint32(a, i, v);
}
bool
xbps_array_get_int64(xbps_array_t a, unsigned int i, int64_t *v)
{
return prop_array_get_int64(a, i, v);
}
bool
xbps_array_get_uint64(xbps_array_t a, unsigned int i, uint64_t *v)
{
return prop_array_get_uint64(a, i, v);
}
bool
xbps_array_set_int64(xbps_array_t a, unsigned int i, int64_t v)
{
return prop_array_set_int64(a, i, v);
}
bool
xbps_array_set_uint64(xbps_array_t a, unsigned int i, uint64_t v)
{
return prop_array_set_uint64(a, i, v);
}
bool
xbps_array_add_int8(xbps_array_t a, int8_t v)
{
return prop_array_add_int8(a, v);
}
bool
xbps_array_add_uint8(xbps_array_t a, uint8_t v)
{
return prop_array_add_uint8(a, v);
}
bool
xbps_array_add_int16(xbps_array_t a, int16_t v)
{
return prop_array_add_int16(a, v);
}
bool
xbps_array_add_uint16(xbps_array_t a, uint16_t v)
{
return prop_array_add_uint16(a, v);
}
bool
xbps_array_add_int32(xbps_array_t a, int32_t v)
{
return prop_array_add_int32(a, v);
}
bool
xbps_array_add_uint32(xbps_array_t a, uint32_t v)
{
return prop_array_add_uint32(a, v);
}
bool
xbps_array_add_int64(xbps_array_t a, int64_t v)
{
return prop_array_add_int64(a, v);
}
bool
xbps_array_add_uint64(xbps_array_t a, uint64_t v)
{
return prop_array_add_uint64(a, v);
}
bool
xbps_array_get_cstring(xbps_array_t a, unsigned int i, char **s)
{
return prop_array_get_cstring(a, i, s);
}
bool
xbps_array_set_cstring(xbps_array_t a, unsigned int i, const char *s)
{
return prop_array_set_cstring(a, i, s);
}
bool
xbps_array_add_cstring(xbps_array_t a, const char *s)
{
return prop_array_add_cstring(a, s);
}
bool
xbps_array_add_cstring_nocopy(xbps_array_t a, const char *s)
{
return prop_array_add_cstring_nocopy(a, s);
}
bool
xbps_array_get_cstring_nocopy(xbps_array_t a, unsigned int i, const char **s)
{
return prop_array_get_cstring_nocopy(a, i, s);
}
bool
xbps_array_set_cstring_nocopy(xbps_array_t a, unsigned int i, const char *s)
{
return prop_array_set_cstring_nocopy(a, i, s);
}
bool
xbps_array_add_and_rel(xbps_array_t a, xbps_object_t o)
{
return prop_array_add_and_rel(a, o);
}
/* prop_bool */
xbps_bool_t
xbps_bool_create(bool v)
{
return prop_bool_create(v);
}
xbps_bool_t
xbps_bool_copy(xbps_bool_t b)
{
return prop_bool_copy(b);
}
bool
xbps_bool_true(xbps_bool_t b)
{
return prop_bool_true(b);
}
bool
xbps_bool_equals(xbps_bool_t a, xbps_bool_t b)
{
return prop_bool_equals(a, b);
}
/* prop_data */
xbps_data_t
xbps_data_create_data(const void *v, size_t s)
{
return prop_data_create_data(v, s);
}
xbps_data_t
xbps_data_create_data_nocopy(const void *v, size_t s)
{
return prop_data_create_data_nocopy(v, s);
}
xbps_data_t
xbps_data_copy(xbps_data_t d)
{
return prop_data_copy(d);
}
size_t
xbps_data_size(xbps_data_t d)
{
return prop_data_size(d);
}
void *
xbps_data_data(xbps_data_t d)
{
return prop_data_data(d);
}
const void *
xbps_data_data_nocopy(xbps_data_t d)
{
return prop_data_data_nocopy(d);
}
bool
xbps_data_equals(xbps_data_t a, xbps_data_t b)
{
return prop_data_equals(a, b);
}
bool
xbps_data_equals_data(xbps_data_t d, const void *v, size_t s)
{
return prop_data_equals_data(d, v, s);
}
/* prop_dictionary */
xbps_dictionary_t
xbps_dictionary_create(void)
{
return prop_dictionary_create();
}
xbps_dictionary_t
xbps_dictionary_create_with_capacity(unsigned int i)
{
return prop_dictionary_create_with_capacity(i);
}
xbps_dictionary_t
xbps_dictionary_copy(xbps_dictionary_t d)
{
return prop_dictionary_copy(d);
}
xbps_dictionary_t
xbps_dictionary_copy_mutable(xbps_dictionary_t d)
{
return prop_dictionary_copy_mutable(d);
}
unsigned int
xbps_dictionary_count(xbps_dictionary_t d)
{
return prop_dictionary_count(d);
}
bool
xbps_dictionary_ensure_capacity(xbps_dictionary_t d, unsigned int i)
{
return prop_dictionary_ensure_capacity(d, i);
}
void
xbps_dictionary_make_immutable(xbps_dictionary_t d)
{
return prop_dictionary_make_immutable(d);
}
xbps_object_iterator_t
xbps_dictionary_iterator(xbps_dictionary_t d)
{
return prop_dictionary_iterator(d);
}
xbps_array_t
xbps_dictionary_all_keys(xbps_dictionary_t d)
{
return prop_dictionary_all_keys(d);
}
xbps_object_t
xbps_dictionary_get(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_get(d, s);
}
bool
xbps_dictionary_set(xbps_dictionary_t d, const char *s, xbps_object_t o)
{
return prop_dictionary_set(d, s, o);
}
void
xbps_dictionary_remove(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_remove(d, s);
}
xbps_object_t
xbps_dictionary_get_keysym(xbps_dictionary_t d, xbps_dictionary_keysym_t k)
{
return prop_dictionary_get_keysym(d, k);
}
bool
xbps_dictionary_set_keysym(xbps_dictionary_t d, xbps_dictionary_keysym_t k,
xbps_object_t o)
{
return prop_dictionary_set_keysym(d, k, o);
}
void
xbps_dictionary_remove_keysym(xbps_dictionary_t d, xbps_dictionary_keysym_t k)
{
return prop_dictionary_remove_keysym(d, k);
}
bool
xbps_dictionary_equals(xbps_dictionary_t a, xbps_dictionary_t b)
{
return prop_dictionary_equals(a, b);
}
char *
xbps_dictionary_externalize(xbps_dictionary_t d)
{
return prop_dictionary_externalize(d);
}
xbps_dictionary_t
xbps_dictionary_internalize(const char *s)
{
return prop_dictionary_internalize(s);
}
bool
xbps_dictionary_externalize_to_file(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_externalize_to_file(d, s);
}
bool
xbps_dictionary_externalize_to_zfile(xbps_dictionary_t d, const char *s)
{
return prop_dictionary_externalize_to_zfile(d, s);
}
xbps_dictionary_t
xbps_dictionary_internalize_from_file(const char *s)
{
return prop_dictionary_internalize_from_file(s);
}
xbps_dictionary_t
xbps_dictionary_internalize_from_zfile(const char *s)
{
return prop_dictionary_internalize_from_zfile(s);
}
const char *
xbps_dictionary_keysym_cstring_nocopy(xbps_dictionary_keysym_t k)
{
return prop_dictionary_keysym_cstring_nocopy(k);
}
bool
xbps_dictionary_keysym_equals(xbps_dictionary_keysym_t a, xbps_dictionary_keysym_t b)
{
return prop_dictionary_keysym_equals(a, b);
}
/*
* Utility routines to make it more convenient to work with values
* stored in dictionaries.
*/
bool
xbps_dictionary_get_dict(xbps_dictionary_t d, const char *s,
xbps_dictionary_t *rd)
{
return prop_dictionary_get_dict(d, s, rd);
}
bool
xbps_dictionary_get_bool(xbps_dictionary_t d, const char *s, bool *b)
{
return prop_dictionary_get_bool(d, s, b);
}
bool
xbps_dictionary_set_bool(xbps_dictionary_t d, const char *s, bool b)
{
return prop_dictionary_set_bool(d, s, b);
}
bool
xbps_dictionary_get_int8(xbps_dictionary_t d, const char *s, int8_t *v)
{
return prop_dictionary_get_int8(d, s, v);
}
bool
xbps_dictionary_get_uint8(xbps_dictionary_t d, const char *s, uint8_t *v)
{
return prop_dictionary_get_uint8(d, s, v);
}
bool
xbps_dictionary_set_int8(xbps_dictionary_t d, const char *s, int8_t v)
{
return prop_dictionary_set_int8(d, s, v);
}
bool
xbps_dictionary_set_uint8(xbps_dictionary_t d, const char *s, uint8_t v)
{
return prop_dictionary_set_uint8(d, s, v);
}
bool
xbps_dictionary_get_int16(xbps_dictionary_t d, const char *s, int16_t *v)
{
return prop_dictionary_get_int16(d, s, v);
}
bool
xbps_dictionary_get_uint16(xbps_dictionary_t d, const char *s, uint16_t *v)
{
return prop_dictionary_get_uint16(d, s, v);
}
bool
xbps_dictionary_set_int16(xbps_dictionary_t d, const char *s, int16_t v)
{
return prop_dictionary_set_int16(d, s, v);
}
bool
xbps_dictionary_set_uint16(xbps_dictionary_t d, const char *s, uint16_t v)
{
return prop_dictionary_set_uint16(d, s, v);
}
bool
xbps_dictionary_get_int32(xbps_dictionary_t d, const char *s, int32_t *v)
{
return prop_dictionary_get_int32(d, s, v);
}
bool
xbps_dictionary_get_uint32(xbps_dictionary_t d, const char *s, uint32_t *v)
{
return prop_dictionary_get_uint32(d, s, v);
}
bool
xbps_dictionary_set_int32(xbps_dictionary_t d, const char *s, int32_t v)
{
return prop_dictionary_set_int32(d, s, v);
}
bool
xbps_dictionary_set_uint32(xbps_dictionary_t d, const char *s, uint32_t v)
{
return prop_dictionary_set_uint32(d, s, v);
}
bool
xbps_dictionary_get_int64(xbps_dictionary_t d, const char *s, int64_t *v)
{
return prop_dictionary_get_int64(d, s, v);
}
bool
xbps_dictionary_get_uint64(xbps_dictionary_t d, const char *s, uint64_t *v)
{
return prop_dictionary_get_uint64(d, s, v);
}
bool
xbps_dictionary_set_int64(xbps_dictionary_t d, const char *s, int64_t v)
{
return prop_dictionary_set_int64(d, s, v);
}
bool
xbps_dictionary_set_uint64(xbps_dictionary_t d, const char *s, uint64_t v)
{
return prop_dictionary_set_uint64(d, s, v);
}
bool
xbps_dictionary_get_cstring(xbps_dictionary_t d, const char *s, char **ss)
{
return prop_dictionary_get_cstring(d, s, ss);
}
bool
xbps_dictionary_set_cstring(xbps_dictionary_t d, const char *s, const char *ss)
{
return prop_dictionary_set_cstring(d, s, ss);
}
bool
xbps_dictionary_get_cstring_nocopy(xbps_dictionary_t d, const char *s, const char **ss)
{
return prop_dictionary_get_cstring_nocopy(d, s, ss);
}
bool
xbps_dictionary_set_cstring_nocopy(xbps_dictionary_t d, const char *s, const char *ss)
{
return prop_dictionary_set_cstring_nocopy(d, s, ss);
}
bool
xbps_dictionary_set_and_rel(xbps_dictionary_t d, const char *s, xbps_object_t o)
{
return prop_dictionary_set_and_rel(d, s, o);
}
/* prop_number */
xbps_number_t
xbps_number_create_integer(int64_t v)
{
return prop_number_create_integer(v);
}
xbps_number_t
xbps_number_create_unsigned_integer(uint64_t v)
{
return prop_number_create_unsigned_integer(v);
}
xbps_number_t
xbps_number_copy(xbps_number_t n)
{
return prop_number_copy(n);
}
int
xbps_number_size(xbps_number_t n)
{
return prop_number_size(n);
}
bool
xbps_number_unsigned(xbps_number_t n)
{
return prop_number_unsigned(n);
}
int64_t
xbps_number_integer_value(xbps_number_t n)
{
return prop_number_integer_value(n);
}
uint64_t
xbps_number_unsigned_integer_value(xbps_number_t n)
{
return prop_number_unsigned_integer_value(n);
}
bool
xbps_number_equals(xbps_number_t n, xbps_number_t nn)
{
return prop_number_equals(n, nn);
}
bool
xbps_number_equals_integer(xbps_number_t n, int64_t v)
{
return prop_number_equals_integer(n, v);
}
bool
xbps_number_equals_unsigned_integer(xbps_number_t n, uint64_t v)
{
return prop_number_equals_unsigned_integer(n, v);
}
/* prop_object */
void
xbps_object_retain(xbps_object_t o)
{
return prop_object_retain(o);
}
void
xbps_object_release(xbps_object_t o)
{
return prop_object_release(o);
}
xbps_type_t
xbps_object_type(xbps_object_t o)
{
return (xbps_type_t)prop_object_type(o);
}
bool
xbps_object_equals(xbps_object_t o, xbps_object_t oo)
{
return prop_object_equals(o, oo);
}
bool
xbps_object_equals_with_error(xbps_object_t o, xbps_object_t oo, bool *b)
{
return prop_object_equals_with_error(o, oo, b);
}
xbps_object_t
xbps_object_iterator_next(xbps_object_iterator_t o)
{
return prop_object_iterator_next(o);
}
void
xbps_object_iterator_reset(xbps_object_iterator_t o)
{
return prop_object_iterator_reset(o);
}
void
xbps_object_iterator_release(xbps_object_iterator_t o)
{
return prop_object_iterator_release(o);
}
/* prop_string */
xbps_string_t
xbps_string_create(void)
{
return prop_string_create();
}
xbps_string_t
xbps_string_create_cstring(const char *s)
{
return prop_string_create_cstring(s);
}
xbps_string_t
xbps_string_create_cstring_nocopy(const char *s)
{
return prop_string_create_cstring_nocopy(s);
}
xbps_string_t
xbps_string_copy(xbps_string_t s)
{
return prop_string_copy(s);
}
xbps_string_t
xbps_string_copy_mutable(xbps_string_t s)
{
return prop_string_copy_mutable(s);
}
size_t
xbps_string_size(xbps_string_t s)
{
return prop_string_size(s);
}
bool
xbps_string_mutable(xbps_string_t s)
{
return prop_string_mutable(s);
}
char *
xbps_string_cstring(xbps_string_t s)
{
return prop_string_cstring(s);
}
const char *
xbps_string_cstring_nocopy(xbps_string_t s)
{
return prop_string_cstring_nocopy(s);
}
bool
xbps_string_append(xbps_string_t s, xbps_string_t ss)
{
return prop_string_append(s, ss);
}
bool
xbps_string_append_cstring(xbps_string_t s, const char *ss)
{
return prop_string_append_cstring(s, ss);
}
bool
xbps_string_equals(xbps_string_t s, xbps_string_t ss)
{
return prop_string_equals(s, ss);
}
bool
xbps_string_equals_cstring(xbps_string_t s, const char *ss)
{
return prop_string_equals_cstring(s, ss);
}

View File

@@ -94,10 +94,10 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url)
return repo; return repo;
} }
prop_dictionary_t xbps_dictionary_t
xbps_repo_get_plist(struct xbps_repo *repo, const char *file) xbps_repo_get_plist(struct xbps_repo *repo, const char *file)
{ {
prop_dictionary_t d; xbps_dictionary_t d;
struct archive_entry *entry; struct archive_entry *entry;
void *buf; void *buf;
size_t buflen; size_t buflen;
@@ -123,7 +123,7 @@ xbps_repo_get_plist(struct xbps_repo *repo, const char *file)
free(buf); free(buf);
return NULL; return NULL;
} }
d = prop_dictionary_internalize(buf); d = xbps_dictionary_internalize(buf);
free(buf); free(buf);
return d; return d;
} }
@@ -138,51 +138,51 @@ xbps_repo_close(struct xbps_repo *repo)
assert(repo); assert(repo);
archive_read_free(repo->ar); archive_read_free(repo->ar);
if (prop_object_type(repo->idx) == PROP_TYPE_DICTIONARY) if (xbps_object_type(repo->idx) == XBPS_TYPE_DICTIONARY)
prop_object_release(repo->idx); xbps_object_release(repo->idx);
if (prop_object_type(repo->idxfiles) == PROP_TYPE_DICTIONARY) if (xbps_object_type(repo->idxfiles) == XBPS_TYPE_DICTIONARY)
prop_object_release(repo->idxfiles); xbps_object_release(repo->idxfiles);
free(repo); free(repo);
} }
prop_dictionary_t xbps_dictionary_t
xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg) xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
assert(repo); assert(repo);
assert(repo->ar); assert(repo->ar);
assert(pkg); assert(pkg);
if (prop_object_type(repo->idx) != PROP_TYPE_DICTIONARY) { if (xbps_object_type(repo->idx) != XBPS_TYPE_DICTIONARY) {
repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX); repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX);
assert(repo->idx); assert(repo->idx);
} }
pkgd = xbps_find_virtualpkg_in_dict(repo->xhp, repo->idx, pkg); pkgd = xbps_find_virtualpkg_in_dict(repo->xhp, repo->idx, pkg);
if (pkgd) { if (pkgd) {
prop_dictionary_set_cstring_nocopy(pkgd, xbps_dictionary_set_cstring_nocopy(pkgd,
"repository", repo->uri); "repository", repo->uri);
return pkgd; return pkgd;
} }
return NULL; return NULL;
} }
prop_dictionary_t xbps_dictionary_t
xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg) xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
assert(repo); assert(repo);
assert(repo->ar); assert(repo->ar);
assert(pkg); assert(pkg);
if (prop_object_type(repo->idx) != PROP_TYPE_DICTIONARY) { if (xbps_object_type(repo->idx) != XBPS_TYPE_DICTIONARY) {
repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX); repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX);
assert(repo->idx); assert(repo->idx);
} }
pkgd = xbps_find_pkg_in_dict(repo->idx, pkg); pkgd = xbps_find_pkg_in_dict(repo->idx, pkg);
if (pkgd) { if (pkgd) {
prop_dictionary_set_cstring_nocopy(pkgd, xbps_dictionary_set_cstring_nocopy(pkgd,
"repository", repo->uri); "repository", repo->uri);
return pkgd; return pkgd;
} }
@@ -190,11 +190,11 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
return NULL; return NULL;
} }
prop_dictionary_t xbps_dictionary_t
xbps_repo_get_pkg_plist(struct xbps_handle *xhp, prop_dictionary_t pkgd, xbps_repo_get_pkg_plist(struct xbps_handle *xhp, xbps_dictionary_t pkgd,
const char *plist) const char *plist)
{ {
prop_dictionary_t bpkgd; xbps_dictionary_t bpkgd;
char *url; char *url;
url = xbps_repository_pkg_path(xhp, pkgd); url = xbps_repository_pkg_path(xhp, pkgd);
@@ -206,27 +206,27 @@ xbps_repo_get_pkg_plist(struct xbps_handle *xhp, prop_dictionary_t pkgd,
return bpkgd; return bpkgd;
} }
static prop_array_t static xbps_array_t
revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str) revdeps_match(struct xbps_repo *repo, xbps_dictionary_t tpkgd, const char *str)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_array_t revdeps = NULL, pkgdeps, provides; xbps_array_t revdeps = NULL, pkgdeps, provides;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_object_t obj; xbps_object_t obj;
const char *pkgver, *tpkgver, *arch, *vpkg; const char *pkgver, *tpkgver, *arch, *vpkg;
char *buf; char *buf;
unsigned int i; unsigned int i;
iter = prop_dictionary_iterator(repo->idx); iter = xbps_dictionary_iterator(repo->idx);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(repo->idx, obj); pkgd = xbps_dictionary_get_keysym(repo->idx, obj);
if (prop_dictionary_equals(pkgd, tpkgd)) if (xbps_dictionary_equals(pkgd, tpkgd))
continue; continue;
pkgdeps = prop_dictionary_get(pkgd, "run_depends"); pkgdeps = xbps_dictionary_get(pkgd, "run_depends");
if (!prop_array_count(pkgdeps)) if (!xbps_array_count(pkgdeps))
continue; continue;
/* /*
* Try to match passed in string. * Try to match passed in string.
@@ -234,28 +234,28 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str)
if (str) { if (str) {
if (!xbps_match_pkgdep_in_array(pkgdeps, str)) if (!xbps_match_pkgdep_in_array(pkgdeps, str))
continue; continue;
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch); "architecture", &arch);
if (!xbps_pkg_arch_match(repo->xhp, arch, NULL)) if (!xbps_pkg_arch_match(repo->xhp, arch, NULL))
continue; continue;
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &tpkgver); "pkgver", &tpkgver);
/* match */ /* match */
if (revdeps == NULL) if (revdeps == NULL)
revdeps = prop_array_create(); revdeps = xbps_array_create();
if (!xbps_match_string_in_array(revdeps, tpkgver)) if (!xbps_match_string_in_array(revdeps, tpkgver))
prop_array_add_cstring_nocopy(revdeps, tpkgver); xbps_array_add_cstring_nocopy(revdeps, tpkgver);
continue; continue;
} }
/* /*
* Try to match any virtual package. * Try to match any virtual package.
*/ */
provides = prop_dictionary_get(tpkgd, "provides"); provides = xbps_dictionary_get(tpkgd, "provides");
for (i = 0; i < prop_array_count(provides); i++) { for (i = 0; i < xbps_array_count(provides); i++) {
prop_array_get_cstring_nocopy(provides, i, &vpkg); xbps_array_get_cstring_nocopy(provides, i, &vpkg);
if (strchr(vpkg, '_') == NULL) if (strchr(vpkg, '_') == NULL)
buf = xbps_xasprintf("%s_1", vpkg); buf = xbps_xasprintf("%s_1", vpkg);
else else
@@ -266,49 +266,49 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str)
continue; continue;
} }
free(buf); free(buf);
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch); "architecture", &arch);
if (!xbps_pkg_arch_match(repo->xhp, arch, NULL)) if (!xbps_pkg_arch_match(repo->xhp, arch, NULL))
continue; continue;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver",
&tpkgver); &tpkgver);
/* match */ /* match */
if (revdeps == NULL) if (revdeps == NULL)
revdeps = prop_array_create(); revdeps = xbps_array_create();
if (!xbps_match_string_in_array(revdeps, tpkgver)) if (!xbps_match_string_in_array(revdeps, tpkgver))
prop_array_add_cstring_nocopy(revdeps, tpkgver); xbps_array_add_cstring_nocopy(revdeps, tpkgver);
} }
/* /*
* Try to match by pkgver. * Try to match by pkgver.
*/ */
prop_dictionary_get_cstring_nocopy(tpkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(tpkgd, "pkgver", &pkgver);
if (!xbps_match_pkgdep_in_array(pkgdeps, pkgver)) if (!xbps_match_pkgdep_in_array(pkgdeps, pkgver))
continue; continue;
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"architecture", &arch); "architecture", &arch);
if (!xbps_pkg_arch_match(repo->xhp, arch, NULL)) if (!xbps_pkg_arch_match(repo->xhp, arch, NULL))
continue; continue;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver);
/* match */ /* match */
if (revdeps == NULL) if (revdeps == NULL)
revdeps = prop_array_create(); revdeps = xbps_array_create();
if (!xbps_match_string_in_array(revdeps, tpkgver)) if (!xbps_match_string_in_array(revdeps, tpkgver))
prop_array_add_cstring_nocopy(revdeps, tpkgver); xbps_array_add_cstring_nocopy(revdeps, tpkgver);
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return revdeps; return revdeps;
} }
prop_array_t xbps_array_t
xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg) xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
{ {
prop_array_t revdeps = NULL, vdeps = NULL; xbps_array_t revdeps = NULL, vdeps = NULL;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *vpkg; const char *vpkg;
char *buf = NULL; char *buf = NULL;
unsigned int i; unsigned int i;
@@ -321,11 +321,11 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
/* /*
* If pkg is a virtual pkg let's match it instead of the real pkgver. * If pkg is a virtual pkg let's match it instead of the real pkgver.
*/ */
if ((vdeps = prop_dictionary_get(pkgd, "provides"))) { if ((vdeps = xbps_dictionary_get(pkgd, "provides"))) {
for (i = 0; i < prop_array_count(vdeps); i++) { for (i = 0; i < xbps_array_count(vdeps); i++) {
char *vpkgn; char *vpkgn;
prop_array_get_cstring_nocopy(vdeps, i, &vpkg); xbps_array_get_cstring_nocopy(vdeps, i, &vpkg);
if (strchr(vpkg, '_') == NULL) if (strchr(vpkg, '_') == NULL)
buf = xbps_xasprintf("%s_1", vpkg); buf = xbps_xasprintf("%s_1", vpkg);
else else
@@ -346,7 +346,7 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
free(buf); free(buf);
} }
} }
if (!prop_array_count(revdeps)) if (!xbps_array_count(revdeps))
revdeps = revdeps_match(repo, pkgd, NULL); revdeps = revdeps_match(repo, pkgd, NULL);
return revdeps; return revdeps;

View File

@@ -32,8 +32,8 @@
static int static int
store_dependency(struct xbps_handle *xhp, store_dependency(struct xbps_handle *xhp,
prop_array_t unsorted, xbps_array_t unsorted,
prop_dictionary_t repo_pkgd, xbps_dictionary_t repo_pkgd,
pkg_state_t repo_pkg_state) pkg_state_t repo_pkg_state)
{ {
int rv; int rv;
@@ -46,12 +46,12 @@ store_dependency(struct xbps_handle *xhp,
/* /*
* Add required objects into package dep's dictionary. * Add required objects into package dep's dictionary.
*/ */
if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true)) if (!xbps_dictionary_set_bool(repo_pkgd, "automatic-install", true))
return EINVAL; return EINVAL;
/* /*
* Add the dictionary into the unsorted queue. * Add the dictionary into the unsorted queue.
*/ */
prop_array_add(unsorted, repo_pkgd); xbps_array_add(unsorted, repo_pkgd);
xbps_dbg_printf_append(xhp, "(added)\n"); xbps_dbg_printf_append(xhp, "(added)\n");
return 0; return 0;
@@ -60,10 +60,10 @@ store_dependency(struct xbps_handle *xhp,
static int static int
add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg) add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
{ {
prop_array_t mdeps; xbps_array_t mdeps;
prop_string_t reqpkg_str; xbps_string_t reqpkg_str;
prop_object_iterator_t iter = NULL; xbps_object_iterator_t iter = NULL;
prop_object_t obj; xbps_object_t obj;
unsigned int idx = 0; unsigned int idx = 0;
bool add_pkgdep, pkgfound, update_pkgdep; bool add_pkgdep, pkgfound, update_pkgdep;
int rv = 0; int rv = 0;
@@ -71,22 +71,22 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
assert(reqpkg != NULL); assert(reqpkg != NULL);
add_pkgdep = update_pkgdep = pkgfound = false; add_pkgdep = update_pkgdep = pkgfound = false;
mdeps = prop_dictionary_get(xhp->transd, "missing_deps"); mdeps = xbps_dictionary_get(xhp->transd, "missing_deps");
reqpkg_str = prop_string_create_cstring_nocopy(reqpkg); reqpkg_str = xbps_string_create_cstring_nocopy(reqpkg);
if (reqpkg_str == NULL) if (reqpkg_str == NULL)
return errno; return errno;
iter = prop_array_iterator(mdeps); iter = xbps_array_iterator(mdeps);
if (iter == NULL) if (iter == NULL)
goto out; goto out;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
const char *curdep, *curver, *pkgver; const char *curdep, *curver, *pkgver;
char *curpkgnamedep = NULL, *pkgnamedep = NULL; char *curpkgnamedep = NULL, *pkgnamedep = NULL;
assert(prop_object_type(obj) == PROP_TYPE_STRING); assert(xbps_object_type(obj) == XBPS_TYPE_STRING);
curdep = prop_string_cstring_nocopy(obj); curdep = xbps_string_cstring_nocopy(obj);
curver = xbps_pkgpattern_version(curdep); curver = xbps_pkgpattern_version(curdep);
pkgver = xbps_pkgpattern_version(reqpkg); pkgver = xbps_pkgpattern_version(reqpkg);
if (curver == NULL || pkgver == NULL) if (curver == NULL || pkgver == NULL)
@@ -132,11 +132,11 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
add_pkgdep = true; add_pkgdep = true;
out: out:
if (iter) if (iter)
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
if (update_pkgdep) if (update_pkgdep)
prop_array_remove(mdeps, idx); xbps_array_remove(mdeps, idx);
if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) { if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) {
prop_object_release(reqpkg_str); xbps_object_release(reqpkg_str);
return errno; return errno;
} }
@@ -147,15 +147,15 @@ out:
static int static int
find_repo_deps(struct xbps_handle *xhp, find_repo_deps(struct xbps_handle *xhp,
prop_array_t unsorted, /* array of unsorted deps */ xbps_array_t unsorted, /* array of unsorted deps */
prop_array_t pkg_rdeps_array, /* current pkg rundeps array */ xbps_array_t pkg_rdeps_array, /* current pkg rundeps array */
const char *curpkg, /* current pkgver */ const char *curpkg, /* current pkgver */
unsigned short *depth) /* max recursion depth */ unsigned short *depth) /* max recursion depth */
{ {
prop_dictionary_t curpkgd, tmpd; xbps_dictionary_t curpkgd, tmpd;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_array_t curpkgrdeps; xbps_array_t curpkgrdeps;
pkg_state_t state; pkg_state_t state;
unsigned int x; unsigned int x;
const char *reqpkg, *pkgver_q, *reason = NULL; const char *reqpkg, *pkgver_q, *reason = NULL;
@@ -169,11 +169,11 @@ find_repo_deps(struct xbps_handle *xhp,
* Iterate over the list of required run dependencies for * Iterate over the list of required run dependencies for
* current package. * current package.
*/ */
iter = prop_array_iterator(pkg_rdeps_array); iter = xbps_array_iterator(pkg_rdeps_array);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
reqpkg = prop_string_cstring_nocopy(obj); reqpkg = xbps_string_cstring_nocopy(obj);
if (xhp->flags & XBPS_FLAG_DEBUG) { if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, ""); xbps_dbg_printf(xhp, "");
for (x = 0; x < *depth; x++) for (x = 0; x < *depth; x++)
@@ -213,7 +213,7 @@ find_repo_deps(struct xbps_handle *xhp,
* Check if installed version matches the * Check if installed version matches the
* required pkgdep version. * required pkgdep version.
*/ */
prop_dictionary_get_cstring_nocopy(tmpd, xbps_dictionary_get_cstring_nocopy(tmpd,
"pkgver", &pkgver_q); "pkgver", &pkgver_q);
/* Check its state */ /* Check its state */
@@ -277,7 +277,7 @@ find_repo_deps(struct xbps_handle *xhp,
*/ */
if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) || if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) ||
(curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) { (curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) {
prop_dictionary_get_cstring_nocopy(curpkgd, xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &pkgver_q); "pkgver", &pkgver_q);
xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q); xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q);
continue; continue;
@@ -315,7 +315,7 @@ find_repo_deps(struct xbps_handle *xhp,
continue; continue;
} }
} }
prop_dictionary_get_cstring_nocopy(curpkgd, xbps_dictionary_get_cstring_nocopy(curpkgd,
"pkgver", &pkgver_q); "pkgver", &pkgver_q);
reqpkgname = xbps_pkg_name(pkgver_q); reqpkgname = xbps_pkg_name(pkgver_q);
assert(reqpkgname); assert(reqpkgname);
@@ -342,7 +342,7 @@ find_repo_deps(struct xbps_handle *xhp,
/* /*
* Package is on repo, add it into the transaction dictionary. * Package is on repo, add it into the transaction dictionary.
*/ */
prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason); xbps_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
rv = store_dependency(xhp, unsorted, curpkgd, state); rv = store_dependency(xhp, unsorted, curpkgd, state);
if (rv != 0) { if (rv != 0) {
xbps_dbg_printf(xhp, "store_dependency failed for " xbps_dbg_printf(xhp, "store_dependency failed for "
@@ -352,7 +352,7 @@ find_repo_deps(struct xbps_handle *xhp,
/* /*
* If package doesn't have rundeps, pass to the next one. * If package doesn't have rundeps, pass to the next one.
*/ */
curpkgrdeps = prop_dictionary_get(curpkgd, "run_depends"); curpkgrdeps = xbps_dictionary_get(curpkgd, "run_depends");
if (curpkgrdeps == NULL) if (curpkgrdeps == NULL)
continue; continue;
@@ -376,7 +376,7 @@ find_repo_deps(struct xbps_handle *xhp,
break; break;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
(*depth)--; (*depth)--;
return rv; return rv;
@@ -384,18 +384,18 @@ find_repo_deps(struct xbps_handle *xhp,
int HIDDEN int HIDDEN
xbps_repository_find_deps(struct xbps_handle *xhp, xbps_repository_find_deps(struct xbps_handle *xhp,
prop_array_t unsorted, xbps_array_t unsorted,
prop_dictionary_t repo_pkgd) xbps_dictionary_t repo_pkgd)
{ {
prop_array_t pkg_rdeps; xbps_array_t pkg_rdeps;
const char *pkgver; const char *pkgver;
unsigned short depth = 0; unsigned short depth = 0;
pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends"); pkg_rdeps = xbps_dictionary_get(repo_pkgd, "run_depends");
if (prop_array_count(pkg_rdeps) == 0) if (xbps_array_count(pkg_rdeps) == 0)
return 0; return 0;
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
xbps_dbg_printf(xhp, "Finding required dependencies for '%s':\n", pkgver); xbps_dbg_printf(xhp, "Finding required dependencies for '%s':\n", pkgver);
/* /*
* This will find direct and indirect deps, if any of them is not * This will find direct and indirect deps, if any of them is not

View File

@@ -37,8 +37,8 @@
* @defgroup repopool Repository pool functions * @defgroup repopool Repository pool functions
*/ */
struct rpool_fpkg { struct rpool_fpkg {
prop_array_t revdeps; xbps_array_t revdeps;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *pattern; const char *pattern;
const char *bestpkgver; const char *bestpkgver;
bool best; bool best;
@@ -78,22 +78,22 @@ static int
find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done) find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done)
{ {
struct rpool_fpkg *rpf = arg; struct rpool_fpkg *rpf = arg;
prop_array_t revdeps = NULL; xbps_array_t revdeps = NULL;
const char *pkgver; const char *pkgver;
unsigned int i; unsigned int i;
(void)done; (void)done;
revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern); revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern);
if (prop_array_count(revdeps)) { if (xbps_array_count(revdeps)) {
/* found */ /* found */
if (rpf->revdeps == NULL) if (rpf->revdeps == NULL)
rpf->revdeps = prop_array_create(); rpf->revdeps = xbps_array_create();
for (i = 0; i < prop_array_count(revdeps); i++) { for (i = 0; i < xbps_array_count(revdeps); i++) {
prop_array_get_cstring_nocopy(revdeps, i, &pkgver); xbps_array_get_cstring_nocopy(revdeps, i, &pkgver);
prop_array_add_cstring_nocopy(rpf->revdeps, pkgver); xbps_array_add_cstring_nocopy(rpf->revdeps, pkgver);
} }
prop_object_release(revdeps); xbps_object_release(revdeps);
} }
return 0; return 0;
} }
@@ -102,7 +102,7 @@ static int
find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done) find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
{ {
struct rpool_fpkg *rpf = arg; struct rpool_fpkg *rpf = arg;
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *repopkgver; const char *repopkgver;
(void)done; (void)done;
@@ -117,14 +117,14 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
"'%s'.\n", rpf->pattern, repo->uri); "'%s'.\n", rpf->pattern, repo->uri);
return 0; return 0;
} }
prop_dictionary_get_cstring_nocopy(pkgd, xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &repopkgver); "pkgver", &repopkgver);
if (rpf->bestpkgver == NULL) { if (rpf->bestpkgver == NULL) {
xbps_dbg_printf(repo->xhp, xbps_dbg_printf(repo->xhp,
"[rpool] Found best match '%s' (%s).\n", "[rpool] Found best match '%s' (%s).\n",
repopkgver, repo->uri); repopkgver, repo->uri);
rpf->pkgd = pkgd; rpf->pkgd = pkgd;
prop_dictionary_set_cstring_nocopy(rpf->pkgd, xbps_dictionary_set_cstring_nocopy(rpf->pkgd,
"repository", repo->uri); "repository", repo->uri);
rpf->bestpkgver = repopkgver; rpf->bestpkgver = repopkgver;
return 0; return 0;
@@ -138,7 +138,7 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
"[rpool] Found best match '%s' (%s).\n", "[rpool] Found best match '%s' (%s).\n",
repopkgver, repo->uri); repopkgver, repo->uri);
rpf->pkgd = pkgd; rpf->pkgd = pkgd;
prop_dictionary_set_cstring_nocopy(rpf->pkgd, xbps_dictionary_set_cstring_nocopy(rpf->pkgd,
"repository", repo->uri); "repository", repo->uri);
rpf->bestpkgver = repopkgver; rpf->bestpkgver = repopkgver;
} }
@@ -152,7 +152,7 @@ typedef enum {
REVDEPS_PKG REVDEPS_PKG
} pkg_repo_type_t; } pkg_repo_type_t;
static prop_object_t static xbps_object_t
repo_find_pkg(struct xbps_handle *xhp, repo_find_pkg(struct xbps_handle *xhp,
const char *pkg, const char *pkg,
pkg_repo_type_t type) pkg_repo_type_t type)
@@ -200,7 +200,7 @@ repo_find_pkg(struct xbps_handle *xhp,
return rpf.pkgd; return rpf.pkgd;
} }
prop_dictionary_t xbps_dictionary_t
xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg) xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
{ {
assert(xhp); assert(xhp);
@@ -209,7 +209,7 @@ xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg)
return repo_find_pkg(xhp, pkg, VIRTUAL_PKG); return repo_find_pkg(xhp, pkg, VIRTUAL_PKG);
} }
prop_dictionary_t xbps_dictionary_t
xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg) xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
{ {
assert(xhp); assert(xhp);
@@ -221,7 +221,7 @@ xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg)
return repo_find_pkg(xhp, pkg, REAL_PKG); return repo_find_pkg(xhp, pkg, REAL_PKG);
} }
prop_array_t xbps_array_t
xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
assert(xhp); assert(xhp);
@@ -230,12 +230,12 @@ xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
return repo_find_pkg(xhp, pkg, REVDEPS_PKG); return repo_find_pkg(xhp, pkg, REVDEPS_PKG);
} }
prop_dictionary_t xbps_dictionary_t
xbps_rpool_get_pkg_plist(struct xbps_handle *xhp, xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
const char *pkg, const char *pkg,
const char *plistf) const char *plistf)
{ {
prop_dictionary_t pkgd = NULL, plistd = NULL; xbps_dictionary_t pkgd = NULL, plistd = NULL;
const char *repo; const char *repo;
char *url; char *url;
@@ -261,8 +261,8 @@ xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
} }
plistd = xbps_get_pkg_plist_from_binpkg(url, plistf); plistd = xbps_get_pkg_plist_from_binpkg(url, plistf);
if (plistd) { if (plistd) {
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repo); xbps_dictionary_get_cstring_nocopy(pkgd, "repository", &repo);
prop_dictionary_set_cstring_nocopy(plistd, "repository", repo); xbps_dictionary_set_cstring_nocopy(plistd, "repository", repo);
} }
free(url); free(url);

View File

@@ -56,23 +56,23 @@
*/ */
static int static int
check_binpkgs_hash(struct xbps_handle *xhp, prop_object_iterator_t iter) check_binpkgs_hash(struct xbps_handle *xhp, xbps_object_iterator_t iter)
{ {
prop_object_t obj; xbps_object_t obj;
const char *pkgver, *arch, *repoloc, *sha256, *trans; const char *pkgver, *arch, *repoloc, *sha256, *trans;
char *binfile, *filen; char *binfile, *filen;
int rv = 0; int rv = 0;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
if ((strcmp(trans, "remove") == 0) || if ((strcmp(trans, "remove") == 0) ||
(strcmp(trans, "configure") == 0)) (strcmp(trans, "configure") == 0))
continue; continue;
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"filename-sha256", &sha256); "filename-sha256", &sha256);
binfile = xbps_repository_pkg_path(xhp, obj); binfile = xbps_repository_pkg_path(xhp, obj);
@@ -97,29 +97,29 @@ check_binpkgs_hash(struct xbps_handle *xhp, prop_object_iterator_t iter)
free(binfile); free(binfile);
free(filen); free(filen);
} }
prop_object_iterator_reset(iter); xbps_object_iterator_reset(iter);
return rv; return rv;
} }
static int static int
download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter) download_binpkgs(struct xbps_handle *xhp, xbps_object_iterator_t iter)
{ {
prop_object_t obj; xbps_object_t obj;
const char *pkgver, *arch, *fetchstr, *repoloc, *trans; const char *pkgver, *arch, *fetchstr, *repoloc, *trans;
char *binfile, *filen; char *binfile, *filen;
int rv = 0; int rv = 0;
bool state_dload = false; bool state_dload = false;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
if ((strcmp(trans, "remove") == 0) || if ((strcmp(trans, "remove") == 0) ||
(strcmp(trans, "configure") == 0)) (strcmp(trans, "configure") == 0))
continue; continue;
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
binfile = xbps_repository_pkg_path(xhp, obj); binfile = xbps_repository_pkg_path(xhp, obj);
if (binfile == NULL) { if (binfile == NULL) {
@@ -188,7 +188,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
free(binfile); free(binfile);
free(filen); free(filen);
} }
prop_object_iterator_reset(iter); xbps_object_iterator_reset(iter);
return rv; return rv;
} }
@@ -196,13 +196,13 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
int int
xbps_transaction_commit(struct xbps_handle *xhp) xbps_transaction_commit(struct xbps_handle *xhp)
{ {
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkgver, *tract; const char *pkgver, *tract;
int rv = 0; int rv = 0;
bool update, install, sr; bool update, install, sr;
assert(prop_object_type(xhp->transd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(xhp->transd) == XBPS_TYPE_DICTIONARY);
update = install = false; update = install = false;
iter = xbps_array_iter_from_dict(xhp->transd, "packages"); iter = xbps_array_iter_from_dict(xhp->transd, "packages");
@@ -225,10 +225,10 @@ xbps_transaction_commit(struct xbps_handle *xhp)
*/ */
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_RUN, 0, NULL, NULL); xbps_set_cb_state(xhp, XBPS_STATE_TRANS_RUN, 0, NULL, NULL);
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
update = false; update = false;
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
if (strcmp(tract, "remove") == 0) { if (strcmp(tract, "remove") == 0) {
update = false; update = false;
@@ -236,9 +236,9 @@ xbps_transaction_commit(struct xbps_handle *xhp)
/* /*
* Remove package. * Remove package.
*/ */
prop_dictionary_get_bool(obj, "remove-and-update", xbps_dictionary_get_bool(obj, "remove-and-update",
&update); &update);
prop_dictionary_get_bool(obj, "softreplace", &sr); xbps_dictionary_get_bool(obj, "softreplace", &sr);
rv = xbps_remove_pkg(xhp, pkgver, update, sr); rv = xbps_remove_pkg(xhp, pkgver, update, sr);
if (rv != 0) { if (rv != 0) {
xbps_dbg_printf(xhp, "[trans] failed to " xbps_dbg_printf(xhp, "[trans] failed to "
@@ -303,20 +303,20 @@ xbps_transaction_commit(struct xbps_handle *xhp)
if (xhp->target_arch && strcmp(xhp->native_arch, xhp->target_arch)) if (xhp->target_arch && strcmp(xhp->native_arch, xhp->target_arch))
goto out; goto out;
prop_object_iterator_reset(iter); xbps_object_iterator_reset(iter);
/* /*
* Configure all unpacked packages. * Configure all unpacked packages.
*/ */
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL); xbps_set_cb_state(xhp, XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL);
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
if ((strcmp(tract, "remove") == 0) || if ((strcmp(tract, "remove") == 0) ||
(strcmp(tract, "configure") == 0)) (strcmp(tract, "configure") == 0))
continue; continue;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
update = false; update = false;
if (strcmp(tract, "update") == 0) if (strcmp(tract, "update") == 0)
update = true; update = true;
@@ -341,7 +341,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
} }
out: out:
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return rv; return rv;
} }

View File

@@ -55,9 +55,9 @@
static int static int
compute_transaction_stats(struct xbps_handle *xhp) compute_transaction_stats(struct xbps_handle *xhp)
{ {
prop_dictionary_t pkg_metad; xbps_dictionary_t pkg_metad;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
prop_object_t obj; xbps_object_t obj;
uint64_t tsize, dlsize, instsize, rmsize; uint64_t tsize, dlsize, instsize, rmsize;
uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt; uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt;
int rv = 0; int rv = 0;
@@ -70,14 +70,14 @@ compute_transaction_stats(struct xbps_handle *xhp)
if (iter == NULL) if (iter == NULL)
return EINVAL; return EINVAL;
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
/* /*
* Count number of pkgs to be removed, configured, * Count number of pkgs to be removed, configured,
* installed and updated. * installed and updated.
*/ */
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repo); xbps_dictionary_get_cstring_nocopy(obj, "repository", &repo);
if (strcmp(tract, "configure") == 0) { if (strcmp(tract, "configure") == 0) {
cf_pkgcnt++; cf_pkgcnt++;
@@ -105,17 +105,17 @@ compute_transaction_stats(struct xbps_handle *xhp)
free(pkgname); free(pkgname);
if (pkg_metad == NULL) if (pkg_metad == NULL)
continue; continue;
prop_dictionary_get_uint64(pkg_metad, xbps_dictionary_get_uint64(pkg_metad,
"installed_size", &tsize); "installed_size", &tsize);
rmsize += tsize; rmsize += tsize;
} }
if ((strcmp(tract, "install") == 0) || if ((strcmp(tract, "install") == 0) ||
(strcmp(tract, "update") == 0)) { (strcmp(tract, "update") == 0)) {
prop_dictionary_get_uint64(obj, xbps_dictionary_get_uint64(obj,
"installed_size", &tsize); "installed_size", &tsize);
instsize += tsize; instsize += tsize;
if (xbps_repository_is_remote(repo)) { if (xbps_repository_is_remote(repo)) {
prop_dictionary_get_uint64(obj, xbps_dictionary_get_uint64(obj,
"filename-size", &tsize); "filename-size", &tsize);
dlsize += tsize; dlsize += tsize;
} }
@@ -123,25 +123,25 @@ compute_transaction_stats(struct xbps_handle *xhp)
} }
if (inst_pkgcnt && if (inst_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-install-pkgs", !xbps_dictionary_set_uint32(xhp->transd, "total-install-pkgs",
inst_pkgcnt)) { inst_pkgcnt)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (up_pkgcnt && if (up_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-update-pkgs", !xbps_dictionary_set_uint32(xhp->transd, "total-update-pkgs",
up_pkgcnt)) { up_pkgcnt)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (cf_pkgcnt && if (cf_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-configure-pkgs", !xbps_dictionary_set_uint32(xhp->transd, "total-configure-pkgs",
cf_pkgcnt)) { cf_pkgcnt)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
if (rm_pkgcnt && if (rm_pkgcnt &&
!prop_dictionary_set_uint32(xhp->transd, "total-remove-pkgs", !xbps_dictionary_set_uint32(xhp->transd, "total-remove-pkgs",
rm_pkgcnt)) { rm_pkgcnt)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
@@ -160,7 +160,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
* Add object in transaction dictionary with total installed * Add object in transaction dictionary with total installed
* size that it will take. * size that it will take.
*/ */
if (!prop_dictionary_set_uint64(xhp->transd, if (!xbps_dictionary_set_uint64(xhp->transd,
"total-installed-size", instsize)) { "total-installed-size", instsize)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
@@ -169,7 +169,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
* Add object in transaction dictionary with total download * Add object in transaction dictionary with total download
* size that needs to be sucked in. * size that needs to be sucked in.
*/ */
if (!prop_dictionary_set_uint64(xhp->transd, if (!xbps_dictionary_set_uint64(xhp->transd,
"total-download-size", dlsize)) { "total-download-size", dlsize)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
@@ -178,13 +178,13 @@ compute_transaction_stats(struct xbps_handle *xhp)
* Add object in transaction dictionary with total size to be * Add object in transaction dictionary with total size to be
* freed from packages to be removed. * freed from packages to be removed.
*/ */
if (!prop_dictionary_set_uint64(xhp->transd, if (!xbps_dictionary_set_uint64(xhp->transd,
"total-removed-size", rmsize)) { "total-removed-size", rmsize)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
out: out:
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return rv; return rv;
} }
@@ -192,41 +192,41 @@ out:
int HIDDEN int HIDDEN
xbps_transaction_init(struct xbps_handle *xhp) xbps_transaction_init(struct xbps_handle *xhp)
{ {
prop_array_t unsorted, mdeps, conflicts; xbps_array_t unsorted, mdeps, conflicts;
if (xhp->transd != NULL) if (xhp->transd != NULL)
return 0; return 0;
if ((xhp->transd = prop_dictionary_create()) == NULL) if ((xhp->transd = xbps_dictionary_create()) == NULL)
return ENOMEM; return ENOMEM;
if ((unsorted = prop_array_create()) == NULL) { if ((unsorted = xbps_array_create()) == NULL) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return ENOMEM; return ENOMEM;
} }
if (!xbps_add_obj_to_dict(xhp->transd, unsorted, "unsorted_deps")) { if (!xbps_add_obj_to_dict(xhp->transd, unsorted, "unsorted_deps")) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return EINVAL; return EINVAL;
} }
if ((mdeps = prop_array_create()) == NULL) { if ((mdeps = xbps_array_create()) == NULL) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return ENOMEM; return ENOMEM;
} }
if (!xbps_add_obj_to_dict(xhp->transd, mdeps, "missing_deps")) { if (!xbps_add_obj_to_dict(xhp->transd, mdeps, "missing_deps")) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return EINVAL; return EINVAL;
} }
if ((conflicts = prop_array_create()) == NULL) { if ((conflicts = xbps_array_create()) == NULL) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return ENOMEM; return ENOMEM;
} }
if (!xbps_add_obj_to_dict(xhp->transd, conflicts, "conflicts")) { if (!xbps_add_obj_to_dict(xhp->transd, conflicts, "conflicts")) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return EINVAL; return EINVAL;
} }
@@ -237,7 +237,7 @@ xbps_transaction_init(struct xbps_handle *xhp)
int int
xbps_transaction_prepare(struct xbps_handle *xhp) xbps_transaction_prepare(struct xbps_handle *xhp)
{ {
prop_array_t mdeps, conflicts; xbps_array_t mdeps, conflicts;
int rv = 0; int rv = 0;
if (xhp->transd == NULL) if (xhp->transd == NULL)
@@ -246,22 +246,22 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
/* /*
* If there are missing deps bail out. * If there are missing deps bail out.
*/ */
mdeps = prop_dictionary_get(xhp->transd, "missing_deps"); mdeps = xbps_dictionary_get(xhp->transd, "missing_deps");
if (prop_array_count(mdeps) > 0) if (xbps_array_count(mdeps) > 0)
return ENODEV; return ENODEV;
/* /*
* If there are package conflicts bail out. * If there are package conflicts bail out.
*/ */
conflicts = prop_dictionary_get(xhp->transd, "conflicts"); conflicts = xbps_dictionary_get(xhp->transd, "conflicts");
if (prop_array_count(conflicts) > 0) if (xbps_array_count(conflicts) > 0)
return EAGAIN; return EAGAIN;
/* /*
* Check for packages to be replaced. * Check for packages to be replaced.
*/ */
if ((rv = xbps_transaction_package_replace(xhp)) != 0) { if ((rv = xbps_transaction_package_replace(xhp)) != 0) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return rv; return rv;
} }
@@ -269,7 +269,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
* Sort package dependencies if necessary. * Sort package dependencies if necessary.
*/ */
if ((rv = xbps_transaction_sort(xhp)) != 0) { if ((rv = xbps_transaction_sort(xhp)) != 0) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return rv; return rv;
} }
@@ -279,16 +279,16 @@ xbps_transaction_prepare(struct xbps_handle *xhp)
* and removed to the transaction dictionary. * and removed to the transaction dictionary.
*/ */
if ((rv = compute_transaction_stats(xhp)) != 0) { if ((rv = compute_transaction_stats(xhp)) != 0) {
prop_object_release(xhp->transd); xbps_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return rv; return rv;
} }
/* /*
* The missing deps and conflicts arrays are not necessary anymore. * The missing deps and conflicts arrays are not necessary anymore.
*/ */
prop_dictionary_remove(xhp->transd, "missing_deps"); xbps_dictionary_remove(xhp->transd, "missing_deps");
prop_dictionary_remove(xhp->transd, "conflicts"); xbps_dictionary_remove(xhp->transd, "conflicts");
prop_dictionary_make_immutable(xhp->transd); xbps_dictionary_make_immutable(xhp->transd);
return 0; return 0;
} }

View File

@@ -60,8 +60,8 @@ enum {
static int static int
trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action) trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
{ {
prop_dictionary_t pkg_pkgdb = NULL, pkg_repod; xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod;
prop_array_t unsorted; xbps_array_t unsorted;
const char *repoloc, *repopkgver, *instpkgver, *reason; const char *repoloc, *repopkgver, *instpkgver, *reason;
char *pkgname; char *pkgname;
int rv = 0; int rv = 0;
@@ -90,14 +90,14 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
return ENOENT; return ENOENT;
} }
} }
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc); xbps_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
if (action == TRANS_UPDATE) { if (action == TRANS_UPDATE) {
/* /*
* Compare installed version vs best pkg available in repos. * Compare installed version vs best pkg available in repos.
*/ */
prop_dictionary_get_cstring_nocopy(pkg_pkgdb, xbps_dictionary_get_cstring_nocopy(pkg_pkgdb,
"pkgver", &instpkgver); "pkgver", &instpkgver);
if (xbps_cmpver(repopkgver, instpkgver) <= 0) { if (xbps_cmpver(repopkgver, instpkgver) <= 0) {
xbps_dbg_printf(xhp, "[rpool] Skipping `%s' " xbps_dbg_printf(xhp, "[rpool] Skipping `%s' "
@@ -106,9 +106,9 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
return EEXIST; return EEXIST;
} }
/* respect current install mode from pkgdb */ /* respect current install mode from pkgdb */
prop_dictionary_get_bool(pkg_pkgdb, "automatic-install", xbps_dictionary_get_bool(pkg_pkgdb, "automatic-install",
&autoinst); &autoinst);
prop_dictionary_set_bool(pkg_repod, "automatic-install", xbps_dictionary_set_bool(pkg_repod, "automatic-install",
autoinst); autoinst);
} }
/* /*
@@ -117,7 +117,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
if ((rv = xbps_transaction_init(xhp)) != 0) if ((rv = xbps_transaction_init(xhp)) != 0)
return rv; return rv;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
/* /*
* Find out if package has matched conflicts. * Find out if package has matched conflicts.
*/ */
@@ -166,7 +166,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
* Set transaction obj in pkg dictionary to "install", "configure" * Set transaction obj in pkg dictionary to "install", "configure"
* or "update". * or "update".
*/ */
if (!prop_dictionary_set_cstring_nocopy(pkg_repod, if (!xbps_dictionary_set_cstring_nocopy(pkg_repod,
"transaction", reason)) "transaction", reason))
return EINVAL; return EINVAL;
@@ -174,7 +174,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
* Add the pkg dictionary from repository's index dictionary into * Add the pkg dictionary from repository's index dictionary into
* the "unsorted" queue. * the "unsorted" queue.
*/ */
if (!prop_array_add(unsorted, pkg_repod)) if (!xbps_array_add(unsorted, pkg_repod))
return EINVAL; return EINVAL;
xbps_dbg_printf(xhp, "%s: added into the transaction (%s).\n", xbps_dbg_printf(xhp, "%s: added into the transaction (%s).\n",
@@ -186,9 +186,9 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
int int
xbps_transaction_update_packages(struct xbps_handle *xhp) xbps_transaction_update_packages(struct xbps_handle *xhp)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkgver, *holdpkg; const char *pkgver, *holdpkg;
char *pkgname; char *pkgname;
bool foundhold = false, newpkg_found = false; bool foundhold = false, newpkg_found = false;
@@ -198,12 +198,12 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
if ((rv = xbps_pkgdb_init(xhp)) != 0) if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv; return rv;
iter = prop_dictionary_iterator(xhp->pkgdb); iter = xbps_dictionary_iterator(xhp->pkgdb);
assert(iter); assert(iter);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
@@ -233,7 +233,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
} }
free(pkgname); free(pkgname);
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
return newpkg_found ? rv : EEXIST; return newpkg_found ? rv : EEXIST;
} }
@@ -248,7 +248,7 @@ int
xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg,
bool reinstall) bool reinstall)
{ {
prop_dictionary_t pkgd = NULL; xbps_dictionary_t pkgd = NULL;
pkg_state_t state; pkg_state_t state;
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) || if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) ||
@@ -269,9 +269,9 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
const char *pkgname, const char *pkgname,
bool recursive) bool recursive)
{ {
prop_dictionary_t pkgd; xbps_dictionary_t pkgd;
prop_array_t unsorted, orphans, orphans_pkg, reqby; xbps_array_t unsorted, orphans, orphans_pkg, reqby;
prop_object_t obj; xbps_object_t obj;
const char *pkgver; const char *pkgver;
unsigned int count; unsigned int count;
int rv = 0; int rv = 0;
@@ -288,7 +288,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
if ((rv = xbps_transaction_init(xhp)) != 0) if ((rv = xbps_transaction_init(xhp)) != 0)
return rv; return rv;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
if (!recursive) if (!recursive)
goto rmpkg; goto rmpkg;
@@ -296,21 +296,21 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
* If recursive is set, find out which packages would be orphans * If recursive is set, find out which packages would be orphans
* if the supplied package were already removed. * if the supplied package were already removed.
*/ */
if ((orphans_pkg = prop_array_create()) == NULL) if ((orphans_pkg = xbps_array_create()) == NULL)
return ENOMEM; return ENOMEM;
prop_array_set_cstring_nocopy(orphans_pkg, 0, pkgname); xbps_array_set_cstring_nocopy(orphans_pkg, 0, pkgname);
orphans = xbps_find_pkg_orphans(xhp, orphans_pkg); orphans = xbps_find_pkg_orphans(xhp, orphans_pkg);
prop_object_release(orphans_pkg); xbps_object_release(orphans_pkg);
if (prop_object_type(orphans) != PROP_TYPE_ARRAY) if (xbps_object_type(orphans) != XBPS_TYPE_ARRAY)
return EINVAL; return EINVAL;
count = prop_array_count(orphans); count = xbps_array_count(orphans);
while (count--) { while (count--) {
obj = prop_array_get(orphans, count); obj = xbps_array_get(orphans, count);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_set_cstring_nocopy(obj, "transaction", "remove"); xbps_dictionary_set_cstring_nocopy(obj, "transaction", "remove");
prop_array_add(unsorted, obj); xbps_array_add(unsorted, obj);
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver); xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver);
} }
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname);
@@ -318,28 +318,28 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
* If target pkg is required by any installed pkg, the client must be aware * If target pkg is required by any installed pkg, the client must be aware
* of this to take appropiate action. * of this to take appropiate action.
*/ */
if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) && if ((xbps_object_type(reqby) == XBPS_TYPE_ARRAY) &&
(prop_array_count(reqby) > 0)) (xbps_array_count(reqby) > 0))
rv = EEXIST; rv = EEXIST;
prop_object_release(orphans); xbps_object_release(orphans);
return rv; return rv;
rmpkg: rmpkg:
/* /*
* Add pkg dictionary into the transaction unsorted queue. * Add pkg dictionary into the transaction unsorted queue.
*/ */
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove"); xbps_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove");
prop_array_add(unsorted, pkgd); xbps_array_add(unsorted, pkgd);
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver); xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver);
/* /*
* If target pkg is required by any installed pkg, the client must be aware * If target pkg is required by any installed pkg, the client must be aware
* of this to take appropiate action. * of this to take appropiate action.
*/ */
if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) && if ((xbps_object_type(reqby) == XBPS_TYPE_ARRAY) &&
(prop_array_count(reqby) > 0)) (xbps_array_count(reqby) > 0))
rv = EEXIST; rv = EEXIST;
return rv; return rv;
@@ -348,14 +348,14 @@ rmpkg:
int int
xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp) xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
{ {
prop_array_t orphans, unsorted; xbps_array_t orphans, unsorted;
prop_object_t obj; xbps_object_t obj;
const char *pkgver; const char *pkgver;
unsigned int count; unsigned int count;
int rv = 0; int rv = 0;
orphans = xbps_find_pkg_orphans(xhp, NULL); orphans = xbps_find_pkg_orphans(xhp, NULL);
if ((count = prop_array_count(orphans)) == 0) { if ((count = xbps_array_count(orphans)) == 0) {
/* no orphans? we are done */ /* no orphans? we are done */
rv = ENOENT; rv = ENOENT;
goto out; goto out;
@@ -366,21 +366,21 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
if ((rv = xbps_transaction_init(xhp)) != 0) if ((rv = xbps_transaction_init(xhp)) != 0)
goto out; goto out;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
/* /*
* Add pkg orphan dictionary into the transaction unsorted queue. * Add pkg orphan dictionary into the transaction unsorted queue.
*/ */
while (count--) { while (count--) {
obj = prop_array_get(orphans, count); obj = xbps_array_get(orphans, count);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_set_cstring_nocopy(obj, xbps_dictionary_set_cstring_nocopy(obj,
"transaction", "remove"); "transaction", "remove");
prop_array_add(unsorted, obj); xbps_array_add(unsorted, obj);
xbps_dbg_printf(xhp, "%s: added (remove).\n", pkgver); xbps_dbg_printf(xhp, "%s: added (remove).\n", pkgver);
} }
out: out:
if (orphans != NULL) if (orphans != NULL)
prop_object_release(orphans); xbps_object_release(orphans);
return rv; return rv;
} }

View File

@@ -36,28 +36,28 @@
int HIDDEN int HIDDEN
xbps_transaction_package_replace(struct xbps_handle *xhp) xbps_transaction_package_replace(struct xbps_handle *xhp)
{ {
prop_array_t replaces, unsorted; xbps_array_t replaces, unsorted;
prop_dictionary_t instd, reppkgd, filesd; xbps_dictionary_t instd, reppkgd, filesd;
prop_object_t obj, obj2; xbps_object_t obj, obj2;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pattern, *pkgver, *curpkgver; const char *pattern, *pkgver, *curpkgver;
char *buf, *pkgname, *curpkgname; char *buf, *pkgname, *curpkgname;
bool instd_auto, sr; bool instd_auto, sr;
unsigned int i; unsigned int i;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
for (i = 0; i < prop_array_count(unsorted); i++) { for (i = 0; i < xbps_array_count(unsorted); i++) {
obj = prop_array_get(unsorted, i); obj = xbps_array_get(unsorted, i);
replaces = prop_dictionary_get(obj, "replaces"); replaces = xbps_dictionary_get(obj, "replaces");
if (replaces == NULL || prop_array_count(replaces) == 0) if (replaces == NULL || xbps_array_count(replaces) == 0)
continue; continue;
iter = prop_array_iterator(replaces); iter = xbps_array_iterator(replaces);
assert(iter); assert(iter);
while ((obj2 = prop_object_iterator_next(iter)) != NULL) { while ((obj2 = xbps_object_iterator_next(iter)) != NULL) {
pattern = prop_string_cstring_nocopy(obj2); pattern = xbps_string_cstring_nocopy(obj2);
/* /*
* Find the installed package that matches the pattern * Find the installed package that matches the pattern
* to be replaced. * to be replaced.
@@ -66,9 +66,9 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
((instd = xbps_pkgdb_get_virtualpkg(xhp, pattern)) == NULL)) ((instd = xbps_pkgdb_get_virtualpkg(xhp, pattern)) == NULL))
continue; continue;
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"pkgver", &pkgver); "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(instd, xbps_dictionary_get_cstring_nocopy(instd,
"pkgver", &curpkgver); "pkgver", &curpkgver);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
assert(pkgname); assert(pkgname);
@@ -88,7 +88,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
"Package `%s' will be replaced by `%s', " "Package `%s' will be replaced by `%s', "
"matched with `%s'\n", curpkgver, pkgver, pattern); "matched with `%s'\n", curpkgver, pkgver, pattern);
instd_auto = false; instd_auto = false;
prop_dictionary_get_bool(instd, xbps_dictionary_get_bool(instd,
"automatic-install", &instd_auto); "automatic-install", &instd_auto);
/* /*
* Package contains replaces="pkgpattern", but the * Package contains replaces="pkgpattern", but the
@@ -99,11 +99,11 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
xbps_dbg_printf(xhp, xbps_dbg_printf(xhp,
"found replaced pkg " "found replaced pkg "
"in transaction\n"); "in transaction\n");
prop_dictionary_set_bool(instd, xbps_dictionary_set_bool(instd,
"remove-and-update", true); "remove-and-update", true);
prop_dictionary_set_bool(reppkgd, xbps_dictionary_set_bool(reppkgd,
"automatic-install", instd_auto); "automatic-install", instd_auto);
prop_dictionary_set_bool(reppkgd, xbps_dictionary_set_bool(reppkgd,
"skip-obsoletes", true); "skip-obsoletes", true);
xbps_array_replace_dict_by_name(unsorted, xbps_array_replace_dict_by_name(unsorted,
reppkgd, curpkgname); reppkgd, curpkgname);
@@ -117,45 +117,45 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
pattern, true) || pattern, true) ||
xbps_match_virtual_pkg_in_dict(instd, xbps_match_virtual_pkg_in_dict(instd,
pkgname, false)) { pkgname, false)) {
prop_dictionary_set_bool(obj, xbps_dictionary_set_bool(obj,
"automatic-install", instd_auto); "automatic-install", instd_auto);
} }
sr = false; sr = false;
prop_dictionary_get_bool(obj, "softreplace", &sr); xbps_dictionary_get_bool(obj, "softreplace", &sr);
if (sr) { if (sr) {
prop_dictionary_set_bool(obj, xbps_dictionary_set_bool(obj,
"automatic-install", instd_auto); "automatic-install", instd_auto);
prop_dictionary_set_bool(instd, xbps_dictionary_set_bool(instd,
"softreplace", true); "softreplace", true);
buf = xbps_xasprintf("%s/.%s.plist", buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, curpkgname); xhp->metadir, curpkgname);
filesd = prop_dictionary_internalize_from_file(buf); filesd = xbps_dictionary_internalize_from_file(buf);
free(buf); free(buf);
assert(filesd != NULL); assert(filesd != NULL);
buf = xbps_xasprintf("%s/.%s.plist", buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, pkgname); xhp->metadir, pkgname);
if (!prop_dictionary_externalize_to_file(filesd, buf)) { if (!xbps_dictionary_externalize_to_file(filesd, buf)) {
free(buf); free(buf);
prop_object_release(filesd); xbps_object_release(filesd);
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
free(pkgname); free(pkgname);
free(curpkgname); free(curpkgname);
return errno; return errno;
} }
prop_object_release(filesd); xbps_object_release(filesd);
free(buf); free(buf);
} }
/* /*
* Add package dictionary into the transaction and mark * Add package dictionary into the transaction and mark
* it as to be "removed". * it as to be "removed".
*/ */
prop_dictionary_set_cstring_nocopy(instd, xbps_dictionary_set_cstring_nocopy(instd,
"transaction", "remove"); "transaction", "remove");
prop_array_add(unsorted, instd); xbps_array_add(unsorted, instd);
free(pkgname); free(pkgname);
free(curpkgname); free(curpkgname);
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
} }
return 0; return 0;

View File

@@ -48,7 +48,7 @@
struct pkgdep { struct pkgdep {
TAILQ_ENTRY(pkgdep) pkgdep_entries; TAILQ_ENTRY(pkgdep) pkgdep_entries;
prop_dictionary_t d; xbps_dictionary_t d;
char *name; char *name;
}; };
@@ -66,13 +66,13 @@ pkgdep_find(const char *pkg)
/* ignore entries without dictionary */ /* ignore entries without dictionary */
continue; continue;
} }
prop_dictionary_get_cstring_nocopy(pd->d, xbps_dictionary_get_cstring_nocopy(pd->d,
"transaction", &tract); "transaction", &tract);
/* ignore pkgs to be removed */ /* ignore pkgs to be removed */
if (strcmp(tract, "remove") == 0) if (strcmp(tract, "remove") == 0)
continue; continue;
/* simple match */ /* simple match */
prop_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
if (strcmp(pkgver, pkg) == 0) if (strcmp(pkgver, pkg) == 0)
return pd; return pd;
/* pkg expression match */ /* pkg expression match */
@@ -100,7 +100,7 @@ pkgdep_find_idx(const char *pkg)
idx++; idx++;
continue; continue;
} }
prop_dictionary_get_cstring_nocopy(pd->d, xbps_dictionary_get_cstring_nocopy(pd->d,
"transaction", &tract); "transaction", &tract);
/* ignore pkgs to be removed */ /* ignore pkgs to be removed */
if (strcmp(tract, "remove") == 0) { if (strcmp(tract, "remove") == 0) {
@@ -108,7 +108,7 @@ pkgdep_find_idx(const char *pkg)
continue; continue;
} }
/* simple match */ /* simple match */
prop_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pd->d, "pkgver", &pkgver);
if (strcmp(pkgver, pkg) == 0) if (strcmp(pkgver, pkg) == 0)
return idx; return idx;
/* pkg expression match */ /* pkg expression match */
@@ -132,7 +132,7 @@ pkgdep_release(struct pkgdep *pd)
} }
static struct pkgdep * static struct pkgdep *
pkgdep_alloc(prop_dictionary_t d, const char *pkg) pkgdep_alloc(xbps_dictionary_t d, const char *pkg)
{ {
struct pkgdep *pd; struct pkgdep *pd;
@@ -145,14 +145,14 @@ pkgdep_alloc(prop_dictionary_t d, const char *pkg)
} }
static void static void
pkgdep_end(prop_array_t sorted) pkgdep_end(xbps_array_t sorted)
{ {
struct pkgdep *pd; struct pkgdep *pd;
while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) { while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) {
TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries); TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries);
if (sorted != NULL && pd->d != NULL) if (sorted != NULL && pd->d != NULL)
prop_array_add(sorted, pd->d); xbps_array_add(sorted, pd->d);
pkgdep_release(pd); pkgdep_release(pd);
} }
@@ -161,10 +161,10 @@ pkgdep_end(prop_array_t sorted)
static int static int
sort_pkg_rundeps(struct xbps_handle *xhp, sort_pkg_rundeps(struct xbps_handle *xhp,
struct pkgdep *pd, struct pkgdep *pd,
prop_array_t pkg_rundeps, xbps_array_t pkg_rundeps,
prop_array_t unsorted) xbps_array_t unsorted)
{ {
prop_dictionary_t curpkgd; xbps_dictionary_t curpkgd;
struct pkgdep *lpd, *pdn; struct pkgdep *lpd, *pdn;
const char *str, *tract; const char *str, *tract;
int32_t pkgdepidx, curpkgidx; int32_t pkgdepidx, curpkgidx;
@@ -175,8 +175,8 @@ sort_pkg_rundeps(struct xbps_handle *xhp,
curpkgidx = pkgdep_find_idx(pd->name); curpkgidx = pkgdep_find_idx(pd->name);
again: again:
for (i = idx; i < prop_array_count(pkg_rundeps); i++) { for (i = idx; i < xbps_array_count(pkg_rundeps); i++) {
prop_array_get_cstring_nocopy(pkg_rundeps, i, &str); xbps_array_get_cstring_nocopy(pkg_rundeps, i, &str);
xbps_dbg_printf(xhp, " Required dependency '%s': ", str); xbps_dbg_printf(xhp, " Required dependency '%s': ", str);
pdn = pkgdep_find(str); pdn = pkgdep_find(str);
@@ -210,7 +210,7 @@ again:
"dependency %s (depends on itself)\n", str); "dependency %s (depends on itself)\n", str);
continue; continue;
} }
prop_dictionary_get_cstring_nocopy(curpkgd, xbps_dictionary_get_cstring_nocopy(curpkgd,
"transaction", &tract); "transaction", &tract);
lpd = pkgdep_alloc(curpkgd, str); lpd = pkgdep_alloc(curpkgd, str);
@@ -255,48 +255,48 @@ again:
int HIDDEN int HIDDEN
xbps_transaction_sort(struct xbps_handle *xhp) xbps_transaction_sort(struct xbps_handle *xhp)
{ {
prop_array_t provides, sorted, unsorted, rundeps; xbps_array_t provides, sorted, unsorted, rundeps;
prop_object_t obj; xbps_object_t obj;
struct pkgdep *pd; struct pkgdep *pd;
unsigned int i, j, ndeps = 0, cnt = 0; unsigned int i, j, ndeps = 0, cnt = 0;
const char *pkgname, *pkgver, *tract, *vpkgdep; const char *pkgname, *pkgver, *tract, *vpkgdep;
int rv = 0; int rv = 0;
bool vpkg_found; bool vpkg_found;
if ((sorted = prop_array_create()) == NULL) if ((sorted = xbps_array_create()) == NULL)
return ENOMEM; return ENOMEM;
/* /*
* Add sorted packages array into transaction dictionary (empty). * Add sorted packages array into transaction dictionary (empty).
*/ */
if (!prop_dictionary_set(xhp->transd, "packages", sorted)) { if (!xbps_dictionary_set(xhp->transd, "packages", sorted)) {
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
/* /*
* All required deps are satisfied (already installed). * All required deps are satisfied (already installed).
*/ */
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
if (prop_array_count(unsorted) == 0) { if (xbps_array_count(unsorted) == 0) {
prop_dictionary_set(xhp->transd, "packages", sorted); xbps_dictionary_set(xhp->transd, "packages", sorted);
prop_object_release(sorted); xbps_object_release(sorted);
return 0; return 0;
} }
/* /*
* The sorted array should have the same capacity than * The sorted array should have the same capacity than
* all objects in the unsorted array. * all objects in the unsorted array.
*/ */
ndeps = prop_array_count(unsorted); ndeps = xbps_array_count(unsorted);
/* /*
* Iterate over the unsorted package dictionaries and sort all * Iterate over the unsorted package dictionaries and sort all
* its package dependencies. * its package dependencies.
*/ */
for (i = 0; i < ndeps; i++) { for (i = 0; i < ndeps; i++) {
vpkg_found = false; vpkg_found = false;
obj = prop_array_get(unsorted, i); obj = xbps_array_get(unsorted, i);
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
provides = prop_dictionary_get(obj, "provides"); provides = xbps_dictionary_get(obj, "provides");
xbps_dbg_printf(xhp, "Sorting package '%s' (%s): ", pkgver, tract); xbps_dbg_printf(xhp, "Sorting package '%s' (%s): ", pkgver, tract);
if (provides) { if (provides) {
@@ -305,8 +305,8 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* if any of them was previously added. If true, don't * if any of them was previously added. If true, don't
* add it into the list again, just order its deps. * add it into the list again, just order its deps.
*/ */
for (j = 0; j < prop_array_count(provides); j++) { for (j = 0; j < xbps_array_count(provides); j++) {
prop_array_get_cstring_nocopy(provides, xbps_array_get_cstring_nocopy(provides,
j, &vpkgdep); j, &vpkgdep);
pd = pkgdep_find(vpkgdep); pd = pkgdep_find(vpkgdep);
if (pd != NULL) { if (pd != NULL) {
@@ -343,8 +343,8 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* Packages that don't have deps go at head, because * Packages that don't have deps go at head, because
* it doesn't matter. * it doesn't matter.
*/ */
rundeps = prop_dictionary_get(obj, "run_depends"); rundeps = xbps_dictionary_get(obj, "run_depends");
if (prop_array_count(rundeps) == 0) { if (xbps_array_count(rundeps) == 0) {
xbps_dbg_printf_append(xhp, "\n"); xbps_dbg_printf_append(xhp, "\n");
cnt++; cnt++;
continue; continue;
@@ -368,17 +368,17 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* Sanity check that the array contains the same number of * Sanity check that the array contains the same number of
* objects than the total number of required dependencies. * objects than the total number of required dependencies.
*/ */
assert(cnt == prop_array_count(unsorted)); assert(cnt == xbps_array_count(unsorted));
/* /*
* We are done, all packages were sorted... remove the * We are done, all packages were sorted... remove the
* temporary array with unsorted packages. * temporary array with unsorted packages.
*/ */
prop_dictionary_remove(xhp->transd, "unsorted_deps"); xbps_dictionary_remove(xhp->transd, "unsorted_deps");
out: out:
if (rv != 0) if (rv != 0)
prop_dictionary_remove(xhp->transd, "packages"); xbps_dictionary_remove(xhp->transd, "packages");
prop_object_release(sorted); xbps_object_release(sorted);
return rv; return rv;
} }

View File

@@ -67,7 +67,7 @@ xbps_repository_is_remote(const char *uri)
int int
xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg) xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
{ {
prop_dictionary_t dict; xbps_dictionary_t dict;
pkg_state_t state; pkg_state_t state;
assert(xhp); assert(xhp);
@@ -172,21 +172,21 @@ xbps_pkgpattern_version(const char *pkg)
} }
char HIDDEN * char HIDDEN *
xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod) xbps_repository_pkg_path(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
{ {
const char *pkgver, *arch, *repoloc; const char *pkgver, *arch, *repoloc;
char *lbinpkg = NULL; char *lbinpkg = NULL;
assert(xhp); assert(xhp);
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
if (!prop_dictionary_get_cstring_nocopy(pkg_repod, if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"pkgver", &pkgver)) "pkgver", &pkgver))
return NULL; return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg_repod, if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"architecture", &arch)) "architecture", &arch))
return NULL; return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg_repod, if (!xbps_dictionary_get_cstring_nocopy(pkg_repod,
"repository", &repoloc)) "repository", &repoloc))
return NULL; return NULL;
@@ -208,14 +208,14 @@ xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
} }
bool bool
xbps_pkg_has_rundeps(prop_dictionary_t pkgd) xbps_pkg_has_rundeps(xbps_dictionary_t pkgd)
{ {
prop_array_t array; xbps_array_t array;
assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(pkgd) == XBPS_TYPE_DICTIONARY);
array = prop_dictionary_get(pkgd, "run_depends"); array = xbps_dictionary_get(pkgd, "run_depends");
if (prop_array_count(array)) if (xbps_array_count(array))
return true; return true;
return false; return false;

View File

@@ -140,13 +140,13 @@ xbps_file_hash_check(const char *file, const char *sha256)
} }
static const char * static const char *
file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file) file_hash_dictionary(xbps_dictionary_t d, const char *key, const char *file)
{ {
prop_object_t obj; xbps_object_t obj;
prop_object_iterator_t iter; xbps_object_iterator_t iter;
const char *curfile = NULL, *sha256 = NULL; const char *curfile = NULL, *sha256 = NULL;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY);
assert(key != NULL); assert(key != NULL);
assert(file != NULL); assert(file != NULL);
@@ -155,17 +155,17 @@ file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file)
errno = ENOENT; errno = ENOENT;
return NULL; return NULL;
} }
while ((obj = prop_object_iterator_next(iter)) != NULL) { while ((obj = xbps_object_iterator_next(iter)) != NULL) {
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"file", &curfile); "file", &curfile);
if (strcmp(file, curfile) == 0) { if (strcmp(file, curfile) == 0) {
/* file matched */ /* file matched */
prop_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256); "sha256", &sha256);
break; break;
} }
} }
prop_object_iterator_release(iter); xbps_object_iterator_release(iter);
if (sha256 == NULL) if (sha256 == NULL)
errno = ENOENT; errno = ENOENT;
@@ -174,7 +174,7 @@ file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file)
int HIDDEN int HIDDEN
xbps_file_hash_check_dictionary(struct xbps_handle *xhp, xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
prop_dictionary_t d, xbps_dictionary_t d,
const char *key, const char *key,
const char *file) const char *file)
{ {
@@ -182,7 +182,7 @@ xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
char *buf; char *buf;
int rv; int rv;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY); assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY);
assert(key != NULL); assert(key != NULL);
assert(file != NULL); assert(file != NULL);