4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
6 #define INDEFINITE_SIGNAL NULL
11 context_t context = xbt_new0(s_context_t, 1);
14 context->command_line = NULL;
15 context->exit_code = 0;
16 context->timeout = INDEFINITE;
17 context->input = xbt_strbuff_new();
18 context->output = xbt_strbuff_new();
19 context->signal = INDEFINITE_SIGNAL;
20 context->output_handling = oh_check;
27 context_dup(context_t context)
30 context_t dup = xbt_new0(s_context_t, 1);
32 dup->line = context->line;
33 dup->command_line = context->command_line;
34 dup->exit_code = context->exit_code;
35 dup->timeout = context->timeout;
40 if(context->input->used)
42 dup->input = xbt_strbuff_new();
43 xbt_strbuff_append(dup->input,context->input->data);
46 if(context->output->used)
48 dup->output = xbt_strbuff_new();
49 xbt_strbuff_append(dup->output,context->output->data);
53 dup->signal = strdup(context->signal);
55 dup->output_handling = context->output_handling;
57 dup->async = context->async;
63 context_clear(context_t context)
66 context->command_line = NULL;
67 context->exit_code = 0;
68 context->timeout = INDEFINITE;
71 xbt_strbuff_empty(context->input);
74 xbt_strbuff_empty(context->output);
78 free(context->signal);
79 context->signal = INDEFINITE_SIGNAL;
82 context->output_handling = oh_check;
88 context_reset(context_t context)
91 context->command_line = NULL;
94 xbt_strbuff_empty(context->input);
97 xbt_strbuff_empty(context->output);
101 free(context->signal);
102 context->signal = NULL;
105 /* default expected exit code */
106 context->exit_code = 0;
108 context->output_handling = oh_check;
114 context_input_write(context_t context, const char* buffer)
116 xbt_strbuff_append(context->input, buffer);
120 context_ouput_read(context_t context, const char* buffer)
122 xbt_strbuff_append(context->output, buffer);
126 context_free(context_t* context)
128 if(((*context)->input))
129 xbt_strbuff_free(((*context)->input));
131 if(((*context)->output))
132 xbt_strbuff_free(((*context)->output));
134 if((*context)->signal)
135 free((*context)->signal);