Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Indent the rest of the code (examples, buildtools, doc...) except for examples/SMPI...
[simgrid.git] / tools / tesh2 / src / context.c
index 877ffc2..5db6bee 100644 (file)
  *             This file contains all the definitions of the functions related with\r
  *             the tesh context type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #include <context.h>\r
-\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
+    \r\rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\r
 #define INDEFINITE_SIGNAL      NULL\r
-\r
-context_t\r
-context_new(void)\r
-{\r
-       context_t context = xbt_new0(s_context_t,1);\r
-       \r
-       context->line = NULL;\r
-       context->pos = NULL;\r
-       context->command_line = NULL;\r
-       context->exit_code = 0;\r
-       context->timeout = INDEFINITE;\r
-       context->input = xbt_strbuff_new();\r
-       context->output = xbt_strbuff_new();\r
-       context->signal = INDEFINITE_SIGNAL;\r
-       context->output_handling = oh_check;\r
-       context->async = 0;\r
-\r
-       #ifdef WIN32\r
-       context->t_command_line = NULL;\r
-       #endif\r
-       \r
-       return context;\r
-}\r
-\r
-int\r
-context_free(context_t* ptr)\r
-{\r
-       if(((*ptr)->input))\r
-               xbt_strbuff_free(((*ptr)->input));\r
-\r
-       if(((*ptr)->output))\r
-               xbt_strbuff_free(((*ptr)->output));\r
-       \r
-       if((*ptr)->command_line)\r
-               free((*ptr)->command_line);\r
-\r
-       if((*ptr)->pos)\r
-               free((*ptr)->pos);\r
-\r
-       if((*ptr)->signal)\r
-               free((*ptr)->signal);\r
-\r
-       #ifdef WIN32\r
-       if((*ptr)->t_command_line)\r
-               free((*ptr)->t_command_line);\r
-       #endif\r
-\r
-       *ptr = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-context_reset(context_t context)\r
-{\r
-       context->line = NULL;\r
-       context->pos = NULL;\r
-\r
-       if(context->command_line)\r
-       {\r
-               free(context->command_line);\r
-               context->command_line = NULL;\r
-       }\r
-\r
-       #ifdef WIN32\r
-       if(context->t_command_line)\r
-       {\r
-               free(context->t_command_line);\r
-               context->t_command_line = NULL;\r
-       }\r
-       #endif\r
-\r
-       if(context->pos)\r
-       {\r
-               free(context->pos);\r
-               context->pos = NULL;\r
-       }\r
-\r
-       if(context->input)\r
-               xbt_strbuff_empty(context->input);\r
-\r
-       if(context->output)\r
-               xbt_strbuff_empty(context->output);\r
-       \r
-       if(context->signal)\r
-       {\r
-               free(context->signal);\r
-               context->signal = NULL;\r
-       }\r
-       \r
-       /* default expected exit code */\r
-       context->exit_code = 0;\r
-\r
-       context->output_handling = oh_check;\r
-       context->async = 0;\r
-       \r
-       return 0;\r
-\r
-}\r
-\r
-context_t\r
-context_dup(context_t context)\r
-{\r
-       context_t dup;\r
-       \r
-       dup = xbt_new0(s_context_t, 1);\r
-       \r
-       dup->line = context->line;\r
-       dup->pos = strdup(context->pos);\r
-       dup->command_line = strdup(context->command_line);\r
-\r
-       \r
-       #ifdef WIN32\r
-       dup->t_command_line = strdup(context->t_command_line);\r
-       #endif\r
-\r
-       dup->exit_code = context->exit_code;\r
-       dup->timeout = context->timeout;\r
-       dup->output = NULL;\r
-       dup->input = NULL;\r
-       dup->signal = NULL;\r
-       \r
-       if(context->input->used)\r
-       {\r
-               dup->input = xbt_strbuff_new();\r
-               xbt_strbuff_append(dup->input,context->input->data);\r
-       }\r
-       \r
-       dup->output = xbt_strbuff_new();\r
-\r
-       if(context->output->used)\r
-       {\r
-               xbt_strbuff_append(dup->output,context->output->data);\r
-       }\r
-\r
-       if(context->signal)\r
-       {\r
-               if(!(dup->signal = strdup(context->signal)))\r
-               {\r
-                       free(dup);\r
-                       return NULL;\r
-               }\r
-       }\r
-\r
-       dup->output_handling = context->output_handling;\r
-       \r
-       dup->async = context->async;\r
-       \r
-       return dup;\r
-}\r
-\r
-void\r
-context_clear(context_t context)\r
-{\r
-       context->line = NULL;\r
-       context->pos = NULL;\r
-       \r
-       if(context->command_line)\r
-       {\r
-               free(context->command_line);\r
-               context->command_line = NULL;\r
-       }\r
-\r
-       #ifdef WIN32\r
-       if(context->t_command_line)\r
-       {\r
-               free(context->t_command_line);\r
-               context->t_command_line = NULL;\r
-       }\r
-       #endif\r
-\r
-       if(context->pos)\r
-       {\r
-               free(context->pos);\r
-               context->pos = NULL;\r
-       }\r
-\r
-       context->exit_code = 0;\r
-       context->timeout = INDEFINITE;\r
-       \r
-       if(context->input)\r
-               xbt_strbuff_empty(context->input);\r
-\r
-       if(context->output)\r
-               xbt_strbuff_empty(context->output);\r
-       \r
-       if(context->signal)\r
-       {\r
-               free(context->signal);\r
-               context->signal = INDEFINITE_SIGNAL;\r
-       }\r
-\r
-       context->output_handling = oh_check;\r
-       context->async = 0;\r
-\r
-}\r
-\r
-void\r
-context_input_write(context_t context, const char* buffer)\r
-{\r
-       xbt_strbuff_append(context->input, buffer);\r
-}\r
-\r
-void\r
-context_ouput_read(context_t context, const char* buffer)\r
-{\r
-       xbt_strbuff_append(context->output, buffer);\r
-}\r
-\r
-\r
-\r
+    \rcontext_t \r context_new(void) \r
+{
+  \rcontext_t context = xbt_new0(s_context_t, 1);
+  \r\rcontext->line = NULL;
+  \rcontext->pos = NULL;
+  \rcontext->command_line = NULL;
+  \rcontext->exit_code = 0;
+  \rcontext->timeout = INDEFINITE;
+  \rcontext->input = xbt_strbuff_new();
+  \rcontext->output = xbt_strbuff_new();
+  \rcontext->signal = INDEFINITE_SIGNAL;
+  \rcontext->output_handling = oh_check;
+  \rcontext->async = 0;
+  \r\r
+#ifdef _XBT_WIN32\r
+      context->t_command_line = NULL;
+  \rcontext->is_not_found = 0;
+  \r
+#endif  /* \r */
+      \rreturn context;
+\r}
+
+\r\rint \r context_free(context_t * ptr) \r
+{
+  \rif (((*ptr)->input))
+    \rxbt_strbuff_free(((*ptr)->input));
+  \r\rif (((*ptr)->output))
+    \rxbt_strbuff_free(((*ptr)->output));
+  \r\rif ((*ptr)->command_line)
+    \rfree((*ptr)->command_line);
+  \r\rif ((*ptr)->pos)
+    \rfree((*ptr)->pos);
+  \r\rif ((*ptr)->signal)
+    \rfree((*ptr)->signal);
+  \r\r
+#ifdef _XBT_WIN32\r
+      if ((*ptr)->t_command_line)
+    \rfree((*ptr)->t_command_line);
+  \r
+#endif  /* \r */
+      \r*ptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rint \r context_reset(context_t context) \r
+{
+  \rcontext->line = NULL;
+  \rcontext->pos = NULL;
+  \r\rif (context->command_line)
+    \r {
+    \rfree(context->command_line);
+    \rcontext->command_line = NULL;
+    \r}
+  \r\r
+#ifdef _XBT_WIN32\r
+      if (context->t_command_line)
+    \r {
+    \rfree(context->t_command_line);
+    \rcontext->t_command_line = NULL;
+    \r}
+  \r\rcontext->is_not_found = 0;
+  \r\r
+#endif  /* \r */
+      \rif (context->pos)
+    \r {
+    \rfree(context->pos);
+    \rcontext->pos = NULL;
+    \r}
+  \r\rif (context->input)
+    \rxbt_strbuff_empty(context->input);
+  \r\rif (context->output)
+    \rxbt_strbuff_empty(context->output);
+  \r\rif (context->signal)
+    \r {
+    \rfree(context->signal);
+    \rcontext->signal = NULL;
+    \r}
+  \r\r
+      /* default expected exit code */ \r
+      context->exit_code = 0;
+  \r\rcontext->output_handling = oh_check;
+  \rcontext->async = 0;
+  \r\rreturn 0;
+\r\r}
+
+\r\rcontext_t \r context_dup(context_t context) \r
+{
+  \rcontext_t dup;
+  \r\rdup = xbt_new0(s_context_t, 1);
+  \r\rdup->line = context->line;
+  \rdup->pos = strdup(context->pos);
+  \rdup->command_line = strdup(context->command_line);
+  \r\r\r
+#ifdef _XBT_WIN32\r
+      dup->t_command_line = strdup(context->t_command_line);
+  \rdup->is_not_found = context->is_not_found;
+  \r
+#endif  /* \r */
+      \rdup->exit_code = context->exit_code;
+  \rdup->timeout = context->timeout;
+  \rdup->output = NULL;
+  \rdup->input = NULL;
+  \rdup->signal = NULL;
+  \r\rif (context->input->used)
+    \r {
+    \rdup->input = xbt_strbuff_new();
+    \rxbt_strbuff_append(dup->input, context->input->data);
+    \r}
+  \r\rdup->output = xbt_strbuff_new();
+  \r\rif (context->output->used)
+    \r {
+    \rxbt_strbuff_append(dup->output, context->output->data);
+    \r}
+  \r\rif (context->signal)
+    \r {
+    \rif (!(dup->signal = strdup(context->signal)))
+      \r {
+      \rfree(dup);
+      \rreturn NULL;
+      \r}
+    \r}
+  \r\rdup->output_handling = context->output_handling;
+  \r\rdup->async = context->async;
+  \r\rreturn dup;
+\r}
+
+\r\rvoid \r context_clear(context_t context) \r
+{
+  \rcontext->line = NULL;
+  \rcontext->pos = NULL;
+  \r\rif (context->command_line)
+    \r {
+    \rfree(context->command_line);
+    \rcontext->command_line = NULL;
+    \r}
+  \r\r
+#ifdef _XBT_WIN32\r
+      if (context->t_command_line)
+    \r {
+    \rfree(context->t_command_line);
+    \rcontext->t_command_line = NULL;
+    \r}
+  \rcontext->is_not_found = 0;
+  \r\r
+#endif  /* \r */
+      \rif (context->pos)
+    \r {
+    \rfree(context->pos);
+    \rcontext->pos = NULL;
+    \r}
+  \r\rcontext->exit_code = 0;
+  \rcontext->timeout = INDEFINITE;
+  \r\rif (context->input)
+    \rxbt_strbuff_empty(context->input);
+  \r\rif (context->output)
+    \rxbt_strbuff_empty(context->output);
+  \r\rif (context->signal)
+    \r {
+    \rfree(context->signal);
+    \rcontext->signal = INDEFINITE_SIGNAL;
+    \r}
+  \r\rcontext->output_handling = oh_check;
+  \rcontext->async = 0;
+\r\r}
+
+\r\rvoid \r context_input_write(context_t context, const char *buffer) \r
+{
+  \rxbt_strbuff_append(context->input, buffer);
+\r\r\rvoid \r context_ouput_read(context_t context, const char *buffer) \r
+{
+  \rxbt_strbuff_append(context->output, buffer);
+\r\r\r\r\r