added qse_sed_io_std_t and related code
This commit is contained in:
		| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: awk.h 549 2011-08-14 09:07:31Z hyunghwan.chung $ | ||||
|  * $Id: awk.h 568 2011-09-17 15:41:26Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2011 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -827,11 +827,10 @@ typedef enum qse_awk_option_t qse_awk_option_t; | ||||
| enum qse_awk_errnum_t | ||||
| { | ||||
| 	QSE_AWK_ENOERR,  /**< no error */ | ||||
| 	QSE_AWK_EUNKNOWN,/**< unknown error */ | ||||
|  | ||||
| 	/* common errors */ | ||||
| 	QSE_AWK_EINVAL,  /**< invalid parameter or data */ | ||||
| 	QSE_AWK_ENOMEM,  /**< insufficient memory */ | ||||
| 	QSE_AWK_EINVAL,  /**< invalid parameter or data */ | ||||
| 	QSE_AWK_ENOSUP,  /**< not supported */ | ||||
| 	QSE_AWK_ENOPER,  /**< operation not allowed */ | ||||
| 	QSE_AWK_ENOENT,  /**< '${0}' not found */ | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: sio.h 565 2011-09-11 02:48:21Z hyunghwan.chung $ | ||||
|  * $Id: sio.h 568 2011-09-17 15:41:26Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2011 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -32,20 +32,20 @@ | ||||
|  | ||||
| enum qse_sio_open_flag_t | ||||
| { | ||||
| 	QSE_SIO_HANDLE       = QSE_FIO_HANDLE, | ||||
| 	QSE_SIO_HANDLE        = QSE_FIO_HANDLE, | ||||
| 	QSE_SIO_IGNOREMBWCERR = QSE_FIO_IGNOREMBWCERR, | ||||
|  | ||||
| 	QSE_SIO_READ         = QSE_FIO_READ, | ||||
| 	QSE_SIO_WRITE        = QSE_FIO_WRITE, | ||||
| 	QSE_SIO_APPEND       = QSE_FIO_APPEND, | ||||
| 	QSE_SIO_READ          = QSE_FIO_READ, | ||||
| 	QSE_SIO_WRITE         = QSE_FIO_WRITE, | ||||
| 	QSE_SIO_APPEND        = QSE_FIO_APPEND, | ||||
|  | ||||
| 	QSE_SIO_CREATE       = QSE_FIO_CREATE, | ||||
| 	QSE_SIO_TRUNCATE     = QSE_FIO_TRUNCATE, | ||||
| 	QSE_SIO_EXCLUSIVE    = QSE_FIO_EXCLUSIVE, | ||||
| 	QSE_SIO_SYNC         = QSE_FIO_SYNC, | ||||
| 	QSE_SIO_CREATE        = QSE_FIO_CREATE, | ||||
| 	QSE_SIO_TRUNCATE      = QSE_FIO_TRUNCATE, | ||||
| 	QSE_SIO_EXCLUSIVE     = QSE_FIO_EXCLUSIVE, | ||||
| 	QSE_SIO_SYNC          = QSE_FIO_SYNC, | ||||
|  | ||||
| 	QSE_SIO_NOSHRD       = QSE_FIO_NOSHRD, | ||||
| 	QSE_SIO_NOSHWR       = QSE_FIO_NOSHWR | ||||
| 	QSE_SIO_NOSHRD        = QSE_FIO_NOSHRD, | ||||
| 	QSE_SIO_NOSHWR        = QSE_FIO_NOSHWR | ||||
| }; | ||||
|  | ||||
| typedef qse_fio_off_t qse_sio_pos_t; | ||||
|  | ||||
| @ -49,6 +49,7 @@ enum qse_cut_errnum_t | ||||
| { | ||||
| 	QSE_CUT_ENOERR,  /**< no error */ | ||||
| 	QSE_CUT_ENOMEM,  /**< insufficient memory */ | ||||
| 	QSE_CUT_EINVAL,  /**< invalid parameter or data */ | ||||
| 	QSE_CUT_ESELNV,  /**< selector not valid */ | ||||
| 	QSE_CUT_EIOFIL,  /**< io error with file '${0}'*/ | ||||
| 	QSE_CUT_EIOUSR   /**< error returned by user io handler */ | ||||
|  | ||||
| @ -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 */ | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user