From 7b57637c32ea9c179c4fa694a98afc64e4922e56 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 4 Apr 2005 14:48:14 +0000 Subject: * Added dll.h * Update base code for the UPNP plugin loading git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1398 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 1 + src/common/Makefile | 2 +- src/common/dll.h | 25 +++++++++++++++++++++++++ src/common/socket.c | 26 ++++---------------------- 4 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 src/common/dll.h diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 3ce650e1b..de6743659 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,7 @@ Date Added 04/04 + * Update base code for the UPNP plugin loading [celest] * Removed anti-freeze system for login and char -- Shinomori's update would be enough to keep inter connections alive [celest] 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 + #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 + #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 #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 - 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; -- cgit v1.2.3-60-g2f50