1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
25 #define WIN32_LEAN_AND_MEAN
29 #include <sal/types.h>
32 static HMODULE module
= NULL
;
33 static HINSTANCE hInstDLL
= NULL
;
34 static CRITICAL_SECTION CriticalSection
;
36 static void InitWrapper(void) {
38 wchar_t path
[MAXPATH
];
41 size
= GetModuleFileNameW(hInstDLL
, path
, MAXPATH
);
45 path
[size
- 5] = L
'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
46 module
= LoadLibraryExW(path
, NULL
, LOAD_WITH_ALTERED_SEARCH_PATH
);
52 static FARPROC
getFunction(char const * name
)
55 EnterCriticalSection(&CriticalSection
);
60 LeaveCriticalSection(&CriticalSection
);
63 return GetProcAddress(module
, name
);
66 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
) {
69 if (fdwReason
== DLL_PROCESS_ATTACH
)
71 InitializeCriticalSection(&CriticalSection
);
78 SAL_DLLPUBLIC_EXPORT
void JNICALL
79 Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI(
80 JNIEnv
* env
, jobject obj_this
, jstring name
)
82 (*(void (*)(JNIEnv
*, jobject
, jstring
))
83 getFunction("PipeConnection_create"))(env
, obj_this
, name
);
86 SAL_DLLPUBLIC_EXPORT
void JNICALL
87 Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI(
88 JNIEnv
* env
, jobject obj_this
)
90 (*(void (*)(JNIEnv
*, jobject
))
91 getFunction("PipeConnection_close"))(env
, obj_this
);
94 SAL_DLLPUBLIC_EXPORT jint JNICALL
95 Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI(
96 JNIEnv
* env
, jobject obj_this
, jobjectArray buffer
, jint len
)
98 return (*(jint (*)(JNIEnv
*, jobject
, jobjectArray
, jint
))
99 getFunction("PipeConnection_read"))(env
, obj_this
, buffer
, len
);
102 SAL_DLLPUBLIC_EXPORT
void JNICALL
103 Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI(
104 JNIEnv
* env
, jobject obj_this
, jbyteArray buffer
)
106 (*(void (*)(JNIEnv
*, jobject
, jbyteArray
))
107 getFunction("PipeConnection_write"))(env
, obj_this
, buffer
);
110 SAL_DLLPUBLIC_EXPORT
void JNICALL
111 Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI(
112 JNIEnv
* env
, jobject obj_this
)
114 (*(void (*)(JNIEnv
*, jobject
))
115 getFunction("PipeConnection_flush"))(env
, obj_this
);
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */