summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Makefile2
-rw-r--r--src/common/dll.h25
-rw-r--r--src/common/socket.c26
3 files changed, 30 insertions, 23 deletions
diff --git a/src/common/Makefile b/src/common/Makefile
index c90940b94..7a00c5a3c 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -9,7 +9,7 @@ obj/%.o: %.c
$(COMPILE.c) $(OUTPUT_OPTION) $<
obj/core.o: core.c core.h showmsg.h
-obj/socket.o: socket.c socket.h mmo.h showmsg.h
+obj/socket.o: socket.c socket.h mmo.h showmsg.h dll.h
obj/timer.o: timer.c timer.h showmsg.h
obj/grfio.o: grfio.c grfio.h showmsg.h
obj/db.o: db.c db.h showmsg.h
diff --git a/src/common/dll.h b/src/common/dll.h
new file mode 100644
index 000000000..ec6f8cbed
--- /dev/null
+++ b/src/common/dll.h
@@ -0,0 +1,25 @@
+
+#ifndef _DLL_H_
+#define _DLL_H_
+
+#ifdef _WIN32
+
+ #include <windows.h>
+ #define DLL_OPEN(x) LoadLibrary(x)
+ #define DLL_SYM(x,y,z) (FARPROC)x=GetProcAddress(y,z)
+ #define DLL_CLOSE(x) FreeLibrary(x)
+ #define DLL HINSTANCE
+
+#else
+
+ #include <dlfcn.h>
+ #define DLL_OPEN(x) dlopen(x,RTLD_NOW)
+ #define DLL_SYM(x,y,z) x=(void *)dlsym(y,z)
+ #define DLL_CLOSE(x) dlclose(x)
+ #define DLL void*
+
+#endif
+
+#endif // _DLL_H_
+
+
diff --git a/src/common/socket.c b/src/common/socket.c
index 7178c95e2..6c7d873e0 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -30,6 +30,7 @@ typedef int socklen_t;
#include <string.h>
#include "socket.h"
+#include "../common/dll.h"
#include "../common/mmo.h" // [Valaris] thanks to fov
#include "../common/timer.h"
#include "../common/utils.h"
@@ -46,35 +47,16 @@ int ip_rules = 1;
#define UPNP
#ifdef UPNP
- #if defined(CYGWIN)
-
- #include <dlfcn.h>
- void *upnp_dll;
+ #if defined(CYGWIN) || defined(_WIN32)
+ DLL upnp_dll;
int (*upnp_init)();
int (*upnp_final)();
int (*firewall_addport)(char *desc, int port);
int (*upnp_addport)(char *desc, char *ip, int port);
- #define DLL_OPEN(x) dlopen(x,RTLD_NOW)
- #define DLL_SYM(x,y,z) x=(void *)dlsym(y,z)
- #define DLL_CLOSE(x) dlclose(x)
-
- #elif _WIN32
-
- // windows.h already included
- HINSTANCE upnp_dll;
- int (WINAPI* upnp_init)();
- int (WINAPI* upnp_final)();
- int (WINAPI* firewall_addport)(char *desc, int port);
- int (WINAPI* upnp_addport)(char *desc, char *ip, int port);
- #define DLL_OPEN(x) LoadLibrary(x)
- #define DLL_SYM(x,y,z) (FARPROC)x=GetProcAddress(y,z)
- #define DLL_CLOSE(x) FreeLibrary(x)
-
+ extern char server_type[24];
#else
#error This doesnt work with non-Windows yet
#endif
-
- extern char server_type[24];
#endif
int rfifo_size = 65536;