Added support for Python 3. (Roland Puntaier)
diff --git a/src/if_python.c b/src/if_python.c
index e017b71..ea2e926 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -96,6 +96,19 @@
 #  define HINSTANCE long_u		/* for generating prototypes */
 # endif
 
+#ifndef _WIN32
+# include <dlfcn.h>
+# define FARPROC void*
+# define HINSTANCE void*
+# define load_dll(n) dlopen((n),RTLD_LAZY)
+# define close_dll dlclose
+# define symbol_from_dll dlsym
+#else
+# define load_dll LoadLibrary
+# define close_dll FreeLibrary
+# define symbol_from_dll GetProcAddress
+#endif
+
 /* This makes if_python.c compile without warnings against Python 2.5
  * on Win32 and Win64. */
 #undef PyRun_SimpleString
@@ -315,7 +328,7 @@
 {
     if (hinstPython)
     {
-	FreeLibrary(hinstPython);
+	close_dll(hinstPython);
 	hinstPython = 0;
     }
 }
@@ -332,7 +345,7 @@
 
     if (hinstPython)
 	return OK;
-    hinstPython = LoadLibrary(libname);
+    hinstPython = load_dll(libname);
     if (!hinstPython)
     {
 	if (verbose)
@@ -342,10 +355,10 @@
 
     for (i = 0; python_funcname_table[i].ptr; ++i)
     {
-	if ((*python_funcname_table[i].ptr = GetProcAddress(hinstPython,
+	if ((*python_funcname_table[i].ptr = symbol_from_dll(hinstPython,
 			python_funcname_table[i].name)) == NULL)
 	{
-	    FreeLibrary(hinstPython);
+	    close_dll(hinstPython);
 	    hinstPython = 0;
 	    if (verbose)
 		EMSG2(_(e_loadfunc), python_funcname_table[i].name);