]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add ltdl.h shim for Windows
authorOndřej Surý <ondrej@isc.org>
Tue, 19 May 2020 14:36:01 +0000 (16:36 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 28 May 2020 06:07:57 +0000 (08:07 +0200)
lib/isc/win32/ltdl.h [new file with mode: 0644]
util/copyrights

diff --git a/lib/isc/win32/ltdl.h b/lib/isc/win32/ltdl.h
new file mode 100644 (file)
index 0000000..16beb86
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#pragma once
+
+#include <windows.h>
+
+#define lt_dlhandle    HMODULE
+#define lt_dlinit()    ISC_R_SUCCESS
+#define lt_dlopen(f)   LoadLibraryW(f)
+#define lt_dlsym(h, s) GetProcAddress(h, s)
+#define lt_dlclose(h)  FreeLibrary(h)
+
+_Thread_local LPSTR __dlerror_message[1024] = { 0 };
+
+static const char *
+lt_dlerror(void) {
+       DWORD errorMessageID = GetLastError();
+       if (errorMessageID == 0) {
+               return (NULL);
+       }
+
+       LPSTR messageBuffer = NULL;
+       size_t size = FormatMessageA(
+               FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS,
+               NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+               (LPSTR)&messageBuffer, 0, NULL);
+
+       strlcpy(__dlerror_message, messageBuffer, sizeof(__dlerror_message));
+
+       LocalFree(messageBuffer);
+
+       return ((const char *)__dlerror_message);
+}
index ee5327228075a19916b33f40fd2b1d5872ecd9ec..119596c90b4c4529e922f5ff56768c15c09e5721 100644 (file)
 ./lib/isc/win32/libisc.vcxproj.filters.in      X       2013,2014,2015,2016,2018,2019,2020
 ./lib/isc/win32/libisc.vcxproj.in              X       2013,2014,2015,2016,2017,2018,2019,2020
 ./lib/isc/win32/libisc.vcxproj.user            X       2013,2018,2019,2020
+./lib/isc/win32/ltdl.h                         C       2020
 ./lib/isc/win32/meminfo.c                      C       2015,2016,2018,2019,2020
 ./lib/isc/win32/net.c                          C       1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2011,2012,2013,2014,2015,2016,2018,2019,2020
 ./lib/isc/win32/netdb.h                                C       2000,2001,2004,2006,2007,2009,2013,2016,2018,2019,2020