summaryrefslogtreecommitdiff
path: root/email-ipc/email-ipc-api.c
diff options
context:
space:
mode:
Diffstat (limited to 'email-ipc/email-ipc-api.c')
-rwxr-xr-xemail-ipc/email-ipc-api.c105
1 files changed, 75 insertions, 30 deletions
diff --git a/email-ipc/email-ipc-api.c b/email-ipc/email-ipc-api.c
index b2fd4f8..bdfe2dd 100755
--- a/email-ipc/email-ipc-api.c
+++ b/email-ipc/email-ipc-api.c
@@ -43,16 +43,13 @@ EXPORT_API HIPC_API emipc_create_email_api(long api_id)
{
EM_DEBUG_FUNC_BEGIN();
- emipc_email_api_info *api_info = NULL;
-
- api_info = (emipc_email_api_info *)malloc(sizeof(emipc_email_api_info));
+ emipc_email_api_info *api_info = (emipc_email_api_info *)calloc(1, sizeof(emipc_email_api_info));
if(api_info == NULL) {
EM_DEBUG_EXCEPTION("Malloc failed");
return NULL;
}
- memset(api_info, 0x00, sizeof(emipc_email_api_info));
- emipc_set_api_id_of_api_info(api_info, api_id);
+ api_info->api_id = api_id;
return (HIPC_API)api_info;
}
@@ -61,6 +58,7 @@ EXPORT_API void emipc_destroy_email_api(HIPC_API api)
{
EM_DEBUG_FUNC_BEGIN("API = %p", api);
emipc_email_api_info *api_info = (emipc_email_api_info *)api;
+ emipc_free_api_info(api_info);
EM_SAFE_FREE(api_info);
}
@@ -68,75 +66,112 @@ EXPORT_API long emipc_get_api_id(HIPC_API api)
{
EM_DEBUG_FUNC_BEGIN();
emipc_email_api_info *api_info = (emipc_email_api_info*)api;
- return emipc_get_api_id_of_api_info(api_info);
+ return api_info->api_id;
}
EXPORT_API long emipc_get_app_id(HIPC_API api)
{
EM_DEBUG_FUNC_BEGIN();
emipc_email_api_info *api_info = (emipc_email_api_info *)api;
- return emipc_get_app_id_of_api_info(api_info);
+ return api_info->app_id;
}
+/* note: there incurs additional cost (malloc & memcpy). */
+/* if data is a dynamic variable, please use emipc_dynamic_parameter instead */
EXPORT_API bool emipc_add_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length)
{
- EM_DEBUG_FUNC_BEGIN();
+ EM_DEBUG_FUNC_BEGIN("data_length[%d]", data_length);
emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
- if (parameters)
- return emipc_add_param_of_param_list(parameters, data, data_length);
- else
+ if (!parameters) {
+ EM_DEBUG_EXCEPTION("emipc_get_api_parameters failed");
return false;
}
-EXPORT_API int emipc_get_parameter_count(HIPC_API api, EPARAMETER_DIRECTION direction)
+ return emipc_add_param_to_param_list(parameters, data, data_length);
+}
+
+/* caution : data should be a dynamic variable */
+/* please, do not use a static variable */
+EXPORT_API bool emipc_add_dynamic_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length)
{
- EM_DEBUG_FUNC_BEGIN();
+ EM_DEBUG_FUNC_BEGIN("data_length[%d]", data_length);
emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
+ if (!parameters) {
+ EM_DEBUG_EXCEPTION("emipc_get_api_parameters failed");
+ return false;
+ }
- if(parameters)
- return emipc_get_param_count_of_param_list(parameters);
- else
- return -1;
+ emipc_add_dynamic_param_to_param_list(parameters, data, data_length);
+ return true;
}
-EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, int input_parameter_index, int input_parameter_buffer_size, void *output_parameter_buffer)
+
+
+EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction,
+ int input_parameter_index, int input_parameter_buffer_size, void *output_parameter_buffer)
{
- EM_DEBUG_FUNC_BEGIN("input_api_handle [%d], input_parameter_direction [%d], input_parameter_index [%d], input_parameter_buffer_size [%d], output_parameter_buffer [%p]", input_api_handle , input_parameter_direction , input_parameter_index, input_parameter_buffer_size, output_parameter_buffer);
+ EM_DEBUG_FUNC_BEGIN("parameter_index [%d], parameter_buffer_size [%d]", input_parameter_index, input_parameter_buffer_size);
emipc_param_list *parameters = NULL;
void *local_buffer = NULL;
if (input_parameter_buffer_size == 0 || output_parameter_buffer == NULL) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
- return EMF_ERROR_INVALID_PARAM;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ return EMAIL_ERROR_INVALID_PARAM;
}
parameters = emipc_get_api_parameters(input_api_handle, input_parameter_direction);
if (parameters == NULL) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_IPC_PROTOCOL_FAILURE");
- return EMF_ERROR_IPC_PROTOCOL_FAILURE;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
+ return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
}
local_buffer = emipc_get_param_of_param_list(parameters, input_parameter_index);
if (local_buffer == NULL) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_IPC_PROTOCOL_FAILURE");
- return EMF_ERROR_IPC_PROTOCOL_FAILURE;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
+ return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
}
if (emipc_get_param_len_of_param_list(parameters, input_parameter_index) != input_parameter_buffer_size) {
- EM_DEBUG_EXCEPTION("EMF_ERROR_IPC_PROTOCOL_FAILURE");
- return EMF_ERROR_IPC_PROTOCOL_FAILURE;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
+ return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
}
memcpy(output_parameter_buffer, local_buffer, input_parameter_buffer_size);
- EM_DEBUG_FUNC_END("Suceeded");
- return EMF_ERROR_NONE;
+ EM_DEBUG_FUNC_END();
+ return EMAIL_ERROR_NONE;
+}
+
+
+EXPORT_API void* emipc_get_nth_parameter_data(HIPC_API api_handle, EPARAMETER_DIRECTION direction, int param_index)
+{
+ EM_DEBUG_FUNC_BEGIN("nth_parameter_index [%d]", param_index);
+ emipc_param_list *parameters = NULL;
+ void *buf = NULL;
+
+ parameters = emipc_get_api_parameters(api_handle, direction);
+
+ if (parameters == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
+ return NULL;
+ }
+
+ buf = emipc_get_param_of_param_list(parameters, param_index);
+
+ if (!buf) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
+ return NULL;
+ }
+
+ EM_DEBUG_FUNC_END();
+ return buf;
}
+
EXPORT_API int emipc_get_parameter_length(HIPC_API api, EPARAMETER_DIRECTION direction, int parameter_index)
{
EM_DEBUG_FUNC_BEGIN();
@@ -149,7 +184,17 @@ EXPORT_API int emipc_get_parameter_length(HIPC_API api, EPARAMETER_DIRECTION dir
return -1;
}
-
+EXPORT_API int emipc_get_nth_parameter_length(HIPC_API api, EPARAMETER_DIRECTION direction, int parameter_index)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
+ if (parameters) {
+ EM_DEBUG_FUNC_END("Suceeded");
+ return emipc_get_param_len_of_param_list(parameters, parameter_index);
+ }
+ EM_DEBUG_FUNC_END("Failed");
+ return -1;
+}