[Ttssh2-commit] [3327] サンプルTTX追加

svnno****@sourc***** svnno****@sourc*****
2009年 4月 18日 (土) 20:30:54 JST


Revision: 3327
          http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3327
Author:   doda
Date:     2009-04-18 20:30:54 +0900 (Sat, 18 Apr 2009)

Log Message:
-----------
サンプルTTX追加
・TTXOutputBuffering -- データ送信をバッファリングし、擬似的にline at a timeモードを実現する。

Modified Paths:
--------------
    trunk/TTXSamples/TTXSamples.sln

Added Paths:
-----------
    trunk/TTXSamples/TTXOutputBuffering/
    trunk/TTXSamples/TTXOutputBuffering/ReadMe-ja.txt
    trunk/TTXSamples/TTXOutputBuffering/ReadMe.txt
    trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.c
    trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.vcproj


-------------- next part --------------

Property changes on: trunk/TTXSamples/TTXOutputBuffering
___________________________________________________________________
Added: svn:ignore
   + [Dd]ebug
[Rr]elease
*.ncb
*.suo
*.aps
*.vcproj.*.user


Added: trunk/TTXSamples/TTXOutputBuffering/ReadMe-ja.txt
===================================================================
--- trunk/TTXSamples/TTXOutputBuffering/ReadMe-ja.txt	                        (rev 0)
+++ trunk/TTXSamples/TTXOutputBuffering/ReadMe-ja.txt	2009-04-18 11:30:54 UTC (rev 3327)
@@ -0,0 +1,15 @@
+TTXOutputBuffering -- ƒf[ƒ^‘—M‚̍s–ˆ‚̃oƒbƒtƒ@ƒŠƒ“ƒO
+
+‹@”\:
+  ƒf[ƒ^‘—M‚ðƒoƒbƒtƒ@ƒŠƒ“ƒO‚µAs’PˆÊ‚Ńf[ƒ^‘—M‚ðs‚¤‚悤‚É‚µ‚Ü‚·B
+
+‰ðà:
+  Œ»Ý‚ÌTera Term‚ł́Aí‚É"ˆê•¶Žš–ˆ‚É‘—M(character at a time)"‚µ‚Ä‚¨‚èA
+  "s–ˆ‚É‘—M(line at a time)"ƒ‚[ƒh‚ɂ͑Ήž‚µ‚Ä‚¢‚Ü‚¹‚ñB
+  ‚±‚ÌTTX‚ð“ü‚ê‚é‚ƁAƒf[ƒ^‘—M‚ðƒoƒbƒtƒ@ƒŠƒ“ƒO‚·‚鎖‚É‚æ‚Á‚Ä‹[Ž—“I‚É
+  line at a timeƒ‚[ƒh‚ðŽÀŒ»‚µ‚Ü‚·B
+
+ƒoƒO:
+  í‚ɍs–ˆ‚É‘—M‚·‚éB
+  ‚»‚Ì‘¼‚¢‚Á‚Ï‚¢‚ ‚èB
+  ŽŽ‚µ‚ɍì‚Á‚Ä‚Ý‚½‚Æ‚¢‚¤ƒŒƒxƒ‹‚ŁAí—p‚É‚Í‘Ï‚¦‚È‚¢‚Å‚µ‚傤B

Added: trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.c
===================================================================
--- trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.c	                        (rev 0)
+++ trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.c	2009-04-18 11:30:54 UTC (rev 3327)
@@ -0,0 +1,149 @@
+#include "teraterm.h"
+#include "tttypes.h"
+#include "ttplugin.h"
+#include "ttlib.h"
+//#include "tt_res.h"
+
+#include "compat_w95.h"
+
+#define ORDER 4000
+#define BUFF_SIZE 4096
+
+static HANDLE hInst;
+
+typedef struct {
+	PTTSet ts;
+	PComVar cv;
+	Tsend origPsend;
+	char buff[BUFF_SIZE];
+	int buff_used;
+} TInstVar;
+
+typedef TInstVar FAR * PTInstVar;
+PTInstVar pvar;
+static TInstVar InstVar;
+
+//
+//  TTXInit -- ‹N“®Žžˆ—
+//
+static void PASCAL FAR TTXInit(PTTSet ts, PComVar cv) {
+	pvar->ts = ts;
+	pvar->cv = cv;
+	pvar->origPsend = NULL;
+	pvar->buff_used = 0;
+}
+
+//
+//  TTXSend -- ƒL[“ü—͏ˆ—
+//
+static int PASCAL FAR TTXsend(SOCKET s, const char FAR *buf, int len, int flags) {
+	int i, wlen;
+
+	if (len > 0) {
+		for (i=0; i<len; i++) {
+			switch (buf[i]) {
+			case '\n':
+				if (pvar->buff_used < BUFF_SIZE)
+					pvar->buff[pvar->buff_used++] = '\n';
+				wlen = pvar->origPsend(s, pvar->buff, pvar->buff_used, flags);
+				if (wlen > 0 && wlen < pvar->buff_used) {
+					pvar->buff_used -= wlen;
+					memmove(pvar->buff, &(pvar->buff[wlen]), pvar->buff_used);
+				}
+				else {
+					pvar->buff_used = 0;
+				}
+				break;
+			case 0x08: // ^H
+				if (pvar->buff_used > 0)
+					pvar->buff_used--;
+				break;
+			case 0x15: // ^U
+				pvar->buff_used = 0;
+				break;
+			default:
+				if (pvar->buff_used < BUFF_SIZE)
+					pvar->buff[pvar->buff_used++] = buf[i];
+				break;
+			}
+		}
+	}
+
+	return len;
+}
+
+//
+// TTXOpen -- ƒZƒbƒVƒ‡ƒ“ŠJŽnˆ—
+//	Psend ‚ðƒtƒbƒN‚·‚éB
+//
+static void PASCAL FAR TTXOpenTCP(TTXSockHooks FAR * hooks) {
+	pvar->origPsend = *hooks->Psend;
+	*hooks->Psend = TTXsend;
+	pvar->buff_used = 0;
+}
+
+//
+// TTXCloseTCP -- ƒZƒbƒVƒ‡ƒ“I—¹Žžˆ—
+//	Psend ‚̃tƒbƒN‚ð‰ðœ‚·‚éB
+//
+static void PASCAL FAR TTXCloseTCP(TTXSockHooks FAR * hooks) {
+	if (pvar->origPsend) {
+		*hooks->Psend = pvar->origPsend;
+	}
+}
+
+static TTXExports Exports = {
+	sizeof(TTXExports),
+	ORDER,
+
+	TTXInit,
+	NULL, // TTXGetUIHooks,
+	NULL, // TTXGetSetupHooks,
+	TTXOpenTCP,
+	TTXCloseTCP,
+	NULL, // TTXSetWinSize,
+	NULL, // TTXModifyMenu,
+	NULL, // TTXModifyPopupMenu,
+	NULL, // TTXProcessCommand,
+	NULL, // TTXEnd,
+	NULL, // TTXSetCommandLine,
+	NULL, // TTXOpenFile,
+	NULL, // TTXCloseFile
+};
+
+BOOL __declspec(dllexport) PASCAL FAR TTXBind(WORD Version, TTXExports FAR * exports) {
+	int size = sizeof(Exports) - sizeof(exports->size);
+	/* do version checking if necessary */
+	/* if (Version!=TTVERSION) return FALSE; */
+
+	if (size > exports->size) {
+		size = exports->size;
+	}
+	memcpy((char FAR *)exports + sizeof(exports->size),
+	       (char FAR *)&Exports + sizeof(exports->size), size);
+	return TRUE;
+}
+
+BOOL WINAPI DllMain(HANDLE hInstance,
+		    ULONG ul_reason_for_call,
+		    LPVOID lpReserved)
+{
+	switch( ul_reason_for_call ) {
+	  case DLL_THREAD_ATTACH:
+		/* do thread initialization */
+		break;
+	  case DLL_THREAD_DETACH:
+		/* do thread cleanup */
+		break;
+	  case DLL_PROCESS_ATTACH:
+		/* do process initialization */
+		DoCover_IsDebuggerPresent();
+		hInst = hInstance;
+		pvar = &InstVar;
+		break;
+	  case DLL_PROCESS_DETACH:
+		/* do process cleanup */
+		break;
+	}
+	return TRUE;
+}

Added: trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.vcproj
===================================================================
--- trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.vcproj	                        (rev 0)
+++ trunk/TTXSamples/TTXOutputBuffering/TTXOutputBuffering.vcproj	2009-04-18 11:30:54 UTC (rev 3327)
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="TTXOutputBuffering"
+	ProjectGUID="{80BE71D1-BEA3-4A5D-8F13-362D6364892D}"
+	RootNamespace="TTXOutputBuffering"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\teraterm\common;..\..\teraterm\teraterm"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\..\teraterm\common;..\..\teraterm\teraterm"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="TTXOutputBuffering.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="ReadMe"
+			>
+			<File
+				RelativePath="ReadMe-ja.txt"
+				>
+			</File>
+			<File
+				RelativePath="ReadMe.txt"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Modified: trunk/TTXSamples/TTXSamples.sln
===================================================================
--- trunk/TTXSamples/TTXSamples.sln	2009-04-18 05:31:48 UTC (rev 3326)
+++ trunk/TTXSamples/TTXSamples.sln	2009-04-18 11:30:54 UTC (rev 3327)
@@ -30,6 +30,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXShowCommandLine", "TTXShowCommandLine\TTXShowCommandLine.vcproj", "{80ED9927-27F9-473A-802C-FB10DEB5ECC6}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTXOutputBuffering", "TTXOutputBuffering\TTXOutputBuffering.vcproj", "{80BE71D1-BEA3-4A5D-8F13-362D6364892D}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -96,6 +98,10 @@
 		{80ED9927-27F9-473A-802C-FB10DEB5ECC6}.Debug|Win32.Build.0 = Debug|Win32
 		{80ED9927-27F9-473A-802C-FB10DEB5ECC6}.Release|Win32.ActiveCfg = Release|Win32
 		{80ED9927-27F9-473A-802C-FB10DEB5ECC6}.Release|Win32.Build.0 = Release|Win32
+		{80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Debug|Win32.ActiveCfg = Debug|Win32
+		{80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Debug|Win32.Build.0 = Debug|Win32
+		{80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Release|Win32.ActiveCfg = Release|Win32
+		{80BE71D1-BEA3-4A5D-8F13-362D6364892D}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE



Ttssh2-commit メーリングリストの案内