Recovered from cvs revision 2007-07-19 14:35:00
This commit is contained in:
parent
5c7341a6d3
commit
3a52d14974
131
ase/net/Awk.cpp
131
ase/net/Awk.cpp
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.6 2007/07/17 09:46:19 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.7 2007/07/18 11:12:34 bacon Exp $
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
@ -144,12 +144,22 @@ namespace ASE
|
||||
|
||||
ssize_t readPipe (Pipe& io, char_t* buf, size_t len)
|
||||
{
|
||||
return 0;
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
|
||||
int n = wrapper->FireReadPipe ((ASE::Net::Awk::Pipe^)gh.Target, b, len);
|
||||
for (int i = 0; i < n; i++) buf[i] = b[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t writePipe (Pipe& io, char_t* buf, size_t len)
|
||||
{
|
||||
return 0;
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
|
||||
for (int i = 0; i < len; i++) b[i] = buf[i];
|
||||
return wrapper->FireWritePipe ((ASE::Net::Awk::Pipe^)gh.Target, b, len);
|
||||
}
|
||||
|
||||
int flushPipe (Pipe& io)
|
||||
@ -183,14 +193,20 @@ namespace ASE
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
return wrapper->FireReadFile ((ASE::Net::Awk::File^)gh.Target);
|
||||
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
|
||||
int n = wrapper->FireReadFile ((ASE::Net::Awk::File^)gh.Target, b, len);
|
||||
for (int i = 0; i < n; i++) buf[i] = b[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t writeFile (File& io, char_t* buf, size_t len)
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
return wrapper->FireWriteFile ((ASE::Net::Awk::File^)gh.Target);
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
|
||||
for (int i = 0; i < len; i++) b[i] = buf[i];
|
||||
return wrapper->FireWriteFile ((ASE::Net::Awk::File^)gh.Target, b, len);
|
||||
}
|
||||
|
||||
int flushFile (File& io)
|
||||
@ -200,12 +216,58 @@ namespace ASE
|
||||
return wrapper->FireFlushFile ((ASE::Net::Awk::File^)gh.Target);
|
||||
}
|
||||
|
||||
int openConsole (Console& io) {return 0; }
|
||||
int closeConsole (Console& io) {return 0; }
|
||||
ssize_t readConsole (Console& io, char_t* buf, size_t len) {return 0; }
|
||||
ssize_t writeConsole (Console& io, char_t* buf, size_t len) {return 0; }
|
||||
int flushConsole (Console& io) {return 0; }
|
||||
int nextConsole (Console& io) {return 0; }
|
||||
int openConsole (Console& io)
|
||||
{
|
||||
ASE::Net::Awk::Console^ nio = gcnew ASE::Net::Awk::Console ();
|
||||
nio->Mode = (ASE::Net::Awk::Console::MODE)io.getMode();
|
||||
|
||||
GCHandle gh = GCHandle::Alloc (nio);
|
||||
io.setHandle (GCHandle::ToIntPtr(gh).ToPointer());
|
||||
|
||||
return wrapper->FireOpenConsole (nio);
|
||||
}
|
||||
|
||||
int closeConsole (Console& io)
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle ());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
int n = wrapper->FireCloseConsole ((ASE::Net::Awk::Console^)gh.Target);
|
||||
gh.Free ();
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t readConsole (Console& io, char_t* buf, size_t len)
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
|
||||
int n = wrapper->FireReadConsole ((ASE::Net::Awk::Console^)gh.Target, b, len);
|
||||
for (int i = 0; i < n; i++) buf[i] = b[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t writeConsole (Console& io, char_t* buf, size_t len)
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
cli::array<char_t>^ b = gcnew cli::array<char_t> (len);
|
||||
for (int i = 0; i < len; i++) b[i] = buf[i];
|
||||
return wrapper->FireWriteConsole ((ASE::Net::Awk::Console^)gh.Target, b, len);
|
||||
}
|
||||
|
||||
int flushConsole (Console& io)
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
return wrapper->FireFlushConsole ((ASE::Net::Awk::Console^)gh.Target);
|
||||
}
|
||||
|
||||
int nextConsole (Console& io)
|
||||
{
|
||||
IntPtr ip ((void*)io.getHandle());
|
||||
GCHandle gh = GCHandle::FromIntPtr (ip);
|
||||
return wrapper->FireNextConsole ((ASE::Net::Awk::Console^)gh.Target);
|
||||
}
|
||||
|
||||
// primitive operations
|
||||
void* allocMem (size_t n) { return ::malloc (n); }
|
||||
@ -289,7 +351,7 @@ namespace ASE
|
||||
|
||||
bool Awk::DeleteFunction (System::String^ name)
|
||||
{
|
||||
pin_ptr<const wchar_t> nptr = PtrToStringChars(name);
|
||||
cli::pin_ptr<const wchar_t> nptr = PtrToStringChars(name);
|
||||
return awk->deleteFunction (nptr) == 0;
|
||||
}
|
||||
|
||||
@ -306,15 +368,13 @@ namespace ASE
|
||||
{
|
||||
return CloseFileHandler (file);
|
||||
}
|
||||
int Awk::FireReadFile (File^ file)
|
||||
int Awk::FireReadFile (File^ file, cli::array<char_t>^ buf, int len)
|
||||
{
|
||||
int n = ReadFileHandler (file);
|
||||
return n;
|
||||
return ReadFileHandler (file, buf, len);
|
||||
}
|
||||
int Awk::FireWriteFile (File^ file)
|
||||
int Awk::FireWriteFile (File^ file, cli::array<char_t>^ buf, int len)
|
||||
{
|
||||
int n = WriteFileHandler (file);
|
||||
return n;
|
||||
return WriteFileHandler (file, buf, len);
|
||||
}
|
||||
int Awk::FireFlushFile (File^ file)
|
||||
{
|
||||
@ -329,21 +389,44 @@ namespace ASE
|
||||
{
|
||||
return ClosePipeHandler (pipe);
|
||||
}
|
||||
int Awk::FireReadPipe (Pipe^ pipe)
|
||||
int Awk::FireReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
|
||||
{
|
||||
int n = ReadPipeHandler (pipe);
|
||||
return n;
|
||||
return ReadPipeHandler (pipe, buf, len);
|
||||
}
|
||||
int Awk::FireWritePipe (Pipe^ pipe)
|
||||
int Awk::FireWritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
|
||||
{
|
||||
int n = WritePipeHandler (pipe);
|
||||
return n;
|
||||
return WritePipeHandler (pipe, buf, len);
|
||||
}
|
||||
int Awk::FireFlushPipe (Pipe^ pipe)
|
||||
{
|
||||
return FlushPipeHandler (pipe);
|
||||
}
|
||||
|
||||
|
||||
int Awk::FireOpenConsole (Console^ console)
|
||||
{
|
||||
return OpenConsoleHandler (console);
|
||||
}
|
||||
int Awk::FireCloseConsole (Console^ console)
|
||||
{
|
||||
return CloseConsoleHandler (console);
|
||||
}
|
||||
int Awk::FireReadConsole (Console^ console, cli::array<char_t>^ buf, int len)
|
||||
{
|
||||
return ReadConsoleHandler (console, buf, len);
|
||||
}
|
||||
int Awk::FireWriteConsole (Console^ console, cli::array<char_t>^ buf, int len)
|
||||
{
|
||||
return WriteConsoleHandler (console, buf, len);
|
||||
}
|
||||
int Awk::FireFlushConsole (Console^ console)
|
||||
{
|
||||
return FlushConsoleHandler (console);
|
||||
}
|
||||
int Awk::FireNextConsole (Console^ console)
|
||||
{
|
||||
return NextConsoleHandler (console);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.4 2007/07/17 09:46:19 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.5 2007/07/18 11:12:34 bacon Exp $
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -111,6 +111,8 @@ namespace ASE
|
||||
MODE^ mode;
|
||||
};
|
||||
|
||||
typedef ASE::Awk::char_t char_t;
|
||||
|
||||
Awk ();
|
||||
virtual ~Awk ();
|
||||
|
||||
@ -153,16 +155,23 @@ namespace ASE
|
||||
|
||||
delegate int OpenPipe (Pipe^ pipe);
|
||||
delegate int ClosePipe (Pipe^ pipe);
|
||||
delegate int ReadPipe (Pipe^ pipe);
|
||||
delegate int WritePipe (Pipe^ pipe);
|
||||
delegate int ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
|
||||
delegate int WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
|
||||
delegate int FlushPipe (Pipe^ pipe);
|
||||
|
||||
delegate int OpenFile (File^ file);
|
||||
delegate int CloseFile (File^ file);
|
||||
delegate int ReadFile (File^ file);
|
||||
delegate int WriteFile (File^ file);
|
||||
delegate int ReadFile (File^ file, cli::array<char_t>^ buf, int len);
|
||||
delegate int WriteFile (File^ file, cli::array<char_t>^ buf, int len);
|
||||
delegate int FlushFile (File^ file);
|
||||
|
||||
delegate int OpenConsole (Console^ console);
|
||||
delegate int CloseConsole (Console^ console);
|
||||
delegate int ReadConsole (Console^ console, cli::array<char_t>^ buf, int len);
|
||||
delegate int WriteConsole (Console^ console, cli::array<char_t>^ buf, int len);
|
||||
delegate int FlushConsole (Console^ console);
|
||||
delegate int NextConsole (Console^ console);
|
||||
|
||||
event OpenPipe^ OpenPipeHandler;
|
||||
event ClosePipe^ ClosePipeHandler;
|
||||
event ReadPipe^ ReadPipeHandler;
|
||||
@ -175,6 +184,13 @@ namespace ASE
|
||||
event WriteFile^ WriteFileHandler;
|
||||
event FlushFile^ FlushFileHandler;
|
||||
|
||||
event OpenConsole^ OpenConsoleHandler;
|
||||
event CloseConsole^ CloseConsoleHandler;
|
||||
event ReadConsole^ ReadConsoleHandler;
|
||||
event WriteConsole^ WriteConsoleHandler;
|
||||
event FlushConsole^ FlushConsoleHandler;
|
||||
event NextConsole^ NextConsoleHandler;
|
||||
|
||||
protected:
|
||||
ASE::Awk* awk;
|
||||
|
||||
@ -186,15 +202,22 @@ namespace ASE
|
||||
|
||||
int FireOpenFile (File^ file);
|
||||
int FireCloseFile (File^ file);
|
||||
int FireReadFile (File^ file);
|
||||
int FireWriteFile (File^ file);
|
||||
int FireReadFile (File^ file, cli::array<char_t>^ buf, int len);
|
||||
int FireWriteFile (File^ file, cli::array<char_t>^ buf, int len);
|
||||
int FireFlushFile (File^ file);
|
||||
|
||||
int FireOpenPipe (Pipe^ pipe);
|
||||
int FireClosePipe (Pipe^ pipe);
|
||||
int FireReadPipe (Pipe^ pipe);
|
||||
int FireWritePipe (Pipe^ pipe);
|
||||
int FireReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
|
||||
int FireWritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len);
|
||||
int FireFlushPipe (Pipe^ pipe);
|
||||
|
||||
int FireOpenConsole (Console^ console);
|
||||
int FireCloseConsole (Console^ console);
|
||||
int FireReadConsole (Console^ console, cli::array<char_t>^ buf, int len);
|
||||
int FireWriteConsole (Console^ console, cli::array<char_t>^ buf, int len);
|
||||
int FireFlushConsole (Console^ console);
|
||||
int FireNextConsole (Console^ console);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user