From 579e5dbfdef48c31bb4e53d0e2c4b79d64931ec0 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 1 Jan 2022 00:25:18 +0000 Subject: [PATCH] Prototype dc_blob_t API --- deltachat-ffi/deltachat.h | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 85a74704b..0ece0f182 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -14,6 +14,7 @@ extern "C" { typedef struct _dc_context dc_context_t; typedef struct _dc_accounts dc_accounts_t; typedef struct _dc_array dc_array_t; +typedef struct _dc_blob dc_blob_t; typedef struct _dc_chatlist dc_chatlist_t; typedef struct _dc_chat dc_chat_t; typedef struct _dc_msg dc_msg_t; @@ -2871,6 +2872,45 @@ int dc_array_is_independent (const dc_array_t* array, size_t in int dc_array_search_id (const dc_array_t* array, uint32_t needle, size_t* ret_index); +/** + * @class dc_blob_t + * + * An object representing a file blob. + */ + + +/** + * Free a blob object. + * + * @memberof dc_blob_t + * @param blob The blob object. + */ +void dc_blob_unref (dc_blob_t* blob); + +/** + * Returns blob size in bytes. + * + * @memberof dc_blob_t + * @param blob The blob object. + * @return Returns blob size. Never fails. + */ + +size_t dc_blob_bytes (dc_blob_t* blob); + +/** + * Reads data from a blob. + * Reads exactly the number of bytes requested and + * returns an error if it's not possible. + * + * @memberof dc_blob_t + * @param blob The blob object. + * @param count Number of bytes to read from the blob. + * @param offset Offset of the first byte to read inside the blob. + * @return 1 on success, 0 on error. + */ +int dc_blob_read (dc_blob_t* blob, void* buf, size_t count, off_t offset); + + /** * @class dc_chatlist_t * @@ -3571,6 +3611,16 @@ char* dc_msg_get_filemime (const dc_msg_t* msg); uint64_t dc_msg_get_filebytes (const dc_msg_t* msg); +/** + * Get the file blob. + * + * @memberof dc_msg_t + * @param msg The message object. + * @return File blob, NULL if not applicable or on errors. + */ +dc_blob_t *dc_msg_get_fileblob (const dc_msg_t* msg); + + /** * Get width of image or video. The width is returned in pixels. * If the width is unknown or if the associated file is no image or video file,