summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/socket_wrapper.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index ab520b1..56d7bac 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -62,6 +62,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <unistd.h>
enum swrap_dbglvl_e {
@@ -325,11 +326,19 @@ struct swrap {
void *libc_handle;
void *libsocket_handle;
+ bool initialised;
+ bool enabled;
+
+ char *socket_dir;
+
struct swrap_libc_fns fns;
};
static struct swrap swrap;
+/* prototypes */
+static const char *socket_wrapper_dir(void);
+
#define LIBC_NAME "libc.so"
static void *swrap_libc_fn(void *handle, const char *fn_name)
@@ -453,6 +462,29 @@ static void swrap_libc_init(void)
swrap_libc_fn(handle, "socket");
}
+static void swrap_init(void)
+{
+ if (swrap.initialised) {
+ return;
+ }
+
+ swrap.socket_dir = strdup(socket_wrapper_dir());
+ if (swrap.socket_dir != NULL) {
+ swrap.enabled = true;
+ }
+
+ swrap_libc_init();
+
+ swrap.initialised = true;
+}
+
+static int swrap_enabled(void)
+{
+ swrap_init();
+
+ return swrap.enabled ? 1 : 0;
+}
+
#ifndef HAVE_APPLE
static void *libc_hnd;