2 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * This file is part of the UI Gadget
5 * Written by Jayoun Lee <airjany@samsung.com>, Jinwoo Nam <jwoo.nam@samsung.com>
7 * PROPRIETARY/CONFIDENTIAL
9 * This software is the confidential and proprietary information of
10 * SAMSUNG ELECTRONICS (Confidential Information).
11 * You shall not disclose such Confidential Information and shall
12 * use it only in accordance with the terms of the license agreement
13 * you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no
14 * representations or warranties about the suitability
15 * of the software, either express or implied, including but not
16 * limited to the implied warranties of merchantability, fitness for a particular purpose, or non-
17 * infringement. SAMSUNG shall not be liable for any damages suffered by licensee as
18 * a result of using, modifying or distributing this software or its derivatives.
22 #include <linux/limits.h>
29 #include <sys/types.h>
31 #include "ug-engine.h"
34 #define UG_ENGINE_INIT_SYM "UG_ENGINE_INIT"
35 #define UG_ENGINE_EXIT_SYM "UG_ENGINE_EXIT"
41 static int file_exist(const char *filename)
45 file = fopen(filename, "r");
54 struct ug_engine *ug_engine_load()
57 struct ug_engine *engine;
58 char engine_file[PATH_MAX];
59 enum ug_engine_type type = UG_ENGINE_EFL;
60 int (*engine_init)(struct ug_engine_ops *ops);
62 engine = calloc(1, sizeof(struct ug_engine));
69 if (type == UG_ENGINE_EFL) { /* UG_ENGINE_EFL is default*/
70 if (snprintf(engine_file, PATH_MAX, "/usr/lib/libug-efl-engine.so") < 0){
73 else if (file_exist(engine_file) < 0) {
80 handle = dlopen(engine_file, RTLD_LAZY);
82 _ERR("dlopen failed: %s\n", dlerror());
86 engine_init = dlsym(handle, UG_ENGINE_INIT_SYM);
88 _ERR("dlsym failed: %s\n", dlerror());
92 if (engine_init(&engine->ops))
95 engine->handle = handle;
106 int ug_engine_unload(struct ug_engine *engine)
108 void (*engine_exit)(struct ug_engine_ops *ops);
115 if (engine->handle) {
116 engine_exit = dlsym(engine->handle, UG_ENGINE_EXIT_SYM);
118 engine_exit(&engine->ops);
120 _ERR("dlsym failed: %s\n", dlerror());
122 dlclose(engine->handle);