apply FSL(Flora Software License)
[framework/system/system-server.git] / ss_device_plugin.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17
18 #include <dlfcn.h>
19 #include <unistd.h>
20
21 #include "ss_log.h"
22 #include "ss_device_plugin.h"
23
24 static void *dlopen_handle;
25
26 int _ss_devman_plugin_init()
27 {
28         char *error;
29
30         dlopen_handle = dlopen(DEVMAN_PLUGIN_PATH, RTLD_NOW);
31         if (!dlopen_handle) {
32                 PRT_TRACE_ERR("dlopen() failed");
33                 return -1;
34         }
35
36         const OEM_sys_devman_plugin_interface *(*get_devman_plugin_interface) ();
37         get_devman_plugin_interface = dlsym(dlopen_handle, "OEM_sys_get_devman_plugin_interface");
38         if ((error = dlerror()) != NULL) {
39                 PRT_TRACE_ERR("dlsym() failed: %s", error);
40                 dlclose(dlopen_handle);
41                 return -1;
42         }
43
44         plugin_intf = get_devman_plugin_interface();
45         if (!plugin_intf) {
46                 PRT_TRACE_ERR("get_devman_plugin_interface() failed");
47                 dlclose(dlopen_handle);
48                 return -1;
49         }
50
51         return 0;
52 }
53
54
55 int _ss_devman_plugin_fini()
56 {
57         if (dlopen_handle) {
58                 dlclose(dlopen_handle);
59         }
60
61         return 0;
62 }
63
64