enhanced qse_env_t to use the natural charater type for underlying process execution system call.

enanced qse_pio_t to accept environment
This commit is contained in:
2011-08-10 10:08:26 +00:00
parent 6f7f368a91
commit 93f8bfca65
9 changed files with 352 additions and 154 deletions

View File

@ -29,6 +29,15 @@
* an environment block.
*/
#if defined(_WIN32) && defined(QSE_CHAR_IS_WCHAR)
typedef qse_wchar_t qse_env_char_t;
# define QSE_ENV_CHAR_IS_WCHAR
#else
typedef qse_mchar_t qse_env_char_t;
# define QSE_ENV_CHAR_IS_MCHAR
#endif
/**
* The qse_env_t type defines a cross-platform environment block.
*/
@ -42,14 +51,14 @@ struct qse_env_t
{
qse_size_t capa;
qse_size_t len;
qse_char_t* ptr;
qse_env_char_t* ptr;
} str;
struct
{
qse_size_t capa;
qse_size_t len;
qse_char_t** ptr;
qse_env_char_t** ptr;
} arr;
};
@ -87,17 +96,36 @@ void qse_env_clear (
#define qse_env_getstr(env) ((env)->str.ptr)
#define qse_env_getarr(env) ((env)->arr.ptr)
int qse_env_insert (
int qse_env_insertw (
qse_env_t* env,
const qse_char_t* name,
const qse_char_t* value
const qse_wchar_t* name,
const qse_wchar_t* value
);
int qse_env_delete (
int qse_env_insertm (
qse_env_t* env,
const qse_char_t* name
const qse_mchar_t* name,
const qse_mchar_t* value
);
int qse_env_deletew (
qse_env_t* env,
const qse_wchar_t* name
);
int qse_env_deletem (
qse_env_t* env,
const qse_mchar_t* name
);
#if defined(QSE_CHAR_IS_WCHAR)
# define qse_env_insert(env,name,value) qse_env_insertw(env,name,value)
# define qse_env_delete(env,name) qse_env_deletew(env,name)
#else
# define qse_env_insert(env,name,value) qse_env_insertm(env,name,value)
# define qse_env_delete(env,name) qse_env_deletem(env,name)
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: pio.h 533 2011-08-04 15:43:28Z hyunghwan.chung $
* $Id: pio.h 538 2011-08-09 16:08:26Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -24,6 +24,7 @@
#include <qse/types.h>
#include <qse/macros.h>
#include <qse/cmn/tio.h>
#include <qse/cmn/env.h>
/** @file
* This file defines a piped interface to a child process. You can execute
@ -190,12 +191,15 @@ QSE_DEFINE_COMMON_FUNCTIONS (pio)
* pipes to it. #QSE_PIO_SHELL causes the function to execute @a cmd via
* the default shell of an underlying system: /bin/sh on *nix, cmd.exe on win32.
* On *nix systems, a full path to the command is needed if it is not specified.
* If @a env is #QSE_NULL, the environment of @a cmd inherits that of the
* calling process.
* @return #qse_pio_t object on success, #QSE_NULL on failure
*/
qse_pio_t* qse_pio_open (
qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t ext, /**< extension size */
const qse_char_t* cmd, /**< command to execute */
qse_env_t* env, /**< environment */
int oflags /**< 0 or a number OR'ed of the
#qse_pio_oflag_t enumerators*/
);
@ -218,6 +222,7 @@ qse_pio_t* qse_pio_init (
qse_pio_t* pio, /**< pio object */
qse_mmgr_t* mmgr, /**< memory manager */
const qse_char_t* cmd, /**< command to execute */
qse_env_t* env, /**< environment */
int oflags /**< 0 or a number OR'ed of the
#qse_pio_oflag_t enumerators*/
);