diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt index cc77f15a..8b6337f7 100644 --- a/apidoc/ostree-sections.txt +++ b/apidoc/ostree-sections.txt @@ -99,6 +99,8 @@ ostree_checksum_inplace_from_bytes ostree_checksum_inplace_to_bytes ostree_checksum_bytes_peek ostree_checksum_bytes_peek_validate +ostree_checksum_b64_from_bytes +ostree_checksum_b64_to_bytes ostree_checksum_b64_inplace_from_bytes ostree_checksum_b64_inplace_to_bytes ostree_cmp_checksum_bytes diff --git a/src/libostree/libostree.sym b/src/libostree/libostree.sym index f26be3f0..04e36453 100644 --- a/src/libostree/libostree.sym +++ b/src/libostree/libostree.sym @@ -351,9 +351,8 @@ global: * NOTE NOTE NOTE */ -/* UNCOMMENT WHEN ADDING THE FIRST NEW SYMBOL FOR 2016.8 LIBOSTREE_2016.8 { global: - insert_symbol_here; + ostree_checksum_b64_to_bytes; + ostree_checksum_b64_from_bytes; } LIBOSTREE_2016.7; -*/ diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c index 32f0fd44..bf4d62a8 100644 --- a/src/libostree/ostree-core.c +++ b/src/libostree/ostree-core.c @@ -1272,6 +1272,20 @@ ostree_checksum_to_bytes_v (const char *checksum) return ot_gvariant_new_bytearray ((guchar*)result, OSTREE_SHA256_DIGEST_LEN); } +/** + * ostree_checksum_b64_to_bytes: + * @checksum: An ASCII checksum + * + * Returns: (transfer full) (array fixed-size=32): Binary version of @checksum. + */ +guchar * +ostree_checksum_b64_to_bytes (const char *checksum) +{ + guchar *ret = g_malloc (32); + ostree_checksum_b64_inplace_to_bytes (checksum, ret); + return ret; +} + /** * ostree_checksum_inplace_from_bytes: (skip) * @csum: (array fixed-size=32): An binary checksum of length 32 @@ -1363,6 +1377,23 @@ ostree_checksum_from_bytes_v (GVariant *csum_v) return ostree_checksum_from_bytes (ostree_checksum_bytes_peek (csum_v)); } +/** + * ostree_checksum_b64_from_bytes: + * @csum: (array fixed-size=32): An binary checksum of length 32 + * + * Returns: (transfer full): Modified base64 encoding of @csum + * + * The "modified" term refers to the fact that instead of '/', the '_' + * character is used. + */ +char * +ostree_checksum_b64_from_bytes (const guchar *csum) +{ + char *ret = g_malloc (44); + ostree_checksum_b64_inplace_from_bytes (csum, ret); + return ret; +} + /** * ostree_checksum_bytes_peek: * @bytes: #GVariant of type ay diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h index 415369d5..d1f76cf1 100644 --- a/src/libostree/ostree-core.h +++ b/src/libostree/ostree-core.h @@ -192,6 +192,8 @@ guchar *ostree_checksum_to_bytes (const char *checksum); _OSTREE_PUBLIC GVariant *ostree_checksum_to_bytes_v (const char *checksum); _OSTREE_PUBLIC +guchar *ostree_checksum_b64_to_bytes (const char *checksum); +_OSTREE_PUBLIC void ostree_checksum_b64_inplace_to_bytes (const char *checksum, guint8 *buf); @@ -199,6 +201,8 @@ _OSTREE_PUBLIC char * ostree_checksum_from_bytes (const guchar *csum); _OSTREE_PUBLIC char * ostree_checksum_from_bytes_v (GVariant *csum_v); +_OSTREE_PUBLIC +char * ostree_checksum_b64_from_bytes (const guchar *csum); _OSTREE_PUBLIC void ostree_checksum_inplace_from_bytes (const guchar *csum,