浏览代码

* Added dll.h
* Update base code for the UPNP plugin loading

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1398 54d463be-8e91-2dee-dedb-b68131a5f0ec

celest 20 年之前
父节点
当前提交
308b7915ff
共有 4 个文件被更改,包括 31 次插入23 次删除
  1. 1 0
      Changelog-SVN.txt
  2. 1 1
      src/common/Makefile
  3. 25 0
      src/common/dll.h
  4. 4 22
      src/common/socket.c

+ 1 - 0
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]
 

+ 1 - 1
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

+ 25 - 0
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_
+
+

+ 4 - 22
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;