Fix the memset size errors
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-util.c
old mode 100755 (executable)
new mode 100644 (file)
index 681d35c..7878d77
@@ -19,6 +19,7 @@
 #include <glib.h>
 #include <dlog.h>
 #include <gio/gio.h>
+#include <dlfcn.h>
 
 #include "bluetooth-api.h"
 #include "bt-service-common.h"
@@ -32,10 +33,12 @@ static GSList *req_list = NULL;
 static int assigned_id;
 static gboolean req_id_used[BT_REQUEST_ID_RANGE_MAX];
 
+bt_plugin_info_t *headed_plugin_info = NULL;
+
 void _bt_init_request_id(void)
 {
        assigned_id = 0;
-       memset(req_id_used, 0x00, BT_REQUEST_ID_RANGE_MAX);
+       memset(req_id_used, 0x00, sizeof(req_id_used));
 }
 
 int _bt_assign_request_id(void)
@@ -86,9 +89,6 @@ int _bt_insert_request_list(int req_id, int service_function,
        request_info_t *info;
 
        info = g_malloc0(sizeof(request_info_t));
-       /* Fix : NULL_RETURNS */
-       retv_if(info == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
-
        info->req_id = req_id;
        info->service_function = service_function;
        info->context = context;
@@ -146,3 +146,67 @@ void _bt_clear_request_list(void)
        }
 }
 
+void bluetooth_plugin_init()
+{
+       headed_plugin_info = g_malloc0(sizeof(bt_plugin_info_t));
+       if (!headed_plugin_info) {
+               BT_ERR("Can not memory alloc headed plugin");
+               return;
+       }
+
+       /* check ARCH 64 or 32*/
+       if (!access(FILEPATH_ARCH_64, 0)) {
+               BT_INFO("plugin loading for ARCH 64");
+               headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH64, RTLD_NOW);
+       } else {
+               BT_INFO("plugin loading for ARCH 32");
+               headed_plugin_info->handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW);
+       }
+
+       if (!headed_plugin_info->handle_headed) {
+               BT_ERR("Can not load plugin %s", dlerror());
+               headed_plugin_info->plugin_headed_enabled = FALSE;
+               return;
+       }
+
+       headed_plugin_info->headed_plugin = dlsym(headed_plugin_info->handle_headed, "headed_plugin");
+       if (!headed_plugin_info->headed_plugin) {
+               BT_ERR("Can not load symbol : %s", dlerror());
+               dlclose(headed_plugin_info->handle_headed);
+               headed_plugin_info->plugin_headed_enabled = FALSE;
+               return;
+       }
+
+       headed_plugin_info->plugin_headed_enabled = TRUE;
+       BT_INFO("Bluetooth Headed Plugin Initialized");
+}
+
+void bluetooth_plugin_deinit()
+{
+       BT_INFO("Bluetooth Headed Plugin Deintialized");
+       if (!headed_plugin_info->plugin_headed_enabled) {
+               g_free(headed_plugin_info);
+               headed_plugin_info = NULL;
+               return;
+       }
+
+       dlclose(headed_plugin_info->handle_headed);
+       headed_plugin_info->plugin_headed_enabled = FALSE;
+       g_free(headed_plugin_info);
+       headed_plugin_info = NULL;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+