+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/**
+ * @file curl_extensions.cpp
+ * @brief external API functions for DLP
+ */
+
+#ifdef USE_TIZEN_FEATURE_DLP
+#include <dlfcn.h>
+#include <extensions/curl_extensions.h>
+
+#define LIBRARY_PATH "/usr/lib/libcurl_extension_dlp.so.0"
+
+static int first_run = 1;
+static void (*tizen_dlp_init)(void) = NULL;
+static void (*tizen_dlp_check_leak)(const char *, char * const, size_t) = NULL;
+
+/**
+ * @fn void curl_extensions_init(void)
+ * @brief Load the extension shared library looking for the function call
+ * symbols it going to use
+ * @callgraph
+ */
+static void curl_extensions_init(void)
+{
+ if (first_run) {
+ void *handle = dlopen(LIBRARY_PATH, RTLD_LAZY);
+ if (handle) {
+ tizen_dlp_init = dlsym(handle, "tizen_dlp_init");
+ tizen_dlp_check_leak = dlsym(handle, "tizen_dlp_check_leak");
+ }
+ first_run = 0;
+ }
+}
+
+/**
+ * @callgraph
+ */
+void curl_extensions_tizen_dlp_init(void)
+{
+ curl_extensions_init();
+
+ if (tizen_dlp_init)
+ tizen_dlp_init();
+}
+
+/**
+ * @callgraph
+ */
+void curl_extensions_tizen_dlp_check_leak(const char *hostname, char * const mem, size_t len)
+{
+ if(tizen_dlp_check_leak)
+ tizen_dlp_check_leak(hostname, mem, len);
+}
+#endif /* USE_TIZEN_FEATURE_DLP */