le64_t offset;
} CatalogItem;
-unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
+static unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
const CatalogItem *i = p;
uint64_t u;
size_t l, sz;
return (unsigned long) u;
}
-int catalog_compare_func(const void *a, const void *b) {
+static int catalog_compare_func(const void *a, const void *b) {
const CatalogItem *i = a, *j = b;
unsigned k;
return strcmp(i->language, j->language);
}
+const struct hash_ops catalog_hash_ops = {
+ .hash = catalog_hash_func,
+ .compare = catalog_compare_func
+};
+
static int finish_item(
Hashmap *h,
struct strbuf *sb,
r = mkdir_p(d, 0775);
if (r < 0) {
- log_error("Recursive mkdir %s: %s", d, strerror(-r));
+ log_error_errno(-r, "Recursive mkdir %s: %m", d);
return r;
}
unsigned n;
long r;
- h = hashmap_new(catalog_hash_func, catalog_compare_func);
+ h = hashmap_new(&catalog_hash_ops);
sb = strbuf_new();
if (!h || !sb) {
r = conf_files_list_strv(&files, ".catalog", root, dirs);
if (r < 0) {
- log_error("Failed to get catalog files: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get catalog files: %m");
goto finish;
}
r = write_catalog(database, h, sb, items, n);
if (r < 0)
- log_error("Failed to write %s: %s", database, strerror(-r));
+ log_error_errno(-r, "Failed to write %s: %m", database);
else
log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
database, n, sb->len, r);