From: WATANABE Hirofumi Date: 1997-12-08T10:32:32+09:00 Subject: [ruby-dev:964] Re: ruby 1.1b0 released わたなべです. 拡張モジュール DLL 化対応のための dln.c への patch です. --- dln.c.orig Wed Sep 24 11:34:42 1997 +++ dln.c Sun Dec 7 16:11:48 1997 @@ -1079,2 +1079,6 @@ +#ifdef _WIN32 +#include +#endif + static char * @@ -1106,2 +1110,16 @@ #endif + +#ifdef _WIN32 + static char message[1024]; + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + GetLastError(), + MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), + message, + sizeof message, + NULL); + + return message; +#endif } @@ -1161,2 +1179,39 @@ { +#ifdef _WIN32 + HINSTANCE handle; + char winfile[255]; + void (*init_fct)(); + char buf[MAXPATHLEN]; + + /* Load the file as an object one */ + init_funcname(buf, file); + +#ifdef __CYGWIN32__ + cygwin32_conv_to_win32_path(file, winfile); +#else + strcpy(winfile, file); +#endif + + /* Load file */ + if ((handle = + LoadLibraryExA(winfile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) == NULL) { + printf("LoadLibraryExA\n"); + goto failed; + } + +#ifdef __CYGWIN32__ + init_fct = (void(*)())GetProcAddress(handle, "impure_setup"); + + if (init_fct) + init_fct(_impure_ptr); +#endif + + if ((init_fct = (void(*)())GetProcAddress(handle, buf)) == NULL) { + printf("GetProcAddress %s\n", buf); + goto failed; + } + /* Call the init code */ + (*init_fct)(); + return; +#else #ifdef USE_DLN_A_OUT @@ -1282,2 +1337,3 @@ #endif /* USE_DLN_A_OUT */ +#endif #if !defined(_AIX) && !defined(NeXT)