*** empty log message ***
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.1 2006-10-24 06:03:14 bacon Exp $
|
||||
* $Id: Awk.java,v 1.2 2006-11-21 15:06:50 bacon Exp $
|
||||
*/
|
||||
|
||||
package ase.test.awk;
|
||||
@ -11,6 +11,8 @@ public class Awk extends ase.awk.Awk
|
||||
private FileReader insrc;
|
||||
private FileWriter outsrc;
|
||||
|
||||
private InputStreamReader console_in = null;
|
||||
|
||||
public Awk () throws ase.awk.Exception
|
||||
{
|
||||
super ();
|
||||
@ -20,13 +22,13 @@ public class Awk extends ase.awk.Awk
|
||||
{
|
||||
if (mode == SOURCE_READ)
|
||||
{
|
||||
try { insrc = new FileReader ("test.awk"); }
|
||||
try { insrc = new FileReader ("t.awk"); }
|
||||
catch (IOException e) { return -1; }
|
||||
return 1;
|
||||
}
|
||||
else if (mode == SOURCE_WRITE)
|
||||
{
|
||||
try { outsrc = new FileWriter ("test.out"); }
|
||||
try { outsrc = new FileWriter ("t.out"); }
|
||||
catch (IOException e) { return -1; }
|
||||
return 1;
|
||||
}
|
||||
@ -65,39 +67,107 @@ public class Awk extends ase.awk.Awk
|
||||
return len;
|
||||
}
|
||||
|
||||
protected int open_console ()
|
||||
protected int open_console (ase.awk.Extio extio)
|
||||
{
|
||||
System.err.println ("[open_console called....]");
|
||||
return 1;
|
||||
System.err.println ("[open_console called.... name: " + extio.getName() + " mode: " + extio.getMode());
|
||||
|
||||
int mode = extio.getMode ();
|
||||
|
||||
if (mode == ase.awk.Extio.MODE_CONSOLE_READ)
|
||||
{
|
||||
InputStreamReader isr =
|
||||
new InputStreamReader (System.in);
|
||||
extio.setHandle (isr);
|
||||
return 1;
|
||||
}
|
||||
else if (mode == ase.awk.Extio.MODE_CONSOLE_WRITE)
|
||||
{
|
||||
OutputStreamWriter osw =
|
||||
new OutputStreamWriter (System.out);
|
||||
extio.setHandle (osw);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int close_console ()
|
||||
protected int close_console (ase.awk.Extio extio)
|
||||
{
|
||||
System.err.println ("[close_console called....]");
|
||||
return 1;
|
||||
System.err.println ("[close_console called.... name: " + extio.getName() + " mode: " + extio.getMode());
|
||||
|
||||
int mode = extio.getMode ();
|
||||
|
||||
if (mode == ase.awk.Extio.MODE_CONSOLE_READ)
|
||||
{
|
||||
InputStreamReader isr = (InputStreamReader)extio.getHandle ();
|
||||
try { isr.close (); }
|
||||
catch (IOException e) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
else if (mode == ase.awk.Extio.MODE_CONSOLE_WRITE)
|
||||
{
|
||||
OutputStreamWriter osw = (OutputStreamWriter)extio.getHandle ();
|
||||
//try { osw.close (); }
|
||||
//catch (IOException e) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int read_console (char[] buf, int len)
|
||||
protected int read_console (ase.awk.Extio extio, char[] buf, int len)
|
||||
{
|
||||
return 0;
|
||||
int mode = extio.getMode ();
|
||||
|
||||
if (mode == ase.awk.Extio.MODE_CONSOLE_READ)
|
||||
{
|
||||
InputStreamReader isr = (InputStreamReader)extio.getHandle ();
|
||||
try
|
||||
{
|
||||
len = isr.read (buf, 0, len);
|
||||
if (len == -1) len = 0;
|
||||
}
|
||||
catch (IOException e) { System.out.println ("EXCEPTIN---"+e.getMessage());return -1; }
|
||||
|
||||
return len;
|
||||
}
|
||||
else if (mode == ase.awk.Extio.MODE_CONSOLE_WRITE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int write_console (char[] buf, int len)
|
||||
protected int write_console (ase.awk.Extio extio, char[] buf, int len)
|
||||
{
|
||||
System.out.print (new String (buf, 0, len));
|
||||
return len;
|
||||
int mode = extio.getMode ();
|
||||
|
||||
if (mode == ase.awk.Extio.MODE_CONSOLE_READ)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (mode == ase.awk.Extio.MODE_CONSOLE_WRITE)
|
||||
{
|
||||
OutputStreamWriter osw = (OutputStreamWriter)extio.getHandle ();
|
||||
try { osw.write (buf, 0, len); osw.flush (); }
|
||||
catch (IOException e) { return -1; }
|
||||
|
||||
return len;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected int next_console (char[] buf, int len)
|
||||
protected int next_console (ase.awk.Extio extio, char[] buf, int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int open_file (ase.awk.Extio extio)
|
||||
{
|
||||
System.out.print ("opening file [");
|
||||
//System.out.print (extio.name());
|
||||
System.out.println ("]");
|
||||
/*System.out.print ("opening file [");
|
||||
System.out.print (extio.getName());
|
||||
System.out.println ("]");*/
|
||||
|
||||
/*
|
||||
FileInputStream f = new FileInputStream (extio.name());
|
||||
@ -106,24 +176,23 @@ public class Awk extends ase.awk.Awk
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
public int open_file (String name)
|
||||
public int close_file (ase.awk.Extio extio)
|
||||
{
|
||||
System.out.print ("opening file [");
|
||||
System.out.print (name);
|
||||
System.out.println ("]");
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
public int close_file (String name)
|
||||
{
|
||||
System.out.print ("closing file [");
|
||||
System.out.print (name);
|
||||
System.out.println ("]");
|
||||
/*System.out.print ("closing file [");
|
||||
System.out.print (extio.getName());
|
||||
System.out.println ("]");*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int read_file (ase.awk.Extio extio, char[] buf, int len)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
protected int write_file (ase.awk.Extio extio, char[] buf, int len)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Awk awk = null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.120 2006-11-19 15:33:40 bacon Exp $
|
||||
* $Id: awk.c,v 1.121 2006-11-21 15:06:51 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/awk.h>
|
||||
@ -271,9 +271,9 @@ static ase_ssize_t process_extio_pipe (
|
||||
FILE* handle;
|
||||
const ase_char_t* mode;
|
||||
|
||||
if (epa->mode == ASE_AWK_IO_PIPE_READ)
|
||||
if (epa->mode == ASE_AWK_EXTIO_PIPE_READ)
|
||||
mode = ASE_T("r");
|
||||
else if (epa->mode == ASE_AWK_IO_PIPE_WRITE)
|
||||
else if (epa->mode == ASE_AWK_EXTIO_PIPE_WRITE)
|
||||
mode = ASE_T("w");
|
||||
else return -1; /* TODO: any way to set the error number? */
|
||||
__awk_dprintf (ASE_T("opending %s of type %d (pipe)\n"), epa->name, epa->type);
|
||||
@ -311,7 +311,7 @@ static ase_ssize_t process_extio_pipe (
|
||||
|
||||
case ASE_AWK_IO_FLUSH:
|
||||
{
|
||||
if (epa->mode == ASE_AWK_IO_PIPE_READ) return -1;
|
||||
if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) return -1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@ -336,11 +336,11 @@ static ase_ssize_t process_extio_file (
|
||||
FILE* handle;
|
||||
const ase_char_t* mode;
|
||||
|
||||
if (epa->mode == ASE_AWK_IO_FILE_READ)
|
||||
if (epa->mode == ASE_AWK_EXTIO_FILE_READ)
|
||||
mode = ASE_T("r");
|
||||
else if (epa->mode == ASE_AWK_IO_FILE_WRITE)
|
||||
else if (epa->mode == ASE_AWK_EXTIO_FILE_WRITE)
|
||||
mode = ASE_T("w");
|
||||
else if (epa->mode == ASE_AWK_IO_FILE_APPEND)
|
||||
else if (epa->mode == ASE_AWK_EXTIO_FILE_APPEND)
|
||||
mode = ASE_T("a");
|
||||
else return -1; /* TODO: any way to set the error number? */
|
||||
|
||||
@ -506,7 +506,7 @@ static int open_extio_console (ase_awk_extio_t* epa)
|
||||
|
||||
__awk_dprintf (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type);
|
||||
|
||||
if (epa->mode == ASE_AWK_IO_CONSOLE_READ)
|
||||
if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ)
|
||||
{
|
||||
if (infiles[infile_no] == ASE_NULL)
|
||||
{
|
||||
@ -546,7 +546,7 @@ static int open_extio_console (ase_awk_extio_t* epa)
|
||||
infile_no++;
|
||||
return 1;
|
||||
}
|
||||
else if (epa->mode == ASE_AWK_IO_CONSOLE_WRITE)
|
||||
else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE)
|
||||
{
|
||||
__awk_dprintf (ASE_T(" console(w) - <standard output>\n"));
|
||||
/* TODO: does output console has a name??? */
|
||||
|
@ -19,8 +19,14 @@ all: awk
|
||||
awk: awk.obj
|
||||
$(LD) $(LDFLAGS) $(STARTUP) awk.obj,$@.exe,,$(LIBS),,
|
||||
|
||||
java:
|
||||
javac -classpath ../../.. Awk.java
|
||||
|
||||
jrun:
|
||||
java -Xms1m -Xmx2m -classpath ../../.. ase.test.awk.Awk
|
||||
|
||||
clean:
|
||||
del $(OBJS) *.obj $(OUT)
|
||||
del $(OBJS) *.obj *.class awk.exe
|
||||
|
||||
.SUFFIXES: .c .obj
|
||||
.c.obj:
|
||||
|
Reference in New Issue
Block a user