summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-09-30 10:24:28 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-09-30 10:24:28 +0900
commit2c3f4f573eccb328f5a9c2baeb4700f5dd82dbba (patch)
tree60a2e2011b779e46c3950899a9e268ab8e9d17b6
parenta93be364f3ed7419616474613ce19f05652b9e09 (diff)
downloadlivebox-2c3f4f573eccb328f5a9c2baeb4700f5dd82dbba.tar.gz
livebox-2c3f4f573eccb328f5a9c2baeb4700f5dd82dbba.tar.bz2
livebox-2c3f4f573eccb328f5a9c2baeb4700f5dd82dbba.zip
Find the internal API using dlsym.
Implicit linking is not stable. Change-Id: I8b4428239b814b3dd66359160f36c497bbabd1a3
-rw-r--r--packaging/liblivebox.spec2
-rw-r--r--src/livebox.c46
2 files changed, 41 insertions, 7 deletions
diff --git a/packaging/liblivebox.spec b/packaging/liblivebox.spec
index c038ef0..b5486d1 100644
--- a/packaging/liblivebox.spec
+++ b/packaging/liblivebox.spec
@@ -1,6 +1,6 @@
Name: liblivebox
Summary: Library for the development of a livebox
-Version: 0.4.3
+Version: 0.4.4
Release: 1
Group: HomeTF/Livebox
License: Flora License
diff --git a/src/livebox.c b/src/livebox.c
index c1007cd..60bc528 100644
--- a/src/livebox.c
+++ b/src/livebox.c
@@ -20,6 +20,8 @@
#include <string.h> /* strdup */
#include <libgen.h>
#include <unistd.h> /* access */
+#define __USE_GNU
+#include <dlfcn.h>
#include <dlog.h>
#include <livebox-service.h>
@@ -39,9 +41,15 @@
/*!
* \brief This function is defined by the data-provider-slave
*/
-extern const char *livebox_find_pkgname(const char *filename);
-extern int livebox_request_update_by_id(const char *uri);
-extern int livebox_trigger_update_monitor(const char *id, int is_pd);
+static struct info {
+ const char *(*find_pkgname)(const char *filename);
+ int (*request_update_by_id)(const char *uri);
+ int (*trigger_update_monitor)(const char *id, int is_pd);
+} s_info = {
+ .find_pkgname = NULL,
+ .request_update_by_id = NULL,
+ .trigger_update_monitor = NULL,
+};
struct block {
unsigned int idx;
@@ -569,7 +577,17 @@ PUBLIC struct livebox_buffer *livebox_acquire_buffer(const char *filename, int i
}
snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
- pkgname = livebox_find_pkgname(uri);
+ if (!s_info.find_pkgname) {
+ s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
+ if (!s_info.find_pkgname) {
+ ErrPrint("Failed to find a \"livebox_find_pkgname\"\n");
+ free(user_data);
+ free(uri);
+ return NULL;
+ }
+ }
+
+ pkgname = s_info.find_pkgname(uri);
if (!pkgname) {
ErrPrint("Invalid Request\n");
free(user_data);
@@ -608,7 +626,15 @@ PUBLIC int livebox_request_update(const char *filename)
}
snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
- ret = livebox_request_update_by_id(uri);
+ if (!s_info.request_update_by_id) {
+ s_info.request_update_by_id = dlsym(RTLD_DEFAULT, "livebox_request_update_by_id");
+ if (!s_info.request_update_by_id) {
+ ErrPrint("\"livebox_request_update_by_id\" is not exists\n");
+ free(uri);
+ return LB_STATUS_ERROR_FAULT;
+ }
+ }
+ ret = s_info.request_update_by_id(uri);
free(uri);
return ret;
}
@@ -885,7 +911,15 @@ PUBLIC int livebox_buffer_post_render(struct livebox_buffer *handle)
PUBLIC int livebox_content_is_updated(const char *filename, int is_pd)
{
- return livebox_trigger_update_monitor(filename, is_pd);
+ if (!s_info.trigger_update_monitor) {
+ s_info.trigger_update_monitor = dlsym(RTLD_DEFAULT, "livebox_trigger_update_monitor");
+ if (!s_info.trigger_update_monitor) {
+ ErrPrint("Trigger update monitor function is not exists\n");
+ return LB_STATUS_ERROR_FAULT;
+ }
+ }
+
+ return s_info.trigger_update_monitor(filename, is_pd);
}
/* End of a file */