more code enhancement

- renamed pcp back to pio
- added more fine-grained control to pio
This commit is contained in:
2009-01-29 08:50:30 +00:00
parent 3f48dd3d7f
commit 5c08cdefc3
20 changed files with 733 additions and 855 deletions

View File

@ -19,7 +19,7 @@
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/str.h>
#include <qse/cmn/time.h>
#include <qse/cmn/pcp.h>
#include <qse/cmn/pio.h>
#include <qse/cmn/sio.h>
#include <qse/utl/stdio.h>
@ -283,57 +283,57 @@ int StdAwk::system (Run& run, Return& ret, const Argument* args, size_t nargs,
int StdAwk::openPipe (Pipe& io)
{
Awk::Pipe::Mode mode = io.getMode();
qse_pcp_t* pcp = QSE_NULL;
qse_pio_t* pio = QSE_NULL;
int flags;
switch (mode)
{
case Awk::Pipe::READ:
/* TODO: should we specify ERRTOOUT? */
flags = QSE_PCP_READOUT |
QSE_PCP_ERRTOOUT;
flags = QSE_PIO_READOUT |
QSE_PIO_ERRTOOUT;
break;
case Awk::Pipe::WRITE:
flags = QSE_PCP_WRITEIN;
flags = QSE_PIO_WRITEIN;
break;
case Awk::Pipe::RW:
flags = QSE_PCP_READOUT |
QSE_PCP_ERRTOOUT |
QSE_PCP_WRITEIN;
flags = QSE_PIO_READOUT |
QSE_PIO_ERRTOOUT |
QSE_PIO_WRITEIN;
break;
}
pcp = qse_pcp_open (
pio = qse_pio_open (
((Awk*)io)->getMmgr(),
0,
io.getName(),
flags|QSE_PCP_TEXT|QSE_PCP_SHELL
flags|QSE_PIO_TEXT|QSE_PIO_SHELL
);
if (pcp == QSE_NULL) return -1;
if (pio == QSE_NULL) return -1;
io.setHandle (pcp);
io.setHandle (pio);
return 1;
}
int StdAwk::closePipe (Pipe& io)
{
qse_pcp_close ((qse_pcp_t*)io.getHandle());
qse_pio_close ((qse_pio_t*)io.getHandle());
return 0;
}
StdAwk::ssize_t StdAwk::readPipe (Pipe& io, char_t* buf, size_t len)
{
return qse_pcp_read ((qse_pcp_t*)io.getHandle(), buf, len, QSE_PCP_OUT);
return qse_pio_read ((qse_pio_t*)io.getHandle(), buf, len, QSE_PIO_OUT);
}
StdAwk::ssize_t StdAwk::writePipe (Pipe& io, const char_t* buf, size_t len)
{
return qse_pcp_write ((qse_pcp_t*)io.getHandle(), buf, len, QSE_PCP_IN);
return qse_pio_write ((qse_pio_t*)io.getHandle(), buf, len, QSE_PIO_IN);
}
int StdAwk::flushPipe (Pipe& io)
{
return qse_pcp_flush ((qse_pcp_t*)io.getHandle(), QSE_PCP_IN);
return qse_pio_flush ((qse_pio_t*)io.getHandle(), QSE_PIO_IN);
}
// file io handlers

View File

@ -18,7 +18,7 @@
#include "awk.h"
#include <qse/cmn/sio.h>
#include <qse/cmn/pcp.h>
#include <qse/cmn/pio.h>
#include <qse/cmn/str.h>
#include <qse/cmn/time.h>
#include <qse/utl/stdio.h> /* TODO: remove dependency on qse_vsprintf */
@ -345,34 +345,34 @@ static qse_ssize_t awk_extio_pipe (
{
case QSE_AWK_IO_OPEN:
{
qse_pcp_t* handle;
qse_pio_t* handle;
int flags;
if (epa->mode == QSE_AWK_EXTIO_PIPE_READ)
{
/* TODO: should we specify ERRTOOUT? */
flags = QSE_PCP_READOUT |
QSE_PCP_ERRTOOUT;
flags = QSE_PIO_READOUT |
QSE_PIO_ERRTOOUT;
}
else if (epa->mode == QSE_AWK_EXTIO_PIPE_WRITE)
{
flags = QSE_PCP_WRITEIN;
flags = QSE_PIO_WRITEIN;
}
else if (epa->mode == QSE_AWK_EXTIO_PIPE_RW)
{
flags = QSE_PCP_READOUT |
QSE_PCP_ERRTOOUT |
QSE_PCP_WRITEIN;
flags = QSE_PIO_READOUT |
QSE_PIO_ERRTOOUT |
QSE_PIO_WRITEIN;
}
else return -1; /* TODO: any way to set the error number? */
/*dprint (QSE_T("opening %s of type %d (pipe)\n"), epa->name, epa->type);*/
handle = qse_pcp_open (
handle = qse_pio_open (
qse_awk_getrunmmgr(epa->run),
0,
epa->name,
flags|QSE_PCP_SHELL|QSE_PCP_TEXT
flags|QSE_PIO_SHELL|QSE_PIO_TEXT
);
if (handle == QSE_NULL) return -1;
@ -383,35 +383,35 @@ static qse_ssize_t awk_extio_pipe (
case QSE_AWK_IO_CLOSE:
{
/*dprint (QSE_T("closing %s of type (pipe) %d\n"), epa->name, epa->type);*/
qse_pcp_close ((qse_pcp_t*)epa->handle);
qse_pio_close ((qse_pio_t*)epa->handle);
epa->handle = QSE_NULL;
return 0;
}
case QSE_AWK_IO_READ:
{
return qse_pcp_read (
(qse_pcp_t*)epa->handle,
return qse_pio_read (
(qse_pio_t*)epa->handle,
data,
size,
QSE_PCP_OUT
QSE_PIO_OUT
);
}
case QSE_AWK_IO_WRITE:
{
return qse_pcp_write (
(qse_pcp_t*)epa->handle,
return qse_pio_write (
(qse_pio_t*)epa->handle,
data,
size,
QSE_PCP_IN
QSE_PIO_IN
);
}
case QSE_AWK_IO_FLUSH:
{
/*if (epa->mode == QSE_AWK_EXTIO_PIPE_READ) return -1;*/
return qse_pcp_flush ((qse_pcp_t*)epa->handle, QSE_PCP_IN);
return qse_pio_flush ((qse_pio_t*)epa->handle, QSE_PIO_IN);
}
case QSE_AWK_IO_NEXT: