]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Move DLL support to lib/fs
authorNick Mathewson <nickm@torproject.org>
Thu, 28 Jun 2018 17:37:51 +0000 (13:37 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 28 Jun 2018 17:37:51 +0000 (13:37 -0400)
src/common/util.c
src/common/util.h
src/lib/fs/include.am
src/lib/fs/winlib.c [new file with mode: 0644]
src/lib/fs/winlib.h [new file with mode: 0644]

index b31bb834e1a8b82dc94d4922849278a057a965b7..135af77c6868af8ad4f9763a246d6efadafef2a0 100644 (file)
@@ -134,18 +134,3 @@ ENABLE_GCC_WARNING(aggregate-return)
 /* =====
  * Time
  * ===== */
-
-#ifdef _WIN32
-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) */
index f174cd3667165de8bcb08a9a3a9545ac4057fab5..ffd958c42ca3a13fda9486fc63a12c2588b3a055 100644 (file)
@@ -40,6 +40,7 @@
 #include "lib/fs/path.h"
 #include "lib/encoding/time_fmt.h"
 #include "lib/encoding/cstring.h"
+#include "lib/fs/winlib.h"
 
 void tor_log_mallinfo(int severity);
 
@@ -76,8 +77,4 @@ void tor_log_mallinfo(int severity);
   ((isSock) ? read_all_from_socket((fd), (buf), (count)) \
             : read_all_from_fd((int)(fd), (buf), (count)))
 
-#ifdef _WIN32
-HANDLE load_windows_system_library(const TCHAR *library_name);
-#endif
-
 #endif /* !defined(TOR_UTIL_H) */
index 0256c0f2f443741aff2419cc743b7f8654b6452b..a025eb81c00e02d54876728c390521f84b649b10 100644 (file)
@@ -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 (file)
index 0000000..7a88a84
--- /dev/null
@@ -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 (file)
index 0000000..f53f046
--- /dev/null
@@ -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