split in java and c++ parts
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,2 @@
|
|||||||
/bin
|
/cpp/Pipe/.settings
|
||||||
/.settings
|
/cpp/pipe/.settings
|
||||||
/sound
|
|
||||||
|
|||||||
154
cpp/Pipe/.cproject
Normal file
154
cpp/Pipe/.cproject
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?fileVersion 4.0.0?>
|
||||||
|
|
||||||
|
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
|
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||||
|
<macros>
|
||||||
|
<stringMacro name="target" type="VALUE_TEXT" value="Pipe"/>
|
||||||
|
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.7.0"/>
|
||||||
|
</macros>
|
||||||
|
<externalSettings>
|
||||||
|
<externalSetting>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Pipe"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Pipe/Debug"/>
|
||||||
|
<entry flags="RESOLVED" kind="libraryFile" name="Pipe" srcPrefixMapping="" srcRootPath=""/>
|
||||||
|
</externalSetting>
|
||||||
|
</externalSettings>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug">
|
||||||
|
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917." name="/" resourcePath="">
|
||||||
|
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.139919199" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug">
|
||||||
|
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.1189720953" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/>
|
||||||
|
<builder buildPath="${workspace_loc:/Pipe/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.482966139" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.268346771" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.665305624" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1220825669" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1175271295" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug">
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.debug.option.optimization.level.1125922986" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.debug.option.debugging.level.1641613502" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.939510920" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1399500702" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug">
|
||||||
|
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.so.debug.option.optimization.level.234429006" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.debug.option.optimization.level" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.mingw.so.debug.option.debugging.level.1525375982" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.option.include.paths.88885521" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include/win32""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||||
|
</option>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.747324638" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.1007471610" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
|
||||||
|
<option defaultValue="true" id="gnu.c.link.mingw.so.debug.option.shared.1850054546" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.debug.option.shared" valueType="boolean"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.2022087314" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug">
|
||||||
|
<option defaultValue="true" id="gnu.cpp.link.mingw.so.debug.option.shared.357933903" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.debug.option.shared" valueType="boolean"/>
|
||||||
|
<option id="gnu.cpp.link.option.flags.1387180659" superClass="gnu.cpp.link.option.flags" value="-Wl,--kill-at -static-libgcc" valueType="string"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2125675597" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.output.216466795" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.output"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||||
|
<macros>
|
||||||
|
<stringMacro name="target" type="VALUE_TEXT" value="Pipe"/>
|
||||||
|
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.7.0"/>
|
||||||
|
</macros>
|
||||||
|
<externalSettings>
|
||||||
|
<externalSetting>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Pipe"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Pipe/Release"/>
|
||||||
|
<entry flags="RESOLVED" kind="libraryFile" name="Pipe" srcPrefixMapping="" srcRootPath=""/>
|
||||||
|
</externalSetting>
|
||||||
|
</externalSettings>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336" name="Release" parent="cdt.managedbuild.config.gnu.mingw.so.release">
|
||||||
|
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336." name="/" resourcePath="">
|
||||||
|
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.1271980283" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release">
|
||||||
|
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.368721242" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/>
|
||||||
|
<builder buildPath="${workspace_loc:/Pipe/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.2065732021" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.release.109377381" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.release">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.689046683" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1183393349" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.726851992" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release">
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.release.option.optimization.level.2002053108" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.release.option.debugging.level.907936589" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.204761037" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1321746613" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release">
|
||||||
|
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.so.release.option.optimization.level.735179609" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.release.option.optimization.level" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.mingw.so.release.option.debugging.level.265400846" name="Debug Level" superClass="gnu.c.compiler.mingw.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.option.include.paths.1576117703" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include/win32""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||||
|
</option>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1173268559" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.1652830435" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release">
|
||||||
|
<option defaultValue="true" id="gnu.c.link.mingw.so.release.option.shared.1257748519" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.release.option.shared" valueType="boolean"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.1600111105" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release">
|
||||||
|
<option defaultValue="true" id="gnu.cpp.link.mingw.so.release.option.shared.684498624" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.release.option.shared" valueType="boolean"/>
|
||||||
|
<option id="gnu.cpp.link.option.flags.51892807" superClass="gnu.cpp.link.option.flags" value="-Wl,--kill-at -static-libgcc" valueType="string"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.656026656" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output.432743873" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<project id="Pipe.cdt.managedbuild.target.gnu.mingw.so.1070782613" name="Shared Library" projectType="cdt.managedbuild.target.gnu.mingw.so"/>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="scannerConfiguration">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917;cdt.managedbuild.config.gnu.mingw.so.debug.1813551917.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1175271295;cdt.managedbuild.tool.gnu.cpp.compiler.input.939510920">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.2043271336;cdt.managedbuild.config.gnu.mingw.so.release.2043271336.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.726851992;cdt.managedbuild.tool.gnu.cpp.compiler.input.204761037">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.2043271336;cdt.managedbuild.config.gnu.mingw.so.release.2043271336.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1321746613;cdt.managedbuild.tool.gnu.c.compiler.input.1173268559">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917;cdt.managedbuild.config.gnu.mingw.so.debug.1813551917.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1399500702;cdt.managedbuild.tool.gnu.c.compiler.input.747324638">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
|
<storageModule moduleId="refreshScope"/>
|
||||||
|
</cproject>
|
||||||
27
cpp/Pipe/.project
Normal file
27
cpp/Pipe/.project
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Pipe</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
6611
cpp/Pipe/include/strsafe.h
Normal file
6611
cpp/Pipe/include/strsafe.h
Normal file
File diff suppressed because it is too large
Load Diff
262
cpp/Pipe/src/pipe.c
Normal file
262
cpp/Pipe/src/pipe.c
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
#include <jni.h>
|
||||||
|
#include "pipe.h"
|
||||||
|
|
||||||
|
#define DEBUG 0
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jstring sPipeName,
|
||||||
|
jint dwOpenMode,
|
||||||
|
jint dwPipeMode,
|
||||||
|
jint nMaxInstances,
|
||||||
|
jint nOutBufferSize,
|
||||||
|
jint nInBufferSize,
|
||||||
|
jint nDefaultTimeOut,
|
||||||
|
jint lpSecurityAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HANDLE pipeHandler;
|
||||||
|
LPCSTR pipeName;
|
||||||
|
pipeName = (*env)->GetStringUTFChars(env, sPipeName, NULL);
|
||||||
|
if (pipeName == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: Pipe Name %s\n", pipeName);
|
||||||
|
printf("Native: dwOpenMode %d\n", dwOpenMode);
|
||||||
|
printf("Native: dwPipeMode %d\n", dwPipeMode);
|
||||||
|
printf("Native: nMaxInstances %d\n", nMaxInstances);
|
||||||
|
printf("Native: nOutBufferSize %d\n", nOutBufferSize);
|
||||||
|
printf("Native: nInBufferSize %d\n", nInBufferSize);
|
||||||
|
printf("Native: nDefaultTimeOut %d\n", nDefaultTimeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
pipeHandler = CreateNamedPipe((LPCSTR)pipeName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize,
|
||||||
|
nDefaultTimeOut, (LPSECURITY_ATTRIBUTES) lpSecurityAttributes);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, sPipeName, pipeName);
|
||||||
|
return (jint) pipeHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_ConnectNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe,
|
||||||
|
jint lpOverlapped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL fConnected;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
fConnected = ConnectNamedPipe(pipeHandler, (LPOVERLAPPED) lpOverlapped);
|
||||||
|
return fConnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_GetLastError
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD errorNumber = GetLastError();
|
||||||
|
return (jint) errorNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_CloseHandle
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
result = CloseHandle(pipeHandler);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jbyteArray JNICALL Java_pipe_Pipes_ReadFile
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe,
|
||||||
|
jint nNumberOfBytesToRead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int bytesRead = 0;
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
LPVOID buffer;
|
||||||
|
jbyteArray lpBuffer;
|
||||||
|
|
||||||
|
buffer = (LPVOID)LocalAlloc(LMEM_ZEROINIT, nNumberOfBytesToRead);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: Before ReadFile pipeHandler %d nNumberOfBytesToRead %d\n", pipeHandler, nNumberOfBytesToRead);
|
||||||
|
}
|
||||||
|
result = ReadFile(pipeHandler, (LPVOID) buffer, (DWORD) nNumberOfBytesToRead, &bytesRead, (LPOVERLAPPED) 0);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
lpBuffer = (*env)->NewByteArray(env, (jsize) bytesRead);
|
||||||
|
(*env)->SetByteArrayRegion(env, lpBuffer, 0, (jsize) bytesRead, (jbyte *) buffer);
|
||||||
|
} else
|
||||||
|
bytesRead = 0;
|
||||||
|
|
||||||
|
LocalFree(buffer);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: After ReadFile BytesRead %d\n", bytesRead);
|
||||||
|
}
|
||||||
|
return lpBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_WriteFile
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe,
|
||||||
|
jbyteArray lpBuffer,
|
||||||
|
jint nNumberOfBytesToWrite
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int bytesWritten = 0;
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
LPVOID buffer;
|
||||||
|
|
||||||
|
buffer = (LPVOID)LocalAlloc(LMEM_ZEROINIT, nNumberOfBytesToWrite);
|
||||||
|
|
||||||
|
(*env)->GetByteArrayRegion(env, lpBuffer, 0, nNumberOfBytesToWrite, buffer);
|
||||||
|
result = WriteFile(pipeHandler, buffer, (DWORD) nNumberOfBytesToWrite, (LPDWORD) &bytesWritten, (LPOVERLAPPED) 0);
|
||||||
|
LocalFree(buffer);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: After WriteFile BytesReadWritten %d\n", bytesWritten);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
if (GetLastError() != ERROR_IO_PENDING)
|
||||||
|
result = 0;
|
||||||
|
else
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
bytesWritten = -1;
|
||||||
|
}
|
||||||
|
return bytesWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_FlushFileBuffers
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
result = FlushFileBuffers(pipeHandler);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_DisconnectNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
result = DisconnectNamedPipe(pipeHandler);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateFile
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jstring lpFileName,
|
||||||
|
jint dwDesiredAccess,
|
||||||
|
jint dwShareMode,
|
||||||
|
jint lpSecurityAttributes,
|
||||||
|
jint dwCreationDisposition,
|
||||||
|
jint dwFlagsAndAttributes,
|
||||||
|
jint hTemplateFile
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HANDLE pipeHandler;
|
||||||
|
const jbyte *fileName;
|
||||||
|
fileName = (*env)->GetStringUTFChars(env, lpFileName, NULL);
|
||||||
|
if (fileName == NULL)
|
||||||
|
return -1;
|
||||||
|
pipeHandler = CreateFile((LPCSTR) fileName, (DWORD) dwDesiredAccess, (DWORD) dwShareMode,
|
||||||
|
(LPSECURITY_ATTRIBUTES) lpSecurityAttributes, (DWORD) dwCreationDisposition, (DWORD) dwFlagsAndAttributes, (HANDLE) hTemplateFile);
|
||||||
|
return (jint) pipeHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_WaitNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jstring lpNamedPipeName,
|
||||||
|
jint nTimeOut
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
const jbyte *pipeName;
|
||||||
|
pipeName = (*env)->GetStringUTFChars(env, lpNamedPipeName, NULL);
|
||||||
|
if (pipeName == NULL)
|
||||||
|
return 0;
|
||||||
|
result = WaitNamedPipe((LPCSTR) pipeName, (DWORD) nTimeOut);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_pipe_Pipes_FormatMessage
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint errorCode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LPVOID lpMsgBuf;
|
||||||
|
LPVOID lpDisplayBuf;
|
||||||
|
DWORD dw = (DWORD) errorCode;
|
||||||
|
|
||||||
|
FormatMessage(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL,
|
||||||
|
dw,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR) &lpMsgBuf,
|
||||||
|
0, NULL );
|
||||||
|
|
||||||
|
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
|
||||||
|
(lstrlen((LPCTSTR)lpMsgBuf) + 40) * sizeof(TCHAR));
|
||||||
|
StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR),
|
||||||
|
TEXT("Failed with error %d: %s"), dw, lpMsgBuf);
|
||||||
|
return (jstring) (*env)->NewStringUTF(env, lpDisplayBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_pipe_Pipes_Print(JNIEnv *env, jclass className, jstring lpMsgBuf)
|
||||||
|
{
|
||||||
|
const jbyte *str;
|
||||||
|
str = (*env)->GetStringUTFChars(env, lpMsgBuf, NULL);
|
||||||
|
if (str == NULL)
|
||||||
|
return;
|
||||||
|
printf("Native: %s\n", str);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, lpMsgBuf, str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
109
cpp/Pipe/src/pipe.h
Normal file
109
cpp/Pipe/src/pipe.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class Pipes */
|
||||||
|
|
||||||
|
#ifndef _Included_pipe
|
||||||
|
#define _Included_pipe
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: CreateNamedPipe
|
||||||
|
* Signature: (Ljava/lang/String;IIIIIII)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateNamedPipe
|
||||||
|
(JNIEnv *, jclass, jstring, jint, jint, jint, jint, jint, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: ConnectNamedPipe
|
||||||
|
* Signature: (II)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_ConnectNamedPipe
|
||||||
|
(JNIEnv *, jclass, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: GetLastError
|
||||||
|
* Signature: ()I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_GetLastError
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: CloseHandle
|
||||||
|
* Signature: (I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_CloseHandle
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: ReadFile
|
||||||
|
* Signature: (II)[B
|
||||||
|
*/
|
||||||
|
JNIEXPORT jbyteArray JNICALL Java_pipe_Pipes_ReadFile
|
||||||
|
(JNIEnv *, jclass, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: WriteFile
|
||||||
|
* Signature: (I[BI)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_WriteFile
|
||||||
|
(JNIEnv *, jclass, jint, jbyteArray, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: FlushFileBuffers
|
||||||
|
* Signature: (I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_FlushFileBuffers
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: DisconnectNamedPipe
|
||||||
|
* Signature: (I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_DisconnectNamedPipe
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: CreateFile
|
||||||
|
* Signature: (Ljava/lang/String;IIIIII)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateFile
|
||||||
|
(JNIEnv *, jclass, jstring, jint, jint, jint, jint, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: WaitNamedPipe
|
||||||
|
* Signature: (Ljava/lang/String;I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_WaitNamedPipe
|
||||||
|
(JNIEnv *, jclass, jstring, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: FormatMessage
|
||||||
|
* Signature: (I)Ljava/lang/String;
|
||||||
|
*/
|
||||||
|
JNIEXPORT jstring JNICALL Java_pipe_Pipes_FormatMessage
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: Print
|
||||||
|
* Signature: (Ljava/lang/String;)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_pipe_Pipes_Print
|
||||||
|
(JNIEnv *, jclass, jstring);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
154
cpp/pipe/.cproject
Normal file
154
cpp/pipe/.cproject
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?fileVersion 4.0.0?>
|
||||||
|
|
||||||
|
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
|
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||||
|
<macros>
|
||||||
|
<stringMacro name="target" type="VALUE_TEXT" value="Pipe"/>
|
||||||
|
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.7.0"/>
|
||||||
|
</macros>
|
||||||
|
<externalSettings>
|
||||||
|
<externalSetting>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Pipe"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Pipe/Debug"/>
|
||||||
|
<entry flags="RESOLVED" kind="libraryFile" name="Pipe" srcPrefixMapping="" srcRootPath=""/>
|
||||||
|
</externalSetting>
|
||||||
|
</externalSettings>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.so.debug">
|
||||||
|
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917." name="/" resourcePath="">
|
||||||
|
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.debug.139919199" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.debug">
|
||||||
|
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.debug.1189720953" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.debug"/>
|
||||||
|
<builder buildPath="${workspace_loc:/Pipe/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.482966139" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug.268346771" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.debug">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.665305624" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1220825669" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1175271295" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug">
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.debug.option.optimization.level.1125922986" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.debug.option.debugging.level.1641613502" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.939510920" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1399500702" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug">
|
||||||
|
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.so.debug.option.optimization.level.234429006" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.debug.option.optimization.level" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.mingw.so.debug.option.debugging.level.1525375982" name="Debug Level" superClass="gnu.c.compiler.mingw.so.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.option.include.paths.88885521" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include/win32""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||||
|
</option>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.747324638" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.1007471610" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
|
||||||
|
<option defaultValue="true" id="gnu.c.link.mingw.so.debug.option.shared.1850054546" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.debug.option.shared" valueType="boolean"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.2022087314" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug">
|
||||||
|
<option defaultValue="true" id="gnu.cpp.link.mingw.so.debug.option.shared.357933903" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.debug.option.shared" valueType="boolean"/>
|
||||||
|
<option id="gnu.cpp.link.option.flags.1387180659" superClass="gnu.cpp.link.option.flags" value="-Wl,--kill-at -static-libgcc" valueType="string"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2125675597" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.output.216466795" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.output"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||||
|
<macros>
|
||||||
|
<stringMacro name="target" type="VALUE_TEXT" value="Pipe"/>
|
||||||
|
<stringMacro name="jdk" type="VALUE_PATH_DIR" value="C:\Program Files (x86)\Java\jdk1.7.0"/>
|
||||||
|
</macros>
|
||||||
|
<externalSettings>
|
||||||
|
<externalSetting>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Pipe"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Pipe/Release"/>
|
||||||
|
<entry flags="RESOLVED" kind="libraryFile" name="Pipe" srcPrefixMapping="" srcRootPath=""/>
|
||||||
|
</externalSetting>
|
||||||
|
</externalSettings>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactExtension="dll" artifactName="${target}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336" name="Release" parent="cdt.managedbuild.config.gnu.mingw.so.release">
|
||||||
|
<folderInfo id="cdt.managedbuild.config.gnu.mingw.so.release.2043271336." name="/" resourcePath="">
|
||||||
|
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.so.release.1271980283" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.so.release">
|
||||||
|
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.so.release.368721242" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.so.release"/>
|
||||||
|
<builder buildPath="${workspace_loc:/Pipe/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.2065732021" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.so.release.109377381" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.so.release">
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.689046683" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1183393349" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.726851992" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release">
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.release.option.optimization.level.2002053108" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.so.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||||
|
<option id="gnu.cpp.compiler.mingw.so.release.option.debugging.level.907936589" name="Debug Level" superClass="gnu.cpp.compiler.mingw.so.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.204761037" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1321746613" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release">
|
||||||
|
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.so.release.option.optimization.level.735179609" name="Optimization Level" superClass="gnu.c.compiler.mingw.so.release.option.optimization.level" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.mingw.so.release.option.debugging.level.265400846" name="Debug Level" superClass="gnu.c.compiler.mingw.so.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||||
|
<option id="gnu.c.compiler.option.include.paths.1576117703" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${jdk}/include/win32""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||||
|
</option>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1173268559" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release.1652830435" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.release">
|
||||||
|
<option defaultValue="true" id="gnu.c.link.mingw.so.release.option.shared.1257748519" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.release.option.shared" valueType="boolean"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.1600111105" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release">
|
||||||
|
<option defaultValue="true" id="gnu.cpp.link.mingw.so.release.option.shared.684498624" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.release.option.shared" valueType="boolean"/>
|
||||||
|
<option id="gnu.cpp.link.option.flags.51892807" superClass="gnu.cpp.link.option.flags" value="-Wl,--kill-at -static-libgcc" valueType="string"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.656026656" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
<outputType id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output.432743873" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.release.output"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<project id="Pipe.cdt.managedbuild.target.gnu.mingw.so.1070782613" name="Shared Library" projectType="cdt.managedbuild.target.gnu.mingw.so"/>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="scannerConfiguration">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917;cdt.managedbuild.config.gnu.mingw.so.debug.1813551917.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.debug.1175271295;cdt.managedbuild.tool.gnu.cpp.compiler.input.939510920">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.2043271336;cdt.managedbuild.config.gnu.mingw.so.release.2043271336.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.so.release.726851992;cdt.managedbuild.tool.gnu.cpp.compiler.input.204761037">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.release.2043271336;cdt.managedbuild.config.gnu.mingw.so.release.2043271336.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.release.1321746613;cdt.managedbuild.tool.gnu.c.compiler.input.1173268559">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.so.debug.1813551917;cdt.managedbuild.config.gnu.mingw.so.debug.1813551917.;cdt.managedbuild.tool.gnu.c.compiler.mingw.so.debug.1399500702;cdt.managedbuild.tool.gnu.c.compiler.input.747324638">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
|
<storageModule moduleId="refreshScope"/>
|
||||||
|
</cproject>
|
||||||
27
cpp/pipe/.project
Normal file
27
cpp/pipe/.project
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Pipe</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
6611
cpp/pipe/include/strsafe.h
Normal file
6611
cpp/pipe/include/strsafe.h
Normal file
File diff suppressed because it is too large
Load Diff
262
cpp/pipe/src/pipe.c
Normal file
262
cpp/pipe/src/pipe.c
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
#include <jni.h>
|
||||||
|
#include "pipe.h"
|
||||||
|
|
||||||
|
#define DEBUG 0
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jstring sPipeName,
|
||||||
|
jint dwOpenMode,
|
||||||
|
jint dwPipeMode,
|
||||||
|
jint nMaxInstances,
|
||||||
|
jint nOutBufferSize,
|
||||||
|
jint nInBufferSize,
|
||||||
|
jint nDefaultTimeOut,
|
||||||
|
jint lpSecurityAttributes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HANDLE pipeHandler;
|
||||||
|
LPCSTR pipeName;
|
||||||
|
pipeName = (*env)->GetStringUTFChars(env, sPipeName, NULL);
|
||||||
|
if (pipeName == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: Pipe Name %s\n", pipeName);
|
||||||
|
printf("Native: dwOpenMode %d\n", dwOpenMode);
|
||||||
|
printf("Native: dwPipeMode %d\n", dwPipeMode);
|
||||||
|
printf("Native: nMaxInstances %d\n", nMaxInstances);
|
||||||
|
printf("Native: nOutBufferSize %d\n", nOutBufferSize);
|
||||||
|
printf("Native: nInBufferSize %d\n", nInBufferSize);
|
||||||
|
printf("Native: nDefaultTimeOut %d\n", nDefaultTimeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
pipeHandler = CreateNamedPipe((LPCSTR)pipeName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize,
|
||||||
|
nDefaultTimeOut, (LPSECURITY_ATTRIBUTES) lpSecurityAttributes);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, sPipeName, pipeName);
|
||||||
|
return (jint) pipeHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_ConnectNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe,
|
||||||
|
jint lpOverlapped
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL fConnected;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
fConnected = ConnectNamedPipe(pipeHandler, (LPOVERLAPPED) lpOverlapped);
|
||||||
|
return fConnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_GetLastError
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DWORD errorNumber = GetLastError();
|
||||||
|
return (jint) errorNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_CloseHandle
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
result = CloseHandle(pipeHandler);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jbyteArray JNICALL Java_pipe_Pipes_ReadFile
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe,
|
||||||
|
jint nNumberOfBytesToRead
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int bytesRead = 0;
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
LPVOID buffer;
|
||||||
|
jbyteArray lpBuffer;
|
||||||
|
|
||||||
|
buffer = (LPVOID)LocalAlloc(LMEM_ZEROINIT, nNumberOfBytesToRead);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: Before ReadFile pipeHandler %d nNumberOfBytesToRead %d\n", pipeHandler, nNumberOfBytesToRead);
|
||||||
|
}
|
||||||
|
result = ReadFile(pipeHandler, (LPVOID) buffer, (DWORD) nNumberOfBytesToRead, &bytesRead, (LPOVERLAPPED) 0);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
lpBuffer = (*env)->NewByteArray(env, (jsize) bytesRead);
|
||||||
|
(*env)->SetByteArrayRegion(env, lpBuffer, 0, (jsize) bytesRead, (jbyte *) buffer);
|
||||||
|
} else
|
||||||
|
bytesRead = 0;
|
||||||
|
|
||||||
|
LocalFree(buffer);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: After ReadFile BytesRead %d\n", bytesRead);
|
||||||
|
}
|
||||||
|
return lpBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_WriteFile
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe,
|
||||||
|
jbyteArray lpBuffer,
|
||||||
|
jint nNumberOfBytesToWrite
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int bytesWritten = 0;
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
LPVOID buffer;
|
||||||
|
|
||||||
|
buffer = (LPVOID)LocalAlloc(LMEM_ZEROINIT, nNumberOfBytesToWrite);
|
||||||
|
|
||||||
|
(*env)->GetByteArrayRegion(env, lpBuffer, 0, nNumberOfBytesToWrite, buffer);
|
||||||
|
result = WriteFile(pipeHandler, buffer, (DWORD) nNumberOfBytesToWrite, (LPDWORD) &bytesWritten, (LPOVERLAPPED) 0);
|
||||||
|
LocalFree(buffer);
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
printf("Native: After WriteFile BytesReadWritten %d\n", bytesWritten);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
if (GetLastError() != ERROR_IO_PENDING)
|
||||||
|
result = 0;
|
||||||
|
else
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
bytesWritten = -1;
|
||||||
|
}
|
||||||
|
return bytesWritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_FlushFileBuffers
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
result = FlushFileBuffers(pipeHandler);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_DisconnectNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint hNamedPipe
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
HANDLE pipeHandler = (HANDLE) hNamedPipe;
|
||||||
|
result = DisconnectNamedPipe(pipeHandler);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateFile
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jstring lpFileName,
|
||||||
|
jint dwDesiredAccess,
|
||||||
|
jint dwShareMode,
|
||||||
|
jint lpSecurityAttributes,
|
||||||
|
jint dwCreationDisposition,
|
||||||
|
jint dwFlagsAndAttributes,
|
||||||
|
jint hTemplateFile
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HANDLE pipeHandler;
|
||||||
|
const jbyte *fileName;
|
||||||
|
fileName = (*env)->GetStringUTFChars(env, lpFileName, NULL);
|
||||||
|
if (fileName == NULL)
|
||||||
|
return -1;
|
||||||
|
pipeHandler = CreateFile((LPCSTR) fileName, (DWORD) dwDesiredAccess, (DWORD) dwShareMode,
|
||||||
|
(LPSECURITY_ATTRIBUTES) lpSecurityAttributes, (DWORD) dwCreationDisposition, (DWORD) dwFlagsAndAttributes, (HANDLE) hTemplateFile);
|
||||||
|
return (jint) pipeHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_WaitNamedPipe
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jstring lpNamedPipeName,
|
||||||
|
jint nTimeOut
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOL result;
|
||||||
|
const jbyte *pipeName;
|
||||||
|
pipeName = (*env)->GetStringUTFChars(env, lpNamedPipeName, NULL);
|
||||||
|
if (pipeName == NULL)
|
||||||
|
return 0;
|
||||||
|
result = WaitNamedPipe((LPCSTR) pipeName, (DWORD) nTimeOut);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_pipe_Pipes_FormatMessage
|
||||||
|
(
|
||||||
|
JNIEnv *env,
|
||||||
|
jclass className,
|
||||||
|
jint errorCode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
LPVOID lpMsgBuf;
|
||||||
|
LPVOID lpDisplayBuf;
|
||||||
|
DWORD dw = (DWORD) errorCode;
|
||||||
|
|
||||||
|
FormatMessage(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL,
|
||||||
|
dw,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR) &lpMsgBuf,
|
||||||
|
0, NULL );
|
||||||
|
|
||||||
|
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
|
||||||
|
(lstrlen((LPCTSTR)lpMsgBuf) + 40) * sizeof(TCHAR));
|
||||||
|
StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR),
|
||||||
|
TEXT("Failed with error %d: %s"), dw, lpMsgBuf);
|
||||||
|
return (jstring) (*env)->NewStringUTF(env, lpDisplayBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_pipe_Pipes_Print(JNIEnv *env, jclass className, jstring lpMsgBuf)
|
||||||
|
{
|
||||||
|
const jbyte *str;
|
||||||
|
str = (*env)->GetStringUTFChars(env, lpMsgBuf, NULL);
|
||||||
|
if (str == NULL)
|
||||||
|
return;
|
||||||
|
printf("Native: %s\n", str);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, lpMsgBuf, str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
109
cpp/pipe/src/pipe.h
Normal file
109
cpp/pipe/src/pipe.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class Pipes */
|
||||||
|
|
||||||
|
#ifndef _Included_pipe
|
||||||
|
#define _Included_pipe
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: CreateNamedPipe
|
||||||
|
* Signature: (Ljava/lang/String;IIIIIII)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateNamedPipe
|
||||||
|
(JNIEnv *, jclass, jstring, jint, jint, jint, jint, jint, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: ConnectNamedPipe
|
||||||
|
* Signature: (II)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_ConnectNamedPipe
|
||||||
|
(JNIEnv *, jclass, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: GetLastError
|
||||||
|
* Signature: ()I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_GetLastError
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: CloseHandle
|
||||||
|
* Signature: (I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_CloseHandle
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: ReadFile
|
||||||
|
* Signature: (II)[B
|
||||||
|
*/
|
||||||
|
JNIEXPORT jbyteArray JNICALL Java_pipe_Pipes_ReadFile
|
||||||
|
(JNIEnv *, jclass, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: WriteFile
|
||||||
|
* Signature: (I[BI)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_WriteFile
|
||||||
|
(JNIEnv *, jclass, jint, jbyteArray, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: FlushFileBuffers
|
||||||
|
* Signature: (I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_FlushFileBuffers
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: DisconnectNamedPipe
|
||||||
|
* Signature: (I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_DisconnectNamedPipe
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: CreateFile
|
||||||
|
* Signature: (Ljava/lang/String;IIIIII)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_pipe_Pipes_CreateFile
|
||||||
|
(JNIEnv *, jclass, jstring, jint, jint, jint, jint, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: WaitNamedPipe
|
||||||
|
* Signature: (Ljava/lang/String;I)Z
|
||||||
|
*/
|
||||||
|
JNIEXPORT jboolean JNICALL Java_pipe_Pipes_WaitNamedPipe
|
||||||
|
(JNIEnv *, jclass, jstring, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: FormatMessage
|
||||||
|
* Signature: (I)Ljava/lang/String;
|
||||||
|
*/
|
||||||
|
JNIEXPORT jstring JNICALL Java_pipe_Pipes_FormatMessage
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: Pipes
|
||||||
|
* Method: Print
|
||||||
|
* Signature: (Ljava/lang/String;)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_pipe_Pipes_Print
|
||||||
|
(JNIEnv *, jclass, jstring);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
3
java/.gitignore
vendored
Normal file
3
java/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/bin
|
||||||
|
/.settings
|
||||||
|
/sound
|
||||||
13
java/txt/keuze.txt
Normal file
13
java/txt/keuze.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from pcm:
|
||||||
|
|
||||||
|
-r -s <freq in khz> [--unsigned] [--big-endian]
|
||||||
|
|
||||||
|
to mp3:
|
||||||
|
--cbr -b <bitrate>
|
||||||
|
|
||||||
|
|
||||||
|
mp3 to pcm:
|
||||||
|
--decode
|
||||||
|
|
||||||
|
always:
|
||||||
|
- - --quiet
|
||||||
1357
java/txt/mp3
Normal file
1357
java/txt/mp3
Normal file
File diff suppressed because it is too large
Load Diff
182
java/txt/options
Normal file
182
java/txt/options
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
LAME 32bits version 3.98.4 (http://www.mp3dev.org/)
|
||||||
|
|
||||||
|
usage: lame [options] <infile> [outfile]
|
||||||
|
|
||||||
|
<infile> and/or <outfile> can be "-", which means stdin/stdout.
|
||||||
|
|
||||||
|
RECOMMENDED:
|
||||||
|
lame -V2 input.wav output.mp3
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
Input options:
|
||||||
|
--scale <arg> scale input (multiply PCM data) by <arg>
|
||||||
|
--scale-l <arg> scale channel 0 (left) input (multiply PCM data) by <arg>
|
||||||
|
--scale-r <arg> scale channel 1 (right) input (multiply PCM data) by <arg>
|
||||||
|
--mp1input input file is a MPEG Layer I file
|
||||||
|
--mp2input input file is a MPEG Layer II file
|
||||||
|
--mp3input input file is a MPEG Layer III file
|
||||||
|
--nogap <file1> <file2> <...>
|
||||||
|
gapless encoding for a set of contiguous files
|
||||||
|
--nogapout <dir>
|
||||||
|
output dir for gapless encoding (must precede --nogap)
|
||||||
|
--nogaptags allow the use of VBR tags in gapless encoding
|
||||||
|
|
||||||
|
Input options for RAW PCM:
|
||||||
|
-r input is raw pcm
|
||||||
|
-x force byte-swapping of input
|
||||||
|
-s sfreq sampling frequency of input file (kHz) - default 44.1 kHz
|
||||||
|
--bitwidth w input bit width is w (default 16)
|
||||||
|
--signed input is signed (default)
|
||||||
|
--unsigned input is unsigned
|
||||||
|
--little-endian input is little-endian (default)
|
||||||
|
--big-endian input is big-endian
|
||||||
|
|
||||||
|
|
||||||
|
Operational options:
|
||||||
|
-a downmix from stereo to mono file for mono encoding
|
||||||
|
-m <mode> (j)oint, (s)imple, (f)orce, (d)dual-mono, (m)ono
|
||||||
|
default is (j) or (s) depending on bitrate
|
||||||
|
joint = joins the best possible of MS and LR stereo
|
||||||
|
simple = force LR stereo on all frames
|
||||||
|
force = force MS stereo on all frames.
|
||||||
|
--preset type type must be "medium", "standard", "extreme", "insane",
|
||||||
|
or a value for an average desired bitrate and depending
|
||||||
|
on the value specified, appropriate quality settings will
|
||||||
|
be used.
|
||||||
|
"--preset help" gives more info on these
|
||||||
|
--comp <arg> choose bitrate to achive a compression ratio of <arg>
|
||||||
|
--replaygain-fast compute RG fast but slightly inaccurately (default)
|
||||||
|
--replaygain-accurate compute RG more accurately and find the peak sample
|
||||||
|
--noreplaygain disable ReplayGain analysis
|
||||||
|
--clipdetect enable --replaygain-accurate and print a message whether
|
||||||
|
clipping occurs and how far the waveform is from full scale
|
||||||
|
--flush flush output stream as soon as possible
|
||||||
|
--freeformat produce a free format bitstream
|
||||||
|
--decode input=mp3 file, output=wav
|
||||||
|
-t disable writing wav header when using --decode
|
||||||
|
|
||||||
|
|
||||||
|
Verbosity:
|
||||||
|
--disptime <arg>print progress report every arg seconds
|
||||||
|
-S don't print progress report, VBR histograms
|
||||||
|
--nohist disable VBR histogram display
|
||||||
|
--silent don't print anything on screen
|
||||||
|
--quiet don't print anything on screen
|
||||||
|
--brief print more useful information
|
||||||
|
--verbose print a lot of useful information
|
||||||
|
|
||||||
|
Noise shaping & psycho acoustic algorithms:
|
||||||
|
-q <arg> <arg> = 0...9. Default -q 5
|
||||||
|
-q 0: Highest quality, very slow
|
||||||
|
-q 9: Poor quality, but fast
|
||||||
|
-h Same as -q 2. Recommended.
|
||||||
|
-f Same as -q 7. Fast, ok quality
|
||||||
|
|
||||||
|
|
||||||
|
CBR (constant bitrate, the default) options:
|
||||||
|
-b <bitrate> set the bitrate in kbps, default 128 kbps
|
||||||
|
--cbr enforce use of constant bitrate
|
||||||
|
|
||||||
|
ABR options:
|
||||||
|
--abr <bitrate> specify average bitrate desired (instead of quality)
|
||||||
|
|
||||||
|
VBR options:
|
||||||
|
-V n quality setting for VBR. default n=4
|
||||||
|
0=high quality,bigger files. 9=smaller files
|
||||||
|
-v the same as -V 4
|
||||||
|
--vbr-old use old variable bitrate (VBR) routine
|
||||||
|
--vbr-new use new variable bitrate (VBR) routine (default)
|
||||||
|
-b <bitrate> specify minimum allowed bitrate, default 32 kbps
|
||||||
|
-B <bitrate> specify maximum allowed bitrate, default 320 kbps
|
||||||
|
-F strictly enforce the -b option, for use with players that
|
||||||
|
do not support low bitrate mp3
|
||||||
|
-t disable writing LAME Tag
|
||||||
|
-T enable and force writing LAME Tag
|
||||||
|
|
||||||
|
|
||||||
|
PSY related:
|
||||||
|
--temporal-masking x x=0 disables, x=1 enables temporal masking effect
|
||||||
|
--nssafejoint M/S switching criterion
|
||||||
|
--nsmsfix <arg> M/S switching tuning [effective 0-3.5]
|
||||||
|
--interch x adjust inter-channel masking ratio
|
||||||
|
--ns-bass x adjust masking for sfbs 0 - 6 (long) 0 - 5 (short)
|
||||||
|
--ns-alto x adjust masking for sfbs 7 - 13 (long) 6 - 10 (short)
|
||||||
|
--ns-treble x adjust masking for sfbs 14 - 21 (long) 11 - 12 (short)
|
||||||
|
--ns-sfb21 x change ns-treble by x dB for sfb21
|
||||||
|
|
||||||
|
|
||||||
|
experimental switches:
|
||||||
|
-Y lets LAME ignore noise in sfb21, like in CBR
|
||||||
|
|
||||||
|
|
||||||
|
MP3 header/stream options:
|
||||||
|
-e <emp> de-emphasis n/5/c (obsolete)
|
||||||
|
-c mark as copyright
|
||||||
|
-o mark as non-original
|
||||||
|
-p error protection. adds 16 bit checksum to every frame
|
||||||
|
(the checksum is computed correctly)
|
||||||
|
--nores disable the bit reservoir
|
||||||
|
--strictly-enforce-ISO comply as much as possible to ISO MPEG spec
|
||||||
|
|
||||||
|
Filter options:
|
||||||
|
--lowpass <freq> frequency(kHz), lowpass filter cutoff above freq
|
||||||
|
--lowpass-width <freq> frequency(kHz) - default 15% of lowpass freq
|
||||||
|
--highpass <freq> frequency(kHz), highpass filter cutoff below freq
|
||||||
|
--highpass-width <freq> frequency(kHz) - default 15% of highpass freq
|
||||||
|
--resample <sfreq> sampling frequency of output file(kHz)- default=automatic
|
||||||
|
|
||||||
|
|
||||||
|
ID3 tag options:
|
||||||
|
--tt <title> audio/song title (max 30 chars for version 1 tag)
|
||||||
|
--ta <artist> audio/song artist (max 30 chars for version 1 tag)
|
||||||
|
--tl <album> audio/song album (max 30 chars for version 1 tag)
|
||||||
|
--ty <year> audio/song year of issue (1 to 9999)
|
||||||
|
--tc <comment> user-defined text (max 30 chars for v1 tag, 28 for v1.1)
|
||||||
|
--tn <track[/total]> audio/song track number and (optionally) the total
|
||||||
|
number of tracks on the original recording. (track
|
||||||
|
and total each 1 to 255. just the track number
|
||||||
|
creates v1.1 tag, providing a total forces v2.0).
|
||||||
|
--tg <genre> audio/song genre (name or number in list)
|
||||||
|
--ti <file> audio/song albumArt (jpeg/png/gif file, 128KB max, v2.3)
|
||||||
|
--tv <id=value> user-defined frame specified by id and value (v2.3 tag)
|
||||||
|
--add-id3v2 force addition of version 2 tag
|
||||||
|
--id3v1-only add only a version 1 tag
|
||||||
|
--id3v2-only add only a version 2 tag
|
||||||
|
--space-id3v1 pad version 1 tag with spaces instead of nulls
|
||||||
|
--pad-id3v2 same as '--pad-id3v2-size 128'
|
||||||
|
--pad-id3v2-size <value> adds version 2 tag, pad with extra <value> bytes
|
||||||
|
--genre-list print alphabetically sorted ID3 genre list and exit
|
||||||
|
--ignore-tag-errors ignore errors in values passed for tags
|
||||||
|
|
||||||
|
Note: A version 2 tag will NOT be added unless one of the input fields
|
||||||
|
won't fit in a version 1 tag (e.g. the title string is longer than 30
|
||||||
|
characters), or the '--add-id3v2' or '--id3v2-only' options are used,
|
||||||
|
or output is redirected to stdout.
|
||||||
|
|
||||||
|
|
||||||
|
MS-Windows-specific options:
|
||||||
|
--priority <type> sets the process priority:
|
||||||
|
0,1 = Low priority (IDLE_PRIORITY_CLASS)
|
||||||
|
2 = normal priority (NORMAL_PRIORITY_CLASS, default)
|
||||||
|
3,4 = High priority (HIGH_PRIORITY_CLASS))
|
||||||
|
Note: Calling '--priority' without a parameter will select priority 0.
|
||||||
|
|
||||||
|
Misc:
|
||||||
|
--license print License information
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Platform specific:
|
||||||
|
--noasm <instructions> disable assembly optimizations for mmx/3dnow/sse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MPEG-1 layer III sample frequencies (kHz): 32 48 44.1
|
||||||
|
bitrates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320
|
||||||
|
|
||||||
|
MPEG-2 layer III sample frequencies (kHz): 16 24 22.05
|
||||||
|
bitrates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160
|
||||||
|
|
||||||
|
MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025
|
||||||
|
bitrates (kbps): 8 16 24 32 40 48 56 64
|
||||||
|
|
||||||
1
java/txt/short
Normal file
1
java/txt/short
Normal file
@@ -0,0 +1 @@
|
|||||||
|
medium.mp3
|
||||||
12
java/txt/testfiles.txt
Normal file
12
java/txt/testfiles.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
junk (with or without header)
|
||||||
|
PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian
|
||||||
|
-r 8k -t s16 -c 1 -e signed-integer
|
||||||
|
|
||||||
|
|
||||||
|
out (without header)
|
||||||
|
PCM_SIGNED 8000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian
|
||||||
|
-r 128k -t s32 -c 2 -2 signed integer [reasonable]
|
||||||
|
|
||||||
|
out (without header)
|
||||||
|
PCM_SIGNED 192000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
|
||||||
|
-r 192k -t s16 -c 2 [-e signed-integer]
|
||||||
Reference in New Issue
Block a user