more code enhancement
- renamed pcp back to pio - added more fine-grained control to pio
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h fio.h pcp.h tio.h sio.h time.h
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h
|
||||
|
||||
pkgincludedir = $(includedir)/qse/cmn
|
||||
|
||||
|
@ -177,7 +177,7 @@ sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h fio.h pcp.h tio.h sio.h time.h
|
||||
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h
|
||||
CLEANFILES = *dist
|
||||
all: all-am
|
||||
|
||||
|
@ -89,8 +89,9 @@ typedef struct qse_fio_lck_t qse_fio_lck_t;
|
||||
struct qse_fio_t
|
||||
{
|
||||
QSE_DEFINE_STD_FIELDS (fio)
|
||||
int errnum;
|
||||
qse_fio_hnd_t handle;
|
||||
qse_tio_t* tio;
|
||||
qse_tio_t* tio;
|
||||
};
|
||||
|
||||
struct qse_fio_lck_t
|
||||
@ -101,7 +102,7 @@ struct qse_fio_lck_t
|
||||
qse_fio_ori_t origin; /* origin */
|
||||
};
|
||||
|
||||
#define QSE_FIO_MMGR(fio) ((fio)->mmgr)
|
||||
#define QSE_FIO_ERRNUM(fio) ((fio)->errnum)
|
||||
#define QSE_FIO_HANDLE(fio) ((fio)->handle)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,322 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2008 Chung, Hyung-Hwan.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitapcpns under the License.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_PCP_H_
|
||||
#define _QSE_CMN_PCP_H_
|
||||
|
||||
/* (P)ipe to a (C)hild (P)rocess */
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/tio.h>
|
||||
|
||||
enum qse_pcp_open_flag_t
|
||||
{
|
||||
/* enable ase_char_t based IO */
|
||||
QSE_PCP_TEXT = (1 << 0),
|
||||
|
||||
/* invoke the command through a system shell
|
||||
* (/bin/sh on *nix, command.com on windows) */
|
||||
QSE_PCP_SHELL = (1 << 1),
|
||||
|
||||
QSE_PCP_WRITEIN = (1 << 8),
|
||||
QSE_PCP_READOUT = (1 << 9),
|
||||
QSE_PCP_READERR = (1 << 10),
|
||||
|
||||
QSE_PCP_ERRTOOUT = (1 << 11),
|
||||
QSE_PCP_OUTTOERR = (1 << 12),
|
||||
|
||||
QSE_PCP_INTONUL = (1 << 13),
|
||||
QSE_PCP_ERRTONUL = (1 << 14),
|
||||
QSE_PCP_OUTTONUL = (1 << 15),
|
||||
|
||||
QSE_PCP_DROPIN = (1 << 16),
|
||||
QSE_PCP_DROPOUT = (1 << 17),
|
||||
QSE_PCP_DROPERR = (1 << 18)
|
||||
};
|
||||
|
||||
enum qse_pcp_wait_flag_t
|
||||
{
|
||||
QSE_PCP_NOHANG = (1 << 0),
|
||||
QSE_PCP_IGNINTR = (1 << 1)
|
||||
};
|
||||
|
||||
enum qse_pcp_hid_t
|
||||
{
|
||||
QSE_PCP_IN = 0,
|
||||
QSE_PCP_OUT = 1,
|
||||
QSE_PCP_ERR = 2
|
||||
};
|
||||
|
||||
enum qse_pcp_err_t
|
||||
{
|
||||
QSE_PCP_ENOERR = 0,
|
||||
QSE_PCP_ENOMEM, /* out of memory */
|
||||
QSE_PCP_ENOHND, /* no handle available */
|
||||
QSE_PCP_ECHILD, /* the child is not valid */
|
||||
QSE_PCP_EINTR, /* interrupted */
|
||||
QSE_PCP_ESYSCALL /* system call error */
|
||||
};
|
||||
|
||||
typedef enum qse_pcp_hid_t qse_pcp_hid_t;
|
||||
typedef enum qse_pcp_err_t qse_pcp_err_t;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* <winnt.h> => typedef PVOID HANDLE; */
|
||||
typedef void* qse_pcp_hnd_t;
|
||||
typedef void* qse_pcp_pid_t;
|
||||
# define QSE_PCP_HND_NIL ((qse_pcp_hnd_t)QSE_NULL)
|
||||
# define QSE_PCP_PID_NIL ((qse_pcp_pid_t)QSE_NULL)
|
||||
#else
|
||||
typedef int qse_pcp_hnd_t;
|
||||
typedef int qse_pcp_pid_t;
|
||||
# define QSE_PCP_HND_NIL ((qse_pcp_hnd_t)-1)
|
||||
# define QSE_PCP_PID_NIL ((qse_pcp_hnd_t)-1)
|
||||
#endif
|
||||
|
||||
typedef struct qse_pcp_t qse_pcp_t;
|
||||
typedef struct qse_pcp_pip_t qse_pcp_pip_t;
|
||||
|
||||
struct qse_pcp_pip_t
|
||||
{
|
||||
qse_pcp_hnd_t handle;
|
||||
qse_tio_t* tio;
|
||||
qse_pcp_t* self;
|
||||
};
|
||||
|
||||
struct qse_pcp_t
|
||||
{
|
||||
QSE_DEFINE_STD_FIELDS(pcp)
|
||||
|
||||
qse_pcp_err_t errnum;
|
||||
qse_pcp_pid_t child;
|
||||
qse_pcp_pip_t pip[3];
|
||||
};
|
||||
|
||||
#define QSE_PCP_MMGR(pcp) ((pcp)->mmgr)
|
||||
#define QSE_PCP_XTN(pcp) ((void*)(((qse_pcp_t*)pcp) + 1))
|
||||
#define QSE_PCP_HANDLE(pcp,hid) ((pcp)->pip[3].handle)
|
||||
#define QSE_PCP_CHILD(pcp) ((pcp)->child)
|
||||
#define QSE_PCP_ERRNUM(pcp) ((pcp)->errnum)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
QSE_DEFINE_STD_FUNCTIONS (pcp)
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_open
|
||||
* NAME
|
||||
* qse_pcp_open - open pipes to a child process
|
||||
*
|
||||
* DESCRIPTION
|
||||
* QSE_PCP_SHELL drives the funcpcpn to execute the command via /bin/sh.
|
||||
* If flags is clear of QSE_PCP_SHELL, you should pass the full program path.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pcp_t* qse_pcp_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext,
|
||||
const qse_char_t* cmd,
|
||||
int flags
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_close
|
||||
* NAME
|
||||
* qse_pcp_close - close pipes to a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_pcp_close (
|
||||
qse_pcp_t* pcp
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/pcp/qse_pcp_init
|
||||
* NAME
|
||||
* qse_pcp_init - initialize pipes to a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pcp_t* qse_pcp_init (
|
||||
qse_pcp_t* pcp,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* path,
|
||||
int flags
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/pcp/qse_pcp_fini
|
||||
* NAME
|
||||
* qse_pcp_fini - finalize pipes to a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_pcp_fini (
|
||||
qse_pcp_t* pcp
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_geterrnum
|
||||
* NAME
|
||||
* qse_pcp_geterrnum - get an error code
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pcp_err_t qse_pcp_geterrnum (qse_pcp_t* pcp);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_geterrstr
|
||||
* NAME
|
||||
* qse_pcp_geterrstr - transllate an error code to a string
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_pcp_geterrstr() funcpcpn returns the pointer to a constant string
|
||||
* describing the last error occurred.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
const qse_char_t* qse_pcp_geterrstr (qse_pcp_t* pcp);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_gethandle
|
||||
* NAME
|
||||
* qse_pcp_gethandle - get native handle
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pcp_hnd_t qse_pcp_gethandle (
|
||||
qse_pcp_t* pcp,
|
||||
qse_pcp_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_getchild
|
||||
* NAME
|
||||
* qse_pcp_getchild - get the PID of a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pcp_pid_t qse_pcp_getchild (
|
||||
qse_pcp_t* pcp
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_read
|
||||
* NAME
|
||||
* qse_pcp_read - read data
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_pcp_read (
|
||||
qse_pcp_t* pcp,
|
||||
void* buf,
|
||||
qse_size_t size,
|
||||
qse_pcp_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_write
|
||||
* NAME
|
||||
* qse_pcp_write - write data
|
||||
*
|
||||
* DESCRIPTION
|
||||
* If the parameter 'size' is zero, qse_pcp_write() closes the the writing
|
||||
* stream causing the child process reach the end of the stream.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_pcp_write (
|
||||
qse_pcp_t* pcp,
|
||||
const void* data,
|
||||
qse_size_t size,
|
||||
qse_pcp_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_flush
|
||||
* NAME
|
||||
* qse_pcp_flush - flush data
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_pcp_flush (
|
||||
qse_pcp_t* pcp,
|
||||
qse_pcp_hid_t hid
|
||||
);
|
||||
/*****/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_end
|
||||
* NAME
|
||||
* qse_pcp_end - close native handle
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_pcp_end (
|
||||
qse_pcp_t* pcp,
|
||||
qse_pcp_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_wait
|
||||
* NAME
|
||||
* qse_pcp_wait - wait for a child process
|
||||
*
|
||||
* DESCRIPTION
|
||||
* QSE_PCP_IGNINTR causes the function to retry when the underlying system
|
||||
* call is interrupted.
|
||||
* When you specify QSE_PCP_NOHANG, the return value of 256 indicates that the
|
||||
* child process has not terminated. If the flag is not specified, 256 will
|
||||
* never be returned.
|
||||
*
|
||||
* RETURN
|
||||
* -1 on error, 256 if the child is alive and QSE_PCP_NOHANG is specified,
|
||||
* a number between 0 and 255 inclusive if the child process ends normally,
|
||||
* 256 + signal number if the child process is terminated by a signal.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_pcp_wait (
|
||||
qse_pcp_t* pcp,
|
||||
int flags
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pcp/qse_pcp_kill
|
||||
* NAME
|
||||
* qse_pcp_kill - terminate the child process
|
||||
*
|
||||
* NOTES
|
||||
* You should know the danger of calling this function as the function can
|
||||
* kill a process that is not your child process if it has terminated but
|
||||
* there is a new process with the same process handle.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_pcp_kill (
|
||||
qse_pcp_t* pcp
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
338
qse/include/qse/cmn/pio.h
Normal file
338
qse/include/qse/cmn/pio.h
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2008 Chung, Hyung-Hwan.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitapions under the License.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_PIO_H_
|
||||
#define _QSE_CMN_PIO_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/tio.h>
|
||||
|
||||
enum qse_pio_open_flag_t
|
||||
{
|
||||
/* enable ase_char_t based IO */
|
||||
QSE_PIO_TEXT = (1 << 0),
|
||||
|
||||
/* invoke the command through a system shell
|
||||
* (/bin/sh on *nix, command.com on windows) */
|
||||
QSE_PIO_SHELL = (1 << 1),
|
||||
|
||||
QSE_PIO_WRITEIN = (1 << 8),
|
||||
QSE_PIO_READOUT = (1 << 9),
|
||||
QSE_PIO_READERR = (1 << 10),
|
||||
|
||||
QSE_PIO_ERRTOOUT = (1 << 11),
|
||||
QSE_PIO_OUTTOERR = (1 << 12),
|
||||
|
||||
QSE_PIO_INTONUL = (1 << 13),
|
||||
QSE_PIO_ERRTONUL = (1 << 14),
|
||||
QSE_PIO_OUTTONUL = (1 << 15),
|
||||
|
||||
QSE_PIO_DROPIN = (1 << 16),
|
||||
QSE_PIO_DROPOUT = (1 << 17),
|
||||
QSE_PIO_DROPERR = (1 << 18),
|
||||
};
|
||||
|
||||
enum qse_pio_hid_t
|
||||
{
|
||||
QSE_PIO_IN = 0,
|
||||
QSE_PIO_OUT = 1,
|
||||
QSE_PIO_ERR = 2
|
||||
};
|
||||
|
||||
enum qse_pio_io_flag_t
|
||||
{
|
||||
/*QSE_PIO_READ_NOBLOCK = (1 << 0),*/
|
||||
QSE_PIO_READ_NORETRY = (1 << 1),
|
||||
/*QSE_PIO_WRITE_NOBLOCK = (1 << 2),*/
|
||||
QSE_PIO_WRITE_NORETRY = (1 << 3),
|
||||
QSE_PIO_WAIT_NOBLOCK = (1 << 4),
|
||||
QSE_PIO_WAIT_NORETRY = (1 << 5)
|
||||
};
|
||||
|
||||
enum qse_pio_err_t
|
||||
{
|
||||
QSE_PIO_ENOERR = 0,
|
||||
QSE_PIO_ENOMEM, /* out of memory */
|
||||
QSE_PIO_ENOHND, /* no handle available */
|
||||
QSE_PIO_ECHILD, /* the child is not valid */
|
||||
QSE_PIO_EINTR, /* interrupted */
|
||||
QSE_PIO_ESUBSYS /* subsystem(system call) error */
|
||||
};
|
||||
|
||||
typedef enum qse_pio_hid_t qse_pio_hid_t;
|
||||
typedef enum qse_pio_err_t qse_pio_err_t;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* <winnt.h> => typedef PVOID HANDLE; */
|
||||
typedef void* qse_pio_hnd_t;
|
||||
typedef void* qse_pio_pid_t;
|
||||
# define QSE_PIO_HND_NIL ((qse_pio_hnd_t)QSE_NULL)
|
||||
# define QSE_PIO_PID_NIL ((qse_pio_pid_t)QSE_NULL)
|
||||
#else
|
||||
typedef int qse_pio_hnd_t;
|
||||
typedef int qse_pio_pid_t;
|
||||
# define QSE_PIO_HND_NIL ((qse_pio_hnd_t)-1)
|
||||
# define QSE_PIO_PID_NIL ((qse_pio_hnd_t)-1)
|
||||
#endif
|
||||
|
||||
typedef struct qse_pio_t qse_pio_t;
|
||||
typedef struct qse_pio_pin_t qse_pio_pin_t;
|
||||
|
||||
struct qse_pio_pin_t
|
||||
{
|
||||
qse_pio_hnd_t handle;
|
||||
qse_tio_t* tio;
|
||||
qse_pio_t* self;
|
||||
};
|
||||
|
||||
struct qse_pio_t
|
||||
{
|
||||
QSE_DEFINE_STD_FIELDS(pio)
|
||||
|
||||
int flags;
|
||||
qse_pio_err_t errnum;
|
||||
qse_pio_pid_t child;
|
||||
qse_pio_pin_t pin[3];
|
||||
};
|
||||
|
||||
#define QSE_PIO_ERRNUM(pio) ((pio)->errnum)
|
||||
#define QSE_PIO_FLAGS(pio) ((pio)->flags)
|
||||
#define QSE_PIO_CHILD(pio) ((pio)->child)
|
||||
#define QSE_PIO_HANDLE(pio,hid) ((pio)->pin[hid].handle)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
QSE_DEFINE_STD_FUNCTIONS (pio)
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_open
|
||||
* NAME
|
||||
* qse_pio_open - open pipes to a child process
|
||||
*
|
||||
* DESCRIPTION
|
||||
* QSE_PIO_SHELL drives the funcpion to execute the command via /bin/sh.
|
||||
* If flags is clear of QSE_PIO_SHELL, you should pass the full program path.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pio_t* qse_pio_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext,
|
||||
const qse_char_t* cmd,
|
||||
int flags
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_close
|
||||
* NAME
|
||||
* qse_pio_close - close pipes to a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_pio_close (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/pio/qse_pio_init
|
||||
* NAME
|
||||
* qse_pio_init - initialize pipes to a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pio_t* qse_pio_init (
|
||||
qse_pio_t* pio,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* path,
|
||||
int flags
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn/pio/qse_pio_fini
|
||||
* NAME
|
||||
* qse_pio_fini - finalize pipes to a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_pio_fini (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
int qse_pio_getflags (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
|
||||
void qse_pio_setflags (
|
||||
qse_pio_t* pio,
|
||||
int flags,
|
||||
int op
|
||||
);
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_geterrnum
|
||||
* NAME
|
||||
* qse_pio_geterrnum - get an error code
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pio_err_t qse_pio_geterrnum (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_geterrstr
|
||||
* NAME
|
||||
* qse_pio_geterrstr - transllate an error code to a string
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The qse_pio_geterrstr() funcpion returns the pointer to a constant string
|
||||
* describing the last error occurred.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
const qse_char_t* qse_pio_geterrstr (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_gethandle
|
||||
* NAME
|
||||
* qse_pio_gethandle - get native handle
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pio_hnd_t qse_pio_gethandle (
|
||||
qse_pio_t* pio,
|
||||
qse_pio_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_getchild
|
||||
* NAME
|
||||
* qse_pio_getchild - get the PID of a child process
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_pio_pid_t qse_pio_getchild (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_read
|
||||
* NAME
|
||||
* qse_pio_read - read data
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_pio_read (
|
||||
qse_pio_t* pio,
|
||||
void* buf,
|
||||
qse_size_t size,
|
||||
qse_pio_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_write
|
||||
* NAME
|
||||
* qse_pio_write - write data
|
||||
*
|
||||
* DESCRIPTION
|
||||
* If the parameter 'size' is zero, qse_pio_write() closes the the writing
|
||||
* stream causing the child process reach the end of the stream.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_pio_write (
|
||||
qse_pio_t* pio,
|
||||
const void* data,
|
||||
qse_size_t size,
|
||||
qse_pio_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_flush
|
||||
* NAME
|
||||
* qse_pio_flush - flush data
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_pio_flush (
|
||||
qse_pio_t* pio,
|
||||
qse_pio_hid_t hid
|
||||
);
|
||||
/*****/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_end
|
||||
* NAME
|
||||
* qse_pio_end - close native handle
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_pio_end (
|
||||
qse_pio_t* pio,
|
||||
qse_pio_hid_t hid
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_wait
|
||||
* NAME
|
||||
* qse_pio_wait - wait for a child process
|
||||
*
|
||||
* DESCRIPTION
|
||||
* QSE_PIO_WAIT_NORETRY causes the function to return an error and set the
|
||||
* errnum field to QSE_PIO_EINTR if the underlying system call is interrupted.
|
||||
*
|
||||
* When QSE_PIO_WAIT_NOBLOCK is used, the return value of 256 indicates that
|
||||
* the child process has not terminated. If the flag is not used, 256 is never
|
||||
* returned.
|
||||
*
|
||||
* RETURN
|
||||
* -1 on error, 256 if the child is alive and QSE_PIO_NOBLOCK is used,
|
||||
* a number between 0 and 255 inclusive if the child process ends normally,
|
||||
* 256 + signal number if the child process is terminated by a signal.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_pio_wait (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.pio/qse_pio_kill
|
||||
* NAME
|
||||
* qse_pio_kill - terminate the child process
|
||||
*
|
||||
* NOTES
|
||||
* You should know the danger of calling this function as the function can
|
||||
* kill a process that is not your child process if it has terminated but
|
||||
* there is a new process with the same process handle.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_pio_kill (
|
||||
qse_pio_t* pio
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -41,7 +41,7 @@ enum qse_sio_open_flag_t
|
||||
QSE_SIO_NOSHWR = QSE_FIO_NOSHWR
|
||||
};
|
||||
|
||||
typedef qse_fio_off_t qse_sio_off_t;
|
||||
typedef qse_fio_off_t qse_sio_pos_t;
|
||||
typedef qse_fio_hnd_t qse_sio_hnd_t;
|
||||
|
||||
typedef struct qse_sio_t qse_sio_t;
|
||||
@ -95,6 +95,7 @@ void qse_sio_purge (
|
||||
qse_sio_t* sio
|
||||
);
|
||||
|
||||
#if 0
|
||||
qse_ssize_t qse_sio_getc (
|
||||
qse_sio_t* sio,
|
||||
qse_char_t* c
|
||||
@ -118,20 +119,31 @@ qse_ssize_t qse_sio_putc (
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_puts (
|
||||
qse_sio_t* sio,
|
||||
qse_sio_t* sio,
|
||||
const qse_char_t* str
|
||||
);
|
||||
#endif
|
||||
|
||||
qse_ssize_t qse_sio_read (
|
||||
qse_sio_t* sio,
|
||||
qse_sio_t* sio,
|
||||
qse_char_t* buf,
|
||||
qse_size_t size
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
qse_ssize_t qse_sio_write (
|
||||
qse_sio_t* sio,
|
||||
qse_sio_t* sio,
|
||||
const qse_char_t* str,
|
||||
qse_size_t size
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
int qse_sio_getpos (
|
||||
qse_sio_t* sio,
|
||||
qse_sio_pos_t* pos
|
||||
);
|
||||
|
||||
int qse_sio_setpos (
|
||||
qse_sio_t* sio,
|
||||
qse_sio_pos_t pos
|
||||
);
|
||||
|
||||
#if 0
|
||||
@ -143,8 +155,6 @@ qse_ssize_t qse_sio_putsxv (qse_sio_t* sio, qse_va_list ap);
|
||||
/* WARNING:
|
||||
* getpos may not return the desired postion because of the buffering
|
||||
*/
|
||||
int qse_sio_getpos (qse_sio_t* sio, qse_sio_off_t* pos);
|
||||
int qse_sio_setpos (qse_sio_t* sio, qse_sio_off_t pos);
|
||||
int qse_sio_rewind (qse_sio_t* sio);
|
||||
int qse_sio_movetoend (qse_sio_t* sio);
|
||||
#endif
|
||||
|
@ -223,87 +223,55 @@ int qse_tio_detachout (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_flush
|
||||
* Flushes the output buffer
|
||||
/****f* qse.cmn.tio/qse_tio_flush
|
||||
* NAME
|
||||
* qse_tio_flush - flush the output buffer
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
* RETURNS
|
||||
* The qse_tio_flush() function return the number of bytes written on
|
||||
* success, -1 on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_tio_flush (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* qse.cmn.tio/qse_tio_purge
|
||||
* NAME
|
||||
* qse_tio_purge - erase input and output buffered
|
||||
*
|
||||
* RETURNS:
|
||||
* Number of bytes written on success, -1 on failure
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_tio_flush (qse_tio_t* tio);
|
||||
void qse_tio_purge (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_purge
|
||||
* Erases all input and output buffered
|
||||
/****f* qse.cmn.tio/qse_tio_read
|
||||
* NAME
|
||||
* qse_tio_read - read text
|
||||
*
|
||||
* PARAMETERS:
|
||||
* tio - a tio object
|
||||
*
|
||||
*/
|
||||
void qse_tio_purge (qse_tio_t* tio);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_getc
|
||||
* Reads a single character
|
||||
*/
|
||||
qse_ssize_t qse_tio_getc (qse_tio_t* tio, qse_char_t* c);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_gets
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <qse_tio_gets> inserts a terminating null if there is a room
|
||||
*/
|
||||
qse_ssize_t qse_tio_gets (qse_tio_t* tio, qse_char_t* buf, qse_size_t size);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_getstr
|
||||
*/
|
||||
qse_ssize_t qse_tio_getstr (qse_tio_t* tio, qse_str_t* buf);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putc
|
||||
*/
|
||||
qse_ssize_t qse_tio_putc (qse_tio_t* tio, qse_char_t c);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_puts
|
||||
*/
|
||||
qse_ssize_t qse_tio_puts (qse_tio_t* tio, const qse_char_t* str);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_read
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* <qse_tio_read> doesn't insert a terminating null character
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_tio_read (
|
||||
qse_tio_t* tio,
|
||||
qse_char_t* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
/******/
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putsx
|
||||
/****f* qse.cmn.tio/qse_tio_write
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ssize_t qse_tio_write (
|
||||
qse_tio_t* tio,
|
||||
const qse_char_t* str,
|
||||
const qse_char_t* data,
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putsn
|
||||
*/
|
||||
qse_ssize_t qse_tio_putsn (qse_tio_t* tio, ...);
|
||||
|
||||
/*
|
||||
* FUNCTION: qse_tio_putsxn
|
||||
*/
|
||||
qse_ssize_t qse_tio_putsxn (qse_tio_t* tio, ...);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user