multipart.h File Reference

Multipart module header file. More...

Include dependency graph for multipart.h:
This graph shows which files directly or indirectly include this file:

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)
 

Detailed Description

Multipart module header file.

This module manages the multipart message structure of HTTP request.

Definition in file multipart.h.

Typedef Documentation

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.

Parameters
[in]bufferDestination address for payload.
[in]sizeSize, in bytes, of each element to be read.
[in]countNumber of elements, each one with a size of size bytes.
[in]user_contextSource address for payload.
Returns
The total number of bytes successfully written is returned.

Definition at line 30 of file multipart.h.

Function Documentation

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).

Parameters
[in]bufferBuffer to be used.
[in,out]buffer_sizeSize of the buffer. Remaining size will be returned via this pointer.
[in]itemItem to be added.
[in]boundaryMultipart boundary.
Returns

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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).

Parameters
[in]bufferBuffer to be used.
[in,out]buffer_sizeSize of the buffer. Remaining size will be returned via this pointer.
[in]itemItem to be added.
[in]boundaryMultipart boundary.
[in]payload_content_typeContent type of payload.
[in]callbackCallback function to be used to copy the payload to http_request.
[in]user_contextUser context pointer to pass to the callback function.
Returns

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
[in]bufferBuffer to be used.
[in,out]buffer_sizeSize of the buffer. Remaining size will be returned via this pointer.
[in]boundaryClosing boundary.
Returns
  • MCL_OK in case of success.
  • MCL_FAIL in case of an internal error in MCL.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

MCL_LOCAL mcl_error_t multipart_generate_boundary ( char **  boundary)

This function is used to generate random boundary to be used in multipart messages.

Parameters
[out]boundaryGenerated boundary.
Returns

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().

Here is the call graph for this function:

Here is the caller graph for this function:

MCL_LOCAL mcl_size_t multipart_get_overhead_size ( void  )

This function is used to get multipart overhead size.

Returns
The size of multipart overhead.

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().

Here is the caller graph for this function:

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.

Parameters
[in]itemItem to calculate its tuple size.
[in]payload_content_typeContent type of payload.
Returns
Tuple size of the item.

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().

Here is the call graph for this function:

Here is the caller graph for this function: