Repository: YuriSizuku/Kirikiroid2Yuri
Branch: yuri
Commit: 6e61ce3b8141
Files: 685
Total size: 8.5 MB
Directory structure:
gitextract_q549lhv5/
├── .github/
│ └── workflows/
│ └── build_android.yml
├── .gitignore
├── .vscode/
│ └── c_cpp_properties.json
├── CMakeLists.txt
├── LICENSE
├── project/
│ ├── android/
│ │ ├── .gitignore
│ │ ├── .idea/
│ │ │ ├── .gitignore
│ │ │ ├── codeStyles/
│ │ │ │ └── Project.xml
│ │ │ ├── compiler.xml
│ │ │ ├── gradle.xml
│ │ │ ├── jarRepositories.xml
│ │ │ ├── misc.xml
│ │ │ └── vcs.xml
│ │ ├── app/
│ │ │ ├── .gitignore
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── build.gradle
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ └── krkr2_android.cpp
│ │ │ ├── java/
│ │ │ │ ├── com/
│ │ │ │ │ └── yuri/
│ │ │ │ │ └── kirikiri2/
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── org/
│ │ │ │ └── tvp/
│ │ │ │ └── kirikiri2/
│ │ │ │ ├── KR2Activity.java
│ │ │ │ └── MediaStoreHack.java
│ │ │ ├── proguard-rules.pro
│ │ │ ├── res/
│ │ │ │ └── values/
│ │ │ │ └── strings.xml
│ │ │ └── sign.jks
│ │ ├── build.gradle
│ │ ├── gradle/
│ │ │ └── wrapper/
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradle.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
│ └── ui/
│ ├── .cocos-project.json
│ ├── Resources/
│ │ └── res/
│ │ └── locale/
│ │ ├── en_us.xml
│ │ ├── ja_jp.xml
│ │ ├── zh_cn.xml
│ │ └── zh_tw.xml
│ ├── cocosstudio/
│ │ └── ui/
│ │ ├── BottomBar.csd
│ │ ├── BottomBarTextInput.csd
│ │ ├── CheckListDialog.csd
│ │ ├── FileItem.csd
│ │ ├── FileManageMenu.csd
│ │ ├── GameMenu.csd
│ │ ├── KeySelect.csd
│ │ ├── ListItem.csd
│ │ ├── ListView.csd
│ │ ├── MainFileSelector.csd
│ │ ├── MediaPlayerBody.csd
│ │ ├── MediaPlayerFoot.csd
│ │ ├── MediaPlayerNavi.csd
│ │ ├── MenuList.csd
│ │ ├── MessageBox.csd
│ │ ├── NaviBar.csd
│ │ ├── NaviBarWithMenu.csd
│ │ ├── ProgressBox.csd
│ │ ├── RecentListItem.csd
│ │ ├── SelectList.csd
│ │ ├── SelectListItem.csd
│ │ ├── TableView.csd
│ │ ├── TextPairInput.csd
│ │ ├── WinMgrOverlay.csd
│ │ ├── comctrl/
│ │ │ ├── CheckBoxItem.csd
│ │ │ ├── SelectListItem.csd
│ │ │ ├── SeperateItem.csd
│ │ │ ├── SliderIconItem.csd
│ │ │ ├── SliderTextItem.csd
│ │ │ └── SubDirItem.csd
│ │ └── help/
│ │ ├── AllTips.csd
│ │ ├── MouseModeTips.csd
│ │ ├── ScreenModeTips.csd
│ │ └── TouchModeTips.csd
│ ├── kr2.ccs
│ └── kr2.cfg
├── readme.md
├── script/
│ ├── _androida64.sh
│ ├── _fetch.sh
│ └── cross_androida64.sh
├── src/
│ ├── core/
│ │ ├── Android.mk
│ │ ├── CMakeLists.txt
│ │ ├── base/
│ │ │ ├── 7zArchive.cpp
│ │ │ ├── BinaryStream.cpp
│ │ │ ├── BinaryStream.h
│ │ │ ├── CharacterSet.cpp
│ │ │ ├── CharacterSet.h
│ │ │ ├── EventIntf.cpp
│ │ │ ├── EventIntf.h
│ │ │ ├── PluginIntf.cpp
│ │ │ ├── PluginIntf.h
│ │ │ ├── ScriptMgnIntf.cpp
│ │ │ ├── ScriptMgnIntf.h
│ │ │ ├── StorageIntf.cpp
│ │ │ ├── StorageIntf.h
│ │ │ ├── SysInitIntf.cpp
│ │ │ ├── SysInitIntf.h
│ │ │ ├── SystemIntf.cpp
│ │ │ ├── SystemIntf.h
│ │ │ ├── TARArchive.cpp
│ │ │ ├── TextStream.cpp
│ │ │ ├── TextStream.h
│ │ │ ├── UserEvent.h
│ │ │ ├── UtilStreams.cpp
│ │ │ ├── UtilStreams.h
│ │ │ ├── XP3Archive.cpp
│ │ │ ├── XP3Archive.h
│ │ │ ├── ZIPArchive.cpp
│ │ │ ├── common.h
│ │ │ ├── tar.h
│ │ │ └── win32/
│ │ │ ├── EventImpl.cpp
│ │ │ ├── EventImpl.h
│ │ │ ├── FileSelector.cpp
│ │ │ ├── FileSelector.h
│ │ │ ├── FuncStubs.cpp
│ │ │ ├── FuncStubs.h
│ │ │ ├── NativeEventQueue.cpp
│ │ │ ├── NativeEventQueue.h
│ │ │ ├── PluginImpl.cpp
│ │ │ ├── PluginImpl.h
│ │ │ ├── ScriptMgnImpl.cpp
│ │ │ ├── ScriptMgnImpl.h
│ │ │ ├── StorageImpl.cpp
│ │ │ ├── StorageImpl.h
│ │ │ ├── SusieArchive.cpp
│ │ │ ├── SusieArchive.h
│ │ │ ├── SysInitImpl.cpp
│ │ │ ├── SysInitImpl.h
│ │ │ ├── SystemImpl.cpp
│ │ │ ├── SystemImpl.h
│ │ │ └── win32io.h
│ │ ├── environ/
│ │ │ ├── Application.cpp
│ │ │ ├── Application.h
│ │ │ ├── ConfigManager/
│ │ │ │ ├── GlobalConfigManager.cpp
│ │ │ │ ├── GlobalConfigManager.h
│ │ │ │ ├── IndividualConfigManager.cpp
│ │ │ │ ├── IndividualConfigManager.h
│ │ │ │ ├── LocaleConfigManager.cpp
│ │ │ │ └── LocaleConfigManager.h
│ │ │ ├── DetectCPU.cpp
│ │ │ ├── DetectCPU.h
│ │ │ ├── DumpSend.cpp
│ │ │ ├── Platform.h
│ │ │ ├── XP3ArchiveRepack.cpp
│ │ │ ├── XP3ArchiveRepack.h
│ │ │ ├── android/
│ │ │ │ ├── AndroidUtils.cpp
│ │ │ │ └── AndroidUtils.h
│ │ │ ├── cocos2d/
│ │ │ │ ├── AppDelegate.cpp
│ │ │ │ ├── AppDelegate.h
│ │ │ │ ├── CCKeyCodeConv.cpp
│ │ │ │ ├── CCKeyCodeConv.h
│ │ │ │ ├── CustomFileUtils.cpp
│ │ │ │ ├── CustomFileUtils.h
│ │ │ │ ├── CustomFileUtils.mm
│ │ │ │ ├── MainScene.cpp
│ │ │ │ ├── MainScene.h
│ │ │ │ ├── YUVSprite.cpp
│ │ │ │ └── YUVSprite.h
│ │ │ ├── combase.h
│ │ │ ├── cpu_types.h
│ │ │ ├── linux/
│ │ │ │ └── Platform.cpp
│ │ │ ├── sdl/
│ │ │ │ └── tvpsdl.cpp
│ │ │ ├── typedefine.h
│ │ │ ├── ui/
│ │ │ │ ├── BaseForm.cpp
│ │ │ │ ├── BaseForm.h
│ │ │ │ ├── ConsoleWindow.cpp
│ │ │ │ ├── ConsoleWindow.h
│ │ │ │ ├── DebugViewLayerForm.cpp
│ │ │ │ ├── DebugViewLayerForm.h
│ │ │ │ ├── FileSelectorForm.cpp
│ │ │ │ ├── FileSelectorForm.h
│ │ │ │ ├── GameMainMenu.cpp
│ │ │ │ ├── GameMainMenu.h
│ │ │ │ ├── GlobalPreferenceForm.cpp
│ │ │ │ ├── GlobalPreferenceForm.h
│ │ │ │ ├── InGameMenuForm.cpp
│ │ │ │ ├── InGameMenuForm.h
│ │ │ │ ├── IndividualPreferenceForm.cpp
│ │ │ │ ├── IndividualPreferenceForm.h
│ │ │ │ ├── MainFileSelectorForm.cpp
│ │ │ │ ├── MainFileSelectorForm.h
│ │ │ │ ├── MessageBox.cpp
│ │ │ │ ├── MessageBox.h
│ │ │ │ ├── PreferenceConfig.h
│ │ │ │ ├── PreferenceForm.cpp
│ │ │ │ ├── PreferenceForm.h
│ │ │ │ ├── SeletListForm.cpp
│ │ │ │ ├── SeletListForm.h
│ │ │ │ ├── SimpleMediaFilePlayer.cpp
│ │ │ │ ├── SimpleMediaFilePlayer.h
│ │ │ │ ├── TipsHelpForm.cpp
│ │ │ │ ├── TipsHelpForm.h
│ │ │ │ ├── XP3RepackForm.cpp
│ │ │ │ ├── XP3RepackForm.h
│ │ │ │ └── extension/
│ │ │ │ ├── ActionExtension.cpp
│ │ │ │ ├── ActionExtension.h
│ │ │ │ ├── UIExtension.cpp
│ │ │ │ └── UIExtension.h
│ │ │ ├── vkdefine.h
│ │ │ ├── win32/
│ │ │ │ ├── ApplicationSpecialPath.h
│ │ │ │ ├── CompatibleNativeFuncs.cpp
│ │ │ │ ├── CompatibleNativeFuncs.h
│ │ │ │ ├── ConfigFormUnit.cpp
│ │ │ │ ├── ConfigFormUnit.h
│ │ │ │ ├── DetectCPU.cpp
│ │ │ │ ├── DetectCPU.h
│ │ │ │ ├── EmergencyExit.cpp
│ │ │ │ ├── EmergencyExit.h
│ │ │ │ ├── HintWindow.cpp
│ │ │ │ ├── HintWindow.h
│ │ │ │ ├── ImeControl.h
│ │ │ │ ├── MainFormUnit.cpp
│ │ │ │ ├── MainFormUnit.h
│ │ │ │ ├── MouseCursor.cpp
│ │ │ │ ├── MouseCursor.h
│ │ │ │ ├── Platform.cpp
│ │ │ │ ├── SystemControl.cpp
│ │ │ │ ├── SystemControl.h
│ │ │ │ ├── TVPWindow.cpp
│ │ │ │ ├── TVPWindow.h
│ │ │ │ ├── TouchPoint.cpp
│ │ │ │ ├── TouchPoint.h
│ │ │ │ ├── VersionFormUnit.cpp
│ │ │ │ ├── VersionFormUnit.h
│ │ │ │ ├── WindowFormUnit.cpp
│ │ │ │ ├── WindowFormUnit.h
│ │ │ │ ├── WindowsUtil.cpp
│ │ │ │ ├── WindowsUtil.h
│ │ │ │ ├── config.h
│ │ │ │ └── my_HintWindow.cpp
│ │ │ └── win32type.h
│ │ ├── extension/
│ │ │ ├── Extension.cpp
│ │ │ └── Extension.h
│ │ ├── movie/
│ │ │ ├── ffmpeg/
│ │ │ │ ├── AE.h
│ │ │ │ ├── AEAudioFormat.h
│ │ │ │ ├── AEChannelData.h
│ │ │ │ ├── AEChannelInfo.cpp
│ │ │ │ ├── AEChannelInfo.h
│ │ │ │ ├── AEFactory.cpp
│ │ │ │ ├── AEFactory.h
│ │ │ │ ├── AEStream.h
│ │ │ │ ├── AEStreamData.h
│ │ │ │ ├── AEStreamInfo.cpp
│ │ │ │ ├── AEStreamInfo.h
│ │ │ │ ├── AEUtil.cpp
│ │ │ │ ├── AEUtil.h
│ │ │ │ ├── AudioCodec.h
│ │ │ │ ├── AudioCodecFFmpeg.cpp
│ │ │ │ ├── AudioCodecFFmpeg.h
│ │ │ │ ├── AudioCodecPassthrough.cpp
│ │ │ │ ├── AudioCodecPassthrough.h
│ │ │ │ ├── AudioDevice.cpp
│ │ │ │ ├── AudioDevice.h
│ │ │ │ ├── BaseRenderer.cpp
│ │ │ │ ├── BaseRenderer.h
│ │ │ │ ├── BitstreamStats.cpp
│ │ │ │ ├── BitstreamStats.h
│ │ │ │ ├── Clock.cpp
│ │ │ │ ├── Clock.h
│ │ │ │ ├── CodecUtils.cpp
│ │ │ │ ├── CodecUtils.h
│ │ │ │ ├── Codecs.h
│ │ │ │ ├── Demux.cpp
│ │ │ │ ├── Demux.h
│ │ │ │ ├── DemuxFFmpeg.cpp
│ │ │ │ ├── DemuxFFmpeg.h
│ │ │ │ ├── DemuxPacket.cpp
│ │ │ │ ├── DemuxPacket.h
│ │ │ │ ├── FactoryCodec.cpp
│ │ │ │ ├── FactoryCodec.h
│ │ │ │ ├── Geometry.h
│ │ │ │ ├── IAudioCallback.h
│ │ │ │ ├── IVideoPlayer.h
│ │ │ │ ├── InputStream.cpp
│ │ │ │ ├── InputStream.h
│ │ │ │ ├── KRMovieDef.h
│ │ │ │ ├── KRMovieLayer.cpp
│ │ │ │ ├── KRMovieLayer.h
│ │ │ │ ├── KRMoviePlayer.cpp
│ │ │ │ ├── KRMoviePlayer.h
│ │ │ │ ├── MathUtils.h
│ │ │ │ ├── Message.cpp
│ │ │ │ ├── Message.h
│ │ │ │ ├── MessageQueue.cpp
│ │ │ │ ├── MessageQueue.h
│ │ │ │ ├── OptionInfo.h
│ │ │ │ ├── ProcessInfo.cpp
│ │ │ │ ├── ProcessInfo.h
│ │ │ │ ├── Ref.h
│ │ │ │ ├── RenderFlags.cpp
│ │ │ │ ├── RenderFlags.h
│ │ │ │ ├── RenderFormats.h
│ │ │ │ ├── StreamInfo.cpp
│ │ │ │ ├── StreamInfo.h
│ │ │ │ ├── TVPMediaDemux.cpp
│ │ │ │ ├── TVPMediaDemux.h
│ │ │ │ ├── Thread.cpp
│ │ │ │ ├── Thread.h
│ │ │ │ ├── TimeUtils.cpp
│ │ │ │ ├── TimeUtils.h
│ │ │ │ ├── Timer.cpp
│ │ │ │ ├── Timer.h
│ │ │ │ ├── VideoCodec.cpp
│ │ │ │ ├── VideoCodec.h
│ │ │ │ ├── VideoCodecFFmpeg.cpp
│ │ │ │ ├── VideoCodecFFmpeg.h
│ │ │ │ ├── VideoPlayer.cpp
│ │ │ │ ├── VideoPlayer.h
│ │ │ │ ├── VideoPlayerAudio.cpp
│ │ │ │ ├── VideoPlayerAudio.h
│ │ │ │ ├── VideoPlayerVideo.cpp
│ │ │ │ ├── VideoPlayerVideo.h
│ │ │ │ ├── VideoReferenceClock.cpp
│ │ │ │ ├── VideoReferenceClock.h
│ │ │ │ ├── VideoRenderer.cpp
│ │ │ │ ├── VideoRenderer.h
│ │ │ │ ├── config.h
│ │ │ │ └── krffmpeg.cpp
│ │ │ └── krmovie.cpp
│ │ ├── msg/
│ │ │ ├── MsgIntf.cpp
│ │ │ ├── MsgIntf.h
│ │ │ ├── MsgIntfInc.h
│ │ │ └── win32/
│ │ │ ├── MsgImpl.cpp
│ │ │ ├── MsgImpl.h
│ │ │ ├── MsgLoad.cpp
│ │ │ ├── OptionsDesc.cpp
│ │ │ ├── OptionsDesc.h
│ │ │ ├── ReadOptionDesc.cpp
│ │ │ └── ReadOptionDesc.h
│ │ ├── sound/
│ │ │ ├── ARM/
│ │ │ │ ├── WaveFunctionARM.cpp
│ │ │ │ └── wavemix_arm.c
│ │ │ ├── CDDAIntf.cpp
│ │ │ ├── CDDAIntf.h
│ │ │ ├── FFWaveDecoder.cpp
│ │ │ ├── FFWaveDecoder.h
│ │ │ ├── MIDIIntf.cpp
│ │ │ ├── MIDIIntf.h
│ │ │ ├── MathAlgorithms.cpp
│ │ │ ├── MathAlgorithms.h
│ │ │ ├── PhaseVocoderDSP.cpp
│ │ │ ├── PhaseVocoderDSP.h
│ │ │ ├── PhaseVocoderFilter.cpp
│ │ │ ├── PhaseVocoderFilter.h
│ │ │ ├── RingBuffer.h
│ │ │ ├── SoundBufferBaseIntf.cpp
│ │ │ ├── SoundBufferBaseIntf.h
│ │ │ ├── VorbisWaveDecoder.cpp
│ │ │ ├── VorbisWaveDecoder.h
│ │ │ ├── WaveFormatConverter.cpp
│ │ │ ├── WaveFormatConverter_SSE.cpp
│ │ │ ├── WaveIntf.cpp
│ │ │ ├── WaveIntf.h
│ │ │ ├── WaveLoopManager.cpp
│ │ │ ├── WaveLoopManager.h
│ │ │ ├── WaveSegmentQueue.cpp
│ │ │ ├── WaveSegmentQueue.h
│ │ │ ├── win32/
│ │ │ │ ├── CDDAImpl.cpp
│ │ │ │ ├── CDDAImpl.h
│ │ │ │ ├── MIDIImpl.cpp
│ │ │ │ ├── MIDIImpl.h
│ │ │ │ ├── SoundBufferBaseImpl.cpp
│ │ │ │ ├── SoundBufferBaseImpl.h
│ │ │ │ ├── WaveImpl.cpp
│ │ │ │ ├── WaveImpl.h
│ │ │ │ ├── WaveMixer.cpp
│ │ │ │ ├── WaveMixer.h
│ │ │ │ ├── kmp_pi.h
│ │ │ │ ├── oldwaveunpacker.h
│ │ │ │ ├── tvpsnd.c
│ │ │ │ ├── tvpsnd.cpp
│ │ │ │ ├── tvpsnd.h
│ │ │ │ └── tvpsnd.idl
│ │ │ └── xmmlib.h
│ │ ├── tjs2/
│ │ │ ├── tjs.cpp
│ │ │ ├── tjs.h
│ │ │ ├── tjs.tab.cpp
│ │ │ ├── tjs.tab.h
│ │ │ ├── tjs.tab.hpp
│ │ │ ├── tjsArray.cpp
│ │ │ ├── tjsArray.h
│ │ │ ├── tjsBinarySerializer.cpp
│ │ │ ├── tjsBinarySerializer.h
│ │ │ ├── tjsByteCodeLoader.cpp
│ │ │ ├── tjsByteCodeLoader.h
│ │ │ ├── tjsCommHead.h
│ │ │ ├── tjsCompileControl.cpp
│ │ │ ├── tjsCompileControl.h
│ │ │ ├── tjsConfig.cpp
│ │ │ ├── tjsConfig.h
│ │ │ ├── tjsConstArrayData.cpp
│ │ │ ├── tjsConstArrayData.h
│ │ │ ├── tjsDate.cpp
│ │ │ ├── tjsDate.h
│ │ │ ├── tjsDateParser.cpp
│ │ │ ├── tjsDateParser.h
│ │ │ ├── tjsDateWordMap.cc
│ │ │ ├── tjsDebug.cpp
│ │ │ ├── tjsDebug.h
│ │ │ ├── tjsDictionary.cpp
│ │ │ ├── tjsDictionary.h
│ │ │ ├── tjsDisassemble.cpp
│ │ │ ├── tjsError.cpp
│ │ │ ├── tjsError.h
│ │ │ ├── tjsErrorDefs.h
│ │ │ ├── tjsErrorInc.h
│ │ │ ├── tjsError_jp.h
│ │ │ ├── tjsException.cpp
│ │ │ ├── tjsException.h
│ │ │ ├── tjsGlobalStringMap.cpp
│ │ │ ├── tjsGlobalStringMap.h
│ │ │ ├── tjsHashSearch.h
│ │ │ ├── tjsInterCodeExec.cpp
│ │ │ ├── tjsInterCodeExec.h
│ │ │ ├── tjsInterCodeGen.cpp
│ │ │ ├── tjsInterCodeGen.h
│ │ │ ├── tjsInterface.cpp
│ │ │ ├── tjsInterface.h
│ │ │ ├── tjsLex.cpp
│ │ │ ├── tjsLex.h
│ │ │ ├── tjsMT19937ar-cok.cpp
│ │ │ ├── tjsMT19937ar-cok.h
│ │ │ ├── tjsMath.cpp
│ │ │ ├── tjsMath.h
│ │ │ ├── tjsMessage.cpp
│ │ │ ├── tjsMessage.h
│ │ │ ├── tjsNamespace.cpp
│ │ │ ├── tjsNamespace.h
│ │ │ ├── tjsNative.cpp
│ │ │ ├── tjsNative.h
│ │ │ ├── tjsObject.cpp
│ │ │ ├── tjsObject.h
│ │ │ ├── tjsObjectExtendable.cpp
│ │ │ ├── tjsObjectExtendable.h
│ │ │ ├── tjsOctPack.cpp
│ │ │ ├── tjsOctPack.h
│ │ │ ├── tjsRandomGenerator.cpp
│ │ │ ├── tjsRandomGenerator.h
│ │ │ ├── tjsRegExp.cpp
│ │ │ ├── tjsRegExp.h
│ │ │ ├── tjsScriptBlock.cpp
│ │ │ ├── tjsScriptBlock.h
│ │ │ ├── tjsScriptCache.cpp
│ │ │ ├── tjsScriptCache.h
│ │ │ ├── tjsString.cpp
│ │ │ ├── tjsString.h
│ │ │ ├── tjsTypes.h
│ │ │ ├── tjsUtils.cpp
│ │ │ ├── tjsUtils.h
│ │ │ ├── tjsVariant.cpp
│ │ │ ├── tjsVariant.h
│ │ │ ├── tjsVariantString.cpp
│ │ │ ├── tjsVariantString.h
│ │ │ ├── tjsdate.tab.cpp
│ │ │ ├── tjsdate.tab.h
│ │ │ ├── tjsdate.tab.hpp
│ │ │ ├── tjspp.tab.cpp
│ │ │ └── tjspp.tab.hpp
│ │ ├── utils/
│ │ │ ├── ClipboardIntf.cpp
│ │ │ ├── ClipboardIntf.h
│ │ │ ├── DebugIntf.cpp
│ │ │ ├── DebugIntf.h
│ │ │ ├── Debugger.h
│ │ │ ├── Exception.h
│ │ │ ├── FilePathUtil.h
│ │ │ ├── KAGParser.cpp
│ │ │ ├── KAGParser.h
│ │ │ ├── MathAlgorithms.h
│ │ │ ├── MathAlgorithms_Default.cpp
│ │ │ ├── MathAlgorithms_Default.h
│ │ │ ├── MiscUtility.cpp
│ │ │ ├── ObjectList.h
│ │ │ ├── PadIntf.cpp
│ │ │ ├── PadIntf.h
│ │ │ ├── Random.cpp
│ │ │ ├── Random.h
│ │ │ ├── RealFFT.h
│ │ │ ├── RealFFT_Default.cpp
│ │ │ ├── StringUtil.h
│ │ │ ├── ThreadIntf.cpp
│ │ │ ├── ThreadIntf.h
│ │ │ ├── TickCount.cpp
│ │ │ ├── TickCount.h
│ │ │ ├── TimerIntf.cpp
│ │ │ ├── TimerIntf.h
│ │ │ ├── VelocityTracker.cpp
│ │ │ ├── VelocityTracker.h
│ │ │ ├── encoding/
│ │ │ │ ├── gbk2unicode.c
│ │ │ │ └── jis2unicode.c
│ │ │ ├── iconv/
│ │ │ │ ├── iconv.h
│ │ │ │ └── utf8.h
│ │ │ ├── md5.c
│ │ │ ├── md5.h
│ │ │ ├── minizip/
│ │ │ │ ├── crypt.h
│ │ │ │ ├── ioapi.cpp
│ │ │ │ ├── ioapi.h
│ │ │ │ ├── unzip.c
│ │ │ │ ├── unzip.h
│ │ │ │ ├── zip.c
│ │ │ │ └── zip.h
│ │ │ └── win32/
│ │ │ ├── ClipboardImpl.cpp
│ │ │ ├── ClipboardImpl.h
│ │ │ ├── DebugImpl.cpp
│ │ │ ├── DebugImpl.h
│ │ │ ├── PadImpl.cpp
│ │ │ ├── PadImpl.h
│ │ │ ├── TVPTimer.cpp
│ │ │ ├── TVPTimer.h
│ │ │ ├── ThreadImpl.cpp
│ │ │ ├── ThreadImpl.h
│ │ │ ├── TimerImpl.cpp
│ │ │ └── TimerImpl.h
│ │ └── visual/
│ │ ├── ARM/
│ │ │ ├── AlphaMovie_mjpeg.h
│ │ │ ├── tvpgl_arm.cpp
│ │ │ ├── tvpgl_arm_intf.h
│ │ │ └── tvpgl_arm_route.h
│ │ ├── BitmapIntf.cpp
│ │ ├── BitmapIntf.h
│ │ ├── BitmapLayerTreeOwner.cpp
│ │ ├── BitmapLayerTreeOwner.h
│ │ ├── CharacterData.cpp
│ │ ├── CharacterData.h
│ │ ├── ComplexRect.cpp
│ │ ├── ComplexRect.h
│ │ ├── FontImpl.cpp
│ │ ├── FontImpl.h
│ │ ├── FontRasterizer.h
│ │ ├── FontSystem.cpp
│ │ ├── FontSystem.h
│ │ ├── FreeType.cpp
│ │ ├── FreeType.h
│ │ ├── FreeTypeFace.h
│ │ ├── FreeTypeFontRasterizer.cpp
│ │ ├── FreeTypeFontRasterizer.h
│ │ ├── GraphicsLoadThread.cpp
│ │ ├── GraphicsLoadThread.h
│ │ ├── GraphicsLoaderIntf.cpp
│ │ ├── GraphicsLoaderIntf.h
│ │ ├── ImageFunction.cpp
│ │ ├── ImageFunction.h
│ │ ├── LayerBitmapIntf.cpp
│ │ ├── LayerBitmapIntf.h
│ │ ├── LayerIntf.cpp
│ │ ├── LayerIntf.h
│ │ ├── LayerManager.cpp
│ │ ├── LayerManager.h
│ │ ├── LayerTreeOwner.h
│ │ ├── LayerTreeOwnerImpl.cpp
│ │ ├── LayerTreeOwnerImpl.h
│ │ ├── LoadBPG.cpp
│ │ ├── LoadJPEG.cpp
│ │ ├── LoadJXR.cpp
│ │ ├── LoadPNG.cpp
│ │ ├── LoadPVRv3.cpp
│ │ ├── LoadTLG.cpp
│ │ ├── LoadTLG.h
│ │ ├── LoadWEBP.cpp
│ │ ├── MenuItemIntf.cpp
│ │ ├── MenuItemIntf.h
│ │ ├── PrerenderedFont.cpp
│ │ ├── PrerenderedFont.h
│ │ ├── RectItf.cpp
│ │ ├── RectItf.h
│ │ ├── RenderManager.cpp
│ │ ├── RenderManager.h
│ │ ├── RenderManager_software.h
│ │ ├── SaveTLG.h
│ │ ├── SaveTLG5.cpp
│ │ ├── SaveTLG6.cpp
│ │ ├── TransIntf.cpp
│ │ ├── TransIntf.h
│ │ ├── VideoOvlIntf.cpp
│ │ ├── VideoOvlIntf.h
│ │ ├── WindowIntf.cpp
│ │ ├── WindowIntf.h
│ │ ├── argb.cpp
│ │ ├── argb.h
│ │ ├── drawable.h
│ │ ├── gl/
│ │ │ ├── ResampleImage.cpp
│ │ │ ├── ResampleImage.h
│ │ │ ├── ResampleImageInternal.h
│ │ │ ├── WeightFunctor.cpp
│ │ │ ├── WeightFunctor.h
│ │ │ ├── aligned_allocator.h
│ │ │ ├── blend_function.cpp
│ │ │ ├── blend_functor_c.h
│ │ │ ├── blend_util_func.h
│ │ │ ├── blend_variation.h
│ │ │ └── tvpgl_mathutil.h
│ │ ├── ogl/
│ │ │ ├── RenderManager_ogl.cpp
│ │ │ ├── RenderManager_ogl_test.hpp
│ │ │ ├── astcrt.cpp
│ │ │ ├── astcrt.h
│ │ │ ├── etcpak.cpp
│ │ │ ├── etcpak.h
│ │ │ ├── imagepacker.cpp
│ │ │ ├── imagepacker.h
│ │ │ ├── ogl_common.h
│ │ │ ├── pvr.h
│ │ │ ├── pvrtc.cpp
│ │ │ └── pvrtc.h
│ │ ├── transhandler.h
│ │ ├── tvpfontstruc.h
│ │ ├── tvpgl.cpp
│ │ ├── tvpgl.h
│ │ ├── tvpgl_asm_init.h
│ │ ├── tvpgl_route.h
│ │ ├── tvphal.h
│ │ ├── tvpinputdefs.h
│ │ ├── tvpps.inc
│ │ ├── voMode.h
│ │ └── win32/
│ │ ├── BasicDrawDevice.cpp
│ │ ├── BasicDrawDevice.h
│ │ ├── BitmapBitsAlloc.cpp
│ │ ├── BitmapBitsAlloc.h
│ │ ├── BitmapInfomation.cpp
│ │ ├── BitmapInfomation.h
│ │ ├── DInputMgn.cpp
│ │ ├── DInputMgn.h
│ │ ├── DrawDevice.cpp
│ │ ├── DrawDevice.h
│ │ ├── GDIFontRasterizer.cpp
│ │ ├── GDIFontRasterizer.h
│ │ ├── GraphicsLoaderImpl.cpp
│ │ ├── GraphicsLoaderImpl.h
│ │ ├── LayerBitmapImpl.cpp
│ │ ├── LayerBitmapImpl.h
│ │ ├── LayerImpl.cpp
│ │ ├── LayerImpl.h
│ │ ├── MenuItemImpl.cpp
│ │ ├── MenuItemImpl.h
│ │ ├── NativeFreeTypeFace.cpp
│ │ ├── NativeFreeTypeFace.h
│ │ ├── PassThroughDrawDevice.cpp
│ │ ├── PassThroughDrawDevice.h
│ │ ├── TVPColor.h
│ │ ├── TVPScreen.cpp
│ │ ├── TVPScreen.h
│ │ ├── TVPSysFont.cpp
│ │ ├── TVPSysFont.h
│ │ ├── VSyncTimingThread.cpp
│ │ ├── VSyncTimingThread.h
│ │ ├── VideoOvlImpl.cpp
│ │ ├── VideoOvlImpl.h
│ │ ├── WindowImpl.cpp
│ │ ├── WindowImpl.h
│ │ └── krmovie.h
│ └── plugins/
│ ├── Android.mk
│ ├── CMakeLists.txt
│ ├── InternalPlugins.cpp
│ ├── LayerExBase.cpp
│ ├── LayerExBase.h
│ ├── PluginStub.h
│ ├── addFont.cpp
│ ├── csvParser.cpp
│ ├── dirlist.cpp
│ ├── fftgraph.cpp
│ ├── getSample.cpp
│ ├── getabout.cpp
│ ├── layerExBase.hpp
│ ├── layerExMovie.cpp
│ ├── layerExPerspective.cpp
│ ├── ncbind/
│ │ ├── ncb_foreach.h
│ │ ├── ncb_invoke.hpp
│ │ ├── ncbind.cpp
│ │ └── ncbind.hpp
│ ├── saveStruct.cpp
│ ├── tp_stub.h
│ ├── varfile.cpp
│ ├── win32dialog.cpp
│ ├── wutcwf.cpp
│ ├── xp3filter.cpp
│ └── xp3filter.h
└── thirdparty/
└── patch/
├── cocos2d-x/
│ ├── android_CCFileUtils-android.cpp
│ ├── android_CCFileUtils-android.h
│ ├── android_Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
│ ├── android_Java_org_cocos2dx_lib_Cocos2dxHelper.h
│ └── android_cocos2dx.cmake
├── ffmpeg/
│ └── android_ffmpeg.diff
├── oniguruma/
│ └── oniguruma.cmake
├── opus/
│ └── opusfile.h
├── p7zip/
│ ├── 7z.h
│ ├── 7zArcIn.c
│ ├── 7zBuf.c
│ ├── 7zDec.c
│ ├── 7zFile.h
│ └── android_p7zip.cmake
├── sdl2/
│ ├── android_SDL_android.c
│ └── android_android_lf.h
└── unrar/
└── android_ulinks.cpp
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/build_android.yml
================================================
name: build android
on:
push: {tags: ['v*']} # Push events to matching v*, i.e. v1.0, v20.15.10
permissions:
contents: write
env:
BUILD_NAME: krk2yuri_android
jobs:
fetch_thirdparty_build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: check thirdparty build
id: check_thirdparty_build
uses: actions/cache@v3
with:
path: ./thirdparty/build
key: thirdparty_build
- name: fetch thirdparty build
if: steps.check_thirdparty_build.outputs.cache-hit != 'true'
run: |
wget https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/deps/thirdparty_build.tar.gz
tar xvzf thirdparty_build.tar.gz
fetch_thirdparty_port:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: check thirdparty port
id: check_thirdparty_port
uses: actions/cache@v3
with:
path: ./thirdparty/port
key: thirdparty_port
- name: fetch thirdparty port
if: steps.check_thirdparty_port.outputs.cache-hit != 'true'
run: |
wget https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/deps/thirdparty_port.tar.gz
tar xvzf thirdparty_port.tar.gz
build_android:
runs-on: ubuntu-20.04
needs:
- fetch_thirdparty_build
- fetch_thirdparty_port
steps:
- uses: actions/checkout@v3
- name: get thirdparty build cache
uses: actions/cache@v3
with:
key: thirdparty_build
path: ./thirdparty/build
- name: get thirdparty port cache
uses: actions/cache@v3
with:
key: thirdparty_port
path: ./thirdparty/port
- uses: actions/setup-java@v3
with:
java-version: |
8
11
distribution: 'temurin'
cache: gradle
- name: build krkr2yuri android
env:
SIGN_KEY_ALIAS: ${{ secrets.SIGN_KEY_ALIAS }}
SIGN_KEY_PASS: ${{ secrets.SIGN_KEY_PASS }}
SIGN_STORE_PASS: ${{ secrets.SIGN_STORE_PASS }}
run: |
wget https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/1.3.9_yuri/Kirikiroid2_yuri_1.3.9.apk
7z x Kirikiroid2_yuri_1.3.9.apk assets
sudo mkdir /build_android && sudo chmod 777 /build_android
cd project/android
chmod +x ./gradlew
./gradlew assembleDebug --no-daemon
- name: create release
uses: ncipollo/release-action@v1
with:
artifacts: "./build_android/outputs/apk/debug/*.apk"
allowUpdates: "true"
prerelease: "true"
token: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .gitignore
================================================
# general
assets/**
build/**
build_*/**
thirdparty/build/**
thirdparty/port/**
.vscode/settings.json
# android
local.properties
sign.properties
project/onsyuri_android/.gradle
project/android/local.properties
project/android/.idea/caches/**
project/android/.idea/modules/**
project/android/.idea/libraries/**
project/android/.idea/modules.xml
project/android/.idea/workspace.xml
project/android/.idea/navEditor.xml
project/android/.idea/assetWizardSettings.xml
project/android/.idea/deploymentTargetDropDown.xml
project/android/.idea/inspectionProfiles
project/android/app/.cxx/**
project/android/app/debug/**
project/android/app/release/**
================================================
FILE: .vscode/c_cpp_properties.json
================================================
{
"env": { // edit your env here
"androidsdk": "D:/Software/env/sdk/androidsdk",
"androidndk": "${androidsdk}/ndk/25.2.9519653"
},
"configurations": [
{
"name": "Android (win)",
"includePath": [
"${workspaceFolder}/src/core/**",
"${workspaceFolder}/src/core/sound/**",
"${workspaceFolder}/thirdparty/build/arch_androida64/include/**",
"${workspaceFolder}/thirdparty/build/arch_androida64/sdk/native/jni/include/**",
"${workspaceFolder}/thirdparty/port/cocos2d-x/**",
"${workspaceFolder}/thirdparty/port/cocos2d-x/external/**",
"${workspaceFolder}/thirdparty/port/cocos2d-x/cocos/**",
"${env:androidndk}/sources/android/cpufeatures"
],
"defines": [
"__linux__"
],
"compilerPath": "${androidndk}/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe",
"intelliSenseMode": "linux-clang-arm64",
"compilerArgs": ["--target=aarch64-linux-android21"]
}
],
"version": 4
}
================================================
FILE: CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.6)
project(krkr2yuri)
set(CMAKE_CXX_STANDARD 11)
set(KRKR2CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/core)
set(KRKR2PLUGIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins)
set(COCOS2DX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/port/cocos2d-x)
# build library
add_subdirectory(${KRKR2CORE_PATH})
add_subdirectory(${KRKR2PLUGIN_PATH})
# build main
if(CMAKE_SYSTEM_NAME MATCHES "Android")
add_library(${PROJECT_NAME} SHARED
project/android/app/cpp/krkr2_android.cpp
)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
message("${CMAKE_SYSTEM_NAME} not support yet")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
message("${CMAKE_SYSTEM_NAME} not support yet")
else()
message("${CMAKE_SYSTEM_NAME} not support yet")
endif()
target_compile_options(${PROJECT_NAME} PUBLIC
-fPIE
)
target_include_directories(${PROJECT_NAME} PUBLIC
src/cocos
${KRKR2CORE_PATH}/environ/cocos2d
${PORTBUILD_PATH}/include
${PORTBUILD_PATH}/include/breakpad
${COCOS2DX_PATH}/cocos
${COCOS2DX_PATH}/cocos/audio/include
)
target_link_directories(${PROJECT_NAME} PUBLIC
${PORTBUILD_PATH}/lib
)
target_link_libraries(${PROJECT_NAME} PUBLIC
-Wl,-Bstatic
-Wl,--whole-archive # cpp_android_spec for jni function, this is important to add whole libraries !
cpp_android_spec krkr2plugin
-Wl,--no-whole-archive
krkr2core
)
================================================
FILE: LICENSE
================================================
Copyright (c), W.Dee and contributors All rights reserved.
Contributors
Go Watanabe, Kenjo, Kiyobee, Kouhei Yanagita, mey, MIK, Takenori Imoto, yun
Kirikiri Z Project Contributors
W.Dee, casper, 有限会社MCF, Biscrat, 青猫, nagai, ルー, 高際 雅之, 永劫,
ゆんゆん探偵, りょうご(今は無きあの星), AZ-UME, 京 秋人,
Katsumasa Tsuneyoshi, 小池潤, miahmie, サークル獏, アザナシ, はっしぃ,
棚中製作所, わっふる/waffle, ワムソフト, TYPE-MOON, 有限会社エムツー,
Takenori Imoto
Kirikiri Z 64bit Project Contributors
合資会社ワムソフト, Takenori Imoto, 他
----------------------------------------------------------------------------
ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満
たす場合に限り、再頒布および使用が許可されます。
・ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責
条項を含めること。
・バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の
著作権表示、本条件一覧、および下記免責条項を含めること。
・書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売
促進に、組織の名前またはコントリビューターの名前を使用してはならない。
本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供
されており、明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適
合性に関する暗黙の保証も含め、またそれに限定されない、いかなる保証もありませ
ん。著作権者もコントリビューターも、事由のいかんを問わず、損害発生の原因いか
んを問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その他の)不法
行為であるかを問わず、仮にそのような損害が発生する可能性を知らされていたとし
ても、本ソフトウェアの使用によって発生した(代替品または代用サービスの調達、
使用の喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定されな
い)直接損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
ついて、一切責任を負わないものとします。
------------------------------------------------------------------------------
Thanks for many libraries to contributors and other supporters that were not
listed here.
This software is based in part on the work of Independent JPEG Group.
------------------------------------------------------------------------------
libjpeg-turbo
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
? Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
? Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
? Neither the name of the libjpeg-turbo Project nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
Using "A C-program for MT19937"
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
libpng LICENSE
This copy of the libpng notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.1, March 28, 2013, are
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
Simon-Pierre Cadieux
Eric S. Raymond
Gilles Vollant
and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
John Bowler
Kevin Bracey
Sam Bushell
Magnus Holmgren
Greg Roelofs
Tom Tanner
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
Andreas Dilger
Dave Martindale
Guy Eric Schalnat
Paul Schmidt
Tim Wegner
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
printf("%s",png_get_copyright(NULL));
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
March 28, 2013
------------------------------------------------------------------------------
zlib LICENSE
The deflate format used by zlib was defined by Phil Katz. The deflate and
zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib; they
are too numerous to cite here.
Copyright notice:
(C) 1995-2012 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
If you use the zlib library in a product, we would appreciate *not* receiving
lengthy legal documents to sign. The sources are provided for free but without
warranty of any kind. The library has been entirely written by Jean-loup
Gailly and Mark Adler; it does not include third-party code.
If you redistribute modified sources, we would appreciate that you include in
the file ChangeLog history information documenting your changes. Please read
the FAQ for more information on the distribution of modified source versions.
------------------------------------------------------------------------------
Oniguruma LICENSE
-----------------
/*-
* Copyright (c) 2002-2007 K.Kosako
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
------------------------------------------------------------------------------
The FreeType Project LICENSE
----------------------------
2006-Jan-27
Copyright 1996-2002, 2006 by
David Turner, Robert Wilhelm, and Werner Lemberg
Introduction
============
The FreeType Project is distributed in several archive packages;
some of them may contain, in addition to the FreeType font engine,
various tools and contributions which rely on, or relate to, the
FreeType Project.
This license applies to all files found in such packages, and
which do not fall under their own explicit license. The license
affects thus the FreeType font engine, the test programs,
documentation and makefiles, at the very least.
This license was inspired by the BSD, Artistic, and IJG
(Independent JPEG Group) licenses, which all encourage inclusion
and use of free software in commercial and freeware products
alike. As a consequence, its main points are that:
o We don't promise that this software works. However, we will be
interested in any kind of bug reports. (`as is' distribution)
o You can use this software for whatever you want, in parts or
full form, without having to pay us. (`royalty-free' usage)
o You may not pretend that you wrote this software. If you use
it, or only parts of it, in a program, you must acknowledge
somewhere in your documentation that you have used the
FreeType code. (`credits')
We specifically permit and encourage the inclusion of this
software, with or without modifications, in commercial products.
We disclaim all warranties covering The FreeType Project and
assume no liability related to The FreeType Project.
Finally, many people asked us for a preferred form for a
credit/disclaimer to use in compliance with this license. We thus
encourage you to use the following text:
"""
Portions of this software are copyright ゥ The FreeType
Project (www.freetype.org). All rights reserved.
"""
Please replace with the value from the FreeType version you
actually use.
Legal Terms
===========
0. Definitions
--------------
Throughout this license, the terms `package', `FreeType Project',
and `FreeType archive' refer to the set of files originally
distributed by the authors (David Turner, Robert Wilhelm, and
Werner Lemberg) as the `FreeType Project', be they named as alpha,
beta or final release.
`You' refers to the licensee, or person using the project, where
`using' is a generic term including compiling the project's source
code as well as linking it to form a `program' or `executable'.
This program is referred to as `a program using the FreeType
engine'.
This license applies to all files distributed in the original
FreeType Project, including all source code, binaries and
documentation, unless otherwise stated in the file in its
original, unmodified form as distributed in the original archive.
If you are unsure whether or not a particular file is covered by
this license, you must contact us to verify this.
The FreeType Project is copyright (C) 1996-2000 by David Turner,
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
specified below.
1. No Warranty
--------------
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
USE, OF THE FREETYPE PROJECT.
2. Redistribution
-----------------
This license grants a worldwide, royalty-free, perpetual and
irrevocable right and license to use, execute, perform, compile,
display, copy, create derivative works of, distribute and
sublicense the FreeType Project (in both source and object code
forms) and derivative works thereof for any purpose; and to
authorize others to exercise some or all of the rights granted
herein, subject to the following conditions:
o Redistribution of source code must retain this license file
(`FTL.TXT') unaltered; any additions, deletions or changes to
the original files must be clearly indicated in accompanying
documentation. The copyright notices of the unaltered,
original files must be preserved in all copies of source
files.
o Redistribution in binary form must provide a disclaimer that
states that the software is based in part of the work of the
FreeType Team, in the distribution documentation. We also
encourage you to put an URL to the FreeType web page in your
documentation, though this isn't mandatory.
These conditions apply to any software derived from or based on
the FreeType Project, not just the unmodified files. If you use
our work, you must acknowledge us. However, no fee need be paid
to us.
3. Advertising
--------------
Neither the FreeType authors and contributors nor you shall use
the name of the other for commercial, advertising, or promotional
purposes without specific prior written permission.
We suggest, but do not require, that you use one or more of the
following phrases to refer to this software in your documentation
or advertising materials: `FreeType Project', `FreeType Engine',
`FreeType library', or `FreeType Distribution'.
As you have not signed this license, you are not required to
accept it. However, as the FreeType Project is copyrighted
material, only this license, or another one contracted with the
authors, grants you the right to use, distribute, and modify it.
Therefore, by using, distributing, or modifying the FreeType
Project, you indicate that you understand and accept all the terms
of this license.
4. Contacts
-----------
There are two mailing lists related to FreeType:
o freetype@nongnu.org
Discusses general use and applications of FreeType, as well as
future and wanted additions to the library and distribution.
If you are looking for support, start in this list if you
haven't found anything to help you in the documentation.
o freetype-devel@nongnu.org
Discusses bugs, as well as engine internals, design issues,
specific licenses, porting, etc.
Our home page can be found at
http://www.freetype.org
------------------------------------------------------------------------------
picojson LICENSE
/* Copyright 2009 Cybozu Labs, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY CYBOZU LABS, INC. ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL CYBOZU LABS, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of Cybozu Labs, Inc.
*
*/
------------------------------------------------------------------------------
Copyright (c) 2012, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
------------------------------------------------------------------------------
Microsoft Corporation Technical Documentation License Agreement for the
specification “JPEG XR Device Porting Kit”
Copyright (c) 2013 Microsoft Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BELIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE..
------------------------------------------------------------------------------
------------------------------------------------------------------------
*** vorbis
*** ogg
Copyright (c) 1994-2004 Xiph.org Foundation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------
*** theora
Copyright (C) 2002-2008 Xiph.org Foundation and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------
*** libfishsound
*** dsfSeeking
Copyright (C) 2003, 2004 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------
*** libCMMLParse
*** libCMMLTags
*** libCMMLTagsDotNET
*** libOOOggChef
*** libTemporalURI
*** libWinCMMLParse
*** dsfCMMLDecoder
*** dsfAnxDemux
*** AnxCutter
*** CMMLDump
*** mod_oggchef
Copyright (C) 2003-2005 Zentaro Kavanagh
Copyright (C) 2003-2005 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------
*** dsfOggDemux
*** dsfOggMux
*** dsfSpeexDecoder
*** dsfSpeexEncoder
*** dsfVorbisDecoder
*** dsfVorbisEncoder
*** dsfFLACDecoder
*** dsfFLACEncoder
*** dsfTheoraDecoder
*** dsfTheoraEncoder
*** dsfAbstractAudioDecoder
*** dsfAbstractAudioEncoder
*** dsfAbstractVideoDecoder
*** dsfAbstractVideoEncoder
*** dsfSubtitleVMR9
*** libiWrapper
*** libilliCore
*** libOOTheora
*** libOOOgg
*** libOOOggSeek
*** libVorbisComment
*** libVorbisCommentDotNET
*** OOOggDump
*** OOOggStat
*** OOOggCommentDump
*** CLOgg
*** DNPlay
*** iOCE
Copyright (C) 2008-2010 Cristian Adam
Copyright (C) 2003-2005 Zentaro Kavanagh
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of Zentaro Kavanagh nor the names of contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------
================================================
FILE: project/android/.gitignore
================================================
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
/.externalNativeBuild
================================================
FILE: project/android/.idea/.gitignore
================================================
# Default ignored files
/shelf/
/workspace.xml
================================================
FILE: project/android/.idea/codeStyles/Project.xml
================================================
.*:id
http://schemas.android.com/apk/res/android
.*:name
http://schemas.android.com/apk/res/android
.*
http://schemas.android.com/apk/res/android
ANDROID_ATTRIBUTE_ORDER
================================================
FILE: project/android/.idea/compiler.xml
================================================
================================================
FILE: project/android/.idea/gradle.xml
================================================
================================================
FILE: project/android/.idea/jarRepositories.xml
================================================
================================================
FILE: project/android/.idea/misc.xml
================================================
================================================
FILE: project/android/.idea/vcs.xml
================================================
================================================
FILE: project/android/app/.gitignore
================================================
/.externalNativeBuild
/.cxx
/build
/release
================================================
FILE: project/android/app/AndroidManifest.xml
================================================
================================================
FILE: project/android/app/build.gradle
================================================
plugins {
id 'com.android.application'
}
android {
// compileSdkVersion PROP_TARGET_SDK_VERSION
ndkVersion '25.2.9519653'
buildToolsVersion '33.0.2'
compileSdkVersion PROP_TARGET_SDK_VERSION.toInteger()
compileOptions {
// sourceCompatibility JavaVersion.VERSION_11
// targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
applicationId "com.yuri.kirikiri2"
targetSdkVersion PROP_TARGET_SDK_VERSION
minSdkVersion PROP_MIN_SDK_VERSION
ndk {
abiFilters = []
abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
}
externalNativeBuild {
if (PROP_BUILD_TYPE == 'cmake') {
cmake {
version '3.22.1'
targets 'krkr2yuri'
arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
}
versionCode 1
versionName "1.4.0beta"
}
signingConfigs {
release {
storeFile file('sign.jks')
def signPropsFile = file('sign.properties')
if (signPropsFile.exists()) {
Properties signProps = new Properties()
signProps.load(new FileInputStream(signPropsFile))
keyAlias signProps['SIGN_KEY_ALIAS']
keyPassword signProps['SIGN_KEY_PASS']
storePassword signProps['SIGN_STORE_PASS']
}
else {
keyAlias System.getenv("SIGN_KEY_ALIAS")
keyPassword System.getenv("SIGN_KEY_PASS")
storePassword System.getenv("SIGN_STORE_PASS")
}
}
}
buildTypes {
release {
debuggable false
renderscriptDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
debuggable true
jniDebuggable true
jniDebuggable true
renderscriptDebuggable true
signingConfig signingConfigs.release
}
}
sourceSets{
main{
manifest.srcFile "AndroidManifest.xml"
java.srcDirs = ["java"]
res.srcDirs = ["res"]
assets.srcDirs =["../../../assets"]
}
}
externalNativeBuild {
cmake {
version '3.22.1'
path "cpp/CMakeLists.txt"
}
}
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "krkr2yuri_v${defaultConfig.versionName}.apk"
}
}
}
dependencies {
//implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':cocos2dx')
implementation "androidx.documentfile:documentfile:1.0.1"
//noinspection GradleDependency
implementation "androidx.activity:activity:1.2.3"
//noinspection GradleDependency
implementation "androidx.fragment:fragment:1.3.4"
}
================================================
FILE: project/android/app/cpp/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.7)
project(krkr2yuri_android)
set(KRKR2YURI_DIR ${CMAKE_SOURCE_DIR}/../../../..)
if(${ANDROID_ABI} MATCHES "arm64-v8a")
set(PORTBUILD_PATH ${KRKR2YURI_DIR}/thirdparty/build/arch_androida64)
else()
set(PORTBUILD_PATH ${KRKR2YURI_DIR}/thirdparty/build/arch_androida64)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
endif()
add_subdirectory(${KRKR2YURI_DIR} ${KRKR2YURI_DIR}/build_android)
================================================
FILE: project/android/app/cpp/krkr2_android.cpp
================================================
/* Include the SDL main definition header */
#include
#include "platform/android/jni/JniHelper.h"
#include "cocos2d/AppDelegate.h"
#include "cocos2d/MainScene.h"
#include "ConfigManager/GlobalConfigManager.h"
#include "Application.h"
/*******************************************************************************
Functions called by JNI
*******************************************************************************/
#include
#include
#include
#include
#include "breakpad/client/linux/handler/exception_handler.h"
#include "breakpad/client/linux/handler/minidump_descriptor.h"
//std::string Android_GetDumpStoragePath();
static bool __DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void* context, bool succeeded)
{
return succeeded;
}
extern bool TVPSystemUninitCalled;
static bool __DumpFilter(void *data) {
if(TVPSystemUninitCalled) return false; // if trying exit system, ignore all exception
return true;
}
//static void __InitAndroidDump() {
// static google_breakpad::MinidumpDescriptor descriptor(Android_GetDumpStoragePath());
// static google_breakpad::ExceptionHandler eh(descriptor, __DumpFilter, __DumpCallback,
// NULL, true, -1);
//}
void cocos_android_app_init (JNIEnv* env) { // for cocos3.10+
// __InitAndroidDump();
__android_log_print(ANDROID_LOG_INFO,"## krkr2yuri","in cocos_android_app_init");
static TVPAppDelegate *pAppDelegate = new TVPAppDelegate();
}
namespace kr2android {
extern std::condition_variable MessageBoxCond;
extern std::mutex MessageBoxLock;
extern int MsgBoxRet;
extern std::string MessageBoxRetText;
}
void Android_PushEvents(const std::function &func);
using namespace kr2android;
extern "C" {
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_initDump(JNIEnv* env, jclass cls, jstring path) {
const char* pszPath = env->GetStringUTFChars(path, NULL);
if (pszPath && *pszPath) {
static google_breakpad::MinidumpDescriptor descriptor(pszPath);
static google_breakpad::ExceptionHandler eh(descriptor, __DumpFilter, __DumpCallback,
NULL, true, -1);
}
env->ReleaseStringUTFChars(path, pszPath);
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_onMessageBoxOK(JNIEnv* env, jclass cls, jint nButton) {
MsgBoxRet = nButton;
MessageBoxCond.notify_one();
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_onMessageBoxText(JNIEnv* env, jclass cls, jstring text) {
const char* pszText = env->GetStringUTFChars(text, NULL);
if (pszText && *pszText) {
MessageBoxRetText = pszText;
}
env->ReleaseStringUTFChars(text, pszText);
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) {
intptr_t idlong = id;
Android_PushEvents([idlong, x, y](){
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, (intptr_t*)&idlong, (float*)&x, (float*)&y);
});
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeTouchesEnd(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) {
intptr_t idlong = id;
Android_PushEvents([idlong, x, y](){
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, (intptr_t*)&idlong, (float*)&x, (float*)&y);
});
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeTouchesMove(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) {
int size = env->GetArrayLength(ids);
if (size == 1) {
intptr_t idlong;
jint id;
jfloat x;
jfloat y;
env->GetIntArrayRegion(ids, 0, size, &id);
env->GetFloatArrayRegion(xs, 0, size, &x);
env->GetFloatArrayRegion(ys, 0, size, &y);
idlong = id;
Android_PushEvents([idlong, x, y](){
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, (intptr_t*)&idlong, (float*)&x, (float*)&y);
});
return;
}
jint id[size];
std::vector x; x.resize(size);
std::vector y; y.resize(size);
env->GetIntArrayRegion(ids, 0, size, id);
env->GetFloatArrayRegion(xs, 0, size, &x[0]);
env->GetFloatArrayRegion(ys, 0, size, &y[0]);
std::vector idlong; idlong.resize(size);
for (int i = 0; i < size; i++)
idlong[i] = id[i];
Android_PushEvents([idlong, x, y](){
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(idlong.size(), (intptr_t*)&idlong[0], (float*)&x[0], (float*)&y[0]);
});
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeTouchesCancel(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) {
int size = env->GetArrayLength(ids);
if (size == 1) {
intptr_t idlong;
jint id;
jfloat x;
jfloat y;
env->GetIntArrayRegion(ids, 0, size, &id);
env->GetFloatArrayRegion(xs, 0, size, &x);
env->GetFloatArrayRegion(ys, 0, size, &y);
idlong = id;
Android_PushEvents([idlong, x, y](){
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(1, (intptr_t*)&idlong, (float*)&x, (float*)&y);
});
return;
}
jint id[size];
std::vector x; x.resize(size);
std::vector y; y.resize(size);
env->GetIntArrayRegion(ids, 0, size, id);
env->GetFloatArrayRegion(xs, 0, size, &x[0]);
env->GetFloatArrayRegion(ys, 0, size, &y[0]);
std::vector idlong; idlong.resize(size);
for (int i = 0; i < size; i++)
idlong[i] = id[i];
Android_PushEvents([idlong, x, y](){
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(idlong.size(), (intptr_t*)&idlong[0], (float*)&x[0], (float*)&y[0]);
});
}
#define KEYCODE_BACK 0x04
#define KEYCODE_MENU 0x52
#define KEYCODE_DPAD_UP 0x13
#define KEYCODE_DPAD_DOWN 0x14
#define KEYCODE_DPAD_LEFT 0x15
#define KEYCODE_DPAD_RIGHT 0x16
#define KEYCODE_ENTER 0x42
#define KEYCODE_PLAY 0x7e
#define KEYCODE_DPAD_CENTER 0x17
#define KEYCODE_DEL 0x43
JNIEXPORT jboolean JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeKeyAction(JNIEnv * env, jclass cls, jint keyCode, jboolean isPress) {
cocos2d::EventKeyboard::KeyCode pKeyCode;
switch (keyCode) {
case KEYCODE_BACK : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_ESCAPE ; break;
case KEYCODE_MENU : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_MENU ; break;
case KEYCODE_DPAD_UP : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_DPAD_UP ; break;
case KEYCODE_DPAD_DOWN : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_DPAD_DOWN ; break;
case KEYCODE_DPAD_LEFT : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_DPAD_LEFT ; break;
case KEYCODE_DPAD_RIGHT : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_DPAD_RIGHT; break;
case KEYCODE_ENTER : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_ENTER ; break;
case KEYCODE_PLAY : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_PLAY ; break;
case KEYCODE_DPAD_CENTER: pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_DPAD_CENTER; break;
case KEYCODE_DEL : pKeyCode = cocos2d::EventKeyboard::KeyCode::KEY_BACKSPACE; break;
default: return JNI_FALSE;
}
Android_PushEvents([pKeyCode, isPress](){
cocos2d::EventKeyboard event(pKeyCode, isPress);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
});
return JNI_TRUE;
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeInsertText(JNIEnv* env, jclass cls, jstring text) {
const char* pszText = env->GetStringUTFChars(text, NULL);
if (pszText && *pszText) {
std::string str = pszText;
Android_PushEvents([str](){
cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(str.c_str(), str.length());
});
}
env->ReleaseStringUTFChars(text, pszText);
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeDeleteBackward(JNIEnv* env, jclass cls) {
Android_PushEvents(std::bind(&cocos2d::IMEDispatcher::dispatchDeleteBackward,
cocos2d::IMEDispatcher::sharedDispatcher()));
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeCharInput(JNIEnv* env, jclass cls, jint keyCode) {
TVPMainScene *pScene = TVPMainScene::GetInstance();
if (!pScene) return;
pScene->getScheduler()->performFunctionInCocosThread(std::bind(&TVPMainScene::onCharInput, keyCode));
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeCommitText(
JNIEnv* env, jclass cls,
jstring text, jint newCursorPosition)
{
TVPMainScene *pScene = TVPMainScene::GetInstance();
if (!pScene) return;
const char *utftext = env->GetStringUTFChars(text, NULL);
std::string str(utftext);
pScene->getScheduler()->performFunctionInCocosThread(std::bind(&TVPMainScene::onTextInput, str));
env->ReleaseStringUTFChars(text, utftext);
}
JNIEXPORT jboolean JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeGetHideSystemButton(JNIEnv* env, jclass cls)
{
return GlobalConfigManager::GetInstance()->GetValue("hide_android_sys_btn", false);
}
static float _mouseX, _mouseY;
JNIEXPORT jboolean JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeHoverMoved(JNIEnv* env, jclass cls, jfloat x, jfloat y)
{
Android_PushEvents([x, y]() {
cocos2d::GLView *glview = cocos2d::Director::getInstance()->getOpenGLView();
float _scaleX = glview->getScaleX(), _scaleY = glview->getScaleY();
_mouseX = x; _mouseY = y;
const cocos2d::Rect _viewPortRect = glview->getViewPortRect();
float cursorX = (_mouseX - _viewPortRect.origin.x) / _scaleX;
float cursorY = (_viewPortRect.origin.y + _viewPortRect.size.height - _mouseY) / _scaleY;
cocos2d::EventMouse event(cocos2d::EventMouse::MouseEventType::MOUSE_MOVE);
event.setCursorPosition(cursorX, cursorY);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
});
return true;
}
JNIEXPORT jboolean JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeMouseScrolled(JNIEnv* env, jclass cls, jfloat v)
{
Android_PushEvents([v]() {
cocos2d::GLView *glview = cocos2d::Director::getInstance()->getOpenGLView();
float _scaleX = glview->getScaleX(), _scaleY = glview->getScaleY();
const cocos2d::Rect _viewPortRect = glview->getViewPortRect();
float cursorX = (_mouseX - _viewPortRect.origin.x) / _scaleX;
float cursorY = (_viewPortRect.origin.y + _viewPortRect.size.height - _mouseY) / _scaleY;
cocos2d::EventMouse event(cocos2d::EventMouse::MouseEventType::MOUSE_SCROLL);
event.setScrollData(0, v);
event.setCursorPosition(cursorX, cursorY);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
});
return true;
}
JNIEXPORT void JNICALL Java_org_tvp_kirikiri2_KR2Activity_nativeOnLowMemory(JNIEnv* env, jclass cls)
{
Android_PushEvents([]() {
::Application->OnLowMemory();
});
}
}
================================================
FILE: project/android/app/java/com/yuri/kirikiri2/MainActivity.java
================================================
package com.yuri.kirikiri2;
import org.tvp.kirikiri2.KR2Activity;
public class MainActivity extends KR2Activity {
static {
// System.loadLibrary("krkr2yuri");
}
@Override
public int get_res_sd_operate_step() { return R.drawable.sd_operate_step; }
}
================================================
FILE: project/android/app/java/org/tvp/kirikiri2/KR2Activity.java
================================================
package org.tvp.kirikiri2;
import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.storage.StorageManager;
import android.preference.PreferenceManager;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.documentfile.provider.DocumentFile;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* Utility class for handling the media store.
*/
@SuppressWarnings("ALL")
abstract class MediaStoreUtil {
public static Uri getUriFromFile(final String path,Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor filecursor = resolver.query(MediaStore.Files.getContentUri("external"),
new String[] { BaseColumns._ID }, MediaStore.MediaColumns.DATA + " = ?",
new String[] { path }, MediaStore.MediaColumns.DATE_ADDED + " desc");
filecursor.moveToFirst();
if (filecursor.isAfterLast()) {
filecursor.close();
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, path);
return resolver.insert(MediaStore.Files.getContentUri("external"), values);
}
else {
int imageId = filecursor.getInt(filecursor.getColumnIndex(BaseColumns._ID));
Uri uri = MediaStore.Files.getContentUri("external").buildUpon().appendPath(
Integer.toString(imageId)).build();
filecursor.close();
return uri;
}
}
public static void addFileToMediaStore(final String path, Context context) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File file = new File(path);
Uri contentUri = Uri.fromFile(file);
mediaScanIntent.setData(contentUri);
context.sendBroadcast(mediaScanIntent);
}
}
/* This is a fake invisible editor view that receives the input and defines the
* pan&scan region
*/
class DummyEdit extends View implements View.OnKeyListener {
InputConnection ic;
public DummyEdit(Context context) {
super(context);
setFocusableInTouchMode(true);
setFocusable(true);
setOnKeyListener(this);
}
@Override
public boolean onCheckIsTextEditor() {
return true;
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// This handles the hardware keyboard input
if (event.isPrintingKey()) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1);
}
return true;
}
return false;
}
//
@Override
public boolean onKeyPreIme (int keyCode, KeyEvent event) {
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
// FIXME: A more effective solution would be to change our Layout from AbsoluteLayout to Relative or Linear
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
if (KR2Activity.mTextEdit != null && KR2Activity.mTextEdit.getVisibility() == View.VISIBLE) {
KR2Activity.hideTextInput();
//KR2Activity.nativeKeyboardFocusLost();
}
}
return super.onKeyPreIme(keyCode, event);
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
ic = new SDLInputConnection(this, true);
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
| 33554432 /* API 11: EditorInfo.IME_FLAG_NO_FULLSCREEN */;
return ic;
}
}
class SDLInputConnection extends BaseInputConnection {
public SDLInputConnection(View targetView, boolean fullEditor) {
super(targetView, fullEditor);
}
@Override
public boolean sendKeyEvent(KeyEvent event) {
/*
* This handles the keycodes from soft keyboard (and IME-translated
* input from hardkeyboard)
*/
int keyCode = event.getKeyCode();
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.isPrintingKey()) {
commitText(String.valueOf((char) event.getUnicodeChar()), 1);
KR2Activity.nativeCharInput(keyCode);
} else if(keyCode == KeyEvent.KEYCODE_DEL) {
KR2Activity.nativeKeyAction(keyCode, true);
}
return true;
} else if (event.getAction() == KeyEvent.ACTION_UP) {
if(keyCode == KeyEvent.KEYCODE_DEL) {
KR2Activity.nativeKeyAction(keyCode, false);
}
//KR2Activity.nativeKeyAction(keyCode, false);
return true;
}
return super.sendKeyEvent(event);
}
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
KR2Activity.nativeCommitText(text.toString(), newCursorPosition);
return super.commitText(text, newCursorPosition);
}
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
//nativeSetComposingText(text.toString(), newCursorPosition);
return super.setComposingText(text, newCursorPosition);
}
//public native void nativeSetComposingText(String text, int newCursorPosition);
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
if (beforeLength == 1 && afterLength == 0) {
// backspace
return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
&& super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
}
return super.deleteSurroundingText(beforeLength, afterLength);
}
}
@SuppressWarnings("ALL")
public class KR2Activity extends Cocos2dxActivity implements ActivityCompat.OnRequestPermissionsResultCallback {
public static final int RC_WRITE_EXTERNAL = 1;
public static final int RC_PHONE_STATE = 2;
static ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
static ActivityManager mAcitivityManager = null;
static Debug.MemoryInfo mDbgMemoryInfo = new Debug.MemoryInfo();
public static void updateMemoryInfo() {
if(mAcitivityManager == null) {
mAcitivityManager =(ActivityManager)sInstance.getSystemService(Activity.ACTIVITY_SERVICE);
}
mAcitivityManager.getMemoryInfo(memoryInfo);
Debug.getMemoryInfo(mDbgMemoryInfo);
}
public static long getAvailMemory() {
return memoryInfo.availMem;
}
public static long getUsedMemory() {
return mDbgMemoryInfo.getTotalPss(); // in kB
}
private static void requestPhoneState() {
// Permission has not been granted and must be requested.
if (ActivityCompat.shouldShowRequestPermissionRationale(sInstance,
Manifest.permission.READ_PHONE_STATE)) {
// Provide an additional rationale to the user if the permission was not granted
// and the user would benefit from additional context for the use of the permission.
// Display a SnackBar with cda button to request the missing permission.
ActivityCompat.requestPermissions(sInstance,
new String[]{Manifest.permission.READ_PHONE_STATE},
RC_PHONE_STATE);
} else {
// Request the permission. The result will be received in onRequestPermissionResult().
ActivityCompat.requestPermissions(sInstance,
new String[]{Manifest.permission.READ_PHONE_STATE}, RC_PHONE_STATE);
}
}
private static void requestExternalWrite() {
// Permission has not been granted and must be requested.
if (ActivityCompat.shouldShowRequestPermissionRationale(sInstance,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// Provide an additional rationale to the user if the permission was not granted
// and the user would benefit from additional context for the use of the permission.
// Display a SnackBar with cda button to request the missing permission.
ActivityCompat.requestPermissions(sInstance,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
RC_WRITE_EXTERNAL);
} else {
// Request the permission. The result will be received in onRequestPermissionResult().
ActivityCompat.requestPermissions(sInstance,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, RC_WRITE_EXTERNAL);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case RC_PHONE_STATE:
Log.d("Krkr2", "onRequestPermissionsResult: PHONE STATE");
break;
case RC_WRITE_EXTERNAL:
Log.d("Krkr2", "onRequestPermissionsResult: WRITE EXTERNAL");
break;
}
}
static public String getDeviceId() { // ## fix android.permission.READ_PRIVILEGED_PHONE_STATE
return "";
}
static public KR2Activity sInstance;
static public KR2Activity GetInstance() {return sInstance;}
@Override
public void onCreate(Bundle savedInstanceState) {
sInstance = this;
Sp = PreferenceManager.getDefaultSharedPreferences(this);
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
for(String path : getExtSdCardPaths(this)) {
if (!isWritableNormalOrSaf(path)) {
guideDialogForLEXA(path);
}
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestExternalWrite();
}
initDump(this.getFilesDir().getAbsolutePath() + "/dump");
}
@Override
public void onDestroy() {
super.onDestroy();
System.exit(0);
}
@Override
public void onLowMemory() {
nativeOnLowMemory();
}
static class DialogMessage
{
public String Title;
public String Text;
public String[] Buttons;
public EditText TextEditor = null;
public DialogMessage()
{
}
public void Init(final String title, final String text, final String[] buttons)
{
this.Title = title;
this.Text = text;
this.Buttons = buttons;
}
void onButtonClick(int n) {
if(TextEditor != null) {
onMessageBoxText(TextEditor.getText().toString());
}
onMessageBoxOK(n);
}
public AlertDialog.Builder CreateBuilder() {
/* TextView showText = new TextView(sInstance);
showText.setText(Text);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
showText.setTextIsSelectable(true);*/
AlertDialog.Builder builder = new AlertDialog.Builder(sInstance).
setTitle(Title).
setMessage(Text).
//setView(showText).
setCancelable(false);
if(Buttons.length >= 1) {
builder = builder.setPositiveButton(Buttons[0], new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onButtonClick(0);
}
});
}
if(Buttons.length >= 2) {
builder = builder.setNeutralButton(Buttons[1], new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onButtonClick(1);
}
});
}
if(Buttons.length >= 3) {
builder = builder.setNegativeButton(Buttons[2], new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onButtonClick(2);
}
});
}
return builder;
}
public void ShowMessageBox()
{
CreateBuilder().create().show();
}
public void ShowInputBox(final String text) {
AlertDialog.Builder builder = CreateBuilder();
TextEditor = new EditText(sInstance);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
TextEditor.setLayoutParams(lp);
TextEditor.setText(text);
builder.setView(TextEditor);
AlertDialog ad = builder.create();
ad.show();
TextEditor.requestFocus();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(TextEditor, 0);
}
}
static DialogMessage mDialogMessage = new DialogMessage();
protected static View mTextEdit = null;
SharedPreferences Sp;
static Handler msgHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
sInstance.handleMessage(msg);
}
};
public void handleMessage(Message msg) {
}
static public void ShowMessageBox(final String title, final String text, final String[] Buttons) {
mDialogMessage.Init(title, text, Buttons);
msgHandler.post(new Runnable() {
@Override
public void run() {
mDialogMessage.ShowMessageBox();
}
});
}
static public void ShowInputBox(final String title, final String prompt, final String text, final String[] Buttons) {
mDialogMessage.Init(title, prompt, Buttons);
msgHandler.post(new Runnable() {
@Override
public void run() {
mDialogMessage.ShowInputBox(text);
}
});
}
static class ShowTextInputTask implements Runnable {
/*
* This is used to regulate the pan&scan method to have some offset from
* the bottom edge of the input region and the top edge of an input
* method (soft keyboard)
*/
static final int HEIGHT_PADDING = 15;
public int x, y, w, h;
public ShowTextInputTask(int x, int y, int w, int h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
@Override
public void run() {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(w, h + HEIGHT_PADDING);
params.leftMargin = x;
params.topMargin = y;
if (mTextEdit == null) {
mTextEdit = new DummyEdit(getContext());
sInstance.mFrameLayout.addView(mTextEdit, params);
} else {
mTextEdit.setLayoutParams(params);
}
mTextEdit.setVisibility(View.VISIBLE);
mTextEdit.requestFocus();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mTextEdit, 0);
}
}
static public void showTextInput(int x, int y, int w, int h) {
msgHandler.post(new ShowTextInputTask(x, y, w, h));
}
static public void hideTextInput() {
msgHandler.post(new Runnable() {
@Override
public void run() {
if (mTextEdit != null) {
mTextEdit.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) sInstance.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
}
}
});
}
static private native void onMessageBoxOK(int nButton);
static private native void onMessageBoxText(String text);
static private native void onNativeExit();
static public native void onNativeInit();
static public native void onBannerSizeChanged(int w, int h);
static private native void initDump(String path);
static private native void nativeOnLowMemory();
static public void MessageController(int what, int arg1, int arg2) {
Message msg = msgHandler.obtainMessage();
msg.what = what;
msg.arg1 = arg1;
msg.arg2 = arg2;
msgHandler.sendMessage(msg);
}
static public String GetVersion() {
String verstr = null;
try {
verstr = sInstance.getPackageManager().getPackageInfo(sInstance.getPackageName(), 0).versionName;
} catch (NameNotFoundException e1) {
}
return verstr;
}
StorageManager mStorageManager = null;
Method mMethodGetPaths = null;
Method mGetVolumeState = null;
public String[] getStoragePath() {
String[] ret = new String[0];
if(mStorageManager == null) {
mStorageManager = (StorageManager)getSystemService(STORAGE_SERVICE);
try {
mMethodGetPaths = StorageManager.class.getMethod("getVolumePaths");
mGetVolumeState = StorageManager.class.getMethod("getVolumeState", String.class);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
if(mMethodGetPaths != null) {
try {
ret = (String[])mMethodGetPaths.invoke(mStorageManager);
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (Exception e) {
}
}
if(mGetVolumeState != null) {
try {
for(int i = 0; i < ret.length; ++i) {
String status = (String)mGetVolumeState.invoke(mStorageManager, ret[i]);
if(Environment.MEDIA_MOUNTED.equals(status) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(status)) {
;
} else {
ret[i] = null;
}
}
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (Exception e) {
}
}
return ret;
}
private static native void nativeTouchesBegin(final int id, final float x, final float y);
private static native void nativeTouchesEnd(final int id, final float x, final float y);
private static native void nativeTouchesMove(final int[] ids, final float[] xs, final float[] ys);
private static native void nativeTouchesCancel(final int[] ids, final float[] xs, final float[] ys);
public static native boolean nativeKeyAction(final int keyCode, final boolean isPress);
public static native void nativeCharInput(final int keyCode);
public static native void nativeCommitText(String text, int newCursorPosition);
private static native void nativeInsertText(final String text);
public static native void nativeDeleteBackward();
private static native String nativeGetContentText();
private static native void nativeHoverMoved(final float x, final float y);
private static native void nativeMouseScrolled(final float scroll);
class KR2GLSurfaceView extends Cocos2dxGLSurfaceView {
public KR2GLSurfaceView(final Context context) {
super(context);
}
public KR2GLSurfaceView(final Context context, final AttributeSet attrs) {
super(context, attrs);
}
@Override
public void insertText(final String pText) {
nativeInsertText(pText);
}
@Override
public void deleteBackward() {
nativeDeleteBackward();
}
@Override
public boolean onKeyDown(final int pKeyCode, final KeyEvent pKeyEvent) {
switch (pKeyCode) {
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_MENU:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_DPAD_CENTER:
nativeKeyAction(pKeyCode, true);
return true;
default:
return super.onKeyDown(pKeyCode, pKeyEvent);
}
}
@Override
public boolean onKeyUp(final int pKeyCode, final KeyEvent pKeyEvent) {
switch (pKeyCode) {
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_MENU:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_DPAD_CENTER:
nativeKeyAction(pKeyCode, false);
return true;
default:
return super.onKeyUp(pKeyCode, pKeyEvent);
}
}
@Override
public boolean onHoverEvent(final MotionEvent pMotionEvent) {
final int pointerNumber = pMotionEvent.getPointerCount();
final float[] xs = new float[pointerNumber];
final float[] ys = new float[pointerNumber];
for (int i = 0; i < pointerNumber; i++) {
xs[i] = pMotionEvent.getX(i);
ys[i] = pMotionEvent.getY(i);
}
switch(pMotionEvent.getActionMasked()) {
case MotionEvent.ACTION_HOVER_MOVE:
nativeHoverMoved(xs[0], ys[0]);
break;
}
return true;
}
@Override
public boolean onTouchEvent(final MotionEvent pMotionEvent) {
// these data are used in ACTION_MOVE and ACTION_CANCEL
final int pointerNumber = pMotionEvent.getPointerCount();
final int[] ids = new int[pointerNumber];
final float[] xs = new float[pointerNumber];
final float[] ys = new float[pointerNumber];
for (int i = 0; i < pointerNumber; i++) {
ids[i] = pMotionEvent.getPointerId(i);
xs[i] = pMotionEvent.getX(i);
ys[i] = pMotionEvent.getY(i);
}
switch (pMotionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_DOWN:
final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int idPointerDown = pMotionEvent.getPointerId(indexPointerDown);
final float xPointerDown = pMotionEvent.getX(indexPointerDown);
final float yPointerDown = pMotionEvent.getY(indexPointerDown);
nativeTouchesBegin(idPointerDown, xPointerDown, yPointerDown);
break;
case MotionEvent.ACTION_DOWN:
// there are only one finger on the screen
final int idDown = pMotionEvent.getPointerId(0);
final float xDown = xs[0];
final float yDown = ys[0];
nativeTouchesBegin(idDown, xDown, yDown);
break;
case MotionEvent.ACTION_MOVE:
nativeTouchesMove(ids, xs, ys);
break;
case MotionEvent.ACTION_POINTER_UP:
final int indexPointUp = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int idPointerUp = pMotionEvent.getPointerId(indexPointUp);
final float xPointerUp = pMotionEvent.getX(indexPointUp);
final float yPointerUp = pMotionEvent.getY(indexPointUp);
nativeTouchesEnd(idPointerUp, xPointerUp, yPointerUp);
break;
case MotionEvent.ACTION_UP:
// there are only one finger on the screen
final int idUp = pMotionEvent.getPointerId(0);
final float xUp = xs[0];
final float yUp = ys[0];
nativeTouchesEnd(idUp, xUp, yUp);
break;
case MotionEvent.ACTION_CANCEL:
nativeTouchesCancel(ids, xs, ys);
break;
}
/*
if (BuildConfig.DEBUG) {
Cocos2dxGLSurfaceView.dumpMotionEvent(pMotionEvent);
}
*/
return true;
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override
public boolean onGenericMotionEvent(MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_SCROLL:
float v = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
nativeMouseScrolled(-v);
return true;
default:
break;
}
return super.onGenericMotionEvent(event);
}
}
//@Override
// ## fix private function
// public Cocos2dxGLSurfaceView onCreateView() {
// Cocos2dxGLSurfaceView glSurfaceView = new KR2GLSurfaceView(this);
// hideSystemUI();
//
// // this line is need on some device if we specify an alpha bits
// if(this.mGLContextAttrs[3] > 0) glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
//
// Cocos2dxEGLConfigChooser chooser = new Cocos2dxEGLConfigChooser(this.mGLContextAttrs);
// glSurfaceView.setEGLConfigChooser(chooser);
//
// return glSurfaceView;
// }
public int get_res_sd_operate_step() { return -1; }
static void requireLEXA(final String path) {
msgHandler.post(new Runnable() {
@Override
public void run() {
guideDialogForLEXA(path);
}
});
}
static void guideDialogForLEXA(final String path) {
AlertDialog.Builder builder = new AlertDialog.Builder(sInstance);
ImageView image = new ImageView(sInstance);
image.setImageResource(sInstance.get_res_sd_operate_step());
builder
.setView(image)
.setTitle(path)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
triggerStorageAccessFramework();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// nothing to do
}
})
.show();
}
static final boolean isWritable(final File file) {
if(file==null)
return false;
boolean isExisting = file.exists();
try {
FileOutputStream output = new FileOutputStream(file, true);
try {
output.close();
}
catch (IOException e) {
// do nothing.
}
}
catch (FileNotFoundException e) {
return false;
}
boolean result = file.canWrite();
// Ensure that file is not created during this process.
if (!isExisting) {
file.delete();
}
return result;
}
static final boolean isWritableNormal(final String path) {
boolean ret = isWritableNormalOrSaf(path);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestExternalWrite();
return isWritableNormalOrSaf(path);
}
return ret;
}
static final boolean isWritableNormalOrSaf(final String path) {
Log.i("kr2activaty","check path " + path + "permision");
Context c = sInstance;
File folder = new File(path);
folder.mkdir();
// Log.d("ke2activate", String.format("%b and %b", folder.exists(), folder.isDirectory()));
if (!folder.exists() || !folder.isDirectory()) {
return false;
}
// Find a non-existing file in this directory.
int i = 0;
File file;
do {
String fileName = "AugendiagnoseDummyFile" + (++i);
file = new File(folder, fileName);
}
while (file.exists());
// First check regular writability
Log.d("ke2activate", String.format("%b ", isWritable(file)));
if (isWritable(file)) {
return true;
}
// Next check SAF writability.
DocumentFile document = getDocumentFile(file, false,c);
if (document == null) {
return false;
}
// This should have created the file - otherwise something is wrong with access URL.
boolean result = document.canWrite() && file.exists();
// Ensure that the dummy file is not remaining.
document.delete();
DocumentFile.fromFile(folder).delete();
return result;
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static String[] getExtSdCardPaths(Context context) {
List paths = new ArrayList();
for (File file : context.getExternalFilesDirs("external")) {
if (file != null && !file.equals(context.getExternalFilesDir("external"))) {
int index = file.getAbsolutePath().lastIndexOf("/Android/data");
if (index < 0) {
Log.w("FileUtils", "Unexpected external file dir: " + file.getAbsolutePath());
} else {
String path = file.getAbsolutePath().substring(0, index);
try {
path = new File(path).getCanonicalPath();
}
catch (IOException e) {
// Keep non-canonical path.
}
paths.add(path);
}
}
}
//if(paths.isEmpty())paths.add("/storage/sdcard1");
return paths.toArray(new String[0]);
}
static String[] _extSdPaths;
public static String getExtSdCardFolder(final File file,Context context) {
if(_extSdPaths == null)
_extSdPaths = getExtSdCardPaths(context);
try {
for (int i = 0; i < _extSdPaths.length; i++) {
if (file.getCanonicalPath().startsWith(_extSdPaths[i])) {
return _extSdPaths[i];
}
}
}
catch (IOException e) {
return null;
}
return null;
}
public static boolean isOnExtSdCard(final File file,Context c) {
return getExtSdCardFolder(file,c) != null;
}
public static DocumentFile getDocumentFile(final File file, final boolean isDirectory,Context context) {
String baseFolder = getExtSdCardFolder(file,context);
boolean originalDirectory=false;
if (baseFolder == null) {
return null;
}
String relativePath = null;
try {
String fullPath = file.getCanonicalPath();
if(!baseFolder.equals(fullPath))
relativePath = fullPath.substring(baseFolder.length() + 1);
else originalDirectory=true;
}
catch (IOException e) {
return null;
}
catch (Exception f){
originalDirectory=true;
//continue
}
String as=PreferenceManager.getDefaultSharedPreferences(context).getString("URI",null);
Uri treeUri =null;
if(as!=null)treeUri=Uri.parse(as);
if (treeUri == null) {
return null;
}
// start with root of SD card and then parse through document tree.
DocumentFile document = DocumentFile.fromTreeUri(context, treeUri);
if(originalDirectory)return document;
String[] parts = relativePath.split("\\/");
for (int i = 0; i < parts.length; i++) {
DocumentFile nextDocument = document.findFile(parts[i]);
if (nextDocument == null) {
try {
if ((i < parts.length - 1) || isDirectory) {
nextDocument = document.createDirectory(parts[i]);
} else {
nextDocument = document.createFile("image", parts[i]);
}
} catch (Exception e) {
return null;
}
}
document = nextDocument;
}
return document;
}
static public boolean RenameFile(String from, String to) {
File file = new File(from);
File target = new File(to);
if(!file.exists())
return false;
if(target.exists()) {
if(!DeleteFile(target.getAbsolutePath())) return false;
}
File parent = target.getParentFile();
if(!parent.exists()) {
if(!CreateFolders(parent.getAbsolutePath())) return false;
}
// Try the normal way
if(file.renameTo(target)) return true;
// Try with Storage Access Framework.
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP /*&& isOnExtSdCard(file, sInstance)*/) {
DocumentFile document = getDocumentFile(file, false, sInstance);
if(document.renameTo(to))
return true;
}
// Try Media Store Hack
if (Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT) {
try {
FileInputStream input = new FileInputStream(file);
int filesize = (int) file.length();
byte []buffer = new byte[filesize];
input.read(buffer);
input.close();
OutputStream out = MediaStoreHack.getOutputStream(sInstance, target.getAbsolutePath());
out.write(buffer);
out.close();
return MediaStoreHack.delete(sInstance, file);
} catch (IOException e) {
// TODO Auto-generated catch block
return false;
//e.printStackTrace();
}
}
return false;
}
public static final boolean deleteFilesInFolder(final File folder,Context context) {
boolean totalSuccess = true;
if(folder==null)
return false;
if (folder.isDirectory()) {
for (File child : folder.listFiles()) {
deleteFilesInFolder(child, context);
}
if (!folder.delete())
totalSuccess = false;
} else {
if (!folder.delete())
totalSuccess = false;
}
return totalSuccess;
}
static public boolean DeleteFile(String path) {
File file = new File(path);
// First try the normal deletion.
boolean fileDelete = deleteFilesInFolder(file, sInstance);
if (file.delete() || fileDelete)
return true;
// Try with Storage Access Framework.
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP && isOnExtSdCard(file, sInstance)) {
DocumentFile document = getDocumentFile(file, false,sInstance);
return document.delete();
}
// Try the Kitkat workaround.
if (Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT) {
ContentResolver resolver = sInstance.getContentResolver();
try {
Uri uri = MediaStoreHack.getUriFromFile(file.getAbsolutePath(),sInstance);
resolver.delete(uri, null, null);
return !file.exists();
}
catch (Exception e) {
Log.e("FileUtils", "Error when deleting file " + file.getAbsolutePath(), e);
return false;
}
}
return !file.exists();
}
public static OutputStream getOutputStream(@NonNull final File target,Context context,long s)throws Exception {
OutputStream outStream = null;
try {
// First try the normal way
if (isWritable(target)) {
// standard way
outStream = new FileOutputStream(target);
} else {
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
// Storage Access Framework
DocumentFile targetDocument = getDocumentFile(target, false,context);
outStream = context.getContentResolver().openOutputStream(targetDocument.getUri());
} else if (Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT) {
// Workaround for Kitkat ext SD card
return MediaStoreHack.getOutputStream(context,target.getPath());
}
}
} catch (Exception e) {
Log.e("FileUtils",
"Error when copying file from " + target.getAbsolutePath(), e);
}
return outStream;
}
static public boolean WriteFile(String path, byte data[]) {
File target = new File(path);
if(target.exists()) {
DeleteFile(target.getAbsolutePath()); // to avoid number suffix name
} else {
File parent = target.getParentFile();
if(!parent.exists())
CreateFolders(parent.getAbsolutePath());
}
OutputStream out = null;
// Try the normal way
try {
if(isWritable(target)) {
OutputStream os = new FileOutputStream(target);
os.write(data);
os.close();
return true;
}
// Try with Storage Access Framework.
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP /*&& isOnExtSdCard(file, sInstance)*/) {
DocumentFile document = getDocumentFile(target, false, sInstance);
try {
Uri docUri = document.getUri();
out = sInstance.getContentResolver().openOutputStream(docUri);
} //catch (FileNotFoundException e) {
// e.printStackTrace();}
catch (IOException e) {
// e.printStackTrace();
}
} else if (Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT) {
// Workaround for Kitkat ext SD card
Uri uri = MediaStoreHack.getUriFromFile(target.getAbsolutePath(),sInstance);
out = sInstance.getContentResolver().openOutputStream(uri);
} else {
return false;
}
if (out != null) {
out.write(data);
out.close();
return true;
}
} catch (FileNotFoundException e) {
//return false;
} catch (IOException e) {
//return false;
}
return false;
}
static public boolean CreateFolders(String path) {
File file = new File(path);
// Try the normal way
if(file.mkdirs()) {
return true;
}
// Try with Storage Access Framework.
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP /*&& FileUtil.isOnExtSdCard(file, context)*/) {
DocumentFile document = getDocumentFile(file, true,sInstance);
// getDocumentFile implicitly creates the directory.
return document.exists();
}
// Try the Kitkat workaround.
if (Build.VERSION.SDK_INT==Build.VERSION_CODES.KITKAT) {
try {
return MediaStoreHack.mkdir(sInstance,file);
} catch (IOException e) {
//return false;
}
}
return false;
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
//SDLActivity.mHasFocus = hasFocus;
if (hasFocus) {
hideSystemUI();
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
void doSetSystemUiVisibility() {
int uiOpts = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getWindow().getDecorView().setSystemUiVisibility(uiOpts);
}
private static native boolean nativeGetHideSystemButton();
void hideSystemUI() {
if(nativeGetHideSystemButton() && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
doSetSystemUiVisibility();
}
}
static public String getLocaleName() {
Locale defloc = Locale.getDefault();
String lang = defloc.getLanguage();
String country = defloc.getCountry();
if(!country.isEmpty()) {
lang += "_";
lang += country.toLowerCase();
}
return lang;
}
static public void exit() {
System.exit(0);
}
static final int ORIENT_VERTICAL = 1;
static final int ORIENT_HORIZONTAL = 2;
static public void setOrientation(int orient) {
if(orient == ORIENT_VERTICAL) {
sInstance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if(orient == ORIENT_HORIZONTAL) {
sInstance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
static public void triggerStorageAccessFramework() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
sInstance.startActivityForResult(intent, 3);
}
@SuppressLint("WrongConstant")
@TargetApi(Build.VERSION_CODES.KITKAT)
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if (requestCode == 3) {
String p = Sp.getString("URI", null);
Uri oldUri = null;
if (p != null) oldUri = Uri.parse(p);
Uri treeUri = null;
if (responseCode == Activity.RESULT_OK) {
// Get Uri from Storage Access Framework.
treeUri = intent.getData();
// Persist URI - this is required for verification of writability.
if (treeUri != null) Sp.edit().putString("URI", treeUri.toString()).commit();
}
// If not confirmed SAF, or if still not writable, then revert settings.
if (responseCode != Activity.RESULT_OK) {
/* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false,
currentFolder);||!FileUtil.isWritableNormalOrSaf(currentFolder)
*/
if (treeUri != null) Sp.edit().putString("URI", oldUri.toString()).commit();
return;
}
// After confirmation, update stored value of folder.
// Persist access permissions.
final int takeFlags = intent.getFlags()
& (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
}
}
}
================================================
FILE: project/android/app/java/org/tvp/kirikiri2/MediaStoreHack.java
================================================
package org.tvp.kirikiri2;
/**
* Created by Arpit on 29-06-2015.
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.util.Log;
/**
* Wrapper for manipulating files via the Android Media Content Provider. As of Android 4.4 KitKat,
* applications can no longer write to the "secondary storage" of a device. Write operations using
* the java.io.File API will thus fail. This class restores access to those write operations by way
* of the Media Content Provider.
*
* Note that this class relies on the internal operational characteristics of the media content
* provider API, and as such is not guaranteed to be future-proof. Then again, we did all think the
* java.io.File API was going to be future-proof for media card access, so all bets are off.
*
* If you're forced to use this class, it's because Google/AOSP made a very poor API decision in
* Android 4.4 KitKat. Read more at https://plus.google.com/+TodLiebeck/posts/gjnmuaDM8sn
*
* Your application must declare the permission "android.permission.WRITE_EXTERNAL_STORAGE".
*
* Adapted from: http://forum.xda-developers.com/showpost.php?p=52151865&postcount=20
*
* @author Jared Rummler
*/
public class MediaStoreHack {
private static final String ALBUM_ART_URI = "content://media/external/audio/albumart";
private static final String[] ALBUM_PROJECTION = {
BaseColumns._ID, MediaStore.Audio.AlbumColumns.ALBUM_ID, "media_type"
};
/**
* Deletes the file. Returns true if the file has been successfully deleted or otherwise does
* not exist. This operation is not recursive.
*/
public static boolean delete(final Context context, final File file) {
final String where = MediaStore.MediaColumns.DATA + "=?";
final String[] selectionArgs = new String[] {
file.getAbsolutePath()
};
final ContentResolver contentResolver = context.getContentResolver();
final Uri filesUri = MediaStore.Files.getContentUri("external");
// Delete the entry from the media database. This will actually delete media files.
contentResolver.delete(filesUri, where, selectionArgs);
// If the file is not a media file, create a new entry.
if (file.exists()) {
final ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath());
contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
// Delete the created entry, such that content provider will delete the file.
contentResolver.delete(filesUri, where, selectionArgs);
}
return !file.exists();
}
private static File getExternalFilesDir(final Context context) {
return context.getExternalFilesDir(null);
}
public static InputStream
getInputStream(final Context context, final File file, final long size) {
try {
final String where = MediaStore.MediaColumns.DATA + "=?";
final String[] selectionArgs = new String[] {
file.getAbsolutePath()
};
final ContentResolver contentResolver = context.getContentResolver();
final Uri filesUri = MediaStore.Files.getContentUri("external");
contentResolver.delete(filesUri, where, selectionArgs);
final ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath());
values.put(MediaStore.MediaColumns.SIZE, size);
final Uri uri = contentResolver.insert(filesUri, values);
return contentResolver.openInputStream(uri);
} catch (final Throwable t) {
return null;
}
}
public static OutputStream getOutputStream(Context context,String str) {
OutputStream outputStream = null;
Uri fileUri = getUriFromFile(str,context);
if (fileUri != null) {
try {
outputStream = context.getContentResolver().openOutputStream(fileUri);
} catch (Throwable th) {
}
}
return outputStream;
}
public static Uri getUriFromFile(final String path,Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor filecursor = resolver.query(MediaStore.Files.getContentUri("external"),
new String[] { BaseColumns._ID }, MediaStore.MediaColumns.DATA + " = ?",
new String[] { path }, MediaStore.MediaColumns.DATE_ADDED + " desc");
filecursor.moveToFirst();
if (filecursor.isAfterLast()) {
filecursor.close();
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, path);
return resolver.insert(MediaStore.Files.getContentUri("external"), values);
}
else {
@SuppressLint("Range") int imageId = filecursor.getInt(filecursor.getColumnIndex(BaseColumns._ID));
Uri uri = MediaStore.Files.getContentUri("external").buildUpon().appendPath(
Integer.toString(imageId)).build();
filecursor.close();
return uri;
}
}
/**
* Returns an OutputStream to write to the file. The file will be truncated immediately.
*/
private static int getTemporaryAlbumId(final Context context) {
final File temporaryTrack;
try {
temporaryTrack = installTemporaryTrack(context);
} catch (final IOException ex) {
Log.w("MediaFile", "Error installing tempory track.", ex);
return 0;
}
final Uri filesUri = MediaStore.Files.getContentUri("external");
final String[] selectionArgs = {
temporaryTrack.getAbsolutePath()
};
final ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(filesUri, ALBUM_PROJECTION,
MediaStore.MediaColumns.DATA + "=?", selectionArgs, null);
if (cursor == null || !cursor.moveToFirst()) {
if (cursor != null) {
cursor.close();
cursor = null;
}
final ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, temporaryTrack.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, "{MediaWrite Workaround}");
values.put(MediaStore.MediaColumns.SIZE, temporaryTrack.length());
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg");
values.put(MediaStore.Audio.AudioColumns.IS_MUSIC, true);
contentResolver.insert(filesUri, values);
}
cursor = contentResolver.query(filesUri, ALBUM_PROJECTION, MediaStore.MediaColumns.DATA
+ "=?", selectionArgs, null);
if (cursor == null) {
return 0;
}
if (!cursor.moveToFirst()) {
cursor.close();
return 0;
}
final int id = cursor.getInt(0);
final int albumId = cursor.getInt(1);
final int mediaType = cursor.getInt(2);
cursor.close();
final ContentValues values = new ContentValues();
boolean updateRequired = false;
if (albumId == 0) {
values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, 13371337);
updateRequired = true;
}
if (mediaType != 2) {
values.put("media_type", 2);
updateRequired = true;
}
if (updateRequired) {
contentResolver.update(filesUri, values, BaseColumns._ID + "=" + id, null);
}
cursor = contentResolver.query(filesUri, ALBUM_PROJECTION, MediaStore.MediaColumns.DATA
+ "=?", selectionArgs, null);
if (cursor == null) {
return 0;
}
try {
if (!cursor.moveToFirst()) {
return 0;
}
return cursor.getInt(1);
} finally {
cursor.close();
}
}
private static final byte [] temptrack_mp3 = new byte [] {
73, 68, 51, 4, 0, 0, 0, 0, 8, 65, 84, 80, 69, 49, 0, 0,
0, 24, 0, 0, 0, 123, 77, 101, 100, 105, 97, 87, 114, 105, 116, 101,
32, 87, 111, 114, 107, 97, 114, 111, 117, 110, 100, 125, 84, 65, 76, 66,
0, 0, 0, 24, 0, 0, 0, 123, 77, 101, 100, 105, 97, 87, 114, 105,
116, 101, 32, 87, 111, 114, 107, 97, 114, 111, 117, 110, 100, 125, 84, 73,
84, 50, 0, 0, 0, 24, 0, 0, 0, 123, 77, 101, 100, 105, 97, 87,
114, 105, 116, 101, 32, 87, 111, 114, 107, 97, 114, 111, 117, 110, 100, 125,
65, 80, 73, 67, 0, 0, 2, 33, 0, 0, 0, 105, 109, 97, 103, 101,
47, 112, 110, 103, 0, 3, 0, -119, 80, 78, 71, 13, 10, 26, 10, 0,
0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 32, 0, 0, 0, 32, 8,
2, 0, 0, 0, -4, 24, -19, -93, 0, 0, 0, 1, 115, 82, 71, 66,
0, -82, -50, 28, -23, 0, 0, 0, -50, 73, 68, 65, 84, 72, -57, -19,
85, -55, 10, -128, 64, 8, 77, -1, -1, -97, -19, 48, 36, -30, 62, 83,
-76, 64, 30, 66, -59, -52, 124, 79, -35, -74, 95, -34, 38, 68, 68, 68,
82, 81, -2, -95, -69, 78, 25, 31, 102, 87, -70, 124, 70, -2, 40, 114,
8, 74, 3, 0, -22, 42, 76, 77, 0, -112, 4, -96, -78, 59, -33, -112,
1, 101, 60, 90, 0, -72, 34, -42, 71, 22, 78, 20, -107, 92, -2, -51,
45, 20, -78, 96, 42, -14, -48, 33, 74, -17, 98, 96, 69, 117, -103, -101,
-58, -26, 28, -56, -106, 106, 121, 103, 75, 70, -96, 11, 84, -97, 39, 37,
-86, -24, -66, -48, 39, 67, 107, -128, -97, 100, 81, -78, 121, 58, 0, -44,
44, 82, -112, 44, -20, 18, -100, 34, -122, 59, -25, 57, 12, 53, -117, -94,
-103, 96, 61, 31, -123, -126, 69, 35, -53, -45, 27, 102, -115, 72, -10, -94,
37, -121, -56, 61, -126, -2, -70, 118, -69, -100, 0, -93, -100, 54, 12, -49,
92, -85, -23, -125, 51, 123, -83, 58, -21, 8, 59, -47, -110, 75, 57, -81,
-66, 70, -71, 95, 46, -111, 29, -73, 67, 31, -101, 122, -93, -81, 8, 0,
0, 0, 0, 73, 69, 78, 68, -82, 66, 96, -126, 84, 68, 84, 71, 0,
0, 0, 20, 0, 0, 0, 50, 48, 49, 52, 45, 48, 52, 45, 48, 49,
84, 50, 49, 58, 51, 57, 58, 51, 53, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -6, -112, -64, 95,
-85, 0, 0, 0, 0, 1, -92, 24, 0, 0, 0, 0, 0, 52, -125, -128,
0, 0, 76, 65, 77, 69, 51, 46, 57, 51, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 76, 65, 77, 69, 51, 46, 57, 51,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, -1, -6, -110, -64,
-26, -97, -59, 3, -64, 0, 1, -92, 0, 0, 0, 0, 0, 0, 52, -128,
0, 0, 0, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 76, 65, 77, 69, 51, 46,
57, 51, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, -1, -6,
-110, -64, -6, -34, -1, -125, -64, 0, 1, -92, 0, 0, 0, 0, 0, 0,
52, -128, 0, 0, 0, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 76, 65, 77, 69,
51, 46, 57, 51, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
-1, -6, -110, -64, -6, -34, -1, -125, -64, 0, 1, -92, 0, 0, 0, 0,
0, 0, 52, -128, 0, 0, 0, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 76, 65,
77, 69, 51, 46, 57, 51, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, -1, -6, -110, -64, -6, -34, -1, -125, -64, 0, 1, -92, 0, 0,
0, 0, 0, 0, 52, -128, 0, 0, 0, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
76, 65, 77, 69, 51, 46, 57, 51, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, -1, -6, -110, -64, -6, -34, -1, -125, -64, 0, 1, -92,
0, 0, 0, 0, 0, 0, 52, -128, 0, 0, 0, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85
};
private static File installTemporaryTrack(final Context context) throws IOException {
final File externalFilesDir = getExternalFilesDir(context);
if (externalFilesDir == null) {
return null;
}
final File temporaryTrack = new File(externalFilesDir, "temptrack.mp3");
OutputStream out = null;
try {
out = new FileOutputStream(temporaryTrack);
out.write(temptrack_mp3);
} finally {
out.close();
}
return temporaryTrack;
}
public static boolean mkdir(final Context context, final File file) throws IOException {
if (file.exists()) {
return file.isDirectory();
}
final File tmpFile = new File(file, ".MediaWriteTemp");
final int albumId = getTemporaryAlbumId(context);
if (albumId == 0) {
throw new IOException("Failed to create temporary album id.");
}
final Uri albumUri = Uri.parse(String.format(Locale.US, ALBUM_ART_URI + "/%d", albumId));
final ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, tmpFile.getAbsolutePath());
final ContentResolver contentResolver = context.getContentResolver();
if (contentResolver.update(albumUri, values, null, null) == 0) {
values.put(MediaStore.Audio.AlbumColumns.ALBUM_ID, albumId);
contentResolver.insert(Uri.parse(ALBUM_ART_URI), values);
}
try {
final ParcelFileDescriptor fd = contentResolver.openFileDescriptor(albumUri, "r");
fd.close();
} finally {
delete(context, tmpFile);
}
return file.exists();
}
public static boolean mkfile(final Context context, final File file) {
final OutputStream outputStream = getOutputStream(context, file.getPath());
if (outputStream == null) {
return false;
}
try {
outputStream.close();
return true;
} catch (final IOException e) {
}
return false;
}
}
================================================
FILE: project/android/app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Proguard Cocos2d-x for release
-keep public class org.cocos2dx.** { *; }
-dontwarn org.cocos2dx.**
-keep public class com.chukong.** { *; }
-dontwarn com.chukong.**
-keep public class com.huawei.android.** { *; }
-dontwarn com.huawei.android.**
-keep public class com.oppo.oiface.engine.** { *; }
-dontwarn com.oppo.oiface.engine.**
# Proguard Apache HTTP for release
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
# Proguard Android Webivew for release. uncomment if you are using a webview in cocos2d-x
#-keep public class android.net.http.SslError
#-keep public class android.webkit.WebViewClient
#-dontwarn android.webkit.WebView
#-dontwarn android.net.http.SslError
#-dontwarn android.webkit.WebViewClient
================================================
FILE: project/android/app/res/values/strings.xml
================================================
Kirikiroid2-Yuri
================================================
FILE: project/android/build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
}
allprojects {
buildDir = "./../../../build_android"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: project/android/gradle/wrapper/gradle-wrapper.properties
================================================
#Sat Mar 11 01:47:25 JST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
================================================
FILE: project/android/gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# Android SDK version that will be used as the compile project
PROP_COMPILE_SDK_VERSION=29
# Android SDK version that will be used as the earliest version of android this application can run on
PROP_MIN_SDK_VERSION=22
# Android SDK version that will be used as the latest version of android this application has been tested on
PROP_TARGET_SDK_VERSION=29
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
PROP_APP_ABI=arm64-v8a
# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=cmake
# uncomment it and fill in sign information for release mode
#RELEASE_STORE_FILE=file path of keystore
#RELEASE_STORE_PASSWORD=password of keystore
#RELEASE_KEY_ALIAS=alias of key
#RELEASE_KEY_PASSWORD=password of key
android.useAndroidX=True
================================================
FILE: project/android/gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: project/android/gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: project/android/settings.gradle
================================================
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
include ':cocos2dx'
project(':cocos2dx').projectDir = new File(settingsDir, '../../thirdparty/port/cocos2d-x/cocos/platform/android/libcocos2dx')
include ':krkr2yuri'
project(':krkr2yuri').projectDir = new File(settingsDir, 'app')
================================================
FILE: project/ui/.cocos-project.json
================================================
{
"engine_type": "prebuilt",
"engine_version": "cocos2d-x-3.6",
"project_type": "cpp"
}
================================================
FILE: project/ui/Resources/res/locale/en_us.xml
================================================
================================================
FILE: project/ui/Resources/res/locale/ja_jp.xml
================================================
================================================
FILE: project/ui/Resources/res/locale/zh_cn.xml
================================================
================================================
FILE: project/ui/Resources/res/locale/zh_tw.xml
================================================
================================================
FILE: project/ui/cocosstudio/ui/BottomBar.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/BottomBarTextInput.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/CheckListDialog.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/FileItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/FileManageMenu.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/GameMenu.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/KeySelect.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/ListItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/ListView.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/MainFileSelector.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/MediaPlayerBody.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/MediaPlayerFoot.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/MediaPlayerNavi.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/MenuList.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/MessageBox.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/NaviBar.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/NaviBarWithMenu.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/ProgressBox.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/RecentListItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/SelectList.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/SelectListItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/TableView.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/TextPairInput.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/WinMgrOverlay.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/comctrl/CheckBoxItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/comctrl/SelectListItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/comctrl/SeperateItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/comctrl/SliderIconItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/comctrl/SliderTextItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/comctrl/SubDirItem.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/help/AllTips.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/help/MouseModeTips.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/help/ScreenModeTips.csd
================================================
================================================
FILE: project/ui/cocosstudio/ui/help/TouchModeTips.csd
================================================
================================================
FILE: project/ui/kr2.ccs
================================================
================================================
FILE: project/ui/kr2.cfg
================================================
-
================================================
FILE: readme.md
================================================
# Krikiroid2-Yuri
 
☘️ A krikiroid2 project matained by Yurisizuku.
It will support the newer android device and more formats.
Roadmap :
- core
- [ ] replace rendering from cocos to SDL2
- [ ] command line or config files for setting
- [ ] recent cx game (hash filename) decryption support
- plugin
- [ ] [windowEx](https://github.com/wamsoft/windowEx)
- [ ] [layerEx](https://github.com/wamsoft/layerEx)
- [ ] [layerExDraw](https://github.com/wamsoft/layerExDraw) (gdiPlus)
- [ ] [scriptsEx](https://github.com/wamsoft/scriptsEx)
- platform
- android
- [x] SDK level above 21 (android 5.1, Lolipop)
- [x] bypass scoped storage
- [ ] access extern sdcard by saf
- windows
- linux
- develop
- [x] camke project structure, documention for develop
- [x] scripts to compile or cross compile
- [x] vscode and android studio project for multi enviroment
- [x] ci in github action to automaticly build
(This project is heavily relying on cocos. Sooner or later, I might rewrite these parts and replace them by SDL2. And because that the upstream didn't provide all the plugins source code, it still needs sometime to adapt them.)
## 1. usage
Although now the apk build from source is runable, it is not perfect. Beta version has some problems due to the cocos version change, incomplecate of some code. Currently the beta version is only aimed for debug. Please use [Kirikiroid2_yuri_1.3.9.apk](https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/1.3.9_yuri/Kirikiroid2_yuri_1.3.9.apk) instead.
## 2. Build
I add some futures by reverse engine before, and now this project can be build from source. This is really a very hard work, because there are so many dependencies, lack of files, code not compatible problems.
### (1) prepare
- wget, 7z, git, make, cmake
- python2(for cocos2d-x v3), msys2 (if windows)
- thirdparty depedency (see `_fetch.sh` in detail)
``` shell
# wget
https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.gz
https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.gz
https://downloads.xiph.org/releases/opus/opusfile-0.12.tar.gz
https://www.rarlab.com/rar/unrarsrc-6.0.7.tar.gz
https://www.libsdl.org/release/SDL2-2.0.14.tar.gz
# git
https://github.com/krkrz/oniguruma
https://github.com/google/breakpad
https://github.com/zeas2/FFmpeg
# git with version
https://github.com/google/oboe/archive/refs/tags/1.7.0.tar.gz
https://github.com/kcat/openal-soft/archive/refs/tags/1.23.0.tar.gz
https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/2.1.5.1.tar.gz
https://github.com/opencv/opencv/archive/refs/tags/4.7.0.tar.gz
https://github.com/lz4/lz4/archive/refs/tags/v1.9.4.tar.gz
https://github.com/libarchive/libarchive/archive/refs/tags/v3.6.2.tar.gz
https://github.com/cocos2d/cocos2d-x/archive/refs/tags/cocos2d-x-3.17.2.tar.gz
```
In windows, you must use msys2 to build ffmpeg port.
You can also download the prebuild ports from [thirdparty_ports.tar.gz](https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/deps/thirdparty_ports.tar.gz"), [thirdparty_build.tar.gz](https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/deps/thirdparty_build.tar.gz).
## (2) android
- android sdk with `ANDROID_HOME` variable in env
- android ndk 25.2.9519653
See `_androida64.sh` for how to build dependencies.
Use `script/cross_android64.sh` to build ports and the use `project/android/gradlew assembleDebug` to build apk.
## 3. Compatibility
|game|version|status|description|
|----|-------|------|-----------|
## 4. Issues (including solved)
(build from souce, beta version)
major:
- title path button click position is not correct
- crash in game menu form
- game alert window button can not click
- member GdiPlus does not exist
- global preference can not save
minor:
- ~~android studio buildDir not worked and it make dir at root~~ fixed by cmake `add_subdirectory` build dir
## 5. Todo
See Roadmap.
___
Original information about kirikiroid2 bellow, also refered some dependencies from [ningshanwutuobang](https://github.com/ningshanwutuobang/Kirikiroid2).
## Kirikiroid2 - A cross-platform port of Kirikiri2/KirikiriZ
==========================================================
Based on most code from [Kirikiri2](http://kikyou.info/tvp/) and [KirikiriZ](https://github.com/krkrz/krkrz)
Video playback module modified from [kodi](https://github.com/xbmc/xbmc)
Some string code from [glibc](https://www.gnu.org/s/libc) and [Apple Libc](https://opensource.apple.com/source/Libc).
Real-time texture codec modified from [etcpak](https://bitbucket.org/wolfpld/etcpak.git), [pvrtccompressor](https://bitbucket.org/jthlim/pvrtccompressor), [astcrt](https://github.com/daoo/astcrt)
Android storage accessing code from [AmazeFileManager](https://github.com/arpitkh96/AmazeFileManager)
================================================
FILE: script/_androida64.sh
================================================
# must use after _fetch.sh from cross_androida64.sh
# audio
build_opus()
{
if ! [ -d $OPUS_SRC/build_$PLATFORM ]; then mkdir -p $OPUS_SRC/build_$PLATFORM ;fi
pushd $OPUS_SRC/build_$PLATFORM
../configure --host=aarch64-linux-android \
CC=aarch64-linux-android21-clang AR=llvm-ar \
CXX=aarch64-linux-android21-clang++ \
--prefix=$PORTBUILD_PATH --with-pic
make -j$CORE_NUM && make install
popd
}
build_ogg()
{
if ! [ -d $OGG_SRC/build_$PLATFORM ]; then mkdir -p $OGG_SRC/build_$PLATFORM ;fi
pushd $OGG_SRC/build_$PLATFORM
../configure --host=aarch64-linux-android \
CC=aarch64-linux-android21-clang AR=llvm-ar \
CXX=aarch64-linux-android21-clang++ \
--prefix=$PORTBUILD_PATH --with-pic
make -j$CORE_NUM && make install
popd
}
build_vorbis()
{
if ! [ -d $VORBIS_SRC/build_$PLATFORM ]; then mkdir -p $VORBIS_SRC/build_$PLATFORM ;fi
pushd $VORBIS_SRC/build_$PLATFORM
../configure --host=aarch64-linux-android \
CC=aarch64-linux-android21-clang AR=llvm-ar \
CXX=aarch64-linux-android21-clang++ \
--prefix=$PORTBUILD_PATH --with-pic \
--with-ogg=$PORTBUILD_PATH
make -j$CORE_NUM && make install
popd
}
build_opusfile() # after ogg, opus, vorbits
{
if ! [ -d $OPUSFILE_SRC/build_$PLATFORM ]; then mkdir -p $OPUSFILE_SRC/build_$PLATFORM ;fi
pushd $OPUSFILE_SRC/build_$PLATFORM
../configure --host=aarch64-linux-android \
CC=aarch64-linux-android21-clang AR=llvm-ar \
CXX=aarch64-linux-android21-clang++ \
--prefix=$PORTBUILD_PATH --with-pic \
DEPS_CFLAGS="-I$PORTBUILD_PATH/include -I$PORTBUILD_PATH/include/opus" \
DEPS_LIBS="-L$PORTBUILD_PATH/lib -logg -lopus" \
--disable-http --disable-examples
make -j$CORE_NUM && make install
cp -rf $CMAKELISTS_PATH/thirdparty/patch/opus/opusfile.h $PORTBUILD_PATH/include/opus/opusfile.h
popd
}
build_oboe()
{
if ! [ -d $OBOE_SRC/build_$PLATFORM ]; then mkdir -p $OBOE_SRC/build_$PLATFORM ;fi
pushd $OBOE_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH \
-DLIBTYPE=STATIC
make -j$CORE_NUM && make install
mv -f $PORTBUILD_PATH/lib/arm64-v8a/liboboe.a $PORTBUILD_PATH/lib/liboboe.a
popd
}
build_openal()
{
if ! [ -d $OPENAL_SRC/build_$PLATFORM ]; then mkdir -p $OPENAL_SRC/build_$PLATFORM ;fi
pushd $OPENAL_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH \
-DLIBTYPE=STATIC
make -j$CORE_NUM && make install
popd
}
# video
build_jpeg()
{
if ! [ -d $JPEG_SRC/build_$PLATFORM ]; then mkdir -p $JPEG_SRC/build_$PLATFORM ;fi
pushd $JPEG_SRC/build_$PLATFORM
NDK_PATH=$NDK_HOME
TOOLCHAIN=clang
ANDROID_VERSION=21
cmake .. -G "Unix Makefiles" \
-DANDROID_ABI=arm64-v8a \
-DANDROID_ARM_MODE=arm \
-DANDROID_PLATFORM=android-${ANDROID_VERSION} \
-DANDROID_TOOLCHAIN=${TOOLCHAIN} \
-DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${ANDROID_VERSION}" \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH
make -j$CORE_NUM && make install
popd
}
build_opencv()
{
if ! [ -d $OPENCV_SRC/build_$PLATFORM ]; then mkdir -p $OPENCV_SRC/build_$PLATFORM ;fi
pushd $OPENCV_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH \
-DWITH_CUDA=OFF -DWITH_MATLAB=OFF -DBUILD_ANDROID_EXAMPLES=OFF \
-DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF \
-DBUILD_opencv_video=OFF -DBUILD_opencv_videoio=OFF -DBUILD_opencv_features2d=OFF \
-DBUILD_opencv_flann=OFF -DBUILD_opencv_highgui=OFF -DBUILD_opencv_ml=OFF \
-DBUILD_opencv_dnn=OFF -DBUILD_opencv_gapi=OFF -DBUILD_opencv_hal=ON \
-DBUILD_opencv_photo=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_shape=OFF \
-DBUILD_opencv_stitching=OFF -DBUILD_opencv_superres=OFF -DWITH_ITT=OFF \
-DBUILD_opencv_ts=OFF -DBUILD_opencv_videostab=OFF -DBUILD_ANDROID_PROJECTS=OFF
make -j$CORE_NUM && make install
cp -rf $PORTBUILD_PATH/sdk/native/3rdparty/libs/arm64-v8a/*.a $PORTBUILD_PATH/lib
cp -rf $PORTBUILD_PATH/sdk/native/staticlibs/arm64-v8a/libtegra_hal.a $PORTBUILD_PATH/lib
popd
}
build_ffmpeg()
{
if ! [ -d $FFMPEG_SRC/build_$PLATFORM ]; then mkdir -p $FFMPEG_SRC/build_$PLATFORM ;fi
pushd $FFMPEG_SRC
git apply $CMAKELISTS_PATH/thirdparty/patch/ffmpeg/android_ffmpeg.diff
cd build_$PLATFORM
../configure --enable-cross-compile --cross-prefix=aarch64-linux-android- \
--cc=aarch64-linux-android21-clang --ar=llvm-ar \
--cxx=aarch64-linux-android21-clang++ --ranlib=llvm-ranlib \
--strip=llvm-strip --prefix=$PORTBUILD_PATH \
--arch=aarch64 --target-os=android --enable-pic --disable-asm \
--enable-static --enable-shared --enable-small --enable-swscale \
--disable-ffmpeg --disable-ffplay --disable-ffprobe \
--disable-avdevice --disable-programs --disable-doc --enable-stripping
# use sh directory is not available in windows (absolute path), must use msys2 shell
make -j$CORE_NUM && make install
popd
}
# archive
build_unrar()
{
cp -rf $CMAKELISTS_PATH/thirdparty/patch/unrar/android_ulinks.cpp $UNRAR_SRC/ulinks.cpp
pushd $UNRAR_SRC
make clean
make lib -j$CORE_NUM \
CXX=aarch64-linux-android21-clang++ \
AR=llvm-ar STRIP=llvm-strip \
DESTDIR=$PORTBUILD_PATH
if ! [ -d $PORTBUILD_PATH/include/unrar ]; then mkdir -p $PORTBUILD_PATH/include/unrar ;fi
cp -rf *.a $PORTBUILD_PATH/lib
cp -rf *.hpp $PORTBUILD_PATH/include/unrar
popd
}
build_lz4()
{
pushd $LZ4_SRC
make clean
make lib -j$CORE_NUM \
CC=aarch64-linux-android21-clang \
CXX=aarch64-linux-android21-clang++ \
AR=llvm-ar STRIP=llvm-strip \
WINBASED=no
if ! [ -d $PORTBUILD_PATH/include/lz4 ]; then mkdir -p $PORTBUILD_PATH/include/lz4 ;fi
cp -rp lib/*.a $PORTBUILD_PATH/lib
cp -rp lib/*.h $PORTBUILD_PATH/include/lz4
popd
}
build_archive()
{
if ! [ -d $ARCHIVE_SRC/build_$PLATFORM ]; then mkdir -p $ARCHIVE_SRC/build_$PLATFORM ;fi
cp -rf $CMAKELISTS_PATH/thirdparty/patch/android_android_lf.h $ARCHIVE_SRC/libarchive/android_lf.h
pushd $ARCHIVE_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DENABLE_OPENSSL=OFF -DENABLE_TEST=OFF \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH
make -j$CORE_NUM && make install
if ! [ -d $PORTBUILD_PATH/include/libarchive ]; then mkdir -p $PORTBUILD_PATH/include/libarchive ;fi
mv -f $PORTBUILD_PATH/include/archive.h $PORTBUILD_PATH/include/libarchive
mv -f $PORTBUILD_PATH/include/archive_entry.h $PORTBUILD_PATH/include/libarchive
popd
}
build_p7zip()
{
if ! [ -d $P7ZIP_SRC/build_$PLATFORM ]; then mkdir -p $P7ZIP_SRC/build_$PLATFORM ;fi
cp -rf $CMAKELISTS_PATH/thirdparty/patch/p7zip/7z* $P7ZIP_SRC/C
cp -rf $CMAKELISTS_PATH/thirdparty/patch/p7zip/android_p7zip.cmake $P7ZIP_SRC/CPP/ANDROID/7za/jni/CMakeLists.txt
pushd $P7ZIP_SRC/build_$PLATFORM
cmake ../CPP/ANDROID/7za/jni -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake
make -j$CORE_NUM
if ! [ -d $PORTBUILD_PATH/include/p7zip/C ]; then mkdir -p $PORTBUILD_PATH/include/p7zip/C ;fi
if ! [ -d $PORTBUILD_PATH/include/p7zip/CPP ]; then mkdir -p $PORTBUILD_PATH/include/p7zip/CPP ;fi
cp -rf lib7za.a $PORTBUILD_PATH/lib
cp -rf ../C/*.h $PORTBUILD_PATH/include/p7zip/C
cp -rf ../CPP $PORTBUILD_PATH/include/p7zip
rm -rf $PORTBUILD_PATH/include/p7zip/CPP/**/*.cpp
rm -rf $PORTBUILD_PATH/include/p7zip/CPP/**/**/*.cpp
rm -rf $PORTBUILD_PATH/include/p7zip/CPP/**/**/**/*.cpp
rm -rf $PORTBUILD_PATH/include/p7zip/CPP/**/**/**/**/*.cpp
rm -rf $PORTBUILD_PATH/include/p7zip/CPP/ANDROID/7za/obj
popd
}
# others
build_oniguruma()
{
if ! [ -d $ONIGURUMA_SRC/build_$PLATFORM ]; then mkdir -p $ONIGURUMA_SRC/build_$PLATFORM ;fi
cp -rf $CMAKELISTS_PATH/thirdparty/patch/oniguruma/oniguruma.cmake $ONIGURUMA_SRC/CMakeLists.txt
pushd $ONIGURUMA_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH
make -j$CORE_NUM && make install
popd
}
build_breakpad() # after linux-syscall
{
if ! [ -d $BREAKPAD_SRC/build_$PLATFORM ]; then mkdir -p $BREAKPAD_SRC/build_$PLATFORM ;fi
cp -rf $SYSCALL_SRC/lss $BREAKPAD_SRC/src/third_party/
pushd $BREAKPAD_SRC/build_$PLATFORM
../configure --host=aarch64-linux-android \
CC=aarch64-linux-android21-clang AR=llvm-ar \
CXX=aarch64-linux-android21-clang++ STRIP=llvm-strip \
--prefix=$PORTBUILD_PATH \
--disable-tools
make -j$CORE_NUM && make install-strip
popd
}
# framework
build_sdl2()
{
if ! [ -d $SDL2_SRC/build_$PLATFORM ]; then mkdir -p $SDL2_SRC/build_$PLATFORM ;fi
cp -rf $CMAKELISTS_PATH/thirdparty/patch/sdl2/android_SDL_android.c $SDL2_SRC/src/core/android/SDL_android.c
pushd $SDL2_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DANDROID=ON -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH \
-DHIDAPI=OFF -DHAVE_GCC_WDECLARATION_AFTER_STATEMENT=OFF
make -j$CORE_NUM && make install
popd
}
build_cocos2dx()
{
if ! [ -d $COCOS2DX_SRC/platform/build_$PLATFORM ]; then mkdir -p $COCOS2DX_SRC/build_$PLATFORM ;fi
cp $CMAKELISTS_PATH/thirdparty/patch/cocos2d-x/android_cocos2dx.cmake $COCOS2DX_SRC/CMakeLists.txt
cp $CMAKELISTS_PATH/thirdparty/patch/cocos2d-x/android_CCFileUtils-android.h $COCOS2DX_SRC/cocos/platform/android/CCFileUtils-android.h
cp $CMAKELISTS_PATH/thirdparty/patch/cocos2d-x/android_CCFileUtils-android.cpp $COCOS2DX_SRC/cocos/platform/android/CCFileUtils-android.cpp
cp $CMAKELISTS_PATH/thirdparty/patch/cocos2d-x/android_Java_org_cocos2dx_lib_Cocos2dxHelper.h $COCOS2DX_SRC/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h
cp $CMAKELISTS_PATH/thirdparty/patch/cocos2d-x/android_Java_org_cocos2dx_lib_Cocos2dxHelper.cpp $COCOS2DX_SRC/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
pushd $COCOS2DX_SRC/build_$PLATFORM
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DCMAKE_INSTALL_PREFIX=$PORTBUILD_PATH \
-DBUILD_TESTS=OFF -DBUILD_LUA_LIBS=OFF -DBUILD_JS_LIBS=OFF
make -j$CORE_NUM
cp -rf lib/libcocos2d.a $PORTBUILD_PATH/lib/
cp -rf lib/libext_*.a $PORTBUILD_PATH/lib/
cp -rf engine/cocos/android/libcpp_android_spec.a $PORTBUILD_PATH/lib/
cp -rf ../external/zlib/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
cp -rf ../external/png/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
cp -rf ../external/tiff/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
cp -rf ../external/webp/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
cp -rf ../external/freetype2/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
cp -rf ../external/chipmunk/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
cp -rf ../external/bullet/prebuilt/android/arm64-v8a/*.a $PORTBUILD_PATH/lib/
popd
}
================================================
FILE: script/_fetch.sh
================================================
# prepare dirs
if ! [ -d $CMAKELISTS_PATH/thirdparty/port ]; then mkdir -p $CMAKELISTS_PATH/thirdparty/port; fi
if ! [ -d $CMAKELISTS_PATH/thirdparty/build/arch_androida32 ]; then mkdir -p $CMAKELISTS_PATH/thirdparty/build/arch_androida32; fi
if ! [ -d $CMAKELISTS_PATH/thirdparty/build/arch_androida64 ]; then mkdir -p $CMAKELISTS_PATH/thirdparty/build/arch_androida64; fi
# fetch by wget
function fetch_port() # urlbase, name, outpath
{
if ! [ -d "$CMAKELISTS_PATH/thirdparty/port/$2" ]; then
echo "## fetch_port $1 $2"
wget $1/$2.tar.gz -O $CMAKELISTS_PATH/thirdparty/port/$2.tar.gz
tar zxf $CMAKELISTS_PATH/thirdparty/port/$2.tar.gz -C $CMAKELISTS_PATH/thirdparty/port
fi
}
# fetch by git
function fetch_port2()
{
if ! [ -d "$CMAKELISTS_PATH/thirdparty/port/$2" ]; then
inpath=$1/$2.git
outpath=$CMAKELISTS_PATH/thirdparty/port/$2
tag=$3
echo "## fetch_port $inpath $tag"
if [ -n "$tag" ]; then
git clone --recursive --depth 1 --branch $tag $inpath $outpath
else
git clone --recursive --depth 1 $inpath $outpath
fi
fi
}
# wget ports
function fetch_vorbis()
{
VORBIS_NAME=libvorbis-1.3.7
VORBIS_SRC=$CMAKELISTS_PATH/thirdparty/port/$VORBIS_NAME
fetch_port https://downloads.xiph.org/releases/vorbis $VORBIS_NAME
}
function fetch_opus()
{
OPUS_NAME=opus-1.3.1
OPUS_SRC=$CMAKELISTS_PATH/thirdparty/port/$OPUS_NAME
fetch_port https://archive.mozilla.org/pub/opus $OPUS_NAME
}
function fetch_ogg()
{
OGG_NAME=libogg-1.3.5
OGG_SRC=$CMAKELISTS_PATH/thirdparty/port/$OGG_NAME
fetch_port https://downloads.xiph.org/releases/ogg $OGG_NAME
}
function fetch_opusfile()
{
OPUSFILE_NAME=opusfile-0.12
OPUSFILE_SRC=$CMAKELISTS_PATH/thirdparty/port/$OPUSFILE_NAME
fetch_port https://downloads.xiph.org/releases/opus $OPUSFILE_NAME
}
function fetch_unrar()
{
UNRAR_NAME=unrarsrc-6.0.7
UNRAR_SRC=$CMAKELISTS_PATH/thirdparty/port/$UNRAR_NAME
fetch_port https://www.rarlab.com/rar $UNRAR_NAME
if [ -d $CMAKELISTS_PATH/thirdparty/port/unrar ]; then
mv $CMAKELISTS_PATH/thirdparty/port/unrar $UNRAR_SRC
fi
}
function fetch_p7zip()
{
P7ZIP_NAME=p7zip_16.02
P7ZIP_SRC=$CMAKELISTS_PATH/thirdparty/port/$P7ZIP_NAME
if ! [ -d "$P7ZIP_SRC" ]; then
echo "## fetch_port $P7ZIP_NAME"
wget https://sourceforge.net/projects/p7zip/files/p7zip/16.02/p7zip_16.02_src_all.tar.bz2 \
-O $CMAKELISTS_PATH/thirdparty/port/$P7ZIP_NAME.tar.bz2
tar zxf $CMAKELISTS_PATH/thirdparty/port//$P7ZIP_NAME.tar.bz2 \
-C $CMAKELISTS_PATH/thirdparty/port
fi
}
function fetch_sdl2()
{
SDL2_NAME=SDL2-2.0.14
SDL2_SRC=$CMAKELISTS_PATH/thirdparty/port/$SDL2_NAME
fetch_port https://www.libsdl.org/release $SDL2_NAME
}
# git ports
function fetch_openal()
{
OPENAL_NAME=openal-soft
OPENAL_VERSION=1.23.0
OPENAL_SRC=$CMAKELISTS_PATH/thirdparty/port/$OPENAL_NAME
fetch_port2 https://github.com/kcat $OPENAL_NAME $OPENAL_VERSION
}
function fetch_oboe()
{
OBOE_NAME=oboe
OBOE_VERSION=1.7.0
OBOE_SRC=$CMAKELISTS_PATH/thirdparty/port/$OBOE_NAME
fetch_port2 https://github.com/google $OBOE_NAME $OBOE_VERSION
}
function fetch_jpeg()
{
JPEG_NAME=libjpeg-turbo
JPEG_SRC=$CMAKELISTS_PATH/thirdparty/port/$JPEG_NAME
JPEG_VERSION=2.1.5.1
fetch_port2 https://github.com/libjpeg-turbo $JPEG_NAME $JPEG_VERSION
}
function fetch_opencv()
{
OPENCV_NAME=opencv
OPENCV_VERSION=4.7.0
OPENCV_SRC=$CMAKELISTS_PATH/thirdparty/port/$OPENCV_NAME
fetch_port2 https://github.com/opencv $OPENCV_NAME $OPENCV_VERSION
}
function fetch_ffmpeg()
{
FFMPEG_NAME=ffmpeg
FFMPEG_SRC=$CMAKELISTS_PATH/thirdparty/port/$FFMPEG_NAME
fetch_port2 https://github.com/zeas2 $FFMPEG_NAME
}
function fetch_lz4()
{
LZ4_NAME=lz4
LZ4_VERSION=v1.9.4
LZ4_SRC=$CMAKELISTS_PATH/thirdparty/port/$LZ4_NAME
fetch_port2 https://github.com/lz4 $LZ4_NAME $LZ4_VERSION
}
function fetch_archive()
{
ARCHIVE_NAME=libarchive
ARCHIVE_VERSION=v3.6.2
ARCHIVE_SRC=$CMAKELISTS_PATH/thirdparty/port/$ARCHIVE_NAME
fetch_port2 https://github.com/libarchive $ARCHIVE_NAME $ARCHIVE_VERSION
}
function fetch_oniguruma()
{
ONIGURUMA_NAME=oniguruma
ONIGURUMA_SRC=$CMAKELISTS_PATH/thirdparty/port/$ONIGURUMA_NAME
fetch_port2 https://github.com/krkrz $ONIGURUMA_NAME
}
function fetch_syscall()
{
SYSCALL_NAME=linux-syscall-support
SYSCALL_SRC=$CMAKELISTS_PATH/thirdparty/port/$SYSCALL_NAME
fetch_port2 https://github.com/adelshokhy112 $SYSCALL_NAME
}
function fetch_breakpad()
{
BREAKPAD_NAME=breakpad
BREAKPAD_SRC=$CMAKELISTS_PATH/thirdparty/port/$BREAKPAD_NAME
fetch_port2 https://github.com/google $BREAKPAD_NAME
}
function fetch_cocos2dx()
{
COCOS2DX_NAME=cocos2d-x
COCOS2DX_VERSION=cocos2d-x-3.17.2
COCOS2DX_SRC=$CMAKELISTS_PATH/thirdparty/port/$COCOS2DX_NAME
fetch_port2 https://github.com/cocos2d $COCOS2DX_NAME $COCOS2DX_VERSION
if ! [ -d "$CMAKELISTS_PATH/thirdparty/port/$COCOS2DX_NAME" ]; then
pushd $COCOS2DX_SRC
python2 download-deps.py # must use cocos v3 and python2
git config --global url.https://github.com/.insteadOf git://github.com/
git submodule update --init # submodule might cuse some problem, as it use git@
popd
fi
}
# android
function fetch_asset()
{
if ! [ -d "$CMAKELISTS_PATH/assets" ]; then
wget https://github.com/YuriSizuku/Kirikiroid2Yuri/releases/download/1.3.9_yuri/Kirikiroid2_yuri_1.3.9.apk \
-O $CMAKELISTS_PATH/thirdparty/port/Kirikiroid2_yuri_1.3.9.apk
7z x -o$CMAKELISTS_PATH $CMAKELISTS_PATH/thirdparty/port/Kirikiroid2_yuri_1.3.9.apk assets
fi
}
# notused ports
function fetch_bpg()
{
BPG_NAME=android-bpg
BPG_SRC=$CMAKELISTS_PATH/thirdparty/port/$BPG_NAME
fetch_port2 https://github.com/alexandruc $BPG_NAME
}
function fetch_jxr()
{
JXR_NAME=jxrlib
JXR_SRC=$CMAKELISTS_PATH/thirdparty/port/$JXR_NAME
fetch_port2 https://github.com/krkrz $JXR_NAME
}
================================================
FILE: script/cross_androida64.sh
================================================
# bash -c "export SKIP_PORTS=yes && ./cross_androida64.sh"
PLATFORM=androida64
BUILD_PATH=./../build_${PLATFORM}
CMAKELISTS_PATH=$(pwd)/..
PORTBUILD_PATH=$CMAKELISTS_PATH/thirdparty/build/arch_$PLATFORM
ANDROID_THIRDPARTY_PATH=$CMAKELISTS_PATH/src/onsyuri_android/app/cpp/thirdparty
CORE_NUM=$(cat /proc/cpuinfo | grep -c ^processor)
TARGETS=$@
function fetch_ports()
{
# audio
fetch_opus
fetch_ogg
fetch_vorbis
fetch_opusfile
fetch_oboe
fetch_openal
# video
fetch_jpeg
fetch_opencv
fetch_ffmpeg
# archive
fetch_unrar
fetch_lz4
fetch_archive
fetch_p7zip
# others
fetch_oniguruma
fetch_syscall
fetch_breakpad
# framework
fetch_sdl2
fetch_cocos2dx
}
function build_ports()
{
# audio
build_opus
build_ogg
build_vorbis
build_opusfile
build_oboe
build_openal
# video
build_jpeg
build_opencv
build_ffmpeg
# archive
build_unrar
build_lz4
build_archive
build_p7zip
# others
build_oniguruma
build_breakpad
# framework
build_sdl2
build_cocos2dx
}
# prepare env, tested with ndk 25.2.9519653
if [ -z "$ANDROID_HOME" ]; then ANDROID_HOME=/d/Software/env/sdk/androidsdk; fi
NDK_HOME=$ANDROID_HOME/ndk/$(ls -A $ANDROID_HOME/ndk | tail -n 1)
PREBUILT_DIR=$NDK_HOME/toolchains/llvm/prebuilt
PREBUILT_DIR=$PREBUILT_DIR/$(ls -A $PREBUILT_DIR | tail -n 1)
PATH=$NDK_HOME/build:$PREBUILT_DIR/bin:$PATH
CC=$(which aarch64-linux-android21-clang)
CXX=$(which aarch64-linux-android21-clang++)
AR=$(which llvm-ar)
RANLIB=$(which llvm-ranlib)
NM=$(which llvm-nm)
STRIP=$(which llvm-strip)
NDKBUILD=$(which ndk-build)
SYSROOT=$PREBUILT_DIR/sysroot
echo "## ANDROID_HOME=$ANDROID_HOME"
echo "## NDK-BUILD=$NDKBUILD"
echo "## CC=$CC"
echo "## AR=$AR"
# fetch and build ports
# SKIP_PORTS="yes"
source ./_fetch.sh
source ./_$PLATFORM.sh
fetch_asset
if [ -z "$SKIP_PORTS" ]; then
fetch_ports
build_ports
fi
# config and build project
if [ -z "$BUILD_TYPE" ]; then BUILD_TYPE=MinSizeRel; fi
if [ -z "$TARGETS" ]; then TARGETS=all; fi
cmake -B $BUILD_PATH -S $CMAKELISTS_PATH \
-G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a \
-DPORTBUILD_PATH=$PORTBUILD_PATH
make -C $BUILD_PATH $TARGETS -j$CORE_NUM
# make -C $BUILD_PATH $TARGETS -j1
# $STRIP $BUILD_PATH/libkrkr2yuri.so
================================================
FILE: src/core/Android.mk
================================================
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := krkr2
LOCAL_SRC_FILES := \
$(filter-out $(LOCAL_PATH)/visual/Resampler.cpp, $(wildcard $(LOCAL_PATH)/visual/*.cpp)) \
$(wildcard $(LOCAL_PATH)/base/7zip/*.c) \
$(wildcard $(LOCAL_PATH)/base/7zip/C/*.c) \
$(wildcard $(LOCAL_PATH)/base/7zip/CPP/*/*.cpp) \
$(wildcard $(LOCAL_PATH)/base/7zip/CPP/*/*/*.cpp) \
$(wildcard $(LOCAL_PATH)/base/7zip/CPP/*/*/*/*.cpp) \
$(wildcard $(LOCAL_PATH)/base/*.cpp) \
$(filter-out $(LOCAL_PATH)/base/win32/FuncStubs.cpp $(LOCAL_PATH)/base/win32/SusieArchive.cpp, $(wildcard $(LOCAL_PATH)/base/win32/*.cpp)) \
$(filter-out $(LOCAL_PATH)/environ/MainFormUnit.cpp, $(wildcard $(LOCAL_PATH)/environ/*.cpp)) \
$(wildcard $(LOCAL_PATH)/environ/cocos2d/*.cpp) \
$(wildcard $(LOCAL_PATH)/environ/android/*.cpp) \
$(wildcard $(LOCAL_PATH)/environ/linux/*.cpp) \
$(wildcard $(LOCAL_PATH)/environ/ui/*.cpp) \
$(wildcard $(LOCAL_PATH)/environ/ui/extension/*.cpp) \
environ/win32/SystemControl.cpp \
$(wildcard $(LOCAL_PATH)/extension/*.cpp) \
$(wildcard $(LOCAL_PATH)/movie/*.cpp) \
$(wildcard $(LOCAL_PATH)/movie/*/*.cpp) \
$(wildcard $(LOCAL_PATH)/msg/*.cpp) \
msg/win32/MsgImpl.cpp \
msg/win32/OptionsDesc.cpp \
$(filter-out $(LOCAL_PATH)/sound/xmmlib.cpp $(LOCAL_PATH)/sound/WaveFormatConverter_SSE.cpp, $(wildcard $(LOCAL_PATH)/sound/*.cpp)) \
$(wildcard $(LOCAL_PATH)/sound/win32/*.cpp) \
$(wildcard $(LOCAL_PATH)/tjs2/*.cpp) \
$(wildcard $(LOCAL_PATH)/utils/*.c) \
$(wildcard $(LOCAL_PATH)/utils/*.cpp) \
$(wildcard $(LOCAL_PATH)/utils/encoding/*.c) \
$(wildcard $(LOCAL_PATH)/utils/minizip/*.c) \
$(wildcard $(LOCAL_PATH)/utils/minizip/*.cpp) \
$(wildcard $(LOCAL_PATH)/utils/win32/*.cpp) \
$(wildcard $(LOCAL_PATH)/visual/gl/*.cpp) \
$(wildcard $(LOCAL_PATH)/visual/ogl/*.cpp) \
$(filter-out $(LOCAL_PATH)/visual/win32/GDIFontRasterizer.cpp $(LOCAL_PATH)/visual/win32/NativeFreeTypeFace.cpp \
$(LOCAL_PATH)/visual/win32/TVPSysFont.cpp $(LOCAL_PATH)/visual/win32/VSyncTimingThread.cpp \
, $(wildcard $(LOCAL_PATH)/visual/win32/*.cpp)) \
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/base \
$(LOCAL_PATH)/base/win32 \
$(LOCAL_PATH)/environ \
$(LOCAL_PATH)/environ/win32 \
$(LOCAL_PATH)/environ/android \
$(LOCAL_PATH)/environ/sdl \
$(LOCAL_PATH)/msg \
$(LOCAL_PATH)/msg/win32 \
$(LOCAL_PATH)/extension \
$(LOCAL_PATH)/sound \
$(LOCAL_PATH)/sound/win32 \
$(LOCAL_PATH)/tjs2 \
$(LOCAL_PATH)/utils \
$(LOCAL_PATH)/utils/win32 \
$(LOCAL_PATH)/../../vendor/freetype/current/include \
$(LOCAL_PATH)/visual \
$(LOCAL_PATH)/visual/ARM \
$(LOCAL_PATH)/visual/win32 \
$(LOCAL_PATH)/../plugins \
$(LOCAL_PATH)/../../vendor/jxrlib/current/common/include \
$(LOCAL_PATH)/../../vendor/jxrlib/current/image/sys \
$(LOCAL_PATH)/../../vendor/jxrlib/current/jxrgluelib \
$(LOCAL_PATH)/../../vendor/libjpeg-turbo/current \
$(LOCAL_PATH)/../../vendor/onig/current \
$(LOCAL_PATH)/../../vendor/libiconv/current/include \
$(LOCAL_PATH)/../../vendor/fmod/include \
$(LOCAL_PATH)/../../vendor/libgdiplus/src \
$(LOCAL_PATH)/../../vendor/opus/current/include \
$(LOCAL_PATH)/../../vendor/opus/opusfile/include \
$(LOCAL_PATH)/../../vendor/opencv/current/build/include \
$(LOCAL_PATH)/../../vendor/openal/current/include \
$(LOCAL_PATH)/../../vendor/lz4 \
$(LOCAL_PATH)/../../libs/android/bpg/include \
$(LOCAL_PATH)/../../libs/android/ffmpeg/include \
$(LOCAL_PATH)/../../libs/android/libarchive/include \
$(LOCAL_PATH)/visual/RenderScript/rs \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/cocos \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/cocos/platform \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/external/webp/include/android \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/external/jpeg/include/android \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/external/png/include/android \
$(LOCAL_PATH)/../../vendor/cocos2d-x/current/external \
LOCAL_CPPFLAGS += -DTJS_TEXT_OUT_CRLF -D__STDC_CONSTANT_MACROS -DUSE_UNICODE_FSTRING
LOCAL_CFLAGS += -DTJS_TEXT_OUT_CRLF -D_7ZIP_ST
LOCAL_STATIC_LIBRARIES := ffmpeg libopencv_imgproc libopencv_core libopencv_hal libtbb gdiplus_static cpufeatures \
opusfile_static opus_static onig_static libbpg_static vorbis_static cairo_static pixman_static expat_static \
breakpad_client openal_static jxrlib_static libarchive_static
# libRScpp_static
include $(BUILD_STATIC_LIBRARY)
$(call import-module, android/cpufeatures)
$(call import-module, opus)
$(call import-module, opusfile)
$(call import-module, onig)
$(call import-module, bpg)
$(call import-module, opencv)
$(call import-module, openal)
$(call import-module, vorbis)
#$(call import-module, android-ndk-profiler)
$(call import-module, jxrlib)
$(call import-module, ffmpeg)
$(call import-module, cairo)
$(call import-module, pixman)
$(call import-module, gdiplus)
$(call import-module, expat)
$(call import-module, google_breakpad)
#$(call import-module, libRScpp)
$(call import-module, libarchive)
================================================
FILE: src/core/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.6)
project(krkr2core)
set(KRKR2CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(COCOS2DX_PATH ${KRKR2CORE_PATH}/../../thirdparty/port/cocos2d-x)
# prepare static lib
function(add_static_library TARGET LIBNAME)
if ("${LIBNAME}" STREQUAL "")
set(LIBNAME "lib${TARGET}.a")
endif()
add_library("${TARGET}_static" STATIC IMPORTED GLOBAL)
set_target_properties("${TARGET}_static"
PROPERTIES IMPORTED_LOCATION
${PORTBUILD_PATH}/lib/${LIBNAME}
)
endfunction()
add_static_library(jpeg libturbojpeg.a)
add_static_library(ogg "")
add_static_library(opus "")
add_static_library(opusfile "")
add_static_library(vorbis "")
add_static_library(vorbisfile "")
add_static_library(vorbisenc "")
add_static_library(openal "")
add_static_library(archive "")
add_static_library(avutil "")
add_static_library(avfilter "")
add_static_library(avformat "")
add_static_library(avcodec "")
add_static_library(swscale "")
add_static_library(swresample "")
add_static_library(onig "")
add_static_library(sdl2 libSDL2.a)
# search kr2core src
file(GLOB KRKR2CORE_CODE
${KRKR2CORE_PATH}/visual/*.cpp
${KRKR2CORE_PATH}/base/*.cpp
${KRKR2CORE_PATH}/base/win32/*.cpp
${KRKR2CORE_PATH}/environ/*.cpp
${KRKR2CORE_PATH}/environ/ConfigManager/*.cpp
${KRKR2CORE_PATH}/environ/cocos2d/*.cpp
${KRKR2CORE_PATH}/environ/linux/*.cpp
${KRKR2CORE_PATH}/environ/ui/*.cpp
${KRKR2CORE_PATH}/environ/ui/extension/*.cpp
${KRKR2CORE_PATH}/environ/win32/SystemControl.cpp
${KRKR2CORE_PATH}/extension/*.cpp
${KRKR2CORE_PATH}/movie/*.cpp
${KRKR2CORE_PATH}/movie/*/*.cpp
${KRKR2CORE_PATH}/msg/*.cpp
${KRKR2CORE_PATH}/msg/win32/MsgImpl.cpp
${KRKR2CORE_PATH}/msg/win32/OptionsDesc.cpp
${KRKR2CORE_PATH}/sound/*.cpp
${KRKR2CORE_PATH}/sound/win32/*.cpp
${KRKR2CORE_PATH}/tjs2/*.cpp
${KRKR2CORE_PATH}/utils/*.c
${KRKR2CORE_PATH}/utils/*.cpp
${KRKR2CORE_PATH}/utils/encoding/*.c
${KRKR2CORE_PATH}/utils/minizip/*.c
${KRKR2CORE_PATH}/utils/minizip/*.cpp
${KRKR2CORE_PATH}/utils/win32/*.cpp
${KRKR2CORE_PATH}/visual/gl/*.cpp
${KRKR2CORE_PATH}/visual/ogl/*.cpp
${KRKR2CORE_PATH}/visual/win32/*.cpp
)
file(GLOB KRKR2CORE_CODEANDROID
${KRKR2CORE_PATH}/environ/android/*.cpp
${KRKR2CORE_PATH}/sound/ARM/*.c
${KRKR2CORE_PATH}/sound/ARM/*.cpp
${KRKR2CORE_PATH}/visual/ARM/*.cpp
${KRKR2CORE_PATH}/visual/ARM/*.c
)
list(REMOVE_ITEM KRKR2CORE_CODE
${KRKR2CORE_PATH}/base/win32/FuncStubs.cpp
${KRKR2CORE_PATH}/base/win32/SusieArchive.cpp
${KRKR2CORE_PATH}/environ/MainFormUnit.cpp
${KRKR2CORE_PATH}/environ/XP3ArchiveRepack.cpp
${KRKR2CORE_PATH}/environ/ui/XP3RepackForm.cpp
${KRKR2CORE_PATH}/sound/xmmlib.cpp
${KRKR2CORE_PATH}/sound/WaveFormatConverter_SSE.cpp
${KRKR2CORE_PATH}/visual/Resampler.cpp
${KRKR2CORE_PATH}/visual/win32/GDIFontRasterizer.cpp
${KRKR2CORE_PATH}/visual/win32/NativeFreeTypeFace.cpp
${KRKR2CORE_PATH}/visual/win32/TVPSysFont.cpp
${KRKR2CORE_PATH}/visual/win32/VSyncTimingThread.cpp
${KRKR2CORE_PATH}/visual/LoadJXR.cpp
${KRKR2CORE_PATH}/visual/LoadBPG.cpp
)
if(CMAKE_SYSTEM_NAME MATCHES "Android")
list(APPEND KRKR2CORE_CODE ${KRKR2CORE_CODEANDROID})
set(PLATFORM android)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(PLATFORM linux)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(PLATFORM win32)
else()
set(PLATFORM android)
endif()
# make krkr2core
add_library(${PROJECT_NAME} STATIC ${KRKR2CORE_CODE})
if(CMAKE_SYSTEM_NAME MATCHES "Android")
target_include_directories(${PROJECT_NAME} PUBLIC
${PORTBUILD_PATH}/sdk/native/jni/include
${CMAKE_ANDROID_NDK}/sources/android/cpufeatures
)
target_link_libraries(${PROJECT_NAME} PUBLIC
-Wl,-Bdynamic
log
android
EGL
GLESv2
GLESv1_CM
OpenSLES
)
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
${KRKR2CORE_PATH}/
${KRKR2CORE_PATH}/base
${KRKR2CORE_PATH}/base/win32
${KRKR2CORE_PATH}/environ
${KRKR2CORE_PATH}/environ/win32
${KRKR2CORE_PATH}/environ/android
${KRKR2CORE_PATH}/environ/sdl
${KRKR2CORE_PATH}/msg
${KRKR2CORE_PATH}/msg/win32
${KRKR2CORE_PATH}/extension
${KRKR2CORE_PATH}/sound
${KRKR2CORE_PATH}/sound/win32
${KRKR2CORE_PATH}/tjs2
${KRKR2CORE_PATH}/utils
${KRKR2CORE_PATH}/utils/win32
${KRKR2CORE_PATH}/visual
${KRKR2CORE_PATH}/visual/ARM
${KRKR2CORE_PATH}/visual/win32
${KRKR2CORE_PATH}/visual/RenderScript/rs
${KRKR2CORE_PATH}/../plugins
${COCOS2DX_PATH}
${COCOS2DX_PATH}/cocos
${COCOS2DX_PATH}/cocos/scripting
${COCOS2DX_PATH}/cocos/editor-support
${COCOS2DX_PATH}/extensions
${COCOS2DX_PATH}/external
${COCOS2DX_PATH}/external/png/include/${PLATFORM}
${COCOS2DX_PATH}/external/webp/include/${PLATFORM}
${COCOS2DX_PATH}/external/freetype2/include/${PLATFORM}
${COCOS2DX_PATH}/external/freetype2/include/${PLATFORM}/freetype2
${PORTBUILD_PATH}/include
)
target_compile_definitions(${PROJECT_NAME} PUBLIC
-DTJS_TEXT_OUT_CRLF -D__STDC_CONSTANT_MACROS -DUSE_UNICODE_FSTRING
-DTJS_TEXT_OUT_CRLF -D_7ZIP_ST
)
target_compile_options(${PROJECT_NAME} PUBLIC
-fPIC
)
target_link_directories(${PROJECT_NAME} PUBLIC
${PORTBUILD_PATH}/lib
)
target_link_libraries(${PROJECT_NAME} PUBLIC
-Wl,-Bstatic
# audio
ogg_static
opus_static
vorbis_static
vorbisfile_static
vorbisenc_static
opusfile_static
oboe
openal_static
# image
jpeg_static
opencv_imgproc
opencv_core
tegra_hal
# video
avutil_static
avfilter_static
avformat_static
avcodec_static
swscale_static
swresample_static
# archive
unrar
lz4
archive_static # libbpg_static jxrlib_static
7za
# others
onig_static
breakpad
breakpad_client
# framework
sdl2_static
cocos2d
ext_unzip
ext_tinyxml2
ext_xxhash
ext_edtaa3func
ext_poly2tri
ext_recast
ext_clipper
ext_convertUTF
ext_pvmp3dec
chipmunk
BulletCollision
BulletDynamics
BulletMultiThreaded
LinearMath
MiniCL
z
png
webp
tiff
freetype
)
================================================
FILE: src/core/base/7zArchive.cpp
================================================
#include "tjsCommHead.h"
#include "StorageIntf.h"
#include "UtilStreams.h"
#include
extern "C" {
#include "p7zip/C/7z.h"
#include "p7zip/C/7zFile.h"
#include "p7zip/C/7zCrc.h"
}
#include "StorageImpl.h"
static ISzAlloc allocImp = {
[](void *p, size_t size) -> void *{ return malloc(size); },
[](void *p, void *addr) { free(addr); }
};
class SevenZipStreamWrap {
public:
CSzArEx db;
tTJSBinaryStream *_stream;
CLookToRead lookStream;
struct CSeekInStream : public ISeekInStream {
SevenZipStreamWrap *Host;
} archiveStream;
public:
SevenZipStreamWrap(tTJSBinaryStream * st) : _stream(st) {
archiveStream.Host = this;
archiveStream.Read = [](void *p, void *buf, size_t *size)->SRes {return ((CSeekInStream*)p)->Host->StreamRead(buf, size); };
archiveStream.Seek = [](void *p, Int64 *pos, ESzSeek origin)->SRes {return ((CSeekInStream*)p)->Host->StreamSeek(pos, origin); };
LookToRead_CreateVTable(&lookStream, false);
lookStream.realStream = &archiveStream;
SzArEx_Init(&db);
if (!g_CrcTable[1]) CrcGenerateTable();
}
~SevenZipStreamWrap() {
SzArEx_Free(&db, &allocImp);
delete _stream;
}
SRes StreamRead(void *buf, size_t *size) {
*size = _stream->Read(buf, *size);
return SZ_OK;
}
SRes StreamSeek(Int64 *pos, ESzSeek origin) {
tjs_int whence = TJS_BS_SEEK_SET;
switch (origin) {
case SZ_SEEK_CUR: whence = TJS_BS_SEEK_CUR; break;
case SZ_SEEK_END: whence = TJS_BS_SEEK_END; break;
case SZ_SEEK_SET: whence = TJS_BS_SEEK_SET; break;
default: break;
}
*pos = _stream->Seek(*pos, whence);
return SZ_OK;
}
};
class SevenZipArchive : public tTVPArchive, public SevenZipStreamWrap {
std::vector > filelist;
public:
SevenZipArchive(const ttstr & name, tTJSBinaryStream *st) : tTVPArchive(name), SevenZipStreamWrap(st) {
}
virtual ~SevenZipArchive() { }
virtual tjs_uint GetCount() { return filelist.size(); }
virtual ttstr GetName(tjs_uint idx) { return filelist[idx].first; }
virtual tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx) {
tjs_uint fileIndex = filelist[idx].second;
UInt64 fileSize = SzArEx_GetFileSize(&db, fileIndex);
if (fileSize <= 0) return new tTVPMemoryStream();
UInt32 folderIndex = db.FileToFolder[fileIndex];
if (folderIndex == (UInt32)-1) return nullptr;
const CSzAr *p = &db.db;
CSzFolder folder;
CSzData sd;
const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex];
sd.Data = data;
sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex];
if (SzGetNextFolderItem(&folder, &sd) != SZ_OK) return nullptr;
if (folder.NumCoders == 1) {
UInt64 startPos = db.dataPos;
const UInt64 *packPositions = p->PackPositions + p->FoStartPackStreamIndex[folderIndex];
UInt64 offset = packPositions[0];
UInt64 inSize = packPositions[1] - offset;
#define k_Copy 0
if (folder.Coders[0].MethodID == k_Copy && inSize == fileSize) {
return new TArchiveStream(this, startPos + offset, inSize);
}
}
UInt32 blockIndex;
Byte *outBuffer = nullptr;
size_t outBufferSize;
size_t offset, outSizeProcessed;
SRes res = SzArEx_Extract(&db, &lookStream.s, fileIndex, &blockIndex, &outBuffer, &outBufferSize,
&offset, &outSizeProcessed, &allocImp, &allocImp);
tTVPMemoryStream *mem;
if (offset == 0 && fileSize <= outBufferSize) {
mem = new tTVPMemoryStream(outBuffer, outBufferSize);
} else {
Byte *buf = new Byte[fileSize];
memcpy(buf, outBuffer, fileSize);
mem = new tTVPMemoryStream(buf, fileSize);
delete outBuffer;
}
return mem;
}
bool Open(bool normalizeFileName) {
SRes res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocImp);
if (res != SZ_OK) {
_stream = nullptr;
return false;
}
for (int i = 0; i < db.NumFiles; i++) {
size_t offset = 0;
size_t outSizeProcessed = 0;
bool isDir = SzArEx_IsDir(&db, i);
if (isDir) continue;
size_t len = SzArEx_GetFileNameUtf16(&db, i, NULL);
ttstr filename;
SzArEx_GetFileNameUtf16(&db, i, (UInt16*)filename.AllocBuffer(len));
filename.FixLen();
if (normalizeFileName)
NormalizeInArchiveStorageName(filename);
filelist.emplace_back(filename, i);
}
if (normalizeFileName) {
std::sort(filelist.begin(), filelist.end(), [](const std::pair& a, const std::pair& b) {
return a.first < b.first;
});
}
return true;
}
};
tTVPArchive * TVPOpen7ZArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName) {
tjs_uint64 pos = st->GetPosition();
bool checkZIP = st->ReadI16LE() == 0x7A37; // '7z'
st->SetPosition(pos);
if (!checkZIP) return nullptr;
SevenZipArchive *arc = new SevenZipArchive(name, st);
if (!arc->Open(normalizeFileName)) {
delete arc;
return nullptr;
}
return arc;
}
#if 0
void TVPUnpack7ZArchive(tTJSBinaryStream *st, ttstr outpath) {
tjs_uint64 origpos = st->GetPosition();
SevenZipStreamWrap szsw(st);
CSzArEx &db = szsw.db;
SRes res = SzArEx_Open(&db, &szsw.lookStream.s, &allocImp, &allocImp);
if (res != SZ_OK) return;
outpath += TJS_W("/");
for (int i = 0; i < db.db.NumFolders; ++i) {
;
}
for (int i = 0; i < db.NumFiles; i++) {
size_t offset = 0;
size_t outSizeProcessed = 0;
size_t len = SzArEx_GetFileNameUtf16(&db, i, NULL);
ttstr filename;
SzArEx_GetFileNameUtf16(&db, i, (UInt16*)filename.AllocBuffer(len));
filename.FixLen();
bool isDir = SzArEx_IsDir(&db, i);
ttstr fullpath = outpath + filename;
if (isDir) {
if (!TVPCheckExistentLocalFolder(fullpath))
TVPCreateFolders(fullpath);
} else {
tjs_uint fileIndex = i;
UInt64 fileSize = SzArEx_GetFileSize(&db, fileIndex);
if (fileSize <= 0) {
FILE *fp = fopen(fullpath.AsStdString().c_str(), "wb");
fclose(fp);
}
UInt32 folderIndex = db.FileToFolder[fileIndex];
if (folderIndex == (UInt32)-1) continue;
const CSzAr *p = &db.db;
CSzFolder folder;
CSzData sd;
const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex];
sd.Data = data;
sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex];
if (SzGetNextFolderItem(&folder, &sd) != SZ_OK) continue;
if (folder.NumCoders == 1) {
UInt64 startPos = db.dataPos;
const UInt64 *packPositions = p->PackPositions + p->FoStartPackStreamIndex[folderIndex];
UInt64 offset = packPositions[0];
UInt64 inSize = packPositions[1] - offset;
if (folder.Coders[0].MethodID == k_Copy && inSize == fileSize) {
CopyStreamToFile(st, origpos + startPos + offset, inSize, fullpath);
continue;
}
}
UInt32 blockIndex;
Byte *outBuffer = nullptr;
size_t outBufferSize;
size_t offset, outSizeProcessed;
SRes res = SzArEx_Extract(&db, &szsw.lookStream.s, fileIndex, &blockIndex, &outBuffer, &outBufferSize,
&offset, &outSizeProcessed, &allocImp, &allocImp);
tTVPMemoryStream *mem;
if (offset == 0 && fileSize <= outBufferSize) {
mem = new tTVPMemoryStream(outBuffer, outBufferSize);
} else {
Byte *buf = new Byte[fileSize];
memcpy(buf, outBuffer, fileSize);
mem = new tTVPMemoryStream(buf, fileSize);
delete outBuffer;
}
return mem;
}
}
}
#endif
================================================
FILE: src/core/base/BinaryStream.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Text read/write stream
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include "TextStream.h"
#include "MsgIntf.h"
#include "DebugIntf.h"
#include "EventIntf.h"
#include "UtilStreams.h"
#include "tjsError.h"
/*
Text stream is used by TJS's Array.saveStruct, Dictionary.saveStruct etc.
to input/output binary files.
*/
//---------------------------------------------------------------------------
tTJSBinaryStream * TVPCreateBinaryStreamForRead(const ttstr & name,
const ttstr & modestr)
{
// check o mode
tTJSBinaryStream* stream = TVPCreateStream(name, TJS_BS_READ);
const tjs_char* o_ofs = TJS_strchr(modestr.c_str(), TJS_W('o'));
if(o_ofs != NULL) {
// seek to offset
o_ofs++;
tjs_char buf[256];
int i;
for(i = 0; i < 255; i++) {
if(o_ofs[i] >= TJS_W('0') && o_ofs[i] <= TJS_W('9'))
buf[i] = o_ofs[i];
else break;
}
buf[i] = 0;
tjs_uint64 ofs = ttstr(buf).AsInteger();
stream->SetPosition(ofs);
}
return stream;
}
//---------------------------------------------------------------------------
tTJSBinaryStream * TVPCreateBinaryStreamForWrite(const ttstr & name,
const ttstr & modestr)
{
tTJSBinaryStream* stream;
// check o mode
const tjs_char * o_ofs;
o_ofs = TJS_strchr(modestr.c_str(), TJS_W('o'));
if(o_ofs != NULL) {
// seek to offset
o_ofs++;
tjs_char buf[256];
int i;
for(i = 0; i < 255; i++) {
if(o_ofs[i] >= TJS_W('0') && o_ofs[i] <= TJS_W('9'))
buf[i] = o_ofs[i];
else break;
}
buf[i] = 0;
tjs_uint64 ofs = ttstr(buf).AsInteger();
stream = TVPCreateStream(name, TJS_BS_UPDATE);
stream->SetPosition(ofs);
} else {
stream = TVPCreateStream(name, TJS_BS_WRITE);
}
return stream;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/BinaryStream.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Text read/write stream
//---------------------------------------------------------------------------
#ifndef BinaryStreamH
#define BinaryStreamH
#include "StorageIntf.h"
//---------------------------------------------------------------------------
// BinaryStream Functions
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(tTJSBinaryStream *, TVPCreateBinaryStreamForRead, (const ttstr &name, const ttstr &modestr));
TJS_EXP_FUNC_DEF(tTJSBinaryStream *, TVPCreateBinaryStreamForWrite, (const ttstr &name, const ttstr &modestr));
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/CharacterSet.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Character code conversion
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "CharacterSet.h"
#include "MsgIntf.h"
//---------------------------------------------------------------------------
static tjs_int inline TVPWideCharToUtf8(tjs_char in, char * out)
{
// convert a wide character 'in' to utf-8 character 'out'
if (in < (1<< 7))
{
if(out)
{
out[0] = (char)in;
}
return 1;
}
else if(in < (1<<11))
{
if(out)
{
out[0] = (char)(0xc0 | (in >> 6));
out[1] = (char)(0x80 | (in & 0x3f));
}
return 2;
}
else if(in < (1<<16))
{
if(out)
{
out[0] = (char)(0xe0 | (in >> 12));
out[1] = (char)(0x80 | ((in >> 6) & 0x3f));
out[2] = (char)(0x80 | (in & 0x3f));
}
return 3;
}
#if 1
else
{
TVPThrowExceptionMessage(TJS_W("Out of UTF-16 range conversion from UTF-8 code"));
}
#else
// ȉIWĩR[hǁAʂȂ͂B
else if(in < (1<<21))
{
if(out)
{
out[0] = (char)(0xf0 | (in >> 18));
out[1] = (char)(0x80 | ((in >> 12) & 0x3f));
out[2] = (char)(0x80 | ((in >> 6 ) & 0x3f));
out[3] = (char)(0x80 | (in & 0x3f));
}
return 4;
}
else if(in < (1<<26))
{
if(out)
{
out[0] = (char)(0xf8 | (in >> 24));
out[1] = (char)(0x80 | ((in >> 16) & 0x3f));
out[2] = (char)(0x80 | ((in >> 12) & 0x3f));
out[3] = (char)(0x80 | ((in >> 6 ) & 0x3f));
out[4] = (char)(0x80 | (in & 0x3f));
}
return 5;
}
else if(in < (1<<31))
{
if(out)
{
out[0] = (char)(0xfc | (in >> 30));
out[1] = (char)(0x80 | ((in >> 24) & 0x3f));
out[2] = (char)(0x80 | ((in >> 18) & 0x3f));
out[3] = (char)(0x80 | ((in >> 12) & 0x3f));
out[4] = (char)(0x80 | ((in >> 6 ) & 0x3f));
out[5] = (char)(0x80 | (in & 0x3f));
}
return 6;
}
#endif
return -1;
}
//---------------------------------------------------------------------------
tjs_int TVPWideCharToUtf8String(const tjs_char *in, char * out)
{
// convert input wide string to output utf-8 string
int count = 0;
while(*in)
{
tjs_int n;
if(out)
{
n = TVPWideCharToUtf8(*in, out);
out += n;
}
else
{
n = TVPWideCharToUtf8(*in, NULL);
/*
in this situation, the compiler's inliner
will collapse all null check parts in
TVPWideCharToUtf8.
*/
}
if(n == -1) return -1; // invalid character found
count += n;
in++;
}
return count;
}
//---------------------------------------------------------------------------
static bool inline TVPUtf8ToWideChar(const char * & in, tjs_char *out)
{
// convert a utf-8 charater from 'in' to wide charater 'out'
const unsigned char * & p = (const unsigned char * &)in;
if(p[0] < 0x80)
{
if(out) *out = (tjs_char)in[0];
in++;
return true;
}
else if(p[0] < 0xc2)
{
// invalid character
return false;
}
else if(p[0] < 0xe0)
{
// two bytes (11bits)
if((p[1] & 0xc0) != 0x80) return false;
if(out) *out = ((p[0] & 0x1f) << 6) + (p[1] & 0x3f);
in += 2;
return true;
}
else if(p[0] < 0xf0)
{
// three bytes (16bits)
if((p[1] & 0xc0) != 0x80) return false;
if((p[2] & 0xc0) != 0x80) return false;
if(out) *out = ((p[0] & 0x1f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f);
in += 3;
return true;
}
else if(p[0] < 0xf8)
{
// four bytes (21bits)
if((p[1] & 0xc0) != 0x80) return false;
if((p[2] & 0xc0) != 0x80) return false;
if((p[3] & 0xc0) != 0x80) return false;
if(out) *out = ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) +
((p[2] & 0x3f) << 6) + (p[3] & 0x3f);
in += 4;
return true;
}
else if(p[0] < 0xfc)
{
// five bytes (26bits)
if((p[1] & 0xc0) != 0x80) return false;
if((p[2] & 0xc0) != 0x80) return false;
if((p[3] & 0xc0) != 0x80) return false;
if((p[4] & 0xc0) != 0x80) return false;
if(out) *out = ((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18) +
((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6) + (p[4] & 0x3f);
in += 5;
return true;
}
else if(p[0] < 0xfe)
{
// six bytes (31bits)
if((p[1] & 0xc0) != 0x80) return false;
if((p[2] & 0xc0) != 0x80) return false;
if((p[3] & 0xc0) != 0x80) return false;
if((p[4] & 0xc0) != 0x80) return false;
if((p[5] & 0xc0) != 0x80) return false;
if(out) *out = ((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24) +
((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12) +
((p[4] & 0x3f) << 6) + (p[5] & 0x3f);
in += 6;
return true;
}
return false;
}
//---------------------------------------------------------------------------
tjs_int TVPUtf8ToWideCharString(const char * in, tjs_char *out)
{
// convert input utf-8 string to output wide string
int count = 0;
while(*in)
{
tjs_char c;
if(out)
{
if(!TVPUtf8ToWideChar(in, &c))
return -1; // invalid character found
*out++ = c;
}
else
{
if(!TVPUtf8ToWideChar(in, NULL))
return -1; // invalid character found
}
count ++;
}
return count;
}
//---------------------------------------------------------------------------
tjs_int TVPUtf8ToWideCharString(const char * in, tjs_uint length, tjs_char *out)
{
// convert input utf-8 string to output wide string
int count = 0;
const char *end = in + length;
while(*in && in < end)
{
if(in + 6 > end)
{
// fetch utf-8 character length
const unsigned char ch = *(const unsigned char *)in;
if(ch >= 0x80)
{
tjs_uint len = 0;
if(ch < 0xc2) return -1;
else if(ch < 0xe0) len = 2;
else if(ch < 0xf0) len = 3;
else if(ch < 0xf8) len = 4;
else if(ch < 0xfc) len = 5;
else if(ch < 0xfe) len = 6;
else return -1;
if(in + len > end) return -1;
}
}
tjs_char c;
if(out)
{
if(!TVPUtf8ToWideChar(in, &c))
return -1; // invalid character found
*out++ = c;
}
else
{
if(!TVPUtf8ToWideChar(in, NULL))
return -1; // invalid character found
}
count ++;
}
return count;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/CharacterSet.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Character code conversion
//---------------------------------------------------------------------------
#ifndef __CharacterSet_H__
#define __CharacterSet_H__
// various character conding conversion.
// currently only utf-8 related functions are implemented.
#include "tjsTypes.h"
TJS_EXP_FUNC_DEF(tjs_int, TVPWideCharToUtf8String, (const tjs_char *in, char * out));
TJS_EXP_FUNC_DEF(tjs_int, TVPUtf8ToWideCharString, (const char * in, tjs_char *out));
extern tjs_int TVPUtf8ToWideCharString(const char * in, tjs_uint length, tjs_char *out);
#endif
================================================
FILE: src/core/base/EventIntf.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Script/Window Event Handling and Dispatching / System Idle Event Delivering
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include "SysInitIntf.h"
#include "EventIntf.h"
#include "WindowIntf.h"
#include "tjsDictionary.h"
#include "MsgIntf.h"
#include "ScriptMgnIntf.h"
#include "TickCount.h"
#include "SystemImpl.h"
//---------------------------------------------------------------------------
// tTVPEvent : script event class
//---------------------------------------------------------------------------
extern tjs_uint64 TVPEventSequenceNumber;
class tTVPEvent
{
iTJSDispatch2 *Target;
iTJSDispatch2 *Source;
ttstr EventName;
tjs_uint32 Tag;
tjs_uint NumArgs;
tTJSVariant *Args;
tjs_uint32 Flags;
tjs_uint64 Sequence;
public:
tTVPEvent(iTJSDispatch2 *target, iTJSDispatch2 *source,
ttstr &eventname, tjs_uint32 tag, tjs_uint numargs, tTJSVariant *args,
tjs_uint32 flags)
{
// constructor
// eventname is not a const object but this object only touch to
// eventname.GetHint()
Args = NULL;
Target = NULL;
Source = NULL;
Sequence = TVPEventSequenceNumber;
EventName = eventname;
NumArgs = numargs;
Args = new tTJSVariant[NumArgs];
for(tjs_uint i=0; iAddRef();
if(Source) Source->AddRef();
}
tTVPEvent(const tTVPEvent &ref)
{
// copy constructor
Args = NULL;
Target = NULL;
Source = NULL;
EventName = ref.EventName;
NumArgs = ref.NumArgs;
Args = new tTJSVariant[NumArgs];
for(tjs_uint i=0; iAddRef();
if(Source) Source->AddRef();
}
~tTVPEvent()
{
if(Args) delete [] Args;
if(Target) Target->Release();
if(Source) Source->Release();
}
void Deliver()
{
if(!TJSIsObjectValid(Target->IsValid(0, NULL, NULL, Target)))
return; // The target had been invalidated
tTJSVariant **ArgsPtr = new tTJSVariant*[NumArgs];
for(tjs_uint i=0; iFuncCall(0, EventName.c_str(), EventName.GetHint(),
NULL, NumArgs, ArgsPtr,
Target);
}
catch(...)
{
delete [] ArgsPtr;
throw;
}
delete [] ArgsPtr;
}
iTJSDispatch2 * GetTargetNoAddRef() const { return Target; }
iTJSDispatch2 * GetSourceNoAddRef() const { return Source; }
ttstr & GetEventName() { return EventName; }
tjs_uint32 GetTag() const { return Tag; }
tjs_uint32 GetFlags() const { return Flags; }
tjs_uint64 GetSequence() const;
};
//---------------------------------------------------------------------------
tjs_uint64 tTVPEvent::GetSequence() const { return Sequence; }
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPWinUpdateEvent : window update event class
//---------------------------------------------------------------------------
class tTVPWinUpdateEvent
{
tTJSNI_BaseWindow *Window;
public:
tTVPWinUpdateEvent(tTJSNI_BaseWindow *window)
{
Window = window;
}
tTVPWinUpdateEvent(const tTVPWinUpdateEvent & ref)
{
Window = ref.Window;
}
~tTVPWinUpdateEvent()
{
}
void Deliver() const
{
if (static_cast(Window)->GetVisible())
Window->UpdateContent();
}
tTJSNI_BaseWindow * GetWindow() const { return Window; }
void MarkEmpty() { Window = NULL; }
bool IsEmpty() const { return Window == NULL; }
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// global/static definitions
//---------------------------------------------------------------------------
// event queue must be a globally sequential queue
std::vector TVPInputEventQueue;
std::vector TVPEventQueue;
std::vector TVPWinUpdateEventQueue;
bool TVPExclusiveEventPosted = false; // true if exclusive event is posted
tjs_uint64 TVPEventSequenceNumber = 0; // event sequence number
tjs_uint64 TVPEventSequenceNumberToProcess = 0;
// current event sequence which must be processed
static void TVPDestroyEventQueue()
{
// delete all event objects
// deletion of event object may cause other deletion of event objects.
{
std::vector::iterator i;
while(TVPEventQueue.size())
{
i = TVPEventQueue.end() -1;
tTVPEvent * ev = *i;
TVPEventQueue.erase(i);
delete ev;
}
}
//--
{
std::vector::iterator i;
while(TVPInputEventQueue.size())
{
i = TVPInputEventQueue.end() - 1;
tTVPBaseInputEvent * ev = *i;
TVPInputEventQueue.erase(i);
delete ev;
}
}
}
static tTVPAtExit TVPDestroyEventQueueAtExit
(TVP_ATEXIT_PRI_PREPARE, TVPDestroyEventQueue);
bool TVPEventDisabled = false;
bool TVPEventInterrupting = false;
//#define TVP_EVENT_TASK_RETURN_TICK 100000
/* TVP event system once returns to Operation system when
TVP_EVENT_TASK_RETURN_TICK is elapsed during event delivering. */
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPPostEvent
//---------------------------------------------------------------------------
void TVPPostEvent(iTJSDispatch2 * source, iTJSDispatch2 *target,
ttstr &eventname, tjs_uint32 tag, tjs_uint32 flag,
tjs_uint numargs, tTJSVariant *args)
{
bool evdisabled = TVPEventDisabled || TVPGetSystemEventDisabledState();
if((flag & TVP_EPT_DISCARDABLE) &&
(TVPEventInterrupting || evdisabled)) return;
tjs_int method = flag & TVP_EPT_METHOD_MASK;
if(method == TVP_EPT_IMMEDIATE)
{
// the event is delivered immediately
if(evdisabled) return;
try
{
try
{
tTVPEvent(target, source, eventname, tag, numargs, args, flag).
Deliver();
}
TJS_CONVERT_TO_TJS_EXCEPTION
}
TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(TJS_W("immediate event"));
return;
}
if(method == TVP_EPT_REMOVE_POST)
{
// events in queue that have same target/source/name/tag are to be removed
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if(source == (*i)->GetSourceNoAddRef() &&
target == (*i)->GetTargetNoAddRef() &&
eventname == (*i)->GetEventName() &&
((tag==0)?true:(tag==(*i)->GetTag())) )
{
tTVPEvent *ev = *i;
TVPEventQueue.erase(i);
i = TVPEventQueue.begin();
delete ev;
}
else
{
i++;
}
}
}
// put into queue
TVPEventQueue.push_back(new tTVPEvent(target, source, eventname, tag,
numargs, args, flag));
// is exclusive?
if((flag & TVP_EPT_PRIO_MASK) == TVP_EPT_EXCLUSIVE) TVPExclusiveEventPosted = true;
// make sure that the event is to be delivered.
TVPInvokeEvents();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCancelEvents
//---------------------------------------------------------------------------
tjs_int TVPCancelEvents(iTJSDispatch2 * source, iTJSDispatch2 *target,
const ttstr &eventname, tjs_uint32 tag)
{
tjs_int count = 0;
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if(source == (*i)->GetSourceNoAddRef() &&
target == (*i)->GetTargetNoAddRef() &&
eventname == (*i)->GetEventName() &&
((tag==0)?true:(tag==(*i)->GetTag())) )
{
tTVPEvent *ev = *i;
TVPEventQueue.erase(i);
i = TVPEventQueue.begin();
delete ev;
count ++;
}
else
{
i++;
}
}
return count;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPAreEventsInQueue
//---------------------------------------------------------------------------
bool TVPAreEventsInQueue(iTJSDispatch2 * source, iTJSDispatch2 *target,
const ttstr &eventname, tjs_uint32 tag)
{
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if(source == (*i)->GetSourceNoAddRef() &&
target == (*i)->GetTargetNoAddRef() &&
eventname == (*i)->GetEventName() &&
((tag==0)?true:(tag==(*i)->GetTag())) )
return true;
i++;
}
return false;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCountEventsInQueue
//---------------------------------------------------------------------------
tjs_int TVPCountEventsInQueue(iTJSDispatch2 * source, iTJSDispatch2 *target,
const ttstr &eventname, tjs_uint32 tag)
{
tjs_int count = 0;
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if(source == (*i)->GetSourceNoAddRef() &&
target == (*i)->GetTargetNoAddRef() &&
eventname == (*i)->GetEventName() &&
((tag==0)?true:(tag==(*i)->GetTag())) )
count ++;
i++;
}
return count;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCancelEventByTag
//---------------------------------------------------------------------------
void TVPCancelEventsByTag(iTJSDispatch2 * source, iTJSDispatch2 *target,
tjs_uint32 tag)
{
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if(source == (*i)->GetSourceNoAddRef() &&
target == (*i)->GetTargetNoAddRef() &&
((tag==0)?true:(tag==(*i)->GetTag())) )
{
tTVPEvent *ev = *i;
TVPEventQueue.erase(i);
i = TVPEventQueue.begin();
delete ev;
}
else
{
i++;
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCancelSourceEvent
//---------------------------------------------------------------------------
void TVPCancelSourceEvents(iTJSDispatch2 * source)
{
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if(source == (*i)->GetSourceNoAddRef())
{
tTVPEvent *ev = *i;
TVPEventQueue.erase(i);
i = TVPEventQueue.begin();
delete ev;
}
else
{
i++;
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPDiscardAllDiscardableEvents
//---------------------------------------------------------------------------
void TVPDiscardAllDiscardableEvents()
{
std::vector::iterator i;
i = TVPEventQueue.begin();
while(/*TVPEventQueue.size() &&*/ i != TVPEventQueue.end())
{
if((*i)->GetFlags() & TVP_EPT_DISCARDABLE)
{
tTVPEvent *ev = *i;
TVPEventQueue.erase(i);
i = TVPEventQueue.begin();
delete ev;
}
else
{
i++;
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPDeliverAllEvents
//---------------------------------------------------------------------------
static void _TVPDeliverEventByPrio(tjs_uint prio)
{
while(true)
{
tTVPEvent *e;
// retrieve item to deliver
if(TVPEventQueue.size() == 0) break;
std::vector::iterator i =
TVPEventQueue.begin();
while(i != TVPEventQueue.end())
{
if((*i)->GetSequence() <= TVPEventSequenceNumberToProcess &&
(((*i)->GetFlags() & TVP_EPT_PRIO_MASK) == prio)) break;
i++;
}
if(i == TVPEventQueue.end()) break;
e = *i;
TVPEventQueue.erase(i);
// event delivering
try
{
e->Deliver();
}
catch(...)
{
delete e;
throw;
}
delete e;
}
}
static bool _TVPDeliverAllEvents2()
{
TVPExclusiveEventPosted = false;
// process exclusive events
_TVPDeliverEventByPrio(TVP_EPT_EXCLUSIVE);
// check exclusive events
if(TVPExclusiveEventPosted) return true;
// process input event queue
while(true)
{
tTVPBaseInputEvent *e;
// retrieve item to deliver
if(TVPInputEventQueue.size() == 0) break;
std::vector::iterator i =
TVPInputEventQueue.begin();
e = *i;
TVPInputEventQueue.erase(i);
// event delivering
try
{
e->Deliver();
}
catch(...)
{
delete e;
throw;
}
delete e;
// check exclusive events
if(TVPExclusiveEventPosted) return true;
}
// process normal event queue
_TVPDeliverEventByPrio(TVP_EPT_NORMAL);
// check exclusive events
if(TVPExclusiveEventPosted) return true;
return true;
}
//---------------------------------------------------------------------------
static bool _TVPDeliverAllEvents()
{
// deliver all pending events to targets.
if(TVPEventDisabled) return true;
// event invokation was received...
TVPEventReceived();
// for script event objects
bool ret_value;
ret_value = _TVPDeliverAllEvents2();
return ret_value;
}
//---------------------------------------------------------------------------
void TVPDeliverAllEvents()
{
bool r;
if(!TVPEventInterrupting)
{
TVPEventSequenceNumberToProcess = TVPEventSequenceNumber;
TVPEventSequenceNumber ++; // increment sequence number
}
TVPEventInterrupting = false;
try
{
try
{
r = _TVPDeliverAllEvents();
}
TJS_CONVERT_TO_TJS_EXCEPTION
}
TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(TJS_W("event"));
if(!r)
{
// event processing is to be interrupted
// XXX: currently this is not functional
TVPEventInterrupting = true;
TVPCallDeliverAllEventsOnIdle();
}
if(!TVPExclusiveEventPosted && !TVPEventInterrupting)
{
try
{
try
{
// process idle event queue
_TVPDeliverEventByPrio(TVP_EPT_IDLE);
}
TJS_CONVERT_TO_TJS_EXCEPTION
}
TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(TJS_W("idle event"));
// process continuous events
if(TVPProcessContinuousHandlerEventFlag)
{
TVPProcessContinuousHandlerEventFlag = false; // processed
// XXX: strictly saying, we need something like InterlockedExchange
// to look/set this flag, because TVPProcessContinuousHandlerEventFlag
// may be accessed by another thread. But I have no dought about
// that no one does care of missing one event in rare race condition.
TVPDeliverContinuousEvent();
}
try
{
try
{
// for window content updating
TVPDeliverWindowUpdateEvents();
}
TJS_CONVERT_TO_TJS_EXCEPTION
}
TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(TJS_W("window update"));
} else {
}
if(TVPEventQueue.size() == 0)
{
TVPEventSequenceNumber = 0; // reset the number
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPPostWindowUpdate
//---------------------------------------------------------------------------
bool TVPWindowUpdateEventsDelivering = false;
void TVPPostWindowUpdate(tTJSNI_BaseWindow *window)
{
if(!TVPWindowUpdateEventsDelivering)
{
if(TVPWinUpdateEventQueue.size())
{
// since duplication is not allowed ...
std::vector::const_iterator i;
for(i = TVPWinUpdateEventQueue.begin();
i !=TVPWinUpdateEventQueue.end(); i++)
{
if(!i->IsEmpty() && window == i->GetWindow()) return;
}
}
}
else
{
if(TVPWinUpdateEventQueue.size())
{
// duplication is allowed up to two
tjs_int count = 0;
std::vector::const_iterator i;
for(i = TVPWinUpdateEventQueue.begin();
i !=TVPWinUpdateEventQueue.end(); i++)
{
if(!i->IsEmpty() && window == i->GetWindow())
{
count++;
if(count == 2) return;
}
}
}
}
// put into queue.
TVPWinUpdateEventQueue.emplace_back(window);
// make sure that the event is to be delivered.
TVPInvokeEvents();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPRemoveWindowUpdate
//---------------------------------------------------------------------------
void TVPRemoveWindowUpdate(tTJSNI_BaseWindow *window)
{
// removes all window update events from queue.
if(TVPWinUpdateEventQueue.size())
{
std::vector::iterator i;
for(i = TVPWinUpdateEventQueue.begin();
i !=TVPWinUpdateEventQueue.end(); i++)
{
if(!i->IsEmpty() && window == i->GetWindow())
i->MarkEmpty();
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPDeliverWindowUpdateEvents
//---------------------------------------------------------------------------
void TVPDeliverWindowUpdateEvents()
{
if(TVPWindowUpdateEventsDelivering) return; // does not allow re-entering
TVPWindowUpdateEventsDelivering = true;
try
{
for(tjs_uint i = 0; i < TVPWinUpdateEventQueue.size(); i++)
{
if(!TVPWinUpdateEventQueue[i].IsEmpty())
TVPWinUpdateEventQueue[i].Deliver();
}
}
catch(...)
{
TVPWinUpdateEventQueue.clear();
TVPWindowUpdateEventsDelivering = false;
throw;
}
TVPWinUpdateEventQueue.clear();
TVPWindowUpdateEventsDelivering = false;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Input Event related
//---------------------------------------------------------------------------
tjs_int TVPInputEventTagMax = 0;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPPostInputEvent
//---------------------------------------------------------------------------
void TVPPostInputEvent(tTVPBaseInputEvent *ev, tjs_uint32 flags)
{
// flag check
if((flags & TVP_EPT_DISCARDABLE) &&
(TVPEventDisabled || TVPGetSystemEventDisabledState()))
{
delete ev;
return;
}
if(flags & TVP_EPT_REMOVE_POST)
{
// cancel previously posted events
TVPCancelInputEvents(ev->GetSource(), ev->GetTag());
}
// push into the event queue
TVPInputEventQueue.push_back(ev);
// make sure that the event is to be delivered.
TVPInvokeEvents();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCancelInputEvents
//---------------------------------------------------------------------------
void TVPCancelInputEvents(void * source)
{
// removes all evens which have the same source
if(TVPInputEventQueue.size())
{
std::vector::iterator i;
for(i = TVPInputEventQueue.begin();
i !=TVPInputEventQueue.end();)
{
if(source == (*i)->GetSource())
{
tTVPBaseInputEvent *ev = *i;
i = TVPInputEventQueue.erase(i);
delete ev;
}
else
{
i++;
}
}
}
}
//---------------------------------------------------------------------------
void TVPCancelInputEvents(void * source, tjs_int tag)
{
// removes all evens which have the same source and the same tag
if(TVPInputEventQueue.size())
{
std::vector::iterator i;
for(i = TVPInputEventQueue.begin();
i !=TVPInputEventQueue.end();)
{
if(source == (*i)->GetSource() && tag == (*i)->GetTag())
{
tTVPBaseInputEvent *ev = *i;
i = TVPInputEventQueue.erase(i);
delete ev;
}
else
{
i++;
}
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetInputEventCount
//---------------------------------------------------------------------------
tjs_int TVPGetInputEventCount()
{
return (tjs_int)TVPInputEventQueue.size();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCreateEventObject
//---------------------------------------------------------------------------
iTJSDispatch2 * TVPCreateEventObject(const tjs_char *type,
iTJSDispatch2 *targthis, iTJSDispatch2 *targ)
{
// create a dictionary object for event dispatching ( to "action" method )
iTJSDispatch2 * object = TJSCreateDictionaryObject();
static ttstr type_name(TJS_W("type"));
static ttstr target_name(TJS_W("target"));
{
tTJSVariant val(type);
if(TJS_FAILED(object->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP,
type_name.c_str(), type_name.GetHint(), &val, object)))
TVPThrowInternalError;
}
{
tTJSVariant val(targthis, targ);
if(TJS_FAILED(object->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP,
target_name.c_str(), target_name.GetHint(), &val, object)))
TVPThrowInternalError;
}
return object;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
ttstr TVPActionName(TJS_W("action"));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Continuous Event Delivering related
//---------------------------------------------------------------------------
bool TVPProcessContinuousHandlerEventFlag = false;
static std::vector TVPContinuousEventVector;
static std::vector TVPContinuousHandlerVector;
static bool TVPContinuousEventProcessing = false;
static void TVPDestroyContinuousHandlerVector()
{
std::vector::iterator i;
for(i = TVPContinuousHandlerVector.begin();
i != TVPContinuousHandlerVector.end();
i++)
{
i->Release();
}
TVPContinuousHandlerVector.clear();
}
static tTVPAtExit TVPDestroyContinuousHandlerVectorAtExit
(TVP_ATEXIT_PRI_PREPARE, TVPDestroyContinuousHandlerVector);
//---------------------------------------------------------------------------
void TVPAddContinuousEventHook(tTVPContinuousEventCallbackIntf *cb)
{
TVPBeginContinuousEvent();
TVPContinuousEventVector.push_back(cb);
}
//---------------------------------------------------------------------------
void TVPRemoveContinuousEventHook(tTVPContinuousEventCallbackIntf *cb)
{
std::vector::iterator i;
for(i = TVPContinuousEventVector.begin();
i !=TVPContinuousEventVector.end();)
{
if(cb == *i) *i = NULL; // simply assign a null
i++;
}
}
//---------------------------------------------------------------------------
static void _TVPDeliverContinuousEvent() // internal
{
TVPStartTickCount();
tjs_uint64 tick = TVPGetTickCount();
if(TVPContinuousEventVector.size())
{
bool emptyflag = false;
for(tjs_uint32 i = 0; i < TVPContinuousEventVector.size(); i++)
{
// note that the handler can remove itself while the event
if(TVPContinuousEventVector[i])
TVPContinuousEventVector[i]->OnContinuousCallback(tick);
else
emptyflag = true;
if(TVPExclusiveEventPosted) return; // check exclusive events
}
if(emptyflag)
{
// the array has empty cell
// eliminate empty
std::vector::iterator i;
for(i = TVPContinuousEventVector.begin();
i !=TVPContinuousEventVector.end();)
{
if(*i == NULL)
i = TVPContinuousEventVector.erase(i);
else
i++;
}
}
}
if(!TVPEventDisabled && TVPContinuousHandlerVector.size())
{
bool emptyflag = false;
tTJSVariant vtick((tjs_int64)tick);
tTJSVariant *pvtick = &vtick;
for(tjs_uint i = 0; i < TVPContinuousHandlerVector.size(); i++)
{
if(TVPContinuousHandlerVector[i].Object)
{
tjs_error er;
try
{
er =
TVPContinuousHandlerVector[i].FuncCall(0, NULL, NULL, NULL, 1, &pvtick, NULL);
}
catch(...)
{
// failed
TVPContinuousHandlerVector[i].Release();
TVPContinuousHandlerVector[i].Object =
TVPContinuousHandlerVector[i].ObjThis = NULL;
throw;
}
if(TJS_FAILED(er))
{
// failed
TVPContinuousHandlerVector[i].Release();
TVPContinuousHandlerVector[i].Object =
TVPContinuousHandlerVector[i].ObjThis = NULL;
emptyflag = true;
}
if(TVPExclusiveEventPosted) return; // check exclusive events
}
else
{
emptyflag = true;
}
}
if(emptyflag)
{
// the array has empty cell
// eliminate empty
std::vector::iterator i;
for(i = TVPContinuousHandlerVector.begin();
i !=TVPContinuousHandlerVector.end();)
{
if(!i->Object)
{
i->Release();
i = TVPContinuousHandlerVector.erase(i);
}
else
{
i++;
}
}
}
}
if(!TVPContinuousEventVector.size() && !TVPContinuousHandlerVector.size())
TVPEndContinuousEvent();
}
//---------------------------------------------------------------------------
void TVPDeliverContinuousEvent()
{
if(TVPContinuousEventProcessing) return;
TVPContinuousEventProcessing = true;
try
{
try
{
try
{
_TVPDeliverContinuousEvent();
}
catch(...)
{
TVPContinuousEventProcessing = false;
throw;
}
}
TJS_CONVERT_TO_TJS_EXCEPTION
}
TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(TJS_W("continuous event"));
TVPContinuousEventProcessing = false;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void TVPAddContinuousHandler(tTJSVariantClosure clo)
{
std::vector::iterator i;
i = std::find(TVPContinuousHandlerVector.begin(),
TVPContinuousHandlerVector.end(), clo);
if(i == TVPContinuousHandlerVector.end())
{
TVPBeginContinuousEvent();
clo.AddRef();
TVPContinuousHandlerVector.emplace_back(clo);
}
}
//---------------------------------------------------------------------------
void TVPRemoveContinuousHandler(tTJSVariantClosure clo)
{
std::vector::iterator i;
i = std::find(TVPContinuousHandlerVector.begin(),
TVPContinuousHandlerVector.end(), clo);
if(i != TVPContinuousHandlerVector.end())
{
i->Release();
i->Object = i->ObjThis = NULL;
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// "Compact" Event Delivering related
//---------------------------------------------------------------------------
// Compact events are to be delivered when:
// 1. the application is in idle state for long duration
// 2. the application had been deactivated ( application has lost the focus )
// 3. the application had been minimized
// these are to reduce memory usage, like garbage collection, cache cleaning,
// or etc ...
//---------------------------------------------------------------------------
static std::vector TVPCompactEventVector;
bool TVPEnableGlobalHeapCompaction = false;
//---------------------------------------------------------------------------
void TVPAddCompactEventHook(tTVPCompactEventCallbackIntf *cb)
{
TVPCompactEventVector.push_back(cb);
}
//---------------------------------------------------------------------------
void TVPRemoveCompactEventHook(tTVPCompactEventCallbackIntf *cb)
{
std::vector::iterator i;
for(i = TVPCompactEventVector.begin();
i !=TVPCompactEventVector.end();)
{
if(cb == *i) *i = NULL; // simply assign a null
i++;
}
}
//---------------------------------------------------------------------------
extern void TVPDoSaveSystemVariables();
void TVPDeliverCompactEvent(tjs_int level)
{
// must be called by each platforms's implementation
//std::vector::iterator i;
if(TVPCompactEventVector.size())
{
bool emptyflag = false;
for(tjs_uint i = 0; i < TVPCompactEventVector.size(); i ++)
{
// note that the handler can remove itself while the event
try
{
try
{
if(TVPCompactEventVector[i])
TVPCompactEventVector[i]->OnCompact(level); else emptyflag = true;
}
TJS_CONVERT_TO_TJS_EXCEPTION
}
TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION_FORCE_SHOW_EXCEPTION(TJS_W("Compact Event"));
}
if(emptyflag)
{
// the array has empty cell
// eliminate empty
std::vector::iterator i;
for(i = TVPCompactEventVector.begin();
i !=TVPCompactEventVector.end();)
{
if(*i == NULL)
i = TVPCompactEventVector.erase(i);
else
i++;
}
}
}
TVPDoSaveSystemVariables();
#if 0
if( level >= TVP_COMPACT_LEVEL_MAX && TVPEnableGlobalHeapCompaction )
{ // Do compact CRT and Global Heap
HANDLE hHeap = ::GetProcessHeap();
if( hHeap ) {
::HeapCompact( hHeap, 0 );
}
HANDLE hCrtHeap = (HANDLE)_get_heap_handle();
if( hCrtHeap && hCrtHeap != hHeap ) {
::HeapCompact( hCrtHeap, 0 );
}
}
#endif
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// AsyncTrigger related
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNI_AsyncTrigger
//---------------------------------------------------------------------------
tTJSNI_AsyncTrigger::tTJSNI_AsyncTrigger()
{
Owner = NULL;
Cached = true;
IdlePendingCount = 0;
Mode = atmNormal;
ActionOwner.Object = ActionOwner.ObjThis = NULL;
ActionName = TVPActionName;
}
//---------------------------------------------------------------------------
tjs_error TJS_INTF_METHOD
tTJSNI_AsyncTrigger::Construct(tjs_int numparams, tTJSVariant **param,
iTJSDispatch2 *tjs_obj)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
tjs_error hr = inherited::Construct(numparams, param, tjs_obj);
if(TJS_FAILED(hr)) return hr;
if(numparams >= 2 && param[1]->Type() != tvtVoid)
ActionName = *param[1]; // action function to be called
ActionOwner = param[0]->AsObjectClosure();
Owner = tjs_obj;
return TJS_S_OK;
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTJSNI_AsyncTrigger::Invalidate()
{
TVPCancelSourceEvents(Owner);
Owner = NULL;
ActionOwner.Release();
ActionOwner.ObjThis = ActionOwner.Object = NULL;
inherited::Invalidate();
}
//---------------------------------------------------------------------------
void tTJSNI_AsyncTrigger::Trigger()
{
// trigger event
if(Owner)
{
if(Cached)
{
// remove undelivered events from queue when "Cached" flag is set
TVPCancelSourceEvents(Owner);
}
static ttstr eventname(TJS_W("onFire"));
tjs_uint32 flags = TVP_EPT_POST;
if(Mode == atmExclusive) flags |= TVP_EPT_EXCLUSIVE; // fire exclusive event
if(Mode == atmAtIdle) flags |= TVP_EPT_IDLE; // fire idle event
TVPPostEvent(Owner, Owner, eventname, 0, flags, 0, NULL);
}
}
//---------------------------------------------------------------------------
void tTJSNI_AsyncTrigger::Cancel()
{
// cancel event
if(Owner) TVPCancelSourceEvents(Owner);
IdlePendingCount = 0;
}
//---------------------------------------------------------------------------
void tTJSNI_AsyncTrigger::SetCached(bool b)
{
// set cached operation flag.
// when this flag is set, only one event is delivered at once.
if(Cached != b)
{
Cached = b;
Cancel(); // all events are canceled
}
}
//---------------------------------------------------------------------------
void tTJSNI_AsyncTrigger::SetMode(tTVPAsyncTriggerMode m)
{
if(Mode != m)
{
Mode = m;
Cancel();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNC_AsyncTrigger
//---------------------------------------------------------------------------
tjs_uint32 tTJSNC_AsyncTrigger::ClassID = -1;
tTJSNC_AsyncTrigger::tTJSNC_AsyncTrigger() : inherited(TJS_W("AsyncTrigger"))
{
// registration of native members
TJS_BEGIN_NATIVE_MEMBERS(AsyncTrigger) // constructor
TJS_DECL_EMPTY_FINALIZE_METHOD
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_CONSTRUCTOR_DECL(/*var.name*/_this, /*var.type*/tTJSNI_AsyncTrigger,
/*TJS class name*/AsyncTrigger)
{
return TJS_S_OK;
}
TJS_END_NATIVE_CONSTRUCTOR_DECL(/*TJS class name*/AsyncTrigger)
//----------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/trigger)
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this, /*var. type*/tTJSNI_AsyncTrigger);
_this->Trigger();
return TJS_S_OK;
}
TJS_END_NATIVE_METHOD_DECL(/*func. name*/trigger)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/cancel)
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this, /*var. type*/tTJSNI_AsyncTrigger);
_this->Cancel();
return TJS_S_OK;
}
TJS_END_NATIVE_METHOD_DECL(/*func. name*/cancel)
//----------------------------------------------------------------------
//-- events
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/onFire)
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this,
/*var. type*/tTJSNI_AsyncTrigger);
tTJSVariantClosure obj = _this->GetActionOwnerNoAddRef();
if(obj.Object)
{
ttstr & actionname = _this->GetActionName();
TVP_ACTION_INVOKE_BEGIN(0, "onFire", objthis);
TVP_ACTION_INVOKE_END_NAME(obj,
actionname.IsEmpty() ? NULL :actionname.c_str(),
actionname.IsEmpty() ? NULL :actionname.GetHint());
}
return TJS_S_OK;
}
TJS_END_NATIVE_METHOD_DECL(/*func. name*/onFire)
//----------------------------------------------------------------------
//--properties
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(cached)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this, /*var. type*/tTJSNI_AsyncTrigger);
*result = _this->GetCached();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this, /*var. type*/tTJSNI_AsyncTrigger);
_this->SetCached(*param);
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_PROP_DECL(cached)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(mode)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this, /*var. type*/tTJSNI_AsyncTrigger);
*result = (tjs_int)_this->GetMode();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TJS_GET_NATIVE_INSTANCE(/*var. name*/_this, /*var. type*/tTJSNI_AsyncTrigger);
_this->SetMode((tTVPAsyncTriggerMode)(tjs_int)*param);
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_PROP_DECL(mode)
//----------------------------------------------------------------------
TJS_END_NATIVE_MEMBERS
}
//---------------------------------------------------------------------------
tTJSNativeInstance *tTJSNC_AsyncTrigger::CreateNativeInstance()
{
return new tTJSNI_AsyncTrigger();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
tTJSNativeClass * TVPCreateNativeClass_AsyncTrigger()
{
return new tTJSNC_AsyncTrigger();
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/EventIntf.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Script Event/Window Handling and Dispatching / System Idle Event Delivering
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef EventIntfH
#define EventIntfH
#include "tjsNative.h"
//---------------------------------------------------------------------------
// Event dispatching
//---------------------------------------------------------------------------
extern void TVPDeliverAllEvents(); // called from (indirectly) the OS
extern bool TVPEventDisabled; // do not write to this variable directly
extern void TVPInvokeEvents();
// implement this in each platform,
// to ensure calling "TVPDeliverAllEvents" when the Application is
// ready to deliver the events.
extern void TVPEventReceived();
// implement this in each platform.
// notifies that events are delivered and ensure being ready for next event.
extern void TVPCallDeliverAllEventsOnIdle();
// implement this in each platform.
// once return control to OS, and set to call TVPInvokeEvents() after it.
//---------------------------------------------------------------------------
// somewhat public
TJS_EXP_FUNC_DEF(void, TVPBreathe, ());
// implement this in each platform
// to handle OS's message events
// this should be called when in a long time processing, something like a
// network access, to reply to user's Windowing message, repainting, etc...
// in TVPBreathe, TVP events must not be invoked. ( happened events over the
// long time processing are pending until next timing of message delivering. )
TJS_EXP_FUNC_DEF(bool, TVPGetBreathing, ()); // return whether now is in event breathing
TJS_EXP_FUNC_DEF(void, TVPSetSystemEventDisabledState, (bool en));
/*
sets whether system overall event handling is enabled.
this works distinctly from TVPEventDisabled.
*/
TJS_EXP_FUNC_DEF(bool, TVPGetSystemEventDisabledState, ());
//---------------------------------------------------------------------------
/*[*/
//---------------------------------------------------------------------------
// Script Event Related
//---------------------------------------------------------------------------
#define TVP_EPT_POST 0x00 // normal post, simply add to queue
#define TVP_EPT_REMOVE_POST 0x01
// remove event in pending queue that has same target, source, tag and
// name before post
// (for input events, only the source and the tag are to be checked)
#define TVP_EPT_IMMEDIATE 0x02
// the event will be delivered immediately
#define TVP_EPT_DISCARDABLE 0x10
// the event can be discarded when event system is disabled
#define TVP_EPT_NORMAL 0x00
// (with TVP_EPT_POST only)
// the event will have normal priority.
#define TVP_EPT_EXCLUSIVE 0x20
// (with TVP_EPT_POST only)
// the event is given priority and other posted events are not processed
// until the exclusive event is processed.
#define TVP_EPT_IDLE 0x40
// (with TVP_EPT_POST only)
// the event is only delivered after the system processes all other events.
// this will have a priority roughly identical to "continuous" events.
#define TVP_EPT_PRIO_MASK 0xe0
#define TVP_EPT_METHOD_MASK 0x0f
/*]*/
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(void, TVPPostEvent, (iTJSDispatch2 * source, iTJSDispatch2 *target,
ttstr &eventname, tjs_uint32 tag, tjs_uint32 flag,
tjs_uint numargs, tTJSVariant *args));
// posts TVP event. this function itself is thread-safe.
TJS_EXP_FUNC_DEF(tjs_int, TVPCancelEvents, (iTJSDispatch2 * source, iTJSDispatch2 *target,
const ttstr &eventname, tjs_uint32 tag = 0));
// removes events that has specified source/target/name/tag.
// tag == 0 removes all tag from queue.
// returns count of removed events.
TJS_EXP_FUNC_DEF(bool, TVPAreEventsInQueue, (iTJSDispatch2 * source, iTJSDispatch2 *target,
const ttstr &eventname, tjs_uint32 tag));
// returns whether the events are in queue that have specified
// source/target/name/tag.
// tag == 0 matches all tag in queue.
TJS_EXP_FUNC_DEF(tjs_int, TVPCountEventsInQueue, (iTJSDispatch2 * source, iTJSDispatch2 *target,
const ttstr &eventname, tjs_uint32 tag));
// returns count of the events in queue that have specified
// source/target/name/tag.
// tag == 0 matches all tag in queue.
TJS_EXP_FUNC_DEF(void, TVPCancelEventsByTag, (iTJSDispatch2 * source, iTJSDispatch2 *target,
tjs_uint32 tag = 0));
// removes all events which have the same source/target/tag.
// tag == 0 removes all tag from queue.
TJS_EXP_FUNC_DEF(void, TVPCancelSourceEvents, (iTJSDispatch2 * source));
// removes all events that has specified source.
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Window update event related
//---------------------------------------------------------------------------
class tTJSNI_BaseWindow;
extern void TVPPostWindowUpdate(tTJSNI_BaseWindow *window);
extern void TVPRemoveWindowUpdate(tTJSNI_BaseWindow *window);
extern void TVPDeliverWindowUpdateEvents();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// User input event related
//---------------------------------------------------------------------------
class tTVPBaseInputEvent // base user input event class
{
void * Source;
tjs_int Tag;
public:
tTVPBaseInputEvent(void *source, tjs_int tag) { Source = source; Tag = tag; }
virtual ~tTVPBaseInputEvent() {};
virtual void Deliver() const = 0;
void * GetSource() const { return Source; }
tjs_int GetTag() const { return Tag; }
};
//---------------------------------------------------------------------------
extern tjs_int TVPInputEventTagMax;
class tTVPUniqueTagForInputEvent // a class for getting unique tag per a event class
{
public:
tjs_int Tag;
tTVPUniqueTagForInputEvent() : Tag(++TVPInputEventTagMax) {;}
operator tjs_int() const { return Tag; }
};
//---------------------------------------------------------------------------
extern void TVPPostInputEvent(tTVPBaseInputEvent *ev, tjs_uint32 flags = 0);
extern void TVPCancelInputEvents(void * source);
extern void TVPCancelInputEvents(void * source, tjs_int tag);
extern tjs_int TVPGetInputEventCount();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCreateEventObject
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(iTJSDispatch2 *, TVPCreateEventObject, (const tjs_char *type,
iTJSDispatch2 *targthis, iTJSDispatch2 *targ));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// some macros for driving "action" method
//---------------------------------------------------------------------------
extern ttstr TVPActionName;
#define TVP_ACTION_INVOKE_BEGIN(argnum, name, object) \
{ \
if(numparams < (argnum)) return TJS_E_BADPARAMCOUNT; \
tjs_int arg_count = 0; \
iTJSDispatch2 *evobj = TVPCreateEventObject(TJS_W(name), (object), \
(object)); \
tTJSVariant evval(evobj, evobj); \
evobj->Release();
#define TVP_ACTION_INVOKE_MEMBER(name) \
{\
static ttstr member_name(TJS_W(name)); \
evobj->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP, \
member_name.c_str(), member_name.GetHint(), param[arg_count++], \
evobj); \
}
#define TVP_ACTION_INVOKE_END(object) \
tTJSVariant *pevval = &evval; \
(object).FuncCall(0, TVPActionName.c_str(), TVPActionName.GetHint(), \
result, 1, &pevval, NULL); \
}
#define TVP_ACTION_INVOKE_END_NAME(object, name, hint) \
tTJSVariant *pevval = &evval; \
(object).FuncCall(0, (name), (hint), \
result, 1, &pevval, NULL); \
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Continuous Event related
//---------------------------------------------------------------------------
/*[*/
class tTVPContinuousEventCallbackIntf // callback class for continuous event delivering
{
public:
virtual void TJS_INTF_METHOD OnContinuousCallback(tjs_uint64 tick) = 0;
};
/*]*/
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(void, TVPAddContinuousEventHook, (tTVPContinuousEventCallbackIntf *cb));
TJS_EXP_FUNC_DEF(void, TVPRemoveContinuousEventHook, (tTVPContinuousEventCallbackIntf *cb));
extern void TVPBeginContinuousEvent();
// must be implemented in each platforms
// this must begin calling TVPDeliverContinuousEvent
extern void TVPEndContinuousEvent();
// must be implemented in each platforms
// this must stop calling TVPDeliverContinuousEvent
extern void TVPDeliverContinuousEvent();
// must be called by each platforms's implementation
extern void TVPAddContinuousHandler(tTJSVariantClosure clo);
// add callback function written in TJS
extern void TVPRemoveContinuousHandler(tTJSVariantClosure clo);
// remove callback function added by TVPAddIdleHandler
extern bool TVPProcessContinuousHandlerEventFlag;
//---------------------------------------------------------------------------
/*[*/
//---------------------------------------------------------------------------
// System "Compact" Event related
//---------------------------------------------------------------------------
#define TVP_COMPACT_LEVEL_IDLE 5 // the application is in idle state
#define TVP_COMPACT_LEVEL_DEACTIVATE 10 // the application had been deactivated
#define TVP_COMPACT_LEVEL_MINIMIZE 15 // the application had been minimized
#define TVP_COMPACT_LEVEL_MAX 100 // strongest level, should clear all caches
//---------------------------------------------------------------------------
class tTVPCompactEventCallbackIntf // callback class for compact event delivering
{
public:
virtual void TJS_INTF_METHOD OnCompact(tjs_int level) = 0;
};
/*]*/
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(void, TVPAddCompactEventHook, (tTVPCompactEventCallbackIntf *cb));
TJS_EXP_FUNC_DEF(void, TVPRemoveCompactEventHook, (tTVPCompactEventCallbackIntf *cb));
extern void TVPDeliverCompactEvent(tjs_int level);
// must be called by each platforms's implementation
//---------------------------------------------------------------------------
/*
AsyncTrigger is a class for invoking events at asynchronous.
Script can trigger event but the event is not delivered immediately,
is delivered at next event flush phase.
*/
/*[*/
//---------------------------------------------------------------------------
// AsyncTrigger related
//---------------------------------------------------------------------------
enum tTVPAsyncTriggerMode
{
atmNormal, atmExclusive, atmAtIdle
};
/*]*/
//---------------------------------------------------------------------------
// tTJSNI_AsyncTrigger : TJS AsyncTrigger native instance
//---------------------------------------------------------------------------
class tTJSNI_AsyncTrigger : public tTJSNativeInstance
{
typedef tTJSNativeInstance inherited;
protected:
iTJSDispatch2 *Owner;
tTJSVariantClosure ActionOwner; // object to send action
ttstr ActionName;
bool Cached; // cached operation
tTVPAsyncTriggerMode Mode; // event mode
tjs_int IdlePendingCount;
public:
tTJSNI_AsyncTrigger();
tjs_error TJS_INTF_METHOD
Construct(tjs_int numparams, tTJSVariant **param,
iTJSDispatch2 *tjs_obj);
void TJS_INTF_METHOD Invalidate();
public:
tTJSVariantClosure GetActionOwnerNoAddRef() const { return ActionOwner; }
ttstr & GetActionName() { return ActionName; }
void Trigger();
void Cancel();
bool GetCached() const { return Cached; }
void SetCached(bool b);
tTVPAsyncTriggerMode GetMode() const { return Mode; }
void SetMode(tTVPAsyncTriggerMode m);
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNC_AsyncTrigger : TJS AsyncTrigger class
//---------------------------------------------------------------------------
class tTJSNC_AsyncTrigger : public tTJSNativeClass
{
typedef tTJSNativeClass inherited;
public:
tTJSNC_AsyncTrigger();
static tjs_uint32 ClassID;
protected:
tTJSNativeInstance *CreateNativeInstance();
};
//---------------------------------------------------------------------------
extern tTJSNativeClass * TVPCreateNativeClass_AsyncTrigger();
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/PluginIntf.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// "Plugins" class interface
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "PluginIntf.h"
#include "MsgIntf.h"
//---------------------------------------------------------------------------
// tTJSNC_Plugins
//---------------------------------------------------------------------------
tjs_uint32 tTJSNC_Plugins::ClassID = -1;
tTJSNC_Plugins::tTJSNC_Plugins() : inherited(TJS_W("Plugins"))
{
// registration of native members
TJS_BEGIN_NATIVE_MEMBERS(Plugins)
TJS_DECL_EMPTY_FINALIZE_METHOD
//----------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
//--properties
//---------------------------------------------------------------------------
TJS_END_NATIVE_MEMBERS
}
//---------------------------------------------------------------------------
tTJSNativeInstance * tTJSNC_Plugins::CreateNativeInstance()
{
// this class cannot create an instance
TVPThrowExceptionMessage(TVPCannotCreateInstance);
return NULL;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/PluginIntf.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// "Plugins" class interface
//---------------------------------------------------------------------------
#ifndef PluginIntfH
#define PluginIntfH
#include "tjsNative.h"
#if 0
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef _stdcall
#define _stdcall
#endif
#ifndef _cdecl
#define _cdecl
#endif
#endif
//---------------------------------------------------------------------------
// tTJSNC_Plugins : TJS Plugins class
//---------------------------------------------------------------------------
class tTJSNC_Plugins : public tTJSNativeClass
{
typedef tTJSNativeClass inherited;
public:
tTJSNC_Plugins();
static tjs_uint32 ClassID;
protected:
tTJSNativeInstance *CreateNativeInstance();
};
//---------------------------------------------------------------------------
extern tTJSNativeClass * TVPCreateNativeClass_Plugins();
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/ScriptMgnIntf.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// TJS2 Script Managing
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "tjs.h"
#include "tjsDebug.h"
#include "tjsArray.h"
#include "ScriptMgnIntf.h"
#include "StorageIntf.h"
#include "DebugIntf.h"
#include "WindowIntf.h"
#include "LayerIntf.h"
#include "CDDAIntf.h"
#include "MIDIIntf.h"
#include "WaveIntf.h"
#include "TimerIntf.h"
#include "EventIntf.h"
#include "SystemIntf.h"
#include "PluginIntf.h"
#include "MenuItemIntf.h"
#include "ClipboardIntf.h"
#include "MsgIntf.h"
#include "KAGParser.h"
#include "VideoOvlIntf.h"
#include "PadIntf.h"
#include "TextStream.h"
#include "Random.h"
#include "tjsRandomGenerator.h"
#include "SysInitIntf.h"
#include "PhaseVocoderFilter.h"
#include "BasicDrawDevice.h"
#include "BinaryStream.h"
#include "SysInitImpl.h"
#include "SystemControl.h"
#include "Application.h"
#include "RectItf.h"
#include "ImageFunction.h"
#include "BitmapIntf.h"
#include "tjsScriptBlock.h"
#include "ApplicationSpecialPath.h"
#include "SystemImpl.h"
#include "BitmapLayerTreeOwner.h"
#include "Extension.h"
#include "Platform.h"
#include "ConfigManager/LocaleConfigManager.h"
//---------------------------------------------------------------------------
// Script system initialization script
//---------------------------------------------------------------------------
static const tjs_nchar * TVPInitTJSScript =
// note that this script is stored as narrow string
TJS_N("const\
\
/* constants */\
/* tTVPBorderStyle */ bsNone=0, bsSingle=1, bsSizeable=2, bsDialog=3, bsToolWindow=4, bsSizeToolWin=5,\
/* tTVPUpdateType */ utNormal=0, utEntire =1,\
/* tTVPMouseButton */ mbLeft=0, mbRight=1, mbMiddle=2, mbX1=3, mbX2=4,\
/* tTVPMouseCursorState */ mcsVisible=0, mcsTempHidden=1, mcsHidden=2,\
/* tTVPImeMode */ imDisable=0, imClose=1, imOpen=2, imDontCare=3, imSAlpha=4, imAlpha=5, imHira=6, imSKata=7, imKata=8, imChinese=9, imSHanguel=10, imHanguel=11,\
/* Set of shift state */ ssShift=(1<<0), ssAlt=(1<<1), ssCtrl=(1<<2), ssLeft=(1<<3), ssRight=(1<<4), ssMiddle=(1<<5), ssDouble =(1<<6), ssRepeat = (1<<7),\
/* TVP_FSF_???? */ fsfFixedPitch=1, fsfSameCharSet=2, fsfNoVertical=4, \
fsfTrueTypeOnly=8, fsfUseFontFace=0x100, fsfIgnoreSymbol=0x10,\
/* tTVPLayerType */ ltBinder=0, ltCoverRect=1, ltOpaque=1, ltTransparent=2, ltAlpha=2, ltAdditive=3, ltSubtractive=4, ltMultiplicative=5, ltEffect=6, ltFilter=7, ltDodge=8, ltDarken=9, ltLighten=10, ltScreen=11, ltAddAlpha = 12,\
ltPsNormal = 13, ltPsAdditive = 14, ltPsSubtractive = 15, ltPsMultiplicative = 16, ltPsScreen = 17, ltPsOverlay = 18, ltPsHardLight = 19, ltPsSoftLight = 20, ltPsColorDodge = 21, ltPsColorDodge5 = 22, ltPsColorBurn = 23, ltPsLighten = 24, ltPsDarken = 25, ltPsDifference = 26, ltPsDifference5 = 27, ltPsExclusion = 28, \
/* tTVPBlendOperationMode */ omPsNormal = ltPsNormal,omPsAdditive = ltPsAdditive,omPsSubtractive = ltPsSubtractive,omPsMultiplicative = ltPsMultiplicative,omPsScreen = ltPsScreen,omPsOverlay = ltPsOverlay,omPsHardLight = ltPsHardLight,omPsSoftLight = ltPsSoftLight,omPsColorDodge = ltPsColorDodge,omPsColorDodge5 = ltPsColorDodge5,omPsColorBurn = ltPsColorBurn,omPsLighten = ltPsLighten,omPsDarken = ltPsDarken,omPsDifference = ltPsDifference,omPsDifference5 = ltPsDifference5,omPsExclusion = ltPsExclusion, \
omAdditive=ltAdditive, omSubtractive=ltSubtractive, omMultiplicative=ltMultiplicative, omDodge=ltDodge, omDarken=ltDarken, omLighten=ltLighten, omScreen=ltScreen, omAddAlpha=ltAddAlpha, omOpaque=ltOpaque, omAlpha=ltAlpha, omAuto = 128,\
/* tTVPDrawFace */ dfBoth=0, dfAlpha = dfBoth, dfAddAlpha = 4, dfMain=1, dfOpaque = dfMain, dfMask=2, dfProvince=3, dfAuto=128,\
/* tTVPHitType */ htMask=0, htProvince=1,\
/* tTVPScrollTransFrom */ sttLeft=0, sttTop=1, sttRight=2, sttBottom=3,\
/* tTVPScrollTransStay */ ststNoStay=0, ststStayDest=1, ststStaySrc=2, \
/* tTVPKAGDebugLevel */ tkdlNone=0, tkdlSimple=1, tkdlVerbose=2, \
/* tTVPAsyncTriggerMode */ atmNormal=0, atmExclusive=1, atmAtIdle=2, \
/* tTVPBBStretchType */ stNearest=0, stFastLinear=1, stLinear=2, stCubic=3, stSemiFastLinear = 4, stFastCubic = 5, stLanczos2 = 6, stFastLanczos2 = 7, stLanczos3 = 8, stFastLanczos3 = 9, stSpline16 = 10, stFastSpline16 = 11, stSpline36 = 12, stFastSpline36 = 13, stAreaAvg = 14, stFastAreaAvg = 15, stGaussian = 16, stFastGaussian = 17, stBlackmanSinc = 18, stFastBlackmanSinc = 19, stRefNoClip = 0x10000,\
/* tTVPClipboardFormat */ cbfText = 1,\
/* TVP_COMPACT_LEVEL_???? */ clIdle = 5, clDeactivate = 10, clMinimize = 15, clAll = 100,\
/* tTVPVideoOverlayMode Add: T.Imoto */ vomOverlay=0, vomLayer=1, vomMixer=2, vomMFEVR=3,\
/* tTVPPeriodEventReason */ perLoop = 0, perPeriod = 1, perPrepare = 2, perSegLoop = 3,\
/* tTVPSoundGlobalFocusMode */ sgfmNeverMute = 0, sgfmMuteOnMinimize = 1, sgfmMuteOnDeactivate = 2,\
/* tTVPTouchDevice */ tdNone=0, tdIntegratedTouch=0x01, tdExternalTouch=0x02, tdIntegratedPen=0x04, tdExternalPen=0x08, tdMultiInput=0x40, tdDigitizerReady=0x80,\
tdMouse=0x0100, tdMouseWheel=0x0200,\
/* Display Orientation */ oriUnknown=0, oriPortrait=1, oriLandscape=2,\
\
/* file attributes */\
faReadOnly=0x01, faHidden=0x02, faSysFile=0x04, faVolumeID=0x08, faDirectory=0x10, faArchive=0x20, faAnyFile=0x3f,\
/* mouse cursor constants */\
crDefault = 0x0,\
crNone = -1,\
crArrow = -2,\
crCross = -3,\
crIBeam = -4,\
crSize = -5,\
crSizeNESW = -6,\
crSizeNS = -7,\
crSizeNWSE = -8,\
crSizeWE = -9,\
crUpArrow = -10,\
crHourGlass = -11,\
crDrag = -12,\
crNoDrop = -13,\
crHSplit = -14,\
crVSplit = -15,\
crMultiDrag = -16,\
crSQLWait = -17,\
crNo = -18,\
crAppStart = -19,\
crHelp = -20,\
crHandPoint = -21,\
crSizeAll = -22,\
crHBeam = 1,\
/* color constants */\
clScrollBar = 0x80000000,\
clBackground = 0x80000001,\
clActiveCaption = 0x80000002,\
clInactiveCaption = 0x80000003,\
clMenu = 0x80000004,\
clWindow = 0x80000005,\
clWindowFrame = 0x80000006,\
clMenuText = 0x80000007,\
clWindowText = 0x80000008,\
clCaptionText = 0x80000009,\
clActiveBorder = 0x8000000a,\
clInactiveBorder = 0x8000000b,\
clAppWorkSpace = 0x8000000c,\
clHighlight = 0x3399ff,\
clHighlightText = 0x8000000e,\
clBtnFace = 0xf0f0f0,\
clBtnShadow = 0x787878,\
clGrayText = 0x80000011,\
clBtnText = 0x000000,\
clInactiveCaptionText = 0x80000013,\
clBtnHighlight = 0x80000014,\
cl3DDkShadow = 0x80000015,\
cl3DLight = 0x80000016,\
clInfoText = 0x80000017,\
clInfoBk = 0x80000018,\
clNone = 0x1fffffff,\
clAdapt= 0x01ffffff,\
clPalIdx = 0x3000000,\
clAlphaMat = 0x4000000,\
/* for Menu.trackPopup (see winuser.h) */\
tpmLeftButton = 0x0000,\
tpmRightButton = 0x0002,\
tpmLeftAlign = 0x0000,\
tpmCenterAlign = 0x0004,\
tpmRightAlign = 0x0008,\
tpmTopAlign = 0x0000,\
tpmVCenterAlign = 0x0010,\
tpmBottomAlign = 0x0020,\
tpmHorizontal = 0x0000,\
tpmVertical = 0x0040,\
tpmNoNotify = 0x0080,\
tpmReturnCmd = 0x0100,\
tpmRecurse = 0x0001,\
tpmHorPosAnimation = 0x0400,\
tpmHorNegAnimation = 0x0800,\
tpmVerPosAnimation = 0x1000,\
tpmVerNegAnimation = 0x2000,\
tpmNoAnimation = 0x4000,\
/* for Pad.showScrollBars (see Vcl/stdctrls.hpp :: enum TScrollStyle) */\
ssNone = 0,\
ssHorizontal = 1,\
ssVertical = 2,\
ssBoth = 3,\
/* virtual keycodes */\
VK_LBUTTON =0x01,\
VK_RBUTTON =0x02,\
VK_CANCEL =0x03,\
VK_MBUTTON =0x04,\
VK_BACK =0x08,\
VK_TAB =0x09,\
VK_CLEAR =0x0C,\
VK_RETURN =0x0D,\
VK_SHIFT =0x10,\
VK_CONTROL =0x11,\
VK_MENU =0x12,\
VK_PAUSE =0x13,\
VK_CAPITAL =0x14,\
VK_KANA =0x15,\
VK_HANGEUL =0x15,\
VK_HANGUL =0x15,\
VK_JUNJA =0x17,\
VK_FINAL =0x18,\
VK_HANJA =0x19,\
VK_KANJI =0x19,\
VK_ESCAPE =0x1B,\
VK_CONVERT =0x1C,\
VK_NONCONVERT =0x1D,\
VK_ACCEPT =0x1E,\
VK_MODECHANGE =0x1F,\
VK_SPACE =0x20,\
VK_PRIOR =0x21,\
VK_NEXT =0x22,\
VK_END =0x23,\
VK_HOME =0x24,\
VK_LEFT =0x25,\
VK_UP =0x26,\
VK_RIGHT =0x27,\
VK_DOWN =0x28,\
VK_SELECT =0x29,\
VK_PRINT =0x2A,\
VK_EXECUTE =0x2B,\
VK_SNAPSHOT =0x2C,\
VK_INSERT =0x2D,\
VK_DELETE =0x2E,\
VK_HELP =0x2F,\
VK_0 =0x30,\
VK_1 =0x31,\
VK_2 =0x32,\
VK_3 =0x33,\
VK_4 =0x34,\
VK_5 =0x35,\
VK_6 =0x36,\
VK_7 =0x37,\
VK_8 =0x38,\
VK_9 =0x39,\
VK_A =0x41,\
VK_B =0x42,\
VK_C =0x43,\
VK_D =0x44,\
VK_E =0x45,\
VK_F =0x46,\
VK_G =0x47,\
VK_H =0x48,\
VK_I =0x49,\
VK_J =0x4A,\
VK_K =0x4B,\
VK_L =0x4C,\
VK_M =0x4D,\
VK_N =0x4E,\
VK_O =0x4F,\
VK_P =0x50,\
VK_Q =0x51,\
VK_R =0x52,\
VK_S =0x53,\
VK_T =0x54,\
VK_U =0x55,\
VK_V =0x56,\
VK_W =0x57,\
VK_X =0x58,\
VK_Y =0x59,\
VK_Z =0x5A,\
VK_LWIN =0x5B,\
VK_RWIN =0x5C,\
VK_APPS =0x5D,\
VK_NUMPAD0 =0x60,\
VK_NUMPAD1 =0x61,\
VK_NUMPAD2 =0x62,\
VK_NUMPAD3 =0x63,\
VK_NUMPAD4 =0x64,\
VK_NUMPAD5 =0x65,\
VK_NUMPAD6 =0x66,\
VK_NUMPAD7 =0x67,\
VK_NUMPAD8 =0x68,\
VK_NUMPAD9 =0x69,\
VK_MULTIPLY =0x6A,\
VK_ADD =0x6B,\
VK_SEPARATOR =0x6C,\
VK_SUBTRACT =0x6D,\
VK_DECIMAL =0x6E,\
VK_DIVIDE =0x6F,\
VK_F1 =0x70,\
VK_F2 =0x71,\
VK_F3 =0x72,\
VK_F4 =0x73,\
VK_F5 =0x74,\
VK_F6 =0x75,\
VK_F7 =0x76,\
VK_F8 =0x77,\
VK_F9 =0x78,\
VK_F10 =0x79,\
VK_F11 =0x7A,\
VK_F12 =0x7B,\
VK_F13 =0x7C,\
VK_F14 =0x7D,\
VK_F15 =0x7E,\
VK_F16 =0x7F,\
VK_F17 =0x80,\
VK_F18 =0x81,\
VK_F19 =0x82,\
VK_F20 =0x83,\
VK_F21 =0x84,\
VK_F22 =0x85,\
VK_F23 =0x86,\
VK_F24 =0x87,\
VK_NUMLOCK =0x90,\
VK_SCROLL =0x91,\
VK_LSHIFT =0xA0,\
VK_RSHIFT =0xA1,\
VK_LCONTROL =0xA2,\
VK_RCONTROL =0xA3,\
VK_LMENU =0xA4,\
VK_RMENU =0xA5,\
/* VK_PADXXXX are KIRIKIRI specific */\
VK_PADLEFT =0x1B5,\
VK_PADUP =0x1B6,\
VK_PADRIGHT =0x1B7,\
VK_PADDOWN =0x1B8,\
VK_PAD1 =0x1C0,\
VK_PAD2 =0x1C1,\
VK_PAD3 =0x1C2,\
VK_PAD4 =0x1C3,\
VK_PAD5 =0x1C4,\
VK_PAD6 =0x1C5,\
VK_PAD7 =0x1C6,\
VK_PAD8 =0x1C7,\
VK_PAD9 =0x1C8,\
VK_PAD10 =0x1C9,\
VK_PADANY = 0x1DF,\
VK_PROCESSKEY =0xE5,\
VK_ATTN =0xF6,\
VK_CRSEL =0xF7,\
VK_EXSEL =0xF8,\
VK_EREOF =0xF9,\
VK_PLAY =0xFA,\
VK_ZOOM =0xFB,\
VK_NONAME =0xFC,\
VK_PA1 =0xFD,\
VK_OEM_CLEAR =0xFE,\
frFreeType=0,\
frGDI=1,\
/* graphic cache system */\
gcsAuto=-1,\
/* image 'mode' tag (mainly is generated by image format converter) constants */\
imageTagLayerType = %[\
opaque :%[type:ltOpaque ],\
rect :%[type:ltOpaque ],\
alpha :%[type:ltAlpha ],\
transparent :%[type:ltAlpha ],\
addalpha :%[type:ltAddAlpha ],\
add :%[type:ltAdditive ],\
sub :%[type:ltSubtractive ],\
mul :%[type:ltMultiplicative ],\
dodge :%[type:ltDodge ],\
darken :%[type:ltDarken ],\
lighten :%[type:ltLighten ],\
screen :%[type:ltScreen ],\
psnormal :%[type:ltPsNormal ],\
psadd :%[type:ltPsAdditive ],\
pssub :%[type:ltPsSubtractive ],\
psmul :%[type:ltPsMultiplicative ],\
psscreen :%[type:ltPsScreen ],\
psoverlay :%[type:ltPsOverlay ],\
pshlight :%[type:ltPsHardLight ],\
psslight :%[type:ltPsSoftLight ],\
psdodge :%[type:ltPsColorDodge ],\
psdodge5 :%[type:ltPsColorDodge5 ],\
psburn :%[type:ltPsColorBurn ],\
pslighten :%[type:ltPsLighten ],\
psdarken :%[type:ltPsDarken ],\
psdiff :%[type:ltPsDifference ],\
psdiff5 :%[type:ltPsDifference5 ],\
psexcl :%[type:ltPsExclusion ],\
],\
/* draw thread num */\
dtnAuto=0\
;");
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// global variables
//---------------------------------------------------------------------------
tTJS *TVPScriptEngine = NULL;
ttstr TVPStartupScriptName(TJS_W("startup.tjs"));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Garbage Collection stuff
//---------------------------------------------------------------------------
class tTVPTJSGCCallback : public tTVPCompactEventCallbackIntf
{
void TJS_INTF_METHOD OnCompact(tjs_int level)
{
// OnCompact method from tTVPCompactEventCallbackIntf
// called when the application is idle, deactivated, minimized, or etc...
if(TVPScriptEngine)
{
if(level >= TVP_COMPACT_LEVEL_IDLE)
{
TVPScriptEngine->DoGarbageCollection();
}
}
}
} static TVPTJSGCCallback;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPInitScriptEngine
//---------------------------------------------------------------------------
static bool TVPScriptEngineInit = false;
void TVPInitScriptEngine()
{
if(TVPScriptEngineInit) return;
TVPScriptEngineInit = true;
tTJSVariant val;
// Set eval expression mode
if(TVPGetCommandLine(TJS_W("-evalcontext"), &val) )
{
ttstr str(val);
if(str == TJS_W("global"))
{
TJSEvalOperatorIsOnGlobal = true;
TJSWarnOnNonGlobalEvalOperator = true;
}
}
// Set igonre-prop compat mode
if(TVPGetCommandLine(TJS_W("-unaryaster"), &val) )
{
ttstr str(val);
if(str == TJS_W("compat"))
{
TJSUnaryAsteriskIgnoresPropAccess = true;
}
}
// Set debug mode
if(TVPGetCommandLine(TJS_W("-debug"), &val) )
{
ttstr str(val);
if(str == TJS_W("yes"))
{
TJSEnableDebugMode = true;
TVPAddImportantLog((const tjs_char *)TVPWarnDebugOptionEnabled);
// if(TVPGetCommandLine(TJS_W("-warnrundelobj"), &val) )
// {
// str = val;
// if(str == TJS_W("yes"))
// {
TJSWarnOnExecutionOnDeletingObject = true;
// }
// }
}
}
// Set Read text encoding
#if 0
if(TVPGetCommandLine(TJS_W("-readencoding"), &val) )
{
ttstr str(val);
TVPSetDefaultReadEncoding( str );
}
TVPScriptTextEncoding = ttstr(TVPGetDefaultReadEncoding());
#endif
#ifdef TVP_START_UP_SCRIPT_NAME
TVPStartupScriptName = TVP_START_UP_SCRIPT_NAME;
#else
// Set startup script name
if(TVPGetCommandLine(TJS_W("-startup"), &val) )
{
ttstr str(val);
TVPStartupScriptName = str;
}
#endif
// create script engine object
TVPScriptEngine = new tTJS();
// add kirikiriz
//TVPScriptEngine->SetPPValue( TJS_W("kirikiriz"), 1 );
// set TJSGetRandomBits128
TJSGetRandomBits128 = TVPGetRandomBits128;
// script system initialization
TVPScriptEngine->ExecScript(ttstr(TVPInitTJSScript));
// set console output gateway handler
TVPScriptEngine->SetConsoleOutput(TVPGetTJS2ConsoleOutputGateway());
// set text stream functions
TJSCreateTextStreamForRead = TVPCreateTextStreamForRead;
TJSCreateTextStreamForWrite = TVPCreateTextStreamForWrite;
// set binary stream functions
TJSCreateBinaryStreamForRead = TVPCreateBinaryStreamForRead;
TJSCreateBinaryStreamForWrite = TVPCreateBinaryStreamForWrite;
// register some TVP classes/objects/functions/propeties
iTJSDispatch2 *dsp;
iTJSDispatch2 *global = TVPScriptEngine->GetGlobalNoAddRef();
#define REGISTER_OBJECT(classname, instance) \
dsp = (instance); \
val = tTJSVariant(dsp/*, dsp*/); \
dsp->Release(); \
global->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP, TJS_W(#classname), NULL, \
&val, global);
/* classes */
REGISTER_OBJECT(Debug, TVPCreateNativeClass_Debug());
REGISTER_OBJECT(Font, TVPCreateNativeClass_Font());
REGISTER_OBJECT(Layer, TVPCreateNativeClass_Layer());
REGISTER_OBJECT(CDDASoundBuffer, TVPCreateNativeClass_CDDASoundBuffer());
REGISTER_OBJECT(MIDISoundBuffer, TVPCreateNativeClass_MIDISoundBuffer());
REGISTER_OBJECT(Timer, TVPCreateNativeClass_Timer());
REGISTER_OBJECT(AsyncTrigger, TVPCreateNativeClass_AsyncTrigger());
REGISTER_OBJECT(System, TVPCreateNativeClass_System());
REGISTER_OBJECT(Storages, TVPCreateNativeClass_Storages());
REGISTER_OBJECT(Plugins, TVPCreateNativeClass_Plugins());
REGISTER_OBJECT(VideoOverlay, TVPCreateNativeClass_VideoOverlay());
REGISTER_OBJECT(Pad, TVPCreateNativeClass_Pad());
REGISTER_OBJECT(Clipboard, TVPCreateNativeClass_Clipboard());
REGISTER_OBJECT(Scripts, TVPCreateNativeClass_Scripts()); // declared in this file
REGISTER_OBJECT(Rect, TVPCreateNativeClass_Rect());
REGISTER_OBJECT(Bitmap, TVPCreateNativeClass_Bitmap());
REGISTER_OBJECT(ImageFunction, TVPCreateNativeClass_ImageFunction());
REGISTER_OBJECT(BitmapLayerTreeOwner, TVPCreateNativeClass_BitmapLayerTreeOwner());
/* KAG special support */
REGISTER_OBJECT(KAGParser, TVPCreateNativeClass_KAGParser());
/* WaveSoundBuffer and its filters */
iTJSDispatch2 * waveclass = NULL;
REGISTER_OBJECT(WaveSoundBuffer, (waveclass = TVPCreateNativeClass_WaveSoundBuffer()));
dsp = new tTJSNC_PhaseVocoder();
val = tTJSVariant(dsp);
dsp->Release();
waveclass->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP|TJS_STATICMEMBER,
TJS_W("PhaseVocoder"), NULL, &val, waveclass);
/* Window and its drawdevices */
iTJSDispatch2 * windowclass = NULL;
REGISTER_OBJECT(Window, (windowclass = TVPCreateNativeClass_Window()));
dsp = new tTJSNC_BasicDrawDevice();
val = tTJSVariant(dsp);
dsp->Release();
windowclass->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP|TJS_STATICMEMBER,
TJS_W("BasicDrawDevice"), NULL, &val, windowclass);
windowclass->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP|TJS_STATICMEMBER,
TJS_W("PassThroughDrawDevice"), NULL, &val, windowclass); // compatible for old version kr2
REGISTER_OBJECT(MenuItem, TVPCreateNativeClass_MenuItem()); // register "menu" to windowclass
// Add Extension Classes
TVPCauseAtInstallExtensionClass( global );
// Garbage Collection Hook
TVPAddCompactEventHook(&TVPTJSGCCallback);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPUninitScriptEngine
//---------------------------------------------------------------------------
static bool TVPScriptEngineUninit = false;
void TVPUninitScriptEngine()
{
if(TVPScriptEngineUninit) return;
TVPScriptEngineUninit = true;
//TVPScriptEngine->Shutdown();
TVPScriptEngine->Release();
/*
Objects, theirs lives are contolled by reference counter, may not be all
freed here in some occations.
*/
TVPScriptEngine = NULL;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPRestartScriptEngine
//---------------------------------------------------------------------------
void TVPRestartScriptEngine()
{
TVPUninitScriptEngine();
TVPScriptEngineInit = false;
TVPInitScriptEngine();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetScriptEngine
//---------------------------------------------------------------------------
tTJS * TVPGetScriptEngine()
{
return TVPScriptEngine;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetScriptDispatch
//---------------------------------------------------------------------------
iTJSDispatch2 * TVPGetScriptDispatch()
{
if(TVPScriptEngine) return TVPScriptEngine->GetGlobal(); else return NULL;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPExecuteScript
//---------------------------------------------------------------------------
void TVPExecuteScript(const ttstr& content, tTJSVariant *result)
{
if(TVPScriptEngine)
TVPScriptEngine->ExecScript(content, result);
else
TVPThrowInternalError;
}
//---------------------------------------------------------------------------
void TVPExecuteScript(const ttstr& content, const ttstr &name, tjs_int lineofs, tTJSVariant *result)
{
if(TVPScriptEngine)
TVPScriptEngine->ExecScript(content, result, NULL, &name, lineofs);
else
TVPThrowInternalError;
}
//---------------------------------------------------------------------------
void TVPExecuteScript(const ttstr& content, iTJSDispatch2 *context, tTJSVariant *result)
{
if(TVPScriptEngine)
TVPScriptEngine->ExecScript(content, result, context);
else
TVPThrowInternalError;
}
//---------------------------------------------------------------------------
void TVPExecuteScript(const ttstr& content, const ttstr &name, tjs_int lineofs, iTJSDispatch2 *context, tTJSVariant *result)
{
if(TVPScriptEngine)
TVPScriptEngine->ExecScript(content, result, context, &name, lineofs);
else
TVPThrowInternalError;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPExecuteExpression
//---------------------------------------------------------------------------
void TVPExecuteExpression(const ttstr& content, tTJSVariant *result)
{
TVPExecuteExpression(content, NULL, result);
}
//---------------------------------------------------------------------------
void TVPExecuteExpression(const ttstr& content, const ttstr &name, tjs_int lineofs, tTJSVariant *result)
{
TVPExecuteExpression(content, name, lineofs, NULL, result);
}
//---------------------------------------------------------------------------
void TVPExecuteExpression(const ttstr& content, iTJSDispatch2 *context, tTJSVariant *result)
{
if(TVPScriptEngine)
{
iTJSConsoleOutput *output = TVPScriptEngine->GetConsoleOutput();
TVPScriptEngine->SetConsoleOutput(NULL); // once set TJS console to null
try
{
TVPScriptEngine->EvalExpression(content, result, context);
}
catch(...)
{
TVPScriptEngine->SetConsoleOutput(output);
throw;
}
TVPScriptEngine->SetConsoleOutput(output);
}
else
{
TVPThrowInternalError;
}
}
//---------------------------------------------------------------------------
void TVPExecuteExpression(const ttstr& content, const ttstr &name, tjs_int lineofs, iTJSDispatch2 *context, tTJSVariant *result)
{
if(TVPScriptEngine)
{
iTJSConsoleOutput *output = TVPScriptEngine->GetConsoleOutput();
TVPScriptEngine->SetConsoleOutput(NULL); // once set TJS console to null
try
{
TVPScriptEngine->EvalExpression(content, result, context, &name, lineofs);
}
catch(...)
{
TVPScriptEngine->SetConsoleOutput(output);
throw;
}
TVPScriptEngine->SetConsoleOutput(output);
}
else
{
TVPThrowInternalError;
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPExecuteBytecode
//---------------------------------------------------------------------------
void TVPExecuteBytecode( const tjs_uint8* content, size_t len, iTJSDispatch2 *context, tTJSVariant *result, const tjs_char *name )
{
if(!TVPScriptEngine) TVPThrowInternalError;
TVPScriptEngine->LoadByteCode( content, len, result, context, name);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void TVPExecuteStorage(const ttstr &name, tTJSVariant *result, bool isexpression,
const tjs_char * modestr)
{
TVPExecuteStorage(name, NULL, result, isexpression, modestr);
}
//---------------------------------------------------------------------------
void TVPExecuteStorage(const ttstr &name, iTJSDispatch2 *context, tTJSVariant *result, bool isexpression,
const tjs_char * modestr)
{
// execute storage which contains script
if(!TVPScriptEngine) TVPThrowInternalError;
{ // for bytecode
ttstr place(TVPSearchPlacedPath(name));
ttstr shortname(TVPExtractStorageName(place));
tTJSBinaryStream* stream = TVPCreateBinaryStreamForRead(place, modestr);
if( stream ) {
bool isbytecode = false;
try {
isbytecode = TVPScriptEngine->LoadByteCode( stream, result, context, shortname.c_str() );
} catch(...) {
delete stream;
throw;
}
delete stream;
if( isbytecode ) return;
}
}
ttstr place(TVPSearchPlacedPath(name));
ttstr shortname(TVPExtractStorageName(place));
iTJSTextReadStream * stream = TVPCreateTextStreamForRead(place, modestr);
ttstr buffer;
try
{
stream->Read(buffer, 0);
}
catch(...)
{
stream->Destruct();
throw;
}
stream->Destruct();
if(TVPScriptEngine)
{
if(!isexpression)
TVPScriptEngine->ExecScript(buffer, result, context,
&shortname);
else
TVPScriptEngine->EvalExpression(buffer, result, context,
&shortname);
}
}
//---------------------------------------------------------------------------
void TVPCompileStorage( const ttstr& name, bool isrequestresult, bool outputdebug, bool isexpression, const ttstr& outputpath ) {
// execute storage which contains script
if(!TVPScriptEngine) TVPThrowInternalError;
ttstr place(TVPSearchPlacedPath(name));
ttstr shortname(TVPExtractStorageName(place));
iTJSTextReadStream * stream = TVPCreateTextStreamForRead(place, TJS_W(""));
ttstr buffer;
try {
stream->Read(buffer, 0);
} catch(...) {
stream->Destruct();
throw;
}
stream->Destruct();
tTJSBinaryStream* outputstream = TVPCreateStream(outputpath, TJS_BS_WRITE);
if(TVPScriptEngine) {
try {
TVPScriptEngine->CompileScript( buffer.c_str(), outputstream, isrequestresult, outputdebug, isexpression, name.c_str(), 0 );
} catch(...) {
delete outputstream;
throw;
}
}
delete outputstream;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCreateMessageMapFile
//---------------------------------------------------------------------------
void TVPCreateMessageMapFile(const ttstr &filename)
{
#ifdef TJS_TEXT_OUT_CRLF
ttstr script(TJS_W("{\r\n\tvar r = System.assignMessage;\r\n"));
#else
ttstr script(TJS_W("{\n\tvar r = System.assignMessage;\n"));
#endif
script += TJSCreateMessageMapString();
script += TJS_W("}");
iTJSTextWriteStream * stream = TVPCreateTextStreamForWrite(
filename, TJS_W(""));
try
{
stream->Write(script);
}
catch(...)
{
stream->Destruct();
throw;
}
stream->Destruct();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPDumpScriptEngine
//---------------------------------------------------------------------------
void TVPDumpScriptEngine()
{
TVPTJS2StartDump();
TVPScriptEngine->SetConsoleOutput(TVPGetTJS2DumpOutputGateway());
try
{
TVPScriptEngine->Dump();
}
catch(...)
{
TVPTJS2EndDump();
TVPScriptEngine->SetConsoleOutput(TVPGetTJS2ConsoleOutputGateway());
throw;
}
TVPScriptEngine->SetConsoleOutput(TVPGetTJS2ConsoleOutputGateway());
TVPTJS2EndDump();
}
//---------------------------------------------------------------------------
bool TVPStartupSuccess = false;
void TVPOpenPatchLibUrl();
//---------------------------------------------------------------------------
// TVPExecuteStartupScript
//---------------------------------------------------------------------------
void TVPExecuteStartupScript()
{
ttstr strPatchError;
try {
ttstr patch = TVPGetAppPath() + "patch.tjs";
if(TVPIsExistentStorageNoSearch(patch))
TVPExecuteStorage(patch);
} catch (const TJS::eTJSScriptError &e) {
ttstr &msg = strPatchError;
msg += e.GetMessage();
const tjs_char *pszBlockName = e.GetBlockName();
if (pszBlockName && *pszBlockName) {
msg += TJS_W("\n@line(");
tjs_char tmp[34];
msg += TJS_int_to_str(e.GetSourceLine(), tmp);
msg += TJS_W(") ");
msg += pszBlockName;
}
msg += TJS_W("\n");
msg += e.GetTrace();
} catch (const TJS::eTJS &e) {
if (!TVPSystemUninitCalled)
strPatchError = e.GetMessage();
} catch (const std::exception &e) {
strPatchError = e.what();
} catch (const char* e) {
strPatchError = e;
} catch (const tjs_char* e) {
strPatchError = e;
}
if (!strPatchError.IsEmpty()) {
ttstr msg = LocaleConfigManager::GetInstance()->GetText("startup_patch_fail");
msg += "\n";
msg += strPatchError;
std::vector btns;
btns.emplace_back(LocaleConfigManager::GetInstance()->GetText("msgbox_ok"));
btns.emplace_back(LocaleConfigManager::GetInstance()->GetText("browse_patch_lib"));
if (TVPShowSimpleMessageBox(msg, TVPGetPackageVersionString(), btns) == 1) {
TVPOpenPatchLibUrl();
}
}
// execute "startup.tjs"
// try
// {
try
{
ttstr place(TVPSearchPlacedPath(TVPStartupScriptName));
TVPAddLog(TJS_W("(info) Loading startup script : ") + place);
TVPStartupSuccess = false;
try {
iTJSTextReadStream * stream = TVPCreateTextStreamForRead(place, "");
stream->Destruct();
TVPExecuteStorage(TVPStartupScriptName);
TVPStartupSuccess = true;
}
catch (...)
{
if (!TVPIsExistentStorage(TJS_W("System/Initialize.tjs"))) {
throw;
}
}
if (TVPStartupSuccess) {
} else {
// try direct execute initialize.tjs to compatible for some patch
TVPExecuteStorage(TJS_W("System/Initialize.tjs"));
TVPStartupSuccess = true;
}
TVPAddLog(TJS_W("(info) Startup script ended."));
try {
ttstr patch = TVPGetAppPath() + "AfterStartup.tjs";
if (TVPIsExistentStorageNoSearch(patch))
TVPExecuteStorage(patch);
}
catch (...) {}
}
TJS_CONVERT_TO_TJS_EXCEPTION
//}
//TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(TJS_W("startup"))
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// unhandled exception handler related
//---------------------------------------------------------------------------
static bool TJSGetSystem_exceptionHandler_Object(tTJSVariantClosure & dest)
{
// get System.exceptionHandler
iTJSDispatch2 * global = TVPGetScriptEngine()->GetGlobalNoAddRef();
if(!global) return false;
tTJSVariant val;
tTJSVariant val2;
tTJSVariantClosure clo;
tjs_error er;
er = global->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("System"), NULL, &val, global);
if(TJS_FAILED(er)) return false;
if(val.Type() != tvtObject) return false;
clo = val.AsObjectClosureNoAddRef();
if(clo.Object == NULL) return false;
clo.PropGet(TJS_MEMBERMUSTEXIST, TJS_W("exceptionHandler"), NULL, &val2, NULL);
if(val2.Type() != tvtObject) return false;
dest = val2.AsObjectClosure();
if(!dest.Object)
{
dest.Release();
return false;
}
return true;
}
//---------------------------------------------------------------------------
bool TVPProcessUnhandledException(eTJSScriptException &e)
{
bool result;
tTJSVariantClosure clo;
clo.Object = clo.ObjThis = NULL;
try
{
// get the script engine
tTJS *engine = TVPGetScriptEngine();
if(!engine)
return false; // the script engine had been shutdown
// get System.exceptionHandler
if(!TJSGetSystem_exceptionHandler_Object(clo))
return false; // System.exceptionHandler cannot be retrieved
// execute clo
tTJSVariant obj(e.GetValue());
tTJSVariant *pval[] = { &obj };
tTJSVariant res;
clo.FuncCall(0, NULL, NULL, &res, 1, pval, NULL);
result = res.operator bool();
}
catch(eTJSScriptError &e)
{
clo.Release();
TVPShowScriptException(e);
}
catch(eTJS &e)
{
clo.Release();
TVPShowScriptException(e);
}
catch(...)
{
clo.Release();
throw;
}
clo.Release();
return result;
}
//---------------------------------------------------------------------------
bool TVPProcessUnhandledException(eTJSScriptError &e)
{
bool result;
tTJSVariantClosure clo;
clo.Object = clo.ObjThis = NULL;
try
{
// get the script engine
tTJS *engine = TVPGetScriptEngine();
if(!engine)
return false; // the script engine had been shutdown
// get System.exceptionHandler
if(!TJSGetSystem_exceptionHandler_Object(clo))
return false; // System.exceptionHandler cannot be retrieved
// execute clo
tTJSVariant obj;
tTJSVariant msg(e.GetMessage());
tTJSVariant trace(e.GetTrace());
TJSGetExceptionObject(engine, &obj, msg, &trace);
tTJSVariant *pval[] = { &obj };
tTJSVariant res;
clo.FuncCall(0, NULL, NULL, &res, 1, pval, NULL);
result = res.operator bool();
}
catch(eTJSScriptError &e)
{
clo.Release();
TVPShowScriptException(e);
}
catch(eTJS &e)
{
clo.Release();
TVPShowScriptException(e);
}
catch(...)
{
clo.Release();
throw;
}
clo.Release();
return result;
}
//---------------------------------------------------------------------------
bool TVPProcessUnhandledException(eTJS &e)
{
bool result;
tTJSVariantClosure clo;
clo.Object = clo.ObjThis = NULL;
try
{
// get the script engine
tTJS *engine = TVPGetScriptEngine();
if(!engine)
return false; // the script engine had been shutdown
// get System.exceptionHandler
if(!TJSGetSystem_exceptionHandler_Object(clo))
return false; // System.exceptionHandler cannot be retrieved
// execute clo
tTJSVariant obj;
tTJSVariant msg(e.GetMessage());
TJSGetExceptionObject(engine, &obj, msg);
tTJSVariant *pval[] = { &obj };
tTJSVariant res;
clo.FuncCall(0, NULL, NULL, &res, 1, pval, NULL);
result = res.operator bool();
}
catch(eTJSScriptError &e)
{
clo.Release();
TVPShowScriptException(e);
}
catch(eTJS &e)
{
clo.Release();
TVPShowScriptException(e);
}
catch(...)
{
clo.Release();
throw;
}
clo.Release();
return result;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void TVPStartObjectHashMap()
{
// addref ObjectHashMap if the program is being debugged.
if(TJSEnableDebugMode)
TJSAddRefObjectHashMap();
}
//---------------------------------------------------------------------------
// TVPBeforeProcessUnhandledException
//---------------------------------------------------------------------------
void TVPBeforeProcessUnhandledException()
{
TVPDumpHWException();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPShowScriptException
//---------------------------------------------------------------------------
/*
These functions display the error location, reason, etc.
And disable the script event dispatching to avoid massive occurrence of
errors.
*/
extern ttstr TVPGetErrorDialogTitle();
//---------------------------------------------------------------------------
void TVPShowScriptException(eTJS &e)
{
TVPSetSystemEventDisabledState(true);
TVPOnError();
if(!TVPSystemUninitCalled)
{
ttstr errstr = (ttstr(TVPScriptExceptionRaised) + TJS_W("\n") + e.GetMessage());
TVPAddLog(ttstr(TVPScriptExceptionRaised) + TJS_W("\n") + e.GetMessage());
TVPShowSimpleMessageBox(errstr, TVPGetErrorDialogTitle());
//Application->MessageDlg( errstr.AsStdString(), std::wstring(), mtError, mbOK );
TVPTerminateSync(1);
}
}
//---------------------------------------------------------------------------
void TVPShowScriptException(eTJSScriptError &e)
{
TVPSetSystemEventDisabledState(true);
TVPOnError();
if(!TVPSystemUninitCalled)
{
ttstr errstr = (ttstr(TVPScriptExceptionRaised) + TJS_W("\n") + e.GetMessage());
TVPAddLog(ttstr(TVPScriptExceptionRaised) + TJS_W("\n") + e.GetMessage());
if(e.GetTrace().GetLen() != 0)
TVPAddLog(ttstr(TJS_W("trace : ")) + e.GetTrace());
TVPShowSimpleMessageBox(errstr, TVPGetErrorDialogTitle());
// Application->MessageDlg( errstr.AsStdString(), Application->GetTitle(), mtStop, mbOK );
#ifdef TVP_ENABLE_EXECUTE_AT_EXCEPTION
const tjs_char* scriptName = e.GetBlockNoAddRef()->GetName();
if( scriptName != NULL && scriptName[0] != 0 ) {
ttstr path(scriptName);
try {
ttstr newpath = TVPGetPlacedPath(path);
if( newpath.IsEmpty() ) {
path = TVPNormalizeStorageName(path);
} else {
path = newpath;
}
TVPGetLocalName( path );
std::wstring scriptPath( path.AsStdString() );
tjs_int lineno = 1+e.GetBlockNoAddRef()->SrcPosToLine(e.GetPosition() )- e.GetBlockNoAddRef()->GetLineOffset();
#if defined(WIN32) && defined(_DEBUG) && !defined(ENABLE_DEBUGGER)
// fobKsĂ鎞AVisual Studio ōsWv鎞̎wfobOo͂ɏoāAbreak Œ~
if( ::IsDebuggerPresent() ) {
std::wstring debuglile( std::wstring(L"2>")+path.AsStdString()+L"("+std::to_wstring(lineno)+L"): error :" + errstr.AsStdString() );
::OutputDebugString( debuglile.c_str() );
// breakŒ~AȌo͍s_uNbNAOӏ̃XNvgVisual StudioŊJ
::DebugBreak();
}
#endif
scriptPath = std::wstring(L"\"") + scriptPath + std::wstring(L"\"");
tTJSVariant val;
if( TVPGetCommandLine(TJS_W("-exceptionexe"), &val) )
{
ttstr exepath(val);
//exepath = ttstr(TJS_W("\"")) + exepath + ttstr(TJS_W("\""));
if( TVPGetCommandLine(TJS_W("-exceptionarg"), &val) )
{
ttstr arg(val);
if( !exepath.IsEmpty() && !arg.IsEmpty() ) {
std::wstring str( arg.AsStdString() );
str = ApplicationSpecialPath::ReplaceStringAll( str, std::wstring(L"%filepath%"), scriptPath );
str = ApplicationSpecialPath::ReplaceStringAll( str, std::wstring(L"%line%"), std::to_wstring(lineno) );
//exepath = exepath + ttstr(str);
//_wsystem( exepath.c_str() );
arg = ttstr(str);
TVPAddLog( ttstr(TJS_W("(execute) "))+exepath+ttstr(TJS_W(" "))+arg);
TVPShellExecute( exepath, arg );
}
}
}
} catch(...) {
}
}
#endif
TVPTerminateSync(1);
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPInitializeStartupScript
//---------------------------------------------------------------------------
void TVPInitializeStartupScript()
{
TVPStartObjectHashMap();
TVPExecuteStartupScript();
if(TVPTerminateOnNoWindowStartup && TVPGetWindowCount() == 0 ) {
// no window is created and main window is invisible
Application->Terminate();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNC_Scripts
//---------------------------------------------------------------------------
tjs_uint32 tTJSNC_Scripts::ClassID = -1;
tTJSNC_Scripts::tTJSNC_Scripts() : inherited(TJS_W("Scripts"))
{
// registration of native members
TJS_BEGIN_NATIVE_MEMBERS(Scripts)
TJS_DECL_EMPTY_FINALIZE_METHOD
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_CONSTRUCTOR_DECL_NO_INSTANCE(/*TJS class name*/Scripts)
{
return TJS_S_OK;
}
TJS_END_NATIVE_CONSTRUCTOR_DECL(/*TJS class name*/Scripts)
//----------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/execStorage)
{
// execute script which stored in storage
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr name = *param[0];
ttstr modestr;
if(numparams >=2 && param[1]->Type() != tvtVoid)
modestr = *param[1];
iTJSDispatch2 *context = numparams >= 3 && param[2]->Type() != tvtVoid ? param[2]->AsObjectNoAddRef() : NULL;
TVPExecuteStorage(name, context, result, false, modestr.c_str());
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/execStorage)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/evalStorage)
{
// execute expression which stored in storage
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr name = *param[0];
ttstr modestr;
if(numparams >=2 && param[1]->Type() != tvtVoid)
modestr = *param[1];
iTJSDispatch2 *context = numparams >= 3 && param[2]->Type() != tvtVoid ? param[2]->AsObjectNoAddRef() : NULL;
TVPExecuteStorage(name, context, result, true, modestr.c_str());
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/evalStorage)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/compileStorage) // bytecode
{
if(numparams < 2) return TJS_E_BADPARAMCOUNT;
ttstr name = *param[0];
ttstr output = *param[1];
bool isresult = false;
if( numparams >= 3 && (tjs_int)*param[2] ) {
isresult = true;
}
bool outputdebug = false;
if( numparams >= 4 && (tjs_int)*param[3] ) {
outputdebug = true;
}
bool isexpression = false;
if( numparams >= 5 && (tjs_int)*param[4] ) {
isexpression = true;
}
TVPCompileStorage( name, isresult, outputdebug, isexpression, output );
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/compileStorage)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/exec)
{
// execute given string as a script
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr content = *param[0];
ttstr name;
tjs_int lineofs = 0;
if(numparams >= 2 && param[1]->Type() != tvtVoid) name = *param[1];
if(numparams >= 3 && param[2]->Type() != tvtVoid) lineofs = *param[2];
iTJSDispatch2 *context = numparams >= 4 && param[3]->Type() != tvtVoid ? param[3]->AsObjectNoAddRef() : NULL;
if(TVPScriptEngine)
TVPScriptEngine->ExecScript(content, result, context,
&name, lineofs);
else
TVPThrowInternalError;
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/exec)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/eval)
{
// execute given string as a script
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr content = *param[0];
ttstr name;
tjs_int lineofs = 0;
if(numparams >= 2 && param[1]->Type() != tvtVoid) name = *param[1];
if(numparams >= 3 && param[2]->Type() != tvtVoid) lineofs = *param[2];
iTJSDispatch2 *context = numparams >= 4 && param[3]->Type() != tvtVoid ? param[3]->AsObjectNoAddRef() : NULL;
if(TVPScriptEngine)
TVPScriptEngine->EvalExpression(content, result, context,
&name, lineofs);
else
TVPThrowInternalError;
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/eval)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/dump)
{
// execute given string as a script
TVPDumpScriptEngine();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/dump)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/getTraceString)
{
// get current stack trace as string
tjs_int limit = 0;
if(numparams >= 1 && param[0]->Type() != tvtVoid)
limit = *param[0];
if(result)
{
*result = TJSGetStackTraceString(limit);
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/getTraceString)
//----------------------------------------------------------------------
#ifdef TJS_DEBUG_DUMP_STRING
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/dumpStringHeap)
{
// dump all strings held by TJS2 framework
TJSDumpStringHeap();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/dumpStringHeap)
#endif
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/setCallMissing) /* UNDOCUMENTED: subject to change */
{
// set to call "missing" method
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
iTJSDispatch2 *dsp = param[0]->AsObjectNoAddRef();
if(dsp)
{
tTJSVariant missing(TJS_W("missing"));
dsp->ClassInstanceInfo(TJS_CII_SET_MISSING, 0, &missing);
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/setCallMissing) /* UNDOCUMENTED: subject to change */
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/getClassNames) /* UNDOCUMENTED: subject to change */
{
// get class name as an array, last (most end) class first.
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
iTJSDispatch2 *dsp = param[0]->AsObjectNoAddRef();
if(dsp)
{
iTJSDispatch2 * array = TJSCreateArrayObject();
try
{
tjs_uint num = 0;
while(true)
{
tTJSVariant val;
tjs_error err = dsp->ClassInstanceInfo(TJS_CII_GET, num, &val);
if(TJS_FAILED(err)) break;
array->PropSetByNum(TJS_MEMBERENSURE, num, &val, array);
num ++;
}
if(result) *result = tTJSVariant(array, array);
}
catch(...)
{
array->Release();
throw;
}
array->Release();
}
else
{
return TJS_E_FAIL;
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/getClassNames) /* UNDOCUMENTED: subject to change */
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(textEncoding)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetDefaultReadEncoding();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TVPSetDefaultReadEncoding(*param);
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(textEncoding)
//----------------------------------------------------------------------
TJS_END_NATIVE_MEMBERS
}
//---------------------------------------------------------------------------
tTJSNativeInstance * tTJSNC_Scripts::CreateNativeInstance()
{
// this class cannot create an instance
TVPThrowExceptionMessage(TVPCannotCreateInstance);
return NULL;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCreateNativeClass_Scripts
//---------------------------------------------------------------------------
tTJSNativeClass * TVPCreateNativeClass_Scripts()
{
tTJSNC_Scripts *cls = new tTJSNC_Scripts();
// setup some platform-specific members
//----------------------------------------------------------------------
// currently none
//----------------------------------------------------------------------
return cls;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/ScriptMgnIntf.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// TJS2 Script Managing
//---------------------------------------------------------------------------
#ifndef ScriptMgnImtfH
#define ScriptMgnImtfH
#include "tjs.h"
#include "tjsNative.h"
#include "tjsError.h"
//---------------------------------------------------------------------------
// implementation in this unit
//---------------------------------------------------------------------------
extern ttstr TVPStartupScriptName;
extern void TVPInitScriptEngine();
extern void TVPUninitScriptEngine();
extern void TVPRestartScriptEngine();
extern tTJS* TVPGetScriptEngine();
TJS_EXP_FUNC_DEF(iTJSDispatch2 *, TVPGetScriptDispatch, ());
TJS_EXP_FUNC_DEF(void, TVPExecuteScript, (const ttstr& content, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteScript, (const ttstr& content, iTJSDispatch2 *context, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteExpression, (const ttstr &content, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteExpression, (const ttstr &content, iTJSDispatch2 *context, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteScript, (const ttstr& content, const ttstr &name, tjs_int lineofs, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteScript, (const ttstr& content, const ttstr &name, tjs_int lineofs, iTJSDispatch2 *context, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteExpression, (const ttstr &content, const ttstr &name, tjs_int lineofs, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteExpression, (const ttstr &content, const ttstr &name, tjs_int lineofs, iTJSDispatch2 *context, tTJSVariant *result = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteStorage, (const ttstr &name, tTJSVariant *result = NULL,
bool isexpression = false, const tjs_char *modestr = NULL));
TJS_EXP_FUNC_DEF(void, TVPExecuteStorage, (const ttstr &name, iTJSDispatch2 *context, tTJSVariant *result = NULL,
bool isexpression = false, const tjs_char *modestr = NULL));
TJS_EXP_FUNC_DEF(void, TVPDumpScriptEngine, ());
TJS_EXP_FUNC_DEF(void, TVPExecuteBytecode, (const tjs_uint8* content, size_t len, iTJSDispatch2 *context, tTJSVariant *result = NULL, const tjs_char *name = NULL ));
extern void TVPExecuteStartupScript();
TJS_EXP_FUNC_DEF(void, TVPCreateMessageMapFile, (const ttstr &filename));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// implementation in each platform to show script exception message
//---------------------------------------------------------------------------
extern void TVPShowScriptException(eTJS &e);
extern void TVPShowScriptException(eTJSScriptError &e);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPBeforeProcessUnhandledException (implementation in each platform)
//---------------------------------------------------------------------------
extern void TVPBeforeProcessUnhandledException();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// unhandled exception handler related macros
//---------------------------------------------------------------------------
extern bool TVPProcessUnhandledException(eTJSScriptException &e);
extern bool TVPProcessUnhandledException(eTJSScriptError &e);
extern bool TVPProcessUnhandledException(eTJS &e);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPInitializeStartupScript
//---------------------------------------------------------------------------
extern void TVPInitializeStartupScript();
extern bool TVPCheckProcessLog();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// unhandled exception handler related macros
//---------------------------------------------------------------------------
#define TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION(origin) \
catch(eTJSScriptException &e) \
{ \
TVPBeforeProcessUnhandledException(); \
e.AddTrace(ttstr(origin)); \
if(!TVPProcessUnhandledException(e)) \
TVPShowScriptException(e); \
} \
catch(eTJSScriptError &e) \
{ \
TVPBeforeProcessUnhandledException(); \
e.AddTrace(ttstr(origin)); \
if(!TVPProcessUnhandledException(e)) \
TVPShowScriptException(e); \
} \
catch(eTJS &e) \
{ \
TVPBeforeProcessUnhandledException(); \
if(!TVPProcessUnhandledException(e)) \
TVPShowScriptException(e); \
} \
catch(...) \
{ \
TVPBeforeProcessUnhandledException(); \
throw; \
}
#define TVP_CATCH_AND_SHOW_SCRIPT_EXCEPTION_FORCE_SHOW_EXCEPTION(origin) \
catch(eTJSScriptError &e) \
{ \
TVPBeforeProcessUnhandledException(); \
e.AddTrace(ttstr(origin)); \
TVPShowScriptException(e); \
} \
catch(eTJS &e) \
{ \
TVPBeforeProcessUnhandledException(); \
TVPShowScriptException(e); \
} \
catch(...) \
{ \
TVPBeforeProcessUnhandledException(); \
throw; \
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNC_Scripts : TJS Scripts class
//---------------------------------------------------------------------------
class tTJSNC_Scripts : public tTJSNativeClass
{
typedef tTJSNativeClass inherited;
public:
tTJSNC_Scripts();
static tjs_uint32 ClassID;
protected:
tTJSNativeInstance *CreateNativeInstance();
};
//---------------------------------------------------------------------------
extern tTJSNativeClass * TVPCreateNativeClass_Scripts();
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/StorageIntf.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include
#include
#include "StorageIntf.h"
#include "tjsUtils.h"
#include "MsgIntf.h"
#include "EventIntf.h"
#include "DebugIntf.h"
#include "tjsArray.h"
#include "SysInitIntf.h"
#include "XP3Archive.h"
#include "TickCount.h"
#define TVP_DEFAULT_ARCHIVE_CACHE_NUM 64
#define TVP_DEFAULT_AUTOPATH_CACHE_NUM 256
//---------------------------------------------------------------------------
// global variables
//---------------------------------------------------------------------------
// current media ( ex. "http" "ftp" "file" )
ttstr TVPCurrentMedia;
// archive delimiter
// this changes '>' from '#' since 2.19 beta 14
tjs_char TVPArchiveDelimiter = '>';
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// statics
//---------------------------------------------------------------------------
static tTJSStaticCriticalSection TVPCreateStreamCS;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// utilities
//---------------------------------------------------------------------------
ttstr TVPStringFromBMPUnicode(const tjs_uint16 *src, tjs_int maxlen)
{
// convert to ttstr from BMP unicode
if(sizeof(tjs_char) == 2)
{
// sizeof(tjs_char) is 2 (windows native)
if(maxlen == -1)
return ttstr((const tjs_char*)src);
else
return ttstr((const tjs_char*)src, maxlen);
}
else if(sizeof(tjs_char) == 4)
{
// sizeof(tjs_char) is 4 (UCS32)
// FIXME: NOT TESTED CODE
tjs_int len = 0;
const tjs_uint16 *p = src;
while(*p) len++, p++;
if(maxlen != -1 && len > maxlen) len = maxlen;
ttstr ret((tTJSStringBufferLength)(len));
tjs_char *dest = ret.Independ();
p = src;
while(len && *p)
{
*dest = *p;
dest++;
p++;
len --;
}
*dest = 0;
ret.FixLen();
return ret;
}
return (const tjs_char*)TVPTjsCharMustBeTwoOrFour;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPStorageMediaManager
//---------------------------------------------------------------------------
class tTVPStorageMediaManager
{
class tMediaNameString : public tTJSString
{
public:
bool operator == (const tMediaNameString &rhs) const
{
const tjs_char * l_p = c_str();
const tjs_char * r_p = rhs.c_str();
while(*l_p && *r_p)
{
if(*l_p == TJS_W(':')) break;
if(*r_p == TJS_W(':')) break;
if(*l_p != *r_p) break;
l_p++;
r_p++;
}
if((*l_p == TJS_W(':') || *l_p == 0) &&
(*r_p == TJS_W(':') || *r_p == 0)) return true;
return false;
}
};
class tHashFunc
{
public:
static tjs_uint32 Make(const tMediaNameString &key)
{
if(key.IsEmpty()) return 0;
const tjs_char *str = key.c_str();
tjs_uint32 ret = 0;
while(*str && *str != ':')
{
ret += *str;
ret += (ret << 10);
ret ^= (ret >> 6);
str++;
}
ret += (ret << 3);
ret ^= (ret >> 11);
ret += (ret << 15);
if(!ret) ret = (tjs_uint32)-1;
return ret;
}
};
class tMediaRecord
{
public:
ttstr CurrentDomain;
ttstr CurrentPath;
tTJSRefHolder MediaIntf;
tjs_int MediaNameLen;
// bool IsCaseSensitive;
tMediaRecord(iTVPStorageMedia *media) : MediaIntf(media), CurrentDomain("."), CurrentPath("/")
{ ttstr name; media->GetName(name); MediaNameLen = name.GetLen();
/*IsCaseSensitive = media->IsCaseSensitive();*/ }
const tjs_char *GetDomainAndPath(const ttstr &name)
{
return name.c_str() + MediaNameLen + 3;
// 3 = strlen("://")
}
};
typedef tTJSHashTable tHashTable;
tHashTable HashTable;
public:
tTVPStorageMediaManager();
~tTVPStorageMediaManager();
private:
static void ThrowUnsupportedMediaType(const ttstr &name);
tMediaRecord * GetMediaRecord(const ttstr &name);
public:
void Register(iTVPStorageMedia * media);
void Unregister(iTVPStorageMedia * media);
ttstr NormalizeStorageName(const ttstr &name, ttstr *ret_media = NULL,
ttstr *ret_domain = NULL, ttstr *ret_path = NULL);
void SetCurrentDirectory(const ttstr &name);
static ttstr ExtractMediaName(const ttstr &name);
bool CheckExistentStorage(const ttstr & name);
tTJSBinaryStream * Open(const ttstr & name, tjs_uint32 flags);
void GetListAt(const ttstr &name, iTVPStorageLister *lister);
ttstr GetLocallyAccessibleName(const ttstr &name);
} TVPStorageMediaManager;
//---------------------------------------------------------------------------
tTVPStorageMediaManager::tTVPStorageMediaManager()
{
iTVPStorageMedia *filemedia = TVPCreateFileMedia();
Register(filemedia);
filemedia->Release();
}
//---------------------------------------------------------------------------
tTVPStorageMediaManager::~tTVPStorageMediaManager()
{
}
//---------------------------------------------------------------------------
void tTVPStorageMediaManager::ThrowUnsupportedMediaType(const ttstr &name)
{
TVPThrowExceptionMessage(TVPUnsupportedMediaName, ExtractMediaName(name));
}
//---------------------------------------------------------------------------
tTVPStorageMediaManager::tMediaRecord *
tTVPStorageMediaManager::GetMediaRecord(const ttstr &name)
{
tMediaRecord *rec = HashTable.Find(*(tMediaNameString*)&name);
if(!rec) ThrowUnsupportedMediaType(name);
return rec;
}
//---------------------------------------------------------------------------
void tTVPStorageMediaManager::Register(iTVPStorageMedia * media)
{
ttstr medianame;
media->GetName(medianame);
tMediaRecord *rec = HashTable.Find(*(tMediaNameString*)&medianame);
if(rec)
TVPThrowExceptionMessage( TVPMediaNameHadAlreadyBeenRegistered, medianame );
tMediaRecord new_rec(media);
HashTable.Add(*(tMediaNameString*)&medianame, new_rec);
}
//---------------------------------------------------------------------------
void tTVPStorageMediaManager::Unregister(iTVPStorageMedia * media)
{
ttstr medianame;
media->GetName(medianame);
tMediaRecord *rec = HashTable.Find(*(tMediaNameString*)&medianame);
if(!rec)
TVPThrowExceptionMessage( TVPMediaNameIsNotRegistered, medianame );
HashTable.Delete(*(tMediaNameString*)&medianame);
}
//---------------------------------------------------------------------------
ttstr tTVPStorageMediaManager::NormalizeStorageName(const ttstr &name,
ttstr *ret_media, ttstr *ret_domain, ttstr *ret_path)
{
// Normalize storage name.
// storage name is basically in following form:
// media://domain/path
// media is sort of access method, like "file", "http" ...etc.
// domain represents in which computer the data is.
// path is where the data is in the computer.
// empty check
if(name.IsEmpty()) return name; // empty name is empty name
// pre-normalize
const tjs_char *pca;//, *pcb, *pcc;
tjs_char *pa, *pb, *pc;
ttstr tmp(name);
TVPPreNormalizeStorageName(tmp);
// unify path delimiter
pa = tmp.Independ();
while(*pa)
{
if(*pa == TJS_W('\\')) *pa = TJS_W('/');
pa++;
}
// save in-archive storage name and normalize it
ttstr inarchive_name;
bool inarc_name_found = false;
pca = tmp.c_str();
pa = const_cast(TJS_strchr(pca, TVPArchiveDelimiter));
if(pa)
{
inarchive_name = ttstr(pa + 1);
tTVPArchive::NormalizeInArchiveStorageName(inarchive_name);
inarc_name_found = true;
tmp = ttstr(pca, (int)(pa - pca));
}
if(tmp.IsEmpty()) TVPThrowExceptionMessage(TVPInvalidPathName, name);
// split the name into media, domain, path
// (and guess what component is omitted)
ttstr media, domain, path;
// - find media name
// media name is: /^[A-Za-z]+:/
pa = pb = tmp.Independ();
while(*pa)
{
if(!(
(*pa >= TJS_W('A') && *pa <= TJS_W('Z')) ||
(*pa >= TJS_W('a') && *pa <= TJS_W('z')) )) break;
pa ++;
}
if(*pa == TJS_W(':'))
{
// media name found
media = ttstr(pb, (int)(pa - pb));
pa ++;
}
else
{
pa = pb;
}
// - find domain name
// at this place, pa may point one of following:
// ///path (domain is omitted)
// //domain/path (none is omitted)
// /path (domain is omitted)
// relative-path (domain and current path are omitted)
if(pa[0] == TJS_W('/'))
{
if(pa[1] == TJS_W('/'))
{
if(pa[2] == TJS_W('/'))
{
// slash count 3: domain is ommited
pa += 2;
}
else
{
// slash count 2: none is omitted
pa += 2;
// find '/' as a domain delimiter
pc = TJS_strchr(pa, TJS_W('/'));
if(!pc)
TVPThrowExceptionMessage(TVPInvalidPathName, name);
domain = ttstr(pa, (int)(pc - pa));
pa = pc;
}
}
else
{
// slash count 1: domain is omitted
;
//
}
}
// - get path name
path = pa;
// supply omitted and normalize
if(media.IsEmpty())
{
media = TVPCurrentMedia;
}
else
{
// normalize media name ( make them all small )
tjs_char *p = media.Independ();
while(*p)
{
if(*p >= TJS_W('A') && *p <= TJS_W('Z'))
*p += (TJS_W('a') - TJS_W('A'));
p ++;
}
}
tMediaRecord * mediarec = GetMediaRecord(media);
if(domain.IsEmpty()) domain = mediarec->CurrentDomain;
mediarec->MediaIntf.GetObjectNoAddRef()->NormalizeDomainName(domain);
if(path.IsEmpty())
{
path = TJS_W("/");
}
else if(path.c_str()[0] != TJS_W('/'))
{
path = mediarec->CurrentPath + path;
}
mediarec->MediaIntf.GetObjectNoAddRef()->NormalizePathName(path);
// compress redudant path accesses
if(inarc_name_found)
{
tjs_char tmp[2];
tmp[0] = TVPArchiveDelimiter;
tmp[1] = 0;
path += tmp + inarchive_name;
}
pa = pb = pc = path.Independ(); // pa = read pointer, pb = write pointer, pc = start
tjs_int dot_count = -1;
while(true)
{
if(*pa == TVPArchiveDelimiter || *pa == TJS_W('/') || *pa == 0)
{
tjs_char delim = 0;
if(*pa && dot_count == 0)
{
// duplicated slashes
pb --;
}
else if(dot_count > 0)
{
pb --;
while(pb >= pc)
{
if(*pb == TJS_W('/') || *pb == TVPArchiveDelimiter)
{
dot_count --;
if(dot_count == 0)
{
delim = *pb;
break;
}
if(*pb == TVPArchiveDelimiter) TVPThrowExceptionMessage(TVPInvalidPathName, name);
}
pb --;
}
if(pb < pc) TVPThrowExceptionMessage(TVPInvalidPathName, name);
}
if(!delim)
*pb = *pa;
else
*pb = delim;
if(*pa == 0) break;
pb ++;
pa ++;
dot_count = 0;
}
else if(*pa == TJS_W('.'))
{
*(pb++) = *(pa++);
if(dot_count != -1) dot_count ++;
}
else
{
*(pb++) = *(pa++);
dot_count = -1;
}
}
path.FixLen();
// merge and return normalize storage name
if(ret_media) *ret_media = media;
if(ret_domain) *ret_domain = domain;
if(ret_path) *ret_path = path;
tmp = media + TJS_W("://") + domain + path;
return tmp;
}
//---------------------------------------------------------------------------
void tTVPStorageMediaManager::SetCurrentDirectory(const ttstr &name)
{
tjs_char ch = name.GetLastChar();
if(ch != TJS_W('/') && ch != TJS_W('\\') && ch != TVPArchiveDelimiter)
TVPThrowExceptionMessage(TVPMissingPathDelimiterAtLast);
ttstr media, domain, path;
NormalizeStorageName(name, &media, &domain, &path);
tMediaRecord *rec = GetMediaRecord(media);
rec->CurrentDomain = domain;
rec->CurrentPath = path;
TVPCurrentMedia = media;
}
//---------------------------------------------------------------------------
ttstr tTVPStorageMediaManager::ExtractMediaName(const ttstr &name)
{
// extract media name from normalized storage named "name".
// returned media name does not contain colon.
const tjs_char * p = name.c_str();
const tjs_char * po = p;
while(*p && *p != TJS_W(':')) p++;
return ttstr(po, (int)(p - po));
}
//---------------------------------------------------------------------------
bool tTVPStorageMediaManager::CheckExistentStorage(const ttstr & name)
{
// gateway for CheckExistentStorage
// name must not be an in-archive storage name
tMediaRecord *rec = GetMediaRecord(name);
return rec->MediaIntf.GetObjectNoAddRef()->CheckExistentStorage(rec->GetDomainAndPath(name));
}
//---------------------------------------------------------------------------
tTJSBinaryStream * tTVPStorageMediaManager::Open(const ttstr & name, tjs_uint32 flags)
{
// gateway for Open
// name must not be an in-archive storage name
tMediaRecord *rec = GetMediaRecord(name);
return rec->MediaIntf.GetObjectNoAddRef()->Open(rec->GetDomainAndPath(name), flags);
}
//---------------------------------------------------------------------------
void tTVPStorageMediaManager::GetListAt(const ttstr &name, iTVPStorageLister * lister)
{
// gateway for GetListAt
// name must not be an in-archive storage name
tMediaRecord *rec = GetMediaRecord(name);
/*return */rec->MediaIntf.GetObjectNoAddRef()->GetListAt(rec->GetDomainAndPath(name), lister);
}
//---------------------------------------------------------------------------
ttstr tTVPStorageMediaManager::GetLocallyAccessibleName(const ttstr &name)
{
// gateway for GetLocallyAccessibleName
// name must not be an in-archive storage name
tMediaRecord *rec = GetMediaRecord(name);
ttstr dname = rec->GetDomainAndPath(name);
rec->MediaIntf.GetObjectNoAddRef()->GetLocallyAccessibleName(dname);
return dname;
}
//---------------------------------------------------------------------------
void TVPGetListAt(const ttstr &name, iTVPStorageLister * lister) {
TVPStorageMediaManager.GetListAt(name, lister);
}
//---------------------------------------------------------------------------
void TVPRegisterStorageMedia(iTVPStorageMedia *media)
{
TVPStorageMediaManager.Register(media);
}
//---------------------------------------------------------------------------
void TVPUnregisterStorageMedia(iTVPStorageMedia *media)
{
TVPStorageMediaManager.Unregister(media);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPNormalizeStorgeName : storage name normalization
//---------------------------------------------------------------------------
ttstr TVPNormalizeStorageName(const ttstr & _name)
// TODO: check what is done in TVPNormalizeStorageName
{
return TVPStorageMediaManager.NormalizeStorageName(_name);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPSetCurrentDirectory
//---------------------------------------------------------------------------
void TVPSetCurrentDirectory(const ttstr & _name)
{
TVPStorageMediaManager.SetCurrentDirectory(_name);
TVPClearStorageCaches();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetLocalName and TVPGetLocallyAccessibleName
//---------------------------------------------------------------------------
void TVPGetLocalName(ttstr &name)
{
ttstr tmp = TVPGetLocallyAccessibleName(name);
if(tmp.IsEmpty()) TVPThrowExceptionMessage(TVPCannotGetLocalName, name);
name = tmp;
}
//---------------------------------------------------------------------------
ttstr TVPGetLocallyAccessibleName(const ttstr &name)
{
if(TJS_strchr(name.c_str(), TVPArchiveDelimiter)) return TJS_W("");
// in-archive storage is always not accessible from local file system
return TVPStorageMediaManager.GetLocallyAccessibleName(name);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPArchive
//---------------------------------------------------------------------------
void tTVPArchive::NormalizeInArchiveStorageName(ttstr & name)
{
// normalization of in-archive storage name does :
if(name.IsEmpty()) return;
// make all characters small
// change '\\' to '/'
tjs_char *ptr = name.Independ();
while(*ptr)
{
if(*ptr >= TJS_W('A') && *ptr <= TJS_W('Z'))
*ptr += TJS_W('a') - TJS_W('A');
else if(*ptr == TJS_W('\\'))
*ptr = TJS_W('/');
ptr++;
}
// eliminate duplicated slashes
ptr = name.Independ();
tjs_char *org_ptr = ptr;
tjs_char *dest = ptr;
while(*ptr)
{
if(*ptr != TJS_W('/'))
{
*dest = *ptr;
ptr ++;
dest ++;
}
else
{
if(ptr != org_ptr)
{
*dest = *ptr;
ptr ++;
dest ++;
}
while(*ptr == TJS_W('/')) ptr++;
}
}
*dest = 0;
name.FixLen();
}
//---------------------------------------------------------------------------
void tTVPArchive::AddToHash()
{
// enter all names to the hash table
tjs_uint Count = GetCount();
tjs_uint i;
for(i = 0; i < Count; i++)
{
ttstr name = GetName(i);
NormalizeInArchiveStorageName(name);
Hash.Add(name, i);
}
}
//---------------------------------------------------------------------------
tTJSBinaryStream * tTVPArchive::CreateStream(const ttstr & name)
{
if(name.IsEmpty()) return NULL;
if(!Init)
{
Init = true;
AddToHash();
}
tjs_uint *p = Hash.Find(name);
if(!p) TVPThrowExceptionMessage(TVPStorageInArchiveNotFound,
name, ArchiveName);
return CreateStreamByIndex(*p);
}
//---------------------------------------------------------------------------
bool tTVPArchive::IsExistent(const ttstr & name)
{
if(name.IsEmpty()) return false;
if(!Init)
{
Init = true;
AddToHash();
}
return Hash.Find(name) != NULL;
}
//---------------------------------------------------------------------------
tjs_int tTVPArchive::GetFirstIndexStartsWith(const ttstr & prefix)
{
// returns first index which have 'prefix' at start of the name.
// returns -1 if the target is not found.
// the item must be sorted by ttstr::operator < , otherwise this function
// will not work propertly.
tjs_uint total_count = GetCount();
tjs_int s = 0, e = total_count;
while(e - s > 1)
{
tjs_int m = (e + s) / 2;
if(!(GetName(m) < prefix))
{
// m is after or at the target
e = m;
}
else
{
// m is before the target
s = m;
}
}
// at this point, s or s+1 should point the target.
// be certain.
if(s >= (tjs_int)total_count) return -1; // out of the index
if(GetName(s).StartsWith(prefix)) return s;
s++;
if(s >= (tjs_int)total_count) return -1; // out of the index
if(GetName(s).StartsWith(prefix)) return s;
return -1;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPArchiveCache
//---------------------------------------------------------------------------
class tTVPArchiveCache
{
typedef tTJSRefHolder tHolder;
tTJSHashCache ArchiveCache;
tTJSCriticalSection CS;
public:
tTVPArchiveCache() : ArchiveCache(TVP_DEFAULT_ARCHIVE_CACHE_NUM)
{
}
~tTVPArchiveCache()
{
}
void SetMaxCount(tjs_int maxcount)
{
ArchiveCache.SetMaxCount(maxcount);
}
void Clear()
{
// releases all elements
ArchiveCache.Clear();
}
tTVPArchive * Get(ttstr name)
{
name = TVPNormalizeStorageName(name);
tTJSCSH csh(CS);
tjs_uint32 hash = tTJSHashCache::MakeHash(name);
tHolder *ptr = ArchiveCache.FindAndTouchWithHash(name, hash);
if(ptr)
{
// exist in the cache
return ptr->GetObject();
}
if(!TVPIsExistentStorageNoSearch(name))
{
// storage not found
TVPThrowExceptionMessage(TVPCannotFindStorage, name);
}
// not exist in the cache
tTVPArchive *arc = TVPOpenArchive(name, true);
tHolder holder(arc);
ArchiveCache.AddWithHash(name, hash, holder);
return arc;
}
private:
} TVPArchiveCache;
static void TVPClearArchiveCache() { TVPArchiveCache.Clear(); }
static tTVPAtExit TVPClearArchiveCacheAtExit
(TVP_ATEXIT_PRI_SHUTDOWN, TVPClearArchiveCache);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPIsExistentStorageNoSearch
//---------------------------------------------------------------------------
bool TVPIsExistentStorageNoSearchNoNormalize(const ttstr &name)
{
// does name contain > ?
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
const tjs_char * sharp_pos = TJS_strchr(name.c_str(), TVPArchiveDelimiter);
if(sharp_pos)
{
// this storagename indicates a file in an archive
ttstr arcname(name, (int)(sharp_pos - name.c_str()));
tTVPArchive *arc;
arc = TVPArchiveCache.Get(arcname);
bool ret;
try
{
ttstr in_arc_name(sharp_pos + 1);
tTVPArchive::NormalizeInArchiveStorageName(in_arc_name);
ret = arc->IsExistent(in_arc_name);
}
catch(...)
{
arc->Release();
throw;
}
arc->Release();
return ret;
}
return TVPStorageMediaManager.CheckExistentStorage(name);
}
//---------------------------------------------------------------------------
bool TVPIsExistentStorageNoSearch(const ttstr &_name)
{
return TVPIsExistentStorageNoSearchNoNormalize(TVPNormalizeStorageName(_name));
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPExtractStorageExt
//---------------------------------------------------------------------------
ttstr TVPExtractStorageExt(const ttstr & name)
{
// extract an extension from name.
// returned string will contain extension delimiter ( '.' ), except for
// missing extension of the input string.
// ( returns null string when input string does not have an extension )
const tjs_char * s = name.c_str();
tjs_int slen = name.GetLen();
const tjs_char * p = s + slen;
p--;
while(p>=s)
{
if(*p == TJS_W('\\')) break;
if(*p == TJS_W('/')) break;
if(*p == TVPArchiveDelimiter) break;
if(*p == TJS_W('.'))
{
// found extension delimiter
tjs_int extlen = (tjs_int)(slen - ( p - s ));
return ttstr(p, extlen);
}
p--;
}
// not found
return ttstr();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPExtractStorageName
//---------------------------------------------------------------------------
ttstr TVPExtractStorageName(const ttstr & name)
{
// extract "name"'s storage name ( excluding path ) and return it.
const tjs_char * s = name.c_str();
tjs_int slen = name.GetLen();
const tjs_char * p = s + slen;
p--;
while(p>=s)
{
if(*p == TJS_W('\\')) break;
if(*p == TJS_W('/')) break;
if(*p == TVPArchiveDelimiter) break;
p--;
}
p++;
if(p == s)
return name;
else
return ttstr(p, (int)(slen - (p -s)));
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPExtractStoragePath
//---------------------------------------------------------------------------
ttstr TVPExtractStoragePath(const ttstr & name)
{
// extract "name"'s path ( including last delimiter ) and return it.
const tjs_char * s = name.c_str();
tjs_int slen = name.GetLen();
const tjs_char * p = s + slen;
p--;
while(p>=s)
{
if(*p == TJS_W('\\')) break;
if(*p == TJS_W('/')) break;
if(*p == TVPArchiveDelimiter) break;
p--;
}
p++;
return ttstr(s, (int)(p-s));
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPChopStorageExt
//---------------------------------------------------------------------------
extern ttstr TVPChopStorageExt(const ttstr & name)
{
// chop storage's extension and return it.
const tjs_char * s = name.c_str();
tjs_int slen = name.GetLen();
const tjs_char * p = s + slen;
p--;
while(p>=s)
{
if(*p == TJS_W('\\')) break;
if(*p == TJS_W('/')) break;
if(*p == TVPArchiveDelimiter) break;
if(*p == TJS_W('.'))
{
// found extension delimiter
return ttstr(s, (int)(p-s));
}
p--;
}
// not found
return name;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Auto search path support
//---------------------------------------------------------------------------
#define TVP_AUTO_PATH_HASH_SIZE 1024
std::vector TVPAutoPathList;
tTJSHashCache TVPAutoPathCache(TVP_DEFAULT_AUTOPATH_CACHE_NUM);
tTJSHashTable, TVP_AUTO_PATH_HASH_SIZE>
TVPAutoPathTable;
bool AutoPathTableInit = false;
//---------------------------------------------------------------------------
static void TVPClearAutoPathCache()
{
TVPAutoPathCache.Clear();
TVPAutoPathTable.Clear();
AutoPathTableInit = false;
}
//---------------------------------------------------------------------------
struct tTVPClearAutoPathCacheCallback : public tTVPCompactEventCallbackIntf
{
virtual void TJS_INTF_METHOD OnCompact(tjs_int level)
{
if(level >= TVP_COMPACT_LEVEL_DEACTIVATE)
{
// clear the auto search path cache on application deactivate
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
TVPClearAutoPathCache();
}
}
} static TVPClearAutoPathCacheCallback;
static bool TVPClearAutoPathCacheCallbackInit = false;
//---------------------------------------------------------------------------
void TVPAddAutoPath(const ttstr & name)
{
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
tjs_char lastchar = name.GetLastChar();
if(lastchar != TVPArchiveDelimiter && lastchar != TJS_W('/') && lastchar != TJS_W('\\'))
TVPThrowExceptionMessage(TVPMissingPathDelimiterAtLast);
ttstr normalized = TVPNormalizeStorageName(name);
std::vector::iterator i =
std::find(TVPAutoPathList.begin(), TVPAutoPathList.end(), normalized);
if(i == TVPAutoPathList.end())
TVPAutoPathList.push_back(normalized);
TVPClearAutoPathCache();
}
//---------------------------------------------------------------------------
void TVPRemoveAutoPath(const ttstr &name)
{
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
tjs_char lastchar = name.GetLastChar();
if(lastchar != TVPArchiveDelimiter && lastchar != TJS_W('/') && lastchar != TJS_W('\\'))
TVPThrowExceptionMessage(TVPMissingPathDelimiterAtLast);
ttstr normalized = TVPNormalizeStorageName(name);
std::vector::iterator i =
std::find(TVPAutoPathList.begin(), TVPAutoPathList.end(), normalized);
if(i != TVPAutoPathList.end())
TVPAutoPathList.erase(i);
TVPClearAutoPathCache();
}
//---------------------------------------------------------------------------
static tjs_uint TVPRebuildAutoPathTable()
{
// rebuild auto path table
if(AutoPathTableInit) return 0;
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
TVPAutoPathTable.Clear();
tjs_uint64 tick = TVPGetTickCount();
TVPAddLog( (const tjs_char*)TVPInfoRebuildingAutoPath );
tjs_uint totalcount = 0;
std::vector::iterator it;
for(it = TVPAutoPathList.begin(); it != TVPAutoPathList.end(); it++)
{
const ttstr & path = *it;
tjs_uint count = 0;
const tjs_char * sharp_pos = TJS_strchr(path.c_str(), TVPArchiveDelimiter);
if(sharp_pos)
{
// this storagename indicates a file in an archive
ttstr arcname(path, (int)(sharp_pos - path.c_str()));
ttstr in_arc_name(sharp_pos + 1);
tTVPArchive::NormalizeInArchiveStorageName(in_arc_name);
tjs_int in_arc_name_len = in_arc_name.GetLen();
tTVPArchive *arc;
arc = TVPArchiveCache.Get(arcname);
try
{
tjs_uint storagecount = arc->GetCount();
// get first index which the item has 'in_arc_name' as its start
// of the string.
tjs_int i = arc->GetFirstIndexStartsWith(in_arc_name);
if(i != -1)
{
for(; i < (tjs_int)storagecount; i++)
{
ttstr name = arc->GetName(i);
if(name.StartsWith(in_arc_name))
{
if(!TJS_strchr(name.c_str() + in_arc_name_len, TJS_W('/')))
{
ttstr sname = TVPExtractStorageName(name);
TVPAutoPathTable.Add(sname, path);
count ++;
}
}
else
{
// no need to check more;
// because the list is sorted by the name.
break;
}
}
}
}
catch(...)
{
arc->Release();
throw;
}
arc->Release();
}
else
{
// normal folder
class tLister : public iTVPStorageLister
{
public:
std::vector list;
void TJS_INTF_METHOD Add(const ttstr &file)
{
list.push_back(file);
}
} lister;
TVPStorageMediaManager.GetListAt(path, &lister);
for(std::vector::iterator i = lister.list.begin();
i != lister.list.end(); i++)
{
TVPAutoPathTable.Add(*i, path);
count ++;
}
}
// TVPAddLog(ttstr(TJS_W("(info) Path ")) + path + TJS_W(" contains ") +
// ttstr((tjs_int)count) + TJS_W(" file(s)."));
totalcount += count;
}
tjs_uint64 endtick = TVPGetTickCount();
TVPAddLog(ttstr(TJS_W("(info) Total ")) +
ttstr((tjs_int)totalcount) + TJS_W(" file(s) found, ") +
ttstr((tjs_int)TVPAutoPathTable.GetCount()) + TJS_W(" file(s) activated.") +
TJS_W(" (") + ttstr((tjs_int)(endtick - tick)) + TJS_W("ms)"));
AutoPathTableInit = true;
return totalcount;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetPlacedPath
//---------------------------------------------------------------------------
ttstr TVPGetPlacedPath(const ttstr & name)
{
// search path and return the path which the "name" is placed.
// returned name is normalized. returns empty string if the storage is not
// found.
#if 0 // needn't
if(!TVPClearAutoPathCacheCallbackInit)
{
TVPAddCompactEventHook(&TVPClearAutoPathCacheCallback);
TVPClearAutoPathCacheCallbackInit = true;
}
#endif
ttstr * incache = TVPAutoPathCache.FindAndTouch(name);
if(incache) return *incache; // found in cache
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
ttstr normalized(TVPNormalizeStorageName(name));
bool found = TVPIsExistentStorageNoSearchNoNormalize(normalized);
if(found)
{
// found in current folder
TVPAutoPathCache.Add(name, normalized);
return normalized;
}
// not found in current folder
// search through auto path table
ttstr storagename = TVPExtractStorageName(normalized);
TVPRebuildAutoPathTable(); // ensure auto path table
ttstr *result = TVPAutoPathTable.Find(storagename);
if(result)
{
// found in table
ttstr found = *result + storagename;
TVPAutoPathCache.Add(name, found);
return found;
}
// not found
// TVPAutoPathCache.Add(name, ttstr()); // do not cache now
return ttstr();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPSearchPlacedPath
//---------------------------------------------------------------------------
ttstr TVPSearchPlacedPath(const ttstr & name)
{
ttstr place = TVPGetPlacedPath(name);
if(place.IsEmpty()) TVPThrowExceptionMessage(TVPCannotFindStorage, name);
return place;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPIsExistentStorage
//---------------------------------------------------------------------------
bool TVPIsExistentStorage(const ttstr &name)
{
return !TVPGetPlacedPath(name).IsEmpty();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCreateStream
//---------------------------------------------------------------------------
static tTJSBinaryStream * _TVPCreateStream(const ttstr & _name, tjs_uint32 flags)
{
tTJSCriticalSectionHolder cs_holder(TVPCreateStreamCS);
ttstr name;
tjs_uint32 access = flags & TJS_BS_ACCESS_MASK;
if(access == TJS_BS_WRITE)
name = TVPNormalizeStorageName(_name);
else
name = TVPGetPlacedPath(_name); // file must exist
if (name.IsEmpty()) {
if (access >= 1) TVPRemoveFromStorageCache(_name);
TVPThrowExceptionMessage(TVPCannotOpenStorage, _name);
}
// does name contain > ?
const tjs_char * sharp_pos = TJS_strchr(name.c_str(), TVPArchiveDelimiter);
if(sharp_pos)
{
// this storagename indicates a file in an archive
if((flags & TJS_BS_ACCESS_MASK ) !=TJS_BS_READ)
TVPThrowExceptionMessage(TVPCannotWriteToArchive);
ttstr arcname(name, (int)(sharp_pos - name.c_str()));
tTVPArchive *arc;
tTJSBinaryStream *stream;
arc = TVPArchiveCache.Get(arcname);
try
{
ttstr in_arc_name(sharp_pos + 1);
tTVPArchive::NormalizeInArchiveStorageName(in_arc_name);
stream = arc->CreateStream(in_arc_name);
}
catch(...)
{
arc->Release();
if(access >= 1) TVPRemoveFromStorageCache(_name);
throw;
}
if(access >= 1) TVPRemoveFromStorageCache(_name);
arc->Release();
return stream;
}
tTJSBinaryStream *stream;
try
{
stream = TVPStorageMediaManager.Open(name, flags);
}
catch(...)
{
if(access >= 1) TVPRemoveFromStorageCache(_name);
throw;
}
if (access >= 1) TVPRemoveFromStorageCache(_name);
return stream;
}
tTJSBinaryStream * TVPCreateStream(const ttstr & _name, tjs_uint32 flags)
{
try
{
return _TVPCreateStream(_name, flags);
}
catch(eTJSScriptException &e)
{
if(TJS_strchr(_name.c_str(), '#'))
e.AppendMessage(TJS_W("[") +
TVPFormatMessage(TVPFilenameContainsSharpWarn, _name) + TJS_W("]"));
throw e;
}
catch(eTJSScriptError &e)
{
if(TJS_strchr(_name.c_str(), '#'))
e.AppendMessage(TJS_W("[") +
TVPFormatMessage(TVPFilenameContainsSharpWarn, _name) + TJS_W("]"));
throw e;
}
catch(eTJSError &e)
{
if(TJS_strchr(_name.c_str(), '#'))
e.AppendMessage(TJS_W("[") +
TVPFormatMessage(TVPFilenameContainsSharpWarn, _name) + TJS_W("]"));
throw e;
}
catch(...)
{
// check whether the filename contains '#' (former delimiter for archive
// filename before 2.19 beta 14)
if(TJS_strchr(_name.c_str(), '#'))
TVPAddLog(TVPFormatMessage(TVPFilenameContainsSharpWarn, _name));
throw;
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPClearStorageCaches
//---------------------------------------------------------------------------
void TVPClearStorageCaches()
{
// clear all storage related caches
TVPClearXP3SegmentCache();
TVPClearAutoPathCache();
}
//---------------------------------------------------------------------------
void TVPRemoveFromStorageCache(const ttstr &name) {
TVPAutoPathCache.Delete(name);
}
//---------------------------------------------------------------------------
// tTJSNC_Storages
//---------------------------------------------------------------------------
tjs_uint32 tTJSNC_Storages::ClassID = -1;
tTJSNC_Storages::tTJSNC_Storages() : inherited(TJS_W("Storages"))
{
// registration of native members
TJS_BEGIN_NATIVE_MEMBERS(Storages)
TJS_DECL_EMPTY_FINALIZE_METHOD
//----------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/addAutoPath)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
TVPAddAutoPath(path);
if(result) result->Clear();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/addAutoPath)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/removeAutoPath)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
TVPRemoveAutoPath(path);
if(result) result->Clear();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/removeAutoPath)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/getFullPath)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = TVPNormalizeStorageName(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/getFullPath)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/getPlacedPath)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = TVPGetPlacedPath(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/getPlacedPath)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/isExistentStorage)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = (tjs_int)TVPIsExistentStorage(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/isExistentStorage)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/extractStorageExt)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = TVPExtractStorageExt(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/extractStorageExt)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/extractStorageName)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = TVPExtractStorageName(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/extractStorageName)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/extractStoragePath)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = TVPExtractStoragePath(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/extractStoragePath)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/chopStorageExt)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr path = *param[0];
if(result)
*result = TVPChopStorageExt(path);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/chopStorageExt)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/clearArchiveCache)
{
TVPClearArchiveCache();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/clearArchiveCache)
//----------------------------------------------------------------------
TJS_END_NATIVE_MEMBERS
}
//---------------------------------------------------------------------------
tTJSNativeInstance * tTJSNC_Storages::CreateNativeInstance()
{
// this class cannot create an instance
TVPThrowExceptionMessage(TVPCannotCreateInstance);
return NULL;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/StorageIntf.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#ifndef StorageIntfH
#define StorageIntfH
#include "tjsNative.h"
#include "tjsHashSearch.h"
#include
//---------------------------------------------------------------------------
// archive delimiter
//---------------------------------------------------------------------------
extern tjs_char TVPArchiveDelimiter; // = '>';
//---------------------------------------------------------------------------
// utilities
//---------------------------------------------------------------------------
ttstr TVPStringFromBMPUnicode(const tjs_uint16 *src, tjs_int maxlen = -1);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPArchive base archive class
//---------------------------------------------------------------------------
class tTVPArchive
{
private:
tjs_uint RefCount;
public:
//-- constructor
tTVPArchive(const ttstr & name)
{ ArchiveName = name; Init = false; RefCount = 1; }
virtual ~tTVPArchive() { ; }
//-- AddRef and Release
void AddRef() { RefCount++; }
void Release() { if(RefCount == 1) delete this; else RefCount--; }
//-- must be implemented by delivered class
virtual tjs_uint GetCount() = 0;
virtual ttstr GetName(tjs_uint idx) = 0;
// returned name must be already normalized using NormalizeInArchiveStorageName
// and the index must be sorted by its name, using ttstr::operator < .
// this is needed by fast directory search.
virtual tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx) = 0;
//-- others, implemented in this class
private:
tTJSHashTable, 1024> Hash;
bool Init;
public:
ttstr ArchiveName;
public:
static void NormalizeInArchiveStorageName(ttstr & name);
private:
void AddToHash();
public:
tTJSBinaryStream * CreateStream(const ttstr & name);
bool IsExistent(const ttstr & name);
tjs_int GetFirstIndexStartsWith(const ttstr & prefix);
// returns first index which have 'prefix' at start of the name.
};
//---------------------------------------------------------------------------
/*[*/
//---------------------------------------------------------------------------
// iTVPStorageMedia
//---------------------------------------------------------------------------
/*
abstract class for managing media ( like file: http: etc.)
*/
/*]*/
#if 0
/*[*/
// for plug-in
class tTJSBinaryStream;
/*]*/
#endif
/*[*/
//---------------------------------------------------------------------------
class iTVPStorageLister // callback class for GetListAt
{
public:
virtual void TJS_INTF_METHOD Add(const ttstr &file) = 0;
};
//---------------------------------------------------------------------------
class iTVPStorageMedia
{
public:
virtual ~iTVPStorageMedia() {} // add by ZeaS
virtual void TJS_INTF_METHOD AddRef() = 0;
virtual void TJS_INTF_METHOD Release() = 0;
virtual void TJS_INTF_METHOD GetName(ttstr &name) = 0;
// returns media name like "file", "http" etc.
// virtual bool TJS_INTF_METHOD IsCaseSensitive() = 0;
// returns whether this media is case sensitive or not
virtual void TJS_INTF_METHOD NormalizeDomainName(ttstr &name) = 0;
// normalize domain name according with the media's rule
virtual void TJS_INTF_METHOD NormalizePathName(ttstr &name) = 0;
// normalize path name according with the media's rule
// "name" below is normalized but does not contain media, eg.
// not "media://domain/path" but "domain/path"
virtual bool TJS_INTF_METHOD CheckExistentStorage(const ttstr &name) = 0;
// check file existence
virtual tTJSBinaryStream * TJS_INTF_METHOD Open(const ttstr & name, tjs_uint32 flags) = 0;
// open a storage and return a tTJSBinaryStream instance.
// name does not contain in-archive storage name but
// is normalized.
virtual void TJS_INTF_METHOD GetListAt(const ttstr &name, iTVPStorageLister * lister) = 0;
// list files at given place
virtual void TJS_INTF_METHOD GetLocallyAccessibleName(ttstr &name) = 0;
// basically the same as above,
// check wether given name is easily accessible from local OS filesystem.
// if true, returns local OS native name. otherwise returns an empty string.
};
//---------------------------------------------------------------------------
/*]*/
//---------------------------------------------------------------------------
// must be implemented in each platform
//---------------------------------------------------------------------------
extern tTVPArchive * TVPOpenArchive(const ttstr & name, bool normalizeFileName);
// open archive and return tTVPArchive instance.
TJS_EXP_FUNC_DEF(ttstr, TVPGetTemporaryName, ());
// retrieve file name to store temporary data ( must be unique, local name )
TJS_EXP_FUNC_DEF(ttstr, TVPGetAppPath, ());
// retrieve program path, in normalized storage name
void TVPPreNormalizeStorageName(ttstr &name);
// called by TVPNormalizeStorageName before it process the storage name.
// user may pass the OS's native filename to the TVP storage system,
// so that this function must convert it to the TVP storage name rules.
iTVPStorageMedia * TVPCreateFileMedia();
// create basic default "file:" storage media
/*
extern void TVPPreNormalizeStorageName(ttstr &name);
extern tTJSBinaryStream * TVPOpenStream(const ttstr & name, tjs_uint32 flags);
// open a storage and return a tTJSBinaryStream instance.
// name does not contain in-archive storage name but
// is normalized.
extern bool TVPCheckExistentStorage(const ttstr &name);
// check file existence
extern void TVPGetStorageListAt(const ttstr &name, std::vector & list);
extern ttstr TVPGetMediaCurrent(const ttstr & name);
extern void TVPSetMediaCurrent(const ttstr & name, const ttstr & dir);
extern ttstr TVPGetNativeName(const ttstr &name);
// retrieve OS native name
extern ttstr TVPGetLocallyAccessibleName(const ttstr &name);
// check wether given name is easily accessible from local OS filesystem.
// if true, returns local OS native name. otherwise returns an empty string.
*/
extern bool TVPRemoveFile(const ttstr &name);
// remove local file ( "name" is a local *native* name )
// this must not throw an exception ( return false if error )
extern bool TVPRemoveFolder(const ttstr &name);
// remove local directory ( "name" is a local *native* name )
// this must not throw an exception ( return false if error )
bool TVPCreateFolders(const ttstr &folder);
// create folder along with the argument recursively (like mkdir -p).
// 'folder' must be a local native name.
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// implementation in this unit
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(void, TVPRegisterStorageMedia, (iTVPStorageMedia *media));
// register storage media
TJS_EXP_FUNC_DEF(void, TVPUnregisterStorageMedia, (iTVPStorageMedia *media));
// remove storage media
extern tTJSBinaryStream * TVPCreateStream(const ttstr & name, tjs_uint32 flags = 0);
// open "name" and return tTJSBinaryStream instance.
// name will be local storage, network storage, in-archive storage, etc...
TJS_EXP_FUNC_DEF(bool, TVPIsExistentStorageNoSearch, (const ttstr &name));
// if "name" is exists, return true. otherwise return false.
// this does not search any auto search path.
TJS_EXP_FUNC_DEF(bool, TVPIsExistentStorageNoSearchNoNormalize, (const ttstr &name));
TJS_EXP_FUNC_DEF(ttstr, TVPNormalizeStorageName, (const ttstr & name));
TJS_EXP_FUNC_DEF(void, TVPSetCurrentDirectory, (const ttstr & name));
// set system current directory.
// directory must end with path delimiter '/',
// or archive delimiter '>'.
TJS_EXP_FUNC_DEF(void, TVPGetLocalName, (ttstr &name));
ttstr TVPGetLocallyAccessibleName(const ttstr &name);
TJS_EXP_FUNC_DEF(ttstr, TVPExtractStorageExt, (const ttstr & name));
// extract "name"'s extension and return it.
TJS_EXP_FUNC_DEF(ttstr, TVPExtractStorageName, (const ttstr & name));
// extract "name"'s storage name ( excluding path ) and return it.
TJS_EXP_FUNC_DEF(ttstr, TVPExtractStoragePath, (const ttstr & name));
// extract "name"'s path ( including last delimiter ) and return it.
TJS_EXP_FUNC_DEF(ttstr, TVPChopStorageExt, (const ttstr & name));
// chop storage's extension and return it.
// extensition delimiter '.' will not be held.
TJS_EXP_FUNC_DEF(void, TVPAddAutoPath, (const ttstr & name));
// add given path to auto search path
TJS_EXP_FUNC_DEF(void, TVPRemoveAutoPath, (const ttstr &name));
// remove given path from auto search path
TJS_EXP_FUNC_DEF(ttstr, TVPGetPlacedPath, (const ttstr & name));
// search path and return the path which the "name" is placed.
extern ttstr TVPSearchPlacedPath(const ttstr & name);
// the same as TVPGetPlacedPath, except for rising exception when the storage
// is not found.
TJS_EXP_FUNC_DEF(bool, TVPIsExistentStorage, (const ttstr &name));
// if "name" is exists, return true. otherwise return false.
// this searches auto search path.
TJS_EXP_FUNC_DEF(void, TVPClearStorageCaches, ());
// clear all internal storage related caches.
void TVPRemoveFromStorageCache(const ttstr &name);
extern tjs_uint TVPSegmentCacheLimit; // XP3 segment cache limit, in bytes.
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNC_Storages : TJS Storages class
//---------------------------------------------------------------------------
class tTJSNC_Storages : public tTJSNativeClass
{
typedef tTJSNativeClass inherited;
public:
tTJSNC_Storages();
static tjs_uint32 ClassID;
protected:
tTJSNativeInstance *CreateNativeInstance();
};
//---------------------------------------------------------------------------
extern tTJSNativeClass * TVPCreateNativeClass_Storages();
//---------------------------------------------------------------------------
class tTVPStorageMedia : public iTVPStorageMedia {
protected:
tjs_int refCount;
tTVPStorageMedia() : refCount(1) {}
virtual void TJS_INTF_METHOD AddRef() override { refCount++; }
virtual void TJS_INTF_METHOD Release() override {
if (refCount == 1) {
delete this;
} else {
refCount--;
}
}
virtual void TJS_INTF_METHOD NormalizeDomainName(ttstr &name) override {}
virtual void TJS_INTF_METHOD NormalizePathName(ttstr &name) override {}
virtual void TJS_INTF_METHOD GetLocallyAccessibleName(ttstr &name) override {}
};
class TArchiveStream : public tTJSBinaryStream {
tTVPArchive *Owner;
tjs_int64 CurrentPos;
tjs_uint64 StartPos, DataLength;
tTJSBinaryStream *_instr;
public:
TArchiveStream(tTVPArchive *owner, tjs_uint64 off, tjs_uint64 len);
virtual ~TArchiveStream();
virtual tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence) {
switch (whence) {
case TJS_BS_SEEK_SET:
CurrentPos = offset;
break;
case TJS_BS_SEEK_CUR:
CurrentPos = offset + CurrentPos;
break;
case TJS_BS_SEEK_END:
CurrentPos = offset + DataLength;
break;
}
if (CurrentPos < 0) CurrentPos = 0;
else if (CurrentPos > (tjs_int64)DataLength) CurrentPos = DataLength;
_instr->SetPosition(CurrentPos + StartPos);
return CurrentPos;
}
virtual tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size) {
if (CurrentPos + read_size >= (tjs_int64)DataLength) {
read_size = (tjs_uint)(DataLength - CurrentPos);
}
_instr->ReadBuffer(buffer, read_size);
CurrentPos += read_size;
return read_size;
}
virtual tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size) {
return 0;
}
virtual tjs_uint64 TJS_INTF_METHOD GetSize() {
return DataLength;
}
};
#endif
================================================
FILE: src/core/base/SysInitIntf.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// System Initialization and Uninitialization
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include
#include
#include "tjsUtils.h"
#include "SysInitIntf.h"
#include "ScriptMgnIntf.h"
#include "tvpgl.h"
// #include "Protect.h"
//---------------------------------------------------------------------------
// global data
//---------------------------------------------------------------------------
ttstr TVPProjectDir; // project directory (in unified storage name)
ttstr TVPDataPath; // data directory (in unified storage name)
//---------------------------------------------------------------------------
extern void TVPGL_C_Init();
//---------------------------------------------------------------------------
// TVPSystemInit : Entire System Initialization
//---------------------------------------------------------------------------
void TVPSystemInit(void)
{
#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32
#ifndef CC_TARGET_OS_IPHONE
if (!TVPProtectInit()) return;
#endif
//#else
#ifdef USING_PROTECT
while (!TVPProtectInit()) {
TVPUpdateLicense();
}
#endif
#endif
TVPBeforeSystemInit();
TVPInitScriptEngine();
TVPInitTVPGL();
// TVPGL_C_Init();
TVPAfterSystemInit();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPSystemUninit : System shutdown, cleanup, etc...
//---------------------------------------------------------------------------
static void TVPCauseAtExit();
bool TVPSystemUninitCalled = false;
void TVPSystemUninit(void)
{
if(TVPSystemUninitCalled) return;
TVPSystemUninitCalled = true;
TVPBeforeSystemUninit();
TVPUninitTVPGL();
try
{
TVPUninitScriptEngine();
}
catch(...)
{
// ignore errors
}
TVPAfterSystemUninit();
TVPCauseAtExit();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPAddAtExitHandler related
//---------------------------------------------------------------------------
struct tTVPAtExitInfo
{
tTVPAtExitInfo(tjs_int pri, void(*handler)())
{
Priority = pri, Handler = handler;
}
tjs_int Priority;
void (*Handler)();
bool operator <(const tTVPAtExitInfo & r) const
{ return this->Priority < r.Priority; }
bool operator >(const tTVPAtExitInfo & r) const
{ return this->Priority > r.Priority; }
bool operator ==(const tTVPAtExitInfo & r) const
{ return this->Priority == r.Priority; }
};
static std::vector *TVPAtExitInfos = NULL;
static bool TVPAtExitShutdown = false;
//---------------------------------------------------------------------------
void TVPAddAtExitHandler(tjs_int pri, void (*handler)())
{
if(TVPAtExitShutdown) return;
if(!TVPAtExitInfos) TVPAtExitInfos = new std::vector();
TVPAtExitInfos->push_back(tTVPAtExitInfo(pri, handler));
}
//---------------------------------------------------------------------------
static void TVPCauseAtExit()
{
if(TVPAtExitShutdown) return;
TVPAtExitShutdown = true;
std::sort(TVPAtExitInfos->begin(), TVPAtExitInfos->end()); // descending sort
std::vector::iterator i;
for(i = TVPAtExitInfos->begin(); i!=TVPAtExitInfos->end(); i++)
{
i->Handler();
}
delete TVPAtExitInfos;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/SysInitIntf.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// System Initialization and Uninitialization
//---------------------------------------------------------------------------
#ifndef SysInitIntfH
#define SysInitIntfH
//---------------------------------------------------------------------------
// System initialization and uninitialization
//---------------------------------------------------------------------------
//-- global data
extern ttstr TVPProjectDir; // project directory
extern ttstr TVPDataPath; // data directory
//-- implementation in this unit
extern void TVPSystemInit(void);
extern void TVPSystemUninit(void);
//-- implement in each platform
extern void TVPBeforeSystemInit(); // this must set TVPProjectDir
extern void TVPAfterSystemInit();
extern void TVPBeforeSystemUninit();
extern void TVPAfterSystemUninit();
extern void TVPTerminateAsync(int code=0); // do acynchronous teminating of application
extern void TVPTerminateSync(int code=0); // do synchronous teminating of application(never return)
extern void TVPMainWindowClosed(); // called from WindowIntf.cpp, caused by closing main window.
// this function must shutdown the application, unless the controller window is visible.
//---------------------------------------------------------------------------
extern bool TVPSystemUninitCalled;
// whether TVPSystemUninit is called or not
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// AtExit related
//---------------------------------------------------------------------------
void TVPAddAtExitHandler(tjs_int pri, void (*handler)());
struct tTVPAtExit
{
tTVPAtExit(tjs_int pri, void (*handler)())
{
TVPAddAtExitHandler(pri, handler);
}
};
#define TVP_ATEXIT_PRI_PREPARE 10
#define TVP_ATEXIT_PRI_SHUTDOWN 100
#define TVP_ATEXIT_PRI_RELEASE 1000
#define TVP_ATEXIT_PRI_CLEANUP 10000
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Command line parameter operations (implement in each platform)
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(bool, TVPGetCommandLine, (const tjs_char * name, tTJSVariant *value = NULL));
// retrieves command line parameter named "name".
// command line parameter format must be "-name=value"
// returns false if the the parameter is not exist, otherwise
// sets the value to "value" and returns true.
TJS_EXP_FUNC_DEF(tjs_int, TVPGetCommandLineArgumentGeneration, ());
// retrieves command line argument generation count. you can check
// whether the command line options has changed, by comparing this value
// to your value which is remembered when of previous call of this.
TJS_EXP_FUNC_DEF(void, TVPSetCommandLine, (const tjs_char * name, const ttstr & value));
// sets command line to the specified value.
// note that this function does not check any consistency or correctness of the value.
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/SystemIntf.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// "System" class interface
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "tjsMessage.h"
#include "SystemIntf.h"
#include "SysInitIntf.h"
#include "SysInitImpl.h"
#include "MsgIntf.h"
#include "GraphicsLoaderIntf.h"
#include "EventIntf.h"
#include "LayerIntf.h"
#include "LayerBitmapIntf.h"
#include "Random.h"
#include "ScriptMgnIntf.h"
#include "DebugIntf.h"
#include "ConfigManager/LocaleConfigManager.h"
#include "Platform.h"
extern bool TVPStartupSuccess;
//---------------------------------------------------------------------------
// TVPFireOnApplicationActivateEvent
//---------------------------------------------------------------------------
void TVPFireOnApplicationActivateEvent(bool activate_or_deactivate)
{
// get the script engine
tTJS *engine = TVPGetScriptEngine();
if(!engine)
return; // the script engine had been shutdown
// get System.onActivate or System.onDeactivate
// and call it.
iTJSDispatch2 * global = TVPGetScriptEngine()->GetGlobalNoAddRef();
if(!global) return;
tTJSVariant val;
tTJSVariant val2;
tTJSVariantClosure clo;
tTJSVariantClosure func;
try
{
tjs_error er;
er = global->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("System"), NULL, &val, global);
if(TJS_FAILED(er)) return;
if(val.Type() != tvtObject) return;
clo = val.AsObjectClosureNoAddRef();
if(clo.Object == NULL) return;
clo.PropGet(TJS_MEMBERMUSTEXIST,
activate_or_deactivate?
TJS_W("onActivate"):
TJS_W("onDeactivate"),
NULL, &val2, NULL);
if(val2.Type() != tvtObject) return;
func = val2.AsObjectClosureNoAddRef();
}
catch(const eTJS &e)
{
// the system should not throw exceptions during retrieving the function
TVPAddLog( TVPFormatMessage( TVPErrorInRetrievingSystemOnActivateOnDeactivate, e.GetMessage() ) );
return;
}
if(func.Object != NULL) func.FuncCall(0, NULL, NULL, NULL, 0, NULL, NULL);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTJSNC_System
//---------------------------------------------------------------------------
tjs_uint32 tTJSNC_System::ClassID = -1;
tTJSNC_System::tTJSNC_System() : inherited(TJS_W("System"))
{
// registration of native members
TJS_BEGIN_NATIVE_MEMBERS(System)
TJS_DECL_EMPTY_FINALIZE_METHOD
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_CONSTRUCTOR_DECL_NO_INSTANCE(/*TJS class name*/System)
{
return TJS_S_OK;
}
TJS_END_NATIVE_CONSTRUCTOR_DECL(/*TJS class name*/System)
//----------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/terminate)
{
int code = numparams > 0 ? param[0]->AsInteger() : 0;
if (!TVPStartupSuccess) {
;
} else {
TVPTerminateAsync(code);
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/terminate)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/exit)
{
// this method does not return
int code = numparams > 0 ? param[0]->AsInteger() : 0;
if (!TVPStartupSuccess) {
;
} else {
TVPTerminateSync(code);
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/exit)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/inputString)
{
if(numparams < 3) return TJS_E_BADPARAMCOUNT;
ttstr value = *param[2];
// bool b = TVPInputQuery(*param[0], *param[1], value);
ttstr caption = *param[0], prompt = *param[1];
// this shows a dialog box which let user to input a string.
// return false if the user selects "cancel", otherwise return true.
// implement in each platform.
std::vector btns;
btns.emplace_back(LocaleConfigManager::GetInstance()->GetText("msgbox_ok"));
btns.emplace_back(LocaleConfigManager::GetInstance()->GetText("cancel"));
int ret = TVPShowSimpleInputBox(value, caption, prompt, btns);
bool b = ret == 0; // the left button clicked
if(result)
{
if(b)
*result = value;
else
result->Clear();
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/inputString)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/addContinuousHandler)
{
// add function to continus handler list
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
tTJSVariantClosure clo = param[0]->AsObjectClosureNoAddRef();
TVPAddContinuousHandler(clo);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/addContinuousHandler)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/removeContinuousHandler)
{
// remove function from continuous handler list
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
tTJSVariantClosure clo = param[0]->AsObjectClosureNoAddRef();
TVPRemoveContinuousHandler(clo);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/removeContinuousHandler)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/toActualColor)
{
// convert color codes to 0xRRGGBB format.
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
if(result)
{
tjs_uint32 color = (tjs_int)(*param[0]);
color = TVPToActualColor(color);
*result = (tjs_int)color;
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/toActualColor)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/clearGraphicCache)
{
// clear graphic cache
TVPClearGraphicCache();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/clearGraphicCache)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/touchImages)
{
// try to cache graphics
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
std::vector storages;
tTJSVariantClosure array = param[0]->AsObjectClosureNoAddRef();
tjs_int count = 0;
while(true)
{
tTJSVariant val;
if(TJS_FAILED(array.Object->PropGetByNum(0, count, &val, array.ObjThis)))
break;
if(val.Type() == tvtVoid) break;
storages.push_back(ttstr(val));
count++;
}
tjs_int64 limit = 0;
tjs_uint64 timeout = 0;
if(numparams >= 2 && param[1]->Type() != tvtVoid) limit = (tjs_int64)*param[1];
if(numparams >= 3 && param[2]->Type() != tvtVoid) timeout = (tjs_int64)*param[2];
TVPTouchImages(storages, limit, timeout);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/touchImages)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/createUUID)
{
// create UUID
// return UUID string in form of "43abda37-c597-4646-a279-c27a1373af90"
tjs_uint8 uuid[16];
TVPGetRandomBits128(uuid);
uuid[8] &= 0x3f;
uuid[8] |= 0x80; // override clock_seq
uuid[6] &= 0x0f;
uuid[6] |= 0x40; // override version
tjs_char buf[40];
TJS_snprintf(buf, sizeof(buf)/sizeof(tjs_char),
TJS_W("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"),
uuid[ 0], uuid[ 1], uuid[ 2], uuid[ 3],
uuid[ 4], uuid[ 5], uuid[ 6], uuid[ 7],
uuid[ 8], uuid[ 9], uuid[10], uuid[11],
uuid[12], uuid[13], uuid[14], uuid[15]);
if(result) *result = tTJSVariant(buf);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/createUUID)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/assignMessage)
{
// assign system message
if(numparams < 2) return TJS_E_BADPARAMCOUNT;
ttstr id(*param[0]);
ttstr msg(*param[1]);
bool res = TJSAssignMessage(id.c_str(), msg.c_str());
if(result) *result = tTJSVariant((tjs_int)res);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/assignMessage)
//---------------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/doCompact)
{
// compact memory usage
tjs_int level = TVP_COMPACT_LEVEL_MAX;
if(numparams >= 1 && param[0]->Type() != tvtVoid)
level = (tjs_int)*param[0];
TVPDeliverCompactEvent(level);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL(/*func. name*/doCompact)
//----------------------------------------------------------------------
//--properties
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(versionString)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetVersionString();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(versionString)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(versionInformation)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetVersionInformation();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(versionInformation)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(eventDisabled)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetSystemEventDisabledState();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TVPSetSystemEventDisabledState(param->operator bool());
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(eventDisabled)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(graphicCacheLimit)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = (tjs_int)TVPGetGraphicCacheLimit();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TVPSetGraphicCacheLimit((tjs_int)*param);
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(graphicCacheLimit)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(platformName)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetPlatformName();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(platformName)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(osName)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetOSName();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(osName)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(exitOnWindowClose)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPTerminateOnWindowClose;
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TVPTerminateOnWindowClose = 0!=(tjs_int)*param;
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(exitOnWindowClose)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(drawThreadNum)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPDrawThreadNum;
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TVPDrawThreadNum = (tjs_int)*param;
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(drawThreadNum)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(processorNum)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetProcessorNum();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(processorNum)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(exeBits)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
#ifdef TJS_64BIT_OS
*result = 64;
#else
*result = 32;
#endif
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(exeBits)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(osBits)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPGetOSBits();
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_DENY_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(osBits)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_PROP_DECL(exitOnNoWindowStartup)
{
TJS_BEGIN_NATIVE_PROP_GETTER
{
*result = TVPTerminateOnNoWindowStartup;
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_GETTER
TJS_BEGIN_NATIVE_PROP_SETTER
{
TVPTerminateOnNoWindowStartup = 0!=(tjs_int)*param;
return TJS_S_OK;
}
TJS_END_NATIVE_PROP_SETTER
}
TJS_END_NATIVE_STATIC_PROP_DECL(exitOnNoWindowStartup)
//----------------------------------------------------------------------
TJS_END_NATIVE_MEMBERS
// register default "exceptionHandler" member
tTJSVariant val((iTJSDispatch2*)NULL, (iTJSDispatch2*)NULL);
PropSet(TJS_MEMBERENSURE, TJS_W("exceptionHandler"), NULL, &val, this);
// and onActivate, onDeactivate
PropSet(TJS_MEMBERENSURE, TJS_W("onActivate"), NULL, &val, this);
PropSet(TJS_MEMBERENSURE, TJS_W("onDeactivate"), NULL, &val, this);
}
//---------------------------------------------------------------------------
tTJSNativeInstance * tTJSNC_System::CreateNativeInstance()
{
// this class cannot create an instance
TVPThrowExceptionMessage(TVPCannotCreateInstance);
return NULL;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/SystemIntf.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// "System" class interface
//---------------------------------------------------------------------------
#ifndef SystemIntfH
#define SystemIntfH
#include "tjsNative.h"
//---------------------------------------------------------------------------
// tTJSNC_System : TJS System class
//---------------------------------------------------------------------------
class tTJSNC_System : public tTJSNativeClass
{
typedef tTJSNativeClass inherited;
public:
tTJSNC_System();
static tjs_uint32 ClassID;
protected:
tTJSNativeInstance *CreateNativeInstance();
};
//---------------------------------------------------------------------------
extern tTJSNativeClass * TVPCreateNativeClass_System();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(ttstr, TVPGetPlatformName, ());
// retrieve platform name (eg. "Win32")
// implement in each platform.
TJS_EXP_FUNC_DEF(ttstr, TVPGetOSName, ());
// retrieve OS name
// implement in each platform.
extern void TVPFireOnApplicationActivateEvent(bool activate_or_deactivate);
extern tjs_int TVPGetOSBits();
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/TARArchive.cpp
================================================
#include "tjsCommHead.h"
#include "StorageIntf.h"
#include "UtilStreams.h"
#include "Platform.h"
#include "MsgIntf.h"
#include
void TVPFreeArchiveHandlePoolByPointer(void * pointer);
void TVPReleaseCachedArchiveHandle(void * pointer, tTJSBinaryStream * stream);
void storeFilename(ttstr &name, const char *narrowName, const ttstr &filename)
{
tjs_int len = TJS_narrowtowidelen(narrowName);
if (len == -1) {
ttstr msg("Filename is not encoded in UTF8 in archive:\n");
TVPShowSimpleMessageBox(msg + filename, TJS_W("Error"));
TVPThrowExceptionMessage(TJS_W("Invalid archive entry name"));
}
tjs_char *p = name.AllocBuffer(len);
p[TJS_narrowtowide(p, narrowName, len)] = 0;
name.FixLen();
}
//---------------------------------------------------------------------------
// tar archive
//---------------------------------------------------------------------------
tjs_uint64 parseOctNum(const char *oct, int length)
{
tjs_uint64 num = 0;
for (int i = 0; i < length; i++){
char c = oct[i];
if ('0' <= c && c <= '9'){
num = num * 8 + (c - '0');
}
}
return num;
}
#include "tar.h"
class TARArchive : public tTVPArchive {
struct EntryInfo {
ttstr filename;
tjs_uint64 offset;
tjs_uint64 size;
};
std::vector filelist;
friend class TARArchiveStream;
public:
TARArchive(const ttstr & arcname) : tTVPArchive(arcname) {
}
~TARArchive() {
TVPFreeArchiveHandlePoolByPointer(this);
}
bool init(tTJSBinaryStream * _instr, bool normalizeFileName) {
if (_instr) {
tjs_uint64 archiveSize = _instr->GetSize();
TAR_HEADER tar_header;
// check first header
if (_instr->Read(&tar_header, sizeof(tar_header)) != sizeof(tar_header)) {
//delete _instr;
return false;
}
unsigned int checksum = parseOctNum(tar_header.dbuf.chksum, sizeof(tar_header.dbuf.chksum));
if (checksum != tar_header.compsum() && (int)checksum != tar_header.compsum_oldtar()) {
//delete _instr;
return false;
}
_instr->SetPosition(0);
while (_instr->GetPosition() <= archiveSize - sizeof(tar_header)) {
if (_instr->Read(&tar_header, sizeof(tar_header)) != sizeof(tar_header)) break;
tjs_uint64 original_size = parseOctNum(tar_header.dbuf.size, sizeof(tar_header.dbuf.size));
std::vector filename;
if (tar_header.dbuf.typeflag == LONGLINK) { // tar_header.dbuf.name == "././@LongLink"
unsigned int readsize = (original_size + (TBLOCK - 1)) & ~(TBLOCK - 1);
filename.resize(readsize + 1); //TODO:size lost
if (_instr->Read(&filename[0], readsize) != readsize) break;
filename[readsize] = 0;
if (_instr->Read(&tar_header, sizeof(tar_header)) != sizeof(tar_header)) break;
original_size = parseOctNum(tar_header.dbuf.size, sizeof(tar_header.dbuf.size));
}
if (tar_header.dbuf.typeflag != REGTYPE) continue; // only accept regular file
if (filename.empty()) {
filename.resize(101);
memcpy(&filename[0], tar_header.dbuf.name, sizeof(tar_header.dbuf.name));
filename[100] = 0;
}
EntryInfo item;
storeFilename(item.filename, &filename[0], ArchiveName);
if (normalizeFileName)
NormalizeInArchiveStorageName(item.filename);
item.size = original_size;
item.offset = _instr->GetPosition();
filelist.emplace_back(item);
tjs_uint64 readsize = (original_size + (TBLOCK - 1)) & ~(TBLOCK - 1);
_instr->SetPosition(item.offset + readsize);
}
if (normalizeFileName) {
std::sort(filelist.begin(), filelist.end(), [](const EntryInfo& a, const EntryInfo& b) {
return a.filename < b.filename;
});
}
TVPReleaseCachedArchiveHandle(this, _instr);
return true;
}
return false;
}
virtual tjs_uint GetCount() { return filelist.size(); }
virtual ttstr GetName(tjs_uint idx) { return filelist[idx].filename; }
virtual tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx);
};
tTJSBinaryStream * TARArchive::CreateStreamByIndex(tjs_uint idx) {
const EntryInfo &info = filelist[idx];
return new TArchiveStream(this, info.offset, info.size);
}
tTVPArchive * TVPOpenTARArchive(const ttstr & name, tTJSBinaryStream * st, bool normalizeFileName) {
TARArchive *arc = new TARArchive(name);
if (!arc->init(st, normalizeFileName)) {
delete arc;
return nullptr;
}
return arc;
}
================================================
FILE: src/core/base/TextStream.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Text read/write stream
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include "TextStream.h"
#include "MsgIntf.h"
#include "DebugIntf.h"
#include "EventIntf.h"
#include "UtilStreams.h"
#include "tjsError.h"
#include "CharacterSet.h"
extern "C" int sjis_mbtowc(unsigned short *wc, const unsigned char *s);
extern "C" int gbk_mbtowc(unsigned short *wc, const unsigned char *s);
int utf8_mbtowc(unsigned short *pwc, const unsigned char *s) {
unsigned char c = s[0];
if (c < 0x80) {
*pwc = c;
return 1;
} else if (c < 0xc2) {
return -1;
} else if (c < 0xe0) {
if (!((s[1] ^ 0x80) < 0x40))
return -1;
*pwc = ((unsigned short)(c & 0x1f) << 6)
| (unsigned short)(s[1] ^ 0x80);
return 2;
} else if (c < 0xf0) {
if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || s[1] >= 0xa0)))
return -1;
*pwc = ((unsigned short)(c & 0x0f) << 12)
| ((unsigned short)(s[1] ^ 0x80) << 6)
| (unsigned short)(s[2] ^ 0x80);
return 3;
} else
return -1;
}
int(*mbtowc_for_text_stream)(unsigned short *wc, const unsigned char *s) = nullptr;
static size_t _TextStream_mbstowcs(int(*func_mbtowc)(unsigned short *, const unsigned char *), tjs_char *pwcs, const tjs_nchar *s, size_t n)
{
if(!s) return -1;
if(pwcs && n == 0) return 0;
size_t count = 0;
int cl;
if(!pwcs) {
while(*s) {
unsigned short wc;
cl = func_mbtowc(&wc, (const unsigned char*)s);
if(cl <= 0)
return -1;
s += cl;
++count;
}
} else {
while(*s && n > 0) {
cl = func_mbtowc((unsigned short *)pwcs, (const unsigned char*)s);
if(cl <= 0)
return -1;
n --;
s += cl;
pwcs++;
++count;
}
}
return count;
}
/*
Text stream is used by TJS's Array.save, Dictionary.saveStruct etc.
to input/output text files.
*/
extern size_t TextStream_mbstowcs(tjs_char *pwcs, const tjs_nchar *s, size_t n) {
if (mbtowc_for_text_stream) {
return _TextStream_mbstowcs(mbtowc_for_text_stream, pwcs, s, n);
}
// trying every encoding available
size_t ret = _TextStream_mbstowcs(sjis_mbtowc, pwcs, s, n);
if (ret == (size_t)-1) {
ret = _TextStream_mbstowcs(utf8_mbtowc, pwcs, s, n);
if (ret != (size_t)-1) {
mbtowc_for_text_stream = utf8_mbtowc;
return ret;
}
ret = _TextStream_mbstowcs(gbk_mbtowc, pwcs, s, n);
if (ret != (size_t)-1) {
mbtowc_for_text_stream = gbk_mbtowc;
return ret;
}
}
return ret;
}
static ttstr enc_utf8 = TJS_W("utf8"), enc_utf8_2 = TJS_W("utf-8"), enc_utf16 = TJS_W("utf16"),
enc_utf16_2 = TJS_W("utf-16"), enc_gbk = TJS_W("gbk"), enc_jis = TJS_W("sjis"),
enc_jis_2 = TJS_W("shiftjis"), enc_jis_3 = TJS_W("shift_jis"), enc_jis_4 = TJS_W("shift-jis");
bool TVPStringDecode(const void *p, int len, ttstr& result, ttstr encoding /*= "utf8"*/) {
if (encoding == enc_utf8 || encoding == enc_utf8_2) {
int n = (int)TJS_mbstowcs(NULL, (char*)p, len);
if (n == -1) return false;
TJS_mbstowcs(result.AllocBuffer(n), (char*)p, len);
} else if (encoding == enc_utf16 || encoding == enc_utf16_2) {
memcpy(result.AllocBuffer(len / 2), p, len);
result.FixLen();
} else if (encoding == enc_jis || encoding == enc_jis_2 || encoding == enc_jis_3 || encoding == enc_jis_4) {
int n = _TextStream_mbstowcs(sjis_mbtowc, NULL, (char*)p, len);
if (n == -1) return false;
_TextStream_mbstowcs(sjis_mbtowc, result.AllocBuffer(n), (char*)p, len);
} else if (encoding == enc_gbk) {
int n = _TextStream_mbstowcs(gbk_mbtowc, NULL, (char*)p, len);
if (n == -1) return false;
_TextStream_mbstowcs(gbk_mbtowc, result.AllocBuffer(n), (char*)p, len);
} else {
return false;
}
return true;
}
bool TVPStringEncode(const ttstr &src, std::string &result, ttstr encoding /*= "utf8"*/)
{
if (encoding == enc_utf8 || encoding == enc_utf8_2) {
result = src.AsNarrowStdString();
} else if (encoding == enc_utf16 || encoding == enc_utf16_2) {
result.resize(src.length() * 2);
memcpy((char*)result.c_str(), src.c_str(), src.length() * 2);
// } else if (encoding == enc_jis || encoding == enc_jis_2 || encoding == enc_jis_3 || encoding == enc_jis_4) {
// } else if (encoding == enc_gbk) { // unsupported yet
} else {
return false;
}
return true;
}
#ifdef TVP_TEXT_READ_ANSI_MBCS
static ttstr DefaultReadEncoding = TJS_W("Shift_JIS");
#else
static ttstr DefaultReadEncoding = TJS_W("UTF-8");
#endif
//---------------------------------------------------------------------------
// Interface to tTJSTextStream
//---------------------------------------------------------------------------
/*
note: encryption of mode 0 or 1 ( simple crypt ) does never intend data pretection
security.
*/
class tTVPTextReadStream : public iTJSTextReadStream
{
tTJSBinaryStream * Stream;
bool DirectLoad;
tjs_char *Buffer;
size_t BufferLen;
tjs_char *BufferPtr;
tjs_int CryptMode;
public:
tTVPTextReadStream(const ttstr & name, const ttstr & modestr)
{
// following syntax of modestr is currently supported.
// oN: read from binary offset N (in bytes)
#ifndef TVP_NO_CHECK_WIDE_CHAR_SIZE
if(sizeof(tjs_char) != 2)
TVPThrowExceptionMessage( TVPTheHostIsNotA16BitUnicodeSystem );
#endif
Stream = NULL;
Buffer = NULL;
DirectLoad = false;
CryptMode = -1;
// check o mode
Stream = TVPCreateStream(name, TJS_BS_READ);
tjs_uint64 ofs = 0;
const tjs_char * o_ofs;
o_ofs = TJS_strchr(modestr.c_str(), TJS_W('o'));
if(o_ofs != NULL)
{
// seek to offset
o_ofs++;
tjs_char buf[256];
int i;
for(i = 0; i < 255; i++)
{
if(o_ofs[i] >= TJS_W('0') && o_ofs[i] <= TJS_W('9'))
buf[i] = o_ofs[i];
else break;
}
buf[i] = 0;
ofs = ttstr(buf).AsInteger();
Stream->SetPosition(ofs);
}
// check first of the file - whether the file is unicode
try
{
tjs_uint8 mark[3] = {0,0};
Stream->Read(mark, 3);
if(mark[0] == 0xff && mark[1] == 0xfe)
{
// unicode
Stream->SetPosition(ofs + 2);
DirectLoad = true;
}
else if(mark[0] == 0xfe && mark[1] == 0xfe)
{
// ciphered text or compressed
tjs_uint8 mode = mark[2];
if(mode != 0 && mode != 1 && mode != 2)
TVPThrowExceptionMessage(TVPUnsupportedCipherMode, name);
// currently only mode0 and mode1, and compressed (mode2) are supported
CryptMode = mode;
DirectLoad = CryptMode != 2;
Stream->Read(mark, 2); // original bom code comes here (is not compressed)
if(mark[0] != 0xff || mark[1] != 0xfe)
TVPThrowExceptionMessage(TVPUnsupportedCipherMode, name);
if(CryptMode == 2)
{
// compressed text stream
tjs_uint64 compressed = Stream->ReadI64LE();
tjs_uint64 uncompressed = Stream->ReadI64LE();
if(compressed != (unsigned long)compressed ||
uncompressed != (unsigned long)uncompressed)
TVPThrowExceptionMessage(TVPUnsupportedCipherMode, name);
// too large stream
unsigned long destlen ;
tjs_uint8 *nbuf = new tjs_uint8[(unsigned long)compressed + 1];
try
{
Stream->ReadBuffer(nbuf, (unsigned long)compressed);
Buffer = new tjs_char [ (BufferLen = (destlen =
(unsigned long)uncompressed) / 2) + 1];
int result = uncompress( /* uncompress from zlib */
(unsigned char*)Buffer,
&destlen, (unsigned char*)nbuf,
(unsigned long)compressed);
if(result != Z_OK ||
destlen != (unsigned long)uncompressed)
TVPThrowExceptionMessage(TVPUnsupportedCipherMode, name);
// uncompression failed.
}
catch(...)
{
delete [] nbuf;
throw;
}
delete [] nbuf;
Buffer[BufferLen] = 0;
BufferPtr = Buffer;
}
}
else
{
// check UTF-8 BOM
if(mark[0] == 0xef && mark[1] == 0xbb && mark[2] == 0xbf) {
// UTF-8 BOM
tjs_uint size = (tjs_uint)(Stream->GetSize() - 3) - ofs;
tjs_uint8 *nbuf = new tjs_uint8[size + 1];
try
{
Stream->ReadBuffer(nbuf, size);
nbuf[size] = 0; // terminater
BufferLen = TVPUtf8ToWideCharString((const char*)nbuf, NULL);
if(BufferLen == (size_t)-1) TVPThrowExceptionMessage(TJSNarrowToWideConversionError);
Buffer = new tjs_char [ BufferLen +1];
TVPUtf8ToWideCharString((const char*)nbuf, Buffer);
}
catch(...)
{
delete [] nbuf;
throw;
}
delete [] nbuf;
Buffer[BufferLen] = 0;
BufferPtr = Buffer;
} else {
// ansi/mbcs
// read whole and hold it
Stream->SetPosition(ofs);
tjs_uint size = (tjs_uint)(Stream->GetSize()) - ofs;
tjs_uint8 *nbuf = new tjs_uint8[size + 1];
try
{
Stream->ReadBuffer(nbuf, size);
nbuf[size] = 0; // terminater
BufferLen = TextStream_mbstowcs(NULL, (tjs_nchar*)nbuf, 0);
if (BufferLen == (size_t)-1) {
ttstr msg(TVPGetMessageByLocale("err_narrow_to_wide"));
TVPThrowExceptionMessage(msg.c_str());
}
Buffer = new tjs_char [ BufferLen +1];
TextStream_mbstowcs(Buffer, (tjs_nchar*)nbuf, BufferLen);
}
catch(...)
{
delete [] nbuf;
throw;
}
delete [] nbuf;
Buffer[BufferLen] = 0;
BufferPtr = Buffer;
}
}
}
catch(...)
{
delete Stream; Stream = NULL;
throw;
}
}
~tTVPTextReadStream()
{
if(Stream) delete Stream;
if(Buffer) delete [] Buffer;
}
tjs_uint TJS_INTF_METHOD Read(tTJSString & targ, tjs_uint size)
{
if(DirectLoad)
{
if(sizeof(tjs_char) == 2)
{
if(size == 0) size = static_cast(Stream->GetSize() - Stream->GetPosition());
if(!size)
{
targ.Clear();
return 0;
}
tjs_char *buf = targ.AllocBuffer(size);
tjs_uint read = Stream->Read(buf, size * 2); // 2 = BMP unicode size
read /= 2;
#if TJS_HOST_IS_BIG_ENDIAN
// re-order input
for(tjs_uint i = 0; i> 8) & 0xff) + ((ch & 0xff) << 8);
}
#endif
if(CryptMode == 0)
{
// simple crypt
for(tjs_uint i = 0; i= 0x20) buf[i] = ch ^ (((ch&0xfe) << 8)^1);
}
}
else if(CryptMode == 1)
{
// simple crypt
for(tjs_uint i = 0; i>1) | ((ch & 0x55555555)<<1);
buf[i] = ch;
}
}
buf[read] = 0;
targ.FixLen();
return read;
}
else
{
// sizeof(tjs_char) is 4
// FIXME: NOT TESTED CODE
if(size == 0) size = static_cast(Stream->GetSize() - Stream->GetPosition());
tjs_uint16 *buf = new tjs_uint16[size / 2];
tjs_uint read;
try
{
read = Stream->Read(buf, size * 2); // 2 = BMP unicode size
read /= 2;
#if TJS_HOST_IS_BIG_ENDIAN
// re-order input
for(tjs_uint i = 0; i> 8) & 0xff) + ((ch & 0xff) << 8);
}
#endif
if(CryptMode == 0)
{
// simple crypt (buggy version)
for(tjs_uint i = 0; i= 0x20) buf[i] = ch ^ (((ch&0xfe) << 8)^1);
}
}
else if(CryptMode == 1)
{
// simple crypt
for(tjs_uint i = 0; i>1) | ((ch & 0x55555555)<<1);
buf[i] = ch;
}
}
buf[read] = 0;
}
catch(...)
{
delete [] buf;
throw;
}
targ = TVPStringFromBMPUnicode(buf);
delete [] buf;
return read;
}
}
else
{
if(size == 0) size = (tjs_uint)BufferLen;
if(size)
{
tjs_char *buf = targ.AllocBuffer(size);
TJS_strncpy(buf, BufferPtr, size);
buf[size] = 0;
BufferPtr += size;
BufferLen -= size;
targ.FixLen();
}
else
{
targ.Clear();
}
return size;
}
}
void TJS_INTF_METHOD Destruct() { delete this; }
};
//---------------------------------------------------------------------------
class tTVPTextWriteStream : public iTJSTextWriteStream
{
// TODO: 32bit wchar_t support
static const tjs_uint COMPRESSION_BUFFER_SIZE = 1024 * 1024;
tTJSBinaryStream * Stream;
tjs_int CryptMode;
// -1 for no-crypt
// 0: (unused) (old buggy crypt mode)
// 1: simple crypt
// 2: complessed
int CompressionLevel; // compression level of zlib
z_stream_s *ZStream;
tjs_uint CompressionSizePosition;
tjs_nchar *CompressionBuffer;
bool CompressionFailed;
public:
tTVPTextWriteStream(const ttstr & name, const ttstr &modestr)
{
// modestr supports following modes:
// dN: deflate(compress) at mode N ( currently not implemented )
// cN: write in cipher at mode N ( currently n is ignored )
// zN: write with compress at mode N ( N is compression level )
// oN: write from binary offset N (in bytes)
Stream = NULL;
CryptMode = -1;
CompressionLevel = Z_DEFAULT_COMPRESSION;
ZStream = NULL;
CompressionSizePosition = 0;
CompressionBuffer = NULL;
CompressionFailed = false;
// check c/z mode
const tjs_char *p;
if((p = TJS_strchr(modestr.c_str(), TJS_W('c'))) != NULL)
{
CryptMode = 1; // simple crypt
if(p[1] >= TJS_W('0') && p[1] <= TJS_W('9'))
CryptMode = p[1] - TJS_W('0');
}
if((p = TJS_strchr(modestr.c_str(), TJS_W('z'))) != NULL)
{
CryptMode = 2; // compressed (cannot be with 'c')
if(p[1] >= TJS_W('0') && p[1] <= TJS_W('9'))
CompressionLevel = p[1] - TJS_W('0');
}
if(CryptMode != -1 && CryptMode != 1 && CryptMode != 2)
TVPThrowExceptionMessage(TVPUnsupportedModeString,
TJS_W("unsupported cipher mode"));
// check o mode
const tjs_char * o_ofs;
o_ofs = TJS_strchr(modestr.c_str(), TJS_W('o'));
if(o_ofs != NULL)
{
// seek to offset
o_ofs++;
tjs_char buf[256];
int i;
for(i = 0; i < 255; i++)
{
if(o_ofs[i] >= TJS_W('0') && o_ofs[i] <= TJS_W('9'))
buf[i] = o_ofs[i];
else break;
}
buf[i] = 0;
tjs_uint64 ofs = ttstr(buf).AsInteger();
Stream = TVPCreateStream(name, TJS_BS_UPDATE);
Stream->SetPosition(ofs);
}
else
{
Stream = TVPCreateStream(name, TJS_BS_WRITE);
}
if(CryptMode == 1 || CryptMode == 2)
{
// simple crypt or compressed
tjs_uint8 crypt_mode_sig[4];
crypt_mode_sig[0] = crypt_mode_sig[1] = 0xfe;
crypt_mode_sig[2] = (tjs_uint8)CryptMode;
crypt_mode_sig[3] = 0;
Stream->WriteBuffer(crypt_mode_sig, 3);
}
// now output text stream will write unicode texts
static tjs_uint8 bommark[4] = { 0xff, 0xfe,
0x00, 0x00/*dummy 2bytes*/ };
Stream->WriteBuffer(bommark, 2);
if(CryptMode == 2)
{
// allocate and initialize zlib straem
ZStream = new z_stream_s();
ZStream->zalloc = Z_NULL;
ZStream->zfree = Z_NULL;
ZStream->opaque = Z_NULL;
if (deflateInit(ZStream, CompressionLevel) != Z_OK) {
CompressionFailed = true;
TVPThrowExceptionMessage(TVPCompressionFailed);
}
CompressionBuffer = new tjs_nchar[COMPRESSION_BUFFER_SIZE];
ZStream->next_in = NULL;
ZStream->avail_in = 0;
ZStream->next_out = reinterpret_cast( CompressionBuffer );
ZStream->avail_out = COMPRESSION_BUFFER_SIZE;
// Compression Size (write dummy)
CompressionSizePosition = static_cast(Stream->GetPosition());
WriteI64LE((tjs_uint64)0);
WriteI64LE((tjs_uint64)0);
}
}
~tTVPTextWriteStream()
{
if(CryptMode == 2)
{
if (! CompressionFailed) {
try {
// close zlib stream
int result = 0;
do {
result = deflate(ZStream, Z_FINISH);
if (result != Z_OK
&& result != Z_STREAM_END) {
TVPThrowExceptionMessage(TVPCompressionFailed);
}
Stream->WriteBuffer(CompressionBuffer, COMPRESSION_BUFFER_SIZE - ZStream->avail_out);
ZStream->next_out = reinterpret_cast( CompressionBuffer );
ZStream->avail_out = COMPRESSION_BUFFER_SIZE;
} while (result != Z_STREAM_END);
// rollback and write compression size.
Stream->SetPosition(CompressionSizePosition);
WriteI64LE((tjs_uint64)ZStream->total_out);
WriteI64LE((tjs_uint64)ZStream->total_in);
}
catch(...) {
// delete zlib compress stream
if (ZStream) {
deflateEnd(ZStream);
delete ZStream;
}
delete[] CompressionBuffer;
delete Stream;
throw;
}
}
// delete zlib compress stream
if (ZStream) {
deflateEnd(ZStream);
delete ZStream;
}
delete[] CompressionBuffer;
}
if(Stream) delete Stream;
}
void WriteI64LE(tjs_uint64 v)
{
// write 64bit little endian value to the file.
tjs_uint8 buf[8];
buf[0] = (tjs_uint8)(v >> (0*8));
buf[1] = (tjs_uint8)(v >> (1*8));
buf[2] = (tjs_uint8)(v >> (2*8));
buf[3] = (tjs_uint8)(v >> (3*8));
buf[4] = (tjs_uint8)(v >> (4*8));
buf[5] = (tjs_uint8)(v >> (5*8));
buf[6] = (tjs_uint8)(v >> (6*8));
buf[7] = (tjs_uint8)(v >> (7*8));
Stream->WriteBuffer(buf, 8);
}
void TJS_INTF_METHOD Write(const ttstr & targ)
{
tjs_uint16 *buf;
tjs_int len = targ.GetLen();
buf = new tjs_uint16 [len + 1];
try
{
const tjs_char *src = targ.c_str();
tjs_int i;
for(i = 0; i < len; i++)
{
if(src[i] < 0x10000)
buf[i] = src[i];
else
buf[i] = TJS_W('?');
}
buf[i] = 0;
#if TJS_HOST_IS_BIG_ENDIAN
tjs_uint16 *p;
if(CryptMode == 1)
{
// simple crypt
p = buf;
if(p)
{
while(*p)
{
tjs_char ch = *p;
ch = ((ch & 0xaaaaaaaa)>>1) | ((ch & 0x55555555)<<1);
*p = ch;
p++;
}
}
}
// re-order to little endian unicode text
p = buf;
if(p)
{
while(*p)
{
*p = ((*p >> 8) & 0xff) + ((*p & 0xff) << 8);
p++;
}
}
WriteRawData(str.c_str(), len * sizeof(tjs_char));
#else
if(CryptMode == 1)
{
// simple crypt
tjs_uint16 *p;
p = buf;
if(p)
{
while(*p)
{
tjs_char ch = *p;
ch = ((ch & 0xaaaaaaaa)>>1) | ((ch & 0x55555555)<<1);
*p = ch;
p++;
}
}
WriteRawData(buf, len * sizeof(tjs_uint16));
}
else
{
WriteRawData(buf, len * sizeof(tjs_uint16));
}
#endif
}
catch(...)
{
delete [] buf;
throw;
}
delete [] buf;
}
void WriteRawData(void *ptr, size_t size)
{
if(CryptMode == 2)
{
// compressed with zlib stream.
ZStream->next_in = (Bytef*)ptr;
ZStream->avail_in = (uInt)size;
while (ZStream->avail_in > 0) {
int result = deflate(ZStream, Z_NO_FLUSH);
if (result != Z_OK) {
CompressionFailed = true;
TVPThrowExceptionMessage(TVPCompressionFailed);
}
if (ZStream->avail_out == 0) {
Stream->WriteBuffer(CompressionBuffer, COMPRESSION_BUFFER_SIZE);
ZStream->next_out = reinterpret_cast( CompressionBuffer );
ZStream->avail_out = COMPRESSION_BUFFER_SIZE;
}
}
}
else
{
Stream->WriteBuffer(ptr, (tjs_uint)size); // write directly
}
}
void TJS_INTF_METHOD Destruct() { delete this; }
};
//---------------------------------------------------------------------------
iTJSTextReadStream * TVPCreateTextStreamForRead(const ttstr & name,
const ttstr & modestr)
{
return new tTVPTextReadStream(name, modestr);
}
//---------------------------------------------------------------------------
iTJSTextReadStream * TVPCreateTextStreamForReadByEncoding(const ttstr & name,
const ttstr & modestr)
{
return new tTVPTextReadStream(name, modestr);
}
//---------------------------------------------------------------------------
iTJSTextWriteStream * TVPCreateTextStreamForWrite(const ttstr & name,
const ttstr & modestr)
{
return new tTVPTextWriteStream(name, modestr);
}
//---------------------------------------------------------------------------
void TVPSetDefaultReadEncoding(const ttstr& encoding)
{
DefaultReadEncoding = encoding;
ttstr codestr = encoding; codestr.ToLowerCase();
if (codestr == enc_gbk) {
mbtowc_for_text_stream = gbk_mbtowc;
} else if (codestr == enc_utf8 || codestr == enc_utf8_2) {
mbtowc_for_text_stream = utf8_mbtowc;
} else if (codestr == enc_jis || codestr == enc_jis_2 || codestr == enc_jis_3 || codestr == enc_jis_4) {
mbtowc_for_text_stream = sjis_mbtowc;
} else {
TVPThrowExceptionMessage(TVPUnsupportedEncoding, encoding);
}
}
//---------------------------------------------------------------------------
const tjs_char* TVPGetDefaultReadEncoding()
{
return DefaultReadEncoding.c_str();
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/TextStream.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Text read/write stream
//---------------------------------------------------------------------------
#ifndef TextStreamH
#define TextStreamH
#include "StorageIntf.h"
//---------------------------------------------------------------------------
// TextStream Functions
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(iTJSTextReadStream *, TVPCreateTextStreamForRead, (const ttstr &name, const ttstr &modestr));
TJS_EXP_FUNC_DEF(iTJSTextWriteStream *, TVPCreateTextStreamForWrite, (const ttstr &name, const ttstr &modestr));
TJS_EXP_FUNC_DEF(void, TVPSetDefaultReadEncoding, (const ttstr& encoding));
TJS_EXP_FUNC_DEF(const tjs_char*, TVPGetDefaultReadEncoding, ());
bool TVPStringDecode(const void *p, int len, ttstr& result, ttstr encoding = "utf8");
bool TVPStringEncode(const ttstr &s, std::string &result, ttstr encoding = "utf8");
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/UserEvent.h
================================================
#ifndef __USER_EVENT_H__
#define __USER_EVENT_H__
#ifndef WM_APP
#define WM_APP 0x10000
#endif
#define TVP_EV_TIMER_THREAD (WM_APP + 1)
#define TVP_EV_WAVE_SND_BUF_THREAD (TVP_EV_TIMER_THREAD + 1)
#define TVP_EV_VSYNC_TIMING_THREAD (TVP_EV_WAVE_SND_BUF_THREAD + 1)
#define TVP_EV_CONTINUE_LIMIT_THREAD (TVP_EV_VSYNC_TIMING_THREAD + 1)
#define TVP_EV_DELIVER_EVENTS_DUMMY (TVP_EV_CONTINUE_LIMIT_THREAD + 1)
#define TVP_EV_KEEP_ALIVE (TVP_EV_DELIVER_EVENTS_DUMMY + 1)
#define TVP_EV_IMAGE_LOAD_THREAD (TVP_EV_KEEP_ALIVE + 1)
#define TVP_EV_WINDOW_RELEASE (TVP_EV_IMAGE_LOAD_THREAD + 1)
#endif // __USER_EVENT_H__
================================================
FILE: src/core/base/UtilStreams.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Stream related utilities / utility streams
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "UtilStreams.h"
#include "MsgIntf.h"
#include "DebugIntf.h"
#include "EventIntf.h"
#include "StorageIntf.h"
#include
#include
#include
#include "Platform.h"
#include
#include
//---------------------------------------------------------------------------
// tTVPLocalTempStorageHolder
//---------------------------------------------------------------------------
#define TVP_LOCAL_TEMP_COPY_BLOCK_SIZE 65536*2
tTVPLocalTempStorageHolder::tTVPLocalTempStorageHolder(const ttstr & name)
{
// name must be normalized !!!
FileMustBeDeleted = false;
FolderMustBeDeleted = false;
LocalName = TVPGetLocallyAccessibleName(name);
if(LocalName.IsEmpty())
{
// file must be copied to local filesystem
// note that the basename is much more important than the directory
// which the file is to be in, so we create a temporary folder and
// store the file in it.
LocalFolder = TVPGetTemporaryName();
LocalName = LocalFolder + TJS_W("/") + TVPExtractStorageName(name);
TVPCreateFolders(LocalFolder); // create temporary folder
FolderMustBeDeleted = true;
FileMustBeDeleted = true;
try
{
// copy to local file
tTVPStreamHolder src(name);
tTVPStreamHolder dest(LocalName, TJS_BS_WRITE|TJS_BS_DELETE_ON_CLOSE);
tjs_uint8 * buffer = new tjs_uint8[TVP_LOCAL_TEMP_COPY_BLOCK_SIZE];
try
{
tjs_uint read;
while(true)
{
read = src->Read(buffer, TVP_LOCAL_TEMP_COPY_BLOCK_SIZE);
if(read == 0) break;
dest->WriteBuffer(buffer, read);
}
}
catch(...)
{
delete [] buffer;
throw;
}
delete [] buffer;
}
catch(...)
{
if(FileMustBeDeleted) TVPRemoveFile(LocalName);
if(FolderMustBeDeleted) TVPRemoveFolder(LocalFolder);
throw;
}
}
}
//---------------------------------------------------------------------------
tTVPLocalTempStorageHolder::~tTVPLocalTempStorageHolder()
{
if(FileMustBeDeleted) TVPRemoveFile(LocalName);
if(FolderMustBeDeleted) TVPRemoveFolder(LocalFolder);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPMemoryStream
//---------------------------------------------------------------------------
tTVPMemoryStream::tTVPMemoryStream()
{
Init();
}
//---------------------------------------------------------------------------
tTVPMemoryStream::tTVPMemoryStream(const void * block, tjs_uint size)
{
Init();
Block = (void*)block;
if(!Block)
{
Block = Alloc(size);
if(!Block) TVPThrowExceptionMessage(TVPInsufficientMemory);
}
else
{
Reference = true; // memory block was given
}
Size = size;
AllocSize = size;
CurrentPos = 0;
}
//---------------------------------------------------------------------------
tTVPMemoryStream::~tTVPMemoryStream()
{
if(Block && !Reference) Free(Block);
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPMemoryStream::Seek(tjs_int64 offset, tjs_int whence)
{
tjs_int64 newpos;
switch(whence)
{
case TJS_BS_SEEK_SET:
if(offset >= 0)
{
if(offset <= Size) CurrentPos = static_cast(offset);
}
return CurrentPos;
case TJS_BS_SEEK_CUR:
if((newpos = offset + (tjs_int64)CurrentPos) >= 0)
{
tjs_uint np = (tjs_uint)newpos;
if(np <= Size) CurrentPos = np;
}
return CurrentPos;
case TJS_BS_SEEK_END:
if((newpos = offset + (tjs_int64)Size) >= 0)
{
tjs_uint np = (tjs_uint)newpos;
if(np <= Size) CurrentPos = np;
}
return CurrentPos;
}
return CurrentPos;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPMemoryStream::Read(void *buffer, tjs_uint read_size)
{
if(CurrentPos + read_size >= Size)
{
read_size = Size - CurrentPos;
}
memcpy(buffer, (tjs_uint8*)Block + CurrentPos, read_size);
CurrentPos += read_size;
return read_size;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPMemoryStream::Write(const void *buffer, tjs_uint write_size)
{
// writing may increase the internal buffer size.
if(Reference) TVPThrowExceptionMessage(TVPWriteError);
tjs_uint newpos = CurrentPos + write_size;
if(newpos >= AllocSize)
{
// exceeds AllocSize
tjs_uint onesize;
if(AllocSize < 64*1024) onesize = 4*1024;
else if(AllocSize < 512*1024) onesize = 16*1024;
else if(AllocSize < 4096*1024) onesize = 256*1024;
else onesize = 2024*1024;
AllocSize += onesize;
if(CurrentPos + write_size >= AllocSize) // still insufficient ?
{
AllocSize = CurrentPos + write_size;
}
Block = Realloc(Block, AllocSize);
if(AllocSize && !Block)
TVPThrowExceptionMessage(TVPInsufficientMemory);
// this exception cannot be repaird; a fatal error.
}
memcpy((tjs_uint8*)Block + CurrentPos, buffer, write_size);
CurrentPos = newpos;
if(CurrentPos > Size) Size = CurrentPos;
return write_size;
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPMemoryStream::SetEndOfStorage()
{
if(Reference) TVPThrowExceptionMessage(TVPWriteError);
Size = CurrentPos;
AllocSize = Size;
Block = Realloc(Block, Size);
if(Size && !Block)
TVPThrowExceptionMessage(TVPInsufficientMemory);
}
//---------------------------------------------------------------------------
void tTVPMemoryStream::Clear(void)
{
if(Block && !Reference) Free(Block);
Init();
}
//---------------------------------------------------------------------------
void tTVPMemoryStream::SetSize(tjs_uint size)
{
if(Reference) TVPThrowExceptionMessage(TVPWriteError);
if(Size > size)
{
// decrease
Size = size;
AllocSize = size;
Block = Realloc(Block, size);
if(CurrentPos > Size) CurrentPos = Size;
if(size && !Block)
TVPThrowExceptionMessage(TVPInsufficientMemory);
}
else
{
// increase
AllocSize = size;
Size = size;
Block = Realloc(Block, size);
if(size && !Block)
TVPThrowExceptionMessage(TVPInsufficientMemory);
}
}
//---------------------------------------------------------------------------
void tTVPMemoryStream::Init()
{
Block = NULL;
Reference = false;
Size = 0;
AllocSize = 0;
CurrentPos = 0;
}
//---------------------------------------------------------------------------
void * tTVPMemoryStream::Alloc(size_t size)
{
return TJS_malloc(size);
}
//---------------------------------------------------------------------------
void * tTVPMemoryStream::Realloc(void *orgblock, size_t size)
{
return TJS_realloc(orgblock, size);
}
//---------------------------------------------------------------------------
void tTVPMemoryStream::Free(void *block)
{
TJS_free(block);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPPartialStream
//---------------------------------------------------------------------------
tTVPPartialStream::tTVPPartialStream(tTJSBinaryStream *stream, tjs_uint64 start,
tjs_uint64 size)
{
// the stream given as a argument here will be owned by this instance,
// and freed at the destruction.
Stream = stream;
Start = start;
Size = size;
CurrentPos = 0;
try
{
Stream->SetPosition(Start);
}
catch(...)
{
delete Stream;
Stream = NULL;
throw;
}
}
//---------------------------------------------------------------------------
tTVPPartialStream::~tTVPPartialStream()
{
if(Stream) delete Stream;
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPPartialStream::Seek(tjs_int64 offset, tjs_int whence)
{
tjs_int64 newpos;
switch(whence)
{
case TJS_BS_SEEK_SET:
newpos = offset;
if(offset >= 0 && offset <= static_cast(Size) )
{
newpos += Start;
CurrentPos = Stream->Seek(newpos, TJS_BS_SEEK_SET) - Start;
}
return CurrentPos;
case TJS_BS_SEEK_CUR:
newpos = offset + CurrentPos;
if(offset >= 0 && offset <= static_cast(Size) )
{
newpos += Start;
CurrentPos = Stream->Seek(newpos, TJS_BS_SEEK_SET) - Start;
}
return CurrentPos;
case TJS_BS_SEEK_END:
newpos = offset + Size;
if(offset >= 0 && offset <= static_cast(Size) )
{
newpos += Start;
CurrentPos = Stream->Seek(newpos, TJS_BS_SEEK_SET) - Start;
}
return CurrentPos;
}
return CurrentPos;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPPartialStream::Read(void *buffer, tjs_uint read_size)
{
if(CurrentPos + read_size >= Size)
{
read_size = static_cast(Size - CurrentPos);
}
tjs_uint read = Stream->Read(buffer, read_size);
CurrentPos += read;
return read;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPPartialStream::Write(const void *buffer, tjs_uint write_size)
{
return 0;
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPPartialStream::GetSize()
{
return Size;
}
//---------------------------------------------------------------------------
extern "C" {
#include "libarchive/archive.h"
#include "libarchive/archive_entry.h"
}
#if 0
class LibArchive_Archive : public tTVPArchive {
struct archive *_arc;
tTJSBinaryStream *_stream;
static const int BUFFER_SIZE = 16 * 1024;
tjs_uint8 *_buffer = new tjs_uint8[BUFFER_SIZE];
std::vector > _filelist;
void Clear() {
if (_arc) {
archive_read_free(_arc);
_arc = nullptr;
}
for (std::pair &it : _filelist) {
archive_entry_free(it.second);
}
_filelist.clear();
}
public:
LibArchive_Archive(const ttstr & name, tTJSBinaryStream *st) : tTVPArchive(name), _stream(st) {
_arc = archive_read_new();
}
~LibArchive_Archive() {
Clear();
if (_stream)
delete _stream;
if (_buffer)
delete[] _buffer;
}
virtual tjs_uint GetCount() { return _filelist.size(); }
virtual ttstr GetName(tjs_uint idx) { return _filelist[idx].first; }
virtual tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx) {
struct archive_entry * entry = _filelist[idx].second;
tjs_uint64 fileSize = archive_entry_size(entry);
if (fileSize <= 0) return new tTVPMemoryStream();
return nullptr;
}
bool Open(bool normalizeFileName) {
archive_read_support_filter_all(_arc);
archive_read_support_format_all(_arc);
archive_read_set_seek_callback(_arc, seek_callback);
archive_read_open2(_arc, this, nullptr, read_callback, nullptr, nullptr);
struct archive_entry *entry = archive_entry_new2(_arc);
while (archive_read_next_header2(_arc, entry) == ARCHIVE_OK) {
ttstr filename(archive_entry_pathname_utf8(entry));
if (normalizeFileName)
NormalizeInArchiveStorageName(filename);
_filelist.emplace_back(filename, entry);
entry = archive_entry_new2(_arc);
}
archive_entry_free(entry);
if (normalizeFileName) {
std::sort(_filelist.begin(), _filelist.end(), [](const std::pair& a, const std::pair& b) {
return a.first < b.first;
});
}
}
void Detach() {
Clear();
_stream = nullptr;
}
static la_ssize_t read_callback(struct archive *, void *_client_data, const void **_buffer) {
LibArchive_Archive *_this = (LibArchive_Archive *)_client_data;
*_buffer = _this->_buffer;
return _this->_stream->Read(_this->_buffer, BUFFER_SIZE);
}
static la_int64_t seek_callback(struct archive *, void *_client_data, la_int64_t offset, int whence) {
LibArchive_Archive *_this = (LibArchive_Archive *)_client_data;
return _this->_stream->Seek(offset, whence);
}
static la_int64_t skip_callback(struct archive *, void *_client_data, la_int64_t request) {
LibArchive_Archive *_this = (LibArchive_Archive *)_client_data;
return _this->_stream->Seek(request, TJS_BS_SEEK_CUR);
}
};
tTVPArchive *TVPOpenLibArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName) {
LibArchive_Archive *arc = new LibArchive_Archive(name, st);
if (arc->Open(normalizeFileName)) {
return arc;
}
arc->Detach();
delete arc;
return nullptr;
}
#endif
static FILE *_fileopen(const std::string &strpath) {
FILE *fp = fopen(strpath.c_str(), "wb");
if (!fp) { // make dirs
ttstr path = TVPExtractStoragePath(strpath);
TVPCreateFolders(path);
fp = fopen(strpath.c_str(), "wb");
}
return fp;
}
class tTVPUnpackArchiveThread {
std::thread *ThreadObj;
std::mutex Mutex;
std::condition_variable Cond;
tTVPUnpackArchive *Owner;
void Entry() {
{
std::unique_lock lk(Mutex);
Cond.wait(lk);
}
Owner->Process();
}
public:
tTVPUnpackArchiveThread(tTVPUnpackArchive *owner) : Owner(owner) {
ThreadObj = new std::thread(&tTVPUnpackArchiveThread::Entry, this);
}
~tTVPUnpackArchiveThread() {
if (ThreadObj->joinable()) {
ThreadObj->join();
}
delete ThreadObj;
}
void Start() {
Cond.notify_all();
}
};
class tTVPUnpackArchiveImplWrap : public iTVPUnpackArchiveImpl {
tTVPArchive *pTVPArc = nullptr;
tjs_int64 _totalSize = 0;
int _totalFileCount = 0;
public:
virtual ~tTVPUnpackArchiveImplWrap() {
if (pTVPArc)
pTVPArc->Release();
}
virtual bool Open(const std::string &path) override {
pTVPArc = TVPOpenArchive(path, false);
int file_count = 0;
if (pTVPArc) {
file_count = pTVPArc->GetCount();
_totalSize = 0;
for (int i = 0; i < file_count; ++i) {
tTJSBinaryStream *str = pTVPArc->CreateStreamByIndex(i);
if (str) {
_totalSize += str->GetSize();
delete str;
}
}
_totalFileCount = file_count;
return true;
}
return false;
}
virtual int GetFileCount() override { return _totalFileCount; }
virtual tjs_int64 GetTotalSize() override { return _totalSize; }
virtual void ExtractTo(const std::string &OutPath) {
tjs_uint64 total_size = 0;
int file_count = pTVPArc->GetCount();
std::vector buffer; buffer.resize(4 * 1024 * 1024);
for (int index = 0; index < file_count && !StopRequired; ++index) {
tjs_uint64 file_size = 0;
std::string filename = pTVPArc->GetName(index).AsStdString();
if (filename.size() > 600) continue;
std::string fullpath = OutPath + filename;
FILE *fp = _fileopen(fullpath);
if (!fp) {
_callbacks->FuncOnError(ARCHIVE_FAILED, "Cannot open output file");
break;
}
tTJSBinaryStream *str = pTVPArc->CreateStreamByIndex(index);
if (!str) {
_callbacks->FuncOnError(ARCHIVE_FAILED, "Cannot open archive stream");
fclose(fp);
break;
}
_callbacks->FuncOnNewFile(index, filename.c_str(), str->GetSize());
while (!StopRequired) {
tjs_uint readed = str->Read(&buffer.front(), buffer.size());
if (readed == 0) break;
if (readed != fwrite(&buffer.front(), 1, readed, fp)) {
_callbacks->FuncOnError(ARCHIVE_FAILED, "Fail to write file.\nPlease check the disk space.");
break;
}
file_size += readed;
total_size += readed;
_callbacks->FuncOnProgress(total_size, file_size);
if (readed < buffer.size())
break;
}
delete str;
fclose(fp);
}
pTVPArc->Release();
pTVPArc = nullptr;
_callbacks->FuncOnEnded();
}
};
class tTVPUnpackArchiveImplLibArchive : public iTVPUnpackArchiveImpl {
protected:
struct archive* ArcObj = nullptr;
tjs_int64 _totalSize = 0;
int _totalFileCount = 0;
//FILE *FpIn = nullptr;
std::string _filepath;
static const char * _onPassphraseCallback(struct archive *, void *clientdata);
std::string onPassphraseCallback();
public:
virtual ~tTVPUnpackArchiveImplLibArchive() {
// if (FpIn) {
// fclose(FpIn);
// FpIn = nullptr;
// }
if (ArcObj) {
archive_read_free(ArcObj);
ArcObj = nullptr;
}
}
virtual bool Open(const std::string &path) override {
//FpIn = fopen(path.c_str(), "rb");
_filepath = path;
int file_count = 0;
tjs_uint64 size_count = 0;
ArcObj = archive_read_new();
archive_read_support_filter_all(ArcObj);
archive_read_support_format_all(ArcObj);
archive_read_set_passphrase_callback(ArcObj, this, _onPassphraseCallback);
#ifdef _MSC_VER
int r = archive_read_open_filename_w(ArcObj, ttstr(path).c_str(), 32768);
#else
int r = archive_read_open_filename(ArcObj, path.c_str(), 32768);
#endif
if (r < ARCHIVE_OK) {
// fclose(FpIn);
// FpIn = nullptr;
archive_read_free(ArcObj);
ArcObj = nullptr;
return false;
}
if (archive_read_has_encrypted_entries(ArcObj) > 0) {
std::string psw = onPassphraseCallback();
if (psw.empty()) {
return false;
}
archive_read_add_passphrase(ArcObj, psw.c_str());
}
r = 0;
while (true) {
struct archive_entry *entry;
int r = archive_read_next_header(ArcObj, &entry);
if (r == ARCHIVE_EOF) {
r = ARCHIVE_OK;
break;
}
if (r < ARCHIVE_OK)
_callbacks->FuncOnError(r, archive_error_string(ArcObj));
if (r < ARCHIVE_WARN)
break;
++file_count;
size_count += archive_entry_size(entry);
}
_totalSize = size_count;
_totalFileCount = file_count;
archive_read_close(ArcObj);
archive_read_free(ArcObj);
ArcObj = nullptr;
return true;
}
virtual int GetFileCount() override { return _totalFileCount; }
virtual tjs_int64 GetTotalSize() override { return _totalSize; }
virtual void ExtractTo(const std::string &OutPath) {
tjs_uint64 total_size = 0;
// fseek(FpIn, 0, SEEK_SET);
ArcObj = archive_read_new();
archive_read_support_filter_all(ArcObj);
archive_read_support_format_all(ArcObj);
#ifdef _MSC_VER
int r = archive_read_open_filename_w(ArcObj, ttstr(_filepath).c_str(), 32768);
#else
int r = archive_read_open_filename(ArcObj, _filepath.c_str(), 32768);
#endif
if (r < ARCHIVE_OK) {
_callbacks->FuncOnError(r, archive_error_string(ArcObj));
_callbacks->FuncOnEnded();
return;
}
for (int index = 0; !StopRequired; ++index) {
struct archive_entry *entry;
int r = archive_read_next_header(ArcObj, &entry);
if (r == ARCHIVE_EOF) {
r = ARCHIVE_OK;
break;
}
if (r < ARCHIVE_OK)
_callbacks->FuncOnError(r, archive_error_string(ArcObj));
if (r < ARCHIVE_WARN)
break;
const char *sfilename = archive_entry_pathname_utf8(entry);
std::string filename;
if (sfilename) {
filename = sfilename;
} else {
const wchar_t* wfilename = archive_entry_pathname_w(entry);
std::wstring_convert > cvt;
filename = cvt.to_bytes(wfilename);
}
if (filename.back() == '/' || filename.back() == '\\') {
// skip folder
continue;
}
std::string fullpath = OutPath + filename;
FILE *fp = _fileopen(fullpath);
if (!fp) {
_callbacks->FuncOnError(ARCHIVE_FAILED, "Cannot open output file");
break;
}
_callbacks->FuncOnNewFile(index, filename, archive_entry_size(entry));
const void *buff;
size_t size;
la_int64_t offset;
tjs_uint64 file_size = 0;
const char *errmsg;
while (!StopRequired) {
r = archive_read_data_block(ArcObj, &buff, &size, &offset);
if (r == ARCHIVE_EOF) {
r = ARCHIVE_OK;
break;
}
if (r < ARCHIVE_OK) {
errmsg = archive_error_string(ArcObj);
break;
}
if (size != fwrite(buff, 1, size, fp)) {
r = ARCHIVE_FAILED;
errmsg = "Fail to write file.\nPlease check the disk space.";
break;
}
file_size += size;
total_size += size;
_callbacks->FuncOnProgress(total_size, file_size);
}
fclose(fp);
if (r < ARCHIVE_OK)
_callbacks->FuncOnError(r, errmsg);
if (r < ARCHIVE_WARN)
break;
if (archive_entry_mtime_is_set(entry)) {
TVP_utime(fullpath.c_str(), archive_entry_mtime(entry));
}
}
archive_read_close(ArcObj);
_callbacks->FuncOnEnded();
}
};
std::string tTVPUnpackArchiveImplLibArchive::onPassphraseCallback()
{
return _callbacks->FuncPassword();
}
const char * tTVPUnpackArchiveImplLibArchive::_onPassphraseCallback(struct archive *, void *clientdata)
{
static std::string psw = ((tTVPUnpackArchiveImplLibArchive*)clientdata)->onPassphraseCallback();
return psw.c_str();
}
extern "C" {
#include "p7zip/C/7z.h"
#include "p7zip/C/7zFile.h"
#include "p7zip/C/7zCrc.h"
}
#include
#include
#include "win32io.h"
static ISzAlloc allocImp = {
[](void *p, size_t size) -> void * { return malloc(size); },
[](void *p, void *addr) { free(addr); }
};
class tTVPUnpackArchiveImpl7Zip : public tTVPUnpackArchiveImplLibArchive {
int _stream;
CLookToRead lookStream;
struct CSeekInStream : public ISeekInStream {
tTVPUnpackArchiveImpl7Zip *Host;
} archiveStream;
SRes StreamRead(void *buf, size_t *size) {
*size = read(_stream, buf, *size);
return SZ_OK;
}
SRes StreamSeek(Int64 *pos, ESzSeek origin) {
int whence = SEEK_SET;
switch (origin) {
case SZ_SEEK_CUR: whence = SEEK_CUR; break;
case SZ_SEEK_END: whence = SEEK_END; break;
case SZ_SEEK_SET: whence = SEEK_SET; break;
default: break;
}
*pos = lseek64(_stream, *pos, whence);
return SZ_OK;
}
public:
tTVPUnpackArchiveImpl7Zip() {
archiveStream.Host = this;
archiveStream.Read = [](void *p, void *buf, size_t *size)->SRes {return ((CSeekInStream*)p)->Host->StreamRead(buf, size); };
archiveStream.Seek = [](void *p, Int64 *pos, ESzSeek origin)->SRes {return ((CSeekInStream*)p)->Host->StreamSeek(pos, origin); };
LookToRead_CreateVTable(&lookStream, false);
lookStream.realStream = &archiveStream;
if (!g_CrcTable[1]) CrcGenerateTable();
}
virtual bool Open(const std::string &path) override {
// FpIn = fopen(path.c_str(), "rb");
_filepath = path;
CSzArEx db;
SzArEx_Init(&db);
_stream = open(path.c_str(), O_RDONLY, 0666);
if (!_stream)
return false;
SRes res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocImp);
if (res != SZ_OK) return false;
_totalFileCount = 0;
_totalSize = 0;
for (int i = 0; i < db.NumFiles; i++) {
size_t offset = 0;
size_t outSizeProcessed = 0;
bool isDir = SzArEx_IsDir(&db, i);
if (isDir) continue;
++_totalFileCount;
_totalSize += SzArEx_GetFileSize(&db, i);
}
SzArEx_Free(&db, &allocImp);
close(_stream);
return true;
}
};
#include "unrar/raros.hpp"
#include "unrar/dll.hpp"
class tTVPUnpackArchiveImplUnRAR : public iTVPUnpackArchiveImpl {
std::string _archivePath;
tjs_int _filecount;
tjs_int64 _totalSize, _totalProcessedBytes, _curProcessedBytes;
std::string _lastUsedPassword;
std::mutex _mutex;
std::condition_variable _cond;
bool _reqBreak = false;
struct RARArc {
RAROpenArchiveDataEx _archiveData;
void *_handle = nullptr;
RARArc() {}
~RARArc() {
Close();
}
bool Open(const std::string &path, int mode) {
memset(&_archiveData, 0, sizeof(_archiveData));
#ifdef _MSC_VER
ttstr _path(path);
_archiveData.ArcNameW = (wchar_t*)_path.c_str();
#else
_archiveData.ArcName = (char *)path.c_str();
#endif
_archiveData.OpenMode = mode;
_handle = RAROpenArchiveEx(&_archiveData);
return !!_handle;
}
void Close() {
if (_handle) RARCloseArchive(_handle);
_handle = nullptr;
}
};
int OnCallback(UINT msg, LPARAM P1, LPARAM P2) {
switch (msg) {
case UCM_CHANGEVOLUME:
case UCM_CHANGEVOLUMEW:
return -1; // manual change multi-volume file name is not supported yet
case UCM_NEEDPASSWORD: {
bool hasPsw = !_lastUsedPassword.empty();
if (!hasPsw) {
_lastUsedPassword = _callbacks->FuncPassword();
}
if (_lastUsedPassword.empty()) {
return -1;
}
int len = _lastUsedPassword.size();
if (len > P2) len = P2;
strncpy((char*)P1, _lastUsedPassword.c_str(), len);
if (hasPsw)
_lastUsedPassword.clear();
return 0;
}
case UCM_PROCESSDATA:
_totalProcessedBytes += P2;
_curProcessedBytes += P2;
_callbacks->FuncOnProgress(_totalProcessedBytes, _curProcessedBytes);
return _reqBreak ? -1 : 0;
}
return -1;
}
public:
virtual ~tTVPUnpackArchiveImplUnRAR() {
}
virtual bool Open(const std::string &path) override {
_archivePath = path;
RARArc arc;
if (!arc.Open(_archivePath, RAR_OM_LIST)) {
return false;
}
RARSetCallback(arc._handle, [](UINT msg, LPARAM UserData, LPARAM P1, LPARAM P2)->int {
return ((tTVPUnpackArchiveImplUnRAR*)UserData)->OnCallback(msg, P1, P2);
}, (LPARAM)this);
arc._handle;
RARHeaderData headerData;
_totalSize = 0;
_filecount = 0;
while (1) {
RARHeaderDataEx headerData;
memset(&headerData, 0, sizeof(headerData));
int result = RARReadHeaderEx(arc._handle, &headerData);
if (result != 0) {
if (result != ERAR_END_ARCHIVE) {
return false;
}
break;
}
_totalSize += ((tjs_int64)headerData.UnpSizeHigh << 32) | headerData.UnpSize;
++_filecount;
// Find next file
result = RARProcessFile(arc._handle, RAR_SKIP, NULL, NULL);
if (result != 0) {
return false;
}
}
return true;
}
virtual int GetFileCount() override { return _filecount; }
virtual tjs_int64 GetTotalSize() override { return _totalSize; }
virtual void ExtractTo(const std::string &path) override {
RARArc arc;
if (!arc.Open(_archivePath, RAR_OM_EXTRACT)) {
_callbacks->FuncOnError(1001, "Cannot open file");
return;
}
RARSetCallback(arc._handle, [](UINT msg, LPARAM UserData, LPARAM P1, LPARAM P2)->int {
return ((tTVPUnpackArchiveImplUnRAR*)UserData)->OnCallback(msg, P1, P2);
}, (LPARAM)this);
RARHeaderData headerData;
for (int counter = 0; ;++counter) {
RARHeaderDataEx headerData;
memset(&headerData, 0, sizeof(headerData));
int result = RARReadHeaderEx(arc._handle, &headerData);
if (result != 0) {
if (result != ERAR_END_ARCHIVE) {
_callbacks->FuncOnError(result, "Extraction Fail");
return;
}
break;
}
// _filelist.emplace_back(headerData.FileName);
_callbacks->FuncOnNewFile(counter, headerData.FileName, ((tjs_int64)headerData.UnpSizeHigh << 32) | headerData.UnpSize);
_curProcessedBytes = 0;
// Find next file
#ifdef _MSC_VER
ttstr _path(path);
result = RARProcessFileW(arc._handle, RAR_EXTRACT, (wchar_t*)_path.c_str(), NULL);
#else
result = RARProcessFile(arc._handle, RAR_EXTRACT, (char*)path.c_str(), NULL);
#endif
if (result != 0) {
_callbacks->FuncOnError(result, "Extraction Fail");
return;
}
}
_callbacks->FuncOnEnded();
}
};
int tTVPUnpackArchive::Prepare(const std::string &path, const std::string &_outpath, tjs_uint64 *totalSize) {
FILE *FpIn = fopen(path.c_str(), "rb");
if (!FpIn) return -1;
char signature[4];
if (fread(signature, 1, 4, FpIn) != 4) {
fclose(FpIn);
return -2;
}
OutPath = _outpath + "/";
fclose(FpIn);
if (!memcmp(signature, "Rar!", 4)) {
_impl = new tTVPUnpackArchiveImplUnRAR();
} else if (!memcmp(signature, "PK", 2)) {
_impl = new tTVPUnpackArchiveImplLibArchive();
} else if (!memcmp(signature, "7z", 2)) {
// _impl = new tTVPUnpackArchiveImpl7Zip();
_impl = new tTVPUnpackArchiveImplLibArchive();
} else {
_impl = new tTVPUnpackArchiveImplWrap(); // xp3, etc
_impl->SetCallback(this);
if (!_impl->Open(path)) {
Close();
_impl = new tTVPUnpackArchiveImplLibArchive();
}
}
_impl->SetCallback(this);
if (!_impl->Open(path)) {
Close();
return -2;
}
if (totalSize) *totalSize = _impl->GetTotalSize();
int file_count = _impl->GetFileCount();
if (file_count) {
ArcThread = new tTVPUnpackArchiveThread(this);
}
return file_count;
}
void tTVPUnpackArchive::Start()
{
_impl->StopRequired = false;
ArcThread->Start();
}
void tTVPUnpackArchive::Stop()
{
_impl->StopRequired = true;
ArcThread->Start();
}
void tTVPUnpackArchive::Close()
{
if (_impl) delete _impl;
_impl = nullptr;
}
void tTVPUnpackArchive::Process()
{
if (_impl->StopRequired)
return;
_impl->ExtractTo(OutPath);
}
tTVPUnpackArchive::tTVPUnpackArchive()
{
}
tTVPUnpackArchive::~tTVPUnpackArchive()
{
if (ArcThread) delete ArcThread;
}
================================================
FILE: src/core/base/UtilStreams.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Stream related utilities / utility streams
//---------------------------------------------------------------------------
#ifndef UtilStreamsH
#define UtilStreamsH
#include "StorageIntf.h"
#include
//---------------------------------------------------------------------------
// tTVPStreamHolder
//---------------------------------------------------------------------------
class tTVPStreamHolder
{
tTJSBinaryStream *Stream;
public:
tTVPStreamHolder()
{
Stream = NULL;
}
tTVPStreamHolder(const ttstr& name, tjs_uint32 mode = 0)
{
Stream = TVPCreateStream(name, mode);
}
~tTVPStreamHolder()
{
if(Stream) delete Stream;
}
tTJSBinaryStream * operator ->() const { return Stream; }
tTJSBinaryStream * Get() const { return Stream; }
void Close()
{
if(Stream)
{
delete Stream;
Stream = NULL;
}
}
void Disown()
{
Stream = NULL;
}
void Open(const ttstr & name, tjs_uint32 flag = 0)
{
if(Stream) delete Stream, Stream = NULL;
Stream = TVPCreateStream(name, flag);
}
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPLocalTempStorageHolder
//---------------------------------------------------------------------------
// this class holds storage as local filesystem file ( does not open it ).
// storage is copied to local fliesystem if needed.
class tTVPLocalTempStorageHolder
{
bool FileMustBeDeleted;
bool FolderMustBeDeleted;
ttstr LocalName;
ttstr LocalFolder;
public:
tTVPLocalTempStorageHolder(const ttstr & name);
~tTVPLocalTempStorageHolder();
bool IsTemporaryFile() const { return FileMustBeDeleted; }
const ttstr & GetLocalName() const { return LocalName; }
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPMemoryStream
//---------------------------------------------------------------------------
/*
this class provides a tTJSBinaryStream based access method for a memory block.
*/
class tTVPMemoryStream : public tTJSBinaryStream
{
protected:
void * Block;
bool Reference;
tjs_uint Size;
tjs_uint AllocSize;
tjs_uint CurrentPos;
public:
tTVPMemoryStream();
tTVPMemoryStream(const void * block, tjs_uint size);
~tTVPMemoryStream();
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
void TJS_INTF_METHOD SetEndOfStorage();
tjs_uint64 TJS_INTF_METHOD GetSize() { return Size; }
// non-tTJSBinaryStream based methods
void * GetInternalBuffer() const { return Block; }
void Clear(void);
void SetSize(tjs_uint size);
protected:
void Init();
protected:
virtual void * Alloc(size_t size);
virtual void * Realloc(void *orgblock, size_t size);
virtual void Free(void *block);
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPPartialStream
//---------------------------------------------------------------------------
/*
this class offers read-only accesses for a partial of the other stream,
limited by given start position for original stream and given limited size.
*/
//---------------------------------------------------------------------------
class tTVPPartialStream : public tTJSBinaryStream
{
private:
tTJSBinaryStream *Stream;
tjs_uint64 Start;
tjs_uint64 Size;
tjs_uint64 CurrentPos;
public:
tTVPPartialStream(tTJSBinaryStream *stream, tjs_uint64 start, tjs_uint64 size);
~tTVPPartialStream();
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
// void SetEndOfStorage(); // use default behavior
tjs_uint64 TJS_INTF_METHOD GetSize();
};
//---------------------------------------------------------------------------
struct tTVPUnpackArchiveCallbacks {
std::function FuncOnEnded;
std::function FuncOnError;
std::function FuncOnProgress;
std::function FuncOnNewFile;
std::function FuncPassword;
};
class tTVPUnpackArchiveThread;
class iTVPUnpackArchiveImpl {
protected:
const tTVPUnpackArchiveCallbacks *_callbacks = nullptr;
public:
bool StopRequired = false;
virtual ~iTVPUnpackArchiveImpl() {}
void SetCallback(const tTVPUnpackArchiveCallbacks* cb) { _callbacks = cb; }
virtual bool Open(const std::string &path) = 0;
virtual int GetFileCount() = 0; // -1 for unknown file count
virtual tjs_int64 GetTotalSize() = 0; // -1 for unknown size
virtual void ExtractTo(const std::string &path) = 0;
};
class tTVPUnpackArchive : public tTVPUnpackArchiveCallbacks {
public:
tTVPUnpackArchive();
virtual ~tTVPUnpackArchive(); // must ve deconstructed from main thread
int Prepare(const std::string &path, const std::string &_outpath, tjs_uint64 *totalSize);
void Start();
void Stop();
void Close();
void SetCallback(
const std::function &funcOnEnded,
const std::function &funcOnError,
const std::function &funcOnProgress,
const std::function &funcOnNewFile,
const std::function& funcPassword) {
FuncOnEnded = funcOnEnded;
FuncOnError = funcOnError;
FuncOnProgress = funcOnProgress;
FuncOnNewFile = funcOnNewFile;
FuncPassword = funcPassword;
}
protected:
// these callbacks are not in main thread !
virtual void OnEnded() {
if (FuncOnEnded)
FuncOnEnded();
}
virtual void OnProgress(tjs_uint64 total_size, tjs_uint64 file_size) {
if (FuncOnProgress)
FuncOnProgress(total_size, file_size);
}
virtual void OnNewFile(int idx, const char * utf8name, tjs_uint64 file_size) {
if (FuncOnNewFile)
FuncOnNewFile(idx, utf8name, file_size);
}
private:
void Process();
iTVPUnpackArchiveImpl *_impl = nullptr;
std::string OutPath;
friend class tTVPUnpackArchiveThread;
tTVPUnpackArchiveThread *ArcThread = nullptr;
};
#endif
================================================
FILE: src/core/base/XP3Archive.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// XP3 virtual file system support
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "XP3Archive.h"
#include "MsgIntf.h"
#include "DebugIntf.h"
#include "EventIntf.h"
#include "UtilStreams.h"
#include "SysInitIntf.h"
#include
#include
bool TVPAllowExtractProtectedStorage = true;
//---------------------------------------------------------------------------
// archive filter related
//---------------------------------------------------------------------------
tTVPXP3ArchiveExtractionFilter TVPXP3ArchiveExtractionFilter = NULL;
void TVPSetXP3ArchiveExtractionFilter(tTVPXP3ArchiveExtractionFilter filter)
{
TVPXP3ArchiveExtractionFilter = filter;
}
//---------------------------------------------------------------------------
static tTVPXP3ArchiveContentFilter TVPXP3ArchiveContentFilter = nullptr;
void TVPSetXP3ArchiveContentFilter(tTVPXP3ArchiveContentFilter filter)
{
TVPXP3ArchiveContentFilter = filter;
}
//---------------------------------------------------------------------------
// tTVPXP3ArchiveHandleCache
//---------------------------------------------------------------------------
#define TVP_MAX_ARCHIVE_HANDLE_CACHE 8
static tjs_uint TVPArchiveHandleCacheAge = 0;
struct tTVPArchiveHandleCacheItem
{
void * Pointer;
tTJSBinaryStream * Stream;
tjs_uint Age;
};
//---------------------------------------------------------------------------
static tTVPArchiveHandleCacheItem * TVPArchiveHandleCachePool = NULL;
static bool TVPArchiveHandleCacheInit = false;
static bool TVPArchiveHandleCacheShutdown = false;
static tTJSCriticalSection TVPArchiveHandleCacheCS;
//---------------------------------------------------------------------------
tTJSBinaryStream * TVPGetCachedArchiveHandle(void * pointer, const ttstr & name)
{
// get cached archive file handle from the pool
if(TVPArchiveHandleCacheShutdown)
{
// the pool has shutdown
return TVPCreateStream(name);
}
tTJSCriticalSectionHolder cs_holder(TVPArchiveHandleCacheCS);
if(!TVPArchiveHandleCacheInit)
{
// initialize the pool
TVPArchiveHandleCachePool =
new tTVPArchiveHandleCacheItem[TVP_MAX_ARCHIVE_HANDLE_CACHE];
for(tjs_int i =0; i < TVP_MAX_ARCHIVE_HANDLE_CACHE; i++)
{
TVPArchiveHandleCachePool[i].Pointer = NULL;
TVPArchiveHandleCachePool[i].Stream = NULL;
TVPArchiveHandleCachePool[i].Age = 0;
}
TVPArchiveHandleCacheInit = true;
}
// linear search wiil be enough here because the
// TVP_MAX_ARCHIVE_HANDLE_CACHE is relatively small
for(tjs_int i =0; i < TVP_MAX_ARCHIVE_HANDLE_CACHE; i++)
{
tTVPArchiveHandleCacheItem *item =
TVPArchiveHandleCachePool + i;
if(item->Stream && item->Pointer == pointer)
{
// found in the pool
tTJSBinaryStream * stream = item->Stream;
item->Stream = NULL;
return stream;
}
}
// not found in the pool
// simply create a stream and return it
return TVPCreateStream(name);
}
//---------------------------------------------------------------------------
/*static*/ void TVPReleaseCachedArchiveHandle(void * pointer,
tTJSBinaryStream * stream)
{
// release archive file handle
if(TVPArchiveHandleCacheShutdown) return;
if(!TVPArchiveHandleCacheInit) return;
tTJSCriticalSectionHolder cs_holder(TVPArchiveHandleCacheCS);
// search empty cell in the pool
tjs_uint oldest_age = 0;
tjs_int oldest = 0;
for(tjs_int i = 0; i < TVP_MAX_ARCHIVE_HANDLE_CACHE; i++)
{
tTVPArchiveHandleCacheItem *item =
TVPArchiveHandleCachePool + i;
if(item->Stream == NULL)
{
// found the empty cell; fill it
item->Pointer = pointer;
item->Stream = stream;
item->Age = ++TVPArchiveHandleCacheAge;
// counter overflow in TVPArchiveHandleCacheAge
// is not so a big problem.
// counter overflow can worsen the cache performance,
// but it occurs only when the counter is overflowed
// (it's too far less than usual)
return;
}
if(i == 0 || oldest_age > item->Age)
{
oldest_age = item->Age;
oldest = i;
}
}
// empty cell not found
// free oldest cell and fill it
tTVPArchiveHandleCacheItem *oldest_item =
TVPArchiveHandleCachePool + oldest;
delete oldest_item->Stream, oldest_item->Stream = NULL;
oldest_item->Pointer = pointer;
oldest_item->Stream = stream;
oldest_item->Age = ++TVPArchiveHandleCacheAge;
}
//---------------------------------------------------------------------------
/*static*/ void TVPFreeArchiveHandlePoolByPointer(void * pointer)
{
// free all streams which have specified pointer
if(TVPArchiveHandleCacheShutdown) return;
if(!TVPArchiveHandleCacheInit) return;
tTJSCriticalSectionHolder cs_holder(TVPArchiveHandleCacheCS);
for(tjs_int i = 0; i < TVP_MAX_ARCHIVE_HANDLE_CACHE; i++)
{
tTVPArchiveHandleCacheItem *item =
TVPArchiveHandleCachePool + i;
if(item->Stream && item->Pointer == pointer)
{
delete item->Stream, item->Stream = NULL;
item->Pointer = NULL;
item->Age = 0;
}
}
}
//---------------------------------------------------------------------------
static void TVPFreeArchiveHandlePool()
{
// free all streams
if(TVPArchiveHandleCacheShutdown) return;
if(!TVPArchiveHandleCacheInit) return;
tTJSCriticalSectionHolder cs_holder(TVPArchiveHandleCacheCS);
for(tjs_int i = 0; i < TVP_MAX_ARCHIVE_HANDLE_CACHE; i++)
{
tTVPArchiveHandleCacheItem *item =
TVPArchiveHandleCachePool + i;
if(item->Stream)
{
delete item->Stream, item->Stream = NULL;
item->Pointer = NULL;
item->Age = 0;
}
}
}
//---------------------------------------------------------------------------
static void TVPShutdownArchiveHandleCache()
{
// free all stream and shutdown the pool
tTJSCriticalSectionHolder cs_holder(TVPArchiveHandleCacheCS);
TVPArchiveHandleCacheShutdown = true;
if(!TVPArchiveHandleCacheInit) return;
for(tjs_int i =0; i < TVP_MAX_ARCHIVE_HANDLE_CACHE; i++)
{
if(TVPArchiveHandleCachePool[i].Stream)
delete TVPArchiveHandleCachePool[i].Stream;
}
delete [] TVPArchiveHandleCachePool;
}
//---------------------------------------------------------------------------
static tTVPAtExit TVPShutdownArchiveCacheAtExit
(TVP_ATEXIT_PRI_CLEANUP, TVPShutdownArchiveHandleCache);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPXP3Archive
//---------------------------------------------------------------------------
/*
TVP XPK3 virtual file system support. (in short : XP3)
TVP supports no longer archive type of "XPK1/XPK2"
( XPK1/XPK2 is used by TVP ver under 0.9x ).
here word "in-archive" is used for the storages which are contained in
archive.
*/
//---------------------------------------------------------------------------
bool TVPGetXP3ArchiveOffset(tTJSBinaryStream *st, const ttstr name,
tjs_uint64 & offset, bool raise)
{
st->SetPosition(0);
tjs_uint8 mark[11+1];
static tjs_uint8 XP3Mark1[] =
{ 0x58/*'X'*/, 0x50/*'P'*/, 0x33/*'3'*/, 0x0d/*'\r'*/,
0x0a/*'\n'*/, 0x20/*' '*/, 0x0a/*'\n'*/, 0x1a/*EOF*/,
0xff /* sentinel */ };
static tjs_uint8 XP3Mark2[] =
{ 0x8b, 0x67, 0x01, 0xff/* sentinel */ };
// XP3 header mark contains:
// 1. line feed and carriage return to detect corruption by unnecessary
// line-feeds convertion
// 2. 1A EOF mark which indicates file's text readable header ending.
// 3. 8B67 KANJI-CODE to detect curruption by unnecessary code convertion
// 4. 01 file structure version and character coding
// higher 4 bits are file structure version, currently 0.
// lower 4 bits are character coding, currently 1, is BMP 16bit Unicode.
static tjs_uint8 XP3Mark[11+1];
// +1: I was warned by CodeGuard that the code will do
// access overrun... because a number of 11 is not aligned by DWORD,
// and the processor may read the value of DWORD at last of this array
// from offset 8. Then the last 1 byte would cause a fail.
static bool DoInit = true;
if(DoInit)
{
// the XP3 header above is splitted into two part; to avoid
// mis-finding of the header in the program's initialized data area.
DoInit = false;
memcpy(XP3Mark, XP3Mark1, 8);
memcpy(XP3Mark + 8, XP3Mark2, 3);
// here joins it.
}
mark[0] = 0; // sentinel
st->ReadBuffer(mark, 11);
if(mark[0] == 0x4d/*'M'*/ && mark[1] == 0x5a/*'Z'*/)
{
// "MZ" is a mark of Win32/DOS executables,
// TVP searches the first mark of XP3 archive
// in the executeble file.
bool found = false;
offset = 16;
st->SetPosition(16);
// XP3 mark must be aligned by a paragraph ( 16 bytes )
const tjs_uint one_read_size = 256*1024;
tjs_uint read;
tjs_uint8 *buffer = new tjs_uint8[one_read_size]; // read 256kbytes at once
while(0!=(read = st->Read(buffer, one_read_size)))
{
tjs_uint p = 0;
while(pSetPosition(11 + offset);
// read all XP3 indices
while(true)
{
if(indexdata) delete [] indexdata;
tjs_uint64 index_ofs = st->ReadI64LE();
st->SetPosition(index_ofs + offset);
// read index to memory
tjs_uint8 index_flag;
st->ReadBuffer(&index_flag, 1);
tjs_uint index_size;
if((index_flag & TVP_XP3_INDEX_ENCODE_METHOD_MASK) ==
TVP_XP3_INDEX_ENCODE_ZLIB)
{
// compressed index
tjs_uint64 compressed_size = st->ReadI64LE();
tjs_uint64 r_index_size = st->ReadI64LE();
if((tjs_uint)compressed_size != compressed_size ||
(tjs_uint)r_index_size != r_index_size)
TVPThrowExceptionMessage(TVPReadError);
// too large to handle, or corrupted
index_size = (tjs_int)r_index_size;
indexdata = new tjs_uint8[index_size];
tjs_uint8 *compressed = new tjs_uint8[(tjs_uint)compressed_size];
try
{
st->ReadBuffer(compressed, (tjs_uint)compressed_size);
unsigned long destlen = (unsigned long)index_size;
int result = uncompress( /* uncompress from zlib */
(unsigned char *)indexdata,
&destlen, (unsigned char*)compressed,
(unsigned long)compressed_size);
if(result != Z_OK ||
destlen != (unsigned long)index_size)
TVPThrowExceptionMessage(TVPUncompressionFailed);
}
catch(...)
{
delete [] compressed;
throw;
}
delete [] compressed;
}
else if((index_flag & TVP_XP3_INDEX_ENCODE_METHOD_MASK) ==
TVP_XP3_INDEX_ENCODE_RAW)
{
// uncompressed index
tjs_uint64 r_index_size = st->ReadI64LE();
if((tjs_uint)r_index_size != r_index_size)
TVPThrowExceptionMessage(TVPReadError);
// too large to handle or corrupted
index_size = (tjs_uint)r_index_size;
indexdata = new tjs_uint8[index_size];
st->ReadBuffer(indexdata, index_size);
}
else
{
// unknown encode method
TVPThrowExceptionMessage(TVPReadError);
}
// read index information from memory
tjs_uint ch_file_start = 0;
tjs_uint ch_file_size = index_size;
//Count = 0;
for(;;)
{
// find 'File' chunk
if(!FindChunk(indexdata, cn_File, ch_file_start, ch_file_size))
break; // not found
// find 'info' sub-chunk
tjs_uint ch_info_start = ch_file_start;
tjs_uint ch_info_size = ch_file_size;
if(!FindChunk(indexdata, cn_info, ch_info_start, ch_info_size))
TVPThrowExceptionMessage(TVPReadError);
// read info sub-chunk
tArchiveItem item;
tjs_uint32 flags = ReadI32FromMem(indexdata + ch_info_start + 0);
if(!TVPAllowExtractProtectedStorage && (flags & TVP_XP3_FILE_PROTECTED))
TVPThrowExceptionMessage( TVPSpecifiedStorageHadBeenProtected );
item.OrgSize = ReadI64FromMem(indexdata + ch_info_start + 4);
item.ArcSize = ReadI64FromMem(indexdata + ch_info_start + 12);
tjs_int len = ReadI16FromMem(indexdata + ch_info_start + 20);
ttstr name = TVPStringFromBMPUnicode(
(const tjs_uint16 *)(indexdata + ch_info_start + 22), len);
item.Name = name;
if (normalizeName)
NormalizeInArchiveStorageName(item.Name);
// find 'segm' sub-chunk
// Each of in-archive storages can be splitted into some segments.
// Each segment can be compressed or uncompressed independently.
// segments can share partial area of archive storage. ( this is used for
// OggVorbis' VQ code book sharing )
tjs_uint ch_segm_start = ch_file_start;
tjs_uint ch_segm_size = ch_file_size;
if(!FindChunk(indexdata, cn_segm, ch_segm_start, ch_segm_size))
TVPThrowExceptionMessage(TVPReadError);
// read segm sub-chunk
tjs_int segment_count = ch_segm_size / 28;
tjs_uint64 offset_in_archive = 0;
for(tjs_int i = 0; i= ItemVector.size()) TVPThrowExceptionMessage(TVPReadError);
tArchiveItem &item = ItemVector[idx];
tTJSBinaryStream *stream = TVPGetCachedArchiveHandle(this, ArchiveName);
tTVPXP3ArchiveStream *out;
try
{
out = new tTVPXP3ArchiveStream(this, idx, &(item.Segments), stream,
item.OrgSize);
if (TVPXP3ArchiveContentFilter) {
tjs_int result = TVPXP3ArchiveContentFilter(item.Name, ArchiveName, item.OrgSize, &out->GetFilterContext());
#define XP3_CONTENT_FILTER_FETCH_FULLDATA 1
if (result == XP3_CONTENT_FILTER_FETCH_FULLDATA) {
tTVPMemoryStream *memstr = new tTVPMemoryStream();
memstr->SetSize(item.OrgSize);
out->ReadBuffer(memstr->GetInternalBuffer(), item.OrgSize);
delete out;
return memstr;
}
}
}
catch(...)
{
TVPReleaseCachedArchiveHandle(this, stream);
throw;
}
return out;
}
//---------------------------------------------------------------------------
bool tTVPXP3Archive::FindChunk(const tjs_uint8 *data, const tjs_uint8 * name,
tjs_uint &start, tjs_uint &size)
{
tjs_uint start_save = start;
tjs_uint size_save = size;
tjs_uint pos = 0;
while(pos < size)
{
bool found = !memcmp(data + start, name, 4);
start += 4;
tjs_uint64 r_size = ReadI64FromMem(data + start);
start += 8;
tjs_uint size_chunk = (tjs_uint)r_size;
if(size_chunk != r_size)
TVPThrowExceptionMessage(TVPReadError);
if(found)
{
// found
size = size_chunk;
return true;
}
start += size_chunk;
pos += size_chunk + 4 + 8;
}
start = start_save;
size = size_save;
return false;
}
//---------------------------------------------------------------------------
tjs_int16 tTVPXP3Archive::ReadI16FromMem(const tjs_uint8 *mem)
{
tjs_uint16 ret = (tjs_uint16)mem[0] | ((tjs_uint16)mem[1] << 8);
return (tjs_int16)ret;
}
//---------------------------------------------------------------------------
tjs_int32 tTVPXP3Archive::ReadI32FromMem(const tjs_uint8 *mem)
{
tjs_uint32 ret = (tjs_uint32)mem[0] | ((tjs_uint32)mem[1] << 8) |
((tjs_uint32)mem[2] << 16) | ((tjs_uint32)mem[3] << 24);
return (tjs_int32)ret;
}
//---------------------------------------------------------------------------
tjs_int64 tTVPXP3Archive::ReadI64FromMem(const tjs_uint8 *mem)
{
tjs_uint64 ret = (tjs_uint64)mem[0] | ((tjs_uint64)mem[1] << 8) |
((tjs_uint64)mem[2] << 16) | ((tjs_uint64)mem[3] << 24) |
((tjs_uint64)mem[4] << 32) | ((tjs_uint64)mem[5] << 40) |
((tjs_uint64)mem[6] << 48) | ((tjs_uint64)mem[7] << 56);
return (tjs_int64)ret;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Compressed segment cache related
//---------------------------------------------------------------------------
#define TVP_SEGCACHE_ONE_LIMIT (1024*1024) // max size limit for each segment
#define TVP_SEGCACHE_TOTAL_LIMIT (1024*1024) // total segment cache size
tjs_uint TVPSegmentCacheLimit = TVP_SEGCACHE_TOTAL_LIMIT;
//---------------------------------------------------------------------------
struct tTVPSegmentCacheSearchData
{
ttstr Name; // archive name
tjs_int StorageIndex; // storage index in archive
tjs_int SegmentIndex; // segment index in storage
bool operator == (const tTVPSegmentCacheSearchData &rhs) const
{
return Name == rhs.Name && StorageIndex == rhs.StorageIndex &&
SegmentIndex == rhs.SegmentIndex;
}
};
//---------------------------------------------------------------------------
class tTVPSegmentCacheSearchHashFunc
{
public:
static tjs_uint32 Make(const tTVPSegmentCacheSearchData &val)
{
tjs_uint32 v = tTJSHashFunc::Make(val.Name);
v ^= val.StorageIndex;
v ^= (val.SegmentIndex<<2);
return v;
}
};
//---------------------------------------------------------------------------
class tTVPSegmentData
{
tjs_int RefCount;
tjs_uint Size;
tjs_uint8 *Data;
public:
tTVPSegmentData() { RefCount = 1; Size = 0; Data = NULL; }
~tTVPSegmentData() { if(Data) delete [] Data; }
void SetData(unsigned long outsize, tTJSBinaryStream *instream,
unsigned long insize)
{
// uncompress data
tjs_uint8 * indata = new tjs_uint8 [insize];
try
{
instream->Read(indata, insize);
Data = new tjs_uint8 [outsize];
unsigned long destlen = outsize;
int result = uncompress( (unsigned char*)Data, &outsize,
(unsigned char*)indata, insize);
if(result != Z_OK || destlen != outsize)
TVPThrowExceptionMessage(TVPUncompressionFailed);
Size = outsize;
}
catch(...)
{
delete [] indata;
throw;
}
delete [] indata;
}
const tjs_uint8 * GetData() const { return Data; }
tjs_uint GetSize() const { return Size; }
void AddRef() { RefCount ++; }
void Release()
{
if(RefCount == 1)
{
delete this;
}
else
{
RefCount--;
}
}
};
//---------------------------------------------------------------------------
typedef tTJSRefHolder tTVPSegmentDataHolder;
typedef
tTJSHashTable
tTVPSegmentCache;
static tTVPSegmentCache TVPSegmentCache;
static tjs_uint TVPSegmentCacheTotalBytes = 0;
static tTJSCriticalSection TVPSegmentCacheCS;
//---------------------------------------------------------------------------
static void TVPCheckSegmentCacheLimit()
{
tTJSCriticalSectionHolder cs_holder(TVPSegmentCacheCS);
while(TVPSegmentCacheTotalBytes > TVPSegmentCacheLimit)
{
// chop last segment
tTVPSegmentCache::tIterator i;
i = TVPSegmentCache.GetLast();
if(!i.IsNull())
{
tjs_uint size = i.GetValue().GetObjectNoAddRef()->GetSize();
TVPSegmentCacheTotalBytes -= size;
TVPSegmentCache.ChopLast(1);
}
else
{
break;
}
}
}
//---------------------------------------------------------------------------
void TVPClearXP3SegmentCache()
{
tTJSCriticalSectionHolder cs_holder(TVPSegmentCacheCS);
TVPSegmentCache.Clear();
TVPSegmentCacheTotalBytes = 0;
}
//---------------------------------------------------------------------------
struct tTVPClearSegmentCacheCallback : public tTVPCompactEventCallbackIntf
{
virtual void TJS_INTF_METHOD OnCompact(tjs_int level)
{
if(level >= TVP_COMPACT_LEVEL_DEACTIVATE)
{
// clear the segment cache on application deactivate
TVPClearXP3SegmentCache();
// also free archive handle pool
TVPFreeArchiveHandlePool();
}
}
} static TVPClearSegmentCacheCallback;
static bool TVPClearSegmentCacheCallbackInit = false;
//---------------------------------------------------------------------------
static tTVPSegmentData * TVPSearchFromSegmentCache(
const tTVPSegmentCacheSearchData &sdata, tjs_uint32 hash)
{
tTJSCriticalSectionHolder cs_holder(TVPSegmentCacheCS);
tTVPSegmentDataHolder * ptr =
TVPSegmentCache.FindAndTouchWithHash(sdata, hash);
if(ptr)
{
// found in cache
return ptr->GetObject(); // add-refed
}
return NULL; // not found in cache
}
//---------------------------------------------------------------------------
static void TVPPushToSegmentCache(const tTVPSegmentCacheSearchData &sdata, tjs_uint32 hash,
tTVPSegmentData *data)
{
if(!TVPClearSegmentCacheCallbackInit)
{
TVPAddCompactEventHook(&TVPClearSegmentCacheCallback);
TVPClearSegmentCacheCallbackInit = true;
}
tTJSCriticalSectionHolder cs_holder(TVPSegmentCacheCS);
tTVPSegmentDataHolder holder(data);
TVPSegmentCache.AddWithHash(sdata, hash, holder);
TVPSegmentCacheTotalBytes += data->GetSize();
TVPCheckSegmentCacheLimit();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPXP3ArchiveStream : stream class for in-archive storage
//---------------------------------------------------------------------------
tTVPXP3ArchiveStream::tTVPXP3ArchiveStream(tTVPXP3Archive *owner,
tjs_int storageindex,
std::vector *segments, tTJSBinaryStream * stream,
tjs_uint64 orgsize)
{
StorageIndex = storageindex;
Segments = segments;
SegmentData = NULL;
CurSegmentNum = 0;
CurSegment = &(Segments->operator [](0));
SegmentPos = 0;
SegmentRemain = CurSegment->OrgSize;
SegmentOpened = false;
CurPos = 0;
LastOpenedSegmentNum = -1;
Owner = owner;
Owner->AddRef(); // hook
Stream = stream;
OrgSize = orgsize;
}
//---------------------------------------------------------------------------
tTVPXP3ArchiveStream::~tTVPXP3ArchiveStream()
{
TVPReleaseCachedArchiveHandle(Owner, Stream);
Owner->Release(); // unhook
if(SegmentData) SegmentData->Release();
}
//---------------------------------------------------------------------------
void tTVPXP3ArchiveStream::EnsureSegment()
{
// ensure accessing to current segment
if(SegmentOpened) return;
if(LastOpenedSegmentNum == CurSegmentNum)
{
if(!CurSegment->IsCompressed)
Stream->SetPosition(CurSegment->Start + SegmentPos);
return;
}
// erase buffer
if(SegmentData) SegmentData->Release(), SegmentData = NULL;
// is compressed segment ?
if(CurSegment->IsCompressed)
{
// a compressed segment
if(CurSegment->OrgSize >= TVP_SEGCACHE_ONE_LIMIT)
{
// too large to cache
Stream->SetPosition(CurSegment->Start);
SegmentData = new tTVPSegmentData;
SegmentData->SetData((tjs_uint)CurSegment->OrgSize,
Stream, (tjs_uint)CurSegment->ArcSize);
}
else
{
// search thru segment cache
tTVPSegmentCacheSearchData sdata;
sdata.Name = Owner->GetName();
sdata.StorageIndex = StorageIndex;
sdata.SegmentIndex = CurSegmentNum;
tjs_uint32 hash;
hash = tTVPSegmentCacheSearchHashFunc::Make(sdata);
SegmentData = TVPSearchFromSegmentCache(sdata, hash);
if(!SegmentData)
{
// not found in cache
Stream->SetPosition(CurSegment->Start);
SegmentData = new tTVPSegmentData;
SegmentData->SetData((tjs_uint)CurSegment->OrgSize,
Stream, (tjs_uint)CurSegment->ArcSize);
// add to cache
TVPPushToSegmentCache(sdata, hash, SegmentData);
}
}
}
else
{
// not a compressed segment
Stream->SetPosition(CurSegment->Start + SegmentPos);
}
SegmentOpened = true;
LastOpenedSegmentNum = CurSegmentNum;
}
//---------------------------------------------------------------------------
void tTVPXP3ArchiveStream::SeekToPosition(tjs_uint64 pos)
{
// open segment at 'pos' and seek
// pos must between zero thru OrgSize
if(CurPos == pos) return;
// do binary search to determine current segment number
tjs_int st = 0;
tjs_int et = (tjs_int)Segments->size();
tjs_int seg_num;
while(true)
{
if(et-st <= 1) { seg_num = st; break; }
tjs_int m = st + (et-st)/2;
if(Segments->operator[](m).Offset > pos)
et = m;
else
st = m;
}
CurSegmentNum = seg_num;
CurSegment = &(Segments->operator [](CurSegmentNum));
SegmentOpened = false;
SegmentPos = pos - CurSegment->Offset;
SegmentRemain = CurSegment->OrgSize - SegmentPos;
CurPos = pos;
}
//---------------------------------------------------------------------------
bool tTVPXP3ArchiveStream::OpenNextSegment()
{
// open next segment
if(CurSegmentNum == (tjs_int)(Segments->size() -1))
return false; // no more segments
CurSegmentNum ++;
CurSegment = &(Segments->operator [](CurSegmentNum));
SegmentOpened = false;
SegmentPos = 0;
SegmentRemain = CurSegment->OrgSize;
CurPos = CurSegment->Offset;
EnsureSegment();
return true;
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPXP3ArchiveStream::Seek(tjs_int64 offset, tjs_int whence)
{
tjs_int64 newpos;
switch(whence)
{
case TJS_BS_SEEK_SET:
newpos = offset;
if(newpos >= 0 && newpos <= static_cast(OrgSize) )
{
SeekToPosition(newpos);
}
return CurPos;
case TJS_BS_SEEK_CUR:
newpos = offset + CurPos;
if(newpos >= 0 && newpos <= static_cast(OrgSize) )
{
SeekToPosition(newpos);
}
return CurPos;
case TJS_BS_SEEK_END:
newpos = offset + OrgSize;
if(newpos >= 0 && newpos <= static_cast(OrgSize) )
{
SeekToPosition(newpos);
}
return CurPos;
}
return CurPos;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPXP3ArchiveStream::Read(void *buffer, tjs_uint read_size)
{
EnsureSegment();
tjs_uint write_size = 0;
while(read_size)
{
while(SegmentRemain == 0)
{
// must go next segment
if(!OpenNextSegment()) // open next segment
return write_size; // could not read more
}
tjs_uint one_size =
read_size > SegmentRemain ? (tjs_uint)SegmentRemain : read_size;
if(CurSegment->IsCompressed)
{
// compressed segment; read from uncompressed data in memory
memcpy((tjs_uint8*)buffer + write_size,
SegmentData->GetData() + (tjs_uint)SegmentPos, one_size);
}
else
{
// read directly from stream
Stream->ReadBuffer((tjs_uint8*)buffer + write_size, one_size);
}
// execute filter (for encryption method)
if(TVPXP3ArchiveExtractionFilter)
{
tTVPXP3ExtractionFilterInfo info(CurPos, (tjs_uint8*)buffer + write_size,
one_size, Owner->GetFileHash(StorageIndex), Owner->GetName(StorageIndex));
TVPXP3ArchiveExtractionFilter
( (tTVPXP3ExtractionFilterInfo*) &info, &FilterContext );
}
// adjust members
SegmentPos += one_size;
CurPos += one_size;
SegmentRemain -= one_size;
read_size -= one_size;
write_size += one_size;
}
return write_size;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPXP3ArchiveStream::Write(const void *buffer, tjs_uint write_size)
{
return 0;
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPXP3ArchiveStream::GetSize()
{
return OrgSize;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Archive extraction utility
//---------------------------------------------------------------------------
#define TVP_LOCAL_TEMP_COPY_BLOCK_SIZE 65536*2
#if 0
// this routine is obsoleted because the Releaser includes over 256-characters
// file name if the user specifies "protect over the archive" option.
// Windows cannot handle such too long filename.
void TVPExtractArchive(const ttstr & name, const ttstr & _destdir, bool allowextractprotected)
{
// extract file to
bool TVPAllowExtractProtectedStorage_save =
TVPAllowExtractProtectedStorage;
TVPAllowExtractProtectedStorage = allowextractprotected;
try
{
ttstr destdir(_destdir);
tjs_char last = _destdir.GetLastChar();
if(_destdir.GetLen() >= 1 && (last != TJS_W('/') && last != TJS_W('\\')))
destdir += TJS_W('/');
tTVPArchive *arc = TVPOpenArchive(name);
try
{
tjs_int count = arc->GetCount();
for(tjs_int i = 0; i < count; i++)
{
ttstr name = arc->GetName(i);
tTJSBinaryStream *src = arc->CreateStreamByIndex(i);
try
{
tTVPStreamHolder dest(destdir + name, TJS_BS_WRITE);
tjs_uint8 * buffer = new tjs_uint8[TVP_LOCAL_TEMP_COPY_BLOCK_SIZE];
try
{
tjs_uint read;
while(true)
{
read = src->Read(buffer, TVP_LOCAL_TEMP_COPY_BLOCK_SIZE);
if(read == 0) break;
dest->WriteBuffer(buffer, read);
}
}
catch(...)
{
delete [] buffer;
throw;
}
delete [] buffer;
}
catch(...)
{
// delete src;
// throw;
}
delete src;
}
}
catch(...)
{
arc->Release();
throw;
}
arc->Release();
}
catch(...)
{
TVPAllowExtractProtectedStorage =
TVPAllowExtractProtectedStorage_save;
throw;
}
TVPAllowExtractProtectedStorage =
TVPAllowExtractProtectedStorage_save;
}
#endif
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/XP3Archive.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// XP3 virtual file system support
//---------------------------------------------------------------------------
#ifndef XP3ArchiveH
#define XP3ArchiveH
#include "StorageIntf.h"
/*[*/
//---------------------------------------------------------------------------
// Extraction filter related
//---------------------------------------------------------------------------
#pragma pack(push, 4)
struct tTVPXP3ExtractionFilterInfo
{
const tjs_uint SizeOfSelf; // structure size of tTVPXP3ExtractionFilterInfo itself
const tjs_uint64 Offset; // offset of the buffer data in uncompressed stream position
void * Buffer; // target data buffer
const tjs_uint BufferSize; // buffer size in bytes pointed by "Buffer"
const tjs_uint32 FileHash; // hash value of the file (since inteface v2)
const ttstr &FileName;
tTVPXP3ExtractionFilterInfo(tjs_uint64 offset, void *buffer,
tjs_uint buffersize, tjs_uint32 filehash, const ttstr& filename) :
Offset(offset), Buffer(buffer), BufferSize(buffersize),
FileHash(filehash), FileName(filename),
SizeOfSelf(sizeof(tTVPXP3ExtractionFilterInfo)) {;}
};
#pragma pack(pop)
#ifndef TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION
#ifdef _WIN32
#define TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION _stdcall
#else
#define TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION
#endif
#endif
// TVP_tTVPXP3ArchiveExtractionFilter_CONV is _stdcall on win32 platforms,
// for backward application compatibility.
typedef void (TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION *
tTVPXP3ArchiveExtractionFilter)(tTVPXP3ExtractionFilterInfo *info, tTJSVariant *ctx);
typedef tjs_int (TVP_tTVPXP3ArchiveExtractionFilter_CONVENTION *
tTVPXP3ArchiveContentFilter)(const ttstr &filepath, const ttstr &archivename, tjs_uint64 filesize, tTJSVariant *ctx);
/*]*/
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(void, TVPSetXP3ArchiveExtractionFilter, (tTVPXP3ArchiveExtractionFilter filter));
TJS_EXP_FUNC_DEF(void, TVPSetXP3ArchiveContentFilter, (tTVPXP3ArchiveContentFilter filter));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPXP3Archive : XP3 ( TVP's native archive format ) Implmentation
//---------------------------------------------------------------------------
#define TVP_XP3_INDEX_ENCODE_METHOD_MASK 0x07
#define TVP_XP3_INDEX_ENCODE_RAW 0
#define TVP_XP3_INDEX_ENCODE_ZLIB 1
#define TVP_XP3_INDEX_CONTINUE 0x80
#define TVP_XP3_FILE_PROTECTED (1<<31)
#define TVP_XP3_SEGM_ENCODE_METHOD_MASK 0x07
#define TVP_XP3_SEGM_ENCODE_RAW 0
#define TVP_XP3_SEGM_ENCODE_ZLIB 1
//---------------------------------------------------------------------------
extern bool TVPIsXP3Archive(const ttstr &name); // check XP3 archive
extern void TVPClearXP3SegmentCache(); // clear XP3 segment cache
//---------------------------------------------------------------------------
struct tTVPXP3ArchiveSegment
{
tjs_uint64 Start; // start position in archive storage
tjs_uint64 Offset; // offset in in-archive storage (in uncompressed offset)
tjs_uint64 OrgSize; // original segment (uncompressed) size
tjs_uint64 ArcSize; // in-archive segment (compressed) size
bool IsCompressed; // is compressed ?
};
//---------------------------------------------------------------------------
class tTVPXP3Archive : public tTVPArchive
{
public:
struct tArchiveItem
{
ttstr Name;
tjs_uint32 FileHash;
tjs_uint64 OrgSize; // original ( uncompressed ) size
tjs_uint64 ArcSize; // in-archive size
std::vector Segments;
bool operator < (const tArchiveItem &rhs) const
{
return this->Name < rhs.Name;
}
};
tjs_int Count = 0;
std::vector ItemVector;
void Init(tTJSBinaryStream *st, tjs_int64 offset, bool normalizeName = true);
public:
tTVPXP3Archive(const ttstr & name, int) : tTVPArchive(name) {}
tTVPXP3Archive(const ttstr & name, tTJSBinaryStream *st = nullptr, tjs_int64 offset = -1, bool normalizeFileName = true);
~tTVPXP3Archive();
static tTVPArchive *Create(const ttstr & name, tTJSBinaryStream *st = nullptr, bool normalizeFileName = true);
tjs_uint GetCount() { return Count; }
const ttstr & GetName(tjs_uint idx) const { return ItemVector[idx].Name; }
tjs_uint32 GetFileHash(tjs_uint idx) const { return ItemVector[idx].FileHash; }
ttstr GetName(tjs_uint idx) { return ItemVector[idx].Name; }
const ttstr & GetName() const { return ArchiveName; }
tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx);
private:
static bool FindChunk(const tjs_uint8 *data, const tjs_uint8 * name,
tjs_uint &start, tjs_uint &size);
static tjs_int16 ReadI16FromMem(const tjs_uint8 *mem);
static tjs_int32 ReadI32FromMem(const tjs_uint8 *mem);
static tjs_int64 ReadI64FromMem(const tjs_uint8 *mem);
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPXP3ArchiveStream : XP3 In-Archive Stream Implmentation
//---------------------------------------------------------------------------
class tTVPSegmentData;
class tTVPXP3ArchiveStream : public tTJSBinaryStream
{
tTVPXP3Archive * Owner;
tjs_int StorageIndex; // index in archive
std::vector * Segments;
tTJSBinaryStream * Stream;
tjs_uint64 OrgSize; // original storage size
tjs_int CurSegmentNum;
tTVPXP3ArchiveSegment *CurSegment;
// currently opened segment ( NULL for not opened )
tjs_int LastOpenedSegmentNum;
tjs_uint64 CurPos; // current position in absolute file position
tjs_uint64 SegmentRemain; // remain bytes in current segment
tjs_uint64 SegmentPos; // offset from current segment's start
tTVPSegmentData *SegmentData; // uncompressed segment data
bool SegmentOpened;
tTJSVariant FilterContext;
public:
tTVPXP3ArchiveStream(tTVPXP3Archive *owner, tjs_int storageindex,
std::vector *segments, tTJSBinaryStream *stream,
tjs_uint64 orgsize);
~tTVPXP3ArchiveStream();
tTJSVariant &GetFilterContext() { return FilterContext; }
private:
void EnsureSegment(); // ensure accessing to current segment
void SeekToPosition(tjs_uint64 pos); // open segment at 'pos' and seek
bool OpenNextSegment();
public:
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
tjs_uint64 TJS_INTF_METHOD GetSize();
};
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/ZIPArchive.cpp
================================================
#include "tjsCommHead.h"
#include "StorageIntf.h"
#include "UtilStreams.h"
#include
#ifndef NOUNCRYPT
#define NOUNCRYPT
#endif
#include "unzip/ioapi_mem.h"
#include "unzip/unzip.h"
#undef ZEXPORT
#define ZEXPORT
//using namespace cocos2d;
typedef cocos2d::ZPOS64_T ZPOS64_T;
typedef cocos2d::zlib_filefunc64_32_def zlib_filefunc64_32_def;
typedef cocos2d::unz_global_info64 unz_global_info64;
typedef cocos2d::zlib_filefunc_def zlib_filefunc_def;
typedef cocos2d::zlib_filefunc64_def zlib_filefunc64_def;
typedef cocos2d::unz_global_info unz_global_info;
typedef cocos2d::tm_unz tm_unz;
typedef struct unz_file_info_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
ZPOS64_T offset_curfile;
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
} unz_file_info;
typedef cocos2d::unz_file_pos unz_file_pos;
typedef struct unz64_file_pos_s
{
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
ZPOS64_T num_of_file; /* # of file */
} unz64_file_pos;
#ifdef STDC
# include
# include
# include
#endif
#ifdef NO_ERRNO_H
extern int errno;
#else
# include
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
#ifndef CASESENSITIVITYDEFAULT_NO
# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
# define CASESENSITIVITYDEFAULT_NO
# endif
#endif
#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (16384)
#endif
#ifndef UNZ_MAXFILENAMEINZIP
#define UNZ_MAXFILENAMEINZIP (256)
#endif
#ifndef ALLOC
# define ALLOC(size) (malloc(size))
#endif
#ifndef TRYFREE
# define TRYFREE(p) {if (p) free(p);}
#endif
#define SIZECENTRALDIRITEM (0x2e)
#define SIZEZIPLOCALHEADER (0x1e)
const char unz_copyright[] =
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
/* unz_file_info_interntal contain internal info about a file in zipfile*/
typedef struct unz_file_info64_internal_s
{
ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
} unz_file_info64_internal;
/* file_in_zip_read_info_s contain internal information about a file in zipfile,
when reading and decompress it */
typedef struct
{
char *read_buffer; /* internal buffer for compressed data */
z_stream stream; /* zLib stream structure for inflate */
#ifdef HAVE_BZIP2
bz_stream bstream; /* bzLib stream structure for bziped */
#endif
ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
uLong stream_initialised; /* flag set if stream structure is initialized*/
ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
uInt size_local_extrafield;/* size of the local extra field */
ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/
ZPOS64_T total_out_64;
uLong crc32; /* crc32 of all data uncompressed */
uLong crc32_wait; /* crc32 we must obtain after decompress all */
ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
//zlib_filefunc64_32_def z_filefunc;
voidpf filestream; /* io structure of the zipfile */
uLong compression_method; /* compression method (0==store) */
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
int raw;
} file_in_zip64_read_info_s;
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info64_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
ZPOS64_T compressed_size; /* compressed size 8 bytes */
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
} unz_file_info64;
/* unz64_s contain internal information about the zipfile
*/
typedef struct
{
//zlib_filefunc64_32_def z_filefunc;
int is64bitOpenFunction;
voidpf filestream; /* io structure of the zipfile */
unz_global_info64 gi; /* public global information */
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
ZPOS64_T num_file; /* number of the current file in the zipfile*/
ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/
ZPOS64_T current_file_ok; /* flag about the usability of the current file*/
ZPOS64_T central_pos; /* position of the beginning of the central dir*/
ZPOS64_T size_central_dir; /* size of the central directory */
ZPOS64_T offset_central_dir; /* offset of start of central directory with
respect to the starting disk number */
unz_file_info64 cur_file_info; /* public info about the current file in zip*/
unz_file_info64_internal cur_file_info_internal; /* private info about it*/
file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
file if we are decompressing it */
int encrypted;
int isZip64;
# ifndef NOUNCRYPT
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
const unsigned long* pcrc_32_tab;
# endif
} unz64_s;
#ifndef NOUNCRYPT
#include "crypt.h"
#endif
static voidpf zip_open64file(voidpf opaque, const void * filename, int mode) {
if (mode == (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING))
return (voidpf)filename;
return nullptr;
}
static uLong zip_readfile(voidpf, voidpf s, void *buf, uLong size);
static uLong zip_writefile(voidpf, voidpf s, const void *buf, uLong size);
static ZPOS64_T zip_tell64file(voidpf, voidpf s);
static long zip_seek64file(voidpf, voidpf s, ZPOS64_T offset, int origin);
static int zip_closefile(voidpf, voidpf s) {
// delete ((tTJSBinaryStream*)s);
return 0;
}
static zlib_filefunc64_32_def zipfunc = {
{
zip_open64file,
zip_readfile,
zip_writefile,
zip_tell64file,
zip_seek64file,
zip_closefile,
nullptr,
nullptr
},
nullptr,
nullptr,
nullptr
};
/* ===========================================================================
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
for end of file.
IN assertion: the stream s has been successfully opened for reading.
*/
local int unz64local_getByte OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
int *pi));
local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
{
unsigned char c;
int err = (int)zip_readfile(nullptr,filestream,&c,1);
if (err==1)
{
*pi = (int)c;
return UNZ_OK;
}
else
{
// if (ZERROR64(nullptr,filestream))
// return UNZ_ERRNO;
// else
return UNZ_EOF;
}
}
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
local int unz64local_getShort OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX)
{
uLong x ;
int i = 0;
int err;
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((uLong)i)<<8;
if (err==UNZ_OK)
*pX = x;
else
*pX = 0;
return err;
}
local int unz64local_getLong OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX)
{
uLong x ;
int i = 0;
int err;
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((uLong)i)<<8;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((uLong)i)<<16;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x += ((uLong)i)<<24;
if (err==UNZ_OK)
*pX = x;
else
*pX = 0;
return err;
}
local int unz64local_getLong64 OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
ZPOS64_T *pX));
local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
ZPOS64_T *pX)
{
ZPOS64_T x ;
int i = 0;
int err;
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x = (ZPOS64_T)i;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<8;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<16;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<24;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<32;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<40;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<48;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<56;
if (err==UNZ_OK)
*pX = x;
else
*pX = 0;
return err;
}
/* My own strcmpi / strcasecmp */
local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
{
for (;;)
{
char c1=*(fileName1++);
char c2=*(fileName2++);
if ((c1>='a') && (c1<='z'))
c1 -= 0x20;
if ((c2>='a') && (c2<='z'))
c2 -= 0x20;
if (c1=='\0')
return ((c2=='\0') ? 0 : -1);
if (c2=='\0')
return 1;
if (c1c2)
return 1;
}
}
#ifdef CASESENSITIVITYDEFAULT_NO
#define CASESENSITIVITYDEFAULTVALUE 2
#else
#define CASESENSITIVITYDEFAULTVALUE 1
#endif
#ifndef STRCMPCASENOSENTIVEFUNCTION
#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
#endif
/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
or strcasecmp)
If iCaseSenisivity = 0, case sensitivity is default of your operating system
(like 1 on Unix, 2 on Windows)
*/
int ZEXPORT unzStringFileNameCompare (const char* fileName1,
const char* fileName2,
int iCaseSensitivity)
{
if (iCaseSensitivity==0)
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
if (iCaseSensitivity==1)
return strcmp(fileName1,fileName2);
return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
}
#ifndef BUFREADCOMMENT
#define BUFREADCOMMENT (0x400)
#endif
/*
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
ZPOS64_T uSizeFile;
ZPOS64_T uBackRead;
ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
ZPOS64_T uPosFound=0;
if (zip_seek64file(nullptr, filestream, 0, ZLIB_FILEFUNC_SEEK_END) != 0)
return 0;
uSizeFile = zip_tell64file(nullptr, filestream);
if (uMaxBack>uSizeFile)
uMaxBack = uSizeFile;
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
if (buf==NULL)
return 0;
uBackRead = 4;
while (uBackReaduMaxBack)
uBackRead = uMaxBack;
else
uBackRead+=BUFREADCOMMENT;
uReadPos = uSizeFile-uBackRead ;
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
(BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
if (zip_seek64file(nullptr, filestream, uReadPos, ZLIB_FILEFUNC_SEEK_SET) != 0)
break;
if (zip_readfile(nullptr, filestream, buf, uReadSize) != uReadSize)
break;
for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{
uPosFound = uReadPos+i;
break;
}
if (uPosFound!=0)
break;
}
TRYFREE(buf);
return uPosFound;
}
/*
Locate the Central directory 64 of a zipfile (at the end, just before
the global comment)
*/
local ZPOS64_T unz64local_SearchCentralDir64 OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream));
local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream)
{
unsigned char* buf;
ZPOS64_T uSizeFile;
ZPOS64_T uBackRead;
ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
ZPOS64_T uPosFound=0;
uLong uL;
ZPOS64_T relativeOffset;
if (zip_seek64file(nullptr,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
return 0;
uSizeFile = zip_tell64file(nullptr,filestream);
if (uMaxBack>uSizeFile)
uMaxBack = uSizeFile;
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
if (buf==NULL)
return 0;
uBackRead = 4;
while (uBackReaduMaxBack)
uBackRead = uMaxBack;
else
uBackRead+=BUFREADCOMMENT;
uReadPos = uSizeFile-uBackRead ;
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
(BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
if (zip_seek64file(nullptr,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
break;
if (zip_readfile(nullptr,filestream,buf,uReadSize)!=uReadSize)
break;
for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
{
uPosFound = uReadPos+i;
break;
}
if (uPosFound!=0)
break;
}
TRYFREE(buf);
if (uPosFound == 0)
return 0;
/* Zip64 end of central directory locator */
if (zip_seek64file(nullptr,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
return 0;
/* the signature, already checked */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return 0;
/* number of the disk with the start of the zip64 end of central directory */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return 0;
if (uL != 0)
return 0;
/* relative offset of the zip64 end of central directory record */
if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
return 0;
/* total number of disks */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return 0;
if (uL != 1)
return 0;
/* Goto end of central directory record */
if (zip_seek64file(nullptr,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
return 0;
/* the signature */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return 0;
if (uL != 0x06064b50)
return 0;
return relativeOffset;
}
int ZEXPORT unzGoToFirstFile64(unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize);
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
"zlib/zlib114.zip".
If the zipfile cannot be opened (file doesn't exist or in not valid), the
return value is NULL.
Else, the return value is a unzFile Handle, usable with other function
of this unzip package.
*/
local unzFile unzOpenInternal (const void *path,
zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
int is64bitOpenFunction)
{
unz64_s us;
unz64_s *s;
ZPOS64_T central_pos;
uLong uL;
uLong number_disk; /* number of the current dist, used for
spanning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used
for spanning ZIP, unsupported, always 0*/
ZPOS64_T number_entry_CD; /* total number of entries in
the central dir
(same than number_entry on nospan) */
int err=UNZ_OK;
if (unz_copyright[0]!=' ')
return NULL;
// us.z_filefunc.zseek32_file = NULL;
// us.z_filefunc.ztell32_file = NULL;
// us.z_filefunc = *pzlib_filefunc64_32_def;
us.is64bitOpenFunction = is64bitOpenFunction;
us.filestream = zip_open64file(nullptr,
path,
ZLIB_FILEFUNC_MODE_READ |
ZLIB_FILEFUNC_MODE_EXISTING);
if (us.filestream==NULL)
return NULL;
central_pos = unz64local_SearchCentralDir64(nullptr,us.filestream);
if (central_pos)
{
uLong uS;
ZPOS64_T uL64;
us.isZip64 = 1;
if (zip_seek64file(nullptr, us.filestream,
central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
err=UNZ_ERRNO;
/* the signature, already checked */
if (unz64local_getLong(nullptr, us.filestream, &uL) != UNZ_OK)
err=UNZ_ERRNO;
/* size of zip64 end of central directory record */
if (unz64local_getLong64(nullptr, us.filestream,&uL64)!=UNZ_OK)
err=UNZ_ERRNO;
/* version made by */
if (unz64local_getShort(nullptr, us.filestream,&uS)!=UNZ_OK)
err=UNZ_ERRNO;
/* version needed to extract */
if (unz64local_getShort(nullptr, us.filestream,&uS)!=UNZ_OK)
err=UNZ_ERRNO;
/* number of this disk */
if (unz64local_getLong(nullptr, us.filestream,&number_disk)!=UNZ_OK)
err=UNZ_ERRNO;
/* number of the disk with the start of the central directory */
if (unz64local_getLong(nullptr, us.filestream,&number_disk_with_CD)!=UNZ_OK)
err=UNZ_ERRNO;
/* total number of entries in the central directory on this disk */
if (unz64local_getLong64(nullptr, us.filestream,&us.gi.number_entry)!=UNZ_OK)
err=UNZ_ERRNO;
/* total number of entries in the central directory */
if (unz64local_getLong64(nullptr, us.filestream,&number_entry_CD)!=UNZ_OK)
err=UNZ_ERRNO;
if ((number_entry_CD!=us.gi.number_entry) ||
(number_disk_with_CD!=0) ||
(number_disk!=0))
err=UNZ_BADZIPFILE;
/* size of the central directory */
if (unz64local_getLong64(nullptr, us.filestream,&us.size_central_dir)!=UNZ_OK)
err=UNZ_ERRNO;
/* offset of start of central directory with respect to the
starting disk number */
if (unz64local_getLong64(nullptr, us.filestream,&us.offset_central_dir)!=UNZ_OK)
err=UNZ_ERRNO;
us.gi.size_comment = 0;
}
else
{
central_pos = unz64local_SearchCentralDir(nullptr,us.filestream);
if (central_pos==0)
err=UNZ_ERRNO;
us.isZip64 = 0;
if (zip_seek64file(nullptr, us.filestream,
central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
err=UNZ_ERRNO;
/* the signature, already checked */
if (unz64local_getLong(nullptr, us.filestream,&uL)!=UNZ_OK)
err=UNZ_ERRNO;
/* number of this disk */
if (unz64local_getShort(nullptr, us.filestream,&number_disk)!=UNZ_OK)
err=UNZ_ERRNO;
/* number of the disk with the start of the central directory */
if (unz64local_getShort(nullptr, us.filestream,&number_disk_with_CD)!=UNZ_OK)
err=UNZ_ERRNO;
/* total number of entries in the central dir on this disk */
if (unz64local_getShort(nullptr, us.filestream,&uL)!=UNZ_OK)
err=UNZ_ERRNO;
us.gi.number_entry = uL;
/* total number of entries in the central dir */
if (unz64local_getShort(nullptr, us.filestream,&uL)!=UNZ_OK)
err=UNZ_ERRNO;
number_entry_CD = uL;
if ((number_entry_CD!=us.gi.number_entry) ||
(number_disk_with_CD!=0) ||
(number_disk!=0))
err=UNZ_BADZIPFILE;
/* size of the central directory */
if (unz64local_getLong(nullptr, us.filestream,&uL)!=UNZ_OK)
err=UNZ_ERRNO;
us.size_central_dir = uL;
/* offset of start of central directory with respect to the
starting disk number */
if (unz64local_getLong(nullptr, us.filestream,&uL)!=UNZ_OK)
err=UNZ_ERRNO;
us.offset_central_dir = uL;
/* zipfile comment length */
if (unz64local_getShort(nullptr, us.filestream,&us.gi.size_comment)!=UNZ_OK)
err=UNZ_ERRNO;
}
if ((central_pospfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
zip_closefile(nullptr, s->filestream);
TRYFREE(s);
return UNZ_OK;
}
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
*pglobal_info=s->gi;
return UNZ_OK;
}
int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
/* to do : check if number_entry is not truncated */
pglobal_info32->number_entry = (uLong)s->gi.number_entry;
pglobal_info32->size_comment = s->gi.size_comment;
return UNZ_OK;
}
/*
Translate date/time from Dos format to tm_unz (readable more easily)
*/
local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
{
ZPOS64_T uDate;
uDate = (ZPOS64_T)(ulDosDate>>16);
ptm->tm_mday = (uInt)(uDate&0x1f) ;
ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
}
/*
Get Info about the current file in the zipfile, with internal only info
*/
local int unz64local_GetCurrentFileInfoInternal (unzFile file,
unz_file_info64 *pfile_info,
unz_file_info64_internal
*pfile_info_internal,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize)
{
unz64_s* s;
unz_file_info64 file_info;
unz_file_info64_internal file_info_internal;
int err=UNZ_OK;
uLong uMagic;
long lSeek=0;
uLong uL;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
if (zip_seek64file(nullptr, s->filestream,
s->pos_in_central_dir+s->byte_before_the_zipfile,
ZLIB_FILEFUNC_SEEK_SET)!=0)
err=UNZ_ERRNO;
/* we check the magic */
if (err==UNZ_OK)
{
if (unz64local_getLong(nullptr, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE;
}
if (unz64local_getShort(nullptr, s->filestream,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.version_needed) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.flag) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.compression_method) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getLong(nullptr, s->filestream,&file_info.dosDate) != UNZ_OK)
err=UNZ_ERRNO;
unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
if (unz64local_getLong(nullptr, s->filestream,&file_info.crc) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getLong(nullptr, s->filestream,&uL) != UNZ_OK)
err=UNZ_ERRNO;
file_info.compressed_size = uL;
if (unz64local_getLong(nullptr, s->filestream,&uL) != UNZ_OK)
err=UNZ_ERRNO;
file_info.uncompressed_size = uL;
if (unz64local_getShort(nullptr, s->filestream,&file_info.size_filename) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.size_file_extra) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.size_file_comment) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.disk_num_start) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&file_info.internal_fa) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getLong(nullptr, s->filestream,&file_info.external_fa) != UNZ_OK)
err=UNZ_ERRNO;
// relative offset of local header
if (unz64local_getLong(nullptr, s->filestream,&uL) != UNZ_OK)
err=UNZ_ERRNO;
file_info_internal.offset_curfile = uL;
lSeek+=file_info.size_filename;
if ((err==UNZ_OK) && (szFileName!=NULL))
{
uLong uSizeRead ;
if (file_info.size_filename0) && (fileNameBufferSize>0))
if (zip_readfile(nullptr, s->filestream, szFileName, uSizeRead) != uSizeRead)
err=UNZ_ERRNO;
lSeek -= uSizeRead;
}
// Read extrafield
if ((err==UNZ_OK) && (extraField!=NULL))
{
ZPOS64_T uSizeRead ;
if (file_info.size_file_extrafilestream, lSeek, ZLIB_FILEFUNC_SEEK_CUR) == 0)
lSeek=0;
else
err=UNZ_ERRNO;
}
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (zip_readfile(nullptr, s->filestream, extraField, (uLong)uSizeRead) != uSizeRead)
err=UNZ_ERRNO;
lSeek += file_info.size_file_extra - (uLong)uSizeRead;
}
else
lSeek += file_info.size_file_extra;
if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
{
uLong acc = 0;
// since lSeek now points to after the extra field we need to move back
lSeek -= file_info.size_file_extra;
if (lSeek!=0)
{
if (zip_seek64file(nullptr, s->filestream, lSeek, ZLIB_FILEFUNC_SEEK_CUR) == 0)
lSeek=0;
else
err=UNZ_ERRNO;
}
while(acc < file_info.size_file_extra)
{
uLong headerId;
uLong dataSize;
if (unz64local_getShort(nullptr, s->filestream,&headerId) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&dataSize) != UNZ_OK)
err=UNZ_ERRNO;
/* ZIP64 extra fields */
if (headerId == 0x0001)
{
uLong uL2;
if (file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
{
if (unz64local_getLong64(nullptr, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
err=UNZ_ERRNO;
}
if (file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
{
if (unz64local_getLong64(nullptr, s->filestream,&file_info.compressed_size) != UNZ_OK)
err=UNZ_ERRNO;
}
if (file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
{
/* Relative Header offset */
if (unz64local_getLong64(nullptr, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info.disk_num_start == (unsigned long)-1)
{
/* Disk Start Number */
if (unz64local_getLong(nullptr, s->filestream, &uL2) != UNZ_OK)
err=UNZ_ERRNO;
}
}
else
{
if (zip_seek64file(nullptr, s->filestream, dataSize, ZLIB_FILEFUNC_SEEK_CUR) != 0)
err=UNZ_ERRNO;
}
acc += 2 + 2 + dataSize;
}
}
if ((err==UNZ_OK) && (szComment!=NULL))
{
uLong uSizeRead ;
if (file_info.size_file_commentfilestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) {
//lSeek=0;
}
else
err=UNZ_ERRNO;
}
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (zip_readfile(nullptr, s->filestream,szComment,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
//lSeek+=file_info.size_file_comment - uSizeRead;
}
//else
// lSeek+=file_info.size_file_comment;
if ((err == UNZ_OK) && (pfile_info != NULL)) {
*pfile_info = file_info;
pfile_info->offset_curfile = file_info_internal.offset_curfile +
s->byte_before_the_zipfile;
}
if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
*pfile_info_internal=file_info_internal;
return err;
}
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem.
*/
int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
unz_file_info64 * pfile_info,
char * szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char* szComment, uLong commentBufferSize)
{
return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
szFileName,fileNameBufferSize,
extraField,extraFieldBufferSize,
szComment,commentBufferSize);
}
int ZEXPORT unzGetCurrentFileInfo (unzFile file,
unz_file_info * pfile_info,
char * szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize)
{
int err;
unz_file_info64 file_info64;
err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
szFileName,fileNameBufferSize,
extraField,extraFieldBufferSize,
nullptr,0);
if (err==UNZ_OK)
{
pfile_info->version = file_info64.version;
pfile_info->version_needed = file_info64.version_needed;
pfile_info->flag = file_info64.flag;
pfile_info->compression_method = file_info64.compression_method;
pfile_info->dosDate = file_info64.dosDate;
pfile_info->crc = file_info64.crc;
pfile_info->size_filename = file_info64.size_filename;
pfile_info->size_file_extra = file_info64.size_file_extra;
pfile_info->size_file_comment = file_info64.size_file_comment;
pfile_info->disk_num_start = file_info64.disk_num_start;
pfile_info->internal_fa = file_info64.internal_fa;
pfile_info->external_fa = file_info64.external_fa;
pfile_info->tmu_date = file_info64.tmu_date,
pfile_info->offset_curfile = file_info64.offset_curfile;
pfile_info->compressed_size = (uLong)file_info64.compressed_size;
pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
}
return err;
}
/*
Set the current file of the zipfile to the first file
with retrieving an information about the file.
return UNZ_OK if there is no problem
*/
int ZEXPORT unzGoToFirstFile64 (unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize)
{
int err=UNZ_OK;
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
s->pos_in_central_dir=s->offset_central_dir;
s->num_file=0;
err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
&s->cur_file_info_internal,
szFileName,fileNameBufferSize,NULL,0,NULL,0);
s->current_file_ok = (err == UNZ_OK);
if (pfile_info)
*pfile_info = s->cur_file_info;
return err;
}
/*
Set the current file of the zipfile to the next file
with retrieving an information about the file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
int ZEXPORT unzGoToNextFile64 (unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize)
{
unz64_s* s;
int err;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
if (!s->current_file_ok)
return UNZ_END_OF_LIST_OF_FILE;
if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
if (s->num_file+1==s->gi.number_entry)
return UNZ_END_OF_LIST_OF_FILE;
s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
s->num_file++;
err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
&s->cur_file_info_internal,
szFileName,fileNameBufferSize,NULL,0,NULL,0);
s->current_file_ok = (err == UNZ_OK);
if (pfile_info)
*pfile_info = s->cur_file_info;
return err;
}
/*
///////////////////////////////////////////
// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
// I need random access
//
// Further optimization could be realized by adding an ability
// to cache the directory in memory. The goal being a single
// comprehensive file read to put the file I need in a memory.
*/
/*
typedef struct unz_file_pos_s
{
ZPOS64_T pos_in_zip_directory; // offset in file
ZPOS64_T num_of_file; // # of file
} unz_file_pos;
*/
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos)
{
unz64_s* s;
if (file==NULL || file_pos==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
if (!s->current_file_ok)
return UNZ_END_OF_LIST_OF_FILE;
file_pos->pos_in_zip_directory = s->pos_in_central_dir;
file_pos->num_of_file = s->num_file;
return UNZ_OK;
}
int ZEXPORT unzGetFilePos(
unzFile file,
unz_file_pos* file_pos)
{
unz64_file_pos file_pos64;
int err = unzGetFilePos64(file,&file_pos64);
if (err==UNZ_OK)
{
file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
file_pos->num_of_file = (uLong)file_pos64.num_of_file;
}
return err;
}
int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
{
unz64_s* s;
int err;
if (file==NULL || file_pos==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
/* jump to the right spot */
s->pos_in_central_dir = file_pos->pos_in_zip_directory;
s->num_file = file_pos->num_of_file;
/* set the current file */
err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
&s->cur_file_info_internal,
NULL,0,NULL,0,NULL,0);
/* return results */
s->current_file_ok = (err == UNZ_OK);
return err;
}
int ZEXPORT unzGoToFilePos(
unzFile file,
unz_file_pos* file_pos)
{
unz64_file_pos file_pos64;
if (file_pos == NULL)
return UNZ_PARAMERROR;
file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
file_pos64.num_of_file = file_pos->num_of_file;
return unzGoToFilePos64(file,&file_pos64);
}
/*
// Unzip Helper Functions - should be here?
///////////////////////////////////////////
*/
/*
Read the local header of the current zipfile
Check the coherency of the local header and info in the end of central
directory about this file
store in *piSizeVar the size of extra info in local header
(filename and size of extra field data)
*/
local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
ZPOS64_T * poffset_local_extrafield,
uInt * psize_local_extrafield)
{
uLong uMagic,uData,uFlags;
uLong size_filename;
uLong size_extra_field;
int err=UNZ_OK;
*piSizeVar = 0;
*poffset_local_extrafield = 0;
*psize_local_extrafield = 0;
if (zip_seek64file(nullptr, s->filestream,s->cur_file_info_internal.offset_curfile +
s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
return UNZ_ERRNO;
if (err==UNZ_OK)
{
if (unz64local_getLong(nullptr, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE;
}
if (unz64local_getShort(nullptr, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
/*
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
err=UNZ_BADZIPFILE;
*/
if (unz64local_getShort(nullptr, s->filestream,&uFlags) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getShort(nullptr, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
err=UNZ_BADZIPFILE;
if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
/* #ifdef HAVE_BZIP2 */
(s->cur_file_info.compression_method!=Z_BZIP2ED) &&
/* #endif */
(s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;
if (unz64local_getLong(nullptr, s->filestream,&uData) != UNZ_OK) /* date/time */
err=UNZ_ERRNO;
if (unz64local_getLong(nullptr, s->filestream,&uData) != UNZ_OK) /* crc */
err=UNZ_ERRNO;
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
err=UNZ_BADZIPFILE;
if (unz64local_getLong(nullptr, s->filestream,&uData) != UNZ_OK) /* size compr */
err=UNZ_ERRNO;
else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
err=UNZ_BADZIPFILE;
if (unz64local_getLong(nullptr, s->filestream,&uData) != UNZ_OK) /* size uncompr */
err=UNZ_ERRNO;
else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
err=UNZ_BADZIPFILE;
if (unz64local_getShort(nullptr, s->filestream,&size_filename) != UNZ_OK)
err=UNZ_ERRNO;
else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
err=UNZ_BADZIPFILE;
*piSizeVar += (uInt)size_filename;
if (unz64local_getShort(nullptr, s->filestream,&size_extra_field) != UNZ_OK)
err=UNZ_ERRNO;
*poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
SIZEZIPLOCALHEADER + size_filename;
*psize_local_extrafield = (uInt)size_extra_field;
*piSizeVar += (uInt)size_extra_field;
return err;
}
/*
Open for reading data the current file in the zipfile.
If there is no error and the file is opened, the return value is UNZ_OK.
*/
int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
int* level, int raw, const char* password)
{
int err=UNZ_OK;
uInt iSizeVar;
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
ZPOS64_T offset_local_extrafield; /* offset of the local extra field */
uInt size_local_extrafield; /* size of the local extra field */
# ifndef NOUNCRYPT
char source[12];
# else
if (password != NULL)
return UNZ_PARAMERROR;
# endif
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
if (!s->current_file_ok)
return UNZ_PARAMERROR;
if (s->pfile_in_zip_read != NULL)
unzCloseCurrentFile(file);
if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
return UNZ_BADZIPFILE;
pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
if (pfile_in_zip_read_info==NULL)
return UNZ_INTERNALERROR;
pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
pfile_in_zip_read_info->pos_local_extrafield=0;
pfile_in_zip_read_info->raw=raw;
if (pfile_in_zip_read_info->read_buffer==NULL)
{
TRYFREE(pfile_in_zip_read_info);
return UNZ_INTERNALERROR;
}
pfile_in_zip_read_info->stream_initialised=0;
if (method!=NULL)
*method = (int)s->cur_file_info.compression_method;
if (level!=NULL)
{
*level = 6;
switch (s->cur_file_info.flag & 0x06)
{
case 6 : *level = 1; break;
case 4 : *level = 2; break;
case 2 : *level = 9; break;
}
}
if ((s->cur_file_info.compression_method!=0) &&
/* #ifdef HAVE_BZIP2 */
(s->cur_file_info.compression_method!=Z_BZIP2ED) &&
/* #endif */
(s->cur_file_info.compression_method!=Z_DEFLATED)) {
//err=UNZ_BADZIPFILE;
}
pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
pfile_in_zip_read_info->crc32=0;
pfile_in_zip_read_info->total_out_64=0;
pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
pfile_in_zip_read_info->filestream=s->filestream;
//pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
pfile_in_zip_read_info->stream.total_out = 0;
if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
{
#ifdef HAVE_BZIP2
pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
pfile_in_zip_read_info->bstream.state = (voidpf)0;
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
pfile_in_zip_read_info->stream.zfree = (free_func)0;
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
pfile_in_zip_read_info->stream.next_in = (voidpf)0;
pfile_in_zip_read_info->stream.avail_in = 0;
err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
if (err == Z_OK)
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
else
{
TRYFREE(pfile_in_zip_read_info);
return err;
}
#else
pfile_in_zip_read_info->raw=1;
#endif
}
else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
{
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
pfile_in_zip_read_info->stream.zfree = (free_func)0;
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
pfile_in_zip_read_info->stream.next_in = 0;
pfile_in_zip_read_info->stream.avail_in = 0;
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
if (err == Z_OK)
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else
{
TRYFREE(pfile_in_zip_read_info);
return err;
}
/* windowBits is passed < 0 to tell that there is no zlib header.
* Note that in this case inflate *requires* an extra "dummy" byte
* after the compressed stream in order to complete decompression and
* return Z_STREAM_END.
* In unzip, i don't wait absolutely Z_STREAM_END because I known the
* size of both compressed and uncompressed data
*/
}
pfile_in_zip_read_info->rest_read_compressed =
s->cur_file_info.compressed_size ;
pfile_in_zip_read_info->rest_read_uncompressed =
s->cur_file_info.uncompressed_size ;
pfile_in_zip_read_info->pos_in_zipfile =
s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
iSizeVar;
pfile_in_zip_read_info->stream.avail_in = (uInt)0;
s->pfile_in_zip_read = pfile_in_zip_read_info;
s->encrypted = 0;
# ifndef NOUNCRYPT
if (password != NULL)
{
int i;
s->pcrc_32_tab = get_crc_table();
init_keys(password,s->keys,s->pcrc_32_tab);
if (zip_seek64file(s->z_filefunc, s->filestream,
s->pfile_in_zip_read->pos_in_zipfile +
s->pfile_in_zip_read->byte_before_the_zipfile,
SEEK_SET)!=0)
return UNZ_INTERNALERROR;
if(zip_readfile(s->z_filefunc, s->filestream,source, 12)<12)
return UNZ_INTERNALERROR;
for (i = 0; i<12; i++)
zdecode(s->keys,s->pcrc_32_tab,source[i]);
s->pfile_in_zip_read->pos_in_zipfile+=12;
s->encrypted=1;
}
# endif
return UNZ_OK;
}
int ZEXPORT unzOpenCurrentFile (unzFile file)
{
return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
}
/** Addition for GDAL : START */
ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
s=(unz64_s*)file;
if (file==NULL)
return 0; //UNZ_PARAMERROR;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return 0; //UNZ_PARAMERROR;
return pfile_in_zip_read_info->pos_in_zipfile +
pfile_in_zip_read_info->byte_before_the_zipfile;
}
/** Addition for GDAL : END */
/*
Read bytes from the current file.
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if some bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
{
int err=UNZ_OK;
uInt iRead = 0;
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
if (pfile_in_zip_read_info->read_buffer == NULL)
return UNZ_END_OF_LIST_OF_FILE;
if (len==0)
return 0;
pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
pfile_in_zip_read_info->stream.avail_out = (uInt)len;
if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
(!(pfile_in_zip_read_info->raw)))
pfile_in_zip_read_info->stream.avail_out =
(uInt)pfile_in_zip_read_info->rest_read_uncompressed;
if ((len>pfile_in_zip_read_info->rest_read_compressed+
pfile_in_zip_read_info->stream.avail_in) &&
(pfile_in_zip_read_info->raw))
pfile_in_zip_read_info->stream.avail_out =
(uInt)pfile_in_zip_read_info->rest_read_compressed+
pfile_in_zip_read_info->stream.avail_in;
while (pfile_in_zip_read_info->stream.avail_out>0)
{
if ((pfile_in_zip_read_info->stream.avail_in==0) &&
(pfile_in_zip_read_info->rest_read_compressed>0))
{
uInt uReadThis = UNZ_BUFSIZE;
if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed;
if (uReadThis == 0)
return UNZ_EOF;
if (zip_seek64file(nullptr,
pfile_in_zip_read_info->filestream,
pfile_in_zip_read_info->pos_in_zipfile +
pfile_in_zip_read_info->byte_before_the_zipfile,
ZLIB_FILEFUNC_SEEK_SET)!=0)
return UNZ_ERRNO;
if (zip_readfile(nullptr,
pfile_in_zip_read_info->filestream,
pfile_in_zip_read_info->read_buffer,
uReadThis)!=uReadThis)
return UNZ_ERRNO;
# ifndef NOUNCRYPT
if(s->encrypted)
{
uInt i;
for(i=0;iread_buffer[i] =
zdecode(s->keys,s->pcrc_32_tab,
pfile_in_zip_read_info->read_buffer[i]);
}
# endif
pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
pfile_in_zip_read_info->stream.next_in =
(Bytef*)pfile_in_zip_read_info->read_buffer;
pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
}
if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
{
uInt uDoCopy,i ;
if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
(pfile_in_zip_read_info->rest_read_compressed == 0))
return (iRead==0) ? UNZ_EOF : iRead;
if (pfile_in_zip_read_info->stream.avail_out <
pfile_in_zip_read_info->stream.avail_in)
uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
else
uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
for (i=0;istream.next_out+i) =
*(pfile_in_zip_read_info->stream.next_in+i);
pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
pfile_in_zip_read_info->stream.next_out,
uDoCopy);
pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
pfile_in_zip_read_info->stream.next_out += uDoCopy;
pfile_in_zip_read_info->stream.next_in += uDoCopy;
pfile_in_zip_read_info->stream.total_out += uDoCopy;
iRead += uDoCopy;
}
else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
{
#ifdef HAVE_BZIP2
uLong uTotalOutBefore,uTotalOutAfter;
const Bytef *bufBefore;
uLong uOutThis;
pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in;
pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in;
pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in;
pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out;
pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out;
pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
uOutThis = uTotalOutAfter-uTotalOutBefore;
pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
if (err==BZ_STREAM_END)
return (iRead==0) ? UNZ_EOF : iRead;
if (err!=BZ_OK)
break;
#endif
} // end Z_BZIP2ED
else
{
ZPOS64_T uTotalOutBefore,uTotalOutAfter;
const Bytef *bufBefore;
ZPOS64_T uOutThis;
int flush=Z_SYNC_FLUSH;
uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
bufBefore = pfile_in_zip_read_info->stream.next_out;
/*
if ((pfile_in_zip_read_info->rest_read_uncompressed ==
pfile_in_zip_read_info->stream.avail_out) &&
(pfile_in_zip_read_info->rest_read_compressed == 0))
flush = Z_FINISH;
*/
err=inflate(&pfile_in_zip_read_info->stream,flush);
if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
err = Z_DATA_ERROR;
uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
uOutThis = uTotalOutAfter-uTotalOutBefore;
pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
pfile_in_zip_read_info->crc32 =
crc32(pfile_in_zip_read_info->crc32,bufBefore,
(uInt)(uOutThis));
pfile_in_zip_read_info->rest_read_uncompressed -=
uOutThis;
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
if (err==Z_STREAM_END)
return (iRead==0) ? UNZ_EOF : iRead;
if (err!=Z_OK)
break;
}
}
if (err==Z_OK)
return iRead;
return err;
}
/*
Give the current position in uncompressed data
*/
z_off_t ZEXPORT unztell (unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
return (z_off_t)pfile_in_zip_read_info->stream.total_out;
}
ZPOS64_T ZEXPORT unztell64 (unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return (ZPOS64_T)-1;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return (ZPOS64_T)-1;
return pfile_in_zip_read_info->total_out_64;
}
/*
return 1 if the end of file was reached, 0 elsewhere
*/
int ZEXPORT unzeof (unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
return 1;
else
return 0;
}
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header)
if buf==NULL, it return the size of the local extra field that can be read
if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf.
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
uInt read_now;
ZPOS64_T size_to_read;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
pfile_in_zip_read_info->pos_local_extrafield);
if (buf==NULL)
return (int)size_to_read;
if (len>size_to_read)
read_now = (uInt)size_to_read;
else
read_now = (uInt)len ;
if (read_now==0)
return 0;
if (zip_seek64file(nullptr,
pfile_in_zip_read_info->filestream,
pfile_in_zip_read_info->offset_local_extrafield +
pfile_in_zip_read_info->pos_local_extrafield,
ZLIB_FILEFUNC_SEEK_SET)!=0)
return UNZ_ERRNO;
if (zip_readfile(nullptr,
pfile_in_zip_read_info->filestream,
buf,read_now)!=read_now)
return UNZ_ERRNO;
return (int)read_now;
}
/*
Close the file in zip opened with unzipOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
int ZEXPORT unzCloseCurrentFile (unzFile file)
{
int err=UNZ_OK;
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
(!pfile_in_zip_read_info->raw))
{
if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
err=UNZ_CRCERROR;
}
TRYFREE(pfile_in_zip_read_info->read_buffer);
pfile_in_zip_read_info->read_buffer = NULL;
if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
inflateEnd(&pfile_in_zip_read_info->stream);
#ifdef HAVE_BZIP2
else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
#endif
pfile_in_zip_read_info->stream_initialised = 0;
TRYFREE(pfile_in_zip_read_info);
s->pfile_in_zip_read=NULL;
return err;
}
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0
*/
int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
{
unz64_s* s;
uLong uReadThis ;
if (file==NULL)
return (int)UNZ_PARAMERROR;
s=(unz64_s*)file;
uReadThis = uSizeBuf;
if (uReadThis>s->gi.size_comment)
uReadThis = s->gi.size_comment;
if (zip_seek64file(nullptr,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
return UNZ_ERRNO;
if (uReadThis>0)
{
*szComment='\0';
if (zip_readfile(nullptr, s->filestream, szComment, uReadThis) != uReadThis)
return UNZ_ERRNO;
}
if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
*(szComment+s->gi.size_comment)='\0';
return (int)uReadThis;
}
/* Additions by RX '2004 */
ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
{
unz64_s* s;
if (file==NULL)
return 0; //UNZ_PARAMERROR;
s=(unz64_s*)file;
if (!s->current_file_ok)
return 0;
if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
if (s->num_file==s->gi.number_entry)
return 0;
return s->pos_in_central_dir;
}
uLong ZEXPORT unzGetOffset (unzFile file)
{
ZPOS64_T offset64;
if (file==NULL)
return 0; //UNZ_PARAMERROR;
offset64 = unzGetOffset64(file);
return (uLong)offset64;
}
int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
{
unz64_s* s;
int err;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
s->pos_in_central_dir = pos;
s->num_file = s->gi.number_entry; /* hack */
err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
&s->cur_file_info_internal,
NULL,0,NULL,0,NULL,0);
s->current_file_ok = (err == UNZ_OK);
return err;
}
int ZEXPORT unzSetOffset (unzFile file, uLong pos)
{
return unzSetOffset64(file,pos);
}
class ZipArchive : public tTVPArchive {
unzFile uf;
typedef std::pair FileEntry;
std::vector filelist;
public:
~ZipArchive();
ZipArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName);
bool isValid() { return uf != nullptr; }
virtual tjs_uint GetCount() { return filelist.size(); }
virtual ttstr GetName(tjs_uint idx) { return filelist[idx].first; }
virtual tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx);
tTJSBinaryStream *_st = nullptr;
};
static uLong zip_readfile(voidpf, voidpf s, void *buf, uLong size) {
return ((ZipArchive*)s)->_st->Read(buf, size);
}
static uLong zip_writefile(voidpf, voidpf s, const void *buf, uLong size) {
return ((ZipArchive*)s)->_st->Write(buf, size);
}
static ZPOS64_T zip_tell64file(voidpf, voidpf s) {
return ((ZipArchive*)s)->_st->GetPosition();
}
static long zip_seek64file(voidpf, voidpf s, ZPOS64_T offset, int origin) {
((ZipArchive*)s)->_st->Seek(offset, origin);
return 0;
}
tTVPArchive * TVPOpenZIPArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName) {
tjs_uint64 pos = st->GetPosition();
bool checkZIP = st->ReadI16LE() == 0x4B50; // 'PK'
st->SetPosition(pos);
if (!checkZIP) return nullptr;
ZipArchive *arc = new ZipArchive(name, st, normalizeFileName);
if (!arc->isValid()) {
arc->_st = nullptr;
delete arc;
return nullptr;
}
return arc;
}
tTJSBinaryStream * ZipArchive::CreateStreamByIndex(tjs_uint idx) {
if (unzGoToFilePos64(uf, &filelist[idx].second) != UNZ_OK) return nullptr;
// decompress and hold in memory for random access
unz_file_info file_info;
if (unzGetCurrentFileInfo(uf, &file_info, NULL, 0, NULL, 0) != UNZ_OK) return nullptr;
if (file_info.compression_method == 0) { // uncompressed
uInt iSizeVar;
ZPOS64_T offset_local_extrafield; /* offset of the local extra field */
uInt size_local_extrafield; /* size of the local extra field */
if (unz64local_CheckCurrentFileCoherencyHeader((unz64_s*)uf, &iSizeVar, &offset_local_extrafield, &size_local_extrafield) != UNZ_OK)
return nullptr;
return new TArchiveStream(this, file_info.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar, file_info.uncompressed_size);
} else {
if (unzOpenCurrentFile(uf) != UNZ_OK) return nullptr;
tTVPMemoryStream *mem = new tTVPMemoryStream();
mem->SetSize(file_info.uncompressed_size);
unzReadCurrentFile(uf, mem->GetInternalBuffer(), file_info.uncompressed_size);
unzCloseCurrentFile(uf);
return mem;
}
}
ZipArchive::~ZipArchive() {
if (uf) {
unzClose(uf);
uf = NULL;
}
if (_st) {
delete _st;
_st = nullptr;
}
}
void storeFilename(ttstr &name, const char *narrowName, const ttstr &filename);
ZipArchive::ZipArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName) : tTVPArchive(name) {
if (!st) st = TVPCreateStream(name);
_st = st;
if ((uf = unzOpenInternal(this, &zipfunc, 1)) != NULL) {
//unzGoToFirstFile64(uf, NULL, NULL, 0);
unz_file_info file_info;
do {
unz64_file_pos entry;
if (unzGetFilePos64(uf, &entry) == UNZ_OK) {
ttstr filename;
char filename_inzip[1024];
if (unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0) == UNZ_OK) {
storeFilename(filename, filename_inzip, name);
if (normalizeFileName)
NormalizeInArchiveStorageName(filename);
filelist.emplace_back(filename, entry);
}
}
} while (unzGoToNextFile64(uf, NULL, NULL, 0) == UNZ_OK);
if (normalizeFileName) {
std::sort(filelist.begin(), filelist.end(), [](const FileEntry& a, const FileEntry& b) {
return a.first < b.first;
});
}
}
}
================================================
FILE: src/core/base/common.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000-2007 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// TVP2 common header file
//---------------------------------------------------------------------------
#ifndef __CommonH__
#define __CommonH__
#include "tjsConfig.h"
#include "config.h"
#include
using namespace TJS;
typedef std::basic_string stdstring;
typedef std::basic_string stdnstring;
#endif
================================================
FILE: src/core/base/tar.h
================================================
#ifndef __TAR_H
#define __TAR_H
/*
* tar header block definition
*
* From IEEE Std 1003.1-1988, pp.156
*/
//POSIX magic
#define TMAGIC "ustar"
#define TMAGLEN 6
//GNU magic+version:
#define TOMAGIC "ustar "
#define TOMAGLEN 8
//POSIX version
#define TVERSION "00"
#define TVERSLEN 2
#define REGTYPE '0' /* Regular file */
#define AREGTYPE '\0' /* Regular file; old V7 format */
#define LNKTYPE '1' /* Link */
#define SYMTYPE '2' /* Symbolic link */
#define CHRTYPE '3' /* Character special */
#define BLKTYPE '4' /* Block special */
#define DIRTYPE '5' /* Directory */
#define FIFOTYPE '6' /* FIFO special */
#define CONTTYPE '7' /* Continguous file */
#define LONGLINK 'L' /* Long name Link by tantan*/
#define PAX_ENTRTY 'x' /* PAX header block for file entry : added by claybird 2011.11.29 */
#define PAX_GLOBAL 'g' /* PAX global extended header : added by claybird 2011.11.29 */
#define MULTYPE 'M' /* Added by GNUtar, not POSIX */
#define VOLTYPE 'V' /* Added by GNUtar, not POSIX */
#define TSUID 04000 /* Set UID on execution */
#define TSGID 02000 /* Set GID on execution */
#define TSVTX 01000 /* Reserved */
/* File permissions */
#define TUREAD 00400 /* read by owner */
#define TUWRITE 00200 /* write by owner */
#define TUEXEC 00100 /* execute/search by owner */
#define TGREAD 00040 /* read by group */
#define TGWRITE 00020 /* write by group */
#define TGEXEC 00010 /* execute/search by group */
#define TOREAD 00004 /* read by other */
#define TOWRITE 00002 /* write by other */
#define TOEXEC 00001 /* execute/search by other */
#define TBLOCK 512
#define NAMSIZ 100
//added by claybird(2009.12.05)
#define TAR_FORMAT_GNU 0
#define TAR_FORMAT_POSIX 1
typedef union hblock {
char dummy[TBLOCK];
struct {
char name[NAMSIZ];
char mode[8];
char uid[8];
char gid[8];
char size[12];
char mtime[12];
char chksum[8];
char typeflag;
char linkname[NAMSIZ];
char magic[6];
char version[2];
char uname[32];
char gname[32];
char devmajor[8];
char devminor[8];
union _exthead{ //header extension
struct _POSIX{ //POSIX ustar format
char prefix[155];
char pad[12];
}posix;
struct _GNU{ //GNUtar format
/* Following fields were added by GNUtar */
char atime[12];
char ctime[12];
char offset[12];
}gnu;
}exthead;
} dbuf;
unsigned int compsum(){
unsigned int sum = 0;
int i;
for(i=0;i and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Script Event Handling and Dispatching
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "EventImpl.h"
#include "SystemControl.h"
#include "ThreadIntf.h"
#include "TickCount.h"
#include "TimerIntf.h"
#include "SysInitIntf.h"
#include "DebugIntf.h"
#include "WindowImpl.h"
//#include
#include "Application.h"
#include "NativeEventQueue.h"
#include "UserEvent.h"
//---------------------------------------------------------------------------
// TVPInvokeEvents
//---------------------------------------------------------------------------
bool TVPEventInvoked = false;
void TVPInvokeEvents()
{
if(TVPEventInvoked) return;
TVPEventInvoked = true;
if(TVPSystemControl)
{
TVPSystemControl->InvokeEvents();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPEventReceived
//---------------------------------------------------------------------------
void TVPEventReceived()
{
TVPEventInvoked = false;
if( TVPSystemControl ) TVPSystemControl->NotifyEventDelivered();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCallDeliverAllEventsOnIdle
//---------------------------------------------------------------------------
void TVPCallDeliverAllEventsOnIdle()
{
if(TVPSystemControl)
{
TVPSystemControl->CallDeliverAllEventsOnIdle();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPBreathe
//---------------------------------------------------------------------------
static bool TVPBreathing = false;
void TVPBreathe()
{
TVPEventDisabled = true; // not to call TVP events...
TVPBreathing = true;
try
{
Application->ProcessMessages(); // do Windows message pumping
}
catch(...)
{
TVPBreathing = false;
TVPEventDisabled = false;
throw;
}
TVPBreathing = false;
TVPEventDisabled = false;
}
//---------------------------------------------------------------------------
bool TVPGetBreathing()
{
// return whether now is in event breathing
return TVPBreathing;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPSystemEventDisabledState
//---------------------------------------------------------------------------
void TVPSetSystemEventDisabledState(bool en)
{
TVPSystemControl->SetEventEnabled( !en );
if(!en) TVPDeliverAllEvents();
}
//---------------------------------------------------------------------------
bool TVPGetSystemEventDisabledState()
{
return !TVPSystemControl->GetEventEnabled();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPContinuousHandlerCallLimitThread
//---------------------------------------------------------------------------
class tTVPContinuousHandlerCallLimitThread : public tTVPThread
{
tjs_uint64 NextEventTick;
tjs_uint64 Interval;
tTVPThreadEvent Event;
tTJSCriticalSection CS;
bool Enabled;
NativeEventQueue EventQueue;
public:
tTVPContinuousHandlerCallLimitThread();
~tTVPContinuousHandlerCallLimitThread();
protected:
void Execute();
void WndProc(NativeEvent& ev) {
EventQueue.HandlerDefault(ev);
}
public:
void SetEnabled(bool enabled);
void SetInterval(tjs_uint64 interval) { Interval = interval; }
} static * TVPContinuousHandlerCallLimitThread = NULL;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
tTVPContinuousHandlerCallLimitThread::tTVPContinuousHandlerCallLimitThread()
: tTVPThread(true), EventQueue(this,&tTVPContinuousHandlerCallLimitThread::WndProc)
{
NextEventTick = 0;
Interval = (1<> TVP_SUBMILLI_FRAC_BITS) +
((sleeptime_64 & ((1<BeginContinuousEvent();
}
else
{
// has limit
if(!TVPContinuousHandlerCallLimitThread)
TVPContinuousHandlerCallLimitThread = new tTVPContinuousHandlerCallLimitThread();
TVPContinuousHandlerCallLimitThread->SetInterval(
(1<SetEnabled(true);
}
}
// TVPEnsureVSyncTimingThread();
// if we wait vsync, the continuous handler will be executed at the every timing of
// vsync.
}
//---------------------------------------------------------------------------
void TVPEndContinuousEvent()
{
// anyway
if(TVPContinuousHandlerCallLimitThread)
TVPContinuousHandlerCallLimitThread->SetEnabled(false);
// anyway
if(TVPSystemControl) TVPSystemControl->EndContinuousEvent();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
static void TVPReleaseContinuousHandlerCallLimitThread()
{
if(TVPContinuousHandlerCallLimitThread)
delete TVPContinuousHandlerCallLimitThread,
TVPContinuousHandlerCallLimitThread = NULL;
}
// to release TVPContinuousHandlerCallLimitThread at exit
static tTVPAtExit TVPTimerThreadUninitAtExit(TVP_ATEXIT_PRI_SHUTDOWN,
TVPReleaseContinuousHandlerCallLimitThread);
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/win32/EventImpl.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Script Event Handling and Dispatching
//---------------------------------------------------------------------------
#ifndef EventImplH
#define EventImplH
#include "EventIntf.h"
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/win32/FileSelector.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// File Selector dialog box
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
// #include
// #include
#include "MsgIntf.h"
#include "StorageImpl.h"
#include "WindowImpl.h"
#include "SysInitIntf.h"
#include "DebugIntf.h"
#include "TVPScreen.h"
std::string TVPShowFileSelector(
const std::string &title,
const std::string &filename,
std::string initdir,
bool issave
);
//---------------------------------------------------------------------------
// TVPSelectFile related
//---------------------------------------------------------------------------
#define TVP_OLD_OFN_STRUCT_SIZE 76
//---------------------------------------------------------------------------
#if 0
static tjs_int TVPLastScreenWidth = 0;
static tjs_int TVPLastScreenHeight = 0;
static tjs_int TVPLastOFNLeft = -30000;
static tjs_int TVPLastOFNTop = -30000;
static UINT_PTR APIENTRY TVPOFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam,
LPARAM lParam)
{
if(uiMsg == WM_INITDIALOG)
{
int left, top;
HWND parent = GetParent(hdlg);
if((TVPLastOFNLeft == -30000 && TVPLastOFNTop == -30000) ||
TVPLastScreenWidth != tTVPScreen::GetWidth() || TVPLastScreenHeight != tTVPScreen::GetHeight() )
{
// center the window
RECT rect;
GetWindowRect(parent, &rect);
left = ((tTVPScreen::GetWidth() - rect.right + rect.left) / 2);
top = ((tTVPScreen::GetHeight() - rect.bottom + rect.top) / 3);
}
else
{
// set last position
left = TVPLastOFNLeft;
top = TVPLastOFNTop;
}
TVPLastScreenWidth = tTVPScreen::GetWidth();
TVPLastScreenHeight = tTVPScreen::GetHeight();
SetWindowPos(parent, 0,
left,
top,
0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
}
else if(uiMsg == WM_DESTROY ||
(uiMsg == WM_NOTIFY && ((OFNOTIFY*)lParam)->hdr.code == CDN_FILEOK))
{
HWND parent = GetParent(hdlg);
RECT rect;
GetWindowRect(parent, &rect);
TVPLastOFNLeft = rect.left;
TVPLastOFNTop = rect.top;
}
return 0;
}
//---------------------------------------------------------------------------
static void TVPPushFilterPair(std::vector &filters, std::wstring filter)
{
std::wstring::size_type vpos = filter.find_first_of(L"|");
if( vpos != std::wstring::npos )
{
std::wstring name = filter.substr(0, vpos);
std::wstring wild = filter.c_str() + vpos+1;
filters.push_back(name);
filters.push_back(wild);
}
else
{
filters.push_back(filter);
filters.push_back(filter);
}
}
#endif
//---------------------------------------------------------------------------
bool TVPSelectFile(iTJSDispatch2 *params)
{
// show open dialog box
// NOTE: currently this only shows ANSI version of file open dialog.
tTJSVariant val;
std::string initialdir;
std::string title;
std::string defaultext;
#if 0
wchar_t* filter = NULL;
wchar_t* filename = NULL;
BOOL result;
try
{
// prepare OPENFILENAME structure
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = TVPGetModalWindowOwnerHandle();
if( ofn.hwndOwner == INVALID_HANDLE_VALUE ) {
ofn.hwndOwner = NULL;
}
ofn.hInstance = NULL;
// set application window position to current window position
// get filter
ofn.lpstrFilter = NULL;
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("filter"), 0,
&val, params)))
{
std::vector filterlist;
if(val.Type() != tvtObject)
{
TVPPushFilterPair(filterlist, ttstr(val).AsStdString());
}
else
{
iTJSDispatch2 * array = val.AsObjectNoAddRef();
tjs_int count;
tTJSVariant tmp;
if(TJS_SUCCEEDED(array->PropGet(TJS_MEMBERMUSTEXIST,
TJS_W("count"), 0, &tmp, array)))
count = tmp;
else
count = 0;
for(tjs_int i = 0; i < count; i++)
{
if(TJS_SUCCEEDED(array->PropGetByNum(TJS_MEMBERMUSTEXIST,
i, &tmp, array)))
{
TVPPushFilterPair(filterlist, ttstr(tmp).AsStdString());
}
}
}
// create filter buffer
tjs_int bufsize = 2;
for(std::vector::iterator i = filterlist.begin(); i != filterlist.end(); i++)
{
bufsize += (tjs_int)(i->length() + 1);
}
filter = new wchar_t[bufsize];
wchar_t* p = filter;
for(std::vector::iterator i = filterlist.begin(); i != filterlist.end(); i++)
{
TJS_strcpy(p, i->c_str());
p += i->length() + 1;
}
*(p++) = 0;
*(p++) = 0;
ofn.lpstrFilter = filter;
}
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("filterIndex"), 0, &val, params)))
ofn.nFilterIndex = (tjs_int)val;
else
ofn.nFilterIndex = 0;
// filenames
filename = new wchar_t[MAX_PATH + 1];
filename[0] = 0;
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("name"), 0, &val, params)))
{
ttstr lname(val);
if(!lname.IsEmpty())
{
lname = TVPNormalizeStorageName(lname);
TVPGetLocalName(lname);
std::wstring name = lname.AsStdString();
TJS_strncpy(filename, name.c_str(), MAX_PATH);
filename[MAX_PATH] = 0;
}
}
ofn.lpstrFile = filename;
ofn.nMaxFile = MAX_PATH + 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
// initial dir
ofn.lpstrInitialDir = NULL;
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("initialDir"), 0, &val, params)))
{
ttstr lname(val);
if(!lname.IsEmpty())
{
lname = TVPNormalizeStorageName(lname);
TVPGetLocalName(lname);
initialdir = lname.AsStdString();
ofn.lpstrInitialDir = initialdir.c_str();
}
}
// title
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("title"), 0, &val, params)))
{
title = ttstr(val).AsStdString();
ofn.lpstrTitle = title.c_str();
}
else
{
ofn.lpstrTitle = NULL;
}
// flags
bool issave = false;
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("save"), 0, &val, params)))
issave = val.operator bool();
ofn.Flags = OFN_ENABLEHOOK|OFN_EXPLORER|OFN_NOCHANGEDIR|
OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_ENABLESIZING;
if(!issave)
ofn.Flags |= OFN_FILEMUSTEXIST;
else
ofn.Flags |= OFN_OVERWRITEPROMPT;
// default extension
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("defaultExt"), 0, &val, params)))
{
defaultext = ttstr(val).AsStdString();
ofn.lpstrDefExt = defaultext.c_str();
}
else
{
ofn.lpstrDefExt = NULL;
}
// hook proc
ofn.lpfnHook = TVPOFNHookProc;
// show dialog box
if(!issave)
result = GetOpenFileName(&ofn);
else
result = GetSaveFileName(&ofn);
if(!result && CommDlgExtendedError() == CDERR_STRUCTSIZE)
{
// for old windows
// set lStructSize to old Windows' structure size
ofn.lStructSize = TVP_OLD_OFN_STRUCT_SIZE;
if(!issave)
result = GetOpenFileName(&ofn);
else
result = GetSaveFileName(&ofn);
}
if(result)
{
// returns some informations
// filter index
val = (tjs_int)ofn.nFilterIndex;
params->PropSet(TJS_MEMBERENSURE, TJS_W("filterIndex"), 0, &val, params);
// file name
val = TVPNormalizeStorageName(ttstr(filename));
params->PropSet(TJS_MEMBERENSURE, TJS_W("name"), 0, &val, params);
}
}
catch(...)
{
if(filter) delete [] filter;
if(filename) delete [] filename;
throw;
}
delete [] filter;
delete [] filename;
return 0!=result;
#endif
std::string filename;
std::string result;
// get filter
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("filter"), 0,
&val, params)))
{
}
// if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("filterIndex"), 0,
// &val, params)))
// ofn.nFilterIndex = (tjs_int)val;
// else
// ofn.nFilterIndex = 0;
// initial dir
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("initialDir"), 0,
&val, params)))
{
ttstr lname(val);
if (!lname.IsEmpty()){
TVPGetLocalName(lname);
initialdir = tTJSNarrowStringHolder(lname.c_str());
}
}
// default extension
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("defaultExt"), 0,
&val, params)))
{
defaultext = tTJSNarrowStringHolder(val.AsStringNoAddRef()->operator const tjs_char*());
}
// filenames
if (TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("name"), 0,
&val, params)))
{
ttstr lname(val);
if (!lname.IsEmpty())
{
if (lname.IndexOf('/') >= 0) {
lname = TVPNormalizeStorageName(lname);
TVPGetLocalName(lname);
ttstr path = TVPExtractStoragePath(lname);
ttstr name = TVPExtractStorageName(lname);
lname = name;
initialdir = path.AsStdString();
} else {
}
if (!defaultext.empty() && TVPExtractStorageExt(lname).IsEmpty()) {
if (defaultext[0] != '.')
lname += TJS_W(".");
lname += defaultext.c_str();
}
filename = tTJSNarrowStringHolder(lname.c_str());
}
}
// title
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("title"), 0,
&val, params)))
{
title = tTJSNarrowStringHolder(val.AsStringNoAddRef()->operator const tjs_char*());
}
// flags
bool issave = false;
if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("save"), 0,
&val, params)))
issave = val.operator bool();
// show dialog box
result = TVPShowFileSelector(title, filename, initialdir, issave);
if(!result.empty())
{
// returns some informations
// filter index
val = (tjs_int)0;
params->PropSet(TJS_MEMBERENSURE, TJS_W("filterIndex"), 0,
&val, params);
// file name
ttstr tresult = TVPNormalizeStorageName(ttstr(result.c_str()));
val = tresult;
params->PropSet(TJS_MEMBERENSURE, TJS_W("name"), 0,
&val, params);
return true;
}
return false;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/win32/FileSelector.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// File Selector dialog box
//---------------------------------------------------------------------------
#ifndef FileSelectorH
#define FileSelectorH
//---------------------------------------------------------------------------
#include "tjs.h"
extern bool TVPSelectFile(iTJSDispatch2 *params);
#endif
================================================
FILE: src/core/base/win32/FuncStubs.cpp
================================================
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000-2009 W.Dee and contributors
See details of license at "license.txt"
*/
/* This file is always generated by makestub.pl . */
/* Modification by hand will be lost. */
#include "tjsCommHead.h"
#include "tjsVariant.h"
#include "tjsString.h"
#include "PluginImpl.h"
static void __stdcall TVP_Stub_3d4b725f0b4234d79524822e7c34486b(tTJSVariant * _this, iTJSDispatch2 * objthis)
{
return _this->ChangeClosureObjThis(objthis);
}
static void __stdcall TVP_Stub_3fc0c32ee41ea0c515f8fbb681e37982(tTJSVariant * _this)
{
::new (_this) tTJSVariant();
}
static void __stdcall TVP_Stub_e8dbd4fe012262d9da831e0735aa33b3(tTJSVariant * _this, const tTJSVariant & ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_ace6cce1353865d7376caca1f2124216(tTJSVariant * _this, iTJSDispatch2 * ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_5055344aa8055bc238b79e5f88fc3300(tTJSVariant * _this, iTJSDispatch2 * obj , iTJSDispatch2 * objthis)
{
::new (_this) tTJSVariant(obj, objthis);
}
static void __stdcall TVP_Stub_8238c542b814acf1a83c00cced57ba26(tTJSVariant * _this, const tjs_char * ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_bd2a14ca8c345fd7f151b08d1792fb60(tTJSVariant * _this, const tTJSString & ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_16d432f9f86738a7688cbfc9b12441ec(tTJSVariant * _this, const tjs_nchar * ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_6dac00582b8ba529e548ef058c4e869e(tTJSVariant * _this, const tjs_uint8 * ref , tjs_uint len)
{
::new (_this) tTJSVariant(ref, len);
}
static void __stdcall TVP_Stub_9193ae470b5efdfe617b5e94cd8f5da6(tTJSVariant * _this, bool ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_ec455b6ef0f5da178063db3875973260(tTJSVariant * _this, tjs_int32 ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_a56aaf685bd171b63b0ef3c894d80ecf(tTJSVariant * _this, tjs_int64 ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_9a5fe199cebb9841f94ac0bb7a4a3b6a(tTJSVariant * _this, tjs_real ref)
{
::new (_this) tTJSVariant(ref);
}
static void __stdcall TVP_Stub_2acb76a1f86e34afc5fe934d406c6c4c(tTJSVariant * _this, const tjs_uint8 * * src)
{
::new (_this) tTJSVariant(src);
}
static void __stdcall TVP_Stub_3a4d914ca7d24989c236ad223c002d49(tTJSVariant * _this)
{
_this->~tTJSVariant();
}
static tTJSVariantType __stdcall TVP_Stub_8fca7d3a123df1eacf228ba89f6a02ff(tTJSVariant * _this)
{
return _this->Type();
}
static void __stdcall TVP_Stub_58be195f96a36c158d638e3b0c79308b(tTJSVariant * _this)
{
return _this->Clear();
}
static tTJSVariantClosure & __stdcall TVP_Stub_eaa4d5b1d186a807a63311ab6d5e16e4(tTJSVariant * _this)
{
return _this->AsObjectClosure();
}
static void __stdcall TVP_Stub_246f30d208c1d3a4e2b558090f403734(tTJSVariant * _this)
{
return _this->ToObject();
}
static iTJSDispatch2 * __stdcall TVP_Stub_3206ef9b7a8013d6572decdea49e7e2e(tTJSVariant * _this)
{
return _this->operator iTJSDispatch2 *();
}
static void __stdcall TVP_Stub_c5a30d297c3a121879b1392bc6c604ef(tTJSVariant * _this)
{
return _this->ToString();
}
static tjs_uint32 * __stdcall TVP_Stub_e398f5aef0ab92bc1323f3b094722fb1(tTJSVariant * _this)
{
return _this->GetHint();
}
static void __stdcall TVP_Stub_0733b0ac80880897d327dc6f3b04ea9e(tTJSVariant * _this)
{
return _this->ToOctet();
}
static void __stdcall TVP_Stub_4cb055ed9d8ef71d1af10898965c940c(tTJSVariant * _this)
{
return _this->ToInteger();
}
static void __stdcall TVP_Stub_ef8d198596b7d3143d02ed4450ccefa1(tTJSVariant * _this)
{
return _this->ToReal();
}
static tTJSVariant & __stdcall TVP_Stub_d48ea419e040ffe8c20c1e86d80c9a5f(tTJSVariant * _this, const tTJSVariant & ref)
{
return _this->operator =(ref);
}
static void __stdcall TVP_Stub_679b215ff76a269871d5f325b981e561(tTJSVariant * _this, const tTJSVariant & ref)
{
return _this->CopyRef(ref);
}
static tTJSVariant & __stdcall TVP_Stub_1039eff4a4443f9238438485a35a93a7(tTJSVariant * _this, iTJSDispatch2 * ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_2f873b0ee1c6591ba28bc4b9c0e4c954(tTJSVariant * _this, iTJSDispatch2 * ref)
{
return _this->SetObject(ref);
}
static tTJSVariant & __stdcall TVP_Stub_a583ffb56cdb2ede691e15053a8a165a(tTJSVariant * _this, iTJSDispatch2 * object , iTJSDispatch2 * objthis)
{
return _this->SetObject(object, objthis);
}
static tTJSVariant & __stdcall TVP_Stub_e09ed277802c1b117e1908421448886d(tTJSVariant * _this, tTJSVariantClosure ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_e76dfb9e00f4a9d491117d815f30db7f(tTJSVariant * _this, tTJSVariantString * ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_b000dd8934508d8ec6d6ef976a6ff49b(tTJSVariant * _this, tTJSVariantOctet * ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_d98ab5c968ebfde4e924901d09190774(tTJSVariant * _this, const tTJSString & ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_661e8c10d5d477e6823a840244937cd8(tTJSVariant * _this, const tjs_char * ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_6b39e70ea89c4f883689f51289029b69(tTJSVariant * _this, const tjs_nchar * ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_4a18b1c0afe37b84e2b35a7fc07c4e0f(tTJSVariant * _this, bool ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_48b85c8774d91ca40b2992f0e452f19e(tTJSVariant * _this, tjs_int32 ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_5ea8db9a9193fe6bab53baf2bee06b6b(tTJSVariant * _this, const tTVInteger ref)
{
return _this->operator =(ref);
}
static tTJSVariant & __stdcall TVP_Stub_46b92626ff6894e993c4f193a129540b(tTJSVariant * _this, tjs_real ref)
{
return _this->operator =(ref);
}
static void __stdcall TVP_Stub_6efc1d1f66f0e01a81faf767d7576816(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->logicalorequal(rhs);
}
static void __stdcall TVP_Stub_4ededf58eae77c320b4a6f5f701acafb(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->logicalandequal(rhs);
}
static void __stdcall TVP_Stub_028d5fda2f4568f6ab14b49d89650a4d(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator |=(rhs);
}
static void __stdcall TVP_Stub_11912984b8c094d2df26bf3c3677d096(tTJSVariant * _this)
{
return _this->increment();
}
static void __stdcall TVP_Stub_6c0df790c33142e286aea9af6993d931(tTJSVariant * _this)
{
return _this->decrement();
}
static void __stdcall TVP_Stub_c27d85b695cd6e144210785bdfd446ce(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator ^=(rhs);
}
static void __stdcall TVP_Stub_8422ef7f42009be0ad58a09d64149051(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator &=(rhs);
}
static void __stdcall TVP_Stub_ee07e6522577952453206ede39cdf54c(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator >>=(rhs);
}
static void __stdcall TVP_Stub_786a65424247e711f6ca31f0a10603d7(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->rbitshiftequal(rhs);
}
static void __stdcall TVP_Stub_995a222f2038dd2007f2c1f6429bd19e(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator <<=(rhs);
}
static void __stdcall TVP_Stub_da8c6e750d6a9c0557a56ef7f7fd8e88(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator %=(rhs);
}
static void __stdcall TVP_Stub_9cf7b0f119bcf3fa4564837ae25429b3(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator /=(rhs);
}
static void __stdcall TVP_Stub_17cbcacad2ed350215d7d700c676ea40(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->idivequal(rhs);
}
static void __stdcall TVP_Stub_2bd375c0598e9148d88579a51b2f07a8(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator *=(rhs);
}
static void __stdcall TVP_Stub_4d2c157f8b0b49e57c3e9b5abc9deb0f(tTJSVariant * _this)
{
return _this->logicalnot();
}
static void __stdcall TVP_Stub_4b7eaccf64af0f3a4c4fe64f4e2dd3fd(tTJSVariant * _this)
{
return _this->bitnot();
}
static void __stdcall TVP_Stub_3a4d2602c392a8d1f4c38d537a8c95e0(tTJSVariant * _this)
{
return _this->tonumber();
}
static void __stdcall TVP_Stub_8d915d35ef8e857f245c5d46798618e4(tTJSVariant * _this)
{
return _this->changesign();
}
static void __stdcall TVP_Stub_1e463482afa8ca30f5fa7bea4fa5741d(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator -=(rhs);
}
static void __stdcall TVP_Stub_fdf270e4080c986abd1649fa9fffdeab(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator +=(rhs);
}
static tTJSVariantType __stdcall TVP_Stub_972e0f9a6ec4648a9fb82bcf5d9095ff(tTJSVariant * _this)
{
return _this->Type();
}
static bool __stdcall TVP_Stub_9d76731c37c4664d654db026644c64b4(tTJSVariant * _this, const tTJSVariant & val2)
{
return _this->NormalCompare(val2);
}
static bool __stdcall TVP_Stub_4f1620cb699874b9c8cedf6e321c606e(tTJSVariant * _this, const tTJSVariant & val2)
{
return _this->DiscernCompare(val2);
}
static bool __stdcall TVP_Stub_ef1c6b2b601d1b0ff70272a4d447aa3c(tTJSVariant * _this, const tTJSVariant & val2)
{
return _this->DiscernCompareStrictReal(val2);
}
static bool __stdcall TVP_Stub_9b7872860c95cfdafb056ab30318e99c(tTJSVariant * _this, const tTJSVariant & val2)
{
return _this->GreaterThan(val2);
}
static bool __stdcall TVP_Stub_53360f194a04fc142ddae2b9a3ab4c92(tTJSVariant * _this, const tTJSVariant & val2)
{
return _this->LittlerThan(val2);
}
static bool __stdcall TVP_Stub_ce1dcb05e5e7c4cafbc4ed37f63b256e(tTJSVariant * _this, const tjs_char * classname)
{
return _this->IsInstanceOf(classname);
}
static iTJSDispatch2 * __stdcall TVP_Stub_841ce4492b37321eea0c1b500de9b352(tTJSVariant * _this)
{
return _this->AsObject();
}
static iTJSDispatch2 * __stdcall TVP_Stub_61785de870894968cd9d95e17e88eafc(tTJSVariant * _this)
{
return _this->AsObjectNoAddRef();
}
static iTJSDispatch2 * __stdcall TVP_Stub_ad3236e727398311c3b8e1ddd5f4b293(tTJSVariant * _this)
{
return _this->AsObjectThis();
}
static iTJSDispatch2 * __stdcall TVP_Stub_80e0b7be488545ff9b8bc52c9ab5fba5(tTJSVariant * _this)
{
return _this->AsObjectThisNoAddRef();
}
static tTJSVariantClosure & __stdcall TVP_Stub_4eaa3e4efb319707db6ef81db1c6f147(tTJSVariant * _this)
{
return _this->AsObjectClosureNoAddRef();
}
static tTJSVariantString * __stdcall TVP_Stub_693a0152f098caee7fc77f545dd3e954(tTJSVariant * _this)
{
return _this->AsString();
}
static tTJSVariantString * __stdcall TVP_Stub_42840710f5fba9bb32b95290b1796a55(tTJSVariant * _this)
{
return _this->AsStringNoAddRef();
}
static const tjs_char * __stdcall TVP_Stub_adec3f9ef429aa9a284081f0fc6a1b5b(tTJSVariant * _this)
{
return _this->GetString();
}
static tTJSVariantOctet * __stdcall TVP_Stub_674a7948152a1d7a49050b9d98796403(tTJSVariant * _this)
{
return _this->AsOctet();
}
static tTJSVariantOctet * __stdcall TVP_Stub_aa6f132b2031c83062f6149c90f2df5f(tTJSVariant * _this)
{
return _this->AsOctetNoAddRef();
}
static tTVInteger __stdcall TVP_Stub_b52f446e22bb92d495f7e65ac71c9bf9(tTJSVariant * _this)
{
return _this->AsInteger();
}
static void __stdcall TVP_Stub_d4899fd4a8beb06f192dcb1d300e3319(tTJSVariant * _this, tTJSVariant & targ)
{
return _this->AsNumber(targ);
}
static tTVInteger __stdcall TVP_Stub_d3f5ec78464d29ee6988a1f90c2e3e1b(tTJSVariant * _this)
{
return _this->operator tTVInteger();
}
static bool __stdcall TVP_Stub_a463ad6a757c3f04e09a72e288737d06(tTJSVariant * _this)
{
return _this->operator bool();
}
static tjs_int __stdcall TVP_Stub_27857bb89d35113183b682c3917d6c7a(tTJSVariant * _this)
{
return _this->operator tjs_int();
}
static tTVReal __stdcall TVP_Stub_a5f80951cfb882ac6a3e06c0b9a95807(tTJSVariant * _this)
{
return _this->AsReal();
}
static tTVReal __stdcall TVP_Stub_35aadb63079c8bd84ebc0389bae306e0(tTJSVariant * _this)
{
return _this->operator tTVReal();
}
static tTJSVariant __stdcall TVP_Stub_fb6573df5887c2020ae58136f8342ed4(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator ||(rhs);
}
static tTJSVariant __stdcall TVP_Stub_86c67d2197c46824ab10f59e568ad13a(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator &&(rhs);
}
static tTJSVariant __stdcall TVP_Stub_263a0c5b335b2c4d5bc1f55b51b8315e(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator |(rhs);
}
static tTJSVariant __stdcall TVP_Stub_975c1099e57ab67122ddef0f44fd7dd5(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator ^(rhs);
}
static tTJSVariant __stdcall TVP_Stub_04493e5237a7ca97afd391cb7e831ba0(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator &(rhs);
}
static tTJSVariant __stdcall TVP_Stub_9996100acc7705cb2b0c904d6bad4401(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator !=(rhs);
}
static tTJSVariant __stdcall TVP_Stub_5d91cff3b2a26ff7c0543e0f6d737117(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator ==(rhs);
}
static tTJSVariant __stdcall TVP_Stub_ef1dedc2cb58dc4e1afc14238b6fc518(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator <(rhs);
}
static tTJSVariant __stdcall TVP_Stub_f18397fe81c043ba2346e31b359f6a73(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator >(rhs);
}
static tTJSVariant __stdcall TVP_Stub_2ee45ad60b0c06a8d0feebc3a6aad9e7(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator <=(rhs);
}
static tTJSVariant __stdcall TVP_Stub_44500491c57e17032951fe6ed268ff1d(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator >=(rhs);
}
static tTJSVariant __stdcall TVP_Stub_056f5d278c75750df792bf8b081fbf7d(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator >>(rhs);
}
static tTJSVariant __stdcall TVP_Stub_04233bc4f7d4df92c260d23110320afe(tTJSVariant * _this, tjs_int count)
{
return _this->rbitshift(count);
}
static tTJSVariant __stdcall TVP_Stub_cdc475c4419e77c22508e337428c4074(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator <<(rhs);
}
static tTJSVariant __stdcall TVP_Stub_06bacb2910308a47bbe27ff7efa1226d(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator %(rhs);
}
static tTJSVariant __stdcall TVP_Stub_521e053199a4aeb4e0f24d9f4a6cc682(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator /(rhs);
}
static tTJSVariant __stdcall TVP_Stub_02164e6fb4c925843ac774ec1e4c6e5d(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->idiv(rhs);
}
static tTJSVariant __stdcall TVP_Stub_5110cbbcddbd9688281ee5418e3f9023(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator *(rhs);
}
static tTJSVariant __stdcall TVP_Stub_1db54b61f00bf931452218c4a39e79ef(tTJSVariant * _this)
{
return _this->operator !();
}
static tTJSVariant __stdcall TVP_Stub_9d0edd8f51f155767301017bd3d256da(tTJSVariant * _this)
{
return _this->operator ~();
}
static tTJSVariant __stdcall TVP_Stub_8f744c5aa8df5471939b960bc759f12b(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator -(rhs);
}
static tTJSVariant __stdcall TVP_Stub_ba7ff7b0b4192bd2cc7f49c7b688ad57(tTJSVariant * _this)
{
return _this->operator +();
}
static tTJSVariant __stdcall TVP_Stub_7773ac921bb82c85de3be69ef86265fd(tTJSVariant * _this)
{
return _this->operator -();
}
static tTJSVariant __stdcall TVP_Stub_114a781ed71edace31abb352a2671f41(tTJSVariant * _this, const tTJSVariant & rhs)
{
return _this->operator +(rhs);
}
static void * __stdcall TVP_Stub_2bc5f4a97decfa82c625430479ec512b(size_t size)
{
return tTJSVariant::operator new(size);
}
static void __stdcall TVP_Stub_066fb79f94523d95d12480f23c58cc8e(void * p)
{
return tTJSVariant::operator delete(p);
}
static void * __stdcall TVP_Stub_803906b8de16ff825d4e69e1952d872f(size_t size)
{
return tTJSVariant::operator new [](size);
}
static void __stdcall TVP_Stub_34cc96a5118ee1e12b0750ea64d40b1f(void * p)
{
return tTJSVariant::operator delete [](p);
}
static void * __stdcall TVP_Stub_dbe821fb8b651d42a9c8e730517c408c(size_t size , void * buf)
{
return tTJSVariant::operator new(size, buf);
}
static void __stdcall TVP_Stub_8970ba46068ac74746c3e84299937d8f(tTJSVariantOctet * _this, const tjs_uint8 * data , tjs_uint length)
{
::new (_this) tTJSVariantOctet(data, length);
}
static void __stdcall TVP_Stub_438e27dcbb077284213eb4d7dcd43f8f(tTJSVariantOctet * _this, const tjs_uint8 * data1 , tjs_uint len1 , const tjs_uint8 * data2 , tjs_uint len2)
{
::new (_this) tTJSVariantOctet(data1, len1, data2, len2);
}
static void __stdcall TVP_Stub_a98d712ca19a49afe07d0a7c5d064cef(tTJSVariantOctet * _this, const tTJSVariantOctet * o1 , const tTJSVariantOctet * o2)
{
::new (_this) tTJSVariantOctet(o1, o2);
}
static void __stdcall TVP_Stub_08aef69683bcfe2a5c63d4c7866de8e9(tTJSVariantOctet * _this)
{
_this->~tTJSVariantOctet();
}
static void __stdcall TVP_Stub_dbc9bc2e27068c8426b1c6a7f89424e0(tTJSVariantOctet * _this)
{
return _this->AddRef();
}
static void __stdcall TVP_Stub_5eeb98ca016123f57966457533bb639e(tTJSVariantOctet * _this)
{
return _this->Release();
}
static tjs_uint __stdcall TVP_Stub_98fdc846d0b4a83412f3521f65bb98b4(tTJSVariantOctet * _this)
{
return _this->GetLength();
}
static const tjs_uint8 * __stdcall TVP_Stub_3309591d3c7f6f688e81588f169dba21(tTJSVariantOctet * _this)
{
return _this->GetData();
}
static void __stdcall TVP_Stub_d83a866389246d824efcc83303a04484(tTJSString * _this)
{
::new (_this) tTJSString();
}
static void __stdcall TVP_Stub_6cf6f332a6a14a15e8dce62301f5c840(tTJSString * _this, const tTJSString & rhs)
{
::new (_this) tTJSString(rhs);
}
static void __stdcall TVP_Stub_566eeea3c5f009b0fc6fa123ba30f496(tTJSString * _this, tTJSVariantString * vstr)
{
::new (_this) tTJSString(vstr);
}
static void __stdcall TVP_Stub_88806e38e35c73b36acadd4061a4fe0b(tTJSString * _this, const tjs_char * str)
{
::new (_this) tTJSString(str);
}
static void __stdcall TVP_Stub_3bb69d3886159aaecc333b6ff17287bf(tTJSString * _this, const tjs_nchar * str)
{
::new (_this) tTJSString(str);
}
static void __stdcall TVP_Stub_3e36278551a9c8b29cb2e8017db6af0d(tTJSString * _this, const tTJSStringBufferLength len)
{
::new (_this) tTJSString(len);
}
static void __stdcall TVP_Stub_5de99d84f3dc902cb0812fb85a7d5c88(tTJSString * _this, tjs_char rch)
{
::new (_this) tTJSString(rch);
}
static void __stdcall TVP_Stub_31e85cbc73f8fbd4cea895a751480059(tTJSString * _this, const tTJSVariant & val)
{
::new (_this) tTJSString(val);
}
static void __stdcall TVP_Stub_6ae29e405ede762f1a89a9dd526cb36e(tTJSString * _this, const tTJSString & str , int n)
{
::new (_this) tTJSString(str, n);
}
static void __stdcall TVP_Stub_c95bd66d95c153cdac41b5243e555f5f(tTJSString * _this, const tjs_char * str , int n)
{
::new (_this) tTJSString(str, n);
}
static void __stdcall TVP_Stub_72a67e9c52fd27dbb66eded47efeea74(tTJSString * _this, tjs_int n)
{
::new (_this) tTJSString(n);
}
static void __stdcall TVP_Stub_fb13e41bda53e4e59403e3e14effccd6(tTJSString * _this)
{
_this->~tTJSString();
}
static tTJSString & __stdcall TVP_Stub_9a5c710e620e47f105752453ad5d6ab1(tTJSString * _this, const tTJSString & rhs)
{
return _this->operator =(rhs);
}
static tTJSString & __stdcall TVP_Stub_18f1ad16c11429707cbf8ea4d1d4a21e(tTJSString * _this, const tjs_char * rhs)
{
return _this->operator =(rhs);
}
static tTJSString & __stdcall TVP_Stub_550f317b573a1256af00586890ae82f1(tTJSString * _this, const tjs_nchar * rhs)
{
return _this->operator =(rhs);
}
static void __stdcall TVP_Stub_cd50da721dfb63f36c1ebb1226830428(tTJSString * _this, const tTJSString & ref)
{
return _this->operator +=(ref);
}
static void __stdcall TVP_Stub_fbba3dd6a087599d1277ae58f6cec18e(tTJSString * _this, const tTJSVariantString * ref)
{
return _this->operator +=(ref);
}
static void __stdcall TVP_Stub_43cc5b5a61a6090af83333d115b5b868(tTJSString * _this, const tjs_char * ref)
{
return _this->operator +=(ref);
}
static void __stdcall TVP_Stub_616fb5060d81eb5bab58647596582df4(tTJSString * _this, tjs_char rch)
{
return _this->operator +=(rch);
}
static void __stdcall TVP_Stub_168cf4c1b9ef70b98f2e0ab3695a4f3b(tTJSString * _this)
{
return _this->Clear();
}
static tjs_char * __stdcall TVP_Stub_314573cca30a7c2aecc9166fbf5400c9(tTJSString * _this, tjs_uint len)
{
return _this->AllocBuffer(len);
}
static tjs_char * __stdcall TVP_Stub_03da356426c038fad663c836c3e330ef(tTJSString * _this, tjs_uint len)
{
return _this->AppendBuffer(len);
}
static void __stdcall TVP_Stub_31dbebdedc08d75e34a2cd564ce60586(tTJSString * _this)
{
return _this->FixLen();
}
static void __stdcall TVP_Stub_d9224ad7a0de743a7eea15fdb2c5f934(tTJSString * _this, const tTJSString & from , const tTJSString & to , bool forall = true)
{
return _this->Replace(from, to, forall);
}
static void __stdcall TVP_Stub_c01b0720b49ce4f792446d8965d2c31f(tTJSString * _this)
{
return _this->ToLowerCase();
}
static void __stdcall TVP_Stub_4af47e46a11e1357cb994f405289d13e(tTJSString * _this)
{
return _this->ToUppserCase();
}
static tjs_uint32 * __stdcall TVP_Stub_25b6dafa19bfa5bde1a8b519da248f82(tTJSString * _this)
{
return _this->GetHint();
}
static tjs_char * __stdcall TVP_Stub_72425405819c900aec719491cbd90c6d(tTJSString * _this)
{
return _this->Independ();
}
static const tjs_char * __stdcall TVP_Stub_a79942af73f33bff6e432c9fd808e469(tTJSString * _this)
{
return _this->c_str();
}
static tTJSVariantString * __stdcall TVP_Stub_df106470a4141ebc7eda22160859ffdc(tTJSString * _this)
{
return _this->AsVariantStringNoAddRef();
}
static tjs_int64 __stdcall TVP_Stub_469bc225b0ecd9561aae5a46b85ded42(tTJSString * _this)
{
return _this->AsInteger();
}
static bool __stdcall TVP_Stub_a6663c078b3aa79b39ee2d09f3875765(tTJSString * _this, const tTJSString & ref)
{
return _this->operator ==(ref);
}
static bool __stdcall TVP_Stub_efbe634ce4f13633e220cae167cf63fb(tTJSString * _this, const tTJSString & ref)
{
return _this->operator !=(ref);
}
static tjs_int __stdcall TVP_Stub_57f4147bcc09e4e4442ffc9b0895727e(tTJSString * _this, const tTJSString & ref)
{
return _this->CompareIC(ref);
}
static bool __stdcall TVP_Stub_1fb2d2e44cf83aebef7b26fd6b20bc2b(tTJSString * _this, const tjs_char * ref)
{
return _this->operator ==(ref);
}
static bool __stdcall TVP_Stub_bd6aa777bac947f5cffd891e9c724794(tTJSString * _this, const tjs_char * ref)
{
return _this->operator !=(ref);
}
static tjs_int __stdcall TVP_Stub_83c662330b75d616cdc8a4e11d7ababa(tTJSString * _this, const tjs_char * ref)
{
return _this->CompareIC(ref);
}
static bool __stdcall TVP_Stub_bbde02fe30c8a6cadb7073174ea3a874(tTJSString * _this, const tTJSString & ref)
{
return _this->operator <(ref);
}
static bool __stdcall TVP_Stub_cc1c14f63867f90bc883de03e9212cbc(tTJSString * _this, const tTJSString & ref)
{
return _this->operator >(ref);
}
static tTJSString __stdcall TVP_Stub_236e007b32bc2631b5f6dc1eda6be0a9(tTJSString * _this, const tTJSString & ref)
{
return _this->operator +(ref);
}
static tTJSString __stdcall TVP_Stub_cfbb9809e0e6d954b2652856e935ced9(tTJSString * _this, const tjs_char * ref)
{
return _this->operator +(ref);
}
static tTJSString __stdcall TVP_Stub_60ee96ae4a7704340bef20fb35ba6ade(tTJSString * _this, tjs_char rch)
{
return _this->operator +(rch);
}
static tjs_char __stdcall TVP_Stub_564b37278b50f4e5597dff6540868d49(tTJSString * _this, tjs_uint i)
{
return _this->operator [](i);
}
static void __stdcall TVP_Stub_890b3a4831b824653e919b4a5197358d(tTJSString * _this, tTJSString & dest)
{
return _this->AsLowerCase(dest);
}
static void __stdcall TVP_Stub_2dfa6c77c5051d160b8a06f540e0d68b(tTJSString * _this, tTJSString & dest)
{
return _this->AsUpperCase(dest);
}
static void __stdcall TVP_Stub_05f88567d510fd84659ccbf493f647ed(tTJSString * _this, tTJSString & dest)
{
return _this->EscapeC(dest);
}
static void __stdcall TVP_Stub_7166b8f7bb9688c980e4fa172f06f30c(tTJSString * _this, tTJSString & dest)
{
return _this->UnescapeC(dest);
}
static bool __stdcall TVP_Stub_b9456ecba8b7898d80d2e5caa64035c9(tTJSString * _this, const tjs_char * string)
{
return _this->StartsWith(string);
}
static bool __stdcall TVP_Stub_dd44464bd8430a5be5fef0cffcd97117(tTJSString * _this, const tTJSString & string)
{
return _this->StartsWith(string);
}
static tjs_int __stdcall TVP_Stub_a57696ca0c157cd7d3cd4e58c1df957c(tTJSString * _this)
{
return _this->GetNarrowStrLen();
}
static void __stdcall TVP_Stub_1aea9f8a38bbb875b6d052f330da9178(tTJSString * _this, tjs_nchar * dest , tjs_int destmaxlen)
{
return _this->ToNarrowStr(dest, destmaxlen);
}
static bool __stdcall TVP_Stub_2d3b3d6e22ee139cda9eee47dc031945(tTJSString * _this)
{
return _this->IsEmpty();
}
static tjs_int __stdcall TVP_Stub_8ff49e56c3c4c566561dcdd5c9ecc4db(tTJSString * _this)
{
return _this->GetLen();
}
static tjs_int __stdcall TVP_Stub_490b547e93e40082d0b83312467104f9(tTJSString * _this)
{
return _this->length();
}
static tjs_char __stdcall TVP_Stub_2c1ef06748df47df52b586ac0fbc6a34(tTJSString * _this)
{
return _this->GetLastChar();
}
static void * __stdcall TVP_Stub_b6b2a03160b88239eccd18d89b1537d3(size_t size)
{
return tTJSString::operator new(size);
}
static void __stdcall TVP_Stub_8becefbd52c76c7ecb0ea7b7f50b7915(void * p)
{
return tTJSString::operator delete(p);
}
static void * __stdcall TVP_Stub_74b9687a3bfd3b2c7abe226efc4225c1(size_t size)
{
return tTJSString::operator new [](size);
}
static void __stdcall TVP_Stub_7cafc2bf5965b594e60830e3057bbd58(void * p)
{
return tTJSString::operator delete [](p);
}
static void * __stdcall TVP_Stub_80f111939c5694cbf43d07cf0ad1726c(size_t size , void * buf)
{
return tTJSString::operator new(size, buf);
}
static void __stdcall TVP_Stub_8dc9cef84191f79b38403a2070952fd4(tTJSVariantString * _this)
{
return _this->AddRef();
}
static void __stdcall TVP_Stub_1d42bd1e659b36886c20567497b7ee96(tTJSVariantString * _this)
{
return _this->Release();
}
static void __stdcall TVP_Stub_0848fbdc7eeddb12c80bcd9c31383a64(tTJSVariantString * _this, const tjs_char * ref , tjs_int maxlen = - 1)
{
return _this->SetString(ref, maxlen);
}
static void __stdcall TVP_Stub_1f1123c906c28ab6d16b6bef3f7ae978(tTJSVariantString * _this, const tjs_nchar * ref)
{
return _this->SetString(ref);
}
static void __stdcall TVP_Stub_b84394e20cc73a90349cf5be4e783111(tTJSVariantString * _this, tjs_uint len)
{
return _this->AllocBuffer(len);
}
static void __stdcall TVP_Stub_76e0db3797851fe8ff90cf84780c50ad(tTJSVariantString * _this, const tjs_char * ref)
{
return _this->ResetString(ref);
}
static void __stdcall TVP_Stub_6616241156c22bced42cd9f2f647677e(tTJSVariantString * _this, tjs_uint applen)
{
return _this->AppendBuffer(applen);
}
static void __stdcall TVP_Stub_1ace346a3dd546c66ad115a33d8cf693(tTJSVariantString * _this, const tjs_char * str)
{
return _this->Append(str);
}
static void __stdcall TVP_Stub_96fb9bbe33531d4268573355c658e165(tTJSVariantString * _this, const tjs_char * str , tjs_int applen)
{
return _this->Append(str, applen);
}
static tTJSVariantString * __stdcall TVP_Stub_c90b5737134c76f9ed0bb5da7cfaad8c(tTJSVariantString * _this)
{
return _this->FixLength();
}
static tjs_uint32 * __stdcall TVP_Stub_070ed05259a265cabdd82bfedabdd638(tTJSVariantString * _this)
{
return _this->GetHint();
}
static const tjs_char * __stdcall TVP_Stub_008b7e3a4c5bb23ee991f684a5064737(tTJSVariantString * _this)
{
return _this->operator const tjs_char *();
}
static tjs_int __stdcall TVP_Stub_b64741dc4544ed43c44ddb6d0eb838ea(tTJSVariantString * _this)
{
return _this->GetLength();
}
static tTVInteger __stdcall TVP_Stub_5b83e28b2d9ab0f75d7c7f6f61b5ded6(tTJSVariantString * _this)
{
return _this->ToInteger();
}
static tTVReal __stdcall TVP_Stub_b948c9f43837efa489b0b91f3f675710(tTJSVariantString * _this)
{
return _this->ToReal();
}
static void __stdcall TVP_Stub_eb83216f6f718245468ef48b97ab4c2d(tTJSVariantString * _this, tTJSVariant & dest)
{
return _this->ToNumber(dest);
}
static tjs_int __stdcall TVP_Stub_c66ab4868b743de9c0ba8b26c67b23da(tTJSVariantString * _this)
{
return _this->GetRefCount();
}
#include "tjsTypes.h"
#include "tjsConfig.h"
static tjs_int __stdcall TVP_Stub_586e16d502a6ad98b08161bdb090f8b6(const tjs_char * s)
{
return TJS_atoi(s);
}
static tjs_char * __stdcall TVP_Stub_d8bc9c71c80b200c39b29167d795cad0(tjs_int value , tjs_char * string)
{
return TJS_int_to_str(value, string);
}
static tjs_char * __stdcall TVP_Stub_85df4beb87f6503891e116ce046353c3(tjs_int64 value , tjs_char * string)
{
return TJS_tTVInt_to_str(value, string);
}
static tjs_int __stdcall TVP_Stub_35b6a7e1c73f257aae91e05fa9826e84(const tjs_char * s1 , const tjs_char * s2 , size_t maxlen)
{
return TJS_strnicmp(s1, s2, maxlen);
}
static tjs_int __stdcall TVP_Stub_a25b46701e25030af1ed847e0df229eb(const tjs_char * s1 , const tjs_char * s2)
{
return TJS_stricmp(s1, s2);
}
static void __stdcall TVP_Stub_c8906bf1efa5e86f9fddfab55a01c8f6(tjs_char * d , const tjs_char * s , size_t len)
{
return TJS_strcpy_maxlen(d, s, len);
}
static void __stdcall TVP_Stub_8141059f613820f694608af28e20cbad(tjs_char * d , const tjs_char * s)
{
return TJS_strcpy(d, s);
}
static size_t __stdcall TVP_Stub_cf2690e47099ac6378ed50df4a8a8e90(const tjs_char * d)
{
return TJS_strlen(d);
}
#include "tjsVariantString.h"
static tjs_char * __stdcall TVP_Stub_810c7054e44f535cf250f00707105417(tjs_uint len)
{
return TJSVS_malloc(len);
}
static tjs_char * __stdcall TVP_Stub_52a9af7905ddc71d8b4e0ef7366eebdd(tjs_char * buf , tjs_uint len)
{
return TJSVS_realloc(buf, len);
}
static void __stdcall TVP_Stub_1635dbae2d91b338ddfd0430f8aa7f10(tjs_char * buf)
{
return TJSVS_free(buf);
}
static tTJSVariantString * __stdcall TVP_Stub_30df0c29ad8f672f7fe0742b4b11cd7f(const tjs_char * ref1 , const tjs_char * ref2)
{
return TJSAllocVariantString(ref1, ref2);
}
static tTJSVariantString * __stdcall TVP_Stub_61c82dec644c58290a25f34a69478870(const tjs_char * ref , tjs_int n)
{
return TJSAllocVariantString(ref, n);
}
static tTJSVariantString * __stdcall TVP_Stub_f08e347d2d47dc5fc9a3cb59355b4fbb(const tjs_char * ref)
{
return TJSAllocVariantString(ref);
}
static tTJSVariantString * __stdcall TVP_Stub_5c62e59c2062f658d4c79d5257a9a586(const tjs_nchar * ref)
{
return TJSAllocVariantString(ref);
}
static tTJSVariantString * __stdcall TVP_Stub_259c72d8bfed1210ca71c54f24cacc7a(const tjs_uint8 * * src)
{
return TJSAllocVariantString(src);
}
static tTJSVariantString * __stdcall TVP_Stub_801a92ace08eb7ed001406869a39a75f(tjs_uint len)
{
return TJSAllocVariantStringBuffer(len);
}
static tTJSVariantString * __stdcall TVP_Stub_e22e647af4ded8e51b1e76c845b4c8e2(tTJSVariantString * str , const tjs_char * app)
{
return TJSAppendVariantString(str, app);
}
static tTJSVariantString * __stdcall TVP_Stub_12902221314df9bcf7f7cb74a5242fe0(tTJSVariantString * str , const tTJSVariantString * app)
{
return TJSAppendVariantString(str, app);
}
static tTJSVariantString * __stdcall TVP_Stub_b10feea1619ba8ac11237c12002cdb3e(const tjs_char * format , tjs_uint numparams , tTJSVariant * * params)
{
return TJSFormatString(format, numparams, params);
}
#include "tjsUtils.h"
static const tjs_char * __stdcall TVP_Stub_19755b50d241edcb477bdcac22663778(tTJSVariantType type)
{
return TJSVariantTypeToTypeString(type);
}
static tTJSString __stdcall TVP_Stub_040a0ecf46963e094ee8ec32ab3f1962(const tTJSVariant & val , tjs_int maxlen = 512)
{
return TJSVariantToReadableString(val, maxlen);
}
static tTJSString __stdcall TVP_Stub_525c529dc687b5d86424d775d00bdfce(const tTJSVariant & val)
{
return TJSVariantToExpressionString(val);
}
static void * __stdcall TVP_Stub_c96107b91e2a215f560a2612c6e85931(tjs_uint bytes , tjs_uint align_bits)
{
return TJSAlignedAlloc(bytes, align_bits);
}
static void __stdcall TVP_Stub_b8788eaa2ca495263c6ea2df264af5f5(void * ptr)
{
return TJSAlignedDealloc(ptr);
}
static tjs_uint32 __stdcall TVP_Stub_4c6494008c520d896d699f82aca30b25(tjs_real r)
{
return TJSGetFPClass(r);
}
#include "tjsString.h"
static tTJSString __stdcall TVP_Stub_7d8f8d5e0832ecf248b19a89801ead0e(const tjs_char * lhs , const tTJSString & rhs)
{
return operator +(lhs, rhs);
}
static tTJSString __stdcall TVP_Stub_70849965060a6402f41b0b11ec2bb3a7(tjs_uint32 num , int zeropad = 8)
{
return TJSInt32ToHex(num, zeropad);
}
#include "tjsInterface.h"
#include "tjsErrorDefs.h"
#include "tjsNative.h"
static tjs_int32 __stdcall TVP_Stub_c72efa6b4efaa6664ae637a03e98e866(const tjs_char * name)
{
return TJSRegisterNativeClass(name);
}
static tjs_int32 __stdcall TVP_Stub_a250e46575d0df1166e1542613218a5c(const tjs_char * name)
{
return TJSFindNativeClassID(name);
}
static const tjs_char * __stdcall TVP_Stub_a7bcff67b8d380c225b9d0d83921b3ae(tjs_int32 id)
{
return TJSFindNativeClassName(id);
}
static tTJSNativeClassMethod * __stdcall TVP_Stub_fb68a3aa16bd2eb7d7550283170321bf(tTJSNativeClassMethodCallback callback)
{
return TJSCreateNativeClassMethod(callback);
}
static tTJSNativeClassMethod * __stdcall TVP_Stub_35b4299ede11f511b331b713ba9f38a8(tTJSNativeClassMethodCallback callback)
{
return TJSCreateNativeClassConstructor(callback);
}
static tTJSNativeClassProperty * __stdcall TVP_Stub_efe52691cff20b2dfaa16e8e16caac0a(tTJSNativeClassPropertyGetCallback get , tTJSNativeClassPropertySetCallback set)
{
return TJSCreateNativeClassProperty(get, set);
}
static void __stdcall TVP_Stub_38eed43ef69251c34dc45695b8cf35c0(tTJSNativeClass * cls , const tjs_char * name , iTJSDispatch2 * dsp , const tjs_char * classname , tTJSNativeInstanceType type , tjs_uint32 flags = 0)
{
return TJSNativeClassRegisterNCM(cls, name, dsp, classname, type, flags);
}
static void __stdcall TVP_Stub_2058b65abdfb7598910f0d584d40a19d(tTJSNativeClass * cls , tjs_int32 classid)
{
return TJSNativeClassSetClassID(cls, classid);
}
static tTJSNativeClassForPlugin * __stdcall TVP_Stub_1ebecaefe2ffdc811fccbac42e67e544(const ttstr & name , tTJSCreateNativeInstance createinstance)
{
return TJSCreateNativeClassForPlugin(name, createinstance);
}
#include "tjsVariant.h"
static void __stdcall TVP_Stub_09e0f0912f8d758d3736ece9478c2686()
{
return TJSThrowNullAccess();
}
static void __stdcall TVP_Stub_23d61eda3959b087b618e348471e2c36()
{
return TJSThrowDivideByZero();
}
static tTJSVariantOctet * __stdcall TVP_Stub_e99b22c79b5bf04f3382f959c7bb69ca(const tjs_uint8 * data , tjs_uint length)
{
return TJSAllocVariantOctet(data, length);
}
static tTJSVariantOctet * __stdcall TVP_Stub_9c4bb9ebee4db0fcebeae11c34950f97(const tjs_uint8 * data1 , tjs_uint len1 , const tjs_uint8 * data2 , tjs_uint len2)
{
return TJSAllocVariantOctet(data1, len1, data2, len2);
}
static tTJSVariantOctet * __stdcall TVP_Stub_505a9563aeb1b0255cfcc8197bee7d9e(const tTJSVariantOctet * o1 , const tTJSVariantOctet * o2)
{
return TJSAllocVariantOctet(o1, o2);
}
static tTJSVariantOctet * __stdcall TVP_Stub_f5ab80fc67ee04570330b9035144e760(const tjs_uint8 * * src)
{
return TJSAllocVariantOctet(src);
}
static void __stdcall TVP_Stub_af50188bbaa019ee88b19ecd931f7cce(tTJSVariantOctet * o)
{
return TJSDeallocVariantOctet(o);
}
static tTJSVariantString * __stdcall TVP_Stub_268c452e85a6ac75301a6132f4f5e38b(const tTJSVariantOctet * oct)
{
return TJSOctetToListString(oct);
}
static tTJSVariantString * __stdcall TVP_Stub_646770a19b1768b372c9991ef0d3de85(const tTJSVariantClosure & dsp)
{
return TJSObjectToString(dsp);
}
static tTJSVariantString * __stdcall TVP_Stub_5ec88e04fcb8e1877752281e172173ed(tjs_int64 i)
{
return TJSIntegerToString(i);
}
static tTJSVariantString * __stdcall TVP_Stub_923f8161f2d2ba0e883bc4edc2901960(tjs_real r)
{
return TJSRealToString(r);
}
static tTJSVariantString * __stdcall TVP_Stub_6f70cdb7586cbe571204f286f43c9780(tjs_real r)
{
return TJSRealToHexString(r);
}
static tTVInteger __stdcall TVP_Stub_9a4eaa6a627038799015c093609bdde7(const tjs_char * str)
{
return TJSStringToInteger(str);
}
static tTVReal __stdcall TVP_Stub_c8bb6590f4a7adc906d7b3e42d907267(const tjs_char * str)
{
return TJSStringToReal(str);
}
#include "tjsArray.h"
static iTJSDispatch2 * __stdcall TVP_Stub_8323d57f26876d87271dbfa257b7f7e2(iTJSDispatch2 * * classout = NULL)
{
return TJSCreateArrayObject(classout);
}
static tjs_int __stdcall TVP_Stub_4d6f148e8997e1ae0cc0006ec1bd9618(iTJSDispatch2 * dsp)
{
return TJSGetArrayElementCount(dsp);
}
static tjs_int __stdcall TVP_Stub_7f03a4ddb254d0518642d15513eaea85(iTJSDispatch2 * dsp , tTJSVariant * dest , tjs_uint start , tjs_int count)
{
return TJSCopyArrayElementTo(dsp, dest, start, count);
}
#include "tjsDictionary.h"
static iTJSDispatch2 * __stdcall TVP_Stub_4add3926c72ba9df9259be58b680de0d(iTJSDispatch2 * * classout = NULL)
{
return TJSCreateDictionaryObject(classout);
}
#include "tjs.h"
#include "tjsMessage.h"
static ttstr __stdcall TVP_Stub_075d42cff8dc0c1fbd99c7459a63e526(const tjs_char * name)
{
return TJSGetMessageMapMessage(name);
}
#include "tjsGlobalStringMap.h"
static ttstr __stdcall TVP_Stub_b6bc45b28e194c7ac98bfdea88edee36(const ttstr & string)
{
return TJSMapGlobalStringMap(string);
}
#include "tjsObject.h"
static void __stdcall TVP_Stub_6dff6abb075da1a304520e60c011ef7b(tjs_int op , tTJSVariant & target , const tTJSVariant * param)
{
return TJSDoVariantOperation(op, target, param);
}
static void __stdcall TVP_Stub_892ffbdb8375851fc557e4abe9589b77()
{
return TJSDoRehash();
}
static iTJSDispatch2 * __stdcall TVP_Stub_b2f3538284fc2adda2a43272ee654a96()
{
return TJSCreateCustomObject();
}
#include "StorageIntf.h"
static ttstr __stdcall TVP_Stub_e0ff899ea4a9cc49a0e3b38deaf93b45()
{
return TVPGetTemporaryName();
}
static ttstr __stdcall TVP_Stub_4b9c9ac2aafad07af4b16f34e9d4bba2()
{
return TVPGetAppPath();
}
static void __stdcall TVP_Stub_c2e423356d9ca3f26f9c1d294ee9b742(iTVPStorageMedia * media)
{
return TVPRegisterStorageMedia(media);
}
static void __stdcall TVP_Stub_c07314686fdf5815ce9b058020da942b(iTVPStorageMedia * media)
{
return TVPUnregisterStorageMedia(media);
}
static bool __stdcall TVP_Stub_4a197be1985d45ee86d5672d24134560(const ttstr & name)
{
return TVPIsExistentStorageNoSearch(name);
}
static bool __stdcall TVP_Stub_dec720a9c3cd2b378f195cf71a9ff8b0(const ttstr & name)
{
return TVPIsExistentStorageNoSearchNoNormalize(name);
}
static ttstr __stdcall TVP_Stub_5726a5c7af641ebaa504dc9ec8380938(const ttstr & name)
{
return TVPNormalizeStorageName(name);
}
static void __stdcall TVP_Stub_1c53bc96ac9dfd483c2227bc5fa44825(const ttstr & name)
{
return TVPSetCurrentDirectory(name);
}
static void __stdcall TVP_Stub_1940c8fa03145aa029d0b7718ce0c809(ttstr & name)
{
return TVPGetLocalName(name);
}
static ttstr __stdcall TVP_Stub_b37f047c0f9bd143b34a2fc87ce5f16e(const ttstr & name)
{
return TVPExtractStorageExt(name);
}
static ttstr __stdcall TVP_Stub_dec35fbd2a24fc32e5c220174d864cf4(const ttstr & name)
{
return TVPExtractStorageName(name);
}
static ttstr __stdcall TVP_Stub_86fd45a126296891aee413388597203e(const ttstr & name)
{
return TVPExtractStoragePath(name);
}
static ttstr __stdcall TVP_Stub_603243e54f3508c37d993e8359b735dc(const ttstr & name)
{
return TVPChopStorageExt(name);
}
static void __stdcall TVP_Stub_c3eadbd75b32dabe6faecebf492eb486(const ttstr & name)
{
return TVPAddAutoPath(name);
}
static void __stdcall TVP_Stub_725e49de1d970ef04b179776666f2c34(const ttstr & name)
{
return TVPRemoveAutoPath(name);
}
static ttstr __stdcall TVP_Stub_55a9b73f877bfd4c6d8157e7b1c458df(const ttstr & name)
{
return TVPGetPlacedPath(name);
}
static bool __stdcall TVP_Stub_d070209f152dd22087e6e996e02c85cf(const ttstr & name)
{
return TVPIsExistentStorage(name);
}
static void __stdcall TVP_Stub_308f905626bc51c7ef9b65b2c0ca34b2()
{
return TVPClearStorageCaches();
}
#include "TextStream.h"
static iTJSTextReadStream * __stdcall TVP_Stub_95aab2a1ac9491e8026f4977e0918760(const ttstr & name , const ttstr & modestr)
{
return TVPCreateTextStreamForRead(name, modestr);
}
static iTJSTextReadStream * __stdcall TVP_Stub_e0ac94325eb783ca2fe7856a54444c90(const ttstr & name , const ttstr & modestr , const ttstr & encoding)
{
return TVPCreateTextStreamForReadByEncoding(name, modestr, encoding);
}
static iTJSTextWriteStream * __stdcall TVP_Stub_0c99a79e866f08b4df3914e83fc203dc(const ttstr & name , const ttstr & modestr)
{
return TVPCreateTextStreamForWrite(name, modestr);
}
static void __stdcall TVP_Stub_f2de531a016173057ff3540e47fed4e6(const ttstr & encoding)
{
return TVPSetDefaultReadEncoding(encoding);
}
static const tjs_char * __stdcall TVP_Stub_4224a9066d8d13d6d7e12f1ace6a5beb()
{
return TVPGetDefaultReadEncoding();
}
#include "CharacterSet.h"
static tjs_int __stdcall TVP_Stub_900476efbc2031e643c042ca8e63a3d7(const tjs_char * in , char * out)
{
return TVPWideCharToUtf8String(in, out);
}
static tjs_int __stdcall TVP_Stub_07dfce61d490cf671a2d5359d713d64a(const char * in , tjs_char * out)
{
return TVPUtf8ToWideCharString(in, out);
}
#include "XP3Archive.h"
static void __stdcall TVP_Stub_52d30ac8479ef7e870b5aff076482799(tTVPXP3ArchiveExtractionFilter filter)
{
return TVPSetXP3ArchiveExtractionFilter(filter);
}
#include "EventIntf.h"
static void __stdcall TVP_Stub_8e4d0392ed46e87f94e5fcf675a124a1()
{
return TVPBreathe();
}
static bool __stdcall TVP_Stub_73f46e08d17e707725f433b454f05a89()
{
return TVPGetBreathing();
}
static void __stdcall TVP_Stub_80d60e682fa72973071e335db272a2a2(bool en)
{
return TVPSetSystemEventDisabledState(en);
}
static bool __stdcall TVP_Stub_6bd6262185fa0b9cf1750f6a525d893a()
{
return TVPGetSystemEventDisabledState();
}
static void __stdcall TVP_Stub_cf29f737d4eb450b26789d421d0ec69a(iTJSDispatch2 * source , iTJSDispatch2 * target , ttstr & eventname , tjs_uint32 tag , tjs_uint32 flag , tjs_uint numargs , tTJSVariant * args)
{
return TVPPostEvent(source, target, eventname, tag, flag, numargs, args);
}
static tjs_int __stdcall TVP_Stub_13c0e371c08fd1b9da2f0c103d01c59a(iTJSDispatch2 * source , iTJSDispatch2 * target , const ttstr & eventname , tjs_uint32 tag = 0)
{
return TVPCancelEvents(source, target, eventname, tag);
}
static bool __stdcall TVP_Stub_82693e38df8f033ea98f9b7969d66d7b(iTJSDispatch2 * source , iTJSDispatch2 * target , const ttstr & eventname , tjs_uint32 tag)
{
return TVPAreEventsInQueue(source, target, eventname, tag);
}
static tjs_int __stdcall TVP_Stub_6e3f8a3b18f55dae6153a889f00a3e87(iTJSDispatch2 * source , iTJSDispatch2 * target , const ttstr & eventname , tjs_uint32 tag)
{
return TVPCountEventsInQueue(source, target, eventname, tag);
}
static void __stdcall TVP_Stub_efe14a197131b4813656d6669cc3475b(iTJSDispatch2 * source , iTJSDispatch2 * target , tjs_uint32 tag = 0)
{
return TVPCancelEventsByTag(source, target, tag);
}
static void __stdcall TVP_Stub_ba4ecf60f872f757b69c84f457b3e941(iTJSDispatch2 * source)
{
return TVPCancelSourceEvents(source);
}
static iTJSDispatch2 * __stdcall TVP_Stub_dffedabe32ce886e3b7e695b44ad3547(const tjs_char * type , iTJSDispatch2 * targthis , iTJSDispatch2 * targ)
{
return TVPCreateEventObject(type, targthis, targ);
}
static void __stdcall TVP_Stub_f518c60b165658d19a0fadd8f69586aa(tTVPContinuousEventCallbackIntf * cb)
{
return TVPAddContinuousEventHook(cb);
}
static void __stdcall TVP_Stub_6fefcb1c2ca01a876c301ab41dbdab9f(tTVPContinuousEventCallbackIntf * cb)
{
return TVPRemoveContinuousEventHook(cb);
}
static void __stdcall TVP_Stub_df55083347df0483b4ca6ba1e4f0b9a0(tTVPCompactEventCallbackIntf * cb)
{
return TVPAddCompactEventHook(cb);
}
static void __stdcall TVP_Stub_d8d28310f702714733c4c5dc850058df(tTVPCompactEventCallbackIntf * cb)
{
return TVPRemoveCompactEventHook(cb);
}
#include "SystemIntf.h"
static ttstr __stdcall TVP_Stub_52d24c38b05be174bc5c4fdcf02e9b9f()
{
return TVPGetPlatformName();
}
static ttstr __stdcall TVP_Stub_f27f455c8f30cbaf1706faac3c7b8e02()
{
return TVPGetOSName();
}
#include "SystemImpl.h"
static bool __stdcall TVP_Stub_78ec453a50b2800bb01347e8ebbac000(tjs_uint keycode , bool getcurrent = true)
{
return TVPGetAsyncKeyState(keycode, getcurrent);
}
#include "ScriptMgnIntf.h"
static iTJSDispatch2 * __stdcall TVP_Stub_0936d0f6fc53339d255893e58bcc6699()
{
return TVPGetScriptDispatch();
}
static void __stdcall TVP_Stub_f4f7181b7fd679784c50b0cc7ba4c60e(const ttstr & content , tTJSVariant * result = NULL)
{
return TVPExecuteScript(content, result);
}
static void __stdcall TVP_Stub_79816d7e5741c2416fefe2c2a8baef00(const ttstr & content , iTJSDispatch2 * context , tTJSVariant * result = NULL)
{
return TVPExecuteScript(content, context, result);
}
static void __stdcall TVP_Stub_42a3d248fab928f16555abcceca62834(const ttstr & content , tTJSVariant * result = NULL)
{
return TVPExecuteExpression(content, result);
}
static void __stdcall TVP_Stub_926d6212b8b1b238e7bef9b17a3ee643(const ttstr & content , iTJSDispatch2 * context , tTJSVariant * result = NULL)
{
return TVPExecuteExpression(content, context, result);
}
static void __stdcall TVP_Stub_236e3d626784d80ca2cc5b2fe14cd9c6(const ttstr & content , const ttstr & name , tjs_int lineofs , tTJSVariant * result = NULL)
{
return TVPExecuteScript(content, name, lineofs, result);
}
static void __stdcall TVP_Stub_1bfac11a5f95c842f97a8bb57d4019de(const ttstr & content , const ttstr & name , tjs_int lineofs , iTJSDispatch2 * context , tTJSVariant * result = NULL)
{
return TVPExecuteScript(content, name, lineofs, context, result);
}
static void __stdcall TVP_Stub_198ce21c54b0cea4c1bf5eeba35349ab(const ttstr & content , const ttstr & name , tjs_int lineofs , tTJSVariant * result = NULL)
{
return TVPExecuteExpression(content, name, lineofs, result);
}
static void __stdcall TVP_Stub_590a1ec7f64904eaa32b5c771bb5f8cd(const ttstr & content , const ttstr & name , tjs_int lineofs , iTJSDispatch2 * context , tTJSVariant * result = NULL)
{
return TVPExecuteExpression(content, name, lineofs, context, result);
}
static void __stdcall TVP_Stub_dd13d4bc2b48540a92f047bf015b829b(const ttstr & name , tTJSVariant * result = NULL , bool isexpression = false , const tjs_char * modestr = NULL)
{
return TVPExecuteStorage(name, result, isexpression, modestr);
}
static void __stdcall TVP_Stub_0ff502d492598d2211405180bfb4d1e1(const ttstr & name , iTJSDispatch2 * context , tTJSVariant * result = NULL , bool isexpression = false , const tjs_char * modestr = NULL)
{
return TVPExecuteStorage(name, context, result, isexpression, modestr);
}
static void __stdcall TVP_Stub_cf5401746759bfe38918087aaab6c57b()
{
return TVPDumpScriptEngine();
}
static void __stdcall TVP_Stub_04e84aa7d8cf0477d55c700164544b38(const tjs_uint8 * content , size_t len , iTJSDispatch2 * context , tTJSVariant * result = NULL , const tjs_char * name = NULL)
{
return TVPExecuteBytecode(content, len, context, result, name);
}
static void __stdcall TVP_Stub_449039d3afbfbd52a63130a3b227a490(const ttstr & filename)
{
return TVPCreateMessageMapFile(filename);
}
#include "StorageImpl.h"
static bool __stdcall TVP_Stub_347a4fa85af84e223c4b61d33ead694a(const ttstr & name)
{
return TVPCheckExistentLocalFolder(name);
}
static bool __stdcall TVP_Stub_4ad1dd24b3b4769ee10149eea006af7a(const ttstr & name)
{
return TVPCheckExistentLocalFile(name);
}
static bool __stdcall TVP_Stub_b246b17b62d273bdc04e9d9e827f5c74(const ttstr & folder)
{
return TVPCreateFolders(folder);
}
static IStream * __stdcall TVP_Stub_9974ebc6296f925cff55d8bcb2d52ce9(const ttstr & name , tjs_uint32 flags)
{
return TVPCreateIStream(name, flags);
}
static tTJSBinaryStream * __stdcall TVP_Stub_0e0c9d9107d8c56b8bc4d4198ae9208a(IStream * refstream)
{
return TVPCreateBinaryStreamAdapter(refstream);
}
#include "PluginImpl.h"
static void __stdcall TVP_Stub_c23ece207f6ec2dd7c76ef873047aee3(const char * funcname)
{
return TVPThrowPluginUnboundFunctionError(funcname);
}
static void __stdcall TVP_Stub_81507020bc646be2f53ab95b9430ba27(const tjs_char * funcname)
{
return TVPThrowPluginUnboundFunctionError(funcname);
}
static void * __stdcall TVP_Stub_acc0d3861d1b971abcbdda1c075dd681(size_t size)
{
return TVP_malloc(size);
}
static void * __stdcall TVP_Stub_ff2dccead1b31e3f34e8be3e2ba5bbf1(void * pp , size_t size)
{
return TVP_realloc(pp, size);
}
static void __stdcall TVP_Stub_e17db0d4f69625c61aba7fffe540dded(void * pp)
{
return TVP_free(pp);
}
static tjs_int __stdcall TVP_Stub_5bbc872e7bba5b761c509d31116e4460()
{
return TVPGetAutoLoadPluginCount();
}
static int __stdcall TVP_Stub_4adf361303eae78829250c7b732a5722(unsigned char * dest , unsigned long * destlen , const unsigned char * source , unsigned long sourcelen)
{
return ZLIB_uncompress(dest, destlen, source, sourcelen);
}
static int __stdcall TVP_Stub_bf172364c57c1aa561b145fd5cacda0c(unsigned char * dest , unsigned long * destlen , const unsigned char * source , unsigned long sourcelen)
{
return ZLIB_compress(dest, destlen, source, sourcelen);
}
static int __stdcall TVP_Stub_d7687aa80dac10f88deac7aa7e70538a(unsigned char * dest , unsigned long * destlen , const unsigned char * source , unsigned long sourcelen , int level)
{
return ZLIB_compress2(dest, destlen, source, sourcelen, level);
}
static void __stdcall TVP_Stub_b18b7259f98029f745c75291d6855ab1(TVP_md5_state_t * pms)
{
return TVP_md5_init(pms);
}
static void __stdcall TVP_Stub_b79e5d877116025576ca1f76af124009(TVP_md5_state_t * pms , const tjs_uint8 * data , int nbytes)
{
return TVP_md5_append(pms, data, nbytes);
}
static void __stdcall TVP_Stub_8aea098dfe8a36c705cc2a9e1a189b84(TVP_md5_state_t * pms , tjs_uint8 * digest)
{
return TVP_md5_finish(pms, digest);
}
static HWND __stdcall TVP_Stub_4ccd3f6ab60d61be6dbfc59e8e3d1726()
{
return TVPGetApplicationWindowHandle();
}
static void __stdcall TVP_Stub_3d70bb72a7d7765c7e8ea580079ab7e9()
{
return TVPProcessApplicationMessages();
}
static void __stdcall TVP_Stub_eba9b272d78a4b0cd7f9212e29a58607()
{
return TVPHandleApplicationMessage();
}
static bool __stdcall TVP_Stub_cfbe8ee9d43aa64ae4190eac91f7c55f(const tjs_char * name , iTJSDispatch2 * dsp)
{
return TVPRegisterGlobalObject(name, dsp);
}
static bool __stdcall TVP_Stub_a4308a386968ef5d23025ab8a9e8c6db(const tjs_char * name)
{
return TVPRemoveGlobalObject(name);
}
static void __stdcall TVP_Stub_5a4fcbe1e398e3d9690d571acbbbae9f(tTVPTryBlockFunction tryblock , tTVPCatchBlockFunction catchblock , tTVPFinallyBlockFunction finallyblock , void * data)
{
return TVPDoTryBlock(tryblock, catchblock, finallyblock, data);
}
static bool __stdcall TVP_Stub_5b62f504fe6d22428d7518d6c52d775d(const wchar_t * module_filename , tjs_int & major , tjs_int & minor , tjs_int & release , tjs_int & build)
{
return TVPGetFileVersionOf(module_filename, major, minor, release, build);
}
#include "SysInitIntf.h"
static bool __stdcall TVP_Stub_fb3b405f8747b54f26c332b9e6af81cd(const tjs_char * name , tTJSVariant * value = NULL)
{
return TVPGetCommandLine(name, value);
}
static tjs_int __stdcall TVP_Stub_b7ccd11d130f186883c109d2ba17b598()
{
return TVPGetCommandLineArgumentGeneration();
}
static void __stdcall TVP_Stub_cf8ab6c24f25993ccc7663e572ac2991(const tjs_char * name , const ttstr & value)
{
return TVPSetCommandLine(name, value);
}
#include "SysInitImpl.h"
#include "DetectCPU.h"
static tjs_uint32 __stdcall TVP_Stub_ba40ffbca76695b54a02aa8c1f1e047b()
{
return TVPGetCPUType();
}
#include "ThreadIntf.h"
static tjs_int __stdcall TVP_Stub_c97720e639e95ba5130ce9dd78d30403()
{
return TVPGetProcessorNum();
}
static tjs_int __stdcall TVP_Stub_c5557ac5391b1b831a22e64b65d1746c()
{
return TVPGetThreadNum();
}
static void __stdcall TVP_Stub_3243a4c32d4f674f1bbc8d3895257568(tjs_int num)
{
return TVPBeginThreadTask(num);
}
static void __stdcall TVP_Stub_78390a3d08879903ee9558e9df68db4d(TVP_THREAD_TASK_FUNC func , TVP_THREAD_PARAM param)
{
return TVPExecThreadTask(func, param);
}
static void __stdcall TVP_Stub_58e9454d7096a52808f9a83b9ce25ff0()
{
return TVPEndThreadTask();
}
#include "DebugIntf.h"
static void __stdcall TVP_Stub_cdefadd0c3bf15b4639b2f0338a40585(const ttstr & line)
{
return TVPAddLog(line);
}
static void __stdcall TVP_Stub_4bf80e9bac16b9e3f9bf385b2fbce657(const ttstr & line)
{
return TVPAddImportantLog(line);
}
#include "Random.h"
static void __stdcall TVP_Stub_51aeacf2b6ef9deb01c3b3db201d6bf9(const void * buf , tjs_int bufsize)
{
return TVPPushEnvironNoise(buf, bufsize);
}
static void __stdcall TVP_Stub_9ed5432d73448da47991df9577ee97bc(void * dest)
{
return TVPGetRandomBits128(dest);
}
#include "ClipboardIntf.h"
static bool __stdcall TVP_Stub_cf1d02d1cc1aff0aae6c038c95dac80f(tTVPClipboardFormat format)
{
return TVPClipboardHasFormat(format);
}
static void __stdcall TVP_Stub_ddb0e05c72c0692e78af885ac7ec82dc(const ttstr & text)
{
return TVPClipboardSetText(text);
}
static bool __stdcall TVP_Stub_a3029db6292616cd16c228b91dc4af13(ttstr & text)
{
return TVPClipboardGetText(text);
}
#include "TickCount.h"
static tjs_uint64 __stdcall TVP_Stub_2d90871c6bc15a9e8d97d24c29e78e3b()
{
return TVPGetTickCount();
}
#include "MsgIntf.h"
static ttstr __stdcall TVP_Stub_0af6744e35e38276d6a98c1f382b1519(const tjs_char * msg , const ttstr & p1)
{
return TVPFormatMessage(msg, p1);
}
static ttstr __stdcall TVP_Stub_ad40567a051208757642e5e087f3e741(const tjs_char * msg , const ttstr & p1 , const ttstr & p2)
{
return TVPFormatMessage(msg, p1, p2);
}
static void __stdcall TVP_Stub_6a15185daab9b274963fe5ef46305775(const tjs_char * msg)
{
return TVPThrowExceptionMessage(msg);
}
static void __stdcall TVP_Stub_073a2332a8ab3ed31ab81daea3d3f2c4(const tjs_char * msg , const ttstr & p1 , tjs_int num)
{
return TVPThrowExceptionMessage(msg, p1, num);
}
static void __stdcall TVP_Stub_01216e91225e06c7422bef0c2febc0cc(const tjs_char * msg , const ttstr & p1)
{
return TVPThrowExceptionMessage(msg, p1);
}
static void __stdcall TVP_Stub_16ce22ad500a5bdfd5d5743c847a28b6(const tjs_char * msg , const ttstr & p1 , const ttstr & p2)
{
return TVPThrowExceptionMessage(msg, p1, p2);
}
static ttstr __stdcall TVP_Stub_59251c4104f736fa2690c5f77fb0a908()
{
return TVPGetAboutString();
}
static ttstr __stdcall TVP_Stub_f923750e0fdb51a6fc6c304832cb3dd3()
{
return TVPGetVersionInformation();
}
static ttstr __stdcall TVP_Stub_bc77a1e312ff7827d90387fb92f0f5b0()
{
return TVPGetVersionString();
}
static void __stdcall TVP_Stub_2090afd7ae8bcb021ec4d04947d0d845(tjs_int & major , tjs_int & minor , tjs_int & release , tjs_int & build)
{
return TVPGetSystemVersion(major, minor, release, build);
}
static void __stdcall TVP_Stub_3a0f858bdf86199dc2d00b583a3b915f(tjs_int & major , tjs_int & minor , tjs_int & release)
{
return TVPGetTJSVersion(major, minor, release);
}
#include "WaveIntf.h"
static void __stdcall TVP_Stub_0d316a141f7a502ff8d9ffe2d38d25a8(tjs_int16 * output , const void * input , const tTVPWaveFormat & format , tjs_int count , bool downmix)
{
return TVPConvertPCMTo16bits(output, input, format, count, downmix);
}
static void __stdcall TVP_Stub_b31ff64ae2d8f93dbf28161d5080b295(tjs_int16 * output , const void * input , tjs_int channels , tjs_int bytespersample , tjs_int bitspersample , bool isfloat , tjs_int count , bool downmix)
{
return TVPConvertPCMTo16bits(output, input, channels, bytespersample, bitspersample, isfloat, count, downmix);
}
static void __stdcall TVP_Stub_d9b1c73516daea6a9c6564e2b731615a(float * output , const void * input , tjs_int channels , tjs_int bytespersample , tjs_int bitspersample , bool isfloat , tjs_int count)
{
return TVPConvertPCMToFloat(output, input, channels, bytespersample, bitspersample, isfloat, count);
}
static void __stdcall TVP_Stub_003f9d3de568fcd71dd532f33d38839c(float * output , const void * input , const tTVPWaveFormat & format , tjs_int count)
{
return TVPConvertPCMToFloat(output, input, format, count);
}
#include "WaveImpl.h"
static void __stdcall TVP_Stub_5da29a19bbe279a89be00e16c59d7641()
{
return TVPReleaseDirectSound();
}
static IDirectSound * __stdcall TVP_Stub_c1b52e8f3578d11f369552a887e13c5b()
{
return TVPGetDirectSound();
}
#include "GraphicsLoaderIntf.h"
static void __stdcall TVP_Stub_b94ead6de9316bc65758c5aefb564078(const ttstr & name , tTVPGraphicLoadingHandlerForPlugin loading , tTVPGraphicHeaderLoadingHandlerForPlugin header , tTVPGraphicSaveHandlerForPlugin save , tTVPGraphicAcceptSaveHandler accept , void * formatdata)
{
return TVPRegisterGraphicLoadingHandler(name, loading, header, save, accept, formatdata);
}
static void __stdcall TVP_Stub_8a35be936d2aca049e398a081e511c97(const ttstr & name , tTVPGraphicLoadingHandlerForPlugin loading , tTVPGraphicHeaderLoadingHandlerForPlugin header , tTVPGraphicSaveHandlerForPlugin save , tTVPGraphicAcceptSaveHandler accept , void * formatdata)
{
return TVPUnregisterGraphicLoadingHandler(name, loading, header, save, accept, formatdata);
}
static void __stdcall TVP_Stub_5b1fa785e397e643dd09cb43c2f2f4db()
{
return TVPClearGraphicCache();
}
#include "tvpfontstruc.h"
#include "tvpinputdefs.h"
#include "LayerBitmapIntf.h"
#include "drawable.h"
#include "ComplexRect.h"
#include "LayerIntf.h"
static tjs_uint32 __stdcall TVP_Stub_29af78765c764c566e6adc77e0ea7041(tjs_uint32 col)
{
return TVPToActualColor(col);
}
static tjs_uint32 __stdcall TVP_Stub_9e0df54e4c24ee28d5517c1743faa3a3(tjs_uint32 col)
{
return TVPFromActualColor(col);
}
static iTJSDispatch2 * __stdcall TVP_Stub_d3aaa55d66777d7308ffa7a348c84841(tTJSNI_BaseLayer * layer)
{
return TVPGetObjectFrom_NI_BaseLayer(layer);
}
#include "LayerManager.h"
#include "WindowIntf.h"
#include "WindowImpl.h"
static tjs_uint32 __stdcall TVP_Stub_b426fbfb6ccb4e89c252b6af566995b8()
{
return TVPGetCurrentShiftKeyState();
}
static void __stdcall TVP_Stub_c145419db7b63f7488ea05a2a8826c1d(HWND hWnd , char virt , short key , short cmd)
{
return TVPRegisterAcceleratorKey(hWnd, virt, key, cmd);
}
static void __stdcall TVP_Stub_d795cd5ebfb6ca6f1b91bafbe66d7a65(HWND hWnd , short cmd)
{
return TVPUnregisterAcceleratorKey(hWnd, cmd);
}
static void __stdcall TVP_Stub_4564a3ce5cf48cb47e63a3948cef03be(HWND hWnd)
{
return TVPDeleteAcceleratorKeyTable(hWnd);
}
static void __stdcall TVP_Stub_bee2775f2e4042043b7cb08056d2ae5c()
{
return TVPEnsureDirect3DObject();
}
static IDirect3D9 * __stdcall TVP_Stub_5fd8dfd2816a2cfd4a51cab41053d575()
{
return TVPGetDirect3DObjectNoAddRef();
}
#include "DrawDevice.h"
#include "voMode.h"
#include "VideoOvlIntf.h"
#include "TransIntf.h"
static iTVPScanLineProvider * __stdcall TVP_Stub_9982ebedc12d343cb098e2a7b25bdef1(const ttstr & name , tjs_int bpp , tjs_uint32 key , tjs_uint w , tjs_uint h)
{
return TVPSLPLoadImage(name, bpp, key, w, h);
}
static void __stdcall TVP_Stub_81eeacbed5ee6129bef4b370e28b5d10(iTVPTransHandlerProvider * pro)
{
return TVPAddTransHandlerProvider(pro);
}
static void __stdcall TVP_Stub_6ed1088905d99012d2fb5827ea19527e(iTVPTransHandlerProvider * pro)
{
return TVPRemoveTransHandlerProvider(pro);
}
#include "transhandler.h"
#include "tvpgl.h"
static void __stdcall TVP_Stub_b4d6c64cc0004ffaba804f0e8f02ab9b(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAlphaBlend(dest, src, len);
}
static void __stdcall TVP_Stub_2c3e08b8df93ec50451edd916c707030(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAlphaBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_eba070d1583ca5f5d02630ba33a5504b(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAlphaBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_ee474537852ce5eb165cb1761950faba(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAlphaBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_eed221c603243522667e2f1c6ace3ba4(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAlphaBlend_d(dest, src, len);
}
static void __stdcall TVP_Stub_1f973c5e3cfaf00fa752b7e22d7ba481(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAlphaBlend_a(dest, src, len);
}
static void __stdcall TVP_Stub_b9d5260bba9edd7503f1adf882218979(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAlphaBlend_do(dest, src, len, opa);
}
static void __stdcall TVP_Stub_aedbd2eda61145de808e295331884245(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAlphaBlend_ao(dest, src, len, opa);
}
static void __stdcall TVP_Stub_ce0f184e84752eb279e4f900d8b53c18(tjs_uint32 * dest , const tjs_uint32 color , tjs_int len)
{
return TVPAlphaColorMat(dest, color, len);
}
static void __stdcall TVP_Stub_0217d49393163b80897d044c1d93092f(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAdditiveAlphaBlend(dest, src, len);
}
static void __stdcall TVP_Stub_5bbd9d5b364840e9615af35a62f69d7d(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAdditiveAlphaBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_2b2837e81fcaeec35f61a2a3ecf2fb2d(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAdditiveAlphaBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_bb0706a78e9066944bfbffd1406be2d4(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAdditiveAlphaBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_770e67c91215292980b88cc6efb9f2a5(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAdditiveAlphaBlend_a(dest, src, len);
}
static void __stdcall TVP_Stub_068ab11f05731f2c2e9ea8c5fdb16a9f(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAdditiveAlphaBlend_ao(dest, src, len, opa);
}
static void __stdcall TVP_Stub_b9873a0ad2653952cb2948b817e786e4(tjs_uint32 * buf , tjs_int len)
{
return TVPConvertAdditiveAlphaToAlpha(buf, len);
}
static void __stdcall TVP_Stub_11d9804ae4db32d731af69c397769cbf(tjs_uint32 * buf , tjs_int len)
{
return TVPConvertAlphaToAdditiveAlpha(buf, len);
}
static void __stdcall TVP_Stub_421f5aa6dbaaaf946f74942c77aac9bc(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAlphaBlend(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_563ee9dcb14a2914fc246e64679f42b5(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAlphaBlend_HDA(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_e23a54b6b80bd03111a40f669524724f(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAlphaBlend_o(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_c90c8bbd18a7190636ae4269c36ad005(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAlphaBlend_HDA_o(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_03c54a8e8c86e171f868a624e490691f(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAlphaBlend_d(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_30b63f3cc59b39f1a71829bbbdf6e45d(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAlphaBlend_a(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_705bcc30a0561ec679c2267e1a573b23(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAlphaBlend_do(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_5c627d080007e455b0393a9b4457cd4d(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAlphaBlend_ao(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_72a64cecd44d80f95fc93faf0d239e32(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAdditiveAlphaBlend(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_ef838904712bfdc614dbc689fbe7fb18(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int blend_y , tjs_int srcstart , tjs_int srcstep)
{
return TVPInterpStretchAdditiveAlphaBlend(dest, destlen, src1, src2, blend_y, srcstart, srcstep);
}
static void __stdcall TVP_Stub_acc97936adc40656e824cfdf7a34e20c(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAdditiveAlphaBlend_HDA(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_5ea1ba3602f9d9fee344de6c3406d7a3(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAdditiveAlphaBlend_o(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_d25f0771b8fc7715d69f01d950463a49(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int blend_y , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPInterpStretchAdditiveAlphaBlend_o(dest, destlen, src1, src2, blend_y, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_f8ab11c930782ce058e517d0440ec87f(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAdditiveAlphaBlend_HDA_o(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_b8157e369d53c2d944b76494980ced7b(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchAdditiveAlphaBlend_a(dest, len, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_aba94f656b4c1de827d11c72b36a5e9c(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchAdditiveAlphaBlend_ao(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_0656942f5a95783a4de73ca6e654d3b5(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAlphaBlend(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_5c2b7d12713dd5a94ef8e6eff1f79752(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAlphaBlend_HDA(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_6f1d30ac7e812cc5a059459c47638cd0(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAlphaBlend_o(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_1d51684322635e7848ef53f7f6be8a1e(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAlphaBlend_HDA_o(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_a1f2d56d138a4038fe1678328910a81d(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAlphaBlend_d(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_c135ef491b533febfd49696d22a1dd3d(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAlphaBlend_a(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_579117a873b466d78bf93e49c4a078da(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAlphaBlend_do(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_ec8fa08705639eb7ae5d44ab63dea5e8(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAlphaBlend_ao(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_b49dc1cda6109256815dae7b4293725d(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAdditiveAlphaBlend(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_912a670f56707ac70f2fee13660c2af8(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPInterpLinTransAdditiveAlphaBlend(dest, destlen, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_d0159986645df76b8c66fdb662efffde(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAdditiveAlphaBlend_HDA(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_cd7a2e6f91bf8d2daa3e28139d7d9f5c(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAdditiveAlphaBlend_o(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_676004ca892b2bfee6859d0bb132fdd7(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPInterpLinTransAdditiveAlphaBlend_o(dest, destlen, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_d4b161d8a745baa5e2113669773a758f(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAdditiveAlphaBlend_HDA_o(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_ef7537293f6e3b6127480f6c5fd018a1(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransAdditiveAlphaBlend_a(dest, len, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_6f6f73b75cffe40a28566d1832ae1224(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransAdditiveAlphaBlend_ao(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_7adc5aad39e459e01543d07c239efe57(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPCopyOpaqueImage(dest, src, len);
}
static void __stdcall TVP_Stub_3ff6b480097eec3f5fdb7bfad685fd2a(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend(dest, src, len, opa);
}
static void __stdcall TVP_Stub_b2c50c3a1dfea7e9d05fed69818bafc3(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend_HDA(dest, src, len, opa);
}
static void __stdcall TVP_Stub_8024df9077e2c85b5b718ad2c87e57e7(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend_d(dest, src, len, opa);
}
static void __stdcall TVP_Stub_989769d4eb8e42e9c9bbe721b296406c(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend_a(dest, src, len, opa);
}
static void __stdcall TVP_Stub_cc1ac928b5c31570dfba7ed8f565be4b(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchCopyOpaqueImage(dest, destlen, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_62931efed5729a332e60bd1f7c7cecdf(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchConstAlphaBlend(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_53c18160b157088f72a9afd79737b48b(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int blend_y , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPInterpStretchConstAlphaBlend(dest, destlen, src1, src2, blend_y, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_48135697fd7f4df87402a7dd4d761555(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchConstAlphaBlend_HDA(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_e2c71cf04e876069eb7315c800a96898(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchConstAlphaBlend_d(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_1f63c018cf805ca1168af192cf8a4b41(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep , tjs_int opa)
{
return TVPStretchConstAlphaBlend_a(dest, len, src, srcstart, srcstep, opa);
}
static void __stdcall TVP_Stub_704a9574dafd3669e10d546549948e03(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransCopyOpaqueImage(dest, destlen, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_97905c510b9502c20c9322c9f5fb4188(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransConstAlphaBlend(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_b23e84230c4736667279c7a71f4ca53e(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPInterpLinTransConstAlphaBlend(dest, destlen, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_eb41fc900b0a6e3aba9d531f266137f1(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransConstAlphaBlend_HDA(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_5bd02c627b74bbb22d5a525b8bcbbd27(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransConstAlphaBlend_d(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_cc82e6a6b31ea743b9ebbdeed1ddedc3(tjs_uint32 * dest , tjs_int len , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch , tjs_int opa)
{
return TVPLinTransConstAlphaBlend_a(dest, len, src, sx, sy, stepx, stepy, srcpitch, opa);
}
static void __stdcall TVP_Stub_247b25d497e48bc0191fdb2ac530f4ca(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend_SD(dest, src1, src2, len, opa);
}
static void __stdcall TVP_Stub_6bbea3af36c35631641cc8356ff65475(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend_SD_a(dest, src1, src2, len, opa);
}
static void __stdcall TVP_Stub_cac02dfd62ba94abf6a346bef0bf3ab9(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int len , tjs_int opa)
{
return TVPConstAlphaBlend_SD_d(dest, src1, src2, len, opa);
}
static void __stdcall TVP_Stub_68eeb36d76d88ff00014f04b23454254(tjs_uint32 * table , tjs_int phase , tjs_int vague)
{
return TVPInitUnivTransBlendTable(table, phase, vague);
}
static void __stdcall TVP_Stub_65e03b1c849b6e9cb5c478024aa9a5b7(tjs_uint32 * table , tjs_int phase , tjs_int vague)
{
return TVPInitUnivTransBlendTable_d(table, phase, vague);
}
static void __stdcall TVP_Stub_7670c0c5630625ee6a73b7b9ee093650(tjs_uint32 * table , tjs_int phase , tjs_int vague)
{
return TVPInitUnivTransBlendTable_a(table, phase, vague);
}
static void __stdcall TVP_Stub_68a0abce6eefa08e74353ec48c4c87a8(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , const tjs_uint8 * rule , const tjs_uint32 * table , tjs_int len)
{
return TVPUnivTransBlend(dest, src1, src2, rule, table, len);
}
static void __stdcall TVP_Stub_ccb6e098b9a0791a0f20e9f1af55e341(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , const tjs_uint8 * rule , const tjs_uint32 * table , tjs_int len , tjs_int src1lv , tjs_int src2lv)
{
return TVPUnivTransBlend_switch(dest, src1, src2, rule, table, len, src1lv, src2lv);
}
static void __stdcall TVP_Stub_0f817efe47b451fd719c05a104c2b803(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , const tjs_uint8 * rule , const tjs_uint32 * table , tjs_int len)
{
return TVPUnivTransBlend_d(dest, src1, src2, rule, table, len);
}
static void __stdcall TVP_Stub_efad1a3d774747bd2b5adb221ede2678(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , const tjs_uint8 * rule , const tjs_uint32 * table , tjs_int len , tjs_int src1lv , tjs_int src2lv)
{
return TVPUnivTransBlend_switch_d(dest, src1, src2, rule, table, len, src1lv, src2lv);
}
static void __stdcall TVP_Stub_563285ed004ddd2945f91db7b5347d3c(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , const tjs_uint8 * rule , const tjs_uint32 * table , tjs_int len)
{
return TVPUnivTransBlend_a(dest, src1, src2, rule, table, len);
}
static void __stdcall TVP_Stub_4c032260ef83d44bfe05fdc16843a8f9(tjs_uint32 * dest , const tjs_uint32 * src1 , const tjs_uint32 * src2 , const tjs_uint8 * rule , const tjs_uint32 * table , tjs_int len , tjs_int src1lv , tjs_int src2lv)
{
return TVPUnivTransBlend_switch_a(dest, src1, src2, rule, table, len, src1lv, src2lv);
}
static void __stdcall TVP_Stub_96fd614457f06499a430b0c6e0e8a941(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap(dest, src, len, color);
}
static void __stdcall TVP_Stub_d6e36d304ff7253088ab4bc1aaf13a98(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap_o(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_eddacf49735189e23d9d49831851ffdb(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap65(dest, src, len, color);
}
static void __stdcall TVP_Stub_20275a5de4aef464b85d3f6db2800063(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap65_o(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_872d1c626e6d4e3d5e86a257f0b14536(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap_HDA(dest, src, len, color);
}
static void __stdcall TVP_Stub_a7ebb70cdec339f26c2ea7fd9a471b88(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap_HDA_o(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_d748ffef5cde2a6a3333e75b7fa3fb49(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap65_HDA(dest, src, len, color);
}
static void __stdcall TVP_Stub_15e1fe0e6230e7b60e216e266f927f7b(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap65_HDA_o(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_f8179eafd0cbe8116874310519207dc0(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap_d(dest, src, len, color);
}
static void __stdcall TVP_Stub_accbc3bed3223d552de2723366cfc2b6(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap65_d(dest, src, len, color);
}
static void __stdcall TVP_Stub_e2c3e74d2a20a601c1f393348f58aeb2(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap_a(dest, src, len, color);
}
static void __stdcall TVP_Stub_e0163a6ca3397c2e71715132cccefa1d(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color)
{
return TVPApplyColorMap65_a(dest, src, len, color);
}
static void __stdcall TVP_Stub_2c3ea1ea88799dfde81025bf1959333a(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap_do(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_a6bb56b3f4b7a89fe78d63956a0f444c(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap65_do(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_09a81ac18a121d8fbb67285a081bf9c6(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap_ao(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_46fdfe0f5369bf234c3ed60a43947d9d(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPApplyColorMap65_ao(dest, src, len, color, opa);
}
static void __stdcall TVP_Stub_d866cb6c8a47444bbac60eeffbfc6d96(tjs_uint32 * dest , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPConstColorAlphaBlend(dest, len, color, opa);
}
static void __stdcall TVP_Stub_7b5718fc67458089c685dbb900126890(tjs_uint32 * dest , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPConstColorAlphaBlend_d(dest, len, color, opa);
}
static void __stdcall TVP_Stub_5713dfe9525662357d3819229e0204c2(tjs_uint32 * dest , tjs_int len , tjs_uint32 color , tjs_int opa)
{
return TVPConstColorAlphaBlend_a(dest, len, color, opa);
}
static void __stdcall TVP_Stub_8954a6b4a7f8b378c2af16a00d5059b0(tjs_uint32 * dest , tjs_int len , tjs_int strength)
{
return TVPRemoveConstOpacity(dest, len, strength);
}
static void __stdcall TVP_Stub_2ed4faa38db6f3dee0dea18ebe973d35(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len)
{
return TVPRemoveOpacity(dest, src, len);
}
static void __stdcall TVP_Stub_d0338dedb0af532d22f2075a85373548(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_int strength)
{
return TVPRemoveOpacity_o(dest, src, len, strength);
}
static void __stdcall TVP_Stub_583d57c3bb9491f8f9904c266d3f52e8(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len)
{
return TVPRemoveOpacity65(dest, src, len);
}
static void __stdcall TVP_Stub_8ac206da43e322eb8e34fce2b0959656(tjs_uint32 * dest , const tjs_uint8 * src , tjs_int len , tjs_int strength)
{
return TVPRemoveOpacity65_o(dest, src, len, strength);
}
static void __stdcall TVP_Stub_14f5f97d90bd8da89b68d035367f4ba4(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAddBlend(dest, src, len);
}
static void __stdcall TVP_Stub_ac3b21181ef4c1be73cf5e0edb4e1a8f(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPAddBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_1d7d97509292a4ca9269f2539dcc70fd(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAddBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_c4033f54a99517783b8d6ad23c90aeed(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPAddBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_f19e38d48755c971fc35408ac65562fa(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPSubBlend(dest, src, len);
}
static void __stdcall TVP_Stub_e01204e226d8aa9520b3620b68da6196(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPSubBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_b50000da98f1257cf789fc63fb1fda02(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPSubBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_c55f38b1a7623646aa5cc45d4f4f479b(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPSubBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_983d270549ec0e83e2a863b43e1e6f70(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPMulBlend(dest, src, len);
}
static void __stdcall TVP_Stub_b48d779dc6a881c67c5f8fa12655aa28(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPMulBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_d3967c6e24d0c4ad107a03c1cadd57b1(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPMulBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_6b6f416b5725a7cafb4774ffc3a00f10(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPMulBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_bc7fc5dfa228152a09d2230823c2fe71(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPColorDodgeBlend(dest, src, len);
}
static void __stdcall TVP_Stub_a1cb941317b947beb88e29fa8d46a2be(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPColorDodgeBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_8e185e82bb27a7fb40f0b08f560a57e9(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPColorDodgeBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_4b7b264b61ee0eea68213934217f5865(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPColorDodgeBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_e872f12593d6853ebdffebbb5d003c10(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPDarkenBlend(dest, src, len);
}
static void __stdcall TVP_Stub_e86fcf60fa658129d937de3728d3c432(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPDarkenBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_350741a7398a187628866f5b397c7a99(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPDarkenBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_3b5a3e187077b0b5eac9a040c99dd9e7(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPDarkenBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_2d9b2bb2cd57220048fe170f1e960cb7(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPLightenBlend(dest, src, len);
}
static void __stdcall TVP_Stub_260624e275a20115e8861eb7b0383971(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPLightenBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_15b31724287dbbecb775b2e46dc35fb9(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPLightenBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_ff652293eef07b5a7ec4f372e5504e2c(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPLightenBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_99b773033e9a2c631b483d4d0e3881f8(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPScreenBlend(dest, src, len);
}
static void __stdcall TVP_Stub_3787960fc29b8545629d894ff46d4641(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPScreenBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_3fc76257bb1639de4bfa0c0fcedf9c4a(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPScreenBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_292ee2eeb8131e34368ba9ee144b737a(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPScreenBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_ec144655bc61bfa2c6e9505cc1a0a298(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchCopy(dest, destlen, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_230218bdabfc34178a8306a54276a3c8(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src1 , const tjs_uint32 * src2 , tjs_int blend_y , tjs_int srcstart , tjs_int srcstep)
{
return TVPInterpStretchCopy(dest, destlen, src1, src2, blend_y, srcstart, srcstep);
}
static void __stdcall TVP_Stub_617dfb046aaf40078ee76715fa4756af(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src)
{
return TVPFastLinearInterpH2F(dest, destlen, src);
}
static void __stdcall TVP_Stub_8116bb2b26dcafd9fefca76e9f1d9b24(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src)
{
return TVPFastLinearInterpH2B(dest, destlen, src);
}
static void __stdcall TVP_Stub_12962f857563cd39b3cb1f9894775cc7(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src0 , const tjs_uint32 * src1)
{
return TVPFastLinearInterpV2(dest, destlen, src0, src1);
}
static void __stdcall TVP_Stub_50c0d25cd9af311a5fb0aca78f691c3b(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int srcstart , tjs_int srcstep)
{
return TVPStretchColorCopy(dest, destlen, src, srcstart, srcstep);
}
static void __stdcall TVP_Stub_6c37a1ccda816c4fbab4f0117ca75e8a(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransCopy(dest, destlen, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_e21c21762dd0e36d6f7d2cedaac97383(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPInterpLinTransCopy(dest, destlen, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_487ee86557f94113db9a981e08d29caa(tjs_uint32 * dest , tjs_int destlen , const tjs_uint32 * src , tjs_int sx , tjs_int sy , tjs_int stepx , tjs_int stepy , tjs_int srcpitch)
{
return TVPLinTransColorCopy(dest, destlen, src, sx, sy, stepx, stepy, srcpitch);
}
static void __stdcall TVP_Stub_dfdfe0e494845bf484612cc97145f85c(tjs_uint32 * dest , tjs_int len , tjs_uint32 key)
{
return TVPMakeAlphaFromKey(dest, len, key);
}
static void __stdcall TVP_Stub_e74dc11dbd56fb450eed1388a65d3102(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPCopyMask(dest, src, len);
}
static void __stdcall TVP_Stub_6981c02247de5799ea7dfbd79fdc208d(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPCopyColor(dest, src, len);
}
static void __stdcall TVP_Stub_7c559043315f6ecd7a86ec7d8d820f6d(tjs_uint32 * main , const tjs_uint8 * mask , tjs_int len)
{
return TVPBindMaskToMain(main, mask, len);
}
static void __stdcall TVP_Stub_3a8b6aca73c83d6fc9ce813661ec734d(tjs_uint32 * dest , tjs_int len , tjs_uint32 value)
{
return TVPFillARGB(dest, len, value);
}
static void __stdcall TVP_Stub_20d7ce65e240b745b10616bb5da1f897(tjs_uint32 * dest , tjs_int len , tjs_uint32 value)
{
return TVPFillARGB_NC(dest, len, value);
}
static void __stdcall TVP_Stub_f4d1217249674ac9274d358c381afc0b(tjs_uint32 * dest , tjs_int len , tjs_uint32 color)
{
return TVPFillColor(dest, len, color);
}
static void __stdcall TVP_Stub_ca77323bbe361f88f68536018fa94c50(tjs_uint32 * dest , tjs_int len , tjs_uint32 mask)
{
return TVPFillMask(dest, len, mask);
}
static void __stdcall TVP_Stub_17983ecc7e7fe370bce664281a84c948(tjs_uint16 * dest , const tjs_uint32 * addline , const tjs_uint32 * subline , tjs_int len)
{
return TVPAddSubVertSum16(dest, addline, subline, len);
}
static void __stdcall TVP_Stub_61a2f61030362903d00ba21a3cebecdd(tjs_uint16 * dest , const tjs_uint32 * addline , const tjs_uint32 * subline , tjs_int len)
{
return TVPAddSubVertSum16_d(dest, addline, subline, len);
}
static void __stdcall TVP_Stub_e9f985403dbd18540d8230a2af6ed76b(tjs_uint32 * dest , const tjs_uint32 * addline , const tjs_uint32 * subline , tjs_int len)
{
return TVPAddSubVertSum32(dest, addline, subline, len);
}
static void __stdcall TVP_Stub_be0523c9a72ba26cb4bfa3cb188cacf6(tjs_uint32 * dest , const tjs_uint32 * addline , const tjs_uint32 * subline , tjs_int len)
{
return TVPAddSubVertSum32_d(dest, addline, subline, len);
}
static void __stdcall TVP_Stub_8ac7cf651223c8ba53df90cf4f3d3bbc(tjs_uint32 * dest , tjs_uint16 * sum , const tjs_uint16 * add , const tjs_uint16 * sub , tjs_int n , tjs_int len)
{
return TVPDoBoxBlurAvg16(dest, sum, add, sub, n, len);
}
static void __stdcall TVP_Stub_873e73aa35096ad4c684d394a10135a6(tjs_uint32 * dest , tjs_uint16 * sum , const tjs_uint16 * add , const tjs_uint16 * sub , tjs_int n , tjs_int len)
{
return TVPDoBoxBlurAvg16_d(dest, sum, add, sub, n, len);
}
static void __stdcall TVP_Stub_3342548f105147c86019ae31ece01d4e(tjs_uint32 * dest , tjs_uint32 * sum , const tjs_uint32 * add , const tjs_uint32 * sub , tjs_int n , tjs_int len)
{
return TVPDoBoxBlurAvg32(dest, sum, add, sub, n, len);
}
static void __stdcall TVP_Stub_607ee0956cbb16b2afb7cb2227aa6267(tjs_uint32 * dest , tjs_uint32 * sum , const tjs_uint32 * add , const tjs_uint32 * sub , tjs_int n , tjs_int len)
{
return TVPDoBoxBlurAvg32_d(dest, sum, add, sub, n, len);
}
static void __stdcall TVP_Stub_816d84c86e86d5e7c0018d551e741e4f(tjs_uint8 * line1 , tjs_uint8 * line2 , tjs_int len)
{
return TVPSwapLine8(line1, line2, len);
}
static void __stdcall TVP_Stub_985fcda0141eb3b4c6bd8342e947f130(tjs_uint32 * line1 , tjs_uint32 * line2 , tjs_int len)
{
return TVPSwapLine32(line1, line2, len);
}
static void __stdcall TVP_Stub_d00e4f9e493334d2f65ea379ff03d717(tjs_uint8 * pixels , tjs_int len)
{
return TVPReverse8(pixels, len);
}
static void __stdcall TVP_Stub_0c246e6c7c8798e4c10d2bbfc66326c9(tjs_uint32 * pixels , tjs_int len)
{
return TVPReverse32(pixels, len);
}
static void __stdcall TVP_Stub_501015843a83368b3ff1c7c9ef5f3bcb(tjs_uint32 * dest , tjs_int len)
{
return TVPDoGrayScale(dest, len);
}
static void __stdcall TVP_Stub_61d5fc5a060f346752a3a8b6886d17bc(tTVPGLGammaAdjustTempData * temp , const tTVPGLGammaAdjustData * data)
{
return TVPInitGammaAdjustTempData(temp, data);
}
static void __stdcall TVP_Stub_0debe3e1caf0f57572a59917851676d3(tTVPGLGammaAdjustTempData * temp)
{
return TVPUninitGammaAdjustTempData(temp);
}
static void __stdcall TVP_Stub_ee3a36682f48639166ba04a19fe1b332(tjs_uint32 * dest , tjs_int len , tTVPGLGammaAdjustTempData * temp)
{
return TVPAdjustGamma(dest, len, temp);
}
static void __stdcall TVP_Stub_4d99b9e38121251b40a90cd2bd5fea63(tjs_uint32 * dest , tjs_int len , tTVPGLGammaAdjustTempData * temp)
{
return TVPAdjustGamma_a(dest, len, temp);
}
static void __stdcall TVP_Stub_f1509827696ebf5627bee1a45d675fb8(tjs_uint8 * dest , const tjs_uint8 * src , tjs_int len , tjs_int level)
{
return TVPChBlurMulCopy65(dest, src, len, level);
}
static void __stdcall TVP_Stub_bbb625e23229350453161810c41419dd(tjs_uint8 * dest , const tjs_uint8 * src , tjs_int len , tjs_int level)
{
return TVPChBlurAddMulCopy65(dest, src, len, level);
}
static void __stdcall TVP_Stub_489a6aae30de0feff5d3c5fbd42ae325(tjs_uint8 * dest , tjs_int destpitch , tjs_int destwidth , tjs_int destheight , const tjs_uint8 * src , tjs_int srcpitch , tjs_int srcwidth , tjs_int srcheight , tjs_int blurwidth , tjs_int blurlevel)
{
return TVPChBlurCopy65(dest, destpitch, destwidth, destheight, src, srcpitch, srcwidth, srcheight, blurwidth, blurlevel);
}
static void __stdcall TVP_Stub_6b9a349305f8c689dcfdbcea2566769c(tjs_uint8 * dest , const tjs_uint8 * src , tjs_int len , tjs_int level)
{
return TVPChBlurMulCopy(dest, src, len, level);
}
static void __stdcall TVP_Stub_6320d208ce1a570aca52c3cdf7421f7c(tjs_uint8 * dest , const tjs_uint8 * src , tjs_int len , tjs_int level)
{
return TVPChBlurAddMulCopy(dest, src, len, level);
}
static void __stdcall TVP_Stub_0f83f0459badd1cd352041b9243d712f(tjs_uint8 * dest , tjs_int destpitch , tjs_int destwidth , tjs_int destheight , const tjs_uint8 * src , tjs_int srcpitch , tjs_int srcwidth , tjs_int srcheight , tjs_int blurwidth , tjs_int blurlevel)
{
return TVPChBlurCopy(dest, destpitch, destwidth, destheight, src, srcpitch, srcwidth, srcheight, blurwidth, blurlevel);
}
static void __stdcall TVP_Stub_186a94b2fed609ed2d2a7ac1a2bed87f(tjs_uint8 * dest , const tjs_uint8 * buf , tjs_int len , const tjs_uint32 * pal)
{
return TVPBLExpand1BitTo8BitPal(dest, buf, len, pal);
}
static void __stdcall TVP_Stub_bde8efb9971664f2b52fe912745e2791(tjs_uint8 * dest , const tjs_uint8 * buf , tjs_int len)
{
return TVPBLExpand1BitTo8Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_386d6fa5cb73e3519b62d20470e5414b(tjs_uint32 * dest , const tjs_uint8 * buf , tjs_int len , const tjs_uint32 * pal)
{
return TVPBLExpand1BitTo32BitPal(dest, buf, len, pal);
}
static void __stdcall TVP_Stub_c61f97ec3d99bdbb23afe93870001bbf(tjs_uint8 * dest , const tjs_uint8 * buf , tjs_int len , const tjs_uint32 * pal)
{
return TVPBLExpand4BitTo8BitPal(dest, buf, len, pal);
}
static void __stdcall TVP_Stub_f92821f2b23662c6f1256511a626cd3f(tjs_uint8 * dest , const tjs_uint8 * buf , tjs_int len)
{
return TVPBLExpand4BitTo8Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_76b0732e3e2886897d5f26b4b0545dee(tjs_uint32 * dest , const tjs_uint8 * buf , tjs_int len , const tjs_uint32 * pal)
{
return TVPBLExpand4BitTo32BitPal(dest, buf, len, pal);
}
static void __stdcall TVP_Stub_903ed11ef3863850e837bd4b3b1d61a1(tjs_uint8 * dest , const tjs_uint8 * buf , tjs_int len , const tjs_uint32 * pal)
{
return TVPBLExpand8BitTo8BitPal(dest, buf, len, pal);
}
static void __stdcall TVP_Stub_2661124b39595ffafe2fb0bfb7bd2efc(tjs_uint32 * dest , const tjs_uint8 * buf , tjs_int len , const tjs_uint32 * pal)
{
return TVPBLExpand8BitTo32BitPal(dest, buf, len, pal);
}
static void __stdcall TVP_Stub_d0b7170e54398c2f9d27dcc513c4cf46(tjs_uint32 * dest , const tjs_uint8 * buf , tjs_int len)
{
return TVPExpand8BitTo32BitGray(dest, buf, len);
}
static void __stdcall TVP_Stub_31bdd2a1eed3785c1422fab5ea6b3ce7(tjs_uint8 * dest , const tjs_uint16 * buf , tjs_int len)
{
return TVPBLConvert15BitTo8Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_dbc300d1dadc1a60cb0dcadfb92f1aee(tjs_uint32 * dest , const tjs_uint16 * buf , tjs_int len)
{
return TVPBLConvert15BitTo32Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_1d4d9f8bdf55bd4c78abd90656af0364(tjs_uint8 * dest , const tjs_uint8 * buf , tjs_int len)
{
return TVPBLConvert24BitTo8Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_5c7049e712e84b40ac05942421202de5(tjs_uint32 * dest , const tjs_uint8 * buf , tjs_int len)
{
return TVPBLConvert24BitTo32Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_5dca8992bb340d70ba65ddab65c28371(tjs_uint32 * dest , const tjs_uint8 * buf , tjs_int len)
{
return TVPConvert24BitTo32Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_85f1f38f783ebfcf638f3c443bc9b204(tjs_uint8 * dest , const tjs_uint32 * buf , tjs_int len)
{
return TVPBLConvert32BitTo8Bit(dest, buf, len);
}
static void __stdcall TVP_Stub_7d61d143884bfa4b6c50dae11c2b659f(tjs_uint32 * dest , const tjs_uint32 * buf , tjs_int len)
{
return TVPBLConvert32BitTo32Bit_NoneAlpha(dest, buf, len);
}
static void __stdcall TVP_Stub_793a2ad7ad3411be3670576a8e6ddcf8(tjs_uint32 * dest , const tjs_uint32 * buf , tjs_int len)
{
return TVPBLConvert32BitTo32Bit_MulAddAlpha(dest, buf, len);
}
static void __stdcall TVP_Stub_68d8eec33254f1684e53bbc0aa8b2466(tjs_uint32 * dest , const tjs_uint32 * buf , tjs_int len)
{
return TVPBLConvert32BitTo32Bit_AddAlpha(dest, buf, len);
}
static void __stdcall TVP_Stub_b09652d2197b29f7d38aff0298c69f17(tjs_uint16 * dest , const tjs_uint32 * src , tjs_int len , tjs_int xofs , tjs_int yofs)
{
return TVPDither32BitTo16Bit565(dest, src, len, xofs, yofs);
}
static void __stdcall TVP_Stub_be7db03ddcf1886cb7233e58f19c8c77(tjs_uint16 * dest , const tjs_uint32 * src , tjs_int len , tjs_int xofs , tjs_int yofs)
{
return TVPDither32BitTo16Bit555(dest, src, len, xofs, yofs);
}
static void __stdcall TVP_Stub_b4c8fedc1ffbe30d9703cb2b8d3c0e7b(tjs_uint8 * dest , const tjs_uint32 * src , tjs_int len , tjs_int xofs , tjs_int yofs)
{
return TVPDither32BitTo8Bit(dest, src, len, xofs, yofs);
}
static void __stdcall TVP_Stub_77efef3b4ffc0cb577b76304e06e39f3(tjs_uint8 * outp , const tjs_uint8 * upper , tjs_uint8 * const * buf , tjs_int width)
{
return TVPTLG5ComposeColors3To4(outp, upper, buf, width);
}
static void __stdcall TVP_Stub_0e55187bde599d6585eaabd2c4ac3f02(tjs_uint8 * outp , const tjs_uint8 * upper , tjs_uint8 * const * buf , tjs_int width)
{
return TVPTLG5ComposeColors4To4(outp, upper, buf, width);
}
static tjs_int __stdcall TVP_Stub_f72e3fc3b97a9141b6f516f5e53bf9b8(tjs_uint8 * out , const tjs_uint8 * in , tjs_int insize , tjs_uint8 * text , tjs_int initialr)
{
return TVPTLG5DecompressSlide(out, in, insize, text, initialr);
}
static void __stdcall TVP_Stub_e7a1ac237f00bb6320d0e0ac7e6d51c6(tjs_int8 * pixelbuf , tjs_int pixel_count , tjs_uint8 * bit_pool)
{
return TVPTLG6DecodeGolombValuesForFirst(pixelbuf, pixel_count, bit_pool);
}
static void __stdcall TVP_Stub_d87682f6d691350878077bd101b7f0fc(tjs_int8 * pixelbuf , tjs_int pixel_count , tjs_uint8 * bit_pool)
{
return TVPTLG6DecodeGolombValues(pixelbuf, pixel_count, bit_pool);
}
static void __stdcall TVP_Stub_d7ae155eaabd8e65d6b4d356fe4af496(tjs_uint32 * prevline , tjs_uint32 * curline , tjs_int width , tjs_int start_block , tjs_int block_limit , tjs_uint8 * filtertypes , tjs_int skipblockbytes , tjs_uint32 * in , tjs_uint32 initialp , tjs_int oddskip , tjs_int dir)
{
return TVPTLG6DecodeLineGeneric(prevline, curline, width, start_block, block_limit, filtertypes, skipblockbytes, in, initialp, oddskip, dir);
}
static void __stdcall TVP_Stub_be3a1844ea6af533bd4e7b0a76c826a1(tjs_uint32 * prevline , tjs_uint32 * curline , tjs_int width , tjs_int block_count , tjs_uint8 * filtertypes , tjs_int skipblockbytes , tjs_uint32 * in , tjs_uint32 initialp , tjs_int oddskip , tjs_int dir)
{
return TVPTLG6DecodeLine(prevline, curline, width, block_count, filtertypes, skipblockbytes, in, initialp, oddskip, dir);
}
static void __stdcall TVP_Stub_aa531d2c3c87f456e48a14722faa1c1f(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsAlphaBlend(dest, src, len);
}
static void __stdcall TVP_Stub_6889cd886e1c2e7faf541528636c16c3(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsAlphaBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_5d9266e6a8a154fe4ba80b0995e109ab(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsAlphaBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_a7dc19b023737979ad1ae1ae01d560d2(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsAlphaBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_d20444b7a6243d668a0d3956d95af510(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsAddBlend(dest, src, len);
}
static void __stdcall TVP_Stub_1458dec9eee36816c8002d4049840355(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsAddBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_21137ff5351245b1611852301b7f5796(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsAddBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_c07fc4e45fc2dc44d839c5e012d0be60(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsAddBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_6815b962a3122ae967284239932cc656(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsSubBlend(dest, src, len);
}
static void __stdcall TVP_Stub_e96cccbe1f16b0fb74673f2ec3343ff8(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsSubBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_e8cd7494f919b18a992cb8c2722b2bf0(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsSubBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_990fdefcafc0de5e8e1f502c1b341e44(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsSubBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_de5d83ba307e822825062377fb76c2ba(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsMulBlend(dest, src, len);
}
static void __stdcall TVP_Stub_5e28bcc0f5ad6a038eb5a6535b56386c(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsMulBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_e33419e8ede4bb501ab1787cf17c7ca5(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsMulBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_1cd7cb9580c0cf723dea402b85a720b1(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsMulBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_d18ca17fad389ff60ce3caa769083798(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsScreenBlend(dest, src, len);
}
static void __stdcall TVP_Stub_0a959a5ff02530a8eb122e7e1f8ceed3(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsScreenBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_a4774ea559e64b4667b3845f8540d207(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsScreenBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_52eae3e8106494bfa604c15492ecb9f4(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsScreenBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_882f458df5e05bb9ab2222e79f6c81cf(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsOverlayBlend(dest, src, len);
}
static void __stdcall TVP_Stub_6069a18bf7d3f394c230cdcf2f574ef4(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsOverlayBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_75b60565caf44027cc52b2b5cf6b0ea3(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsOverlayBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_9d735149c3ad586363895f76645abf2e(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsOverlayBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_ea5168fae254acdd8c8db6f1f3d2da03(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsHardLightBlend(dest, src, len);
}
static void __stdcall TVP_Stub_f5a42bd5239e1a0be29f92eb838d2c8c(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsHardLightBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_7cc8cd9f415b183b42c546635aeade7f(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsHardLightBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_ad2fefa53e05528f9c1fe29d27db0f37(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsHardLightBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_f3e06fed4c82a9bd1b53252abaf50847(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsSoftLightBlend(dest, src, len);
}
static void __stdcall TVP_Stub_960db7ea36202bf7ec3bf6b767cc045e(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsSoftLightBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_7bf5d357eb52dd206a269b54c8136e0e(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsSoftLightBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_ba1c9b771c5cdb725128de684af3c9ca(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsSoftLightBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_69cc6311196adc134fd153c4c5346bc5(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsColorDodgeBlend(dest, src, len);
}
static void __stdcall TVP_Stub_8ed68f8e79efe1c767f92e7d92eb8b54(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsColorDodgeBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_60da1e9ec15b251ff18ddcdf8a3e93e0(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsColorDodgeBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_ef47304bad87a036e38f0319b48c1f6e(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsColorDodgeBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_182d19020e4e2d5cd1462d7c8ef24d1f(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsColorDodge5Blend(dest, src, len);
}
static void __stdcall TVP_Stub_9e1fa429a92a5c99d397a06c20fd6705(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsColorDodge5Blend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_74ac7c291299eb928aa4c2899df5567e(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsColorDodge5Blend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_fb645d9ec0ef3fd2aba2b762ef6b9a15(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsColorDodge5Blend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_f988626275257574050ac789f9060a3b(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsColorBurnBlend(dest, src, len);
}
static void __stdcall TVP_Stub_1831064ed23493cef407648763ba4d69(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsColorBurnBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_305390c94750daa7124db3ff6e77931c(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsColorBurnBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_4fb384a391bfcf6a3a2932661d3051aa(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsColorBurnBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_305537c4820e23cf217a15efb56dba1c(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsLightenBlend(dest, src, len);
}
static void __stdcall TVP_Stub_aacf83677ca7df75117f7bafa7a53791(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsLightenBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_d14b922fefc6c07aa536b94762579fe5(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsLightenBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_00fd650a79c603bdeb2f8e36f667a782(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsLightenBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_a36ee133c07c30185b0bbc6375954e88(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsDarkenBlend(dest, src, len);
}
static void __stdcall TVP_Stub_dc657ecacf8e578870314427216864d9(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsDarkenBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_e79d02b58a8bfdee439bc0694d7edd6d(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsDarkenBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_6b7537b66b71d27384bea45bc2bf24b4(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsDarkenBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_b3456dbad652b52f5bce1889b6f4d0ef(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsDiffBlend(dest, src, len);
}
static void __stdcall TVP_Stub_9a50803a03e1ccb60120dff8b92ecdcd(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsDiffBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_0f6b3940dc72e3e56cd15216b53b9126(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsDiffBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_23b647f1c825e214a7465de3ebe9968d(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsDiffBlend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_8ec96bc7b777180f23e1a2e43bf9a413(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsDiff5Blend(dest, src, len);
}
static void __stdcall TVP_Stub_cffd45014652659638d59abe11daf3be(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsDiff5Blend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_a784285a35b1bc76bb367305b5099e35(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsDiff5Blend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_03773751329896facf2003ab79bbc475(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsDiff5Blend_HDA_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_923884216edf134d07d8e70f8f57e827(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsExclusionBlend(dest, src, len);
}
static void __stdcall TVP_Stub_e48798dc69498f80b6633bb405eda6eb(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsExclusionBlend_o(dest, src, len, opa);
}
static void __stdcall TVP_Stub_998a5e1aa5cd85689795348fc540a655(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len)
{
return TVPPsExclusionBlend_HDA(dest, src, len);
}
static void __stdcall TVP_Stub_5f6d263c0d48d03f6eb0dc44c9dd0be2(tjs_uint32 * dest , const tjs_uint32 * src , tjs_int len , tjs_int opa)
{
return TVPPsExclusionBlend_HDA_o(dest, src, len, opa);
}
#include "tvpgl_ia32_intf.h"
#include "TVPVideoOverlay.h"
static void __stdcall TVP_Stub_bf363ba3d5b54df9d6df35a518deb6b0(const ttstr & name , void * guid , tTVPCreateDSFilter splitter , tTVPCreateDSFilter video , tTVPCreateDSFilter audio , void * formatdata)
{
return TVPRegisterDSVideoCodec(name, guid, splitter, video, audio, formatdata);
}
static void __stdcall TVP_Stub_6cc8a24cc7ce23179d1d4ccab7a8c97b(const ttstr & name , void * guid , tTVPCreateDSFilter splitter , tTVPCreateDSFilter video , tTVPCreateDSFilter audio , void * formatdata)
{
return TVPUnregisterDSVideoCodec(name, guid, splitter, video, audio, formatdata);
}
#include
/* function table is pretty large; is compressed via zlib */
static tjs_uint8 compressed_functable[] = {
0x78, 0x9c, 0xd5, 0x5d, 0x6b, 0x73, 0xdb, 0xba, 0xd1, 0xce, 0x4f, 0x49, 0x3f, 0x34, 0xa3, 0x93,
0xe3, 0x4e, 0x27, 0x4e, 0xec, 0x49, 0x3b, 0xe7, 0x9c, 0x19, 0x5d, 0x7c, 0x51, 0x6b, 0x3b, 0x6a,
0xa4, 0x38, 0x9d, 0x76, 0xde, 0x7a, 0x60, 0x12, 0xb6, 0x78, 0x42, 0x11, 0x2a, 0x49, 0x39, 0x56,
0xa7, 0x73, 0x7e, 0x7b, 0x71, 0xe1, 0x05, 0x77, 0x82, 0x04, 0x94, 0xcc, 0xfb, 0xc5, 0xb6, 0x88,
0xdd, 0x67, 0x17, 0x8b, 0xc5, 0x62, 0xb1, 0x00, 0xe5, 0x27, 0x94, 0xc4, 0x2f, 0xcb, 0xd5, 0x5f,
0x96, 0xb7, 0x20, 0x4f, 0x40, 0x56, 0xfe, 0xf9, 0xcf, 0xd3, 0x35, 0xc8, 0x1e, 0xe1, 0x34, 0x45,
0xc5, 0x2e, 0x87, 0x1f, 0xee, 0x7f, 0x5d, 0xad, 0x93, 0x62, 0x94, 0x60, 0x8a, 0x59, 0x52, 0x6c,
0x41, 0x19, 0xad, 0x8f, 0x5f, 0xbe, 0xfe, 0xe1, 0x85, 0xc0, 0xc2, 0x7d, 0x18, 0x59, 0x9a, 0x22,
0x94, 0x15, 0x25, 0x2f, 0xec, 0xe5, 0x2b, 0x0b, 0xb5, 0xbb, 0x48, 0x89, 0xf2, 0xc8, 0x9d, 0xb3,
0xd2, 0xe8, 0xd7, 0xe2, 0x2e, 0x5a, 0x83, 0xdc, 0x85, 0x14, 0x3f, 0x59, 0x96, 0x79, 0x92, 0x3d,
0x5a, 0x75, 0x6f, 0x71, 0x33, 0x57, 0x60, 0x4c, 0xbb, 0x4b, 0xb2, 0xf2, 0x3d, 0xd6, 0xbf, 0xfe,
0xdb, 0xc2, 0x74, 0x8f, 0x50, 0x6a, 0x69, 0x26, 0x08, 0x18, 0xe0, 0xed, 0x71, 0x37, 0xcd, 0xe9,
0xbb, 0x0e, 0x9a, 0x1c, 0x02, 0x9b, 0x28, 0x45, 0x7d, 0xa5, 0xb3, 0xbf, 0xbd, 0x34, 0xfa, 0xc7,
0x6a, 0xbf, 0x85, 0xa2, 0xf7, 0x91, 0x27, 0x98, 0xe6, 0x49, 0x75, 0xcb, 0x14, 0x82, 0x5c, 0xe4,
0xae, 0x7c, 0xf4, 0xe5, 0x2b, 0x91, 0x72, 0x5c, 0x60, 0xaf, 0x85, 0x51, 0xdd, 0xac, 0x45, 0x5b,
0x21, 0x46, 0x23, 0xbb, 0x2b, 0xda, 0xc2, 0x1c, 0x94, 0x28, 0x7f, 0x29, 0xf9, 0x90, 0x01, 0x84,
0xb9, 0x02, 0x01, 0xa9, 0xfa, 0xff, 0x16, 0xd3, 0x8a, 0x44, 0x17, 0xb0, 0xbc, 0x4c, 0x68, 0xbf,
0xb5, 0x5a, 0x44, 0x25, 0x34, 0xb5, 0xcd, 0xb3, 0x12, 0x3e, 0xc2, 0xdc, 0xd0, 0xfa, 0x11, 0x0f,
0x8b, 0xa8, 0xbd, 0x6c, 0x87, 0xa6, 0x2f, 0x3f, 0xeb, 0x67, 0x9e, 0xc6, 0xc6, 0x68, 0xbb, 0xff,
0x08, 0x1f, 0x3a, 0x27, 0xaa, 0x45, 0x92, 0x6d, 0xee, 0xc9, 0x6c, 0x4b, 0x58, 0x56, 0xa3, 0x10,
0x84, 0xcb, 0x3a, 0xef, 0x2d, 0x2a, 0xab, 0x1e, 0x35, 0x80, 0xb3, 0x0a, 0x0a, 0x43, 0x84, 0x52,
0x1f, 0x70, 0xe7, 0xec, 0x08, 0x44, 0xdd, 0x9c, 0xfa, 0x68, 0xe7, 0xc4, 0xa7, 0x8b, 0x66, 0x16,
0x46, 0x25, 0x4a, 0xd9, 0x0c, 0xa2, 0x0d, 0x59, 0x0e, 0x76, 0xb8, 0xad, 0xe6, 0x49, 0x1f, 0x41,
0x2c, 0xa6, 0xa9, 0x13, 0x20, 0x45, 0x8f, 0x49, 0x04, 0x52, 0x94, 0xc3, 0x7f, 0xef, 0xf0, 0xf4,
0x72, 0x9c, 0x36, 0x15, 0x17, 0xc8, 0xe2, 0x5e, 0x6c, 0x8d, 0x4e, 0xff, 0x75, 0x9e, 0xa0, 0x49,
0x16, 0xe5, 0x70, 0x03, 0x0d, 0xe1, 0x24, 0x86, 0xb6, 0xd6, 0x46, 0xdc, 0xbf, 0x9c, 0xc5, 0x35,
0x2c, 0xaf, 0xfa, 0xb3, 0xfc, 0xf2, 0x8b, 0x33, 0x4f, 0x7e, 0x9f, 0x94, 0xc5, 0x3a, 0x79, 0x28,
0x87, 0x99, 0xef, 0xa7, 0x9f, 0xfa, 0x6b, 0xf7, 0xfb, 0xfe, 0x2c, 0x7f, 0x74, 0x1f, 0xa5, 0x38,
0x79, 0x1a, 0xd6, 0x95, 0xd7, 0xce, 0x32, 0x2a, 0x9f, 0xcb, 0x90, 0x7e, 0xb0, 0xb1, 0x45, 0x4d,
0x4d, 0x25, 0xca, 0x76, 0x9b, 0x7b, 0xc3, 0xba, 0x12, 0xd1, 0xe4, 0xaf, 0x48, 0x1e, 0x33, 0xbb,
0x0f, 0xfd, 0xa1, 0xbf, 0xfd, 0x7e, 0x34, 0xb0, 0x38, 0xa4, 0x03, 0x2f, 0x29, 0xe3, 0x0b, 0x12,
0x4e, 0xc4, 0xe6, 0x1b, 0x94, 0x6f, 0x40, 0x3a, 0x45, 0x9b, 0x2d, 0xc0, 0x0b, 0xbd, 0x0e, 0xde,
0xc8, 0x8a, 0x17, 0x8a, 0x08, 0xe6, 0x59, 0x00, 0x5e, 0x12, 0x86, 0xa3, 0x92, 0xae, 0xc7, 0xbd,
0x50, 0x2e, 0x70, 0x14, 0x2a, 0x61, 0xbe, 0xc2, 0x26, 0xef, 0xc7, 0x78, 0x95, 0x94, 0x65, 0x3a,
0x84, 0x71, 0x5e, 0xcc, 0x71, 0x03, 0xc8, 0x22, 0xf8, 0xe1, 0x41, 0x5d, 0x0d, 0x2a, 0x36, 0x69,
0x15, 0xd5, 0xe7, 0x56, 0xa3, 0x5e, 0xd4, 0x37, 0x68, 0x1c, 0xc7, 0x24, 0xb1, 0xe8, 0xc5, 0x45,
0x37, 0x1e, 0xbd, 0x39, 0x14, 0x59, 0xbd, 0x13, 0x46, 0x1b, 0x42, 0xbd, 0xcc, 0xcb, 0x00, 0x75,
0x22, 0xd8, 0x97, 0x43, 0x91, 0x25, 0x8f, 0x8a, 0x92, 0x4c, 0x9a, 0x25, 0x55, 0x79, 0x84, 0xd2,
0x37, 0x96, 0x62, 0xf6, 0xa3, 0xd7, 0xd8, 0xa0, 0x5e, 0x67, 0x65, 0xfa, 0x26, 0x4d, 0xad, 0x28,
0xd5, 0x10, 0x30, 0x2e, 0x6e, 0x58, 0xc4, 0xd1, 0xba, 0xa9, 0x3e, 0x5a, 0xb4, 0xf2, 0x74, 0xaa,
0x73, 0x84, 0xc4, 0xcb, 0x3b, 0x48, 0xaa, 0xd4, 0x82, 0xef, 0x0b, 0x99, 0xad, 0xb2, 0x92, 0x2c,
0xa3, 0xee, 0xd2, 0xca, 0x44, 0x65, 0x5a, 0xdb, 0xff, 0x6b, 0x9b, 0xa2, 0xdd, 0xfc, 0xaf, 0x5e,
0xf9, 0xf1, 0x7b, 0x8a, 0xff, 0x97, 0xa7, 0xf6, 0x7e, 0xec, 0xbf, 0xd3, 0x2f, 0x19, 0xce, 0xfc,
0x3f, 0x7b, 0xf2, 0xff, 0xe4, 0xc7, 0xfe, 0x8b, 0xa7, 0x74, 0x4f, 0xed, 0x0d, 0x09, 0x98, 0x3b,
0xff, 0x30, 0xfd, 0x9b, 0x6c, 0xae, 0x4e, 0xe9, 0x7b, 0xf4, 0xd8, 0xd3, 0xe0, 0xbf, 0xf7, 0x63,
0xff, 0xe3, 0x20, 0x76, 0x92, 0xed, 0xf9, 0xc9, 0x7d, 0xed, 0x39, 0x4b, 0x7a, 0x84, 0xa3, 0xdf,
0x7a, 0xd0, 0xfe, 0xc1, 0x4f, 0xad, 0x1f, 0x7b, 0x89, 0xea, 0x83, 0x6b, 0x51, 0x8b, 0x2e, 0x3e,
0xaf, 0x0d, 0x9c, 0x19, 0xfc, 0x3a, 0x2a, 0x92, 0xff, 0xc0, 0xbb, 0xd2, 0x9a, 0xa8, 0xc6, 0x30,
0x85, 0x25, 0x1c, 0x31, 0xa8, 0x1f, 0x3a, 0x21, 0x5f, 0xfe, 0xf3, 0xff, 0xdc, 0x51, 0x09, 0xb1,
0x2b, 0x70, 0x85, 0x7a, 0x54, 0xd3, 0xcb, 0x4b, 0xb7, 0x50, 0x87, 0x63, 0xab, 0xbc, 0x63, 0x2d,
0xb1, 0x3f, 0xfb, 0x51, 0x18, 0x64, 0x25, 0xf9, 0x38, 0x32, 0x35, 0xe8, 0x50, 0x7f, 0x53, 0xe8,
0x34, 0x9b, 0x94, 0x8a, 0xb6, 0x4e, 0x5f, 0x4c, 0xed, 0x1f, 0xf1, 0x70, 0x80, 0x02, 0x72, 0xa5,
0x3b, 0x0d, 0x11, 0x4e, 0xb7, 0xae, 0x60, 0xf6, 0x58, 0xae, 0x35, 0xe9, 0x59, 0x5d, 0xed, 0xd4,
0x72, 0xcd, 0x40, 0x09, 0x04, 0x97, 0x66, 0x59, 0x1b, 0x33, 0x4c, 0x5b, 0x34, 0xd4, 0x37, 0x98,
0x0a, 0x3c, 0x1a, 0x52, 0x4d, 0x9e, 0xd9, 0x05, 0x2b, 0x55, 0x7f, 0xac, 0x84, 0x99, 0x1b, 0x65,
0xf3, 0x60, 0xb2, 0x7b, 0x78, 0x80, 0x39, 0x33, 0x99, 0x59, 0xe7, 0x4a, 0x03, 0x07, 0x54, 0x69,
0x97, 0xe8, 0x64, 0xab, 0xa3, 0xc6, 0x25, 0x1d, 0x6c, 0x60, 0x25, 0xae, 0x97, 0x2f, 0xa1, 0xfd,
0xb7, 0x97, 0x86, 0x21, 0xac, 0x36, 0x15, 0x35, 0x9d, 0x43, 0xc1, 0xce, 0x91, 0x4f, 0x3b, 0x60,
0x2e, 0x5c, 0xcd, 0xe8, 0x35, 0x53, 0x40, 0x21, 0xff, 0x51, 0xaf, 0x9d, 0x23, 0x83, 0xe2, 0x79,
0x2e, 0x7c, 0x5c, 0x77, 0xac, 0xe4, 0xad, 0x9b, 0x28, 0x64, 0xcd, 0x51, 0x80, 0xb8, 0x4b, 0xaa,
0x9b, 0xc7, 0x69, 0x8a, 0x22, 0xe6, 0x8a, 0x23, 0x2e, 0x48, 0x19, 0x88, 0xb7, 0x5b, 0x98, 0xc5,
0x0a, 0xb5, 0x22, 0xf3, 0x3c, 0x79, 0xc6, 0x7e, 0x3d, 0xd2, 0xb4, 0x7c, 0x84, 0xdb, 0x14, 0x44,
0x50, 0xe7, 0x8a, 0x9a, 0x47, 0xac, 0x24, 0xaa, 0x80, 0xac, 0xd0, 0x15, 0xfa, 0x0a, 0xf3, 0x29,
0x0b, 0x49, 0x9a, 0xe6, 0x4f, 0xdb, 0x6d, 0xd1, 0xb4, 0x2b, 0xa7, 0x0d, 0x35, 0x5d, 0x7b, 0xd8,
0x60, 0xe8, 0xee, 0x3c, 0x8b, 0x21, 0xe9, 0x30, 0xa6, 0xd0, 0xee, 0x34, 0x6b, 0xba, 0xe8, 0xae,
0x28, 0xb5, 0x3b, 0x2f, 0x61, 0x3b, 0xdb, 0x18, 0xb1, 0x10, 0x5a, 0xd5, 0xcd, 0x63, 0x7d, 0xd4,
0x24, 0x71, 0xc9, 0x3b, 0xbc, 0xa6, 0x62, 0xa1, 0xfa, 0xb5, 0xd6, 0x51, 0x3b, 0xd9, 0x7e, 0x67,
0x63, 0xab, 0xb4, 0x12, 0x5d, 0x8b, 0x95, 0x74, 0xe6, 0xd3, 0x41, 0xe2, 0x7e, 0xd6, 0x78, 0x79,
0x0f, 0x1d, 0x15, 0x26, 0x27, 0x0d, 0x7b, 0x88, 0xfa, 0x69, 0x50, 0xaf, 0x7e, 0xb1, 0xd9, 0xb0,
0x7d, 0xa6, 0x9f, 0xc8, 0x21, 0x78, 0x55, 0xbb, 0x74, 0x72, 0x36, 0xd1, 0x83, 0xb3, 0x24, 0xc5,
0xd0, 0xd2, 0xe3, 0xa4, 0xac, 0x99, 0xfa, 0x72, 0x15, 0xa3, 0xf5, 0xd6, 0x76, 0x86, 0xea, 0x7a,
0xa3, 0x61, 0xc0, 0x73, 0xb6, 0x0f, 0xc3, 0x59, 0x11, 0x81, 0x2d, 0x9c, 0xba, 0x11, 0x7f, 0xca,
0xa0, 0x85, 0x5c, 0x19, 0xcc, 0x65, 0x09, 0xf2, 0xb2, 0xf8, 0x9c, 0xe0, 0x54, 0xc6, 0xd9, 0x6d,
0x54, 0x1e, 0xc7, 0x49, 0x84, 0xa3, 0xd0, 0x0d, 0xc8, 0x73, 0xf4, 0x15, 0x3f, 0xa0, 0x41, 0xd3,
0xd4, 0x89, 0x15, 0x6a, 0xe8, 0x46, 0xdc, 0x8a, 0x75, 0x24, 0x6d, 0x1c, 0x15, 0xcd, 0xe6, 0xc5,
0xd9, 0x66, 0x5b, 0xee, 0xe5, 0xf8, 0x22, 0x2b, 0xc1, 0xcb, 0xd6, 0x91, 0xa4, 0x62, 0x6e, 0xa7,
0xf5, 0x11, 0x02, 0x03, 0x8a, 0x72, 0xba, 0x06, 0x52, 0x85, 0xeb, 0xb5, 0xde, 0x95, 0xb4, 0x7b,
0x0c, 0x85, 0xca, 0xbc, 0xc5, 0xd0, 0x01, 0x6a, 0x77, 0x18, 0x06, 0x4c, 0xc3, 0x06, 0xc3, 0xa2,
0xe7, 0x91, 0x40, 0xae, 0x84, 0x7a, 0x4b, 0x2a, 0xdd, 0xae, 0x80, 0x75, 0x2e, 0x6d, 0xa2, 0x58,
0x36, 0x75, 0x4b, 0x25, 0x03, 0x6b, 0xb2, 0xac, 0x3e, 0xbc, 0x6a, 0x6a, 0x23, 0xeb, 0xac, 0xcd,
0x01, 0xcc, 0x1d, 0x28, 0x8c, 0x0a, 0x5a, 0x64, 0x74, 0xa4, 0x0e, 0x5a, 0xf2, 0xde, 0xf8, 0x16,
0x8b, 0x99, 0x96, 0x65, 0x09, 0x87, 0xa5, 0x2e, 0xd4, 0xd3, 0x8d, 0xf7, 0x14, 0x34, 0x09, 0x84,
0xda, 0xd8, 0x38, 0x8f, 0xac, 0x92, 0x76, 0x96, 0xa9, 0xc8, 0xd2, 0x5e, 0x4a, 0x5f, 0x52, 0x6e,
0x63, 0x83, 0x5a, 0xff, 0x55, 0xca, 0xb6, 0x2d, 0xb1, 0x50, 0x96, 0x35, 0x59, 0x14, 0xc7, 0x1b,
0x5b, 0x21, 0xda, 0xaa, 0x3c, 0x9e, 0x02, 0x53, 0xb4, 0xe3, 0xab, 0xc8, 0x15, 0x39, 0x86, 0xfd,
0xcb, 0xf2, 0x0e, 0xdb, 0x25, 0xd1, 0x65, 0xec, 0x6d, 0x7a, 0xc5, 0xe8, 0x30, 0xc7, 0x5d, 0x89,
0x68, 0x76, 0x55, 0x01, 0x1c, 0x59, 0xe9, 0x99, 0x91, 0x24, 0x96, 0xd3, 0x77, 0x0a, 0x53, 0xab,
0x09, 0xa6, 0xcb, 0x92, 0x68, 0xb3, 0x55, 0x1d, 0x47, 0x79, 0x50, 0x07, 0x15, 0x05, 0xc0, 0x8d,
0xbf, 0x72, 0xdd, 0x86, 0x2b, 0xda, 0xee, 0xef, 0x36, 0xe0, 0x19, 0x87, 0xd5, 0x91, 0x8b, 0x54,
0x85, 0xd9, 0xc6, 0xf5, 0xc3, 0x0b, 0xc6, 0xd6, 0x32, 0x10, 0x31, 0xdd, 0x06, 0xbf, 0x5d, 0x62,
0x95, 0x48, 0x30, 0xd0, 0x6f, 0x05, 0x6a, 0x1a, 0x72, 0x21, 0xa0, 0x26, 0xe2, 0xa6, 0x19, 0x37,
0xa3, 0x6b, 0xca, 0x87, 0x1c, 0xc2, 0x91, 0x20, 0x51, 0x33, 0x0b, 0x29, 0x31, 0x8d, 0x41, 0x42,
0x8b, 0x8b, 0x49, 0xbd, 0xe0, 0xac, 0xa1, 0xc1, 0x15, 0x65, 0x28, 0xb7, 0xee, 0x72, 0x48, 0x0f,
0x76, 0xfd, 0xf5, 0xb1, 0x2e, 0x00, 0x75, 0x9f, 0x67, 0xe4, 0xa5, 0xe1, 0x54, 0x94, 0xae, 0x21,
0xee, 0x35, 0x24, 0xfd, 0x20, 0x75, 0x5b, 0x66, 0x23, 0xf6, 0x39, 0x39, 0xda, 0xb6, 0x0e, 0x34,
0xad, 0xcb, 0xf1, 0x91, 0x8c, 0xda, 0x4e, 0xd9, 0xd6, 0x31, 0xc7, 0x65, 0x24, 0xe4, 0x38, 0x7d,
0x85, 0xc8, 0x4f, 0x55, 0x5b, 0xf2, 0x54, 0x28, 0x31, 0x08, 0x8c, 0x24, 0xc0, 0xc6, 0xe0, 0x3e,
0x85, 0xa2, 0x46, 0x7c, 0x1c, 0x15, 0xbd, 0x4f, 0x0b, 0x72, 0xf6, 0xbc, 0xcd, 0x61, 0x51, 0x24,
0x28, 0x33, 0xc3, 0x34, 0x79, 0x4b, 0x35, 0xe2, 0xc9, 0x63, 0x06, 0xe3, 0xb1, 0x30, 0x85, 0xb5,
0x73, 0xb3, 0xa2, 0x9c, 0x55, 0x33, 0xb9, 0xa9, 0x9a, 0xb6, 0x2b, 0x1e, 0x25, 0xc3, 0xa1, 0xfc,
0x7c, 0x31, 0x4d, 0x41, 0x51, 0x48, 0xb7, 0x1b, 0x1b, 0x85, 0x2d, 0x1b, 0x10, 0xcd, 0x8e, 0x5e,
0xed, 0xed, 0x9c, 0x08, 0x5b, 0xa1, 0x4b, 0xf8, 0x3c, 0x6a, 0x85, 0x1f, 0x35, 0x91, 0x87, 0xd3,
0xe5, 0x23, 0x7c, 0x4c, 0x8a, 0x12, 0xe6, 0x37, 0xa0, 0x4c, 0x9e, 0x20, 0x53, 0x4a, 0x1f, 0xd2,
0x38, 0xa6, 0xf3, 0x24, 0x8b, 0x39, 0x86, 0xf9, 0x4c, 0xc3, 0xa2, 0x77, 0x02, 0x89, 0xf3, 0x06,
0x6c, 0xa0, 0x7c, 0xed, 0x8a, 0x6b, 0xbe, 0x86, 0xe5, 0x1a, 0x35, 0xe3, 0x30, 0xa5, 0x97, 0x15,
0x94, 0xe6, 0x91, 0x96, 0x69, 0x8a, 0x87, 0xe0, 0x1e, 0x44, 0x5f, 0xfa, 0x62, 0x4e, 0x89, 0xda,
0xf9, 0x2e, 0xc2, 0xc6, 0xef, 0x09, 0xbc, 0xc8, 0xc9, 0xa8, 0x95, 0x7b, 0x23, 0x74, 0x4d, 0x20,
0xe3, 0xd6, 0xcf, 0xb1, 0x5b, 0xd4, 0xe0, 0x47, 0x06, 0x92, 0x65, 0x4b, 0xc2, 0xfb, 0x1d, 0x47,
0xd9, 0x8c, 0xe7, 0xf4, 0x5a, 0x96, 0xa3, 0x5b, 0x08, 0xe5, 0xfb, 0x8b, 0xea, 0x2c, 0x6f, 0x30,
0xea, 0x7b, 0x1b, 0x64, 0x92, 0x1e, 0xb5, 0x5e, 0x65, 0xd0, 0x83, 0x68, 0x5a, 0xf9, 0x86, 0xaa,
0x86, 0x79, 0xc4, 0x71, 0xc8, 0x59, 0xa4, 0xbb, 0xc7, 0x24, 0x33, 0x5a, 0xb1, 0xa1, 0xa8, 0x7d,
0xae, 0xc4, 0xe3, 0x45, 0x66, 0xbe, 0x44, 0x5c, 0xab, 0xcb, 0xeb, 0xb7, 0x5a, 0xe3, 0x9d, 0xde,
0xcd, 0x2e, 0x4d, 0xc7, 0x51, 0x84, 0x63, 0xc0, 0x48, 0x69, 0x9b, 0x25, 0x4f, 0x49, 0x0c, 0x27,
0xfb, 0x7f, 0xc0, 0x1c, 0x89, 0x09, 0x68, 0x7d, 0x53, 0x41, 0x59, 0x03, 0xfa, 0x9f, 0x7a, 0x0c,
0x41, 0xe9, 0x75, 0xf8, 0xd1, 0x29, 0x40, 0xa1, 0xef, 0x71, 0x06, 0xd2, 0x43, 0x7b, 0x31, 0x3d,
0xab, 0xa2, 0xa2, 0xc0, 0xd2, 0x21, 0x50, 0x5c, 0x8e, 0x28, 0xc5, 0x0a, 0x5d, 0x61, 0xff, 0x36,
0x85, 0x6e, 0x07, 0x10, 0x76, 0x4b, 0x07, 0x99, 0x10, 0x9a, 0xfb, 0x39, 0x16, 0x8c, 0x6a, 0x57,
0xd0, 0x80, 0xe8, 0xaf, 0xb1, 0x8b, 0x3c, 0x64, 0x73, 0x20, 0x30, 0x28, 0x77, 0xda, 0x75, 0xf4,
0x38, 0x80, 0x6b, 0x58, 0x9a, 0x3d, 0x0b, 0xa5, 0x64, 0x04, 0xed, 0x5e, 0x45, 0x97, 0x3c, 0xb0,
0x5d, 0x8b, 0x40, 0xce, 0x5f, 0x16, 0xe3, 0x68, 0xe5, 0x4b, 0x4e, 0xdc, 0x24, 0x1c, 0xe7, 0x39,
0xd8, 0xeb, 0xef, 0x3d, 0x2b, 0x5b, 0x00, 0x1c, 0xcb, 0x28, 0xf9, 0x59, 0x4a, 0x6f, 0x83, 0xb2,
0x6d, 0x8b, 0x7a, 0x39, 0x9a, 0x67, 0x21, 0x37, 0xbf, 0x79, 0x9e, 0x15, 0x52, 0x6e, 0x57, 0x0b,
0x99, 0xc6, 0x91, 0xb0, 0x14, 0xd3, 0x89, 0x60, 0x51, 0x7e, 0x96, 0x44, 0x25, 0x5e, 0xf3, 0x41,
0x6e, 0xeb, 0x01, 0x0d, 0x25, 0xb5, 0xfe, 0xd7, 0x38, 0x42, 0x80, 0x47, 0x78, 0x0d, 0xb6, 0xd5,
0x5f, 0x3a, 0xcb, 0xb6, 0x1c, 0x98, 0xee, 0x22, 0x45, 0xf7, 0x20, 0x65, 0x06, 0xc6, 0x1f, 0xc5,
0x00, 0x25, 0x4c, 0x05, 0x54, 0xfb, 0x2b, 0x5d, 0xe7, 0xb1, 0x5e, 0xed, 0x4e, 0x4c, 0x48, 0x67,
0xd4, 0xdc, 0x44, 0x9c, 0x52, 0x78, 0x14, 0xd7, 0xa0, 0x20, 0xbb, 0x6a, 0x4b, 0xd7, 0xa7, 0xbb,
0xa2, 0x44, 0x9b, 0xf6, 0x65, 0x83, 0x5a, 0xe7, 0xdb, 0x05, 0xee, 0xe5, 0x0a, 0x6e, 0xb6, 0x28,
0xc7, 0x66, 0xa1, 0x4b, 0xb1, 0xdc, 0x8a, 0xb3, 0xcb, 0x05, 0xa0, 0xbb, 0xf6, 0x5a, 0xe8, 0xed,
0xa2, 0x5e, 0x61, 0x96, 0x78, 0x89, 0x24, 0xf6, 0x81, 0x71, 0x02, 0xb0, 0x35, 0x6f, 0x17, 0xfc,
0x03, 0x5e, 0xcf, 0xdb, 0xc5, 0xa7, 0x2c, 0x77, 0x65, 0xa2, 0x85, 0x36, 0xca, 0x34, 0x2f, 0xce,
0x9e, 0x09, 0x0f, 0x99, 0x19, 0x94, 0xe6, 0x06, 0x2d, 0x21, 0xc8, 0xa3, 0xb5, 0x6c, 0x57, 0x07,
0x96, 0x1b, 0xc4, 0xae, 0x69, 0xe2, 0xfd, 0x9b, 0xcc, 0xcd, 0x75, 0xb8, 0xa1, 0xa9, 0xb9, 0x89,
0x49, 0x0c, 0x83, 0x88, 0x35, 0xc7, 0x2b, 0xdc, 0x2e, 0xcf, 0xb1, 0xb0, 0x59, 0x92, 0x43, 0x92,
0x30, 0xec, 0xcd, 0xc4, 0xa4, 0xf4, 0x80, 0x22, 0x90, 0xb2, 0x84, 0x47, 0x23, 0xfb, 0xec, 0xb9,
0xcc, 0x41, 0x54, 0xeb, 0x8d, 0x3f, 0x59, 0xf4, 0x14, 0x69, 0x75, 0x5a, 0x1a, 0x89, 0xe9, 0x68,
0x9a, 0x89, 0xa7, 0x6b, 0xb4, 0x35, 0xab, 0xd0, 0x76, 0x67, 0x1c, 0xc7, 0xe3, 0x5d, 0x89, 0x74,
0x68, 0xbc, 0xa3, 0x6c, 0xd0, 0x13, 0x34, 0xd1, 0x89, 0x8e, 0xb6, 0x20, 0xe7, 0x57, 0xb1, 0x8e,
0xce, 0x32, 0xba, 0x66, 0xd1, 0xf4, 0x78, 0xae, 0xa2, 0x9a, 0x82, 0x68, 0x0d, 0x8b, 0x6a, 0x8a,
0xac, 0xe0, 0x33, 0xb9, 0x26, 0x1b, 0xe3, 0x49, 0x0a, 0xc1, 0x86, 0xcd, 0x13, 0x4c, 0x4e, 0xe7,
0x09, 0x69, 0x63, 0xcf, 0x71, 0x8e, 0x41, 0x88, 0xa4, 0x0c, 0x43, 0x92, 0xd6, 0x1b, 0x6e, 0xb2,
0x3f, 0xcb, 0x22, 0x14, 0x73, 0xcb, 0x8e, 0x0e, 0xd8, 0x24, 0xe6, 0x73, 0x9e, 0x94, 0xb0, 0x53,
0x0e, 0xa5, 0xb2, 0xeb, 0x2d, 0x78, 0xf0, 0x0c, 0x3e, 0x80, 0x5d, 0x4a, 0xfb, 0xa0, 0x57, 0x4e,
0x9f, 0xc8, 0xd3, 0x31, 0xd3, 0xf1, 0x0a, 0x31, 0xfd, 0x76, 0xf1, 0x19, 0x67, 0x53, 0xa4, 0x6e,
0xbd, 0x42, 0x9f, 0xca, 0x87, 0xf7, 0xc6, 0x0a, 0x84, 0x5a, 0x44, 0xc2, 0x31, 0x03, 0x33, 0xac,
0x50, 0x0d, 0x20, 0xb0, 0x72, 0x1b, 0x50, 0xb9, 0x0a, 0x44, 0x3b, 0xf5, 0xf7, 0xc5, 0xdb, 0x31,
0x9e, 0xf4, 0x38, 0x09, 0xac, 0x9c, 0x1f, 0x07, 0xd8, 0xf3, 0x24, 0x2d, 0x69, 0xd5, 0xed, 0x76,
0x61, 0x6e, 0xe6, 0x71, 0x26, 0xc4, 0xb8, 0x6b, 0x12, 0x12, 0x5b, 0x0f, 0xc4, 0x9d, 0x66, 0x8f,
0x59, 0x57, 0x05, 0xa1, 0xcb, 0x3d, 0x76, 0xcd, 0xcd, 0xd9, 0x13, 0x8d, 0x07, 0x05, 0xd9, 0xa6,
0x62, 0xaf, 0xc0, 0xc3, 0x53, 0xbd, 0x81, 0x22, 0x80, 0x18, 0x69, 0x79, 0xcc, 0x05, 0x2a, 0x4a,
0x4a, 0xd2, 0xf5, 0x92, 0xd1, 0x51, 0x93, 0x02, 0xb7, 0x5b, 0x3d, 0xcd, 0x9f, 0x47, 0xd2, 0x32,
0x22, 0x58, 0x7b, 0x4a, 0x52, 0xe5, 0x94, 0x8a, 0x53, 0xde, 0xb4, 0x34, 0x6d, 0x12, 0x14, 0xa9,
0x7c, 0x2f, 0xc7, 0x39, 0x64, 0x68, 0xf3, 0xec, 0x6f, 0x3b, 0xb8, 0x83, 0x1e, 0xa0, 0xa2, 0xa2,
0x24, 0x93, 0x08, 0x85, 0xcc, 0x05, 0x0c, 0xae, 0xff, 0x93, 0xfd, 0x0a, 0x3c, 0x76, 0x1b, 0xdd,
0x82, 0xb3, 0x44, 0xbb, 0x3c, 0x82, 0x7a, 0x6b, 0x6a, 0x97, 0xea, 0x7a, 0x2e, 0x53, 0x96, 0x6a,
0xa5, 0xee, 0xdc, 0xab, 0x29, 0xc0, 0x42, 0x7c, 0xc6, 0x1b, 0xd9, 0x32, 0xc9, 0x76, 0x68, 0x57,
0x50, 0xd0, 0x4b, 0x84, 0xbe, 0x50, 0xef, 0x97, 0x9e, 0xd7, 0xdb, 0x49, 0x9c, 0x3d, 0x3e, 0x88,
0x18, 0x2c, 0x7c, 0x7b, 0xc3, 0x50, 0x55, 0x36, 0x5b, 0x3c, 0xcd, 0x64, 0x80, 0xf6, 0x61, 0xb7,
0x12, 0x3d, 0x01, 0x94, 0xc5, 0xa5, 0x7c, 0xc0, 0x6b, 0xbb, 0x36, 0xc5, 0xf9, 0xb0, 0xac, 0x1e,
0x0b, 0x33, 0x74, 0x5c, 0xec, 0xb3, 0xe8, 0xaf, 0x70, 0xcf, 0xa6, 0x65, 0x33, 0x85, 0xd8, 0x5c,
0xd6, 0x0e, 0x20, 0x99, 0xd6, 0x51, 0x9e, 0x6c, 0xcb, 0xba, 0x45, 0x98, 0xcc, 0x67, 0xcf, 0x30,
0xda, 0xe1, 0xf8, 0x4d, 0x29, 0x34, 0x3b, 0x57, 0x4d, 0x7a, 0x67, 0x67, 0xb2, 0xa6, 0xc6, 0x1a,
0x90, 0xb6, 0xec, 0xd5, 0x53, 0xba, 0x91, 0xb1, 0xaf, 0x06, 0xda, 0x6e, 0xa8, 0x73, 0x53, 0x13,
0xa9, 0x7c, 0xa0, 0x82, 0xd9, 0x69, 0x98, 0xa6, 0x3d, 0xe1, 0x7a, 0xdb, 0x54, 0x97, 0x08, 0x49,
0xdb, 0x24, 0xe2, 0xb3, 0x96, 0x73, 0x93, 0x0e, 0x2c, 0xfb, 0x16, 0xac, 0x13, 0x7b, 0xb6, 0xdb,
0x6c, 0xd9, 0x68, 0x9d, 0x65, 0x8f, 0x49, 0x06, 0x75, 0x93, 0x62, 0xb2, 0x2f, 0x21, 0x4e, 0x1f,
0xf8, 0xfd, 0x55, 0x5d, 0xe3, 0xa8, 0x8e, 0x87, 0xed, 0x4a, 0xd8, 0xe4, 0xb3, 0xb0, 0xda, 0x6e,
0xe5, 0xf0, 0x3a, 0xaf, 0xa4, 0x8d, 0xed, 0xc4, 0x9f, 0xae, 0x61, 0xf4, 0xa5, 0x4e, 0x32, 0x69,
0xbe, 0x7e, 0x8e, 0xd2, 0xb8, 0xdd, 0x53, 0x3b, 0x71, 0xd8, 0x25, 0x50, 0x7d, 0x18, 0x6a, 0x21,
0x93, 0xcd, 0x75, 0xe9, 0x5d, 0xf5, 0x50, 0x1e, 0x62, 0x7e, 0x7d, 0xc4, 0xd6, 0x98, 0x24, 0x64,
0x6b, 0xab, 0xe3, 0xe7, 0x5b, 0xc6, 0x31, 0xd8, 0x92, 0x2c, 0xa8, 0x11, 0xc4, 0x9b, 0x8a, 0x16,
0xc0, 0x58, 0x69, 0xed, 0x53, 0x76, 0x8f, 0x97, 0xd9, 0xf8, 0x7c, 0x97, 0xd1, 0xe4, 0xe8, 0x2c,
0xcf, 0x51, 0x2e, 0xe4, 0x5e, 0xfd, 0xf9, 0x94, 0xe1, 0xa9, 0x94, 0xac, 0x8f, 0xc6, 0x84, 0x13,
0xb9, 0xba, 0x2d, 0x17, 0x0a, 0xe9, 0xca, 0xa9, 0x1d, 0xa6, 0xa0, 0x47, 0x61, 0x7c, 0x9d, 0xbd,
0x49, 0x14, 0x48, 0x10, 0xc7, 0x5b, 0x8f, 0x2b, 0x04, 0x62, 0xa6, 0x5c, 0x75, 0x74, 0xfa, 0x82,
0x51, 0xfc, 0xe3, 0x6a, 0x3e, 0xb9, 0xc3, 0x7a, 0xe2, 0x45, 0x84, 0x4c, 0xd0, 0xd1, 0x2e, 0x2b,
0x68, 0xed, 0xbe, 0x4e, 0x2e, 0x9b, 0xcf, 0x29, 0xe2, 0xce, 0x4f, 0xac, 0x54, 0x02, 0xf4, 0xc1,
0x81, 0x8f, 0x43, 0x20, 0x1f, 0x09, 0x07, 0x18, 0x64, 0x34, 0xe2, 0x13, 0x6c, 0xc2, 0xa4, 0x1c,
0xd5, 0x1f, 0x0a, 0xb2, 0x00, 0xde, 0x49, 0xd1, 0x87, 0xb6, 0x00, 0x76, 0x37, 0x40, 0x21, 0xd4,
0x94, 0x2a, 0x75, 0x52, 0x1e, 0xb0, 0x98, 0x62, 0xad, 0x61, 0xe7, 0x18, 0x7f, 0x78, 0x71, 0xf9,
0xf9, 0x66, 0xc6, 0x57, 0x23, 0xd2, 0x24, 0xa2, 0xf5, 0x92, 0xcf, 0x49, 0x16, 0xa3, 0xaf, 0x97,
0x20, 0x8b, 0x53, 0x29, 0x6b, 0xce, 0x11, 0x29, 0xed, 0x72, 0xa4, 0xd5, 0xe4, 0x2f, 0x04, 0x32,
0xc6, 0xa9, 0x52, 0x09, 0x79, 0x40, 0x5d, 0xe9, 0x60, 0x75, 0x1d, 0xc7, 0xb4, 0x4c, 0x04, 0x20,
0xd9, 0x8b, 0x95, 0x5d, 0x08, 0x96, 0x68, 0x95, 0xef, 0x27, 0xd8, 0xe1, 0x59, 0x82, 0x53, 0x7f,
0xa8, 0xa7, 0xd3, 0x11, 0xcd, 0x7a, 0x88, 0x18, 0xf5, 0xf1, 0x39, 0x9e, 0xe5, 0x69, 0x2a, 0xd1,
0xd7, 0xf3, 0x42, 0xc8, 0x6c, 0x48, 0x7c, 0xba, 0xc5, 0xc1, 0x07, 0x13, 0x34, 0x6f, 0x60, 0x7e,
0x25, 0xba, 0x34, 0xc6, 0x4f, 0xf8, 0x93, 0x34, 0xfd, 0x5f, 0x12, 0x26, 0x4e, 0xc5, 0x36, 0xd8,
0xa0, 0x57, 0x24, 0xc0, 0x6b, 0x4f, 0x10, 0x4c, 0xdb, 0x0e, 0x91, 0x77, 0x9c, 0x3f, 0xee, 0x48,
0xe5, 0xef, 0x02, 0x66, 0x75, 0x59, 0x4c, 0x2e, 0xb8, 0xd8, 0x04, 0xc9, 0x05, 0x06, 0xe1, 0xd4,
0x8d, 0xc9, 0x5a, 0x7c, 0xaa, 0xbe, 0xdc, 0x43, 0xd6, 0xa2, 0x72, 0x1b, 0x94, 0xdf, 0xec, 0x36,
0x9a, 0x66, 0x1c, 0xe3, 0xf0, 0x2e, 0x97, 0xb5, 0x71, 0x5b, 0x44, 0xec, 0x1f, 0x19, 0x6b, 0x5a,
0x81, 0xe2, 0x4b, 0x7b, 0x5b, 0x5b, 0x5c, 0xe2, 0x38, 0x0a, 0xe2, 0xed, 0xab, 0xcb, 0x8f, 0x67,
0xe3, 0xd9, 0xdd, 0x6a, 0xbc, 0xfc, 0xeb, 0xdd, 0xf9, 0xa7, 0x9b, 0xe9, 0x11, 0xf7, 0x70, 0x31,
0xfe, 0x38, 0xbe, 0x16, 0xf8, 0xb3, 0x98, 0x63, 0x97, 0xf2, 0xea, 0x2b, 0xa4, 0x6c, 0xd6, 0x85,
0xf6, 0x39, 0x29, 0xed, 0x95, 0x80, 0x2c, 0x4c, 0x16, 0xc2, 0xc5, 0xae, 0x58, 0x9f, 0x65, 0x4f,
0x49, 0x8e, 0xb2, 0x1b, 0x94, 0x14, 0xb5, 0x61, 0xab, 0x98, 0xab, 0xe9, 0x13, 0xb9, 0x89, 0x82,
0x07, 0x01, 0x6d, 0x26, 0x49, 0x59, 0xbc, 0x39, 0x7e, 0x3f, 0x52, 0xfd, 0x6c, 0x9a, 0x26, 0xdb,
0x7b, 0x04, 0xf2, 0xf8, 0x12, 0x14, 0xec, 0x14, 0x99, 0xa5, 0xec, 0xf5, 0x63, 0xf6, 0x4c, 0xac,
0xd8, 0x54, 0x4d, 0x4b, 0x52, 0x93, 0x54, 0x6b, 0x4f, 0x1a, 0xec, 0x8b, 0x8a, 0x52, 0x19, 0xf1,
0xd3, 0x77, 0xed, 0xc0, 0x25, 0xd1, 0x97, 0x3a, 0xf0, 0x73, 0x79, 0x3f, 0x93, 0x6f, 0xaa, 0xeb,
0x2a, 0x9e, 0x34, 0x8c, 0xd1, 0x5c, 0x78, 0xa1, 0x4b, 0xe6, 0xd9, 0x73, 0x04, 0xb7, 0x7c, 0xe8,
0xb1, 0x85, 0x06, 0x37, 0x0e, 0x7d, 0x56, 0xe9, 0x8b, 0xe3, 0xad, 0x87, 0xb5, 0xf2, 0x37, 0xc6,
0x29, 0x43, 0xf3, 0x46, 0xb1, 0xd4, 0x56, 0xc5, 0xa9, 0x79, 0xf6, 0x40, 0xcd, 0xce, 0x02, 0x82,
0x96, 0xa4, 0x01, 0x10, 0xdc, 0x94, 0xd5, 0x59, 0x2a, 0x92, 0x91, 0x73, 0x6c, 0x13, 0x30, 0x48,
0xf4, 0x72, 0x01, 0x10, 0x9c, 0x19, 0x65, 0x4f, 0x30, 0x2f, 0x17, 0xd3, 0xeb, 0x15, 0x7a, 0x73,
0x4a, 0x5e, 0x46, 0xac, 0x79, 0xdf, 0x9c, 0x36, 0xd6, 0xa9, 0x26, 0x58, 0x5d, 0xe2, 0xbf, 0x5d,
0x7c, 0x06, 0x4f, 0x90, 0xf9, 0x17, 0xb7, 0x23, 0xe0, 0x2e, 0xeb, 0xf7, 0x86, 0x6e, 0x36, 0x29,
0xd2, 0x6f, 0x9a, 0xb5, 0xbb, 0x08, 0x38, 0x4f, 0x11, 0x9e, 0xb9, 0x0f, 0xe4, 0xe7, 0x10, 0xec,
0x01, 0xb0, 0x76, 0x6b, 0x88, 0x95, 0x01, 0x7a, 0xe3, 0x93, 0xd5, 0xde, 0x97, 0x24, 0xed, 0xc4,
0xa3, 0x3f, 0xe7, 0x3e, 0xf2, 0x95, 0x4a, 0x81, 0x48, 0x3d, 0xca, 0xb8, 0xc8, 0xc1, 0x76, 0x9d,
0x44, 0x24, 0x57, 0xc4, 0x5e, 0xc4, 0x72, 0x83, 0x5c, 0xd9, 0x54, 0x61, 0x28, 0x1d, 0x5d, 0x73,
0x20, 0xcd, 0x93, 0x5c, 0xe2, 0x90, 0x0d, 0x73, 0x07, 0xc2, 0x25, 0xee, 0xa6, 0xad, 0x9d, 0x9c,
0x54, 0x6f, 0x4b, 0x8e, 0x4a, 0xbc, 0x2b, 0x2b, 0x1d, 0xaf, 0xfc, 0x3f, 0xef, 0x08, 0x2d, 0xdb,
0x57, 0xf4, 0xb4, 0x6c, 0x3f, 0x52, 0x97, 0xf1, 0x15, 0x1a, 0x47, 0xe5, 0x8e, 0x7c, 0xe3, 0x46,
0x8a, 0x72, 0xee, 0x76, 0x8b, 0x4a, 0x79, 0x9e, 0xa3, 0x8d, 0x89, 0xd6, 0x54, 0xc2, 0x61, 0x59,
0x1a, 0xe1, 0xbc, 0xbb, 0x99, 0xdf, 0x4d, 0xb0, 0x83, 0x5d, 0x81, 0x7d, 0x75, 0x5b, 0x93, 0x7f,
0xa0, 0x5e, 0xeb, 0x61, 0x09, 0x06, 0x3b, 0x10, 0x5a, 0x92, 0x77, 0x8f, 0x9b, 0xea, 0x91, 0xce,
0xe3, 0x88, 0x35, 0x52, 0x76, 0xc7, 0x07, 0xd3, 0x8d, 0x48, 0x9a, 0x4b, 0xcb, 0xe0, 0x47, 0xc5,
0x1a, 0x2f, 0xd9, 0xec, 0xa7, 0x7e, 0x88, 0x75, 0x9c, 0x0a, 0xf9, 0x8c, 0x5e, 0xc4, 0x16, 0x49,
0x57, 0xa4, 0xce, 0x4c, 0xe9, 0xc5, 0x04, 0x83, 0x1c, 0x77, 0xb3, 0x09, 0xf2, 0x76, 0xd6, 0x1c,
0x12, 0xce, 0xeb, 0x27, 0x7f, 0x52, 0xa6, 0x51, 0x4d, 0xd5, 0xbe, 0x62, 0xf3, 0x82, 0x1e, 0xe4,
0x45, 0x20, 0x23, 0x79, 0x19, 0xce, 0xa4, 0xc8, 0x1d, 0x8a, 0xe6, 0xa0, 0x60, 0x79, 0xb5, 0x20,
0xde, 0x33, 0xdf, 0x68, 0xea, 0x14, 0x5c, 0xec, 0x50, 0x8a, 0xd5, 0xca, 0xf5, 0x2a, 0x9a, 0xd2,
0xac, 0x72, 0x90, 0x15, 0x95, 0x03, 0xd5, 0x92, 0xe8, 0x39, 0xa2, 0xae, 0x41, 0x57, 0x4a, 0xf4,
0x00, 0x18, 0xa7, 0xdb, 0x35, 0x98, 0xa4, 0x64, 0xd3, 0xc3, 0x0d, 0xbd, 0xbc, 0xdf, 0x79, 0x7b,
0xac, 0xcf, 0x9a, 0x5a, 0xee, 0xbb, 0xcb, 0xd9, 0xd8, 0x13, 0x01, 0xb9, 0xf2, 0x77, 0x6b, 0x12,
0x0c, 0xcb, 0xd7, 0x2a, 0xc0, 0x93, 0x3f, 0x0e, 0xd5, 0x11, 0xe0, 0x0f, 0x44, 0x03, 0xce, 0x35,
0x28, 0xed, 0x40, 0x5a, 0xf6, 0x38, 0x4e, 0xc8, 0xf5, 0x25, 0x4f, 0x67, 0x53, 0x50, 0x06, 0x3b,
0x9d, 0x8a, 0xe4, 0x67, 0x1e, 0xad, 0x66, 0xc1, 0x31, 0x87, 0x39, 0x93, 0x06, 0xc7, 0x4b, 0xb1,
0x2a, 0xe9, 0x11, 0x70, 0xf1, 0xfa, 0x45, 0x7e, 0x8d, 0xba, 0x94, 0xa9, 0x79, 0x2b, 0x1e, 0x1e,
0xa2, 0x93, 0x97, 0x94, 0xf7, 0xf0, 0xc2, 0x66, 0xf2, 0xa1, 0x5a, 0xe3, 0x7e, 0x9d, 0x51, 0x40,
0x55, 0x97, 0x0a, 0x05, 0x8c, 0x86, 0xc2, 0x3a, 0xeb, 0x7d, 0x68, 0x11, 0x07, 0xb2, 0xb8, 0x7e,
0xe8, 0xbd, 0x61, 0xe5, 0xd0, 0x19, 0xda, 0x1a, 0xf2, 0x2c, 0x0a, 0x83, 0xdf, 0x11, 0x29, 0x87,
0x19, 0x67, 0x9e, 0xe1, 0x1c, 0x6b, 0xeb, 0x2f, 0x22, 0x70, 0xd7, 0x42, 0xcf, 0xb5, 0xce, 0xa8,
0xee, 0x37, 0x44, 0x1d, 0x56, 0xec, 0x21, 0xcc, 0x5d, 0x7e, 0x6f, 0x7b, 0x1e, 0x26, 0x06, 0x74,
0xae, 0x45, 0xa1, 0x07, 0x2e, 0xec, 0xe4, 0xc2, 0x29, 0x3c, 0xcd, 0x84, 0xfd, 0x67, 0xd5, 0x30,
0x69, 0x3e, 0x8e, 0x3e, 0x50, 0xa2, 0xb7, 0xfd, 0x86, 0xf7, 0xf4, 0xbb, 0xc9, 0xfe, 0xd6, 0xa3,
0x3a, 0x78, 0x0e, 0x0c, 0xed, 0xdf, 0xf7, 0x32, 0xac, 0xff, 0x6c, 0xec, 0x25, 0x38, 0xd8, 0x1a,
0xe8, 0x1e, 0xd5, 0xbf, 0x8f, 0x6c, 0xb3, 0xd4, 0x6f, 0x16, 0x31, 0x0e, 0xb0, 0x66, 0x86, 0xb0,
0xfa, 0x37, 0x8e, 0x21, 0x07, 0x5a, 0x4a, 0x3d, 0x75, 0xf8, 0x36, 0xf1, 0xe5, 0x10, 0x8b, 0xaf,
0x8b, 0x02, 0xe4, 0xd5, 0x88, 0x0f, 0x5b, 0xf0, 0xef, 0x1d, 0x64, 0x65, 0x34, 0x01, 0xd7, 0x6d,
0x6f, 0x3b, 0x25, 0x54, 0xfd, 0x8b, 0x0a, 0x0e, 0x50, 0x7d, 0x2a, 0x0b, 0x2e, 0x70, 0x41, 0x75,
0x73, 0xae, 0x03, 0x58, 0x72, 0x2e, 0xab, 0xf5, 0xdd, 0x07, 0x5c, 0x8b, 0x6c, 0x19, 0x94, 0xfe,
0xae, 0x64, 0xcc, 0xc0, 0x87, 0xca, 0x09, 0x92, 0x7c, 0x77, 0xba, 0x8b, 0x5f, 0x47, 0x0d, 0x52,
0x82, 0x1a, 0xd3, 0x20, 0xc3, 0x3b, 0xe8, 0xe8, 0x82, 0x4c, 0x20, 0x6f, 0xeb, 0x27, 0x32, 0xa8,
0x1b, 0xf6, 0x5f, 0xd4, 0xbe, 0x83, 0x02, 0x06, 0xd1, 0x87, 0x48, 0x26, 0xfa, 0x88, 0xff, 0xae,
0x7d, 0x0f, 0xbe, 0x88, 0xba, 0x44, 0xe8, 0xe5, 0xac, 0x33, 0x44, 0xfb, 0x2d, 0x01, 0xcb, 0x99,
0xc3, 0x2a, 0xe0, 0x2d, 0xa2, 0x7b, 0xd5, 0xea, 0x5b, 0x87, 0x4a, 0xca, 0x4f, 0x59, 0xf2, 0x44,
0x07, 0x8a, 0x4a, 0x61, 0xe7, 0x77, 0x9e, 0xfc, 0x26, 0x07, 0xeb, 0x81, 0x60, 0xf0, 0x12, 0x0d,
0x82, 0xc8, 0x3d, 0xc4, 0x40, 0xe2, 0xa3, 0xf7, 0xce, 0xd9, 0x8e, 0x28, 0xf9, 0xae, 0xf8, 0x9a,
0x90, 0x0b, 0xf9, 0x07, 0x56, 0xc0, 0xdd, 0x14, 0xc3, 0xbc, 0x25, 0xa8, 0x31, 0x0e, 0xaf, 0x42,
0x0f, 0x73, 0x0c, 0x9a, 0x9f, 0x61, 0xcd, 0x71, 0x70, 0x15, 0x6c, 0xe6, 0x20, 0xf7, 0x50, 0xf7,
0xd5, 0x99, 0xe1, 0xd6, 0xa6, 0xc8, 0x7b, 0x09, 0x8f, 0x91, 0x19, 0xa1, 0xec, 0xc7, 0x6a, 0x7a,
0xb0, 0x4e, 0xfd, 0x4e, 0x4f, 0x02, 0x6a, 0x78, 0x7a, 0x72, 0x10, 0x1d, 0xbb, 0xf6, 0x24, 0x7d,
0xed, 0xd8, 0x79, 0x44, 0x39, 0xd8, 0x96, 0x81, 0x35, 0x65, 0x80, 0x87, 0xb1, 0xa9, 0x35, 0x62,
0xf4, 0xd7, 0x33, 0x24, 0x9c, 0x7d, 0xfa, 0xf6, 0xd7, 0x2d, 0x24, 0x5c, 0xc7, 0xc5, 0x84, 0xe1,
0x9e, 0x73, 0x10, 0xdc, 0x8e, 0x13, 0xef, 0xe1, 0xda, 0x86, 0xc2, 0xa5, 0xb9, 0x17, 0xc5, 0xed,
0xda, 0x30, 0xf4, 0xc7, 0xb1, 0x65, 0x47, 0x3d, 0x91, 0x2c, 0x59, 0x92, 0x19, 0xa9, 0x79, 0xe5,
0xb2, 0x28, 0xf1, 0x16, 0x30, 0x4a, 0xca, 0xbd, 0x73, 0xae, 0xc5, 0x58, 0xb5, 0x5c, 0x46, 0x4b,
0x1b, 0xf9, 0xfb, 0xc5, 0x0f, 0x1b, 0x92, 0xf3, 0x62, 0x61, 0x41, 0xf0, 0xd2, 0x66, 0x1c, 0xc7,
0x3e, 0xb7, 0x68, 0x7c, 0xef, 0xce, 0x84, 0xb9, 0x31, 0x13, 0xe8, 0x9e, 0xcc, 0x72, 0x77, 0x3f,
0xd8, 0x16, 0x35, 0xef, 0x50, 0x5b, 0x34, 0xfc, 0x41, 0x7a, 0xe0, 0x6f, 0x8b, 0xeb, 0x5d, 0x3a,
0xd8, 0x16, 0x35, 0xef, 0x50, 0x5b, 0x34, 0xfc, 0x41, 0x7a, 0xe0, 0x6f, 0x0b, 0x1a, 0xbb, 0x66,
0x28, 0x7e, 0x84, 0x83, 0x4d, 0x22, 0x41, 0x0c, 0xb5, 0x8c, 0x0c, 0x13, 0xb2, 0x5b, 0xfe, 0x76,
0x9a, 0x81, 0xfc, 0x0b, 0xcc, 0x06, 0xdb, 0x88, 0x63, 0x1f, 0x6a, 0x1f, 0x1e, 0x22, 0x54, 0x57,
0xfc, 0xed, 0x72, 0x95, 0x3c, 0xae, 0x4b, 0x0f, 0xc3, 0xf0, 0xfc, 0x43, 0x2d, 0x23, 0x60, 0x04,
0xeb, 0x4d, 0x80, 0x98, 0x1b, 0xe5, 0xd0, 0xc3, 0x34, 0x1c, 0xfb, 0xe0, 0xc8, 0xcb, 0x41, 0x84,
0xea, 0x4a, 0x00, 0xbb, 0xb4, 0x67, 0x2b, 0xc1, 0xaf, 0x6d, 0xf5, 0x02, 0x1d, 0xb6, 0x63, 0x3f,
0x07, 0x45, 0x49, 0x6e, 0xbb, 0x83, 0x9c, 0x49, 0xbe, 0x3c, 0x3e, 0x77, 0x95, 0x68, 0x87, 0x99,
0x84, 0x80, 0xb9, 0x3d, 0xf6, 0xe8, 0xbe, 0x76, 0x94, 0x70, 0x24, 0x0d, 0x35, 0x54, 0xfc, 0x41,
0xc7, 0xb7, 0xbb, 0xad, 0x70, 0x68, 0x69, 0xad, 0x1c, 0x4f, 0x53, 0xb9, 0x08, 0xbb, 0x06, 0x5f,
0xd8, 0x21, 0x34, 0x79, 0x51, 0x85, 0xbc, 0x05, 0x62, 0x04, 0x54, 0xf7, 0xa6, 0x44, 0xb7, 0xeb,
0xfa, 0x6d, 0xd5, 0xde, 0xcb, 0xf3, 0x76, 0x2f, 0xbf, 0x4b, 0xe3, 0xcc, 0x3c, 0x49, 0xb2, 0x98,
0x08, 0x5e, 0xa1, 0x6b, 0x90, 0x64, 0x03, 0xb6, 0x05, 0xe7, 0x49, 0x9a, 0x8e, 0x3f, 0x5e, 0x18,
0x66, 0x88, 0xbe, 0xb7, 0x35, 0xcf, 0xdd, 0xcd, 0xb4, 0x2f, 0x9b, 0xa6, 0xa3, 0xdd, 0x4c, 0xaa,
0x65, 0xed, 0x3c, 0x38, 0xb9, 0xc7, 0x39, 0xed, 0x2d, 0xcc, 0xcb, 0xe5, 0x6e, 0xf3, 0xe6, 0xb4,
0x61, 0xe5, 0x5e, 0xe6, 0x1b, 0x60, 0x6a, 0x09, 0x95, 0xdb, 0xd6, 0x06, 0xc4, 0x7d, 0x7b, 0xdc,
0xe9, 0x05, 0x83, 0x50, 0xbd, 0x8e, 0x52, 0x84, 0x1c, 0x07, 0x4d, 0xd0, 0xf3, 0x24, 0xdd, 0xe5,
0xe3, 0xa7, 0x47, 0xce, 0xb4, 0x0d, 0xb9, 0xc1, 0x1e, 0xa6, 0x47, 0x96, 0xf9, 0x28, 0x4a, 0xd2,
0x55, 0x11, 0x0e, 0x23, 0x4b, 0x1e, 0x82, 0xe1, 0x76, 0xeb, 0x96, 0x64, 0xea, 0x55, 0x18, 0x59,
0xcb, 0xaf, 0x80, 0x84, 0x6a, 0xf8, 0xbe, 0x11, 0xc2, 0x7f, 0xc5, 0xad, 0x21, 0x20, 0xd4, 0x4c,
0x56, 0x33, 0x68, 0xf8, 0x3e, 0xc2, 0x27, 0x98, 0x17, 0x1a, 0x59, 0x7a, 0x3a, 0x1d, 0xbc, 0x62,
0xaa, 0x8b, 0x1c, 0xec, 0x97, 0x11, 0x30, 0x9c, 0xd0, 0xc9, 0xe7, 0x6a, 0x17, 0x60, 0xb3, 0x01,
0xe3, 0xf8, 0xd7, 0x5d, 0x41, 0xbf, 0x80, 0x93, 0xfe, 0xaf, 0x3e, 0xfa, 0xae, 0xe4, 0x95, 0xa6,
0xa5, 0x35, 0xa6, 0x4c, 0xc1, 0x5a, 0xa5, 0xc3, 0x8d, 0xfe, 0xf0, 0xe2, 0x64, 0x24, 0x6d, 0x94,
0xcc, 0x10, 0xc7, 0x7a, 0xe3, 0x18, 0x6b, 0x61, 0x6e, 0x48, 0xd3, 0x35, 0xf1, 0x41, 0xbc, 0xdb,
0x25, 0xab, 0x0f, 0x57, 0x4f, 0x52, 0x8f, 0x5b, 0x3a, 0x4a, 0x41, 0x0c, 0x08, 0x47, 0x9b, 0x60,
0x58, 0x1a, 0x14, 0xd3, 0x2a, 0xde, 0x89, 0xee, 0xb2, 0xee, 0x0b, 0xa6, 0x08, 0x67, 0x88, 0x10,
0x66, 0xf8, 0x76, 0x46, 0x98, 0x5c, 0x9d, 0x3d, 0x6f, 0x41, 0x16, 0xbf, 0x99, 0x24, 0xe5, 0x0a,
0xbd, 0xc7, 0x3f, 0x17, 0x20, 0x75, 0xec, 0x82, 0x3d, 0xdb, 0x55, 0x91, 0xdd, 0x60, 0xcd, 0x18,
0x6f, 0x8f, 0x25, 0xf5, 0x3a, 0x0a, 0x98, 0x6e, 0xfa, 0xbd, 0x3b, 0x58, 0xcf, 0xdf, 0x05, 0xe8,
0xf9, 0xbb, 0x03, 0xf6, 0xfc, 0xfd, 0xc1, 0x7a, 0xfe, 0xfe, 0x00, 0x5a, 0x2b, 0xc8, 0x64, 0x91,
0x18, 0x90, 0xf8, 0x4e, 0xae, 0xa6, 0xec, 0x65, 0xc0, 0x37, 0x27, 0x2e, 0xe3, 0xc3, 0x67, 0x10,
0x36, 0x18, 0xaa, 0x92, 0x4d, 0x9d, 0x4e, 0xa0, 0x63, 0x3f, 0x7f, 0x11, 0x51, 0x3a, 0xd5, 0x31,
0xe0, 0x84, 0x41, 0x69, 0xb4, 0xa1, 0x00, 0x9d, 0x7d, 0x32, 0x6e, 0x72, 0x24, 0x18, 0xfa, 0xeb,
0xee, 0x06, 0x65, 0xba, 0x37, 0x37, 0x7d, 0x20, 0x71, 0xe8, 0x26, 0x5f, 0xc2, 0x1c, 0x16, 0xd4,
0x07, 0x71, 0x96, 0x94, 0x6b, 0x98, 0x57, 0x70, 0x6f, 0x4e, 0xf1, 0xaf, 0x13, 0x6e, 0x69, 0x34,
0xed, 0x3b, 0x1c, 0xe2, 0xbd, 0x06, 0xf8, 0x24, 0x3c, 0x70, 0x8f, 0xf1, 0xb6, 0x61, 0xae, 0xae,
0x2e, 0x4e, 0xc8, 0x17, 0x93, 0xa2, 0x02, 0xd2, 0xfd, 0x63, 0xf1, 0x76, 0x85, 0xde, 0x39, 0xcc,
0x8d, 0xea, 0xef, 0xea, 0xdf, 0x9a, 0x69, 0x0d, 0xac, 0x40, 0xbf, 0xf3, 0x84, 0xae, 0xfe, 0x68,
0xd1, 0x67, 0xb0, 0xfe, 0x72, 0xb9, 0x65, 0x9a, 0xc4, 0xb0, 0x47, 0x5a, 0x60, 0x99, 0x58, 0x18,
0xf8, 0x74, 0x46, 0xbf, 0xdf, 0xf1, 0x02, 0x6b, 0xbd, 0xb9, 0xbf, 0x05, 0xe9, 0x0e, 0x92, 0x2f,
0x85, 0x3a, 0x4f, 0xf2, 0x82, 0x99, 0xdc, 0x0c, 0xd8, 0x0d, 0x34, 0x08, 0x80, 0x6c, 0x1a, 0xe8,
0x97, 0x8c, 0x25, 0xd1, 0x48, 0x19, 0x61, 0xa7, 0xc2, 0x8c, 0xc9, 0x08, 0x12, 0x4a, 0x87, 0xab,
0x70, 0xea, 0xf4, 0xd4, 0x23, 0x80, 0xfc, 0x85, 0xf1, 0x1d, 0x3f, 0xb7, 0x09, 0xbf, 0xb0, 0xbc,
0x43, 0xd7, 0x6f, 0xf3, 0xb7, 0xb0, 0xbe, 0xff, 0x37, 0x40, 0x1b, 0xef, 0xea, 0xf4, 0xa2, 0xf0,
0x39, 0x37, 0x6e, 0xb9, 0x43, 0x69, 0xe1, 0x61, 0x95, 0x60, 0xa7, 0xc7, 0x8b, 0xc2, 0xe7, 0xfc,
0xb8, 0xe5, 0x0e, 0xa5, 0xc5, 0x70, 0x9b, 0x84, 0x3b, 0x45, 0x5e, 0x14, 0x3e, 0xe7, 0xc8, 0x2d,
0x77, 0x28, 0x2d, 0x86, 0xdb, 0x24, 0xdc, 0x69, 0x32, 0xb6, 0xaf, 0xdf, 0x99, 0x97, 0x00, 0x10,
0x50, 0x17, 0x0f, 0x87, 0x09, 0x79, 0xf2, 0xb5, 0x28, 0x3e, 0xe0, 0xc4, 0x2b, 0x05, 0x7b, 0x0f,
0x03, 0xf1, 0x08, 0x21, 0xb5, 0x19, 0x6e, 0x22, 0x19, 0xc5, 0x57, 0xab, 0x4b, 0x90, 0xc7, 0xf4,
0x24, 0xd6, 0xc3, 0x4a, 0x22, 0x46, 0x58, 0x8d, 0x86, 0x5b, 0x4a, 0xc5, 0xf1, 0xf6, 0x71, 0xf4,
0x50, 0xfa, 0xda, 0x4a, 0xc4, 0x08, 0xab, 0x91, 0xc7, 0xc4, 0x53, 0x70, 0x7c, 0x35, 0x0b, 0x70,
0xd7, 0x45, 0x01, 0x09, 0xac, 0xd3, 0x70, 0x73, 0x05, 0xbf, 0xf1, 0xc2, 0x43, 0x9e, 0x04, 0x31,
0xd8, 0x49, 0x60, 0x8b, 0x9d, 0x04, 0x33, 0xd9, 0x49, 0x58, 0x9b, 0x4d, 0x76, 0xb9, 0xcf, 0x12,
0x28, 0x62, 0x84, 0xd5, 0xc8, 0xd3, 0x5a, 0x02, 0x8e, 0xaf, 0x66, 0xbe, 0x77, 0x87, 0x44, 0x84,
0x90, 0xda, 0x0c, 0xb7, 0x52, 0xd8, 0x1b, 0x44, 0x8b, 0xc2, 0xf3, 0xde, 0x99, 0x00, 0x10, 0x50,
0x97, 0xe1, 0x06, 0x0a, 0x7a, 0xfb, 0x0c, 0xc3, 0x25, 0x0f, 0x0f, 0x3e, 0xd6, 0xa9, 0xd9, 0x83,
0xe9, 0xe1, 0x61, 0x19, 0x1e, 0x22, 0x84, 0x3e, 0x3e, 0x51, 0xbb, 0xe5, 0x0f, 0xa7, 0x89, 0x9f,
0x69, 0xc2, 0xc5, 0xe8, 0xb3, 0xe7, 0x28, 0xdd, 0x91, 0x6f, 0x75, 0xf6, 0xb0, 0x8f, 0x88, 0x11,
0x56, 0xa3, 0xe1, 0x76, 0x52, 0x71, 0xfc, 0x34, 0xab, 0xbf, 0xb2, 0x76, 0xb6, 0xbc, 0x4d, 0x62,
0x88, 0xa6, 0x28, 0x86, 0x91, 0xf4, 0x45, 0xae, 0x94, 0xf8, 0x35, 0xfb, 0xff, 0x04, 0xec, 0xbf,
0x6d, 0x2e, 0xd9, 0x3f, 0x54, 0x73, 0x7c, 0xc4, 0xf8, 0xc5, 0x73, 0xec, 0xfc, 0xdb, 0x89, 0xfd,
0x1f, 0x79, 0x51, 0x95, 0x71,
};
static void * func_ptrs[] = {
TVP_Stub_3d4b725f0b4234d79524822e7c34486b,
TVP_Stub_3fc0c32ee41ea0c515f8fbb681e37982,
TVP_Stub_e8dbd4fe012262d9da831e0735aa33b3,
TVP_Stub_ace6cce1353865d7376caca1f2124216,
TVP_Stub_5055344aa8055bc238b79e5f88fc3300,
TVP_Stub_8238c542b814acf1a83c00cced57ba26,
TVP_Stub_bd2a14ca8c345fd7f151b08d1792fb60,
TVP_Stub_16d432f9f86738a7688cbfc9b12441ec,
TVP_Stub_6dac00582b8ba529e548ef058c4e869e,
TVP_Stub_9193ae470b5efdfe617b5e94cd8f5da6,
TVP_Stub_ec455b6ef0f5da178063db3875973260,
TVP_Stub_a56aaf685bd171b63b0ef3c894d80ecf,
TVP_Stub_9a5fe199cebb9841f94ac0bb7a4a3b6a,
TVP_Stub_2acb76a1f86e34afc5fe934d406c6c4c,
TVP_Stub_3a4d914ca7d24989c236ad223c002d49,
TVP_Stub_8fca7d3a123df1eacf228ba89f6a02ff,
TVP_Stub_58be195f96a36c158d638e3b0c79308b,
TVP_Stub_eaa4d5b1d186a807a63311ab6d5e16e4,
TVP_Stub_246f30d208c1d3a4e2b558090f403734,
TVP_Stub_3206ef9b7a8013d6572decdea49e7e2e,
TVP_Stub_c5a30d297c3a121879b1392bc6c604ef,
TVP_Stub_e398f5aef0ab92bc1323f3b094722fb1,
TVP_Stub_0733b0ac80880897d327dc6f3b04ea9e,
TVP_Stub_4cb055ed9d8ef71d1af10898965c940c,
TVP_Stub_ef8d198596b7d3143d02ed4450ccefa1,
TVP_Stub_d48ea419e040ffe8c20c1e86d80c9a5f,
TVP_Stub_679b215ff76a269871d5f325b981e561,
TVP_Stub_1039eff4a4443f9238438485a35a93a7,
TVP_Stub_2f873b0ee1c6591ba28bc4b9c0e4c954,
TVP_Stub_a583ffb56cdb2ede691e15053a8a165a,
TVP_Stub_e09ed277802c1b117e1908421448886d,
TVP_Stub_e76dfb9e00f4a9d491117d815f30db7f,
TVP_Stub_b000dd8934508d8ec6d6ef976a6ff49b,
TVP_Stub_d98ab5c968ebfde4e924901d09190774,
TVP_Stub_661e8c10d5d477e6823a840244937cd8,
TVP_Stub_6b39e70ea89c4f883689f51289029b69,
TVP_Stub_4a18b1c0afe37b84e2b35a7fc07c4e0f,
TVP_Stub_48b85c8774d91ca40b2992f0e452f19e,
TVP_Stub_5ea8db9a9193fe6bab53baf2bee06b6b,
TVP_Stub_46b92626ff6894e993c4f193a129540b,
TVP_Stub_6efc1d1f66f0e01a81faf767d7576816,
TVP_Stub_4ededf58eae77c320b4a6f5f701acafb,
TVP_Stub_028d5fda2f4568f6ab14b49d89650a4d,
TVP_Stub_11912984b8c094d2df26bf3c3677d096,
TVP_Stub_6c0df790c33142e286aea9af6993d931,
TVP_Stub_c27d85b695cd6e144210785bdfd446ce,
TVP_Stub_8422ef7f42009be0ad58a09d64149051,
TVP_Stub_ee07e6522577952453206ede39cdf54c,
TVP_Stub_786a65424247e711f6ca31f0a10603d7,
TVP_Stub_995a222f2038dd2007f2c1f6429bd19e,
TVP_Stub_da8c6e750d6a9c0557a56ef7f7fd8e88,
TVP_Stub_9cf7b0f119bcf3fa4564837ae25429b3,
TVP_Stub_17cbcacad2ed350215d7d700c676ea40,
TVP_Stub_2bd375c0598e9148d88579a51b2f07a8,
TVP_Stub_4d2c157f8b0b49e57c3e9b5abc9deb0f,
TVP_Stub_4b7eaccf64af0f3a4c4fe64f4e2dd3fd,
TVP_Stub_3a4d2602c392a8d1f4c38d537a8c95e0,
TVP_Stub_8d915d35ef8e857f245c5d46798618e4,
TVP_Stub_1e463482afa8ca30f5fa7bea4fa5741d,
TVP_Stub_fdf270e4080c986abd1649fa9fffdeab,
TVP_Stub_972e0f9a6ec4648a9fb82bcf5d9095ff,
TVP_Stub_9d76731c37c4664d654db026644c64b4,
TVP_Stub_4f1620cb699874b9c8cedf6e321c606e,
TVP_Stub_ef1c6b2b601d1b0ff70272a4d447aa3c,
TVP_Stub_9b7872860c95cfdafb056ab30318e99c,
TVP_Stub_53360f194a04fc142ddae2b9a3ab4c92,
TVP_Stub_ce1dcb05e5e7c4cafbc4ed37f63b256e,
TVP_Stub_841ce4492b37321eea0c1b500de9b352,
TVP_Stub_61785de870894968cd9d95e17e88eafc,
TVP_Stub_ad3236e727398311c3b8e1ddd5f4b293,
TVP_Stub_80e0b7be488545ff9b8bc52c9ab5fba5,
TVP_Stub_4eaa3e4efb319707db6ef81db1c6f147,
TVP_Stub_693a0152f098caee7fc77f545dd3e954,
TVP_Stub_42840710f5fba9bb32b95290b1796a55,
TVP_Stub_adec3f9ef429aa9a284081f0fc6a1b5b,
TVP_Stub_674a7948152a1d7a49050b9d98796403,
TVP_Stub_aa6f132b2031c83062f6149c90f2df5f,
TVP_Stub_b52f446e22bb92d495f7e65ac71c9bf9,
TVP_Stub_d4899fd4a8beb06f192dcb1d300e3319,
TVP_Stub_d3f5ec78464d29ee6988a1f90c2e3e1b,
TVP_Stub_a463ad6a757c3f04e09a72e288737d06,
TVP_Stub_27857bb89d35113183b682c3917d6c7a,
TVP_Stub_a5f80951cfb882ac6a3e06c0b9a95807,
TVP_Stub_35aadb63079c8bd84ebc0389bae306e0,
TVP_Stub_fb6573df5887c2020ae58136f8342ed4,
TVP_Stub_86c67d2197c46824ab10f59e568ad13a,
TVP_Stub_263a0c5b335b2c4d5bc1f55b51b8315e,
TVP_Stub_975c1099e57ab67122ddef0f44fd7dd5,
TVP_Stub_04493e5237a7ca97afd391cb7e831ba0,
TVP_Stub_9996100acc7705cb2b0c904d6bad4401,
TVP_Stub_5d91cff3b2a26ff7c0543e0f6d737117,
TVP_Stub_ef1dedc2cb58dc4e1afc14238b6fc518,
TVP_Stub_f18397fe81c043ba2346e31b359f6a73,
TVP_Stub_2ee45ad60b0c06a8d0feebc3a6aad9e7,
TVP_Stub_44500491c57e17032951fe6ed268ff1d,
TVP_Stub_056f5d278c75750df792bf8b081fbf7d,
TVP_Stub_04233bc4f7d4df92c260d23110320afe,
TVP_Stub_cdc475c4419e77c22508e337428c4074,
TVP_Stub_06bacb2910308a47bbe27ff7efa1226d,
TVP_Stub_521e053199a4aeb4e0f24d9f4a6cc682,
TVP_Stub_02164e6fb4c925843ac774ec1e4c6e5d,
TVP_Stub_5110cbbcddbd9688281ee5418e3f9023,
TVP_Stub_1db54b61f00bf931452218c4a39e79ef,
TVP_Stub_9d0edd8f51f155767301017bd3d256da,
TVP_Stub_8f744c5aa8df5471939b960bc759f12b,
TVP_Stub_ba7ff7b0b4192bd2cc7f49c7b688ad57,
TVP_Stub_7773ac921bb82c85de3be69ef86265fd,
TVP_Stub_114a781ed71edace31abb352a2671f41,
TVP_Stub_2bc5f4a97decfa82c625430479ec512b,
TVP_Stub_066fb79f94523d95d12480f23c58cc8e,
TVP_Stub_803906b8de16ff825d4e69e1952d872f,
TVP_Stub_34cc96a5118ee1e12b0750ea64d40b1f,
TVP_Stub_dbe821fb8b651d42a9c8e730517c408c,
TVP_Stub_8970ba46068ac74746c3e84299937d8f,
TVP_Stub_438e27dcbb077284213eb4d7dcd43f8f,
TVP_Stub_a98d712ca19a49afe07d0a7c5d064cef,
TVP_Stub_08aef69683bcfe2a5c63d4c7866de8e9,
TVP_Stub_dbc9bc2e27068c8426b1c6a7f89424e0,
TVP_Stub_5eeb98ca016123f57966457533bb639e,
TVP_Stub_98fdc846d0b4a83412f3521f65bb98b4,
TVP_Stub_3309591d3c7f6f688e81588f169dba21,
TVP_Stub_d83a866389246d824efcc83303a04484,
TVP_Stub_6cf6f332a6a14a15e8dce62301f5c840,
TVP_Stub_566eeea3c5f009b0fc6fa123ba30f496,
TVP_Stub_88806e38e35c73b36acadd4061a4fe0b,
TVP_Stub_3bb69d3886159aaecc333b6ff17287bf,
TVP_Stub_3e36278551a9c8b29cb2e8017db6af0d,
TVP_Stub_5de99d84f3dc902cb0812fb85a7d5c88,
TVP_Stub_31e85cbc73f8fbd4cea895a751480059,
TVP_Stub_6ae29e405ede762f1a89a9dd526cb36e,
TVP_Stub_c95bd66d95c153cdac41b5243e555f5f,
TVP_Stub_72a67e9c52fd27dbb66eded47efeea74,
TVP_Stub_fb13e41bda53e4e59403e3e14effccd6,
TVP_Stub_9a5c710e620e47f105752453ad5d6ab1,
TVP_Stub_18f1ad16c11429707cbf8ea4d1d4a21e,
TVP_Stub_550f317b573a1256af00586890ae82f1,
TVP_Stub_cd50da721dfb63f36c1ebb1226830428,
TVP_Stub_fbba3dd6a087599d1277ae58f6cec18e,
TVP_Stub_43cc5b5a61a6090af83333d115b5b868,
TVP_Stub_616fb5060d81eb5bab58647596582df4,
TVP_Stub_168cf4c1b9ef70b98f2e0ab3695a4f3b,
TVP_Stub_314573cca30a7c2aecc9166fbf5400c9,
TVP_Stub_03da356426c038fad663c836c3e330ef,
TVP_Stub_31dbebdedc08d75e34a2cd564ce60586,
TVP_Stub_d9224ad7a0de743a7eea15fdb2c5f934,
TVP_Stub_c01b0720b49ce4f792446d8965d2c31f,
TVP_Stub_4af47e46a11e1357cb994f405289d13e,
TVP_Stub_25b6dafa19bfa5bde1a8b519da248f82,
TVP_Stub_72425405819c900aec719491cbd90c6d,
TVP_Stub_a79942af73f33bff6e432c9fd808e469,
TVP_Stub_df106470a4141ebc7eda22160859ffdc,
TVP_Stub_469bc225b0ecd9561aae5a46b85ded42,
TVP_Stub_a6663c078b3aa79b39ee2d09f3875765,
TVP_Stub_efbe634ce4f13633e220cae167cf63fb,
TVP_Stub_57f4147bcc09e4e4442ffc9b0895727e,
TVP_Stub_1fb2d2e44cf83aebef7b26fd6b20bc2b,
TVP_Stub_bd6aa777bac947f5cffd891e9c724794,
TVP_Stub_83c662330b75d616cdc8a4e11d7ababa,
TVP_Stub_bbde02fe30c8a6cadb7073174ea3a874,
TVP_Stub_cc1c14f63867f90bc883de03e9212cbc,
TVP_Stub_236e007b32bc2631b5f6dc1eda6be0a9,
TVP_Stub_cfbb9809e0e6d954b2652856e935ced9,
TVP_Stub_60ee96ae4a7704340bef20fb35ba6ade,
TVP_Stub_564b37278b50f4e5597dff6540868d49,
TVP_Stub_890b3a4831b824653e919b4a5197358d,
TVP_Stub_2dfa6c77c5051d160b8a06f540e0d68b,
TVP_Stub_05f88567d510fd84659ccbf493f647ed,
TVP_Stub_7166b8f7bb9688c980e4fa172f06f30c,
TVP_Stub_b9456ecba8b7898d80d2e5caa64035c9,
TVP_Stub_dd44464bd8430a5be5fef0cffcd97117,
TVP_Stub_a57696ca0c157cd7d3cd4e58c1df957c,
TVP_Stub_1aea9f8a38bbb875b6d052f330da9178,
TVP_Stub_2d3b3d6e22ee139cda9eee47dc031945,
TVP_Stub_8ff49e56c3c4c566561dcdd5c9ecc4db,
TVP_Stub_490b547e93e40082d0b83312467104f9,
TVP_Stub_2c1ef06748df47df52b586ac0fbc6a34,
TVP_Stub_b6b2a03160b88239eccd18d89b1537d3,
TVP_Stub_8becefbd52c76c7ecb0ea7b7f50b7915,
TVP_Stub_74b9687a3bfd3b2c7abe226efc4225c1,
TVP_Stub_7cafc2bf5965b594e60830e3057bbd58,
TVP_Stub_80f111939c5694cbf43d07cf0ad1726c,
TVP_Stub_8dc9cef84191f79b38403a2070952fd4,
TVP_Stub_1d42bd1e659b36886c20567497b7ee96,
TVP_Stub_0848fbdc7eeddb12c80bcd9c31383a64,
TVP_Stub_1f1123c906c28ab6d16b6bef3f7ae978,
TVP_Stub_b84394e20cc73a90349cf5be4e783111,
TVP_Stub_76e0db3797851fe8ff90cf84780c50ad,
TVP_Stub_6616241156c22bced42cd9f2f647677e,
TVP_Stub_1ace346a3dd546c66ad115a33d8cf693,
TVP_Stub_96fb9bbe33531d4268573355c658e165,
TVP_Stub_c90b5737134c76f9ed0bb5da7cfaad8c,
TVP_Stub_070ed05259a265cabdd82bfedabdd638,
TVP_Stub_008b7e3a4c5bb23ee991f684a5064737,
TVP_Stub_b64741dc4544ed43c44ddb6d0eb838ea,
TVP_Stub_5b83e28b2d9ab0f75d7c7f6f61b5ded6,
TVP_Stub_b948c9f43837efa489b0b91f3f675710,
TVP_Stub_eb83216f6f718245468ef48b97ab4c2d,
TVP_Stub_c66ab4868b743de9c0ba8b26c67b23da,
TVP_Stub_586e16d502a6ad98b08161bdb090f8b6,
TVP_Stub_d8bc9c71c80b200c39b29167d795cad0,
TVP_Stub_85df4beb87f6503891e116ce046353c3,
TVP_Stub_35b6a7e1c73f257aae91e05fa9826e84,
TVP_Stub_a25b46701e25030af1ed847e0df229eb,
TVP_Stub_c8906bf1efa5e86f9fddfab55a01c8f6,
TVP_Stub_8141059f613820f694608af28e20cbad,
TVP_Stub_cf2690e47099ac6378ed50df4a8a8e90,
TVP_Stub_810c7054e44f535cf250f00707105417,
TVP_Stub_52a9af7905ddc71d8b4e0ef7366eebdd,
TVP_Stub_1635dbae2d91b338ddfd0430f8aa7f10,
TVP_Stub_30df0c29ad8f672f7fe0742b4b11cd7f,
TVP_Stub_61c82dec644c58290a25f34a69478870,
TVP_Stub_f08e347d2d47dc5fc9a3cb59355b4fbb,
TVP_Stub_5c62e59c2062f658d4c79d5257a9a586,
TVP_Stub_259c72d8bfed1210ca71c54f24cacc7a,
TVP_Stub_801a92ace08eb7ed001406869a39a75f,
TVP_Stub_e22e647af4ded8e51b1e76c845b4c8e2,
TVP_Stub_12902221314df9bcf7f7cb74a5242fe0,
TVP_Stub_b10feea1619ba8ac11237c12002cdb3e,
TVP_Stub_19755b50d241edcb477bdcac22663778,
TVP_Stub_040a0ecf46963e094ee8ec32ab3f1962,
TVP_Stub_525c529dc687b5d86424d775d00bdfce,
TVP_Stub_c96107b91e2a215f560a2612c6e85931,
TVP_Stub_b8788eaa2ca495263c6ea2df264af5f5,
TVP_Stub_4c6494008c520d896d699f82aca30b25,
TVP_Stub_7d8f8d5e0832ecf248b19a89801ead0e,
TVP_Stub_70849965060a6402f41b0b11ec2bb3a7,
TVP_Stub_c72efa6b4efaa6664ae637a03e98e866,
TVP_Stub_a250e46575d0df1166e1542613218a5c,
TVP_Stub_a7bcff67b8d380c225b9d0d83921b3ae,
TVP_Stub_fb68a3aa16bd2eb7d7550283170321bf,
TVP_Stub_35b4299ede11f511b331b713ba9f38a8,
TVP_Stub_efe52691cff20b2dfaa16e8e16caac0a,
TVP_Stub_38eed43ef69251c34dc45695b8cf35c0,
TVP_Stub_2058b65abdfb7598910f0d584d40a19d,
TVP_Stub_1ebecaefe2ffdc811fccbac42e67e544,
TVP_Stub_09e0f0912f8d758d3736ece9478c2686,
TVP_Stub_23d61eda3959b087b618e348471e2c36,
TVP_Stub_e99b22c79b5bf04f3382f959c7bb69ca,
TVP_Stub_9c4bb9ebee4db0fcebeae11c34950f97,
TVP_Stub_505a9563aeb1b0255cfcc8197bee7d9e,
TVP_Stub_f5ab80fc67ee04570330b9035144e760,
TVP_Stub_af50188bbaa019ee88b19ecd931f7cce,
TVP_Stub_268c452e85a6ac75301a6132f4f5e38b,
TVP_Stub_646770a19b1768b372c9991ef0d3de85,
TVP_Stub_5ec88e04fcb8e1877752281e172173ed,
TVP_Stub_923f8161f2d2ba0e883bc4edc2901960,
TVP_Stub_6f70cdb7586cbe571204f286f43c9780,
TVP_Stub_9a4eaa6a627038799015c093609bdde7,
TVP_Stub_c8bb6590f4a7adc906d7b3e42d907267,
TVP_Stub_8323d57f26876d87271dbfa257b7f7e2,
TVP_Stub_4d6f148e8997e1ae0cc0006ec1bd9618,
TVP_Stub_7f03a4ddb254d0518642d15513eaea85,
TVP_Stub_4add3926c72ba9df9259be58b680de0d,
TVP_Stub_075d42cff8dc0c1fbd99c7459a63e526,
TVP_Stub_b6bc45b28e194c7ac98bfdea88edee36,
TVP_Stub_6dff6abb075da1a304520e60c011ef7b,
TVP_Stub_892ffbdb8375851fc557e4abe9589b77,
TVP_Stub_b2f3538284fc2adda2a43272ee654a96,
TVP_Stub_e0ff899ea4a9cc49a0e3b38deaf93b45,
TVP_Stub_4b9c9ac2aafad07af4b16f34e9d4bba2,
TVP_Stub_c2e423356d9ca3f26f9c1d294ee9b742,
TVP_Stub_c07314686fdf5815ce9b058020da942b,
TVP_Stub_4a197be1985d45ee86d5672d24134560,
TVP_Stub_dec720a9c3cd2b378f195cf71a9ff8b0,
TVP_Stub_5726a5c7af641ebaa504dc9ec8380938,
TVP_Stub_1c53bc96ac9dfd483c2227bc5fa44825,
TVP_Stub_1940c8fa03145aa029d0b7718ce0c809,
TVP_Stub_b37f047c0f9bd143b34a2fc87ce5f16e,
TVP_Stub_dec35fbd2a24fc32e5c220174d864cf4,
TVP_Stub_86fd45a126296891aee413388597203e,
TVP_Stub_603243e54f3508c37d993e8359b735dc,
TVP_Stub_c3eadbd75b32dabe6faecebf492eb486,
TVP_Stub_725e49de1d970ef04b179776666f2c34,
TVP_Stub_55a9b73f877bfd4c6d8157e7b1c458df,
TVP_Stub_d070209f152dd22087e6e996e02c85cf,
TVP_Stub_308f905626bc51c7ef9b65b2c0ca34b2,
TVP_Stub_95aab2a1ac9491e8026f4977e0918760,
TVP_Stub_e0ac94325eb783ca2fe7856a54444c90,
TVP_Stub_0c99a79e866f08b4df3914e83fc203dc,
TVP_Stub_f2de531a016173057ff3540e47fed4e6,
TVP_Stub_4224a9066d8d13d6d7e12f1ace6a5beb,
TVP_Stub_900476efbc2031e643c042ca8e63a3d7,
TVP_Stub_07dfce61d490cf671a2d5359d713d64a,
TVP_Stub_52d30ac8479ef7e870b5aff076482799,
TVP_Stub_8e4d0392ed46e87f94e5fcf675a124a1,
TVP_Stub_73f46e08d17e707725f433b454f05a89,
TVP_Stub_80d60e682fa72973071e335db272a2a2,
TVP_Stub_6bd6262185fa0b9cf1750f6a525d893a,
TVP_Stub_cf29f737d4eb450b26789d421d0ec69a,
TVP_Stub_13c0e371c08fd1b9da2f0c103d01c59a,
TVP_Stub_82693e38df8f033ea98f9b7969d66d7b,
TVP_Stub_6e3f8a3b18f55dae6153a889f00a3e87,
TVP_Stub_efe14a197131b4813656d6669cc3475b,
TVP_Stub_ba4ecf60f872f757b69c84f457b3e941,
TVP_Stub_dffedabe32ce886e3b7e695b44ad3547,
TVP_Stub_f518c60b165658d19a0fadd8f69586aa,
TVP_Stub_6fefcb1c2ca01a876c301ab41dbdab9f,
TVP_Stub_df55083347df0483b4ca6ba1e4f0b9a0,
TVP_Stub_d8d28310f702714733c4c5dc850058df,
TVP_Stub_52d24c38b05be174bc5c4fdcf02e9b9f,
TVP_Stub_f27f455c8f30cbaf1706faac3c7b8e02,
TVP_Stub_78ec453a50b2800bb01347e8ebbac000,
TVP_Stub_0936d0f6fc53339d255893e58bcc6699,
TVP_Stub_f4f7181b7fd679784c50b0cc7ba4c60e,
TVP_Stub_79816d7e5741c2416fefe2c2a8baef00,
TVP_Stub_42a3d248fab928f16555abcceca62834,
TVP_Stub_926d6212b8b1b238e7bef9b17a3ee643,
TVP_Stub_236e3d626784d80ca2cc5b2fe14cd9c6,
TVP_Stub_1bfac11a5f95c842f97a8bb57d4019de,
TVP_Stub_198ce21c54b0cea4c1bf5eeba35349ab,
TVP_Stub_590a1ec7f64904eaa32b5c771bb5f8cd,
TVP_Stub_dd13d4bc2b48540a92f047bf015b829b,
TVP_Stub_0ff502d492598d2211405180bfb4d1e1,
TVP_Stub_cf5401746759bfe38918087aaab6c57b,
TVP_Stub_04e84aa7d8cf0477d55c700164544b38,
TVP_Stub_449039d3afbfbd52a63130a3b227a490,
TVP_Stub_347a4fa85af84e223c4b61d33ead694a,
TVP_Stub_4ad1dd24b3b4769ee10149eea006af7a,
TVP_Stub_b246b17b62d273bdc04e9d9e827f5c74,
TVP_Stub_9974ebc6296f925cff55d8bcb2d52ce9,
TVP_Stub_0e0c9d9107d8c56b8bc4d4198ae9208a,
TVP_Stub_c23ece207f6ec2dd7c76ef873047aee3,
TVP_Stub_81507020bc646be2f53ab95b9430ba27,
TVP_Stub_acc0d3861d1b971abcbdda1c075dd681,
TVP_Stub_ff2dccead1b31e3f34e8be3e2ba5bbf1,
TVP_Stub_e17db0d4f69625c61aba7fffe540dded,
TVP_Stub_5bbc872e7bba5b761c509d31116e4460,
TVP_Stub_4adf361303eae78829250c7b732a5722,
TVP_Stub_bf172364c57c1aa561b145fd5cacda0c,
TVP_Stub_d7687aa80dac10f88deac7aa7e70538a,
TVP_Stub_b18b7259f98029f745c75291d6855ab1,
TVP_Stub_b79e5d877116025576ca1f76af124009,
TVP_Stub_8aea098dfe8a36c705cc2a9e1a189b84,
TVP_Stub_4ccd3f6ab60d61be6dbfc59e8e3d1726,
TVP_Stub_3d70bb72a7d7765c7e8ea580079ab7e9,
TVP_Stub_eba9b272d78a4b0cd7f9212e29a58607,
TVP_Stub_cfbe8ee9d43aa64ae4190eac91f7c55f,
TVP_Stub_a4308a386968ef5d23025ab8a9e8c6db,
TVP_Stub_5a4fcbe1e398e3d9690d571acbbbae9f,
TVP_Stub_5b62f504fe6d22428d7518d6c52d775d,
TVP_Stub_fb3b405f8747b54f26c332b9e6af81cd,
TVP_Stub_b7ccd11d130f186883c109d2ba17b598,
TVP_Stub_cf8ab6c24f25993ccc7663e572ac2991,
TVP_Stub_ba40ffbca76695b54a02aa8c1f1e047b,
TVP_Stub_c97720e639e95ba5130ce9dd78d30403,
TVP_Stub_c5557ac5391b1b831a22e64b65d1746c,
TVP_Stub_3243a4c32d4f674f1bbc8d3895257568,
TVP_Stub_78390a3d08879903ee9558e9df68db4d,
TVP_Stub_58e9454d7096a52808f9a83b9ce25ff0,
TVP_Stub_cdefadd0c3bf15b4639b2f0338a40585,
TVP_Stub_4bf80e9bac16b9e3f9bf385b2fbce657,
TVP_Stub_51aeacf2b6ef9deb01c3b3db201d6bf9,
TVP_Stub_9ed5432d73448da47991df9577ee97bc,
TVP_Stub_cf1d02d1cc1aff0aae6c038c95dac80f,
TVP_Stub_ddb0e05c72c0692e78af885ac7ec82dc,
TVP_Stub_a3029db6292616cd16c228b91dc4af13,
TVP_Stub_2d90871c6bc15a9e8d97d24c29e78e3b,
TVP_Stub_0af6744e35e38276d6a98c1f382b1519,
TVP_Stub_ad40567a051208757642e5e087f3e741,
TVP_Stub_6a15185daab9b274963fe5ef46305775,
TVP_Stub_073a2332a8ab3ed31ab81daea3d3f2c4,
TVP_Stub_01216e91225e06c7422bef0c2febc0cc,
TVP_Stub_16ce22ad500a5bdfd5d5743c847a28b6,
TVP_Stub_59251c4104f736fa2690c5f77fb0a908,
TVP_Stub_f923750e0fdb51a6fc6c304832cb3dd3,
TVP_Stub_bc77a1e312ff7827d90387fb92f0f5b0,
TVP_Stub_2090afd7ae8bcb021ec4d04947d0d845,
TVP_Stub_3a0f858bdf86199dc2d00b583a3b915f,
TVP_Stub_0d316a141f7a502ff8d9ffe2d38d25a8,
TVP_Stub_b31ff64ae2d8f93dbf28161d5080b295,
TVP_Stub_d9b1c73516daea6a9c6564e2b731615a,
TVP_Stub_003f9d3de568fcd71dd532f33d38839c,
TVP_Stub_5da29a19bbe279a89be00e16c59d7641,
TVP_Stub_c1b52e8f3578d11f369552a887e13c5b,
TVP_Stub_b94ead6de9316bc65758c5aefb564078,
TVP_Stub_8a35be936d2aca049e398a081e511c97,
TVP_Stub_5b1fa785e397e643dd09cb43c2f2f4db,
TVP_Stub_29af78765c764c566e6adc77e0ea7041,
TVP_Stub_9e0df54e4c24ee28d5517c1743faa3a3,
TVP_Stub_d3aaa55d66777d7308ffa7a348c84841,
TVP_Stub_b426fbfb6ccb4e89c252b6af566995b8,
TVP_Stub_c145419db7b63f7488ea05a2a8826c1d,
TVP_Stub_d795cd5ebfb6ca6f1b91bafbe66d7a65,
TVP_Stub_4564a3ce5cf48cb47e63a3948cef03be,
TVP_Stub_bee2775f2e4042043b7cb08056d2ae5c,
TVP_Stub_5fd8dfd2816a2cfd4a51cab41053d575,
TVP_Stub_9982ebedc12d343cb098e2a7b25bdef1,
TVP_Stub_81eeacbed5ee6129bef4b370e28b5d10,
TVP_Stub_6ed1088905d99012d2fb5827ea19527e,
TVP_Stub_b4d6c64cc0004ffaba804f0e8f02ab9b,
TVP_Stub_2c3e08b8df93ec50451edd916c707030,
TVP_Stub_eba070d1583ca5f5d02630ba33a5504b,
TVP_Stub_ee474537852ce5eb165cb1761950faba,
TVP_Stub_eed221c603243522667e2f1c6ace3ba4,
TVP_Stub_1f973c5e3cfaf00fa752b7e22d7ba481,
TVP_Stub_b9d5260bba9edd7503f1adf882218979,
TVP_Stub_aedbd2eda61145de808e295331884245,
TVP_Stub_ce0f184e84752eb279e4f900d8b53c18,
TVP_Stub_0217d49393163b80897d044c1d93092f,
TVP_Stub_5bbd9d5b364840e9615af35a62f69d7d,
TVP_Stub_2b2837e81fcaeec35f61a2a3ecf2fb2d,
TVP_Stub_bb0706a78e9066944bfbffd1406be2d4,
TVP_Stub_770e67c91215292980b88cc6efb9f2a5,
TVP_Stub_068ab11f05731f2c2e9ea8c5fdb16a9f,
TVP_Stub_b9873a0ad2653952cb2948b817e786e4,
TVP_Stub_11d9804ae4db32d731af69c397769cbf,
TVP_Stub_421f5aa6dbaaaf946f74942c77aac9bc,
TVP_Stub_563ee9dcb14a2914fc246e64679f42b5,
TVP_Stub_e23a54b6b80bd03111a40f669524724f,
TVP_Stub_c90c8bbd18a7190636ae4269c36ad005,
TVP_Stub_03c54a8e8c86e171f868a624e490691f,
TVP_Stub_30b63f3cc59b39f1a71829bbbdf6e45d,
TVP_Stub_705bcc30a0561ec679c2267e1a573b23,
TVP_Stub_5c627d080007e455b0393a9b4457cd4d,
TVP_Stub_72a64cecd44d80f95fc93faf0d239e32,
TVP_Stub_ef838904712bfdc614dbc689fbe7fb18,
TVP_Stub_acc97936adc40656e824cfdf7a34e20c,
TVP_Stub_5ea1ba3602f9d9fee344de6c3406d7a3,
TVP_Stub_d25f0771b8fc7715d69f01d950463a49,
TVP_Stub_f8ab11c930782ce058e517d0440ec87f,
TVP_Stub_b8157e369d53c2d944b76494980ced7b,
TVP_Stub_aba94f656b4c1de827d11c72b36a5e9c,
TVP_Stub_0656942f5a95783a4de73ca6e654d3b5,
TVP_Stub_5c2b7d12713dd5a94ef8e6eff1f79752,
TVP_Stub_6f1d30ac7e812cc5a059459c47638cd0,
TVP_Stub_1d51684322635e7848ef53f7f6be8a1e,
TVP_Stub_a1f2d56d138a4038fe1678328910a81d,
TVP_Stub_c135ef491b533febfd49696d22a1dd3d,
TVP_Stub_579117a873b466d78bf93e49c4a078da,
TVP_Stub_ec8fa08705639eb7ae5d44ab63dea5e8,
TVP_Stub_b49dc1cda6109256815dae7b4293725d,
TVP_Stub_912a670f56707ac70f2fee13660c2af8,
TVP_Stub_d0159986645df76b8c66fdb662efffde,
TVP_Stub_cd7a2e6f91bf8d2daa3e28139d7d9f5c,
TVP_Stub_676004ca892b2bfee6859d0bb132fdd7,
TVP_Stub_d4b161d8a745baa5e2113669773a758f,
TVP_Stub_ef7537293f6e3b6127480f6c5fd018a1,
TVP_Stub_6f6f73b75cffe40a28566d1832ae1224,
TVP_Stub_7adc5aad39e459e01543d07c239efe57,
TVP_Stub_3ff6b480097eec3f5fdb7bfad685fd2a,
TVP_Stub_b2c50c3a1dfea7e9d05fed69818bafc3,
TVP_Stub_8024df9077e2c85b5b718ad2c87e57e7,
TVP_Stub_989769d4eb8e42e9c9bbe721b296406c,
TVP_Stub_cc1ac928b5c31570dfba7ed8f565be4b,
TVP_Stub_62931efed5729a332e60bd1f7c7cecdf,
TVP_Stub_53c18160b157088f72a9afd79737b48b,
TVP_Stub_48135697fd7f4df87402a7dd4d761555,
TVP_Stub_e2c71cf04e876069eb7315c800a96898,
TVP_Stub_1f63c018cf805ca1168af192cf8a4b41,
TVP_Stub_704a9574dafd3669e10d546549948e03,
TVP_Stub_97905c510b9502c20c9322c9f5fb4188,
TVP_Stub_b23e84230c4736667279c7a71f4ca53e,
TVP_Stub_eb41fc900b0a6e3aba9d531f266137f1,
TVP_Stub_5bd02c627b74bbb22d5a525b8bcbbd27,
TVP_Stub_cc82e6a6b31ea743b9ebbdeed1ddedc3,
TVP_Stub_247b25d497e48bc0191fdb2ac530f4ca,
TVP_Stub_6bbea3af36c35631641cc8356ff65475,
TVP_Stub_cac02dfd62ba94abf6a346bef0bf3ab9,
TVP_Stub_68eeb36d76d88ff00014f04b23454254,
TVP_Stub_65e03b1c849b6e9cb5c478024aa9a5b7,
TVP_Stub_7670c0c5630625ee6a73b7b9ee093650,
TVP_Stub_68a0abce6eefa08e74353ec48c4c87a8,
TVP_Stub_ccb6e098b9a0791a0f20e9f1af55e341,
TVP_Stub_0f817efe47b451fd719c05a104c2b803,
TVP_Stub_efad1a3d774747bd2b5adb221ede2678,
TVP_Stub_563285ed004ddd2945f91db7b5347d3c,
TVP_Stub_4c032260ef83d44bfe05fdc16843a8f9,
TVP_Stub_96fd614457f06499a430b0c6e0e8a941,
TVP_Stub_d6e36d304ff7253088ab4bc1aaf13a98,
TVP_Stub_eddacf49735189e23d9d49831851ffdb,
TVP_Stub_20275a5de4aef464b85d3f6db2800063,
TVP_Stub_872d1c626e6d4e3d5e86a257f0b14536,
TVP_Stub_a7ebb70cdec339f26c2ea7fd9a471b88,
TVP_Stub_d748ffef5cde2a6a3333e75b7fa3fb49,
TVP_Stub_15e1fe0e6230e7b60e216e266f927f7b,
TVP_Stub_f8179eafd0cbe8116874310519207dc0,
TVP_Stub_accbc3bed3223d552de2723366cfc2b6,
TVP_Stub_e2c3e74d2a20a601c1f393348f58aeb2,
TVP_Stub_e0163a6ca3397c2e71715132cccefa1d,
TVP_Stub_2c3ea1ea88799dfde81025bf1959333a,
TVP_Stub_a6bb56b3f4b7a89fe78d63956a0f444c,
TVP_Stub_09a81ac18a121d8fbb67285a081bf9c6,
TVP_Stub_46fdfe0f5369bf234c3ed60a43947d9d,
TVP_Stub_d866cb6c8a47444bbac60eeffbfc6d96,
TVP_Stub_7b5718fc67458089c685dbb900126890,
TVP_Stub_5713dfe9525662357d3819229e0204c2,
TVP_Stub_8954a6b4a7f8b378c2af16a00d5059b0,
TVP_Stub_2ed4faa38db6f3dee0dea18ebe973d35,
TVP_Stub_d0338dedb0af532d22f2075a85373548,
TVP_Stub_583d57c3bb9491f8f9904c266d3f52e8,
TVP_Stub_8ac206da43e322eb8e34fce2b0959656,
TVP_Stub_14f5f97d90bd8da89b68d035367f4ba4,
TVP_Stub_ac3b21181ef4c1be73cf5e0edb4e1a8f,
TVP_Stub_1d7d97509292a4ca9269f2539dcc70fd,
TVP_Stub_c4033f54a99517783b8d6ad23c90aeed,
TVP_Stub_f19e38d48755c971fc35408ac65562fa,
TVP_Stub_e01204e226d8aa9520b3620b68da6196,
TVP_Stub_b50000da98f1257cf789fc63fb1fda02,
TVP_Stub_c55f38b1a7623646aa5cc45d4f4f479b,
TVP_Stub_983d270549ec0e83e2a863b43e1e6f70,
TVP_Stub_b48d779dc6a881c67c5f8fa12655aa28,
TVP_Stub_d3967c6e24d0c4ad107a03c1cadd57b1,
TVP_Stub_6b6f416b5725a7cafb4774ffc3a00f10,
TVP_Stub_bc7fc5dfa228152a09d2230823c2fe71,
TVP_Stub_a1cb941317b947beb88e29fa8d46a2be,
TVP_Stub_8e185e82bb27a7fb40f0b08f560a57e9,
TVP_Stub_4b7b264b61ee0eea68213934217f5865,
TVP_Stub_e872f12593d6853ebdffebbb5d003c10,
TVP_Stub_e86fcf60fa658129d937de3728d3c432,
TVP_Stub_350741a7398a187628866f5b397c7a99,
TVP_Stub_3b5a3e187077b0b5eac9a040c99dd9e7,
TVP_Stub_2d9b2bb2cd57220048fe170f1e960cb7,
TVP_Stub_260624e275a20115e8861eb7b0383971,
TVP_Stub_15b31724287dbbecb775b2e46dc35fb9,
TVP_Stub_ff652293eef07b5a7ec4f372e5504e2c,
TVP_Stub_99b773033e9a2c631b483d4d0e3881f8,
TVP_Stub_3787960fc29b8545629d894ff46d4641,
TVP_Stub_3fc76257bb1639de4bfa0c0fcedf9c4a,
TVP_Stub_292ee2eeb8131e34368ba9ee144b737a,
TVP_Stub_ec144655bc61bfa2c6e9505cc1a0a298,
TVP_Stub_230218bdabfc34178a8306a54276a3c8,
TVP_Stub_617dfb046aaf40078ee76715fa4756af,
TVP_Stub_8116bb2b26dcafd9fefca76e9f1d9b24,
TVP_Stub_12962f857563cd39b3cb1f9894775cc7,
TVP_Stub_50c0d25cd9af311a5fb0aca78f691c3b,
TVP_Stub_6c37a1ccda816c4fbab4f0117ca75e8a,
TVP_Stub_e21c21762dd0e36d6f7d2cedaac97383,
TVP_Stub_487ee86557f94113db9a981e08d29caa,
TVP_Stub_dfdfe0e494845bf484612cc97145f85c,
TVP_Stub_e74dc11dbd56fb450eed1388a65d3102,
TVP_Stub_6981c02247de5799ea7dfbd79fdc208d,
TVP_Stub_7c559043315f6ecd7a86ec7d8d820f6d,
TVP_Stub_3a8b6aca73c83d6fc9ce813661ec734d,
TVP_Stub_20d7ce65e240b745b10616bb5da1f897,
TVP_Stub_f4d1217249674ac9274d358c381afc0b,
TVP_Stub_ca77323bbe361f88f68536018fa94c50,
TVP_Stub_17983ecc7e7fe370bce664281a84c948,
TVP_Stub_61a2f61030362903d00ba21a3cebecdd,
TVP_Stub_e9f985403dbd18540d8230a2af6ed76b,
TVP_Stub_be0523c9a72ba26cb4bfa3cb188cacf6,
TVP_Stub_8ac7cf651223c8ba53df90cf4f3d3bbc,
TVP_Stub_873e73aa35096ad4c684d394a10135a6,
TVP_Stub_3342548f105147c86019ae31ece01d4e,
TVP_Stub_607ee0956cbb16b2afb7cb2227aa6267,
TVP_Stub_816d84c86e86d5e7c0018d551e741e4f,
TVP_Stub_985fcda0141eb3b4c6bd8342e947f130,
TVP_Stub_d00e4f9e493334d2f65ea379ff03d717,
TVP_Stub_0c246e6c7c8798e4c10d2bbfc66326c9,
TVP_Stub_501015843a83368b3ff1c7c9ef5f3bcb,
TVP_Stub_61d5fc5a060f346752a3a8b6886d17bc,
TVP_Stub_0debe3e1caf0f57572a59917851676d3,
TVP_Stub_ee3a36682f48639166ba04a19fe1b332,
TVP_Stub_4d99b9e38121251b40a90cd2bd5fea63,
TVP_Stub_f1509827696ebf5627bee1a45d675fb8,
TVP_Stub_bbb625e23229350453161810c41419dd,
TVP_Stub_489a6aae30de0feff5d3c5fbd42ae325,
TVP_Stub_6b9a349305f8c689dcfdbcea2566769c,
TVP_Stub_6320d208ce1a570aca52c3cdf7421f7c,
TVP_Stub_0f83f0459badd1cd352041b9243d712f,
TVP_Stub_186a94b2fed609ed2d2a7ac1a2bed87f,
TVP_Stub_bde8efb9971664f2b52fe912745e2791,
TVP_Stub_386d6fa5cb73e3519b62d20470e5414b,
TVP_Stub_c61f97ec3d99bdbb23afe93870001bbf,
TVP_Stub_f92821f2b23662c6f1256511a626cd3f,
TVP_Stub_76b0732e3e2886897d5f26b4b0545dee,
TVP_Stub_903ed11ef3863850e837bd4b3b1d61a1,
TVP_Stub_2661124b39595ffafe2fb0bfb7bd2efc,
TVP_Stub_d0b7170e54398c2f9d27dcc513c4cf46,
TVP_Stub_31bdd2a1eed3785c1422fab5ea6b3ce7,
TVP_Stub_dbc300d1dadc1a60cb0dcadfb92f1aee,
TVP_Stub_1d4d9f8bdf55bd4c78abd90656af0364,
TVP_Stub_5c7049e712e84b40ac05942421202de5,
TVP_Stub_5dca8992bb340d70ba65ddab65c28371,
TVP_Stub_85f1f38f783ebfcf638f3c443bc9b204,
TVP_Stub_7d61d143884bfa4b6c50dae11c2b659f,
TVP_Stub_793a2ad7ad3411be3670576a8e6ddcf8,
TVP_Stub_68d8eec33254f1684e53bbc0aa8b2466,
TVP_Stub_b09652d2197b29f7d38aff0298c69f17,
TVP_Stub_be7db03ddcf1886cb7233e58f19c8c77,
TVP_Stub_b4c8fedc1ffbe30d9703cb2b8d3c0e7b,
TVP_Stub_77efef3b4ffc0cb577b76304e06e39f3,
TVP_Stub_0e55187bde599d6585eaabd2c4ac3f02,
TVP_Stub_f72e3fc3b97a9141b6f516f5e53bf9b8,
TVP_Stub_e7a1ac237f00bb6320d0e0ac7e6d51c6,
TVP_Stub_d87682f6d691350878077bd101b7f0fc,
TVP_Stub_d7ae155eaabd8e65d6b4d356fe4af496,
TVP_Stub_be3a1844ea6af533bd4e7b0a76c826a1,
TVP_Stub_aa531d2c3c87f456e48a14722faa1c1f,
TVP_Stub_6889cd886e1c2e7faf541528636c16c3,
TVP_Stub_5d9266e6a8a154fe4ba80b0995e109ab,
TVP_Stub_a7dc19b023737979ad1ae1ae01d560d2,
TVP_Stub_d20444b7a6243d668a0d3956d95af510,
TVP_Stub_1458dec9eee36816c8002d4049840355,
TVP_Stub_21137ff5351245b1611852301b7f5796,
TVP_Stub_c07fc4e45fc2dc44d839c5e012d0be60,
TVP_Stub_6815b962a3122ae967284239932cc656,
TVP_Stub_e96cccbe1f16b0fb74673f2ec3343ff8,
TVP_Stub_e8cd7494f919b18a992cb8c2722b2bf0,
TVP_Stub_990fdefcafc0de5e8e1f502c1b341e44,
TVP_Stub_de5d83ba307e822825062377fb76c2ba,
TVP_Stub_5e28bcc0f5ad6a038eb5a6535b56386c,
TVP_Stub_e33419e8ede4bb501ab1787cf17c7ca5,
TVP_Stub_1cd7cb9580c0cf723dea402b85a720b1,
TVP_Stub_d18ca17fad389ff60ce3caa769083798,
TVP_Stub_0a959a5ff02530a8eb122e7e1f8ceed3,
TVP_Stub_a4774ea559e64b4667b3845f8540d207,
TVP_Stub_52eae3e8106494bfa604c15492ecb9f4,
TVP_Stub_882f458df5e05bb9ab2222e79f6c81cf,
TVP_Stub_6069a18bf7d3f394c230cdcf2f574ef4,
TVP_Stub_75b60565caf44027cc52b2b5cf6b0ea3,
TVP_Stub_9d735149c3ad586363895f76645abf2e,
TVP_Stub_ea5168fae254acdd8c8db6f1f3d2da03,
TVP_Stub_f5a42bd5239e1a0be29f92eb838d2c8c,
TVP_Stub_7cc8cd9f415b183b42c546635aeade7f,
TVP_Stub_ad2fefa53e05528f9c1fe29d27db0f37,
TVP_Stub_f3e06fed4c82a9bd1b53252abaf50847,
TVP_Stub_960db7ea36202bf7ec3bf6b767cc045e,
TVP_Stub_7bf5d357eb52dd206a269b54c8136e0e,
TVP_Stub_ba1c9b771c5cdb725128de684af3c9ca,
TVP_Stub_69cc6311196adc134fd153c4c5346bc5,
TVP_Stub_8ed68f8e79efe1c767f92e7d92eb8b54,
TVP_Stub_60da1e9ec15b251ff18ddcdf8a3e93e0,
TVP_Stub_ef47304bad87a036e38f0319b48c1f6e,
TVP_Stub_182d19020e4e2d5cd1462d7c8ef24d1f,
TVP_Stub_9e1fa429a92a5c99d397a06c20fd6705,
TVP_Stub_74ac7c291299eb928aa4c2899df5567e,
TVP_Stub_fb645d9ec0ef3fd2aba2b762ef6b9a15,
TVP_Stub_f988626275257574050ac789f9060a3b,
TVP_Stub_1831064ed23493cef407648763ba4d69,
TVP_Stub_305390c94750daa7124db3ff6e77931c,
TVP_Stub_4fb384a391bfcf6a3a2932661d3051aa,
TVP_Stub_305537c4820e23cf217a15efb56dba1c,
TVP_Stub_aacf83677ca7df75117f7bafa7a53791,
TVP_Stub_d14b922fefc6c07aa536b94762579fe5,
TVP_Stub_00fd650a79c603bdeb2f8e36f667a782,
TVP_Stub_a36ee133c07c30185b0bbc6375954e88,
TVP_Stub_dc657ecacf8e578870314427216864d9,
TVP_Stub_e79d02b58a8bfdee439bc0694d7edd6d,
TVP_Stub_6b7537b66b71d27384bea45bc2bf24b4,
TVP_Stub_b3456dbad652b52f5bce1889b6f4d0ef,
TVP_Stub_9a50803a03e1ccb60120dff8b92ecdcd,
TVP_Stub_0f6b3940dc72e3e56cd15216b53b9126,
TVP_Stub_23b647f1c825e214a7465de3ebe9968d,
TVP_Stub_8ec96bc7b777180f23e1a2e43bf9a413,
TVP_Stub_cffd45014652659638d59abe11daf3be,
TVP_Stub_a784285a35b1bc76bb367305b5099e35,
TVP_Stub_03773751329896facf2003ab79bbc475,
TVP_Stub_923884216edf134d07d8e70f8f57e827,
TVP_Stub_e48798dc69498f80b6633bb405eda6eb,
TVP_Stub_998a5e1aa5cd85689795348fc540a655,
TVP_Stub_5f6d263c0d48d03f6eb0dc44c9dd0be2,
TVP_Stub_bf363ba3d5b54df9d6df35a518deb6b0,
TVP_Stub_6cc8a24cc7ce23179d1d4ccab7a8c97b,
};
void TVPExportFunctions()
{
const unsigned long compressed_size = 5173;
const unsigned long decompressed_size = 42625;
const tjs_int function_count = 653;
unsigned char * dest = new unsigned char [decompressed_size];
try
{
unsigned long dest_size = decompressed_size;
int result = uncompress(dest, &dest_size,
(unsigned char*)compressed_functable, compressed_size);
if(result != Z_OK || dest_size != decompressed_size) { TVPThrowInternalError; }
const unsigned char *p = dest;
for(tjs_int i = 0; i < function_count; i++)
{
TVPAddExportFunction((const char *)p, ((void **)func_ptrs)[i]);
while(*p) p++;
p++;
}
}
catch(...)
{
delete [] dest;
throw;
}
delete [] dest;
}
================================================
FILE: src/core/base/win32/FuncStubs.h
================================================
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000-2009 W.Dee and contributors
See details of license at "license.txt"
*/
/* This file is always generated by makestub.pl . */
/* Modification by hand will be lost. */
extern void TVPExportFunctions();
================================================
FILE: src/core/base/win32/NativeEventQueue.cpp
================================================
#include "tjsCommHead.h"
#include "NativeEventQueue.h"
#include "Application.h"
void NativeEventQueueImplement::PostEvent(const NativeEvent& ev) {
Application->PostUserMessage([this, ev](){ Dispatch(*const_cast(&ev)); }, this);
}
void NativeEventQueueImplement::Clear(int msg)
{
Application->FilterUserMessage([this, msg](std::vector > &lst){
for (auto it = lst.begin(); it != lst.end();) {
if (std::get<0>(*it) == this && (!msg || std::get<1>(*it) == msg)) {
it = lst.erase(it);
} else {
++it;
}
}
});
}
================================================
FILE: src/core/base/win32/NativeEventQueue.h
================================================
#ifndef __NATIVE_EVENT_QUEUE_H__
#define __NATIVE_EVENT_QUEUE_H__
// ĂяonhVOXbhœ삷CxgL[
class NativeEvent {
public:
// LRESULT Result;
// HWND HWnd;
unsigned int Message;
intptr_t WParam;
intptr_t LParam;
// NativeEvent(){}
NativeEvent( int mes ) : /*Result(0), HWnd(NULL),*/ Message(mes), WParam(0), LParam(0) {}
};
#if 0
class NativeEventQueueIntarface {
public:
// ftHgnh
virtual void HandlerDefault( class NativeEvent& event ) = 0;
// Queue ̐
virtual void Allocate() = 0;
// Queue ̍폜
virtual void Deallocate() = 0;
virtual void Dispatch( class NativeEvent& event ) = 0;
virtual void PostEvent( const NativeEvent& event ) = 0;
};
#endif
class NativeEventQueueImplement/* : public NativeEventQueueIntarface*/ {
// HWND window_handle_;
// WNDCLASSEX wc_;
int CreateUtilWindow();
// static LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
public:
// NativeEventQueueImplement() : window_handle_(NULL) {}
// ftHgnh
void HandlerDefault(NativeEvent& event) {}
// Queue ̐
void Allocate() {}
// Queue ̍폜
void Deallocate() {}
void PostEvent( const NativeEvent& event );
void Clear(int msg = 0);
// void* GetOwner() { return window_handle_; }
virtual void Dispatch(class NativeEvent& event) = 0;
};
template
class NativeEventQueue : public NativeEventQueueImplement {
void (T::*handler_)(NativeEvent&);
T* owner_;
public:
NativeEventQueue( T* owner, void (T::*Handler)(NativeEvent&) ) : owner_(owner), handler_(Handler) {}
void Dispatch( NativeEvent &ev ) {
(owner_->*handler_)(ev);
}
T* GetOwner() { return owner_; }
};
#endif // __NATIVE_EVENT_QUEUE_H__
================================================
FILE: src/core/base/win32/PluginImpl.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// "Plugins" class implementation / Service for plug-ins
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include
#include "ScriptMgnIntf.h"
#include "PluginImpl.h"
#include "StorageImpl.h"
#include "GraphicsLoaderImpl.h"
#include "MsgImpl.h"
#include "SysInitIntf.h"
#include "tjsHashSearch.h"
#include "EventIntf.h"
#include "TransIntf.h"
#include "tjsArray.h"
#include "tjsDictionary.h"
#include "DebugIntf.h"
#include "FuncStubs.h"
#include "tjs.h"
#ifdef TVP_SUPPORT_OLD_WAVEUNPACKER
#include "oldwaveunpacker.h"
#endif
#pragma pack(push, 8)
/// tvpsnd.h needs packing size of 8
//#include "tvpsnd.h"
#pragma pack(pop)
#ifdef TVP_SUPPORT_KPI
#include "kmp_pi.h"
#endif
#include "FilePathUtil.h"
#include "Application.h"
#include "SysInitImpl.h"
#include
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
#if 0
//---------------------------------------------------------------------------
// export table
//---------------------------------------------------------------------------
static tTJSHashTable TVPExportFuncs;
static bool TVPExportFuncsInit = false;
void TVPAddExportFunction(const char *name, void *ptr)
{
TVPExportFuncs.Add(name, ptr);
}
void TVPAddExportFunction(const tjs_char *name, void *ptr)
{
TVPExportFuncs.Add(name, ptr);
}
static void TVPInitExportFuncs()
{
if(TVPExportFuncsInit) return;
TVPExportFuncsInit = true;
// Export functions
TVPExportFunctions();
}
//---------------------------------------------------------------------------
struct tTVPFunctionExporter : iTVPFunctionExporter
{
bool TJS_INTF_METHOD QueryFunctions(const tjs_char **name, void **function,
tjs_uint count);
bool TJS_INTF_METHOD QueryFunctionsByNarrowString(const char **name,
void **function, tjs_uint count);
} static TVPFunctionExporter;
//---------------------------------------------------------------------------
bool TJS_INTF_METHOD tTVPFunctionExporter::QueryFunctions(const tjs_char **name, void **function,
tjs_uint count)
{
// retrieve function table by given name table.
// return false if any function is missing.
bool ret = true;
ttstr tname;
for(tjs_uint i = 0; i SupportedExts;
tTVPPlugin(const ttstr & name, ITSSStorageProvider *storageprovider);
~tTVPPlugin();
bool Uninit();
};
//---------------------------------------------------------------------------
tTVPPlugin::tTVPPlugin(const ttstr & name, ITSSStorageProvider *storageprovider)
{
Name = name;
Instance = NULL;
Holder = NULL;
IsSusiePicturePlugin = false;
IsSusieArchivePlugin = false;
TSSModule = NULL;
#ifdef TVP_SUPPORT_KPI
KMPModule = NULL;
#endif
V2Link = NULL;
V2Unlink = NULL;
GetModuleInstance = NULL;
GetModuleThreadModel = NULL;
ShowConfigWindow = NULL;
CanUnloadNow = NULL;
#ifdef TVP_SUPPORT_OLD_WAVEUNPACKER
CreateWaveUnpacker = NULL;
#endif
#ifdef TVP_SUPPORT_KPI
GetKMPModule = NULL;
#endif
// load DLL
Holder = new tTVPPluginHolder(name);
Instance = LoadLibrary(Holder->GetLocalName().AsStdString().c_str());
if(!Instance)
{
delete Holder;
TVPThrowExceptionMessage(TVPCannotLoadPlugin, name);
}
try
{
// retrieve each functions
V2Link = (tTVPV2LinkProc)
GetProcAddress(Instance, "V2Link");
V2Unlink = (tTVPV2UnlinkProc)
GetProcAddress(Instance, "V2Unlink");
GetModuleInstance = (tTVPGetModuleInstanceProc)
GetProcAddress(Instance, "GetModuleInstance");
GetModuleThreadModel = (tTVPGetModuleThreadModelProc)
GetProcAddress(Instance, "GetModuleThreadModel");
ShowConfigWindow = (tTVPShowConfigWindowProc)
GetProcAddress(Instance, "ShowConfigWindow");
CanUnloadNow = (tTVPCanUnloadNowProc)
GetProcAddress(Instance, "CanUnloadNow");
#ifdef TVP_SUPPORT_OLD_WAVEUNPACKER
CreateWaveUnpacker = (tTVPCreateWaveUnpackerProc)
GetProcAddress(Instance, "CreateWaveUnpacker");
#endif
#ifdef TVP_SUPPORT_KPI
GetKMPModule = (pfnGetKMPModule)
GetProcAddress(Instance, SZ_KMP_GETMODULE);
#endif
// link
if(V2Link)
{
V2Link(TVPGetFunctionExporter());
}
// retrieve ModuleInstance
// Susie Plug-in check
if(GetProcAddress(Instance, "GetPicture"))
{
IsSusiePicturePlugin = true;
TVPLoadPictureSPI(Instance);
return;
}
if(GetProcAddress(Instance, "GetFile"))
{
IsSusieArchivePlugin = true;
TVPLoadArchiveSPI(Instance);
return;
}
if(GetModuleInstance)
{
HRESULT hr = GetModuleInstance(&TSSModule, storageprovider,
NULL, Application->GetHandle());
if(FAILED(hr) || TSSModule == NULL)
TVPThrowExceptionMessage(TVPCannotLoadPlugin, name);
// get supported extensions
unsigned long index = 0;
while(true)
{
wchar_t mediashortname[33];
wchar_t buf[256];
HRESULT hr = TSSModule->GetSupportExts(index,
mediashortname, buf, 255);
if(hr == S_OK)
SupportedExts.push_back(ttstr(buf).AsLowerCase());
else
break;
index ++;
}
}
#ifdef TVP_SUPPORT_KPI
// retrieve KbMediaPlayer Plug-in module instance
if(GetKMPModule)
{
KMPModule = GetKMPModule();
if(KMPModule->dwVersion != 100)
TVPThrowExceptionMessage(TVPCannotLoadPlugin, name +
TJS_W(" (invalid version)"));
if(!KMPModule->dwReentrant)
TVPThrowExceptionMessage(TVPCannotLoadPlugin, name +
TJS_W(" (is not re-entrant)"));
if(KMPModule->Init) KMPModule->Init();
}
#endif
}
catch(...)
{
FreeLibrary(Instance);
delete Holder;
throw;
}
}
//---------------------------------------------------------------------------
tTVPPlugin::~tTVPPlugin()
{
}
//---------------------------------------------------------------------------
bool tTVPPlugin::Uninit()
{
tTJS *tjs = TVPGetScriptEngine();
if(tjs) tjs->DoGarbageCollection(); // to release unused objects
if(V2Unlink)
{
if(FAILED(V2Unlink())) return false;
}
#ifdef TVP_SUPPORT_KPI
if(KMPModule) if(KMPModule->Deinit) KMPModule->Deinit();
#endif
if(TSSModule) TSSModule->Release();
if(IsSusiePicturePlugin) TVPUnloadPictureSPI(Instance);
if(IsSusieArchivePlugin) TVPUnloadArchiveSPI(Instance);
FreeLibrary(Instance);
delete Holder;
return true;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
bool TVPPluginUnloadedAtSystemExit = false;
typedef std::vector tTVPPluginVectorType;
struct tTVPPluginVectorStruc
{
tTVPPluginVectorType Vector;
tTVPStorageProvider StorageProvider;
} static TVPPluginVector;
static void TVPDestroyPluginVector(void)
{
// state all plugins are to be released
TVPPluginUnloadedAtSystemExit = true;
// delete all objects
tTVPPluginVectorType::iterator i;
while(TVPPluginVector.Vector.size())
{
i = TVPPluginVector.Vector.end() - 1;
try
{
(*i)->Uninit();
delete *i;
}
catch(...)
{
}
TVPPluginVector.Vector.pop_back();
}
}
tTVPAtExit TVPDestroyPluginVectorAtExit
(TVP_ATEXIT_PRI_RELEASE, TVPDestroyPluginVector);
#endif
//---------------------------------------------------------------------------
bool TVPLoadInternalPlugin(const ttstr &_name);
extern std::set TVPRegisteredPlugins;
static bool TVPPluginLoading = false;
void TVPLoadPlugin(const ttstr & name)
{
bool success = TVPLoadInternalPlugin(name);
return; // seal all plugins
#if 0
// load plugin
if(TVPPluginLoading)
TVPThrowExceptionMessage(TVPCannnotLinkPluginWhilePluginLinking);
// linking plugin while other plugin is linking, is prohibited
// by data security reason.
// check whether the same plugin was already loaded
tTVPPluginVectorType::iterator i;
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->Name == name) return;
}
tTVPPlugin * p;
try
{
TVPPluginLoading = true;
p = new tTVPPlugin(name, &TVPPluginVector.StorageProvider);
TVPPluginLoading = false;
}
catch(...)
{
TVPPluginLoading = false;
throw;
}
TVPPluginVector.Vector.push_back(p);
#endif
}
//---------------------------------------------------------------------------
bool TVPUnloadPlugin(const ttstr & name)
{
// unload plugin
#if 0
tTVPPluginVectorType::iterator i;
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->Name == name)
{
if(!(*i)->Uninit()) return false;
delete *i;
TVPPluginVector.Vector.erase(i);
return true;
}
}
TVPThrowExceptionMessage(TVPNotLoadedPlugin, name);
return false;
#endif
return true;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// plug-in autoload support
//---------------------------------------------------------------------------
struct tTVPFoundPlugin
{
std::string Path;
std::string Name;
bool operator < (const tTVPFoundPlugin &rhs) const { return Name < rhs.Name; }
};
static tjs_int TVPAutoLoadPluginCount = 0;
static void TVPSearchPluginsAt(std::vector &list, std::string folder)
{
TVPListDir(folder, [&](const std::string &filename, int mask){
if (mask & S_IFREG) {
if (!strcasecmp(filename.c_str() + filename.length() - 4, ".tpm")) {
tTVPFoundPlugin fp;
fp.Path = folder;
fp.Name = filename;
list.emplace_back(fp);
}
}
});
#if 0
WIN32_FIND_DATA ffd;
HANDLE handle = ::FindFirstFile((folder + L"*.tpm").c_str(), &ffd);
if(handle != INVALID_HANDLE_VALUE)
{
BOOL cont;
do
{
if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
tTVPFoundPlugin fp;
fp.Path = folder;
fp.Name = ffd.cFileName;
list.push_back(fp);
}
cont = FindNextFile(handle, &ffd);
} while(cont);
FindClose(handle);
}
#endif
}
void TVPLoadInternalPlugins();
void TVPLoadPluigins(void)
{
TVPLoadInternalPlugins();
// This function searches plugins which have an extension of ".tpm"
// in the default path:
// 1. a folder which holds kirikiri executable
// 2. "plugin" folder of it
// Plugin load order is to be decided using its name;
// aaa.tpm is to be loaded before aab.tpm (sorted by ASCII order)
// search plugins from path: (exepath), (exepath)\system, (exepath)\plugin
std::vector list;
std::string exepath = ExtractFileDir(TVPNativeProjectDir.AsNarrowStdString());
TVPSearchPluginsAt(list, exepath);
TVPSearchPluginsAt(list, exepath + "/system");
TVPSearchPluginsAt(list, exepath + "/plugin");
// sort by filename
std::sort(list.begin(), list.end());
// load each plugin
TVPAutoLoadPluginCount = (tjs_int)list.size();
for(std::vector::iterator i = list.begin();
i != list.end();
i++)
{
TVPAddImportantLog(ttstr(TJS_W("(info) Loading ")) + ttstr(i->Name.c_str()));
TVPLoadPlugin((i->Path + "/" + i->Name).c_str());
}
}
//---------------------------------------------------------------------------
tjs_int TVPGetAutoLoadPluginCount() { return TVPAutoLoadPluginCount; }
//---------------------------------------------------------------------------
#if 0
//---------------------------------------------------------------------------
// interface to Wave decode plugins
//---------------------------------------------------------------------------
ITSSWaveDecoder * TVPSearchAvailTSSWaveDecoder(const ttstr & storage, const ttstr & extension)
{
tTVPPluginVectorType::iterator i;
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->TSSModule)
{
// check whether the plugin supports extension
bool supported = false;
std::vector::iterator ei;
for(ei = (*i)->SupportedExts.begin(); ei != (*i)->SupportedExts.end(); ei++)
{
if(ei->GetLen() == 0) { supported = true; break; }
if(extension == *ei) { supported = true; break; }
}
if(!supported) continue;
// retrieve instance from (*i)->TSSModule
IUnknown *intf = NULL;
HRESULT hr = (*i)->TSSModule->GetMediaInstance(
(wchar_t*)storage.c_str(), &intf);
if(SUCCEEDED(hr))
{
try
{
// check whether the instance has IID_ITSSWaveDecoder
// interface.
ITSSWaveDecoder * decoder;
if(SUCCEEDED(intf->QueryInterface(IID_ITSSWaveDecoder,
(void**) &decoder)))
{
intf->Release();
return decoder; // OK
}
}
catch(...)
{
intf->Release();
throw;
}
intf->Release();
}
}
}
return NULL; // not found
}
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
#ifdef TVP_SUPPORT_OLD_WAVEUNPACKER
IWaveUnpacker * TVPSearchAvailWaveUnpacker(const ttstr & storage, IStream **stream)
{
tTVPPluginVectorType::iterator i;
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->CreateWaveUnpacker) break;
}
if(i == TVPPluginVector.Vector.end()) return NULL; // KPI not found
// retrieve IStream interface
AnsiString ansiname = storage.AsAnsiString();
tTJSBinaryStream *stream0 = NULL;
long size;
try
{
stream0 = TVPCreateStream(storage);
size = (long)stream0->GetSize();
}
catch(...)
{
if(stream0) delete stream0;
return NULL;
}
IStream *istream = new tTVPIStreamAdapter(stream0);
try
{
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->CreateWaveUnpacker)
{
// call CreateWaveUnpacker to retrieve decoder instance
IWaveUnpacker *out;
HRESULT hr = (*i)->CreateWaveUnpacker(istream, size,
ansiname.c_str(), &out);
if(SUCCEEDED(hr))
{
*stream = istream;
return out;
}
}
}
}
catch(...)
{
istream->Release();
return NULL;
}
istream->Release();
return NULL; // not found
}
#endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifdef TVP_SUPPORT_KPI
void * TVPSearchAvailKMPWaveDecoder(const ttstr & storage, KMPMODULE ** module,
SOUNDINFO * info)
{
tTVPPluginVectorType::iterator i;
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->KMPModule) break;
}
if(i == TVPPluginVector.Vector.end()) return NULL; // KPI not found
AnsiString localname;
if(TJS_strchr(storage.c_str(), TVPArchiveDelimiter)) return NULL;
// in-archive storage is not supported
try
{
ttstr ln(TVPSearchPlacedPath(storage));
TVPGetLocalName(ln);
localname = ln.AsAnsiString();
}
catch(...)
{
return NULL;
}
AnsiString ext = TVPExtractStorageExt(storage).AsAnsiString();
for(i = TVPPluginVector.Vector.begin();
i != TVPPluginVector.Vector.end(); i++)
{
if((*i)->KMPModule)
{
// search over available extensions
const char **module_ext = (*i)->KMPModule->ppszSupportExts;
while(*module_ext)
{
if(!strcmpi(ext.c_str(), *module_ext)) break;
module_ext ++;
}
if(!*module_ext) continue; // not found in this plug-in
*module = (*i)->KMPModule;
HKMP hkmp = (*i)->KMPModule->Open(localname.c_str(), info);
if(hkmp)
(*i)->KMPModule->SetPosition(hkmp, 0);
// rewind; some plug-ins crash when the initial rewind is
// not processed...
return hkmp;
}
}
return NULL; // not found
}
#endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// some service functions for plugin
//---------------------------------------------------------------------------
#include
int ZLIB_uncompress(unsigned char *dest, unsigned long *destlen,
const unsigned char *source, unsigned long sourcelen)
{
return uncompress(dest, destlen, source, sourcelen);
}
//---------------------------------------------------------------------------
int ZLIB_compress(unsigned char *dest, unsigned long *destlen,
const unsigned char *source, unsigned long sourcelen)
{
return compress(dest, destlen, source, sourcelen);
}
//---------------------------------------------------------------------------
int ZLIB_compress2(unsigned char *dest, unsigned long *destlen,
const unsigned char *source, unsigned long sourcelen, int level)
{
return compress2(dest, destlen, source, sourcelen, level);
}
//---------------------------------------------------------------------------
#include "md5.h"
static char TVP_assert_md5_state_t_size[
(sizeof(TVP_md5_state_t) >= sizeof(md5_state_t))];
// if this errors, sizeof(TVP_md5_state_t) is not equal to sizeof(md5_state_t).
// sizeof(TVP_md5_state_t) must be equal to sizeof(md5_state_t).
//---------------------------------------------------------------------------
void TVP_md5_init(TVP_md5_state_t *pms)
{
md5_init((md5_state_t*)pms);
}
//---------------------------------------------------------------------------
void TVP_md5_append(TVP_md5_state_t *pms, const tjs_uint8 *data, int nbytes)
{
md5_append((md5_state_t*)pms, (const md5_byte_t*)data, nbytes);
}
//---------------------------------------------------------------------------
void TVP_md5_finish(TVP_md5_state_t *pms, tjs_uint8 *digest)
{
md5_finish((md5_state_t*)pms, digest);
}
#if 0
//---------------------------------------------------------------------------
HWND TVPGetApplicationWindowHandle()
{
return Application->GetHandle();
}
//---------------------------------------------------------------------------
void TVPProcessApplicationMessages()
{
Application->ProcessMessages();
}
//---------------------------------------------------------------------------
void TVPHandleApplicationMessage()
{
Application->HandleMessage();
}
#endif
//---------------------------------------------------------------------------
bool TVPRegisterGlobalObject(const tjs_char *name, iTJSDispatch2 * dsp)
{
// register given object to global object
tTJSVariant val(dsp);
iTJSDispatch2 *global = TVPGetScriptDispatch();
tjs_error er;
try
{
er = global->PropSet(TJS_MEMBERENSURE, name, NULL, &val, global);
}
catch(...)
{
global->Release();
return false;
}
global->Release();
return TJS_SUCCEEDED(er);
}
//---------------------------------------------------------------------------
bool TVPRemoveGlobalObject(const tjs_char *name)
{
// remove registration of global object
iTJSDispatch2 *global = TVPGetScriptDispatch();
if(!global) return false;
tjs_error er;
try
{
er = global->DeleteMember(0, name, NULL, global);
}
catch(...)
{
global->Release();
return false;
}
global->Release();
return TJS_SUCCEEDED(er);
}
//---------------------------------------------------------------------------
void TVPDoTryBlock(
tTVPTryBlockFunction tryblock,
tTVPCatchBlockFunction catchblock,
tTVPFinallyBlockFunction finallyblock,
void *data)
{
try
{
tryblock(data);
}
catch(const eTJS & e)
{
if(finallyblock) finallyblock(data);
tTVPExceptionDesc desc;
desc.type = TJS_W("eTJS");
desc.message = e.GetMessage();
if(catchblock(data, desc)) throw;
return;
}
catch(...)
{
if(finallyblock) finallyblock(data);
tTVPExceptionDesc desc;
desc.type = TJS_W("unknown");
if(catchblock(data, desc)) throw;
return;
}
if(finallyblock) finallyblock(data);
}
//---------------------------------------------------------------------------
#if 0
//---------------------------------------------------------------------------
// TVPGetFileVersionOf
//---------------------------------------------------------------------------
bool TVPGetFileVersionOf(const wchar_t* module_filename, tjs_int &major, tjs_int &minor, tjs_int &release, tjs_int &build)
{
// retrieve file version
major = minor = release = build = 0;
VS_FIXEDFILEINFO *FixedFileInfo;
BYTE *VersionInfo;
bool got = false;
UINT dum;
DWORD dum2;
wchar_t* filename = new wchar_t[TJS_strlen(module_filename) + 1];
try
{
TJS_strcpy(filename, module_filename);
DWORD size = ::GetFileVersionInfoSize (filename, &dum2);
if(size)
{
VersionInfo = new BYTE[size + 2];
try
{
if(::GetFileVersionInfo(filename, 0, size, (void*)VersionInfo))
{
if(::VerQueryValue((void*)VersionInfo, L"\\", (void**)(&FixedFileInfo),
&dum))
{
major = FixedFileInfo->dwFileVersionMS >> 16;
minor = FixedFileInfo->dwFileVersionMS & 0xffff;
release = FixedFileInfo->dwFileVersionLS >> 16;
build = FixedFileInfo->dwFileVersionLS & 0xffff;
got = true;
}
}
}
catch(...)
{
delete [] VersionInfo;
throw;
}
delete [] VersionInfo;
}
}
catch(...)
{
delete [] filename;
throw;
}
delete [] filename;
return got;
}
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
// TVPCreateNativeClass_Plugins
//---------------------------------------------------------------------------
tTJSNativeClass * TVPCreateNativeClass_Plugins()
{
tTJSNC_Plugins *cls = new tTJSNC_Plugins();
// setup some platform-specific members
//---------------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/link)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr name = *param[0];
TVPLoadPlugin(name);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL_OUTER(/*object to register*/cls,
/*func. name*/link)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/unlink)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
ttstr name = *param[0];
bool res = TVPUnloadPlugin(name);
if(result) *result = (tjs_int)res;
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL_OUTER(/*object to register*/cls,
/*func. name*/unlink)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(getList)
{
iTJSDispatch2 * array = TJSCreateArrayObject();
try
{
tjs_int idx = 0;
for (ttstr name : TVPRegisteredPlugins) {
tTJSVariant val(name);
array->PropSetByNum(TJS_MEMBERENSURE, idx++, &val, array);
}
#if 0
tTVPPluginVectorType::iterator i;
tjs_int idx = 0;
for(i = TVPPluginVector.Vector.begin(); i != TVPPluginVector.Vector.end(); i++)
{
tTJSVariant val = (*i)->Name.c_str();
array->PropSetByNum(TJS_MEMBERENSURE, idx++, &val, array);
}
#endif
if (result) *result = tTJSVariant(array, array);
}
catch(...)
{
array->Release();
throw;
}
array->Release();
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL_OUTER(cls, getList)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
return cls;
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/win32/PluginImpl.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// "Plugins" class implementation / Service for plug-ins
//---------------------------------------------------------------------------
#ifndef PluginImplH
#define PluginImplH
//---------------------------------------------------------------------------
#include
#include "PluginIntf.h"
#include "win32type.h"
#ifdef TVP_SUPPORT_KPI
#include "kmp_pi.h"
#endif
#if 0
//---------------------------------------------------------------------------
/*[*/
//---------------------------------------------------------------------------
// iTVPFunctionExporter, exporting main module's functions
//---------------------------------------------------------------------------
struct iTVPFunctionExporter
{
virtual bool TJS_INTF_METHOD QueryFunctions(const tjs_char **name, void **function,
tjs_uint count) = 0;
virtual bool TJS_INTF_METHOD QueryFunctionsByNarrowString(const char **name,
void **function, tjs_uint count) = 0;
};
//---------------------------------------------------------------------------
/*]*/
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
struct ITSSModule;
struct IWaveUnpacker;
struct ITSSStorageProvider;
extern "C"
{
iTVPFunctionExporter * __stdcall TVPGetFunctionExporter();
// V2 plug-in
typedef HRESULT (_stdcall * tTVPV2LinkProc)(iTVPFunctionExporter *);
typedef HRESULT (_stdcall * tTVPV2UnlinkProc)();
// TSS
typedef HRESULT (_stdcall * tTVPGetModuleInstanceProc)(ITSSModule **out,
ITSSStorageProvider *provider, IStream * config, HWND mainwin);
typedef ULONG (_stdcall * tTVPGetModuleThreadModelProc)(void);
typedef HRESULT (_stdcall * tTVPShowConfigWindowProc)(HWND parentwin,
IStream * storage );
typedef ULONG (_stdcall * tTVPCanUnloadNowProc)(void);
#ifdef TVP_SUPPORT_OLD_WAVEUNPACKER
// WaveUnpacker
typedef HRESULT (_stdcall * tTVPCreateWaveUnpackerProc)(IStream *storage,long size,
char *name,IWaveUnpacker **out); // old WaveUnpacker stuff
#endif
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
struct ITSSWaveDecoder;
extern ITSSWaveDecoder * TVPSearchAvailTSSWaveDecoder(const ttstr & storage, const ttstr & extension);
#ifdef TVP_SUPPORT_OLD_WAVEUNPACKER
class IWaveUnpacker;
extern IWaveUnpacker * TVPSearchAvailWaveUnpacker(const ttstr & storage, IStream **stream);
#endif
#ifdef TVP_SUPPORT_KPI
extern void * TVPSearchAvailKMPWaveDecoder(const ttstr & storage, KMPMODULE ** module,
SOUNDINFO * info);
#endif
extern void TVPAddExportFunction(const tjs_char *name, void *ptr);
extern void TVPAddExportFunction(const char *name, void *ptr);
TJS_EXP_FUNC_DEF(void, TVPThrowPluginUnboundFunctionError, (const char *funcname));
TJS_EXP_FUNC_DEF(void, TVPThrowPluginUnboundFunctionError, (const tjs_char *funcname));
#endif
inline TJS_EXP_FUNC_DEF(void *, TVP_malloc, (size_t size)) { return malloc(size); }
// inline TJS_EXP_FUNC_DEF(void *, TVP_realloc, (void *pp, size_t size)) { return realloc(pp, size); }
inline TJS_EXP_FUNC_DEF(void, TVP_free, (void *pp)) { return free(pp); }
TJS_EXP_FUNC_DEF(tjs_int, TVPGetAutoLoadPluginCount, ());
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(int, ZLIB_uncompress, (unsigned char *dest, unsigned long *destlen, const unsigned char *source, unsigned long sourcelen));
TJS_EXP_FUNC_DEF(int, ZLIB_compress, (unsigned char *dest, unsigned long *destlen, const unsigned char *source, unsigned long sourcelen));
TJS_EXP_FUNC_DEF(int, ZLIB_compress2, (unsigned char *dest, unsigned long *destlen, const unsigned char *source, unsigned long sourcelen, int level));
/*[*/
//---------------------------------------------------------------------------
// this stub includes exported function from Independent implementation of
// MD5 (RFC 1321) by Aladdin Enterprises.
//---------------------------------------------------------------------------
// TVP_md5_init, TVP_md5_append, TVP_md5_finish are exported
typedef struct TVP_md5_state_s { tjs_uint8 buffer[4*2+8+4*4+8+64]; } TVP_md5_state_t; // md5_state_t
//---------------------------------------------------------------------------
/*]*/
TJS_EXP_FUNC_DEF(void, TVP_md5_init, (TVP_md5_state_t *pms));
TJS_EXP_FUNC_DEF(void, TVP_md5_append, (TVP_md5_state_t *pms, const tjs_uint8 *data, int nbytes));
TJS_EXP_FUNC_DEF(void, TVP_md5_finish, (TVP_md5_state_t *pms, tjs_uint8 *digest));
//TJS_EXP_FUNC_DEF(HWND, TVPGetApplicationWindowHandle, ());
TJS_EXP_FUNC_DEF(void, TVPProcessApplicationMessages, ());
TJS_EXP_FUNC_DEF(void, TVPHandleApplicationMessage, ());
TJS_EXP_FUNC_DEF(bool, TVPRegisterGlobalObject, (const tjs_char *name, iTJSDispatch2 * dsp));
TJS_EXP_FUNC_DEF(bool, TVPRemoveGlobalObject, (const tjs_char *name));
/*[*/
//---------------------------------------------------------------------------
// data types for TVPDoTryBlock
//---------------------------------------------------------------------------
// TVPDoTryBlock executes specified 'tryblock' in try block.
// If any exception occured,
// 'catchblock' is to be executed. 'data' is applicatoin defined data
// block passed to 'tryblock' and 'catchblock' and 'finallyblock'.
// if the 'catchblock' returns true, the exception is to be rethrown.
// if false then the exception is to be vanished.
// 'finallyblock' can be null, is to be executed whatever the exception
// is generated or not.
struct tTVPExceptionDesc
{
ttstr type; // the exception type, currently 'eTJS' or 'unknown'
ttstr message; // the exception message (if exists. otherwise empty).
};
typedef void (TJS_USERENTRY *tTVPTryBlockFunction)(void * data);
typedef bool (TJS_USERENTRY *tTVPCatchBlockFunction)(void * data, const tTVPExceptionDesc & desc);
typedef void (TJS_USERENTRY *tTVPFinallyBlockFunction)(void *data);
//---------------------------------------------------------------------------
/*]*/
TJS_EXP_FUNC_DEF(void, TVPDoTryBlock, (tTVPTryBlockFunction tryblock, tTVPCatchBlockFunction catchblock, tTVPFinallyBlockFunction finallyblock, void *data));
//TJS_EXP_FUNC_DEF(bool, TVPGetFileVersionOf, (const wchar_t* module_filename, tjs_int &major, tjs_int &minor, tjs_int &release, tjs_int &build));
//---------------------------------------------------------------------------
extern bool TVPPluginUnloadedAtSystemExit;
extern void TVPLoadPluigins(void);
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/win32/ScriptMgnImpl.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// TJS2 Script Managing
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "SystemControl.h"
#include "WindowIntf.h"
#include "ScriptMgnIntf.h"
#include "MsgIntf.h"
#include "tjsScriptBlock.h"
#include "EventIntf.h"
#include "SysInitImpl.h"
#include "SysInitIntf.h"
#include "DebugIntf.h"
#include "StorageImpl.h"
#include "tjsDebug.h"
#include "Application.h"
//---------------------------------------------------------------------------
/*
Object Hash Map (implemented in tjsDebug) is a simple object memory leak
detector.
Object Hash Map rely on TVP logging facility for logging unfreed objects.
But TVP logging facility ends before some of TJS2 objects had been freed.
To solve this problem, TJS2 uses two method to track objects;
on-memory hash map and interprocess communication (IPC).
On-memory hash map is a simple method, tracking object's creation and
destruction on one hash map.
Interprocess communication throws all object creation/destruction log
to a process, which is specially created as a child-process for processing
received log. Interprocess communication is implemented using low-level
API, works very end of the parent process.
TVP switches these two methods at framework finalization.
On-memory hash map is used during most of the time.
At the end of the framework, the framework switches to interprocess
communication method. This continues rest of Object Hash Map operation until
the process ends.
Process of receiving object hash map log is implemented as the same executable
of Kirikiri (There is a command line option for running this facility).
*/
#if 0
//---------------------------------------------------------------------------
// tTVPPipeStream to do IPC (used for Object Hash Map)
//---------------------------------------------------------------------------
class tTVPPipeStream : public tTJSBinaryStream
{
private:
HANDLE Handle;
public:
tTVPPipeStream(HANDLE handle)
{
Handle = handle;
}
~tTVPPipeStream()
{
CloseHandle(Handle);
}
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence)
{
return 0; // pipes does not support seeking
}
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size)
{
DWORD ret = 0;
ReadFile(Handle, buffer, read_size, &ret, NULL);
return ret;
}
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size)
{
DWORD ret = 0;
WriteFile(Handle, buffer, write_size, &ret, NULL);
FlushFileBuffers(Handle);
return ret;
}
void TJS_INTF_METHOD SetEndOfStorage()
{
return;
}
tjs_uint64 TJS_INTF_METHOD GetSize()
{
return 0;
}
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Object Hash Map (memory leak detector) related
//---------------------------------------------------------------------------
static char TVPObjectHashMapLogStream[sizeof(tTVPPipeStream)];
//---------------------------------------------------------------------------
void TVPStartObjectHashMapLog(void)
{
#ifndef ENABLE_DEBUGGER
if(TJSObjectHashMapEnabled())
{
// begin logging
// create anonymous pipe to communicate with child kirikiri process
HANDLE read, write;
SECURITY_ATTRIBUTES sa;
ZeroMemory(&sa, sizeof(sa));
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
CreatePipe(&read, &write, &sa, 0);
// redirect stdin to output the object hash map log
HANDLE org_stdin = GetStdHandle(STD_INPUT_HANDLE);
HANDLE childdupwrite;
SetStdHandle(STD_INPUT_HANDLE, read);
DuplicateHandle(GetCurrentProcess(), write, GetCurrentProcess(),
&childdupwrite, 0, FALSE, DUPLICATE_SAME_ACCESS);
CloseHandle(write);
write = childdupwrite;
// create child kirikiri process
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
wchar_t szFull[_MAX_PATH];
::GetModuleFileName(NULL, szFull, sizeof(szFull) / sizeof(wchar_t));
std::wstring exepath(szFull);
BOOL ret =
::CreateProcess(
NULL,
const_cast((exepath + L" -@processohmlog").c_str()),
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi);
if(ret)
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
// close unneeded handle
CloseHandle(read);
// restore original stdin handle
SetStdHandle(STD_INPUT_HANDLE, org_stdin);
// create tTJSBinaryStream object in STATIC AREA
::new (TVPObjectHashMapLogStream) tTVPPipeStream(write);
// set object hash map log
TJSObjectHashMapSetLog((tTVPLocalFileStream*)TVPObjectHashMapLogStream);
// write all objects to log
TJSWriteAllUnfreedObjectsToLog();
// end object mapping
TJSReleaseObjectHashMap();
}
#endif
}
//---------------------------------------------------------------------------
static tTVPAtExit TVPReportUnfreedObjectsAtExit
(TVP_ATEXIT_PRI_CLEANUP - 1, TVPStartObjectHashMapLog);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
bool TVPCheckProcessLog()
{
// process object hash map log
int argc = Application->ArgC;
char** argv = Application->ArgV;
tjs_int i;
for(i=1; i and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// TJS2 Script Managing
//---------------------------------------------------------------------------
#ifndef ScriptMgnImplH
#define ScriptMgnImplH
#include "ScriptMgnIntf.h"
//---------------------------------------------------------------------------
// TVPInitializeStartupScript
//---------------------------------------------------------------------------
extern void TVPInitializeStartupScript();
//extern bool TVPCheckProcessLog(int argc, char *argv[]);
//---------------------------------------------------------------------------
#endif
================================================
FILE: src/core/base/win32/StorageImpl.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
// #include
// #include
#include "MsgIntf.h"
#include "StorageImpl.h"
#include "WindowImpl.h"
#include "GraphicsLoaderImpl.h"
#include "SysInitIntf.h"
#include "DebugIntf.h"
#include "Random.h"
#include "XP3Archive.h"
//#include "SusieArchive.h"
#include "FileSelector.h"
#include "Random.h"
#include
#include "Application.h"
#include "StringUtil.h"
#include "FilePathUtil.h"
#include "Platform.h"
#include "platform/CCPlatformConfig.h"
#include "dirent.h"
#include "TickCount.h"
#include
#include
#include "combase.h"
#include "win32io.h"
//---------------------------------------------------------------------------
// tTVPFileMedia
//---------------------------------------------------------------------------
class tTVPFileMedia : public iTVPStorageMedia
{
tjs_uint RefCount;
public:
tTVPFileMedia() { RefCount = 1; }
~tTVPFileMedia() {;}
void TJS_INTF_METHOD AddRef() { RefCount ++; }
void TJS_INTF_METHOD Release()
{
if(RefCount == 1)
delete this;
else
RefCount --;
}
void TJS_INTF_METHOD GetName(ttstr &name) { name = TJS_W("file"); }
void TJS_INTF_METHOD NormalizeDomainName(ttstr &name);
void TJS_INTF_METHOD NormalizePathName(ttstr &name);
bool TJS_INTF_METHOD CheckExistentStorage(const ttstr &name);
tTJSBinaryStream * TJS_INTF_METHOD Open(const ttstr & name, tjs_uint32 flags);
void TJS_INTF_METHOD GetListAt(const ttstr &name, iTVPStorageLister *lister);
void TJS_INTF_METHOD GetLocallyAccessibleName(ttstr &name);
public:
void TJS_INTF_METHOD GetLocalName(ttstr &name);
};
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPFileMedia::NormalizeDomainName(ttstr &name)
{
// normalize domain name
// make all characters small
tjs_char *p = name.Independ();
while(*p)
{
if(*p >= TJS_W('A') && *p <= TJS_W('Z'))
*p += TJS_W('a') - TJS_W('A');
p++;
}
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPFileMedia::NormalizePathName(ttstr &name)
{
// normalize path name
// make all characters small
tjs_char *p = name.Independ();
while(*p)
{
if(*p >= TJS_W('A') && *p <= TJS_W('Z'))
*p += TJS_W('a') - TJS_W('A');
p++;
}
}
//---------------------------------------------------------------------------
bool TJS_INTF_METHOD tTVPFileMedia::CheckExistentStorage(const ttstr &name)
{
if(name.IsEmpty()) return false;
ttstr _name(name);
GetLocalName(_name);
return TVPCheckExistentLocalFile(_name);
}
//---------------------------------------------------------------------------
tTJSBinaryStream * TJS_INTF_METHOD tTVPFileMedia::Open(const ttstr & name, tjs_uint32 flags)
{
// open storage named "name".
// currently only local/network(by OS) storage systems are supported.
if(name.IsEmpty())
TVPThrowExceptionMessage(TVPCannotOpenStorage, TJS_W("\"\""));
ttstr origname = name;
ttstr _name(name);
GetLocalName(_name);
return new tTVPLocalFileStream(origname, _name, flags);
}
void TVPListDir(const std::string &folder, std::function cb) {
DIR *dirp;
struct dirent *direntp;
tTVP_stat stat_buf;
if ((dirp = opendir(folder.c_str())))
{
while ((direntp = readdir(dirp)) != NULL)
{
std::string fullpath = folder + "/" + direntp->d_name;
if (!TVP_stat(fullpath.c_str(), stat_buf))
continue;
cb(direntp->d_name, stat_buf.st_mode);
}
closedir(dirp);
}
}
void TVPGetLocalFileListAt(const ttstr &name, const std::function& cb) {
DIR *dirp;
struct dirent *direntp;
tTVP_stat stat_buf;
std::string folder(name.AsNarrowStdString());
if ((dirp = opendir(folder.c_str())))
{
while ((direntp = readdir(dirp)) != NULL)
{
std::string fullpath = folder + "/" + direntp->d_name;
if (!TVP_stat(fullpath.c_str(), stat_buf))
continue;
ttstr file(direntp->d_name);
if (file.length() <= 2) {
if (file == TJS_W(".") || file == TJS_W(".."))
continue;
}
tjs_char *p = file.Independ();
while (*p)
{
// make all characters small
if (*p >= TJS_W('A') && *p <= TJS_W('Z'))
*p += TJS_W('a') - TJS_W('A');
p++;
}
tTVPLocalFileInfo info;
info.NativeName = direntp->d_name;
info.Mode = stat_buf.st_mode;
info.Size = stat_buf.st_size;
info.AccessTime = stat_buf.st_atime;
info.ModifyTime = stat_buf.st_mtime;
info.CreationTime = stat_buf.st_ctime;
cb(file, &info);
}
closedir(dirp);
}
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPFileMedia::GetListAt(const ttstr &_name, iTVPStorageLister *lister)
{
ttstr name(_name);
GetLocalName(name);
#if 0
name += TJS_W("*.*");
// perform UNICODE operation
WIN32_FIND_DATAW ffd;
HANDLE handle = ::FindFirstFile(name.c_str(), &ffd);
if(handle != INVALID_HANDLE_VALUE)
{
BOOL cont;
do
{
if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
ttstr file(ffd.cFileName);
tjs_char *p = file.Independ();
while(*p)
{
// make all characters small
if(*p >= TJS_W('A') && *p <= TJS_W('Z'))
*p += TJS_W('a') - TJS_W('A');
p++;
}
lister->Add(file);
}
cont = ::FindNextFile(handle, &ffd);
} while(cont);
FindClose(handle);
}
#endif
TVPGetLocalFileListAt(name, [lister](const ttstr &name, tTVPLocalFileInfo* s) {
if (s->Mode & (S_IFREG)) {
lister->Add(name);
}
});
}
static int _utf8_strcasecmp(const char *a, const char *b) {
for(; *a && *b; ++a, ++b) {
int ca = *a, cb = *b;
if('A' <= ca && ca <= 'Z') ca += 'a' - 'A';
if('A' <= cb && cb <= 'Z') cb += 'a' - 'A';
int ret = ca - cb;
if(ret) return ret;
}
return *a - *b;
}
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
const std::vector &TVPGetApplicationHomeDirectory();
const std::vector &_getPrefixPath() {
static std::vector ret;
if (ret.empty()) {
for (const std::string &path : TVPGetApplicationHomeDirectory()) {
ret.emplace_back(path);
}
}
return ret;
}
const std::vector &_getHomeDir() {
static std::vector ret;
if (ret.empty()) {
for (const std::string &path : TVPGetApplicationHomeDirectory()) {
ret.emplace_back(path + "/");
}
}
return ret;
}
#endif
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPFileMedia::GetLocallyAccessibleName(ttstr &name)
{
ttstr newname;
const tjs_char *ptr = name.c_str();
#ifdef WIN32
if(TJS_strncmp(ptr, TJS_W("./"), 2))
{
// differs from "./",
// this may be a UNC file name.
// UNC first two chars must be "\\\\" ?
// AFAIK 32-bit version of Windows assumes that '/' can be used as a path
// delimiter. Can UNC "\\\\" be replaced by "//" though ?
newname = ttstr(TJS_W("\\\\")) + ptr;
}
else
{
ptr += 2; // skip "./"
if(!*ptr) {
newname = TJS_W("");
} else {
tjs_char dch = *ptr;
if(*ptr < TJS_W('a') || *ptr > TJS_W('z')) {
newname = TJS_W("");
} else {
ptr++;
if(*ptr != TJS_W('/')) {
newname = TJS_W("");
} else {
newname = ttstr(dch) + TJS_W(":") + ptr;
}
}
}
}
// change path delimiter to '\\'
tjs_char *pp = newname.Independ();
while(*pp)
{
if(*pp == TJS_W('/')) *pp = TJS_W('\\');
pp++;
}
#else // posix
if(!TJS_strncmp(ptr, TJS_W("./"), 2)) {
ptr += 2; // skip "./"
newname.Clear();
}
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
{
std::string prefix = "/";
prefix += tTJSNarrowStringHolder(ptr).Buf;
static const std::vector &prefixPath = _getPrefixPath();
static const std::vector &homeDir = _getHomeDir();
for (int i = 0; i < prefixPath.size(); ++i) {
const std::string &dir = homeDir[i];
if (prefix.length() < dir.length()) continue;
std::string actualPrefix = prefix.substr(0, dir.length());
if (!_utf8_strcasecmp(actualPrefix.c_str(), dir.c_str())) {
newname = prefixPath[i];
ptr += prefixPath[i].length();
while (*ptr && *ptr == TJS_W('/')) ++ptr;
break;
}
}
}
#endif
while(*ptr) {
const tjs_char *ptr_end = ptr;
while(*ptr_end && *ptr_end != TJS_W('/')) ++ptr_end;
if(ptr_end == ptr) break;
const tjs_char *ptr_cur = ptr;
tTJSNarrowStringHolder walker(ttstr(ptr, ptr_end - ptr).c_str());
while(*ptr_end && *ptr_end == TJS_W('/')) ++ptr_end;
ptr = ptr_end;
DIR *dirp;
struct dirent *direntp;
newname += "/";
if ((dirp = opendir( tTJSNarrowStringHolder(newname.c_str()) ))) {
bool found = false;
while ((direntp = readdir( dirp)) != NULL) {
if(!_utf8_strcasecmp(walker, direntp->d_name)) {
newname += direntp->d_name;
found = true;
break;
}
}
closedir(dirp);
if(!found) {
newname += ptr_cur;
break;
}
} else {
newname += ptr_cur;
break;
}
}
#endif
name = newname;
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPFileMedia::GetLocalName(ttstr &name)
{
ttstr tmp = name;
GetLocallyAccessibleName(tmp);
if(tmp.IsEmpty()) TVPThrowExceptionMessage(TVPCannotGetLocalName, name);
name = tmp;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
iTVPStorageMedia * TVPCreateFileMedia()
{
return new tTVPFileMedia;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPPreNormalizeStorageName
//---------------------------------------------------------------------------
void TVPPreNormalizeStorageName(ttstr &name)
{
// if the name is an OS's native expression, change it according with the
// TVP storage system naming rule.
tjs_int namelen = name.GetLen();
if(namelen == 0) return;
#ifdef WIN32
if(namelen >= 2)
{
if((name[0] >= TJS_W('a') && name[0]<=TJS_W('z') ||
name[0] >= TJS_W('A') && name[0]<=TJS_W('Z') ) &&
name[1] == TJS_W(':'))
{
// Windows drive:path expression
ttstr newname(TJS_W("file://./"));
newname += name[0];
newname += (name.c_str()+2);
name = newname;
return;
}
}
if(namelen>=3)
{
if(name[0] == TJS_W('\\') && name[1] == TJS_W('\\') ||
name[0] == TJS_W('/') && name[1] == TJS_W('/'))
{
// unc expression
name = ttstr(TJS_W("file:")) + name;
return;
}
}
#else // posix
if(namelen>=1) {
if(name[0] == TJS_W('/')) {
name = ttstr(TJS_W("file://.")) + name;
return;
}
}
#endif
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetTemporaryName
//---------------------------------------------------------------------------
static tjs_int TVPTempUniqueNum = 0;
static tTJSCriticalSection TVPTempUniqueNumCS;
static ttstr TVPTempPath;
bool TVPTempPathInit = false;
static tjs_int TVPProcessID;
ttstr TVPGetTemporaryName()
{
static tjs_int TVPTempUniqueNum = (tjs_int)TVPGetRoughTickCount32();
tjs_int num = TVPTempUniqueNum++;
ttstr TVPTempPath = TVPGetAppPath();
#if 0
tjs_int num;
{
tTJSCriticalSectionHolder holder(TVPTempUniqueNumCS);
if(!TVPTempPathInit)
{
wchar_t tmp[MAX_PATH+1];
::GetTempPath(MAX_PATH, tmp);
TVPTempPath = tmp;
if(TVPTempPath.GetLastChar() != TJS_W('\\')) TVPTempPath += TJS_W("\\");
TVPProcessID = (tjs_int) GetCurrentProcessId();
TVPTempUniqueNum = (tjs_int) GetTickCount();
TVPTempPathInit = true;
}
num = TVPTempUniqueNum ++;
}
#endif
unsigned char buf[16];
TVPGetRandomBits128(buf);
tjs_char random[128];
TJS_snprintf(random, sizeof(random)/sizeof(tjs_char), TJS_W("%02x%02x%02x%02x%02x%02x"),
buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5]);
return TVPTempPath + TJS_W("krkr_") + ttstr(random) +
TJS_W("_") + ttstr(num) + TJS_W("_") + ttstr(TVPProcessID);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPRemoveFile
//---------------------------------------------------------------------------
bool TVPRemoveFile(const ttstr &name)
{
tTJSNarrowStringHolder holder(name.c_str());
return !remove(holder);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPRemoveFolder
//---------------------------------------------------------------------------
bool TVPRemoveFolder(const ttstr &name)
{
tTJSNarrowStringHolder holder(name.c_str());
return !unlink(holder);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPGetAppPath
//---------------------------------------------------------------------------
ttstr TVPGetAppPath()
{
#if 0
static ttstr exepath(TVPExtractStoragePath(TVPNormalizeStorageName(ExePath())));
return exepath;
#endif
static ttstr apppath(TVPExtractStoragePath(TVPProjectDir));
return apppath;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPOpenStream
//---------------------------------------------------------------------------
tTJSBinaryStream * TVPOpenStream(const ttstr & _name, tjs_uint32 flags)
{
// open storage named "name".
// currently only local/network(by OS) storage systems are supported.
if(_name.IsEmpty())
TVPThrowExceptionMessage(TVPCannotOpenStorage, TJS_W("\"\""));
ttstr origname = _name;
ttstr name(_name);
TVPGetLocalName(name);
return new tTVPLocalFileStream(origname, name, flags);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCheckExistantLocalFile
//---------------------------------------------------------------------------
bool TVPCheckExistentLocalFile(const ttstr &name)
{
#if 0
DWORD attrib = ::GetFileAttributes(name.c_str());
if(attrib == 0xffffffff || (attrib & FILE_ATTRIBUTE_DIRECTORY))
return false; // not a file
else
return true; // a file
#endif
tTVP_stat s;
if(!TVP_stat(name.c_str(), s)) {
return false; // not exist
}
return s.st_mode & S_IFREG;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCheckExistantLocalFolder
//---------------------------------------------------------------------------
bool TVPCheckExistentLocalFolder(const ttstr &name)
{
#if 0
DWORD attrib = GetFileAttributes(name.c_str());
if(attrib != 0xffffffff && (attrib & FILE_ATTRIBUTE_DIRECTORY))
return true; // a folder
else
return false; // not a folder
#endif
tTVP_stat s;
if (!TVP_stat(name.c_str(), s)) {
return false; // not exist
}
return s.st_mode & S_IFDIR;
}
//---------------------------------------------------------------------------
tTVPArchive * TVPOpenZIPArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName);
tTVPArchive * TVPOpen7ZArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName);
tTVPArchive * TVPOpenTARArchive(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName);
static tTVPArchive*(*ArchiveCreators[])(const ttstr & name, tTJSBinaryStream *st, bool normalizeFileName) = {
TVPOpenZIPArchive,
TVPOpen7ZArchive,
TVPOpenTARArchive,
tTVPXP3Archive::Create
};
//---------------------------------------------------------------------------
// TVPOpenArchive
//---------------------------------------------------------------------------
tTVPArchive * TVPOpenArchive(const ttstr & name, bool normalizeFileName)
{
#if 0
tTVPArchive * archive = TVPOpenSusieArchive(name); // in SusieArchive.h
if(!archive) return new tTVPXP3Archive(name); else return archive;
#endif
tTJSBinaryStream *st = TVPCreateStream(name);
if (!st) return nullptr;
for (int i = 0; i < sizeof(ArchiveCreators) / sizeof(ArchiveCreators[0]); ++i) {
tTVPArchive*(*creator)(const ttstr &, tTJSBinaryStream*, bool) = ArchiveCreators[i];
tTVPArchive * archive = creator(name, st, normalizeFileName);
if (archive) return archive;
st->SetPosition(0);
}
delete st;
return nullptr;
}
//---------------------------------------------------------------------------
int TVPCheckArchive(const ttstr &localname)
{
tTVPArchive *arc = nullptr;
int validArchive = 2; // archive but no startup.tjs
try {
arc = TVPOpenArchive(TVPNormalizeStorageName(localname), false);
if (arc) {
tjs_uint count = arc->GetCount();
ttstr str_startup_tjs = TJS_W("startup.tjs");
//ttstr str_sys_init_tjs = TJS_W("system/initialize.tjs");
for (int i = 0; i < count; ++i) {
ttstr name = arc->GetName(i);
if (name.length() == str_startup_tjs.length()) {
arc->NormalizeInArchiveStorageName(name);
if (name == str_startup_tjs) {
validArchive = 1;
break;
}
}
// else if (name.length() == str_sys_init_tjs.length()) {
// arc->NormalizeInArchiveStorageName(name);
// if (name == str_sys_init_tjs) {
// validArchive = true;
// break;
// }
// }
}
}
} catch (eTJSError e) {
//arc = nullptr;
}
if (arc) {
delete arc;
return validArchive;
}
return 0; // not archive
}
//---------------------------------------------------------------------------
// TVPLocalExtrectFilePath
//---------------------------------------------------------------------------
ttstr TVPLocalExtractFilePath(const ttstr & name)
{
// this extracts given name's path under local filename rule
const tjs_char *p = name.c_str();
tjs_int i = name.GetLen() -1;
for(; i >= 0; i--)
{
if(p[i] == TJS_W(':') || p[i] == TJS_W('/') ||
p[i] == TJS_W('\\'))
break;
}
return ttstr(p, i + 1);
}
//---------------------------------------------------------------------------
#if 0
//---------------------------------------------------------------------------
// TVPCreateFolders
//---------------------------------------------------------------------------
static bool _TVPCreateFolders(const ttstr &folder)
{
// create directories along with "folder"
if(folder.IsEmpty()) return true;
if(TVPCheckExistentLocalFolder(folder))
return true; // already created
const tjs_char *p = folder.c_str();
tjs_int i = folder.GetLen() - 1;
if(p[i] == TJS_W(':')) return true;
while(i >= 0 && (p[i] == TJS_W('/') || p[i] == TJS_W('\\'))) i--;
if(i >= 0 && p[i] == TJS_W(':')) return true;
for(; i >= 0; i--)
{
if(p[i] == TJS_W(':') || p[i] == TJS_W('/') ||
p[i] == TJS_W('\\'))
break;
}
ttstr parent(p, i + 1);
if(!_TVPCreateFolders(parent)) return false;
BOOL res = ::CreateDirectory(folder.c_str(), NULL);
return 0!=res;
}
bool TVPCreateFolders(const ttstr &folder)
{
if(folder.IsEmpty()) return true;
const tjs_char *p = folder.c_str();
tjs_int i = folder.GetLen() - 1;
if(p[i] == TJS_W(':')) return true;
if(p[i] == TJS_W('/') || p[i] == TJS_W('\\')) i--;
return _TVPCreateFolders(ttstr(p, i+1));
}
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
// tTVPLocalFileStream
//---------------------------------------------------------------------------
tTVPLocalFileStream::tTVPLocalFileStream(const ttstr &origname,
const ttstr &localname, tjs_uint32 flag)
: MemBuffer(nullptr), FileName(localname), Handle(-1)
{
tjs_uint32 access = flag & TJS_BS_ACCESS_MASK;
if(access == TJS_BS_WRITE) {
if (TVPCheckExistentLocalFile(localname)) {
} else {
ttstr dirpath = TVPLocalExtractFilePath(localname);
const tjs_char *p = dirpath.c_str();
tjs_int i = dirpath.GetLen();
if (p[i-1] == TJS_W('/') || p[i-1] == TJS_W('\\')) i--;
dirpath = dirpath.SubString(0, i);
if (!TVPCheckExistentLocalFolder(dirpath) && !TVPCreateFolders(dirpath)) {
TVPThrowExceptionMessage(TVPCannotOpenStorage, origname);
}
// _lastFileSystemChanged = true;
}
MemBuffer = new tTVPMemoryStream();
return;
}
unsigned int rw = 0;
switch(access)
{
case TJS_BS_READ:
rw |= O_RDONLY; break;
case TJS_BS_WRITE:
rw |= O_RDWR | O_CREAT | O_TRUNC; break;
case TJS_BS_APPEND:
rw |= O_APPEND; break;
case TJS_BS_UPDATE:
rw |= O_RDWR; break;
}
tTJSNarrowStringHolder holder(localname.c_str());
Handle = open(holder, rw, 0666);
if (Handle < 0) {
if (access == TJS_BS_APPEND || access == TJS_BS_UPDATE) {
// use whole file writing
Handle = open(holder, O_RDONLY, 0666);
if (Handle >= 0) {
tjs_uint64 size = GetSize();
if (size < 4 * 1024 * 1024) { // only support file size <= 4M
MemBuffer = new tTVPMemoryStream();
MemBuffer->SetSize(size);
read(Handle, MemBuffer->GetInternalBuffer(), size);
}
close(Handle);
Handle = -1;
}
}
if (!MemBuffer)
TVPThrowExceptionMessage(TVPCannotOpenStorage, origname);
}
// push current tick as an environment noise
uint32_t tick = TVPGetRoughTickCount32();
TVPPushEnvironNoise(&tick, sizeof(tick));
}
//---------------------------------------------------------------------------
bool TVPWriteDataToFile(const ttstr &filepath, const void *data, unsigned int len);
tTVPLocalFileStream::~tTVPLocalFileStream()
{
if(MemBuffer) {
if (!TVPWriteDataToFile(FileName, MemBuffer->GetInternalBuffer(), MemBuffer->GetSize())) {
delete MemBuffer;
ttstr filename(FileName);
FileName.~tTJSString();
free(this);
TVPThrowExceptionMessage(TJS_W("File Writing Error: %1"), filename);
}
delete MemBuffer;
}
if (Handle >= 0) {
close(Handle);
}
// push current tick as an environment noise
// (timing information from file accesses may be good noises)
uint32_t tick = TVPGetRoughTickCount32();
TVPPushEnvironNoise(&tick, sizeof(tick));
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPLocalFileStream::Seek(tjs_int64 offset, tjs_int whence)
{
if(MemBuffer) {
return MemBuffer->Seek(offset, whence);
}
return lseek64(Handle, offset, whence);
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPLocalFileStream::Read(void *buffer, tjs_uint read_size)
{
if(MemBuffer) {
return MemBuffer->Read(buffer, read_size);
}
return read(Handle, buffer, read_size);
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPLocalFileStream::Write(const void *buffer, tjs_uint write_size)
{
if(MemBuffer) {
return MemBuffer->Write(buffer, write_size);
}
return write(Handle, buffer, write_size);
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPLocalFileStream::SetEndOfStorage()
{
if(MemBuffer) {
return MemBuffer->SetEndOfStorage();
}
lseek64(Handle, 0, SEEK_END);
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPLocalFileStream::GetSize()
{
if(MemBuffer) {
return MemBuffer->GetSize();
}
tjs_uint64 ret;
tjs_int64 curpos = lseek64(Handle, 0, SEEK_CUR);
ret = lseek64(Handle, 0, SEEK_END);
lseek64(Handle, curpos, SEEK_SET);
return ret;
}
//---------------------------------------------------------------------------
#ifdef TJS_SUPPORT_VCL
//---------------------------------------------------------------------------
// TTVPStreamAdapter
//---------------------------------------------------------------------------
__fastcall TTVPStreamAdapter::TTVPStreamAdapter(tTJSBinaryStream *ref)
{
Stream = ref;
Stream->SetPosition(0);
}
//---------------------------------------------------------------------------
__fastcall TTVPStreamAdapter::~TTVPStreamAdapter()
{
delete Stream;
}
//---------------------------------------------------------------------------
int __fastcall TTVPStreamAdapter::Read(void *Buffer, int Count)
{
return (int)Stream->Read(Buffer, Count);
}
//---------------------------------------------------------------------------
int __fastcall TTVPStreamAdapter::Seek(int Offset, WORD Origin)
{
tjs_int whence;
switch(Origin)
{
case soFromBeginning: whence = TJS_BS_SEEK_SET; break;
case soFromCurrent: whence = TJS_BS_SEEK_CUR; break;
case soFromEnd: whence = TJS_BS_SEEK_END; break;
}
return (int)Stream->Seek(Offset, whence);
}
//---------------------------------------------------------------------------
int __fastcall TTVPStreamAdapter::Write(const void *Buffer,int Count)
{
return (int)Stream->Write(Buffer, Count);
}
//---------------------------------------------------------------------------
#endif
#if 1
//---------------------------------------------------------------------------
// tTVPIStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides COM's IStream adapter for tTJSBinaryStream
*/
class tTVPIStreamAdapter : public IStream
{
private:
tTJSBinaryStream *Stream;
ULONG RefCount;
public:
tTVPIStreamAdapter(tTJSBinaryStream *ref);
/*
the stream passed by argument here is freed by this instance'
destruction.
*/
~tTVPIStreamAdapter();
// IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
void **ppvObject);
ULONG STDMETHODCALLTYPE AddRef(void);
ULONG STDMETHODCALLTYPE Release(void);
// ISequentialStream
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead);
HRESULT STDMETHODCALLTYPE Write(const void *pv, ULONG cb,
ULONG *pcbWritten);
// IStream
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER libNewSize);
HRESULT STDMETHODCALLTYPE CopyTo(IStream *pstm, ULARGE_INTEGER cb,
ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
HRESULT STDMETHODCALLTYPE Commit(DWORD grfCommitFlags);
HRESULT STDMETHODCALLTYPE Revert(void);
HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType);
HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType);
HRESULT STDMETHODCALLTYPE Stat(STATSTG *pstatstg, DWORD grfStatFlag);
HRESULT STDMETHODCALLTYPE Clone(IStream **ppstm);
void ClearStream() {
Stream = NULL;
}
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPIStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides adapter for COM's IStream
*/
tTVPIStreamAdapter::tTVPIStreamAdapter(tTJSBinaryStream *ref)
{
Stream = ref;
RefCount = 1;
}
//---------------------------------------------------------------------------
tTVPIStreamAdapter::~tTVPIStreamAdapter()
{
delete Stream;
}
//---------------------------------------------------------------------------
extern "C" const IID IID_IUnknown;
extern "C" const IID IID_IStream;
extern "C" const IID IID_ISequentialStream;
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::QueryInterface(REFIID riid,
void **ppvObject)
{
if(!ppvObject) return E_INVALIDARG;
*ppvObject=NULL;
if(!memcmp(&riid,&IID_IUnknown,16))
*ppvObject=(IUnknown*)this;
else if(!memcmp(&riid,&IID_ISequentialStream,16))
*ppvObject=(ISequentialStream*)this;
else if(!memcmp(&riid,&IID_IStream,16))
*ppvObject=(IStream*)this;
if(*ppvObject)
{
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
//---------------------------------------------------------------------------
ULONG STDMETHODCALLTYPE tTVPIStreamAdapter::AddRef(void)
{
return ++ RefCount;
}
//---------------------------------------------------------------------------
ULONG STDMETHODCALLTYPE tTVPIStreamAdapter::Release(void)
{
if(RefCount == 1)
{
delete this;
return 0;
}
else
{
return --RefCount;
}
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Read(void *pv, ULONG cb, ULONG *pcbRead)
{
try
{
ULONG read;
read = Stream->Read(pv, cb);
if(pcbRead) *pcbRead = read;
}
catch(...)
{
return E_FAIL;
}
return S_OK;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Write(const void *pv, ULONG cb,
ULONG *pcbWritten)
{
try
{
ULONG written;
written = Stream->Write(pv, cb);
if(pcbWritten) *pcbWritten = written;
}
catch(...)
{
return E_FAIL;
}
return S_OK;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Seek(LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
try
{
switch(dwOrigin)
{
case STREAM_SEEK_SET:
if(plibNewPosition)
(*plibNewPosition).QuadPart =
Stream->Seek(dlibMove.QuadPart, TJS_BS_SEEK_SET);
else
Stream->Seek(dlibMove.QuadPart, TJS_BS_SEEK_SET);
break;
case STREAM_SEEK_CUR:
if(plibNewPosition)
(*plibNewPosition).QuadPart =
Stream->Seek(dlibMove.QuadPart, TJS_BS_SEEK_CUR);
else
Stream->Seek(dlibMove.QuadPart, TJS_BS_SEEK_CUR);
break;
case STREAM_SEEK_END:
if(plibNewPosition)
(*plibNewPosition).QuadPart =
Stream->Seek(dlibMove.QuadPart, TJS_BS_SEEK_END);
else
Stream->Seek(dlibMove.QuadPart, TJS_BS_SEEK_END);
break;
default:
return E_FAIL;
}
}
catch(...)
{
return E_FAIL;
}
return S_OK;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::SetSize(ULARGE_INTEGER libNewSize)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::CopyTo(IStream *pstm, ULARGE_INTEGER cb,
ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Commit(DWORD grfCommitFlags)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Revert(void)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::LockRegion(ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::UnlockRegion(ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
{
// This method imcompletely fills the target structure, because some
// informations like access mode or stream name are already lost
// at this point.
if(pstatstg)
{
memset(pstatstg, 0, sizeof(*pstatstg));
// pwcsName
// this object's storage pointer does not have a name ...
if(!(grfStatFlag & STATFLAG_NONAME))
{
// anyway returns an empty string
pstatstg->pwcsName = (LPOLESTR)TJS_W("");
}
// type
pstatstg->type = STGTY_STREAM;
// cbSize
pstatstg->cbSize.QuadPart = Stream->GetSize();
// mtime, ctime, atime unknown
// grfMode unknown
pstatstg->grfMode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_DENY_WRITE ;
// Note that this method always returns flags above, regardless of the
// actual mode.
// In the return value, the stream is to be indicated that the
// stream can be written, but of cource, the Write method will fail
// if the stream is read-only.
// grfLockSuppoted
pstatstg->grfLocksSupported = 0;
// grfStatBits unknown
}
else
{
return E_INVALIDARG;
}
return S_OK;
}
//---------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE tTVPIStreamAdapter::Clone(IStream **ppstm)
{
return E_NOTIMPL;
}
//---------------------------------------------------------------------------
#endif
IStream * TVPCreateIStream(tTJSBinaryStream *s) { return new tTVPIStreamAdapter(s); }
//---------------------------------------------------------------------------
// IStream creator
//---------------------------------------------------------------------------
IStream * TVPCreateIStream(const ttstr &name, tjs_uint32 flags)
{
// convert tTJSBinaryStream to IStream thru TStream
tTJSBinaryStream *stream0 = NULL;
try
{
stream0 = TVPCreateStream(name, flags);
}
catch(...)
{
if(stream0) delete stream0;
return NULL;
}
IStream *istream = new tTVPIStreamAdapter(stream0);
return istream;
}
//---------------------------------------------------------------------------
#if 0
//---------------------------------------------------------------------------
// tTVPBinaryStreamAdapter
//---------------------------------------------------------------------------
tTVPBinaryStreamAdapter::tTVPBinaryStreamAdapter(IStream *ref)
{
Stream = ref;
Stream->AddRef();
}
//---------------------------------------------------------------------------
tTVPBinaryStreamAdapter::~tTVPBinaryStreamAdapter()
{
Stream->Release();
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPBinaryStreamAdapter::Seek(tjs_int64 offset, tjs_int whence)
{
DWORD origin;
switch(whence)
{
case TJS_BS_SEEK_SET: origin = STREAM_SEEK_SET; break;
case TJS_BS_SEEK_CUR: origin = STREAM_SEEK_CUR; break;
case TJS_BS_SEEK_END: origin = STREAM_SEEK_END; break;
default: origin = STREAM_SEEK_SET; break;
}
LARGE_INTEGER ofs;
ULARGE_INTEGER newpos;
ofs.QuadPart = 0;
HRESULT hr = Stream->Seek(ofs, STREAM_SEEK_CUR, &newpos);
bool orgpossaved;
LARGE_INTEGER orgpos;
if(FAILED(hr))
{
orgpossaved = false;
}
else
{
orgpossaved = true;
*(LARGE_INTEGER*)&orgpos = *(LARGE_INTEGER*)&newpos;
}
ofs.QuadPart = offset;
hr = Stream->Seek(ofs, origin, &newpos);
if(FAILED(hr))
{
if(orgpossaved)
{
Stream->Seek(orgpos, STREAM_SEEK_SET, &newpos);
}
else
{
TVPThrowExceptionMessage(TVPSeekError);
}
}
return newpos.QuadPart;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPBinaryStreamAdapter::Read(void *buffer, tjs_uint read_size)
{
ULONG cb = read_size;
ULONG read;
HRESULT hr = Stream->Read(buffer, cb, &read);
if(FAILED(hr)) read = 0;
return read;
}
//---------------------------------------------------------------------------
tjs_uint TJS_INTF_METHOD tTVPBinaryStreamAdapter::Write(const void *buffer, tjs_uint write_size)
{
ULONG cb = write_size;
ULONG written;
HRESULT hr = Stream->Write(buffer, cb, &written);
if(FAILED(hr)) written = 0;
return written;
}
//---------------------------------------------------------------------------
tjs_uint64 TJS_INTF_METHOD tTVPBinaryStreamAdapter::GetSize()
{
HRESULT hr;
STATSTG stg;
hr = Stream->Stat(&stg, STATFLAG_NONAME);
if(FAILED(hr))
{
return inherited::GetSize(); // use default routine
}
return stg.cbSize.QuadPart;
}
//---------------------------------------------------------------------------
void TJS_INTF_METHOD tTVPBinaryStreamAdapter::SetEndOfStorage()
{
ULARGE_INTEGER pos;
pos.QuadPart = GetPosition();
HRESULT hr = Stream->SetSize(pos);
if(FAILED(hr)) TVPThrowExceptionMessage(TVPTruncateError);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCreateBinaryStreamAdapter
//---------------------------------------------------------------------------
tTJSBinaryStream * TVPCreateBinaryStreamAdapter(IStream *refstream)
{
return new tTVPBinaryStreamAdapter(refstream);
}
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
// tTVPPluginHolder
//---------------------------------------------------------------------------
tTVPPluginHolder::tTVPPluginHolder(const ttstr &aname)
{
LocalTempStorageHolder = NULL;
// search in TVP storage system
ttstr place(TVPGetPlacedPath(aname));
if(!place.IsEmpty())
{
LocalTempStorageHolder = new tTVPLocalTempStorageHolder(place);
}
else
{
// not found in TVP storage system; search exepath, exepath\system, exepath\plugin
#if 0
ttstr exepath =
IncludeTrailingBackslash(ExtractFileDir(ExePath()));
ttstr pname = exepath + aname;
if(TVPCheckExistentLocalFile(pname))
{
LocalName = pname;
return;
}
pname = exepath + TJS_W("system\\") + aname;
if(TVPCheckExistentLocalFile(pname))
{
LocalName = pname;
return;
}
#ifdef TJS_64BIT_OS
pname = exepath + TJS_W("plugin64\\") + aname;
#else
pname = exepath + TJS_W("plugin\\") + aname;
#endif
if(TVPCheckExistentLocalFile(pname))
{
LocalName = pname;
return;
}
#endif
}
}
//---------------------------------------------------------------------------
tTVPPluginHolder::~tTVPPluginHolder()
{
if(LocalTempStorageHolder)
{
delete LocalTempStorageHolder;
}
}
//---------------------------------------------------------------------------
const ttstr & tTVPPluginHolder::GetLocalName() const
{
if(LocalTempStorageHolder) return LocalTempStorageHolder->GetLocalName();
return LocalName;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPSearchCD
//---------------------------------------------------------------------------
ttstr TVPSearchCD(const ttstr & name)
{
// search CD which has specified volume label name.
// return drive letter ( such as 'A' or 'B' )
// return empty string if not found.
#if 0
std::wstring narrow_name = name.AsStdString();
wchar_t dr[4];
for(dr[0]=L'A',dr[1]=L':',dr[2]=L'\\',dr[3]=0;dr[0]<=L'Z';dr[0]++)
{
if(::GetDriveType(dr) == DRIVE_CDROM)
{
wchar_t vlabel[256];
wchar_t fs[256];
DWORD mcl = 0,sfs = 0;
GetVolumeInformation(dr, vlabel, 255, NULL, &mcl, &sfs, fs, 255);
if( icomp(std::wstring(vlabel),narrow_name) )
//if(std::string(vlabel).AnsiCompareIC(narrow_name)==0)
return ttstr((tjs_char)dr[0]);
}
}
#endif
return ttstr();
}
//---------------------------------------------------------------------------
tTJSBinaryStream * TVPGetCachedArchiveHandle(void * pointer, const ttstr & name);
void TVPReleaseCachedArchiveHandle(void * pointer, tTJSBinaryStream * stream);
TArchiveStream::TArchiveStream(tTVPArchive *owner, tjs_uint64 off, tjs_uint64 len) : Owner(owner), StartPos(off), DataLength(len) {
Owner->AddRef();
_instr = TVPGetCachedArchiveHandle(Owner, Owner->ArchiveName);
CurrentPos = 0;
_instr->SetPosition(off);
}
TArchiveStream::~TArchiveStream() {
TVPReleaseCachedArchiveHandle(Owner, _instr);
Owner->Release();
}
//---------------------------------------------------------------------------
// TVPCreateNativeClass_Storages
//---------------------------------------------------------------------------
tTJSNativeClass * TVPCreateNativeClass_Storages()
{
tTJSNC_Storages *cls = new tTJSNC_Storages();
// setup some platform-specific members
//----------------------------------------------------------------------
//-- methods
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/searchCD)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
if(result)
*result = TVPSearchCD(*param[0]);
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL_OUTER(/*object to register*/cls,
/*func. name*/searchCD)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/getLocalName)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
if(result)
{
ttstr str(TVPNormalizeStorageName(*param[0]));
TVPGetLocalName(str);
*result = str;
}
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL_OUTER(/*object to register*/cls,
/*func. name*/getLocalName)
//----------------------------------------------------------------------
TJS_BEGIN_NATIVE_METHOD_DECL(/*func. name*/selectFile)
{
if(numparams < 1) return TJS_E_BADPARAMCOUNT;
iTJSDispatch2 * dsp = param[0]->AsObjectNoAddRef();
bool res = TVPSelectFile(dsp);
if(result) *result = (tjs_int)res;
return TJS_S_OK;
}
TJS_END_NATIVE_STATIC_METHOD_DECL_OUTER(/*object to register*/cls,
/*func. name*/selectFile)
//----------------------------------------------------------------------
return cls;
}
//---------------------------------------------------------------------------
static FILE *_fileopen(ttstr path) {
std::string strpath = path.AsStdString();
FILE *fp = fopen(strpath.c_str(), "wb");
if (!fp) { // make dirs
path = TVPExtractStoragePath(path);
TVPCreateFolders(path);
fp = fopen(strpath.c_str(), "wb");
}
return fp;
}
bool TVPSaveStreamToFile(tTJSBinaryStream *st, tjs_uint64 offset, tjs_uint64 size, ttstr outpath) {
FILE *fp = _fileopen(outpath);
if (!fp) return false;
tjs_uint64 origpos = st->GetPosition();
st->SetPosition(offset);
std::vector buffer; buffer.resize(2 * 1024 * 1024);
while (size > 0) {
unsigned int readsize = size > buffer.size() ? buffer.size() : size;
readsize = st->Read(&buffer.front(), readsize);
fwrite(&buffer.front(), 1, readsize, fp);
size -= readsize;
}
fclose(fp);
st->SetPosition(origpos);
return true;
}
================================================
FILE: src/core/base/win32/StorageImpl.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#ifndef StorageImplH
#define StorageImplH
//---------------------------------------------------------------------------
#include "StorageIntf.h"
#include "UtilStreams.h"
#include
//#include // for IStream
#if 0
//---------------------------------------------------------------------------
// Susie plug-in related
//---------------------------------------------------------------------------
void TVPLoadArchiveSPI(HINSTANCE inst);
void TVPUnloadArchiveSPI(HINSTANCE inst);
//---------------------------------------------------------------------------
#endif
#ifndef S_IFMT
#define S_IFDIR 0x4000 // Directory
#define S_IFREG 0x8000 // Regular
#endif
struct tTVPLocalFileInfo {
const char * NativeName;
unsigned short Mode; // S_IFMT
tjs_uint64 Size;
time_t AccessTime;
time_t ModifyTime;
time_t CreationTime;
};
void TVPGetLocalFileListAt(const ttstr &name, const std::function& cb);
//---------------------------------------------------------------------------
// tTVPLocalFileStream
//---------------------------------------------------------------------------
class tTVPLocalFileStream : public tTJSBinaryStream
{
private:
//HANDLE Handle;
int Handle;
tTVPMemoryStream *MemBuffer = nullptr;
ttstr FileName;
public:
tTVPLocalFileStream(const ttstr &origname, const ttstr & localname,
tjs_uint32 flag);
~tTVPLocalFileStream();
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
void TJS_INTF_METHOD SetEndOfStorage();
tjs_uint64 TJS_INTF_METHOD GetSize();
int GetHandle() const { return Handle; }
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(bool, TVPCheckExistentLocalFolder, (const ttstr &name));
/* name must be an OS's NATIVE folder name */
TJS_EXP_FUNC_DEF(bool, TVPCheckExistentLocalFile, (const ttstr &name));
/* name must be an OS's NATIVE file name */
TJS_EXP_FUNC_DEF(bool, TVPCreateFolders, (const ttstr &folder));
/* make folders recursively, like mkdir -p. folder must be OS NATIVE folder name */
//---------------------------------------------------------------------------
#ifdef TJS_SUPPORT_VCL
//---------------------------------------------------------------------------
// TTVPStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides VCL's TStream adapter for tTJSBinaryStream
*/
class TTVPStreamAdapter : public TStream
{
private:
tTJSBinaryStream *Stream;
public:
__fastcall TTVPStreamAdapter(tTJSBinaryStream *ref);
/*
the stream passed by argument here is freed by this instance'
destruction.
*/
__fastcall ~TTVPStreamAdapter();
int __fastcall Read(void *Buffer,int Count);
// read
int __fastcall Seek(int Offset,WORD Origin);
// seek
int __fastcall Write(const void *Buffer,int Count);
__property Size;
__property Position;
};
//---------------------------------------------------------------------------
#endif
class tTVPIStreamAdapter;
struct IStream;
//---------------------------------------------------------------------------
// IStream creator
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(IStream *, TVPCreateIStream, (const ttstr &name, tjs_uint32 flags));
TJS_EXP_FUNC_DEF(IStream *, TVPCreateIStream, (tTJSBinaryStream *));
//---------------------------------------------------------------------------
#if 0
//---------------------------------------------------------------------------
// tTVPBinaryStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides tTJSBinaryStream adapter for IStream
*/
class tTVPBinaryStreamAdapter : public tTJSBinaryStream
{
typedef tTJSBinaryStream inherited;
private:
IStream *Stream;
public:
tTVPBinaryStreamAdapter(IStream *ref);
/*
the stream passed by argument here is freed by this instance'
destruction.
*/
~tTVPBinaryStreamAdapter();
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
tjs_uint64 TJS_INTF_METHOD GetSize();
void TJS_INTF_METHOD SetEndOfStorage();
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPBinaryStreamAdapter creator
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(tTJSBinaryStream *, TVPCreateBinaryStreamAdapter, (IStream *refstream));
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
// tTVPPluginHolder
//---------------------------------------------------------------------------
/*
tTVPPluginHolder holds plug-in. if the plug-in is not a local storage,
plug-in is to be extracted to temporary directory and be held until
the program done using it.
*/
class tTVPPluginHolder
{
private:
ttstr LocalName;
tTVPLocalTempStorageHolder * LocalTempStorageHolder;
public:
tTVPPluginHolder(const ttstr &aname);
~tTVPPluginHolder();
const ttstr & GetLocalName() const;
};
//---------------------------------------------------------------------------
void TVPListDir(const std::string &folder, std::function cb);
bool TVPSaveStreamToFile(tTJSBinaryStream *st, tjs_uint64 offset, tjs_uint64 size, ttstr outpath);
#endif
================================================
FILE: src/core/base/win32/SusieArchive.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Archive eXtractor Susie plug-in support
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include
#include "StorageImpl.h"
#include "SusieArchive.h"
#include "GraphicsLoaderImpl.h"
#include "DebugIntf.h"
#include "XP3Archive.h"
#include "MsgIntf.h"
#include "SysInitIntf.h"
#include
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPSusieArchivePlugin
//---------------------------------------------------------------------------
#pragma pack(push, 1)
struct tTVPSusieFileInfo
{
unsigned char method[8]; // compression method
unsigned long position; // position in archive file
unsigned long compsize; // compressed size
unsigned long filesize; // original size
time_t timestamp; // update timestamp
char path[200]; // relative path
char filename[200]; // filename
unsigned long crc; // CRC
};
#pragma pack(pop)
struct tTVPSusieFileRecord
{
ttstr Name;
unsigned long Position;
unsigned long Size;
bool operator < (const tTVPSusieFileRecord & rhs) const
{
return this->Name < rhs.Name;
}
};
//---------------------------------------------------------------------------
// tTVPSusiePlugin is defined in GraphicLoaderImpl.h
class tTVPSusieArchivePlugin : public tTVPSusiePlugin
{
tTJSCriticalSection CS;
tjs_int LockCount;
public:
tTVPSusieArchivePlugin(HINSTANCE inst);
~tTVPSusieArchivePlugin();
void Lock();
void Unlock();
bool CanRelease() { return LockCount <= 0; }
bool CheckSupported(tTVPLocalFileStream * stream, std::string localname);
void GetFileList(std::wstring localname, std::vector &dest);
tTJSBinaryStream * CreateStream(std::wstring localname,
unsigned long pos, unsigned long sise);
tTJSCriticalSection & GetCS() { return CS; }
};
//---------------------------------------------------------------------------
tTVPSusieArchivePlugin::tTVPSusieArchivePlugin(HINSTANCE inst) :
tTVPSusiePlugin(inst, "00AM")
{
LockCount = 0;
}
//---------------------------------------------------------------------------
tTVPSusieArchivePlugin::~tTVPSusieArchivePlugin()
{
}
//---------------------------------------------------------------------------
void tTVPSusieArchivePlugin::Lock()
{
tTJSCriticalSectionHolder holder(CS);
LockCount++;
}
//---------------------------------------------------------------------------
void tTVPSusieArchivePlugin::Unlock()
{
tTJSCriticalSectionHolder holder(CS);
LockCount--;
}
//---------------------------------------------------------------------------
bool tTVPSusieArchivePlugin::CheckSupported(tTVPLocalFileStream * stream,
std::string localname)
{
int res = IsSupported(const_cast(localname.c_str()), (DWORD)stream->GetHandle());
return 0!=res;
}
//---------------------------------------------------------------------------
void tTVPSusieArchivePlugin::GetFileList(std::wstring localname,
std::vector &dest)
{
// retrieve file list
TVPAddLog( TVPFormatMessage(TVPInfoListingFiles, ttstr(localname.c_str()) ) );
HLOCAL infohandle = NULL;
int errorcode = 0xff&GetArchiveInfo(const_cast(ttstr(localname).AsNarrowStdString().c_str()), 0, 0x00, &infohandle);
if(infohandle == NULL)
{
TVPThrowExceptionMessage(TVPSusiePluginError,
ttstr(TJS_W("tTVPSusieArchivePlugin::GetArchiveInfo failed, errorcode = ")) +
ttstr((tjs_int)errorcode));
}
else
{
if(errorcode != 0)
{
TVPAddLog(TJS_W("Warning : invalid errorcode ") + ttstr((tjs_int)errorcode) +
TJS_W(" was returned from tTVPSusieArchivePlugin::GetArchiveInfo, ")
TJS_W("continuing anyway."));
}
}
const tTVPSusieFileInfo *info = (const tTVPSusieFileInfo*)LocalLock(infohandle);
if(info == NULL)
{
TVPThrowExceptionMessage(TVPSusiePluginError,
ttstr(TJS_W("tTVPSusieArchivePlugin::GetArchiveInfo failed : invalid memory block.")));
}
try
{
while(info->method[0])
{
if(info->filename[0])
{
char buf[401];
TJS_nstrcpy(buf, info->path);
TJS_nstrcat(buf, "/");
TJS_nstrcat(buf, info->filename);
tTVPSusieFileRecord record;
record.Name = buf;
tTVPArchive::NormalizeInArchiveStorageName(record.Name);
record.Position = info->position;
record.Size = info->filesize;
dest.push_back(record);
}
info++;
}
// sort item vector by its name (required for tTVPArchive specification)
std::stable_sort(dest.begin(), dest.end());
}
catch(...)
{
LocalUnlock(infohandle);
LocalFree(infohandle);
throw;
}
LocalUnlock(infohandle);
LocalFree(infohandle);
TVPAddLog(TJS_W("(info) ") + ttstr((tjs_int)dest.size()) + TJS_W(" files found."));
}
//---------------------------------------------------------------------------
tTJSBinaryStream * tTVPSusieArchivePlugin::CreateStream(std::wstring localname,
unsigned long pos, unsigned long size)
{
HLOCAL memhandle = NULL;
int errorcode = 0xff & GetFile(const_cast(ttstr(localname).AsNarrowStdString().c_str()), pos, (LPSTR)(void*)&memhandle,
0x0100, (FARPROC)ProgressCallback, 0);
if(errorcode || memhandle == NULL)
{
TVPThrowExceptionMessage(TVPSusiePluginError,
ttstr(TJS_W("tTVPSusieArchivePlugin::GetFile failed, errorcode = ")) +
ttstr((tjs_int)errorcode));
}
tTVPMemoryStream *memstream = new tTVPMemoryStream;
void *memblock = NULL;
try
{
memblock = LocalLock(memhandle);
if(memblock == NULL)
{
TVPThrowExceptionMessage(TVPSusiePluginError,
ttstr(TJS_W("tTVPSusieArchivePlugin::GetFile failed : invalid memory block.")));
}
// write to on-memory stream
memstream->WriteBuffer(memblock, size);
memstream->SetPosition(0);
}
catch(...)
{
if(memblock) LocalUnlock(memhandle);
LocalFree(memhandle);
delete memstream;
throw;
}
if(memblock) LocalUnlock(memhandle);
LocalFree(memhandle);
return memstream;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
static std::vector TVPSusiePluginVector;
static void TVPDestroySusiePluginList()
{
std::vector::iterator i;
for(i = TVPSusiePluginVector.begin(); i != TVPSusiePluginVector.end(); i++)
{
delete *i;
}
}
static tTVPAtExit TVPDestroySusiePluginListAtExit
(TVP_ATEXIT_PRI_CLEANUP, TVPDestroySusiePluginList);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPLoadArchiveSPI/TVPUnloadArchiveSPI : load/unload archive spi
//---------------------------------------------------------------------------
void TVPLoadArchiveSPI(HINSTANCE inst)
{
// load specified Susie plug-in.
std::vector::iterator i;
for(i = TVPSusiePluginVector.begin(); i != TVPSusiePluginVector.end(); i++)
{
if((*i)->GetModuleInstance() == inst)
TVPThrowInternalError;
}
tTVPSusieArchivePlugin *spi = new tTVPSusieArchivePlugin(inst);
TVPSusiePluginVector.push_back(spi);
}
//---------------------------------------------------------------------------
void TVPUnloadArchiveSPI(HINSTANCE inst)
{
// unload specified Susie plug-in from system.
std::vector::iterator i;
for(i = TVPSusiePluginVector.begin(); i != TVPSusiePluginVector.end(); i++)
{
if((*i)->GetModuleInstance() == inst) break;
}
if(i == TVPSusiePluginVector.end())
TVPThrowExceptionMessage(TVPNotLoadedPlugin);
if(!(*i)->CanRelease())
TVPThrowExceptionMessage(TVPCannotReleasePlugin);
for(i = TVPSusiePluginVector.begin(); i != TVPSusiePluginVector.end();)
{
if((*i)->GetModuleInstance() == inst)
i = TVPSusiePluginVector.erase(i);
else
i++;
}
delete *i;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPCheckSusieSupport : checks which plugin supports specified archive
//---------------------------------------------------------------------------
tTVPSusieArchivePlugin * TVPCheckSusieSupport(const ttstr &name, std::wstring &a_localname)
{
if(TVPSusiePluginVector.size() == 0) return NULL;
ttstr localname = TVPGetLocallyAccessibleName(name);
tTVPLocalFileStream stream(name, localname, TJS_BS_READ);
if(localname.GetLen() == 0) return NULL; // only local filesystem stream is supported
a_localname = localname.AsStdString();
std::vector::iterator i;
for(i = TVPSusiePluginVector.end() - 1; i >= TVPSusiePluginVector.begin(); i--)
{
stream.SetPosition(0);
if((*i)->CheckSupported(&stream, localname.AsNarrowStdString()))
return *i;
}
return NULL;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPSusieArchive
//---------------------------------------------------------------------------
class tTVPSusieArchive : public tTVPArchive
{
tTVPSusieArchivePlugin *Plugin;
std::wstring LocalName;
std::vector FileRecords;
public:
tTVPSusieArchive(tTVPSusieArchivePlugin *plugin, const ttstr & name,
std::wstring localname);
~tTVPSusieArchive();
tjs_uint GetCount();
ttstr GetName(tjs_uint idx);
tTJSBinaryStream * CreateStreamByIndex(tjs_uint idx);
};
//---------------------------------------------------------------------------
tTVPSusieArchive::tTVPSusieArchive(tTVPSusieArchivePlugin *plugin,
const ttstr &name, std::wstring localname) : tTVPArchive(name)
{
LocalName = localname;
Plugin = plugin;
tTJSCriticalSectionHolder(Plugin->GetCS());
Plugin->Lock();
Plugin->GetFileList(LocalName, FileRecords);
}
//---------------------------------------------------------------------------
tTVPSusieArchive::~tTVPSusieArchive()
{
Plugin->Unlock();
}
//---------------------------------------------------------------------------
tjs_uint tTVPSusieArchive::GetCount()
{
return (tjs_uint)FileRecords.size();
}
//---------------------------------------------------------------------------
ttstr tTVPSusieArchive::GetName(tjs_uint idx)
{
return FileRecords[idx].Name;
}
//---------------------------------------------------------------------------
tTJSBinaryStream * tTVPSusieArchive::CreateStreamByIndex(tjs_uint idx)
{
tTJSCriticalSectionHolder(Plugin->GetCS());
return Plugin->CreateStream(LocalName, FileRecords[idx].Position,
FileRecords[idx].Size);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// TVPOpenSusieArchive
//---------------------------------------------------------------------------
tTVPArchive * TVPOpenSusieArchive(const ttstr & name)
{
std::wstring localname;
tTVPSusieArchivePlugin *plugin = TVPCheckSusieSupport(name, localname);
if(plugin)
{
return new tTVPSusieArchive(plugin, name, localname);
}
else
{
return NULL;
}
}
//---------------------------------------------------------------------------
================================================
FILE: src/core/base/win32/SusieArchive.h
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Archive eXtractor Susie plug-in support
//---------------------------------------------------------------------------
#ifndef SusieArchiveH
#define SusieArchiveH
//---------------------------------------------------------------------------
#include "StorageIntf.h"
void TVPLoadArchiveSPI(HINSTANCE inst);
void TVPUnloadArchiveSPI(HINSTANCE inst);
class tTVPArchive;
tTVPArchive * TVPOpenSusieArchive(const ttstr & name);
#endif
================================================
FILE: src/core/base/win32/SysInitImpl.cpp
================================================
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// System Initialization and Uninitialization
//---------------------------------------------------------------------------
#include "tjsCommHead.h"
#include "FilePathUtil.h"
// #include
// #include
// #include