2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
21 #include <linux/limits.h>
28 #include <sys/types.h>
30 #include "ug-engine.h"
33 #define UG_ENGINE_INIT_SYM "UG_ENGINE_INIT"
34 #define UG_ENGINE_EXIT_SYM "UG_ENGINE_EXIT"
40 static int file_exist(const char *filename)
44 file = fopen(filename, "r");
53 struct ug_engine *ug_engine_load()
56 struct ug_engine *engine;
57 char engine_file[PATH_MAX];
58 enum ug_engine_type type = UG_ENGINE_EFL;
59 int (*engine_init)(struct ug_engine_ops *ops);
61 engine = calloc(1, sizeof(struct ug_engine));
68 if (type == UG_ENGINE_EFL) { /* UG_ENGINE_EFL is default*/
69 if (snprintf(engine_file, PATH_MAX, "/usr/lib/libug-efl-engine.so") < 0){
72 else if (file_exist(engine_file) < 0) {
79 handle = dlopen(engine_file, RTLD_LAZY);
81 _ERR("dlopen failed: %s\n", dlerror());
85 engine_init = dlsym(handle, UG_ENGINE_INIT_SYM);
87 _ERR("dlsym failed: %s\n", dlerror());
91 if (engine_init(&engine->ops))
94 engine->handle = handle;
105 int ug_engine_unload(struct ug_engine *engine)
107 void (*engine_exit)(struct ug_engine_ops *ops);
114 if (engine->handle) {
115 engine_exit = dlsym(engine->handle, UG_ENGINE_EXIT_SYM);
117 engine_exit(&engine->ops);
119 _ERR("dlsym failed: %s\n", dlerror());
121 dlclose(engine->handle);