aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-28 13:37:51 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-28 13:37:51 -0400
commit02bb701bba5fb6b5eb6ce5716b8fff9fd2c5e028 (patch)
tree03b336e462f1f7d23db6aa89a1fbff9f754505ec /src/lib
parent8fc15e4861b37f7799abde6b9d6ec63fdceb55da (diff)
downloadtor-02bb701bba5fb6b5eb6ce5716b8fff9fd2c5e028.tar.gz
tor-02bb701bba5fb6b5eb6ce5716b8fff9fd2c5e028.zip
Move DLL support to lib/fs
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fs/include.am7
-rw-r--r--src/lib/fs/winlib.c21
-rw-r--r--src/lib/fs/winlib.h16
3 files changed, 43 insertions, 1 deletions
diff --git a/src/lib/fs/include.am b/src/lib/fs/include.am
index 0256c0f2f4..a025eb81c0 100644
--- a/src/lib/fs/include.am
+++ b/src/lib/fs/include.am
@@ -15,6 +15,10 @@ src_lib_libtor_fs_a_SOURCES = \
src/lib/fs/storagedir.c \
src/lib/fs/userdb.c
+if WIN32
+src_lib_libtor_fs_a_SOURCES += src/lib/fs/winlib.c
+endif
+
src_lib_libtor_fs_testing_a_SOURCES = \
$(src_lib_libtor_fs_a_SOURCES)
src_lib_libtor_fs_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
@@ -28,4 +32,5 @@ noinst_HEADERS += \
src/lib/fs/mmap.h \
src/lib/fs/path.h \
src/lib/fs/storagedir.h \
- src/lib/fs/userdb.h
+ src/lib/fs/userdb.h \
+ src/lib/fs/winlib.h
diff --git a/src/lib/fs/winlib.c b/src/lib/fs/winlib.c
new file mode 100644
index 0000000000..7a88a841a6
--- /dev/null
+++ b/src/lib/fs/winlib.c
@@ -0,0 +1,21 @@
+/* Copyright (c) 2003, Roger Dingledine
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifdef _WIN32
+#include "lib/fs/winlib.h"
+
+HANDLE
+load_windows_system_library(const TCHAR *library_name)
+{
+ TCHAR path[MAX_PATH];
+ unsigned n;
+ n = GetSystemDirectory(path, MAX_PATH);
+ if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH)
+ return 0;
+ _tcscat(path, TEXT("\\"));
+ _tcscat(path, library_name);
+ return LoadLibrary(path);
+}
+#endif /* defined(_WIN32) */
diff --git a/src/lib/fs/winlib.h b/src/lib/fs/winlib.h
new file mode 100644
index 0000000000..f53f046451
--- /dev/null
+++ b/src/lib/fs/winlib.h
@@ -0,0 +1,16 @@
+/* Copyright (c) 2003, Roger Dingledine
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_WINLIB_H
+#define TOR_WINLIB_H
+
+#ifdef _WIN32
+#include <windows.h>
+#include <tchar.h>
+
+HANDLE load_windows_system_library(const TCHAR *library_name);
+#endif
+
+#endif