Skip to content

Commit

Permalink
Replace the link-time pragma from r1839494 with APR_DECLARE_LATE_DLL_…
Browse files Browse the repository at this point in the history
…FUNC

resolution of if_indextoname and if_nametoindex.



git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1855855 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
wrowe committed Mar 19, 2019
1 parent bc9f2d3 commit dfee56a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
26 changes: 24 additions & 2 deletions include/arch/win32/apr_arch_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
#include <tlhelp32.h>
#endif

#if defined(HAVE_IF_INDEXTONAME) && defined(_MSC_VER)
#include <Iphlpapi.h>
#endif

struct apr_other_child_rec_t {
apr_pool_t *p;
struct apr_other_child_rec_t *next;
Expand Down Expand Up @@ -174,8 +178,9 @@ typedef enum {
DLL_WINSOCKAPI = 2, /* mswsock From WinSock.h */
DLL_WINSOCK2API = 3, /* ws2_32 From WinSock2.h */
DLL_SHSTDAPI = 4, /* shell32 From ShellAPI.h */
DLL_NTDLL = 5, /* shell32 From our real kernel */
DLL_defined = 6 /* must define as last idx_ + 1 */
DLL_NTDLL = 5, /* ntdll From our real kernel */
DLL_IPHLPAPI = 6, /* Iphlpapi From Iphlpapi.h */
DLL_defined = 7 /* must define as last idx_ + 1 */
} apr_dlltoken_e;

FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal);
Expand Down Expand Up @@ -381,6 +386,23 @@ APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SetDllDirectoryW, 0, (
(lpPathName));
#define SetDllDirectoryW apr_winapi_SetDllDirectoryW

#ifdef if_nametoindex
#undef if_nametoindex
#endif
APR_DECLARE_LATE_DLL_FUNC(DLL_IPHLPAPI, NET_IFINDEX, WINAPI, if_nametoindex, 0, (
IN PCSTR InterfaceName),
(InterfaceName));
#define if_nametoindex apr_winapi_if_nametoindex

#ifdef if_indextoname
#undef if_indextoname
#endif
APR_DECLARE_LATE_DLL_FUNC(DLL_IPHLPAPI, PCHAR, NETIOAPI_API_, if_indextoname, 0, (
NET_IFINDEX InterfaceIndex
PCHAR InterfaceName),
(InterfaceIndex, InterfaceName));
#define if_indextoname apr_winapi_if_indextoname

#endif /* !defined(_WIN32_WCE) */

#endif /* ! MISC_H */
6 changes: 4 additions & 2 deletions misc/win32/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ apr_status_t apr_get_oslevel(apr_oslevel_e *level)
*/

static const char* const lateDllName[DLL_defined] = {
"kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll" };
"kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll",
"Iphplapi" };
static HMODULE lateDllHandle[DLL_defined] = {
NULL, NULL, NULL, NULL, NULL, NULL };
NULL, NULL, NULL, NULL, NULL, NULL,
NULL };

FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal)
{
Expand Down
1 change: 0 additions & 1 deletion network_io/unix/sockaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#if defined(HAVE_IF_INDEXTONAME) && defined(_MSC_VER)
#include <Iphlpapi.h>
#pragma comment(lib, "Iphlpapi.lib")
#endif

#define APR_WANT_STRFUNC
Expand Down

0 comments on commit dfee56a

Please sign in to comment.