Multipart module header file. More...
#include "mcl_connectivity/mcl_connectivity_common.h"
Go to the source code of this file.
Typedefs | |
typedef mcl_size_t(* | multipart_add_payload_callback) (char *buffer, mcl_size_t size, mcl_size_t count, void *user_context) |
Functions | |
MCL_LOCAL mcl_error_t | multipart_add_tuple (char *buffer, mcl_size_t *buffer_size, void *item, const char *boundary) |
MCL_LOCAL mcl_error_t | multipart_add_tuple_with_callback (char *buffer, mcl_size_t *buffer_size, void *item, const char *boundary, const char *payload_content_type, multipart_add_payload_callback callback, void *user_context) |
MCL_LOCAL mcl_size_t | multipart_get_tuple_size (void *item, const char *payload_content_type) |
MCL_LOCAL mcl_error_t | multipart_close (char *buffer, mcl_size_t *buffer_size, const char *boundary) |
MCL_LOCAL mcl_size_t | multipart_get_overhead_size (void) |
MCL_LOCAL mcl_error_t | multipart_generate_boundary (char **boundary) |
Multipart module header file.
This module manages the multipart message structure of HTTP request.
Definition in file multipart.h.
typedef mcl_size_t(* multipart_add_payload_callback) (char *buffer, mcl_size_t size, mcl_size_t count, void *user_context) |
Callback function prototype for adding payload to multipart.
[in] | buffer | Destination address for payload. |
[in] | size | Size, in bytes, of each element to be read. |
[in] | count | Number of elements, each one with a size of size bytes. |
[in] | user_context | Source address for payload. |
Definition at line 30 of file multipart.h.
MCL_LOCAL mcl_error_t multipart_add_tuple | ( | char * | buffer, |
mcl_size_t * | buffer_size, | ||
void * | item, | ||
const char * | boundary | ||
) |
This function is used to add a connectivity item to the HTTP request as a multipart content (meta + payload).
[in] | buffer | Buffer to be used. |
[in,out] | buffer_size | Size of the buffer. Remaining size will be returned via this pointer. |
[in] | item | Item to be added. |
[in] | boundary | Multipart boundary. |
Definition at line 117 of file multipart.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_NULL, and multipart_add_tuple_with_callback().
Referenced by _add_item_to_buffer().
MCL_LOCAL mcl_error_t multipart_add_tuple_with_callback | ( | char * | buffer, |
mcl_size_t * | buffer_size, | ||
void * | item, | ||
const char * | boundary, | ||
const char * | payload_content_type, | ||
multipart_add_payload_callback | callback, | ||
void * | user_context | ||
) |
This function is used to add a connectivity item to the HTTP request using callback as a multipart content (meta + payload).
[in] | buffer | Buffer to be used. |
[in,out] | buffer_size | Size of the buffer. Remaining size will be returned via this pointer. |
[in] | item | Item to be added. |
[in] | boundary | Multipart boundary. |
[in] | payload_content_type | Content type of payload. |
[in] | callback | Callback function to be used to copy the payload to http_request . |
[in] | user_context | User context pointer to pass to the callback function. |
Definition at line 130 of file multipart.c.
References _add_boundary(), _add_item_meta_json(), _add_item_payload(), _add_item_payload_content_type(), _space_needed_for_state, boundary_key, BOUNDARY_KEY_LENGTH, BOUNDARY_LENGTH, content_type, CONTENT_TYPE_LENGTH, content_type_meta_json, CONTENT_TYPE_META_JSON_LENGTH, content_type_multipart_related, CONTENT_TYPE_MULTIPART_RELATED_LENGTH, DOUBLE_ENDLINE_LENGTH, endline, ENDLINE_LENGTH, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_FALSE, MCL_FREE, MCL_NULL, MCL_OK, mcl_string_util_memcpy(), MCL_TRUE, multipart_generate_boundary(), MULTIPART_STATE_BOUNDARY_KEY, MULTIPART_STATE_BOUNDARY_VALUE_SUB_BOUNDARY, MULTIPART_STATE_CLOSE_SUB_BOUNDARY, MULTIPART_STATE_CONTENT_TYPE_KEY_FOR_META_JSON, MULTIPART_STATE_CONTENT_TYPE_KEY_FOR_MULTIPART_RELATED, MULTIPART_STATE_CONTENT_TYPE_KEY_FOR_PAYLOAD, MULTIPART_STATE_CONTENT_TYPE_VALUE_META_JSON, MULTIPART_STATE_CONTENT_TYPE_VALUE_MULTIPART_RELATED, MULTIPART_STATE_CONTENT_TYPE_VALUE_PAYLOAD, MULTIPART_STATE_DOUBLE_ENDLINE_FIRST, MULTIPART_STATE_DOUBLE_ENDLINE_SECOND, MULTIPART_STATE_DOUBLE_ENDLINE_THIRD, MULTIPART_STATE_END, MULTIPART_STATE_ENDLINE_FIRST, MULTIPART_STATE_ENDLINE_SECOND, MULTIPART_STATE_ITEM_META_JSON, MULTIPART_STATE_ITEM_PAYLOAD, MULTIPART_STATE_OPEN_MAIN_BOUNDARY, MULTIPART_STATE_OPEN_SUB_BOUNDARY_FIRST, and MULTIPART_STATE_OPEN_SUB_BOUNDARY_SECOND.
Referenced by _add_custom_data_to_buffer(), _add_item_to_buffer(), and multipart_add_tuple().
MCL_LOCAL mcl_error_t multipart_close | ( | char * | buffer, |
mcl_size_t * | buffer_size, | ||
const char * | boundary | ||
) |
This function is used to close the multipart section of HTTP request with closing boundary.
[in] | buffer | Buffer to be used. |
[in,out] | buffer_size | Size of the buffer. Remaining size will be returned via this pointer. |
[in] | boundary | Closing boundary. |
Definition at line 250 of file multipart.c.
References BOUNDARY_LENGTH, boundary_sign, BOUNDARY_SIGN_LENGTH, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_OK, mcl_string_util_memcpy(), and MULTIPART_CLOSE_LENGTH.
Referenced by _prepare_body(), and _prepare_body_for_store().
MCL_LOCAL mcl_error_t multipart_generate_boundary | ( | char ** | boundary | ) |
This function is used to generate random boundary to be used in multipart messages.
[out] | boundary | Generated boundary. |
boundary
is null. Definition at line 280 of file multipart.c.
References boundary_characters, BOUNDARY_LENGTH, MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_STATEMENT_CODE_MESSAGE, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR, MCL_OK, MCL_OUT_OF_MEMORY, and mcl_random_generate_bytes().
Referenced by connectivity_processor_exchange(), and multipart_add_tuple_with_callback().
MCL_LOCAL mcl_size_t multipart_get_overhead_size | ( | void | ) |
This function is used to get multipart overhead size.
Definition at line 273 of file multipart.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MULTIPART_CLOSE_LENGTH.
Referenced by _check_store_size(), _prepare_body(), and _select_store_items_to_exchange().
MCL_LOCAL mcl_size_t multipart_get_tuple_size | ( | void * | item, |
const char * | payload_content_type | ||
) |
This function calculates the tuple size of an item.
[in] | item | Item to calculate its tuple size. |
[in] | payload_content_type | Content type of payload. |
Definition at line 237 of file multipart.c.
References json_get_item_size(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_string_util_strlen(), and MULTIPART_BASE_SIZE.
Referenced by _get_item_size().