*** empty log message ***

This commit is contained in:
hyung-hwan 2006-08-04 17:54:52 +00:00
parent e144c0ac29
commit ef1059528f
4 changed files with 28 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.89 2006-08-04 17:36:40 bacon Exp $ * $Id: awk.h,v 1.90 2006-08-04 17:54:52 bacon Exp $
*/ */
#ifndef _XP_AWK_AWK_H_ #ifndef _XP_AWK_AWK_H_
@ -12,6 +12,7 @@ typedef struct xp_awk_t xp_awk_t;
typedef struct xp_awk_val_t xp_awk_val_t; typedef struct xp_awk_val_t xp_awk_val_t;
typedef struct xp_awk_extio_t xp_awk_extio_t; typedef struct xp_awk_extio_t xp_awk_extio_t;
typedef struct xp_awk_srcios_t xp_awk_srcios_t;
typedef struct xp_awk_runios_t xp_awk_runios_t; typedef struct xp_awk_runios_t xp_awk_runios_t;
typedef struct xp_awk_runcbs_t xp_awk_runcbs_t; typedef struct xp_awk_runcbs_t xp_awk_runcbs_t;
@ -39,6 +40,13 @@ struct xp_awk_extio_t
xp_awk_extio_t* next; xp_awk_extio_t* next;
}; };
struct xp_awk_srcios_t
{
xp_awk_io_t in;
xp_awk_io_t out;
void* custom_data;
};
struct xp_awk_runios_t struct xp_awk_runios_t
{ {
xp_awk_io_t pipe; xp_awk_io_t pipe;
@ -233,10 +241,10 @@ xp_size_t xp_awk_getsrcline (xp_awk_t* awk);
int xp_awk_setextio (xp_awk_t* awk, int id, xp_awk_io_t handler, void* arg); int xp_awk_setextio (xp_awk_t* awk, int id, xp_awk_io_t handler, void* arg);
int xp_awk_parse (xp_awk_t* awk); int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios);
int xp_awk_run (xp_awk_t* awk, int xp_awk_run (xp_awk_t* awk,
xp_awk_runcbs_t* runcbs, xp_awk_runios_t* runios); xp_awk_runios_t* runios, xp_awk_runcbs_t* runcbs);
int xp_awk_stop (xp_awk_t* awk, void* run); int xp_awk_stop (xp_awk_t* awk, void* run);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.158 2006-08-04 17:36:40 bacon Exp $ * $Id: parse.c,v 1.159 2006-08-04 17:54:52 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -408,8 +408,9 @@ static void __dump (xp_awk_t* awk)
} }
} }
int xp_awk_parse (xp_awk_t* awk) int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios)
{ {
/* TODO: switch to srcios */
if (awk->srcio == XP_NULL) if (awk->srcio == XP_NULL)
{ {
/* the source code io handler is not set */ /* the source code io handler is not set */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.162 2006-08-04 17:36:40 bacon Exp $ * $Id: run.c,v 1.163 2006-08-04 17:54:52 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -222,7 +222,7 @@ void xp_awk_seterrnum (void* run, int errnum)
r->errnum = errnum; r->errnum = errnum;
} }
int xp_awk_run (xp_awk_t* awk, xp_awk_runcbs_t* runcbs, xp_awk_runios_t* runios) int xp_awk_run (xp_awk_t* awk, xp_awk_runios_t* runios, xp_awk_runcbs_t* runcbs)
{ {
xp_awk_run_t* run; xp_awk_run_t* run;
int n; int n;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.66 2006-08-04 17:36:40 bacon Exp $ * $Id: awk.c,v 1.67 2006-08-04 17:54:52 bacon Exp $
*/ */
#include <xp/awk/awk.h> #include <xp/awk/awk.h>
@ -514,6 +514,7 @@ static int __main (int argc, xp_char_t* argv[])
#endif #endif
{ {
xp_awk_t* awk; xp_awk_t* awk;
xp_awk_srcios_t srcios;
xp_awk_runcbs_t runcbs; xp_awk_runcbs_t runcbs;
xp_awk_runios_t runios; xp_awk_runios_t runios;
struct src_io src_io = { NULL, NULL }; struct src_io src_io = { NULL, NULL };
@ -606,7 +607,11 @@ static int __main (int argc, xp_char_t* argv[])
return -1; return -1;
} }
if (xp_awk_parse(awk) == -1) srcios.in = process_source;
srcios.out = XP_NULL;
srcios.custom_data = XP_NULL;
if (xp_awk_parse (awk, &srcios) == -1)
{ {
#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR) #if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR)
xp_printf ( xp_printf (
@ -634,17 +639,17 @@ static int __main (int argc, xp_char_t* argv[])
signal (SIGINT, __stop_run); signal (SIGINT, __stop_run);
runcbs.start = __on_run_start;
runcbs.end = __on_run_end;
runcbs.custom_data = XP_NULL;
runios.pipe = process_extio_pipe; runios.pipe = process_extio_pipe;
runios.coproc = XP_NULL; runios.coproc = XP_NULL;
runios.file = process_extio_file; runios.file = process_extio_file;
runios.console = process_extio_console; runios.console = process_extio_console;
runios.custom_data = XP_NULL; runios.custom_data = XP_NULL;
if (xp_awk_run (awk, &runcbs, &runios) == -1) runcbs.start = __on_run_start;
runcbs.end = __on_run_end;
runcbs.custom_data = XP_NULL;
if (xp_awk_run (awk, &runios, &runcbs) == -1)
{ {
#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR) #if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR)
xp_printf ( xp_printf (