diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index a28c2fdb..1504f8dd 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -59,7 +59,7 @@ static TAILQ_HEAD(xentry_head, xentry) xentry_list = TAILQ_HEAD_INITIALIZER(xentry_list); 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 void __attribute__((noreturn)) @@ -122,7 +122,7 @@ die(const char *fmt, ...) static void process_array(const char *key, const char *val) { - prop_array_t array; + xbps_array_t array; char *args, *p = NULL, *saveptr; assert(key); @@ -130,11 +130,11 @@ process_array(const char *key, const char *val) if (val == NULL) return; - array = prop_array_create(); + array = xbps_array_create(); assert(array); if (strchr(val, ' ') == NULL) { - prop_array_add_cstring_nocopy(array, val); + xbps_array_add_cstring_nocopy(array, val); goto out; } @@ -145,29 +145,29 @@ process_array(const char *key, const char *val) (p = strtok_r(NULL, " ", &saveptr))) { if (p == NULL) continue; - prop_array_add_cstring(array, p); + xbps_array_add_cstring(array, p); } free(args); out: - prop_dictionary_set(pkg_propsd, key, array); - prop_object_release(array); + xbps_dictionary_set(pkg_propsd, key, array); + xbps_object_release(array); } static bool entry_is_conf_file(const char *file) { - prop_array_t a; + xbps_array_t a; const char *curfile; unsigned int i; assert(file); - a = prop_dictionary_get(pkg_propsd, "conf_files"); - if (a == NULL || prop_array_count(a) == 0) + a = xbps_dictionary_get(pkg_propsd, "conf_files"); + if (a == NULL || xbps_array_count(a) == 0) return false; - for (i = 0; i < prop_array_count(a); i++) { - prop_array_get_cstring_nocopy(a, i, &curfile); + for (i = 0; i < xbps_array_count(a); i++) { + xbps_array_get_cstring_nocopy(a, i, &curfile); if (strcmp(file, curfile) == 0) return true; } @@ -292,13 +292,13 @@ out: static void process_xentry(const char *key, const char *mutable_files) { - prop_array_t a; - prop_dictionary_t d; + xbps_array_t a; + xbps_dictionary_t d; struct xentry *xe; char *p, *saveptr, *args, *tok; bool found = false, mutable_found = false; - a = prop_array_create(); + a = xbps_array_create(); assert(a); TAILQ_FOREACH_REVERSE(xe, &xentry_list, xentry_head, entries) { @@ -306,7 +306,7 @@ process_xentry(const char *key, const char *mutable_files) continue; found = true; - d = prop_dictionary_create(); + d = xbps_dictionary_create(); assert(d); /* sanitize file path */ p = strchr(xe->file, '.') + 1; @@ -316,7 +316,7 @@ process_xentry(const char *key, const char *mutable_files) if (mutable_files) { if ((strchr(mutable_files, ' ') == NULL) && (strcmp(mutable_files, p) == 0)) - prop_dictionary_set_bool(d, "mutable", true); + xbps_dictionary_set_bool(d, "mutable", true); else { args = strdup(mutable_files); assert(args); @@ -329,24 +329,24 @@ process_xentry(const char *key, const char *mutable_files) } free(args); if (mutable_found) { - prop_dictionary_set_bool(d, "mutable", + xbps_dictionary_set_bool(d, "mutable", true); mutable_found = false; } } } - prop_dictionary_set_cstring(d, "file", p); + xbps_dictionary_set_cstring(d, "file", p); if (xe->target) - prop_dictionary_set_cstring(d, "target", xe->target); + xbps_dictionary_set_cstring(d, "target", xe->target); else if (xe->hash) - prop_dictionary_set_cstring(d, "sha256", xe->hash); - prop_array_add(a, d); - prop_object_release(d); + xbps_dictionary_set_cstring(d, "sha256", xe->hash); + xbps_array_add(a, d); + xbps_object_release(d); } 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 @@ -485,17 +485,17 @@ process_archive(struct archive *ar, /* * 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 */ - xml = prop_dictionary_externalize(pkg_propsd); + xml = xbps_dictionary_externalize(pkg_propsd); assert(xml); xbps_archive_append_buf(ar, xml, strlen(xml), "./props.plist", 0644, "root", "root"); free(xml); /* Add files.plist metadata file */ - xml = prop_dictionary_externalize(pkg_filesd); + xml = xbps_dictionary_externalize(pkg_filesd); assert(xml); xbps_archive_append_buf(ar, xml, strlen(xml), "./files.plist", 0644, "root", "root"); @@ -530,7 +530,7 @@ set_build_date(void) if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", tmp) == 0) 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:"); } @@ -687,40 +687,40 @@ main(int argc, char **argv) /* * Process XBPS_PKGPROPS metadata file. */ - pkg_propsd = prop_dictionary_create(); + pkg_propsd = xbps_dictionary_create(); assert(pkg_propsd); /* Required properties */ - prop_dictionary_set_cstring_nocopy(pkg_propsd, "architecture", arch); - prop_dictionary_set_cstring_nocopy(pkg_propsd, "pkgname", pkgname); - prop_dictionary_set_cstring_nocopy(pkg_propsd, "version", version); - prop_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, "architecture", arch); + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "pkgname", pkgname); + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "version", version); + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "pkgver", pkgver); + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "short_desc", desc); set_build_date(); /* Optional properties */ if (homepage) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "homepage", homepage); if (license) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "license", license); if (maint) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "maintainer", maint); if (ldesc) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "long_desc", ldesc); if (bwith) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "packaged-with", bwith); if (srcrevs) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "source-revisions", srcrevs); if (preserve) - prop_dictionary_set_bool(pkg_propsd, "preserve", true); + xbps_dictionary_set_bool(pkg_propsd, "preserve", true); if (buildopts) - prop_dictionary_set_cstring_nocopy(pkg_propsd, + xbps_dictionary_set_cstring_nocopy(pkg_propsd, "build-options", buildopts); /* Optional arrays */ @@ -742,7 +742,7 @@ main(int argc, char **argv) /* * Process XBPS_PKGFILES metadata file. */ - pkg_filesd = prop_dictionary_create(); + pkg_filesd = xbps_dictionary_create(); assert(pkg_filesd); process_destdir(mutable_files); diff --git a/bin/xbps-dgraph/main.c b/bin/xbps-dgraph/main.c index e96a8478..dc80e50e 100644 --- a/bin/xbps-dgraph/main.c +++ b/bin/xbps-dgraph/main.c @@ -117,22 +117,22 @@ usage(void) } static const char * -convert_proptype_to_string(prop_object_t obj) +convert_proptype_to_string(xbps_object_t obj) { - switch (prop_object_type(obj)) { - case PROP_TYPE_ARRAY: + switch (xbps_object_type(obj)) { + case XBPS_TYPE_ARRAY: return "array"; - case PROP_TYPE_BOOL: + case XBPS_TYPE_BOOL: return "bool"; - case PROP_TYPE_DICTIONARY: + case XBPS_TYPE_DICTIONARY: return "dictionary"; - case PROP_TYPE_DICT_KEYSYM: + case XBPS_TYPE_DICT_KEYSYM: return "dictionary key"; - case PROP_TYPE_NUMBER: + case XBPS_TYPE_NUMBER: return "integer"; - case PROP_TYPE_STRING: + case XBPS_TYPE_STRING: return "string"; - case PROP_TYPE_DATA: + case XBPS_TYPE_DATA: return "data"; default: return NULL; @@ -142,77 +142,77 @@ convert_proptype_to_string(prop_object_t obj) static void generate_conf_file(void) { - prop_dictionary_t d, d2; + xbps_dictionary_t d, d2; struct defprops *dfp; size_t i; const char *outfile = "xbps-dgraph.conf"; - d = prop_dictionary_create(); + d = xbps_dictionary_create(); - d2 = prop_dictionary_create(); - prop_dictionary_set(d, "graph", d2); - prop_object_release(d2); + d2 = xbps_dictionary_create(); + xbps_dictionary_set(d, "graph", d2); + xbps_object_release(d2); - d2 = prop_dictionary_create(); - prop_dictionary_set(d, "edge", d2); - prop_object_release(d2); + d2 = xbps_dictionary_create(); + xbps_dictionary_set(d, "edge", d2); + xbps_object_release(d2); - d2 = prop_dictionary_create(); - prop_dictionary_set(d, "node", d2); - prop_object_release(d2); + d2 = xbps_dictionary_create(); + xbps_dictionary_set(d, "node", d2); + xbps_object_release(d2); - d2 = prop_dictionary_create(); - prop_dictionary_set(d, "node-sub", d2); - prop_object_release(d2); + d2 = xbps_dictionary_create(); + xbps_dictionary_set(d, "node-sub", d2); + xbps_object_release(d2); for (i = 0; i < __arraycount(dfprops); i++) { dfp = &dfprops[i]; - d2 = prop_dictionary_get(d, dfp->sect); - prop_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val); + d2 = xbps_dictionary_get(d, dfp->sect); + xbps_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val); } - if (prop_dictionary_externalize_to_file(d, outfile) == false) { - prop_object_release(d); + if (xbps_dictionary_externalize_to_file(d, outfile) == false) { + xbps_object_release(d); 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); } static void write_conf_property_on_stream(FILE *f, const char *section, - prop_dictionary_t confd) + xbps_dictionary_t confd) { - prop_array_t allkeys, allkeys2; - prop_dictionary_keysym_t dksym, dksym2; - prop_object_t keyobj, keyobj2; + xbps_array_t allkeys, allkeys2; + xbps_dictionary_keysym_t dksym, dksym2; + xbps_object_t keyobj, keyobj2; size_t i, x; const char *cf_val, *keyname, *keyname2; /* * Iterate over the main dictionary. */ - allkeys = prop_dictionary_all_keys(confd); - for (i = 0; i < prop_array_count(allkeys); i++) { - dksym = prop_array_get(allkeys, i); - keyname = prop_dictionary_keysym_cstring_nocopy(dksym); - keyobj = prop_dictionary_get_keysym(confd, dksym); + allkeys = xbps_dictionary_all_keys(confd); + for (i = 0; i < xbps_array_count(allkeys); i++) { + dksym = xbps_array_get(allkeys, i); + keyname = xbps_dictionary_keysym_cstring_nocopy(dksym); + keyobj = xbps_dictionary_get_keysym(confd, dksym); if (strcmp(keyname, section)) continue; /* * Iterate over the dictionary sections [edge/graph/node]. */ - allkeys2 = prop_dictionary_all_keys(keyobj); - for (x = 0; x < prop_array_count(allkeys2); x++) { - dksym2 = prop_array_get(allkeys2, x); - keyname2 = prop_dictionary_keysym_cstring_nocopy(dksym2); - keyobj2 = prop_dictionary_get_keysym(keyobj, dksym2); + allkeys2 = xbps_dictionary_all_keys(keyobj); + for (x = 0; x < xbps_array_count(allkeys2); x++) { + dksym2 = xbps_array_get(allkeys2, x); + keyname2 = xbps_dictionary_keysym_cstring_nocopy(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); - if (x + 1 >= prop_array_count(allkeys2)) + if (x + 1 >= xbps_array_count(allkeys2)) continue; fprintf(f, ","); @@ -238,19 +238,19 @@ strip_dashes_from_key(const char *str) } static void -parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd, - prop_dictionary_t sub_confd, - prop_array_t allkeys) +parse_array_in_pkg_dictionary(FILE *f, xbps_dictionary_t plistd, + xbps_dictionary_t sub_confd, + xbps_array_t allkeys) { - prop_dictionary_keysym_t dksym; - prop_object_t keyobj, sub_keyobj; + xbps_dictionary_keysym_t dksym; + xbps_object_t keyobj, sub_keyobj; unsigned int i, x; const char *tmpkeyname, *cfprop, *optnodetmp; char *optnode, *keyname; - for (i = 0; i < prop_array_count(allkeys); i++) { - dksym = prop_array_get(allkeys, i); - tmpkeyname = prop_dictionary_keysym_cstring_nocopy(dksym); + for (i = 0; i < xbps_array_count(allkeys); i++) { + dksym = xbps_array_get(allkeys, i); + tmpkeyname = xbps_dictionary_keysym_cstring_nocopy(dksym); /* Ignore these objects */ if ((strcmp(tmpkeyname, "source-revisions") == 0) || (strcmp(tmpkeyname, "files") == 0) || @@ -259,14 +259,14 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd, (strcmp(tmpkeyname, "links") == 0)) continue; - keyobj = prop_dictionary_get_keysym(plistd, dksym); + keyobj = xbps_dictionary_get_keysym(plistd, dksym); keyname = strip_dashes_from_key(tmpkeyname); optnode = NULL; fprintf(f, " main -> %s [label=\"%s\"];\n", 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 */ for (x = 0; x < __arraycount(optional_objs); x++) { 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. */ - prop_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop); - if (prop_object_type(keyobj) == PROP_TYPE_ARRAY) { + xbps_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop); + if (xbps_object_type(keyobj) == XBPS_TYPE_ARRAY) { if (optnodetmp) fprintf(f, " %s %s];\n", keyname, optnodetmp); - for (x = 0; x < prop_array_count(keyobj); x++) { - sub_keyobj = prop_array_get(keyobj, x); - if (prop_object_type(sub_keyobj) == PROP_TYPE_STRING) { + for (x = 0; x < xbps_array_count(keyobj); x++) { + sub_keyobj = xbps_array_get(keyobj, x); + if (xbps_object_type(sub_keyobj) == XBPS_TYPE_STRING) { /* * Process arrays of strings. */ fprintf(f, " %s -> %s_%u_string " "[label=\"string\"];\n", keyname, keyname, x); - prop_dictionary_get_cstring_nocopy(sub_confd, + xbps_dictionary_get_cstring_nocopy(sub_confd, "style", &cfprop); fprintf(f, " %s_%u_string [style=\"%s\",", keyname, x, cfprop); - prop_dictionary_get_cstring_nocopy(sub_confd, + xbps_dictionary_get_cstring_nocopy(sub_confd, "fillcolor", &cfprop); fprintf(f, "fillcolor=\"%s\"," "label=\"%s\"];\n", cfprop, - prop_string_cstring_nocopy(sub_keyobj)); + xbps_string_cstring_nocopy(sub_keyobj)); } } if (optnode) @@ -319,28 +319,28 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd, } else 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); - prop_dictionary_get_cstring_nocopy(sub_confd, + xbps_dictionary_get_cstring_nocopy(sub_confd, "fillcolor", &cfprop); fprintf(f, "fillcolor=\"%s\"", cfprop); /* * Process all other object types... */ - switch (prop_object_type(keyobj)) { - case PROP_TYPE_BOOL: + switch (xbps_object_type(keyobj)) { + case XBPS_TYPE_BOOL: fprintf(f, ",label=\"%s\"", - prop_bool_true(keyobj) ? "true" : "false"); + xbps_bool_true(keyobj) ? "true" : "false"); break; - case PROP_TYPE_DATA: - fprintf(f, ",label=\"%zu bytes\"", prop_data_size(keyobj)); + case XBPS_TYPE_DATA: + fprintf(f, ",label=\"%zu bytes\"", xbps_data_size(keyobj)); break; - case PROP_TYPE_NUMBER: + case XBPS_TYPE_NUMBER: fprintf(f, ",label=\"%"PRIu64" bytes\"", - prop_number_unsigned_integer_value(keyobj)); + xbps_number_unsigned_integer_value(keyobj)); break; - case PROP_TYPE_STRING: + case XBPS_TYPE_STRING: if (strcmp(keyname, "long_desc") == 0) { /* * 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=\"...\""); } else { fprintf(f, ",label=\"%s\"", - prop_string_cstring_nocopy(keyobj)); + xbps_string_cstring_nocopy(keyobj)); } break; default: @@ -365,15 +365,15 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd, static void create_dot_graph(struct xbps_handle *xhp, FILE *f, - prop_dictionary_t plistd, - prop_dictionary_t confd, + xbps_dictionary_t plistd, + xbps_dictionary_t confd, bool revdeps) { - prop_dictionary_t sub_confd; - prop_array_t allkeys, rdeps; + xbps_dictionary_t sub_confd; + xbps_array_t allkeys, rdeps; 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... @@ -407,11 +407,11 @@ create_dot_graph(struct xbps_handle *xhp, * Process the node-sub section in config file. */ fprintf(f, " main ["); - sub_confd = prop_dictionary_get(confd, "node-sub"); - prop_dictionary_get_cstring_nocopy(sub_confd, "main-style", &cfprop); + sub_confd = xbps_dictionary_get(confd, "node-sub"); + xbps_dictionary_get_cstring_nocopy(sub_confd, "main-style", &cfprop); if (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) fprintf(f, "fillcolor=\"%s\",", cfprop); fprintf(f, "label=\"Dictionary\"];\n"); @@ -422,10 +422,10 @@ create_dot_graph(struct xbps_handle *xhp, */ if (revdeps) { rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver); - if (prop_array_count(rdeps)) - prop_dictionary_set(plistd, "requiredby", rdeps); + if (xbps_array_count(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); /* * Terminate the stream... @@ -438,7 +438,7 @@ create_dot_graph(struct xbps_handle *xhp, int main(int argc, char **argv) { - prop_dictionary_t plistd, confd = NULL; + xbps_dictionary_t plistd, confd = NULL; struct xbps_handle xh; FILE *f = NULL; char *outfile = NULL; @@ -502,7 +502,7 @@ main(int argc, char **argv) /* * Internalize the configuration file. */ - confd = prop_dictionary_internalize_from_zfile(conf_file); + confd = xbps_dictionary_internalize_from_zfile(conf_file); if (confd == NULL) die("cannot read conf file `%s'", conf_file); diff --git a/bin/xbps-install/state_cb.c b/bin/xbps-install/state_cb.c index 2cab0ae6..339ed8a0 100644 --- a/bin/xbps-install/state_cb.c +++ b/bin/xbps-install/state_cb.c @@ -34,7 +34,7 @@ void state_cb(struct xbps_state_cb_data *xscd, void *cbdata) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; const char *instver, *newver; char *pkgname; bool syslog_enabled = false; @@ -90,7 +90,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata) assert(pkgname); newver = xbps_pkg_version(xscd->arg); 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); free(pkgname); break; diff --git a/bin/xbps-install/transaction.c b/bin/xbps-install/transaction.c index ec350fde..df239e60 100644 --- a/bin/xbps-install/transaction.c +++ b/bin/xbps-install/transaction.c @@ -37,8 +37,8 @@ #include "defs.h" struct transaction { - prop_dictionary_t d; - prop_object_iterator_t iter; + xbps_dictionary_t d; + xbps_object_iterator_t iter; uint32_t inst_pkgcnt; uint32_t up_pkgcnt; uint32_t cf_pkgcnt; @@ -46,45 +46,45 @@ struct transaction { }; static void -show_missing_deps(prop_array_t a) +show_missing_deps(xbps_array_t a) { unsigned int i; const char *str; fprintf(stderr, "Unable to locate some required packages:\n"); - for (i = 0; i < prop_array_count(a); i++) { - prop_array_get_cstring_nocopy(a, i, &str); + for (i = 0; i < xbps_array_count(a); i++) { + xbps_array_get_cstring_nocopy(a, i, &str); fprintf(stderr, " %s\n", str); } } static void -show_conflicts(prop_array_t a) +show_conflicts(xbps_array_t a) { unsigned int i; const char *str; fprintf(stderr, "Conflicting packages were found:\n"); - for (i = 0; i < prop_array_count(a); i++) { - prop_array_get_cstring_nocopy(a, i, &str); + for (i = 0; i < xbps_array_count(a); i++) { + xbps_array_get_cstring_nocopy(a, i, &str); fprintf(stderr, " %s\n", str); } } 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; repoloc = trans = pkgver = arch = NULL; - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); printf("%s %s", pkgver, trans); - prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); - prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); + xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); + xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch); if (repoloc && arch) printf(" %s %s", arch, repoloc); @@ -93,19 +93,19 @@ show_actions(prop_object_iterator_t iter) } 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; - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract); if (strcmp(match, tract)) continue; print_package_line(pkgver, cols, false); } - prop_object_iterator_reset(iter); + xbps_object_iterator_reset(iter); 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. */ - if (prop_dictionary_get_uint32(trans->d, "total-install-pkgs", + if (xbps_dictionary_get_uint32(trans->d, "total-install-pkgs", &trans->inst_pkgcnt)) { printf("%u package%s will be installed:\n", trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s"); show_package_list(trans->iter, "install", cols); 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)) { printf("%u package%s will be updated:\n", trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s"); show_package_list(trans->iter, "update", cols); 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)) { printf("%u package%s will be configured:\n", trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s"); show_package_list(trans->iter, "configure", cols); 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)) { printf("%u package%s will be removed:\n", 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. */ - prop_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-download-size", &dlsize); + xbps_dictionary_get_uint64(trans->d, "total-installed-size", &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) printf("\n"); @@ -258,7 +258,7 @@ update_pkg(struct xbps_handle *xhp, const char *pkgname) int 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; 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 == ENODEV) { mdeps = - prop_dictionary_get(xhp->transd, "missing_deps"); + xbps_dictionary_get(xhp->transd, "missing_deps"); /* missing packages */ show_missing_deps(mdeps); goto out; } else if (rv == EAGAIN) { /* conflicts */ - cflicts = prop_dictionary_get(xhp->transd, "conflicts"); + cflicts = xbps_dictionary_get(xhp->transd, "conflicts"); show_conflicts(cflicts); 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_append(xhp, "%s", - prop_dictionary_externalize(xhp->transd)); + xbps_dictionary_externalize(xhp->transd)); trans->d = xhp->transd; 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: if (trans->iter) - prop_object_iterator_release(trans->iter); + xbps_object_iterator_release(trans->iter); if (trans) free(trans); diff --git a/bin/xbps-pkgdb/check.c b/bin/xbps-pkgdb/check.c index a20d7361..4b3162c8 100644 --- a/bin/xbps-pkgdb/check.c +++ b/bin/xbps-pkgdb/check.c @@ -47,23 +47,23 @@ struct thread_data { static void * pkgdb_thread_worker(void *arg) { - prop_dictionary_t pkgd; - prop_array_t array; - prop_object_t obj; + xbps_dictionary_t pkgd; + xbps_array_t array; + xbps_object_t obj; struct thread_data *thd = arg; const char *pkgver; char *pkgname; unsigned int i; int rv; - array = prop_dictionary_all_keys(thd->xhp->pkgdb); + array = xbps_dictionary_all_keys(thd->xhp->pkgdb); assert(array); /* process pkgs from start until end */ for (i = thd->start; i < thd->end; i++) { - obj = prop_array_get(array, i); - pkgd = prop_dictionary_get_keysym(thd->xhp->pkgdb, obj); - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + obj = xbps_array_get(array, i); + pkgd = xbps_dictionary_get_keysym(thd->xhp->pkgdb, obj); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); if (thd->xhp->flags & XBPS_FLAG_VERBOSE) printf("Checking %s ...\n", pkgver); @@ -75,7 +75,7 @@ pkgdb_thread_worker(void *arg) fprintf(stderr, "pkgdb[%d] failed for %s: %s\n", thd->thread_num, pkgver, strerror(rv)); } - prop_object_release(array); + xbps_object_release(array); return NULL; } @@ -94,7 +94,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp) thd = calloc(maxthreads, sizeof(*thd)); assert(thd); - slicecount = prop_dictionary_count(xhp->pkgdb) / maxthreads; + slicecount = xbps_dictionary_count(xhp->pkgdb) / maxthreads; pkgcount = 0; for (i = 0; i < maxthreads; i++) { @@ -102,7 +102,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp) thd[i].xhp = xhp; thd[i].start = pkgcount; if (i + 1 >= maxthreads) - thd[i].end = prop_dictionary_count(xhp->pkgdb); + thd[i].end = xbps_dictionary_count(xhp->pkgdb); else thd[i].end = pkgcount + slicecount; pthread_create(&thd[i].thread, NULL, @@ -124,10 +124,10 @@ check_pkg_integrity_all(struct xbps_handle *xhp) int check_pkg_integrity(struct xbps_handle *xhp, - prop_dictionary_t pkgd, + xbps_dictionary_t pkgd, const char *pkgname) { - prop_dictionary_t opkgd, propsd; + xbps_dictionary_t opkgd, propsd; const char *sha256; char *buf; int rv = 0; @@ -147,27 +147,27 @@ check_pkg_integrity(struct xbps_handle *xhp, * Check for props.plist metadata file. */ 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); if (propsd == NULL) { xbps_error_printf("%s: unexistent metafile!\n", pkgname); 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); - prop_object_release(propsd); + xbps_object_release(propsd); return 1; } /* * 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) { buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); rv = xbps_file_hash_check(buf, sha256); free(buf); if (rv == ERANGE) { - prop_object_release(propsd); + xbps_object_release(propsd); fprintf(stderr, "%s: metadata file has been " "modified!\n", pkgname); return 1; @@ -190,7 +190,7 @@ do { \ RUN_PKG_CHECK(xhp, rundeps, propsd); RUN_PKG_CHECK(xhp, unneeded, opkgd); - prop_object_release(propsd); + xbps_object_release(propsd); #undef RUN_PKG_CHECK diff --git a/bin/xbps-pkgdb/check_pkg_files.c b/bin/xbps-pkgdb/check_pkg_files.c index afe18b1a..a76cfbaf 100644 --- a/bin/xbps-pkgdb/check_pkg_files.c +++ b/bin/xbps-pkgdb/check_pkg_files.c @@ -48,25 +48,25 @@ int check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) { - prop_array_t array; - prop_object_t obj; - prop_object_iterator_t iter; - prop_dictionary_t pkg_filesd = arg; + xbps_array_t array; + xbps_object_t obj; + xbps_object_iterator_t iter; + xbps_dictionary_t pkg_filesd = arg; const char *file, *sha256; char *path; bool mutable, broken = false, test_broken = false; int rv; - array = prop_dictionary_get(pkg_filesd, "files"); - if (array != NULL && prop_array_count(array) > 0) { + array = xbps_dictionary_get(pkg_filesd, "files"); + if (array != NULL && xbps_array_count(array) > 0) { iter = xbps_array_iter_from_dict(pkg_filesd, "files"); if (iter == NULL) return -1; - while ((obj = prop_object_iterator_next(iter))) { - prop_dictionary_get_cstring_nocopy(obj, "file", &file); + while ((obj = xbps_object_iterator_next(iter))) { + xbps_dictionary_get_cstring_nocopy(obj, "file", &file); path = xbps_xasprintf("%s/%s", xhp->rootdir, file); - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "sha256", &sha256); rv = xbps_file_hash_check(path, sha256); free(path); @@ -80,7 +80,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) break; case ERANGE: mutable = false; - prop_dictionary_get_bool(obj, + xbps_dictionary_get_bool(obj, "mutable", &mutable); if (!mutable) { xbps_error_printf("%s: hash mismatch " @@ -95,7 +95,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) break; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); } if (test_broken) { 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. */ - array = prop_dictionary_get(pkg_filesd, "conf_files"); - if (array != NULL && prop_array_count(array) > 0) { + array = xbps_dictionary_get(pkg_filesd, "conf_files"); + if (array != NULL && xbps_array_count(array) > 0) { iter = xbps_array_iter_from_dict(pkg_filesd, "conf_files"); if (iter == NULL) return -1; - while ((obj = prop_object_iterator_next(iter))) { - prop_dictionary_get_cstring_nocopy(obj, "file", &file); + while ((obj = xbps_object_iterator_next(iter))) { + xbps_dictionary_get_cstring_nocopy(obj, "file", &file); path = xbps_xasprintf("%s/%s", xhp->rootdir, file); if (access(path, R_OK) == -1) { if (errno == ENOENT) { @@ -129,7 +129,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) } free(path); } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); } if (test_broken) { xbps_error_printf("%s: conf files check FAILED.\n", pkgname); diff --git a/bin/xbps-pkgdb/check_pkg_rundeps.c b/bin/xbps-pkgdb/check_pkg_rundeps.c index 5da6e8f6..64db28c7 100644 --- a/bin/xbps-pkgdb/check_pkg_rundeps.c +++ b/bin/xbps-pkgdb/check_pkg_rundeps.c @@ -47,8 +47,8 @@ int check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg) { - prop_dictionary_t pkg_propsd = arg; - prop_array_t array; + xbps_dictionary_t pkg_propsd = arg; + xbps_array_t array; unsigned int i; const char *reqpkg; 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)) return 0; - array = prop_dictionary_get(pkg_propsd, "run_depends"); - for (i = 0; i < prop_array_count(array); i++) { - prop_array_get_cstring_nocopy(array, i, &reqpkg); + array = xbps_dictionary_get(pkg_propsd, "run_depends"); + for (i = 0; i < xbps_array_count(array); i++) { + xbps_array_get_cstring_nocopy(array, i, &reqpkg); if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) { xbps_error_printf("%s: dependency not satisfied: %s\n", pkgname, reqpkg); diff --git a/bin/xbps-pkgdb/check_pkg_symlinks.c b/bin/xbps-pkgdb/check_pkg_symlinks.c index 64ac710b..5bf6ce8b 100644 --- a/bin/xbps-pkgdb/check_pkg_symlinks.c +++ b/bin/xbps-pkgdb/check_pkg_symlinks.c @@ -74,27 +74,27 @@ symlink_target(const char *pkgname, const char *path) int check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg) { - prop_array_t array; - prop_object_t obj; - prop_dictionary_t filesd = arg; + xbps_array_t array; + xbps_object_t obj; + xbps_dictionary_t filesd = arg; unsigned int i; const char *file, *tgt = NULL; char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path; int rv; bool broken = false; - array = prop_dictionary_get(filesd, "links"); + array = xbps_dictionary_get(filesd, "links"); if (array == NULL) return false; - for (i = 0; i < prop_array_count(array); i++) { - obj = prop_array_get(array, i); - if (!prop_dictionary_get_cstring_nocopy(obj, "target", &tgt)) { + for (i = 0; i < xbps_array_count(array); i++) { + obj = xbps_array_get(array, i); + if (!xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt)) { xbps_warn_printf("%s: `%s' symlink with " "empty target object!\n", pkgname, file); continue; } - prop_dictionary_get_cstring_nocopy(obj, "file", &file); + xbps_dictionary_get_cstring_nocopy(obj, "file", &file); if (strcmp(tgt, "") == 0) { xbps_warn_printf("%s: `%s' symlink with " "empty target object!\n", pkgname, file); diff --git a/bin/xbps-pkgdb/check_pkg_unneeded.c b/bin/xbps-pkgdb/check_pkg_unneeded.c index 1379f4a2..b048ae4b 100644 --- a/bin/xbps-pkgdb/check_pkg_unneeded.c +++ b/bin/xbps-pkgdb/check_pkg_unneeded.c @@ -45,19 +45,19 @@ int 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)pkgname; - if (prop_dictionary_get(pkgd, "remove-and-update")) - prop_dictionary_remove(pkgd, "remove-and-update"); + if (xbps_dictionary_get(pkgd, "remove-and-update")) + xbps_dictionary_remove(pkgd, "remove-and-update"); - if (prop_dictionary_get(pkgd, "transaction")) - prop_dictionary_remove(pkgd, "transaction"); + if (xbps_dictionary_get(pkgd, "transaction")) + xbps_dictionary_remove(pkgd, "transaction"); - if (prop_dictionary_get(pkgd, "skip-obsoletes")) - prop_dictionary_remove(pkgd, "skip-obsoletes"); + if (xbps_dictionary_get(pkgd, "skip-obsoletes")) + xbps_dictionary_remove(pkgd, "skip-obsoletes"); return 0; } diff --git a/bin/xbps-pkgdb/convert.c b/bin/xbps-pkgdb/convert.c index 598d1e2d..f12def45 100644 --- a/bin/xbps-pkgdb/convert.c +++ b/bin/xbps-pkgdb/convert.c @@ -44,8 +44,8 @@ static void pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new) { - prop_array_t array, rdeps; - prop_dictionary_t pkgdb, pkgd; + xbps_array_t array, rdeps; + xbps_dictionary_t pkgdb, pkgd; unsigned int i; char *pkgname, *plist; @@ -61,45 +61,45 @@ pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new) exit(EXIT_FAILURE); } - array = prop_array_internalize_from_zfile(plist); - if (prop_object_type(array) != PROP_TYPE_ARRAY) { + array = xbps_array_internalize_from_zfile(plist); + if (xbps_object_type(array) != XBPS_TYPE_ARRAY) { xbps_error_printf("unknown object type for %s\n", plist, strerror(errno)); exit(EXIT_FAILURE); } - pkgdb = prop_dictionary_create(); + pkgdb = xbps_dictionary_create(); assert(pkgdb); - for (i = 0; i < prop_array_count(array); i++) { - pkgd = prop_array_get(array, i); - prop_dictionary_get_cstring(pkgd, "pkgname", &pkgname); - rdeps = prop_dictionary_get(pkgd, "run_depends"); + for (i = 0; i < xbps_array_count(array); i++) { + pkgd = xbps_array_get(array, i); + xbps_dictionary_get_cstring(pkgd, "pkgname", &pkgname); + rdeps = xbps_dictionary_get(pkgd, "run_depends"); /* remove unneeded objs */ - prop_dictionary_remove(pkgd, "pkgname"); - prop_dictionary_remove(pkgd, "version"); - if (prop_array_count(rdeps) == 0) - prop_dictionary_remove(pkgd, "run_depends"); + xbps_dictionary_remove(pkgd, "pkgname"); + xbps_dictionary_remove(pkgd, "version"); + if (xbps_array_count(rdeps) == 0) + xbps_dictionary_remove(pkgd, "run_depends"); - prop_dictionary_set(pkgdb, pkgname, pkgd); + xbps_dictionary_set(pkgdb, pkgname, pkgd); 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 " - "(got %zu, need %zu)\n", prop_dictionary_count(pkgdb), - prop_array_count(array)); + "(got %zu, need %zu)\n", xbps_dictionary_count(pkgdb), + xbps_array_count(array)); 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", plist_new, strerror(errno)); exit(EXIT_FAILURE); } - prop_object_release(array); - prop_object_release(pkgdb); + xbps_object_release(array); + xbps_object_release(pkgdb); free(plist); printf("Conversion to 0.21 pkgdb format successfully\n"); diff --git a/bin/xbps-pkgdb/defs.h b/bin/xbps-pkgdb/defs.h index 5e4d37b7..2603fb11 100644 --- a/bin/xbps-pkgdb/defs.h +++ b/bin/xbps-pkgdb/defs.h @@ -30,7 +30,7 @@ #include /* 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 *); #define CHECK_PKG_DECL(type) \ diff --git a/bin/xbps-pkgdb/main.c b/bin/xbps-pkgdb/main.c index c09a9749..c63171b3 100644 --- a/bin/xbps-pkgdb/main.c +++ b/bin/xbps-pkgdb/main.c @@ -57,7 +57,7 @@ change_pkg_instmode(struct xbps_handle *xhp, const char *pkgname, const char *modestr) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; bool mode = false; pkgd = xbps_pkgdb_get_pkg(xhp, pkgname); @@ -67,7 +67,7 @@ change_pkg_instmode(struct xbps_handle *xhp, if (strcmp(modestr, "auto") == 0) mode = true; - prop_dictionary_set_bool(pkgd, "automatic-install", mode); + xbps_dictionary_set_bool(pkgd, "automatic-install", mode); return xbps_pkgdb_update(xhp, true); } diff --git a/bin/xbps-query/defs.h b/bin/xbps-query/defs.h index d8eb509d..2268b6e7 100644 --- a/bin/xbps-query/defs.h +++ b/bin/xbps-query/defs.h @@ -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 *); /* from show-info-files.c */ -void show_pkg_info(prop_dictionary_t); -void show_pkg_info_one(prop_dictionary_t, const char *); +void show_pkg_info(xbps_dictionary_t); +void show_pkg_info_one(xbps_dictionary_t, const char *); int show_pkg_info_from_metadir(struct xbps_handle *, 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 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_namedesc(struct xbps_handle *, prop_object_t, void *, +int repo_show_pkg_namedesc(struct xbps_handle *, xbps_object_t, void *, bool *); /* from ownedby.c */ @@ -57,10 +57,10 @@ int ownedby(struct xbps_handle *, int, char **); int repo_ownedby(struct xbps_handle *, int, char **); /* 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_manual_pkgs(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 *, xbps_object_t, void *, bool *); int list_orphans(struct xbps_handle *); int list_pkgs_pkgdb(struct xbps_handle *); diff --git a/bin/xbps-query/list.c b/bin/xbps-query/list.c index a1993806..0de27531 100644 --- a/bin/xbps-query/list.c +++ b/bin/xbps-query/list.c @@ -40,7 +40,7 @@ struct list_pkgver_cb { int list_pkgs_in_dict(struct xbps_handle *xhp, - prop_object_t obj, + xbps_object_t obj, void *arg, bool *loop_done) { @@ -53,8 +53,8 @@ list_pkgs_in_dict(struct xbps_handle *xhp, (void)xhp; (void)loop_done; - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc); if (!pkgver || !short_desc) return EINVAL; @@ -92,7 +92,7 @@ list_pkgs_in_dict(struct xbps_handle *xhp, int list_manual_pkgs(struct xbps_handle *xhp, - prop_object_t obj, + xbps_object_t obj, void *arg, bool *loop_done) { @@ -103,9 +103,9 @@ list_manual_pkgs(struct xbps_handle *xhp, (void)arg; (void)loop_done; - prop_dictionary_get_bool(obj, "automatic-install", &automatic); + xbps_dictionary_get_bool(obj, "automatic-install", &automatic); if (automatic == false) { - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); printf("%s\n", pkgver); } @@ -115,24 +115,24 @@ list_manual_pkgs(struct xbps_handle *xhp, int list_orphans(struct xbps_handle *xhp) { - prop_array_t orphans; - prop_object_iterator_t iter; - prop_object_t obj; + xbps_array_t orphans; + xbps_object_iterator_t iter; + xbps_object_t obj; const char *pkgver; orphans = xbps_find_pkg_orphans(xhp, NULL); if (orphans == NULL) return EINVAL; - if (prop_array_count(orphans) == 0) + if (xbps_array_count(orphans) == 0) return 0; - iter = prop_array_iterator(orphans); + iter = xbps_array_iterator(orphans); if (iter == NULL) return ENOMEM; - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); printf("%s\n", pkgver); } @@ -157,7 +157,7 @@ repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done) (void)done; printf("%s (%u packages)\n", repo->uri, - prop_dictionary_count(repo->idx)); + xbps_dictionary_count(repo->idx)); return 0; } @@ -177,30 +177,30 @@ repo_list(struct xbps_handle *xhp) } struct fflongest { - prop_dictionary_t d; + xbps_dictionary_t d; unsigned int len; }; static int _find_longest_pkgver_cb(struct xbps_handle *xhp, - prop_object_t obj, + xbps_object_t obj, void *arg, bool *loop_done) { struct fflongest *ffl = arg; - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; const char *pkgver; unsigned int len; (void)xhp; (void)loop_done; - if (prop_object_type(obj) == PROP_TYPE_DICT_KEYSYM) - pkgd = prop_dictionary_get_keysym(ffl->d, obj); + if (xbps_object_type(obj) == XBPS_TYPE_DICT_KEYSYM) + pkgd = xbps_dictionary_get_keysym(ffl->d, obj); else pkgd = obj; - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); len = strlen(pkgver); if (ffl->len == 0 || len > ffl->len) ffl->len = len; @@ -209,20 +209,20 @@ _find_longest_pkgver_cb(struct xbps_handle *xhp, } 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; ffl.d = o; ffl.len = 0; - if (prop_object_type(o) == PROP_TYPE_DICTIONARY) { - prop_array_t array; + if (xbps_object_type(o) == XBPS_TYPE_DICTIONARY) { + xbps_array_t array; - array = prop_dictionary_all_keys(o); + array = xbps_dictionary_all_keys(o); (void)xbps_callback_array_iter(xhp, array, _find_longest_pkgver_cb, &ffl); - prop_object_release(array); + xbps_object_release(array); } else { (void)xbps_pkgdb_foreach_cb(xhp, _find_longest_pkgver_cb, &ffl); diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c index f60e0b37..472be3fa 100644 --- a/bin/xbps-query/ownedby.c +++ b/bin/xbps-query/ownedby.c @@ -42,18 +42,18 @@ struct ffdata { }; static void -match_files_by_pattern(prop_dictionary_t pkg_filesd, - prop_dictionary_keysym_t key, +match_files_by_pattern(xbps_dictionary_t pkg_filesd, + xbps_dictionary_keysym_t key, struct ffdata *ffd, const char *pkgver) { - prop_array_t array; - prop_object_t obj; + xbps_array_t array; + xbps_object_t obj; const char *keyname, *filestr, *typestr; unsigned int i; int x; - keyname = prop_dictionary_keysym_cstring_nocopy(key); + keyname = xbps_dictionary_keysym_cstring_nocopy(key); if (strcmp(keyname, "files") == 0) typestr = "regular file"; @@ -66,10 +66,10 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, else return; - array = prop_dictionary_get_keysym(pkg_filesd, key); - for (i = 0; i < prop_array_count(array); i++) { - obj = prop_array_get(array, i); - prop_dictionary_get_cstring_nocopy(obj, "file", &filestr); + array = xbps_dictionary_get_keysym(pkg_filesd, key); + for (i = 0; i < xbps_array_count(array); i++) { + obj = xbps_array_get(array, i); + xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr); if (filestr == NULL) continue; for (x = 0; x < ffd->npatterns; x++) { @@ -82,24 +82,24 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, } 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; - prop_array_t files_keys; + xbps_dictionary_t pkgmetad; + xbps_array_t files_keys; struct ffdata *ffd = arg; unsigned int i; const char *pkgver; (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); assert(pkgmetad); - files_keys = prop_dictionary_all_keys(pkgmetad); - for (i = 0; i < prop_array_count(files_keys); i++) { + files_keys = xbps_dictionary_all_keys(pkgmetad); + for (i = 0; i < xbps_array_count(files_keys); i++) { match_files_by_pattern(pkgmetad, - prop_array_get(files_keys, i), ffd, pkgver); + xbps_array_get(files_keys, i), ffd, pkgver); } return 0; } @@ -123,7 +123,7 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns) } static void -repo_match_files_by_pattern(prop_array_t files, +repo_match_files_by_pattern(xbps_array_t files, const char *pkgver, struct ffdata *ffd) { @@ -131,8 +131,8 @@ repo_match_files_by_pattern(prop_array_t files, unsigned int i; int x; - for (i = 0; i < prop_array_count(files); i++) { - prop_array_get_cstring_nocopy(files, i, &filestr); + for (i = 0; i < xbps_array_count(files); i++) { + xbps_array_get_cstring_nocopy(files, i, &filestr); for (x = 0; x < ffd->npatterns; x++) { if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) { printf("%s: %s (%s)\n", @@ -145,9 +145,9 @@ repo_match_files_by_pattern(prop_array_t files, static int repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done) { - prop_array_t allkeys, pkgar; - prop_dictionary_t filesd; - prop_dictionary_keysym_t ksym; + xbps_array_t allkeys, pkgar; + xbps_dictionary_t filesd; + xbps_dictionary_keysym_t ksym; struct ffdata *ffd = arg; const char *pkgver; 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); 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++) { - ksym = prop_array_get(allkeys, i); - pkgar = prop_dictionary_get_keysym(filesd, ksym); - pkgver = prop_dictionary_keysym_cstring_nocopy(ksym); + for (i = 0; i < xbps_array_count(allkeys); i++) { + ksym = xbps_array_get(allkeys, i); + pkgar = xbps_dictionary_get_keysym(filesd, ksym); + pkgver = xbps_dictionary_keysym_cstring_nocopy(ksym); repo_match_files_by_pattern(pkgar, pkgver, ffd); } diff --git a/bin/xbps-query/search.c b/bin/xbps-query/search.c index 0258f5a0..c2909973 100644 --- a/bin/xbps-query/search.c +++ b/bin/xbps-query/search.c @@ -48,7 +48,7 @@ struct search_data { int npatterns; char **patterns; int maxcols; - prop_array_t results; + xbps_array_t results; }; static void @@ -59,16 +59,16 @@ print_results(struct xbps_handle *xhp, struct search_data *sd) unsigned int i, j, tlen = 0, len = 0; /* Iterate over results array and find out largest pkgver string */ - for (i = 0; i < prop_array_count(sd->results); i++) { - prop_array_get_cstring_nocopy(sd->results, i, &pkgver); + for (i = 0; i < xbps_array_count(sd->results); i++) { + xbps_array_get_cstring_nocopy(sd->results, i, &pkgver); len = strlen(pkgver); if (tlen == 0 || len > tlen) tlen = len; i++; } - for (i = 0; i < prop_array_count(sd->results); i++) { - prop_array_get_cstring_nocopy(sd->results, i, &pkgver); - prop_array_get_cstring_nocopy(sd->results, i+1, &desc); + for (i = 0; i < xbps_array_count(sd->results); i++) { + xbps_array_get_cstring_nocopy(sd->results, i, &pkgver); + xbps_array_get_cstring_nocopy(sd->results, i+1, &desc); strncpy(tmp, pkgver, sizeof(tmp)); for (j = strlen(tmp); j < tlen; j++) tmp[j] = ' '; @@ -98,9 +98,9 @@ print_results(struct xbps_handle *xhp, struct search_data *sd) static int search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done) { - prop_array_t allkeys; - prop_dictionary_t pkgd; - prop_dictionary_keysym_t ksym; + xbps_array_t allkeys; + xbps_dictionary_t pkgd; + xbps_dictionary_keysym_t ksym; struct search_data *sd = arg; const char *pkgver, *desc; unsigned int i; @@ -108,13 +108,13 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done) (void)done; - allkeys = prop_dictionary_all_keys(repo->idx); - for (i = 0; i < prop_array_count(allkeys); i++) { - ksym = prop_array_get(allkeys, i); - pkgd = prop_dictionary_get_keysym(repo->idx, ksym); + allkeys = xbps_dictionary_all_keys(repo->idx); + for (i = 0; i < xbps_array_count(allkeys); i++) { + ksym = xbps_array_get(allkeys, i); + pkgd = xbps_dictionary_get_keysym(repo->idx, ksym); - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc); for (x = 0; x < sd->npatterns; x++) { 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])) || (strcasestr(pkgver, sd->patterns[x])) || (strcasestr(desc, sd->patterns[x])) || vpkgfound) { - prop_array_add_cstring_nocopy(sd->results, pkgver); - prop_array_add_cstring_nocopy(sd->results, desc); + xbps_array_add_cstring_nocopy(sd->results, pkgver); + xbps_array_add_cstring_nocopy(sd->results, desc); } } } - prop_object_release(allkeys); + xbps_object_release(allkeys); return 0; } @@ -144,7 +144,7 @@ repo_search(struct xbps_handle *xhp, int npatterns, char **patterns) sd.npatterns = npatterns; sd.patterns = patterns; sd.maxcols = get_maxcols(); - sd.results = prop_array_create(); + sd.results = xbps_array_create(); rv = xbps_rpool_foreach(xhp, search_pkgs_cb, &sd); if (rv != 0 && rv != ENOTSUP) diff --git a/bin/xbps-query/show-deps.c b/bin/xbps-query/show-deps.c index 6e52612c..11068a16 100644 --- a/bin/xbps-query/show-deps.c +++ b/bin/xbps-query/show-deps.c @@ -34,11 +34,11 @@ #include "defs.h" 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) { - prop_array_t currdeps; - prop_dictionary_t pkgd; + xbps_array_t currdeps; + xbps_dictionary_t pkgd; const char *pkgdep; unsigned int i; int j; @@ -46,8 +46,8 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps, if (!origin) (*indent)++; - for (i = 0; i < prop_array_count(rdeps); i++) { - prop_array_get_cstring_nocopy(rdeps, i, &pkgdep); + for (i = 0; i < xbps_array_count(rdeps); i++) { + xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep); if (!origin || !full) for (j = 0; j < *indent; j++) putchar(' '); @@ -66,7 +66,7 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps, pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgdep); } if (pkgd != NULL) { - currdeps = prop_dictionary_get(pkgd, "run_depends"); + currdeps = xbps_dictionary_get(pkgd, "run_depends"); if (currdeps != NULL) print_rdeps(xhp, currdeps, full, repo, false, indent); @@ -78,15 +78,15 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps, int show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full) { - prop_array_t rdeps; - prop_dictionary_t pkgd; + xbps_array_t rdeps; + xbps_dictionary_t pkgd; int indent = 0; pkgd = xbps_pkgdb_get_pkg(xhp, pkgname); if (pkgd == NULL) return ENOENT; - rdeps = prop_dictionary_get(pkgd, "run_depends"); + rdeps = xbps_dictionary_get(pkgd, "run_depends"); if (rdeps != NULL) 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 show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) { - prop_array_t reqby; + xbps_array_t reqby; const char *pkgdep; unsigned int i; if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) { - for (i = 0; i < prop_array_count(reqby); i++) { - prop_array_get_cstring_nocopy(reqby, i, &pkgdep); + for (i = 0; i < xbps_array_count(reqby); i++) { + xbps_array_get_cstring_nocopy(reqby, i, &pkgdep); printf("%s\n", pkgdep); } } @@ -112,15 +112,15 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) int repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full) { - prop_array_t rdeps; - prop_dictionary_t pkgd; + xbps_array_t rdeps; + xbps_dictionary_t pkgd; int indent = 0; if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) && ((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL)) return errno; - rdeps = prop_dictionary_get(pkgd, "run_depends"); + rdeps = xbps_dictionary_get(pkgd, "run_depends"); if (rdeps != NULL) 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 repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) { - prop_array_t revdeps; + xbps_array_t revdeps; const char *pkgver; unsigned int i; 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); rv = errno; - for (i = 0; i < prop_array_count(revdeps); i++) { - prop_array_get_cstring_nocopy(revdeps, i, &pkgver); + for (i = 0; i < xbps_array_count(revdeps); i++) { + xbps_array_get_cstring_nocopy(revdeps, i, &pkgver); printf("%s\n", pkgver); } diff --git a/bin/xbps-query/show-info-files.c b/bin/xbps-query/show-info-files.c index e4d3a360..89e93a97 100644 --- a/bin/xbps-query/show-info-files.c +++ b/bin/xbps-query/show-info-files.c @@ -37,11 +37,11 @@ #include "defs.h" 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) { - prop_array_t allkeys; - prop_object_t obj2, keysym; + xbps_array_t allkeys; + xbps_object_t obj2, keysym; const char *ksymname, *value; unsigned int i; char size[8]; @@ -49,34 +49,34 @@ print_value_obj(const char *keyname, prop_object_t obj, if (indent == NULL) indent = ""; - switch (prop_object_type(obj)) { - case PROP_TYPE_STRING: + switch (xbps_object_type(obj)) { + case XBPS_TYPE_STRING: if (!raw) printf("%s%s: ", indent, keyname); - printf("%s\n", prop_string_cstring_nocopy(obj)); + printf("%s\n", xbps_string_cstring_nocopy(obj)); break; - case PROP_TYPE_NUMBER: + case XBPS_TYPE_NUMBER: if (!raw) printf("%s%s: ", indent, keyname); 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", - prop_number_unsigned_integer_value(obj)); + xbps_number_unsigned_integer_value(obj)); else printf("%s\n", size); break; - case PROP_TYPE_BOOL: + case XBPS_TYPE_BOOL: if (!raw) printf("%s%s: ", indent, keyname); - printf("%s\n", prop_bool_true(obj) ? "yes" : "no"); + printf("%s\n", xbps_bool_true(obj) ? "yes" : "no"); break; - case PROP_TYPE_ARRAY: + case XBPS_TYPE_ARRAY: if (!raw) printf("%s%s:\n", indent, keyname); - for (i = 0; i < prop_array_count(obj); i++) { - obj2 = prop_array_get(obj, i); - if (prop_object_type(obj2) == PROP_TYPE_STRING) { - value = prop_string_cstring_nocopy(obj2); + for (i = 0; i < xbps_array_count(obj); i++) { + obj2 = xbps_array_get(obj, i); + if (xbps_object_type(obj2) == XBPS_TYPE_STRING) { + value = xbps_string_cstring_nocopy(obj2); printf("%s%s%s\n", indent, !raw ? "\t" : "", value); } else { @@ -84,29 +84,29 @@ print_value_obj(const char *keyname, prop_object_t obj, } } break; - case PROP_TYPE_DICTIONARY: - allkeys = prop_dictionary_all_keys(obj); - for (i = 0; i < prop_array_count(allkeys); i++) { - keysym = prop_array_get(allkeys, i); - ksymname = prop_dictionary_keysym_cstring_nocopy(keysym); - obj2 = prop_dictionary_get_keysym(obj, keysym); + case XBPS_TYPE_DICTIONARY: + allkeys = xbps_dictionary_all_keys(obj); + for (i = 0; i < xbps_array_count(allkeys); i++) { + keysym = xbps_array_get(allkeys, i); + ksymname = xbps_dictionary_keysym_cstring_nocopy(keysym); + obj2 = xbps_dictionary_get_keysym(obj, keysym); print_value_obj(ksymname, obj2, " ", raw); } - prop_object_release(allkeys); + xbps_object_release(allkeys); if (raw) printf("\n"); break; - case PROP_TYPE_DATA: + case XBPS_TYPE_DATA: 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); } else { FILE *f; char buf[BUFSIZ-1]; void *data; - data = prop_data_data(obj); - f = fmemopen(data, prop_data_size(obj), "r"); + data = xbps_data_data(obj); + f = fmemopen(data, xbps_data_size(obj), "r"); assert(f); while (fgets(buf, BUFSIZ-1, f)) printf("%s", buf); @@ -122,13 +122,13 @@ print_value_obj(const char *keyname, prop_object_t obj, } 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; if (strchr(keys, ',') == NULL) { - obj = prop_dictionary_get(d, keys); + obj = xbps_dictionary_get(d, keys); if (obj == NULL) return; print_value_obj(keys, obj, NULL, true); @@ -139,7 +139,7 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys) abort(); for ((p = strtok_r(key, ",", &saveptr)); p; (p = strtok_r(NULL, ",", &saveptr))) { - obj = prop_dictionary_get(d, p); + obj = xbps_dictionary_get(d, p); if (obj == NULL) continue; print_value_obj(p, obj, NULL, true); @@ -148,9 +148,9 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys) } 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; /* parse string appending a \t after EOL */ @@ -165,18 +165,18 @@ print_srcrevs(const char *keyname, prop_string_t obj) } void -show_pkg_info(prop_dictionary_t dict) +show_pkg_info(xbps_dictionary_t dict) { - prop_array_t all_keys; - prop_object_t obj, keysym; + xbps_array_t all_keys; + xbps_object_t obj, keysym; const char *keyname; unsigned int i; - all_keys = prop_dictionary_all_keys(dict); - for (i = 0; i < prop_array_count(all_keys); i++) { - keysym = prop_array_get(all_keys, i); - keyname = prop_dictionary_keysym_cstring_nocopy(keysym); - obj = prop_dictionary_get_keysym(dict, keysym); + all_keys = xbps_dictionary_all_keys(dict); + for (i = 0; i < xbps_array_count(all_keys); i++) { + keysym = xbps_array_get(all_keys, i); + keyname = xbps_dictionary_keysym_cstring_nocopy(keysym); + obj = xbps_dictionary_get_keysym(dict, keysym); /* ignore objs shown by other targets */ if ((strcmp(keyname, "run_depends") == 0) || (strcmp(keyname, "files") == 0) || @@ -195,37 +195,37 @@ show_pkg_info(prop_dictionary_t dict) } int -show_pkg_files(prop_dictionary_t filesd) +show_pkg_files(xbps_dictionary_t filesd) { - prop_array_t array, allkeys; - prop_object_t obj; - prop_dictionary_keysym_t ksym; + xbps_array_t array, allkeys; + xbps_object_t obj; + xbps_dictionary_keysym_t ksym; const char *keyname, *file; unsigned int i, x; - if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY) + if (xbps_object_type(filesd) != XBPS_TYPE_DICTIONARY) return EINVAL; - allkeys = prop_dictionary_all_keys(filesd); - for (i = 0; i < prop_array_count(allkeys); i++) { - ksym = prop_array_get(allkeys, i); - keyname = prop_dictionary_keysym_cstring_nocopy(ksym); + allkeys = xbps_dictionary_all_keys(filesd); + for (i = 0; i < xbps_array_count(allkeys); i++) { + ksym = xbps_array_get(allkeys, i); + keyname = xbps_dictionary_keysym_cstring_nocopy(ksym); if ((strcmp(keyname, "files") && (strcmp(keyname, "conf_files") && (strcmp(keyname, "links"))))) continue; - array = prop_dictionary_get(filesd, keyname); - if (array == NULL || prop_array_count(array) == 0) + array = xbps_dictionary_get(filesd, keyname); + if (array == NULL || xbps_array_count(array) == 0) continue; - for (x = 0; x < prop_array_count(array); x++) { - obj = prop_array_get(array, x); - if (prop_object_type(obj) != PROP_TYPE_DICTIONARY) + for (x = 0; x < xbps_array_count(array); x++) { + obj = xbps_array_get(array, x); + if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) continue; - prop_dictionary_get_cstring_nocopy(obj, "file", &file); + xbps_dictionary_get_cstring_nocopy(obj, "file", &file); printf("%s", file); - if (prop_dictionary_get_cstring_nocopy(obj, + if (xbps_dictionary_get_cstring_nocopy(obj, "target", &file)) printf(" -> %s", file); @@ -241,7 +241,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp, const char *pkg, const char *option) { - prop_dictionary_t d, pkgdb_d; + xbps_dictionary_t d, pkgdb_d; const char *instdate; bool autoinst; pkg_state_t state; @@ -254,13 +254,13 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp, if (d == NULL) return ENOENT; - if (prop_dictionary_get_cstring_nocopy(pkgdb_d, + if (xbps_dictionary_get_cstring_nocopy(pkgdb_d, "install-date", &instdate)) - prop_dictionary_set_cstring_nocopy(d, "install-date", + xbps_dictionary_set_cstring_nocopy(d, "install-date", instdate); - if (prop_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst)) - prop_dictionary_set_bool(d, "automatic-install", autoinst); + if (xbps_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst)) + xbps_dictionary_set_bool(d, "automatic-install", autoinst); xbps_pkg_state_dictionary(pkgdb_d, &state); xbps_set_pkg_state_dictionary(d, state); @@ -276,7 +276,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp, int show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkg) { - prop_dictionary_t d; + xbps_dictionary_t d; int rv = 0; 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 *option) { - prop_dictionary_t ipkgd, bpkgd; + xbps_dictionary_t ipkgd, bpkgd; if (((ipkgd = xbps_rpool_get_pkg(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) return errno; - prop_dictionary_set(bpkgd, "filename-sha256", - prop_dictionary_get(ipkgd, "filename-sha256")); - prop_dictionary_set(bpkgd, "filename-size", - prop_dictionary_get(ipkgd, "filename-size")); + xbps_dictionary_set(bpkgd, "filename-sha256", + xbps_dictionary_get(ipkgd, "filename-sha256")); + xbps_dictionary_set(bpkgd, "filename-size", + xbps_dictionary_get(ipkgd, "filename-size")); if (option) show_pkg_info_one(bpkgd, option); @@ -318,7 +318,7 @@ repo_show_pkg_info(struct xbps_handle *xhp, int 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"); if (pkgd == NULL) { diff --git a/bin/xbps-remove/main.c b/bin/xbps-remove/main.c index d0fa7cbc..2bb9b30f 100644 --- a/bin/xbps-remove/main.c +++ b/bin/xbps-remove/main.c @@ -119,7 +119,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata) static int cachedir_clean(struct xbps_handle *xhp) { - prop_dictionary_t pkg_propsd, repo_pkgd; + xbps_dictionary_t pkg_propsd, repo_pkgd; DIR *dirp; struct dirent *dp; const char *pkgver, *rsha256; @@ -152,14 +152,14 @@ cachedir_clean(struct xbps_handle *xhp) rv = errno; 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 * or if hash doesn't match. */ repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver); if (repo_pkgd) { - prop_dictionary_get_cstring_nocopy(repo_pkgd, + xbps_dictionary_get_cstring_nocopy(repo_pkgd, "filename-sha256", &rsha256); if (xbps_file_hash_check(binpkg, rsha256) == ERANGE) { 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, bool recursive) { - prop_array_t reqby; + xbps_array_t reqby; const char *pkgver; unsigned int x; int rv; @@ -196,10 +196,10 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols, /* pkg has revdeps */ reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgname); printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n", - pkgname, prop_array_count(reqby), - prop_array_count(reqby) > 1 ? "S" : ""); - for (x = 0; x < prop_array_count(reqby); x++) { - prop_array_get_cstring_nocopy(reqby, x, &pkgver); + pkgname, xbps_array_count(reqby), + xbps_array_count(reqby) > 1 ? "S" : ""); + for (x = 0; x < xbps_array_count(reqby); x++) { + xbps_array_get_cstring_nocopy(reqby, x, &pkgver); print_package_line(pkgver, cols, false); } printf("\n\n"); diff --git a/bin/xbps-rindex/defs.h b/bin/xbps-rindex/defs.h index 02614cc9..d40390e2 100644 --- a/bin/xbps-rindex/defs.h +++ b/bin/xbps-rindex/defs.h @@ -43,6 +43,6 @@ int remove_obsoletes(struct xbps_handle *, const char *); /* From repoflush.c */ 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_ */ diff --git a/bin/xbps-rindex/index-add.c b/bin/xbps-rindex/index-add.c index 3bf1b89b..9f87a04c 100644 --- a/bin/xbps-rindex/index-add.c +++ b/bin/xbps-rindex/index-add.c @@ -44,9 +44,9 @@ int index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) { - prop_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles; - prop_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd; - prop_object_t obj, fileobj; + xbps_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles; + xbps_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd; + xbps_object_t obj, fileobj; struct xbps_repo *repo; struct stat st; 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); } if (idx == NULL) - idx = prop_dictionary_create(); + idx = xbps_dictionary_create(); if (idxfiles == NULL) - idxfiles = prop_dictionary_create(); + idxfiles = xbps_dictionary_create(); if (repo != NULL) 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]); continue; } - prop_dictionary_get_cstring_nocopy(newpkgd, "architecture", + xbps_dictionary_get_cstring_nocopy(newpkgd, "architecture", &arch); - prop_dictionary_get_cstring(newpkgd, "pkgver", &pkgver); + xbps_dictionary_get_cstring(newpkgd, "pkgver", &pkgver); if (!xbps_pkg_arch_match(xhp, arch, NULL)) { fprintf(stderr, "index: ignoring %s, unmatched " "arch (%s)\n", pkgver, arch); - prop_object_release(newpkgd); + xbps_object_release(newpkgd); continue; } 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 * pass to the next one. */ - curpkgd = prop_dictionary_get(idx, pkgname); + curpkgd = xbps_dictionary_get(idx, pkgname); if (curpkgd == NULL) { if (errno && errno != ENOENT) { free(pkgver); @@ -118,9 +118,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) } } else if (!force) { /* Only check version if !force */ - prop_dictionary_get_cstring_nocopy(curpkgd, + xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &oldpkgver); - prop_dictionary_get_cstring_nocopy(curpkgd, + xbps_dictionary_get_cstring_nocopy(curpkgd, "architecture", &oldarch); ret = xbps_cmpver(pkgver, oldpkgver); if (ret <= 0) { @@ -128,7 +128,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) fprintf(stderr, "index: skipping `%s' " "(%s), already registered.\n", pkgver, arch); - prop_object_release(newpkgd); + xbps_object_release(newpkgd); free(pkgver); free(pkgname); continue; @@ -138,7 +138,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) * index version. */ 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); free(buf); } @@ -151,7 +151,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) free(pkgname); return errno; } - if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256", + if (!xbps_dictionary_set_cstring(newpkgd, "filename-sha256", sha256)) { free(pkgver); free(pkgname); @@ -165,7 +165,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) return errno; } - if (!prop_dictionary_set_uint64(newpkgd, "filename-size", + if (!xbps_dictionary_set_uint64(newpkgd, "filename-size", (uint64_t)st.st_size)) { free(pkgver); free(pkgname); @@ -174,23 +174,23 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) /* * Remove obsolete package objects. */ - prop_dictionary_remove(newpkgd, "archive-compression-type"); - prop_dictionary_remove(newpkgd, "build-date"); - prop_dictionary_remove(newpkgd, "build_date"); - prop_dictionary_remove(newpkgd, "conf_files"); - prop_dictionary_remove(newpkgd, "filename"); - prop_dictionary_remove(newpkgd, "homepage"); - prop_dictionary_remove(newpkgd, "license"); - prop_dictionary_remove(newpkgd, "maintainer"); - prop_dictionary_remove(newpkgd, "packaged-with"); - prop_dictionary_remove(newpkgd, "source-revisions"); - prop_dictionary_remove(newpkgd, "long_desc"); - prop_dictionary_remove(newpkgd, "pkgname"); - prop_dictionary_remove(newpkgd, "version"); + xbps_dictionary_remove(newpkgd, "archive-compression-type"); + xbps_dictionary_remove(newpkgd, "build-date"); + xbps_dictionary_remove(newpkgd, "build_date"); + xbps_dictionary_remove(newpkgd, "conf_files"); + xbps_dictionary_remove(newpkgd, "filename"); + xbps_dictionary_remove(newpkgd, "homepage"); + xbps_dictionary_remove(newpkgd, "license"); + xbps_dictionary_remove(newpkgd, "maintainer"); + xbps_dictionary_remove(newpkgd, "packaged-with"); + xbps_dictionary_remove(newpkgd, "source-revisions"); + xbps_dictionary_remove(newpkgd, "long_desc"); + xbps_dictionary_remove(newpkgd, "pkgname"); + xbps_dictionary_remove(newpkgd, "version"); /* * Add new pkg dictionary into the index. */ - if (!prop_dictionary_set(idx, pkgname, newpkgd)) { + if (!xbps_dictionary_set(idx, pkgname, newpkgd)) { free(pkgname); 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 */ - pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files"); - if (prop_array_count(pkg_cffiles)) + pkg_cffiles = xbps_dictionary_get(newpkgfilesd, "conf_files"); + if (xbps_array_count(pkg_cffiles)) found = true; else pkg_cffiles = NULL; - pkg_files = prop_dictionary_get(newpkgfilesd, "files"); - if (prop_array_count(pkg_files)) + pkg_files = xbps_dictionary_get(newpkgfilesd, "files"); + if (xbps_array_count(pkg_files)) found = true; else pkg_files = NULL; - pkg_links = prop_dictionary_get(newpkgfilesd, "links"); - if (prop_array_count(pkg_links)) + pkg_links = xbps_dictionary_get(newpkgfilesd, "links"); + if (xbps_array_count(pkg_links)) found = true; else pkg_links = NULL; /* If pkg does not contain any file, ignore it */ if (!found) { - prop_object_release(newpkgfilesd); - prop_object_release(newpkgd); + xbps_object_release(newpkgfilesd); + xbps_object_release(newpkgd); free(pkgver); free(pkgname); continue; } /* create pkg files array */ - filespkgar = prop_array_create(); + filespkgar = xbps_array_create(); assert(filespkgar); /* add conf_files in pkg files array */ if (pkg_cffiles != NULL) { - for (x = 0; x < prop_array_count(pkg_cffiles); x++) { - obj = prop_array_get(pkg_cffiles, x); - fileobj = prop_dictionary_get(obj, "file"); - prop_array_add(filespkgar, fileobj); + for (x = 0; x < xbps_array_count(pkg_cffiles); x++) { + obj = xbps_array_get(pkg_cffiles, x); + fileobj = xbps_dictionary_get(obj, "file"); + xbps_array_add(filespkgar, fileobj); } } /* add files array in pkg array */ if (pkg_files != NULL) { - for (x = 0; x < prop_array_count(pkg_files); x++) { - obj = prop_array_get(pkg_files, x); - fileobj = prop_dictionary_get(obj, "file"); - prop_array_add(filespkgar, fileobj); + for (x = 0; x < xbps_array_count(pkg_files); x++) { + obj = xbps_array_get(pkg_files, x); + fileobj = xbps_dictionary_get(obj, "file"); + xbps_array_add(filespkgar, fileobj); } } /* add links array in pkgd */ if (pkg_links != NULL) { - for (x = 0; x < prop_array_count(pkg_links); x++) { - obj = prop_array_get(pkg_links, x); - fileobj = prop_dictionary_get(obj, "file"); - prop_array_add(filespkgar, fileobj); + for (x = 0; x < xbps_array_count(pkg_links); x++) { + obj = xbps_array_get(pkg_links, x); + fileobj = xbps_dictionary_get(obj, "file"); + xbps_array_add(filespkgar, fileobj); } } - prop_object_release(newpkgfilesd); + xbps_object_release(newpkgfilesd); /* add pkg files array into index-files */ - prop_dictionary_set(idxfiles, pkgver, filespkgar); - prop_object_release(filespkgar); + xbps_dictionary_set(idxfiles, pkgver, filespkgar); + xbps_object_release(filespkgar); printf("index-files: added `%s' (%s)\n", pkgver, arch); - prop_object_release(newpkgd); + xbps_object_release(newpkgd); free(pkgver); free(pkgname); } @@ -283,12 +283,12 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) return rv; } printf("index: %u packages registered.\n", - prop_dictionary_count(idx)); + xbps_dictionary_count(idx)); printf("index-files: %u packages registered.\n", - prop_dictionary_count(idxfiles)); + xbps_dictionary_count(idxfiles)); - prop_object_release(idx); - prop_object_release(idxfiles); + xbps_object_release(idx); + xbps_object_release(idxfiles); return 0; } diff --git a/bin/xbps-rindex/index-clean.c b/bin/xbps-rindex/index-clean.c index d1eccca8..967489da 100644 --- a/bin/xbps-rindex/index-clean.c +++ b/bin/xbps-rindex/index-clean.c @@ -40,10 +40,10 @@ struct thread_data { pthread_t thread; - prop_dictionary_t idx; - prop_dictionary_t idxfiles; - prop_array_t result; - prop_array_t result_files; + xbps_dictionary_t idx; + xbps_dictionary_t idxfiles; + xbps_array_t result; + xbps_array_t result_files; struct xbps_handle *xhp; unsigned int start; unsigned int end; @@ -53,22 +53,22 @@ struct thread_data { static void * cleaner_thread(void *arg) { - prop_object_t obj; - prop_dictionary_t pkgd; - prop_array_t array; + xbps_object_t obj; + xbps_dictionary_t pkgd; + xbps_array_t array; struct thread_data *thd = arg; char *filen; const char *pkgver, *arch, *sha256; unsigned int i; /* 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++) { - obj = prop_array_get(array, i); - pkgd = prop_dictionary_get_keysym(thd->idx, obj); - prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + obj = xbps_array_get(array, i); + pkgd = xbps_dictionary_get_keysym(thd->idx, obj); + xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); filen = xbps_xasprintf("%s.%s.xbps", pkgver, arch); xbps_dbg_printf(thd->xhp, "thread[%d] checking %s\n", thd->thread_num, pkgver); @@ -77,20 +77,20 @@ cleaner_thread(void *arg) * File cannot be read, might be permissions, * 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); continue; } /* * File can be read; check its hash. */ - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "filename-sha256", &sha256); 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); } - prop_object_release(array); + xbps_object_release(array); return NULL; } @@ -98,35 +98,35 @@ cleaner_thread(void *arg) static void * cleaner_files_thread(void *arg) { - prop_object_t obj; - prop_array_t array; - prop_dictionary_t ipkgd; + xbps_object_t obj; + xbps_array_t array; + xbps_dictionary_t ipkgd; struct thread_data *thd = arg; const char *pkgver, *ipkgver; char *pkgname; unsigned int i; /* 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++) { - obj = prop_array_get(array, i); - pkgver = prop_dictionary_keysym_cstring_nocopy(obj); + obj = xbps_array_get(array, i); + pkgver = xbps_dictionary_keysym_cstring_nocopy(obj); pkgname = xbps_pkg_name(pkgver); 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 (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 */ else { - prop_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver); + xbps_dictionary_get_cstring_nocopy(ipkgd, "pkgver", &ipkgver); if (strcmp(ipkgver, pkgver)) - prop_array_add_cstring_nocopy(thd->result_files, pkgver); + xbps_array_add_cstring_nocopy(thd->result_files, pkgver); } free(pkgname); } - prop_object_release(array); + xbps_object_release(array); return NULL; } @@ -140,7 +140,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir) { struct xbps_repo *repo; struct thread_data *thd; - prop_dictionary_t idx, idxfiles; + xbps_dictionary_t idx, idxfiles; const char *keyname; char *pkgname; unsigned int x, pkgcount, slicecount; @@ -171,18 +171,18 @@ index_clean(struct xbps_handle *xhp, const char *repodir) maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); thd = calloc(maxthreads, sizeof(*thd)); - slicecount = prop_dictionary_count(idx) / maxthreads; + slicecount = xbps_dictionary_count(idx) / maxthreads; pkgcount = 0; /* Setup threads to cleanup index and index-files */ for (i = 0; i < maxthreads; i++) { thd[i].thread_num = i; thd[i].idx = idx; - thd[i].result = prop_array_create(); + thd[i].result = xbps_array_create(); thd[i].xhp = xhp; thd[i].start = pkgcount; if (i + 1 >= maxthreads) - thd[i].end = prop_dictionary_count(idx); + thd[i].end = xbps_dictionary_count(idx); else thd[i].end = pkgcount + slicecount; 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); /* Setup threads to cleanup index-files */ - slicecount = prop_dictionary_count(idxfiles) / maxthreads; + slicecount = xbps_dictionary_count(idxfiles) / maxthreads; pkgcount = 0; for (i = 0; i < maxthreads; i++) { thd[i].thread_num = i; thd[i].idx = idx; thd[i].idxfiles = idxfiles; - thd[i].result_files = prop_array_create(); + thd[i].result_files = xbps_array_create(); thd[i].xhp = xhp; thd[i].start = pkgcount; if (i + 1 >= maxthreads) - thd[i].end = prop_dictionary_count(idxfiles); + thd[i].end = xbps_dictionary_count(idxfiles); else thd[i].end = pkgcount + slicecount; 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); for (i = 0; i < maxthreads; i++) { - for (x = 0; x < prop_array_count(thd[i].result); x++) { - prop_array_get_cstring_nocopy(thd[i].result, + for (x = 0; x < xbps_array_count(thd[i].result); x++) { + xbps_array_get_cstring_nocopy(thd[i].result, x, &keyname); printf("index: removed entry %s\n", keyname); pkgname = xbps_pkg_name(keyname); - prop_dictionary_remove(idx, pkgname); - prop_dictionary_remove(idxfiles, keyname); + xbps_dictionary_remove(idx, pkgname); + xbps_dictionary_remove(idxfiles, keyname); free(pkgname); flush = true; } - for (x = 0; x < prop_array_count(thd[i].result_files); x++) { - prop_array_get_cstring_nocopy(thd[i].result_files, + for (x = 0; x < xbps_array_count(thd[i].result_files); x++) { + xbps_array_get_cstring_nocopy(thd[i].result_files, x, &keyname); printf("index-files: removed entry %s\n", keyname); - prop_dictionary_remove(idxfiles, keyname); + xbps_dictionary_remove(idxfiles, keyname); flush = true; } } @@ -239,11 +239,11 @@ index_clean(struct xbps_handle *xhp, const char *repodir) return rv; } printf("index: %u packages registered.\n", - prop_dictionary_count(idx)); + xbps_dictionary_count(idx)); printf("index-files: %u packages registered.\n", - prop_dictionary_count(idxfiles)); - prop_object_release(idx); - prop_object_release(idxfiles); + xbps_dictionary_count(idxfiles)); + xbps_object_release(idx); + xbps_object_release(idxfiles); return rv; } diff --git a/bin/xbps-rindex/remove-obsoletes.c b/bin/xbps-rindex/remove-obsoletes.c index b844909d..b84f0f31 100644 --- a/bin/xbps-rindex/remove-obsoletes.c +++ b/bin/xbps-rindex/remove-obsoletes.c @@ -39,7 +39,7 @@ struct thread_data { pthread_t thread; - prop_array_t array; + xbps_array_t array; struct xbps_repo *repo; unsigned int start; unsigned int end; @@ -84,7 +84,7 @@ remove_pkg(const char *repodir, const char *arch, const char *file) static void * cleaner_thread(void *arg) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; struct thread_data *thd = arg; const char *binpkg, *pkgver, *arch; unsigned int i; @@ -92,21 +92,21 @@ cleaner_thread(void *arg) /* process pkgs from start until end */ 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"); if (pkgd == NULL) { rv = remove_pkg(thd->repo->uri, arch, binpkg); if (rv != 0) { - prop_object_release(pkgd); + xbps_object_release(pkgd); continue; } printf("Removed broken package `%s'.\n", binpkg); } - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); /* ignore pkgs from other archs */ if (!xbps_pkg_arch_match(thd->repo->xhp, arch, NULL)) { - prop_object_release(pkgd); + xbps_object_release(pkgd); continue; } 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)) { rv = remove_pkg(thd->repo->uri, arch, binpkg); if (rv != 0) { - prop_object_release(pkgd); + xbps_object_release(pkgd); continue; } printf("Removed obsolete package `%s'.\n", binpkg); } - prop_object_release(pkgd); + xbps_object_release(pkgd); } return NULL; @@ -131,7 +131,7 @@ cleaner_thread(void *arg) int remove_obsoletes(struct xbps_handle *xhp, const char *repodir) { - prop_array_t array = NULL; + xbps_array_t array = NULL; struct xbps_repo *repo; struct thread_data *thd; DIR *dirp; @@ -171,16 +171,16 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir) if (strcmp(ext, ".xbps")) continue; 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); maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN); thd = calloc(maxthreads, sizeof(*thd)); - slicecount = prop_array_count(array) / maxthreads; + slicecount = xbps_array_count(array) / maxthreads; pkgcount = 0; 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].start = pkgcount; if (i + 1 >= maxthreads) - thd[i].end = prop_array_count(array); + thd[i].end = xbps_array_count(array); else thd[i].end = pkgcount + slicecount; pthread_create(&thd[i].thread, NULL, cleaner_thread, &thd[i]); diff --git a/bin/xbps-rindex/repoflush.c b/bin/xbps-rindex/repoflush.c index a6149aa9..3b72c529 100644 --- a/bin/xbps-rindex/repoflush.c +++ b/bin/xbps-rindex/repoflush.c @@ -39,7 +39,7 @@ int 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; 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_open_fd(ar, repofd); - xml = prop_dictionary_externalize(idx); + xml = xbps_dictionary_externalize(idx); assert(xml); if (xbps_archive_append_buf(ar, xml, strlen(xml), XBPS_PKGINDEX, 0644, "root", "root") != 0) { @@ -69,7 +69,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir, } free(xml); - xml = prop_dictionary_externalize(idxfiles); + xml = xbps_dictionary_externalize(idxfiles); assert(xml); if (xbps_archive_append_buf(ar, xml, strlen(xml), XBPS_PKGINDEX_FILES, 0644, "root", "root") != 0) { diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 25acd456..d956e79e 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -37,12 +37,12 @@ #include "../xbps-install/defs.h" 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); - if (!prop_dictionary_externalize_to_zfile(dict, file)) { - prop_object_release(dict); + if (!xbps_dictionary_externalize_to_zfile(dict, file)) { + xbps_object_release(dict); xbps_error_printf("xbps-uhelper: couldn't write to %s: %s\n", file, strerror(errno)); exit(EXIT_FAILURE); @@ -97,7 +97,7 @@ usage(void) int main(int argc, char **argv) { - prop_dictionary_t dict; + xbps_dictionary_t dict; struct xbps_handle xh; struct xferstat xfer; 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))) 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)); } else if (strcasecmp(argv[0], "sanitize-plist") == 0) { /* Sanitize a plist file (properly indent the file) */ if (argc != 2) usage(); - dict = prop_dictionary_internalize_from_zfile(argv[1]); + dict = xbps_dictionary_internalize_from_zfile(argv[1]); if (dict == NULL) { fprintf(stderr, "=> ERROR: couldn't sanitize %s plist file " diff --git a/configure b/configure index 58728669..aaab57d8 100755 --- a/configure +++ b/configure @@ -311,6 +311,17 @@ else BUILD_PIE_VALUE=no 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(). # @@ -469,60 +480,6 @@ else fi rm -f _$func.c _$func -# -# Check for libfetch's fetchIO_read(). -# -func=fetchIO_read -printf "Checking for $func() ... " -cat < _$func.c -#include -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 < _$func.c -#include -#include -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). # @@ -744,8 +701,6 @@ echo " Build Kyua test suite = $BUILD_TESTS_VALUE" echo " Build programs as PIE = $BUILD_PIE_VALUE" echo " Build static programs = $BUILD_STATIC_VALUE" echo " Build with debug = $DEBUG" -echo " Use external proplib = $PROPLIB" -echo " Use external libfetch = $LIBFETCH" if [ -n "$HAVE_VISIBILITY" ]; then echo " Symbol visibility = $HAVE_VISIBILITY" fi diff --git a/include/Makefile b/include/Makefile index f74e0e77..d19182c6 100644 --- a/include/Makefile +++ b/include/Makefile @@ -8,8 +8,11 @@ all: .PHONY: install install: - install -d $(DESTDIR)$(INCLUDEDIR) + install -d $(DESTDIR)$(INCLUDEDIR)/xbps 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 uninstall: diff --git a/include/xbps/xbps_array.h b/include/xbps/xbps_array.h new file mode 100644 index 00000000..0c5c8b54 --- /dev/null +++ b/include/xbps/xbps_array.h @@ -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 +#include + +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_ */ diff --git a/include/xbps/xbps_bool.h b/include/xbps/xbps_bool.h new file mode 100644 index 00000000..d6e515ad --- /dev/null +++ b/include/xbps/xbps_bool.h @@ -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 +#include + +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_ */ diff --git a/include/xbps/xbps_data.h b/include/xbps/xbps_data.h new file mode 100644 index 00000000..7ce28217 --- /dev/null +++ b/include/xbps/xbps_data.h @@ -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 +#include +#include + +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_ */ diff --git a/include/xbps/xbps_dictionary.h b/include/xbps/xbps_dictionary.h new file mode 100644 index 00000000..ab5f5417 --- /dev/null +++ b/include/xbps/xbps_dictionary.h @@ -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 +#include +#include + +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_ */ diff --git a/include/xbps/xbps_number.h b/include/xbps/xbps_number.h new file mode 100644 index 00000000..2905b354 --- /dev/null +++ b/include/xbps/xbps_number.h @@ -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 +#include + +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_ */ diff --git a/include/xbps/xbps_object.h b/include/xbps/xbps_object.h new file mode 100644 index 00000000..435f897e --- /dev/null +++ b/include/xbps/xbps_object.h @@ -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 +#include + +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_ */ diff --git a/include/xbps/xbps_string.h b/include/xbps/xbps_string.h new file mode 100644 index 00000000..c5970186 --- /dev/null +++ b/include/xbps/xbps_string.h @@ -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 +#include +#include + +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_ */ diff --git a/include/xbps_api.h.in b/include/xbps_api.h.in index a39e3ab2..1aa3ba3e 100644 --- a/include/xbps_api.h.in +++ b/include/xbps_api.h.in @@ -30,9 +30,15 @@ #include #include +#include +#include +#include +#include +#include +#include + #include #include -#include /** * @file include/xbps_api.h @@ -40,7 +46,7 @@ * * This header documents the full API for the XBPS Library. */ -#define XBPS_API_VERSION "20130614-1" +#define XBPS_API_VERSION "20130620" #ifndef XBPS_VERSION #define XBPS_VERSION "UNSET" @@ -452,22 +458,22 @@ struct xbps_handle { * Internalized proplib dictionary with the master package database * stored in XBPS_META_PATH/XBPS_PKGDB. */ - prop_dictionary_t pkgdb; + xbps_dictionary_t pkgdb; /** * @private */ - prop_dictionary_t pkg_metad; + xbps_dictionary_t pkg_metad; /** * @private */ - prop_dictionary_t pkgdb_revdeps; + xbps_dictionary_t pkgdb_revdeps; /** * @var transd * * Proplib dictionary with transaction details, required by * xbps_transaction_commit(). */ - prop_dictionary_t transd; + xbps_dictionary_t transd; /** * Pointer to the supplifed function callback to be used * 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, * 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 @@ -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. */ -prop_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp, - prop_dictionary_t instd, - prop_dictionary_t newd); +xbps_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp, + xbps_dictionary_t instd, + xbps_dictionary_t newd); /** @addtogroup pkgdb */ /*@{*/ @@ -703,7 +709,7 @@ prop_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp, * the value returned by the function callback. */ 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); /** @@ -719,7 +725,7 @@ int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp, */ int 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); /** @@ -731,7 +737,7 @@ int xbps_pkgdb_foreach_reverse_cb( * * @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); /** @@ -743,7 +749,7 @@ prop_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, * * @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); /** @@ -754,7 +760,7 @@ prop_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, * * @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); /** @@ -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. */ -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); /** @@ -813,7 +819,7 @@ int xbps_pkg_exec_buffer(struct xbps_handle *xhp, * @return 0 on success, or an errno value otherwise. */ int xbps_pkg_exec_script(struct xbps_handle *xhp, - prop_dictionary_t d, + xbps_dictionary_t d, const char *script, const char *action, bool update); @@ -838,8 +844,8 @@ int xbps_pkg_exec_script(struct xbps_handle *xhp, * callback. */ int xbps_callback_array_iter(struct xbps_handle *xhp, - prop_array_t array, - int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), + xbps_array_t array, + int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *), void *arg); /** @@ -857,8 +863,8 @@ int xbps_callback_array_iter(struct xbps_handle *xhp, * callback. */ int xbps_callback_array_iter_reverse(struct xbps_handle *xhp, - prop_array_t array, - int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), + xbps_array_t array, + int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *), void *arg); /** @@ -878,9 +884,9 @@ int xbps_callback_array_iter_reverse(struct xbps_handle *xhp, * the value returned by the function callback. */ int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, - prop_dictionary_t dict, + xbps_dictionary_t dict, 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); /** @@ -900,9 +906,9 @@ int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, * the value returned by the function callback. */ int xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp, - prop_dictionary_t dict, + xbps_dictionary_t dict, 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); /** @@ -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 * 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, 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. */ -bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps, - prop_array_t provides); +bool xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps, + xbps_array_t provides); /** * 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. */ -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. @@ -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. */ -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 @@ -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. */ -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. @@ -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. */ -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 @@ -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 * 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); /*@}*/ @@ -1115,7 +1121,7 @@ int xbps_transaction_commit(struct xbps_handle *xhp); * @return An internalized proplib dictionary, otherwise NULL and * 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); /*@}*/ @@ -1140,13 +1146,13 @@ struct xbps_repo { * * Proplib dictionary associated with the repository index. */ - prop_dictionary_t idx; + xbps_dictionary_t idx; /** * @var idxfiles * * Proplib dictionary associated with the repository index files. */ - prop_dictionary_t idxfiles; + xbps_dictionary_t idxfiles; /** * @var uri * @@ -1204,9 +1210,9 @@ int xbps_rpool_foreach(struct xbps_handle *xhp, * * @return The package dictionary if found, NULL otherwise. * @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 @@ -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. * @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); /** @@ -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 * 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 @@ -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 * 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 *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. */ -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. @@ -1310,7 +1316,7 @@ char *xbps_repo_path(struct xbps_handle *xhp, const char *url); * * @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 @@ -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. */ -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); /** @@ -1335,8 +1341,8 @@ prop_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, * * @return The pkg dictionary on success, NULL otherwise. */ -prop_dictionary_t xbps_repo_get_pkg_plist(struct xbps_handle *xhp, - prop_dictionary_t pkgd, +xbps_dictionary_t xbps_repo_get_pkg_plist(struct xbps_handle *xhp, + xbps_dictionary_t pkgd, 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 * 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. */ -prop_dictionary_t xbps_archive_get_dictionary(struct archive *ar, +xbps_dictionary_t xbps_archive_get_dictionary(struct archive *ar, 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. */ -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. @@ -1460,7 +1466,7 @@ int xbps_set_pkg_state_installed(struct xbps_handle *xhp, * * @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. */ -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. diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index b26e9be2..39e00704 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -35,6 +35,7 @@ #include #define LIBXBPS_PRIVATE #include + /* * By default all public functions have default visibility, unless * visibility has been detected by configure and the HIDDEN definition @@ -103,32 +104,32 @@ void HIDDEN xbps_pkgdb_release(struct xbps_handle *); * @private * From lib/plist.c */ -bool HIDDEN xbps_add_obj_to_dict(prop_dictionary_t, - prop_object_t, const char *); -bool HIDDEN xbps_add_obj_to_array(prop_array_t, prop_object_t); +bool HIDDEN xbps_add_obj_to_dict(xbps_dictionary_t, + xbps_object_t, const char *); +bool HIDDEN xbps_add_obj_to_array(xbps_array_t, xbps_object_t); -int HIDDEN xbps_array_replace_dict_by_name(prop_array_t, - prop_dictionary_t, +int HIDDEN xbps_array_replace_dict_by_name(xbps_array_t, + xbps_dictionary_t, const char *); -int HIDDEN xbps_array_replace_dict_by_pattern(prop_array_t, - prop_dictionary_t, +int HIDDEN xbps_array_replace_dict_by_pattern(xbps_array_t, + xbps_dictionary_t, const char *); /** * @private * 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_pattern(prop_array_t, const char *); -bool HIDDEN xbps_remove_pkg_from_array_by_pkgver(prop_array_t, const char *); -bool HIDDEN xbps_remove_pkgname_from_array(prop_array_t, const char *); -bool HIDDEN xbps_remove_string_from_array(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(xbps_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(xbps_array_t, const char *); +bool HIDDEN xbps_remove_string_from_array(xbps_array_t, const char *); /** * @private * 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 @@ -148,9 +149,9 @@ void HIDDEN xbps_fetch_unset_cache_connection(void); * @private * 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 *, - prop_dictionary_t, + xbps_dictionary_t, struct archive_entry *, const char *, const char *, @@ -160,20 +161,20 @@ int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *, * From lib/repo_pkgdeps.c */ int HIDDEN xbps_repository_find_deps(struct xbps_handle *, - prop_array_t, - prop_dictionary_t); + xbps_array_t, + xbps_dictionary_t); /** * @private * From lib/plist_find.c */ -prop_dictionary_t HIDDEN xbps_find_pkg_in_array(prop_array_t, const char *); -prop_dictionary_t HIDDEN - xbps_find_virtualpkg_in_array(struct xbps_handle *, prop_array_t, +xbps_dictionary_t HIDDEN xbps_find_pkg_in_array(xbps_array_t, const char *); +xbps_dictionary_t HIDDEN + xbps_find_virtualpkg_in_array(struct xbps_handle *, xbps_array_t, const char *); -prop_dictionary_t HIDDEN xbps_find_pkg_in_dict(prop_dictionary_t, const char *); -prop_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, - prop_dictionary_t, +xbps_dictionary_t HIDDEN xbps_find_pkg_in_dict(xbps_dictionary_t, const char *); +xbps_dictionary_t HIDDEN xbps_find_virtualpkg_in_dict(struct xbps_handle *, + xbps_dictionary_t, const char *); /** * @private @@ -199,7 +200,7 @@ int HIDDEN xbps_repo_sync(struct xbps_handle *, const char *); * From lib/util_hash.c */ int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *, - prop_dictionary_t d, + xbps_dictionary_t d, const char *, const char *); @@ -222,7 +223,7 @@ void HIDDEN xbps_set_cb_state(struct xbps_handle *, xbps_state_t, int, * @private * 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 *); @@ -231,22 +232,22 @@ int HIDDEN xbps_transaction_package_replace(struct xbps_handle *); * From lib/package_remove.c */ 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 *); /** * @private * 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 * From lib/package_conflicts.c */ void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *, - prop_array_t, - prop_dictionary_t); + xbps_array_t, + xbps_dictionary_t); /** * @private * From lib/plist_find.c diff --git a/lib/Makefile b/lib/Makefile index 1db592b4..329a0546 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -16,10 +16,7 @@ LIBPROP_OBJS += portableproplib/prop_dictionary_util.o portableproplib/prop_zlib LIBPROP_OBJS += portableproplib/prop_data.o LIBPROP_CPPFLAGS = -D_GNU_SOURCE LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter - -ifdef USE_EXTERNAL_PROPLIB -LIBPROP_OBJS = -endif +LIBPROP_CFLAGS += -fvisibility=hidden # libfetch LIBFETCH_OBJS = fetch/common.o fetch/fetch.o fetch/file.o @@ -32,10 +29,6 @@ endif LIBFETCH_INCS = fetch/common.h LIBFETCH_GEN = fetch/ftperr.h fetch/httperr.h -ifdef USE_EXTERNAL_LIBFETCH -LIBFETCH_OBJS = -endif - # External code used by libxbps 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_remove.o plist_fetch.o util.o util_hash.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) .PHONY: all @@ -77,13 +70,13 @@ $(OBJS): %.o: %.c @printf " [CC]\t\t$@\n" ${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" ${SILENT}$(CC) $^ $(LDFLAGS) -o $(LIBXBPS_SHLIB) @-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBXBPS_MAJOR) @-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" ${SILENT}$(AR) rcs $@ $^ @printf " [RANLIB]\t$@\n" diff --git a/lib/archive.c b/lib/archive.c index 65e803a4..b9ee88fd 100644 --- a/lib/archive.c +++ b/lib/archive.c @@ -108,10 +108,10 @@ uncompress_plist_data(char *xml, size_t len) } #undef _READ_CHUNK -prop_dictionary_t HIDDEN +xbps_dictionary_t HIDDEN xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry) { - prop_dictionary_t d = NULL; + xbps_dictionary_t d = NULL; size_t buflen; ssize_t nbytes = -1; 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 */ - d = prop_dictionary_internalize(buf); - if (prop_object_type(d) == PROP_TYPE_DICTIONARY) + d = xbps_dictionary_internalize(buf); + if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY) goto out; /* Try to uncompress blob */ @@ -143,7 +143,7 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry) return NULL; } else { /* We have the uncompressed data */ - d = prop_dictionary_internalize(uncomp_buf); + d = xbps_dictionary_internalize(uncomp_buf); free(uncomp_buf); } diff --git a/lib/initend.c b/lib/initend.c index 93b86961..7212fd5e 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -257,7 +257,7 @@ xbps_end(struct xbps_handle *xhp) xbps_rpool_release(xhp); xbps_fetch_unset_cache_connection(); if (xhp->pkgdb_revdeps != NULL) - prop_object_release(xhp->pkgdb_revdeps); + xbps_object_release(xhp->pkgdb_revdeps); cfg_free(xhp->cfg); free(xhp->cachedir_priv); diff --git a/lib/package_config_files.c b/lib/package_config_files.c index 40273410..65ebb8e2 100644 --- a/lib/package_config_files.c +++ b/lib/package_config_files.c @@ -34,22 +34,22 @@ * Returns true if entry is a configuration file, false otherwise. */ 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) { - prop_array_t array; + xbps_array_t array; const char *cffile; unsigned int i; - assert(prop_object_type(propsd) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY); assert(entry_pname != NULL); - array = prop_dictionary_get(propsd, "conf_files"); - if (prop_array_count(array) == 0) + array = xbps_dictionary_get(propsd, "conf_files"); + if (xbps_array_count(array) == 0) return false; - for (i = 0; i < prop_array_count(array); i++) { - prop_array_get_cstring_nocopy(array, i, &cffile); + for (i = 0; i < xbps_array_count(array); i++) { + xbps_array_get_cstring_nocopy(array, i, &cffile); if (strcmp(cffile, entry_pname) == 0) return true; } @@ -61,20 +61,20 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd, */ int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *xhp, - prop_dictionary_t filesd, + xbps_dictionary_t filesd, struct archive_entry *entry, const char *entry_pname, const char *pkgver, const char *pkgname) { - prop_dictionary_t forigd; - prop_object_t obj, obj2; - prop_object_iterator_t iter, iter2; + xbps_dictionary_t forigd; + xbps_object_t obj, obj2; + xbps_object_iterator_t iter, iter2; const char *cffile, *sha256_new = NULL; char *buf, *sha256_cur = NULL, *sha256_orig = NULL; int rv = 0; - assert(prop_object_type(filesd) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(filesd) == XBPS_TYPE_DICTIONARY); assert(entry != NULL); assert(entry_pname != 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"); if (iter2 != NULL) { - while ((obj2 = prop_object_iterator_next(iter2))) { - prop_dictionary_get_cstring_nocopy(obj2, + while ((obj2 = xbps_object_iterator_next(iter2))) { + xbps_dictionary_get_cstring_nocopy(obj2, "file", &cffile); buf = xbps_xasprintf(".%s", cffile); if (strcmp(entry_pname, buf) == 0) { - prop_dictionary_get_cstring(obj2, "sha256", + xbps_dictionary_get_cstring(obj2, "sha256", &sha256_orig); free(buf); break; @@ -113,7 +113,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, free(buf); buf = NULL; } - prop_object_iterator_release(iter2); + xbps_object_iterator_release(iter2); } /* * 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. */ - while ((obj = prop_object_iterator_next(iter))) { - prop_dictionary_get_cstring_nocopy(obj, "file", &cffile); + while ((obj = xbps_object_iterator_next(iter))) { + xbps_dictionary_get_cstring_nocopy(obj, "file", &cffile); buf = xbps_xasprintf(".%s", cffile); if (strcmp(entry_pname, buf)) { free(buf); @@ -138,7 +138,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, } sha256_cur = xbps_file_hash(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 (errno == ENOENT) { /* @@ -239,7 +239,7 @@ out: if (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", pkgver, entry_pname, rv); diff --git a/lib/package_configure.c b/lib/package_configure.c index d0320618..79c313af 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -49,20 +49,20 @@ int xbps_configure_packages(struct xbps_handle *xhp, bool flush) { - prop_dictionary_t pkgd; - prop_object_t obj; - prop_object_iterator_t iter; + xbps_dictionary_t pkgd; + xbps_object_t obj; + xbps_object_iterator_t iter; const char *pkgver; int rv; if ((rv = xbps_pkgdb_init(xhp)) != 0) return rv; - iter = prop_dictionary_iterator(xhp->pkgdb); + iter = xbps_dictionary_iterator(xhp->pkgdb); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); rv = xbps_configure_pkg(xhp, pkgver, true, false, false); if (rv != 0) { 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; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); if ((rv == 0) && flush) rv = xbps_pkgdb_update(xhp, true); @@ -85,7 +85,7 @@ xbps_configure_pkg(struct xbps_handle *xhp, bool update, bool flush) { - prop_dictionary_t pkgd, pkgmetad; + xbps_dictionary_t pkgd, pkgmetad; char *pkgname, *plist; int rv = 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); free(pkgname); - pkgmetad = prop_dictionary_internalize_from_file(plist); + pkgmetad = xbps_dictionary_internalize_from_file(plist); if (pkgmetad == NULL) { xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL, errno, pkgver, @@ -143,7 +143,7 @@ xbps_configure_pkg(struct xbps_handle *xhp, return rv; } if (state == XBPS_PKG_STATE_INSTALLED) { - prop_object_release(pkgmetad); + xbps_object_release(pkgmetad); return rv; } @@ -161,7 +161,7 @@ xbps_configure_pkg(struct xbps_handle *xhp, pkgver, strerror(rv)); } } - prop_object_release(pkgmetad); + xbps_object_release(pkgmetad); if (rv == 0) xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_DONE, 0, pkgver, NULL); diff --git a/lib/package_conflicts.c b/lib/package_conflicts.c index 05ad76fe..e44ea6e5 100644 --- a/lib/package_conflicts.c +++ b/lib/package_conflicts.c @@ -33,37 +33,37 @@ void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *xhp, - prop_array_t unsorted, - prop_dictionary_t pkg_repod) + xbps_array_t unsorted, + xbps_dictionary_t pkg_repod) { - prop_array_t pkg_cflicts, trans_cflicts; - prop_dictionary_t pkgd; - prop_object_t obj; - prop_object_iterator_t iter; + xbps_array_t pkg_cflicts, trans_cflicts; + xbps_dictionary_t pkgd; + xbps_object_t obj; + xbps_object_iterator_t iter; const char *cfpkg, *repopkgver, *pkgver; char *pkgname, *repopkgname, *buf; - pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts"); - if (prop_array_count(pkg_cflicts) == 0) + pkg_cflicts = xbps_dictionary_get(pkg_repod, "conflicts"); + if (xbps_array_count(pkg_cflicts) == 0) return; - trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts"); - prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); + trans_cflicts = xbps_dictionary_get(xhp->transd, "conflicts"); + xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); repopkgname = xbps_pkg_name(repopkgver); assert(repopkgname); - iter = prop_array_iterator(pkg_cflicts); + iter = xbps_array_iterator(pkg_cflicts); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - cfpkg = prop_string_cstring_nocopy(obj); + while ((obj = xbps_object_iterator_next(iter))) { + cfpkg = xbps_string_cstring_nocopy(obj); /* * Check if current pkg conflicts with an installed package. */ if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) || (pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) { - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); pkgname = xbps_pkg_name(pkgver); assert(pkgname); @@ -77,7 +77,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, repopkgver); buf = xbps_xasprintf("%s conflicts with " "installed pkg %s", repopkgver, pkgver); - prop_array_add_cstring(trans_cflicts, buf); + xbps_array_add_cstring(trans_cflicts, buf); free(buf); continue; } @@ -86,7 +86,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, */ if ((pkgd = xbps_find_pkg_in_array(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); pkgname = xbps_pkg_name(pkgver); assert(pkgname); @@ -99,11 +99,11 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, "transaction %s <-> %s\n", pkgver, repopkgver); buf = xbps_xasprintf("%s conflicts with " "%s in transaction", repopkgver, pkgver); - prop_array_add_cstring(trans_cflicts, buf); + xbps_array_add_cstring(trans_cflicts, buf); free(buf); continue; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); free(repopkgname); } diff --git a/lib/package_find_obsoletes.c b/lib/package_find_obsoletes.c index 8971ef82..61e49c7a 100644 --- a/lib/package_find_obsoletes.c +++ b/lib/package_find_obsoletes.c @@ -32,68 +32,68 @@ #include "xbps_api_impl.h" -static prop_array_t -merge_filelist(prop_dictionary_t d) +static xbps_array_t +merge_filelist(xbps_dictionary_t d) { - prop_array_t a, result; - prop_dictionary_t filed; + xbps_array_t a, result; + xbps_dictionary_t filed; unsigned int i; - result = prop_array_create(); + result = xbps_array_create(); assert(result); - if ((a = prop_dictionary_get(d, "files"))) { - for (i = 0; i < prop_array_count(a); i++) { - filed = prop_array_get(a, i); - prop_array_add(result, filed); + if ((a = xbps_dictionary_get(d, "files"))) { + for (i = 0; i < xbps_array_count(a); i++) { + filed = xbps_array_get(a, i); + xbps_array_add(result, filed); } } - if ((a = prop_dictionary_get(d, "links"))) { - for (i = 0; i < prop_array_count(a); i++) { - filed = prop_array_get(a, i); - prop_array_add(result, filed); + if ((a = xbps_dictionary_get(d, "links"))) { + for (i = 0; i < xbps_array_count(a); i++) { + filed = xbps_array_get(a, i); + xbps_array_add(result, filed); } } - if ((a = prop_dictionary_get(d, "conf_files"))) { - for (i = 0; i < prop_array_count(a); i++) { - filed = prop_array_get(a, i); - prop_array_add(result, filed); + if ((a = xbps_dictionary_get(d, "conf_files"))) { + for (i = 0; i < xbps_array_count(a); i++) { + filed = xbps_array_get(a, i); + xbps_array_add(result, filed); } } - if ((a = prop_dictionary_get(d, "dirs"))) { - for (i = 0; i < prop_array_count(a); i++) { - filed = prop_array_get(a, i); - prop_array_add(result, filed); + if ((a = xbps_dictionary_get(d, "dirs"))) { + for (i = 0; i < xbps_array_count(a); i++) { + filed = xbps_array_get(a, i); + xbps_array_add(result, filed); } } return result; } -prop_array_t +xbps_array_t xbps_find_pkg_obsoletes(struct xbps_handle *xhp, - prop_dictionary_t instd, - prop_dictionary_t newd) + xbps_dictionary_t instd, + xbps_dictionary_t newd) { - prop_array_t instfiles, newfiles, obsoletes; - prop_object_t obj, obj2; - prop_string_t oldstr, newstr; + xbps_array_t instfiles, newfiles, obsoletes; + xbps_object_t obj, obj2; + xbps_string_t oldstr, newstr; unsigned int i, x; const char *oldhash; char *file; int rv = 0; bool found; - assert(prop_object_type(instd) == PROP_TYPE_DICTIONARY); - assert(prop_object_type(newd) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(instd) == XBPS_TYPE_DICTIONARY); + assert(xbps_object_type(newd) == XBPS_TYPE_DICTIONARY); - obsoletes = prop_array_create(); + obsoletes = xbps_array_create(); assert(obsoletes); 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 */ - prop_object_release(instfiles); + xbps_object_release(instfiles); return obsoletes; } newfiles = merge_filelist(newd); @@ -101,22 +101,22 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp, /* * 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; - obj = prop_array_get(instfiles, i); - if (prop_object_type(obj) != PROP_TYPE_DICTIONARY) { + obj = xbps_array_get(instfiles, i); + if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) { /* ignore unexistent files */ continue; } - oldstr = prop_dictionary_get(obj, "file"); + oldstr = xbps_dictionary_get(obj, "file"); if (oldstr == NULL) continue; file = xbps_xasprintf(".%s", - prop_string_cstring_nocopy(oldstr)); + xbps_string_cstring_nocopy(oldstr)); oldhash = NULL; - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "sha256", &oldhash); if (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. */ - for (x = 0; x < prop_array_count(newfiles); x++) { - obj2 = prop_array_get(newfiles, x); - newstr = prop_dictionary_get(obj2, "file"); + for (x = 0; x < xbps_array_count(newfiles); x++) { + obj2 = xbps_array_get(newfiles, x); + newstr = xbps_dictionary_get(obj2, "file"); assert(newstr); /* * Skip files with same path. */ - if (prop_string_equals(oldstr, newstr)) { + if (xbps_string_equals(oldstr, newstr)) { found = true; break; } @@ -167,11 +167,11 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp, * Obsolete found, add onto the array. */ xbps_dbg_printf(xhp, "found obsolete: %s\n", file); - prop_array_add_cstring(obsoletes, file); + xbps_array_add_cstring(obsoletes, file); free(file); } - prop_object_release(instfiles); - prop_object_release(newfiles); + xbps_object_release(instfiles); + xbps_object_release(newfiles); return obsoletes; } diff --git a/lib/package_orphans.c b/lib/package_orphans.c index 446e7fe4..e80913df 100644 --- a/lib/package_orphans.c +++ b/lib/package_orphans.c @@ -59,13 +59,13 @@ * dictionary. */ -prop_array_t -xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user) +xbps_array_t +xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) { - prop_array_t rdeps, reqby, array = NULL; - prop_dictionary_t pkgd, deppkgd; - prop_object_t obj; - prop_object_iterator_t iter; + xbps_array_t rdeps, reqby, array = NULL; + xbps_dictionary_t pkgd, deppkgd; + xbps_object_t obj; + xbps_object_iterator_t iter; const char *curpkgver, *deppkgver, *reqbydep; bool automatic = false; 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) return NULL; - if ((array = prop_array_create()) == NULL) + if ((array = xbps_array_create()) == NULL) return NULL; /* * Add all packages specified by the client. */ - for (i = 0; i < prop_array_count(orphans_user); i++) { - prop_array_get_cstring_nocopy(orphans_user, i, &curpkgver); + for (i = 0; i < xbps_array_count(orphans_user); i++) { + xbps_array_get_cstring_nocopy(orphans_user, i, &curpkgver); pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver); if (pkgd == NULL) continue; - prop_array_add(array, pkgd); + xbps_array_add(array, pkgd); } - if (prop_array_count(array)) + if (xbps_array_count(array)) goto find_orphans; - iter = prop_dictionary_iterator(xhp->pkgdb); + iter = xbps_dictionary_iterator(xhp->pkgdb); assert(iter); /* * First pass: track pkgs that were installed manually and * without reverse dependencies. */ - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); /* * 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) 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); - if (prop_array_count(reqby) == 0) { + if (xbps_array_count(reqby) == 0) { /* * Add packages with empty revdeps. */ - prop_array_add(array, pkgd); + xbps_array_add(array, pkgd); continue; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); find_orphans: - for (i = 0; i < prop_array_count(array); i++) { - pkgd = prop_array_get(array, i); - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); + for (i = 0; i < xbps_array_count(array); i++) { + pkgd = xbps_array_get(array, i); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); - rdeps = prop_dictionary_get(pkgd, "run_depends"); - for (x = 0; x < prop_array_count(rdeps); x++) { + rdeps = xbps_dictionary_get(pkgd, "run_depends"); + for (x = 0; x < xbps_array_count(rdeps); x++) { 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); if (reqby == NULL) continue; - reqbycnt = prop_array_count(reqby); + reqbycnt = xbps_array_count(reqby); 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)) { cnt++; continue; @@ -140,7 +140,7 @@ find_orphans: if (cnt == reqbycnt) { deppkgd = xbps_pkgdb_get_pkg(xhp, deppkgver); if (!xbps_find_pkg_in_array(array, deppkgver)) - prop_array_add(array, deppkgd); + xbps_array_add(array, deppkgd); } } } diff --git a/lib/package_register.c b/lib/package_register.c index 82411fcb..175b06d6 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -32,10 +32,10 @@ #include "xbps_api_impl.h" 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; - prop_array_t provides, rundeps; + xbps_dictionary_t pkgd; + xbps_array_t provides, rundeps; char outstr[64]; time_t t; struct tm *tmp; @@ -44,13 +44,13 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd) int rv = 0; 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); - prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); - prop_dictionary_get_bool(pkgrd, "automatic-install", &autoinst); - provides = prop_dictionary_get(pkgrd, "provides"); - rundeps = prop_dictionary_get(pkgrd, "run_depends"); + xbps_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); + xbps_dictionary_get_bool(pkgrd, "automatic-install", &autoinst); + provides = xbps_dictionary_get(pkgrd, "provides"); + rundeps = xbps_dictionary_get(pkgrd, "run_depends"); assert(pkgver != NULL); assert(desc != NULL); @@ -60,14 +60,14 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd) rv = ENOENT; goto out; } - if (!prop_dictionary_set_cstring_nocopy(pkgd, + if (!xbps_dictionary_set_cstring_nocopy(pkgd, "pkgver", pkgver)) { xbps_dbg_printf(xhp, "%s: invalid pkgver for %s\n", __func__, pkgver); rv = EINVAL; goto out; } - if (!prop_dictionary_set_cstring_nocopy(pkgd, + if (!xbps_dictionary_set_cstring_nocopy(pkgd, "short_desc", desc)) { xbps_dbg_printf(xhp, "%s: invalid short_desc for %s\n", __func__, pkgver); @@ -77,7 +77,7 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd) if (xhp->flags & XBPS_FLAG_INSTALL_AUTO) autoinst = true; - if (!prop_dictionary_set_bool(pkgd, + if (!xbps_dictionary_set_bool(pkgd, "automatic-install", autoinst)) { xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n", __func__, pkgver); @@ -100,19 +100,19 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd) rv = EINVAL; 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); rv = EINVAL; 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", __func__, pkgver); rv = EINVAL; 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", __func__, pkgver); 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); sha256 = xbps_file_hash(buf); assert(sha256); - prop_dictionary_set_cstring(pkgd, "metafile-sha256", sha256); + xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256); free(sha256); free(buf); /* * Remove unneeded objs from pkg dictionary. */ - prop_dictionary_remove(pkgd, "remove-and-update"); - prop_dictionary_remove(pkgd, "transaction"); - prop_dictionary_remove(pkgd, "skip-obsoletes"); + xbps_dictionary_remove(pkgd, "remove-and-update"); + xbps_dictionary_remove(pkgd, "transaction"); + 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, "%s: failed to set pkgd for %s\n", __func__, pkgver); goto out; diff --git a/lib/package_remove.c b/lib/package_remove.c index b213e7f4..be06b784 100644 --- a/lib/package_remove.c +++ b/lib/package_remove.c @@ -35,24 +35,24 @@ int HIDDEN xbps_remove_pkg_files(struct xbps_handle *xhp, - prop_dictionary_t dict, + xbps_dictionary_t dict, const char *key, const char *pkgver) { struct stat st; - prop_array_t array; - prop_object_iterator_t iter; - prop_object_t obj; + xbps_array_t array; + xbps_object_iterator_t iter; + xbps_object_t obj; const char *file, *sha256, *curobj = NULL; char *path = NULL, *pkgname = NULL; char buf[PATH_MAX]; int rv = 0; - assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY); assert(key != NULL); - array = prop_dictionary_get(dict, key); - if (prop_array_count(array) == 0) + array = xbps_dictionary_get(dict, key); + if (xbps_array_count(array) == 0) return 0; 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); assert(pkgname); - while ((obj = prop_object_iterator_next(iter))) { - prop_dictionary_get_cstring_nocopy(obj, "file", &file); + while ((obj = xbps_object_iterator_next(iter))) { + xbps_dictionary_get_cstring_nocopy(obj, "file", &file); path = xbps_xasprintf("%s/%s", xhp->rootdir, file); if ((strcmp(key, "files") == 0) || @@ -81,7 +81,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp, * Check SHA256 hash in regular files and * configuration files. */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "sha256", &sha256); rv = xbps_file_hash_check(path, sha256); if (rv == ENOENT) { @@ -157,7 +157,7 @@ xbps_remove_pkg_files(struct xbps_handle *xhp, } free(path); } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); free(pkgname); return rv; @@ -169,7 +169,7 @@ xbps_remove_pkg(struct xbps_handle *xhp, bool update, bool soft_replace) { - prop_dictionary_t pkgd = NULL; + xbps_dictionary_t pkgd = NULL; char *pkgname, *buf = NULL; int rv = 0; pkg_state_t state = 0; @@ -200,7 +200,7 @@ xbps_remove_pkg(struct xbps_handle *xhp, /* internalize pkg dictionary from metadir */ 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); if (pkgd == NULL) xbps_dbg_printf(xhp, "WARNING: metaplist for %s " @@ -231,7 +231,7 @@ xbps_remove_pkg(struct xbps_handle *xhp, */ if (update) { if (pkgd) - prop_object_release(pkgd); + xbps_object_release(pkgd); free(pkgname); return 0; } else if (soft_replace) { @@ -297,7 +297,7 @@ purge: "purge ACTION: %s", pkgver, strerror(rv)); goto out; } - prop_object_release(pkgd); + xbps_object_release(pkgd); } /* * Remove package metadata plist. @@ -315,7 +315,7 @@ purge: /* * Unregister package from pkgdb. */ - prop_dictionary_remove(xhp->pkgdb, pkgname); + xbps_dictionary_remove(xhp->pkgdb, pkgname); if ((rv = xbps_pkgdb_update(xhp, true)) != 0) goto out; diff --git a/lib/package_script.c b/lib/package_script.c index 5ef4b90c..5b50c333 100644 --- a/lib/package_script.c +++ b/lib/package_script.c @@ -109,12 +109,12 @@ out: int xbps_pkg_exec_script(struct xbps_handle *xhp, - prop_dictionary_t d, + xbps_dictionary_t d, const char *script, const char *action, bool update) { - prop_data_t data; + xbps_data_t data; void *buf; size_t buflen; const char *pkgver; @@ -125,14 +125,14 @@ xbps_pkg_exec_script(struct xbps_handle *xhp, assert(script); assert(action); - data = prop_dictionary_get(d, script); + data = xbps_dictionary_get(d, script); if (data == NULL) return 0; - prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); - buf = prop_data_data(data); - buflen = prop_data_size(data); + buf = xbps_data_data(data); + buflen = xbps_data_size(data); rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, action, update); free(buf); diff --git a/lib/package_state.c b/lib/package_state.c index f6f39161..250ea61b 100644 --- a/lib/package_state.c +++ b/lib/package_state.c @@ -53,11 +53,11 @@ static const struct state states[] = { */ 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; - assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY); for (stp = states; stp->string != NULL; stp++) if (state == stp->number) @@ -66,21 +66,21 @@ set_new_state(prop_dictionary_t dict, pkg_state_t state) if (stp->string == NULL) 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 0; } static pkg_state_t -get_state(prop_dictionary_t dict) +get_state(xbps_dictionary_t dict) { const struct state *stp; 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)) return 0; @@ -96,7 +96,7 @@ xbps_pkg_state_installed(struct xbps_handle *xhp, const char *pkgver, pkg_state_t *state) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; assert(pkgver != NULL); assert(state != NULL); @@ -113,9 +113,9 @@ xbps_pkg_state_installed(struct xbps_handle *xhp, } 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); if ((*state = get_state(dict)) == 0) @@ -125,9 +125,9 @@ xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state) } 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); } @@ -137,7 +137,7 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp, const char *pkgver, pkg_state_t state) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; char *pkgname; int rv = 0; @@ -145,35 +145,35 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp, pkgd = xbps_pkgdb_get_pkg(xhp, pkgver); if (pkgd == NULL) { - pkgd = prop_dictionary_create(); + pkgd = xbps_dictionary_create(); if (pkgd == NULL) return ENOMEM; - if (!prop_dictionary_set_cstring_nocopy(pkgd, + if (!xbps_dictionary_set_cstring_nocopy(pkgd, "pkgver", pkgver)) { - prop_object_release(pkgd); + xbps_object_release(pkgd); return EINVAL; } if ((rv = set_new_state(pkgd, state)) != 0) { - prop_object_release(pkgd); + xbps_object_release(pkgd); return rv; } pkgname = xbps_pkg_name(pkgver); assert(pkgname); - if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { - prop_object_release(pkgd); + if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { + xbps_object_release(pkgd); free(pkgname); return EINVAL; } free(pkgname); - prop_object_release(pkgd); + xbps_object_release(pkgd); } else { if ((rv = set_new_state(pkgd, state)) != 0) return rv; pkgname = xbps_pkg_name(pkgver); assert(pkgname); - if (!prop_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { + if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { free(pkgname); return EINVAL; } diff --git a/lib/package_unpack.c b/lib/package_unpack.c index 57e40fdc..7673e987 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -53,23 +53,23 @@ set_extract_flags(uid_t euid) } 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; - prop_object_t obj; + xbps_array_t links; + xbps_object_t obj; unsigned int i; const char *pkgfile, *tgt = NULL; char *rfile; assert(d); - links = prop_dictionary_get(d, "links"); - for (i = 0; i < prop_array_count(links); i++) { + links = xbps_dictionary_get(d, "links"); + for (i = 0; i < xbps_array_count(links); i++) { rfile = strchr(file, '.') + 1; - obj = prop_array_get(links, i); - prop_dictionary_get_cstring_nocopy(obj, "file", &pkgfile); + obj = xbps_array_get(links, i); + xbps_dictionary_get_cstring_nocopy(obj, "file", &pkgfile); if (strcmp(rfile, pkgfile) == 0) { - prop_dictionary_get_cstring_nocopy(obj, "target", &tgt); + xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt); break; } } @@ -79,52 +79,52 @@ find_pkg_symlink_target(prop_dictionary_t d, const char *file) static int 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 *rembuf, const size_t rembufsiz) { - prop_array_t array; - prop_dictionary_t pkg_metad; - prop_data_t data; + xbps_array_t array; + xbps_dictionary_t pkg_metad; + xbps_data_t data; char *buf; int rv = 0; - prop_dictionary_make_immutable(propsd); - pkg_metad = prop_dictionary_copy_mutable(propsd); + xbps_dictionary_make_immutable(propsd); + pkg_metad = xbps_dictionary_copy_mutable(propsd); /* Add objects from XBPS_PKGFILES */ - array = prop_dictionary_get(filesd, "files"); - if (prop_array_count(array)) - prop_dictionary_set(pkg_metad, "files", array); - array = prop_dictionary_get(filesd, "conf_files"); - if (prop_array_count(array)) - prop_dictionary_set(pkg_metad, "conf_files", array); - array = prop_dictionary_get(filesd, "links"); - if (prop_array_count(array)) - prop_dictionary_set(pkg_metad, "links", array); - array = prop_dictionary_get(filesd, "dirs"); - if (prop_array_count(array)) - prop_dictionary_set(pkg_metad, "dirs", array); + array = xbps_dictionary_get(filesd, "files"); + if (xbps_array_count(array)) + xbps_dictionary_set(pkg_metad, "files", array); + array = xbps_dictionary_get(filesd, "conf_files"); + if (xbps_array_count(array)) + xbps_dictionary_set(pkg_metad, "conf_files", array); + array = xbps_dictionary_get(filesd, "links"); + if (xbps_array_count(array)) + xbps_dictionary_set(pkg_metad, "links", array); + array = xbps_dictionary_get(filesd, "dirs"); + if (xbps_array_count(array)) + xbps_dictionary_set(pkg_metad, "dirs", array); /* Add install/remove scripts data objects */ if (instbuf != NULL) { - data = prop_data_create_data(instbuf, instbufsiz); + data = xbps_data_create_data(instbuf, instbufsiz); assert(data); - prop_dictionary_set(pkg_metad, "install-script", data); - prop_object_release(data); + xbps_dictionary_set(pkg_metad, "install-script", data); + xbps_object_release(data); } if (rembuf != NULL) { - data = prop_data_create_data(rembuf, rembufsiz); + data = xbps_data_create_data(rembuf, rembufsiz); assert(data); - prop_dictionary_set(pkg_metad, "remove-script", data); - prop_object_release(data); + xbps_dictionary_set(pkg_metad, "remove-script", data); + xbps_object_release(data); } /* Remove unneeded objs from transaction */ - prop_dictionary_remove(pkg_metad, "remove-and-update"); - prop_dictionary_remove(pkg_metad, "transaction"); - prop_dictionary_remove(pkg_metad, "state"); - prop_dictionary_remove(pkg_metad, "pkgname"); - prop_dictionary_remove(pkg_metad, "version"); + xbps_dictionary_remove(pkg_metad, "remove-and-update"); + xbps_dictionary_remove(pkg_metad, "transaction"); + xbps_dictionary_remove(pkg_metad, "state"); + xbps_dictionary_remove(pkg_metad, "pkgname"); + xbps_dictionary_remove(pkg_metad, "version"); /* * 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); - if (!prop_dictionary_externalize_to_file(pkg_metad, buf)) { + if (!xbps_dictionary_externalize_to_file(pkg_metad, buf)) { rv = errno; xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, errno, pkgver, @@ -145,21 +145,21 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p pkgver, buf, strerror(errno)); } free(buf); - prop_object_release(pkg_metad); + xbps_object_release(pkg_metad); return rv; } static int unpack_archive(struct xbps_handle *xhp, - prop_dictionary_t pkg_repod, + xbps_dictionary_t pkg_repod, const char *pkgver, const char *fname, struct archive *ar) { - prop_dictionary_t propsd, filesd, old_filesd; - prop_array_t array, obsoletes; - prop_object_t obj; + xbps_dictionary_t propsd, filesd, old_filesd; + xbps_array_t array, obsoletes; + xbps_object_t obj; void *instbuf = NULL, *rembuf = NULL; struct stat st; struct xbps_unpack_cb_data xucd; @@ -173,17 +173,17 @@ unpack_archive(struct xbps_handle *xhp, bool softreplace, skip_extract, force, metafile; uid_t euid; - assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY); assert(ar != NULL); propsd = filesd = old_filesd = NULL; force = preserve = update = conf_file = file_exists = false; skip_obsoletes = softreplace = metafile = false; - prop_dictionary_get_bool(pkg_repod, "preserve", &preserve); - prop_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes); - prop_dictionary_get_bool(pkg_repod, "softreplace", &softreplace); - prop_dictionary_get_cstring_nocopy(pkg_repod, + xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve); + xbps_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes); + xbps_dictionary_get_bool(pkg_repod, "softreplace", &softreplace); + xbps_dictionary_get_cstring_nocopy(pkg_repod, "transaction", &transact); euid = geteuid(); @@ -350,15 +350,15 @@ unpack_archive(struct xbps_handle *xhp, */ if (xhp->unpack_cb != NULL) { xucd.entry_total_count = 0; - array = prop_dictionary_get(filesd, "files"); + array = xbps_dictionary_get(filesd, "files"); xucd.entry_total_count += - (ssize_t)prop_array_count(array); - array = prop_dictionary_get(filesd, "conf_files"); + (ssize_t)xbps_array_count(array); + array = xbps_dictionary_get(filesd, "conf_files"); xucd.entry_total_count += - (ssize_t)prop_array_count(array); - array = prop_dictionary_get(filesd, "links"); + (ssize_t)xbps_array_count(array); + array = xbps_dictionary_get(filesd, "links"); xucd.entry_total_count += - (ssize_t)prop_array_count(array); + (ssize_t)xbps_array_count(array); } /* * Always check that extracted file exists and hash @@ -589,9 +589,9 @@ unpack_archive(struct xbps_handle *xhp, goto out; obsoletes = xbps_find_pkg_obsoletes(xhp, old_filesd, filesd); - for (i = 0; i < prop_array_count(obsoletes); i++) { - obj = prop_array_get(obsoletes, i); - file = prop_string_cstring_nocopy(obj); + for (i = 0; i < xbps_array_count(obsoletes); i++) { + obj = xbps_array_get(obsoletes, i); + file = xbps_string_cstring_nocopy(obj); if (remove(file) == -1) { xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL, @@ -603,14 +603,14 @@ unpack_archive(struct xbps_handle *xhp, xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FILE_OBSOLETE, 0, pkgver, "%s: removed obsolete entry: %s", pkgver, file); - prop_object_release(obj); + xbps_object_release(obj); } out: - if (prop_object_type(filesd) == PROP_TYPE_DICTIONARY) - prop_object_release(filesd); - if (prop_object_type(propsd) == PROP_TYPE_DICTIONARY) - prop_object_release(propsd); + if (xbps_object_type(filesd) == XBPS_TYPE_DICTIONARY) + xbps_object_release(filesd); + if (xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY) + xbps_object_release(propsd); if (pkgname != NULL) free(pkgname); if (instbuf != NULL) @@ -622,16 +622,16 @@ out: } 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; const char *pkgver; char *bpkg; 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); bpkg = xbps_repository_pkg_path(xhp, pkg_repod); diff --git a/lib/pkgdb.c b/lib/pkgdb.c index 21a11b42..e72729a1 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -79,7 +79,7 @@ xbps_pkgdb_init(struct xbps_handle *xhp) int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush) { - prop_dictionary_t pkgdb_storage; + xbps_dictionary_t pkgdb_storage; char *plist; static int cached_rv; 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); if (xhp->pkgdb && flush) { - pkgdb_storage = prop_dictionary_internalize_from_file(plist); + pkgdb_storage = xbps_dictionary_internalize_from_file(plist); if (pkgdb_storage == NULL || - !prop_dictionary_equals(xhp->pkgdb, pkgdb_storage)) { + !xbps_dictionary_equals(xhp->pkgdb, pkgdb_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); return errno; } } 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; cached_rv = 0; } /* 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) - xhp->pkgdb = prop_dictionary_create(); + xhp->pkgdb = xbps_dictionary_create(); else 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) return; - if (prop_object_type(xhp->pkg_metad) == PROP_TYPE_DICTIONARY) - prop_object_release(xhp->pkg_metad); + if (xbps_object_type(xhp->pkg_metad) == XBPS_TYPE_DICTIONARY) + xbps_object_release(xhp->pkg_metad); - prop_object_release(xhp->pkgdb); + xbps_object_release(xhp->pkgdb); xhp->pkgdb = NULL; xbps_dbg_printf(xhp, "[pkgdb] released ok.\n"); } int 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) { - prop_array_t allkeys; - prop_object_t obj; - prop_dictionary_t pkgd; + xbps_array_t allkeys; + xbps_object_t obj; + xbps_dictionary_t pkgd; unsigned int i; int rv; bool done = false; @@ -150,45 +150,45 @@ xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp, if ((rv = xbps_pkgdb_init(xhp)) != 0) return rv; - allkeys = prop_dictionary_all_keys(xhp->pkgdb); - for (i = prop_array_count(allkeys); i > 0; i--) { - obj = prop_array_get(allkeys, i); - pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); + allkeys = xbps_dictionary_all_keys(xhp->pkgdb); + for (i = xbps_array_count(allkeys); i > 0; i--) { + obj = xbps_array_get(allkeys, i); + pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); rv = (*fn)(xhp, pkgd, arg, &done); if (rv != 0 || done) break; } - prop_object_release(allkeys); + xbps_object_release(allkeys); return rv; } 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) { - prop_object_t obj; - prop_object_iterator_t iter; - prop_dictionary_t pkgd; + xbps_object_t obj; + xbps_object_iterator_t iter; + xbps_dictionary_t pkgd; int rv; bool done = false; if ((rv = xbps_pkgdb_init(xhp)) != 0) return rv; - iter = prop_dictionary_iterator(xhp->pkgdb); + iter = xbps_dictionary_iterator(xhp->pkgdb); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); rv = (*fn)(xhp, pkgd, arg, &done); if (rv != 0 || done) break; } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return rv; } -prop_dictionary_t +xbps_dictionary_t xbps_pkgdb_get_pkg(struct xbps_handle *xhp, const char *pkg) { 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); } -prop_dictionary_t +xbps_dictionary_t xbps_pkgdb_get_virtualpkg(struct xbps_handle *xhp, const char *vpkg) { 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); } -static prop_dictionary_t -get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd) +static xbps_dictionary_t +get_pkg_metadata(struct xbps_handle *xhp, xbps_dictionary_t pkgd) { - prop_dictionary_t pkg_metad; + xbps_dictionary_t pkg_metad; const char *pkgver; char *pkgname, *plist; - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); pkgname = xbps_pkg_name(pkgver); 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); return pkg_metad; } 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); if (pkg_metad == NULL) { @@ -233,10 +233,10 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd) } 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); - prop_object_release(pkg_metad); + xbps_dictionary_set(xhp->pkg_metad, pkgname, pkg_metad); + xbps_object_release(pkg_metad); free(pkgname); return pkg_metad; @@ -245,10 +245,10 @@ get_pkg_metadata(struct xbps_handle *xhp, prop_dictionary_t pkgd) static void generate_full_revdeps_tree(struct xbps_handle *xhp) { - prop_array_t rundeps, pkg; - prop_dictionary_t pkgd; - prop_object_t obj; - prop_object_iterator_t iter; + xbps_array_t rundeps, pkg; + xbps_dictionary_t pkgd; + xbps_object_t obj; + xbps_object_iterator_t iter; const char *pkgver, *pkgdep, *vpkgname; char *curpkgname; unsigned int i; @@ -257,20 +257,20 @@ generate_full_revdeps_tree(struct xbps_handle *xhp) if (xhp->pkgdb_revdeps) 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); - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); - rundeps = prop_dictionary_get(pkgd, "run_depends"); - if (!prop_array_count(rundeps)) + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); + rundeps = xbps_dictionary_get(pkgd, "run_depends"); + if (!xbps_array_count(rundeps)) continue; - for (i = 0; i < prop_array_count(rundeps); i++) { + for (i = 0; i < xbps_array_count(rundeps); i++) { alloc = false; - prop_array_get_cstring_nocopy(rundeps, i, &pkgdep); + xbps_array_get_cstring_nocopy(rundeps, i, &pkgdep); curpkgname = xbps_pkgpattern_name(pkgdep); if (curpkgname == NULL) curpkgname = xbps_pkg_name(pkgdep); @@ -279,29 +279,29 @@ generate_full_revdeps_tree(struct xbps_handle *xhp) if (vpkgname == NULL) vpkgname = curpkgname; - pkg = prop_dictionary_get(xhp->pkgdb_revdeps, vpkgname); + pkg = xbps_dictionary_get(xhp->pkgdb_revdeps, vpkgname); if (pkg == NULL) { 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)) { - prop_array_add_cstring_nocopy(pkg, pkgver); - prop_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg); + xbps_array_add_cstring_nocopy(pkg, pkgver); + xbps_dictionary_set(xhp->pkgdb_revdeps, vpkgname, pkg); } free(curpkgname); 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) { - prop_array_t res; - prop_dictionary_t pkgd; + xbps_array_t res; + xbps_dictionary_t pkgd; const char *pkgver; char *pkgname; @@ -309,18 +309,18 @@ xbps_pkgdb_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) return NULL; 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); - res = prop_dictionary_get(xhp->pkgdb_revdeps, pkgname); + res = xbps_dictionary_get(xhp->pkgdb_revdeps, pkgname); free(pkgname); return res; } -prop_dictionary_t +xbps_dictionary_t 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); if (pkgd == NULL) diff --git a/lib/plist.c b/lib/plist.c index ac00e3e1..e6292edb 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -40,88 +40,88 @@ * all library functions. */ 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) { - assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY); assert(obj != NULL); assert(key != NULL); - if (!prop_dictionary_set(dict, key, obj)) { - prop_object_release(dict); + if (!xbps_dictionary_set(dict, key, obj)) { + xbps_object_release(dict); errno = EINVAL; return false; } - prop_object_release(obj); + xbps_object_release(obj); return true; } 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); - if (!prop_array_add(array, obj)) { - prop_object_release(array); + if (!xbps_array_add(array, obj)) { + xbps_object_release(array); errno = EINVAL; return false; } - prop_object_release(obj); + xbps_object_release(obj); return true; } int xbps_callback_array_iter(struct xbps_handle *xhp, - prop_array_t array, - int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), + xbps_array_t array, + int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *), void *arg) { - prop_object_t obj; - prop_object_iterator_t iter; + xbps_object_t obj; + xbps_object_iterator_t iter; int rv = 0; bool loop_done = false; - assert(prop_object_type(array) == PROP_TYPE_ARRAY); + assert(xbps_object_type(array) == XBPS_TYPE_ARRAY); assert(fn != NULL); - iter = prop_array_iterator(array); + iter = xbps_array_iterator(array); if (iter == NULL) 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); if (rv != 0 || loop_done) break; } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return rv; } int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, - prop_dictionary_t dict, + xbps_dictionary_t dict, 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) { - prop_object_t obj; - prop_array_t array; + xbps_object_t obj; + xbps_array_t array; unsigned int i; int rv = 0; bool cbloop_done = false; - assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY); assert(xhp != NULL); assert(key != NULL); assert(fn != NULL); - array = prop_dictionary_get(dict, key); - for (i = 0; i < prop_array_count(array); i++) { - obj = prop_array_get(array, i); + array = xbps_dictionary_get(dict, key); + for (i = 0; i < xbps_array_count(array); i++) { + obj = xbps_array_get(array, i); if (obj == NULL) continue; rv = (*fn)(xhp, obj, arg, &cbloop_done); @@ -134,24 +134,24 @@ xbps_callback_array_iter_in_dict(struct xbps_handle *xhp, int xbps_callback_array_iter_reverse(struct xbps_handle *xhp, - prop_array_t array, - int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), + xbps_array_t array, + int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *), void *arg) { - prop_object_t obj; + xbps_object_t obj; unsigned int cnt; int rv = 0; bool loop_done = false; - assert(prop_object_type(array) == PROP_TYPE_ARRAY); + assert(xbps_object_type(array) == XBPS_TYPE_ARRAY); assert(fn != NULL); assert(xhp != NULL); - if ((cnt = prop_array_count(array)) == 0) + if ((cnt = xbps_array_count(array)) == 0) return 0; while (cnt--) { - obj = prop_array_get(array, cnt); + obj = xbps_array_get(array, cnt); if (obj == NULL) continue; rv = (*fn)(xhp, obj, arg, &loop_done); @@ -164,20 +164,20 @@ xbps_callback_array_iter_reverse(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, - int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *), + int (*fn)(struct xbps_handle *, xbps_object_t, void *, bool *), 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(fn != NULL); assert(xhp != NULL); - array = prop_dictionary_get(dict, key); - if (prop_object_type(array) != PROP_TYPE_ARRAY) { + array = xbps_dictionary_get(dict, key); + if (xbps_object_type(array) != XBPS_TYPE_ARRAY) { xbps_dbg_printf(xhp, "invalid key '%s' for dictionary", key); 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); } -prop_object_iterator_t -xbps_array_iter_from_dict(prop_dictionary_t dict, const char *key) +xbps_object_iterator_t +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); - array = prop_dictionary_get(dict, key); - if (prop_object_type(array) != PROP_TYPE_ARRAY) { + array = xbps_dictionary_get(dict, key); + if (xbps_object_type(array) != XBPS_TYPE_ARRAY) { errno = EINVAL; return NULL; } - return prop_array_iterator(array); + return xbps_array_iterator(array); } static int -array_replace_dict(prop_array_t array, - prop_dictionary_t dict, +array_replace_dict(xbps_array_t array, + xbps_dictionary_t dict, const char *str, bool bypattern) { - prop_object_t obj; + xbps_object_t obj; unsigned int i; const char *curpkgver; char *curpkgname; - assert(prop_object_type(array) == PROP_TYPE_ARRAY); - assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(array) == XBPS_TYPE_ARRAY); + assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY); assert(str != NULL); - for (i = 0; i < prop_array_count(array); i++) { - obj = prop_array_get(array, i); + for (i = 0; i < xbps_array_count(array); i++) { + obj = xbps_array_get(array, i); if (obj == NULL) continue; if (bypattern) { /* pkgpattern match */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &curpkgver); if (xbps_pkgpattern_match(curpkgver, str)) { - if (!prop_array_set(array, i, dict)) + if (!xbps_array_set(array, i, dict)) return EINVAL; return 0; } } else { /* pkgname match */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &curpkgver); curpkgname = xbps_pkg_name(curpkgver); assert(curpkgname); if (strcmp(curpkgname, str) == 0) { - if (!prop_array_set(array, i, dict)) { + if (!xbps_array_set(array, i, dict)) { free(curpkgname); return EINVAL; } @@ -253,16 +253,16 @@ array_replace_dict(prop_array_t array, } int HIDDEN -xbps_array_replace_dict_by_name(prop_array_t array, - prop_dictionary_t dict, +xbps_array_replace_dict_by_name(xbps_array_t array, + xbps_dictionary_t dict, const char *pkgver) { return array_replace_dict(array, dict, pkgver, false); } int HIDDEN -xbps_array_replace_dict_by_pattern(prop_array_t array, - prop_dictionary_t dict, +xbps_array_replace_dict_by_pattern(xbps_array_t array, + xbps_dictionary_t dict, const char *pattern) { return array_replace_dict(array, dict, pattern, true); diff --git a/lib/plist_fetch.c b/lib/plist_fetch.c index 55209cbb..a5dc5d3f 100644 --- a/lib/plist_fetch.c +++ b/lib/plist_fetch.c @@ -145,10 +145,10 @@ open_archive(const char *url) return a; } -prop_dictionary_t +xbps_dictionary_t 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_entry *entry; const char *curpath, *comptype; @@ -185,7 +185,7 @@ xbps_get_pkg_plist_from_binpkg(const char *fname, const char *plistf) errno = EINVAL; break; } - prop_dictionary_set_cstring_nocopy(plistd, + xbps_dictionary_set_cstring_nocopy(plistd, "archive-compression-type", comptype); break; diff --git a/lib/plist_find.c b/lib/plist_find.c index 1238258b..582ffc05 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -37,19 +37,19 @@ static pthread_mutex_t cfg_mtx = PTHREAD_MUTEX_INITIALIZER; static bool cfg_vpkgs_init; -static prop_dictionary_t -get_pkg_in_array(prop_array_t array, const char *str, bool virtual) +static xbps_dictionary_t +get_pkg_in_array(xbps_array_t array, const char *str, bool virtual) { - prop_object_t obj = NULL; - prop_object_iterator_t iter; + xbps_object_t obj = NULL; + xbps_object_iterator_t iter; const char *pkgver; char *dpkgn; bool found = false; - iter = prop_array_iterator(array); + iter = xbps_array_iterator(array); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { + while ((obj = xbps_object_iterator_next(iter))) { if (virtual) { /* * Check if package pattern matches @@ -64,7 +64,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual) break; } else if (xbps_pkgpattern_version(str)) { /* ,atch by pattern against pkgver */ - if (!prop_dictionary_get_cstring_nocopy(obj, + if (!xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver)) continue; 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)) { /* match by exact pkgver */ - if (!prop_dictionary_get_cstring_nocopy(obj, + if (!xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver)) continue; if (strcmp(str, pkgver) == 0) { @@ -82,7 +82,7 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual) } } else { /* match by pkgname */ - if (!prop_dictionary_get_cstring_nocopy(obj, + if (!xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver)) continue; dpkgn = xbps_pkg_name(pkgver); @@ -95,31 +95,31 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual) free(dpkgn); } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return found ? obj : NULL; } -prop_dictionary_t HIDDEN -xbps_find_pkg_in_array(prop_array_t a, const char *s) +xbps_dictionary_t HIDDEN +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); 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, - prop_array_t a, + xbps_array_t a, const char *s) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; const char *vpkg; bool bypattern = false; assert(x); - assert(prop_object_type(a) == PROP_TYPE_ARRAY); + assert(xbps_object_type(a) == XBPS_TYPE_ARRAY); assert(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); } -static prop_dictionary_t -match_pkg_by_pkgver(prop_dictionary_t repod, const char *p) +static xbps_dictionary_t +match_pkg_by_pkgver(xbps_dictionary_t repod, const char *p) { - prop_dictionary_t d = NULL; + xbps_dictionary_t d = NULL; const char *pkgver; char *pkgname; @@ -144,9 +144,9 @@ match_pkg_by_pkgver(prop_dictionary_t repod, const char *p) if ((pkgname = xbps_pkg_name(p)) == NULL) return NULL; - d = prop_dictionary_get(repod, pkgname); + d = xbps_dictionary_get(repod, pkgname); if (d) { - prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); if (strcmp(pkgver, p)) d = NULL; } @@ -155,10 +155,10 @@ match_pkg_by_pkgver(prop_dictionary_t repod, const char *p) return d; } -static prop_dictionary_t -match_pkg_by_pattern(prop_dictionary_t repod, const char *p) +static xbps_dictionary_t +match_pkg_by_pattern(xbps_dictionary_t repod, const char *p) { - prop_dictionary_t d = NULL; + xbps_dictionary_t d = NULL; const char *pkgver; char *pkgname; @@ -170,9 +170,9 @@ match_pkg_by_pattern(prop_dictionary_t repod, const char *p) return NULL; } - d = prop_dictionary_get(repod, pkgname); + d = xbps_dictionary_get(repod, pkgname); if (d) { - prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); assert(pkgver); if (!xbps_pkgpattern_match(pkgver, p)) d = NULL; @@ -289,14 +289,14 @@ vpkg_user_conf(struct xbps_handle *xhp, return pkg; } -prop_dictionary_t +xbps_dictionary_t xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, - prop_dictionary_t d, + xbps_dictionary_t d, const char *pkg) { - prop_object_t obj; - prop_object_iterator_t iter; - prop_dictionary_t pkgd = NULL; + xbps_object_t obj; + xbps_object_iterator_t iter; + xbps_dictionary_t pkgd = NULL; const char *vpkg; bool found = false, bypattern = false; @@ -311,7 +311,7 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, else if (xbps_pkg_version(vpkg)) pkgd = match_pkg_by_pkgver(d, vpkg); else - pkgd = prop_dictionary_get(d, vpkg); + pkgd = xbps_dictionary_get(d, vpkg); if (pkgd) { found = true; @@ -320,17 +320,17 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp, } /* ... otherwise match the first one in dictionary */ - iter = prop_dictionary_iterator(d); + iter = xbps_dictionary_iterator(d); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(d, obj); + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(d, obj); if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) { found = true; break; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); out: if (found) @@ -339,17 +339,17 @@ out: return NULL; } -prop_dictionary_t -xbps_find_pkg_in_dict(prop_dictionary_t d, const char *pkg) +xbps_dictionary_t +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)) pkgd = match_pkg_by_pattern(d, pkg); else if (xbps_pkg_version(pkg)) pkgd = match_pkg_by_pkgver(d, pkg); else - pkgd = prop_dictionary_get(d, pkg); + pkgd = xbps_dictionary_get(d, pkg); return pkgd; } diff --git a/lib/plist_match.c b/lib/plist_match.c index df00244f..1e9dd34f 100644 --- a/lib/plist_match.c +++ b/lib/plist_match.c @@ -40,16 +40,16 @@ * all library functions. */ bool -xbps_match_virtual_pkg_in_dict(prop_dictionary_t d, +xbps_match_virtual_pkg_in_dict(xbps_dictionary_t d, const char *str, bool bypattern) { - prop_array_t provides; + xbps_array_t provides; 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) found = xbps_match_pkgpattern_in_array(provides, str); else { @@ -62,72 +62,72 @@ xbps_match_virtual_pkg_in_dict(prop_dictionary_t d, } bool -xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps, - prop_array_t provides) +xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps, + xbps_array_t provides) { - prop_object_t obj, obj2; - prop_object_iterator_t iter, iter2; + xbps_object_t obj, obj2; + xbps_object_iterator_t iter, iter2; const char *vpkgver, *pkgpattern; char *tmp; - iter = prop_array_iterator(provides); + iter = xbps_array_iterator(provides); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { + while ((obj = xbps_object_iterator_next(iter))) { tmp = NULL; - vpkgver = prop_string_cstring_nocopy(obj); + vpkgver = xbps_string_cstring_nocopy(obj); if (strchr(vpkgver, '_') == NULL) { tmp = xbps_xasprintf("%s_1", vpkgver); vpkgver = tmp; } - iter2 = prop_array_iterator(rundeps); + iter2 = xbps_array_iterator(rundeps); assert(iter2); - while ((obj2 = prop_object_iterator_next(iter2))) { - pkgpattern = prop_string_cstring_nocopy(obj2); + while ((obj2 = xbps_object_iterator_next(iter2))) { + pkgpattern = xbps_string_cstring_nocopy(obj2); if (xbps_pkgpattern_match(vpkgver, pkgpattern)) { if (tmp != NULL) free(tmp); - prop_object_iterator_release(iter2); - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter2); + xbps_object_iterator_release(iter); return true; } } - prop_object_iterator_release(iter2); + xbps_object_iterator_release(iter2); if (tmp != NULL) free(tmp); } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return false; } 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; - prop_object_t obj; + xbps_object_iterator_t iter; + xbps_object_t obj; const char *pkgdep; char *curpkgname, *tmp; bool found = false; - assert(prop_object_type(array) == PROP_TYPE_ARRAY); + assert(xbps_object_type(array) == XBPS_TYPE_ARRAY); assert(str != NULL); - iter = prop_array_iterator(array); + iter = xbps_array_iterator(array); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { + while ((obj = xbps_object_iterator_next(iter))) { tmp = NULL; if (mode == 0) { /* match by string */ - if (prop_string_equals_cstring(obj, str)) { + if (xbps_string_equals_cstring(obj, str)) { found = true; break; } } else if (mode == 1) { /* match by pkgname */ - pkgdep = prop_string_cstring_nocopy(obj); + pkgdep = xbps_string_cstring_nocopy(obj); if (strchr(pkgdep, '_') == NULL) { tmp = xbps_xasprintf("%s_1", pkgdep); curpkgname = xbps_pkg_name(tmp); @@ -145,7 +145,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode) free(curpkgname); } else if (mode == 2) { /* match pkgpattern against pkgdep */ - pkgdep = prop_string_cstring_nocopy(obj); + pkgdep = xbps_string_cstring_nocopy(obj); if (strchr(pkgdep, '_') == NULL) { tmp = xbps_xasprintf("%s_1", pkgdep); pkgdep = tmp; @@ -161,7 +161,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode) } else if (mode == 3) { /* match pkgdep against pkgpattern */ - pkgdep = prop_string_cstring_nocopy(obj); + pkgdep = xbps_string_cstring_nocopy(obj); if (strchr(pkgdep, '_') == NULL) { tmp = xbps_xasprintf("%s_1", pkgdep); pkgdep = tmp; @@ -176,31 +176,31 @@ match_string_in_array(prop_array_t array, const char *str, int mode) free(tmp); } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return found; } 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); } 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); } 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); } 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); } diff --git a/lib/plist_remove.c b/lib/plist_remove.c index 766b8e43..5ec65a59 100644 --- a/lib/plist_remove.c +++ b/lib/plist_remove.c @@ -32,31 +32,31 @@ #include "xbps_api_impl.h" 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; - prop_object_t obj; + xbps_object_iterator_t iter; + xbps_object_t obj; const char *curname, *pkgdep; char *curpkgname; unsigned int idx = 0; 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) return false; - while ((obj = prop_object_iterator_next(iter))) { + while ((obj = xbps_object_iterator_next(iter))) { if (mode == 0) { /* exact match, obj is a string */ - if (prop_string_equals_cstring(obj, str)) { + if (xbps_string_equals_cstring(obj, str)) { found = true; break; } } else if (mode == 1) { /* match by pkgname, obj is a string */ - pkgdep = prop_string_cstring_nocopy(obj); + pkgdep = xbps_string_cstring_nocopy(obj); curpkgname = xbps_pkg_name(pkgdep); if (curpkgname == NULL) break; @@ -68,7 +68,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode) free(curpkgname); } else if (mode == 2) { /* match by pkgname, obj is a dictionary */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &curname); if (strcmp(curname, str) == 0) { found = true; @@ -76,7 +76,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode) } } else if (mode == 3) { /* match by pkgver, obj is a dictionary */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &curname); if (strcmp(curname, str) == 0) { found = true; @@ -84,7 +84,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode) } } else if (mode == 4) { /* match by pattern, obj is a dictionary */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &curname); if (xbps_pkgpattern_match(curname, str)) { found = true; @@ -93,43 +93,43 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode) } idx++; } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); if (!found) { errno = ENOENT; return false; } - prop_array_remove(array, idx); + xbps_array_remove(array, idx); return true; } 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); } 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); } 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); } 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); } 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); } diff --git a/lib/portableproplib/prop_object.c b/lib/portableproplib/prop_object.c index ec764530..ae2105a0 100644 --- a/lib/portableproplib/prop_object.c +++ b/lib/portableproplib/prop_object.c @@ -29,6 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "prop_object_impl.h" @@ -834,7 +838,7 @@ _prop_object_externalize_write_file(const char *fname, const char *xml, return (false); } #else - otname = strncat(tname, "/.plistXXXXXX", sizeof(tname)); + otname = strncat(tname, "/.plistXXXXXX", sizeof(tname) - strlen(tname) - 1); if (sizeof(*otname) >= sizeof(tname)) { errno = ENAMETOOLONG; diff --git a/lib/proplib_wrapper.c b/lib/proplib_wrapper.c new file mode 100644 index 00000000..dfbdfd62 --- /dev/null +++ b/lib/proplib_wrapper.c @@ -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 +#include +#include +#include +#include + +#include "xbps_api_impl.h" +#include + +/* 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); +} diff --git a/lib/repo.c b/lib/repo.c index 1b29dcdb..28b8e5ae 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -94,10 +94,10 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url) return repo; } -prop_dictionary_t +xbps_dictionary_t xbps_repo_get_plist(struct xbps_repo *repo, const char *file) { - prop_dictionary_t d; + xbps_dictionary_t d; struct archive_entry *entry; void *buf; size_t buflen; @@ -123,7 +123,7 @@ xbps_repo_get_plist(struct xbps_repo *repo, const char *file) free(buf); return NULL; } - d = prop_dictionary_internalize(buf); + d = xbps_dictionary_internalize(buf); free(buf); return d; } @@ -138,51 +138,51 @@ xbps_repo_close(struct xbps_repo *repo) assert(repo); archive_read_free(repo->ar); - if (prop_object_type(repo->idx) == PROP_TYPE_DICTIONARY) - prop_object_release(repo->idx); - if (prop_object_type(repo->idxfiles) == PROP_TYPE_DICTIONARY) - prop_object_release(repo->idxfiles); + if (xbps_object_type(repo->idx) == XBPS_TYPE_DICTIONARY) + xbps_object_release(repo->idx); + if (xbps_object_type(repo->idxfiles) == XBPS_TYPE_DICTIONARY) + xbps_object_release(repo->idxfiles); free(repo); } -prop_dictionary_t +xbps_dictionary_t xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; assert(repo); assert(repo->ar); 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); assert(repo->idx); } pkgd = xbps_find_virtualpkg_in_dict(repo->xhp, repo->idx, pkg); if (pkgd) { - prop_dictionary_set_cstring_nocopy(pkgd, + xbps_dictionary_set_cstring_nocopy(pkgd, "repository", repo->uri); return pkgd; } return NULL; } -prop_dictionary_t +xbps_dictionary_t xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg) { - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; assert(repo); assert(repo->ar); 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); assert(repo->idx); } pkgd = xbps_find_pkg_in_dict(repo->idx, pkg); if (pkgd) { - prop_dictionary_set_cstring_nocopy(pkgd, + xbps_dictionary_set_cstring_nocopy(pkgd, "repository", repo->uri); return pkgd; } @@ -190,11 +190,11 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg) return NULL; } -prop_dictionary_t -xbps_repo_get_pkg_plist(struct xbps_handle *xhp, prop_dictionary_t pkgd, +xbps_dictionary_t +xbps_repo_get_pkg_plist(struct xbps_handle *xhp, xbps_dictionary_t pkgd, const char *plist) { - prop_dictionary_t bpkgd; + xbps_dictionary_t bpkgd; char *url; 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; } -static prop_array_t -revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str) +static xbps_array_t +revdeps_match(struct xbps_repo *repo, xbps_dictionary_t tpkgd, const char *str) { - prop_dictionary_t pkgd; - prop_array_t revdeps = NULL, pkgdeps, provides; - prop_object_iterator_t iter; - prop_object_t obj; + xbps_dictionary_t pkgd; + xbps_array_t revdeps = NULL, pkgdeps, provides; + xbps_object_iterator_t iter; + xbps_object_t obj; const char *pkgver, *tpkgver, *arch, *vpkg; char *buf; unsigned int i; - iter = prop_dictionary_iterator(repo->idx); + iter = xbps_dictionary_iterator(repo->idx); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(repo->idx, obj); - if (prop_dictionary_equals(pkgd, tpkgd)) + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(repo->idx, obj); + if (xbps_dictionary_equals(pkgd, tpkgd)) continue; - pkgdeps = prop_dictionary_get(pkgd, "run_depends"); - if (!prop_array_count(pkgdeps)) + pkgdeps = xbps_dictionary_get(pkgd, "run_depends"); + if (!xbps_array_count(pkgdeps)) continue; /* * 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 (!xbps_match_pkgdep_in_array(pkgdeps, str)) continue; - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); if (!xbps_pkg_arch_match(repo->xhp, arch, NULL)) continue; - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver); /* match */ if (revdeps == NULL) - revdeps = prop_array_create(); + revdeps = xbps_array_create(); if (!xbps_match_string_in_array(revdeps, tpkgver)) - prop_array_add_cstring_nocopy(revdeps, tpkgver); + xbps_array_add_cstring_nocopy(revdeps, tpkgver); continue; } /* * Try to match any virtual package. */ - provides = prop_dictionary_get(tpkgd, "provides"); - for (i = 0; i < prop_array_count(provides); i++) { - prop_array_get_cstring_nocopy(provides, i, &vpkg); + provides = xbps_dictionary_get(tpkgd, "provides"); + for (i = 0; i < xbps_array_count(provides); i++) { + xbps_array_get_cstring_nocopy(provides, i, &vpkg); if (strchr(vpkg, '_') == NULL) buf = xbps_xasprintf("%s_1", vpkg); else @@ -266,49 +266,49 @@ revdeps_match(struct xbps_repo *repo, prop_dictionary_t tpkgd, const char *str) continue; } free(buf); - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); if (!xbps_pkg_arch_match(repo->xhp, arch, NULL)) continue; - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver); /* match */ if (revdeps == NULL) - revdeps = prop_array_create(); + revdeps = xbps_array_create(); 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. */ - prop_dictionary_get_cstring_nocopy(tpkgd, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(tpkgd, "pkgver", &pkgver); if (!xbps_match_pkgdep_in_array(pkgdeps, pkgver)) continue; - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); if (!xbps_pkg_arch_match(repo->xhp, arch, NULL)) continue; - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &tpkgver); /* match */ if (revdeps == NULL) - revdeps = prop_array_create(); + revdeps = xbps_array_create(); 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; } -prop_array_t +xbps_array_t xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg) { - prop_array_t revdeps = NULL, vdeps = NULL; - prop_dictionary_t pkgd; + xbps_array_t revdeps = NULL, vdeps = NULL; + xbps_dictionary_t pkgd; const char *vpkg; char *buf = NULL; 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 ((vdeps = prop_dictionary_get(pkgd, "provides"))) { - for (i = 0; i < prop_array_count(vdeps); i++) { + if ((vdeps = xbps_dictionary_get(pkgd, "provides"))) { + for (i = 0; i < xbps_array_count(vdeps); i++) { char *vpkgn; - prop_array_get_cstring_nocopy(vdeps, i, &vpkg); + xbps_array_get_cstring_nocopy(vdeps, i, &vpkg); if (strchr(vpkg, '_') == NULL) buf = xbps_xasprintf("%s_1", vpkg); else @@ -346,7 +346,7 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg) free(buf); } } - if (!prop_array_count(revdeps)) + if (!xbps_array_count(revdeps)) revdeps = revdeps_match(repo, pkgd, NULL); return revdeps; diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index df17b530..4917c139 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -32,8 +32,8 @@ static int store_dependency(struct xbps_handle *xhp, - prop_array_t unsorted, - prop_dictionary_t repo_pkgd, + xbps_array_t unsorted, + xbps_dictionary_t repo_pkgd, pkg_state_t repo_pkg_state) { int rv; @@ -46,12 +46,12 @@ store_dependency(struct xbps_handle *xhp, /* * 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; /* * 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"); return 0; @@ -60,10 +60,10 @@ store_dependency(struct xbps_handle *xhp, static int add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg) { - prop_array_t mdeps; - prop_string_t reqpkg_str; - prop_object_iterator_t iter = NULL; - prop_object_t obj; + xbps_array_t mdeps; + xbps_string_t reqpkg_str; + xbps_object_iterator_t iter = NULL; + xbps_object_t obj; unsigned int idx = 0; bool add_pkgdep, pkgfound, update_pkgdep; int rv = 0; @@ -71,22 +71,22 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg) assert(reqpkg != NULL); 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) return errno; - iter = prop_array_iterator(mdeps); + iter = xbps_array_iterator(mdeps); if (iter == NULL) goto out; - while ((obj = prop_object_iterator_next(iter)) != NULL) { + while ((obj = xbps_object_iterator_next(iter)) != NULL) { const char *curdep, *curver, *pkgver; char *curpkgnamedep = NULL, *pkgnamedep = NULL; - assert(prop_object_type(obj) == PROP_TYPE_STRING); - curdep = prop_string_cstring_nocopy(obj); + assert(xbps_object_type(obj) == XBPS_TYPE_STRING); + curdep = xbps_string_cstring_nocopy(obj); curver = xbps_pkgpattern_version(curdep); pkgver = xbps_pkgpattern_version(reqpkg); if (curver == NULL || pkgver == NULL) @@ -132,11 +132,11 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg) add_pkgdep = true; out: if (iter) - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); if (update_pkgdep) - prop_array_remove(mdeps, idx); + xbps_array_remove(mdeps, idx); if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) { - prop_object_release(reqpkg_str); + xbps_object_release(reqpkg_str); return errno; } @@ -147,15 +147,15 @@ out: static int find_repo_deps(struct xbps_handle *xhp, - prop_array_t unsorted, /* array of unsorted deps */ - prop_array_t pkg_rdeps_array, /* current pkg rundeps array */ + xbps_array_t unsorted, /* array of unsorted deps */ + xbps_array_t pkg_rdeps_array, /* current pkg rundeps array */ const char *curpkg, /* current pkgver */ unsigned short *depth) /* max recursion depth */ { - prop_dictionary_t curpkgd, tmpd; - prop_object_t obj; - prop_object_iterator_t iter; - prop_array_t curpkgrdeps; + xbps_dictionary_t curpkgd, tmpd; + xbps_object_t obj; + xbps_object_iterator_t iter; + xbps_array_t curpkgrdeps; pkg_state_t state; unsigned int x; 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 * current package. */ - iter = prop_array_iterator(pkg_rdeps_array); + iter = xbps_array_iterator(pkg_rdeps_array); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - reqpkg = prop_string_cstring_nocopy(obj); + while ((obj = xbps_object_iterator_next(iter))) { + reqpkg = xbps_string_cstring_nocopy(obj); if (xhp->flags & XBPS_FLAG_DEBUG) { xbps_dbg_printf(xhp, ""); for (x = 0; x < *depth; x++) @@ -213,7 +213,7 @@ find_repo_deps(struct xbps_handle *xhp, * Check if installed version matches the * required pkgdep version. */ - prop_dictionary_get_cstring_nocopy(tmpd, + xbps_dictionary_get_cstring_nocopy(tmpd, "pkgver", &pkgver_q); /* Check its state */ @@ -277,7 +277,7 @@ find_repo_deps(struct xbps_handle *xhp, */ if ((curpkgd = xbps_find_pkg_in_array(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); xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q); continue; @@ -315,7 +315,7 @@ find_repo_deps(struct xbps_handle *xhp, continue; } } - prop_dictionary_get_cstring_nocopy(curpkgd, + xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q); reqpkgname = xbps_pkg_name(pkgver_q); assert(reqpkgname); @@ -342,7 +342,7 @@ find_repo_deps(struct xbps_handle *xhp, /* * 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); if (rv != 0) { 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. */ - curpkgrdeps = prop_dictionary_get(curpkgd, "run_depends"); + curpkgrdeps = xbps_dictionary_get(curpkgd, "run_depends"); if (curpkgrdeps == NULL) continue; @@ -376,7 +376,7 @@ find_repo_deps(struct xbps_handle *xhp, break; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); (*depth)--; return rv; @@ -384,18 +384,18 @@ find_repo_deps(struct xbps_handle *xhp, int HIDDEN xbps_repository_find_deps(struct xbps_handle *xhp, - prop_array_t unsorted, - prop_dictionary_t repo_pkgd) + xbps_array_t unsorted, + xbps_dictionary_t repo_pkgd) { - prop_array_t pkg_rdeps; + xbps_array_t pkg_rdeps; const char *pkgver; unsigned short depth = 0; - pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends"); - if (prop_array_count(pkg_rdeps) == 0) + pkg_rdeps = xbps_dictionary_get(repo_pkgd, "run_depends"); + if (xbps_array_count(pkg_rdeps) == 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); /* * This will find direct and indirect deps, if any of them is not diff --git a/lib/rpool_get.c b/lib/rpool_get.c index 08905c7f..18c63af5 100644 --- a/lib/rpool_get.c +++ b/lib/rpool_get.c @@ -37,8 +37,8 @@ * @defgroup repopool Repository pool functions */ struct rpool_fpkg { - prop_array_t revdeps; - prop_dictionary_t pkgd; + xbps_array_t revdeps; + xbps_dictionary_t pkgd; const char *pattern; const char *bestpkgver; bool best; @@ -78,22 +78,22 @@ static int find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done) { struct rpool_fpkg *rpf = arg; - prop_array_t revdeps = NULL; + xbps_array_t revdeps = NULL; const char *pkgver; unsigned int i; (void)done; revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern); - if (prop_array_count(revdeps)) { + if (xbps_array_count(revdeps)) { /* found */ if (rpf->revdeps == NULL) - rpf->revdeps = prop_array_create(); - for (i = 0; i < prop_array_count(revdeps); i++) { - prop_array_get_cstring_nocopy(revdeps, i, &pkgver); - prop_array_add_cstring_nocopy(rpf->revdeps, pkgver); + rpf->revdeps = xbps_array_create(); + for (i = 0; i < xbps_array_count(revdeps); i++) { + xbps_array_get_cstring_nocopy(revdeps, i, &pkgver); + xbps_array_add_cstring_nocopy(rpf->revdeps, pkgver); } - prop_object_release(revdeps); + xbps_object_release(revdeps); } return 0; } @@ -102,7 +102,7 @@ static int find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done) { struct rpool_fpkg *rpf = arg; - prop_dictionary_t pkgd; + xbps_dictionary_t pkgd; const char *repopkgver; (void)done; @@ -117,14 +117,14 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done) "'%s'.\n", rpf->pattern, repo->uri); return 0; } - prop_dictionary_get_cstring_nocopy(pkgd, + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &repopkgver); if (rpf->bestpkgver == NULL) { xbps_dbg_printf(repo->xhp, "[rpool] Found best match '%s' (%s).\n", repopkgver, repo->uri); rpf->pkgd = pkgd; - prop_dictionary_set_cstring_nocopy(rpf->pkgd, + xbps_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", repo->uri); rpf->bestpkgver = repopkgver; 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", repopkgver, repo->uri); rpf->pkgd = pkgd; - prop_dictionary_set_cstring_nocopy(rpf->pkgd, + xbps_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", repo->uri); rpf->bestpkgver = repopkgver; } @@ -152,7 +152,7 @@ typedef enum { REVDEPS_PKG } pkg_repo_type_t; -static prop_object_t +static xbps_object_t repo_find_pkg(struct xbps_handle *xhp, const char *pkg, pkg_repo_type_t type) @@ -200,7 +200,7 @@ repo_find_pkg(struct xbps_handle *xhp, return rpf.pkgd; } -prop_dictionary_t +xbps_dictionary_t xbps_rpool_get_virtualpkg(struct xbps_handle *xhp, const char *pkg) { 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); } -prop_dictionary_t +xbps_dictionary_t xbps_rpool_get_pkg(struct xbps_handle *xhp, const char *pkg) { 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); } -prop_array_t +xbps_array_t xbps_rpool_get_pkg_revdeps(struct xbps_handle *xhp, const char *pkg) { 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); } -prop_dictionary_t +xbps_dictionary_t xbps_rpool_get_pkg_plist(struct xbps_handle *xhp, const char *pkg, const char *plistf) { - prop_dictionary_t pkgd = NULL, plistd = NULL; + xbps_dictionary_t pkgd = NULL, plistd = NULL; const char *repo; char *url; @@ -261,8 +261,8 @@ xbps_rpool_get_pkg_plist(struct xbps_handle *xhp, } plistd = xbps_get_pkg_plist_from_binpkg(url, plistf); if (plistd) { - prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repo); - prop_dictionary_set_cstring_nocopy(plistd, "repository", repo); + xbps_dictionary_get_cstring_nocopy(pkgd, "repository", &repo); + xbps_dictionary_set_cstring_nocopy(plistd, "repository", repo); } free(url); diff --git a/lib/transaction_commit.c b/lib/transaction_commit.c index 09d41a66..5acc25d9 100644 --- a/lib/transaction_commit.c +++ b/lib/transaction_commit.c @@ -56,23 +56,23 @@ */ 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; char *binfile, *filen; int rv = 0; - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans); + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans); if ((strcmp(trans, "remove") == 0) || (strcmp(trans, "configure") == 0)) continue; - prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); - prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch); + xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "filename-sha256", &sha256); 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(filen); } - prop_object_iterator_reset(iter); + xbps_object_iterator_reset(iter); return rv; } 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; char *binfile, *filen; int rv = 0; bool state_dload = false; - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans); + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &trans); if ((strcmp(trans, "remove") == 0) || (strcmp(trans, "configure") == 0)) continue; - prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); - prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch); + xbps_dictionary_get_cstring_nocopy(obj, "repository", &repoloc); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); binfile = xbps_repository_pkg_path(xhp, obj); if (binfile == NULL) { @@ -188,7 +188,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter) free(binfile); free(filen); } - prop_object_iterator_reset(iter); + xbps_object_iterator_reset(iter); return rv; } @@ -196,13 +196,13 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter) int xbps_transaction_commit(struct xbps_handle *xhp) { - prop_object_t obj; - prop_object_iterator_t iter; + xbps_object_t obj; + xbps_object_iterator_t iter; const char *pkgver, *tract; int rv = 0; 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; 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); - while ((obj = prop_object_iterator_next(iter)) != NULL) { + while ((obj = xbps_object_iterator_next(iter)) != NULL) { update = false; - prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); if (strcmp(tract, "remove") == 0) { update = false; @@ -236,9 +236,9 @@ xbps_transaction_commit(struct xbps_handle *xhp) /* * Remove package. */ - prop_dictionary_get_bool(obj, "remove-and-update", + xbps_dictionary_get_bool(obj, "remove-and-update", &update); - prop_dictionary_get_bool(obj, "softreplace", &sr); + xbps_dictionary_get_bool(obj, "softreplace", &sr); rv = xbps_remove_pkg(xhp, pkgver, update, sr); if (rv != 0) { 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)) goto out; - prop_object_iterator_reset(iter); + xbps_object_iterator_reset(iter); /* * Configure all unpacked packages. */ xbps_set_cb_state(xhp, XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL); - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract); if ((strcmp(tract, "remove") == 0) || (strcmp(tract, "configure") == 0)) continue; - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); update = false; if (strcmp(tract, "update") == 0) update = true; @@ -341,7 +341,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) } out: - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return rv; } diff --git a/lib/transaction_dictionary.c b/lib/transaction_dictionary.c index 9aa5e72f..30a7e051 100644 --- a/lib/transaction_dictionary.c +++ b/lib/transaction_dictionary.c @@ -55,9 +55,9 @@ static int compute_transaction_stats(struct xbps_handle *xhp) { - prop_dictionary_t pkg_metad; - prop_object_iterator_t iter; - prop_object_t obj; + xbps_dictionary_t pkg_metad; + xbps_object_iterator_t iter; + xbps_object_t obj; uint64_t tsize, dlsize, instsize, rmsize; uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt; int rv = 0; @@ -70,14 +70,14 @@ compute_transaction_stats(struct xbps_handle *xhp) if (iter == NULL) 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, * installed and updated. */ - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); - prop_dictionary_get_cstring_nocopy(obj, "repository", &repo); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract); + xbps_dictionary_get_cstring_nocopy(obj, "repository", &repo); if (strcmp(tract, "configure") == 0) { cf_pkgcnt++; @@ -105,17 +105,17 @@ compute_transaction_stats(struct xbps_handle *xhp) free(pkgname); if (pkg_metad == NULL) continue; - prop_dictionary_get_uint64(pkg_metad, + xbps_dictionary_get_uint64(pkg_metad, "installed_size", &tsize); rmsize += tsize; } if ((strcmp(tract, "install") == 0) || (strcmp(tract, "update") == 0)) { - prop_dictionary_get_uint64(obj, + xbps_dictionary_get_uint64(obj, "installed_size", &tsize); instsize += tsize; if (xbps_repository_is_remote(repo)) { - prop_dictionary_get_uint64(obj, + xbps_dictionary_get_uint64(obj, "filename-size", &tsize); dlsize += tsize; } @@ -123,25 +123,25 @@ compute_transaction_stats(struct xbps_handle *xhp) } if (inst_pkgcnt && - !prop_dictionary_set_uint32(xhp->transd, "total-install-pkgs", + !xbps_dictionary_set_uint32(xhp->transd, "total-install-pkgs", inst_pkgcnt)) { rv = EINVAL; goto out; } if (up_pkgcnt && - !prop_dictionary_set_uint32(xhp->transd, "total-update-pkgs", + !xbps_dictionary_set_uint32(xhp->transd, "total-update-pkgs", up_pkgcnt)) { rv = EINVAL; goto out; } if (cf_pkgcnt && - !prop_dictionary_set_uint32(xhp->transd, "total-configure-pkgs", + !xbps_dictionary_set_uint32(xhp->transd, "total-configure-pkgs", cf_pkgcnt)) { rv = EINVAL; goto out; } if (rm_pkgcnt && - !prop_dictionary_set_uint32(xhp->transd, "total-remove-pkgs", + !xbps_dictionary_set_uint32(xhp->transd, "total-remove-pkgs", rm_pkgcnt)) { rv = EINVAL; goto out; @@ -160,7 +160,7 @@ compute_transaction_stats(struct xbps_handle *xhp) * Add object in transaction dictionary with total installed * size that it will take. */ - if (!prop_dictionary_set_uint64(xhp->transd, + if (!xbps_dictionary_set_uint64(xhp->transd, "total-installed-size", instsize)) { rv = EINVAL; goto out; @@ -169,7 +169,7 @@ compute_transaction_stats(struct xbps_handle *xhp) * Add object in transaction dictionary with total download * 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)) { rv = EINVAL; goto out; @@ -178,13 +178,13 @@ compute_transaction_stats(struct xbps_handle *xhp) * Add object in transaction dictionary with total size to be * freed from packages to be removed. */ - if (!prop_dictionary_set_uint64(xhp->transd, + if (!xbps_dictionary_set_uint64(xhp->transd, "total-removed-size", rmsize)) { rv = EINVAL; goto out; } out: - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return rv; } @@ -192,41 +192,41 @@ out: int HIDDEN xbps_transaction_init(struct xbps_handle *xhp) { - prop_array_t unsorted, mdeps, conflicts; + xbps_array_t unsorted, mdeps, conflicts; if (xhp->transd != NULL) return 0; - if ((xhp->transd = prop_dictionary_create()) == NULL) + if ((xhp->transd = xbps_dictionary_create()) == NULL) return ENOMEM; - if ((unsorted = prop_array_create()) == NULL) { - prop_object_release(xhp->transd); + if ((unsorted = xbps_array_create()) == NULL) { + xbps_object_release(xhp->transd); xhp->transd = NULL; return ENOMEM; } if (!xbps_add_obj_to_dict(xhp->transd, unsorted, "unsorted_deps")) { - prop_object_release(xhp->transd); + xbps_object_release(xhp->transd); xhp->transd = NULL; return EINVAL; } - if ((mdeps = prop_array_create()) == NULL) { - prop_object_release(xhp->transd); + if ((mdeps = xbps_array_create()) == NULL) { + xbps_object_release(xhp->transd); xhp->transd = NULL; return ENOMEM; } if (!xbps_add_obj_to_dict(xhp->transd, mdeps, "missing_deps")) { - prop_object_release(xhp->transd); + xbps_object_release(xhp->transd); xhp->transd = NULL; return EINVAL; } - if ((conflicts = prop_array_create()) == NULL) { - prop_object_release(xhp->transd); + if ((conflicts = xbps_array_create()) == NULL) { + xbps_object_release(xhp->transd); xhp->transd = NULL; return ENOMEM; } if (!xbps_add_obj_to_dict(xhp->transd, conflicts, "conflicts")) { - prop_object_release(xhp->transd); + xbps_object_release(xhp->transd); xhp->transd = NULL; return EINVAL; } @@ -237,7 +237,7 @@ xbps_transaction_init(struct xbps_handle *xhp) int xbps_transaction_prepare(struct xbps_handle *xhp) { - prop_array_t mdeps, conflicts; + xbps_array_t mdeps, conflicts; int rv = 0; if (xhp->transd == NULL) @@ -246,22 +246,22 @@ xbps_transaction_prepare(struct xbps_handle *xhp) /* * If there are missing deps bail out. */ - mdeps = prop_dictionary_get(xhp->transd, "missing_deps"); - if (prop_array_count(mdeps) > 0) + mdeps = xbps_dictionary_get(xhp->transd, "missing_deps"); + if (xbps_array_count(mdeps) > 0) return ENODEV; /* * If there are package conflicts bail out. */ - conflicts = prop_dictionary_get(xhp->transd, "conflicts"); - if (prop_array_count(conflicts) > 0) + conflicts = xbps_dictionary_get(xhp->transd, "conflicts"); + if (xbps_array_count(conflicts) > 0) return EAGAIN; /* * Check for packages to be replaced. */ if ((rv = xbps_transaction_package_replace(xhp)) != 0) { - prop_object_release(xhp->transd); + xbps_object_release(xhp->transd); xhp->transd = NULL; return rv; } @@ -269,7 +269,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) * Sort package dependencies if necessary. */ if ((rv = xbps_transaction_sort(xhp)) != 0) { - prop_object_release(xhp->transd); + xbps_object_release(xhp->transd); xhp->transd = NULL; return rv; } @@ -279,16 +279,16 @@ xbps_transaction_prepare(struct xbps_handle *xhp) * and removed to the transaction dictionary. */ if ((rv = compute_transaction_stats(xhp)) != 0) { - prop_object_release(xhp->transd); + xbps_object_release(xhp->transd); xhp->transd = NULL; return rv; } /* * The missing deps and conflicts arrays are not necessary anymore. */ - prop_dictionary_remove(xhp->transd, "missing_deps"); - prop_dictionary_remove(xhp->transd, "conflicts"); - prop_dictionary_make_immutable(xhp->transd); + xbps_dictionary_remove(xhp->transd, "missing_deps"); + xbps_dictionary_remove(xhp->transd, "conflicts"); + xbps_dictionary_make_immutable(xhp->transd); return 0; } diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index a9d6487f..d96d2df3 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -60,8 +60,8 @@ enum { static int trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action) { - prop_dictionary_t pkg_pkgdb = NULL, pkg_repod; - prop_array_t unsorted; + xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod; + xbps_array_t unsorted; const char *repoloc, *repopkgver, *instpkgver, *reason; char *pkgname; int rv = 0; @@ -90,14 +90,14 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action) return ENOENT; } } - prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); - prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc); + xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); + xbps_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc); if (action == TRANS_UPDATE) { /* * 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); if (xbps_cmpver(repopkgver, instpkgver) <= 0) { 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; } /* respect current install mode from pkgdb */ - prop_dictionary_get_bool(pkg_pkgdb, "automatic-install", + xbps_dictionary_get_bool(pkg_pkgdb, "automatic-install", &autoinst); - prop_dictionary_set_bool(pkg_repod, "automatic-install", + xbps_dictionary_set_bool(pkg_repod, "automatic-install", autoinst); } /* @@ -117,7 +117,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action) if ((rv = xbps_transaction_init(xhp)) != 0) 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. */ @@ -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" * or "update". */ - if (!prop_dictionary_set_cstring_nocopy(pkg_repod, + if (!xbps_dictionary_set_cstring_nocopy(pkg_repod, "transaction", reason)) 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 * the "unsorted" queue. */ - if (!prop_array_add(unsorted, pkg_repod)) + if (!xbps_array_add(unsorted, pkg_repod)) return EINVAL; 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 xbps_transaction_update_packages(struct xbps_handle *xhp) { - prop_dictionary_t pkgd; - prop_object_t obj; - prop_object_iterator_t iter; + xbps_dictionary_t pkgd; + xbps_object_t obj; + xbps_object_iterator_t iter; const char *pkgver, *holdpkg; char *pkgname; 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) return rv; - iter = prop_dictionary_iterator(xhp->pkgdb); + iter = xbps_dictionary_iterator(xhp->pkgdb); assert(iter); - while ((obj = prop_object_iterator_next(iter))) { - pkgd = prop_dictionary_get_keysym(xhp->pkgdb, obj); - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + while ((obj = xbps_object_iterator_next(iter))) { + pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); pkgname = xbps_pkg_name(pkgver); assert(pkgname); @@ -233,7 +233,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp) } free(pkgname); } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); return newpkg_found ? rv : EEXIST; } @@ -248,7 +248,7 @@ int xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall) { - prop_dictionary_t pkgd = NULL; + xbps_dictionary_t pkgd = NULL; pkg_state_t state; if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkg)) || @@ -269,9 +269,9 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive) { - prop_dictionary_t pkgd; - prop_array_t unsorted, orphans, orphans_pkg, reqby; - prop_object_t obj; + xbps_dictionary_t pkgd; + xbps_array_t unsorted, orphans, orphans_pkg, reqby; + xbps_object_t obj; const char *pkgver; unsigned int count; int rv = 0; @@ -288,7 +288,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp, if ((rv = xbps_transaction_init(xhp)) != 0) return rv; - unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); + unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps"); if (!recursive) 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 the supplied package were already removed. */ - if ((orphans_pkg = prop_array_create()) == NULL) + if ((orphans_pkg = xbps_array_create()) == NULL) 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); - prop_object_release(orphans_pkg); - if (prop_object_type(orphans) != PROP_TYPE_ARRAY) + xbps_object_release(orphans_pkg); + if (xbps_object_type(orphans) != XBPS_TYPE_ARRAY) return EINVAL; - count = prop_array_count(orphans); + count = xbps_array_count(orphans); while (count--) { - obj = prop_array_get(orphans, count); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_set_cstring_nocopy(obj, "transaction", "remove"); - prop_array_add(unsorted, obj); + obj = xbps_array_get(orphans, count); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_set_cstring_nocopy(obj, "transaction", "remove"); + xbps_array_add(unsorted, obj); xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver); } 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 * of this to take appropiate action. */ - if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) && - (prop_array_count(reqby) > 0)) + if ((xbps_object_type(reqby) == XBPS_TYPE_ARRAY) && + (xbps_array_count(reqby) > 0)) rv = EEXIST; - prop_object_release(orphans); + xbps_object_release(orphans); return rv; rmpkg: /* * Add pkg dictionary into the transaction unsorted queue. */ - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); - prop_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove"); - prop_array_add(unsorted, pkgd); + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + xbps_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove"); + xbps_array_add(unsorted, pkgd); xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver); /* * If target pkg is required by any installed pkg, the client must be aware * of this to take appropiate action. */ - if ((prop_object_type(reqby) == PROP_TYPE_ARRAY) && - (prop_array_count(reqby) > 0)) + if ((xbps_object_type(reqby) == XBPS_TYPE_ARRAY) && + (xbps_array_count(reqby) > 0)) rv = EEXIST; return rv; @@ -348,14 +348,14 @@ rmpkg: int xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp) { - prop_array_t orphans, unsorted; - prop_object_t obj; + xbps_array_t orphans, unsorted; + xbps_object_t obj; const char *pkgver; unsigned int count; int rv = 0; 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 */ rv = ENOENT; goto out; @@ -366,21 +366,21 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp) if ((rv = xbps_transaction_init(xhp)) != 0) 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. */ while (count--) { - obj = prop_array_get(orphans, count); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_set_cstring_nocopy(obj, + obj = xbps_array_get(orphans, count); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_set_cstring_nocopy(obj, "transaction", "remove"); - prop_array_add(unsorted, obj); + xbps_array_add(unsorted, obj); xbps_dbg_printf(xhp, "%s: added (remove).\n", pkgver); } out: if (orphans != NULL) - prop_object_release(orphans); + xbps_object_release(orphans); return rv; } diff --git a/lib/transaction_package_replace.c b/lib/transaction_package_replace.c index 2a4bbb01..6bdaadda 100644 --- a/lib/transaction_package_replace.c +++ b/lib/transaction_package_replace.c @@ -36,28 +36,28 @@ int HIDDEN xbps_transaction_package_replace(struct xbps_handle *xhp) { - prop_array_t replaces, unsorted; - prop_dictionary_t instd, reppkgd, filesd; - prop_object_t obj, obj2; - prop_object_iterator_t iter; + xbps_array_t replaces, unsorted; + xbps_dictionary_t instd, reppkgd, filesd; + xbps_object_t obj, obj2; + xbps_object_iterator_t iter; const char *pattern, *pkgver, *curpkgver; char *buf, *pkgname, *curpkgname; bool instd_auto, sr; 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++) { - obj = prop_array_get(unsorted, i); - replaces = prop_dictionary_get(obj, "replaces"); - if (replaces == NULL || prop_array_count(replaces) == 0) + for (i = 0; i < xbps_array_count(unsorted); i++) { + obj = xbps_array_get(unsorted, i); + replaces = xbps_dictionary_get(obj, "replaces"); + if (replaces == NULL || xbps_array_count(replaces) == 0) continue; - iter = prop_array_iterator(replaces); + iter = xbps_array_iterator(replaces); assert(iter); - while ((obj2 = prop_object_iterator_next(iter)) != NULL) { - pattern = prop_string_cstring_nocopy(obj2); + while ((obj2 = xbps_object_iterator_next(iter)) != NULL) { + pattern = xbps_string_cstring_nocopy(obj2); /* * Find the installed package that matches the pattern * to be replaced. @@ -66,9 +66,9 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) ((instd = xbps_pkgdb_get_virtualpkg(xhp, pattern)) == NULL)) continue; - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(instd, + xbps_dictionary_get_cstring_nocopy(instd, "pkgver", &curpkgver); pkgname = xbps_pkg_name(pkgver); assert(pkgname); @@ -88,7 +88,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) "Package `%s' will be replaced by `%s', " "matched with `%s'\n", curpkgver, pkgver, pattern); instd_auto = false; - prop_dictionary_get_bool(instd, + xbps_dictionary_get_bool(instd, "automatic-install", &instd_auto); /* * Package contains replaces="pkgpattern", but the @@ -99,11 +99,11 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) xbps_dbg_printf(xhp, "found replaced pkg " "in transaction\n"); - prop_dictionary_set_bool(instd, + xbps_dictionary_set_bool(instd, "remove-and-update", true); - prop_dictionary_set_bool(reppkgd, + xbps_dictionary_set_bool(reppkgd, "automatic-install", instd_auto); - prop_dictionary_set_bool(reppkgd, + xbps_dictionary_set_bool(reppkgd, "skip-obsoletes", true); xbps_array_replace_dict_by_name(unsorted, reppkgd, curpkgname); @@ -117,45 +117,45 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) pattern, true) || xbps_match_virtual_pkg_in_dict(instd, pkgname, false)) { - prop_dictionary_set_bool(obj, + xbps_dictionary_set_bool(obj, "automatic-install", instd_auto); } sr = false; - prop_dictionary_get_bool(obj, "softreplace", &sr); + xbps_dictionary_get_bool(obj, "softreplace", &sr); if (sr) { - prop_dictionary_set_bool(obj, + xbps_dictionary_set_bool(obj, "automatic-install", instd_auto); - prop_dictionary_set_bool(instd, + xbps_dictionary_set_bool(instd, "softreplace", true); buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, curpkgname); - filesd = prop_dictionary_internalize_from_file(buf); + filesd = xbps_dictionary_internalize_from_file(buf); free(buf); assert(filesd != NULL); buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname); - if (!prop_dictionary_externalize_to_file(filesd, buf)) { + if (!xbps_dictionary_externalize_to_file(filesd, buf)) { free(buf); - prop_object_release(filesd); - prop_object_iterator_release(iter); + xbps_object_release(filesd); + xbps_object_iterator_release(iter); free(pkgname); free(curpkgname); return errno; } - prop_object_release(filesd); + xbps_object_release(filesd); free(buf); } /* * Add package dictionary into the transaction and mark * it as to be "removed". */ - prop_dictionary_set_cstring_nocopy(instd, + xbps_dictionary_set_cstring_nocopy(instd, "transaction", "remove"); - prop_array_add(unsorted, instd); + xbps_array_add(unsorted, instd); free(pkgname); free(curpkgname); } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); } return 0; diff --git a/lib/transaction_sortdeps.c b/lib/transaction_sortdeps.c index 307a6542..9331b4aa 100644 --- a/lib/transaction_sortdeps.c +++ b/lib/transaction_sortdeps.c @@ -48,7 +48,7 @@ struct pkgdep { TAILQ_ENTRY(pkgdep) pkgdep_entries; - prop_dictionary_t d; + xbps_dictionary_t d; char *name; }; @@ -66,13 +66,13 @@ pkgdep_find(const char *pkg) /* ignore entries without dictionary */ continue; } - prop_dictionary_get_cstring_nocopy(pd->d, + xbps_dictionary_get_cstring_nocopy(pd->d, "transaction", &tract); /* ignore pkgs to be removed */ if (strcmp(tract, "remove") == 0) continue; /* 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) return pd; /* pkg expression match */ @@ -100,7 +100,7 @@ pkgdep_find_idx(const char *pkg) idx++; continue; } - prop_dictionary_get_cstring_nocopy(pd->d, + xbps_dictionary_get_cstring_nocopy(pd->d, "transaction", &tract); /* ignore pkgs to be removed */ if (strcmp(tract, "remove") == 0) { @@ -108,7 +108,7 @@ pkgdep_find_idx(const char *pkg) continue; } /* 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) return idx; /* pkg expression match */ @@ -132,7 +132,7 @@ pkgdep_release(struct pkgdep *pd) } static struct pkgdep * -pkgdep_alloc(prop_dictionary_t d, const char *pkg) +pkgdep_alloc(xbps_dictionary_t d, const char *pkg) { struct pkgdep *pd; @@ -145,14 +145,14 @@ pkgdep_alloc(prop_dictionary_t d, const char *pkg) } static void -pkgdep_end(prop_array_t sorted) +pkgdep_end(xbps_array_t sorted) { struct pkgdep *pd; while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) { TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries); if (sorted != NULL && pd->d != NULL) - prop_array_add(sorted, pd->d); + xbps_array_add(sorted, pd->d); pkgdep_release(pd); } @@ -161,10 +161,10 @@ pkgdep_end(prop_array_t sorted) static int sort_pkg_rundeps(struct xbps_handle *xhp, struct pkgdep *pd, - prop_array_t pkg_rundeps, - prop_array_t unsorted) + xbps_array_t pkg_rundeps, + xbps_array_t unsorted) { - prop_dictionary_t curpkgd; + xbps_dictionary_t curpkgd; struct pkgdep *lpd, *pdn; const char *str, *tract; int32_t pkgdepidx, curpkgidx; @@ -175,8 +175,8 @@ sort_pkg_rundeps(struct xbps_handle *xhp, curpkgidx = pkgdep_find_idx(pd->name); again: - for (i = idx; i < prop_array_count(pkg_rundeps); i++) { - prop_array_get_cstring_nocopy(pkg_rundeps, i, &str); + for (i = idx; i < xbps_array_count(pkg_rundeps); i++) { + xbps_array_get_cstring_nocopy(pkg_rundeps, i, &str); xbps_dbg_printf(xhp, " Required dependency '%s': ", str); pdn = pkgdep_find(str); @@ -210,7 +210,7 @@ again: "dependency %s (depends on itself)\n", str); continue; } - prop_dictionary_get_cstring_nocopy(curpkgd, + xbps_dictionary_get_cstring_nocopy(curpkgd, "transaction", &tract); lpd = pkgdep_alloc(curpkgd, str); @@ -255,48 +255,48 @@ again: int HIDDEN xbps_transaction_sort(struct xbps_handle *xhp) { - prop_array_t provides, sorted, unsorted, rundeps; - prop_object_t obj; + xbps_array_t provides, sorted, unsorted, rundeps; + xbps_object_t obj; struct pkgdep *pd; unsigned int i, j, ndeps = 0, cnt = 0; const char *pkgname, *pkgver, *tract, *vpkgdep; int rv = 0; bool vpkg_found; - if ((sorted = prop_array_create()) == NULL) + if ((sorted = xbps_array_create()) == NULL) return ENOMEM; /* * 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; goto out; } /* * All required deps are satisfied (already installed). */ - unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); - if (prop_array_count(unsorted) == 0) { - prop_dictionary_set(xhp->transd, "packages", sorted); - prop_object_release(sorted); + unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps"); + if (xbps_array_count(unsorted) == 0) { + xbps_dictionary_set(xhp->transd, "packages", sorted); + xbps_object_release(sorted); return 0; } /* * The sorted array should have the same capacity than * 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 * its package dependencies. */ for (i = 0; i < ndeps; i++) { vpkg_found = false; - obj = prop_array_get(unsorted, i); - prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); - provides = prop_dictionary_get(obj, "provides"); + obj = xbps_array_get(unsorted, i); + xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); + xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract); + provides = xbps_dictionary_get(obj, "provides"); xbps_dbg_printf(xhp, "Sorting package '%s' (%s): ", pkgver, tract); if (provides) { @@ -305,8 +305,8 @@ xbps_transaction_sort(struct xbps_handle *xhp) * if any of them was previously added. If true, don't * add it into the list again, just order its deps. */ - for (j = 0; j < prop_array_count(provides); j++) { - prop_array_get_cstring_nocopy(provides, + for (j = 0; j < xbps_array_count(provides); j++) { + xbps_array_get_cstring_nocopy(provides, j, &vpkgdep); pd = pkgdep_find(vpkgdep); if (pd != NULL) { @@ -343,8 +343,8 @@ xbps_transaction_sort(struct xbps_handle *xhp) * Packages that don't have deps go at head, because * it doesn't matter. */ - rundeps = prop_dictionary_get(obj, "run_depends"); - if (prop_array_count(rundeps) == 0) { + rundeps = xbps_dictionary_get(obj, "run_depends"); + if (xbps_array_count(rundeps) == 0) { xbps_dbg_printf_append(xhp, "\n"); cnt++; continue; @@ -368,17 +368,17 @@ xbps_transaction_sort(struct xbps_handle *xhp) * Sanity check that the array contains the same number of * 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 * temporary array with unsorted packages. */ - prop_dictionary_remove(xhp->transd, "unsorted_deps"); + xbps_dictionary_remove(xhp->transd, "unsorted_deps"); out: 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; } diff --git a/lib/util.c b/lib/util.c index f61c1ad5..f7bd1141 100644 --- a/lib/util.c +++ b/lib/util.c @@ -67,7 +67,7 @@ xbps_repository_is_remote(const char *uri) int xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg) { - prop_dictionary_t dict; + xbps_dictionary_t dict; pkg_state_t state; assert(xhp); @@ -172,21 +172,21 @@ xbps_pkgpattern_version(const char *pkg) } 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; char *lbinpkg = NULL; 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)) return NULL; - if (!prop_dictionary_get_cstring_nocopy(pkg_repod, + if (!xbps_dictionary_get_cstring_nocopy(pkg_repod, "architecture", &arch)) return NULL; - if (!prop_dictionary_get_cstring_nocopy(pkg_repod, + if (!xbps_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc)) return NULL; @@ -208,14 +208,14 @@ xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod) } 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"); - if (prop_array_count(array)) + array = xbps_dictionary_get(pkgd, "run_depends"); + if (xbps_array_count(array)) return true; return false; diff --git a/lib/util_hash.c b/lib/util_hash.c index 938a8563..777a95e9 100644 --- a/lib/util_hash.c +++ b/lib/util_hash.c @@ -140,13 +140,13 @@ xbps_file_hash_check(const char *file, const char *sha256) } 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; - prop_object_iterator_t iter; + xbps_object_t obj; + xbps_object_iterator_t iter; 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(file != NULL); @@ -155,17 +155,17 @@ file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file) errno = ENOENT; return NULL; } - while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, + while ((obj = xbps_object_iterator_next(iter)) != NULL) { + xbps_dictionary_get_cstring_nocopy(obj, "file", &curfile); if (strcmp(file, curfile) == 0) { /* file matched */ - prop_dictionary_get_cstring_nocopy(obj, + xbps_dictionary_get_cstring_nocopy(obj, "sha256", &sha256); break; } } - prop_object_iterator_release(iter); + xbps_object_iterator_release(iter); if (sha256 == NULL) errno = ENOENT; @@ -174,7 +174,7 @@ file_hash_dictionary(prop_dictionary_t d, const char *key, const char *file) int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *xhp, - prop_dictionary_t d, + xbps_dictionary_t d, const char *key, const char *file) { @@ -182,7 +182,7 @@ xbps_file_hash_check_dictionary(struct xbps_handle *xhp, char *buf; int rv; - assert(prop_object_type(d) == PROP_TYPE_DICTIONARY); + assert(xbps_object_type(d) == XBPS_TYPE_DICTIONARY); assert(key != NULL); assert(file != NULL);