started adding nwio
This commit is contained in:
@ -1674,6 +1674,24 @@ void qse_awk_rtx_stop (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_getrio() function copies runtime I/O handlers
|
||||
* to the memory buffer pointed to by @a rio.
|
||||
*/
|
||||
void qse_awk_rtx_getrio (
|
||||
qse_awk_rtx_t* rtx,
|
||||
qse_awk_rio_t* rio
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_getrio() function sets runtime I/O handlers
|
||||
* with the functions pointed to by @a rio.
|
||||
*/
|
||||
void qse_awk_rtx_setrio (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_awk_rio_t* rio
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_poprcb() function pops a runtime callback set
|
||||
* and returns the pointer to it. If no callback set can be popped,
|
||||
|
@ -166,12 +166,23 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_getxtnstd() gets the pointer to extension space.
|
||||
* The qse_awk_rtx_getxtnstd() function gets the pointer to extension space.
|
||||
*/
|
||||
void* qse_awk_rtx_getxtnstd (
|
||||
qse_awk_rtx_t* rtx
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_getcmgrstd() function gets the current character
|
||||
* manager associated with a particular I/O target indicated by the name
|
||||
* @a ioname.
|
||||
*/
|
||||
qse_cmgr_t* qse_awk_rtx_getcmgrstd (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_char_t* ioname
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@ pkginclude_HEADERS = \
|
||||
mbwc.h \
|
||||
mem.h \
|
||||
nwad.h \
|
||||
nwio.h \
|
||||
oht.h \
|
||||
opt.h \
|
||||
path.h \
|
||||
|
@ -53,9 +53,9 @@ SOURCES =
|
||||
DIST_SOURCES =
|
||||
am__pkginclude_HEADERS_DIST = alg.h chr.h cp949.h cp950.h dll.h env.h \
|
||||
fio.h fma.h fmt.h fs.h gdl.h htb.h hton.h ipad.h lda.h main.h \
|
||||
map.h mbwc.h mem.h nwad.h oht.h opt.h path.h pio.h pma.h rbt.h \
|
||||
rex.h sio.h sll.h slmb.h stdio.h str.h time.h tio.h tre.h \
|
||||
utf8.h xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
|
||||
map.h mbwc.h mem.h nwad.h nwio.h oht.h opt.h path.h pio.h \
|
||||
pma.h rbt.h rex.h sio.h sll.h slmb.h stdio.h str.h time.h \
|
||||
tio.h tre.h utf8.h xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
@ -231,9 +231,9 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = alg.h chr.h cp949.h cp950.h dll.h env.h fio.h \
|
||||
fma.h fmt.h fs.h gdl.h htb.h hton.h ipad.h lda.h main.h map.h \
|
||||
mbwc.h mem.h nwad.h oht.h opt.h path.h pio.h pma.h rbt.h rex.h \
|
||||
sio.h sll.h slmb.h stdio.h str.h time.h tio.h tre.h utf8.h \
|
||||
xma.h $(am__append_1)
|
||||
mbwc.h mem.h nwad.h nwio.h oht.h opt.h path.h pio.h pma.h \
|
||||
rbt.h rex.h sio.h sll.h slmb.h stdio.h str.h time.h tio.h \
|
||||
tre.h utf8.h xma.h $(am__append_1)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
201
qse/include/qse/cmn/nwio.h
Normal file
201
qse/include/qse/cmn/nwio.h
Normal file
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_NWIO_H_
|
||||
#define _QSE_CMN_NWIO_H_
|
||||
|
||||
/** @file
|
||||
* This file defines a generic text I/O interface.
|
||||
*/
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/tio.h>
|
||||
#include <qse/cmn/nwad.h>
|
||||
|
||||
enum qse_nwio_flag_t
|
||||
{
|
||||
QSE_NWIO_TEXT = (1 << 0),
|
||||
QSE_NWIO_IGNOREMBWCERR = (1 << 1),
|
||||
QSE_NWIO_NOAUTOFLUSH = (1 << 2),
|
||||
|
||||
/* normal open flags */
|
||||
QSE_NWIO_READ = (1 << 8),
|
||||
QSE_NWIO_WRITE = (1 << 9),
|
||||
|
||||
/** do not reread if read has been interrupted */
|
||||
QSE_NWIO_READNORETRY = (1 << 10),
|
||||
/** do not rewrite if write has been interrupted */
|
||||
QSE_NWIO_WRITENORETRY = (1 << 11),
|
||||
QSE_NWIO_LISTEN = (1 << 12)
|
||||
};
|
||||
|
||||
enum qse_nwio_errnum_t
|
||||
{
|
||||
QSE_NWIO_ENOERR = 0, /**< no error */
|
||||
|
||||
QSE_NWIO_ENOMEM, /**< out of memory */
|
||||
QSE_NWIO_EINVAL, /**< invalid parameter */
|
||||
QSE_NWIO_EACCES, /**< access denied */
|
||||
QSE_NWIO_ENOENT, /**< no such file */
|
||||
QSE_NWIO_EEXIST, /**< already exist */
|
||||
QSE_NWIO_EINTR, /**< interrupted */
|
||||
QSE_NWIO_EPIPE, /**< broken pipe */
|
||||
QSE_NWIO_ECONN, /**< connection refused */
|
||||
QSE_NWIO_EILSEQ, /**< illegal sequence */
|
||||
QSE_NWIO_EICSEQ, /**< incomplete sequence */
|
||||
QSE_NWIO_EILCHR, /**< illegal character */
|
||||
QSE_NWIO_ESYSERR, /**< subsystem(system call) error */
|
||||
QSE_NWIO_ENOIMPL, /**< not implemented */
|
||||
|
||||
QSE_NWIO_EOTHER /**< other error */
|
||||
};
|
||||
typedef enum qse_nwio_errnum_t qse_nwio_errnum_t;
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* TODO: */
|
||||
#elif defined(__OS2__)
|
||||
/* TODO: */
|
||||
#elif defined(__DOS__)
|
||||
/* TODO: */
|
||||
#else
|
||||
typedef int qse_nwio_hnd_t; /**< defines a pipe handle type */
|
||||
# define QSE_NWIO_HND_NIL ((qse_nwio_hnd_t)-1)
|
||||
#endif
|
||||
|
||||
typedef struct qse_nwio_t qse_nwio_t;
|
||||
|
||||
struct qse_nwio_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS (nwio)
|
||||
int flags;
|
||||
qse_nwio_errnum_t errnum;
|
||||
qse_nwio_hnd_t handle;
|
||||
qse_tio_t* tio;
|
||||
};
|
||||
|
||||
#define QSE_NWIO_HANDLE(nwio) ((nwio)->handle)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
QSE_DEFINE_COMMON_FUNCTIONS (nwio)
|
||||
|
||||
/**
|
||||
* The qse_nwio_open() function opens a file.
|
||||
* To open a file, you should set the flags with at least one of
|
||||
* QSE_NWIO_READ, QSE_NWIO_WRITE, QSE_NWIO_APPEND.
|
||||
*
|
||||
* If the #QSE_NWIO_HANDLE flag is set, the @a nwad parameter is interpreted
|
||||
* as a pointer to qse_nwio_hnd_t.
|
||||
*/
|
||||
qse_nwio_t* qse_nwio_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext,
|
||||
const qse_nwad_t* nwad,
|
||||
int flags
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_nwio_close() function closes a file.
|
||||
*/
|
||||
void qse_nwio_close (
|
||||
qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_nwio_close() function opens a file into @a nwio.
|
||||
*/
|
||||
int qse_nwio_init (
|
||||
qse_nwio_t* nwio,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_nwad_t* nwad,
|
||||
int flags
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_nwio_close() function finalizes a file by closing the handle
|
||||
* stored in @a nwio.
|
||||
*/
|
||||
void qse_nwio_fini (
|
||||
qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
qse_nwio_errnum_t qse_nwio_geterrnum (
|
||||
const qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_nwio_gethandle() function returns the native file handle.
|
||||
*/
|
||||
qse_nwio_hnd_t qse_nwio_gethandle (
|
||||
const qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
qse_ubi_t qse_nwio_gethandleasubi (
|
||||
const qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
|
||||
qse_cmgr_t* qse_nwio_getcmgr (
|
||||
qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
void qse_nwio_setcmgr (
|
||||
qse_nwio_t* nwio,
|
||||
qse_cmgr_t* cmgr
|
||||
);
|
||||
|
||||
|
||||
qse_ssize_t qse_nwio_flush (
|
||||
qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
void qse_nwio_purge (
|
||||
qse_nwio_t* nwio
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_nwio_read() function reads data.
|
||||
*/
|
||||
qse_ssize_t qse_nwio_read (
|
||||
qse_nwio_t* nwio,
|
||||
void* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_nwio_write() function writes data.
|
||||
* If QSE_NWIO_TEXT is used and the size parameter is (qse_size_t)-1,
|
||||
* the function treats the data parameter as a pointer to a null-terminated
|
||||
* string.
|
||||
*/
|
||||
qse_ssize_t qse_nwio_write (
|
||||
qse_nwio_t* nwio,
|
||||
const void* data,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -83,7 +83,16 @@ enum qse_pio_flag_t
|
||||
/** drop stdout */
|
||||
QSE_PIO_DROPOUT = (1 << 17),
|
||||
/** drop stderr */
|
||||
QSE_PIO_DROPERR = (1 << 18)
|
||||
QSE_PIO_DROPERR = (1 << 18),
|
||||
|
||||
/** do not reread if read has been interrupted */
|
||||
QSE_PIO_READNORETRY = (1 << 21),
|
||||
/** do not rewrite if write has been interrupted */
|
||||
QSE_PIO_WRITENORETRY = (1 << 22),
|
||||
/** return immediately from qse_pio_wait() if a child has not exited */
|
||||
QSE_PIO_WAITNOBLOCK = (1 << 23),
|
||||
/** do not wait again if waitpid has been interrupted */
|
||||
QSE_PIO_WAITNORETRY = (1 << 24)
|
||||
};
|
||||
|
||||
/**
|
||||
@ -97,29 +106,6 @@ enum qse_pio_hid_t
|
||||
};
|
||||
typedef enum qse_pio_hid_t qse_pio_hid_t;
|
||||
|
||||
/**
|
||||
* The qse_pio_option_t type defines options to change the behavior of
|
||||
* qse_pio_xxx functions.
|
||||
*/
|
||||
enum qse_pio_option_t
|
||||
{
|
||||
/*QSE_PIO_READ_NOBLOCK = (1 << 0),*/
|
||||
|
||||
/** do not reread if read has been interrupted */
|
||||
QSE_PIO_READ_NORETRY = (1 << 1),
|
||||
|
||||
/*QSE_PIO_WRITE_NOBLOCK = (1 << 2),*/
|
||||
|
||||
/** do not rewrite if write has been interrupted */
|
||||
QSE_PIO_WRITE_NORETRY = (1 << 3),
|
||||
|
||||
/** return immediately from qse_pio_wait() if a child has not exited */
|
||||
QSE_PIO_WAIT_NOBLOCK = (1 << 4),
|
||||
|
||||
/** do not wait again if waitpid has been interrupted */
|
||||
QSE_PIO_WAIT_NORETRY = (1 << 5)
|
||||
};
|
||||
|
||||
/**
|
||||
* The qse_pio_errnum_t type defines error numbers.
|
||||
*/
|
||||
@ -190,7 +176,7 @@ struct qse_pio_pin_t
|
||||
struct qse_pio_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS(pio)
|
||||
int option; /**< options */
|
||||
int flags; /**< options */
|
||||
qse_pio_errnum_t errnum; /**< error number */
|
||||
qse_pio_pid_t child; /**< handle to a child process */
|
||||
qse_pio_pin_t pin[3];
|
||||
@ -198,8 +184,6 @@ struct qse_pio_t
|
||||
|
||||
/** access the @a errnum field of the #qse_pio_t structure */
|
||||
#define QSE_PIO_ERRNUM(pio) ((pio)->errnum)
|
||||
/** access the @a option field of the #qse_pio_t structure */
|
||||
#define QSE_PIO_OPTION(pio) ((pio)->option)
|
||||
/** access the @a child field of the #qse_pio_t structure */
|
||||
#define QSE_PIO_CHILD(pio) ((pio)->child)
|
||||
/** get the native handle from the #qse_pio_t structure */
|
||||
@ -272,23 +256,6 @@ qse_pio_errnum_t qse_pio_geterrnum (
|
||||
const qse_pio_t* pio /**< pio object */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_pio_getoption() function gets the current option.
|
||||
* @return option number OR'ed of #qse_pio_option_t enumerators
|
||||
*/
|
||||
int qse_pio_getoption (
|
||||
const qse_pio_t* pio /**< pio object */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_pio_setoption() function sets the option.
|
||||
*/
|
||||
void qse_pio_setoption (
|
||||
qse_pio_t* pio, /**< pio object */
|
||||
int opt /**< 0 or a number OR'ed of #qse_pio_option_t
|
||||
enumerators */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_pio_getcmgr() function returns the current character manager.
|
||||
* It returns #QSE_NULL is @a pio is not opened with #QSE_PIO_TEXT.
|
||||
@ -368,6 +335,15 @@ qse_ssize_t qse_pio_flush (
|
||||
qse_pio_hid_t hid /**< handle ID */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_pio_purge() drops unflushed input and output data in the
|
||||
* buffer.
|
||||
*/
|
||||
void qse_pio_purge (
|
||||
qse_pio_t* pio, /**< pio object */
|
||||
qse_pio_hid_t hid /**< handle ID */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_pio_end() function closes a pipe to a child process
|
||||
*/
|
||||
|
@ -99,15 +99,7 @@ struct qse_sio_t
|
||||
QSE_DEFINE_COMMON_FIELDS (sio)
|
||||
qse_sio_errnum_t errnum;
|
||||
|
||||
/*
|
||||
depending on the stream type... FILE, FIFO, TCP, UDP
|
||||
qse_sio_type_t type;
|
||||
*/
|
||||
union
|
||||
{
|
||||
qse_fio_t file;
|
||||
int sck;
|
||||
} u;
|
||||
qse_fio_t file;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -126,30 +118,6 @@ struct qse_sio_t
|
||||
/** access the @a errnum field of the #qse_sio_t structure */
|
||||
#define QSE_SIO_ERRNUM(sio) ((sio)->errnum)
|
||||
|
||||
#if 0
|
||||
typedef struct qse_sio_uri_t qse_sio_uri_t;
|
||||
struct qse_sio_uri_t
|
||||
{
|
||||
enum
|
||||
{
|
||||
QSE_SIO_FILE,
|
||||
QSE_SIO_FIFO,
|
||||
QSE_SIO_PIPE,
|
||||
QSE_SIO_TCP,
|
||||
QSE_SIO_UDP
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
const qse_char_t* file;
|
||||
const qse_char_t* fifo;
|
||||
/* nothing needed for pipe */
|
||||
/* qse_ipap_t tcp;
|
||||
qse_ipap_t udp; */
|
||||
} u;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -101,7 +101,19 @@
|
||||
#endif
|
||||
|
||||
#define QSE_SIZEOF_WCHAR_T 4
|
||||
#define QSE_CHAR_IS_WCHAR
|
||||
|
||||
#if defined(vax) || defined(__vax)
|
||||
# define QSE_SIZEOF_OFF_T 4
|
||||
#elif defined(_LARGEFILE)
|
||||
# define QSE_SIZEOF_OFF_T 8
|
||||
#else
|
||||
# define QSE_SIZEOF_OFF_T 4
|
||||
#endif
|
||||
|
||||
#define QSE_SIZEOF_OFF64_T 0
|
||||
#define QSE_SIZEOF_MBSTATE_T 24
|
||||
#define QSE_MBLEN_MAX 8
|
||||
|
||||
/* make sure you change these when you change
|
||||
* the version in configure.ac */
|
||||
|
@ -55,6 +55,15 @@
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* epoll support */
|
||||
#undef HAVE_EPOLL
|
||||
|
||||
/* Define to 1 if you have the `epoll_create' function. */
|
||||
#undef HAVE_EPOLL_CREATE
|
||||
|
||||
/* Define to 1 if you have the `epoll_create1' function. */
|
||||
#undef HAVE_EPOLL_CREATE1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
@ -263,6 +272,9 @@
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/epoll.h> header file. */
|
||||
#undef HAVE_SYS_EPOLL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
Reference in New Issue
Block a user