core: Add allocating b64 checksum functions
The checksum_b64_inplace variants can't be used in bindings. Provide versions that allocate and return the output rather than working on a passed in buffer. These can then be used in GI bindings to get the ostree modified base64 encodings. Closes: #398 Approved by: cgwalters
This commit is contained in:
1 parent
2e97e72123
commit
db974b0596
4 files changed
+39
-3
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user