// JavaHooks.cpp //#include #if defined(_WIN32) || defined(_WIN64) #define WIN32_LEAN_AND_MEAN #include #include #include "SystemError.hpp" #include "ErrorHandling.hpp" #endif #include "cipres-jni.h" #if defined(_WIN32) || defined(_WIN64) using namespace CipresJNI; #endif // public interface // JNI_OnLoad JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { #if defined(_WIN32) || defined(_WIN64) WSADATA lib_data; if(::WSAStartup(MAKEWORD(2, 0), &lib_data) != 0) { JNIEnv *env; if(vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_4) == JNI_OK) { SystemError sys_err("JNI_OnLoad", "WSAStartup", ::WSAGetLastError()); ThrowError(env, JAVA_CLASS_RUNTIME_EXCEPT, sys_err.what()); } } #endif return JNI_VERSION_1_4; } // JNI_OnUnload JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) { #if defined(_WIN32) || defined(_WIN64) ::WSACleanup(); #endif }