From 62a00b8e0007c3b004e180439053249124eb3918 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 22 Apr 2007 10:19:14 +0000 Subject: [PATCH] *** empty log message *** --- ase/test/cnt/Awk.cs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/ase/test/cnt/Awk.cs b/ase/test/cnt/Awk.cs index 2800e931..4e8963f1 100644 --- a/ase/test/cnt/Awk.cs +++ b/ase/test/cnt/Awk.cs @@ -1,5 +1,5 @@ /* - * $Id: Awk.cs,v 1.2 2007-04-22 08:40:29 bacon Exp $ + * $Id: Awk.cs,v 1.3 2007-04-22 10:19:14 bacon Exp $ */ using System; @@ -30,13 +30,16 @@ namespace ASETestCom public delegate object FunctionHandler (object[] args); private System.Collections.Hashtable funcTable; - + + char[] consoleInputBuffer = new char[1024]; + public Awk() { this.funcTable = new System.Collections.Hashtable(); this.awk = new ASECOM.Awk(); this.awk.UseLongLong = true; + //this.awk.UseCrlf = true; COM.IConnectionPointContainer icpc = (COM.IConnectionPointContainer)awk; @@ -341,7 +344,13 @@ namespace ASETestCom public virtual int OpenExtio(ASECOM.AwkExtio extio) { - if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_WRITE) + if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_READ) + { + if (this.consoleInputStream == null) return 0; + this.consoleInputReader = new StreamReader(this.consoleInputStream); + return 1; + } + else if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_WRITE) { if (this.consoleOutputStream == null) return 0; this.consoleOutputWriter = new StreamWriter(this.consoleOutputStream); @@ -353,7 +362,12 @@ namespace ASETestCom public virtual int CloseExtio(ASECOM.AwkExtio extio) { - if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_WRITE) + if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_READ) + { + this.consoleInputReader.Close(); + return 0; + } + else if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_WRITE) { this.consoleOutputWriter.Close(); return 0; @@ -364,7 +378,15 @@ namespace ASETestCom public virtual int ReadExtio(ASECOM.AwkExtio extio, ASECOM.Buffer buf) { - throw new Exception("The method or operation is not implemented."); + if (extio.Mode == ASECOM.AwkExtioMode.AWK_EXTIO_CONSOLE_READ) + { + int n = this.consoleInputReader.Read(consoleInputBuffer, 0, consoleInputBuffer.Length); + if (n == 0) return 0; + buf.Value = new string(consoleInputBuffer, 0, n); + return buf.Value.Length; + } + + return -1; } public virtual int WriteExtio(ASECOM.AwkExtio extio, ASECOM.Buffer buf)