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"
27 #include "sal/types.h"
30 static HMODULE module
= NULL
;
31 static HINSTANCE hInstDLL
= NULL
;
32 static CRITICAL_SECTION CriticalSection
;
34 void InitWrapper(void) {
36 wchar_t path
[MAXPATH
];
39 size
= GetModuleFileNameW(hInstDLL
, path
, MAXPATH
);
43 path
[size
- 5] = L
'x'; /* ...\jpipe.dll -> ...\jpipx.dll */
44 module
= LoadLibraryExW(path
, NULL
, LOAD_WITH_ALTERED_SEARCH_PATH
);
50 static FARPROC
getFunction(char const * name
)
53 EnterCriticalSection(&CriticalSection
);
58 LeaveCriticalSection(&CriticalSection
);
61 return GetProcAddress(module
, name
);
64 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
) {
67 if (fdwReason
== DLL_PROCESS_ATTACH
)
69 InitializeCriticalSection(&CriticalSection
);
76 SAL_DLLPUBLIC_EXPORT
void JNICALL
77 Java_com_sun_star_lib_connections_pipe_PipeConnection_createJNI(
78 JNIEnv
* env
, jobject obj_this
, jstring name
)
80 (*(void (*)(JNIEnv
*, jobject
, jstring
))
81 getFunction("PipeConnection_create"))(env
, obj_this
, name
);
84 SAL_DLLPUBLIC_EXPORT
void JNICALL
85 Java_com_sun_star_lib_connections_pipe_PipeConnection_closeJNI(
86 JNIEnv
* env
, jobject obj_this
)
88 (*(void (*)(JNIEnv
*, jobject
))
89 getFunction("PipeConnection_close"))(env
, obj_this
);
92 SAL_DLLPUBLIC_EXPORT jint JNICALL
93 Java_com_sun_star_lib_connections_pipe_PipeConnection_readJNI(
94 JNIEnv
* env
, jobject obj_this
, jobjectArray buffer
, jint len
)
96 return (*(jint (*)(JNIEnv
*, jobject
, jobjectArray
, jint
))
97 getFunction("PipeConnection_read"))(env
, obj_this
, buffer
, len
);
100 SAL_DLLPUBLIC_EXPORT
void JNICALL
101 Java_com_sun_star_lib_connections_pipe_PipeConnection_writeJNI(
102 JNIEnv
* env
, jobject obj_this
, jbyteArray buffer
)
104 (*(void (*)(JNIEnv
*, jobject
, jbyteArray
))
105 getFunction("PipeConnection_write"))(env
, obj_this
, buffer
);
108 SAL_DLLPUBLIC_EXPORT
void JNICALL
109 Java_com_sun_star_lib_connections_pipe_PipeConnection_flushJNI(
110 JNIEnv
* env
, jobject obj_this
)
112 (*(void (*)(JNIEnv
*, jobject
))
113 getFunction("PipeConnection_flush"))(env
, obj_this
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */