summaryrefslogtreecommitdiff
path: root/src/common/socket.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-30 17:10:03 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-30 17:10:03 +0000
commit56f8c49f065831c21156dd88bd5397b6ba355813 (patch)
treeb667b75966806a271eeee6ac72e42a7aacfeb0bd /src/common/socket.c
parentc883ca205971275e576d34b54304c3c5c30f3580 (diff)
downloadhercules-56f8c49f065831c21156dd88bd5397b6ba355813.tar.gz
hercules-56f8c49f065831c21156dd88bd5397b6ba355813.tar.bz2
hercules-56f8c49f065831c21156dd88bd5397b6ba355813.tar.xz
hercules-56f8c49f065831c21156dd88bd5397b6ba355813.zip
* Added base code for loading Ser's UPNP plugin
* Added 'idle_no_share' to battle_athena.conf * Added item_findingore.txt git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1343 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 70432eddf..5dd2e38f9 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -38,6 +38,20 @@ typedef int socklen_t;
#include "memwatch.h"
#endif
+#ifdef UPNP
+ #if defined(CYGWIN)
+ #include <dlfcn.h>
+ #elif _WIN32
+ // windows.h already included
+ #else
+ #error This doesnt work with non-Windows yet
+ #endif
+
+ void *upnp_dll;
+ void (*upnp_init)();
+ void (*upnp_final)();
+#endif
+
fd_set readfds;
int fd_max;
time_t tick_;
@@ -920,6 +934,27 @@ int Net_Init(void)
return(0);
}
+#ifdef UPNP
+// not implemented yet ^^;
+void do_init_upnp(void)
+{
+ upnp_dll = dlopen("upnp.dll", RTLD_NOW);
+ if (!upnp_dll) {
+ printf ("Cannot open upnp.dll: %s\n", dlerror());
+ return;
+ }
+ upnp_init = (void *)dlsym(upnp_dll, "do_init");
+ upnp_final = (void *)dlsym(upnp_dll, "do_final");
+ if (!upnp_init || !upnp_final) {
+ printf ("Cannot load symbol: %s\n", dlerror());
+ dlclose (upnp_dll);
+ return;
+ }
+ upnp_init();
+ return;
+}
+#endif
+
void do_final_socket(void)
{
int i;
@@ -945,7 +980,14 @@ void do_final_socket(void)
// session[0] のダミーデータを削除
aFree(session[0]->rdata);
aFree(session[0]->wdata);
- aFree(session[0]);
+ aFree(session[0]);
+
+#ifdef UPNP
+ if (upnp_final)
+ upnp_final();
+ if (upnp_dll)
+ dlclose(upnp_dll);
+#endif
}
void do_socket(void)
@@ -966,4 +1008,8 @@ void do_socket(void)
// とりあえず5分ごとに不要なデータを削除する
add_timer_interval(gettick()+1000,connect_check_clear,0,0,300*1000);
+
+#ifdef UPNP
+ do_init_upnp();
+#endif
}