* added QSE_SIO_NOCLOSE.
* enhanced qse_sed_comp() to accept an array of qse_sed_iostd_t
This commit is contained in:
@ -32,27 +32,30 @@
|
||||
|
||||
enum qse_fio_open_flag_t
|
||||
{
|
||||
/* request qse_char_io based IO */
|
||||
/** request qse_char_io based IO */
|
||||
QSE_FIO_TEXT = (1 << 0),
|
||||
QSE_FIO_IGNOREMBWCERR = (1 << 1),
|
||||
|
||||
/* treat the file name pointer as a handle pointer */
|
||||
/** treat the file name pointer as a handle pointer */
|
||||
QSE_FIO_HANDLE = (1 << 3),
|
||||
|
||||
QSE_FIO_READ = (1 << 8),
|
||||
QSE_FIO_WRITE = (1 << 9),
|
||||
QSE_FIO_APPEND = (1 << 10),
|
||||
/** don't close an I/O handle in qse_fio_fini() and qse_fio_close() */
|
||||
QSE_FIO_NOCLOSE = (1 << 4),
|
||||
|
||||
QSE_FIO_CREATE = (1 << 11),
|
||||
QSE_FIO_TRUNCATE = (1 << 12),
|
||||
QSE_FIO_EXCLUSIVE = (1 << 13),
|
||||
QSE_FIO_SYNC = (1 << 14),
|
||||
QSE_FIO_READ = (1 << 8),
|
||||
QSE_FIO_WRITE = (1 << 9),
|
||||
QSE_FIO_APPEND = (1 << 10),
|
||||
|
||||
QSE_FIO_CREATE = (1 << 11),
|
||||
QSE_FIO_TRUNCATE = (1 << 12),
|
||||
QSE_FIO_EXCLUSIVE = (1 << 13),
|
||||
QSE_FIO_SYNC = (1 << 14),
|
||||
|
||||
/* for WIN32 only. harmless(no effect) when used on other platforms */
|
||||
QSE_FIO_NOSHRD = (1 << 24),
|
||||
QSE_FIO_NOSHWR = (1 << 25),
|
||||
QSE_FIO_RANDOM = (1 << 26), /* hint that access be random */
|
||||
QSE_FIO_SEQUENTIAL = (1 << 27) /* hint that access is sequential */
|
||||
QSE_FIO_NOSHRD = (1 << 24),
|
||||
QSE_FIO_NOSHWR = (1 << 25),
|
||||
QSE_FIO_RANDOM = (1 << 26), /* hint that access be random */
|
||||
QSE_FIO_SEQUENTIAL = (1 << 27) /* hint that access is sequential */
|
||||
};
|
||||
|
||||
enum qse_fio_std_t
|
||||
|
@ -29,6 +29,10 @@
|
||||
#ifndef _QSE_CMN_PMA_H_
|
||||
#define _QSE_CMN_PMA_H_
|
||||
|
||||
/** @file
|
||||
* This file defines a pool-based block allocator.
|
||||
*/
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
@ -42,6 +46,9 @@ struct qse_pma_blk_t
|
||||
qse_pma_blk_t* next;
|
||||
};
|
||||
|
||||
/**
|
||||
* The qse_pma_t type defines a pool-base block allocator.
|
||||
*/
|
||||
typedef struct qse_pma_t qse_pma_t;
|
||||
|
||||
struct qse_pma_t
|
||||
|
@ -33,6 +33,7 @@
|
||||
enum qse_sio_open_flag_t
|
||||
{
|
||||
QSE_SIO_HANDLE = QSE_FIO_HANDLE,
|
||||
QSE_SIO_NOCLOSE = QSE_FIO_NOCLOSE,
|
||||
QSE_SIO_IGNOREMBWCERR = QSE_FIO_IGNOREMBWCERR,
|
||||
|
||||
QSE_SIO_READ = QSE_FIO_READ,
|
||||
|
@ -177,23 +177,11 @@ public:
|
||||
void close ();
|
||||
|
||||
///
|
||||
/// The compile() function compiles a null-terminated string pointed
|
||||
/// to by @a sptr.
|
||||
/// The compile() function compiles a script from a stream
|
||||
/// @a iostream.
|
||||
/// @return 0 on success, -1 on failure
|
||||
///
|
||||
int compile (
|
||||
const char_t* sptr ///< a pointer to a null-terminated string
|
||||
);
|
||||
|
||||
///
|
||||
/// The compile() function compiles a string pointed to by @a sptr
|
||||
/// and of the length @a slen.
|
||||
/// @return 0 on success, -1 on failure
|
||||
///
|
||||
int compile (
|
||||
const char_t* sptr, ///< a pointer to a string
|
||||
size_t slen ///< the number of characters in the string
|
||||
);
|
||||
int compile (Stream& sstream);
|
||||
|
||||
///
|
||||
/// The execute() function executes compiled commands over the I/O
|
||||
@ -202,7 +190,6 @@ public:
|
||||
///
|
||||
int execute (Stream& iostream);
|
||||
|
||||
|
||||
///
|
||||
/// The stop() function makes a request to break a running loop
|
||||
/// inside execute(). Note that this does not affect blocking
|
||||
@ -310,11 +297,15 @@ protected:
|
||||
sed_t* sed;
|
||||
/// default error formatting string getter
|
||||
errstr_t dflerrstr;
|
||||
/// Stream to read script from
|
||||
Stream* sstream;
|
||||
/// I/O stream to read data from and write output to.
|
||||
Stream* iostream;
|
||||
|
||||
|
||||
private:
|
||||
static ssize_t sin (
|
||||
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
|
||||
static ssize_t xin (
|
||||
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
|
||||
static ssize_t xout (
|
||||
|
@ -369,8 +369,7 @@ void qse_sed_seterror (
|
||||
*/
|
||||
int qse_sed_comp (
|
||||
qse_sed_t* sed, /**< stream editor */
|
||||
const qse_char_t* ptr, /**< pointer to a string containing commands */
|
||||
qse_size_t len /**< the number of characters in the string */
|
||||
qse_sed_io_fun_t inf /**< script stream reader */
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -95,13 +95,13 @@ void* qse_sed_getxtnstd (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_sed_compstd() function compiles a null-terminated sed script.
|
||||
* Call qse_sed_comp() for a length delimited script.
|
||||
* The qse_sed_compstd() function compiles sed scripts specified in
|
||||
* a null-terminated array of stream resources.
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_sed_compstd (
|
||||
qse_sed_t* sed, /**< stream editor */
|
||||
const qse_char_t* str /**< null-terminated script */
|
||||
qse_sed_iostd_t in[] /**< input scripts */
|
||||
);
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ int qse_sed_compstd (
|
||||
* over input streams @a in and an output stream @a out.
|
||||
*
|
||||
* If @a in is not #QSE_NULL, it must point to a null-terminated array
|
||||
* of standard I/O resources. if in[0].type is QSE_SED_IOSTD_NULL, this
|
||||
* of stream resources. if in[0].type is QSE_SED_IOSTD_NULL, this
|
||||
* function returns failure, requiring at least 1 valid resource to be
|
||||
* included in the array.
|
||||
*
|
||||
|
@ -119,6 +119,7 @@ typedef enum qse_tri_t qse_tri_t;
|
||||
/** @typedef qse_ulong_t
|
||||
* The qse_ulong_t type defines the largest unsigned integer type supported
|
||||
*/
|
||||
/* TODO: use qse_int128_t in defining qse_long_t */
|
||||
#if QSE_SIZEOF_LONG >= QSE_SIZEOF_LONG_LONG
|
||||
typedef long qse_long_t;
|
||||
typedef unsigned long qse_ulong_t;
|
||||
|
Reference in New Issue
Block a user