added qse_sed_io_std_t and related code

This commit is contained in:
2011-09-18 09:41:26 +00:00
parent 0d4ea6aab9
commit ecaed2c2b3
13 changed files with 513 additions and 237 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: sed.h 563 2011-09-08 07:49:53Z hyunghwan.chung $
* $Id: sed.h 568 2011-09-17 15:41:26Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -82,6 +82,7 @@ enum qse_sed_errnum_t
{
QSE_SED_ENOERR, /**< no error */
QSE_SED_ENOMEM, /**< insufficient memory */
QSE_SED_EINVAL, /**< invalid parameter or data */
QSE_SED_ECMDNR, /**< command '${0}' not recognized */
QSE_SED_ECMDMS, /**< command code missing */
QSE_SED_ECMDIC, /**< command '${0}' incomplete */

View File

@ -22,6 +22,7 @@
#define _QSE_SED_STD_H_
#include <qse/sed/sed.h>
#include <qse/cmn/sio.h>
/** @file
* This file defines easier-to-use helper interface for a stream editor.
@ -35,6 +36,29 @@
* functions.
*/
/**
* The qse_sed_iostd_t type defines standard I/O resources.
*/
typedef struct qse_sed_iostd_t qse_sed_iostd_t;
struct qse_sed_iostd_t
{
enum
{
QSE_SED_IOSTD_NULL, /** invalid resource */
QSE_SED_IOSTD_SIO,
QSE_SED_IOSTD_FILE,
QSE_SED_IOSTD_MEM
} type;
union
{
qse_sio_t* sio;
const qse_char_t* file;
qse_xstr_t mem;
} u;
};
#ifdef __cplusplus
extern "C" {
#endif
@ -82,15 +106,22 @@ int qse_sed_compstd (
/**
* The qse_sed_execstd() function executes the compiled script
* over an input file @a infile and an output file @a outfile.
* If @a infile is #QSE_NULL, the standard console input is used.
* If @a outfile is #QSE_NULL, the standard console output is used.
* 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] is QSE_NULL, this function
* returns failure, requiring at least 1 valid resource to be included
* in the array.
*
* If @a in is #QSE_NULL, the standard console input is used.
* If @a out is #QSE_NULL, the standard console output is used.
*
* @return 0 on success, -1 on failure
*/
int qse_sed_execstd (
qse_sed_t* sed, /**< stream editor */
const qse_char_t* infile, /**< input file */
const qse_char_t* outfile /**< output file */
qse_sed_t* sed,
qse_sed_iostd_t in[],
qse_sed_iostd_t* out
);
#ifdef __cplusplus