qse/ase/awk/jni.c

638 lines
14 KiB
C
Raw Normal View History

2006-08-02 15:03:49 +00:00
/*
2006-10-24 04:10:12 +00:00
* $Id: jni.c,v 1.15 2006-10-24 04:10:12 bacon Exp $
2006-08-02 15:03:49 +00:00
*/
2006-10-24 04:10:12 +00:00
#include <ase/awk/jni.h>
#include <ase/awk/awk.h>
2006-10-12 14:36:25 +00:00
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
#include <wchar.h>
#include <stdio.h>
2006-08-02 15:03:49 +00:00
2006-10-24 04:10:12 +00:00
#define EXCEPTION_AWK "ase/awk/AwkException"
2006-08-06 08:16:03 +00:00
#define FIELD_AWK "__awk"
2006-10-13 10:18:39 +00:00
enum
{
SOURCE_READ = 1,
SOURCE_WRITE = 2
};
2006-10-24 04:10:12 +00:00
/* TODO: what if ase_char_t is ase_mchar_t??? */
2006-10-13 10:18:39 +00:00
2006-10-24 04:10:12 +00:00
static ase_ssize_t __read_source (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
static ase_ssize_t __write_source (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
static ase_ssize_t __process_extio_console (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
static ase_ssize_t __process_extio_file (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
2006-08-06 08:16:03 +00:00
typedef struct srcio_data_t srcio_data_t;
2006-10-13 10:18:39 +00:00
typedef struct runio_data_t runio_data_t;
2006-08-06 08:16:03 +00:00
struct srcio_data_t
{
JNIEnv* env;
jobject obj;
};
2006-10-13 10:18:39 +00:00
struct runio_data_t
{
JNIEnv* env;
jobject obj;
};
2006-10-24 04:10:12 +00:00
static void* __awk_malloc (ase_size_t n, void* custom_data)
2006-10-12 14:36:25 +00:00
{
return malloc (n);
}
2006-10-24 04:10:12 +00:00
static void* __awk_realloc (void* ptr, ase_size_t n, void* custom_data)
2006-10-12 14:36:25 +00:00
{
return realloc (ptr, n);
}
static void __awk_free (void* ptr, void* custom_data)
{
free (ptr);
}
2006-08-06 08:16:03 +00:00
2006-10-24 04:10:12 +00:00
JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
2006-08-06 08:16:03 +00:00
{
jclass class;
jfieldID fid;
jthrowable except;
2006-10-24 04:10:12 +00:00
ase_awk_t* awk;
ase_awk_syscas_t syscas;
2006-08-06 08:16:03 +00:00
int opt;
class = (*env)->GetObjectClass(env, obj);
2006-10-12 14:36:25 +00:00
memset (&syscas, 0, sizeof(syscas));
syscas.malloc = __awk_malloc;
syscas.realloc = __awk_realloc;
syscas.free = __awk_free;
syscas.is_upper = iswupper;
syscas.is_lower = iswlower;
syscas.is_alpha = iswalpha;
syscas.is_digit = iswdigit;
syscas.is_xdigit = iswxdigit;
syscas.is_alnum = iswalnum;
syscas.is_space = iswspace;
syscas.is_print = iswprint;
syscas.is_graph = iswgraph;
syscas.is_cntrl = iswcntrl;
syscas.is_punct = iswpunct;
syscas.to_upper = towupper;
syscas.to_lower = towlower;
syscas.memcpy = memcpy;
syscas.memset = memset;
2006-10-13 10:18:39 +00:00
#ifdef _WIN32
2006-10-12 14:36:25 +00:00
syscas.sprintf = _snwprintf;
syscas.dprintf = wprintf;
syscas.abort = abort;
2006-10-13 10:18:39 +00:00
#else
/* TODO: */
syscas.sprintf = XXXXX;
syscas.dprintf = XXXXX;
syscas.abort = abort;
#endif
2006-10-12 14:36:25 +00:00
2006-10-24 04:10:12 +00:00
awk = ase_awk_open (&syscas);
2006-08-06 08:16:03 +00:00
if (awk == NULL)
{
except = (*env)->FindClass (env, EXCEPTION_AWK);
if (except == 0) return;
(*env)->ThrowNew (env, except, "cannot create awk");
return;
}
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
if (fid == 0) return;
(*env)->SetLongField (env, obj, fid, (jlong)awk);
2006-10-24 04:10:12 +00:00
opt = ASE_AWK_EXPLICIT | ASE_AWK_UNIQUE | ASE_AWK_DBLSLASHES |
ASE_AWK_SHADING | ASE_AWK_IMPLICIT | ASE_AWK_SHIFT |
ASE_AWK_EXTIO | ASE_AWK_BLOCKLESS;
ase_awk_setopt (awk, opt);
2006-08-06 08:16:03 +00:00
2006-10-12 14:36:25 +00:00
printf ("__awk(native) done => %u, 0x%X\n", awk, awk);
2006-08-06 08:16:03 +00:00
}
2006-10-24 04:10:12 +00:00
JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj)
2006-08-02 15:03:49 +00:00
{
2006-08-06 08:16:03 +00:00
jclass class;
jfieldID fid;
class = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
if (fid == 0) return;
2006-10-24 04:10:12 +00:00
ase_awk_close ((ase_awk_t*) (*env)->GetLongField (env, obj, fid));
2006-08-06 08:16:03 +00:00
(*env)->SetLongField (env, obj, fid, (jlong)0);
2006-10-12 14:36:25 +00:00
printf ("close (native) done\n");
2006-08-02 15:03:49 +00:00
}
2006-10-24 04:10:12 +00:00
JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj)
2006-08-02 15:03:49 +00:00
{
2006-08-06 08:16:03 +00:00
jclass class;
jfieldID fid;
jthrowable except;
2006-10-24 04:10:12 +00:00
ase_awk_t* awk;
ase_awk_srcios_t srcios;
2006-08-06 08:16:03 +00:00
srcio_data_t srcio_data;
class = (*env)->GetObjectClass (env, obj);
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
if (fid == 0) return;
2006-10-24 04:10:12 +00:00
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, fid);
2006-08-06 08:16:03 +00:00
srcio_data.env = env;
srcio_data.obj = obj;
srcios.in = __read_source;
2006-08-06 15:03:42 +00:00
srcios.out = __write_source;
2006-08-06 08:16:03 +00:00
srcios.custom_data = &srcio_data;
2006-10-24 04:10:12 +00:00
if (ase_awk_parse (awk, &srcios) == -1)
2006-08-06 08:16:03 +00:00
{
2006-10-12 14:36:25 +00:00
printf ("parse error.......\n");
2006-08-06 08:16:03 +00:00
except = (*env)->FindClass (env, EXCEPTION_AWK);
if (except == 0) return;
2006-10-13 10:18:39 +00:00
(*env)->ThrowNew (env, except, "Parse Error ...");
2006-10-24 04:10:12 +00:00
printf ("parse error -> line [%d] %S\n", ase_awk_getsrcline(awk), ase_awk_geterrstr(ase_awk_geterrnum(awk)));
2006-08-06 08:16:03 +00:00
return;
}
}
2006-10-24 04:10:12 +00:00
JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj)
2006-08-06 08:16:03 +00:00
{
2006-10-13 10:18:39 +00:00
jclass class;
jfieldID fid;
jthrowable except;
2006-10-24 04:10:12 +00:00
ase_awk_t* awk;
ase_awk_runios_t runios;
2006-10-13 10:18:39 +00:00
runio_data_t runio_data;
class = (*env)->GetObjectClass (env, obj);
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
if (fid == 0) return;
2006-10-24 04:10:12 +00:00
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, fid);
2006-10-13 10:18:39 +00:00
runio_data.env = env;
runio_data.obj = obj;
2006-10-24 04:10:12 +00:00
runios.pipe = ASE_NULL;
runios.coproc = ASE_NULL;
2006-10-13 14:05:24 +00:00
runios.file = __process_extio_file;
2006-10-13 10:18:39 +00:00
runios.console = __process_extio_console;
runios.custom_data = &runio_data;
2006-10-24 04:10:12 +00:00
if (ase_awk_run (awk, &runios, ASE_NULL, ASE_NULL) == -1)
2006-10-13 10:18:39 +00:00
{
except = (*env)->FindClass (env, EXCEPTION_AWK);
if (except == 0) return;
(*env)->ThrowNew (env, except, "Run Error ...");
return;
}
2006-08-06 08:16:03 +00:00
}
2006-10-24 04:10:12 +00:00
JNIEXPORT void JNICALL Java_ase_awk_Awk_set_1extio (
2006-10-15 15:46:14 +00:00
JNIEnv* env, jobject obj, jlong extio, jobject handle)
{
2006-10-24 04:10:12 +00:00
ase_awk_extio_t* epa = (ase_awk_extio_t*)extio;
2006-10-15 15:46:14 +00:00
epa->handle = (void*)handle;
}
2006-10-24 04:10:12 +00:00
JNIEXPORT jobject JNICALL Java_ase_awk_Awk_get_1extio (
2006-10-17 09:36:09 +00:00
JNIEnv* env, jobject obj, jlong extio)
{
2006-10-24 04:10:12 +00:00
ase_awk_extio_t* epa = (ase_awk_extio_t*)extio;
2006-10-17 09:36:09 +00:00
return (jobject)epa->handle;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_open_source (JNIEnv* env, jobject obj, int mode)
2006-08-06 08:16:03 +00:00
{
2006-10-13 10:18:39 +00:00
jclass class;
jmethodID mid;
jthrowable thrown;
jint ret;
class = (*env)->GetObjectClass(env, obj);
2006-08-06 08:16:03 +00:00
2006-10-13 10:18:39 +00:00
mid = (*env)->GetMethodID (env, class, "open_source", "(I)I");
if (mid == 0) return -1;
2006-10-12 14:36:25 +00:00
2006-10-13 10:18:39 +00:00
ret = (*env)->CallIntMethod (env, obj, mid, mode);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
2006-08-06 08:16:03 +00:00
{
2006-10-13 10:18:39 +00:00
(*env)->ExceptionClear (env);
ret = -1;
2006-08-06 08:16:03 +00:00
}
2006-08-06 15:03:42 +00:00
2006-10-13 10:18:39 +00:00
return ret;
2006-08-06 15:03:42 +00:00
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_close_source (JNIEnv* env, jobject obj, int mode)
2006-08-06 15:03:42 +00:00
{
2006-10-13 10:18:39 +00:00
jclass class;
jmethodID mid;
jthrowable thrown;
jint ret;
class = (*env)->GetObjectClass(env, obj);
2006-08-06 15:03:42 +00:00
2006-10-13 10:18:39 +00:00
mid = (*env)->GetMethodID (env, class, "close_source", "(I)I");
if (mid == 0) return -1;
2006-08-06 15:03:42 +00:00
2006-10-13 10:18:39 +00:00
ret = (*env)->CallIntMethod (env, obj, mid, mode);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
2006-08-06 08:16:03 +00:00
{
2006-10-13 10:18:39 +00:00
(*env)->ExceptionClear (env);
ret = -1;
2006-08-06 08:16:03 +00:00
}
2006-08-06 15:03:42 +00:00
2006-10-13 10:18:39 +00:00
return ret;
2006-08-06 08:16:03 +00:00
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_read_source (
JNIEnv* env, jobject obj, ase_char_t* buf, ase_size_t size)
2006-08-06 08:16:03 +00:00
{
jclass class;
jmethodID mid;
jcharArray array;
jchar* tmp;
2006-10-13 10:18:39 +00:00
jint ret, i;
jthrowable thrown;
2006-08-06 08:16:03 +00:00
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, "read_source", "([CI)I");
if (mid == 0) return -1;
2006-10-13 10:18:39 +00:00
array = (*env)->NewCharArray (env, size);
2006-08-06 08:16:03 +00:00
if (array == NULL) return -1;
2006-10-13 10:18:39 +00:00
ret = (*env)->CallIntMethod (env, obj, mid, array, size);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
2006-08-06 08:16:03 +00:00
tmp = (*env)->GetCharArrayElements (env, array, 0);
2006-10-24 04:10:12 +00:00
for (i = 0; i < ret; i++) buf[i] = (ase_char_t)tmp[i];
2006-08-06 08:16:03 +00:00
(*env)->ReleaseCharArrayElements (env, array, tmp, 0);
2006-10-22 07:05:34 +00:00
(*env)->DeleteLocalRef (env, array);
2006-08-06 08:16:03 +00:00
return i;
2006-08-02 15:03:49 +00:00
}
2006-08-06 15:03:42 +00:00
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_write_source (
JNIEnv* env, jobject obj, ase_char_t* buf, ase_size_t size)
2006-08-06 15:03:42 +00:00
{
jclass class;
jmethodID mid;
jcharArray array;
jchar* tmp;
2006-10-13 10:18:39 +00:00
jint ret, i;
jthrowable thrown;
2006-08-06 15:03:42 +00:00
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, "write_source", "([CI)I");
if (mid == 0) return -1;
array = (*env)->NewCharArray (env, size);
if (array == NULL) return -1;
tmp = (*env)->GetCharArrayElements (env, array, 0);
for (i = 0; i < size; i++) tmp[i] = (jchar)buf[i];
(*env)->ReleaseCharArrayElements (env, array, tmp, 0);
2006-10-13 10:18:39 +00:00
ret = (*env)->CallIntMethod (env, obj, mid, array, size);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
2006-10-22 07:05:34 +00:00
(*env)->DeleteLocalRef (env, array);
2006-10-13 10:18:39 +00:00
return ret;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_open_extio (
JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio)
2006-10-13 10:18:39 +00:00
{
jclass class;
jmethodID mid;
jthrowable thrown;
jint ret;
class = (*env)->GetObjectClass(env, obj);
2006-10-24 04:10:12 +00:00
if (extio == ASE_NULL)
2006-10-13 14:05:24 +00:00
{
mid = (*env)->GetMethodID (env, class, meth, "()I");
if (mid == 0) return -1;
ret = (*env)->CallIntMethod (env, obj, mid);
}
else
{
2006-10-18 14:06:47 +00:00
/*
2006-10-13 14:05:24 +00:00
jstring name_str;
mid = (*env)->GetMethodID (
env, class, meth, "(Ljava/lang/String;)I");
if (mid == 0) return -1;
2006-10-22 07:05:34 +00:00
name_str = (*env)->NewString (
2006-10-24 04:10:12 +00:00
env, extio->name, ase_awk_strlen(extio->name));
2006-10-13 14:05:24 +00:00
if (name_str == 0) return -1;
ret = (*env)->CallIntMethod (env, obj, mid, name_str);
2006-10-22 07:05:34 +00:00
(*env)->DeleteLocalRef (env, name_str);
2006-10-18 14:06:47 +00:00
*/
2006-10-22 07:05:34 +00:00
jclass extio_class;
jmethodID extio_cons;
jobject extio_object;
2006-10-22 11:34:53 +00:00
extio_class = (*env)->FindClass (env, "ssekit/ssej/awk/Extio");
2006-10-22 07:05:34 +00:00
if (extio_class == NULL) return -1;
extio_cons = (*env)->GetMethodID (
env, extio_class, "<init>", "(J)V");
if (extio_cons == NULL) return -1;
mid = (*env)->GetMethodID (
2006-10-22 11:34:53 +00:00
env, class, meth, "(Lssekit/ssej/awk/Extio;)I");
2006-10-22 07:05:34 +00:00
if (mid == NULL) return -1;
extio_object = (*env)->NewObject (
env, extio_class, extio_cons, (jlong)extio);
if (extio_object == NULL) return -1;
ret = (*env)->CallIntMethod (env, obj, mid, extio_object);
2006-10-13 14:05:24 +00:00
}
2006-10-13 10:18:39 +00:00
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
return ret;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_close_extio (
JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio)
2006-10-13 10:18:39 +00:00
{
jclass class;
jmethodID mid;
jthrowable thrown;
jint ret;
class = (*env)->GetObjectClass(env, obj);
2006-10-24 04:10:12 +00:00
if (extio == ASE_NULL)
2006-10-13 14:05:24 +00:00
{
mid = (*env)->GetMethodID (env, class, meth, "()I");
if (mid == 0) return -1;
ret = (*env)->CallIntMethod (env, obj, mid);
}
else
{
jstring name_str;
mid = (*env)->GetMethodID (
env, class, meth, "(Ljava/lang/String;)I");
if (mid == 0) return -1;
2006-10-22 07:05:34 +00:00
name_str = (*env)->NewString (
2006-10-24 04:10:12 +00:00
env, extio->name, ase_awk_strlen(extio->name));
2006-10-13 14:05:24 +00:00
if (name_str == 0) return -1;
ret = (*env)->CallIntMethod (env, obj, mid, name_str);
2006-10-22 07:05:34 +00:00
(*env)->DeleteLocalRef (env, name_str);
2006-10-13 14:05:24 +00:00
}
2006-10-13 10:18:39 +00:00
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
return ret;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_read_extio (
JNIEnv* env, jobject obj, char* meth, ase_char_t* buf, ase_size_t size)
2006-10-13 10:18:39 +00:00
{
jclass class;
jmethodID mid;
jcharArray array;
jchar* tmp;
jint ret, i;
jthrowable thrown;
class = (*env)->GetObjectClass(env, obj);
2006-10-13 14:05:24 +00:00
mid = (*env)->GetMethodID (env, class, meth, "([CI)I");
2006-10-13 10:18:39 +00:00
if (mid == 0) return -1;
array = (*env)->NewCharArray (env, size);
if (array == NULL) return -1;
ret = (*env)->CallIntMethod (env, obj, mid, array, size);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
tmp = (*env)->GetCharArrayElements (env, array, 0);
2006-10-24 04:10:12 +00:00
for (i = 0; i < ret; i++) buf[i] = (ase_char_t)tmp[i];
2006-10-13 10:18:39 +00:00
(*env)->ReleaseCharArrayElements (env, array, tmp, 0);
2006-10-22 07:05:34 +00:00
(*env)->DeleteLocalRef (env, array);
2006-10-13 10:18:39 +00:00
return ret;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __call_java_write_extio (
JNIEnv* env, jobject obj, char* meth, ase_char_t* data, ase_size_t size)
2006-10-13 10:18:39 +00:00
{
jclass class;
jmethodID mid;
jcharArray array;
2006-10-24 04:10:12 +00:00
ase_ssize_t i;
2006-10-13 10:18:39 +00:00
jchar* tmp;
jint ret;
jthrowable thrown;
class = (*env)->GetObjectClass(env, obj);
2006-10-13 14:05:24 +00:00
mid = (*env)->GetMethodID (env, class, meth, "([CI)I");
2006-10-13 10:18:39 +00:00
if (mid == 0) return -1;
array = (*env)->NewCharArray (env, size);
if (array == NULL) return -1;
tmp = (*env)->GetCharArrayElements (env, array, 0);
for (i = 0; i < size; i++) tmp[i] = (jchar)data[i];
(*env)->ReleaseCharArrayElements (env, array, tmp, 0);
ret = (*env)->CallIntMethod (env, obj, mid, array, size);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
2006-10-22 07:05:34 +00:00
(*env)->DeleteLocalRef (env, array);
2006-10-13 10:18:39 +00:00
return ret;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __read_source (
int cmd, void* arg, ase_char_t* data, ase_size_t count)
2006-10-13 10:18:39 +00:00
{
srcio_data_t* srcio_data = (srcio_data_t*)arg;
2006-10-24 04:10:12 +00:00
if (cmd == ASE_AWK_IO_OPEN)
2006-10-13 10:18:39 +00:00
{
return __call_java_open_source (
srcio_data->env, srcio_data->obj, SOURCE_READ);
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_CLOSE)
2006-10-13 10:18:39 +00:00
{
return __call_java_close_source (
srcio_data->env, srcio_data->obj, SOURCE_READ);
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_READ)
2006-10-13 10:18:39 +00:00
{
return __call_java_read_source (
srcio_data->env, srcio_data->obj, data, count);
}
return -1;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __write_source (
int cmd, void* arg, ase_char_t* data, ase_size_t count)
2006-10-13 10:18:39 +00:00
{
srcio_data_t* srcio_data = (srcio_data_t*)arg;
2006-10-24 04:10:12 +00:00
if (cmd == ASE_AWK_IO_OPEN)
2006-10-13 10:18:39 +00:00
{
return __call_java_open_source (
srcio_data->env, srcio_data->obj, SOURCE_WRITE);
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_CLOSE)
2006-10-13 10:18:39 +00:00
{
return __call_java_close_source (
srcio_data->env, srcio_data->obj, SOURCE_WRITE);
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_WRITE)
2006-10-13 10:18:39 +00:00
{
return __call_java_write_source (
srcio_data->env, srcio_data->obj, data, count);
}
return -1;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __process_extio_console (
int cmd, void* arg, ase_char_t* data, ase_size_t size)
2006-10-13 10:18:39 +00:00
{
2006-10-24 04:10:12 +00:00
ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
2006-10-13 10:18:39 +00:00
runio_data_t* runio_data = (runio_data_t*)epa->custom_data;
2006-10-24 04:10:12 +00:00
if (cmd == ASE_AWK_IO_OPEN)
2006-10-13 10:18:39 +00:00
{
return __call_java_open_extio (
2006-10-13 14:05:24 +00:00
runio_data->env, runio_data->obj,
2006-10-24 04:10:12 +00:00
"open_console", ASE_NULL);
2006-10-13 10:18:39 +00:00
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_CLOSE)
2006-10-13 10:18:39 +00:00
{
return __call_java_close_extio (
2006-10-13 14:05:24 +00:00
runio_data->env, runio_data->obj,
2006-10-24 04:10:12 +00:00
"close_console", ASE_NULL);
2006-10-13 10:18:39 +00:00
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_READ)
2006-10-13 10:18:39 +00:00
{
return __call_java_read_extio (
runio_data->env, runio_data->obj, "read_console",
data, size);
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_WRITE)
2006-10-13 10:18:39 +00:00
{
return __call_java_write_extio (
runio_data->env, runio_data->obj, "write_console",
data, size);
}
#if 0
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_FLUSH)
2006-10-13 10:18:39 +00:00
{
2006-10-13 14:05:24 +00:00
return __call_java_flush_extio (
runio_data->env, runio_data->obj, "flush_console",
data, size);
2006-10-13 10:18:39 +00:00
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_NEXT)
2006-10-13 10:18:39 +00:00
{
2006-10-13 14:05:24 +00:00
return __call_java_next_extio (
runio_data->env, runio_data->obj, "flush_console",
data, size);
2006-10-13 10:18:39 +00:00
}
#endif
2006-10-13 14:05:24 +00:00
return -1;
}
2006-10-24 04:10:12 +00:00
static ase_ssize_t __process_extio_file (
int cmd, void* arg, ase_char_t* data, ase_size_t size)
2006-10-13 14:05:24 +00:00
{
2006-10-24 04:10:12 +00:00
ase_awk_extio_t* epa = (ase_awk_extio_t*)arg;
2006-10-13 14:05:24 +00:00
runio_data_t* runio_data = (runio_data_t*)epa->custom_data;
2006-10-24 04:10:12 +00:00
if (cmd == ASE_AWK_IO_OPEN)
2006-10-13 14:05:24 +00:00
{
return __call_java_open_extio (
runio_data->env, runio_data->obj,
2006-10-18 14:06:47 +00:00
"open_file", epa);
2006-10-13 14:05:24 +00:00
}
2006-10-24 04:10:12 +00:00
else if (cmd == ASE_AWK_IO_CLOSE)
2006-10-13 14:05:24 +00:00
{
return __call_java_close_extio (
runio_data->env, runio_data->obj,
2006-10-18 14:06:47 +00:00
"close_file", epa);
2006-10-13 14:05:24 +00:00
}
2006-10-13 10:18:39 +00:00
return -1;
2006-08-06 15:03:42 +00:00
}