interim commit for qse_pio_t
- adding code to support QSE_PIO_TEXT. not compilable yet.
This commit is contained in:
		| @ -21,6 +21,7 @@ | |||||||
|  |  | ||||||
| #include <qse/types.h> | #include <qse/types.h> | ||||||
| #include <qse/macros.h> | #include <qse/macros.h> | ||||||
|  | #include <qse/cmn/tio.h> | ||||||
|  |  | ||||||
| enum qse_pio_open_flag_t | enum qse_pio_open_flag_t | ||||||
| { | { | ||||||
| @ -90,9 +91,11 @@ typedef struct qse_pio_t qse_pio_t; | |||||||
| struct qse_pio_t | struct qse_pio_t | ||||||
| { | { | ||||||
| 	qse_mmgr_t*   mmgr; | 	qse_mmgr_t*   mmgr; | ||||||
| 	qse_pio_pid_t child; |  | ||||||
| 	qse_pio_hnd_t handle[3]; |  | ||||||
| 	qse_pio_err_t errnum; | 	qse_pio_err_t errnum; | ||||||
|  | 	qse_pio_pid_t child; | ||||||
|  |  | ||||||
|  | 	qse_pio_hnd_t handle[3]; | ||||||
|  | 	qse_tio_t*    tio[3]; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #define QSE_PIO_MMGR(pio)       ((pio)->mmgr) | #define QSE_PIO_MMGR(pio)       ((pio)->mmgr) | ||||||
| @ -256,6 +259,11 @@ qse_ssize_t qse_pio_write ( | |||||||
| ); | ); | ||||||
| /******/ | /******/ | ||||||
|  |  | ||||||
|  | void qse_pio_flush ( | ||||||
|  | 	qse_pio_t*    pio, | ||||||
|  | 	qse_pio_hid_t hid | ||||||
|  | ); | ||||||
|  |  | ||||||
| /****f* qse.cmn.pio/qse_pio_end | /****f* qse.cmn.pio/qse_pio_end | ||||||
|  * NAME |  * NAME | ||||||
|  *  qse_pio_end |  *  qse_pio_end | ||||||
|  | |||||||
| @ -230,7 +230,6 @@ int qse_tio_detachout ( | |||||||
| 	qse_tio_t* tio | 	qse_tio_t* tio | ||||||
| ); | ); | ||||||
|  |  | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * FUNCTION: qse_tio_flush |  * FUNCTION: qse_tio_flush | ||||||
|  *   Flushes the output buffer |  *   Flushes the output buffer | ||||||
|  | |||||||
| @ -32,6 +32,14 @@ | |||||||
|  |  | ||||||
| #define CHILD_EXIT_CODE 128 | #define CHILD_EXIT_CODE 128 | ||||||
|  |  | ||||||
|  | static qse_ssize_t pio_read ( | ||||||
|  | 	qse_pio_t* pio, void* buf, qse_size_t size, qse_pio_hid_t hid); | ||||||
|  | static qse_ssize_t pio_write ( | ||||||
|  | 	qse_pio_t* pio, const void* data, qse_size_t size, qse_pio_hid_t hid)a; | ||||||
|  |  | ||||||
|  | static qse_ssize_t pio_input (int cmd, void* arg, void* buf, qse_size_t size); | ||||||
|  | static qse_ssize_t pio_output (int cmd, void* arg, void* buf, qse_size_t size); | ||||||
|  |  | ||||||
| qse_pio_t* qse_pio_open ( | qse_pio_t* qse_pio_open ( | ||||||
| 	qse_mmgr_t* mmgr, qse_size_t ext, | 	qse_mmgr_t* mmgr, qse_size_t ext, | ||||||
| 	const qse_char_t* path, int flags) | 	const qse_char_t* path, int flags) | ||||||
| @ -343,10 +351,33 @@ http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  | 	if (flags & QSE_PIO_TEXT) | ||||||
|  | 	{ | ||||||
|  | 		qse_tio_t* tio[3]; | ||||||
|  |  | ||||||
|  | 		tio[0] = qse_tio_open (pio->mmgr, 0); | ||||||
|  | 		tio[1] = qse_tio_open (pio->mmgr, 0); | ||||||
|  | 		tio[2] = qse_tio_open (pio->mmgr, 0); | ||||||
|  |  | ||||||
|  | 		qse_tio_attachout (tio[0], pio_output, &handle[1]); | ||||||
|  | 		qse_tio_attachin (tio[1], pio_input, &handle[2]); | ||||||
|  | 		qse_tio_attachin (tio[2], pio_input, &handle[4]); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/* store back references */ | ||||||
|  | 	pio->p[QSE_PIO_IN].self = pio; | ||||||
|  | 	pio->p[QSE_PIO_OUT].self = pio; | ||||||
|  | 	pio->p[QSE_PIO_ERR].self = pio; | ||||||
|  |  | ||||||
|  | 	/* store actual pipe handles */ | ||||||
|  | 	pio->p[QSE_PIO_IN].handle = handle[1]; | ||||||
|  | 	pio->p[QSE_PIO_OUT].handle = handle[2]; | ||||||
|  | 	pio->p[QSE_PIO_ERR].handle = handle[4]; | ||||||
|  | /* | ||||||
| 	pio->handle[QSE_PIO_IN] = handle[1]; | 	pio->handle[QSE_PIO_IN] = handle[1]; | ||||||
| 	pio->handle[QSE_PIO_OUT] = handle[2]; | 	pio->handle[QSE_PIO_OUT] = handle[2]; | ||||||
| 	pio->handle[QSE_PIO_ERR] = handle[4]; | 	pio->handle[QSE_PIO_ERR] = handle[4]; | ||||||
|  | */ | ||||||
|  |  | ||||||
| 	return pio; | 	return pio; | ||||||
|  |  | ||||||
| @ -375,6 +406,24 @@ qse_pio_pid_t qse_pio_getchild (qse_pio_t* pio) | |||||||
|  |  | ||||||
| qse_ssize_t qse_pio_read ( | qse_ssize_t qse_pio_read ( | ||||||
| 	qse_pio_t* pio, void* buf, qse_size_t size, qse_pio_hid_t hid) | 	qse_pio_t* pio, void* buf, qse_size_t size, qse_pio_hid_t hid) | ||||||
|  | { | ||||||
|  | 	if (pio->p[hid].tio == QSE_NULL)  | ||||||
|  | 		return pio_read (pio, buf, size, hid); | ||||||
|  | 	else | ||||||
|  | 		return qse_tio_read (pio->p[hid].tio, buf, size); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | qse_ssize_t qse_pio_write ( | ||||||
|  | 	qse_pio_t* pio, const void* data, qse_size_t size, qse_pio_hid_t hid) | ||||||
|  | { | ||||||
|  | 	if (pio->p[hid].tio == QSE_NULL) | ||||||
|  | 		return pio_write (pio, buf, size, hid); | ||||||
|  | 	else | ||||||
|  | 		return qse_tio_write (pio->p[hid].tio, buf, size); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | static qse_ssize_t pio_read ( | ||||||
|  | 	qse_pio_t* pio, void* buf, qse_size_t size, qse_pio_hid_t hid) | ||||||
| { | { | ||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
| 	DWORD count; | 	DWORD count; | ||||||
| @ -406,7 +455,7 @@ qse_ssize_t qse_pio_read ( | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| qse_ssize_t qse_pio_write ( | static qse_ssize_t pio_write ( | ||||||
| 	qse_pio_t* pio, const void* data, qse_size_t size, qse_pio_hid_t hid) | 	qse_pio_t* pio, const void* data, qse_size_t size, qse_pio_hid_t hid) | ||||||
| { | { | ||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
| @ -577,3 +626,19 @@ int qse_pio_kill (qse_pio_t* pio) | |||||||
| 	return n; | 	return n; | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static qse_ssize_t pio_input (int cmd, void* arg, void* buf, qse_size_t size) | ||||||
|  | { | ||||||
|  |         qse_pio_t* pio = (qse_pio_t*)arg; | ||||||
|  |         QSE_ASSERT (pio != QSE_NULL); | ||||||
|  |         if (cmd == QSE_TIO_IO_DATA) return pio_read (pio, buf, size, hid); | ||||||
|  |         return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | static qse_ssize_t pio_output (int cmd, void* arg, void* buf, qse_size_t size) | ||||||
|  | { | ||||||
|  |         qse_pio_t* pio = (qse_pio_t*)arg; | ||||||
|  |         QSE_ASSERT (pio != QSE_NULL); | ||||||
|  |         if (cmd == QSE_TIO_IO_DATA) return pio_write (pio, buf, size, hid); | ||||||
|  |         return 0; | ||||||
|  | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user