return 0;
}
+/*
+ * Convenience function to hash a buffer
+ */
+int pakfire_hash_buffer(struct pakfire_ctx* ctx, const char* buffer, const size_t length,
+ const enum pakfire_hash_type types, struct pakfire_hashes* hashes) {
+ struct pakfire_hasher* hasher = NULL;
+ int r;
+
+ // Create a new hasher
+ r = pakfire_hasher_create(&hasher, ctx, types);
+ if (r < 0)
+ goto ERROR;
+
+ // To make the static analyzer happy
+ assert(hasher);
+
+ // Feed the buffer into the hash functions
+ r = pakfire_hasher_update(hasher, buffer, length);
+ if (r < 0)
+ goto ERROR;
+
+ // Finalize the hash functions
+ r = pakfire_hasher_finalize(hasher, hashes);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (hasher)
+ pakfire_hasher_unref(hasher);
+
+ return r;
+}
+
/*
Convenience function to hash a file
*/
int pakfire_hasher_update(struct pakfire_hasher* self, const char* buffer, const size_t length);
int pakfire_hasher_finalize(struct pakfire_hasher* self, struct pakfire_hashes* computed_hashes);
+int pakfire_hash_buffer(struct pakfire_ctx* ctx, const char* buffer, const size_t length,
+ const enum pakfire_hash_type types, struct pakfire_hashes* hashes);
int pakfire_hash_file(struct pakfire_ctx* ctx,
FILE* f, enum pakfire_hash_type types, struct pakfire_hashes* hashes);
int pakfire_hash_path(struct pakfire_ctx* ctx,