112 inline int in ()
const {
return rep[0]; }
113 inline int out ()
const {
return rep[1]; }
142 int n =
c->buffer_size;
143 char*
b =
A (
c->buffer);
148 if (
m > 0)
c->data.append (
b,
m);
150 if (close (fd) != 0)
c->status= -1;
161 const char*
d =
c->data.a;
162 int n =
c->buffer_size;
163 int t= (
c->data).n,
k= 0,
o= 0;
164 if (
t == 0)
return (
void*)
NULL;
172 o= write (fd, (
void*) (
d +
k),
m);
180 if (close (fd) != 0)
c->status= -1;
182 }
while (
o > 0 &&
k <
t);
188 posix_spawn_file_actions_t
rep;
209 if (
N (
arg) == 0)
return 0;
216 for (
int i= 0; i <
n_in; i++) {
218 pp_in[i].out ()) != 0)
225 pp_in[i].in ()) != 0)
229 for (
int i= 0; i <
n_out; i++) {
241 for (
int j= 0;
j <
N (
arg);
j++)
242 for (
int i= 0; i <
n_in; i++)
259 for (
int i= 0; i <
n_in; i++)
260 close (
pp_in[i].in ());
261 for (
int i= 0; i <
n_out; i++)
267 for (
int i= 0; i <
n_in; i++) {
277 for (
int i= 0; i <
n_out; i++) {
297 for (
int i= 0; i <
n_in; i++) {
301 for (
int i= 0; i <
n_out; i++) {
bool read(string s, int &i, const char *test)
array< string > tokenize(string s, string sep)
string recompose(array< string > a, string sep)
string replace(string s, string what, string by)
T * A(array< T > a)
Get a pointer to the first element of the array.
int N(array< T > a)
Get the length of the array.
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
The list class represents a linked list.
list(T item)
Construct a new list object with a single item.
void tm_delete_array(C *Ptr)
SI min(SI i, SI j)
Returns the minimum of two signed integers.
SI max(SI i, SI j)
Returns the maximum of two signed integers.
char * as_charp(string s)
string as_string(int16_t i)
void _init_in(int fd2, string data2, int chunk_size)
void _init_out(int fd2, int buffer_size2)
posix_spawn_file_actions_t rep
void append(char *b, int m)
void copy(char *b, int m)
static void * _background_write_task(void *channel_as_void_ptr)
static void * _background_read_task(void *channel_as_void_ptr)
int unix_system(array< string > arg, array< int > fd_in, array< string > str_in, array< int > fd_out, array< string * > str_out)
static _mutex _ts_memory_lock
string unix_get_username()
static void _unix_system_warn(pid_t pid, string which, string msg)