78 string cmd_line(xxx->
cmd);
79 for (
auto arg : xxx->
args) {
80 if ( !cmd_line.empty() ) {
85 if (arg.find(
' ') ==
NPOS) {
87 }
else if (arg.find(
'"') ==
NPOS) {
89 }
else if (arg.find(
'\'') ==
NPOS) {
101 if ( !quote.empty() ) {
104 cmd_line += replace ?
tmp : arg;
105 if ( !quote.empty() ) {
109 return strdup(cmd_line.c_str());
237 const vector<string>& args,
253 xxx->pipe = pipe ? pipe :
new CPipe;
255 xxx->pipe_size = pipe_size;
258 ccc->handle = xxx.release();
264 return ccc.release();
unique_ptr< T, TDeleter > make_c_unique(T *p, TDeleter d)
Eliminates the necessity for specifying types of both allocated resource and deallocating C function.
@ eTakeOwnership
An object can take ownership of another.
CONNECTOR PIPE_CreateConnector(const string &cmd, const vector< string > &args, CPipe::TCreateFlags flags, CPipe *pipe, EOwnership own_pipe, size_t pipe_size)
Create CPipe-based CONNECTOR.
#define CONN_SET_METHOD(meta, method, function, connector)
const STimeout * default_timeout
default timeout pointer
void * handle
data handle of the connector
SMetaConnector * meta
back link to original meta
EIO_Status Write(const void *data, size_t count, size_t *written=0)
Write data to pipe (data always goes to the child's eStdIn handle).
TChildPollMask Poll(TChildPollMask mask, const STimeout *timeout=0)
Wait for I/O event(s).
unsigned int TChildPollMask
bitwise OR of "EChildIOHandle"
EIO_Status SetTimeout(EIO_Event event, const STimeout *timeout)
Specify timeout for the pipe I/O.
EIO_Status Read(void *buf, size_t count, size_t *read=0, EChildIOHandle from_handle=eDefault)
Read data from the pipe's default read handle.
EIO_Status Open(const string &cmd, const vector< string > &args, TCreateFlags create_flags=0, const string ¤t_dir=kEmptyStr, const char *const env[]=0, size_t pipe_size=0)
Open pipe.
unsigned int TCreateFlags
bitwise OR of "ECreateFlag"
EIO_Status Close(int *exitcode=0)
Close pipe.
EIO_Status Status(EIO_Event direction) const
Return a status of the last I/O operation.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
EIO_Event
I/O event (or direction).
@ eIO_Success
everything is fine, no error occurred
@ eIO_Unknown
unknown I/O error (likely fatal but can retry)
@ eIO_Close
also serves as an error indicator in SOCK_Poll
if(yy_accept[yy_current_state])
const struct ncbi::grid::netcache::search::fields::SIZE size
static EIO_Status s_VT_Write(CONNECTOR connector, const void *buf, size_t size, size_t *n_written, const STimeout *timeout)
static EIO_Status s_VT_Read(CONNECTOR connector, void *buf, size_t size, size_t *n_read, const STimeout *timeout)
static EIO_Status s_VT_Close(CONNECTOR connector, const STimeout *timeout)
static const char * s_VT_GetType(CONNECTOR)
static void s_Setup(CONNECTOR connector)
static EIO_Status s_VT_Status(CONNECTOR connector, EIO_Event dir)
static EIO_Status s_VT_Wait(CONNECTOR connector, EIO_Event event, const STimeout *timeout)
static EIO_Status s_VT_Open(CONNECTOR connector, const STimeout *)
static void s_Destroy(CONNECTOR connector)
static char * s_VT_Descr(CONNECTOR connector)
Implement CONNECTOR for a pipe interprocess communication (based on the NCBI CPipe).
CPipe::TCreateFlags flags