- h = hashmap_new(catalog_hash_func, catalog_compare_func);
- if (!h)
- return -ENOMEM;
-
- sb = strbuf_new();
- if (!sb) {
- r = log_oom();
- goto finish;
- }
-
- r = conf_files_list_strv(&files, ".catalog", (const char **) conf_file_dirs);
- if (r < 0) {
- log_error("Failed to get catalog files: %s", strerror(-r));
- goto finish;
- }
-
- STRV_FOREACH(f, files) {
- log_debug("reading file '%s'", *f);
- import_file(h, sb, *f);
- }
-
- if (hashmap_size(h) <= 0) {
- log_info("No items in catalog.");
- r = 0;
- goto finish;
- } else
- log_debug("Found %u items in catalog.", hashmap_size(h));
-
- strbuf_complete(sb);
-
- items = new(CatalogItem, hashmap_size(h));
- if (!items) {
- r = log_oom();
- goto finish;
- }
-
- n = 0;
- HASHMAP_FOREACH(i, h, j) {
- log_debug("Found " SD_ID128_FORMAT_STR ", language %s", SD_ID128_FORMAT_VAL(i->id), isempty(i->language) ? "C" : i->language);
- items[n++] = *i;
- }
-
- assert(n == hashmap_size(h));
- qsort(items, n, sizeof(CatalogItem), catalog_compare_func);