Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Indent the rest of the code (examples, buildtools, doc...) except for examples/SMPI...
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 11 Oct 2010 09:49:00 +0000 (09:49 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 11 Oct 2010 09:49:00 +0000 (09:49 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8395 48e7efb5-ca39-0410-a469-dd3cf9ba447f

220 files changed:
buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c
buildtools/Cmake/test_prog/prog_GRAS_ARCH.c
buildtools/Cmake/test_prog/prog_GRAS_CHECK_STRUCT_COMPACTION.c
buildtools/Cmake/test_prog/prog_getline.c
buildtools/Cmake/test_prog/prog_max_size.c
buildtools/Cmake/test_prog/prog_mutex_timedlock.c
buildtools/Cmake/test_prog/prog_printf_null.c
buildtools/Cmake/test_prog/prog_sem_init.c
buildtools/Cmake/test_prog/prog_sem_timedwait.c
buildtools/Cmake/test_prog/prog_snprintf.c
buildtools/Cmake/test_prog/prog_stackgrowth.c
buildtools/Cmake/test_prog/prog_stacksetup.c
buildtools/Cmake/test_prog/prog_vsnprintf.c
buildtools/builder6/libgras/libgras.c
buildtools/builder6/simgrid/simgrid.c
buildtools/vc7/cxx/SimGridX.c
buildtools/vc7/simgrid/simgrid.c
buildtools/vc7/simgrid4java/libSimgrid4java.c
doc/gtut-files/01-bones.c
doc/gtut-files/02-simple.c
doc/gtut-files/03-args.c
doc/gtut-files/04-callback.c
doc/gtut-files/05-globals.c
doc/gtut-files/06-logs.c
doc/gtut-files/07-timers.c
doc/gtut-files/08-exceptions.c
doc/gtut-files/09-datatype-dump.c
doc/gtut-files/09-simpledata.c
doc/gtut-files/10-rpc.c
doc/gtut-files/11-explicitwait.c
examples/amok/alnem/alnem.c
examples/amok/alnem/alnem_builder.c
examples/amok/bandwidth/bandwidth.c
examples/amok/saturate/env.c
examples/amok/saturate/saturate.c
examples/gras/all2all/all2all.c
examples/gras/chrono/chrono2.c
examples/gras/console/ping_server.c
examples/gras/mmrpc/mmrpc.c
examples/gras/mmrpc/mmrpc.h
examples/gras/mmrpc/mmrpc_common.c
examples/gras/p2p/can/can.c
examples/gras/p2p/can/can_tests.c
examples/gras/p2p/can/types.h
examples/gras/p2p/chord/chord.c
examples/gras/ping/ping_server.c
examples/gras/pmm/pmm.c
examples/gras/properties/properties.c
examples/gras/replay/replay.c
examples/gras/replay/workload.h
examples/gras/replay/xbt_workload.c
examples/gras/rpc/rpc.c
examples/gras/spawn/spawn_child.c
examples/gras/spawn/spawn_father.c
examples/gras/synchro/philosopher.c
examples/gras/timer/timer.c
examples/msg/actions/actions.c
examples/msg/alias/masterslave_forwarder_with_alias.c
examples/msg/gtnets/gtnets.c
examples/msg/icomms/peer.c
examples/msg/icomms/peer2.c
examples/msg/icomms/peer3.c
examples/msg/masterslave/masterslave_bypass.c
examples/msg/masterslave/masterslave_console.c
examples/msg/masterslave/masterslave_failure.c
examples/msg/masterslave/masterslave_forwarder.c
examples/msg/masterslave/masterslave_mailbox.c
examples/msg/mc/bugged1.c
examples/msg/mc/bugged2.c
examples/msg/mc/bugged3.c
examples/msg/mc/centralized_mutex.c
examples/msg/mc/random_test.c
examples/msg/migration/migration.c
examples/msg/parallel_task/test_ptask.c
examples/msg/priority/priority.c
examples/msg/properties/msg_prop.c
examples/msg/sendrecv/sendrecv.c
examples/msg/trace/test_trace_integration.c
examples/msg/tracing/categories.c
examples/msg/tracing/ms.c
examples/msg/tracing/procmig.c
examples/msg/tracing/tasks.c
examples/msg/tracing/volume.c
examples/simdag/dax/dax_test.c
examples/simdag/dot/dot_test.c
examples/simdag/scheduling/minmin_test.c
examples/simdag/sd_seq_access.c
examples/simdag/sd_test.c
examples/simdag/sd_test2.c
examples/simdag/sd_test_console.c
examples/smpi/allreduce.c
examples/smpi/alltoall2.c
examples/smpi/alltoall_basic.c
examples/smpi/alltoallv.c
examples/smpi/barrier.c
examples/smpi/bcast.c
examples/smpi/bcbench.c
examples/smpi/compute2.c
examples/smpi/compute3.c
examples/smpi/get_processor_name.c
examples/smpi/mvmul.c
examples/smpi/pingpong.c
examples/smpi/reduce.c
examples/smpi/scatter.c
examples/smpi/sendrecv.c
examples/smpi/smpi_traced.c
examples/smpi/ttest01.c
examples/xbt/sem_basic.c
examples/xbt/sem_sched.c
teshsuite/gras/datadesc/datadesc_structs.c
teshsuite/gras/datadesc/datadesc_usage.c
teshsuite/gras/msg_handle/msg_handle.c
teshsuite/msg/get_sender.c
teshsuite/simdag/basic0.c
teshsuite/simdag/basic1.c
teshsuite/simdag/basic2.c
teshsuite/simdag/basic3.c
teshsuite/simdag/basic4.c
teshsuite/simdag/basic5.c
teshsuite/simdag/basic6.c
teshsuite/simdag/network/p2p/test_latency1.c
teshsuite/simdag/network/p2p/test_latency2.c
teshsuite/simdag/network/p2p/test_latency3.c
teshsuite/simdag/network/p2p/test_latency_bound.c
teshsuite/simdag/network/test_reinit_costs.c
teshsuite/simdag/platforms/basic_parsing_test.c
teshsuite/simdag/platforms/is_router_test.c
teshsuite/xbt/log_large_test.c
teshsuite/xbt/parallel_log_crashtest.c
testsuite/simdag/sd_test.c
testsuite/surf/lmm_usage.c
testsuite/surf/surf_usage.c
testsuite/surf/surf_usage2.c
testsuite/surf/trace_usage.c
testsuite/xbt/graphxml_usage.c
testsuite/xbt/heap_bench.c
testsuite/xbt/log_usage.c
tools/gras/stub_generator.c
tools/gras/unix_stub_generator.c
tools/gras/windows_stub_generator.c
tools/tesh/run_context.c
tools/tesh/run_context.h
tools/tesh/tesh.c
tools/tesh/tesh.h
tools/tesh2/include/com.h
tools/tesh2/include/command.h
tools/tesh2/include/context.h
tools/tesh2/include/def.h
tools/tesh2/include/directories.h
tools/tesh2/include/directory.h
tools/tesh2/include/excludes.h
tools/tesh2/include/explode.h
tools/tesh2/include/fstream.h
tools/tesh2/include/fstreams.h
tools/tesh2/include/getpath.h
tools/tesh2/include/is_cmd.h
tools/tesh2/include/reader.h
tools/tesh2/include/readline.h
tools/tesh2/include/runner.h
tools/tesh2/include/str_replace.h
tools/tesh2/include/timer.h
tools/tesh2/include/types.h
tools/tesh2/include/unit.h
tools/tesh2/include/units.h
tools/tesh2/include/variable.h
tools/tesh2/include/writer.h
tools/tesh2/include/xerrno.h
tools/tesh2/include/xsignal.h
tools/tesh2/src/command.c
tools/tesh2/src/context.c
tools/tesh2/src/directories.c
tools/tesh2/src/directory.c
tools/tesh2/src/excludes.c
tools/tesh2/src/explode.c
tools/tesh2/src/fstream.c
tools/tesh2/src/fstreams.c
tools/tesh2/src/getpath.c
tools/tesh2/src/is_cmd.c
tools/tesh2/src/main.c
tools/tesh2/src/reader.c
tools/tesh2/src/readline.c
tools/tesh2/src/runner.c
tools/tesh2/src/str_replace.c
tools/tesh2/src/timer.c
tools/tesh2/src/unit.c
tools/tesh2/src/units.c
tools/tesh2/src/variable.c
tools/tesh2/src/writer.c
tools/tesh2/src/xerrno.c
tools/tesh2/src/xsignal.c
tools/tesh2/w32/include/dirent.h
tools/tesh2/w32/include/getopt.h
tools/tesh2/w32/src/Cat.c
tools/tesh2/w32/src/dirent.c
tools/tesh2/w32/src/getopt.c
win32_test_app/include/TBuffer.h
win32_test_app/include/TDefs.h
win32_test_app/include/TErrno.h
win32_test_app/include/TStream.h
win32_test_app/include/TTestCaseContext.h
win32_test_app/include/TTestRunner.h
win32_test_app/include/TTestSuite.h
win32_test_app/include/TThreadDynarray.h
win32_test_app/include/TTime.h
win32_test_app/src/TBuffer.c
win32_test_app/src/TErrno.c
win32_test_app/src/TStream.c
win32_test_app/src/TTestCaseContext.c
win32_test_app/src/TTestRunner.c
win32_test_app/src/TTestSuite.c
win32_test_app/src/TThreadDynarray.c
win32_test_app/src/TTime.c
win32_test_app/src/Test.c
win32_testsuite/borland/builder6/realistic/gras/datadesc_usage/datadesc_structs.c
win32_testsuite/borland/builder6/realistic/gras/datadesc_usage/datadesc_usage.c
win32_testsuite/borland/builder6/simulation/surf/trace_usage/trace_usage.c
win32_testsuite/borland/builder6/simulation/xbt/context_usage/context_usage.c
win32_testsuite/borland/builder6/simulation/xbt/graphxml_usage/graphxml_usage.c
win32_testsuite/borland/builder6/simulation/xbt/heap_bench/heap_bench.c
win32_testsuite/borland/builder6/simulation/xbt/log_usage/log_usage.c

index 2fc26ed..59d5289 100644 (file)
@@ -8,10 +8,10 @@
 #include <stdlib.h>
 
 #ifdef _XBT_WIN32
-       #include "win32_ucontext.h"
-       #include "win32_ucontext.c"
+#include "win32_ucontext.h"
+#include "win32_ucontext.c"
 #else
-       #include <ucontext.h>
+#include <ucontext.h>
 #endif
 
 void child(void);
@@ -23,43 +23,43 @@ ucontext_t uc_main;
 
 void child(void)
 {
-    if (swapcontext(&uc_child, &uc_main) != 0)
-        exit(2);
+  if (swapcontext(&uc_child, &uc_main) != 0)
+    exit(2);
 }
 
 int main(int argc, char *argv[])
 {
-    FILE *fp;
-    void *stack;
+  FILE *fp;
+  void *stack;
 
-    /* the default is that it fails */
-    if ((fp = fopen("conftestval", "w")) == NULL)
-        exit(3);
-    fprintf(fp, "no\n");
-    fclose(fp);
+  /* the default is that it fails */
+  if ((fp = fopen("conftestval", "w")) == NULL)
+    exit(3);
+  fprintf(fp, "no\n");
+  fclose(fp);
 
-    /* configure a child user-space context */
-    if ((stack = malloc(64*1024)) == NULL)
-        exit(4);
-    if (getcontext(&uc_child) != 0)
-        exit(5);
-    uc_child.uc_link = NULL;
-    uc_child.uc_stack.ss_sp = (char *)stack+(32*1024);
-    uc_child.uc_stack.ss_size = 32*1024;
-    uc_child.uc_stack.ss_flags = 0;
-    makecontext(&uc_child, child, 0);
+  /* configure a child user-space context */
+  if ((stack = malloc(64 * 1024)) == NULL)
+    exit(4);
+  if (getcontext(&uc_child) != 0)
+    exit(5);
+  uc_child.uc_link = NULL;
+  uc_child.uc_stack.ss_sp = (char *) stack + (32 * 1024);
+  uc_child.uc_stack.ss_size = 32 * 1024;
+  uc_child.uc_stack.ss_flags = 0;
+  makecontext(&uc_child, child, 0);
 
-    /* switch into the user context */
-    if (swapcontext(&uc_main, &uc_child) != 0)
-        exit(6);
+  /* switch into the user context */
+  if (swapcontext(&uc_main, &uc_child) != 0)
+    exit(6);
 
-    /* Fine, child came home */
-    if ((fp = fopen("conftestval", "w")) == NULL)
-        exit(7);
-    fprintf(fp, "yes\n");
-    fclose(fp);
+  /* Fine, child came home */
+  if ((fp = fopen("conftestval", "w")) == NULL)
+    exit(7);
+  fprintf(fp, "yes\n");
+  fclose(fp);
 
-    /* die successfully */
-    exit(0);
-       return 1;
+  /* die successfully */
+  exit(0);
+  return 1;
 }
index 52b03af..00b6dff 100644 (file)
@@ -9,49 +9,72 @@
 #include <sys/types.h>
 #include <stdio.h>
 
-int main (void)
+int main(void)
 {
 
-       int c = sizeof(char);
-       int si = sizeof(short int);
-       int i = sizeof(int);
-       int li = sizeof(long int);
-       int lli = sizeof(long long int);
-       int f = sizeof(float);
-       int v = sizeof(void *);
-       int vv = sizeof(void (*) (void));
-       /*printf("char : %d\n",c);
-       printf("short int : %d\n",si);
-       printf("int : %d\n",i);
-       printf("long int : %d\n",li);
-       printf("long long int : %d\n",lli);
-       printf("float : %d\n",f);
-       printf("void * : %d\n",v);
-       printf("void (*) (void) : %d\n",vv);*/
+  int c = sizeof(char);
+  int si = sizeof(short int);
+  int i = sizeof(int);
+  int li = sizeof(long int);
+  int lli = sizeof(long long int);
+  int f = sizeof(float);
+  int v = sizeof(void *);
+  int vv = sizeof(void (*)(void));
+  /*printf("char : %d\n",c);
+     printf("short int : %d\n",si);
+     printf("int : %d\n",i);
+     printf("long int : %d\n",li);
+     printf("long long int : %d\n",lli);
+     printf("float : %d\n",f);
+     printf("void * : %d\n",v);
+     printf("void (*) (void) : %d\n",vv); */
 
-       struct s0 {char c0; char i0;};
-       struct s1 {char c1; short int i1;};
-       struct s2 {char c2; int i2;};
-       struct s3 {char c3; long int i3;};
-       struct s4 {char c4; long long int i4;};
-       struct s5 {char c5; double i5;};
-       struct s6 {char c6; void * i6;};
-       int res0=sizeof(struct s0)-sizeof(char);
-       int res1=sizeof(struct s1)-sizeof(short int);
-       int res2=sizeof(struct s2)-sizeof(int);
-       int res3=sizeof(struct s3)-sizeof(long int);
-       int res4=sizeof(struct s4)-sizeof(long long int);
-       int res5=sizeof(struct s5)-sizeof(double);
-       int res6=sizeof(struct s6)-sizeof(void *);
-       /*printf("struct-char : %d\n",res0);
-       printf("struct-short int : %d\n",res1); 
-       printf("struct-int : %d\n",res2);       
-       printf("struct-long int : %d\n",res3);  
-       printf("struct-long long int : %d\n",res4);     
-       printf("struct-double : %d\n",res5);    
-       printf("struct-void * : %d\n",res6);*/
+  struct s0 {
+    char c0;
+    char i0;
+  };
+  struct s1 {
+    char c1;
+    short int i1;
+  };
+  struct s2 {
+    char c2;
+    int i2;
+  };
+  struct s3 {
+    char c3;
+    long int i3;
+  };
+  struct s4 {
+    char c4;
+    long long int i4;
+  };
+  struct s5 {
+    char c5;
+    double i5;
+  };
+  struct s6 {
+    char c6;
+    void *i6;
+  };
+  int res0 = sizeof(struct s0) - sizeof(char);
+  int res1 = sizeof(struct s1) - sizeof(short int);
+  int res2 = sizeof(struct s2) - sizeof(int);
+  int res3 = sizeof(struct s3) - sizeof(long int);
+  int res4 = sizeof(struct s4) - sizeof(long long int);
+  int res5 = sizeof(struct s5) - sizeof(double);
+  int res6 = sizeof(struct s6) - sizeof(void *);
+  /*printf("struct-char : %d\n",res0);
+     printf("struct-short int : %d\n",res1);      
+     printf("struct-int : %d\n",res2);    
+     printf("struct-long int : %d\n",res3);       
+     printf("struct-long long int : %d\n",res4);  
+     printf("struct-double : %d\n",res5); 
+     printf("struct-void * : %d\n",res6); */
 
-       printf("_C:%d/%d:_I:%d/%d:%d/%d:%d/%d:%d/%d:_P:%d/%d:%d/%d:_D:4/%d:8/%d:",c,res0,si,res1,i,res2,li,res3,lli,res4,v,res6,vv,res6,f,res5);
-       return 1;
+  printf
+      ("_C:%d/%d:_I:%d/%d:%d/%d:%d/%d:%d/%d:_P:%d/%d:%d/%d:_D:4/%d:8/%d:",
+       c, res0, si, res1, i, res2, li, res3, lli, res4, v, res6, vv, res6,
+       f, res5);
+  return 1;
 }
-
index 059941d..865eeaf 100644 (file)
@@ -5,62 +5,68 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <sys/types.h>
-#include <stddef.h> /* offsetof() */
+#include <stddef.h>             /* offsetof() */
 #include <stdio.h>
 
-int main (void)
+int main(void)
 {
 
-struct s0 {char c0; double d0;};
-struct s1 {double d1; int i1; char c1;};
-struct s2 {double d2; int i2; char c2[6];};
-struct s3 {double d3; int a3; int b3;}; 
+  struct s0 {
+    char c0;
+    double d0;
+  };
+  struct s1 {
+    double d1;
+    int i1;
+    char c1;
+  };
+  struct s2 {
+    double d2;
+    int i2;
+    char c2[6];
+  };
+  struct s3 {
+    double d3;
+    int a3;
+    int b3;
+  };
 
-int gras_struct_packed;
-int gras_struct_compact;
-int gras_array_straddle_struct;
-int gras_compact_struct;
+  int gras_struct_packed;
+  int gras_struct_compact;
+  int gras_array_straddle_struct;
+  int gras_compact_struct;
 
-       if (sizeof(struct s0) == sizeof(double)+sizeof(char))
-       {
-               gras_struct_packed=1;
-       }
-       else
-       {
-               gras_struct_packed=0;
-       }
-       if (offsetof(struct s1,c1) == sizeof(double)+sizeof(int))
-       {
-               gras_struct_compact=1;
-       }
-       else
-       {
-               gras_struct_compact=0;
-       }
-       if (offsetof(struct s2,c2) == sizeof(double)+sizeof(int))
-       {
-               gras_array_straddle_struct=1;
-       }
-       else
-       {
-               gras_array_straddle_struct=0;
-       }
-       if (offsetof(struct s3,b3) == sizeof(double)+sizeof(int))
-       {
-               gras_compact_struct=1;
-       }
-       else
-       {
-               gras_compact_struct=0;
-       }
+  if (sizeof(struct s0) == sizeof(double) + sizeof(char)) {
+    gras_struct_packed = 1;
+  } else {
+    gras_struct_packed = 0;
+  }
+  if (offsetof(struct s1, c1) == sizeof(double) + sizeof(int)) {
+    gras_struct_compact = 1;
+  } else {
+    gras_struct_compact = 0;
+  }
+  if (offsetof(struct s2, c2) == sizeof(double) + sizeof(int)) {
+    gras_array_straddle_struct = 1;
+  } else {
+    gras_array_straddle_struct = 0;
+  }
+  if (offsetof(struct s3, b3) == sizeof(double) + sizeof(int)) {
+    gras_compact_struct = 1;
+  } else {
+    gras_compact_struct = 0;
+  }
 
 
-       if(gras_struct_packed == 0 && gras_struct_compact == 1) printf("GRAS_STRUCT_COMPACT ");
+  if (gras_struct_packed == 0 && gras_struct_compact == 1)
+    printf("GRAS_STRUCT_COMPACT ");
 
-       if(gras_array_straddle_struct == 1) printf("GRAS_ARRAY_STRADDLE_STRUCT ");
+  if (gras_array_straddle_struct == 1)
+    printf("GRAS_ARRAY_STRADDLE_STRUCT ");
 
-       if(gras_compact_struct == 1) printf("GRAS_COMPACT_STRUCT ");
+  if (gras_compact_struct == 1)
+    printf("GRAS_COMPACT_STRUCT ");
 
-return 1;
+  return 1;
 
 }
index 81a257f..0c4780c 100644 (file)
@@ -6,9 +6,10 @@
 
 #define _GNU_SOURCE
 #include <stdio.h>
-int main(void){
-   FILE * fp;
-   char * line = NULL;
-   size_t len = 0;
-   getline(&line, &len, fp);
+int main(void)
+{
+  FILE *fp;
+  char *line = NULL;
+  size_t len = 0;
+  getline(&line, &len, fp);
 }
index d89e76d..021c5d5 100644 (file)
 #include <sys/types.h>
 #include <stdio.h>
 
-int main (void)
+int main(void)
 {
 
-       int c = sizeof(char);
-       int si = sizeof(short int);
-       int i = sizeof(int);
-       int li = sizeof(long int);
-       int lli = sizeof(long long int);
-       int f = sizeof(float);
-       int v = sizeof(void *);
-       int vv = sizeof(void (*) (void));
-       int t[8] = {c,si,i,li,lli,f,v,vv};
-       
-       int max = t[0];
-
-       for (i = 1; i < 8; i++)
-       { 
-               if (t[i] > max) max = t[i];
-
-       } 
-       printf("%d",max);
-       return 1;
+  int c = sizeof(char);
+  int si = sizeof(short int);
+  int i = sizeof(int);
+  int li = sizeof(long int);
+  int lli = sizeof(long long int);
+  int f = sizeof(float);
+  int v = sizeof(void *);
+  int vv = sizeof(void (*)(void));
+  int t[8] = { c, si, i, li, lli, f, v, vv };
+
+  int max = t[0];
+
+  for (i = 1; i < 8; i++) {
+    if (t[i] > max)
+      max = t[i];
+
+  }
+  printf("%d", max);
+  return 1;
 }
-
index c3eb72d..1b0664a 100644 (file)
@@ -6,9 +6,9 @@
 
 #include <pthread.h>
 
-void main (void)
+void main(void)
 {
-       pthread_mutex_t s;
-       const struct timespec t;
-       sem_timedlock(&s, &t);
+  pthread_mutex_t s;
+  const struct timespec t;
+  sem_timedlock(&s, &t);
 }
index 473d6c5..00277d4 100644 (file)
@@ -5,4 +5,4 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
-printf("%s",NULL);
+printf("%s", NULL);
index f4d3038..0fe001f 100644 (file)
@@ -8,6 +8,6 @@
 
 void main(void)
 {
-       sem_t s;
-       sem_init(&s);
+  sem_t s;
+  sem_init(&s);
 }
index 58876f6..994d9ad 100644 (file)
@@ -8,7 +8,7 @@
 
 int main()
 {
-       sem_t *s;
-       const struct timespec * t;
-       sem_timedwait(s, t);
+  sem_t *s;
+  const struct timespec *t;
+  sem_timedwait(s, t);
 }
index a33c846..60f2403 100644 (file)
@@ -8,14 +8,18 @@
 
 int main(void)
 {
-    char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
-    char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
-    int i;
-    i = snprintf (bufs, 2, "%s", "111");
-    if (strcmp (bufs, "1")) exit (1);
-    if (i != 3) exit (1);
-    i = snprintf (bufd, 2, "%d", 111);
-    if (strcmp (bufd, "1")) exit (1);
-    if (i != 3) exit (1);
-    exit(0);
+  char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
+  char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
+  int i;
+  i = snprintf(bufs, 2, "%s", "111");
+  if (strcmp(bufs, "1"))
+    exit(1);
+  if (i != 3)
+    exit(1);
+  i = snprintf(bufd, 2, "%d", 111);
+  if (strcmp(bufd, "1"))
+    exit(1);
+  if (i != 3)
+    exit(1);
+  exit(0);
 }
index c1a9e78..f0f2f1a 100644 (file)
@@ -9,22 +9,23 @@
 static int iterate = 10;
 static int growsdown(int *x)
 {
-    auto int y;
-    y = (x > &y);
-    if (--iterate > 0)
-        y = growsdown(&y);
-    if (y != (x > &y))
-        exit(1);
-    return y;
+  auto int y;
+  y = (x > &y);
+  if (--iterate > 0)
+    y = growsdown(&y);
+  if (y != (x > &y))
+    exit(1);
+  return y;
 }
+
 int main(int argc, char *argv[])
 {
-    FILE *f;
-    auto int x;
-    if ((f = fopen("conftestval", "w")) == NULL)
-        exit(1);
-    fprintf(f, "%s\n", growsdown(&x) ? "down" : "up");;
-    fclose(f);
-    exit(0);
-       return 1;
+  FILE *f;
+  auto int x;
+  if ((f = fopen("conftestval", "w")) == NULL)
+    exit(1);
+  fprintf(f, "%s\n", growsdown(&x) ? "down" : "up");;
+  fclose(f);
+  exit(0);
+  return 1;
 }
index 8bffd64..66dcba0 100644 (file)
@@ -9,8 +9,8 @@
 #endif
 
 #ifdef _XBT_WIN32
-       #include "win32_ucontext.h"
-       #include "win32_ucontext.c"
+#include "win32_ucontext.h"
+#include "win32_ucontext.c"
 #endif
 
 #include <stdio.h>
 
 #if defined(TEST_makecontext)
 #ifdef _XBT_WIN32
-       #include "win32_ucontext.h"
+#include "win32_ucontext.h"
 #else
-       #include <ucontext.h>
+#include <ucontext.h>
 #endif
 
 #endif
 union alltypes {
-    long   l;
-    double d;
-    void  *vp;
-    void (*fp)(void);
-    char  *cp;
+  long l;
+  double d;
+  void *vp;
+  void (*fp) (void);
+  char *cp;
 };
-static volatile char *handler_addr = (char *)0xDEAD;
+static volatile char *handler_addr = (char *) 0xDEAD;
 #if defined(TEST_sigstack) || defined(TEST_sigaltstack)
 static volatile int handler_done = 0;
 void handler(int sig)
 {
-    char garbage[1024];
-    int i;
-    auto int dummy;
-    for (i = 0; i < 1024; i++)
-        garbage[i] = 'X';
-    handler_addr = (char *)&dummy;
-    handler_done = 1;
-    return;
+  char garbage[1024];
+  int i;
+  auto int dummy;
+  for (i = 0; i < 1024; i++)
+    garbage[i] = 'X';
+  handler_addr = (char *) &dummy;
+  handler_done = 1;
+  return;
 }
 #endif
 #if defined(TEST_makecontext)
@@ -57,96 +57,95 @@ static ucontext_t uc_handler;
 static ucontext_t uc_main;
 void handler(void)
 {
-    char garbage[1024];
-    int i;
-    auto int dummy;
-    for (i = 0; i < 1024; i++)
-        garbage[i] = 'X';
-    handler_addr = (char *)&dummy;
-    swapcontext(&uc_handler, &uc_main);
-    return;
+  char garbage[1024];
+  int i;
+  auto int dummy;
+  for (i = 0; i < 1024; i++)
+    garbage[i] = 'X';
+  handler_addr = (char *) &dummy;
+  swapcontext(&uc_handler, &uc_main);
+  return;
 }
 #endif
 int main(int argc, char *argv[])
 {
-    FILE *f;
-    char *skaddr;
-    char *skbuf;
-    int sksize;
-    char result[1024];
-    int i;
-    sksize = 32768;
-    skbuf = (char *)malloc(sksize*2+2*sizeof(union alltypes));
-    if (skbuf == NULL)
-        exit(1);
-    for (i = 0; i < sksize*2+2*sizeof(union alltypes); i++)
-        skbuf[i] = 'A';
-    skaddr = skbuf+sizeof(union alltypes);
+  FILE *f;
+  char *skaddr;
+  char *skbuf;
+  int sksize;
+  char result[1024];
+  int i;
+  sksize = 32768;
+  skbuf = (char *) malloc(sksize * 2 + 2 * sizeof(union alltypes));
+  if (skbuf == NULL)
+    exit(1);
+  for (i = 0; i < sksize * 2 + 2 * sizeof(union alltypes); i++)
+    skbuf[i] = 'A';
+  skaddr = skbuf + sizeof(union alltypes);
 #if defined(TEST_sigstack) || defined(TEST_sigaltstack)
-    {
-        struct sigaction sa;
+  {
+    struct sigaction sa;
 #if defined(TEST_sigstack)
-        struct sigstack ss;
+    struct sigstack ss;
 #elif defined(TEST_sigaltstack) && defined(HAVE_STACK_T)
-        stack_t ss;
+    stack_t ss;
 #else
-        struct sigaltstack ss;
+    struct sigaltstack ss;
 #endif
 #if defined(TEST_sigstack)
-        ss.ss_sp      = (void *)(skaddr + sksize);
-        ss.ss_onstack = 0;
-        if (sigstack(&ss, NULL) < 0)
-            exit(1);
+    ss.ss_sp = (void *) (skaddr + sksize);
+    ss.ss_onstack = 0;
+    if (sigstack(&ss, NULL) < 0)
+      exit(1);
 #elif defined(TEST_sigaltstack)
-        ss.ss_sp    = (void *)(skaddr + sksize);
-        ss.ss_size  = sksize;
-        ss.ss_flags = 0;
-        if (sigaltstack(&ss, NULL) < 0)
-            exit(1);
+    ss.ss_sp = (void *) (skaddr + sksize);
+    ss.ss_size = sksize;
+    ss.ss_flags = 0;
+    if (sigaltstack(&ss, NULL) < 0)
+      exit(1);
 #endif
-        memset((void *)&sa, 0, sizeof(struct sigaction));
-        sa.sa_handler = handler;
-        sa.sa_flags = SA_ONSTACK;
-        sigemptyset(&sa.sa_mask);
-        sigaction(SIGUSR1, &sa, NULL);
-        kill(getpid(), SIGUSR1);
-        while (!handler_done)
-            /*nop*/;
-    }
+    memset((void *) &sa, 0, sizeof(struct sigaction));
+    sa.sa_handler = handler;
+    sa.sa_flags = SA_ONSTACK;
+    sigemptyset(&sa.sa_mask);
+    sigaction(SIGUSR1, &sa, NULL);
+    kill(getpid(), SIGUSR1);
+    while (!handler_done)
+      /*nop */ ;
+  }
 #endif
 #if defined(TEST_makecontext)
-    {
-        if (getcontext(&uc_handler) != 0)
-            exit(1);
-        uc_handler.uc_link = NULL;
-        uc_handler.uc_stack.ss_sp    = (void *)(skaddr + sksize);
-        uc_handler.uc_stack.ss_size  = sksize;
-        uc_handler.uc_stack.ss_flags = 0;
-        makecontext(&uc_handler, handler, 0);
-        swapcontext(&uc_main, &uc_handler);
-    }
+  {
+    if (getcontext(&uc_handler) != 0)
+      exit(1);
+    uc_handler.uc_link = NULL;
+    uc_handler.uc_stack.ss_sp = (void *) (skaddr + sksize);
+    uc_handler.uc_stack.ss_size = sksize;
+    uc_handler.uc_stack.ss_flags = 0;
+    makecontext(&uc_handler, handler, 0);
+    swapcontext(&uc_main, &uc_handler);
+  }
 #endif
-    if (handler_addr == (char *)0xDEAD)
-        exit(1);
-    if (handler_addr < skaddr+sksize) {
-        /* stack was placed into lower area */
-        if (*(skaddr+sksize) != 'A')
-             sprintf(result, "(skaddr)+(sksize)-%d,(sksize)-%d",
-                     sizeof(union alltypes), sizeof(union alltypes));
-        else
-             strcpy(result, "(skaddr)+(sksize),(sksize)");
-    }
-    else {
-        /* stack was placed into higher area */
-        if (*(skaddr+sksize*2) != 'A')
-            sprintf(result, "(skaddr),(sksize)-%d", sizeof(union alltypes));
-        else
-            strcpy(result, "(skaddr),(sksize)");
-    }
-    if ((f = fopen("conftestval", "w")) == NULL)
-        exit(1);
-    fprintf(f, "%s\n", result);
-    fclose(f);
-    exit(0);
-       return 1;
+  if (handler_addr == (char *) 0xDEAD)
+    exit(1);
+  if (handler_addr < skaddr + sksize) {
+    /* stack was placed into lower area */
+    if (*(skaddr + sksize) != 'A')
+      sprintf(result, "(skaddr)+(sksize)-%d,(sksize)-%d",
+              sizeof(union alltypes), sizeof(union alltypes));
+    else
+      strcpy(result, "(skaddr)+(sksize),(sksize)");
+  } else {
+    /* stack was placed into higher area */
+    if (*(skaddr + sksize * 2) != 'A')
+      sprintf(result, "(skaddr),(sksize)-%d", sizeof(union alltypes));
+    else
+      strcpy(result, "(skaddr),(sksize)");
+  }
+  if ((f = fopen("conftestval", "w")) == NULL)
+    exit(1);
+  fprintf(f, "%s\n", result);
+  fclose(f);
+  exit(0);
+  return 1;
 }
index 30f4a9d..26e1db9 100644 (file)
@@ -7,26 +7,30 @@
 #include <stdio.h>
 #include <stdarg.h>
 
-int my_vsnprintf (char *buf, const char *tmpl, ...)
+int my_vsnprintf(char *buf, const char *tmpl, ...)
 {
-    int i;
-    va_list args;
-    va_start (args, tmpl);
-    i = vsnprintf (buf, 2, tmpl, args);
-    va_end (args);
-    return i;
+  int i;
+  va_list args;
+  va_start(args, tmpl);
+  i = vsnprintf(buf, 2, tmpl, args);
+  va_end(args);
+  return i;
 }
 
 int main(void)
 {
-    char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
-    char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
-    int i;
-    i = my_vsnprintf (bufs, "%s", "111");
-    if (strcmp (bufs, "1")) exit (1);
-    if (i != 3) exit (1);
-    i = my_vsnprintf (bufd, "%d", 111);
-    if (strcmp (bufd, "1")) exit (1);
-    if (i != 3) exit (1);
-    exit(0);
+  char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
+  char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
+  int i;
+  i = my_vsnprintf(bufs, "%s", "111");
+  if (strcmp(bufs, "1"))
+    exit(1);
+  if (i != 3)
+    exit(1);
+  i = my_vsnprintf(bufd, "%d", 111);
+  if (strcmp(bufd, "1"))
+    exit(1);
+  if (i != 3)
+    exit(1);
+  exit(0);
 }
index cf253ee..dcf146c 100644 (file)
 //---------------------------------------------------------------------------
 
 #pragma argsused
-int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
+int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason,
+                         void *lpReserved)
 {
-       return 1;
+  return 1;
 }
+
 //---------------------------------------------------------------------------
index 16c8e2a..dcf146c 100644 (file)
 //---------------------------------------------------------------------------
 
 #pragma argsused
-int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
+int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason,
+                         void *lpReserved)
 {
-    return 1;
+  return 1;
 }
+
 //---------------------------------------------------------------------------
\ No newline at end of file
index 7f50312..41e4702 100644 (file)
@@ -1,11 +1,11 @@
 #include <windows.h>\r
 \r
 #include <xbt/log.h>\r
-\r
-/* logs */\r
+    \r
+/* logs */ \r
 // XBT_LOG_NEW_DEFAULT_CATEGORY(SimGridX,"SimGrid for cxx");\r
-\r
-int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)\r
-{\r
-    return 1;\r
-}
\ No newline at end of file
+\rint WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason,
+                          void *lpReserved) \r
+{
+  \rreturn 1;
+\r}
index c2a6fe5..b896056 100644 (file)
@@ -1,7 +1,6 @@
 #include <windows.h>\r
-\r
-\r
-int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)\r
-{\r
-    return 1;\r
-}
\ No newline at end of file
+\r \rint WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason,
+                            void *lpReserved) \r
+{
+  \rreturn 1;
+\r}
index c2a6fe5..b896056 100644 (file)
@@ -1,7 +1,6 @@
 #include <windows.h>\r
-\r
-\r
-int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)\r
-{\r
-    return 1;\r
-}
\ No newline at end of file
+\r \rint WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason,
+                            void *lpReserved) \r
+{
+  \rreturn 1;
+\r}
index ea9a3c0..97fea93 100644 (file)
@@ -6,20 +6,22 @@
 
 #include <gras.h>
 
-int client(int argc, char *argv[]) {
-  gras_init(&argc,argv);
+int client(int argc, char *argv[])
+{
+  gras_init(&argc, argv);
 
   /* Your own code for the client process */
-  
+
   gras_exit();
   return 0;
 }
 
-int server(int argc, char *argv[]) {
-  gras_init(&argc,argv);
+int server(int argc, char *argv[])
+{
+  gras_init(&argc, argv);
 
   /* Your own code for the server process */
-  
+
   gras_exit();
   return 0;
 }
index ded8811..269414c 100644 (file)
@@ -7,39 +7,44 @@
 #include <stdio.h>
 #include <gras.h>
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toclient; /* socket used to write to the client */
-  
-  gras_init(&argc,argv);
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toclient;       /* socket used to write to the client */
+
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server(12345);
 
-  gras_msg_wait(60, "hello", &toclient, NULL /* no payload */);
-  
-  fprintf(stderr,"Cool, we received the message from %s:%d.\n",
-         gras_socket_peer_name(toclient), gras_socket_peer_port(toclient));
-  
+  gras_msg_wait(60, "hello", &toclient, NULL /* no payload */ );
+
+  fprintf(stderr, "Cool, we received the message from %s:%d.\n",
+          gras_socket_peer_name(toclient),
+          gras_socket_peer_port(toclient));
+
   gras_exit();
   return 0;
 }
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
+
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
-  fprintf(stderr,"Client ready; listening on %d\n", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  fprintf(stderr, "Client ready; listening on %d\n",
+          gras_socket_my_port(mysock));
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client("Jacquelin", 12345);
-  
-  gras_msg_send(toserver,"hello", NULL);
-  fprintf(stderr,"That's it, we sent the data to the server\n");
+
+  gras_msg_send(toserver, "hello", NULL);
+  fprintf(stderr, "That's it, we sent the data to the server\n");
 
   gras_exit();
   return 0;
index 19070e7..06d6f1a 100644 (file)
@@ -7,39 +7,45 @@
 #include <stdio.h>
 #include <gras.h>
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toclient; /* socket used to write to the client */
-  
-  gras_init(&argc,argv);
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toclient;       /* socket used to write to the client */
+
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
 
-  gras_msg_wait(60, "hello", &toclient, NULL /* no payload */);
-  
-  fprintf(stderr,"Cool, we received the message from %s:%d.\n",
-         gras_socket_peer_name(toclient), gras_socket_peer_port(toclient));
-  
+  gras_msg_wait(60, "hello", &toclient, NULL /* no payload */ );
+
+  fprintf(stderr, "Cool, we received the message from %s:%d.\n",
+          gras_socket_peer_name(toclient),
+          gras_socket_peer_port(toclient));
+
   gras_exit();
   return 0;
 }
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
+
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
-  fprintf(stderr,"Client ready; listening on %d\n", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  fprintf(stderr, "Client ready; listening on %d\n",
+          gras_socket_my_port(mysock));
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
-  
-  gras_msg_send(toserver,"hello", NULL);
-  fprintf(stderr,"That's it, we sent the data to the server on %s\n", gras_socket_peer_name(toserver));
+
+  gras_msg_send(toserver, "hello", NULL);
+  fprintf(stderr, "That's it, we sent the data to the server on %s\n",
+          gras_socket_peer_name(toserver));
 
   gras_exit();
   return 0;
index 956f6b5..1e4c45f 100644 (file)
@@ -7,46 +7,51 @@
 #include <stdio.h>
 #include <gras.h>
 
-int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
 
-  fprintf(stderr,"Cool, we received the message from %s:%d.\n",
-         gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+  fprintf(stderr, "Cool, we received the message from %s:%d.\n",
+          gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   return 0;
-} /* end_of_callback */
+}                               /* end_of_callback */
+
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
-   
-  gras_cb_register("hello",&server_hello_cb);   
+
+  gras_cb_register("hello", &server_hello_cb);
   gras_msg_handle(60);
-    
+
   gras_exit();
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
-  fprintf(stderr,"Client ready; listening on %d\n", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  fprintf(stderr, "Client ready; listening on %d\n",
+          gras_socket_my_port(mysock));
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
-  
-  gras_msg_send(toserver,"hello", NULL);
-  fprintf(stderr,"That's it, we sent the data to the server on %s\n", gras_socket_peer_name(toserver));
+
+  gras_msg_send(toserver, "hello", NULL);
+  fprintf(stderr, "That's it, we sent the data to the server on %s\n",
+          gras_socket_peer_name(toserver));
 
   gras_exit();
   return 0;
index a21233d..4751176 100644 (file)
@@ -8,77 +8,84 @@
 #include <gras.h>
 
 typedef struct {
-   int killed;
+  int killed;
 } server_data_t;
-   
 
-int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+
+int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
-   
-  fprintf(stderr,"Argh, killed by %s:%d! Bye folks...\n",
-         gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
+
+  fprintf(stderr, "Argh, killed by %s:%d! Bye folks...\n",
+          gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   globals->killed = 1;
-   
+
   return 0;
-} /* end_of_kill_callback */
+}                               /* end_of_kill_callback */
 
-int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
 
-  fprintf(stderr,"Cool, we received the message from %s:%d.\n",
-         gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+  fprintf(stderr, "Cool, we received the message from %s:%d.\n",
+          gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   return 0;
-} /* end_of_hello_callback */
+}                               /* end_of_hello_callback */
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
-  
-  gras_init(&argc,argv);
 
-  globals=gras_userdata_new(server_data_t);
-  globals->killed=0;
+  gras_init(&argc, argv);
+
+  globals = gras_userdata_new(server_data_t);
+  globals->killed = 0;
 
   gras_msgtype_declare("hello", NULL);
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
-   
-  gras_cb_register("hello",&server_hello_cb);   
-  gras_cb_register("kill",&server_kill_cb);
+
+  gras_cb_register("hello", &server_hello_cb);
+  gras_cb_register("kill", &server_kill_cb);
 
   while (!globals->killed) {
-     gras_msg_handle(-1); /* blocking */
+    gras_msg_handle(-1);        /* blocking */
   }
-    
+
   gras_exit();
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
-  fprintf(stderr,"Client ready; listening on %d\n", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  fprintf(stderr, "Client ready; listening on %d\n",
+          gras_socket_my_port(mysock));
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
-  
-  gras_msg_send(toserver,"hello", NULL);
-  fprintf(stderr,"we sent the data to the server on %s. Let's do it again for fun\n", gras_socket_peer_name(toserver));
-  gras_msg_send(toserver,"hello", NULL);
-   
-  fprintf(stderr,"Ok. Enough. Have a rest, and then kill the server\n");
-  gras_os_sleep(5); /* sleep 1 second and half */
-  gras_msg_send(toserver,"kill", NULL);
+
+  gras_msg_send(toserver, "hello", NULL);
+  fprintf(stderr,
+          "we sent the data to the server on %s. Let's do it again for fun\n",
+          gras_socket_peer_name(toserver));
+  gras_msg_send(toserver, "hello", NULL);
+
+  fprintf(stderr, "Ok. Enough. Have a rest, and then kill the server\n");
+  gras_os_sleep(5);             /* sleep 1 second and half */
+  gras_msg_send(toserver, "kill", NULL);
 
   gras_exit();
   return 0;
index f0acfb7..9ab0443 100644 (file)
@@ -6,80 +6,85 @@
 
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "My little example");
 
 typedef struct {
-   int killed;
+  int killed;
 } server_data_t;
-   
 
-int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+
+int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
-   
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
+
   CRITICAL2("Argh, killed by %s:%d! Bye folks...",
-       gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+            gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   globals->killed = 1;
-   
+
   return 0;
-} /* end_of_kill_callback */
+}                               /* end_of_kill_callback */
 
-int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
 
   INFO2("Cool, we received the message from %s:%d.",
-       gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+        gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   return 0;
-} /* end_of_hello_callback */
+}                               /* end_of_hello_callback */
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
-  
-  gras_init(&argc,argv);
 
-  globals=gras_userdata_new(server_data_t*);
-  globals->killed=0;
+  gras_init(&argc, argv);
+
+  globals = gras_userdata_new(server_data_t *);
+  globals->killed = 0;
 
   gras_msgtype_declare("hello", NULL);
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
-   
-  gras_cb_register("hello",&server_hello_cb);   
-  gras_cb_register("kill",&server_kill_cb);
+
+  gras_cb_register("hello", &server_hello_cb);
+  gras_cb_register("kill", &server_kill_cb);
 
   while (!globals->killed) {
-     gras_msg_handle(-1); /* blocking */
+    gras_msg_handle(-1);        /* blocking */
   }
-    
+
   gras_exit();
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
+
   VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
-  
-  gras_msg_send(toserver,"hello", NULL);
-  INFO1("we sent the data to the server on %s. Let's do it again for fun", gras_socket_peer_name(toserver));
-  gras_msg_send(toserver,"hello", NULL);
-   
+
+  gras_msg_send(toserver, "hello", NULL);
+  INFO1("we sent the data to the server on %s. Let's do it again for fun",
+        gras_socket_peer_name(toserver));
+  gras_msg_send(toserver, "hello", NULL);
+
   INFO0("Ok. Enough. Have a rest, and then kill the server");
-  gras_os_sleep(5); /* sleep 1 second and half */
-  gras_msg_send(toserver,"kill", NULL);
+  gras_os_sleep(5);             /* sleep 1 second and half */
+  gras_msg_send(toserver, "kill", NULL);
 
   gras_exit();
   return 0;
index cb5ad51..6ddb67d 100644 (file)
@@ -6,54 +6,57 @@
 
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "My little example");
 
 /* *********************** Server *********************** */
 typedef struct {
-   int killed;
-} server_data_t;   
+  int killed;
+} server_data_t;
 
-int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
-   
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
+
   CRITICAL2("Argh, killed by %s:%d! Bye folks...",
-       gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+            gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   globals->killed = 1;
-   
+
   return 0;
-} /* end_of_kill_callback */
+}                               /* end_of_kill_callback */
 
-int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
 
   INFO2("Cool, we received the message from %s:%d.",
-       gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+        gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   return 0;
-} /* end_of_hello_callback */
+}                               /* end_of_hello_callback */
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
-  
-  gras_init(&argc,argv);
 
-  globals=gras_userdata_new(server_data_t*);
-  globals->killed=0;
+  gras_init(&argc, argv);
+
+  globals = gras_userdata_new(server_data_t *);
+  globals->killed = 0;
 
   gras_msgtype_declare("hello", NULL);
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
-   
-  gras_cb_register("hello",&server_hello_cb);   
-  gras_cb_register("kill",&server_kill_cb);
+
+  gras_cb_register("hello", &server_hello_cb);
+  gras_cb_register("kill", &server_kill_cb);
 
   while (!globals->killed) {
-     gras_msg_handle(60);
+    gras_msg_handle(60);
   }
-    
+
   gras_exit();
   return 0;
 }
@@ -61,59 +64,61 @@ int server(int argc, char *argv[]) {
 /* *********************** Client *********************** */
 /* client_data */
 typedef struct {
-   gras_socket_t toserver;
-   int done;
+  gras_socket_t toserver;
+  int done;
 } client_data_t;
 
-void client_do_hello(void) {
-  client_data_t *globals=(client_data_t*)gras_userdata_get();
-   
-  gras_msg_send(globals->toserver,"hello", NULL);
+
+void client_do_hello(void)
+{
+  client_data_t *globals = (client_data_t *) gras_userdata_get();
+
+  gras_msg_send(globals->toserver, "hello", NULL);
   INFO0("Hello sent to server");
-} /* end_of_client_do_hello */
+}                               /* end_of_client_do_hello */
+
+void client_do_stop(void)
+{
+  client_data_t *globals = (client_data_t *) gras_userdata_get();
 
-void client_do_stop(void) {
-  client_data_t *globals=(client_data_t*)gras_userdata_get();
-   
-  gras_msg_send(globals->toserver,"kill", NULL);
+  gras_msg_send(globals->toserver, "kill", NULL);
   INFO0("Kill sent to server");
-   
-  gras_timer_cancel_repeat(0.5,client_do_hello);
+
+  gras_timer_cancel_repeat(0.5, client_do_hello);
+
   globals->done = 1;
   INFO0("Break the client's while loop");
-} /* end_of_client_do_stop */
+}                               /* end_of_client_do_stop */
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   client_data_t *globals;
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("hello", NULL);
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
+
   VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
-  
-  globals=gras_userdata_new(client_data_t*);
+
+  globals = gras_userdata_new(client_data_t *);
   globals->done = 0;
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   globals->toserver = gras_socket_client(argv[1], atoi(argv[2]));
-   
+
   INFO0("Programming the repetitive action with a frequency of 0.5 sec");
-  gras_timer_repeat(0.5,client_do_hello);
-  
+  gras_timer_repeat(0.5, client_do_hello);
+
   INFO0("Programming the delayed action in 5 secs");
-  gras_timer_delay(5,client_do_stop);
-  
+  gras_timer_delay(5, client_do_stop);
+
   while (!globals->done) {
-     gras_msg_handle(60);
+    gras_msg_handle(60);
   }
 
   gras_exit();
   return 0;
 }
-
index 6b90168..19d663e 100644 (file)
@@ -6,86 +6,93 @@
 
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "My little example");
 
 typedef struct {
-   int killed;
+  int killed;
 } server_data_t;
-   
 
-int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+
+int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
-   
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
+
   CRITICAL2("Argh, killed by %s:%d! Bye folks, I'm out of here...",
-       gras_socket_peer_name(client), gras_socket_peer_port(client));
-  
+            gras_socket_peer_name(client), gras_socket_peer_port(client));
+
   globals->killed = 1;
-   
+
   return 0;
-} /* end_of_kill_callback */
+}                               /* end_of_kill_callback */
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
-  
-  gras_init(&argc,argv);
 
-  globals=gras_userdata_new(server_data_t*);
-  globals->killed=0;
+  gras_init(&argc, argv);
+
+  globals = gras_userdata_new(server_data_t *);
+  globals->killed = 0;
 
   gras_msgtype_declare("kill", NULL);
-  gras_cb_register("kill",&server_kill_cb);
-   
-  if (argc>1 && !strcmp(argv[1],"--cheat")) {
-     mysock = gras_socket_server(9999);
-     INFO0("Hi! hi! I'm not in the search range, but in 9999...");
+  gras_cb_register("kill", &server_kill_cb);
+
+  if (argc > 1 && !strcmp(argv[1], "--cheat")) {
+    mysock = gras_socket_server(9999);
+    INFO0("Hi! hi! I'm not in the search range, but in 9999...");
   } else {
-     mysock = gras_socket_server((rand() % 10) + 3000);   
-     INFO1("Ok, I'm hidden on port %d. Hope for the best.", gras_socket_my_port(mysock));
-  } 
-   
+    mysock = gras_socket_server((rand() % 10) + 3000);
+    INFO1("Ok, I'm hidden on port %d. Hope for the best.",
+          gras_socket_my_port(mysock));
+  }
+
   while (!globals->killed) {
-     gras_msg_handle(-1); /* blocking */
+    gras_msg_handle(-1);        /* blocking */
   }
-    
+
   gras_exit();
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
-  int found;              /* whether we found peer */
-  int port;               /* where we think that the server is */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
+  int found;                    /* whether we found peer */
+  int port;                     /* where we think that the server is */
   xbt_ex_t e;
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
+
   VERB0("Run little server, run. I'll get you. (sleep 1.5 sec)");
   gras_os_sleep(1.5);
-   
-  for (port=3000, found=0; port<3010 && !found; port++) {
-     TRY {
-       toserver = gras_socket_client(argv[1], port);
-       gras_msg_send(toserver,"kill", NULL);
-       gras_socket_close(toserver);
-       found = 1;
-       INFO1("Yeah! I found the server on %d! It's eradicated by now.",port);
-     } CATCH(e) {
-       xbt_ex_free(e);
-     }
-     if (!found)
-       INFO1("Damn, the server is not on %d",port);
-  } /* end_of_loop */
-   
-  if(!found) 
-     THROW0(not_found_error, 0, "Damn, I failed to find the server! I cannot survive this humilliation.");
-  
-     
+
+  for (port = 3000, found = 0; port < 3010 && !found; port++) {
+    TRY {
+      toserver = gras_socket_client(argv[1], port);
+      gras_msg_send(toserver, "kill", NULL);
+      gras_socket_close(toserver);
+      found = 1;
+      INFO1("Yeah! I found the server on %d! It's eradicated by now.",
+            port);
+    }
+    CATCH(e) {
+      xbt_ex_free(e);
+    }
+    if (!found)
+      INFO1("Damn, the server is not on %d", port);
+  }                             /* end_of_loop */
+
+  if (!found)
+    THROW0(not_found_error, 0,
+           "Damn, I failed to find the server! I cannot survive this humilliation.");
+
+
   gras_exit();
   return 0;
 }
index 3d871a3..8124064 100644 (file)
 extern const char *_gras_procname;
 
 /* This is a private data of gras/Datadesc we want to explore */
-xbt_set_t gras_datadesc_set_local=NULL;
+xbt_set_t gras_datadesc_set_local = NULL;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
   xbt_set_elm_t elm;
   xbt_set_cursor_t cursor;
-  gras_init(&argc,argv);
-   
+  gras_init(&argc, argv);
+
   xbt_set_foreach(gras_datadesc_set_local, cursor, elm) {
-     printf("%s\n",elm->name);
+    printf("%s\n", elm->name);
   }
-   
-   
+
+
   gras_exit();
   return 0;
 }
index 7ba96df..a170ee4 100644 (file)
@@ -6,91 +6,97 @@
 
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "My little example");
 
 typedef struct {
-   int killed;
+  int killed;
 } server_data_t;
-   
 
-int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  double delay = *(double*)payload;
+
+int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  double delay = *(double *) payload;
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
-   
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
+
   CRITICAL3("Argh, %s:%d gave me %.2f seconds before suicide!",
-       gras_socket_peer_name(client), gras_socket_peer_port(client),delay);
+            gras_socket_peer_name(client), gras_socket_peer_port(client),
+            delay);
   gras_os_sleep(delay);
   CRITICAL0("Bye folks...");
-   
-   
+
+
   globals->killed = 1;
-   
+
   return 0;
-} /* end_of_kill_callback */
+}                               /* end_of_kill_callback */
 
-int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  char *msg=*(char**)payload;
+int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  char *msg = *(char **) payload;
   gras_socket_t client = gras_msg_cb_ctx_from(ctx);
 
   INFO3("Cool, we received a message from %s:%d. Here it is: \"%s\"",
-       gras_socket_peer_name(client), gras_socket_peer_port(client),
-       msg);
-  
+        gras_socket_peer_name(client), gras_socket_peer_port(client), msg);
+
   return 0;
-} /* end_of_hello_callback */
+}                               /* end_of_hello_callback */
 
-void message_declaration(void) {
+void message_declaration(void)
+{
   gras_msgtype_declare("kill", gras_datadesc_by_name("double"));
   gras_msgtype_declare("hello", gras_datadesc_by_name("string"));
 }
 
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
-  
-  gras_init(&argc,argv);
 
-  globals=gras_userdata_new(server_data_t*);
-  globals->killed=0;
+  gras_init(&argc, argv);
+
+  globals = gras_userdata_new(server_data_t *);
+  globals->killed = 0;
 
   message_declaration();
   mysock = gras_socket_server(atoi(argv[1]));
-   
-  gras_cb_register("hello",&server_hello_cb);   
-  gras_cb_register("kill",&server_kill_cb);
+
+  gras_cb_register("hello", &server_hello_cb);
+  gras_cb_register("kill", &server_kill_cb);
 
   while (!globals->killed) {
-     gras_msg_handle(-1); /* blocking */
+    gras_msg_handle(-1);        /* blocking */
   }
-    
+
   gras_exit();
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   message_declaration();
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
+
   VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
-  
-  char *hello_payload="Nice to meet you";
-  gras_msg_send(toserver,"hello", &hello_payload);
-  INFO1("we sent the hello to the server on %s.", gras_socket_peer_name(toserver));
-   
-  double kill_payload=0.5;
-  gras_msg_send(toserver,"kill", &kill_payload);
+
+  char *hello_payload = "Nice to meet you";
+  gras_msg_send(toserver, "hello", &hello_payload);
+  INFO1("we sent the hello to the server on %s.",
+        gras_socket_peer_name(toserver));
+
+  double kill_payload = 0.5;
+  gras_msg_send(toserver, "kill", &kill_payload);
   INFO0("Gave the server more 0.5 second to live");
-   
+
   gras_exit();
   return 0;
 }
index 1e8e64d..9cc423a 100644 (file)
 #include <stdlib.h>
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "My little example");
 
 typedef struct {
-   int done;
+  int done;
 } server_data_t;
-int server_done_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
+int server_done_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
   globals->done = 1;
   INFO0("Server done");
-   
+
   return 0;
-} /* end_of_done_callback */
+}                               /* end_of_done_callback */
+
+void message_declaration(void)
+{
+  gras_msgtype_declare_rpc("convert a2i", gras_datadesc_by_name("string"),
+                           gras_datadesc_by_name("long"));
+  gras_msgtype_declare_rpc("convert i2a", gras_datadesc_by_name("long"),
+                           gras_datadesc_by_name("string"));
 
-void message_declaration(void) {
-  gras_msgtype_declare_rpc("convert a2i", gras_datadesc_by_name("string"), gras_datadesc_by_name("long"));
-  gras_msgtype_declare_rpc("convert i2a", gras_datadesc_by_name("long"), gras_datadesc_by_name("string"));
   /* the other message allowing the client to stop the server after use */
-  gras_msgtype_declare("done", NULL); 
+  gras_msgtype_declare("done", NULL);
 }
 
-int server_convert_i2a_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  long data = *(long*)payload;
+int server_convert_i2a_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  long data = *(long *) payload;
   char *result;
   char *p;
 
-  INFO1("Convert %ld to string",data);  
-  result = bprintf("%ld", data);   
-  INFO2("%ld converted to string: %s",data,result);
-   
-  gras_msg_rpcreturn(60,ctx,&result);
+  INFO1("Convert %ld to string", data);
+  result = bprintf("%ld", data);
+  INFO2("%ld converted to string: %s", data, result);
+
+  gras_msg_rpcreturn(60, ctx, &result);
   free(result);
   return 0;
-} /* end_of_convert_callback */
+}                               /* end_of_convert_callback */
 
-int server_convert_a2i_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  char *string = *(char**)payload;
+int server_convert_a2i_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  char *string = *(char **) payload;
   long result;
   char *p;
 
-  INFO1("Convert %s to long",string);
+  INFO1("Convert %s to long", string);
   result = strtol(string, &p, 10);
-   
+
   if (*p != '\0')
-     THROW2(arg_error,0,"Error while converting %s: this does not seem to be a valid number (problem at '%s')",string,p);
-             
-  gras_msg_rpcreturn(60,ctx,&result);
+    THROW2(arg_error, 0,
+           "Error while converting %s: this does not seem to be a valid number (problem at '%s')",
+           string, p);
+
+  gras_msg_rpcreturn(60, ctx, &result);
   return 0;
-} /* end_of_convert_callback */
+}                               /* end_of_convert_callback */
 
 
-int server(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
-  
-  gras_init(&argc,argv);
 
-  globals=gras_userdata_new(server_data_t*);
-  globals->done=0;
+  gras_init(&argc, argv);
+
+  globals = gras_userdata_new(server_data_t *);
+  globals->done = 0;
 
   message_declaration();
   mysock = gras_socket_server(atoi(argv[1]));
-   
-  gras_cb_register("convert a2i",&server_convert_a2i_cb);
-  gras_cb_register("convert i2a",&server_convert_i2a_cb);
-  gras_cb_register("done",&server_done_cb);
+
+  gras_cb_register("convert a2i", &server_convert_a2i_cb);
+  gras_cb_register("convert i2a", &server_convert_i2a_cb);
+  gras_cb_register("done", &server_done_cb);
 
   while (!globals->done) {
-     gras_msg_handle(-1); /* blocking */
+    gras_msg_handle(-1);        /* blocking */
   }
-    
+
   gras_exit();
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
+int client(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   message_declaration();
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
+
   VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
-  
-  long long_to_convert=4321;
+
+  long long_to_convert = 4321;
   char *string_result;
   INFO1("Ask to convert %ld", long_to_convert);
-  gras_msg_rpccall(toserver, 60, "convert i2a", &long_to_convert, &string_result);
-  INFO2("The server says that %ld is equal to \"%s\".", long_to_convert, string_result);
+  gras_msg_rpccall(toserver, 60, "convert i2a", &long_to_convert,
+                   &string_result);
+  INFO2("The server says that %ld is equal to \"%s\".", long_to_convert,
+        string_result);
   free(string_result);
-   
-  char *string_to_convert="1234";
+
+  char *string_to_convert = "1234";
   long long_result;
   INFO1("Ask to convert %s", string_to_convert);
-  gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert, &long_result);
-  INFO2("The server says that \"%s\" is equal to %d.", string_to_convert, long_result);
-   
+  gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert,
+                   &long_result);
+  INFO2("The server says that \"%s\" is equal to %d.", string_to_convert,
+        long_result);
+
   xbt_ex_t e;
   string_to_convert = "azerty";
   TRY {
-     gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert, &long_result);
+    gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert,
+                     &long_result);
   } CATCH(e) {
-     INFO1("The server refuses to convert %s. Here is the received exception:",string_to_convert);
-     xbt_ex_display(&e);
-     xbt_ex_free(e);
-     INFO0("Again, previous exception was excepted");
-  }            
-   
-  gras_msg_send(toserver,"done", NULL);
+    INFO1
+        ("The server refuses to convert %s. Here is the received exception:",
+         string_to_convert);
+    xbt_ex_display(&e);
+    xbt_ex_free(e);
+    INFO0("Again, previous exception was excepted");
+  }
+
+  gras_msg_send(toserver, "done", NULL);
   INFO0("Stopped the server");
-   
+
   gras_exit();
   return 0;
 }
index 05146d3..4923f8d 100644 (file)
 #include <stdlib.h>
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "My little example");
 
-void message_declaration(void) {
+void message_declaration(void)
+{
   gras_msgtype_declare("request", NULL);
   gras_msgtype_declare("grant", NULL);
   gras_msgtype_declare("release", NULL);
 }
 
 typedef struct {
-   int process_in_CS;
-   xbt_dynar_t waiting_queue;
+  int process_in_CS;
+  xbt_dynar_t waiting_queue;
 } server_data_t;
 
-int server_request_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
+int server_request_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
   gras_socket_t s = gras_msg_cb_ctx_from(ctx);
+
   if (globals->process_in_CS) {
-     xbt_dynar_push(globals->waiting_queue, &s);
-     INFO2("put %s:%d in waiting queue",gras_socket_peer_name(s),gras_socket_peer_port(s));
-  } else {     
-     globals->process_in_CS = 1;
-     INFO2("grant %s:%d since nobody wanted it",gras_socket_peer_name(s),gras_socket_peer_port(s));
-     gras_msg_send(s, "grant", NULL);     
+    xbt_dynar_push(globals->waiting_queue, &s);
+    INFO2("put %s:%d in waiting queue", gras_socket_peer_name(s),
+          gras_socket_peer_port(s));
+  } else {
+    globals->process_in_CS = 1;
+    INFO2("grant %s:%d since nobody wanted it", gras_socket_peer_name(s),
+          gras_socket_peer_port(s));
+    gras_msg_send(s, "grant", NULL);
   }
   return 0;
-} /* end_of_request_callback */
+}                               /* end_of_request_callback */
+
+int server_release_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
+  server_data_t *globals = (server_data_t *) gras_userdata_get();
 
-int server_release_cb(gras_msg_cb_ctx_t ctx, void *payload) {
-  server_data_t *globals=(server_data_t*)gras_userdata_get();
-   
   if (xbt_dynar_length(globals->waiting_queue)) {
-     gras_socket_t s;
-     xbt_dynar_pop(globals->waiting_queue, &s);
-     
-     INFO2("grant %s:%d since token released",gras_socket_peer_name(s),gras_socket_peer_port(s));
-     gras_msg_send(s, "grant", NULL);
+    gras_socket_t s;
+    xbt_dynar_pop(globals->waiting_queue, &s);
+
+    INFO2("grant %s:%d since token released", gras_socket_peer_name(s),
+          gras_socket_peer_port(s));
+    gras_msg_send(s, "grant", NULL);
   } else {
-     globals->process_in_CS = 0;
+    globals->process_in_CS = 0;
   }
-   
+
   return 0;
-} /* end_of_release_callback */
+}                               /* end_of_release_callback */
 
-int server(int argc, char *argv[]) { 
-  gras_socket_t mysock;   /* socket on which I listen */
+int server(int argc, char *argv[])
+{
+  gras_socket_t mysock;         /* socket on which I listen */
   server_data_t *globals;
   int i;
-  
-  gras_init(&argc,argv);
+
+  gras_init(&argc, argv);
   mysock = gras_socket_server(atoi(argv[1]));
 
-  globals=gras_userdata_new(server_data_t);
-  globals->process_in_CS=0;
-  globals->waiting_queue=xbt_dynar_new( sizeof(gras_socket_t), NULL /* not closing sockets */);
+  globals = gras_userdata_new(server_data_t);
+  globals->process_in_CS = 0;
+  globals->waiting_queue =
+      xbt_dynar_new(sizeof(gras_socket_t),
+                    NULL /* not closing sockets */ );
 
-  message_declaration();   
-  gras_cb_register("request",&server_request_cb);
-  gras_cb_register("release",&server_release_cb);
+  message_declaration();
+  gras_cb_register("request", &server_request_cb);
+  gras_cb_register("release", &server_release_cb);
+
+  for (i = 0; i < 20; i++)      /* 5 requests of each process, 2 processes, 2 messages per request */
+    gras_msg_handle(-1);
 
-  for (i=0; i<20; i++)  /* 5 requests of each process, 2 processes, 2 messages per request */
-    gras_msg_handle(-1); 
-    
   gras_exit();
   return 0;
-} /* end_of_server */
-
-void lock(gras_socket_t toserver) {
-   gras_msg_send(toserver,"request",NULL);
-   gras_msg_wait(-1, "grant",NULL,NULL);
-   INFO0("Granted by server");
-} /* end_of_lock */
-
-void unlock(gras_socket_t toserver) {
-   INFO0("Release the token");
-   gras_msg_send(toserver,"release",NULL);
-} /* end_of_unlock */
-
-int client(int argc, char *argv[]) {
+}                               /* end_of_server */
+
+void lock(gras_socket_t toserver)
+{
+  gras_msg_send(toserver, "request", NULL);
+  gras_msg_wait(-1, "grant", NULL, NULL);
+  INFO0("Granted by server");
+}                               /* end_of_lock */
+
+void unlock(gras_socket_t toserver)
+{
+  INFO0("Release the token");
+  gras_msg_send(toserver, "release", NULL);
+}                               /* end_of_unlock */
+
+int client(int argc, char *argv[])
+{
   int i;
-  gras_socket_t mysock;   /* socket on which I listen */
-  gras_socket_t toserver; /* socket used to write to the server */
+  gras_socket_t mysock;         /* socket on which I listen */
+  gras_socket_t toserver;       /* socket used to write to the server */
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
 
   mysock = gras_socket_server_range(1024, 10000, 0, 0);
-  
+
   VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
-  
-  gras_os_sleep(1.5); /* sleep 1 second and half */
+
+  gras_os_sleep(1.5);           /* sleep 1 second and half */
   message_declaration();
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
 
-  for (i=0;i<5; i++) {
-     gras_os_sleep(0.1);
-     lock(toserver);
-     gras_os_sleep(0.1);
-     unlock(toserver);
+  for (i = 0; i < 5; i++) {
+    gras_os_sleep(0.1);
+    lock(toserver);
+    gras_os_sleep(0.1);
+    unlock(toserver);
   }
   gras_exit();
   return 0;
index 720318f..9bcb87f 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <gras.h>
 
-#include <tbx_graph.h> /* alvin's graph toolbox (+ reconstruction algorithm) */
+#include <tbx_graph.h>          /* alvin's graph toolbox (+ reconstruction algorithm) */
 
 /* **********************************************************************
  * Sensor code
@@ -26,14 +26,17 @@ typedef struct {
 } sensor_data_t;
 
 /* Function prototypes */
-int sensor (int argc,char *argv[]);
+int sensor(int argc, char *argv[]);
 
-int sensor (int argc,char *argv[]) {
+int sensor(int argc, char *argv[])
+{
   xbt_error_t errcode;
-  sensor_data_t *g=gras_userdata_new(sensor_data_t);  
+  sensor_data_t *g = gras_userdata_new(sensor_data_t);
 
-  if ((errcode=gras_sock_server_open(4000,4000,&(g->sock)))) { 
-    fprintf(stderr,"Sensor: Error %s encountered while opening the server socket\n",xbt_error_name(errcode));
+  if ((errcode = gras_sock_server_open(4000, 4000, &(g->sock)))) {
+    fprintf(stderr,
+            "Sensor: Error %s encountered while opening the server socket\n",
+            xbt_error_name(errcode));
     return 1;
   }
 
@@ -43,13 +46,13 @@ int sensor (int argc,char *argv[]) {
   }
 
   while (1) {
-    if ((errcode=gras_msg_handle(3600.0)) && errcode != timeout_error) {
-      fprintf(stderr,"Sensor: Error '%s' while handling message\n",
-             xbt_error_name(errcode));
+    if ((errcode = gras_msg_handle(3600.0)) && errcode != timeout_error) {
+      fprintf(stderr, "Sensor: Error '%s' while handling message\n",
+              xbt_error_name(errcode));
     }
   }
 
-  gras_sleep(5,0);
+  gras_sleep(5, 0);
   return gras_sock_close(g->sock);
 }
 
@@ -63,7 +66,7 @@ typedef struct {
 } maestro_data_t;
 
 /* Function prototypes */
-int maestro (int argc,char *argv[]);
+int maestro(int argc, char *argv[]);
 
 #define MAXHOSTS 100
 
@@ -73,33 +76,38 @@ int maestro (int argc,char *argv[]);
                                                 TBX_Graph_nodeSearch(graph,b),\
                                                 TBX_Graph_nodeSearch(graph,v))
 
-int maestro(int argc,char *argv[]) {
-  int bufSize=32 * 1024;
-  int expSize= 1024 * 1024;
-  int msgSize=expSize;
-  int satSize=msgSize * 100;
-  double dummy,beginSim;
+int maestro(int argc, char *argv[])
+{
+  int bufSize = 32 * 1024;
+  int expSize = 1024 * 1024;
+  int msgSize = expSize;
+  int satSize = msgSize * 100;
+  double dummy, beginSim;
   xbt_error_t errcode;
-  maestro_data_t *g=gras_userdata_new(maestro_data_t);
+  maestro_data_t *g = gras_userdata_new(maestro_data_t);
 
   double bw[MAXHOSTS][MAXHOSTS];
   double bw_sat[MAXHOSTS][MAXHOSTS];
 
-  int a,b,c,d,begin;
+  int a, b, c, d, begin;
 
-  TBX_Graph_t graph = TBX_Graph_newGraph("Essai",0,NULL); /* a dummy graph containing all hosts */
+  TBX_Graph_t graph = TBX_Graph_newGraph("Essai", 0, NULL);     /* a dummy graph containing all hosts */
   TBX_FIFO_t host_fifo = TBX_FIFO_newFIFO();
-  TBX_InterfTable_t interf = NULL; /* the measured interferences */
-  TBX_Graph_t builded_graph = NULL; /* the graph builded from the interferences */
+  TBX_InterfTable_t interf = NULL;      /* the measured interferences */
+  TBX_Graph_t builded_graph = NULL;     /* the graph builded from the interferences */
 
   /* basics setups */
-  if (argc>MAXHOSTS) {
-    fprintf(stderr,"You gave more than %d sensors for this experiment. Increase the MAX HOSTS constant in alnem code to be bigger than this number.\n",argc);
+  if (argc > MAXHOSTS) {
+    fprintf(stderr,
+            "You gave more than %d sensors for this experiment. Increase the MAX HOSTS constant in alnem code to be bigger than this number.\n",
+            argc);
     return 1;
   }
 
-  if ((errcode=gras_sock_server_open(4000,5000,&(g->sock)))) { 
-    fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",xbt_error_name(errcode));
+  if ((errcode = gras_sock_server_open(4000, 5000, &(g->sock)))) {
+    fprintf(stderr,
+            "MAESTRO: Error %s encountered while opening the server socket\n",
+            xbt_error_name(errcode));
     return 1;
   }
 
@@ -108,109 +116,125 @@ int maestro(int argc,char *argv[]) {
     return 1;
   }
 
-  for (a=1; a<argc; a++) {
-    TBX_FIFO_insert(host_fifo,TBX_Graph_newNode(graph,argv[a], NULL));
+  for (a = 1; a < argc; a++) {
+    TBX_FIFO_insert(host_fifo, TBX_Graph_newNode(graph, argv[a], NULL));
   }
   TBX_Graph_fixNodeNumbering(graph);
-  interf=TBX_Graph_newInterfTable(host_fifo);
-  TBX_Graph_graphInterfTableInit(graph,interf);
+  interf = TBX_Graph_newInterfTable(host_fifo);
+  TBX_Graph_graphInterfTableInit(graph, interf);
 
   /* measure the bandwidths */
-  begin=time(NULL);
-  beginSim=gras_time();
-  for (a=1; a<argc; a++) {
-    for (b=1; b<argc; b++) {
-      int test=0;
-       
-      if (a==b) continue;
-      fprintf(stderr,"BW XP(%s %s)=",argv[a],argv[b]); 
-      while ((errcode=grasbw_request(argv[a],4000,argv[b],4000,bufSize,expSize,msgSize,
-                                 &dummy,&(bw[a][b]))) && (errcode == timeout_error)) {
-        test++;
-        if (test==10) {
-           fprintf(stderr,"MAESTRO: 10 Timeouts; giving up\n");
-           return 1;
-        }
+  begin = time(NULL);
+  beginSim = gras_time();
+  for (a = 1; a < argc; a++) {
+    for (b = 1; b < argc; b++) {
+      int test = 0;
+
+      if (a == b)
+        continue;
+      fprintf(stderr, "BW XP(%s %s)=", argv[a], argv[b]);
+      while ((errcode =
+              grasbw_request(argv[a], 4000, argv[b], 4000, bufSize,
+                             expSize, msgSize, &dummy, &(bw[a][b])))
+             && (errcode == timeout_error)) {
+        test++;
+        if (test == 10) {
+          fprintf(stderr, "MAESTRO: 10 Timeouts; giving up\n");
+          return 1;
+        }
       }
       if (errcode) {
-       fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
-       return 1;
+        fprintf(stderr,
+                "MAESTRO: Error %s encountered while doing the test\n",
+                xbt_error_name(errcode));
+        return 1;
       }
-      fprintf(stderr,"%f Mb/s in %f sec\n",bw[a][b],dummy);
+      fprintf(stderr, "%f Mb/s in %f sec\n", bw[a][b], dummy);
     }
   }
-  fprintf(stderr,"Did all BW tests in %ld sec (%.2f simulated sec)\n",
-         time(NULL)-begin,gras_time()-beginSim);
-      
+  fprintf(stderr, "Did all BW tests in %ld sec (%.2f simulated sec)\n",
+          time(NULL) - begin, gras_time() - beginSim);
+
   /* saturation tests */
-  for (a=1; a<argc; a++) {
-    for (b=1; b<argc; b++) {
-      for (c=1 ;c<argc; c++) {
-       INTERF(graph,interf,argv[a],argv[c],argv[b],argv[c])= 1;
+  for (a = 1; a < argc; a++) {
+    for (b = 1; b < argc; b++) {
+      for (c = 1; c < argc; c++) {
+        INTERF(graph, interf, argv[a], argv[c], argv[b], argv[c]) = 1;
       }
     }
   }
-         
-  for (a=1; a<argc; a++) {
-    for (b=1; b<argc; b++) {
-      if (a==b) continue;
-       
-      if ((errcode=grasbw_saturate_start(argv[a],4000,argv[b],4000,satSize,360000000))) {
-       fprintf(stderr,"MAESTRO: Error %s encountered while starting saturation\n",
-               xbt_error_name(errcode));
-       return -1;
+
+  for (a = 1; a < argc; a++) {
+    for (b = 1; b < argc; b++) {
+      if (a == b)
+        continue;
+
+      if ((errcode =
+           grasbw_saturate_start(argv[a], 4000, argv[b], 4000, satSize,
+                                 360000000))) {
+        fprintf(stderr,
+                "MAESTRO: Error %s encountered while starting saturation\n",
+                xbt_error_name(errcode));
+        return -1;
       }
-      gras_sleep(1,0);
-
-      begin=time(NULL);
-      beginSim=gras_time();
-      for (c=1 ;c<argc; c++) {
-       if (a==c || b==c) continue;
-
-       for (d=1 ;d<argc; d++) {
-         if (a==d || b==d || c==d) continue;
-         
-         if ((errcode=grasbw_request(argv[c],4000,argv[d],4000,bufSize,expSize,msgSize,
-                                     &dummy,&(bw_sat[c][d])))) {
-           fprintf(stderr,"MAESTRO: Error %s encountered in test\n",xbt_error_name(errcode));
-           return 1;
-         }
-         fprintf(stderr, "MAESTRO[%.2f sec]: SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s\n",
-                 gras_time(),
-                 argv[c],argv[d],argv[a],argv[b],
-                 bw_sat[c][d]/bw[c][d],bw[c][d],bw_sat[c][d],
-
-                 (bw_sat[c][d]/bw[c][d] < 0.75) ? " THERE IS SOME INTERFERENCE !!!":"");
-         INTERF(graph,interf,argv[c],argv[d],argv[a],argv[b])= 
-           (bw_sat[c][d]/bw[c][d] < 0.75) ? 1 : 0;
-       }
+      gras_sleep(1, 0);
+
+      begin = time(NULL);
+      beginSim = gras_time();
+      for (c = 1; c < argc; c++) {
+        if (a == c || b == c)
+          continue;
+
+        for (d = 1; d < argc; d++) {
+          if (a == d || b == d || c == d)
+            continue;
+
+          if ((errcode =
+               grasbw_request(argv[c], 4000, argv[d], 4000, bufSize,
+                              expSize, msgSize, &dummy,
+                              &(bw_sat[c][d])))) {
+            fprintf(stderr, "MAESTRO: Error %s encountered in test\n",
+                    xbt_error_name(errcode));
+            return 1;
+          }
+          fprintf(stderr,
+                  "MAESTRO[%.2f sec]: SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s\n",
+                  gras_time(), argv[c], argv[d], argv[a], argv[b],
+                  bw_sat[c][d] / bw[c][d], bw[c][d], bw_sat[c][d],
+                  (bw_sat[c][d] / bw[c][d] <
+                   0.75) ? " THERE IS SOME INTERFERENCE !!!" : "");
+          INTERF(graph, interf, argv[c], argv[d], argv[a], argv[b]) =
+              (bw_sat[c][d] / bw[c][d] < 0.75) ? 1 : 0;
+        }
       }
 
-      if ((errcode=grasbw_saturate_stop(argv[a],4000,argv[b],4000))) {
-       fprintf(stderr,"MAESTRO: Error %s encountered while stopping saturation\n",
-               xbt_error_name(errcode));
-       return -1;
+      if ((errcode = grasbw_saturate_stop(argv[a], 4000, argv[b], 4000))) {
+        fprintf(stderr,
+                "MAESTRO: Error %s encountered while stopping saturation\n",
+                xbt_error_name(errcode));
+        return -1;
       }
-      fprintf(stderr,"Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n",
-             time(NULL)-begin, gras_time()-beginSim);
+      fprintf(stderr,
+              "Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n",
+              time(NULL) - begin, gras_time() - beginSim);
     }
   }
 
   /* reconstruct the graph */
   TBX_Graph_interferenceTableDump(interf);
-  TBX_Graph_interferenceTableSave(interf,"interference.dat");
-  begin=time(NULL);
+  TBX_Graph_interferenceTableSave(interf, "interference.dat");
+  begin = time(NULL);
   fprintf(stderr, "MAESTRO: Reconstruct the graph... ");
   builded_graph = TBX_Graph_exploreInterference(interf);
   TBX_Graph_exportToGraphViz(builded_graph, "toto.dot");
-  fprintf(stderr, "done (took %d sec)",(int)time(NULL));
+  fprintf(stderr, "done (took %d sec)", (int) time(NULL));
 
   /* end */
-  TBX_Graph_freeGraph(graph,NULL,NULL,NULL);
-  TBX_Graph_freeGraph(builded_graph,NULL,NULL,NULL);
+  TBX_Graph_freeGraph(graph, NULL, NULL, NULL);
+  TBX_Graph_freeGraph(builded_graph, NULL, NULL, NULL);
   TBX_Graph_freeInterfTable(interf);
 
-  gras_sleep(5,0);
-  exit(0); /* FIXME: There is a bug in MSG preventing me from terminating this server properly */
+  gras_sleep(5, 0);
+  exit(0);                      /* FIXME: There is a bug in MSG preventing me from terminating this server properly */
   return gras_sock_close(g->sock);
 }
index 8fa78e7..26341f1 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <tbx_graph.h> /* alvin's graph toolbox (+ reconstruction algorithm) */
+#include <tbx_graph.h>          /* alvin's graph toolbox (+ reconstruction algorithm) */
 
-int main(int argc,char *argv[]) {
-  TBX_Graph_t graph; /* a dummy graph containing all hosts */
+int main(int argc, char *argv[])
+{
+  TBX_Graph_t graph;            /* a dummy graph containing all hosts */
   TBX_FIFO_t host_fifo;
-  TBX_InterfTable_t interf; /* the measured interferences */
-  TBX_Graph_t builded_graph; /* the graph builded from the interferences */
+  TBX_InterfTable_t interf;     /* the measured interferences */
+  TBX_Graph_t builded_graph;    /* the graph builded from the interferences */
 
   if (argc != 2) {
-    fprintf(stderr,"alnem_builder: USAGE:\n");
-    fprintf(stderr,"  alnem_builder interference_file\n");
-    exit (1);
+    fprintf(stderr, "alnem_builder: USAGE:\n");
+    fprintf(stderr, "  alnem_builder interference_file\n");
+    exit(1);
   }
 
-  if (TBX_Graph_interferenceTableRead (argv[1],&graph,&interf,&host_fifo)) {
-    fprintf(stderr,"Can't read the interference data, aborting\n");
-    exit (1);
+  if (TBX_Graph_interferenceTableRead
+      (argv[1], &graph, &interf, &host_fifo)) {
+    fprintf(stderr, "Can't read the interference data, aborting\n");
+    exit(1);
   }
 
   builded_graph = TBX_Graph_exploreInterference(interf);
index 1090b5f..e5d5de9 100644 (file)
@@ -11,7 +11,8 @@
 #include "amok/bandwidth.h"
 #include "amok/peermanagement.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth, "Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,
+                             "Messages specific to this example");
 
 /* **********************************************************************
  * Sensor code
@@ -110,19 +111,21 @@ int maestro(int argc, char *argv[])
   peer = gras_socket_client(h1->name, h1->port);
 
   INFO0("Test the BW between me and one of the sensors");
-  amok_bw_test(peer, buf_size, msg_size, msg_amount, min_duration, &sec, &bw);
+  amok_bw_test(peer, buf_size, msg_size, msg_amount, min_duration, &sec,
+               &bw);
   INFO7
-    ("Experience between me and %s:%d (initially %d msgs of %d bytes, maybe modified to fill the pipe at least %.1fs) took %f sec, achieving %f kb/s",
-     h1->name, h1->port, msg_amount, msg_size, min_duration, sec,
-     ((double) bw) / 1024.0);
-
-  INFO4("Test the BW between %s:%d and %s:%d", h1->name, h1->port, h2->name,
-        h2->port);
-  amok_bw_request(h1->name, h1->port, h2->name, h2->port, buf_size, msg_size,
-                  msg_amount, min_duration, &sec, &bw);
+      ("Experience between me and %s:%d (initially %d msgs of %d bytes, maybe modified to fill the pipe at least %.1fs) took %f sec, achieving %f kb/s",
+       h1->name, h1->port, msg_amount, msg_size, min_duration, sec,
+       ((double) bw) / 1024.0);
+
+  INFO4("Test the BW between %s:%d and %s:%d", h1->name, h1->port,
+        h2->name, h2->port);
+  amok_bw_request(h1->name, h1->port, h2->name, h2->port, buf_size,
+                  msg_size, msg_amount, min_duration, &sec, &bw);
   INFO6
-    ("Experience between %s:%d and %s:%d took took %f sec, achieving %f kb/s",
-     h1->name, h1->port, h2->name, h2->port, sec, ((double) bw) / 1024.0);
+      ("Experience between %s:%d and %s:%d took took %f sec, achieving %f kb/s",
+       h1->name, h1->port, h2->name, h2->port, sec,
+       ((double) bw) / 1024.0);
 
   /* Game is over, friends */
   amok_pm_group_shutdown("bandwidth");
index 45abca5..9309cba 100644 (file)
 #include "amok/bandwidth.h"
 #include "amok/hostmanagement.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,
+                             "Messages specific to this example");
 
-static void env_hosttohost_bw(int argc, char*argv[]) {
+static void env_hosttohost_bw(int argc, char *argv[])
+{
 
   /* where are the sensors */
-  xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
+  xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t), &free_host);
   int nb_hosts;
 
   /* results */
@@ -30,108 +32,114 @@ static void env_hosttohost_bw(int argc, char*argv[]) {
   int i;
   xbt_host_t h1;
 
-  gras_socket_t peer; /* socket to sensor */
+  gras_socket_t peer;           /* socket to sensor */
 
-  /* wait to ensure that all server sockets are there before starting the experiment */        
+  /* wait to ensure that all server sockets are there before starting the experiment */
   gras_os_sleep(0.5);
 
   /* Get the sensor location from argc/argv */
-  for (i=1; i<argc-1; i+=2){
-    xbt_host_t host=xbt_new(s_xbt_host_t,1);
-    host->name=strdup(argv[i]);
-    host->port=atoi(argv[i+1]);
-    INFO2("New sensor: %s:%d",host->name,host->port);
-    xbt_dynar_push(hosts,&host);
+  for (i = 1; i < argc - 1; i += 2) {
+    xbt_host_t host = xbt_new(s_xbt_host_t, 1);
+    host->name = strdup(argv[i]);
+    host->port = atoi(argv[i + 1]);
+    INFO2("New sensor: %s:%d", host->name, host->port);
+    xbt_dynar_push(hosts, &host);
   }
   nb_hosts = xbt_dynar_length(hosts);
 
   INFO0(">>> start Test1: ENV end to end mesurements");
 
-  xbt_dynar_foreach(hosts,i,h1) {
-        peer = gras_socket_client(h1->name,h1->port);
-       amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
-       INFO6("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
-       h1->name,h1->port,
-       exp_size,msg_size,
-       sec,((double)bw)/1024.0);
+  xbt_dynar_foreach(hosts, i, h1) {
+    peer = gras_socket_client(h1->name, h1->port);
+    amok_bw_test(peer, buf_size, exp_size, msg_size, min_duration, &sec,
+                 &bw);
+    INFO6
+        ("Bandwidth between me and %s:%d (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
+         h1->name, h1->port, exp_size, msg_size, sec,
+         ((double) bw) / 1024.0);
   }
 
-  xbt_dynar_map(hosts,kill_buddy_dynar);
+  xbt_dynar_map(hosts, kill_buddy_dynar);
   xbt_dynar_free(&hosts);
 
 }
+
 /********************************************************************************************/
-static void env_Pairwisehost_bw(int argc, char*argv[]) {
+static void env_Pairwisehost_bw(int argc, char *argv[])
+{
   xbt_ex_t e;
 
   /* where are the sensors */
-  xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&free_host);
+  xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t), &free_host);
   int nb_hosts;
 
   /* getting the name of maestro for the saturation and the concurrent bandwidth measurements  */
-  char* host_test=argv[0];
+  char *host_test = argv[0];
 
   /* results */
   double sec, bw;
 
   /* iterators */
-  int i,j;
-  xbt_host_t h1,h2;
+  int i, j;
+  xbt_host_t h1, h2;
 
   /* socket to sensor */
   gras_socket_t peer;
 
-  /* wait to ensure that all server sockets are there before starting the experiment */        
+  /* wait to ensure that all server sockets are there before starting the experiment */
   gras_os_sleep(0.5);
 
-  INFO1(">>>>>< le maestro est: %s ",argv[0]);
+  INFO1(">>>>>< le maestro est: %s ", argv[0]);
   /* Get the sensor location from argc/argv */
-  for (i=1; i<argc-1; i+=2){
-    xbt_host_t host=xbt_new(s_xbt_host_t,1);
-    host->name=strdup(argv[i]);
-    host->port=atoi(argv[i+1]);
-    INFO2("New sensor: %s:%d",host->name,host->port);
-    xbt_dynar_push(hosts,&host);
+  for (i = 1; i < argc - 1; i += 2) {
+    xbt_host_t host = xbt_new(s_xbt_host_t, 1);
+    host->name = strdup(argv[i]);
+    host->port = atoi(argv[i + 1]);
+    INFO2("New sensor: %s:%d", host->name, host->port);
+    xbt_dynar_push(hosts, &host);
   }
   nb_hosts = xbt_dynar_length(hosts);
 
   INFO0(">>> start Test2: ENV pairwise host bandwidth mesurements");
- xbt_dynar_foreach(hosts,i,h1) {
-
-      TRY {
-       amok_bw_saturate_start(h1->name,h1->port,
-                              host_test,h1->port,//"Ginette"
-                              msg_size,120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
-      } CATCH(e) {
-       RETHROW0("Cannot ask hosts to saturate the link: %s");
-      }
-     // gras_os_sleep(1.0);
-
-       xbt_dynar_foreach(hosts,j,h2) {
-        if (i==j) continue;
-
-        peer = gras_socket_client(h2->name,h2->port);
-       amok_bw_test(peer,buf_size,exp_size,msg_size,min_duration,&sec,&bw);
-       INFO6("Bandwidth between me and %s // measurement between me and %s (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
-       h2->name,h1->name,
-       exp_size,msg_size,
-       sec,((double)bw)/1024.0);
-
+  xbt_dynar_foreach(hosts, i, h1) {
+
+    TRY {
+      amok_bw_saturate_start(h1->name, h1->port, host_test, h1->port,   //"Ginette"
+                             msg_size, 120);    // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
+    }
+    CATCH(e) {
+      RETHROW0("Cannot ask hosts to saturate the link: %s");
+    }
+    // gras_os_sleep(1.0);
+
+    xbt_dynar_foreach(hosts, j, h2) {
+      if (i == j)
+        continue;
+
+      peer = gras_socket_client(h2->name, h2->port);
+      amok_bw_test(peer, buf_size, exp_size, msg_size, min_duration, &sec,
+                   &bw);
+      INFO6
+          ("Bandwidth between me and %s // measurement between me and %s (%d bytes in msgs of %d bytes) took %f sec, achieving %.3f kb/s",
+           h2->name, h1->name, exp_size, msg_size, sec,
+           ((double) bw) / 1024.0);
+
+    }
+    amok_bw_saturate_stop(h1->name, h1->port, NULL, NULL);
   }
-       amok_bw_saturate_stop(h1->name,h1->port,NULL,NULL);
-}
-  xbt_dynar_map(hosts,kill_buddy_dynar);
+  xbt_dynar_map(hosts, kill_buddy_dynar);
   xbt_dynar_free(&hosts);
 
 }
 
-int maestro(int argc,char *argv[]) {
+int maestro(int argc, char *argv[])
+{
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
   amok_bw_init();
   amok_hm_init();
 
-  gras_socket_server(3333); /* only so that messages from the transport layer in gras identify us */
+  gras_socket_server(3333);     /* only so that messages from the transport layer in gras identify us */
 
   //env_Pairwisehost_bw(argc,argv);
   //env_hosttohost_bw(argc,argv);
index 8d4a537..1b77417 100644 (file)
@@ -16,7 +16,8 @@
 #include "amok/bandwidth.h"
 #include "amok/peermanagement.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(saturate, "Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,
+                             "Messages specific to this example");
 
 /* **********************************************************************
  * Sensor code
@@ -83,8 +84,8 @@ static double XP(const char *bw1, const char *bw2,
   amok_bw_request(bw1, 4000, bw2, 4000,
                   buf_size, msg_size, msg_amount, min_duration, &sec_sat,
                   &bw_sat);
-  INFO6("BW(%s,%s//%s,%s) => %f sec, achieving %f Mb/s", bw1, bw2, sat1, sat2,
-        sec, bw / 1024.0 / 1024.0);
+  INFO6("BW(%s,%s//%s,%s) => %f sec, achieving %f Mb/s", bw1, bw2, sat1,
+        sat2, sec, bw / 1024.0 / 1024.0);
 
   amok_bw_saturate_stop(sat1, 4000, NULL, NULL);
 
@@ -252,10 +253,12 @@ static void full_fledged_saturation(int argc, char *argv[])
       amok_bw_saturate_stop(h1->name, h1->port, &time1, &bw1);
 
       INFO2
-        ("Did an iteration on saturation pair in %ld sec (%.2f simulated sec)",
-         (long int) (time(NULL) - begin), gras_os_time() - begin_simulated);
-      INFO2("the duration of the experiment >>>>> %.3f sec (%.3f bandwidth)",
-            time1, bw1);
+          ("Did an iteration on saturation pair in %ld sec (%.2f simulated sec)",
+           (long int) (time(NULL) - begin),
+           gras_os_time() - begin_simulated);
+      INFO2
+          ("the duration of the experiment >>>>> %.3f sec (%.3f bandwidth)",
+           time1, bw1);
     }
   }
   free(bw_sat);
index 4c58b72..8e5d607 100644 (file)
@@ -57,8 +57,8 @@ int receiver(int argc, char *argv[])
     free(data);
 
     INFO3("Got Data from %s:%d (still %d to go)",
-          gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor),
-          todo);
+          gras_socket_peer_name(expeditor),
+          gras_socket_peer_port(expeditor), todo);
 
   }
 
@@ -86,7 +86,8 @@ int sender(int argc, char *argv[])
 
 
   /* xbt_dynar for peers */
-  xbt_dynar_t peers = xbt_dynar_new(sizeof(xbt_peer_t), &xbt_peer_free_voidp);
+  xbt_dynar_t peers =
+      xbt_dynar_new(sizeof(xbt_peer_t), &xbt_peer_free_voidp);
 
   /* Init the GRAS infrastructure and declare my globals */
   gras_init(&argc, argv);
index 7816fd2..5a0e1fd 100644 (file)
@@ -9,54 +9,54 @@
 #include "gras.h"
 #include "xbt/log.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono, "Messages specific to this example");
 
 #include <cblas.h>
 void cblas_dgemm(const enum CBLAS_ORDER Order,
-                const enum CBLAS_TRANSPOSE TransA,
-                const enum CBLAS_TRANSPOSE TransB, const int M,
-                const int N, const int K, const double alpha,
-                const double *A, const int lda, const double *B,
-                const int ldb, const double beta, double *C,
-                const int ldc);
+                 const enum CBLAS_TRANSPOSE TransA,
+                 const enum CBLAS_TRANSPOSE TransB, const int M,
+                 const int N, const int K, const double alpha,
+                 const double *A, const int lda, const double *B,
+                 const int ldb, const double beta, double *C,
+                 const int ldc);
 
 
 /* Function prototypes */
 static int mat_mult(int n)
 {
-  int i,j,k,l;
-  double *A,*B,*C;
+  int i, j, k, l;
+  double *A, *B, *C;
   double start = 0.0;
   double now = 0.0;
 
-  A = malloc(n*n*sizeof(double));
-  B = malloc(n*n*sizeof(double));
-  C = malloc(n*n*sizeof(double));
+  A = malloc(n * n * sizeof(double));
+  B = malloc(n * n * sizeof(double));
+  C = malloc(n * n * sizeof(double));
 
-  start=now=gras_os_time();
+  start = now = gras_os_time();
 
-  INFO1("Matrix size: %d",n);
+  INFO1("Matrix size: %d", n);
 /*   INFO1("Before computation: %lg", start); */
 
-  for(l=0; l<40; l++) {
-    now=gras_os_time();
+  for (l = 0; l < 40; l++) {
+    now = gras_os_time();
     GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
-    for(i=0; i<n; i++)
-      for(j=0; j<n; j++) {
-       A[i*n+j]=2/n;
-       B[i*n+j]=1/n;
-       C[i*n+j]=0.0;
+    for (i = 0; i < n; i++)
+      for (j = 0; j < n; j++) {
+        A[i * n + j] = 2 / n;
+        B[i * n + j] = 1 / n;
+        C[i * n + j] = 0.0;
       }
 
     cblas_dgemm(CblasRowMajor,
-               CblasNoTrans, CblasNoTrans, n, n, n,
-               1.0, A, n, B, n, 0.0, C, n);    
+                CblasNoTrans, CblasNoTrans, n, n, n,
+                1.0, A, n, B, n, 0.0, C, n);
     GRAS_BENCH_ONCE_RUN_ONCE_END();
-    now=gras_os_time()-now;
+    now = gras_os_time() - now;
 /*     INFO2("Iteration %d : %lg ", l, now); */
   }
 
-  now=gras_os_time()-start;
+  now = gras_os_time() - start;
   INFO1("Duration: %lg ", now);
 
   free(A);
@@ -64,7 +64,7 @@ static int mat_mult(int n)
   free(C);
 }
 
-int multiplier (int argc,char *argv[])
+int multiplier(int argc, char *argv[])
 {
   gras_init(&argc, argv);
 
index 11a9ccc..03e0317 100644 (file)
@@ -33,7 +33,8 @@ static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload)
   /* 3. Log which client connected */
   INFO3(">>>>>>>> Got message PING(%d) from %s:%d <<<<<<<<",
         msg,
-        gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor));
+        gras_socket_peer_name(expeditor),
+        gras_socket_peer_port(expeditor));
 
   /* 4. Change the value of the msg variable */
   msg = 4321;
@@ -93,7 +94,8 @@ int server(int argc, char *argv[])
 
   /* 7. Housekeeping */
   if (!globals->endcondition)
-    WARN0("An error occured, the endcondition was not set by the callback");
+    WARN0
+        ("An error occured, the endcondition was not set by the callback");
 
   /* 8. Free the allocated resources, and shut GRAS down */
   gras_socket_close(globals->sock);
index d1d3565..bfad502 100644 (file)
 #include "xbt/matrix.h"
 #include "mmrpc.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(MatMult,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(MatMult, "Messages specific to this example");
 
 /* register messages which may be sent and their payload
    (common to client and server) */
-void mmrpc_register_messages(void) {
+void mmrpc_register_messages(void)
+{
   gras_datadesc_type_t matrix_type, request_type;
 
-  matrix_type=gras_datadesc_matrix(gras_datadesc_by_name("double"),
-                                  NULL);
-  request_type=gras_datadesc_array_fixed("s_matrix_t(double)[2]",matrix_type,2);
-  
+  matrix_type = gras_datadesc_matrix(gras_datadesc_by_name("double"),
+                                     NULL);
+  request_type =
+      gras_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
+
   gras_msgtype_declare("answer", matrix_type);
   gras_msgtype_declare("request", request_type);
 }
 
 typedef xbt_matrix_t request_t[2];
-static int server_cb_request_handler(gras_msg_cb_ctx_t ctx, 
-                                    void *payload_data) {
+static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
+                                     void *payload_data)
+{
+
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
 
-  gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);
-                            
   /* 1. Get the payload into the data variable */
-  xbt_matrix_t *request = (xbt_matrix_t*)payload_data;
+  xbt_matrix_t *request = (xbt_matrix_t *) payload_data;
   xbt_matrix_t result;
-  
+
   /* 2. Do the computation */
   result = xbt_matrix_double_new_mult(request[0], request[1]);
 
@@ -46,124 +49,129 @@ static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
   xbt_matrix_free(request[1]);
   xbt_matrix_free(result);
   gras_socket_close(expeditor);
-   
+
   return 0;
-} /* end_of_server_cb_request_handler */
+}                               /* end_of_server_cb_request_handler */
 
-int server (int argc,char *argv[]) {
-  xbt_ex_t e; 
-  gras_socket_t sock=NULL;
+int server(int argc, char *argv[])
+{
+  xbt_ex_t e;
+  gras_socket_t sock = NULL;
   int port = 4000;
-  
+
   /* 1. Init the GRAS infrastructure */
-  gras_init(&argc,argv);
-   
+  gras_init(&argc, argv);
+
   /* 2. Get the port I should listen on from the command line, if specified */
   if (argc == 2) {
-    port=atoi(argv[1]);
+    port = atoi(argv[1]);
   }
 
   /* 3. Create my master socket */
   INFO1("Launch server (port=%d)", port);
   TRY {
     sock = gras_socket_server(port);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     RETHROW0("Unable to establish a server socket: %s");
   }
 
   /* 4. Register the known messages and payloads. */
   mmrpc_register_messages();
-   
+
   /* 5. Register my callback */
-  gras_cb_register("request",&server_cb_request_handler);
+  gras_cb_register("request", &server_cb_request_handler);
 
   /* 6. Wait up to 10 minutes for an incomming message to handle */
   gras_msg_handle(600.0);
-   
+
   /* 7. Free the allocated resources, and shut GRAS down */
   gras_socket_close(sock);
   gras_exit();
-   
+
   INFO0("Done.");
   return 0;
-} /* end_of_server */
+}                               /* end_of_server */
 
 
-int client(int argc,char *argv[]) {
-  xbt_ex_t e; 
-  gras_socket_t toserver=NULL; /* peer */
+int client(int argc, char *argv[])
+{
+  xbt_ex_t e;
+  gras_socket_t toserver = NULL;        /* peer */
 
   gras_socket_t from;
   xbt_matrix_t request[2], answer;
 
-  int i,j;
+  int i, j;
 
   const char *host = "127.0.0.1";
-        int   port = 4000;
+  int port = 4000;
 
   /* 1. Init the GRAS's infrastructure */
   gras_init(&argc, argv);
-   
+
   /* 2. Get the server's address. The command line override defaults when specified */
   if (argc == 3) {
-    host=argv[1];
-    port=atoi(argv[2]);
-  } 
+    host = argv[1];
+    port = atoi(argv[2]);
+  }
+
+  INFO2("Launch client (server on %s:%d)", host, port);
 
-  INFO2("Launch client (server on %s:%d)",host,port);
-   
   /* 3. Wait for the server startup */
   gras_os_sleep(1);
-   
+
   /* 4. Create a socket to speak to the server */
   TRY {
-    toserver=gras_socket_client(host,port);
-  } CATCH(e) {
+    toserver = gras_socket_client(host, port);
+  }
+  CATCH(e) {
     RETHROW0("Unable to connect to the server: %s");
   }
-  INFO2("Connected to %s:%d.",host,port);    
+  INFO2("Connected to %s:%d.", host, port);
 
 
   /* 5. Register the messages (before use) */
   mmrpc_register_messages();
 
   /* 6. Keep the user informed of what's going on */
-  INFO2(">>>>>>>> Connected to server which is on %s:%d <<<<<<<<", 
-       gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
+  INFO2(">>>>>>>> Connected to server which is on %s:%d <<<<<<<<",
+        gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
 
   /* 7. Prepare and send the request to the server */
 
-  request[0] = xbt_matrix_double_new_id(MATSIZE,MATSIZE);
-  request[1] = xbt_matrix_double_new_rand(MATSIZE,MATSIZE);
+  request[0] = xbt_matrix_double_new_id(MATSIZE, MATSIZE);
+  request[1] = xbt_matrix_double_new_rand(MATSIZE, MATSIZE);
 
   /*
-  xbt_matrix_dump(request[0],"C:sent0",0,xbt_matrix_dump_display_double);
-  xbt_matrix_dump(request[1],"C:sent1",0,xbt_matrix_dump_display_double);
-  */
+     xbt_matrix_dump(request[0],"C:sent0",0,xbt_matrix_dump_display_double);
+     xbt_matrix_dump(request[1],"C:sent1",0,xbt_matrix_dump_display_double);
+   */
 
   gras_msg_send(toserver, "request", &request);
 
   xbt_matrix_free(request[0]);
 
   INFO2(">>>>>>>> Request sent to %s:%d <<<<<<<<",
-       gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
+        gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
 
   /* 8. Wait for the answer from the server, and deal with issues */
-  gras_msg_wait(6000,"answer",&from,&answer);
+  gras_msg_wait(6000, "answer", &from, &answer);
 
   /*
-  xbt_matrix_dump(answer,"C:answer",0,xbt_matrix_dump_display_double);
-  */
-  for (i=0; i<MATSIZE; i++) 
-    for (j=0; i<MATSIZE; i++) 
-      xbt_assert4(xbt_matrix_get_as(answer,i,j,double)==xbt_matrix_get_as(request[1],i,j,double),
-                 "Answer does not match expectations. Found %f at cell %d,%d instead of %f",
-                 xbt_matrix_get_as(answer,i,j,double),i,j,
-                 xbt_matrix_get_as(request[1],i,j,double));
+     xbt_matrix_dump(answer,"C:answer",0,xbt_matrix_dump_display_double);
+   */
+  for (i = 0; i < MATSIZE; i++)
+    for (j = 0; i < MATSIZE; i++)
+      xbt_assert4(xbt_matrix_get_as(answer, i, j, double) ==
+                  xbt_matrix_get_as(request[1], i, j, double),
+                  "Answer does not match expectations. Found %f at cell %d,%d instead of %f",
+                  xbt_matrix_get_as(answer, i, j, double), i, j,
+                  xbt_matrix_get_as(request[1], i, j, double));
 
   /* 9. Keep the user informed of what's going on, again */
-  INFO2(">>>>>>>> Got answer from %s:%d (values are right) <<<<<<<<", 
-       gras_socket_peer_name(from),gras_socket_peer_port(from));
+  INFO2(">>>>>>>> Got answer from %s:%d (values are right) <<<<<<<<",
+        gras_socket_peer_name(from), gras_socket_peer_port(from));
 
   /* 10. Free the allocated resources, and shut GRAS down */
   xbt_matrix_free(request[1]);
@@ -172,4 +180,4 @@ int client(int argc,char *argv[]) {
   gras_exit();
   INFO0("Done.");
   return 0;
-} /* end_of_client */
+}                               /* end_of_client */
index 13f5e0f..3f08bc8 100644 (file)
@@ -21,4 +21,4 @@ void mmrpc_register_messages(void);
 int server(int argc, char *argv[]);
 int client(int argc, char *argv[]);
 
-#endif /* MMRPC_H */
+#endif                          /* MMRPC_H */
index 5b0beaf..a488470 100644 (file)
@@ -16,9 +16,10 @@ void mmrpc_register_messages(void)
 {
   gras_datadesc_type_t matrix_type, request_type;
 
-  matrix_type = gras_datadesc_matrix(gras_datadesc_by_name("double"), NULL);
+  matrix_type =
+      gras_datadesc_matrix(gras_datadesc_by_name("double"), NULL);
   request_type =
-    gras_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
+      gras_datadesc_array_fixed("s_matrix_t(double)[2]", matrix_type, 2);
 
   gras_msgtype_declare("answer", matrix_type);
   gras_msgtype_declare("request", request_type);
index a9b9141..4c359f0 100644 (file)
 #include "xbt/sysdep.h"
 #include "gras.h"
 
-#include "can_tests.c"                                               
+#include "can_tests.c"
 //#include "types.h" // header alone containing the typedef struct of a node // include can_tests.c must be OFF.
 
 //XBT_LOG_NEW_DEFAULT_CATEGORY(can,"Messages specific to this example"); // include can_tests.c must be OFF.
 
 //extern char *_gras_this_type_symbol_does_not_exist__s_nuke;
-int node_nuke_handler(gras_msg_cb_ctx_t ctx,void *payload_data);
+int node_nuke_handler(gras_msg_cb_ctx_t ctx, void *payload_data);
 
 // struct of a "get_successor" message, when a node look after the area in which he want to be.
-GRAS_DEFINE_TYPE(s_get_suc,
-       struct s_get_suc{
-               int xId;
-               int yId;
-               char host[1024];
-               int port;       
-       };
-);
+GRAS_DEFINE_TYPE(s_get_suc, struct s_get_suc {
+                 int xId; int yId; char host[1024]; int port;};);
+
 typedef struct s_get_suc get_suc_t;
 
 // struct of a "response_successor" message, hen a node receive the information of his new area.
-GRAS_DEFINE_TYPE(s_rep_suc,
-       struct s_rep_suc{
-               int x1; // Xmin
-               int x2; // Xmax
-               int y1; // Ymin
-               int y2; // Ymax
-
-               char north_host[1024];
-               int north_port;
-               char south_host[1024];
-               int south_port;
-               char east_host[1024];
-               int east_port;
-               char west_host[1024];
-               int west_port;
-       };
-);
+GRAS_DEFINE_TYPE(s_rep_suc, struct s_rep_suc {
+                 int x1;        // Xmin
+                 int x2;        // Xmax
+                 int y1;        // Ymin
+                 int y2;        // Ymax
+                 char north_host[1024];
+                 int north_port;
+                 char south_host[1024];
+                 int south_port;
+                 char east_host[1024];
+                 int east_port; char west_host[1024]; int west_port;};);
 typedef struct s_rep_suc rep_suc_t;
 
-int node(int argc,char **argv);
+int node(int argc, char **argv);
 
 // registering messages types
-static void register_messages(){
-       gras_msgtype_declare("can_get_suc",gras_datadesc_by_symbol(s_get_suc));
-       gras_msgtype_declare("can_rep_suc",gras_datadesc_by_symbol(s_rep_suc));
-       gras_msgtype_declare("can_nuke",gras_datadesc_by_symbol(s_nuke));// can_test.c message // include can_tests.c must be ON.
+static void register_messages()
+{
+  gras_msgtype_declare("can_get_suc", gras_datadesc_by_symbol(s_get_suc));
+  gras_msgtype_declare("can_rep_suc", gras_datadesc_by_symbol(s_rep_suc));
+  gras_msgtype_declare("can_nuke", gras_datadesc_by_symbol(s_nuke));    // can_test.c message // include can_tests.c must be ON.
 }
 
 
 // a forwarding function for a "get_suc" message.
-static void forward_get_suc(get_suc_t msg, char host[1024], int port){
-       gras_socket_t temp_sock=NULL;
-       xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
-       //INFO2("Transmiting message to %s:%d",host,port);      
-       TRY{
-               temp_sock=gras_socket_client(host,port);
-       }CATCH(e){
-               RETHROW0("Unable to connect!: %s");
-       }
-       TRY{
-               gras_msg_send(temp_sock,"can_get_suc",&msg);
-       }CATCH(e){
-               RETHROW0("Unable to send!: %s");
-       }
-       INFO3("Forwarding a get_successor message to %s for (%d;%d)",host,msg.xId,msg.yId);
-       gras_socket_close(temp_sock);
+static void forward_get_suc(get_suc_t msg, char host[1024], int port)
+{
+  gras_socket_t temp_sock = NULL;
+  xbt_ex_t e;                   // the error variable used in TRY.. CATCH tokens.
+  //INFO2("Transmiting message to %s:%d",host,port);      
+  TRY {
+    temp_sock = gras_socket_client(host, port);
+  } CATCH(e) {
+    RETHROW0("Unable to connect!: %s");
+  }
+  TRY {
+    gras_msg_send(temp_sock, "can_get_suc", &msg);
+  } CATCH(e) {
+    RETHROW0("Unable to send!: %s");
+  }
+  INFO3("Forwarding a get_successor message to %s for (%d;%d)", host,
+        msg.xId, msg.yId);
+  gras_socket_close(temp_sock);
 }
 
 // the handling function of a "get_suc" message (what do a node when he receive a "get_suc" message.
-static int node_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
-        gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);
-       get_suc_t *incoming=(get_suc_t*)payload_data;
-       xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
-       node_data_t *globals=(node_data_t*)gras_userdata_get();
-       gras_socket_t temp_sock=NULL;
-       INFO3("Received a get_successor message from %s for (%d;%d)",gras_socket_peer_name(expeditor),incoming->xId,incoming->yId);
-       //INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
-       if(incoming->xId<globals->x1) // test if the message must be forwarded to a neighbour.
-               forward_get_suc(*incoming, globals->west_host, globals->west_port);
-       else if(incoming->xId>globals->x2)
-               forward_get_suc(*incoming, globals->east_host, globals->east_port);
-       else if(incoming->yId<globals->y1)
-               forward_get_suc(*incoming, globals->south_host, globals->south_port);
-       else if(incoming->yId>globals->y2)
-               forward_get_suc(*incoming, globals->north_host, globals->north_port);
-       else{ // if the message must not be forwarded, then the area is splitted in half and one half is assignated to the new node.
-               rep_suc_t outgoing;
-               int validate=0;
-               INFO4("Spliting my area between me (%d;%d) and the inserting node (%d;%d)!",
-                     globals->xId,globals->yId,incoming->xId,incoming->yId);
-               if((globals->x2-globals->x1)>(globals->y2-globals->y1)){ // the height of the area is smaller than its width.
-                 if(incoming->xId<globals->xId){ // the new node is west from the actual node.
-                       outgoing.x1=globals->x1;
-                       outgoing.x2=(incoming->xId+globals->xId)/2;
-                       outgoing.y1=globals->y1;
-                       outgoing.y2=globals->y2;
-                       strcpy(outgoing.north_host,globals->north_host);
-                       outgoing.north_port=globals->north_port;
-                       strcpy(outgoing.south_host,globals->south_host);
-                       outgoing.south_port=globals->south_port;
-                       strcpy(outgoing.east_host,globals->host);
-                       outgoing.east_port=globals->port;
-                       strcpy(outgoing.west_host,globals->west_host);
-                       outgoing.west_port=globals->west_port;
-
-                       globals->x1=(incoming->xId+globals->xId)/2;
-                       strcpy(globals->west_host,incoming->host);
-                       globals->west_port=incoming->port;
-                       validate=1;
-                 }
-                 else if(incoming->xId>globals->xId){ // the new node is east from the actual node.
-                       outgoing.x1=(incoming->xId+globals->xId)/2;
-                       outgoing.x2=globals->x2;
-                       outgoing.y1=globals->y1;
-                       outgoing.y2=globals->y2;
-                       strcpy(outgoing.north_host,globals->north_host);
-                       outgoing.north_port=globals->north_port;
-                       strcpy(outgoing.south_host,globals->south_host);
-                       outgoing.south_port=globals->south_port;
-                       strcpy(outgoing.east_host,globals->east_host);
-                       outgoing.east_port=globals->east_port;
-                       strcpy(outgoing.west_host,globals->host);
-                       outgoing.west_port=globals->port;
-
-                       globals->x2=(incoming->xId+globals->xId)/2;
-                       strcpy(globals->east_host,incoming->host);
-                       globals->east_port=incoming->port;
-                       validate=1;                     
-                 }
-               }
-               else{
-                  if(incoming->yId<globals->yId){ // the new node is south from the actual node.
-                       outgoing.y1=globals->y1;
-                       outgoing.y2=(incoming->yId+globals->yId)/2;
-                       outgoing.y1=globals->y1;
-                       outgoing.x2=globals->x2;
-                       strcpy(outgoing.east_host,globals->east_host);
-                       outgoing.east_port=globals->east_port;
-                       strcpy(outgoing.west_host,globals->west_host);
-                       outgoing.west_port=globals->west_port;
-                       strcpy(outgoing.north_host,globals->host);
-                       outgoing.north_port=globals->port;
-                       strcpy(outgoing.south_host,globals->south_host);
-                       outgoing.south_port=globals->south_port;
-
-                       globals->y1=(incoming->yId+globals->yId)/2;
-                       strcpy(globals->south_host,incoming->host);
-                       globals->south_port=incoming->port;
-                       validate=1;                     
-                  }
-                  else if(incoming->yId>globals->yId){ // the new node is north from the actual node.
-                       outgoing.y1=(incoming->yId+globals->yId)/2;
-                       outgoing.y2=globals->y2;
-                       outgoing.x1=globals->x1;
-                       outgoing.x2=globals->x2;
-                       strcpy(outgoing.east_host,globals->east_host);
-                       outgoing.east_port=globals->east_port;
-                       strcpy(outgoing.west_host,globals->west_host);
-                       outgoing.west_port=globals->west_port;
-                       strcpy(outgoing.north_host,globals->north_host);
-                       outgoing.north_port=globals->north_port;
-                       strcpy(outgoing.south_host,globals->host);
-                       outgoing.south_port=globals->port;
-
-                       globals->y2=(incoming->yId+globals->yId)/2;
-                       strcpy(globals->north_host,incoming->host);
-                       globals->north_port=incoming->port;
-                       validate=1;                     
-                  }
-               }
-               if(validate==1){ // the area for the new node has been defined, then send theses informations to the new node.
-                       INFO2("Sending environment informations to node %s:%d",incoming->host,incoming->port);
-
-                       TRY{
-                               temp_sock=gras_socket_client(incoming->host,incoming->port);
-                       }CATCH(e){
-                               RETHROW0("Unable to connect to the node wich has requested for an area!: %s");
-                       }
-                       TRY{
-                               gras_msg_send(temp_sock,"can_rep_suc",&outgoing);
-                               INFO0("Environment informations sent!");
-                       }CATCH(e){
-                               RETHROW2("%s:Timeout sending environment informations to %s: %s",globals->host,gras_socket_peer_name(expeditor));
-                       }
-                       gras_socket_close(temp_sock);
-               }
-               else // we have a problem!
-                       INFO0("An error occurded!!!!!!!!!!!!!");
-
-       }
-       gras_socket_close(expeditor); // spare
-       TRY{
-         gras_msg_handle(10000.0); // wait a bit in case of someone want to ask me for something.
-       }CATCH(e){
-       INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
-         //INFO0("Closing node, all has been done!");
-       }
-   return 0;
+static int node_get_suc_handler(gras_msg_cb_ctx_t ctx, void *payload_data)
+{
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+  get_suc_t *incoming = (get_suc_t *) payload_data;
+  xbt_ex_t e;                   // the error variable used in TRY.. CATCH tokens.
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
+  gras_socket_t temp_sock = NULL;
+  INFO3("Received a get_successor message from %s for (%d;%d)",
+        gras_socket_peer_name(expeditor), incoming->xId, incoming->yId);
+  //INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
+  if (incoming->xId < globals->x1)      // test if the message must be forwarded to a neighbour.
+    forward_get_suc(*incoming, globals->west_host, globals->west_port);
+  else if (incoming->xId > globals->x2)
+    forward_get_suc(*incoming, globals->east_host, globals->east_port);
+  else if (incoming->yId < globals->y1)
+    forward_get_suc(*incoming, globals->south_host, globals->south_port);
+  else if (incoming->yId > globals->y2)
+    forward_get_suc(*incoming, globals->north_host, globals->north_port);
+  else {                        // if the message must not be forwarded, then the area is splitted in half and one half is assignated to the new node.
+    rep_suc_t outgoing;
+    int validate = 0;
+    INFO4
+        ("Spliting my area between me (%d;%d) and the inserting node (%d;%d)!",
+         globals->xId, globals->yId, incoming->xId, incoming->yId);
+    if ((globals->x2 - globals->x1) > (globals->y2 - globals->y1)) {    // the height of the area is smaller than its width.
+      if (incoming->xId < globals->xId) {       // the new node is west from the actual node.
+        outgoing.x1 = globals->x1;
+        outgoing.x2 = (incoming->xId + globals->xId) / 2;
+        outgoing.y1 = globals->y1;
+        outgoing.y2 = globals->y2;
+        strcpy(outgoing.north_host, globals->north_host);
+        outgoing.north_port = globals->north_port;
+        strcpy(outgoing.south_host, globals->south_host);
+        outgoing.south_port = globals->south_port;
+        strcpy(outgoing.east_host, globals->host);
+        outgoing.east_port = globals->port;
+        strcpy(outgoing.west_host, globals->west_host);
+        outgoing.west_port = globals->west_port;
+
+        globals->x1 = (incoming->xId + globals->xId) / 2;
+        strcpy(globals->west_host, incoming->host);
+        globals->west_port = incoming->port;
+        validate = 1;
+      } else if (incoming->xId > globals->xId) {        // the new node is east from the actual node.
+        outgoing.x1 = (incoming->xId + globals->xId) / 2;
+        outgoing.x2 = globals->x2;
+        outgoing.y1 = globals->y1;
+        outgoing.y2 = globals->y2;
+        strcpy(outgoing.north_host, globals->north_host);
+        outgoing.north_port = globals->north_port;
+        strcpy(outgoing.south_host, globals->south_host);
+        outgoing.south_port = globals->south_port;
+        strcpy(outgoing.east_host, globals->east_host);
+        outgoing.east_port = globals->east_port;
+        strcpy(outgoing.west_host, globals->host);
+        outgoing.west_port = globals->port;
+
+        globals->x2 = (incoming->xId + globals->xId) / 2;
+        strcpy(globals->east_host, incoming->host);
+        globals->east_port = incoming->port;
+        validate = 1;
+      }
+    } else {
+      if (incoming->yId < globals->yId) {       // the new node is south from the actual node.
+        outgoing.y1 = globals->y1;
+        outgoing.y2 = (incoming->yId + globals->yId) / 2;
+        outgoing.y1 = globals->y1;
+        outgoing.x2 = globals->x2;
+        strcpy(outgoing.east_host, globals->east_host);
+        outgoing.east_port = globals->east_port;
+        strcpy(outgoing.west_host, globals->west_host);
+        outgoing.west_port = globals->west_port;
+        strcpy(outgoing.north_host, globals->host);
+        outgoing.north_port = globals->port;
+        strcpy(outgoing.south_host, globals->south_host);
+        outgoing.south_port = globals->south_port;
+
+        globals->y1 = (incoming->yId + globals->yId) / 2;
+        strcpy(globals->south_host, incoming->host);
+        globals->south_port = incoming->port;
+        validate = 1;
+      } else if (incoming->yId > globals->yId) {        // the new node is north from the actual node.
+        outgoing.y1 = (incoming->yId + globals->yId) / 2;
+        outgoing.y2 = globals->y2;
+        outgoing.x1 = globals->x1;
+        outgoing.x2 = globals->x2;
+        strcpy(outgoing.east_host, globals->east_host);
+        outgoing.east_port = globals->east_port;
+        strcpy(outgoing.west_host, globals->west_host);
+        outgoing.west_port = globals->west_port;
+        strcpy(outgoing.north_host, globals->north_host);
+        outgoing.north_port = globals->north_port;
+        strcpy(outgoing.south_host, globals->host);
+        outgoing.south_port = globals->port;
+
+        globals->y2 = (incoming->yId + globals->yId) / 2;
+        strcpy(globals->north_host, incoming->host);
+        globals->north_port = incoming->port;
+        validate = 1;
+      }
+    }
+    if (validate == 1) {        // the area for the new node has been defined, then send theses informations to the new node.
+      INFO2("Sending environment informations to node %s:%d",
+            incoming->host, incoming->port);
+
+      TRY {
+        temp_sock = gras_socket_client(incoming->host, incoming->port);
+      }
+      CATCH(e) {
+        RETHROW0
+            ("Unable to connect to the node wich has requested for an area!: %s");
+      }
+      TRY {
+        gras_msg_send(temp_sock, "can_rep_suc", &outgoing);
+        INFO0("Environment informations sent!");
+      }
+      CATCH(e) {
+        RETHROW2("%s:Timeout sending environment informations to %s: %s",
+                 globals->host, gras_socket_peer_name(expeditor));
+      }
+      gras_socket_close(temp_sock);
+    } else                      // we have a problem!
+      INFO0("An error occurded!!!!!!!!!!!!!");
+
+  }
+  gras_socket_close(expeditor); // spare
+  TRY {
+    gras_msg_handle(10000.0);   // wait a bit in case of someone want to ask me for something.
+  }
+  CATCH(e) {
+    INFO4("My area is [%d;%d;%d;%d]", globals->x1, globals->x2,
+          globals->y1, globals->y2);
+    //INFO0("Closing node, all has been done!");
+  }
+  return 0;
 }
 
 
 
 
 
-int node(int argc,char **argv){
-       node_data_t *globals=NULL;
-       xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
-       gras_socket_t temp_sock=NULL;
-
-       rep_suc_t rep_suc_msg;
-
-       get_suc_t get_suc_msg; // building the "get_suc" message.
-       gras_socket_t temp_sock2=NULL;
-
-       INFO0("Starting");
-
-       /* 1. Init the GRAS infrastructure and declare my globals */
-       gras_init(&argc,argv);
-       gras_os_sleep((15-gras_os_getpid())*20); // wait a bit.
-       
-       globals=gras_userdata_new(node_data_t);
-
-       globals->xId=atoi(argv[1]); // x coordinate of the node.
-       globals->yId=atoi(argv[2]); // y coordinate of the node.
-       globals->port=atoi(argv[3]); // node port
-       globals->sock=gras_socket_server(globals->port); // node socket.
-       snprintf(globals->host,1024,gras_os_myname()); // node name.
-       globals->version=0; // node version (used for fun)
-
-       /* 2. Inserting the Node */
-       INFO2("Inserting node %s:%d",globals->host,globals->port);
-       if(argc==4){ // the node is a server, then he has the whole area.
-               globals->x1=0;
-               globals->x2=1000;
-               globals->y1=0;
-               globals->y2=1000;
-       }else{ // asking for an area.
-               INFO1("Contacting %s so as to request for an area",argv[4]);
-
-               TRY{
-                       temp_sock=gras_socket_client(argv[4],atoi(argv[5]));
-               }CATCH(e){
-                       RETHROW0("Unable to connect known host to request for an area!: %s");
-               }
-
-
-               get_suc_msg.xId=globals->xId;
-               get_suc_msg.yId=globals->yId;
-               strcpy(get_suc_msg.host,globals->host);
-               get_suc_msg.port=globals->port;
-               TRY{ // asking.
-                       gras_msg_send(temp_sock,"can_get_suc",&get_suc_msg);
-               }CATCH(e){
-                       gras_socket_close(temp_sock);
-                       RETHROW0("Unable to contact known host to get an area!: %s");
-               }
-               gras_socket_close(temp_sock);
-
-
-
-               TRY{ // waiting for a reply.
-                       INFO0("Waiting for reply!");
-                       gras_msg_wait(6000,"can_rep_suc",&temp_sock2,&rep_suc_msg);
-               }CATCH(e){
-                       RETHROW1("%s: Error waiting for an area:%s",globals->host);
-               }
-
-               // retreiving the data of the response.
-               globals->x1=rep_suc_msg.x1;
-               globals->x2=rep_suc_msg.x2;
-               globals->y1=rep_suc_msg.y1;
-               globals->y2=rep_suc_msg.y2;
-               strcpy(globals->north_host,rep_suc_msg.north_host);
-               globals->north_port=rep_suc_msg.north_port;
-               strcpy(globals->south_host,rep_suc_msg.south_host);
-               globals->south_port=rep_suc_msg.south_port;
-               strcpy(globals->east_host,rep_suc_msg.east_host);
-               globals->east_port=rep_suc_msg.east_port;
-               strcpy(globals->west_host,rep_suc_msg.west_host);
-               globals->west_port=rep_suc_msg.west_port;
-
-               gras_socket_close(temp_sock); // spare
-       }
-       INFO2("Node %s:%d inserted",globals->host,globals->port);
-
-       // associating messages to handlers.
-       register_messages();
-       gras_cb_register("can_get_suc",&node_get_suc_handler);
-       gras_cb_register("can_nuke",&node_nuke_handler);// can_test.c handler // include can_tests.c must be ON.
-       
-       TRY{
-         gras_msg_handle(10000.0); // waiting.. in case of someone has something to say.
-       }CATCH(e){
-               INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
-         //INFO0("Closing node, all has been done!");
-       }
-
-       gras_socket_close(globals->sock); // spare.
-       free(globals); // spare.
-       //gras_exit();
-       return(0);
+int node(int argc, char **argv)
+{
+  node_data_t *globals = NULL;
+  xbt_ex_t e;                   // the error variable used in TRY.. CATCH tokens.
+  gras_socket_t temp_sock = NULL;
+
+  rep_suc_t rep_suc_msg;
+
+  get_suc_t get_suc_msg;        // building the "get_suc" message.
+  gras_socket_t temp_sock2 = NULL;
+
+  INFO0("Starting");
+
+  /* 1. Init the GRAS infrastructure and declare my globals */
+  gras_init(&argc, argv);
+  gras_os_sleep((15 - gras_os_getpid()) * 20);  // wait a bit.
+
+  globals = gras_userdata_new(node_data_t);
+
+  globals->xId = atoi(argv[1]); // x coordinate of the node.
+  globals->yId = atoi(argv[2]); // y coordinate of the node.
+  globals->port = atoi(argv[3]);        // node port
+  globals->sock = gras_socket_server(globals->port);    // node socket.
+  snprintf(globals->host, 1024, gras_os_myname());      // node name.
+  globals->version = 0;         // node version (used for fun)
+
+  /* 2. Inserting the Node */
+  INFO2("Inserting node %s:%d", globals->host, globals->port);
+  if (argc == 4) {              // the node is a server, then he has the whole area.
+    globals->x1 = 0;
+    globals->x2 = 1000;
+    globals->y1 = 0;
+    globals->y2 = 1000;
+  } else {                      // asking for an area.
+    INFO1("Contacting %s so as to request for an area", argv[4]);
+
+    TRY {
+      temp_sock = gras_socket_client(argv[4], atoi(argv[5]));
+    }
+    CATCH(e) {
+      RETHROW0("Unable to connect known host to request for an area!: %s");
+    }
+
+
+    get_suc_msg.xId = globals->xId;
+    get_suc_msg.yId = globals->yId;
+    strcpy(get_suc_msg.host, globals->host);
+    get_suc_msg.port = globals->port;
+    TRY {                       // asking.
+      gras_msg_send(temp_sock, "can_get_suc", &get_suc_msg);
+    }
+    CATCH(e) {
+      gras_socket_close(temp_sock);
+      RETHROW0("Unable to contact known host to get an area!: %s");
+    }
+    gras_socket_close(temp_sock);
+
+
+
+    TRY {                       // waiting for a reply.
+      INFO0("Waiting for reply!");
+      gras_msg_wait(6000, "can_rep_suc", &temp_sock2, &rep_suc_msg);
+    }
+    CATCH(e) {
+      RETHROW1("%s: Error waiting for an area:%s", globals->host);
+    }
+
+    // retreiving the data of the response.
+    globals->x1 = rep_suc_msg.x1;
+    globals->x2 = rep_suc_msg.x2;
+    globals->y1 = rep_suc_msg.y1;
+    globals->y2 = rep_suc_msg.y2;
+    strcpy(globals->north_host, rep_suc_msg.north_host);
+    globals->north_port = rep_suc_msg.north_port;
+    strcpy(globals->south_host, rep_suc_msg.south_host);
+    globals->south_port = rep_suc_msg.south_port;
+    strcpy(globals->east_host, rep_suc_msg.east_host);
+    globals->east_port = rep_suc_msg.east_port;
+    strcpy(globals->west_host, rep_suc_msg.west_host);
+    globals->west_port = rep_suc_msg.west_port;
+
+    gras_socket_close(temp_sock);       // spare
+  }
+  INFO2("Node %s:%d inserted", globals->host, globals->port);
+
+  // associating messages to handlers.
+  register_messages();
+  gras_cb_register("can_get_suc", &node_get_suc_handler);
+  gras_cb_register("can_nuke", &node_nuke_handler);     // can_test.c handler // include can_tests.c must be ON.
+
+  TRY {
+    gras_msg_handle(10000.0);   // waiting.. in case of someone has something to say.
+  }
+  CATCH(e) {
+    INFO4("My area is [%d;%d;%d;%d]", globals->x1, globals->x2,
+          globals->y1, globals->y2);
+    //INFO0("Closing node, all has been done!");
+  }
+
+  gras_socket_close(globals->sock);     // spare.
+  free(globals);                // spare.
+  //gras_exit();
+  return (0);
 }
 
 // END
index 80eca19..8742379 100644 (file)
@@ -1,5 +1,5 @@
 /* Broken Peer-To-Peer CAN simulator                                        */
+
 /* Copyright (c) 2006, 2007, 2010. The SimGrid Team.
  * All rights reserved.                                                     */
 
 
 #include <time.h>
 //#include "gras.h"
-#include "types.h" // header containing the typedef struct of a node
+#include "types.h"              // header containing the typedef struct of a node
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(can,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(can, "Messages specific to this example");
 
 // struct of a "nuke" message, when a node send a nuke to (xId;yId).
-GRAS_DEFINE_TYPE(s_nuke,
-       struct s_nuke{
-         int xId;
-         int yId;
-         char host[1024]; // original expeditor..
-         int port; // ..and his port.
-
-         int version; // fun.
-       };
-);
+GRAS_DEFINE_TYPE(s_nuke, struct s_nuke {
+                 int xId; int yId; char host[1024];     // original expeditor..
+                 int port;      // ..and his port.
+                 int version;   // fun.
+                 };);
+
 typedef struct s_nuke nuke_t;
 
 // the function that start the **** War of the Nodes ****
-int start_war(int argc,char **argv);
-int start_war(int argc,char **argv){
-       gras_socket_t temp_sock=NULL;
-       nuke_t nuke_msg;
-  xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
+int start_war(int argc, char **argv);
+int start_war(int argc, char **argv)
+{
+  gras_socket_t temp_sock = NULL;
+  nuke_t nuke_msg;
+  xbt_ex_t e;                   // the error variable used in TRY.. CATCH tokens.
   //return 0; // in order to inhibit the War of the Nodes 
-  gras_init(&argc,argv);
-  gras_os_sleep((15-gras_os_getpid())*20+200); // wait a bit.
+  gras_init(&argc, argv);
+  gras_os_sleep((15 - gras_os_getpid()) * 20 + 200);    // wait a bit.
+
 
-       
-  TRY{ // contacting the bad guy that will launch the War.
-    temp_sock=gras_socket_client(gras_os_myname(),atoi(argv[1]));
-  }CATCH(e){
+  TRY {                         // contacting the bad guy that will launch the War.
+    temp_sock = gras_socket_client(gras_os_myname(), atoi(argv[1]));
+  } CATCH(e) {
     RETHROW0("Unable to connect known host so as to declare WAR!: %s");
   }
-  
 
-  nuke_msg.xId=-1;
-  nuke_msg.yId=-1;
-  nuke_msg.version=atoi(argv[2]); 
-  strcpy(nuke_msg.host,gras_os_myname());
-  nuke_msg.port=atoi(argv[1]);
 
-  TRY{
-    gras_msg_send(temp_sock,"can_nuke",&nuke_msg);
-  }CATCH(e){
+  nuke_msg.xId = -1;
+  nuke_msg.yId = -1;
+  nuke_msg.version = atoi(argv[2]);
+  strcpy(nuke_msg.host, gras_os_myname());
+  nuke_msg.port = atoi(argv[1]);
+
+  TRY {
+    gras_msg_send(temp_sock, "can_nuke", &nuke_msg);
+  } CATCH(e) {
     gras_socket_close(temp_sock);
-    RETHROW0("Unable to contact known host so as to declare WAR!!!!!!!!!!!!!!!!!!!!!: %s");
+    RETHROW0
+        ("Unable to contact known host so as to declare WAR!!!!!!!!!!!!!!!!!!!!!: %s");
   }
   gras_socket_close(temp_sock); // spare.
-  gras_exit(); // spare.
+  gras_exit();                  // spare.
   return 0;
 }
 
 // the function thaht send the nuke "msg" on (xId;yId), if it's not on me :p.
-static int send_nuke(nuke_t *msg, int xId, int yId){
-  node_data_t *globals=(node_data_t*)gras_userdata_get();
-  gras_socket_t temp_sock=NULL;
-   xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
-
-  if(xId>=globals->x1 && xId<=globals->x2 && yId>=globals->y1 && yId<=globals->y2){
+static int send_nuke(nuke_t * msg, int xId, int yId)
+{
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
+  gras_socket_t temp_sock = NULL;
+  xbt_ex_t e;                   // the error variable used in TRY.. CATCH tokens.
+
+  if (xId >= globals->x1 && xId <= globals->x2 && yId >= globals->y1
+      && yId <= globals->y2) {
     INFO0("Nuclear launch missed");
     return 0;
-  }
-  else{
+  } else {
     char host[1024];
-    int port=0;
-    
-    if(xId<globals->x1){
-      strcpy(host,globals->west_host);
-      port=globals->west_port;}
-    else if(xId>globals->x2){
-      strcpy(host,globals->east_host);
-      port=globals->east_port;}
-    else if(yId<globals->y1){
-      strcpy(host,globals->south_host);
-      port=globals->south_port;}
-    else if(yId>globals->y2){
-      strcpy(host,globals->north_host);
-      port=globals->north_port;}
-
-    msg->xId=xId;
-    msg->yId=yId;
-
-
-
-    TRY{ // sending the nuke.
-      temp_sock=gras_socket_client(host,port);
-    }CATCH(e){
+    int port = 0;
+
+    if (xId < globals->x1) {
+      strcpy(host, globals->west_host);
+      port = globals->west_port;
+    } else if (xId > globals->x2) {
+      strcpy(host, globals->east_host);
+      port = globals->east_port;
+    } else if (yId < globals->y1) {
+      strcpy(host, globals->south_host);
+      port = globals->south_port;
+    } else if (yId > globals->y2) {
+      strcpy(host, globals->north_host);
+      port = globals->north_port;
+    }
+
+    msg->xId = xId;
+    msg->yId = yId;
+
+
+
+    TRY {                       // sending the nuke.
+      temp_sock = gras_socket_client(host, port);
+    }
+    CATCH(e) {
       RETHROW0("Unable to connect the nuke!: %s");
     }
     //INFO4("%s ON %s %d %d <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",globals->host,host,xId,yId);
-    TRY{
-      gras_msg_send(temp_sock,"can_nuke",msg);
-    }CATCH(e){
+    TRY {
+      gras_msg_send(temp_sock, "can_nuke", msg);
+    }
+    CATCH(e) {
       RETHROW0("Unable to send the nuke!: %s");
     }
     gras_socket_close(temp_sock);
-    INFO4("Nuke launched by %s to %s for (%d;%d)",globals->host,host,msg->xId,msg->yId);
+    INFO4("Nuke launched by %s to %s for (%d;%d)", globals->host, host,
+          msg->xId, msg->yId);
     return 1;
   }
 }
 
 
-static int node_nuke_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
-  gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);
-  nuke_t *incoming=(nuke_t*)payload_data;
-  node_data_t *globals=(node_data_t*)gras_userdata_get();
-  
-       int x;
-       int y;
-       nuke_t nuke_msg; // writing my name one the nuke.
-        gras_socket_t temp_sock=NULL;
-        xbt_ex_t e; // the error variable used in TRY.. CATCH tokens.
-       
-
-  if(incoming->xId==-1){ // i must start the War
-    INFO2("%s:%d declare the WAR!!!!!!!!!!!!!!!!!",globals->host,globals->port);
-    srand((unsigned int)time((time_t *)NULL));
-
-    do{
-      x=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      y=(int)(1000.0*rand()/(RAND_MAX+1.0));
+static int node_nuke_handler(gras_msg_cb_ctx_t ctx, void *payload_data)
+{
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+  nuke_t *incoming = (nuke_t *) payload_data;
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
+
+  int x;
+  int y;
+  nuke_t nuke_msg;              // writing my name one the nuke.
+  gras_socket_t temp_sock = NULL;
+  xbt_ex_t e;                   // the error variable used in TRY.. CATCH tokens.
+
+
+  if (incoming->xId == -1) {    // i must start the War
+    INFO2("%s:%d declare the WAR!!!!!!!!!!!!!!!!!", globals->host,
+          globals->port);
+    srand((unsigned int) time((time_t *) NULL));
+
+    do {
+      x = (int) (1000.0 * rand() / (RAND_MAX + 1.0));
+      y = (int) (1000.0 * rand() / (RAND_MAX + 1.0));
     }
-    while(send_nuke(incoming,x,y)==0);
-    
-  }
-  else if(incoming->xId>=globals->x1 && incoming->xId<=globals->x2 && incoming->yId>=globals->y1 && incoming->yId<=globals->y2){ // the nuke crash on my area..
-    if(globals->version==incoming->version) // ..but i'm dead.
+    while (send_nuke(incoming, x, y) == 0);
+
+  } else if (incoming->xId >= globals->x1 && incoming->xId <= globals->x2 && incoming->yId >= globals->y1 && incoming->yId <= globals->y2) {    // the nuke crash on my area..
+    if (globals->version == incoming->version)  // ..but i'm dead.
       INFO0("I'm already dead :p");
-    else if((incoming->xId-globals->xId)/60==0 && (incoming->yId-globals->yId)/60==0){ // ..and it's on me, so i die :X.
-      globals->version=incoming->version;
-      INFO2("Euuuaarrrgghhhh...   %s killed %s !!!!!!!!!!!!!!!!!",incoming->host,globals->host);
-    }
-    else{ // and it miss me, i angry and i send my own nuke!
-      INFO1("%s was missed, and counteract!",globals->host);
+    else if ((incoming->xId - globals->xId) / 60 == 0 && (incoming->yId - globals->yId) / 60 == 0) {    // ..and it's on me, so i die :X.
+      globals->version = incoming->version;
+      INFO2("Euuuaarrrgghhhh...   %s killed %s !!!!!!!!!!!!!!!!!",
+            incoming->host, globals->host);
+    } else {                    // and it miss me, i angry and i send my own nuke!
+      INFO1("%s was missed, and counteract!", globals->host);
       /*int x1=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int y1=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int x2=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int y2=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int x3=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int y3=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int x4=(int)(1000.0*rand()/(RAND_MAX+1.0));
-      int y4=(int)(1000.0*rand()/(RAND_MAX+1.0));*/
-      
-
-         nuke_msg.version=incoming->version;
-      strcpy(nuke_msg.host,globals->host);
-      nuke_msg.port=globals->port;
-      
-         
-      do{
-       x=(int)(1000.0*rand()/(RAND_MAX+1.0));
-       y=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int y1=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int x2=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int y2=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int x3=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int y3=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int x4=(int)(1000.0*rand()/(RAND_MAX+1.0));
+         int y4=(int)(1000.0*rand()/(RAND_MAX+1.0)); */
+
+
+      nuke_msg.version = incoming->version;
+      strcpy(nuke_msg.host, globals->host);
+      nuke_msg.port = globals->port;
+
+
+      do {
+        x = (int) (1000.0 * rand() / (RAND_MAX + 1.0));
+        y = (int) (1000.0 * rand() / (RAND_MAX + 1.0));
       }
-      while(send_nuke(&nuke_msg,x,y)==0); // and sending if it's not on me.
+      while (send_nuke(&nuke_msg, x, y) == 0);  // and sending if it's not on me.
     }
-  }
-  else{ // the nuke isn't for me, so i forward her.
+  } else {                      // the nuke isn't for me, so i forward her.
     char host[1024];
-    int port=0;
-    
-    if(incoming->xId<globals->x1){
-      strcpy(host,globals->west_host);
-      port=globals->west_port;}
-    else if(incoming->xId>globals->x2){
-      strcpy(host,globals->east_host);
-      port=globals->east_port;}
-    else if(incoming->yId<globals->y1){
-      strcpy(host,globals->south_host);
-      port=globals->south_port;}
-    else if(incoming->yId>globals->y2){
-      strcpy(host,globals->north_host);
-      port=globals->north_port;}
-    
-
-
-       TRY{
-      temp_sock=gras_socket_client(host,port);
-    }CATCH(e){
+    int port = 0;
+
+    if (incoming->xId < globals->x1) {
+      strcpy(host, globals->west_host);
+      port = globals->west_port;
+    } else if (incoming->xId > globals->x2) {
+      strcpy(host, globals->east_host);
+      port = globals->east_port;
+    } else if (incoming->yId < globals->y1) {
+      strcpy(host, globals->south_host);
+      port = globals->south_port;
+    } else if (incoming->yId > globals->y2) {
+      strcpy(host, globals->north_host);
+      port = globals->north_port;
+    }
+
+
+
+    TRY {
+      temp_sock = gras_socket_client(host, port);
+    }
+    CATCH(e) {
       RETHROW0("Unable to connect the nuke!: %s");
     }
-    TRY{
-      gras_msg_send(temp_sock,"can_nuke",incoming);
-    }CATCH(e){
+    TRY {
+      gras_msg_send(temp_sock, "can_nuke", incoming);
+    }
+    CATCH(e) {
       RETHROW0("Unable to send the nuke!: %s");
     }
-    INFO4("Nuke re-aimed by %s to %s for (%d;%d)",globals->host,host,incoming->xId,incoming->yId);
+    INFO4("Nuke re-aimed by %s to %s for (%d;%d)", globals->host, host,
+          incoming->xId, incoming->yId);
     gras_socket_close(temp_sock);
   }
   gras_socket_close(expeditor); // spare.
 
-  TRY{
-    gras_msg_handle(10000.0); // wait a bit, in case of..
-  }CATCH(e){
-    INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
+  TRY {
+    gras_msg_handle(10000.0);   // wait a bit, in case of..
+  }
+  CATCH(e) {
+    INFO4("My area is [%d;%d;%d;%d]", globals->x1, globals->x2,
+          globals->y1, globals->y2);
     //INFO0("Closing node, all has been done!");
-    }
-   return 0;
+  }
+  return 0;
 }
 
 // END
index 4e2f0d1..ddeb68f 100644 (file)
@@ -7,26 +7,26 @@
 #include "gras.h"
 
 /* Global private data */
-typedef struct{
-       gras_socket_t sock; /* server socket on which I'm listening */
-       int xId;
-       int yId;
-       char host[1024]; /* my host name */
-       int port; /* port on which I'm listening FIXME */
+typedef struct {
+  gras_socket_t sock;           /* server socket on which I'm listening */
+  int xId;
+  int yId;
+  char host[1024];              /* my host name */
+  int port;                     /* port on which I'm listening FIXME */
 
-       int x1; // Xmin
-       int x2; // Xmax
-       int y1; // Ymin
-       int y2; // Ymax
+  int x1;                       // Xmin
+  int x2;                       // Xmax
+  int y1;                       // Ymin
+  int y2;                       // Ymax
 
-       char north_host[1024];
-       int north_port;
-       char south_host[1024];
-       int south_port;
-       char east_host[1024];
-       int east_port;
-       char west_host[1024];
-       int west_port;
+  char north_host[1024];
+  int north_port;
+  char south_host[1024];
+  int south_port;
+  char east_host[1024];
+  int east_port;
+  char west_host[1024];
+  int west_port;
 
-        int version;
-}node_data_t;
+  int version;
+} node_data_t;
index b6b9de1..debf98f 100644 (file)
@@ -11,9 +11,9 @@
 static int closest_preceding_node(int id);
 static void check_predecessor(void);
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(chord,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(chord, "Messages specific to this example");
 
-typedef enum msg_typus{
+typedef enum msg_typus {
   PING,
   PONG,
   GET_PRE,
@@ -21,7 +21,7 @@ typedef enum msg_typus{
   GET_SUC,
   REP_SUC,
   STD,
-}msg_typus;
+} msg_typus;
 
 /*GRAS_DEFINE_TYPE(s_pbio,
   struct s_pbio{
@@ -33,76 +33,69 @@ typedef enum msg_typus{
 typedef struct s_pbio pbio_t;*/
 
 /*GRAS_DEFINE_TYPE(s_ping,*/
-  struct s_ping{
-    int id;
-  };
+struct s_ping {
+  int id;
+};
 /*);*/
 typedef struct s_ping ping_t;
 
 /*GRAS_DEFINE_TYPE(s_pong,*/
-  struct s_pong{
-    int id;
-    int failed;
-  };
+struct s_pong {
+  int id;
+  int failed;
+};
 /*);*/
 typedef struct s_pong pong_t;
 
-GRAS_DEFINE_TYPE(s_notify,
-  struct s_notify{
-    int id;
-    char host[1024];
-    int port;
-  };
-);
+GRAS_DEFINE_TYPE(s_notify, struct s_notify {
+                 int id; char host[1024]; int port;};);
+
 typedef struct s_notify notify_t;
 
-GRAS_DEFINE_TYPE(s_get_suc,
-  struct s_get_suc{
-    int id;
-  };
-);
+GRAS_DEFINE_TYPE(s_get_suc, struct s_get_suc {
+                 int id;};);
+
 typedef struct s_get_suc get_suc_t;
 
-GRAS_DEFINE_TYPE(s_rep_suc,
-  struct s_rep_suc{
-    int id;
-    char host[1024];
-    int port;
-  };
-);
+GRAS_DEFINE_TYPE(s_rep_suc, struct s_rep_suc {
+                 int id; char host[1024]; int port;};);
+
 typedef struct s_rep_suc rep_suc_t;
 
-typedef struct finger_elem{
+typedef struct finger_elem {
   int id;
   char host[1024];
   int port;
-}finger_elem;
+} finger_elem;
 
 
 
-static void register_messages(){
+static void register_messages()
+{
 /*  gras_msgtype_declare("chord",gras_datadesc_by_symbol(s_pbio));*/
-  gras_msgtype_declare("chord_get_suc",gras_datadesc_by_symbol(s_get_suc));
-  gras_msgtype_declare("chord_rep_suc",gras_datadesc_by_symbol(s_rep_suc));
-  gras_msgtype_declare("chord_notify",gras_datadesc_by_symbol(s_notify));
+  gras_msgtype_declare("chord_get_suc",
+                       gras_datadesc_by_symbol(s_get_suc));
+  gras_msgtype_declare("chord_rep_suc",
+                       gras_datadesc_by_symbol(s_rep_suc));
+  gras_msgtype_declare("chord_notify", gras_datadesc_by_symbol(s_notify));
 }
 
 /* Global private data */
-typedef struct{
-  gras_socket_t sock; /* server socket on which I'm listening */
-  int id; /* my id number */
-  char host[1024]; /* my host name */
-  int port; /* port on which I'm listening FIXME */
-  int fingers; /* how many fingers */
-  finger_elem *finger; /* finger table */
-  int next_to_fix; /* next in the finger list to be checked */
-  int pre_id; /* predecessor id */
-  char pre_host[1024]; /* predecessor host */
-  int pre_port; /* predecessor port */
-}node_data_t;
-
-
-int node(int argc,char **argv);
+typedef struct {
+  gras_socket_t sock;           /* server socket on which I'm listening */
+  int id;                       /* my id number */
+  char host[1024];              /* my host name */
+  int port;                     /* port on which I'm listening FIXME */
+  int fingers;                  /* how many fingers */
+  finger_elem *finger;          /* finger table */
+  int next_to_fix;              /* next in the finger list to be checked */
+  int pre_id;                   /* predecessor id */
+  char pre_host[1024];          /* predecessor host */
+  int pre_port;                 /* predecessor port */
+} node_data_t;
+
+
+int node(int argc, char **argv);
 
 /*static int node_cb_chord_handler(gras_socket_t expeditor,void *payload_data){
   xbt_ex_t e;
@@ -116,151 +109,166 @@ int node(int argc,char **argv);
 
 }*/
 
-static int node_cb_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
-  gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);   
+static int node_cb_get_suc_handler(gras_msg_cb_ctx_t ctx,
+                                   void *payload_data)
+{
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
   xbt_ex_t e;
-  get_suc_t incoming=*(get_suc_t*)payload_data;
+  get_suc_t incoming = *(get_suc_t *) payload_data;
   rep_suc_t outgoing;
-  node_data_t *globals=(node_data_t*)gras_userdata_get();
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
   INFO2("Received a get_successor message from %s for %d",
-        gras_socket_peer_name(expeditor),incoming.id);
-  if((globals->id==globals->finger[0].id)||
-     (incoming.id>globals->id&&incoming.id<=globals->finger[0].id)){
-    outgoing.id=globals->finger[0].id;
-    snprintf(outgoing.host,1024,globals->finger[0].host);
-    outgoing.port=globals->finger[0].port;
+        gras_socket_peer_name(expeditor), incoming.id);
+  if ((globals->id == globals->finger[0].id) ||
+      (incoming.id > globals->id
+       && incoming.id <= globals->finger[0].id)) {
+    outgoing.id = globals->finger[0].id;
+    snprintf(outgoing.host, 1024, globals->finger[0].host);
+    outgoing.port = globals->finger[0].port;
     INFO0("My successor is his successor!");
-  }else{
+  } else {
     gras_socket_t temp_sock;
-    int contact=closest_preceding_node(incoming.id);
-    if(contact==-1){
-      outgoing.id=globals->finger[0].id;
-      snprintf(outgoing.host,1024,globals->finger[0].host);
-      outgoing.port=globals->finger[0].port;
+    int contact = closest_preceding_node(incoming.id);
+    if (contact == -1) {
+      outgoing.id = globals->finger[0].id;
+      snprintf(outgoing.host, 1024, globals->finger[0].host);
+      outgoing.port = globals->finger[0].port;
       INFO0("My successor is his successor!");
-    }else{
-      get_suc_t asking;asking.id=incoming.id;
-      TRY{
-        temp_sock=gras_socket_client(globals->finger[contact].host,
-                                     globals->finger[contact].port);
-      }CATCH(e){
+    } else {
+      get_suc_t asking;
+      asking.id = incoming.id;
+      TRY {
+        temp_sock = gras_socket_client(globals->finger[contact].host,
+                                       globals->finger[contact].port);
+      }
+      CATCH(e) {
         RETHROW0("Unable to connect!: %s");
       }
-      TRY{
-        gras_msg_send(temp_sock,"chord_get_suc",&asking);
-      }CATCH(e){
+      TRY {
+        gras_msg_send(temp_sock, "chord_get_suc", &asking);
+      }
+      CATCH(e) {
         RETHROW0("Unable to ask!: %s");
       }
-      gras_msg_wait(10.,"chord_rep_suc",&temp_sock, &outgoing);
+      gras_msg_wait(10., "chord_rep_suc", &temp_sock, &outgoing);
     }
   }
-  
-  TRY{
-    gras_msg_send(expeditor,"chord_rep_suc",&outgoing);
+
+  TRY {
+    gras_msg_send(expeditor, "chord_rep_suc", &outgoing);
     INFO0("Successor information sent!");
-  }CATCH(e){
+  }
+  CATCH(e) {
     RETHROW2("%s:Timeout sending successor information to %s: %s",
-             globals->host,gras_socket_peer_name(expeditor));
+             globals->host, gras_socket_peer_name(expeditor));
   }
   gras_socket_close(expeditor);
   return 0;
 }
 
-static int closest_preceding_node(int id){
-  node_data_t *globals=(node_data_t*)gras_userdata_get();
+static int closest_preceding_node(int id)
+{
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
   int i;
-  for(i=globals->fingers-1;i>=0;i--){
-    if(globals->finger[i].id>globals->id&&globals->finger[i].id<id){
-      return(i);
+  for (i = globals->fingers - 1; i >= 0; i--) {
+    if (globals->finger[i].id > globals->id && globals->finger[i].id < id) {
+      return (i);
     }
   }
-  
+
   return i;
 }
 
-static int node_cb_notify_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
-  gras_socket_t expeditor=gras_msg_cb_ctx_from(ctx);   
-  /*xbt_ex_t e;*/
-  notify_t incoming=*(notify_t*)payload_data;
-  node_data_t *globals=(node_data_t*)gras_userdata_get();
+static int node_cb_notify_handler(gras_msg_cb_ctx_t ctx,
+                                  void *payload_data)
+{
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+  /*xbt_ex_t e; */
+  notify_t incoming = *(notify_t *) payload_data;
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
   INFO2("Received a notifying message from %s as %d",
-        gras_socket_peer_name(expeditor),incoming.id);
-  if(globals->pre_id==-1||
-     (incoming.id>globals->pre_id&&incoming.id<globals->id)){
-    globals->pre_id=incoming.id;
-    snprintf(globals->pre_host,1024,incoming.host);
-    globals->pre_port=incoming.port;
+        gras_socket_peer_name(expeditor), incoming.id);
+  if (globals->pre_id == -1 ||
+      (incoming.id > globals->pre_id && incoming.id < globals->id)) {
+    globals->pre_id = incoming.id;
+    snprintf(globals->pre_host, 1024, incoming.host);
+    globals->pre_port = incoming.port;
     INFO0("Set as my new predecessor!");
   }
   return 0;
 }
 
-static void fix_fingers(){
-       get_suc_t get_suc_msg;
+static void fix_fingers()
+{
+  get_suc_t get_suc_msg;
   xbt_ex_t e;
-  gras_socket_t temp_sock=NULL;
-  gras_socket_t temp_sock2=NULL;
+  gras_socket_t temp_sock = NULL;
+  gras_socket_t temp_sock2 = NULL;
   rep_suc_t rep_suc_msg;
-  node_data_t *globals=(node_data_t*)gras_userdata_get();
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
 
-  TRY{
-    temp_sock=gras_socket_client(globals->host,globals->port);
-  }CATCH(e){
+  TRY {
+    temp_sock = gras_socket_client(globals->host, globals->port);
+  } CATCH(e) {
     RETHROW0("Unable to contact known host: %s");
   }
 
-  get_suc_msg.id=globals->id;
-  TRY{
-    gras_msg_send(temp_sock,"chord_get_suc",&get_suc_msg);
-  }CATCH(e){
+  get_suc_msg.id = globals->id;
+  TRY {
+    gras_msg_send(temp_sock, "chord_get_suc", &get_suc_msg);
+  } CATCH(e) {
     gras_socket_close(temp_sock);
     RETHROW0("Unable to contact known host to get successor!: %s");
   }
 
-  TRY{
+  TRY {
     INFO0("Waiting for reply!");
-    gras_msg_wait(6000,"chord_rep_suc",&temp_sock2, &rep_suc_msg);
-  }CATCH(e){
-    RETHROW1("%s: Error waiting for successor:%s",globals->host);
+    gras_msg_wait(6000, "chord_rep_suc", &temp_sock2, &rep_suc_msg);
+  } CATCH(e) {
+    RETHROW1("%s: Error waiting for successor:%s", globals->host);
   }
-  globals->finger[0].id=rep_suc_msg.id;
-  snprintf(globals->finger[0].host,1024,rep_suc_msg.host);
-  globals->finger[0].port=rep_suc_msg.port;
-  INFO1("→ Finger %d fixed!",globals->next_to_fix);
+  globals->finger[0].id = rep_suc_msg.id;
+  snprintf(globals->finger[0].host, 1024, rep_suc_msg.host);
+  globals->finger[0].port = rep_suc_msg.port;
+  INFO1("→ Finger %d fixed!", globals->next_to_fix);
   gras_socket_close(temp_sock);
-  
-  globals->next_to_fix=(++globals->next_to_fix==globals->fingers)?
-                       0:globals->next_to_fix;
+
+  globals->next_to_fix = (++globals->next_to_fix == globals->fingers) ?
+      0 : globals->next_to_fix;
 }
 
-static void check_predecessor(){
-  node_data_t *globals = (node_data_t*)gras_userdata_get();
+static void check_predecessor()
+{
+  node_data_t *globals = (node_data_t *) gras_userdata_get();
   gras_socket_t temp_sock;
-   ping_t ping;
+  ping_t ping;
   pong_t pong;
   xbt_ex_t e;
-  if (globals->pre_id == -1){
+  if (globals->pre_id == -1) {
     return;
   }
-  TRY{
-    temp_sock = gras_socket_client( globals->pre_host, globals->pre_port );
-  }CATCH(e){
+  TRY {
+    temp_sock = gras_socket_client(globals->pre_host, globals->pre_port);
+  }
+  CATCH(e) {
     globals->pre_id = -1;
     globals->pre_host[0] = 0;
     globals->pre_port = 0;
   }
 
   ping.id = 0;
-  TRY{
-    gras_msg_send( temp_sock, "chord_ping",&ping);
-  }CATCH(e){
+  TRY {
+    gras_msg_send(temp_sock, "chord_ping", &ping);
+  }
+  CATCH(e) {
     globals->pre_id = -1;
     globals->pre_host[0] = 0;
     globals->pre_port = 0;
   }
-  TRY{
-    gras_msg_wait( 60, "chord_pong", &temp_sock, &pong);
-  }CATCH(e){
+  TRY {
+    gras_msg_wait(60, "chord_pong", &temp_sock, &pong);
+  }
+  CATCH(e) {
     globals->pre_id = -1;
     globals->pre_host[0] = 0;
     globals->pre_port = 0;
@@ -268,120 +276,127 @@ static void check_predecessor(){
   gras_socket_close(temp_sock);
 }
 
-int node(int argc,char **argv){
-  node_data_t *globals=NULL;
-  gras_socket_t temp_sock=NULL;
-  gras_socket_t temp_sock2=NULL;
+int node(int argc, char **argv)
+{
+  node_data_t *globals = NULL;
+  gras_socket_t temp_sock = NULL;
+  gras_socket_t temp_sock2 = NULL;
   get_suc_t get_suc_msg;
   rep_suc_t rep_suc_msg;
 
   xbt_ex_t e;
 
-  int create=0;
-  int other_port=-1;
+  int create = 0;
+  int other_port = -1;
   char *other_host;
   notify_t notify_msg;
   int l;
 
   /* 1. Init the GRAS infrastructure and declare my globals */
-  gras_init(&argc,argv);
-   
-  gras_os_sleep((15-gras_os_getpid())*20);
-   
-  globals=gras_userdata_new(node_data_t);
-
-  globals->id=atoi(argv[1]);
-  globals->port=atoi(argv[2]);
-  globals->fingers=0;
-  globals->finger=NULL;
-  globals->pre_id=-1;
-  globals->pre_host[0]=0;
-  globals->pre_port=-1;
-  
-  snprintf(globals->host,1024,gras_os_myname());
-
-  if(argc==3){
-    create=1;
-  }else{
-    asprintf(&other_host,"%s",argv[3]);
-    other_port=atoi(argv[4]);
+  gras_init(&argc, argv);
+
+  gras_os_sleep((15 - gras_os_getpid()) * 20);
+
+  globals = gras_userdata_new(node_data_t);
+
+  globals->id = atoi(argv[1]);
+  globals->port = atoi(argv[2]);
+  globals->fingers = 0;
+  globals->finger = NULL;
+  globals->pre_id = -1;
+  globals->pre_host[0] = 0;
+  globals->pre_port = -1;
+
+  snprintf(globals->host, 1024, gras_os_myname());
+
+  if (argc == 3) {
+    create = 1;
+  } else {
+    asprintf(&other_host, "%s", argv[3]);
+    other_port = atoi(argv[4]);
   }
-  
-  globals->sock=gras_socket_server(globals->port);
+
+  globals->sock = gras_socket_server(globals->port);
   gras_os_sleep(1.0);
 
   register_messages();
 
-  globals->finger=(finger_elem*)calloc(1,sizeof(finger_elem));
-  INFO2("Launching node %s:%d",globals->host,globals->port);
-  if(create){
+  globals->finger = (finger_elem *) calloc(1, sizeof(finger_elem));
+  INFO2("Launching node %s:%d", globals->host, globals->port);
+  if (create) {
     INFO0("→Creating ring");
-    globals->finger[0].id=globals->id;
-    snprintf(globals->finger[0].host,1024,globals->host);
-    globals->finger[0].port=globals->port;
-  }else{
-    INFO2("→Known node %s:%d",other_host,other_port);
+    globals->finger[0].id = globals->id;
+    snprintf(globals->finger[0].host, 1024, globals->host);
+    globals->finger[0].port = globals->port;
+  } else {
+    INFO2("→Known node %s:%d", other_host, other_port);
     INFO0("→Contacting to determine successor");
-    TRY{
-      temp_sock=gras_socket_client(other_host,other_port);
-    }CATCH(e){
+    TRY {
+      temp_sock = gras_socket_client(other_host, other_port);
+    }
+    CATCH(e) {
       RETHROW0("Unable to contact known host: %s");
     }
 
-       get_suc_msg.id=globals->id;
-    TRY{
-      gras_msg_send(temp_sock,"chord_get_suc", &get_suc_msg);
-    }CATCH(e){
+    get_suc_msg.id = globals->id;
+    TRY {
+      gras_msg_send(temp_sock, "chord_get_suc", &get_suc_msg);
+    }
+    CATCH(e) {
       gras_socket_close(temp_sock);
       RETHROW0("Unable to contact known host to get successor!: %s");
     }
 
-    TRY{
+    TRY {
       INFO0("Waiting for reply!");
-      gras_msg_wait(10.,"chord_rep_suc",&temp_sock2, &rep_suc_msg);
-    }CATCH(e){
-      RETHROW1("%s: Error waiting for successor:%s",globals->host);
+      gras_msg_wait(10., "chord_rep_suc", &temp_sock2, &rep_suc_msg);
+    }
+    CATCH(e) {
+      RETHROW1("%s: Error waiting for successor:%s", globals->host);
     }
-    globals->finger[0].id=rep_suc_msg.id;
-    snprintf(globals->finger[0].host,1024,rep_suc_msg.host);
-    globals->finger[0].port=rep_suc_msg.port;
-    INFO3("→Got successor : %d-%s:%d",globals->finger[0].id,
-          globals->finger[0].host,globals->finger[0].port);
+    globals->finger[0].id = rep_suc_msg.id;
+    snprintf(globals->finger[0].host, 1024, rep_suc_msg.host);
+    globals->finger[0].port = rep_suc_msg.port;
+    INFO3("→Got successor : %d-%s:%d", globals->finger[0].id,
+          globals->finger[0].host, globals->finger[0].port);
     gras_socket_close(temp_sock);
-    TRY{
-      temp_sock=gras_socket_client(globals->finger[0].host,
-                                   globals->finger[0].port);
-    }CATCH(e){
+    TRY {
+      temp_sock = gras_socket_client(globals->finger[0].host,
+                                     globals->finger[0].port);
+    }
+    CATCH(e) {
       RETHROW0("Unable to contact successor: %s");
     }
 
-       notify_msg.id=globals->id;
-    snprintf(notify_msg.host,1024,globals->host);
-    notify_msg.port=globals->port;
-    TRY{
-      gras_msg_send(temp_sock,"chord_notify",&notify_msg);
-    }CATCH(e){
+    notify_msg.id = globals->id;
+    snprintf(notify_msg.host, 1024, globals->host);
+    notify_msg.port = globals->port;
+    TRY {
+      gras_msg_send(temp_sock, "chord_notify", &notify_msg);
+    }
+    CATCH(e) {
       RETHROW0("Unable to notify successor! %s");
     }
   }
-  
+
   gras_cb_register("chord_get_suc", &node_cb_get_suc_handler);
-  gras_cb_register("chord_notify",  &node_cb_notify_handler);
-  /*gras_cb_register("chord_ping",&node_cb_ping_handler);*/
/* gras_timer_repeat(600.,fix_fingers);*/
-  /*while(1){*/
+  gras_cb_register("chord_notify", &node_cb_notify_handler);
+  /*gras_cb_register("chord_ping",&node_cb_ping_handler); */
 /* gras_timer_repeat(600.,fix_fingers); */
+  /*while(1){ */
 
-  for(l=0;l<50;l++){
-    TRY{
+  for (l = 0; l < 50; l++) {
+    TRY {
       gras_msg_handle(6000000.0);
-    }CATCH(e){
+    }
+    CATCH(e) {
     }
   }
-  /*}*/
-  
+  /*} */
+
   gras_socket_close(globals->sock);
   free(globals);
   gras_exit();
   INFO0("Done");
-  return(0);
+  return (0);
 }
index 27597d9..d75975a 100644 (file)
@@ -33,7 +33,8 @@ static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload)
   /* 3. Log which client connected */
   INFO3(">>>>>>>> Got message PING(%d) from %s:%d <<<<<<<<",
         msg,
-        gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor));
+        gras_socket_peer_name(expeditor),
+        gras_socket_peer_port(expeditor));
 
   /* 4. Change the value of the msg variable */
   msg = 4321;
@@ -93,7 +94,8 @@ int server(int argc, char *argv[])
 
   /* 7. Housekeeping */
   if (!globals->endcondition)
-    WARN0("An error occured, the endcondition was not set by the callback");
+    WARN0
+        ("An error occured, the endcondition was not set by the callback");
 
   /* 8. Free the allocated resources, and shut GRAS down */
   gras_socket_close(globals->sock);
index 78778ef..0ad4e98 100755 (executable)
@@ -21,8 +21,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(pmm, "Parallel Matrix Multiplication");
 
 /* struct for recovering results */
 GRAS_DEFINE_TYPE(s_result, struct s_result {
-                 int linepos;
-                 int rowpos; xbt_matrix_t C GRAS_ANNOTE(subtype, double);});
+                 int linepos; int rowpos;
+                 xbt_matrix_t C GRAS_ANNOTE(subtype, double);
+                 });
 
 typedef struct s_result result_t;
 
@@ -33,7 +34,8 @@ GRAS_DEFINE_TYPE(s_pmm_assignment, struct s_pmm_assignment {
                  xbt_peer_t line[NEIGHBOR_COUNT];
                  xbt_peer_t row[NEIGHBOR_COUNT];
                  xbt_matrix_t A GRAS_ANNOTE(subtype, double);
-                 xbt_matrix_t B GRAS_ANNOTE(subtype, double);});
+                 xbt_matrix_t B GRAS_ANNOTE(subtype, double);
+                 });
 
 typedef struct s_pmm_assignment s_pmm_assignment_t;
 
@@ -55,11 +57,11 @@ static void register_messages(void)
 
   /* send data between slaves */
   gras_msgtype_declare("dataA",
-                       gras_datadesc_matrix(gras_datadesc_by_name("double"),
-                                            NULL));
+                       gras_datadesc_matrix(gras_datadesc_by_name
+                                            ("double"), NULL));
   gras_msgtype_declare("dataB",
-                       gras_datadesc_matrix(gras_datadesc_by_name("double"),
-                                            NULL));
+                       gras_datadesc_matrix(gras_datadesc_by_name
+                                            ("double"), NULL));
 
   /* synchronization message */
   gras_msgtype_declare("pmm_sync", 0);
@@ -113,8 +115,9 @@ int master(int argc, char *argv[])
   /* friends, we're ready. Come and play */
   INFO0("Wait for peers for 2 sec");
   gras_msg_handleall(2);
-  while (xbt_dynar_length(peers)<9) {
-    INFO1("Got only %ld pals. Wait 2 more seconds", xbt_dynar_length(peers));
+  while (xbt_dynar_length(peers) < 9) {
+    INFO1("Got only %ld pals. Wait 2 more seconds",
+          xbt_dynar_length(peers));
     gras_msg_handleall(2);
   }
   INFO1("Good. Got %ld pals", xbt_dynar_length(peers));
@@ -167,8 +170,9 @@ int master(int argc, char *argv[])
                                       submatrix_size * line,
                                       submatrix_size * row, NULL);
     assignment.B =
-      xbt_matrix_new_sub(B, submatrix_size, submatrix_size,
-                         submatrix_size * line, submatrix_size * row, NULL);
+        xbt_matrix_new_sub(B, submatrix_size, submatrix_size,
+                           submatrix_size * line, submatrix_size * row,
+                           NULL);
     row++;
     if (row >= PROC_MATRIX_SIZE) {
       row = 0;
@@ -181,18 +185,19 @@ int master(int argc, char *argv[])
   }
 
   /* synchronize slaves */
-  for (i = 0 ; i < PROC_MATRIX_SIZE ; i++) {
+  for (i = 0; i < PROC_MATRIX_SIZE; i++) {
     int j;
-    for (j = 0 ; j < SLAVE_COUNT ; j++)
+    for (j = 0; j < SLAVE_COUNT; j++)
       gras_msg_wait(600, "pmm_sync", NULL, NULL);
-    for (j = 0 ; j < SLAVE_COUNT ; j++)
+    for (j = 0; j < SLAVE_COUNT; j++)
       gras_msg_send(socket[j], "pmm_sync", NULL);
   }
 
   /* Retrieve the results */
   for (i = 0; i < SLAVE_COUNT; i++) {
     gras_msg_wait(6000, "result", &from, &result);
-    VERB2("%d slaves are done already. Waiting for %d", i + 1, SLAVE_COUNT);
+    VERB2("%d slaves are done already. Waiting for %d", i + 1,
+          SLAVE_COUNT);
     xbt_matrix_copy_values(C, result.C, submatrix_size, submatrix_size,
                            submatrix_size * result.linepos,
                            submatrix_size * result.rowpos, 0, 0, NULL);
@@ -204,13 +209,13 @@ int master(int argc, char *argv[])
     INFO0("XXXXXXXXXXXXXXXXXXXXXX Ok, the result matches expectations");
   else {
     WARN0("the result seems wrong");
-  if (DATA_MATRIX_SIZE < 30) {
-    INFO0("The Result of Multiplication is :");
-    xbt_matrix_dump(C, "C:res", 0, xbt_matrix_dump_display_double);
-  } else {
-    INFO1("Matrix size too big (%d>30) to be displayed here",
-          DATA_MATRIX_SIZE);
-  }
+    if (DATA_MATRIX_SIZE < 30) {
+      INFO0("The Result of Multiplication is :");
+      xbt_matrix_dump(C, "C:res", 0, xbt_matrix_dump_display_double);
+    } else {
+      INFO1("Matrix size too big (%d>30) to be displayed here",
+            DATA_MATRIX_SIZE);
+    }
   }
 
   amok_pm_group_shutdown("pmm");        /* Ok, we're out of here */
@@ -246,7 +251,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload)
   int myline, myrow;
   xbt_matrix_t mydataA, mydataB;
   xbt_matrix_t bC =
-    xbt_matrix_double_new_zeros(submatrix_size, submatrix_size);
+      xbt_matrix_double_new_zeros(submatrix_size, submatrix_size);
 
   result_t result;
 
@@ -290,7 +295,8 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload)
 
     /* a line brodcast */
     if (myline == step) {
-      VERB2("LINE: step(%d) = Myline(%d). Broadcast my data.", step, myline);
+      VERB2("LINE: step(%d) = Myline(%d). Broadcast my data.", step,
+            myline);
       for (l = 0; l < PROC_MATRIX_SIZE - 1; l++) {
         VERB1("LINE:   Send to %s", gras_socket_peer_name(socket_row[l]));
         gras_msg_send(socket_row[l], "dataB", &mydataB);
@@ -316,7 +322,8 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload)
     if (myrow == step) {
       VERB2("ROW: step(%d)=myrow(%d). Broadcast my data.", step, myrow);
       for (l = 1; l < PROC_MATRIX_SIZE; l++) {
-        VERB1("ROW:   Send to %s", gras_socket_peer_name(socket_line[l - 1]));
+        VERB1("ROW:   Send to %s",
+              gras_socket_peer_name(socket_line[l - 1]));
         gras_msg_send(socket_line[l - 1], "dataA", &mydataA);
       }
       xbt_matrix_free(bA);
index 850b91d..ce8372e 100644 (file)
@@ -28,11 +28,11 @@ int alice(int argc, char *argv[])
 
   INFO0("== Dump all the properties of current host");
   xbt_dict_foreach(host_props, cursor, key, data)
-    INFO2("  Host property: '%s' has value: '%s'", key, data);
+      INFO2("  Host property: '%s' has value: '%s'", key, data);
 
   INFO0("== Dump all the properties of alice");
   xbt_dict_foreach(process_props, cursor, key, data)
-    if (!strncmp(key, "SG_TEST_", 8))
+      if (!strncmp(key, "SG_TEST_", 8))
     INFO2("  Process property: '%s' has value: '%s'", key, data);
 
   INFO0("== Try to get a process property that does not exist");
@@ -68,20 +68,21 @@ int bob(int argc, char *argv[])
 
   INFO0("== Dump all the properties of host1");
   xbt_dict_foreach(host_props, cursor, key, data)
-    INFO2("  Host property: '%s' has value: '%s'", key, data);
+      INFO2("  Host property: '%s' has value: '%s'", key, data);
 
   INFO0("== Try to get a property that does not exist");
   value = gras_os_host_property_value("non existing key");
   xbt_assert1(value == NULL,
-              "The key 'non existing key' exists (with value '%s')!!", value);
+              "The key 'non existing key' exists (with value '%s')!!",
+              value);
 
   INFO0
-    ("== Set a host property that alice will try to retrieve in SG (from bob->hello)");
+      ("== Set a host property that alice will try to retrieve in SG (from bob->hello)");
   xbt_dict_set(host_props, "from bob", xbt_strdup("hello"), xbt_free_f);
 
   INFO0("== Dump all the properties of host1 again to check the addition");
   xbt_dict_foreach(host_props, cursor, key, data)
-    INFO2("  Host property: '%s' has value: '%s'", key, data);
+      INFO2("  Host property: '%s' has value: '%s'", key, data);
 
   gras_os_sleep(1);             /* KILLME once bug on empty main is solved */
   gras_exit();
index c29f566..a0a42e9 100644 (file)
 
 #include "simix/simix.h"
 
-int master(int argc,char *argv[]);
-int worker(int argc,char *argv[]);
+int master(int argc, char *argv[]);
+int worker(int argc, char *argv[]);
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(replay, "Messages specific to this example");
 
-static void declare_msg() {
+static void declare_msg()
+{
   amok_pm_init();
   xbt_workload_declare_datadesc();
-  gras_msgtype_declare("go",NULL);
+  gras_msgtype_declare("go", NULL);
   gras_msgtype_declare("commands",
-      gras_datadesc_dynar(
-          gras_datadesc_by_name("xbt_workload_elm_t"),xbt_workload_elm_free_voidp));
-  gras_msgtype_declare("chunk",gras_datadesc_by_name("xbt_workload_data_chunk_t"));
+                       gras_datadesc_dynar(gras_datadesc_by_name
+                                           ("xbt_workload_elm_t"),
+                                           xbt_workload_elm_free_voidp));
+  gras_msgtype_declare("chunk",
+                       gras_datadesc_by_name("xbt_workload_data_chunk_t"));
 }
 
-int master(int argc,char *argv[]) {
+int master(int argc, char *argv[])
+{
 
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
   declare_msg();
 
 
-  xbt_assert0(argc==3,"usage: replay_master tracefile port");
-  gras_socket_server(atoi(argv[2])); /* open my master socket, even if I don't use it */
-  xbt_dynar_t peers = amok_pm_group_new("replay");            /* group of slaves */
+  xbt_assert0(argc == 3, "usage: replay_master tracefile port");
+  gras_socket_server(atoi(argv[2]));    /* open my master socket, even if I don't use it */
+  xbt_dynar_t peers = amok_pm_group_new("replay");      /* group of slaves */
   xbt_peer_t peer;
   xbt_dynar_t cmds = xbt_workload_parse_file(argv[1]);
   xbt_workload_sort_who_date(cmds);
@@ -54,28 +58,30 @@ int master(int argc,char *argv[]) {
   xbt_ex_t e;
   xbt_dict_cursor_t dict_cursor;
 
-  xbt_dict_t pals_int=xbt_dict_new();
-  xbt_dynar_foreach(cmds,cursor,cmd) {
-    int *p = xbt_dict_get_or_null(pals_int,cmd->who);
+  xbt_dict_t pals_int = xbt_dict_new();
+  xbt_dynar_foreach(cmds, cursor, cmd) {
+    int *p = xbt_dict_get_or_null(pals_int, cmd->who);
     if (!p) {
-      p=(int*)0xBEAF;
-      xbt_dict_set(pals_int,cmd->who,&p,NULL);
+      p = (int *) 0xBEAF;
+      xbt_dict_set(pals_int, cmd->who, &p, NULL);
     }
   }
 
   /* friends, we're ready. Come and play */
-  INFO1("Wait for peers for a while. I need %d peers",xbt_dict_size(pals_int));
-  while (xbt_dynar_length(peers)<xbt_dict_size(pals_int)) {
+  INFO1("Wait for peers for a while. I need %d peers",
+        xbt_dict_size(pals_int));
+  while (xbt_dynar_length(peers) < xbt_dict_size(pals_int)) {
     TRY {
       gras_msg_handle(20);
-    } CATCH(e) {
-      xbt_dynar_foreach(peers,cursor,peer){
-        xbt_dict_remove(pals_int,peer->name);
+    }
+    CATCH(e) {
+      xbt_dynar_foreach(peers, cursor, peer) {
+        xbt_dict_remove(pals_int, peer->name);
       }
       char *peer_name;
       void *data;
-      xbt_dict_foreach(pals_int,dict_cursor,peer_name,data) {
-        INFO1("Peer %s didn't showed up",peer_name);
+      xbt_dict_foreach(pals_int, dict_cursor, peer_name, data) {
+        INFO1("Peer %s didn't showed up", peer_name);
       }
       RETHROW;
     }
@@ -86,16 +92,16 @@ int master(int argc,char *argv[]) {
   /* Check who came */
   xbt_dict_t pals = xbt_dict_new();
   gras_socket_t pal;
-  xbt_dynar_foreach(peers,cursor, peer) {
+  xbt_dynar_foreach(peers, cursor, peer) {
     //INFO1("%s is here",peer->name);
-    gras_socket_t sock = gras_socket_client(peer->name,peer->port);
-    xbt_dict_set(pals,peer->name,sock,NULL);
+    gras_socket_t sock = gras_socket_client(peer->name, peer->port);
+    xbt_dict_set(pals, peer->name, sock, NULL);
   }
   /* check that we have a dude for every element of the trace */
-  xbt_dynar_foreach(cmds,cursor,cmd) {
-    pal=xbt_dict_get_or_null(pals,cmd->who);
+  xbt_dynar_foreach(cmds, cursor, cmd) {
+    pal = xbt_dict_get_or_null(pals, cmd->who);
     if (!pal) {
-      CRITICAL1("Process %s didn't came! Abording!",cmd->who);
+      CRITICAL1("Process %s didn't came! Abording!", cmd->who);
       amok_pm_group_shutdown("replay");
       xbt_dynar_free(&cmds);
       gras_exit();
@@ -104,18 +110,18 @@ int master(int argc,char *argv[]) {
   }
   /* Send the commands to every pal */
   char *pal_name;
-  xbt_dict_foreach(pals,dict_cursor,pal_name,pal) {
-    gras_msg_send(pal,"commands",&cmds);
+  xbt_dict_foreach(pals, dict_cursor, pal_name, pal) {
+    gras_msg_send(pal, "commands", &cmds);
   }
   INFO0("Sent commands to every processes. Let them start now");
   xbt_dict_cursor_t dict_it;
-  xbt_dict_foreach(pals,dict_it,pal_name,pal) {
-    gras_msg_send(pal,"go",NULL);
+  xbt_dict_foreach(pals, dict_it, pal_name, pal) {
+    gras_msg_send(pal, "go", NULL);
   }
   INFO0("They should be started by now. Wait for their completion.");
 
-  for (cursor=0;cursor<xbt_dynar_length(peers);cursor++) {
-    gras_msg_wait(-1,"go",NULL,NULL);
+  for (cursor = 0; cursor < xbt_dynar_length(peers); cursor++) {
+    gras_msg_wait(-1, "go", NULL, NULL);
   }
 
   /* Done, exiting */
@@ -129,69 +135,79 @@ typedef struct {
   xbt_dynar_t commands;
   xbt_dict_t peers;
   gras_socket_t mysock;
-} s_worker_data_t,*worker_data_t;
+} s_worker_data_t, *worker_data_t;
 
 
-static gras_socket_t get_peer_sock(char*peer) {
+static gras_socket_t get_peer_sock(char *peer)
+{
   worker_data_t g = gras_userdata_get();
-  gras_socket_t peer_sock = xbt_dict_get_or_null(g->peers,peer);
+  gras_socket_t peer_sock = xbt_dict_get_or_null(g->peers, peer);
   if (!peer_sock) {
-    INFO1("Create a socket to %s",peer);
-    peer_sock = gras_socket_client(peer,4000);
-    xbt_dict_set(g->peers,peer,peer_sock,NULL);//gras_socket_close_voidp);
+    INFO1("Create a socket to %s", peer);
+    peer_sock = gras_socket_client(peer, 4000);
+    xbt_dict_set(g->peers, peer, peer_sock, NULL);      //gras_socket_close_voidp);
   }
   return peer_sock;
 }
-static int worker_commands_cb(gras_msg_cb_ctx_t ctx, void *payload) {
+
+static int worker_commands_cb(gras_msg_cb_ctx_t ctx, void *payload)
+{
   worker_data_t g = gras_userdata_get();
-  g->commands = *(xbt_dynar_t*)payload;
+  g->commands = *(xbt_dynar_t *) payload;
   return 0;
 }
-static void do_command(int rank, void*c) {
+
+static void do_command(int rank, void *c)
+{
   xbt_ex_t e;
-  xbt_workload_elm_t cmd = *(xbt_workload_elm_t*)c;
+  xbt_workload_elm_t cmd = *(xbt_workload_elm_t *) c;
   xbt_workload_data_chunk_t chunk;
 
   if (cmd->action == XBT_WORKLOAD_SEND) {
     gras_socket_t sock = get_peer_sock(cmd->str_arg);
-    chunk = xbt_workload_data_chunk_new((int)(cmd->d_arg));
-    INFO4("Send %.f bytes to %s %s:%d",cmd->d_arg,cmd->str_arg,
-        gras_socket_peer_name(sock),gras_socket_peer_port(sock));
-    gras_msg_send_(sock,gras_msgtype_by_name("chunk"),&chunk);
-    INFO2("Done sending %.f bytes to %s",cmd->d_arg,cmd->str_arg);
+    chunk = xbt_workload_data_chunk_new((int) (cmd->d_arg));
+    INFO4("Send %.f bytes to %s %s:%d", cmd->d_arg, cmd->str_arg,
+          gras_socket_peer_name(sock), gras_socket_peer_port(sock));
+    gras_msg_send_(sock, gras_msgtype_by_name("chunk"), &chunk);
+    INFO2("Done sending %.f bytes to %s", cmd->d_arg, cmd->str_arg);
 
   } else if (cmd->action == XBT_WORKLOAD_RECV) {
-    INFO2("Recv %.f bytes from %s",cmd->d_arg,cmd->str_arg);
+    INFO2("Recv %.f bytes from %s", cmd->d_arg, cmd->str_arg);
     TRY {
-      gras_msg_wait(1000000,"chunk",NULL,&chunk);
-    } CATCH(e) {
+      gras_msg_wait(1000000, "chunk", NULL, &chunk);
+    }
+    CATCH(e) {
       SIMIX_display_process_status();
       RETHROW2("Exception while waiting for %f bytes from %s: %s",
-            cmd->d_arg,cmd->str_arg);
+               cmd->d_arg, cmd->str_arg);
     }
     xbt_workload_data_chunk_free(chunk);
-    INFO2("Done receiving %.f bytes from %s",cmd->d_arg,cmd->str_arg);
+    INFO2("Done receiving %.f bytes from %s", cmd->d_arg, cmd->str_arg);
 
   } else {
-    xbt_die(bprintf("unknown command: %s",xbt_workload_elm_to_string(cmd)));
+    xbt_die(bprintf
+            ("unknown command: %s", xbt_workload_elm_to_string(cmd)));
   }
 }
-int worker(int argc,char *argv[]) {
+
+int worker(int argc, char *argv[])
+{
   xbt_ex_t e;
   worker_data_t globals;
-  gras_init(&argc,argv);
+  gras_init(&argc, argv);
   declare_msg();
   globals = gras_userdata_new(s_worker_data_t);
   /* Create the connexions */
-  globals->mysock = gras_socket_server(4000); /* FIXME: shouldn't be hardcoded */
-  gras_socket_t master=NULL;
-  int connected=0;
+  globals->mysock = gras_socket_server(4000);   /* FIXME: shouldn't be hardcoded */
+  gras_socket_t master = NULL;
+  int connected = 0;
 
   gras_cb_register("commands", worker_commands_cb);
-  globals->peers=xbt_dict_new();
+  globals->peers = xbt_dict_new();
 
   if (gras_if_RL())
-    INFO2("Sensor %s starting. Connecting to master on %s", gras_os_myname(), argv[1]);
+    INFO2("Sensor %s starting. Connecting to master on %s",
+          gras_os_myname(), argv[1]);
   while (!connected) {
     xbt_ex_t e;
     TRY {
@@ -208,57 +224,60 @@ int worker(int argc,char *argv[]) {
   }
   /* Join and run the group */
   amok_pm_group_join(master, "replay", -1);
-  gras_msg_handle(60); // command message
-  gras_msg_wait(60,"go",NULL,NULL);
+  gras_msg_handle(60);          // command message
+  gras_msg_wait(60, "go", NULL, NULL);
   {
     worker_data_t g = gras_userdata_get();
     unsigned int cursor;
     xbt_workload_elm_t cmd;
-    const char *myname=gras_os_myname();
-    xbt_dynar_t cmd_to_go = xbt_dynar_new(sizeof(xbt_workload_elm_t),NULL);
+    const char *myname = gras_os_myname();
+    xbt_dynar_t cmd_to_go =
+        xbt_dynar_new(sizeof(xbt_workload_elm_t), NULL);
 
-    xbt_dynar_foreach(g->commands,cursor,cmd) {
-      if (!strcmp(cmd->who,myname)) {
+    xbt_dynar_foreach(g->commands, cursor, cmd) {
+      if (!strcmp(cmd->who, myname)) {
         char *c = xbt_workload_elm_to_string(cmd);
-  //      INFO1("TODO: %s",c);
+        //      INFO1("TODO: %s",c);
         free(c);
 
         switch (cmd->action) {
         case XBT_WORKLOAD_COMPUTE:
           /* If any communication were queued, do them in parallel */
-          if (xbt_dynar_length(cmd_to_go)){
+          if (xbt_dynar_length(cmd_to_go)) {
             TRY {
-              xbt_dynar_dopar(cmd_to_go,do_command);
+              xbt_dynar_dopar(cmd_to_go, do_command);
               xbt_dynar_reset(cmd_to_go);
-            } CATCH(e) {
+            }
+            CATCH(e) {
               SIMIX_display_process_status();
             }
             INFO0("Communications all done");
             xbt_dynar_reset(cmd_to_go);
           }
-          INFO1("Compute %.f flops",cmd->d_arg);
+          INFO1("Compute %.f flops", cmd->d_arg);
           gras_cpu_burn(cmd->d_arg);
-          INFO1("Done computing %.f flops",cmd->d_arg);
+          INFO1("Done computing %.f flops", cmd->d_arg);
           break;
         case XBT_WORKLOAD_SEND:
           /* Create the socket from main thread since it seems to fails when done from dopar thread */
           get_peer_sock(cmd->str_arg);
         case XBT_WORKLOAD_RECV:
           /* queue communications for later realization in parallel */
-          xbt_dynar_push(cmd_to_go,&cmd);
+          xbt_dynar_push(cmd_to_go, &cmd);
           break;
         }
       }
     }
     /* do in parallel any communication still queued */
-    INFO1("Do %ld pending communications after end of TODO list",xbt_dynar_length(cmd_to_go));
-    if (xbt_dynar_length(cmd_to_go)){
-      xbt_dynar_dopar(cmd_to_go,do_command);
+    INFO1("Do %ld pending communications after end of TODO list",
+          xbt_dynar_length(cmd_to_go));
+    if (xbt_dynar_length(cmd_to_go)) {
+      xbt_dynar_dopar(cmd_to_go, do_command);
       xbt_dynar_reset(cmd_to_go);
     }
   }
 
-  gras_msg_send(master,"go",NULL);
+  gras_msg_send(master, "go", NULL);
 //  amok_pm_group_leave(master, "replay");
 
   gras_socket_close(globals->mysock);
index 46dcd83..2d4372d 100644 (file)
 typedef struct {
   /* keep it in sync with function xbt_workload_declare_datadesc() */
 
-  char *who;      /* the slave who should do it */
-  char *comment;  /* a comment placed at the end of the line, if any */
-  int action;     /* 0: compute(darg flops); 1: send darg bytes to strarg; 2: recv darg bytes from strarg */
-  double date;    /* when it occured when the trace was captured */
-  double d_arg;   /* double argument, if any */
-  char * str_arg; /* string argument, if any */
+  char *who;                    /* the slave who should do it */
+  char *comment;                /* a comment placed at the end of the line, if any */
+  int action;                   /* 0: compute(darg flops); 1: send darg bytes to strarg; 2: recv darg bytes from strarg */
+  double date;                  /* when it occured when the trace was captured */
+  double d_arg;                 /* double argument, if any */
+  char *str_arg;                /* string argument, if any */
 } s_xbt_workload_elm_t, *xbt_workload_elm_t;
 
 XBT_PUBLIC(xbt_workload_elm_t) xbt_workload_elm_parse(char *line);
 XBT_PUBLIC(void) xbt_workload_elm_free(xbt_workload_elm_t cmd);
-XBT_PUBLIC(void) xbt_workload_elm_free_voidp(void*cmd);
-XBT_PUBLIC(char *)xbt_workload_elm_to_string(xbt_workload_elm_t cmd);
-XBT_PUBLIC(int) xbt_workload_elm_cmp_who_date(const void* _c1, const void* _c2);
+XBT_PUBLIC(void) xbt_workload_elm_free_voidp(void *cmd);
+XBT_PUBLIC(char *) xbt_workload_elm_to_string(xbt_workload_elm_t cmd);
+XBT_PUBLIC(int) xbt_workload_elm_cmp_who_date(const void *_c1,
+                                              const void *_c2);
 XBT_PUBLIC(void) xbt_workload_sort_who_date(xbt_dynar_t c);
 XBT_PUBLIC(xbt_dynar_t) xbt_workload_parse_file(char *filename);
 
@@ -46,8 +47,9 @@ XBT_PUBLIC(void) xbt_workload_declare_datadesc(void);
 typedef struct {
   int size;
   char *chunk;
-} s_xbt_workload_data_chunk_t,*xbt_workload_data_chunk_t;
-XBT_PUBLIC(xbt_workload_data_chunk_t) xbt_workload_data_chunk_new(int size);
+} s_xbt_workload_data_chunk_t, *xbt_workload_data_chunk_t;
+XBT_PUBLIC(xbt_workload_data_chunk_t) xbt_workload_data_chunk_new(int
+                                                                  size);
 XBT_PUBLIC(void) xbt_workload_data_chunk_free(xbt_workload_data_chunk_t c);
 
-#endif /* XBT_WORKLOAD_H_ */
+#endif                          /* XBT_WORKLOAD_H_ */
index 46a9e4b..769d8b5 100644 (file)
 #include "workload.h"
 #include "gras/datadesc.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_workload,xbt, "Workload characterisation mecanisms");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_workload, xbt,
+                                "Workload characterisation mecanisms");
 
 
-xbt_workload_elm_t xbt_workload_elm_parse(char *line) {
-  xbt_workload_elm_t res = xbt_new(s_xbt_workload_elm_t,1);
-  res->date=-1;
-  res->comment=NULL; /* it's not enough to memset for valgrind, apparently */
-  res->who=NULL;
-  res->str_arg=NULL;
+xbt_workload_elm_t xbt_workload_elm_parse(char *line)
+{
+  xbt_workload_elm_t res = xbt_new(s_xbt_workload_elm_t, 1);
+  res->date = -1;
+  res->comment = NULL;          /* it's not enough to memset for valgrind, apparently */
+  res->who = NULL;
+  res->str_arg = NULL;
 
-  xbt_dynar_t w = xbt_str_split(line," ");
+  xbt_dynar_t w = xbt_str_split(line, " ");
 
   if (xbt_dynar_length(w) == 0) {
     free(res);
@@ -33,38 +35,40 @@ xbt_workload_elm_t xbt_workload_elm_parse(char *line) {
     return NULL;
   }
 
-  char **words = xbt_dynar_get_ptr(w,0);
-  int i=0;
+  char **words = xbt_dynar_get_ptr(w, 0);
+  int i = 0;
   if (words[i][0] == '[') {
-    sscanf(words[i]+1,"%lg",&(res->date));
+    sscanf(words[i] + 1, "%lg", &(res->date));
     i++;
   }
   res->who = xbt_strdup(words[i++]);
-  if (!strcmp(words[i],"recv")) {
+  if (!strcmp(words[i], "recv")) {
     res->action = XBT_WORKLOAD_RECV;
     res->str_arg = xbt_strdup(words[++i]);
-    sscanf(words[++i],"%lg",&(res->d_arg));
+    sscanf(words[++i], "%lg", &(res->d_arg));
 
-  } else if (!strcmp(words[i],"send")) {
+  } else if (!strcmp(words[i], "send")) {
     res->action = XBT_WORKLOAD_SEND;
     res->str_arg = xbt_strdup(words[++i]);
-    sscanf(words[++i],"%lg",&(res->d_arg));
+    sscanf(words[++i], "%lg", &(res->d_arg));
 
-  } else if (!strcmp(words[i],"compute")) {
+  } else if (!strcmp(words[i], "compute")) {
     res->action = XBT_WORKLOAD_COMPUTE;
-    sscanf(words[++i],"%lg",&(res->d_arg));
+    sscanf(words[++i], "%lg", &(res->d_arg));
   } else {
-    xbt_die(bprintf("Unparsable command: %s (in %s)",words[i],line));
+    xbt_die(bprintf("Unparsable command: %s (in %s)", words[i], line));
   }
   i++;
   if (words[i] && words[i][0] == '#') {
-    res->comment = xbt_strdup(strchr(line,'#')+1);
+    res->comment = xbt_strdup(strchr(line, '#') + 1);
   }
 
   xbt_dynar_free(&w);
   return res;
 }
-void xbt_workload_elm_free(xbt_workload_elm_t cmd) {
+
+void xbt_workload_elm_free(xbt_workload_elm_t cmd)
+{
   if (!cmd)
     return;
   if (cmd->who)
@@ -75,55 +79,65 @@ void xbt_workload_elm_free(xbt_workload_elm_t cmd) {
     free(cmd->str_arg);
   free(cmd);
 }
-void xbt_workload_elm_free_voidp(void*cmd) {
-  xbt_workload_elm_free(*(xbt_workload_elm_t*)cmd);
+
+void xbt_workload_elm_free_voidp(void *cmd)
+{
+  xbt_workload_elm_free(*(xbt_workload_elm_t *) cmd);
 }
 
-char *xbt_workload_elm_to_string(xbt_workload_elm_t cmd) {
+char *xbt_workload_elm_to_string(xbt_workload_elm_t cmd)
+{
   char res[2048];
   char *addon;
-  res[0]='\0';
-  if (cmd==NULL)
+  res[0] = '\0';
+  if (cmd == NULL)
     return xbt_strdup("(null command)");
   if (cmd->date != -1) {
-    addon=bprintf("[%f] ",cmd->date);
-    strcat(res,addon);
+    addon = bprintf("[%f] ", cmd->date);
+    strcat(res, addon);
     free(addon);
   }
-  addon= bprintf("'%s' ",cmd->who);
-  strcat(res,addon);free(addon);
+  addon = bprintf("'%s' ", cmd->who);
+  strcat(res, addon);
+  free(addon);
 
   switch (cmd->action) {
   case XBT_WORKLOAD_COMPUTE:
-    addon=bprintf("computed %f flops",cmd->d_arg);
-    strcat(res,addon);free(addon);
+    addon = bprintf("computed %f flops", cmd->d_arg);
+    strcat(res, addon);
+    free(addon);
     break;
   case XBT_WORKLOAD_SEND:
-    addon=bprintf("sent %f bytes to '%s'",cmd->d_arg,cmd->str_arg);
-    strcat(res,addon);free(addon);
+    addon = bprintf("sent %f bytes to '%s'", cmd->d_arg, cmd->str_arg);
+    strcat(res, addon);
+    free(addon);
     break;
   case XBT_WORKLOAD_RECV:
-    addon=bprintf("received %f bytes from '%s'",cmd->d_arg,cmd->str_arg);
-    strcat(res,addon);free(addon);
+    addon =
+        bprintf("received %f bytes from '%s'", cmd->d_arg, cmd->str_arg);
+    strcat(res, addon);
+    free(addon);
     break;
   default:
-    xbt_die(bprintf("Unknown command %d in '%s...'",cmd->action,res));
+    xbt_die(bprintf("Unknown command %d in '%s...'", cmd->action, res));
   }
   if (cmd->comment) {
-    addon=bprintf(" (comment: %s)",cmd->comment);
-    strcat(res,addon);free(addon);
+    addon = bprintf(" (comment: %s)", cmd->comment);
+    strcat(res, addon);
+    free(addon);
   }
   return xbt_strdup(res);
 }
 
-int xbt_workload_elm_cmp_who_date(const void* _c1, const void* _c2) {
-  xbt_workload_elm_t c1=*(xbt_workload_elm_t*)_c1;
-  xbt_workload_elm_t c2=*(xbt_workload_elm_t*)_c2;
+int xbt_workload_elm_cmp_who_date(const void *_c1, const void *_c2)
+{
+  xbt_workload_elm_t c1 = *(xbt_workload_elm_t *) _c1;
+  xbt_workload_elm_t c2 = *(xbt_workload_elm_t *) _c2;
   if (!c1 || !c1->who)
     return -1;
   if (!c2 || !c2->who)
     return 1;
-  int r = strcmp(c1->who,c2->who);
+  int r = strcmp(c1->who, c2->who);
   if (r)
     return r;
   if (c1->date == c2->date)
@@ -132,64 +146,81 @@ int xbt_workload_elm_cmp_who_date(const void* _c1, const void* _c2) {
     return -1;
   return 1;
 }
-void xbt_workload_sort_who_date(xbt_dynar_t c) {
-  qsort(xbt_dynar_get_ptr(c,0),xbt_dynar_length(c),sizeof(xbt_workload_elm_t),xbt_workload_elm_cmp_who_date);
+
+void xbt_workload_sort_who_date(xbt_dynar_t c)
+{
+  qsort(xbt_dynar_get_ptr(c, 0), xbt_dynar_length(c),
+        sizeof(xbt_workload_elm_t), xbt_workload_elm_cmp_who_date);
 }
-xbt_dynar_t xbt_workload_parse_file(char *filename) {
+
+xbt_dynar_t xbt_workload_parse_file(char *filename)
+{
   FILE *file_in;
-  file_in = fopen(filename,"r");
-  xbt_assert1(file_in, "cannot open tracefile '%s'",filename);
+  file_in = fopen(filename, "r");
+  xbt_assert1(file_in, "cannot open tracefile '%s'", filename);
   char *str_in = xbt_str_from_file(file_in);
   fclose(file_in);
-  xbt_dynar_t in = xbt_str_split(str_in,"\n");
+  xbt_dynar_t in = xbt_str_split(str_in, "\n");
   free(str_in);
-  xbt_dynar_t cmds=xbt_dynar_new(sizeof(xbt_workload_elm_t),xbt_workload_elm_free_voidp);
+  xbt_dynar_t cmds =
+      xbt_dynar_new(sizeof(xbt_workload_elm_t),
+                    xbt_workload_elm_free_voidp);
 
   unsigned int cursor;
   char *line;
-  xbt_dynar_foreach(in,cursor,line) {
+  xbt_dynar_foreach(in, cursor, line) {
     xbt_workload_elm_t cmd = xbt_workload_elm_parse(line);
     if (cmd)
-      xbt_dynar_push(cmds,&cmd);
+      xbt_dynar_push(cmds, &cmd);
   }
-  xbt_dynar_shrink(cmds,0);
+  xbt_dynar_shrink(cmds, 0);
   xbt_dynar_free(&in);
   return cmds;
 }
 
 
-void xbt_workload_declare_datadesc(void) {
+void xbt_workload_declare_datadesc(void)
+{
   gras_datadesc_type_t ddt;
 
   ddt = gras_datadesc_struct("s_xbt_workload_elm_t");
-  gras_datadesc_struct_append(ddt,"who",gras_datadesc_by_name("string"));
-  gras_datadesc_struct_append(ddt,"comment",gras_datadesc_by_name("string"));
-  gras_datadesc_struct_append(ddt,"action",gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(ddt,"date",gras_datadesc_by_name("double"));
-  gras_datadesc_struct_append(ddt,"d_arg",gras_datadesc_by_name("double"));
-  gras_datadesc_struct_append(ddt,"str_arg",gras_datadesc_by_name("string"));
+  gras_datadesc_struct_append(ddt, "who", gras_datadesc_by_name("string"));
+  gras_datadesc_struct_append(ddt, "comment",
+                              gras_datadesc_by_name("string"));
+  gras_datadesc_struct_append(ddt, "action", gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(ddt, "date",
+                              gras_datadesc_by_name("double"));
+  gras_datadesc_struct_append(ddt, "d_arg",
+                              gras_datadesc_by_name("double"));
+  gras_datadesc_struct_append(ddt, "str_arg",
+                              gras_datadesc_by_name("string"));
   gras_datadesc_struct_close(ddt);
 
-  gras_datadesc_ref("xbt_workload_elm_t",ddt);
+  gras_datadesc_ref("xbt_workload_elm_t", ddt);
 
   ddt = gras_datadesc_struct("s_xbt_workload_data_chunk_t");
-  gras_datadesc_struct_append(ddt,"size",gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(ddt, "size", gras_datadesc_by_name("int"));
   gras_datadesc_cb_field_push(ddt, "size");
-  gras_datadesc_struct_append(ddt,"chunk",gras_datadesc_ref_pop_arr(gras_datadesc_by_name("char")));
+  gras_datadesc_struct_append(ddt, "chunk",
+                              gras_datadesc_ref_pop_arr
+                              (gras_datadesc_by_name("char")));
   gras_datadesc_struct_close(ddt);
 
-  gras_datadesc_ref("xbt_workload_data_chunk_t",ddt);
+  gras_datadesc_ref("xbt_workload_data_chunk_t", ddt);
 }
 
 
 
-xbt_workload_data_chunk_t xbt_workload_data_chunk_new(int size) {
-  xbt_workload_data_chunk_t res = xbt_new0(s_xbt_workload_data_chunk_t,1);
-  res->size = size-sizeof(res)-sizeof(int);
-  res->chunk = xbt_new(char,res->size);
+xbt_workload_data_chunk_t xbt_workload_data_chunk_new(int size)
+{
+  xbt_workload_data_chunk_t res = xbt_new0(s_xbt_workload_data_chunk_t, 1);
+  res->size = size - sizeof(res) - sizeof(int);
+  res->chunk = xbt_new(char, res->size);
   return res;
 }
-void xbt_workload_data_chunk_free(xbt_workload_data_chunk_t c) {
+
+void xbt_workload_data_chunk_free(xbt_workload_data_chunk_t c)
+{
   free(c->chunk);
   free(c);
 }
index f4ee78f..ae7f548 100644 (file)
@@ -145,7 +145,7 @@ int client(int argc, char *argv[])
     xbt_assert1(!strncmp(e.msg, exception_msg, strlen(exception_msg)),
                 "Got wrong message: %s", e.msg);
     INFO0
-      ("Got the expected exception when calling the exception raising RPC");
+        ("Got the expected exception when calling the exception raising RPC");
     xbt_ex_free(e);
   }
 
@@ -176,7 +176,8 @@ int client(int argc, char *argv[])
   for (i = 0; i < 5; i++) {
     INFO1("Call the exception raising RPC on the forwarder (i=%d)", i);
     TRY {
-      gras_msg_rpccall(toforwarder, 6000.0, "forward exception", NULL, NULL);
+      gras_msg_rpccall(toforwarder, 6000.0, "forward exception", NULL,
+                       NULL);
     }
     CATCH(e) {
       gotit = 1;
@@ -191,7 +192,7 @@ int client(int argc, char *argv[])
                 "Got wrong category: %d (instead of %d)",
                 e.category, unknown_error);
     INFO0
-      ("Got the expected exception when calling the exception raising RPC");
+        ("Got the expected exception when calling the exception raising RPC");
     xbt_ex_free(e);
     exception_catching();
   }
@@ -231,7 +232,8 @@ static int forwarder_cb_kill(gras_msg_cb_ctx_t ctx, void *payload_data)
   return 0;
 }
 
-static int forwarder_cb_forward_ex(gras_msg_cb_ctx_t ctx, void *payload_data)
+static int forwarder_cb_forward_ex(gras_msg_cb_ctx_t ctx,
+                                   void *payload_data)
 {
   forward_data_t fdata = gras_userdata_get();
 
@@ -313,7 +315,8 @@ static int server_cb_ping(gras_msg_cb_ctx_t ctx, void *payload_data)
   /* 2. Log which client connected */
   INFO3("Got message PING(%d) from %s:%d",
         msg,
-        gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor));
+        gras_socket_peer_name(expeditor),
+        gras_socket_peer_port(expeditor));
 
   /* 4. Change the value of the msg variable */
   msg = 4321;
index 3098ffd..acc3523 100644 (file)
@@ -62,7 +62,8 @@ int child(int argc, char *argv[])
     gras_socket_close(dady);
     RETHROW0("Dad don't want to speak with me! : %s");
   }
-  INFO2("Pinged dad with %d, he answered with %d; leaving now.", ping, pong);
+  INFO2("Pinged dad with %d, he answered with %d; leaving now.", ping,
+        pong);
 
   /* 7. Free the allocated resources, and shut GRAS down */
   gras_socket_close(dady);
index edf1fa2..12cc6ae 100644 (file)
@@ -46,7 +46,8 @@ static int father_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload)
     RETHROW0("Unable to answer to my poor child: %s");
   }
   INFO2("Answered to %s:%d's request",
-        gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor));
+        gras_socket_peer_name(expeditor),
+        gras_socket_peer_port(expeditor));
 
   /* 7. Tell GRAS that we consummed this message */
   return 0;
index 96a653f..d4debb2 100644 (file)
@@ -29,14 +29,14 @@ static void pickup(int id, int lunch)
 {
   INFO2("Thread %d gets hungry (lunch #%d)", id, lunch);
   xbt_mutex_acquire(mutex);
-  while (state[(id + (philosopher_amount - 1)) % philosopher_amount] == EATING
-         || state[(id + 1) % philosopher_amount] == EATING) {
+  while (state[(id + (philosopher_amount - 1)) % philosopher_amount] ==
+         EATING || state[(id + 1) % philosopher_amount] == EATING) {
     xbt_cond_wait(forks[id], mutex);
   }
 
   state[id] = EATING;
-  xbt_assert1(state[(id + (philosopher_amount - 1)) % philosopher_amount] ==
-              THINKING
+  xbt_assert1(state[(id + (philosopher_amount - 1)) % philosopher_amount]
+              == THINKING
               && state[(id + 1) % philosopher_amount] == THINKING,
               "Philosopher %d eats at the same time that one of its neighbors!!!",
               id);
@@ -87,8 +87,8 @@ static void philo_thread(void *arg)
 
   /* Enter an endless loop to test the killing facilities */
   INFO1
-    ("Thread %d tries to enter the dead-end; hopefully, the master will cancel it",
-     id);
+      ("Thread %d tries to enter the dead-end; hopefully, the master will cancel it",
+       id);
   xbt_mutex_acquire(dead_end);
   INFO1("Oops, thread %d reached the dead-end. Cancelation failed", id);
 }
@@ -129,7 +129,9 @@ int philosopher(int argc, char *argv[])
   /* spawn threads */
   for (i = 0; i < philosopher_amount; i++) {
     char *name = bprintf("thread %d", i);
-    philosophers[i] = xbt_thread_create(name, philo_thread, &id[i],0/*not joinable*/);
+    philosophers[i] =
+        xbt_thread_create(name, philo_thread, &id[i],
+                          0 /*not joinable */ );
     free(name);
   }
 
index 9c1aab5..18d52a1 100644 (file)
@@ -35,8 +35,9 @@ static void repetitive_action(void)
     gras_timer_cancel_repeat(REPEAT_INTERVAL, repetitive_action);
   }
 
-  INFO1("repetitive_action decrementing globals->still_to_do. New value: %d",
-        globals->still_to_do - 1);
+  INFO1
+      ("repetitive_action decrementing globals->still_to_do. New value: %d",
+       globals->still_to_do - 1);
 
   globals->still_to_do--;       /* should be the last line of the action since value=0 stops the program */
 }                               /* end_of_repetitive_action */
@@ -71,7 +72,8 @@ int client(int argc, char *argv[])
   INFO0("Canceling the delayed_action.");
   gras_timer_cancel_delay(REPEAT_INTERVAL, delayed_action);
 
-  INFO1("Re-programming the delayed_action for after %f sec", DELAY_INTERVAL);
+  INFO1("Re-programming the delayed_action for after %f sec",
+        DELAY_INTERVAL);
   gras_timer_delay(REPEAT_INTERVAL, delayed_action);
 
   while (globals->still_to_do == -1 ||  /* Before delayed action runs */
index 02fcb18..5ab23f0 100644 (file)
 #include "simgrid_config.h"     /* getline */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(actions,
-                 "Messages specific for this msg example");
-int communicator_size=0;
+                             "Messages specific for this msg example");
+int communicator_size = 0;
 
-typedef struct coll_ctr_t{
+typedef struct coll_ctr_t {
   int bcast_counter;
   int reduce_counter;
   int allReduce_counter;
 } *coll_ctr;
 
 /* Helper function */
-static double parse_double(const char *string) {
+static double parse_double(const char *string)
+{
   double value;
   char *endptr;
 
-  value=strtod(string, &endptr);
+  value = strtod(string, &endptr);
   if (*endptr != '\0')
-         THROW1(unknown_error, 0, "%s is not a double", string);
+    THROW1(unknown_error, 0, "%s is not a double", string);
   return value;
 }
 
@@ -40,28 +41,28 @@ static void action_send(xbt_dynar_t action)
   char to[250];
   char *size = xbt_dynar_get_as(action, 3, char *);
   double clock = MSG_get_clock();
-  sprintf (to,"%s_%s", MSG_process_get_name(MSG_process_self()),
-          xbt_dynar_get_as(action, 2, char *));
+  sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()),
+          xbt_dynar_get_as(action, 2, char *));
   //  char *to =  xbt_dynar_get_as(action, 2, char *);
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     name = xbt_str_join(action, " ");
 
   DEBUG2("Entering Send: %s (size: %lg)", name, parse_double(size));
   MSG_task_send(MSG_task_create(name, 0, parse_double(size), NULL), to);
-  DEBUG2("%s %f", name, MSG_get_clock()-clock);
+  DEBUG2("%s %f", name, MSG_get_clock() - clock);
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     free(name);
 }
 
 
 static int spawned_send(int argc, char *argv[])
 {
-  DEBUG3("%s: Sending %s on %s", MSG_process_get_name(MSG_process_self()), 
-       argv[1],argv[0]);
-  MSG_task_send(MSG_task_create(argv[0], 0, parse_double(argv[1]), NULL), 
-               argv[0]);
+  DEBUG3("%s: Sending %s on %s", MSG_process_get_name(MSG_process_self()),
+         argv[1], argv[0]);
+  MSG_task_send(MSG_task_create(argv[0], 0, parse_double(argv[1]), NULL),
+                argv[0]);
   return 0;
 }
 
@@ -74,47 +75,47 @@ static void Isend(xbt_dynar_t action)
   char **myargv;
   m_process_t comm_helper;
   double clock = MSG_get_clock();
-  DEBUG1("Isend on %s: spawn process ", 
-        MSG_process_get_name(MSG_process_self()));
+  DEBUG1("Isend on %s: spawn process ",
+         MSG_process_get_name(MSG_process_self()));
+
+  sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()),
+          xbt_dynar_get_as(action, 2, char *));
+  myargv = (char **) calloc(3, sizeof(char *));
 
-  sprintf (to,"%s_%s", MSG_process_get_name(MSG_process_self()),
-          xbt_dynar_get_as(action, 2, char *));
-  myargv = (char**) calloc (3, sizeof (char*));
-  
   myargv[0] = xbt_strdup(to);
   myargv[1] = xbt_strdup(size);
   myargv[2] = NULL;
 
   //    sprintf(spawn_name,"%s_wait",MSG_process_get_name(MSG_process_self()));
-  sprintf(spawn_name,"%s_wait",to);
+  sprintf(spawn_name, "%s_wait", to);
   comm_helper =
-    MSG_process_create_with_arguments(spawn_name, spawned_send, 
-                                     NULL, MSG_host_self(), 2, myargv);
-  DEBUG2("%s %f",xbt_str_join(action, " "), MSG_get_clock()-clock);
+      MSG_process_create_with_arguments(spawn_name, spawned_send,
+                                        NULL, MSG_host_self(), 2, myargv);
+  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
 }
 
 
 static void action_recv(xbt_dynar_t action)
 {
   char *name = NULL;
-    char mailbox_name[250];
+  char mailbox_name[250];
   m_task_t task = NULL;
   double clock = MSG_get_clock();
   //FIXME: argument of action ignored so far; semantic not clear
   //char *from=xbt_dynar_get_as(action,2,char*);
-  sprintf (mailbox_name,"%s_%s", xbt_dynar_get_as(action, 2, char *),
-          MSG_process_get_name(MSG_process_self()));
+  sprintf(mailbox_name, "%s_%s", xbt_dynar_get_as(action, 2, char *),
+          MSG_process_get_name(MSG_process_self()));
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     name = xbt_str_join(action, " ");
 
   DEBUG1("Receiving: %s", name);
   MSG_task_receive(&task, mailbox_name);
   //  MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
-  DEBUG2("%s %f", name, MSG_get_clock()-clock);
+  DEBUG2("%s %f", name, MSG_get_clock() - clock);
   MSG_task_destroy(task);
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     free(name);
 }
 
@@ -125,9 +126,9 @@ static int spawned_recv(int argc, char *argv[])
   MSG_task_receive(&task, argv[0]);
   DEBUG1("Received %s", MSG_task_get_name(task));
   DEBUG1("waiter on %s", MSG_process_get_name(MSG_process_self()));
-  MSG_task_send(MSG_task_create("waiter",0,0,NULL),
-               MSG_process_get_name(MSG_process_self())); 
-  
+  MSG_task_send(MSG_task_create("waiter", 0, 0, NULL),
+                MSG_process_get_name(MSG_process_self()));
+
   MSG_task_destroy(task);
   return 0;
 }
@@ -140,23 +141,22 @@ static void Irecv(xbt_dynar_t action)
   char mailbox_name[250];
   char **myargv;
   double clock = MSG_get_clock();
-  DEBUG1("Irecv on %s: spawn process ", 
-        MSG_process_get_name(MSG_process_self()));
-
-  sprintf (mailbox_name,"%s_%s", xbt_dynar_get_as(action, 2, char *),
-          MSG_process_get_name(MSG_process_self()));
-  name = bprintf("%s_wait",MSG_process_get_name(MSG_process_self()));
-  myargv = (char**) calloc (2, sizeof (char*));
-  
+  DEBUG1("Irecv on %s: spawn process ",
+         MSG_process_get_name(MSG_process_self()));
+
+  sprintf(mailbox_name, "%s_%s", xbt_dynar_get_as(action, 2, char *),
+          MSG_process_get_name(MSG_process_self()));
+  name = bprintf("%s_wait", MSG_process_get_name(MSG_process_self()));
+  myargv = (char **) calloc(2, sizeof(char *));
+
   myargv[0] = xbt_strdup(mailbox_name);
   myargv[1] = NULL;
-  comm_helper = MSG_process_create_with_arguments(name,spawned_recv,
-                                                 NULL, MSG_host_self(),
-                                                 1, myargv);
+  comm_helper = MSG_process_create_with_arguments(name, spawned_recv,
+                                                  NULL, MSG_host_self(),
+                                                  1, myargv);
+
+  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
 
-  DEBUG2("%s %f",  xbt_str_join(action, " "), 
-      MSG_get_clock()-clock);
   free(name);
 }
 
@@ -167,44 +167,44 @@ static void action_wait(xbt_dynar_t action)
   char task_name[80];
   m_task_t task = NULL;
   double clock = MSG_get_clock();
-  
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     name = xbt_str_join(action, " ");
 
   DEBUG1("Entering %s", name);
-  sprintf(task_name,"%s_wait",MSG_process_get_name(MSG_process_self()));
+  sprintf(task_name, "%s_wait", MSG_process_get_name(MSG_process_self()));
   DEBUG1("wait: %s", task_name);
-  MSG_task_receive(&task,task_name);
+  MSG_task_receive(&task, task_name);
   MSG_task_destroy(task);
-  DEBUG2("%s %f", name,        MSG_get_clock()-clock);
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  DEBUG2("%s %f", name, MSG_get_clock() - clock);
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     free(name);
 }
 
 /* FIXME: that's a poor man's implementation: we should take the message exchanges into account */
-smx_sem_t barrier_semaphore=NULL;
-static void barrier (xbt_dynar_t action)
+smx_sem_t barrier_semaphore = NULL;
+static void barrier(xbt_dynar_t action)
 {
   char *name = NULL;
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     name = xbt_str_join(action, " ");
 
   DEBUG1("Entering barrier: %s", name);
-  if (barrier_semaphore == NULL)  // first arriving on the barrier
+  if (barrier_semaphore == NULL)        // first arriving on the barrier
     barrier_semaphore = SIMIX_sem_init(0);
 
-  if (SIMIX_sem_get_capacity(barrier_semaphore)==-communicator_size +1) { // last arriving
+  if (SIMIX_sem_get_capacity(barrier_semaphore) == -communicator_size + 1) {    // last arriving
     SIMIX_sem_release_forever(barrier_semaphore);
     SIMIX_sem_destroy(barrier_semaphore);
     barrier_semaphore = NULL;
-  } else { // not last
+  } else {                      // not last
     SIMIX_sem_acquire(barrier_semaphore);
   }
 
   DEBUG1("Exiting barrier: %s", name);
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     free(name);
 
 }
@@ -218,129 +218,130 @@ static void reduce(xbt_dynar_t action)
   char **myargv;
   char *comm_size = xbt_dynar_get_as(action, 2, char *);
   char *comp_size = xbt_dynar_get_as(action, 3, char *);
-  m_process_t comm_helper=NULL;
-  m_task_t task=NULL, comp_task=NULL;
-  const charprocess_name;
+  m_process_t comm_helper = NULL;
+  m_task_t task = NULL, comp_task = NULL;
+  const char *process_name;
   double clock = MSG_get_clock();
-  
-  coll_ctr counters =  (coll_ctr) MSG_process_get_data(MSG_process_self());
+
+  coll_ctr counters = (coll_ctr) MSG_process_get_data(MSG_process_self());
 
   xbt_assert0(communicator_size, "Size of Communicator is not defined"
-             ", can't use collective operations");
+              ", can't use collective operations");
 
   process_name = MSG_process_get_name(MSG_process_self());
 
-  if (!counters){
+  if (!counters) {
     DEBUG0("Initialize the counters");
-    counters = (coll_ctr) calloc (1, sizeof(struct coll_ctr_t));
+    counters = (coll_ctr) calloc(1, sizeof(struct coll_ctr_t));
   }
 
   name = bprintf("reduce_%d", counters->reduce_counter++);
 
-  if (!strcmp(process_name, "p0")){
-    DEBUG2("%s: %s is the Root",name, process_name);
-    for(i=1;i<communicator_size;i++){
-      sprintf(spawn_name,"%s_p%d_%s", name, i,
-          MSG_process_get_name(MSG_process_self()));
-      sprintf(task_name,"%s_wait", spawn_name);
-      myargv = (char**) calloc (2, sizeof (char*));
-      
+  if (!strcmp(process_name, "p0")) {
+    DEBUG2("%s: %s is the Root", name, process_name);
+    for (i = 1; i < communicator_size; i++) {
+      sprintf(spawn_name, "%s_p%d_%s", name, i,
+              MSG_process_get_name(MSG_process_self()));
+      sprintf(task_name, "%s_wait", spawn_name);
+      myargv = (char **) calloc(2, sizeof(char *));
+
       myargv[0] = xbt_strdup(spawn_name);
       myargv[1] = NULL;
 
-      comm_helper = 
-       MSG_process_create_with_arguments(task_name, spawned_recv, 
-                                         NULL, MSG_host_self(),
-                                         1, myargv);
+      comm_helper =
+          MSG_process_create_with_arguments(task_name, spawned_recv,
+                                            NULL, MSG_host_self(),
+                                            1, myargv);
     }
 
-    for(i=1;i<communicator_size;i++){
-      sprintf(task_name,"%s_p%d_p0_wait", name, i);
-      MSG_task_receive(&task,task_name);
+    for (i = 1; i < communicator_size; i++) {
+      sprintf(task_name, "%s_p%d_p0_wait", name, i);
+      MSG_task_receive(&task, task_name);
       MSG_task_destroy(task);
-      task=NULL;
+      task = NULL;
     }
 
-    comp_task = 
-      MSG_task_create("reduce_comp", parse_double(comp_size), 0, NULL);
+    comp_task =
+        MSG_task_create("reduce_comp", parse_double(comp_size), 0, NULL);
     DEBUG1("%s: computing 'reduce_comp'", name);
     MSG_task_execute(comp_task);
     MSG_task_destroy(comp_task);
     DEBUG1("%s: computed", name);
   } else {
     DEBUG2("%s: %s sends", name, process_name);
-    sprintf(task_name,"%s_%s_p0", name, process_name);
+    sprintf(task_name, "%s_%s_p0", name, process_name);
     DEBUG1("put on %s", task_name);
     MSG_task_send(MSG_task_create(name, 0, parse_double(comm_size), NULL),
-                 task_name);
+                  task_name);
   }
 
-  MSG_process_set_data(MSG_process_self(), (void*)counters);
-  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock()-clock);
+  MSG_process_set_data(MSG_process_self(), (void *) counters);
+  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
   free(name);
 }
 
-static void bcast (xbt_dynar_t action)
+static void bcast(xbt_dynar_t action)
 {
   int i;
   char *name;
-  const charprocess_name;
+  const char *process_name;
   char task_name[80];
   char spawn_name[80];
   char **myargv;
-  m_process_t comm_helper=NULL;
-  m_task_t task=NULL;
+  m_process_t comm_helper = NULL;
+  m_task_t task = NULL;
   char *size = xbt_dynar_get_as(action, 2, char *);
-  coll_ctr counters =  (coll_ctr) MSG_process_get_data(MSG_process_self());
+  coll_ctr counters = (coll_ctr) MSG_process_get_data(MSG_process_self());
   double clock = MSG_get_clock();
-  
+
   xbt_assert0(communicator_size, "Size of Communicator is not defined"
-             ", can't use collective operations");
+              ", can't use collective operations");
 
 
   process_name = MSG_process_get_name(MSG_process_self());
-  if (!counters){
+  if (!counters) {
     DEBUG0("Initialize the counters");
-    counters = (coll_ctr) calloc (1, sizeof(struct coll_ctr_t));
+    counters = (coll_ctr) calloc(1, sizeof(struct coll_ctr_t));
   }
 
   name = bprintf("bcast_%d", counters->bcast_counter++);
-  if (!strcmp(process_name, "p0")){
-    DEBUG2("%s: %s is the Root",name, process_name);
+  if (!strcmp(process_name, "p0")) {
+    DEBUG2("%s: %s is the Root", name, process_name);
 
-    for(i=1;i<communicator_size;i++){
-      myargv = (char**) calloc (3, sizeof (char*));
+    for (i = 1; i < communicator_size; i++) {
+      myargv = (char **) calloc(3, sizeof(char *));
       myargv[0] = xbt_strdup(name);
       myargv[1] = xbt_strdup(size);
       myargv[2] = NULL;
 
-      sprintf(spawn_name,"%s_%d", myargv[0], i);
-      comm_helper = 
-       MSG_process_create_with_arguments(spawn_name, spawned_send, 
-                                         NULL, MSG_host_self(), 2, myargv);
+      sprintf(spawn_name, "%s_%d", myargv[0], i);
+      comm_helper =
+          MSG_process_create_with_arguments(spawn_name, spawned_send,
+                                            NULL, MSG_host_self(), 2,
+                                            myargv);
     }
-    
-    for(i=1;i<communicator_size;i++){
-      sprintf(task_name,"p%d_wait", i);
+
+    for (i = 1; i < communicator_size; i++) {
+      sprintf(task_name, "p%d_wait", i);
       DEBUG1("get on %s", task_name);
-      MSG_task_receive(&task,task_name);      
+      MSG_task_receive(&task, task_name);
       MSG_task_destroy(task);
-      task=NULL;
+      task = NULL;
     }
     DEBUG2("%s: all messages sent by %s have been received",
-         name, process_name);
+           name, process_name);
   } else {
     DEBUG2("%s: %s receives", name, process_name);
     MSG_task_receive(&task, name);
     MSG_task_destroy(task);
-    DEBUG2("%s: %s has received", name,process_name);
-    sprintf(task_name,"%s_wait", process_name);
+    DEBUG2("%s: %s has received", name, process_name);
+    sprintf(task_name, "%s_wait", process_name);
     DEBUG1("put on %s", task_name);
-    MSG_task_send(MSG_task_create("waiter",0,0,NULL),task_name);
+    MSG_task_send(MSG_task_create("waiter", 0, 0, NULL), task_name);
   }
 
-  MSG_process_set_data(MSG_process_self(), (void*)counters);
-  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock()-clock);
+  MSG_process_set_data(MSG_process_self(), (void *) counters);
+  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
   free(name);
 }
 
@@ -351,14 +352,14 @@ static void action_sleep(xbt_dynar_t action)
   char *duration = xbt_dynar_get_as(action, 2, char *);
   double clock = MSG_get_clock();
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     name = xbt_str_join(action, " ");
 
   DEBUG1("Entering %s", name);
   MSG_process_sleep(parse_double(duration));
-  DEBUG2("%s %f ", name, MSG_get_clock()-clock);
+  DEBUG2("%s %f ", name, MSG_get_clock() - clock);
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     free(name);
 }
 
@@ -371,96 +372,98 @@ static void allReduce(xbt_dynar_t action)
   char **myargv;
   char *comm_size = xbt_dynar_get_as(action, 2, char *);
   char *comp_size = xbt_dynar_get_as(action, 3, char *);
-  m_process_t comm_helper=NULL;
-  m_task_t task=NULL, comp_task=NULL;
-  const charprocess_name;
+  m_process_t comm_helper = NULL;
+  m_task_t task = NULL, comp_task = NULL;
+  const char *process_name;
   double clock = MSG_get_clock();
-  coll_ctr counters =  (coll_ctr) MSG_process_get_data(MSG_process_self());
+
+  coll_ctr counters = (coll_ctr) MSG_process_get_data(MSG_process_self());
 
   xbt_assert0(communicator_size, "Size of Communicator is not defined"
-             ", can't use collective operations");
+              ", can't use collective operations");
 
   process_name = MSG_process_get_name(MSG_process_self());
 
-  if (!counters){
+  if (!counters) {
     DEBUG0("Initialize the counters");
-    counters = (coll_ctr) calloc (1, sizeof(struct coll_ctr_t));
+    counters = (coll_ctr) calloc(1, sizeof(struct coll_ctr_t));
   }
 
   name = bprintf("allReduce_%d", counters->allReduce_counter++);
 
-  if (!strcmp(process_name, "p0")){
-    DEBUG2("%s: %s is the Root",name, process_name);
-    for(i=1;i<communicator_size;i++){
-      sprintf(spawn_name,"%s_p%d_%s", name, i,
-          MSG_process_get_name(MSG_process_self()));
-      sprintf(task_name,"%s_wait", spawn_name);
-      myargv = (char**) calloc (2, sizeof (char*));
-      
+  if (!strcmp(process_name, "p0")) {
+    DEBUG2("%s: %s is the Root", name, process_name);
+    for (i = 1; i < communicator_size; i++) {
+      sprintf(spawn_name, "%s_p%d_%s", name, i,
+              MSG_process_get_name(MSG_process_self()));
+      sprintf(task_name, "%s_wait", spawn_name);
+      myargv = (char **) calloc(2, sizeof(char *));
+
       myargv[0] = xbt_strdup(spawn_name);
       myargv[1] = NULL;
 
-      comm_helper = 
-       MSG_process_create_with_arguments(task_name, spawned_recv, 
-                                         NULL, MSG_host_self(),
-                                         1, myargv);
+      comm_helper =
+          MSG_process_create_with_arguments(task_name, spawned_recv,
+                                            NULL, MSG_host_self(),
+                                            1, myargv);
     }
 
-    for(i=1;i<communicator_size;i++){
-      sprintf(task_name,"%s_p%d_p0_wait", name, i);
-      MSG_task_receive(&task,task_name);
+    for (i = 1; i < communicator_size; i++) {
+      sprintf(task_name, "%s_p%d_p0_wait", name, i);
+      MSG_task_receive(&task, task_name);
       MSG_task_destroy(task);
-      task=NULL;
+      task = NULL;
     }
 
-    comp_task = 
-      MSG_task_create("allReduce_comp", parse_double(comp_size), 0, NULL);
+    comp_task =
+        MSG_task_create("allReduce_comp", parse_double(comp_size), 0,
+                        NULL);
     DEBUG1("%s: computing 'reduce_comp'", name);
     MSG_task_execute(comp_task);
     MSG_task_destroy(comp_task);
     DEBUG1("%s: computed", name);
 
-    for(i=1;i<communicator_size;i++){
-      myargv = (char**) calloc (3, sizeof (char*));
+    for (i = 1; i < communicator_size; i++) {
+      myargv = (char **) calloc(3, sizeof(char *));
       myargv[0] = xbt_strdup(name);
       myargv[1] = xbt_strdup(comm_size);
       myargv[2] = NULL;
 
-      sprintf(spawn_name,"%s_%d", myargv[0], i);
-      comm_helper = 
-       MSG_process_create_with_arguments(spawn_name, spawned_send, 
-                                         NULL, MSG_host_self(), 2, myargv);
+      sprintf(spawn_name, "%s_%d", myargv[0], i);
+      comm_helper =
+          MSG_process_create_with_arguments(spawn_name, spawned_send,
+                                            NULL, MSG_host_self(), 2,
+                                            myargv);
     }
-    
-    for(i=1;i<communicator_size;i++){
-      sprintf(task_name,"p%d_wait", i);
+
+    for (i = 1; i < communicator_size; i++) {
+      sprintf(task_name, "p%d_wait", i);
       DEBUG1("get on %s", task_name);
-      MSG_task_receive(&task,task_name);      
+      MSG_task_receive(&task, task_name);
       MSG_task_destroy(task);
-      task=NULL;
+      task = NULL;
     }
     DEBUG2("%s: all messages sent by %s have been received",
-         name, process_name);
+           name, process_name);
 
   } else {
     DEBUG2("%s: %s sends", name, process_name);
-    sprintf(task_name,"%s_%s_p0", name, process_name);
+    sprintf(task_name, "%s_%s_p0", name, process_name);
     DEBUG1("put on %s", task_name);
     MSG_task_send(MSG_task_create(name, 0, parse_double(comm_size), NULL),
-                 task_name);
+                  task_name);
 
     MSG_task_receive(&task, name);
     MSG_task_destroy(task);
-    DEBUG2("%s: %s has received", name,process_name);
-    sprintf(task_name,"%s_wait", process_name);
+    DEBUG2("%s: %s has received", name, process_name);
+    sprintf(task_name, "%s_wait", process_name);
     DEBUG1("put on %s", task_name);
-    MSG_task_send(MSG_task_create("waiter",0,0,NULL),task_name);
+    MSG_task_send(MSG_task_create("waiter", 0, 0, NULL), task_name);
 
   }
 
-  MSG_process_set_data(MSG_process_self(), (void*)counters);
-  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock()-clock);
+  MSG_process_set_data(MSG_process_self(), (void *) counters);
+  DEBUG2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
   free(name);
 }
 
@@ -472,18 +475,18 @@ static void comm_size(xbt_dynar_t action)
 
 static void compute(xbt_dynar_t action)
 {
-  char *name=NULL;
+  char *name = NULL;
   char *amout = xbt_dynar_get_as(action, 2, char *);
   m_task_t task = MSG_task_create(name, parse_double(amout), 0, NULL);
   double clock = MSG_get_clock();
 
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     name = xbt_str_join(action, " ");
   DEBUG1("Entering %s", name);
   MSG_task_execute(task);
   MSG_task_destroy(task);
-  DEBUG2("%s %f", name, MSG_get_clock()-clock);
-  if (XBT_LOG_ISENABLED(actions,xbt_log_priority_debug))
+  DEBUG2("%s %f", name, MSG_get_clock() - clock);
+  if (XBT_LOG_ISENABLED(actions, xbt_log_priority_debug))
     free(name);
 }
 
@@ -491,15 +494,18 @@ static void compute(xbt_dynar_t action)
 int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
-  
+
   /* Check the given arguments */
   MSG_global_init(&argc, argv);
   if (argc < 3) {
-    printf("Usage: %s platform_file deployment_file [action_files]\n", argv[0]);
-    printf("example: %s msg_platform.xml msg_deployment.xml actions # if all actions are in the same file\n",
-           argv[0]);
-    printf("example: %s msg_platform.xml msg_deployment.xml # if actions are in separate files, specified in deployment\n",
+    printf("Usage: %s platform_file deployment_file [action_files]\n",
            argv[0]);
+    printf
+        ("example: %s msg_platform.xml msg_deployment.xml actions # if all actions are in the same file\n",
+         argv[0]);
+    printf
+        ("example: %s msg_platform.xml msg_deployment.xml # if actions are in separate files, specified in deployment\n",
+         argv[0]);
     exit(1);
   }
 
@@ -525,7 +531,7 @@ int main(int argc, char *argv[])
 
 
   /* Actually do the simulation using MSG_action_trace_run */
-  res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here
+  res = MSG_action_trace_run(argv[3]);  // it's ok to pass a NULL argument here
 
   INFO1("Simulation time %g", MSG_get_clock());
   MSG_clean();
index 9cad168..4258bfb 100644 (file)
@@ -5,13 +5,14 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
-#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 
 typedef enum {
@@ -22,218 +23,220 @@ typedef enum {
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
 int forwarder(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 
-#define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */
+#define FINALIZE ((void*)221297)        /* a magic number to tell people to stop working */
 
 /** Emitter function  */
 int master(int argc, char *argv[])
 {
-       int alias_count = 0;
-       char** aliases = NULL;
-       m_task_t *todo = NULL;
-       int number_of_tasks = 0;
-       double task_comp_size = 0;
-       double task_comm_size = 0;
-
-
-       int i;
-
-       xbt_assert1(sscanf(argv[1],"%d", &number_of_tasks),"Invalid argument %s\n",argv[1]);
-       xbt_assert1(sscanf(argv[2],"%lg", &task_comp_size),"Invalid argument %s\n",argv[2]);
-       xbt_assert1(sscanf(argv[3],"%lg", &task_comm_size),"Invalid argument %s\n",argv[3]);
-
-       {
-               /*  Task creation */
-               char sprintf_buffer[64];
-
-               todo = xbt_new0(m_task_t,number_of_tasks);
-
-               for (i = 0; i < number_of_tasks; i++) 
-               {
-                       sprintf(sprintf_buffer, "Task_%d", i);
-                       todo[i] = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
-               }
-       }
-
-       {                  
-               /* Process organisation */
-               alias_count = argc - 4;
-               aliases = xbt_new0(char*,alias_count);
-
-               for(i = 4; i < argc; i++) 
-               {
-                       aliases[i-4] = strdup(argv[i]);
-               }
-       }
-
-       INFO2("Got %d aliases and %d tasks to process", alias_count,number_of_tasks);
-       
-       for (i = 0; i < alias_count; i++)
-               DEBUG1("%s", aliases[i]);
-
-       for (i = 0; i < number_of_tasks; i++) 
-       {
-               INFO2("Sending \"%s\" to \"%s\"",todo[i]->name,aliases[i % alias_count]);
-               
-               if(!strcmp(MSG_host_get_name(MSG_host_self()), aliases[i % alias_count])) 
-               {
-                       INFO0("Hey ! It's me ! :)");
-               }
-
-               MSG_task_send(todo[i], aliases[i % alias_count]);
-               INFO0("Sent");
-       }
-
-       INFO0("All tasks have been dispatched. Let's tell everybody the computation is over.");
-       
-       for (i = 0; i < alias_count; i++) 
-               MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE),aliases[i]);
-
-       INFO0("Goodbye now!");
-       
-       for(i = 0; i < alias_count; i++)
-               free(aliases[i]);
-               
-       free(aliases);
-       free(todo);
-       return 0;
-} /* end_of_master */
+  int alias_count = 0;
+  char **aliases = NULL;
+  m_task_t *todo = NULL;
+  int number_of_tasks = 0;
+  double task_comp_size = 0;
+  double task_comm_size = 0;
+
+
+  int i;
+
+  xbt_assert1(sscanf(argv[1], "%d", &number_of_tasks),
+              "Invalid argument %s\n", argv[1]);
+  xbt_assert1(sscanf(argv[2], "%lg", &task_comp_size),
+              "Invalid argument %s\n", argv[2]);
+  xbt_assert1(sscanf(argv[3], "%lg", &task_comm_size),
+              "Invalid argument %s\n", argv[3]);
+
+  {
+    /*  Task creation */
+    char sprintf_buffer[64];
+
+    todo = xbt_new0(m_task_t, number_of_tasks);
+
+    for (i = 0; i < number_of_tasks; i++) {
+      sprintf(sprintf_buffer, "Task_%d", i);
+      todo[i] =
+          MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                          NULL);
+    }
+  }
+
+  {
+    /* Process organisation */
+    alias_count = argc - 4;
+    aliases = xbt_new0(char *, alias_count);
+
+    for (i = 4; i < argc; i++) {
+      aliases[i - 4] = strdup(argv[i]);
+    }
+  }
+
+  INFO2("Got %d aliases and %d tasks to process", alias_count,
+        number_of_tasks);
+
+  for (i = 0; i < alias_count; i++)
+    DEBUG1("%s", aliases[i]);
+
+  for (i = 0; i < number_of_tasks; i++) {
+    INFO2("Sending \"%s\" to \"%s\"", todo[i]->name,
+          aliases[i % alias_count]);
+
+    if (!strcmp
+        (MSG_host_get_name(MSG_host_self()), aliases[i % alias_count])) {
+      INFO0("Hey ! It's me ! :)");
+    }
+
+    MSG_task_send(todo[i], aliases[i % alias_count]);
+    INFO0("Sent");
+  }
+
+  INFO0
+      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+
+  for (i = 0; i < alias_count; i++)
+    MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE), aliases[i]);
+
+  INFO0("Goodbye now!");
+
+  for (i = 0; i < alias_count; i++)
+    free(aliases[i]);
+
+  free(aliases);
+  free(todo);
+  return 0;
+}                               /* end_of_master */
 
 /** Receiver function  */
 int slave(int argc, char *argv[])
 {
-       m_task_t task = NULL;
-       int res;
-       
-       while(1) 
-       {
-               res = MSG_task_receive(&(task), MSG_host_get_name(MSG_host_self()));
-               xbt_assert0(res == MSG_OK, "MSG_task_receive failed");
-       
-               INFO1("Received \"%s\"", MSG_task_get_name(task));
-       
-               if (!strcmp(MSG_task_get_name(task),"finalize")) 
-               {
-                       MSG_task_destroy(task);
-                       break;
-               }
-
-               INFO1("Processing \"%s\"", MSG_task_get_name(task));
-               MSG_task_execute(task);
-               INFO1("\"%s\" done", MSG_task_get_name(task));
-               MSG_task_destroy(task);
-               task = NULL;
-       }
-       
-       INFO0("I'm done. See you!");
-       return 0;
-} /* end_of_slave */
+  m_task_t task = NULL;
+  int res;
+
+  while (1) {
+    res = MSG_task_receive(&(task), MSG_host_get_name(MSG_host_self()));
+    xbt_assert0(res == MSG_OK, "MSG_task_receive failed");
+
+    INFO1("Received \"%s\"", MSG_task_get_name(task));
+
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
+    }
+
+    INFO1("Processing \"%s\"", MSG_task_get_name(task));
+    MSG_task_execute(task);
+    INFO1("\"%s\" done", MSG_task_get_name(task));
+    MSG_task_destroy(task);
+    task = NULL;
+  }
+
+  INFO0("I'm done. See you!");
+  return 0;
+}                               /* end_of_slave */
 
 /** Forwarder function */
 int forwarder(int argc, char *argv[])
 {
-       int i;
-       int alias_count;
-       char** aliases;
-       
-       {                  /* Process organisation */
-               alias_count = argc - 1;
-               aliases = xbt_new0(char*,alias_count);
-       
-               for (i = 1; i < argc; i++) 
-                       aliases[i-1] =strdup(argv[i]);
-       }
-
-       i=0;
-       
-       while(1) 
-       {
-               m_task_t task = NULL;
-               int a;
-               
-               a = MSG_task_receive(&(task),MSG_host_get_name(MSG_host_self()));
-               
-               if (a == MSG_OK) 
-               {
-                       INFO1("Received \"%s\"", MSG_task_get_name(task));
-                       
-                       if(MSG_task_get_data(task)==FINALIZE) 
-                       {
-                               INFO0("All tasks have been dispatched. Let's tell everybody the computation is over.");
-                               
-                               for (i = 0; i < alias_count; i++) 
-                                       MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE),aliases[i]);
-                               
-                               MSG_task_destroy(task);
-                               break;
-                       }
-               
-                       INFO2("Sending \"%s\" to \"%s\"",MSG_task_get_name(task),aliases[i% alias_count]);
-                       MSG_task_send(task, aliases[i % alias_count]);
-                       i++;
-               } 
-               else 
-               {
-                       INFO0("Hey ?! What's up ? ");
-                       xbt_assert0(0,"Unexpected behavior");
-               }
-       }
-       
-       for(i = 0; i < alias_count; i++)
-               free(aliases[i]);
-
-       INFO0("I'm done. See you!");
-       return 0;
-       
-} /* end_of_forwarder */
+  int i;
+  int alias_count;
+  char **aliases;
+
+  {                             /* Process organisation */
+    alias_count = argc - 1;
+    aliases = xbt_new0(char *, alias_count);
+
+    for (i = 1; i < argc; i++)
+      aliases[i - 1] = strdup(argv[i]);
+  }
+
+  i = 0;
+
+  while (1) {
+    m_task_t task = NULL;
+    int a;
+
+    a = MSG_task_receive(&(task), MSG_host_get_name(MSG_host_self()));
+
+    if (a == MSG_OK) {
+      INFO1("Received \"%s\"", MSG_task_get_name(task));
+
+      if (MSG_task_get_data(task) == FINALIZE) {
+        INFO0
+            ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+
+        for (i = 0; i < alias_count; i++)
+          MSG_task_send(MSG_task_create("finalize", 0, 0, FINALIZE),
+                        aliases[i]);
+
+        MSG_task_destroy(task);
+        break;
+      }
+
+      INFO2("Sending \"%s\" to \"%s\"", MSG_task_get_name(task),
+            aliases[i % alias_count]);
+      MSG_task_send(task, aliases[i % alias_count]);
+      i++;
+    } else {
+      INFO0("Hey ?! What's up ? ");
+      xbt_assert0(0, "Unexpected behavior");
+    }
+  }
+
+  for (i = 0; i < alias_count; i++)
+    free(aliases[i]);
+
+  INFO0("I'm done. See you!");
+  return 0;
+
+}                               /* end_of_forwarder */
 
 /** Test function */
-MSG_error_t test_all(const char *platform_file,const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
-       MSG_error_t res = MSG_OK;
-
-       {       /*  Simulation setting */
-               MSG_set_channel_number(MAX_CHANNEL);
-               MSG_paje_output("msg_test.trace");
-               MSG_create_environment(platform_file);
-       }
-       
-       {
-               /*   Application deployment */
-               MSG_function_register("master", master);
-               MSG_function_register("slave", slave);
-               MSG_function_register("forwarder", forwarder);
-               MSG_launch_application(application_file);
-       }
-       
-       res = MSG_main();
-
-       INFO1("Simulation time %g",MSG_get_clock());
-       return res;
-} /* end_of_test_all */
+  MSG_error_t res = MSG_OK;
+
+  {                             /*  Simulation setting */
+    MSG_set_channel_number(MAX_CHANNEL);
+    MSG_paje_output("msg_test.trace");
+    MSG_create_environment(platform_file);
+  }
+
+  {
+    /*   Application deployment */
+    MSG_function_register("master", master);
+    MSG_function_register("slave", slave);
+    MSG_function_register("forwarder", forwarder);
+    MSG_launch_application(application_file);
+  }
+
+  res = MSG_main();
+
+  INFO1("Simulation time %g", MSG_get_clock());
+  return res;
+}                               /* end_of_test_all */
 
 
 /** Main function */
 int main(int argc, char *argv[])
 {
-       MSG_error_t res = MSG_OK;
-       
-       MSG_global_init(&argc,argv);
-       
-       if (argc < 3) 
-       {
-               printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-               printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-               exit(1);
-       }
-       
-       res = test_all(argv[1],argv[2]);
-       MSG_clean();
-       
-       if(res==MSG_OK)
-               return 0;
-       else
-               return 1;
-} /* end_of_main */
+  MSG_error_t res = MSG_OK;
+
+  MSG_global_init(&argc, argv);
+
+  if (argc < 3) {
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
+  }
+
+  res = test_all(argv[1], argv[2]);
+  MSG_clean();
+
+  if (res == MSG_OK)
+    return 0;
+  else
+    return 1;
+}                               /* end_of_main */
index 22adcee..c288484 100644 (file)
@@ -15,7 +15,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 typedef enum {
   PORT_22 = 0,
@@ -58,14 +59,14 @@ int master(int argc, char *argv[])
   id = atoi(argv[3]);
   sprintf(id_alias, "flow_%d", id);
   slavenames[id] = slavename;
-  TRACE_category (id_alias);
+  TRACE_category(id_alias);
 
   masternames[id] = MSG_host_get_name(MSG_host_self());
 
   {                             /*  Task creation.  */
     char sprintf_buffer[64] = "Task_0";
     todo = MSG_task_create(sprintf_buffer, 0, task_comm_size, NULL);
-    TRACE_msg_set_task_category(todo,id_alias);
+    TRACE_msg_set_task_category(todo, id_alias);
     //keep track of running tasks
     gl_task_array[id] = todo;
     gl_data_size[id] = task_comm_size;
@@ -83,10 +84,12 @@ int master(int argc, char *argv[])
 
 
   if (!bool_printed) {
-    INFO3("Send completed (to %s). Transfer time: %f\t Agregate bandwidth: %f",
-         slave->name, (end_time - start_time),
-         task_comm_size / (end_time - start_time));
-    INFO2("Completed peer: %s time: %f", slave->name, (end_time - start_time));
+    INFO3
+        ("Send completed (to %s). Transfer time: %f\t Agregate bandwidth: %f",
+         slave->name, (end_time - start_time),
+         task_comm_size / (end_time - start_time));
+    INFO2("Completed peer: %s time: %f", slave->name,
+          (end_time - start_time));
   }
   return 0;
 }                               /* end_of_master */
@@ -99,7 +102,7 @@ int slave(int argc, char *argv[])
   int a;
   int id = 0;
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-  int limited_latency=0;
+  int limited_latency = 0;
 #endif
   double remaining = 0;
   char id_alias[10];
@@ -127,42 +130,44 @@ int slave(int argc, char *argv[])
       if (gl_task_array[id] == NULL) {
       } else if (gl_task_array[id] == task) {
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-         limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]);
-          if(limited_latency){
-                 INFO1("WARNING FLOW[%d] is limited by latency!!", id);
-          }
+        limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]);
+        if (limited_latency) {
+          INFO1("WARNING FLOW[%d] is limited by latency!!", id);
+        }
 #endif
-         INFO5
-          ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
-           id, gl_data_size[id] / elapsed_time, masternames[id],
-           slavenames[id], 0.0);
+        INFO5
+            ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
+             id, gl_data_size[id] / elapsed_time, masternames[id],
+             slavenames[id], 0.0);
       } else {
-        remaining = MSG_task_get_remaining_communication(gl_task_array[id]);
+        remaining =
+            MSG_task_get_remaining_communication(gl_task_array[id]);
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-       limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]);
+        limited_latency = MSG_task_is_latency_bounded(gl_task_array[id]);
 
-        if(limited_latency){
-         INFO1("WARNING FLOW[%d] is limited by latency!!", id);
+        if (limited_latency) {
+          INFO1("WARNING FLOW[%d] is limited by latency!!", id);
         }
 #endif
         INFO5
-          ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
-           id, (gl_data_size[id] - remaining) / elapsed_time, masternames[id],
-           slavenames[id], remaining);
+            ("===> Estimated Bw of FLOW[%d] : %f ;  message from %s to %s  with remaining : %f",
+             id, (gl_data_size[id] - remaining) / elapsed_time,
+             masternames[id], slavenames[id], remaining);
       }
 
     }
-  }  
+  }
   char mark[100];
-  snprintf (mark, 100, "flow_%d_finished", trace_id);
-  TRACE_mark ("endmark", mark);
+  snprintf(mark, 100, "flow_%d_finished", trace_id);
+  TRACE_mark("endmark", mark);
 
   MSG_task_destroy(task);
   return 0;
 }                               /* end_of_slave */
 
 /** Test function */
-MSG_error_t test_all(const char *platform_file, const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
@@ -193,14 +198,14 @@ int main(int argc, char *argv[])
     exit(1);
   }
 
-  TRACE_start ();
-  TRACE_declare_mark ("endmark");
+  TRACE_start();
+  TRACE_declare_mark("endmark");
 
   res = test_all(argv[1], argv[2]);
 
   MSG_clean();
 
-  TRACE_end ();
+  TRACE_end();
 
   if (res == MSG_OK)
     return 0;
index 0e2c21d..ccf0ac4 100755 (executable)
@@ -5,18 +5,20 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
-#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int sender(int argc, char *argv[]);
 int receiver(int argc, char *argv[]);
 
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Sender function  */
 int sender(int argc, char *argv[])
@@ -28,62 +30,57 @@ int sender(int argc, char *argv[])
   double sleep_start_time = atof(argv[5]);
   double sleep_test_time = atof(argv[6]);
 
-  INFO2("sleep_start_time : %f , sleep_test_time : %f",sleep_start_time,sleep_test_time);
+  INFO2("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
+        sleep_test_time);
 
   msg_comm_t comm = NULL;
   int i;
   m_task_t task = NULL;
-  MSG_process_sleep (sleep_start_time);
-  for (i = 0; i < number_of_tasks; i++)
-  {
-       char mailbox[256];
-       char sprintf_buffer[256];
+  MSG_process_sleep(sleep_start_time);
+  for (i = 0; i < number_of_tasks; i++) {
+    char mailbox[256];
+    char sprintf_buffer[256];
 
-    sprintf(mailbox,"receiver-%ld",i % receivers_count);
+    sprintf(mailbox, "receiver-%ld", i % receivers_count);
     sprintf(sprintf_buffer, "Task_%d", i);
 
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
-    comm=MSG_task_isend(task, mailbox);
-    INFO2("Send to receiver-%ld Task_%d",i % receivers_count,i);
-
-    if(sleep_test_time == 0)
-    {
-       MSG_comm_wait(comm,-1);
-    }
-    else
-    {
-       while(MSG_comm_test(comm) == 0){
-               MSG_process_sleep (sleep_test_time);
-       };
-       MSG_comm_destroy(comm);
+    task =
+        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                        NULL);
+    comm = MSG_task_isend(task, mailbox);
+    INFO2("Send to receiver-%ld Task_%d", i % receivers_count, i);
+
+    if (sleep_test_time == 0) {
+      MSG_comm_wait(comm, -1);
+    } else {
+      while (MSG_comm_test(comm) == 0) {
+        MSG_process_sleep(sleep_test_time);
+      };
+      MSG_comm_destroy(comm);
     }
 
   }
 
-  for (i = 0; i < receivers_count; i++)
-  {
+  for (i = 0; i < receivers_count; i++) {
     char mailbox[80];
-    sprintf(mailbox,"receiver-%ld",i % receivers_count);
-    task = MSG_task_create ("finalize", 0, 0, 0);
+    sprintf(mailbox, "receiver-%ld", i % receivers_count);
+    task = MSG_task_create("finalize", 0, 0, 0);
     comm = MSG_task_isend(task, mailbox);
-    INFO1("Send to receiver-%ld finalize",i % receivers_count);
-    if(sleep_test_time == 0)
-    {
-       MSG_comm_wait(comm,-1);
-    }
-    else
-    {
-       while(MSG_comm_test(comm) == 0){
-               MSG_process_sleep (sleep_test_time);
-       };
-       MSG_comm_destroy(comm);
+    INFO1("Send to receiver-%ld finalize", i % receivers_count);
+    if (sleep_test_time == 0) {
+      MSG_comm_wait(comm, -1);
+    } else {
+      while (MSG_comm_test(comm) == 0) {
+        MSG_process_sleep(sleep_test_time);
+      };
+      MSG_comm_destroy(comm);
     }
 
   }
 
   INFO0("Goodbye now!");
   return 0;
-} /* end_of_sender */
+}                               /* end_of_sender */
 
 /** Receiver function  */
 int receiver(int argc, char *argv[])
@@ -95,35 +92,33 @@ int receiver(int argc, char *argv[])
   msg_comm_t res_irecv;
   double sleep_start_time = atof(argv[2]);
   double sleep_test_time = atof(argv[3]);
-  INFO2("sleep_start_time : %f , sleep_test_time : %f",sleep_start_time,sleep_test_time);
-
-  xbt_assert1(sscanf(argv[1],"%d", &id),
-        "Invalid argument %s\n",argv[1]);
-
-  MSG_process_sleep (sleep_start_time);
-
-  sprintf(mailbox,"receiver-%d",id);
-  while(1) {
-       res_irecv = MSG_task_irecv(&(task), mailbox);
-       INFO0("Wait to receive a task");
-
-    if(sleep_test_time == 0)
-    {
-       res = MSG_comm_wait(res_irecv,-1);
-       xbt_assert0(res == MSG_OK, "MSG_task_get failed");
-    }
-    else
-    {
-       while(MSG_comm_test(res_irecv) == 0){
-               MSG_process_sleep (sleep_test_time);
-       };
-       MSG_comm_destroy(res_irecv);
+  INFO2("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time,
+        sleep_test_time);
+
+  xbt_assert1(sscanf(argv[1], "%d", &id),
+              "Invalid argument %s\n", argv[1]);
+
+  MSG_process_sleep(sleep_start_time);
+
+  sprintf(mailbox, "receiver-%d", id);
+  while (1) {
+    res_irecv = MSG_task_irecv(&(task), mailbox);
+    INFO0("Wait to receive a task");
+
+    if (sleep_test_time == 0) {
+      res = MSG_comm_wait(res_irecv, -1);
+      xbt_assert0(res == MSG_OK, "MSG_task_get failed");
+    } else {
+      while (MSG_comm_test(res_irecv) == 0) {
+        MSG_process_sleep(sleep_test_time);
+      };
+      MSG_comm_destroy(res_irecv);
     }
 
-       INFO1("Received \"%s\"", MSG_task_get_name(task));
-       if (!strcmp(MSG_task_get_name(task),"finalize")) {
-         MSG_task_destroy(task);
-         break;
+    INFO1("Received \"%s\"", MSG_task_get_name(task));
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
     }
 
     INFO1("Processing \"%s\"", MSG_task_get_name(task));
@@ -134,29 +129,29 @@ int receiver(int argc, char *argv[])
   }
   INFO0("I'm done. See you!");
   return 0;
-} /* end_of_receiver */
+}                               /* end_of_receiver */
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
   /* MSG_config("workstation/model","KCCFLN05"); */
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("sender", sender);
     MSG_function_register("receiver", receiver);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
-} /* end_of_test_all */
+}                               /* end_of_test_all */
 
 
 /** Main function */
@@ -164,18 +159,18 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-  res = test_all(argv[1],argv[2]);
-   SIMIX_message_sizes_output("toto.txt");
+  res = test_all(argv[1], argv[2]);
+  SIMIX_message_sizes_output("toto.txt");
   MSG_clean();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index 0625a15..6a0d0fc 100755 (executable)
@@ -5,18 +5,20 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
-#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int sender(int argc, char *argv[]);
 int receiver(int argc, char *argv[]);
 
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Sender function  */
 int sender(int argc, char *argv[])
@@ -26,34 +28,35 @@ int sender(int argc, char *argv[])
   double task_comm_size = atof(argv[3]);
   long receivers_count = atol(argv[4]);
 
-  msg_comm_t *comm = malloc((number_of_tasks+receivers_count)*sizeof(msg_comm_t));
+  msg_comm_t *comm =
+      malloc((number_of_tasks + receivers_count) * sizeof(msg_comm_t));
   int i;
   m_task_t task = NULL;
-  for (i = 0; i < number_of_tasks; i++)
-  {
-       char mailbox[256];
-       char sprintf_buffer[256];
-    sprintf(mailbox,"receiver-%ld",i % receivers_count);
+  for (i = 0; i < number_of_tasks; i++) {
+    char mailbox[256];
+    char sprintf_buffer[256];
+    sprintf(mailbox, "receiver-%ld", i % receivers_count);
     sprintf(sprintf_buffer, "Task_%d", i);
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
-    comm[i]=MSG_task_isend(task, mailbox);
-    INFO2("Send to receiver-%ld Task_%d",i % receivers_count,i);
+    task =
+        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                        NULL);
+    comm[i] = MSG_task_isend(task, mailbox);
+    INFO2("Send to receiver-%ld Task_%d", i % receivers_count, i);
   }
-  for (i = 0; i < receivers_count; i++)
-  {
+  for (i = 0; i < receivers_count; i++) {
     char mailbox[80];
-    sprintf(mailbox,"receiver-%ld",i % receivers_count);
-    task = MSG_task_create ("finalize", 0, 0, 0);
-    comm[i+number_of_tasks]=MSG_task_isend(task, mailbox);
-    INFO1("Send to receiver-%ld finalize",i % receivers_count);
+    sprintf(mailbox, "receiver-%ld", i % receivers_count);
+    task = MSG_task_create("finalize", 0, 0, 0);
+    comm[i + number_of_tasks] = MSG_task_isend(task, mailbox);
+    INFO1("Send to receiver-%ld finalize", i % receivers_count);
 
   }
-  /* Here we are waiting for the completion of all communications*/
-  MSG_comm_waitall(comm,(number_of_tasks+receivers_count),-1);
+  /* Here we are waiting for the completion of all communications */
+  MSG_comm_waitall(comm, (number_of_tasks + receivers_count), -1);
 
   INFO0("Goodbye now!");
   return 0;
-} /* end_of_sender */
+}                               /* end_of_sender */
 
 /** Receiver function  */
 int receiver(int argc, char *argv[])
@@ -63,19 +66,19 @@ int receiver(int argc, char *argv[])
   int id = -1;
   char mailbox[80];
   msg_comm_t res_irecv;
-  xbt_assert1(sscanf(argv[1],"%d", &id),
-        "Invalid argument %s\n",argv[1]);
-  MSG_process_sleep (10);
-  sprintf(mailbox,"receiver-%d",id);
-  while(1) {
-       res_irecv = MSG_task_irecv(&(task), mailbox);
-       INFO0("Wait to receive a task");
-       res = MSG_comm_wait(res_irecv,-1);
-       xbt_assert0(res == MSG_OK, "MSG_task_get failed");
-       INFO1("Received \"%s\"", MSG_task_get_name(task));
-       if (!strcmp(MSG_task_get_name(task),"finalize")) {
-         MSG_task_destroy(task);
-         break;
+  xbt_assert1(sscanf(argv[1], "%d", &id),
+              "Invalid argument %s\n", argv[1]);
+  MSG_process_sleep(10);
+  sprintf(mailbox, "receiver-%d", id);
+  while (1) {
+    res_irecv = MSG_task_irecv(&(task), mailbox);
+    INFO0("Wait to receive a task");
+    res = MSG_comm_wait(res_irecv, -1);
+    xbt_assert0(res == MSG_OK, "MSG_task_get failed");
+    INFO1("Received \"%s\"", MSG_task_get_name(task));
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
     }
 
     INFO1("Processing \"%s\"", MSG_task_get_name(task));
@@ -86,29 +89,29 @@ int receiver(int argc, char *argv[])
   }
   INFO0("I'm done. See you!");
   return 0;
-} /* end_of_receiver */
+}                               /* end_of_receiver */
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
   /* MSG_config("workstation/model","KCCFLN05"); */
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("sender", sender);
     MSG_function_register("receiver", receiver);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
-} /* end_of_test_all */
+}                               /* end_of_test_all */
 
 
 /** Main function */
@@ -116,18 +119,18 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-  res = test_all(argv[1],argv[2]);
-   SIMIX_message_sizes_output("toto.txt");
+  res = test_all(argv[1], argv[2]);
+  SIMIX_message_sizes_output("toto.txt");
   MSG_clean();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index 45b4f56..feba87d 100755 (executable)
@@ -5,18 +5,20 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
-#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
+#include "xbt/sysdep.h"         /* calloc, printf */
 #include <math.h>
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int sender(int argc, char *argv[]);
 int receiver(int argc, char *argv[]);
 
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Sender function  */
 int sender(int argc, char *argv[])
@@ -26,53 +28,57 @@ int sender(int argc, char *argv[])
   double task_comm_size = atof(argv[3]);
   long receivers_count = atol(argv[4]);
   int diff_com = atol(argv[5]);
-  double coef= 0;
+  double coef = 0;
   xbt_dynar_t d = NULL;
   int i;
   m_task_t task = NULL;
   char mailbox[256];
   char sprintf_buffer[256];
   d = xbt_dynar_new(sizeof(msg_comm_t), NULL);
-  msg_comm_t *comm = malloc((number_of_tasks+receivers_count)*sizeof(msg_comm_t));
+  msg_comm_t *comm =
+      malloc((number_of_tasks + receivers_count) * sizeof(msg_comm_t));
   msg_comm_t res_irecv = NULL;
-  for (i = 0; i < (number_of_tasks); i++)
-  {
-       task = NULL;
-       if(diff_com == 0) coef = 1;
-       else coef = (i+1);
-
-    sprintf(mailbox,"receiver-%ld",(i % receivers_count));
+  for (i = 0; i < (number_of_tasks); i++) {
+    task = NULL;
+    if (diff_com == 0)
+      coef = 1;
+    else
+      coef = (i + 1);
+
+    sprintf(mailbox, "receiver-%ld", (i % receivers_count));
     sprintf(sprintf_buffer, "Task_%d", i);
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size/coef, NULL);
+    task =
+        MSG_task_create(sprintf_buffer, task_comp_size,
+                        task_comm_size / coef, NULL);
     comm[i] = MSG_task_isend(task, mailbox);
     MSG_task_refcount_dec(task);
     xbt_dynar_push_as(d, msg_comm_t, comm[i]);
-    INFO3("Send to receiver-%ld %s comm_size %f",i % receivers_count,sprintf_buffer,task_comm_size/coef);
+    INFO3("Send to receiver-%ld %s comm_size %f", i % receivers_count,
+          sprintf_buffer, task_comm_size / coef);
   }
-  /* Here we are waiting for the completion of all communications*/
+  /* Here we are waiting for the completion of all communications */
 
-  while(d->used)
-  {
+  while (d->used) {
     xbt_dynar_remove_at(d, MSG_comm_waitany(d), &res_irecv);
   }
   xbt_dynar_free(&d);
 
 
-  /* Here we are waiting for the completion of all tasks*/
-  sprintf(mailbox,"finalize");
+  /* Here we are waiting for the completion of all tasks */
+  sprintf(mailbox, "finalize");
 
-  for(i=0; i<receivers_count; i++)
-  {
-         task = NULL;
-         res_irecv = NULL;
-         res_irecv = MSG_task_irecv(&(task), mailbox);
-         xbt_assert0(MSG_comm_wait(res_irecv,-1) == MSG_OK, "MSG_comm_wait failed");
-         MSG_task_destroy(task);
+  for (i = 0; i < receivers_count; i++) {
+    task = NULL;
+    res_irecv = NULL;
+    res_irecv = MSG_task_irecv(&(task), mailbox);
+    xbt_assert0(MSG_comm_wait(res_irecv, -1) == MSG_OK,
+                "MSG_comm_wait failed");
+    MSG_task_destroy(task);
   }
 
   INFO0("Goodbye now!");
   return 0;
-} /* end_of_sender */
+}                               /* end_of_sender */
 
 /** Receiver function  */
 int receiver(int argc, char *argv[])
@@ -84,68 +90,66 @@ int receiver(int argc, char *argv[])
   int tasks = atof(argv[2]);
   comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
 
-  xbt_assert1(sscanf(argv[1],"%d", &id),
-        "Invalid argument %s\n",argv[1]);
-  sprintf(mailbox,"receiver-%d",id);
-  MSG_process_sleep (10);
+  xbt_assert1(sscanf(argv[1], "%d", &id),
+              "Invalid argument %s\n", argv[1]);
+  sprintf(mailbox, "receiver-%d", id);
+  MSG_process_sleep(10);
   msg_comm_t res_irecv = NULL;
   m_task_t task = NULL;
   m_task_t task_com = NULL;
-  for(i=0; i<tasks ;i++)
-  {
-       INFO1("Wait to receive task %d",i);
-       res_irecv = MSG_task_irecv(&task, mailbox);
-       xbt_dynar_push_as(comms, msg_comm_t , res_irecv);
-       task = NULL;
-       res_irecv = NULL;
+  for (i = 0; i < tasks; i++) {
+    INFO1("Wait to receive task %d", i);
+    res_irecv = MSG_task_irecv(&task, mailbox);
+    xbt_dynar_push_as(comms, msg_comm_t, res_irecv);
+    task = NULL;
+    res_irecv = NULL;
   }
 
-  /* Here we are waiting for the receiving of all communications*/
-  while(comms->used)
-  {
-       task_com = NULL;
-       res_irecv = NULL;
-       MSG_error_t err = MSG_OK;
-       int num = MSG_comm_waitany(comms);
-       xbt_dynar_remove_at(comms, num, &res_irecv);
-       task_com = MSG_comm_get_task(res_irecv);
-       INFO1("Processing \"%s\"", MSG_task_get_name(task_com) );
-       MSG_task_execute(task_com);
-       INFO1("\"%s\" done", MSG_task_get_name(task_com));
-       err = MSG_task_destroy(task_com);
-       xbt_assert0(err == MSG_OK, "MSG_task_destroy failed");
+  /* Here we are waiting for the receiving of all communications */
+  while (comms->used) {
+    task_com = NULL;
+    res_irecv = NULL;
+    MSG_error_t err = MSG_OK;
+    int num = MSG_comm_waitany(comms);
+    xbt_dynar_remove_at(comms, num, &res_irecv);
+    task_com = MSG_comm_get_task(res_irecv);
+    INFO1("Processing \"%s\"", MSG_task_get_name(task_com));
+    MSG_task_execute(task_com);
+    INFO1("\"%s\" done", MSG_task_get_name(task_com));
+    err = MSG_task_destroy(task_com);
+    xbt_assert0(err == MSG_OK, "MSG_task_destroy failed");
   }
   xbt_dynar_free(&comms);
 
-  /* Here we tell to sender that all tasks are done*/
-  sprintf(mailbox,"finalize");
+  /* Here we tell to sender that all tasks are done */
+  sprintf(mailbox, "finalize");
   res_irecv = MSG_task_isend(MSG_task_create(NULL, 0, 0, NULL), mailbox);
-  MSG_comm_wait(res_irecv,-1);
+  MSG_comm_wait(res_irecv, -1);
   INFO0("I'm done. See you!");
   return 0;
-} /* end_of_receiver */
+}                               /* end_of_receiver */
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
   /* MSG_config("workstation/model","KCCFLN05"); */
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("sender", sender);
     MSG_function_register("receiver", receiver);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
-} /* end_of_test_all */
+}                               /* end_of_test_all */
 
 
 /** Main function */
@@ -153,18 +157,18 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-  res = test_all(argv[1],argv[2]);
-   SIMIX_message_sizes_output("toto.txt");
+  res = test_all(argv[1], argv[2]);
+  SIMIX_message_sizes_output("toto.txt");
   MSG_clean();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index cd30465..f6d3e28 100644 (file)
@@ -179,7 +179,8 @@ int master(int argc, char *argv[])
     for (i = 0; i < number_of_tasks; i++) {
       sprintf(sprintf_buffer, "Task_%d", i);
       todo[i] =
-        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+          MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                          NULL);
     }
   }
 
@@ -216,7 +217,7 @@ int master(int argc, char *argv[])
   }
 
   INFO0
-    ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (i = 0; i < slaves_count; i++)
     MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE),
                  slaves[i], PORT_22);
index fa5543b..978bf70 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
-MSG_error_t test_all(const char*);
+MSG_error_t test_all(const char *);
 
 typedef enum {
   PORT_22 = 0,
@@ -26,37 +26,42 @@ typedef enum {
 /** Emitter function  */
 int master(int argc, char *argv[])
 {
-       long number_of_tasks = atol(argv[1]);
-       double task_comp_size = atof(argv[2]);
-       double task_comm_size = atof(argv[3]);
-       long slaves_count = atol(argv[4]);
-    int i;
-
-    INFO2("Got %ld slaves and %ld tasks to process", slaves_count,number_of_tasks);
-       for (i = 0; i < number_of_tasks; i++) {
-       char mailbox[256];
-       char sprintf_buffer[256];
-       m_task_t task=NULL;
-
-    sprintf(mailbox,"slave-%ld",i % slaves_count);
-       sprintf(sprintf_buffer, "Task_%d", i);
-       task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
-       if (number_of_tasks<10000 || i%10000 == 0)
-           INFO3("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
-           MSG_task_send(task, mailbox);
-         }
-
-       INFO0("All tasks have been dispatched. Let's tell everybody the computation is over.");
-       for (i = 0; i < slaves_count; i++) {
-       char mailbox[80];
-
-       sprintf(mailbox,"slave-%ld",i % slaves_count);
-       m_task_t finalize = MSG_task_create ("finalize", 0, 0, 0);
-       MSG_task_send(finalize, mailbox);
-         }
-
-    INFO0("Goodbye now!");
-       return 0;
+  long number_of_tasks = atol(argv[1]);
+  double task_comp_size = atof(argv[2]);
+  double task_comm_size = atof(argv[3]);
+  long slaves_count = atol(argv[4]);
+  int i;
+
+  INFO2("Got %ld slaves and %ld tasks to process", slaves_count,
+        number_of_tasks);
+  for (i = 0; i < number_of_tasks; i++) {
+    char mailbox[256];
+    char sprintf_buffer[256];
+    m_task_t task = NULL;
+
+    sprintf(mailbox, "slave-%ld", i % slaves_count);
+    sprintf(sprintf_buffer, "Task_%d", i);
+    task =
+        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                        NULL);
+    if (number_of_tasks < 10000 || i % 10000 == 0)
+      INFO3("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
+            number_of_tasks, mailbox);
+    MSG_task_send(task, mailbox);
+  }
+
+  INFO0
+      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  for (i = 0; i < slaves_count; i++) {
+    char mailbox[80];
+
+    sprintf(mailbox, "slave-%ld", i % slaves_count);
+    m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
+    MSG_task_send(finalize, mailbox);
+  }
+
+  INFO0("Goodbye now!");
+  return 0;
 }                               /* end_of_master */
 
 /** Receiver function  */
@@ -67,19 +72,19 @@ int slave(int argc, char *argv[])
   int id = -1;
   char mailbox[80];
 
-  xbt_assert1(sscanf(argv[1],"%d", &id),
-        "Invalid argument %s\n",argv[1]);
+  xbt_assert1(sscanf(argv[1], "%d", &id),
+              "Invalid argument %s\n", argv[1]);
 
-  sprintf(mailbox,"slave-%d",id);
+  sprintf(mailbox, "slave-%d", id);
 
-  while(1) {
+  while (1) {
     res = MSG_task_receive(&(task), mailbox);
     xbt_assert0(res == MSG_OK, "MSG_task_get failed");
 
     INFO1("Received \"%s\"", MSG_task_get_name(task));
-    if (!strcmp(MSG_task_get_name(task),"finalize")) {
-       MSG_task_destroy(task);
-       break;
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
     }
 
     INFO1("Processing \"%s\"", MSG_task_get_name(task));
@@ -90,10 +95,10 @@ int slave(int argc, char *argv[])
   }
   INFO0("I'm done. See you!");
   return 0;
-} /* end_of_slave */
+}                               /* end_of_slave */
 
 /** Test function */
-MSG_error_t test_all(const char *file)//(void)
+MSG_error_t test_all(const char *file)  //(void)
 {
   MSG_error_t res = MSG_OK;
   /*  Simulation setting */
@@ -116,9 +121,9 @@ int main(int argc, char *argv[])
 
   MSG_global_init(&argc, argv);
   if (argc < 2) {
-     printf ("Usage: %s platform_script[.lua]\n",argv[0]);
-     printf ("example: %s platform_script.lua\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_script[.lua]\n", argv[0]);
+    printf("example: %s platform_script.lua\n", argv[0]);
+    exit(1);
   }
   res = test_all(argv[1]);
   MSG_clean();
index 330250d..1629a0a 100644 (file)
@@ -17,7 +17,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
 int forwarder(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 typedef enum {
   PORT_22 = 0,
@@ -70,25 +71,24 @@ int master(int argc, char *argv[])
     int a;
     *((double *) task->data) = MSG_get_clock();
 
-    a =
-      MSG_task_put_with_timeout(task, slaves[i % slaves_count], PORT_22,
-                                10.0);
+    a = MSG_task_put_with_timeout(task, slaves[i % slaves_count], PORT_22,
+                                  10.0);
     if (a == MSG_OK) {
       INFO0("Send completed");
     } else if (a == MSG_HOST_FAILURE) {
       INFO0
-        ("Gloups. The cpu on which I'm running just turned off!. See you!");
+          ("Gloups. The cpu on which I'm running just turned off!. See you!");
       free(slaves);
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       INFO1
-        ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
-         slaves[i % slaves_count]->name);
+          ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
+           slaves[i % slaves_count]->name);
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       INFO1
-        ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-         slaves[i % slaves_count]->name);
+          ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
+           slaves[i % slaves_count]->name);
       MSG_task_destroy(task);
     } else {
       INFO0("Hey ?! What's up ? ");
@@ -97,7 +97,7 @@ int master(int argc, char *argv[])
   }
 
   INFO0
-    ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (i = 0; i < slaves_count; i++) {
     m_task_t task = MSG_task_create("finalize", 0, 0, FINALIZE);
     int a = MSG_task_put_with_timeout(task, slaves[i], PORT_22, 1.0);
@@ -105,7 +105,7 @@ int master(int argc, char *argv[])
       continue;
     if (a == MSG_HOST_FAILURE) {
       INFO0
-        ("Gloups. The cpu on which I'm running just turned off!. See you!");
+          ("Gloups. The cpu on which I'm running just turned off!. See you!");
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       INFO1("Mmh. Can't reach '%s'! Nevermind. Let's keep going!",
@@ -113,12 +113,13 @@ int master(int argc, char *argv[])
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       INFO1
-        ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-         slaves[i % slaves_count]->name);
+          ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
+           slaves[i % slaves_count]->name);
       MSG_task_destroy(task);
     } else {
       INFO0("Hey ?! What's up ? ");
-      xbt_assert2(0, "Unexpected behavior with '%s': %d", slaves[i]->name, a);
+      xbt_assert2(0, "Unexpected behavior with '%s': %d", slaves[i]->name,
+                  a);
     }
   }
 
@@ -155,7 +156,7 @@ int slave(int argc, char *argv[])
         MSG_task_destroy(task);
       } else if (a == MSG_HOST_FAILURE) {
         INFO0
-          ("Gloups. The cpu on which I'm running just turned off!. See you!");
+            ("Gloups. The cpu on which I'm running just turned off!. See you!");
         return 0;
       } else {
         INFO0("Hey ?! What's up ? ");
@@ -163,7 +164,7 @@ int slave(int argc, char *argv[])
       }
     } else if (a == MSG_HOST_FAILURE) {
       INFO0
-        ("Gloups. The cpu on which I'm running just turned off!. See you!");
+          ("Gloups. The cpu on which I'm running just turned off!. See you!");
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       INFO0("Mmh. Something went wrong. Nevermind. Let's keep going!");
@@ -177,7 +178,8 @@ int slave(int argc, char *argv[])
 }                               /* end_of_slave */
 
 /** Test function */
-MSG_error_t test_all(const char *platform_file, const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
index b1a28cf..312a922 100644 (file)
@@ -17,7 +17,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
 int forwarder(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 typedef enum {
   PORT_22 = 0,
@@ -53,7 +54,8 @@ int master(int argc, char *argv[])
     for (i = 0; i < number_of_tasks; i++) {
       sprintf(sprintf_buffer, "Task_%d", i);
       todo[i] =
-        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+          MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                          NULL);
     }
   }
 
@@ -85,9 +87,9 @@ int master(int argc, char *argv[])
   }
 
   INFO0
-    ("All tasks have been dispatched. Let's tell everybody the computation is over.");
-  for (i = 0; i < slaves_count; i++){
-    m_task_t finalize=MSG_task_create("finalize", 0, 0, FINALIZE);
+      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  for (i = 0; i < slaves_count; i++) {
+    m_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
     MSG_task_put(finalize, slaves[i], PORT_22);
   }
 
@@ -151,7 +153,7 @@ int forwarder(int argc, char *argv[])
       INFO1("Received \"%s\"", MSG_task_get_name(task));
       if (MSG_task_get_data(task) == FINALIZE) {
         INFO0
-          ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+            ("All tasks have been dispatched. Let's tell everybody the computation is over.");
         for (i = 0; i < slaves_count; i++)
           MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE),
                        slaves[i], PORT_22);
@@ -174,7 +176,8 @@ int forwarder(int argc, char *argv[])
 }                               /* end_of_forwarder */
 
 /** Test function */
-MSG_error_t test_all(const char *platform_file, const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
index 80497e5..02ebcc5 100644 (file)
@@ -5,18 +5,20 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <stdio.h>
-#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
 int forwarder(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Emitter function  */
 int master(int argc, char *argv[])
@@ -28,34 +30,39 @@ int master(int argc, char *argv[])
 
   int i;
 
-  INFO2("Got %ld slaves and %ld tasks to process", slaves_count,number_of_tasks);
+  INFO2("Got %ld slaves and %ld tasks to process", slaves_count,
+        number_of_tasks);
 
   for (i = 0; i < number_of_tasks; i++) {
     char mailbox[256];
     char sprintf_buffer[256];
-    m_task_t task=NULL;
+    m_task_t task = NULL;
 
-    sprintf(mailbox,"slave-%ld",i % slaves_count);
+    sprintf(mailbox, "slave-%ld", i % slaves_count);
     sprintf(sprintf_buffer, "Task_%d", i);
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
-    if (number_of_tasks<10000 || i%10000 == 0) 
-      INFO3("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
-     
+    task =
+        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
+                        NULL);
+    if (number_of_tasks < 10000 || i % 10000 == 0)
+      INFO3("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
+            number_of_tasks, mailbox);
+
     MSG_task_send(task, mailbox);
   }
-  
-   INFO0("All tasks have been dispatched. Let's tell everybody the computation is over."); 
-   for (i = 0; i < slaves_count; i++) { 
-     char mailbox[80]; 
-    
-     sprintf(mailbox,"slave-%ld",i % slaves_count); 
-     m_task_t finalize = MSG_task_create ("finalize", 0, 0, 0);
-     MSG_task_send(finalize, mailbox);
-   } 
-  
+
+  INFO0
+      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  for (i = 0; i < slaves_count; i++) {
+    char mailbox[80];
+
+    sprintf(mailbox, "slave-%ld", i % slaves_count);
+    m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
+    MSG_task_send(finalize, mailbox);
+  }
+
 //  INFO0("Goodbye now!");
   return 0;
-} /* end_of_master */
+}                               /* end_of_master */
 
 /** Receiver function  */
 int slave(int argc, char *argv[])
@@ -65,21 +72,20 @@ int slave(int argc, char *argv[])
   int id = -1;
   char mailbox[80];
 
-  xbt_assert1(sscanf(argv[1],"%d", &id),
-        "Invalid argument %s\n",argv[1]);
+  xbt_assert1(sscanf(argv[1], "%d", &id),
+              "Invalid argument %s\n", argv[1]);
 
-  sprintf(mailbox,"slave-%d",id);
+  sprintf(mailbox, "slave-%d", id);
 
-  while(1) {
+  while (1) {
     res = MSG_task_receive(&(task), mailbox);
     xbt_assert0(res == MSG_OK, "MSG_task_get failed");
 
 //  INFO1("Received \"%s\"", MSG_task_get_name(task));
-    if (!strcmp(MSG_task_get_name(task),"finalize")) {
-       MSG_task_destroy(task);
-       break;
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+      MSG_task_destroy(task);
+      break;
     }
-     
 //    INFO1("Processing \"%s\"", MSG_task_get_name(task));
     MSG_task_execute(task);
 //    INFO1("\"%s\" done", MSG_task_get_name(task));
@@ -88,29 +94,29 @@ int slave(int argc, char *argv[])
   }
   INFO0("I'm done. See you!");
   return 0;
-} /* end_of_slave */
+}                               /* end_of_slave */
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
   /* MSG_config("workstation/model","KCCFLN05"); */
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("master", master);
     MSG_function_register("slave", slave);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
-} /* end_of_test_all */
+}                               /* end_of_test_all */
 
 
 /** Main function */
@@ -118,18 +124,18 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-  res = test_all(argv[1],argv[2]);
-   SIMIX_message_sizes_output("toto.txt");
+  res = test_all(argv[1], argv[2]);
+  SIMIX_message_sizes_output("toto.txt");
   MSG_clean();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index 43e4cb4..b83efd7 100644 (file)
@@ -7,54 +7,57 @@
 #include <mc/modelchecker.h>
 #define N 3
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(example,"this example");
-
-int server(int argc,char *argv[]);
-int client(int argc,char *argv[]);
-
-int server(int argc,char *argv[]) {
- m_task_t task = NULL;
- int count = 0;
- while(count < N){
-   if(task){
-     MSG_task_destroy(task);
-     task = NULL;
-   }
-   MSG_task_receive(&task,"mymailbox");
-   count++;
- }
- MC_assert(atoi(MSG_task_get_name(task)) == 3);
+XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
+
+int server(int argc, char *argv[]);
+int client(int argc, char *argv[]);
+
+int server(int argc, char *argv[])
+{
+  m_task_t task = NULL;
+  int count = 0;
+  while (count < N) {
+    if (task) {
+      MSG_task_destroy(task);
+      task = NULL;
+    }
+    MSG_task_receive(&task, "mymailbox");
+    count++;
+  }
+  MC_assert(atoi(MSG_task_get_name(task)) == 3);
 
   INFO0("OK");
- return 0;
 return 0;
 }
 
-int client(int argc,char *argv[]) {
+int client(int argc, char *argv[])
+{
 
- m_task_t task = MSG_task_create(argv[1], 0/*comp cost*/, 10000/*comm size*/, NULL /*arbitrary data*/);
+  m_task_t task =
+      MSG_task_create(argv[1], 0 /*comp cost */ , 10000 /*comm size */ ,
+                      NULL /*arbitrary data */ );
 
MSG_task_send(task,"mymailbox");
 MSG_task_send(task, "mymailbox");
 
- INFO0("Sent!");
- return 0;
 INFO0("Sent!");
 return 0;
 }
 
-int main(int argc,char*argv[]) {
+int main(int argc, char *argv[])
+{
 
MSG_global_init(&argc,argv);
 MSG_global_init(&argc, argv);
 
- MSG_create_environment("platform.xml");
 MSG_create_environment("platform.xml");
 
- MSG_function_register("server", server);
 MSG_function_register("server", server);
 
- MSG_function_register("client", client);
 MSG_function_register("client", client);
 
- MSG_launch_application("deploy_bugged1.xml");
 MSG_launch_application("deploy_bugged1.xml");
 
- MSG_main();
-
- return 0;
-  
-}
+  MSG_main();
 
+  return 0;
 
+}
index 180db60..e5040b7 100644 (file)
@@ -7,47 +7,49 @@
 #include <mc/modelchecker.h>
 #define N 3
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(example,"this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
 
-int server(int argc,char *argv[]);
-int client(int argc,char *argv[]);
+int server(int argc, char *argv[]);
+int client(int argc, char *argv[]);
 
-int server(int argc,char *argv[])
+int server(int argc, char *argv[])
 {
   m_task_t task1, task2;
   long val1, val2;
 
-  MSG_task_receive(&task1,"mymailbox");
-  val1 = (long)MSG_task_get_data(task1);
+  MSG_task_receive(&task1, "mymailbox");
+  val1 = (long) MSG_task_get_data(task1);
   INFO1("Received %lu", val1);
 
-  MSG_task_receive(&task2,"mymailbox");
-  val2 = (long)MSG_task_get_data(task2);
+  MSG_task_receive(&task2, "mymailbox");
+  val2 = (long) MSG_task_get_data(task2);
   INFO1("Received %lu", val2);
 
-  MC_assert( min(val1, val2) == 1 );
+  MC_assert(min(val1, val2) == 1);
 
   INFO0("OK");
   return 0;
 }
 
-int client(int argc,char *argv[])
+int client(int argc, char *argv[])
 {
-  m_task_t task1 = MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
-  m_task_t task2 = MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
+  m_task_t task1 =
+      MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
+  m_task_t task2 =
+      MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
 
   INFO1("Send %d!", atoi(argv[1]));
-  MSG_task_send(task1,"mymailbox");
+  MSG_task_send(task1, "mymailbox");
 
   INFO1("Send %d!", atoi(argv[1]));
-  MSG_task_send(task2,"mymailbox");
+  MSG_task_send(task2, "mymailbox");
 
   return 0;
 }
 
-int main(int argc,char*argv[]) 
+int main(int argc, char *argv[])
 {
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
 
   MSG_create_environment("platform.xml");
 
index fa81b63..5853337 100644 (file)
 #include <msg/msg.h>
 #include <mc/modelchecker.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(bugged3,"this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(bugged3, "this example");
 
-int server(int argc,char *argv[]);
-int client(int argc,char *argv[]);
+int server(int argc, char *argv[]);
+int client(int argc, char *argv[]);
 
-int server(int argc,char *argv[])
+int server(int argc, char *argv[])
 {
   m_task_t task1;
   long val1;
   msg_comm_t comm1, comm2;
 
-  comm1 = MSG_task_irecv(&task1,"mymailbox1");
-  comm2 = MSG_task_irecv(&task1,"mymailbox2");
+  comm1 = MSG_task_irecv(&task1, "mymailbox1");
+  comm2 = MSG_task_irecv(&task1, "mymailbox2");
   MSG_comm_wait(comm1, -1);
   MSG_comm_wait(comm2, -1);
 
-  val1 = (long)MSG_task_get_data(task1);
+  val1 = (long) MSG_task_get_data(task1);
   INFO1("Received %lu", val1);
-  
+
   MC_assert(val1 == 2);
-  
+
   INFO0("OK");
   return 0;
 }
 
-int client(int argc,char *argv[])
+int client(int argc, char *argv[])
 {
   msg_comm_t comm;
   char *mbox;
-  m_task_t task1 = MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
+  m_task_t task1 =
+      MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
 
   mbox = bprintf("mymailbox%s", argv[1]);
-  
+
   INFO1("Send %d!", atoi(argv[1]));
-  comm = MSG_task_isend(task1,mbox);
+  comm = MSG_task_isend(task1, mbox);
   MSG_comm_wait(comm, -1);
 
   xbt_free(mbox);
-  
+
   return 0;
 }
 
-int main(int argc,char*argv[]) 
+int main(int argc, char *argv[])
 {
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
 
   MSG_create_environment("platform.xml");
 
index 73b27eb..7b68ace 100644 (file)
 #define CS_PER_PROCESS 2
 XBT_LOG_NEW_DEFAULT_CATEGORY(centralized, "my log messages");
 
-int coordinator(int argc, char** argv);
-int client(int argc, char** argv);
+int coordinator(int argc, char **argv);
+int client(int argc, char **argv);
 
-int coordinator(int argc, char*argv[]) {
-  xbt_dynar_t requests=xbt_dynar_new(sizeof(char*),NULL); // dynamic vector storing requests (which are char*)
-  int CS_used=0; // initially the CS is idle
-  int todo= AMOUNT_OF_CLIENTS*CS_PER_PROCESS; // amount of releases we are expecting
-  while(todo>0) { 
-    m_task_t task=NULL; 
-    MSG_task_receive(&task,"coordinator");
+int coordinator(int argc, char *argv[])
+{
+  xbt_dynar_t requests = xbt_dynar_new(sizeof(char *), NULL);   // dynamic vector storing requests (which are char*)
+  int CS_used = 0;              // initially the CS is idle
+  int todo = AMOUNT_OF_CLIENTS * CS_PER_PROCESS;        // amount of releases we are expecting
+  while (todo > 0) {
+    m_task_t task = NULL;
+    MSG_task_receive(&task, "coordinator");
     const char *kind = MSG_task_get_name(task); //is it a request or a release?
-    if (!strcmp(kind,"request")) { // that's a request
+    if (!strcmp(kind, "request")) {     // that's a request
       char *req = MSG_task_get_data(task);
-      if (CS_used) { // need to push the request in the vector
-       INFO0("CS already used. Queue the request");
-       xbt_dynar_push(requests, &req);
-      } else { // can serve it immediatly
-       INFO0("CS idle. Grant immediatly");
-       m_task_t answer = MSG_task_create("grant",0,1000,NULL);
-       MSG_task_send(answer,req);
-       CS_used = 1;
+      if (CS_used) {            // need to push the request in the vector
+        INFO0("CS already used. Queue the request");
+        xbt_dynar_push(requests, &req);
+      } else {                  // can serve it immediatly
+        INFO0("CS idle. Grant immediatly");
+        m_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
+        MSG_task_send(answer, req);
+        CS_used = 1;
       }
-    } else { // that's a release. Check if someone was waiting for the lock
-      if (xbt_dynar_length(requests)>0) {
-       INFO1("CS release. Grant to queued requests (queue size: %lu)",xbt_dynar_length(requests));
-       char *req;
-       xbt_dynar_pop(requests,&req);
-       MSG_task_send(MSG_task_create("grant",0,1000,NULL),req);        
-       todo--;
-      } else { // nobody wants it
-       INFO0("CS release. resource now idle");
-       CS_used=0;
-       todo--;
+    } else {                    // that's a release. Check if someone was waiting for the lock
+      if (xbt_dynar_length(requests) > 0) {
+        INFO1("CS release. Grant to queued requests (queue size: %lu)",
+              xbt_dynar_length(requests));
+        char *req;
+        xbt_dynar_pop(requests, &req);
+        MSG_task_send(MSG_task_create("grant", 0, 1000, NULL), req);
+        todo--;
+      } else {                  // nobody wants it
+        INFO0("CS release. resource now idle");
+        CS_used = 0;
+        todo--;
       }
     }
     MSG_task_destroy(task);
@@ -51,30 +53,34 @@ int coordinator(int argc, char*argv[]) {
   return 0;
 }
 
-int client(int argc, char *argv[]) {
-  int my_pid=MSG_process_get_PID(MSG_process_self());
+int client(int argc, char *argv[])
+{
+  int my_pid = MSG_process_get_PID(MSG_process_self());
   // use my pid as name of mailbox to contact me
-  char *my_mailbox=bprintf("%d",my_pid);
+  char *my_mailbox = bprintf("%d", my_pid);
   // request the CS 3 times, sleeping a bit in between
   int i;
-  for (i=0; i<CS_PER_PROCESS;i++) {
+  for (i = 0; i < CS_PER_PROCESS; i++) {
     INFO0("Ask the request");
-    MSG_task_send(MSG_task_create("request",0,1000,my_mailbox),"coordinator");
+    MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox),
+                  "coordinator");
     // wait the answer
     m_task_t grant = NULL;
-    MSG_task_receive(&grant,my_mailbox);
+    MSG_task_receive(&grant, my_mailbox);
     MSG_task_destroy(grant);
     INFO0("got the answer. Sleep a bit and release it");
     MSG_process_sleep(1);
-    MSG_task_send(MSG_task_create("release",0,1000,NULL),"coordinator");    
+    MSG_task_send(MSG_task_create("release", 0, 1000, NULL),
+                  "coordinator");
     MSG_process_sleep(my_pid);
   }
   INFO0("Got all the CS I wanted, quit now");
   return 0;
 }
 
-int main(int argc, char*argv[]) {
-  MSG_global_init(&argc,argv);
+int main(int argc, char *argv[])
+{
+  MSG_global_init(&argc, argv);
   MSG_create_environment("../msg_platform.xml");
   MSG_function_register("coordinator", coordinator);
   MSG_function_register("client", client);
index 3dee89c..b5039c7 100644 (file)
@@ -1,22 +1,22 @@
 #include <msg/msg.h>
 #include <mc/modelchecker.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(random_test,"Random Test");
+XBT_LOG_NEW_DEFAULT_CATEGORY(random_test, "Random Test");
 
-int server(int argc,char *argv[]);
+int server(int argc, char *argv[]);
 
-int server(int argc,char *argv[])
+int server(int argc, char *argv[])
 {
   int val;
-  val = MC_random(3,6);
+  val = MC_random(3, 6);
   INFO1("val=%d", val);
   INFO0("OK");
   return 0;
 }
 
-int main(int argc,char*argv[]) 
+int main(int argc, char *argv[])
 {
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
 
   MSG_create_environment("platform.xml");
 
index 18936c7..0d83c80 100644 (file)
@@ -17,17 +17,17 @@ static int emigrant(int argc, char *argv[])
 {
   m_task_t task;
   INFO0
-    ("I'll look for a new job on another machine where the grass is greener.");
+      ("I'll look for a new job on another machine where the grass is greener.");
   MSG_process_change_host(MSG_get_host_by_name("Boivin"));
   INFO0("Yeah, found something to do");
   task = MSG_task_create("job", 98095000, 0, NULL);
   MSG_task_execute(task);
   MSG_task_destroy(task);
-  MSG_process_sleep (2);
+  MSG_process_sleep(2);
   INFO0("Moving back home after work");
   MSG_process_change_host(MSG_get_host_by_name("Jacquelin"));
   MSG_process_change_host(MSG_get_host_by_name("Boivin"));
-  MSG_process_sleep (4);
+  MSG_process_sleep(4);
   INFO0("Uh, nothing to do here. Stopping now");
   return 0;
 }                               /* end_of_emigrant */
@@ -37,7 +37,8 @@ static int emigrant(int argc, char *argv[])
  */
 static int policeman(int argc, char *argv[])
 {
-  INFO0("No function in the API to move the emigrant back, so do nothing.");
+  INFO0
+      ("No function in the API to move the emigrant back, so do nothing.");
   return 0;
 }                               /* end_of_policeman */
 
index 9beea97..b73ab3a 100644 (file)
@@ -17,7 +17,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 
 int execute(int argc, char *argv[]);
 int redistribute(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 typedef enum {
   PORT_22 = 0,
@@ -54,12 +55,12 @@ int execute(int argc, char *argv[])
               "Invalid argument %s\n", argv[argc - 1]);
   computation_duration = (double *) calloc(host_list_size, sizeof(double));
   communication_table =
-    (double *) calloc(host_list_size * host_list_size, sizeof(double));
+      (double *) calloc(host_list_size * host_list_size, sizeof(double));
   for (i = 0; i < host_list_size; i++) {
     computation_duration[i] = computation_amount / host_list_size;
     for (j = 0; j < host_list_size; j++)
       communication_table[i * host_list_size + j] =
-        communication_amount / (host_list_size * host_list_size);
+          communication_amount / (host_list_size * host_list_size);
   }
 
   sprintf(buffer, "redist#0\n");
@@ -105,11 +106,11 @@ int redistribute(int argc, char *argv[])
               "Invalid argument %s\n", argv[argc - 1]);
   computation_duration = (double *) calloc(host_list_size, sizeof(double));
   communication_table =
-    (double *) calloc(host_list_size * host_list_size, sizeof(double));
+      (double *) calloc(host_list_size * host_list_size, sizeof(double));
   for (i = 0; i < host_list_size; i++) {
     for (j = 0; j < host_list_size; j++)
       communication_table[i * host_list_size + j] =
-        communication_amount / (host_list_size * host_list_size);
+          communication_amount / (host_list_size * host_list_size);
   }
 
   sprintf(buffer, "redist#0\n");
@@ -129,7 +130,8 @@ int redistribute(int argc, char *argv[])
 }
 
 
-MSG_error_t test_all(const char *platform_file, const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
index 066b374..1a31157 100644 (file)
@@ -62,7 +62,8 @@ int main(int argc, char *argv[])
   MSG_error_t res = MSG_OK;
 
 #ifdef _MSC_VER
-  unsigned int prev_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
+  unsigned int prev_exponent_format =
+      _set_output_format(_TWO_DIGIT_EXPONENT);
 #endif
 
 
index 6c88118..5501a25 100644 (file)
@@ -19,7 +19,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test");
 int alice(int argc, char *argv[]);
 int bob(int argc, char *argv[]);
 int forwarder(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 int alice(int argc, char *argv[])
 {
@@ -33,7 +34,7 @@ int alice(int argc, char *argv[])
 
   INFO0("== Print the properties of the host");
   xbt_dict_foreach(props, cursor, key, data)
-    INFO2("  Host property: '%s' -> '%s'", key, data);
+      INFO2("  Host property: '%s' -> '%s'", key, data);
 
   INFO0("== Try to get a host property that does not exist");
   value = MSG_host_get_property_value(host1, noexist);
@@ -41,7 +42,8 @@ int alice(int argc, char *argv[])
 
   INFO0("== Try to get a host property that does exist");
   value = MSG_host_get_property_value(host1, exist);
-  xbt_assert1(value, "\tProperty %s is undefined (where it should)", exist);
+  xbt_assert1(value, "\tProperty %s is undefined (where it should)",
+              exist);
   xbt_assert2(!strcmp(value, "180"),
               "\tValue of property %s is defined to %s (where it should be 180)",
               exist, value);
@@ -72,7 +74,7 @@ int bob(int argc, char *argv[])
 
   INFO0("== Print the properties of the process");
   xbt_dict_foreach(props, cursor, key, data)
-    INFO2("   Process property: %s -> %s", key, data);
+      INFO2("   Process property: %s -> %s", key, data);
 
   INFO0("== Try to get a process property that does not exist");
 
@@ -83,7 +85,8 @@ int bob(int argc, char *argv[])
 }
 
 /** Test function */
-MSG_error_t test_all(const char *platform_file, const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
   MSG_function_register("alice", alice);
   MSG_function_register("bob", bob);
index ae41aff..d413535 100644 (file)
@@ -19,7 +19,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 int sender(int argc, char *argv[]);
 int receiver(int argc, char *argv[]);
 
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 typedef enum {
   PORT_22 = 0,
@@ -55,7 +56,8 @@ int sender(int argc, char *argv[])
   /* Latency */
   time = MSG_get_clock();
   sprintf(sprintf_buffer_la, "latency task");
-  task_la = MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL);
+  task_la =
+      MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL);
   task_la->data = xbt_new(double, 1);
   *(double *) task_la->data = time;
   INFO1("task_la->data = %le", *((double *) task_la->data));
@@ -64,7 +66,8 @@ int sender(int argc, char *argv[])
   /* Bandwidth */
   time = MSG_get_clock();
   sprintf(sprintf_buffer_bw, "bandwidth task");
-  task_bw = MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL);
+  task_bw =
+      MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL);
   task_bw->data = xbt_new(double, 1);
   *(double *) task_bw->data = time;
   INFO1("task_bw->data = %le", *((double *) task_bw->data));
@@ -123,7 +126,8 @@ int receiver(int argc, char *argv[])
 
 
 /** Test function */
-MSG_error_t test_all(const char *platform_file, const char *application_file)
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file)
 {
 
   MSG_error_t res = MSG_OK;
@@ -154,17 +158,19 @@ int main(int argc, char *argv[])
   MSG_error_t res = MSG_OK;
 
 #ifdef _MSC_VER
-  unsigned int prev_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
+  unsigned int prev_exponent_format =
+      _set_output_format(_TWO_DIGIT_EXPONENT);
 #endif
 
   MSG_global_init(&argc, argv);
 
 
   if (argc != 3) {
-    CRITICAL1("Usage: %s platform_file deployment_file <model>\n", argv[0]);
+    CRITICAL1("Usage: %s platform_file deployment_file <model>\n",
+              argv[0]);
     CRITICAL1
-      ("example: %s msg_platform.xml msg_deployment.xml KCCFLN05_Vegas\n",
-       argv[0]);
+        ("example: %s msg_platform.xml msg_deployment.xml KCCFLN05_Vegas\n",
+         argv[0]);
     exit(1);
   }
 
index e42c1e9..057810d 100644 (file)
@@ -18,31 +18,32 @@ int test_trace(int argc, char *argv[]);
 /** test the trace integration cpu model */
 int test_trace(int argc, char *argv[])
 {
-       m_task_t task;
-       double task_comp_size = 2800;
-       double task_prio = 1.0;
+  m_task_t task;
+  double task_comp_size = 2800;
+  double task_prio = 1.0;
 
-       if (argc != 3) {
-               printf("Wrong number of arguments!\nUsage:\n\t1) task computational size in FLOPS\n\t2 task priority\n");
-           exit(1);
-       }
+  if (argc != 3) {
+    printf
+        ("Wrong number of arguments!\nUsage:\n\t1) task computational size in FLOPS\n\t2 task priority\n");
+    exit(1);
+  }
 
-       task_comp_size = atof(argv[1]);
-       task_prio = atof(argv[2]);
+  task_comp_size = atof(argv[1]);
+  task_prio = atof(argv[2]);
 
-       INFO0("Testing the trace integration cpu model: CpuTI");
-       INFO1("Task size: %lf", task_comp_size);
-       INFO1("Task prio: %lf", task_prio);
+  INFO0("Testing the trace integration cpu model: CpuTI");
+  INFO1("Task size: %lf", task_comp_size);
+  INFO1("Task prio: %lf", task_prio);
 
-       /* Create and execute a single task. */
-       task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
-       MSG_task_set_priority(task, task_prio);
-       MSG_task_execute(task);
+  /* Create and execute a single task. */
+  task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
+  MSG_task_set_priority(task, task_prio);
+  MSG_task_execute(task);
 
-       INFO0("Test finished");
+  INFO0("Test finished");
 
 
-       return 0;
+  return 0;
 }
 
 /** Main function */
index e84e9dd..ecc22fb 100644 (file)
@@ -6,16 +6,18 @@
 
 #include <stdio.h>
 #include "msg/msg.h"
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Emitter function  */
 int master(int argc, char *argv[])
@@ -28,25 +30,25 @@ int master(int argc, char *argv[])
     m_task_t task = NULL;
 
     //creating task and setting its category
-    if (i%2){
-      task = MSG_task_create ("task_compute", 10000000, 0, NULL);
-      TRACE_msg_set_task_category (task, "compute");
-    }else if (i%3){
-      task = MSG_task_create ("task_request", 10, 10, NULL);
-      TRACE_msg_set_task_category (task, "request");
-    }else{
-      task = MSG_task_create ("task_data", 10, 10000000, NULL);
-      TRACE_msg_set_task_category (task, "data");
+    if (i % 2) {
+      task = MSG_task_create("task_compute", 10000000, 0, NULL);
+      TRACE_msg_set_task_category(task, "compute");
+    } else if (i % 3) {
+      task = MSG_task_create("task_request", 10, 10, NULL);
+      TRACE_msg_set_task_category(task, "request");
+    } else {
+      task = MSG_task_create("task_data", 10, 10000000, NULL);
+      TRACE_msg_set_task_category(task, "data");
     }
     MSG_task_send(task, "master_mailbox");
   }
-  
-   for (i = 0; i < slaves_count; i++) { 
-     m_task_t finalize = MSG_task_create ("finalize", 0, 1000, 0);
-     TRACE_msg_set_task_category(finalize, "finalize");
-     MSG_task_send(finalize, "master_mailbox");
-   } 
-  
+
+  for (i = 0; i < slaves_count; i++) {
+    m_task_t finalize = MSG_task_create("finalize", 0, 1000, 0);
+    TRACE_msg_set_task_category(finalize, "finalize");
+    MSG_task_send(finalize, "master_mailbox");
+  }
+
   return 0;
 }
 
@@ -56,12 +58,12 @@ int slave(int argc, char *argv[])
   m_task_t task = NULL;
   int res;
 
-  while(1) {
+  while (1) {
     res = MSG_task_receive(&(task), "master_mailbox");
 
-    if (!strcmp(MSG_task_get_name(task),"finalize")) {
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
       MSG_task_destroy(task);
-       break;
+      break;
     }
 
     MSG_task_execute(task);
@@ -73,22 +75,22 @@ int slave(int argc, char *argv[])
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("master", master);
     MSG_function_register("slave", slave);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
 }
 
@@ -98,30 +100,29 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-
   //starting the simulation tracing
-  TRACE_start ();
+  TRACE_start();
 
   //declaring user categories
-  TRACE_category ("compute");
-  TRACE_category ("request");
-  TRACE_category ("data");
-  TRACE_category ("finalize");
+  TRACE_category("compute");
+  TRACE_category("request");
+  TRACE_category("data");
+  TRACE_category("finalize");
 
-  res = test_all(argv[1],argv[2]);
+  res = test_all(argv[1], argv[2]);
   MSG_clean();
 
   //ending the simulation tracing
   TRACE_end();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index d63b04d..1f7a168 100644 (file)
@@ -6,16 +6,18 @@
 
 #include <stdio.h>
 #include "msg/msg.h"
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Emitter function  */
 int master(int argc, char *argv[])
@@ -26,30 +28,30 @@ int master(int argc, char *argv[])
   long slaves_count = atol(argv[4]);
 
   //setting the variable "is_master" (previously declared) to value 1
-  TRACE_host_variable_set ("is_master", 1);
+  TRACE_host_variable_set("is_master", 1);
 
-  TRACE_mark ("msmark", "start_send_tasks");
+  TRACE_mark("msmark", "start_send_tasks");
   int i;
   for (i = 0; i < number_of_tasks; i++) {
-    m_task_t task=NULL;
+    m_task_t task = NULL;
     task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
 
     //setting the variable "task_creation" to value i
-    TRACE_host_variable_set ("task_creation", i);
+    TRACE_host_variable_set("task_creation", i);
 
     //setting the category of task to "compute"
     //the category of a task must be defined before it is sent or executed
-    TRACE_msg_set_task_category (task, "compute");
+    TRACE_msg_set_task_category(task, "compute");
     MSG_task_send(task, "master_mailbox");
   }
-  TRACE_mark ("msmark", "finish_send_tasks");
-  
-   for (i = 0; i < slaves_count; i++) { 
-     m_task_t finalize = MSG_task_create ("finalize", 0, 0, 0);
-     TRACE_msg_set_task_category(finalize, "finalize");
-     MSG_task_send(finalize, "master_mailbox");
-   } 
-  
+  TRACE_mark("msmark", "finish_send_tasks");
+
+  for (i = 0; i < slaves_count; i++) {
+    m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
+    TRACE_msg_set_task_category(finalize, "finalize");
+    MSG_task_send(finalize, "master_mailbox");
+  }
+
   return 0;
 }
 
@@ -59,19 +61,18 @@ int slave(int argc, char *argv[])
   m_task_t task = NULL;
   int res;
 
-  TRACE_host_variable_set ("is_slave", 1);
-  while(1) {
+  TRACE_host_variable_set("is_slave", 1);
+  while (1) {
     res = MSG_task_receive(&(task), "master_mailbox");
 
-    if (!strcmp(MSG_task_get_name(task),"finalize")) {
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
       MSG_task_destroy(task);
-       break;
+      break;
     }
-
     //adding the value returned by MSG_task_get_compute_duration(task)
     //to the variable "task_computation"
-    TRACE_host_variable_add ("task_computation",
-        MSG_task_get_compute_duration(task));
+    TRACE_host_variable_add("task_computation",
+                            MSG_task_get_compute_duration(task));
     MSG_task_execute(task);
     MSG_task_destroy(task);
     task = NULL;
@@ -81,22 +82,22 @@ int slave(int argc, char *argv[])
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("master", master);
     MSG_function_register("slave", slave);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
 }
 
@@ -106,37 +107,36 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-
   //starting the simulation tracing
-  TRACE_start ();
+  TRACE_start();
 
   //declaring user variables
-  TRACE_host_variable_declare ("is_slave");
-  TRACE_host_variable_declare ("is_master");
-  TRACE_host_variable_declare ("task_creation");
-  TRACE_host_variable_declare ("task_computation");
+  TRACE_host_variable_declare("is_slave");
+  TRACE_host_variable_declare("is_master");
+  TRACE_host_variable_declare("task_creation");
+  TRACE_host_variable_declare("task_computation");
 
   //declaring user markers
-  TRACE_declare_mark ("msmark");
+  TRACE_declare_mark("msmark");
 
   //declaring user categories
-  TRACE_category ("compute");
-  TRACE_category ("finalize");
+  TRACE_category("compute");
+  TRACE_category("finalize");
 
-  res = test_all(argv[1],argv[2]);
+  res = test_all(argv[1], argv[2]);
   MSG_clean();
 
   //ending the simulation tracing
   TRACE_end();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index c9ebc99..e45aab6 100644 (file)
@@ -17,23 +17,23 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
 static int emigrant(int argc, char *argv[])
 {
   INFO0("Setting process category");
-  TRACE_msg_set_process_category (MSG_process_self(), "emigrant");
-  MSG_process_sleep (2);
+  TRACE_msg_set_process_category(MSG_process_self(), "emigrant");
+  MSG_process_sleep(2);
   INFO0("Migrating to Tremblay");
   MSG_process_change_host(MSG_get_host_by_name("Tremblay"));
-  MSG_process_sleep (2);
+  MSG_process_sleep(2);
   INFO0("Migrating to Jupiter");
   MSG_process_change_host(MSG_get_host_by_name("Jupiter"));
-  MSG_process_sleep (2);
+  MSG_process_sleep(2);
   INFO0("Migrating to Fafard");
   MSG_process_change_host(MSG_get_host_by_name("Fafard"));
-  MSG_process_sleep (2);
+  MSG_process_sleep(2);
   INFO0("Migrating to Ginette");
   MSG_process_change_host(MSG_get_host_by_name("Ginette"));
-  MSG_process_sleep (2);
+  MSG_process_sleep(2);
   INFO0("Migrating to Bourassa");
   MSG_process_change_host(MSG_get_host_by_name("Bourassa"));
-  MSG_process_sleep (2);
+  MSG_process_sleep(2);
   return 0;
 }
 
@@ -50,10 +50,9 @@ int main(int argc, char *argv[])
               argv[0]);
     exit(1);
   }
-
   //starting the simulation trace
-  TRACE_start ();
-  TRACE_category ("emigrant");
+  TRACE_start();
+  TRACE_category("emigrant");
 
   /* Simulation setting */
   MSG_create_environment(argv[1]);
index 2f28834..ca955ee 100644 (file)
@@ -7,16 +7,18 @@
 
 #include <stdio.h>
 #include "msg/msg.h"
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Emitter function  */
 int master(int argc, char *argv[])
@@ -25,25 +27,26 @@ int master(int argc, char *argv[])
   double task_comp_size = atof(argv[2]);
   double task_comm_size = atof(argv[3]);
   long slaves_count = atol(argv[4]);
-  INFO4 ("master %ld %f %f %ld", number_of_tasks, task_comp_size, task_comm_size, slaves_count);
+  INFO4("master %ld %f %f %ld", number_of_tasks, task_comp_size,
+        task_comm_size, slaves_count);
 
   int i;
   for (i = 0; i < number_of_tasks; i++) {
-    m_task_t task=NULL;
+    m_task_t task = NULL;
     task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
 
     //setting the category of task to "compute"
     //the category of a task must be defined before it is sent or executed
-    TRACE_msg_set_task_category (task, "compute");
+    TRACE_msg_set_task_category(task, "compute");
     MSG_task_send(task, "master_mailbox");
   }
-  
-   for (i = 0; i < slaves_count; i++) { 
-     m_task_t finalize = MSG_task_create ("finalize", 0, 0, 0);
-     TRACE_msg_set_task_category(finalize, "finalize");
-     MSG_task_send(finalize, "master_mailbox");
-   } 
-  
+
+  for (i = 0; i < slaves_count; i++) {
+    m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
+    TRACE_msg_set_task_category(finalize, "finalize");
+    MSG_task_send(finalize, "master_mailbox");
+  }
+
   return 0;
 }
 
@@ -53,16 +56,16 @@ int slave(int argc, char *argv[])
   m_task_t task = NULL;
   int res;
 
-  while(1) {
+  while (1) {
     res = MSG_task_receive(&(task), "master_mailbox");
-    if (res != MSG_OK){
+    if (res != MSG_OK) {
       INFO0("error");
       break;
     }
 
-    if (!strcmp(MSG_task_get_name(task),"finalize")) {
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
       MSG_task_destroy(task);
-       break;
+      break;
     }
 
     INFO1("Executing task %f", MSG_task_get_compute_duration(task));
@@ -76,22 +79,22 @@ int slave(int argc, char *argv[])
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("master", master);
     MSG_function_register("slave", slave);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
 }
 
@@ -101,28 +104,27 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-
   //starting the simulation tracing
-  TRACE_start ();
+  TRACE_start();
 
   //declaring user categories
-  TRACE_category ("compute");
-  TRACE_category ("finalize");
+  TRACE_category("compute");
+  TRACE_category("finalize");
 
-  res = test_all(argv[1],argv[2]);
+  res = test_all(argv[1], argv[2]);
   MSG_clean();
 
   //ending the simulation tracing
   TRACE_end();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index c8ded0c..7210fc5 100644 (file)
@@ -7,22 +7,24 @@
 
 #include <stdio.h>
 #include "msg/msg.h"
-#include "xbt/sysdep.h" /* calloc, printf */
+#include "xbt/sysdep.h"         /* calloc, printf */
 
 /* Create a log channel to have nice outputs. */
 #include "xbt/log.h"
 #include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for this msg example");
 
 int master(int argc, char *argv[]);
 int slave(int argc, char *argv[]);
-MSG_error_t test_all(const char *platform_file, const char *application_file);
+MSG_error_t test_all(const char *platform_file,
+                     const char *application_file);
 
 /** Emitter function  */
 int master(int argc, char *argv[])
 {
   //defining the category of the master process
-  TRACE_msg_set_process_category (MSG_process_self(), "master");
+  TRACE_msg_set_process_category(MSG_process_self(), "master");
 
   long number_of_tasks = atol(argv[1]);
   long slaves_count = atol(argv[4]);
@@ -30,27 +32,27 @@ int master(int argc, char *argv[])
   int c = 10000000;
 
   int i;
-  for (i = 0; i < number_of_tasks; i++){
+  for (i = 0; i < number_of_tasks; i++) {
     m_task_t task = NULL;
-    task = MSG_task_create ("task_compute", p, c, NULL);
-    TRACE_msg_set_task_category (task, "compute");
+    task = MSG_task_create("task_compute", p, c, NULL);
+    TRACE_msg_set_task_category(task, "compute");
     MSG_task_send(task, "master_mailbox");
     task = NULL;
-    task = MSG_task_create ("task_request", p, c, NULL);
-    TRACE_msg_set_task_category (task, "request");
+    task = MSG_task_create("task_request", p, c, NULL);
+    TRACE_msg_set_task_category(task, "request");
     MSG_task_send(task, "master_mailbox");
     task = NULL;
-    task = MSG_task_create ("task_data", p, c, NULL);
-    TRACE_msg_set_task_category (task, "data");
+    task = MSG_task_create("task_data", p, c, NULL);
+    TRACE_msg_set_task_category(task, "data");
     MSG_task_send(task, "master_mailbox");
   }
-  
-   for (i = 0; i < slaves_count; i++) { 
-     m_task_t finalize = MSG_task_create ("finalize", 0, 1000, 0);
-     TRACE_msg_set_task_category(finalize, "finalize");
-     MSG_task_send(finalize, "master_mailbox");
-   } 
-  
+
+  for (i = 0; i < slaves_count; i++) {
+    m_task_t finalize = MSG_task_create("finalize", 0, 1000, 0);
+    TRACE_msg_set_task_category(finalize, "finalize");
+    MSG_task_send(finalize, "master_mailbox");
+  }
+
   return 0;
 }
 
@@ -58,17 +60,17 @@ int master(int argc, char *argv[])
 int slave(int argc, char *argv[])
 {
   //defining the category of this slave process
-  TRACE_msg_set_process_category (MSG_process_self(), "slave");
+  TRACE_msg_set_process_category(MSG_process_self(), "slave");
 
   m_task_t task = NULL;
   int res;
 
-  while(1) {
+  while (1) {
     res = MSG_task_receive(&(task), "master_mailbox");
 
-    if (!strcmp(MSG_task_get_name(task),"finalize")) {
+    if (!strcmp(MSG_task_get_name(task), "finalize")) {
       MSG_task_destroy(task);
-       break;
+      break;
     }
 
     MSG_task_execute(task);
@@ -80,22 +82,22 @@ int slave(int argc, char *argv[])
 
 /** Test function */
 MSG_error_t test_all(const char *platform_file,
-                           const char *application_file)
+                     const char *application_file)
 {
   MSG_error_t res = MSG_OK;
 
-  {                            /*  Simulation setting */
+  {                             /*  Simulation setting */
     MSG_set_channel_number(0);
     MSG_create_environment(platform_file);
   }
-  {                            /*   Application deployment */
+  {                             /*   Application deployment */
     MSG_function_register("master", master);
     MSG_function_register("slave", slave);
     MSG_launch_application(application_file);
   }
   res = MSG_main();
-  
-  INFO1("Simulation time %g",MSG_get_clock());
+
+  INFO1("Simulation time %g", MSG_get_clock());
   return res;
 }
 
@@ -105,37 +107,36 @@ int main(int argc, char *argv[])
 {
   MSG_error_t res = MSG_OK;
 
-  MSG_global_init(&argc,argv);
+  MSG_global_init(&argc, argv);
   if (argc < 3) {
-     printf ("Usage: %s platform_file deployment_file\n",argv[0]);
-     printf ("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]);
-     exit(1);
+    printf("Usage: %s platform_file deployment_file\n", argv[0]);
+    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
+    exit(1);
   }
-
   //starting the simulation tracing with the TRACE_VOLUME mask
   // - the communication volume among processes expects that:
   //     - the processes involved have a category
   //     - the tasks sent have a category
-  TRACE_start ();
+  TRACE_start();
 
   //declaring user categories (for tasks)
-  TRACE_category ("compute");
-  TRACE_category ("request");
-  TRACE_category ("data");
-  TRACE_category ("finalize");
+  TRACE_category("compute");
+  TRACE_category("request");
+  TRACE_category("data");
+  TRACE_category("finalize");
 
   //declaring user categories (for processes)
-  TRACE_category ("master");
-  TRACE_category ("slave");
+  TRACE_category("master");
+  TRACE_category("slave");
 
-  res = test_all(argv[1],argv[2]);
+  res = test_all(argv[1], argv[2]);
   MSG_clean();
 
   //ending the simulation tracing
   TRACE_end();
 
-  if(res==MSG_OK)
+  if (res == MSG_OK)
     return 0;
   else
     return 1;
-} /* end_of_main */
+}                               /* end_of_main */
index 464531d..8ae9424 100644 (file)
@@ -25,7 +25,8 @@ static int name_compare_hosts(const void *n1, const void *n2)
   return strcmp(name1, name2);
 }
 
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
   xbt_dynar_t dax, changed;
   unsigned int cursor;
   SD_task_t task;
@@ -36,14 +37,19 @@ int main(int argc, char **argv) {
   /* Check our arguments */
   if (argc < 3) {
     INFO1("Usage: %s platform_file dax_file [trace_file]", argv[0]);
-    INFO1("example: %s ../sd_platform.xml Montage_50.xml Montage_50.mytrace", argv[0]);
+    INFO1
+        ("example: %s ../sd_platform.xml Montage_50.xml Montage_50.mytrace",
+         argv[0]);
     exit(1);
   }
   char *tracefilename;
   if (argc == 3) {
-    char *last=strrchr(argv[2],'.');
+    char *last = strrchr(argv[2], '.');
 
-    tracefilename=bprintf("%.*s.trace",(int)(last==NULL?strlen(argv[2]):last-argv[2]),argv[2]);
+    tracefilename =
+        bprintf("%.*s.trace",
+                (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),
+                argv[2]);
   } else {
     tracefilename = xbt_strdup(argv[3]);
   }
@@ -52,67 +58,77 @@ int main(int argc, char **argv) {
   SD_create_environment(argv[1]);
 
   /* load the DAX file */
-  dax=SD_daxload(argv[2]);
+  dax = SD_daxload(argv[2]);
 
   /* Display all the tasks */
-  INFO0("------------------- Display all tasks of the loaded DAG ---------------------------");
-  xbt_dynar_foreach(dax,cursor,task) {
+  INFO0
+      ("------------------- Display all tasks of the loaded DAG ---------------------------");
+  xbt_dynar_foreach(dax, cursor, task) {
     SD_task_dump(task);
   }
 
-  FILE *dotout = fopen("dax.dot","w");
-  fprintf(dotout,"digraph A {\n");
-  xbt_dynar_foreach(dax,cursor,task) {
-    SD_task_dotty(task,dotout);
+  FILE *dotout = fopen("dax.dot", "w");
+  fprintf(dotout, "digraph A {\n");
+  xbt_dynar_foreach(dax, cursor, task) {
+    SD_task_dotty(task, dotout);
   }
-  fprintf(dotout,"}\n");
+  fprintf(dotout, "}\n");
   fclose(dotout);
 
   /* Schedule them all on the first workstation */
   INFO0("------------------- Schedule tasks ---------------------------");
-  const SD_workstation_t *ws_list =  SD_workstation_get_list();
+  const SD_workstation_t *ws_list = SD_workstation_get_list();
   int totalHosts = SD_workstation_get_number();
   qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t),
         name_compare_hosts);
 
   int count = SD_workstation_get_number();
-  xbt_dynar_foreach(dax,cursor,task) {
+  xbt_dynar_foreach(dax, cursor, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
-      if (!strcmp(SD_task_get_name(task),"end"))
-        SD_task_schedulel(task,1,ws_list[0]);
+      if (!strcmp(SD_task_get_name(task), "end"))
+        SD_task_schedulel(task, 1, ws_list[0]);
       else
-        SD_task_schedulel(task,1,ws_list[cursor%count]);
+        SD_task_schedulel(task, 1, ws_list[cursor % count]);
     }
   }
 
-  INFO0("------------------- Run the schedule ---------------------------");
+  INFO0
+      ("------------------- Run the schedule ---------------------------");
   changed = SD_simulate(-1);
   xbt_dynar_free_container(&changed);
-  INFO0("------------------- Produce the trace file---------------------------");
-  INFO1("Producing the trace of the run into %s",tracefilename);
-  FILE*out = fopen(tracefilename,"w");
-  xbt_assert1(out,"Cannot write to %s",tracefilename);
+  INFO0
+      ("------------------- Produce the trace file---------------------------");
+  INFO1("Producing the trace of the run into %s", tracefilename);
+  FILE *out = fopen(tracefilename, "w");
+  xbt_assert1(out, "Cannot write to %s", tracefilename);
   free(tracefilename);
 
-  xbt_dynar_foreach(dax,cursor,task) {
+  xbt_dynar_foreach(dax, cursor, task) {
     int kind = SD_task_get_kind(task);
     SD_workstation_t *wsl = SD_task_get_workstation_list(task);
     switch (kind) {
     case SD_TASK_COMP_SEQ:
-      fprintf(out,"[%f] %s compute %f # %s\n",SD_task_get_start_time(task),
-          SD_workstation_get_name(wsl[0]),SD_task_get_amount(task),
-          SD_task_get_name(task));
+      fprintf(out, "[%f] %s compute %f # %s\n",
+              SD_task_get_start_time(task),
+              SD_workstation_get_name(wsl[0]), SD_task_get_amount(task),
+              SD_task_get_name(task));
       break;
     case SD_TASK_COMM_E2E:
-      fprintf(out,"[%f] %s send %s %f # %s\n",SD_task_get_start_time(task),
-          SD_workstation_get_name(wsl[0]),SD_workstation_get_name(wsl[1]),
-          SD_task_get_amount(task), SD_task_get_name(task));
-      fprintf(out,"[%f] %s recv %s %f # %s\n",SD_task_get_finish_time(task),
-          SD_workstation_get_name(wsl[1]),SD_workstation_get_name(wsl[0]),
-          SD_task_get_amount(task), SD_task_get_name(task));
+      fprintf(out, "[%f] %s send %s %f # %s\n",
+              SD_task_get_start_time(task),
+              SD_workstation_get_name(wsl[0]),
+              SD_workstation_get_name(wsl[1]), SD_task_get_amount(task),
+              SD_task_get_name(task));
+      fprintf(out, "[%f] %s recv %s %f # %s\n",
+              SD_task_get_finish_time(task),
+              SD_workstation_get_name(wsl[1]),
+              SD_workstation_get_name(wsl[0]), SD_task_get_amount(task),
+              SD_task_get_name(task));
       break;
     default:
-      xbt_die(bprintf("Task %s is of unknown kind %d",SD_task_get_name(task),SD_task_get_kind(task)));
+      xbt_die(bprintf
+              ("Task %s is of unknown kind %d", SD_task_get_name(task),
+               SD_task_get_kind(task)));
     }
     SD_task_destroy(task);
   }
index 23a8c2c..4a6da7b 100644 (file)
 XBT_LOG_NEW_DEFAULT_CATEGORY(test,
                              "Logging specific to this SimDag example");
 
-int main(int argc, char **argv) {
-    xbt_dynar_t dot, changed;
-    unsigned int cursor;
-    SD_task_t task;
-
-    /* initialisation of SD */
-    SD_init(&argc, argv);
-
-    /* Check our arguments */
-    if (argc < 3) {
-        INFO1("Usage: %s platform_file dot_file [trace_file]", argv[0]);
-        INFO1("example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0]);
-        exit(1);
+int main(int argc, char **argv)
+{
+  xbt_dynar_t dot, changed;
+  unsigned int cursor;
+  SD_task_t task;
+
+  /* initialisation of SD */
+  SD_init(&argc, argv);
+
+  /* Check our arguments */
+  if (argc < 3) {
+    INFO1("Usage: %s platform_file dot_file [trace_file]", argv[0]);
+    INFO1("example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0]);
+    exit(1);
+  }
+  char *tracefilename;
+  if (argc == 3) {
+    char *last = strrchr(argv[2], '.');
+
+    tracefilename =
+        bprintf("%.*s.trace",
+                (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),
+                argv[2]);
+  } else {
+    tracefilename = xbt_strdup(argv[3]);
+  }
+
+  /* creation of the environment */
+  SD_create_environment(argv[1]);
+
+  /* load the DOT file */
+  dot = SD_dotload(argv[2]);
+
+  /* Display all the tasks */
+  INFO0
+      ("------------------- Display all tasks of the loaded DAG ---------------------------");
+  xbt_dynar_foreach(dot, cursor, task) {
+    SD_task_dump(task);
+  }
+
+  FILE *dotout = fopen("dot.dot", "w");
+  fprintf(dotout, "digraph A {\n");
+  xbt_dynar_foreach(dot, cursor, task) {
+    SD_task_dotty(task, dotout);
+  }
+  fprintf(dotout, "}\n");
+  fclose(dotout);
+
+  /* Schedule them all on the first workstation */
+  INFO0("------------------- Schedule tasks ---------------------------");
+  const SD_workstation_t *ws_list = SD_workstation_get_list();
+
+  int count = SD_workstation_get_number();
+  xbt_dynar_foreach(dot, cursor, task) {
+    if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
+      if (!strcmp(SD_task_get_name(task), "end"))
+        SD_task_schedulel(task, 1, ws_list[0]);
+      else
+        SD_task_schedulel(task, 1, ws_list[cursor % count]);
     }
-    char *tracefilename;
-    if (argc == 3) {
-        char *last=strrchr(argv[2],'.');
-
-        tracefilename=bprintf("%.*s.trace",(int)(last==NULL?strlen(argv[2]):last-argv[2]),argv[2]);
-    } else {
-        tracefilename = xbt_strdup(argv[3]);
-    }
-
-    /* creation of the environment */
-    SD_create_environment(argv[1]);
-
-    /* load the DOT file */
-    dot=SD_dotload(argv[2]);
-
-    /* Display all the tasks */
-    INFO0("------------------- Display all tasks of the loaded DAG ---------------------------");
-    xbt_dynar_foreach(dot,cursor,task) {
-        SD_task_dump(task);
-    }
-
-    FILE *dotout = fopen("dot.dot","w");
-    fprintf(dotout,"digraph A {\n");
-    xbt_dynar_foreach(dot,cursor,task) {
-        SD_task_dotty(task,dotout);
-    }
-    fprintf(dotout,"}\n");
-    fclose(dotout);
-
-    /* Schedule them all on the first workstation */
-    INFO0("------------------- Schedule tasks ---------------------------");
-    const SD_workstation_t *ws_list =  SD_workstation_get_list();
-
-    int count = SD_workstation_get_number();
-    xbt_dynar_foreach(dot,cursor,task) {
-        if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
-            if (!strcmp(SD_task_get_name(task),"end"))
-                SD_task_schedulel(task,1,ws_list[0]);
-            else
-                SD_task_schedulel(task,1,ws_list[cursor%count]);
-        }
-    }
-
-    INFO0("------------------- Run the schedule ---------------------------");
-    changed = SD_simulate(-1);
-    xbt_dynar_free_container(&changed);
-    INFO0("------------------- Produce the trace file---------------------------");
-    INFO1("Producing the trace of the run into %s",tracefilename);
-    FILE*out = fopen(tracefilename,"w");
-    xbt_assert1(out,"Cannot write to %s",tracefilename);
-    free(tracefilename);
-
-    xbt_dynar_foreach(dot,cursor,task) {
-        int kind = SD_task_get_kind(task);
-        SD_workstation_t *wsl = SD_task_get_workstation_list(task);
-        switch (kind) {
-            case SD_TASK_COMP_SEQ:
-                fprintf(out,"[%f] %s compute %f # %s\n",SD_task_get_start_time(task),
-                        SD_workstation_get_name(wsl[0]),SD_task_get_amount(task),
-                        SD_task_get_name(task));
-                break;
-            case SD_TASK_COMM_E2E:
-                fprintf(out,"[%f] %s send %s %f # %s\n",SD_task_get_start_time(task),
-                        SD_workstation_get_name(wsl[0]),SD_workstation_get_name(wsl[1]),
-                        SD_task_get_amount(task), SD_task_get_name(task));
-                fprintf(out,"[%f] %s recv %s %f # %s\n",SD_task_get_finish_time(task),
-                        SD_workstation_get_name(wsl[1]),SD_workstation_get_name(wsl[0]),
-                        SD_task_get_amount(task), SD_task_get_name(task));
-                break;
-            default:
-                xbt_die(bprintf("Task %s is of unknown kind %d",SD_task_get_name(task),SD_task_get_kind(task)));
-        }
-        SD_task_destroy(task);
+  }
+
+  INFO0
+      ("------------------- Run the schedule ---------------------------");
+  changed = SD_simulate(-1);
+  xbt_dynar_free_container(&changed);
+  INFO0
+      ("------------------- Produce the trace file---------------------------");
+  INFO1("Producing the trace of the run into %s", tracefilename);
+  FILE *out = fopen(tracefilename, "w");
+  xbt_assert1(out, "Cannot write to %s", tracefilename);
+  free(tracefilename);
+
+  xbt_dynar_foreach(dot, cursor, task) {
+    int kind = SD_task_get_kind(task);
+    SD_workstation_t *wsl = SD_task_get_workstation_list(task);
+    switch (kind) {
+    case SD_TASK_COMP_SEQ:
+      fprintf(out, "[%f] %s compute %f # %s\n",
+              SD_task_get_start_time(task),
+              SD_workstation_get_name(wsl[0]), SD_task_get_amount(task),
+              SD_task_get_name(task));
+      break;
+    case SD_TASK_COMM_E2E:
+      fprintf(out, "[%f] %s send %s %f # %s\n",
+              SD_task_get_start_time(task),
+              SD_workstation_get_name(wsl[0]),
+              SD_workstation_get_name(wsl[1]), SD_task_get_amount(task),
+              SD_task_get_name(task));
+      fprintf(out, "[%f] %s recv %s %f # %s\n",
+              SD_task_get_finish_time(task),
+              SD_workstation_get_name(wsl[1]),
+              SD_workstation_get_name(wsl[0]), SD_task_get_amount(task),
+              SD_task_get_name(task));
+      break;
+    default:
+      xbt_die(bprintf
+              ("Task %s is of unknown kind %d", SD_task_get_name(task),
+               SD_task_get_kind(task)));
     }
-    fclose(out);
+    SD_task_destroy(task);
+  }
+  fclose(out);
 
-    /* exit */
-    SD_exit();
-    return 0;
+  /* exit */
+  SD_exit();
+  return 0;
 }
index 72ee23b..7fb1cca 100644 (file)
@@ -18,138 +18,144 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,
 
 typedef struct _WorkstationAttribute *WorkstationAttribute;
 struct _WorkstationAttribute {
-       /* Earliest time at wich a workstation is ready to execute a task*/
-       double available_at;
+  /* Earliest time at wich a workstation is ready to execute a task */
+  double available_at;
 };
 
-static void SD_workstation_allocate_attribute(SD_workstation_t workstation){
-       void *data;
-    data = calloc(1,sizeof(struct _WorkstationAttribute));
-    SD_workstation_set_data(workstation, data);
+static void SD_workstation_allocate_attribute(SD_workstation_t workstation)
+{
+  void *data;
+  data = calloc(1, sizeof(struct _WorkstationAttribute));
+  SD_workstation_set_data(workstation, data);
 }
 
-static void SD_workstation_free_attribute(SD_workstation_t workstation){
-    free(SD_workstation_get_data(workstation));
-    SD_workstation_set_data(workstation, NULL);
+static void SD_workstation_free_attribute(SD_workstation_t workstation)
+{
+  free(SD_workstation_get_data(workstation));
+  SD_workstation_set_data(workstation, NULL);
 }
 
-static double SD_workstation_get_available_at( SD_workstation_t workstation){
-       WorkstationAttribute attr =
-                       (WorkstationAttribute) SD_workstation_get_data(workstation);
-       return attr->available_at;
+static double SD_workstation_get_available_at(SD_workstation_t workstation)
+{
+  WorkstationAttribute attr =
+      (WorkstationAttribute) SD_workstation_get_data(workstation);
+  return attr->available_at;
 }
 
 static void SD_workstation_set_available_at(SD_workstation_t workstation,
-               double time){
-       WorkstationAttribute attr =
-                       (WorkstationAttribute) SD_workstation_get_data(workstation);
-       attr->available_at=time;
-       SD_workstation_set_data(workstation, attr);
+                                            double time)
+{
+  WorkstationAttribute attr =
+      (WorkstationAttribute) SD_workstation_get_data(workstation);
+  attr->available_at = time;
+  SD_workstation_set_data(workstation, attr);
 }
 
 
-static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax){
+static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
+{
   unsigned int i;
   xbt_dynar_t ready_tasks;
   SD_task_t task;
 
-  ready_tasks= xbt_dynar_new(sizeof(SD_task_t), NULL);
-  xbt_dynar_foreach(dax, i, task){
+  ready_tasks = xbt_dynar_new(sizeof(SD_task_t), NULL);
+  xbt_dynar_foreach(dax, i, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ &&
-       SD_task_get_state(task) == SD_SCHEDULABLE){
+        SD_task_get_state(task) == SD_SCHEDULABLE) {
       xbt_dynar_push(ready_tasks, &task);
     }
   }
   DEBUG1("There are %lu ready tasks", xbt_dynar_length(ready_tasks));
-  
+
   return ready_tasks;
 }
 
-static double finish_on_at(SD_task_t task, SD_workstation_t workstation){
+static double finish_on_at(SD_task_t task, SD_workstation_t workstation)
+{
   unsigned int i;
-  double data_available=0.;
-  double redist_time=0;
+  double data_available = 0.;
+  double redist_time = 0;
   double last_data_available;
-  SD_task_t parent,grand_parent;
+  SD_task_t parent, grand_parent;
   xbt_dynar_t parents, grand_parents;
-  
+
   int grand_parent_nworkstations;
   SD_workstation_t *grand_parent_workstation_list;
-  
+
   parents = SD_task_get_parents(task);
-  
+
   if (xbt_dynar_length(parents)) {
     /* compute last_data_available */
-    last_data_available=-1.0;
-    xbt_dynar_foreach(parents, i, parent){
-      
+    last_data_available = -1.0;
+    xbt_dynar_foreach(parents, i, parent) {
+
       /* normal case */
       if (SD_task_get_kind(parent) == SD_TASK_COMM_E2E) {
-       grand_parents = SD_task_get_parents(parent);
-       
-       if (xbt_dynar_length(grand_parents) > 1) {
-         ERROR1("Warning: transfer %s has 2 parents",
-                SD_task_get_name(parent));
-       }
-       xbt_dynar_get_cpy(grand_parents, 0, &grand_parent);
-       
-       grand_parent_nworkstations =
-         SD_task_get_workstation_count(grand_parent);
-       grand_parent_workstation_list =
-         SD_task_get_workstation_list(grand_parent);
-       /* Estimate the redistribution time from this parent */
-       redist_time =
-         SD_route_get_communication_time(grand_parent_workstation_list[0],
-                                         workstation, 
-                                         SD_task_get_amount(parent));
-       data_available =
-         SD_task_get_finish_time(grand_parent) + redist_time;
-       
-       xbt_dynar_free_container(&grand_parents);
+        grand_parents = SD_task_get_parents(parent);
+
+        if (xbt_dynar_length(grand_parents) > 1) {
+          ERROR1("Warning: transfer %s has 2 parents",
+                 SD_task_get_name(parent));
+        }
+        xbt_dynar_get_cpy(grand_parents, 0, &grand_parent);
+
+        grand_parent_nworkstations =
+            SD_task_get_workstation_count(grand_parent);
+        grand_parent_workstation_list =
+            SD_task_get_workstation_list(grand_parent);
+        /* Estimate the redistribution time from this parent */
+        redist_time =
+            SD_route_get_communication_time(grand_parent_workstation_list
+                                            [0], workstation,
+                                            SD_task_get_amount(parent));
+        data_available =
+            SD_task_get_finish_time(grand_parent) + redist_time;
+
+        xbt_dynar_free_container(&grand_parents);
       }
-      
+
       /* no transfer, control dependency */
       if (SD_task_get_kind(parent) == SD_TASK_COMP_SEQ) {
-       data_available = SD_task_get_finish_time(parent);
+        data_available = SD_task_get_finish_time(parent);
       }
-      
+
       if (last_data_available < data_available)
-       last_data_available = data_available;
-      
+        last_data_available = data_available;
+
     }
-    
+
     xbt_dynar_free_container(&parents);
-    
+
     return MAX(SD_workstation_get_available_at(workstation),
-              last_data_available) +
-      SD_workstation_get_computation_time(workstation,
-                                         SD_task_get_amount(task));
+               last_data_available) +
+        SD_workstation_get_computation_time(workstation,
+                                            SD_task_get_amount(task));
   } else {
     xbt_dynar_free_container(&parents);
-    
-    return  SD_workstation_get_available_at(workstation)+
-      SD_workstation_get_computation_time(workstation,
-                                         SD_task_get_amount(task));
+
+    return SD_workstation_get_available_at(workstation) +
+        SD_workstation_get_computation_time(workstation,
+                                            SD_task_get_amount(task));
   }
 }
 
-static SD_workstation_t SD_task_get_best_workstation (SD_task_t task){
+static SD_workstation_t SD_task_get_best_workstation(SD_task_t task)
+{
   int i;
-  double EFT, min_EFT=-1.0;
-  const SD_workstation_t *workstations = SD_workstation_get_list ();
-  int nworkstations = SD_workstation_get_number ();
+  double EFT, min_EFT = -1.0;
+  const SD_workstation_t *workstations = SD_workstation_get_list();
+  int nworkstations = SD_workstation_get_number();
   SD_workstation_t best_workstation;
-  
+
   best_workstation = workstations[0];
   min_EFT = finish_on_at(task, workstations[0]);
-  
-  for (i=1; i<nworkstations;i++){
+
+  for (i = 1; i < nworkstations; i++) {
     EFT = finish_on_at(task, workstations[i]);
     DEBUG3("%s finishes on %s at %f",
-          SD_task_get_name(task),
-          SD_workstation_get_name(workstations[i]),
-          EFT);
-    
+           SD_task_get_name(task),
+           SD_workstation_get_name(workstations[i]), EFT);
+
     if (EFT < min_EFT) {
       min_EFT = EFT;
       best_workstation = workstations[i];
@@ -159,77 +165,84 @@ static SD_workstation_t SD_task_get_best_workstation (SD_task_t task){
   return best_workstation;
 }
 
-static void output_xml(FILE *out, xbt_dynar_t dax){
-  unsigned int i,j, k;
+static void output_xml(FILE * out, xbt_dynar_t dax)
+{
+  unsigned int i, j, k;
   int current_nworkstations;
   const int nworkstations = SD_workstation_get_number();
-  const SD_workstation_t * workstations = SD_workstation_get_list();
+  const SD_workstation_t *workstations = SD_workstation_get_list();
   SD_task_t task;
-  SD_workstation_t * list;
-  
-  fprintf(out,"<?xml version=\"1.0\"?>\n");
-  fprintf(out,"<grid_schedule>\n");
-  fprintf(out,"   <grid_info>\n");
-  fprintf(out,"      <info name=\"nb_clusters\" value=\"1\"/>\n");
-  fprintf(out,"         <clusters>\n");
-  fprintf(out,"            <cluster id=\"1\" hosts=\"%d\" first_host=\"0\"/>\n",
-         nworkstations);
-  fprintf(out,"         </clusters>\n");
-  fprintf(out,"      </grid_info>\n");
-  fprintf(out,"   <node_infos>\n");
-  
-  xbt_dynar_foreach(dax, i, task){
-    fprintf(out,"      <node_statistics>\n");
-    fprintf(out,"         <node_property name=\"id\" value=\"%s\"/>\n",
-           SD_task_get_name(task));
-    fprintf(out,"         <node_property name=\"type\" value=\"");
+  SD_workstation_t *list;
+
+  fprintf(out, "<?xml version=\"1.0\"?>\n");
+  fprintf(out, "<grid_schedule>\n");
+  fprintf(out, "   <grid_info>\n");
+  fprintf(out, "      <info name=\"nb_clusters\" value=\"1\"/>\n");
+  fprintf(out, "         <clusters>\n");
+  fprintf(out,
+          "            <cluster id=\"1\" hosts=\"%d\" first_host=\"0\"/>\n",
+          nworkstations);
+  fprintf(out, "         </clusters>\n");
+  fprintf(out, "      </grid_info>\n");
+  fprintf(out, "   <node_infos>\n");
+
+  xbt_dynar_foreach(dax, i, task) {
+    fprintf(out, "      <node_statistics>\n");
+    fprintf(out, "         <node_property name=\"id\" value=\"%s\"/>\n",
+            SD_task_get_name(task));
+    fprintf(out, "         <node_property name=\"type\" value=\"");
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ)
-      fprintf(out,"computation\"/>\n");
+      fprintf(out, "computation\"/>\n");
     if (SD_task_get_kind(task) == SD_TASK_COMM_E2E)
-      fprintf(out,"transfer\"/>\n");
-    
-    fprintf(out,"         <node_property name=\"start_time\" value=\"%.3f\"/>\n",
-           SD_task_get_start_time(task));
-    fprintf(out,"         <node_property name=\"end_time\" value=\"%.3f\"/>\n",
-           SD_task_get_finish_time(task));
-    fprintf(out,"         <configuration>\n");
-    
+      fprintf(out, "transfer\"/>\n");
+
+    fprintf(out,
+            "         <node_property name=\"start_time\" value=\"%.3f\"/>\n",
+            SD_task_get_start_time(task));
+    fprintf(out,
+            "         <node_property name=\"end_time\" value=\"%.3f\"/>\n",
+            SD_task_get_finish_time(task));
+    fprintf(out, "         <configuration>\n");
+
     current_nworkstations = SD_task_get_workstation_count(task);
-    
-    fprintf(out,"            <conf_property name=\"host_nb\" value=\"%d\"/>\n",
-           current_nworkstations);
-    
-    fprintf(out,"            <host_lists>\n");
+
+    fprintf(out,
+            "            <conf_property name=\"host_nb\" value=\"%d\"/>\n",
+            current_nworkstations);
+
+    fprintf(out, "            <host_lists>\n");
     list = SD_task_get_workstation_list(task);
-    for (j=0;j<current_nworkstations;j++){
-      for (k=0;k<nworkstations;k++){
-       if (!strcmp(SD_workstation_get_name(workstations[k]),
-                   SD_workstation_get_name(list[j]))){
-         fprintf(out,"               <hosts start=\"%u\" nb=\"1\"/>\n",k);
-         fprintf(out,
-                 "            <conf_property name=\"cluster_id\" value=\"0\"/>\n");
-         break;
-       }
+    for (j = 0; j < current_nworkstations; j++) {
+      for (k = 0; k < nworkstations; k++) {
+        if (!strcmp(SD_workstation_get_name(workstations[k]),
+                    SD_workstation_get_name(list[j]))) {
+          fprintf(out, "               <hosts start=\"%u\" nb=\"1\"/>\n",
+                  k);
+          fprintf(out,
+                  "            <conf_property name=\"cluster_id\" value=\"0\"/>\n");
+          break;
+        }
       }
     }
-    fprintf(out,"            </host_lists>\n");
-    fprintf(out,"         </configuration>\n");
-    fprintf(out,"      </node_statistics>\n");
+    fprintf(out, "            </host_lists>\n");
+    fprintf(out, "         </configuration>\n");
+    fprintf(out, "      </node_statistics>\n");
   }
-  fprintf(out,"   </node_infos>\n");
-  fprintf(out,"</grid_schedule>\n");
+  fprintf(out, "   </node_infos>\n");
+  fprintf(out, "</grid_schedule>\n");
 }
 
-int main(int argc, char **argv) {
-  unsigned int cursor, selected_idx=0;
+int main(int argc, char **argv)
+{
+  unsigned int cursor, selected_idx = 0;
   double finish_time, min_finish_time = -1.0;
-  SD_task_t task, selected_task=NULL;
+  SD_task_t task, selected_task = NULL;
   xbt_dynar_t ready_tasks;
-  SD_workstation_t workstation, selected_workstation=NULL;
-  int total_nworkstations=0;
-  const SD_workstation_t *workstations=NULL;
+  SD_workstation_t workstation, selected_workstation = NULL;
+  int total_nworkstations = 0;
+  const SD_workstation_t *workstations = NULL;
   xbt_dynar_t dax, changed;
-  FILE *out=NULL;
+  FILE *out = NULL;
 
   /* initialization of SD */
   SD_init(&argc, argv);
@@ -237,17 +250,19 @@ int main(int argc, char **argv) {
   /* Check our arguments */
   if (argc < 3) {
     INFO1("Usage: %s platform_file dax_file [jedule_file]", argv[0]);
-    INFO1("example: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", 
-         argv[0]);
+    INFO1
+        ("example: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed",
+         argv[0]);
     exit(1);
   }
   char *tracefilename;
   if (argc == 3) {
-    char *last=strrchr(argv[2],'.');
+    char *last = strrchr(argv[2], '.');
 
-    tracefilename=bprintf("%.*s.jed",
-                         (int)(last==NULL?strlen(argv[2]):last-argv[2]),
-                         argv[2]);
+    tracefilename = bprintf("%.*s.jed",
+                            (int) (last ==
+                                   NULL ? strlen(argv[2]) : last -
+                                   argv[2]), argv[2]);
   } else {
     tracefilename = xbt_strdup(argv[3]);
   }
@@ -258,26 +273,26 @@ int main(int argc, char **argv) {
   /*  Allocating the workstation attribute */
   total_nworkstations = SD_workstation_get_number();
   workstations = SD_workstation_get_list();
-               
-  for(cursor=0; cursor<total_nworkstations; cursor++)
+
+  for (cursor = 0; cursor < total_nworkstations; cursor++)
     SD_workstation_allocate_attribute(workstations[cursor]);
-  
+
 
   /* load the DAX file */
-  dax=SD_daxload(argv[2]);
+  dax = SD_daxload(argv[2]);
 
-  xbt_dynar_foreach(dax,cursor,task) {
-      SD_task_watch(task,SD_DONE);
+  xbt_dynar_foreach(dax, cursor, task) {
+    SD_task_watch(task, SD_DONE);
   }
 
-  /* Schedule the root first */ 
+  /* Schedule the root first */
   xbt_dynar_get_cpy(dax, 0, &task);
-  workstation =  SD_task_get_best_workstation(task);
+  workstation = SD_task_get_best_workstation(task);
   SD_task_schedulel(task, 1, workstation);
-  
-  while(!xbt_dynar_is_empty((changed = SD_simulate(-1.0)))){
+
+  while (!xbt_dynar_is_empty((changed = SD_simulate(-1.0)))) {
     /* Get the set of ready tasks */
-    ready_tasks= get_ready_tasks(dax);
+    ready_tasks = get_ready_tasks(dax);
     if (!xbt_dynar_length(ready_tasks)) {
       xbt_dynar_free_container(&ready_tasks);
       xbt_dynar_free_container(&changed);
@@ -289,40 +304,40 @@ int main(int argc, char **argv) {
      * select the task that has the minimum completion time on
      * its best workstation.
      */
-    xbt_dynar_foreach(ready_tasks, cursor, task){
+    xbt_dynar_foreach(ready_tasks, cursor, task) {
       DEBUG1("%s is ready", SD_task_get_name(task));
-      workstation =  SD_task_get_best_workstation(task);
+      workstation = SD_task_get_best_workstation(task);
       finish_time = finish_on_at(task, workstation);
       if (min_finish_time == -1. || finish_time < min_finish_time) {
-       min_finish_time = finish_time;
-       selected_task = task;
-       selected_workstation = workstation;
-       selected_idx = cursor;
+        min_finish_time = finish_time;
+        selected_task = task;
+        selected_workstation = workstation;
+        selected_idx = cursor;
       }
     }
 
     INFO2("Schedule %s on %s", SD_task_get_name(selected_task),
-         SD_workstation_get_name(selected_workstation));
+          SD_workstation_get_name(selected_workstation));
 
     SD_task_schedulel(selected_task, 1, selected_workstation);
-    SD_workstation_set_available_at(selected_workstation, 
-                                   min_finish_time);
-    
+    SD_workstation_set_available_at(selected_workstation, min_finish_time);
+
     xbt_dynar_free_container(&ready_tasks);
     /* reset the min_finish_time for the next set of ready tasks */
     min_finish_time = -1.;
     xbt_dynar_free_container(&changed);
   }
-  
+
   INFO1("Simulation Time: %f", SD_get_clock());
-  
 
 
 
-  INFO0("------------------- Produce the trace file---------------------------");
-  INFO1("Producing the trace of the run into %s",tracefilename);
-  out = fopen(tracefilename,"w");
-  xbt_assert1(out,"Cannot write to %s",tracefilename);
+
+  INFO0
+      ("------------------- Produce the trace file---------------------------");
+  INFO1("Producing the trace of the run into %s", tracefilename);
+  out = fopen(tracefilename, "w");
+  xbt_assert1(out, "Cannot write to %s", tracefilename);
   free(tracefilename);
 
   output_xml(out, dax);
@@ -333,13 +348,13 @@ int main(int argc, char **argv) {
   xbt_dynar_free_container(&ready_tasks);
   xbt_dynar_free_container(&changed);
 
-  xbt_dynar_foreach(dax,cursor,task) {
+  xbt_dynar_foreach(dax, cursor, task) {
     SD_task_destroy(task);
   }
 
-  for(cursor=0; cursor<total_nworkstations; cursor++)
+  for (cursor = 0; cursor < total_nworkstations; cursor++)
     SD_workstation_free_attribute(workstations[cursor]);
-  
+
   /* exit */
   SD_exit();
   return 0;
index a0eb553..82ac121 100644 (file)
@@ -46,13 +46,13 @@ int main(int argc, char **argv)
   workstations = SD_workstation_get_list();
   w1 = workstations[0];
   w2 = workstations[1];
-  for(i=0;i<2; i++){
-    SD_workstation_set_access_mode(workstations[i], 
-                                  SD_WORKSTATION_SEQUENTIAL_ACCESS);
-    INFO2("Access mode of %s is %s", 
-         SD_workstation_get_name(workstations[i]), 
-         (SD_workstation_get_access_mode(workstations[i]) == 
-          SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");
+  for (i = 0; i < 2; i++) {
+    SD_workstation_set_access_mode(workstations[i],
+                                   SD_WORKSTATION_SEQUENTIAL_ACCESS);
+    INFO2("Access mode of %s is %s",
+          SD_workstation_get_name(workstations[i]),
+          (SD_workstation_get_access_mode(workstations[i]) ==
+           SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");
   }
 
   /* creation of the tasks and their dependencies */
@@ -86,34 +86,34 @@ int main(int argc, char **argv)
                    &(computation_amount[1]), SD_SCHED_NO_COST, rate);
 
   /* let's launch the simulation! */
-  while(xbt_dynar_length(changed_tasks = SD_simulate(-1.0))>0){
-    for(i=0;i<2; i++){
+  while (xbt_dynar_length(changed_tasks = SD_simulate(-1.0)) > 0) {
+    for (i = 0; i < 2; i++) {
       task = SD_workstation_get_current_task(workstations[i]);
       if (task)
-       kind = SD_task_get_kind(task);
-      else{
-       INFO1("There is no task running on %s",
-             SD_workstation_get_name(workstations[i]));
-       continue;
+        kind = SD_task_get_kind(task);
+      else {
+        INFO1("There is no task running on %s",
+              SD_workstation_get_name(workstations[i]));
+        continue;
       }
 
-      switch (kind){
+      switch (kind) {
       case SD_TASK_COMP_SEQ:
-       INFO2("%s is currently running on %s (SD_TASK_COMP_SEQ)",
-             SD_task_get_name(task),
-             SD_workstation_get_name(workstations[i]));
-       break;
+        INFO2("%s is currently running on %s (SD_TASK_COMP_SEQ)",
+              SD_task_get_name(task),
+              SD_workstation_get_name(workstations[i]));
+        break;
       case SD_TASK_COMM_E2E:
-       INFO2("%s is currently running on %s (SD_TASK_COMM_E2E)",
-             SD_task_get_name(task),
-             SD_workstation_get_name(workstations[i]));
-       break;
+        INFO2("%s is currently running on %s (SD_TASK_COMM_E2E)",
+              SD_task_get_name(task),
+              SD_workstation_get_name(workstations[i]));
+        break;
       case SD_TASK_NOT_TYPED:
-       INFO1("Task running on %s has no type",
-             SD_workstation_get_name(workstations[i]));
-       break;
+        INFO1("Task running on %s has no type",
+              SD_workstation_get_name(workstations[i]));
+        break;
       default:
-       ERROR0("Shouldn't be here");
+        ERROR0("Shouldn't be here");
       }
     }
     xbt_dynar_free_container(&changed_tasks);
index 1aa17d1..886f80b 100644 (file)
@@ -63,17 +63,20 @@ int main(int argc, char **argv)
   computation_amount2 = 1000000;
   communication_amount12 = 2000000;
   communication_amount21 = 3000000;
-  INFO3("Computation time for %f flops on %s: %f", computation_amount1, name1,
-        SD_workstation_get_computation_time(w1, computation_amount1));
-  INFO3("Computation time for %f flops on %s: %f", computation_amount2, name2,
-        SD_workstation_get_computation_time(w2, computation_amount2));
+  INFO3("Computation time for %f flops on %s: %f", computation_amount1,
+        name1, SD_workstation_get_computation_time(w1,
+                                                   computation_amount1));
+  INFO3("Computation time for %f flops on %s: %f", computation_amount2,
+        name2, SD_workstation_get_computation_time(w2,
+                                                   computation_amount2));
 
   INFO2("Route between %s and %s:", name1, name2);
   route = SD_route_get_list(w1, w2);
   route_size = SD_route_get_size(w1, w2);
   for (i = 0; i < route_size; i++) {
     INFO3("   Link %s: latency = %f, bandwidth = %f",
-          SD_link_get_name(route[i]), SD_link_get_current_latency(route[i]),
+          SD_link_get_name(route[i]),
+          SD_link_get_current_latency(route[i]),
           SD_link_get_current_bandwidth(route[i]));
   }
   INFO2("Route latency = %f, route bandwidth = %f",
@@ -162,8 +165,9 @@ int main(int argc, char **argv)
   /* estimated time */
   task = taskD;
   INFO2("Estimated time for '%s': %f", SD_task_get_name(task),
-        SD_task_get_execution_time(task, workstation_number, workstation_list,
-                                   computation_amount, communication_amount));
+        SD_task_get_execution_time(task, workstation_number,
+                                   workstation_list, computation_amount,
+                                   communication_amount));
 
   /* let's launch the simulation! */
 
@@ -177,11 +181,10 @@ int main(int argc, char **argv)
                    computation_amount, communication_amount, rate);
 
   changed_tasks = SD_simulate(-1.0);
-  xbt_dynar_foreach(changed_tasks, ctr, task){
-                 INFO3("Task '%s' start time: %f, finish time: %f",
+  xbt_dynar_foreach(changed_tasks, ctr, task) {
+    INFO3("Task '%s' start time: %f, finish time: %f",
           SD_task_get_name(task),
-          SD_task_get_start_time(task),
-          SD_task_get_finish_time(task));
+          SD_task_get_start_time(task), SD_task_get_finish_time(task));
   }
 
   xbt_dynar_get_cpy(changed_tasks, 0, &checkD);
index 0184860..cc86f17 100644 (file)
@@ -68,7 +68,8 @@ int main(int argc, char **argv)
   hosts = SD_workstation_get_list();
 
   /* sorting hosts by hostname */
-  qsort((void *) hosts, n_hosts, sizeof(SD_workstation_t), nameCompareHosts);
+  qsort((void *) hosts, n_hosts, sizeof(SD_workstation_t),
+        nameCompareHosts);
 
   /* creation of the tasks */
   taskInit = SD_task_create("Initial", NULL, 1.0);
@@ -176,11 +177,12 @@ int main(int argc, char **argv)
 
 
   /* scheduling the tasks */
-  SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST, -1.0);
-  SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST, PtoPcomm1_table,
-                   -1.0);
-  SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST, PtoPcomm2_table,
+  SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST,
                    -1.0);
+  SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST,
+                   PtoPcomm1_table, -1.0);
+  SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST,
+                   PtoPcomm2_table, -1.0);
   SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts,
                    ParComp_wocomm_cost, ParComp_wocomm_table, -1.0);
   SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost,
@@ -191,7 +193,8 @@ int main(int argc, char **argv)
                    InterRedist_table, -1.0);
   SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts,
                    ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0);
-  SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost, SD_SCHED_NO_COST, -1.0);
+  SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost,
+                   SD_SCHED_NO_COST, -1.0);
 
   /* let's launch the simulation! */
   changed_tasks = SD_simulate(-1.0);
index 8e20d43..ad8d4b4 100644 (file)
@@ -63,17 +63,20 @@ int main(int argc, char **argv)
   computation_amount2 = 1000000;
   communication_amount12 = 2000000;
   communication_amount21 = 3000000;
-  INFO3("Computation time for %f flops on %s: %f", computation_amount1, name1,
-        SD_workstation_get_computation_time(w1, computation_amount1));
-  INFO3("Computation time for %f flops on %s: %f", computation_amount2, name2,
-        SD_workstation_get_computation_time(w2, computation_amount2));
+  INFO3("Computation time for %f flops on %s: %f", computation_amount1,
+        name1, SD_workstation_get_computation_time(w1,
+                                                   computation_amount1));
+  INFO3("Computation time for %f flops on %s: %f", computation_amount2,
+        name2, SD_workstation_get_computation_time(w2,
+                                                   computation_amount2));
 
   INFO2("Route between %s and %s:", name1, name2);
   route = SD_route_get_list(w1, w2);
   route_size = SD_route_get_size(w1, w2);
   for (i = 0; i < route_size; i++) {
     INFO3("   Link %s: latency = %f, bandwidth = %f",
-          SD_link_get_name(route[i]), SD_link_get_current_latency(route[i]),
+          SD_link_get_name(route[i]),
+          SD_link_get_current_latency(route[i]),
           SD_link_get_current_bandwidth(route[i]));
   }
   INFO2("Route latency = %f, route bandwidth = %f",
@@ -162,8 +165,9 @@ int main(int argc, char **argv)
   /* estimated time */
   task = taskD;
   INFO2("Estimated time for '%s': %f", SD_task_get_name(task),
-        SD_task_get_execution_time(task, workstation_number, workstation_list,
-                                   computation_amount, communication_amount));
+        SD_task_get_execution_time(task, workstation_number,
+                                   workstation_list, computation_amount,
+                                   communication_amount));
 
   /* let's launch the simulation! */
 
@@ -177,11 +181,10 @@ int main(int argc, char **argv)
                    computation_amount, communication_amount, rate);
 
   changed_tasks = SD_simulate(-1.0);
-  xbt_dynar_foreach(changed_tasks, ctr, task){
-                 INFO3("Task '%s' start time: %f, finish time: %f",
+  xbt_dynar_foreach(changed_tasks, ctr, task) {
+    INFO3("Task '%s' start time: %f, finish time: %f",
           SD_task_get_name(task),
-          SD_task_get_start_time(task),
-          SD_task_get_finish_time(task));
+          SD_task_get_start_time(task), SD_task_get_finish_time(task));
   }
 
   xbt_dynar_get_cpy(changed_tasks, 0, &checkD);
index 83e6b10..72f5b61 100644 (file)
  **/
 static int ibm_test(int rank, int size)
 {
-         int success = 1;
+  int success = 1;
 #define MAXLEN  10000
 
-         int root = 0, i, j, k;
-         int out[MAXLEN];
-         int in[MAXLEN];
-
-         for (j = 1; j <= MAXLEN; j *= 10) {
-                   for (i = 0; i < j; i++)
-                               out[i] = i;
-
-                   MPI_Allreduce(out, in, j, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
-                   MPI_Barrier(MPI_COMM_WORLD);
-
-                   if (rank == root) {
-                               for (k = 0; k < j; k++) {
-                                         if (in[k] != k * size) {
-                                                   printf("bad answer (%d) at index %d of %d (should be %d)", in[k], k,
-                                                                         j, k * size);
-                                                   success = 0;
-                                                   break;
-                                         }
-                               }
-                   }
-         }
-         return (success);
+  int root = 0, i, j, k;
+  int out[MAXLEN];
+  int in[MAXLEN];
+
+  for (j = 1; j <= MAXLEN; j *= 10) {
+    for (i = 0; i < j; i++)
+      out[i] = i;
+
+    MPI_Allreduce(out, in, j, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
+
+    if (rank == root) {
+      for (k = 0; k < j; k++) {
+        if (in[k] != k * size) {
+          printf("bad answer (%d) at index %d of %d (should be %d)", in[k],
+                 k, j, k * size);
+          success = 0;
+          break;
+        }
+      }
+    }
+  }
+  return (success);
 }
 
 
index a46f765..ef2068e 100644 (file)
 
 
 #define MAXLEN 10000
-int main( int argc, char *argv[] )
+
+int main(int argc, char *argv[])
 {
 #define N 1000000
-   int *out, *in,i,j,k;
-   int myself,tasks;
-   out = malloc(N*sizeof(int));
-   in  = malloc(N*sizeof(int));
-   if ((out==NULL) || (in==NULL)) {
-           printf("Error: cannot allocate N bytes for in or out arrays\n");
-           exit(1);
-   }
-   MPI_Init( &argc,&argv );
-   MPI_Comm_rank(MPI_COMM_WORLD,&myself);
-   MPI_Comm_size(MPI_COMM_WORLD,&tasks);
-   for(j=1;j<=MAXLEN;j*=10)  {
-           if ( 0 == myself ) {
-                   printf("* calling MPI_Alltoall with buffers of %d ints\n",j);
-           }
-           for(i=0;i<j*tasks;i++)  
-                   out[i] = myself;
-
-           MPI_Alltoall(out,j,MPI_INT,in,j,MPI_INT,MPI_COMM_WORLD);
-
-           for(i=0;i<tasks;i++)  {
-                   for(k=0;k<j;k++) {
-                           if(in[k+i*j] != i) {  
-                                   printf("<%d> bad answer (%d) at index %d of %d (should be %d)\n",myself,in[k+i*j],k+i*j,j*tasks,i); 
-                                   break; 
-                           }
-                   }
-           }
-   }
-   MPI_Barrier(MPI_COMM_WORLD);
-   if(myself==0)  printf("TEST COMPLETE\n");
-   MPI_Finalize();
-   return EXIT_SUCCESS;
+  int *out, *in, i, j, k;
+  int myself, tasks;
+
+  out = malloc(N * sizeof(int));
+  in = malloc(N * sizeof(int));
+  if ((out == NULL) || (in == NULL)) {
+    printf("Error: cannot allocate N bytes for in or out arrays\n");
+    exit(1);
+  }
+  MPI_Init(&argc, &argv);
+  MPI_Comm_rank(MPI_COMM_WORLD, &myself);
+  MPI_Comm_size(MPI_COMM_WORLD, &tasks);
+  for (j = 1; j <= MAXLEN; j *= 10) {
+    if (0 == myself) {
+      printf("* calling MPI_Alltoall with buffers of %d ints\n", j);
+    }
+    for (i = 0; i < j * tasks; i++)
+      out[i] = myself;
+
+    MPI_Alltoall(out, j, MPI_INT, in, j, MPI_INT, MPI_COMM_WORLD);
+
+    for (i = 0; i < tasks; i++) {
+      for (k = 0; k < j; k++) {
+        if (in[k + i * j] != i) {
+          printf("<%d> bad answer (%d) at index %d of %d (should be %d)\n",
+                 myself, in[k + i * j], k + i * j, j * tasks, i);
+          break;
+        }
+      }
+    }
+  }
+  MPI_Barrier(MPI_COMM_WORLD);
+  if (myself == 0)
+    printf("TEST COMPLETE\n");
+  MPI_Finalize();
+  return EXIT_SUCCESS;
 }
index 56aa80e..485752e 100644 (file)
 #define EXIT_FAILURE 1
 #endif
 
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
 {
-    int rank, size;
-    int i;
-    int *sb;
-    int *rb;
-    int status;
-
-    MPI_Init(&argc,&argv);
-    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
-    MPI_Comm_size(MPI_COMM_WORLD,&size);
-    
-    sb = (int *)malloc(size*sizeof(int));
-    if ( !sb ) {
-        perror( "can't allocate send buffer" );fflush(stderr);
-        MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
-    }
-    rb = (int *)malloc(size*sizeof(int));
-    if ( !rb ) {
-        perror( "can't allocate recv buffer");fflush(stderr);
-        free(sb);
-        MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
-    }
-    for ( i=0 ; i < size ; ++i ) {
-        sb[i] = rank + 1;
-        rb[i] = 0;
-    }
-    status = MPI_Alltoall(sb, 1, MPI_INT, rb, 1, MPI_INT, MPI_COMM_WORLD);
+  int rank, size;
+  int i;
+  int *sb;
+  int *rb;
+  int status;
 
-    printf("[%d] rcvbuf=[",rank);
-    for (i=0;i<size;i++) 
-            printf("%d ",rb[i]);
-    printf("]\n");
+  MPI_Init(&argc, &argv);
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  MPI_Comm_size(MPI_COMM_WORLD, &size);
 
+  sb = (int *) malloc(size * sizeof(int));
+  if (!sb) {
+    perror("can't allocate send buffer");
+    fflush(stderr);
+    MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
+  }
+  rb = (int *) malloc(size * sizeof(int));
+  if (!rb) {
+    perror("can't allocate recv buffer");
+    fflush(stderr);
+    free(sb);
+    MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
+  }
+  for (i = 0; i < size; ++i) {
+    sb[i] = rank + 1;
+    rb[i] = 0;
+  }
+  status = MPI_Alltoall(sb, 1, MPI_INT, rb, 1, MPI_INT, MPI_COMM_WORLD);
 
-    if (rank == 0) {
-        if (status != 0) {
-            printf("all_to_all returned %d\n",status);fflush(stdout);
-        }
+  printf("[%d] rcvbuf=[", rank);
+  for (i = 0; i < size; i++)
+    printf("%d ", rb[i]);
+  printf("]\n");
+
+
+  if (rank == 0) {
+    if (status != 0) {
+      printf("all_to_all returned %d\n", status);
+      fflush(stdout);
     }
-    free(sb);
-    free(rb);
-    MPI_Finalize();
-    return(EXIT_SUCCESS);
+  }
+  free(sb);
+  free(rb);
+  MPI_Finalize();
+  return (EXIT_SUCCESS);
 }
index 5c3857c..492db4e 100644 (file)
@@ -4,7 +4,7 @@
  *      See COPYRIGHT in top-level directory.
  */
 #include "mpi.h"
- #include <string.h>
+#include <string.h>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -53,7 +53,7 @@
 static void print_buffer_int(void *buf, int len, char *msg, int rank)
 {
   int tmp, *v;
-  printf("**<%d> %s (#%d): ", rank, msg,len);
+  printf("**<%d> %s (#%d): ", rank, msg, len);
   for (tmp = 0; tmp < len; tmp++) {
     v = buf;
     printf("[%d]", v[tmp]);
@@ -63,109 +63,109 @@ static void print_buffer_int(void *buf, int len, char *msg, int rank)
 }
 
 
-int main( int argc, char **argv )
+int main(int argc, char **argv)
 {
 
-        MPI_Comm comm;
-        int      *sbuf, *rbuf, *erbuf;
-        int      rank, size;
-        int      *sendcounts, *recvcounts, *rdispls, *sdispls;
-        int      i, j, *p, err;
-
-        MPI_Init( &argc, &argv );
-        err = 0;
-
-        comm = MPI_COMM_WORLD;
-
-        /* Create the buffer */
-        MPI_Comm_size( comm, &size );
-        MPI_Comm_rank( comm, &rank );
-        sbuf = (int *)malloc( size * size * sizeof(int) );
-        rbuf = (int *)malloc( size * size * sizeof(int) );
-        erbuf = (int *)malloc( size * size * sizeof(int) ); // expected
-        if (!sbuf || !rbuf) {
-                fprintf( stderr, "Could not allocated buffers!\n" );
-                MPI_Abort( comm, 1 );
-        }
-
-        /* Load up the buffers */
-        for (i=0; i<size*size; i++) {
-                sbuf[i] = i + 100*rank;
-                rbuf[i] = -i;
-                erbuf[i]= -i;
-        }
-
-        /* Create and load the arguments to alltoallv */
-        sendcounts = (int *)malloc( size * sizeof(int) );
-        recvcounts = (int *)malloc( size * sizeof(int) );
-        rdispls    = (int *)malloc( size * sizeof(int) );
-        sdispls    = (int *)malloc( size * sizeof(int) );
-        if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
-                fprintf( stderr, "Could not allocate arg items!\n" );
-                MPI_Abort( comm, 1 );
-        }
-        for (i=0; i<size; i++) {
-                sendcounts[i] = i;
-                recvcounts[i] = rank;
-                rdispls[i]    = i * rank;
-                sdispls[i]    = (i * (i+1))/2;
-        }
-
-        /* debug */
-        /* 
-        print_buffer_int( sbuf, size*size, strdup("sbuf:"),rank);
-        print_buffer_int( sendcounts, size, strdup("scount:"),rank);
-        print_buffer_int( recvcounts, size, strdup("rcount:"),rank);
-        print_buffer_int( sdispls, size, strdup("sdisp:"),rank);
-        print_buffer_int( rdispls, size, strdup("rdisp:"),rank);
-        */
-
-
-        /* debug : erbuf */
-        /* debug
-        for (i=0; i<size; i++) {
-                for (j=0; j<rank; j++) {
-                        *(erbuf+j+ rdispls[i]) = i * 100 + (rank*(rank+1))/2 + j; 
-                }
-        }
-        */
-
-
-        //print_buffer_int( erbuf, size*size, strdup("erbuf:"),rank);
-
-        MPI_Alltoallv( sbuf, sendcounts, sdispls, MPI_INT,
-                        rbuf, recvcounts, rdispls, MPI_INT, comm );
-
-        // debug: print_buffer_int( rbuf, size*size, strdup("rbuf:"),rank);
-
-        
-        /* Check rbuf */
-        for (i=0; i<size; i++) {
-                p = rbuf + rdispls[i];
-                for (j=0; j<rank; j++) {
-                        if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
-                                fprintf( stderr, "** Error: <%d> got %d expected %d for %dth\n",
-                                                rank, p[j],(i*(i+1))/2 + j, j );
-                                err++;
-                        }
-                }
-        }
-
-        /* Summary */
-        if ( err > 0) {
-                      printf("<%d> Alltoallv test: failure (%d errors).\n",rank,err);
-        }
-        if ( 0==rank ) {
-                printf("* Alltoallv TEST COMPLETE.\n");
-        }
-        free( sdispls );
-        free( rdispls );
-        free( recvcounts );
-        free( sendcounts );
-        free( rbuf );
-        free( sbuf );
-            
-        MPI_Barrier( MPI_COMM_WORLD);
-        MPI_Finalize();
-        return 0;
+  MPI_Comm comm;
+  int *sbuf, *rbuf, *erbuf;
+  int rank, size;
+  int *sendcounts, *recvcounts, *rdispls, *sdispls;
+  int i, j, *p, err;
+
+  MPI_Init(&argc, &argv);
+  err = 0;
+
+  comm = MPI_COMM_WORLD;
+
+  /* Create the buffer */
+  MPI_Comm_size(comm, &size);
+  MPI_Comm_rank(comm, &rank);
+  sbuf = (int *) malloc(size * size * sizeof(int));
+  rbuf = (int *) malloc(size * size * sizeof(int));
+  erbuf = (int *) malloc(size * size * sizeof(int));    // expected
+  if (!sbuf || !rbuf) {
+    fprintf(stderr, "Could not allocated buffers!\n");
+    MPI_Abort(comm, 1);
+  }
+
+  /* Load up the buffers */
+  for (i = 0; i < size * size; i++) {
+    sbuf[i] = i + 100 * rank;
+    rbuf[i] = -i;
+    erbuf[i] = -i;
+  }
+
+  /* Create and load the arguments to alltoallv */
+  sendcounts = (int *) malloc(size * sizeof(int));
+  recvcounts = (int *) malloc(size * sizeof(int));
+  rdispls = (int *) malloc(size * sizeof(int));
+  sdispls = (int *) malloc(size * sizeof(int));
+  if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
+    fprintf(stderr, "Could not allocate arg items!\n");
+    MPI_Abort(comm, 1);
+  }
+  for (i = 0; i < size; i++) {
+    sendcounts[i] = i;
+    recvcounts[i] = rank;
+    rdispls[i] = i * rank;
+    sdispls[i] = (i * (i + 1)) / 2;
+  }
+
+  /* debug */
+  /* 
+     print_buffer_int( sbuf, size*size, strdup("sbuf:"),rank);
+     print_buffer_int( sendcounts, size, strdup("scount:"),rank);
+     print_buffer_int( recvcounts, size, strdup("rcount:"),rank);
+     print_buffer_int( sdispls, size, strdup("sdisp:"),rank);
+     print_buffer_int( rdispls, size, strdup("rdisp:"),rank);
+   */
+
+
+  /* debug : erbuf */
+  /* debug
+     for (i=0; i<size; i++) {
+     for (j=0; j<rank; j++) {
+     *(erbuf+j+ rdispls[i]) = i * 100 + (rank*(rank+1))/2 + j; 
+     }
+     }
+   */
+
+
+  //print_buffer_int( erbuf, size*size, strdup("erbuf:"),rank);
+
+  MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT,
+                rbuf, recvcounts, rdispls, MPI_INT, comm);
+
+  // debug: print_buffer_int( rbuf, size*size, strdup("rbuf:"),rank);
+
+
+  /* Check rbuf */
+  for (i = 0; i < size; i++) {
+    p = rbuf + rdispls[i];
+    for (j = 0; j < rank; j++) {
+      if (p[j] != i * 100 + (rank * (rank + 1)) / 2 + j) {
+        fprintf(stderr, "** Error: <%d> got %d expected %d for %dth\n",
+                rank, p[j], (i * (i + 1)) / 2 + j, j);
+        err++;
+      }
+    }
+  }
+
+  /* Summary */
+  if (err > 0) {
+    printf("<%d> Alltoallv test: failure (%d errors).\n", rank, err);
+  }
+  if (0 == rank) {
+    printf("* Alltoallv TEST COMPLETE.\n");
+  }
+  free(sdispls);
+  free(rdispls);
+  free(recvcounts);
+  free(sendcounts);
+  free(rbuf);
+  free(sbuf);
+
+  MPI_Barrier(MPI_COMM_WORLD);
+  MPI_Finalize();
+  return 0;
 }
index be4ded8..568015e 100644 (file)
@@ -8,27 +8,27 @@
 #include <mpi.h>
 
 
-int main (int argc, char **argv) {
-         int size, rank;
-         int root=0;
-         int value;
-         double start_timer;
+int main(int argc, char **argv)
+{
+  int size, rank;
+  int root = 0;
+  int value;
+  double start_timer;
 
-         MPI_Init(&argc, &argv);
-         MPI_Comm_size(MPI_COMM_WORLD, &size);
-         MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  MPI_Init(&argc, &argv);
+  MPI_Comm_size(MPI_COMM_WORLD, &size);
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
   start_timer = MPI_Wtime();
 
-  MPI_Barrier( MPI_COMM_WORLD );
+  MPI_Barrier(MPI_COMM_WORLD);
 
-  MPI_Barrier( MPI_COMM_WORLD );
+  MPI_Barrier(MPI_COMM_WORLD);
   if (0 == rank) {
-          printf("... Barrier ....\n");
-          printf("Elapsed=%lf s\n", MPI_Wtime() - start_timer);
+    printf("... Barrier ....\n");
+    printf("Elapsed=%lf s\n", MPI_Wtime() - start_timer);
   }
 
   MPI_Finalize();
   return 0;
 }
-
index ba172dd..72ad419 100644 (file)
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
   }
   MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD);
   if (value != 17) {
-     printf("node %d has value %d after broadcast\n", rank, value);
+    printf("node %d has value %d after broadcast\n", rank, value);
   }
 
   MPI_Barrier(MPI_COMM_WORLD);
index b603bab..75defac 100644 (file)
@@ -74,8 +74,9 @@ int main(int argc, char *argv[])
         exit(EXIT_FAILURE);
       }
       seconds =
-        (double) (stop_time->tv_sec - start_time->tv_sec) +
-        (double) (stop_time->tv_usec - start_time->tv_usec) / ONE_MILLION;
+          (double) (stop_time->tv_sec - start_time->tv_sec) +
+          (double) (stop_time->tv_usec -
+                    start_time->tv_usec) / ONE_MILLION;
     }
 
     free(buffer);
index 4811b80..8f82144 100644 (file)
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
   double d;
   MPI_Init(&argc, &argv);
   d = 2.0;
-/*  SMPI_DO_ONCE */{
+/*  SMPI_DO_ONCE */  {
     for (i = 0; i < atoi(argv[1]); i++) {
       if (d < 10000) {
         d = d * d;
index ed22bfc..ad823a2 100644 (file)
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
   double d;
   MPI_Init(&argc, &argv);
   d = 2.0;
-/*  SMPI_DO_ONCE */{
+/*  SMPI_DO_ONCE */  {
     for (i = 0; i < atoi(argv[1]); i++) {
       if (d < 10000) {
         d = d * d;
@@ -23,7 +23,7 @@ int main(int argc, char *argv[])
     }
     printf("%d %f\n", i, d);
   }
-/*  SMPI_DO_ONCE */{
+/*  SMPI_DO_ONCE */  {
     for (i = 0; i < 2 * atoi(argv[1]); i++) {
       if (d < 10000) {
         d = d * d;
index 21cdc54..05a2616 100644 (file)
@@ -7,7 +7,8 @@
 #include <stdio.h>
 #include <mpi.h>
 
-int main (int argc, char **argv) {
+int main(int argc, char **argv)
+{
   int size, rank;
 
   char name[MPI_MAX_PROCESSOR_NAME];
@@ -17,7 +18,7 @@ int main (int argc, char **argv) {
   MPI_Comm_size(MPI_COMM_WORLD, &size);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
-  MPI_Get_processor_name(name,&len);
+  MPI_Get_processor_name(name, &len);
   printf("rank %d is running on host %s\n", rank, name);
   MPI_Finalize();
   return 0;
index 18b3420..a328121 100644 (file)
@@ -24,7 +24,7 @@ int main(int argc, char *argv[])
   MPI_Status status;
   struct timeval *start_time = NULL, *stop_time = NULL;
   long parallel_usecs, parallel_usecs_total =
-    0, sequential_usecs, sequential_usecs_total = 0;
+      0, sequential_usecs, sequential_usecs_total = 0;
 
   MPI_Init(&argc, &argv);
 
@@ -91,15 +91,16 @@ int main(int argc, char *argv[])
 
         for (i = 1, j = n; i < size && j < N; i++, j += k) {
           k = N / size + ((i < (N % size)) ? 1 : 0);
-          MPI_Send(matrix + N * j, N * k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
+          MPI_Send(matrix + N * j, N * k, MPI_DOUBLE, i, 0,
+                   MPI_COMM_WORLD);
           MPI_Send(vector, N, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
         }
 
         // sanity check
 #ifdef DEBUG
         if (i != size || j != N) {
-          printf("index calc error: i = %d, size = %d, j = %d, N = %d\n", i,
-                 size, j, N);
+          printf("index calc error: i = %d, size = %d, j = %d, N = %d\n",
+                 i, size, j, N);
           MPI_Abort(MPI_COMM_WORLD, SANITY_ERROR);
           exit(SANITY_ERROR);
         }
@@ -131,14 +132,15 @@ int main(int argc, char *argv[])
 
         for (i = 1, j = n; i < size && j < N; i++, j += k) {
           k = N / size + ((i < (N % size)) ? 1 : 0);
-          MPI_Recv(vcalc + j, k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &status);
+          MPI_Recv(vcalc + j, k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD,
+                   &status);
         }
 
         // sanity check
 #ifdef DEBUG
         if (i != size || j != N) {
-          printf("index calc error 2: i = %d, size = %d, j = %d, N = %d\n", i,
-                 size, j, N);
+          printf("index calc error 2: i = %d, size = %d, j = %d, N = %d\n",
+                 i, size, j, N);
           MPI_Abort(MPI_COMM_WORLD, SANITY_ERROR);
           exit(SANITY_ERROR);
         }
@@ -151,8 +153,8 @@ int main(int argc, char *argv[])
         }
 
         parallel_usecs =
-          (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
-          (start_time->tv_sec * 1000000 + start_time->tv_usec);
+            (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
+            (start_time->tv_sec * 1000000 + start_time->tv_usec);
 
         if (-1 == gettimeofday(start_time, NULL)) {
           printf("couldn't set start_time on node 0!\n");
@@ -175,8 +177,8 @@ int main(int argc, char *argv[])
         }
 
         sequential_usecs =
-          (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
-          (start_time->tv_sec * 1000000 + start_time->tv_usec);
+            (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
+            (start_time->tv_sec * 1000000 + start_time->tv_usec);
 
         // verify correctness
         for (i = 0; i < N && vcalc[i] == vcheck[i]; i++);
@@ -185,11 +187,11 @@ int main(int argc, char *argv[])
 
         if (i == N) {
           printf
-            ("ptime: %ld us, stime: %ld us, speedup: %.3f, nodes: %d, efficiency: %.3f\n",
-             parallel_usecs, sequential_usecs,
-             (double) sequential_usecs / (double) parallel_usecs, size,
-             (double) sequential_usecs / ((double) parallel_usecs *
-                                          (double) size));
+              ("ptime: %ld us, stime: %ld us, speedup: %.3f, nodes: %d, efficiency: %.3f\n",
+               parallel_usecs, sequential_usecs,
+               (double) sequential_usecs / (double) parallel_usecs, size,
+               (double) sequential_usecs / ((double) parallel_usecs *
+                                            (double) size));
 
           parallel_usecs_total += parallel_usecs;
           sequential_usecs_total += sequential_usecs;
@@ -213,14 +215,15 @@ int main(int argc, char *argv[])
     printf("prog: blocking, ");
     if (0 < successful_iterations) {
       printf
-        ("iterations: %d, avg. ptime: %.3f us, avg. stime: %.3f us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n",
-         successful_iterations,
-         (double) parallel_usecs_total / (double) successful_iterations,
-         (double) sequential_usecs_total / (double) successful_iterations,
-         (double) sequential_usecs_total / (double) parallel_usecs_total,
-         size,
-         (double) sequential_usecs_total / ((double) parallel_usecs_total *
-                                            (double) size));
+          ("iterations: %d, avg. ptime: %.3f us, avg. stime: %.3f us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n",
+           successful_iterations,
+           (double) parallel_usecs_total / (double) successful_iterations,
+           (double) sequential_usecs_total /
+           (double) successful_iterations,
+           (double) sequential_usecs_total / (double) parallel_usecs_total,
+           size,
+           (double) sequential_usecs_total /
+           ((double) parallel_usecs_total * (double) size));
     } else {
       printf("no successful iterations!\n");
     }
index e7b4a7d..871c229 100644 (file)
 
 int main(int argc, char *argv[])
 {
-         const int tag1 = 42, tag2= 43;           /* Message tag */
-         int rank; 
-         int size; 
-         int msg=99;
-         int err;
-         int pivot;
-         MPI_Status status;
+  const int tag1 = 42, tag2 = 43;       /* Message tag */
+  int rank;
+  int size;
+  int msg = 99;
+  int err;
+  int pivot;
+  MPI_Status status;
 
-         err = MPI_Init(&argc, &argv); /* Initialize MPI */
-         if (err != MPI_SUCCESS) {
-                   printf("MPI initialization failed!\n");
-                   exit(1);
-         }
-         err = MPI_Comm_size(MPI_COMM_WORLD, &size); /* Get nr of tasks */
-         err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);     /* Get id of this process */
-         if ( size < 2 ) {
-                   printf("run this program with exactly 2 processes (-np 2)\n");
-                   MPI_Finalize();         
-                   exit(0);
-         }
-        if (0 == rank) {
-                               printf("\n    *** Ping-pong test (MPI_Send/MPI_Recv) ***\n\n");
-         }
+  err = MPI_Init(&argc, &argv); /* Initialize MPI */
+  if (err != MPI_SUCCESS) {
+    printf("MPI initialization failed!\n");
+    exit(1);
+  }
+  err = MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
+  err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
+  if (size < 2) {
+    printf("run this program with exactly 2 processes (-np 2)\n");
+    MPI_Finalize();
+    exit(0);
+  }
+  if (0 == rank) {
+    printf("\n    *** Ping-pong test (MPI_Send/MPI_Recv) ***\n\n");
+  }
 
-        /* start pingpong tests between several pairs */
-         for (pivot=0; pivot<size-1; pivot++) {
+  /* start pingpong tests between several pairs */
+  for (pivot = 0; pivot < size - 1; pivot++) {
 
-                   if (pivot == rank) {           
-                               printf("\n== pivot=%d : pingpong [%d] <--> [%d]\n",pivot,pivot,pivot+1);
+    if (pivot == rank) {
+      printf("\n== pivot=%d : pingpong [%d] <--> [%d]\n", pivot, pivot,
+             pivot + 1);
 
-                               int dst= rank + 1;
-                               printf("[%d] About to send 1st message '%d' to process [%d] \n", rank,msg, dst);
-                               err = MPI_Send(&msg, 1, MPI_INT, dst, tag1, MPI_COMM_WORLD);
+      int dst = rank + 1;
+      printf("[%d] About to send 1st message '%d' to process [%d] \n",
+             rank, msg, dst);
+      err = MPI_Send(&msg, 1, MPI_INT, dst, tag1, MPI_COMM_WORLD);
 
-                               err = MPI_Recv(&msg, 1, MPI_INT, dst, tag2, MPI_COMM_WORLD, &status);    /* Receive a message */
-                               printf("[%d] Received relpy message '%d' from process [%d] \n", rank,msg, dst);
+      err = MPI_Recv(&msg, 1, MPI_INT, dst, tag2, MPI_COMM_WORLD, &status);     /* Receive a message */
+      printf("[%d] Received relpy message '%d' from process [%d] \n", rank,
+             msg, dst);
 
-                   }
-                   if ((pivot+1) == rank) {
-                               int src= rank - 1;
-                               err = MPI_Recv(&msg, 1, MPI_INT, src, tag1, MPI_COMM_WORLD, &status);    /* Receive a message */
-                               printf("[%d] Received 1st message '%d' from process [%d] \n", rank,msg, src);
-                               msg++;
-                               printf("[%d] increment message's value to  '%d'\n", rank,msg);
-                               printf("[%d] About to send back message '%d' to process [%d] \n", rank,msg, src);
-                               err = MPI_Send(&msg, 1, MPI_INT, src, tag2, MPI_COMM_WORLD);
-                   }
-         }
-         err = MPI_Finalize();         /* Terminate MPI */
-         return 0;
+    }
+    if ((pivot + 1) == rank) {
+      int src = rank - 1;
+      err = MPI_Recv(&msg, 1, MPI_INT, src, tag1, MPI_COMM_WORLD, &status);     /* Receive a message */
+      printf("[%d] Received 1st message '%d' from process [%d] \n", rank,
+             msg, src);
+      msg++;
+      printf("[%d] increment message's value to  '%d'\n", rank, msg);
+      printf("[%d] About to send back message '%d' to process [%d] \n",
+             rank, msg, src);
+      err = MPI_Send(&msg, 1, MPI_INT, src, tag2, MPI_COMM_WORLD);
+    }
+  }
+  err = MPI_Finalize();         /* Terminate MPI */
+  return 0;
 }
index bd4e151..2946edc 100644 (file)
@@ -43,8 +43,8 @@ static int ibm_test(int rank, int size)
     if (rank == root) {
       for (k = 0; k < j; k++) {
         if (in[k] != k * size) {
-          printf("bad answer (%d) at index %d of %d (should be %d)", in[k], k,
-                 j, k * size);
+          printf("bad answer (%d) at index %d of %d (should be %d)", in[k],
+                 k, j, k * size);
           success = 0;
           break;
         }
@@ -81,7 +81,8 @@ int main(int argc, char **argv)
 
   //printf("[%d] has value %d\n", rank, value);
   MPI_Reduce(&value, &sum, 1, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
-  MPI_Reduce(&value, &sum_mirror, 1, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
+  MPI_Reduce(&value, &sum_mirror, 1, MPI_INT, MPI_SUM, root,
+             MPI_COMM_WORLD);
 
   MPI_Reduce(&value, &min, 1, MPI_INT, MPI_MIN, root, MPI_COMM_WORLD);
   MPI_Reduce(&value, &max, 1, MPI_INT, MPI_MAX, root, MPI_COMM_WORLD);
index 8833cea..e4a6303 100644 (file)
 #include <stdio.h>
 #include <mpi.h>
 
-static int ibm_test(int rank, int size)  {
+static int ibm_test(int rank, int size)
+{
 
 #define MAXLEN  10000
 
-         int success = 1;
-         int root=0;
-        int i,j,k;
-         int *out;
-         int *in;
-        
-        
-        out = malloc(MAXLEN*64*sizeof(int));
-        in  = malloc(MAXLEN*sizeof(int));
-
-         for(j=1;j<=MAXLEN;j*=10){
-                root=(root+1)%size;
-                   if (rank == root)
-                               for(i=0;i<j*size;i++)  
-                                out[i] = i;
-
-                   MPI_Scatter(out,j,MPI_INT,in,j,MPI_INT,root,MPI_COMM_WORLD);
-
-                   for(k=0;k<j;k++) {
-                               if(in[k] != k+rank*j) {
-                                         fprintf(stderr,"task %d bad answer (%d) at index %d k of %d (should be %d)", rank,in[k],k,j,(k+rank*j));
-                                         return( 0 ); 
-                               }
-                   }
-         }
-        free(out);
-        free(in);
-         MPI_Barrier( MPI_COMM_WORLD );
-        return( success );
+  int success = 1;
+  int root = 0;
+  int i, j, k;
+  int *out;
+  int *in;
+
+
+  out = malloc(MAXLEN * 64 * sizeof(int));
+  in = malloc(MAXLEN * sizeof(int));
+
+  for (j = 1; j <= MAXLEN; j *= 10) {
+    root = (root + 1) % size;
+    if (rank == root)
+      for (i = 0; i < j * size; i++)
+        out[i] = i;
+
+    MPI_Scatter(out, j, MPI_INT, in, j, MPI_INT, root, MPI_COMM_WORLD);
+
+    for (k = 0; k < j; k++) {
+      if (in[k] != k + rank * j) {
+        fprintf(stderr,
+                "task %d bad answer (%d) at index %d k of %d (should be %d)",
+                rank, in[k], k, j, (k + rank * j));
+        return (0);
+      }
+    }
+  }
+  free(out);
+  free(in);
+  MPI_Barrier(MPI_COMM_WORLD);
+  return (success);
 }
 
 /**
  * small test: the root sends a single distinct double to other processes
  **/
-static int small_test( int rank, int size ) {
-        int success=1;
-        int retval;
-        int sendcount=1; // one double to each process
-        int recvcount=1;
-        int i;
-        double *sndbuf =NULL;
-        double rcvd;
-        int root=0; // arbitrary choice 
-
-        // on root, initialize sendbuf
-        if (root == rank )  {
-                sndbuf = malloc( size * sizeof(double));
-                for (i=0; i< size;i++) {
-                        sndbuf[i] = (double) i;
-                }
-        }
-
-        retval=MPI_Scatter(sndbuf, sendcount, MPI_DOUBLE, &rcvd,recvcount,MPI_DOUBLE,root,MPI_COMM_WORLD);
-        if (retval != MPI_SUCCESS) {
-                fprintf(stderr,"(%s:%d) MPI_Scatter() returned retval=%d\n",__FILE__,__LINE__,retval);
-                return 0;
-        }
-
-        // verification
-        if ((double)rank != rcvd) {
-                fprintf(stderr,"[%d] has %lf instead of %d\n",rank,rcvd,rank);
-                success=0;
-        }
-        return(success);
+static int small_test(int rank, int size)
+{
+  int success = 1;
+  int retval;
+  int sendcount = 1;            // one double to each process
+  int recvcount = 1;
+  int i;
+  double *sndbuf = NULL;
+  double rcvd;
+  int root = 0;                 // arbitrary choice 
+
+  // on root, initialize sendbuf
+  if (root == rank) {
+    sndbuf = malloc(size * sizeof(double));
+    for (i = 0; i < size; i++) {
+      sndbuf[i] = (double) i;
+    }
+  }
+
+  retval =
+      MPI_Scatter(sndbuf, sendcount, MPI_DOUBLE, &rcvd, recvcount,
+                  MPI_DOUBLE, root, MPI_COMM_WORLD);
+  if (retval != MPI_SUCCESS) {
+    fprintf(stderr, "(%s:%d) MPI_Scatter() returned retval=%d\n", __FILE__,
+            __LINE__, retval);
+    return 0;
+  }
+  // verification
+  if ((double) rank != rcvd) {
+    fprintf(stderr, "[%d] has %lf instead of %d\n", rank, rcvd, rank);
+    success = 0;
+  }
+  return (success);
 }
 
 
 
 int main(int argc, char **argv)
 {
-        int size, rank;
+  int size, rank;
 
 
-        MPI_Init(&argc, &argv);
-        MPI_Comm_size(MPI_COMM_WORLD, &size);
-        MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  MPI_Init(&argc, &argv);
+  MPI_Comm_size(MPI_COMM_WORLD, &size);
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
-        /* test 1 */
-        if (0 == rank)
-                printf("** Small Test Result: ... \n");
-        if (! small_test( rank, size ))
-                printf("\t[%d] failed.\n", rank);
-        else
-                printf("\t[%d] ok.\n", rank);
+  /* test 1 */
+  if (0 == rank)
+    printf("** Small Test Result: ... \n");
+  if (!small_test(rank, size))
+    printf("\t[%d] failed.\n", rank);
+  else
+    printf("\t[%d] ok.\n", rank);
 
 
-        MPI_Barrier( MPI_COMM_WORLD );
+  MPI_Barrier(MPI_COMM_WORLD);
 
-        /* test 2 */
-        if (0 == rank)
-                printf("** IBM Test Result: ... \n");
-        if (!ibm_test(rank, size))
-                printf("\t[%d] failed.\n", rank);
-        else
-                printf("\t[%d] ok.\n", rank);
+  /* test 2 */
+  if (0 == rank)
+    printf("** IBM Test Result: ... \n");
+  if (!ibm_test(rank, size))
+    printf("\t[%d] failed.\n", rank);
+  else
+    printf("\t[%d] ok.\n", rank);
 
-        MPI_Finalize();
-        return 0;
+  MPI_Finalize();
+  return 0;
 }
index 6d5ba17..ae9e297 100644 (file)
@@ -7,7 +7,8 @@
 #include "mpi.h"
 #include <stdio.h>
 
-static int test(int myid, int numprocs) {
+static int test(int myid, int numprocs)
+{
 // The tags should match on the sender and receiver side.
 // The distinction between sendtag and recvtag is mainly
 // useful to make some other Recv or Send calls match the sendrecv. 
@@ -16,53 +17,54 @@ static int test(int myid, int numprocs) {
 
 
 #define BUFLEN 10
-    int left, right;
-    int buffer[BUFLEN], buffer2[BUFLEN];
-    int i;
-    MPI_Status status;
+  int left, right;
+  int buffer[BUFLEN], buffer2[BUFLEN];
+  int i;
+  MPI_Status status;
 
-    for (i=0;i<BUFLEN;i++) {
-               buffer[i]=myid;
-    }
+  for (i = 0; i < BUFLEN; i++) {
+    buffer[i] = myid;
+  }
+
+  right = (myid + 1) % numprocs;
+  left = myid - 1;
+  if (left < 0)
+    left = numprocs - 1;
+
+  /* performs a right-to-left shift of vectors */
+  MPI_Sendrecv(buffer, 10, MPI_INT, left, TAG_SND, buffer2, 10, MPI_INT,
+               right, TAG_RCV, MPI_COMM_WORLD, &status);
 
-    right = (myid + 1) % numprocs;
-    left = myid - 1;
-    if (left < 0)
-        left = numprocs - 1;
-
-    /* performs a right-to-left shift of vectors */ 
-    MPI_Sendrecv(buffer, 10, MPI_INT, left, TAG_SND, buffer2, 10, MPI_INT, right, TAG_RCV, MPI_COMM_WORLD, &status);
-    for (i=0;i<BUFLEN;i++) {
-               if (buffer2[i]!=right) {
-                         fprintf(stderr,"[%d] error: should have values %d, has %d\n",myid,right,buffer2[i]);
-                         return(0);
-             }
+  for (i = 0; i < BUFLEN; i++) {
+    if (buffer2[i] != right) {
+      fprintf(stderr, "[%d] error: should have values %d, has %d\n", myid,
+              right, buffer2[i]);
+      return (0);
     }
-    return(1);
+  }
+  return (1);
 }
+
 int main(int argc, char *argv[])
 {
 
-   int myid, numprocs;
+  int myid, numprocs;
 
-    MPI_Init(&argc,&argv);
-    MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
-    MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+  MPI_Init(&argc, &argv);
+  MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+  MPI_Comm_rank(MPI_COMM_WORLD, &myid);
 
 
-    if (0==myid) 
-               printf("\n    *** MPI_Sendrecv test ***\n\n");
+  if (0 == myid)
+    printf("\n    *** MPI_Sendrecv test ***\n\n");
 
-    if ( test(myid,numprocs)) {
-               fprintf(stderr,"[%d] ok.\n",myid);
-    }
-    else {
-               fprintf(stderr,"[%d] failed.\n",myid);
-    }
+  if (test(myid, numprocs)) {
+    fprintf(stderr, "[%d] ok.\n", myid);
+  } else {
+    fprintf(stderr, "[%d] failed.\n", myid);
+  }
 
 
-    MPI_Finalize();
-    return 0;
+  MPI_Finalize();
+  return 0;
 }
index b39cc32..cf3cc15 100644 (file)
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
 {
   int rank, numprocs, i;
 
-  MPI_Init(&argc,&argv);
+  MPI_Init(&argc, &argv);
   MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
@@ -48,272 +48,281 @@ int main(int argc, char *argv[])
 /////////////////////////////////////////
 ////////////////// RANK 0
 ///////////////////////////////////
-  if (rank == 0){
+  if (rank == 0) {
     MPI_Request request;
     MPI_Status status;
-    MPI_Request req[2*N];
-    MPI_Status sta[2*N];
-    int *r = (int*)malloc(sizeof(int)*DATATOSENT);
-    if (A){
-      TRACE_smpi_set_category ("A");
+    MPI_Request req[2 * N];
+    MPI_Status sta[2 * N];
+    int *r = (int *) malloc(sizeof(int) * DATATOSENT);
+    if (A) {
+      TRACE_smpi_set_category("A");
       MPI_Isend(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &request);
-      MPI_Wait (&request, &status);
+      MPI_Wait(&request, &status);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (B){
-      TRACE_smpi_set_category ("B");
+    if (B) {
+      TRACE_smpi_set_category("B");
       MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (C){
-      TRACE_smpi_set_category ("C");
-      for (i = 0; i < N; i++){
+    if (C) {
+      TRACE_smpi_set_category("C");
+      for (i = 0; i < N; i++) {
         MPI_Isend(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
-        MPI_Wait (&req[i], &sta[i]);
+      for (i = 0; i < N; i++) {
+        MPI_Wait(&req[i], &sta[i]);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (D){
-      TRACE_smpi_set_category ("D");
-      for (i = 0; i < N; i++){
+    if (D) {
+      TRACE_smpi_set_category("D");
+      for (i = 0; i < N; i++) {
         MPI_Isend(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
+      for (i = 0; i < N; i++) {
         int completed;
-        MPI_Waitany (N, req, &completed, sta);
+        MPI_Waitany(N, req, &completed, sta);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (E){
-      TRACE_smpi_set_category ("E");
-      for (i = 0; i < N; i++){
+    if (E) {
+      TRACE_smpi_set_category("E");
+      for (i = 0; i < N; i++) {
         MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (F){
-      TRACE_smpi_set_category ("F");
-      for (i = 0; i < N; i++){
+    if (F) {
+      TRACE_smpi_set_category("F");
+      for (i = 0; i < N; i++) {
         MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (G){
-      TRACE_smpi_set_category ("G");
-      for (i = 0; i < N; i++){
+    if (G) {
+      TRACE_smpi_set_category("G");
+      for (i = 0; i < N; i++) {
         MPI_Isend(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &req[i]);
       }
-      MPI_Waitall (N, req, sta);
+      MPI_Waitall(N, req, sta);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (H){
-      TRACE_smpi_set_category ("H");
-      for (i = 0; i < N; i++){
+    if (H) {
+      TRACE_smpi_set_category("H");
+      for (i = 0; i < N; i++) {
         MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (I){
-      TRACE_smpi_set_category ("I");
-      for (i = 0; i < 2*N; i++){
-        if (i < N){
+    if (I) {
+      TRACE_smpi_set_category("I");
+      for (i = 0; i < 2 * N; i++) {
+        if (i < N) {
           MPI_Send(r, DATATOSENT, MPI_INT, 2, tag, MPI_COMM_WORLD);
-        }else{
+        } else {
           MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
         }
       }
-      MPI_Barrier (MPI_COMM_WORLD);
-      for (i = 0; i < 2*N; i++){
-        if (i < N){
-          MPI_Irecv(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &req[i]);
-        }else{
-          MPI_Irecv(r, DATATOSENT, MPI_INT, 2, tag, MPI_COMM_WORLD, &req[i]);
+      MPI_Barrier(MPI_COMM_WORLD);
+      for (i = 0; i < 2 * N; i++) {
+        if (i < N) {
+          MPI_Irecv(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD,
+                    &req[i]);
+        } else {
+          MPI_Irecv(r, DATATOSENT, MPI_INT, 2, tag, MPI_COMM_WORLD,
+                    &req[i]);
         }
       }
-      MPI_Waitall (2*N, req, sta);
+      MPI_Waitall(2 * N, req, sta);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (J){
-      TRACE_smpi_set_category ("J");
-      for (i = 0; i < N; i++){
+    if (J) {
+      TRACE_smpi_set_category("J");
+      for (i = 0; i < N; i++) {
         MPI_Isend(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
+      for (i = 0; i < N; i++) {
         int flag;
-        MPI_Test (&req[i], &flag, &sta[i]);
+        MPI_Test(&req[i], &flag, &sta[i]);
       }
-      for (i = 0; i < N; i++){
-        MPI_Wait (&req[i], &sta[i]);
+      for (i = 0; i < N; i++) {
+        MPI_Wait(&req[i], &sta[i]);
       }
     }
-
 /////////////////////////////////////////
 ////////////////// RANK 1
 ///////////////////////////////////
-  }else if (rank == 1){
+  } else if (rank == 1) {
     MPI_Request request;
     MPI_Status status;
     MPI_Request req[N];
     MPI_Status sta[N];
-    int *r = (int*)malloc(sizeof(int)*DATATOSENT);
+    int *r = (int *) malloc(sizeof(int) * DATATOSENT);
 
-    if (A){
-      TRACE_smpi_set_category ("A");
+    if (A) {
+      TRACE_smpi_set_category("A");
       MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (B){
-      TRACE_smpi_set_category ("B");
+    if (B) {
+      TRACE_smpi_set_category("B");
       MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &request);
-      MPI_Wait (&request, &status);
+      MPI_Wait(&request, &status);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (C){
-      TRACE_smpi_set_category ("C");
-      for (i = 0; i < N; i++){
+    if (C) {
+      TRACE_smpi_set_category("C");
+      for (i = 0; i < N; i++) {
         MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &sta[i]);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (D){
-      TRACE_smpi_set_category ("D");
-      for (i = 0; i < N; i++){
+    if (D) {
+      TRACE_smpi_set_category("D");
+      for (i = 0; i < N; i++) {
         MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &sta[i]);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (E){
-      TRACE_smpi_set_category ("E");
-      for (i = 0; i < N; i++){
+    if (E) {
+      TRACE_smpi_set_category("E");
+      for (i = 0; i < N; i++) {
         MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
-        MPI_Wait (&req[i], &sta[i]);
+      for (i = 0; i < N; i++) {
+        MPI_Wait(&req[i], &sta[i]);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (F){
-      TRACE_smpi_set_category ("F");
-      for (i = 0; i < N; i++){
+    if (F) {
+      TRACE_smpi_set_category("F");
+      for (i = 0; i < N; i++) {
         MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
+      for (i = 0; i < N; i++) {
         int completed;
-        MPI_Waitany (N, req, &completed, sta);
+        MPI_Waitany(N, req, &completed, sta);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (G){
-      TRACE_smpi_set_category ("G");
-      for (i = 0; i < N; i++){
+    if (G) {
+      TRACE_smpi_set_category("G");
+      for (i = 0; i < N; i++) {
         MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &sta[i]);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (H){
-      TRACE_smpi_set_category ("H");
-      for (i = 0; i < N; i++){
+    if (H) {
+      TRACE_smpi_set_category("H");
+      for (i = 0; i < N; i++) {
         MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      MPI_Waitall (N, req, sta);
+      MPI_Waitall(N, req, sta);
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (I){
-      TRACE_smpi_set_category ("I");
-      for (i = 0; i < N; i++){
+    if (I) {
+      TRACE_smpi_set_category("I");
+      for (i = 0; i < N; i++) {
         MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      MPI_Waitall (N, req, sta);
+      MPI_Waitall(N, req, sta);
 
-      MPI_Barrier (MPI_COMM_WORLD);
-      for (i = 0; i < N; i++){
+      MPI_Barrier(MPI_COMM_WORLD);
+      for (i = 0; i < N; i++) {
         MPI_Isend(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      MPI_Waitall (N, req, sta);
+      MPI_Waitall(N, req, sta);
 //      for (i = 0; i < N; i++){
 //        MPI_Wait (&req[i], &sta[i]);
 //      }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
-    if (J){
-      TRACE_smpi_set_category ("J");
-      for (i = 0; i < N; i++){
+    if (J) {
+      TRACE_smpi_set_category("J");
+      for (i = 0; i < N; i++) {
         MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
+      for (i = 0; i < N; i++) {
         int flag;
-        MPI_Test (&req[i], &flag, &sta[i]);
+        MPI_Test(&req[i], &flag, &sta[i]);
       }
-      for (i = 0; i < N; i++){
-        MPI_Wait (&req[i], &sta[i]);
+      for (i = 0; i < N; i++) {
+        MPI_Wait(&req[i], &sta[i]);
       }
     }
-
 /////////////////////////////////////////
 ////////////////// RANK 2
 ///////////////////////////////////
-  }else if (rank == 2){
+  } else if (rank == 2) {
 //    MPI_Request request;
 //    MPI_Status status;
     MPI_Request req[N];
     MPI_Status sta[N];
-    int *r = (int*)malloc(sizeof(int)*DATATOSENT);
+    int *r = (int *) malloc(sizeof(int) * DATATOSENT);
 
-    if (A) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (B) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (C) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (D) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (E) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (F) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (G) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (H) {} 
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (I){
-      TRACE_smpi_set_category ("I");
-      for (i = 0; i < N; i++){
+    if (A) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (B) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (C) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (D) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (E) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (F) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (G) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (H) {
+    }
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (I) {
+      TRACE_smpi_set_category("I");
+      for (i = 0; i < N; i++) {
         MPI_Irecv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &req[i]);
       }
-      for (i = 0; i < N; i++){
+      for (i = 0; i < N; i++) {
         int completed;
-        MPI_Waitany (N, req, &completed, sta);
+        MPI_Waitany(N, req, &completed, sta);
       }
-      MPI_Barrier (MPI_COMM_WORLD);
+      MPI_Barrier(MPI_COMM_WORLD);
 
-      for (i = 0; i < N; i++){
+      for (i = 0; i < N; i++) {
         MPI_Send(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD);
       }
     }
-    MPI_Barrier (MPI_COMM_WORLD);
-    if (J){}
+    MPI_Barrier(MPI_COMM_WORLD);
+    if (J) {
+    }
   }
-  MPI_Barrier (MPI_COMM_WORLD);
+  MPI_Barrier(MPI_COMM_WORLD);
   MPI_Finalize();
   return 0;
 }
index 848cfe8..2324eeb 100644 (file)
@@ -16,28 +16,28 @@ int main(int argc, char *argv[])
   int rank, numprocs, tag = 0;
   int *r = malloc(sizeof(int) * DATATOSENT);
 
-  MPI_Init(&argc,&argv);
+  MPI_Init(&argc, &argv);
   MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
-  TRACE_smpi_set_category ("A"); 
-  if (rank == 0){
+  TRACE_smpi_set_category("A");
+  if (rank == 0) {
     MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
-  }else if (rank == 1){
+  } else if (rank == 1) {
     MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-  }else{ 
+  } else {
     //do nothing
   }
-  TRACE_smpi_set_category ("B"); 
-  if (rank == 0){
+  TRACE_smpi_set_category("B");
+  if (rank == 0) {
     MPI_Recv(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &status);
-  }else if (rank == 1){
+  } else if (rank == 1) {
     MPI_Send(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD);
-  }else{ 
+  } else {
     //do nothing
   }
-  TRACE_smpi_set_category ("C"); 
-  MPI_Barrier (MPI_COMM_WORLD);
+  TRACE_smpi_set_category("C");
+  MPI_Barrier(MPI_COMM_WORLD);
   MPI_Finalize();
   return 0;
 }
index dad97af..1d944f7 100644 (file)
@@ -11,7 +11,8 @@
 #include "xbt/xbt_os_thread.h"
 #include "xbt.h"
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(sem_basic,"Messages specific for this sem example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(sem_basic,
+                             "Messages specific for this sem example");
 
 
 
@@ -20,73 +21,67 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sem_basic,"Messages specific for this sem example")
 /*
  * the thread funtion.
  */
-void*
-thread_routine(void* param);
+void *thread_routine(void *param);
 
 /* an entry of the table of threads */
-typedef struct s_thread_entry
-{
-       xbt_os_thread_t thread;
-       unsigned int thread_index;      /* the index of the thread      */
-}s_thread_entry_t,* thread_entry_t;
+typedef struct s_thread_entry {
+  xbt_os_thread_t thread;
+  unsigned int thread_index;    /* the index of the thread      */
+} s_thread_entry_t, *thread_entry_t;
 
 
-static xbt_os_sem_t 
-sem = NULL;
+static xbt_os_sem_t sem = NULL;
 
 static
 int value = 0;
-int
-main(int argc, char* argv[])
+int main(int argc, char *argv[])
 {
-       s_thread_entry_t threads_table[THREAD_THREADS_MAX] = {0};       
-       unsigned int i,j;
-       int exit_code = 0;
-       
-       xbt_init(&argc,argv);
-       
-       sem = xbt_os_sem_init(1);
-       
-       i = 0;
-       
-       while(i < THREAD_THREADS_MAX)
-       {
-               threads_table[i].thread_index = i;
-
-               if(NULL == (threads_table[i].thread = xbt_os_thread_create("thread",thread_routine,&(threads_table[i].thread_index))))
-                       break;
-       
-               i++;
-       }
-       
-       /* close the thread handles */
-       for(j = 0; j < THREAD_THREADS_MAX; j++)
-               xbt_os_thread_join(threads_table[j].thread,NULL);
-       
-       xbt_os_sem_destroy(sem);
-       
-       INFO1("sem_basic terminated with exit code %d (success)",EXIT_SUCCESS);
-
-       return EXIT_SUCCESS;
-               
+  s_thread_entry_t threads_table[THREAD_THREADS_MAX] = { 0 };
+  unsigned int i, j;
+  int exit_code = 0;
+
+  xbt_init(&argc, argv);
+
+  sem = xbt_os_sem_init(1);
+
+  i = 0;
+
+  while (i < THREAD_THREADS_MAX) {
+    threads_table[i].thread_index = i;
+
+    if (NULL ==
+        (threads_table[i].thread =
+         xbt_os_thread_create("thread", thread_routine,
+                              &(threads_table[i].thread_index))))
+      break;
+
+    i++;
+  }
+
+  /* close the thread handles */
+  for (j = 0; j < THREAD_THREADS_MAX; j++)
+    xbt_os_thread_join(threads_table[j].thread, NULL);
+
+  xbt_os_sem_destroy(sem);
+
+  INFO1("sem_basic terminated with exit code %d (success)", EXIT_SUCCESS);
+
+  return EXIT_SUCCESS;
+
 }
 
-void*
-thread_routine(void* param)
+void *thread_routine(void *param)
 {
-       int thread_index = *((int*)param);
-       int exit_code = 0;
-       
-       xbt_os_sem_acquire(sem);
-       INFO1("Hello i'm the thread %d",thread_index);
-       value++;
-       INFO1("The new value of the global variable is %d, bye",value);
-       xbt_os_sem_release(sem);
-       
-       xbt_os_thread_exit(&exit_code);
-
-       return (void*)(NULL);
-}
+  int thread_index = *((int *) param);
+  int exit_code = 0;
 
+  xbt_os_sem_acquire(sem);
+  INFO1("Hello i'm the thread %d", thread_index);
+  value++;
+  INFO1("The new value of the global variable is %d, bye", value);
+  xbt_os_sem_release(sem);
 
+  xbt_os_thread_exit(&exit_code);
 
+  return (void *) (NULL);
+}
index ab14ee1..7ae8b7d 100644 (file)
@@ -13,7 +13,8 @@
 #include "xbt/xbt_os_thread.h"
 #include "xbt.h"
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(sem_sched,"Messages specific for this sem example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(sem_sched,
+                             "Messages specific for this sem example");
 
 #ifndef ENOBUFS
 #define ENOBUFS                1024
@@ -25,439 +26,393 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sem_sched,"Messages specific for this sem example")
 #define MAX_ARG                                                30
 #define MAX_ARGS                                       10
 
-typedef int (*pfn_func_t)(int, char**);
+typedef int (*pfn_func_t) (int, char **);
 
 static int
-__next_ctx_ID = 0;
+ __next_ctx_ID = 0;
 
-typedef struct s_job
-{
-       pfn_func_t func;
-       int argc;
-       char** argv;
-}s_job_t,* job_t;
+typedef struct s_job {
+  pfn_func_t func;
+  int argc;
+  char **argv;
+} s_job_t, *job_t;
 
 
-job_t
-job_new(pfn_func_t func, int argc, char** argv);
+job_t job_new(pfn_func_t func, int argc, char **argv);
 
-int
-job_execute(job_t job);
+int job_execute(job_t job);
 
-int
-job_free(job_t* ref);
+int job_free(job_t * ref);
 
 /* an entry of the table of threads */
-typedef struct s_ctx
-{
-       xbt_os_sem_t begin;
-       xbt_os_sem_t end;
-       int failure;
-       job_t job;
-       xbt_os_thread_t imp;
-       int index;
-}s_ctx_t,* ctx_t;
-
-typedef struct s_shed
-{
-       ctx_t* ctxs;
-       int size;
-       int capacity;
-}s_sched_t,* sched_t;
+typedef struct s_ctx {
+  xbt_os_sem_t begin;
+  xbt_os_sem_t end;
+  int failure;
+  job_t job;
+  xbt_os_thread_t imp;
+  int index;
+} s_ctx_t, *ctx_t;
 
+typedef struct s_shed {
+  ctx_t *ctxs;
+  int size;
+  int capacity;
+} s_sched_t, *sched_t;
 
-void 
-schedule(ctx_t c);
-void 
-unschedule(ctx_t c);
 
-void*
-ctx_function(void* param);
+void schedule(ctx_t c);
+void unschedule(ctx_t c);
 
-ctx_t 
-ctx_new(job_t job);
+void *ctx_function(void *param);
 
-int 
-ctx_free(ctx_t* ref);
+ctx_t ctx_new(job_t job);
 
-sched_t
-sched_new(int size);
+int ctx_free(ctx_t * ref);
 
-int
-sched_add_job(sched_t sched, job_t job);
+sched_t sched_new(int size);
 
-int
-sched_init(sched_t sched);
+int sched_add_job(sched_t sched, job_t job);
 
-int
-sched_schedule(sched_t sched);
+int sched_init(sched_t sched);
 
-int
-sched_clean(sched_t sched);
+int sched_schedule(sched_t sched);
 
-int
-sched_free(sched_t* ref);
+int sched_clean(sched_t sched);
 
-int
-job(int argc, char* argv[]);
+int sched_free(sched_t * ref);
 
-int
-main(int argc, char* argv[])
+int job(int argc, char *argv[]);
+
+int main(int argc, char *argv[])
 {
-       sched_t sched;
-       int i, size;
-       char** __argv;
-       char arg[MAX_ARG] = {0};
-       
-       
-       xbt_init(&argc, argv);
-       
-       if(argc != 2) 
-       {
-               INFO1("Usage: %s job count",argv[0]);
-               exit(EXIT_FAILURE);
-       }  
-       
-       
-       size = atoi(argv[1]);
-       
-       /* create a new scheduler */
-       sched = sched_new(size);
-       
-       if(!sched)
-       {
-               INFO1("sched_new() failed : errno %d",errno);
-               exit(EXIT_FAILURE);
-       }
-       
-       __argv = xbt_new0(char*,MAX_ARGS);
-       
-       for(i = 0; i < MAX_ARGS; i++)
-       {
-               sprintf(arg,"arg_%d",i);
-               __argv[i] = strdup(arg);
-               memset(arg,0,MAX_ARG);
-               
-       }
-       
-       for(i = 0; i < size; i++)
-               sched_add_job(sched,job_new(job,(i < MAX_ARGS) ? i : MAX_ARGS,__argv));
-       
-       /* initialize the scheduler */
-       if(sched_init(sched) < 0)
-       {
-               sched_free(&sched);
-               INFO1("sched_init() failed : errno %d\n",errno);
-               exit(EXIT_FAILURE);
-       }
-       
-       /* schedule the jobs */
-       if(sched_schedule(sched) < 0)
-       {
-               sched_free(&sched);
-               INFO1("sched_init() failed : errno %d",errno);
-               exit(EXIT_FAILURE);
-       }
-       
-       /* cleanup */
-       if(sched_clean(sched) < 0)
-       {
-               sched_free(&sched);
-               INFO1("sched_init() failed : errno %d",errno);
-               exit(EXIT_FAILURE);
-       }
-       
-       /* destroy the scheduler */
-       sched_free(&sched);
-       
-       INFO1("sem_sched terminated with exit code %d (success)",EXIT_SUCCESS);
-
-       return EXIT_SUCCESS;
-               
+  sched_t sched;
+  int i, size;
+  char **__argv;
+  char arg[MAX_ARG] = { 0 };
+
+
+  xbt_init(&argc, argv);
+
+  if (argc != 2) {
+    INFO1("Usage: %s job count", argv[0]);
+    exit(EXIT_FAILURE);
+  }
+
+
+  size = atoi(argv[1]);
+
+  /* create a new scheduler */
+  sched = sched_new(size);
+
+  if (!sched) {
+    INFO1("sched_new() failed : errno %d", errno);
+    exit(EXIT_FAILURE);
+  }
+
+  __argv = xbt_new0(char *, MAX_ARGS);
+
+  for (i = 0; i < MAX_ARGS; i++) {
+    sprintf(arg, "arg_%d", i);
+    __argv[i] = strdup(arg);
+    memset(arg, 0, MAX_ARG);
+
+  }
+
+  for (i = 0; i < size; i++)
+    sched_add_job(sched,
+                  job_new(job, (i < MAX_ARGS) ? i : MAX_ARGS, __argv));
+
+  /* initialize the scheduler */
+  if (sched_init(sched) < 0) {
+    sched_free(&sched);
+    INFO1("sched_init() failed : errno %d\n", errno);
+    exit(EXIT_FAILURE);
+  }
+
+  /* schedule the jobs */
+  if (sched_schedule(sched) < 0) {
+    sched_free(&sched);
+    INFO1("sched_init() failed : errno %d", errno);
+    exit(EXIT_FAILURE);
+  }
+
+  /* cleanup */
+  if (sched_clean(sched) < 0) {
+    sched_free(&sched);
+    INFO1("sched_init() failed : errno %d", errno);
+    exit(EXIT_FAILURE);
+  }
+
+  /* destroy the scheduler */
+  sched_free(&sched);
+
+  INFO1("sem_sched terminated with exit code %d (success)", EXIT_SUCCESS);
+
+  return EXIT_SUCCESS;
+
 }
 
-void*
-ctx_function(void* param)
+void *ctx_function(void *param)
 {
-       int i = 0;
-       int exit_code = 1;
-       ctx_t ctx = (ctx_t)param;
-       
-       INFO1("Hello i'm the owner of the context %d, i'm waiting for starting",ctx->index);
-       
-       unschedule(ctx);
-       
-       if(ctx->failure)
-       {
-               INFO1("0ups the scheduler initialization failed bye {%d}.",ctx->index);
-               xbt_os_thread_exit(&exit_code);
-       }
-       
-       INFO1("I'm the owner of the context %d : I'm started",ctx->index);
-       INFO0("Wait a minute, I do my job");
-       
-       /* do its job */
-       exit_code = job_execute(ctx->job);
-       
-       INFO1("Have finished my job, bye {%d}\n",ctx->index);
-       
-       xbt_os_sem_release(ctx->end);
-       
-       xbt_os_thread_exit(&exit_code);
+  int i = 0;
+  int exit_code = 1;
+  ctx_t ctx = (ctx_t) param;
+
+  INFO1("Hello i'm the owner of the context %d, i'm waiting for starting",
+        ctx->index);
+
+  unschedule(ctx);
+
+  if (ctx->failure) {
+    INFO1("0ups the scheduler initialization failed bye {%d}.",
+          ctx->index);
+    xbt_os_thread_exit(&exit_code);
+  }
+
+  INFO1("I'm the owner of the context %d : I'm started", ctx->index);
+  INFO0("Wait a minute, I do my job");
+
+  /* do its job */
+  exit_code = job_execute(ctx->job);
+
+  INFO1("Have finished my job, bye {%d}\n", ctx->index);
+
+  xbt_os_sem_release(ctx->end);
+
+  xbt_os_thread_exit(&exit_code);
 }
 
-void schedule(ctx_t c) 
+void schedule(ctx_t c)
 {
-       xbt_os_sem_release(c->begin);   /* allow C to go                */
-       xbt_os_sem_acquire(c->end);     /* wait C's end                 */
+  xbt_os_sem_release(c->begin); /* allow C to go                */
+  xbt_os_sem_acquire(c->end);   /* wait C's end                 */
 }
 
-void unschedule(ctx_t c) 
+void unschedule(ctx_t c)
 {
-   xbt_os_sem_release(c->end);         /* I'm done, dude               */
-   xbt_os_sem_acquire(c->begin);       /* can I start again?   */
+  xbt_os_sem_release(c->end);   /* I'm done, dude               */
+  xbt_os_sem_acquire(c->begin); /* can I start again?   */
 }
 
-ctx_t 
-ctx_new(job_t job)
+ctx_t ctx_new(job_t job)
 {
-       ctx_t ctx = xbt_new0(s_ctx_t,1);
-       ctx->index = ++__next_ctx_ID;
-       ctx->begin = xbt_os_sem_init(0);
-       ctx->end = xbt_os_sem_init(0);
-       ctx->failure = 0;
-       ctx->job = job;
-       
-       return ctx;
+  ctx_t ctx = xbt_new0(s_ctx_t, 1);
+  ctx->index = ++__next_ctx_ID;
+  ctx->begin = xbt_os_sem_init(0);
+  ctx->end = xbt_os_sem_init(0);
+  ctx->failure = 0;
+  ctx->job = job;
+
+  return ctx;
 }
 
-int 
-ctx_free(ctx_t* ref)
+int ctx_free(ctx_t * ref)
 {
-       ctx_t ctx;
-       if(!(*ref))
-               return EINVAL;
-       
-       ctx = *ref;
-       
-       xbt_os_sem_destroy(ctx->begin);
-       xbt_os_sem_destroy(ctx->end);
-       job_free(&(ctx->job));
-       free(ctx);
-       *ref = NULL;
-       
-       return 0;
+  ctx_t ctx;
+  if (!(*ref))
+    return EINVAL;
+
+  ctx = *ref;
+
+  xbt_os_sem_destroy(ctx->begin);
+  xbt_os_sem_destroy(ctx->end);
+  job_free(&(ctx->job));
+  free(ctx);
+  *ref = NULL;
+
+  return 0;
 }
 
-sched_t
-sched_new(int size)
+sched_t sched_new(int size)
 {
-       sched_t sched;
-       
-       if(size <= 0)
-       {
-               errno = EINVAL;
-               return NULL;
-       }
-       
-       sched = xbt_new0(s_sched_t,1);
-       
-       if(!sched)
-       {
-               errno = ENOMEM;
-               return NULL;
-       }
-               
-       sched->ctxs = xbt_new0(ctx_t,size);
-       
-       if(!(sched->ctxs))
-       {
-               errno = ENOMEM;
-               free(sched);
-               return NULL;
-       }
-       
-       sched->size = 0;
-       sched->capacity = size;
-       
-       return sched;
+  sched_t sched;
+
+  if (size <= 0) {
+    errno = EINVAL;
+    return NULL;
+  }
+
+  sched = xbt_new0(s_sched_t, 1);
+
+  if (!sched) {
+    errno = ENOMEM;
+    return NULL;
+  }
+
+  sched->ctxs = xbt_new0(ctx_t, size);
+
+  if (!(sched->ctxs)) {
+    errno = ENOMEM;
+    free(sched);
+    return NULL;
+  }
+
+  sched->size = 0;
+  sched->capacity = size;
+
+  return sched;
 }
 
-int
-sched_add_job(sched_t sched, job_t job)
+int sched_add_job(sched_t sched, job_t job)
 {
-       if(!sched || !job)
-               return EINVAL;
-       
-       if(sched->capacity < sched->size)
-               return ENOBUFS;
-               
-       sched->ctxs[(sched->size)++] = ctx_new(job);
-       
-       return 0;
+  if (!sched || !job)
+    return EINVAL;
+
+  if (sched->capacity < sched->size)
+    return ENOBUFS;
+
+  sched->ctxs[(sched->size)++] = ctx_new(job);
+
+  return 0;
 }
 
-int
-sched_init(sched_t sched)
+int sched_init(sched_t sched)
 {
-       int i,j;
-       int success = 1;
-       
-       if(!sched)
-               return EINVAL;
-       
-       for(i = 0; i < sched->size; i++)
-       {       
-               sched->ctxs[i]->imp = xbt_os_thread_create("thread",ctx_function,(void*)sched->ctxs[i]);
-               
-               xbt_os_sem_acquire(sched->ctxs[i]->end);
-       }
-       
-       if(!success)
-       {
-               for(j = 0; j < i; j++)
-               {
-                       sched->ctxs[j]->failure = 1;
-                       xbt_os_sem_release(sched->ctxs[j]->begin);
-               }
-                       
-               for(j = 0; j < i; j++)
-               {
-                       xbt_os_thread_join(sched->ctxs[j]->imp,0);
-                       
-                       ctx_free(&(sched->ctxs[j]));
-               }
-               
-               return -1;
-                                       
-       }
-       
-       return 0;
+  int i, j;
+  int success = 1;
+
+  if (!sched)
+    return EINVAL;
+
+  for (i = 0; i < sched->size; i++) {
+    sched->ctxs[i]->imp =
+        xbt_os_thread_create("thread", ctx_function,
+                             (void *) sched->ctxs[i]);
+
+    xbt_os_sem_acquire(sched->ctxs[i]->end);
+  }
+
+  if (!success) {
+    for (j = 0; j < i; j++) {
+      sched->ctxs[j]->failure = 1;
+      xbt_os_sem_release(sched->ctxs[j]->begin);
+    }
+
+    for (j = 0; j < i; j++) {
+      xbt_os_thread_join(sched->ctxs[j]->imp, 0);
+
+      ctx_free(&(sched->ctxs[j]));
+    }
+
+    return -1;
+
+  }
+
+  return 0;
 }
 
-int
-sched_schedule(sched_t sched)
+int sched_schedule(sched_t sched)
 {
-       int i;
-       
-       if(!sched)
-               return EINVAL;
-               
-       for(i = 0; i < sched->size; i++)
-               schedule(sched->ctxs[i]);
-               
-       return 0;
+  int i;
+
+  if (!sched)
+    return EINVAL;
+
+  for (i = 0; i < sched->size; i++)
+    schedule(sched->ctxs[i]);
+
+  return 0;
 }
 
-int
-sched_clean(sched_t sched)
+int sched_clean(sched_t sched)
 {
-       int i;
-       
-       if(!sched)
-               return EINVAL;
-               
-       for(i = 0; i < sched->size; i++)
-       {
-               xbt_os_thread_join(sched->ctxs[i]->imp,NULL);
-               
-               ctx_free(&(sched->ctxs[i]));
-       }
-       
-       return 0;
+  int i;
+
+  if (!sched)
+    return EINVAL;
+
+  for (i = 0; i < sched->size; i++) {
+    xbt_os_thread_join(sched->ctxs[i]->imp, NULL);
+
+    ctx_free(&(sched->ctxs[i]));
+  }
+
+  return 0;
 }
 
-int
-sched_free(sched_t* ref)
+int sched_free(sched_t * ref)
 {
-       if(*ref)
-               return EINVAL;
-               
-       free(((sched_t)(*ref))->ctxs);
-       
-       *ref = NULL;
-       
-       return 0;
+  if (*ref)
+    return EINVAL;
+
+  free(((sched_t) (*ref))->ctxs);
+
+  *ref = NULL;
+
+  return 0;
 }
 
 
-int
-job(int argc, char** argv)
+int job(int argc, char **argv)
 {
-       int i = 0;
-       
-       INFO0("I'm the job : I'm going to print all the args of my commande line");
-       
-       INFO1("-- Arguments (%d):",argc);
-       
-       for(i = 0; i < argc; i++)
-               INFO2("  ---- [%i] %s",i,argv[i]);
-               
-       return 0;
+  int i = 0;
+
+  INFO0
+      ("I'm the job : I'm going to print all the args of my commande line");
+
+  INFO1("-- Arguments (%d):", argc);
+
+  for (i = 0; i < argc; i++)
+    INFO2("  ---- [%i] %s", i, argv[i]);
+
+  return 0;
 }
 
-job_t
-job_new(pfn_func_t func, int argc, char** argv)
+job_t job_new(pfn_func_t func, int argc, char **argv)
 {
-       job_t job;
-       int i;
-       
-       /* todo check the parameters */
-       job = xbt_new0(s_job_t,1);
-       
-       if(!job)
-       {
-               errno = ENOMEM;
-               return NULL;
-       }
-       
-       job->argv = xbt_new0(char*,argc);
-       
-       if(!(job->argv))
-       {
-               free(job);
-               errno = ENOMEM;
-               return NULL;
-       }
-       
-       for(i = 0; i < argc; i++)
-               job->argv[i] = strdup(argv[i]);
-       
-       job->func = func;       
-       job->argc = argc;
-       
-       return job;
+  job_t job;
+  int i;
+
+  /* todo check the parameters */
+  job = xbt_new0(s_job_t, 1);
+
+  if (!job) {
+    errno = ENOMEM;
+    return NULL;
+  }
+
+  job->argv = xbt_new0(char *, argc);
+
+  if (!(job->argv)) {
+    free(job);
+    errno = ENOMEM;
+    return NULL;
+  }
+
+  for (i = 0; i < argc; i++)
+    job->argv[i] = strdup(argv[i]);
+
+  job->func = func;
+  job->argc = argc;
+
+  return job;
 }
 
-int
-job_execute(job_t job)
+int job_execute(job_t job)
 {
-       if(!job)
-               return EINVAL;
-               
-       return (*(job->func))(job->argc, job->argv);
+  if (!job)
+    return EINVAL;
+
+  return (*(job->func)) (job->argc, job->argv);
 }
 
-int
-job_free(job_t* ref)
+int job_free(job_t * ref)
 {
-       job_t job;
-       int i;
-       
-       if(!(*ref))
-               return EINVAL;
-               
-       job = *ref;
-       
-       for(i = 0; i < job->argc; i++)
-               free(job->argv[i]);
-       
-       free(job->argv);
-       free(*ref);
-       *ref = NULL;
-       
-       return 0;
-}
+  job_t job;
+  int i;
+
+  if (!(*ref))
+    return EINVAL;
 
+  job = *ref;
 
+  for (i = 0; i < job->argc; i++)
+    free(job->argv[i]);
 
+  free(job->argv);
+  free(*ref);
+  *ref = NULL;
+
+  return 0;
+}
index 155ebbf..8a9ac55 100644 (file)
 
 #include "gras.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,"Logs about the gigantic struct test");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs, test,
+                                "Logs about the gigantic struct test");
 
 #define READ  0
 #define WRITE 1
 #define RW    2
 
-void write_read(const char *type,void *src, void *dst, gras_socket_t *sock, int direction);
-
-GRAS_DEFINE_TYPE(cccc,struct cccc { char a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(ccsc,struct ccsc { char a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(ccic,struct ccic { char a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(cclc,struct cclc { char a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(ccLc,struct ccLc { char a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(ccfc,struct ccfc { char a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(ccdc,struct ccdc { char a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(sccc,struct sccc { short int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(scsc,struct scsc { short int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(scic,struct scic { short int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(sclc,struct sclc { short int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(scLc,struct scLc { short int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(scfc,struct scfc { short int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(scdc,struct scdc { short int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(iccc,struct iccc { int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(icsc,struct icsc { int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(icic,struct icic { int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(iclc,struct iclc { int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(icLc,struct icLc { int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(icfc,struct icfc { int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(icdc,struct icdc { int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(lccc,struct lccc { long int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(lcsc,struct lcsc { long int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(lcic,struct lcic { long int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(lclc,struct lclc { long int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(lcLc,struct lcLc { long int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(lcfc,struct lcfc { long int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(lcdc,struct lcdc { long int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(Lccc,struct Lccc { long long int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(Lcsc,struct Lcsc { long long int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(Lcic,struct Lcic { long long int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(Lclc,struct Lclc { long long int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(LcLc,struct LcLc { long long int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(Lcfc,struct Lcfc { long long int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(Lcdc,struct Lcdc { long long int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(fccc,struct fccc { float a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(fcsc,struct fcsc { float a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(fcic,struct fcic { float a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(fclc,struct fclc { float a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(fcLc,struct fcLc { float a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(fcfc,struct fcfc { float a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(fcdc,struct fcdc { float a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(dccc,struct dccc { double a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(dcsc,struct dcsc { double a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(dcic,struct dcic { double a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(dclc,struct dclc { double a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(dcLc,struct dcLc { double a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(dcfc,struct dcfc { double a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(dcdc,struct dcdc { double a; char b; double c;char d;};)
+void write_read(const char *type, void *src, void *dst,
+                gras_socket_t * sock, int direction);
 
+GRAS_DEFINE_TYPE(cccc, struct cccc {
+                 char a;
+                 char b;
+                 char c;
+                 char d;
+                 };
+
+    )
+    GRAS_DEFINE_TYPE(ccsc, struct ccsc {
+                     char a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccic, struct ccic {
+                     char a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(cclc, struct cclc {
+                     char a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccLc, struct ccLc {
+                     char a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccfc, struct ccfc {
+                     char a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccdc, struct ccdc {
+                     char a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(sccc, struct sccc {
+                     short int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scsc, struct scsc {
+                     short int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scic, struct scic {
+                     short int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(sclc, struct sclc {
+                     short int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scLc, struct scLc {
+                     short int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scfc, struct scfc {
+                     short int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scdc, struct scdc {
+                     short int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(iccc, struct iccc {
+                     int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icsc, struct icsc {
+                     int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icic, struct icic {
+                     int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(iclc, struct iclc {
+                     int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icLc, struct icLc {
+                     int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icfc, struct icfc {
+                     int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icdc, struct icdc {
+                     int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lccc, struct lccc {
+                     long int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcsc, struct lcsc {
+                     long int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcic, struct lcic {
+                     long int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lclc, struct lclc {
+                     long int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcLc, struct lcLc {
+                     long int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcfc, struct lcfc {
+                     long int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcdc, struct lcdc {
+                     long int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lccc, struct Lccc {
+                     long long int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcsc, struct Lcsc {
+                     long long int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcic, struct Lcic {
+                     long long int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lclc, struct Lclc {
+                     long long int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(LcLc, struct LcLc {
+                     long long int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcfc, struct Lcfc {
+                     long long int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcdc, struct Lcdc {
+                     long long int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fccc, struct fccc {
+                     float a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcsc, struct fcsc {
+                     float a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcic, struct fcic {
+                     float a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fclc, struct fclc {
+                     float a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcLc, struct fcLc {
+                     float a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcfc, struct fcfc {
+                     float a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcdc, struct fcdc {
+                     float a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dccc, struct dccc {
+                     double a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcsc, struct dcsc {
+                     double a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcic, struct dcic {
+                     double a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dclc, struct dclc {
+                     double a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcLc, struct dcLc {
+                     double a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcfc, struct dcfc {
+                     double a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcdc, struct dcdc {
+                     double a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
 #define test(a) xbt_assert(a)
 void register_structures(void);
-void register_structures(void) {
+void register_structures(void)
+{
   gras_msgtype_declare("cccc", gras_datadesc_by_symbol(cccc));
   gras_msgtype_declare("ccsc", gras_datadesc_by_symbol(ccsc));
   gras_msgtype_declare("ccic", gras_datadesc_by_symbol(ccic));
@@ -113,497 +458,647 @@ void register_structures(void) {
   gras_msgtype_declare("dcfc", gras_datadesc_by_symbol(dcfc));
   gras_msgtype_declare("dcdc", gras_datadesc_by_symbol(dcdc));
 }
-void test_structures(gras_socket_t *sock, int direction);
-void test_structures(gras_socket_t *sock, int direction) {
-  struct cccc my_cccc = {'w'+(char)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_cccc2;
-  struct ccsc my_ccsc = {'w'+(char)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_ccsc2;
-  struct ccic my_ccic = {'w'+(char)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_ccic2;
-  struct cclc my_cclc = {'w'+(char)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_cclc2;
-  struct ccLc my_ccLc = {'w'+(char)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_ccLc2;
-  struct ccfc my_ccfc = {'w'+(char)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_ccfc2;
-  struct ccdc my_ccdc = {'w'+(char)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_ccdc2;
-  struct sccc my_sccc = {134+(short int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_sccc2;
-  struct scsc my_scsc = {134+(short int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_scsc2;
-  struct scic my_scic = {134+(short int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_scic2;
-  struct sclc my_sclc = {134+(short int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_sclc2;
-  struct scLc my_scLc = {134+(short int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_scLc2;
-  struct scfc my_scfc = {134+(short int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_scfc2;
-  struct scdc my_scdc = {134+(short int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_scdc2;
-  struct iccc my_iccc = {-11249+(int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_iccc2;
-  struct icsc my_icsc = {-11249+(int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_icsc2;
-  struct icic my_icic = {-11249+(int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_icic2;
-  struct iclc my_iclc = {-11249+(int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_iclc2;
-  struct icLc my_icLc = {-11249+(int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_icLc2;
-  struct icfc my_icfc = {-11249+(int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_icfc2;
-  struct icdc my_icdc = {-11249+(int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_icdc2;
-  struct lccc my_lccc = {31319919+(long int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_lccc2;
-  struct lcsc my_lcsc = {31319919+(long int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_lcsc2;
-  struct lcic my_lcic = {31319919+(long int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_lcic2;
-  struct lclc my_lclc = {31319919+(long int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_lclc2;
-  struct lcLc my_lcLc = {31319919+(long int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_lcLc2;
-  struct lcfc my_lcfc = {31319919+(long int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_lcfc2;
-  struct lcdc my_lcdc = {31319919+(long int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_lcdc2;
-  struct Lccc my_Lccc = {-232130010+(long long int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_Lccc2;
-  struct Lcsc my_Lcsc = {-232130010+(long long int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_Lcsc2;
-  struct Lcic my_Lcic = {-232130010+(long long int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_Lcic2;
-  struct Lclc my_Lclc = {-232130010+(long long int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_Lclc2;
-  struct LcLc my_LcLc = {-232130010+(long long int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_LcLc2;
-  struct Lcfc my_Lcfc = {-232130010+(long long int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_Lcfc2;
-  struct Lcdc my_Lcdc = {-232130010+(long long int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_Lcdc2;
-  struct fccc my_fccc = {-11313.1135+(float)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_fccc2;
-  struct fcsc my_fcsc = {-11313.1135+(float)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_fcsc2;
-  struct fcic my_fcic = {-11313.1135+(float)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_fcic2;
-  struct fclc my_fclc = {-11313.1135+(float)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_fclc2;
-  struct fcLc my_fcLc = {-11313.1135+(float)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_fcLc2;
-  struct fcfc my_fcfc = {-11313.1135+(float)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_fcfc2;
-  struct fcdc my_fcdc = {-11313.1135+(float)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_fcdc2;
-  struct dccc my_dccc = {1424420.11331+(double)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_dccc2;
-  struct dcsc my_dcsc = {1424420.11331+(double)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_dcsc2;
-  struct dcic my_dcic = {1424420.11331+(double)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_dcic2;
-  struct dclc my_dclc = {1424420.11331+(double)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_dclc2;
-  struct dcLc my_dcLc = {1424420.11331+(double)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_dcLc2;
-  struct dcfc my_dcfc = {1424420.11331+(double)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_dcfc2;
-  struct dcdc my_dcdc = {1424420.11331+(double)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_dcdc2;
-  INFO0("---- Test on all possible struct having 3 fields (49 structs) ----");
-  write_read("cccc", &my_cccc, &my_cccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_cccc.a == my_cccc2.a);
-     test(my_cccc.b == my_cccc2.b);
-     test(my_cccc.c == my_cccc2.c);
-     test(my_cccc.d == my_cccc2.d);
-     if (!failed) VERB0("Passed cccc");
-  }
-  write_read("ccsc", &my_ccsc, &my_ccsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccsc.a == my_ccsc2.a);
-     test(my_ccsc.b == my_ccsc2.b);
-     test(my_ccsc.c == my_ccsc2.c);
-     test(my_ccsc.d == my_ccsc2.d);
-     if (!failed) VERB0("Passed ccsc");
-  }
-  write_read("ccic", &my_ccic, &my_ccic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccic.a == my_ccic2.a);
-     test(my_ccic.b == my_ccic2.b);
-     test(my_ccic.c == my_ccic2.c);
-     test(my_ccic.d == my_ccic2.d);
-     if (!failed) VERB0("Passed ccic");
-  }
-  write_read("cclc", &my_cclc, &my_cclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_cclc.a == my_cclc2.a);
-     test(my_cclc.b == my_cclc2.b);
-     test(my_cclc.c == my_cclc2.c);
-     test(my_cclc.d == my_cclc2.d);
-     if (!failed) VERB0("Passed cclc");
-  }
-  write_read("ccLc", &my_ccLc, &my_ccLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccLc.a == my_ccLc2.a);
-     test(my_ccLc.b == my_ccLc2.b);
-     test(my_ccLc.c == my_ccLc2.c);
-     test(my_ccLc.d == my_ccLc2.d);
-     if (!failed) VERB0("Passed ccLc");
-  }
-  write_read("ccfc", &my_ccfc, &my_ccfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccfc.a == my_ccfc2.a);
-     test(my_ccfc.b == my_ccfc2.b);
-     test(my_ccfc.c == my_ccfc2.c);
-     test(my_ccfc.d == my_ccfc2.d);
-     if (!failed) VERB0("Passed ccfc");
-  }
-  write_read("ccdc", &my_ccdc, &my_ccdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccdc.a == my_ccdc2.a);
-     test(my_ccdc.b == my_ccdc2.b);
-     test(my_ccdc.c == my_ccdc2.c);
-     test(my_ccdc.d == my_ccdc2.d);
-     if (!failed) VERB0("Passed ccdc");
-  }
-  write_read("sccc", &my_sccc, &my_sccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_sccc.a == my_sccc2.a);
-     test(my_sccc.b == my_sccc2.b);
-     test(my_sccc.c == my_sccc2.c);
-     test(my_sccc.d == my_sccc2.d);
-     if (!failed) VERB0("Passed sccc");
-  }
-  write_read("scsc", &my_scsc, &my_scsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scsc.a == my_scsc2.a);
-     test(my_scsc.b == my_scsc2.b);
-     test(my_scsc.c == my_scsc2.c);
-     test(my_scsc.d == my_scsc2.d);
-     if (!failed) VERB0("Passed scsc");
-  }
-  write_read("scic", &my_scic, &my_scic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scic.a == my_scic2.a);
-     test(my_scic.b == my_scic2.b);
-     test(my_scic.c == my_scic2.c);
-     test(my_scic.d == my_scic2.d);
-     if (!failed) VERB0("Passed scic");
-  }
-  write_read("sclc", &my_sclc, &my_sclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_sclc.a == my_sclc2.a);
-     test(my_sclc.b == my_sclc2.b);
-     test(my_sclc.c == my_sclc2.c);
-     test(my_sclc.d == my_sclc2.d);
-     if (!failed) VERB0("Passed sclc");
-  }
-  write_read("scLc", &my_scLc, &my_scLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scLc.a == my_scLc2.a);
-     test(my_scLc.b == my_scLc2.b);
-     test(my_scLc.c == my_scLc2.c);
-     test(my_scLc.d == my_scLc2.d);
-     if (!failed) VERB0("Passed scLc");
-  }
-  write_read("scfc", &my_scfc, &my_scfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scfc.a == my_scfc2.a);
-     test(my_scfc.b == my_scfc2.b);
-     test(my_scfc.c == my_scfc2.c);
-     test(my_scfc.d == my_scfc2.d);
-     if (!failed) VERB0("Passed scfc");
-  }
-  write_read("scdc", &my_scdc, &my_scdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scdc.a == my_scdc2.a);
-     test(my_scdc.b == my_scdc2.b);
-     test(my_scdc.c == my_scdc2.c);
-     test(my_scdc.d == my_scdc2.d);
-     if (!failed) VERB0("Passed scdc");
-  }
-  write_read("iccc", &my_iccc, &my_iccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_iccc.a == my_iccc2.a);
-     test(my_iccc.b == my_iccc2.b);
-     test(my_iccc.c == my_iccc2.c);
-     test(my_iccc.d == my_iccc2.d);
-     if (!failed) VERB0("Passed iccc");
-  }
-  write_read("icsc", &my_icsc, &my_icsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icsc.a == my_icsc2.a);
-     test(my_icsc.b == my_icsc2.b);
-     test(my_icsc.c == my_icsc2.c);
-     test(my_icsc.d == my_icsc2.d);
-     if (!failed) VERB0("Passed icsc");
-  }
-  write_read("icic", &my_icic, &my_icic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icic.a == my_icic2.a);
-     test(my_icic.b == my_icic2.b);
-     test(my_icic.c == my_icic2.c);
-     test(my_icic.d == my_icic2.d);
-     if (!failed) VERB0("Passed icic");
-  }
-  write_read("iclc", &my_iclc, &my_iclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_iclc.a == my_iclc2.a);
-     test(my_iclc.b == my_iclc2.b);
-     test(my_iclc.c == my_iclc2.c);
-     test(my_iclc.d == my_iclc2.d);
-     if (!failed) VERB0("Passed iclc");
-  }
-  write_read("icLc", &my_icLc, &my_icLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icLc.a == my_icLc2.a);
-     test(my_icLc.b == my_icLc2.b);
-     test(my_icLc.c == my_icLc2.c);
-     test(my_icLc.d == my_icLc2.d);
-     if (!failed) VERB0("Passed icLc");
-  }
-  write_read("icfc", &my_icfc, &my_icfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icfc.a == my_icfc2.a);
-     test(my_icfc.b == my_icfc2.b);
-     test(my_icfc.c == my_icfc2.c);
-     test(my_icfc.d == my_icfc2.d);
-     if (!failed) VERB0("Passed icfc");
-  }
-  write_read("icdc", &my_icdc, &my_icdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icdc.a == my_icdc2.a);
-     test(my_icdc.b == my_icdc2.b);
-     test(my_icdc.c == my_icdc2.c);
-     test(my_icdc.d == my_icdc2.d);
-     if (!failed) VERB0("Passed icdc");
-  }
-  write_read("lccc", &my_lccc, &my_lccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lccc.a == my_lccc2.a);
-     test(my_lccc.b == my_lccc2.b);
-     test(my_lccc.c == my_lccc2.c);
-     test(my_lccc.d == my_lccc2.d);
-     if (!failed) VERB0("Passed lccc");
-  }
-  write_read("lcsc", &my_lcsc, &my_lcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcsc.a == my_lcsc2.a);
-     test(my_lcsc.b == my_lcsc2.b);
-     test(my_lcsc.c == my_lcsc2.c);
-     test(my_lcsc.d == my_lcsc2.d);
-     if (!failed) VERB0("Passed lcsc");
-  }
-  write_read("lcic", &my_lcic, &my_lcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcic.a == my_lcic2.a);
-     test(my_lcic.b == my_lcic2.b);
-     test(my_lcic.c == my_lcic2.c);
-     test(my_lcic.d == my_lcic2.d);
-     if (!failed) VERB0("Passed lcic");
-  }
-  write_read("lclc", &my_lclc, &my_lclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lclc.a == my_lclc2.a);
-     test(my_lclc.b == my_lclc2.b);
-     test(my_lclc.c == my_lclc2.c);
-     test(my_lclc.d == my_lclc2.d);
-     if (!failed) VERB0("Passed lclc");
-  }
-  write_read("lcLc", &my_lcLc, &my_lcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcLc.a == my_lcLc2.a);
-     test(my_lcLc.b == my_lcLc2.b);
-     test(my_lcLc.c == my_lcLc2.c);
-     test(my_lcLc.d == my_lcLc2.d);
-     if (!failed) VERB0("Passed lcLc");
-  }
-  write_read("lcfc", &my_lcfc, &my_lcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcfc.a == my_lcfc2.a);
-     test(my_lcfc.b == my_lcfc2.b);
-     test(my_lcfc.c == my_lcfc2.c);
-     test(my_lcfc.d == my_lcfc2.d);
-     if (!failed) VERB0("Passed lcfc");
-  }
-  write_read("lcdc", &my_lcdc, &my_lcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcdc.a == my_lcdc2.a);
-     test(my_lcdc.b == my_lcdc2.b);
-     test(my_lcdc.c == my_lcdc2.c);
-     test(my_lcdc.d == my_lcdc2.d);
-     if (!failed) VERB0("Passed lcdc");
-  }
-  write_read("Lccc", &my_Lccc, &my_Lccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lccc.a == my_Lccc2.a);
-     test(my_Lccc.b == my_Lccc2.b);
-     test(my_Lccc.c == my_Lccc2.c);
-     test(my_Lccc.d == my_Lccc2.d);
-     if (!failed) VERB0("Passed Lccc");
-  }
-  write_read("Lcsc", &my_Lcsc, &my_Lcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcsc.a == my_Lcsc2.a);
-     test(my_Lcsc.b == my_Lcsc2.b);
-     test(my_Lcsc.c == my_Lcsc2.c);
-     test(my_Lcsc.d == my_Lcsc2.d);
-     if (!failed) VERB0("Passed Lcsc");
-  }
-  write_read("Lcic", &my_Lcic, &my_Lcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcic.a == my_Lcic2.a);
-     test(my_Lcic.b == my_Lcic2.b);
-     test(my_Lcic.c == my_Lcic2.c);
-     test(my_Lcic.d == my_Lcic2.d);
-     if (!failed) VERB0("Passed Lcic");
-  }
-  write_read("Lclc", &my_Lclc, &my_Lclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lclc.a == my_Lclc2.a);
-     test(my_Lclc.b == my_Lclc2.b);
-     test(my_Lclc.c == my_Lclc2.c);
-     test(my_Lclc.d == my_Lclc2.d);
-     if (!failed) VERB0("Passed Lclc");
-  }
-  write_read("LcLc", &my_LcLc, &my_LcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_LcLc.a == my_LcLc2.a);
-     test(my_LcLc.b == my_LcLc2.b);
-     test(my_LcLc.c == my_LcLc2.c);
-     test(my_LcLc.d == my_LcLc2.d);
-     if (!failed) VERB0("Passed LcLc");
-  }
-  write_read("Lcfc", &my_Lcfc, &my_Lcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcfc.a == my_Lcfc2.a);
-     test(my_Lcfc.b == my_Lcfc2.b);
-     test(my_Lcfc.c == my_Lcfc2.c);
-     test(my_Lcfc.d == my_Lcfc2.d);
-     if (!failed) VERB0("Passed Lcfc");
-  }
-  write_read("Lcdc", &my_Lcdc, &my_Lcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcdc.a == my_Lcdc2.a);
-     test(my_Lcdc.b == my_Lcdc2.b);
-     test(my_Lcdc.c == my_Lcdc2.c);
-     test(my_Lcdc.d == my_Lcdc2.d);
-     if (!failed) VERB0("Passed Lcdc");
-  }
-  write_read("fccc", &my_fccc, &my_fccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fccc.a == my_fccc2.a);
-     test(my_fccc.b == my_fccc2.b);
-     test(my_fccc.c == my_fccc2.c);
-     test(my_fccc.d == my_fccc2.d);
-     if (!failed) VERB0("Passed fccc");
-  }
-  write_read("fcsc", &my_fcsc, &my_fcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcsc.a == my_fcsc2.a);
-     test(my_fcsc.b == my_fcsc2.b);
-     test(my_fcsc.c == my_fcsc2.c);
-     test(my_fcsc.d == my_fcsc2.d);
-     if (!failed) VERB0("Passed fcsc");
-  }
-  write_read("fcic", &my_fcic, &my_fcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcic.a == my_fcic2.a);
-     test(my_fcic.b == my_fcic2.b);
-     test(my_fcic.c == my_fcic2.c);
-     test(my_fcic.d == my_fcic2.d);
-     if (!failed) VERB0("Passed fcic");
-  }
-  write_read("fclc", &my_fclc, &my_fclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fclc.a == my_fclc2.a);
-     test(my_fclc.b == my_fclc2.b);
-     test(my_fclc.c == my_fclc2.c);
-     test(my_fclc.d == my_fclc2.d);
-     if (!failed) VERB0("Passed fclc");
-  }
-  write_read("fcLc", &my_fcLc, &my_fcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcLc.a == my_fcLc2.a);
-     test(my_fcLc.b == my_fcLc2.b);
-     test(my_fcLc.c == my_fcLc2.c);
-     test(my_fcLc.d == my_fcLc2.d);
-     if (!failed) VERB0("Passed fcLc");
-  }
-  write_read("fcfc", &my_fcfc, &my_fcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcfc.a == my_fcfc2.a);
-     test(my_fcfc.b == my_fcfc2.b);
-     test(my_fcfc.c == my_fcfc2.c);
-     test(my_fcfc.d == my_fcfc2.d);
-     if (!failed) VERB0("Passed fcfc");
-  }
-  write_read("fcdc", &my_fcdc, &my_fcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcdc.a == my_fcdc2.a);
-     test(my_fcdc.b == my_fcdc2.b);
-     test(my_fcdc.c == my_fcdc2.c);
-     test(my_fcdc.d == my_fcdc2.d);
-     if (!failed) VERB0("Passed fcdc");
-  }
-  write_read("dccc", &my_dccc, &my_dccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dccc.a == my_dccc2.a);
-     test(my_dccc.b == my_dccc2.b);
-     test(my_dccc.c == my_dccc2.c);
-     test(my_dccc.d == my_dccc2.d);
-     if (!failed) VERB0("Passed dccc");
-  }
-  write_read("dcsc", &my_dcsc, &my_dcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcsc.a == my_dcsc2.a);
-     test(my_dcsc.b == my_dcsc2.b);
-     test(my_dcsc.c == my_dcsc2.c);
-     test(my_dcsc.d == my_dcsc2.d);
-     if (!failed) VERB0("Passed dcsc");
-  }
-  write_read("dcic", &my_dcic, &my_dcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcic.a == my_dcic2.a);
-     test(my_dcic.b == my_dcic2.b);
-     test(my_dcic.c == my_dcic2.c);
-     test(my_dcic.d == my_dcic2.d);
-     if (!failed) VERB0("Passed dcic");
-  }
-  write_read("dclc", &my_dclc, &my_dclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dclc.a == my_dclc2.a);
-     test(my_dclc.b == my_dclc2.b);
-     test(my_dclc.c == my_dclc2.c);
-     test(my_dclc.d == my_dclc2.d);
-     if (!failed) VERB0("Passed dclc");
-  }
-  write_read("dcLc", &my_dcLc, &my_dcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcLc.a == my_dcLc2.a);
-     test(my_dcLc.b == my_dcLc2.b);
-     test(my_dcLc.c == my_dcLc2.c);
-     test(my_dcLc.d == my_dcLc2.d);
-     if (!failed) VERB0("Passed dcLc");
-  }
-  write_read("dcfc", &my_dcfc, &my_dcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcfc.a == my_dcfc2.a);
-     test(my_dcfc.b == my_dcfc2.b);
-     test(my_dcfc.c == my_dcfc2.c);
-     test(my_dcfc.d == my_dcfc2.d);
-     if (!failed) VERB0("Passed dcfc");
-  }
-  write_read("dcdc", &my_dcdc, &my_dcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcdc.a == my_dcdc2.a);
-     test(my_dcdc.b == my_dcdc2.b);
-     test(my_dcdc.c == my_dcdc2.c);
-     test(my_dcdc.d == my_dcdc2.d);
-     if (!failed) VERB0("Passed dcdc");
+
+void test_structures(gras_socket_t * sock, int direction);
+void test_structures(gras_socket_t * sock, int direction)
+{
+  struct cccc my_cccc =
+      { 'w' + (char) 1, 'w' + (char) 2, 'w' + (char) 3, 'w' + (char) 4 },
+      my_cccc2;
+  struct ccsc my_ccsc =
+      { 'w' + (char) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_ccsc2;
+  struct ccic my_ccic =
+      { 'w' + (char) 1, 'w' + (char) 2, -11249 + (int) 3, 'w' + (char) 4 },
+      my_ccic2;
+  struct cclc my_cclc =
+      { 'w' + (char) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_cclc2;
+  struct ccLc my_ccLc =
+      { 'w' + (char) 1, 'w' + (char) 2, -232130010 + (long long int) 3,
+'w' + (char) 4 }, my_ccLc2;
+  struct ccfc my_ccfc =
+      { 'w' + (char) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_ccfc2;
+  struct ccdc my_ccdc =
+      { 'w' + (char) 1, 'w' + (char) 2, 1424420.11331 + (double) 3,
+'w' + (char) 4 }, my_ccdc2;
+  struct sccc my_sccc =
+      { 134 + (short int) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_sccc2;
+  struct scsc my_scsc =
+      { 134 + (short int) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_scsc2;
+  struct scic my_scic =
+      { 134 + (short int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_scic2;
+  struct sclc my_sclc =
+      { 134 + (short int) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_sclc2;
+  struct scLc my_scLc =
+      { 134 + (short int) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_scLc2;
+  struct scfc my_scfc =
+      { 134 + (short int) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_scfc2;
+  struct scdc my_scdc =
+      { 134 + (short int) 1, 'w' + (char) 2, 1424420.11331 + (double) 3,
+'w' + (char) 4 }, my_scdc2;
+  struct iccc my_iccc =
+      { -11249 + (int) 1, 'w' + (char) 2, 'w' + (char) 3, 'w' + (char) 4 },
+      my_iccc2;
+  struct icsc my_icsc =
+      { -11249 + (int) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_icsc2;
+  struct icic my_icic =
+      { -11249 + (int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_icic2;
+  struct iclc my_iclc =
+      { -11249 + (int) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_iclc2;
+  struct icLc my_icLc =
+      { -11249 + (int) 1, 'w' + (char) 2, -232130010 + (long long int) 3,
+'w' + (char) 4 }, my_icLc2;
+  struct icfc my_icfc =
+      { -11249 + (int) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_icfc2;
+  struct icdc my_icdc =
+      { -11249 + (int) 1, 'w' + (char) 2, 1424420.11331 + (double) 3,
+'w' + (char) 4 }, my_icdc2;
+  struct lccc my_lccc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_lccc2;
+  struct lcsc my_lcsc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_lcsc2;
+  struct lcic my_lcic =
+      { 31319919 + (long int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_lcic2;
+  struct lclc my_lclc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_lclc2;
+  struct lcLc my_lcLc =
+      { 31319919 + (long int) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_lcLc2;
+  struct lcfc my_lcfc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_lcfc2;
+  struct lcdc my_lcdc =
+      { 31319919 + (long int) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_lcdc2;
+  struct Lccc my_Lccc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_Lccc2;
+  struct Lcsc my_Lcsc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+134 + (short int) 3, 'w' + (char) 4 }, my_Lcsc2;
+  struct Lcic my_Lcic =
+      { -232130010 + (long long int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_Lcic2;
+  struct Lclc my_Lclc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+31319919 + (long int) 3, 'w' + (char) 4 }, my_Lclc2;
+  struct LcLc my_LcLc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_LcLc2;
+  struct Lcfc my_Lcfc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+-11313.1135 + (float) 3, 'w' + (char) 4 }, my_Lcfc2;
+  struct Lcdc my_Lcdc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_Lcdc2;
+  struct fccc my_fccc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_fccc2;
+  struct fcsc my_fcsc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_fcsc2;
+  struct fcic my_fcic =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_fcic2;
+  struct fclc my_fclc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_fclc2;
+  struct fcLc my_fcLc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_fcLc2;
+  struct fcfc my_fcfc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_fcfc2;
+  struct fcdc my_fcdc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_fcdc2;
+  struct dccc my_dccc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_dccc2;
+  struct dcsc my_dcsc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_dcsc2;
+  struct dcic my_dcic =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_dcic2;
+  struct dclc my_dclc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+31319919 + (long int) 3, 'w' + (char) 4 }, my_dclc2;
+  struct dcLc my_dcLc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_dcLc2;
+  struct dcfc my_dcfc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+-11313.1135 + (float) 3, 'w' + (char) 4 }, my_dcfc2;
+  struct dcdc my_dcdc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_dcdc2;
+  INFO0
+      ("---- Test on all possible struct having 3 fields (49 structs) ----");
+  write_read("cccc", &my_cccc, &my_cccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_cccc.a == my_cccc2.a);
+    test(my_cccc.b == my_cccc2.b);
+    test(my_cccc.c == my_cccc2.c);
+    test(my_cccc.d == my_cccc2.d);
+    if (!failed)
+      VERB0("Passed cccc");
+  }
+  write_read("ccsc", &my_ccsc, &my_ccsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccsc.a == my_ccsc2.a);
+    test(my_ccsc.b == my_ccsc2.b);
+    test(my_ccsc.c == my_ccsc2.c);
+    test(my_ccsc.d == my_ccsc2.d);
+    if (!failed)
+      VERB0("Passed ccsc");
+  }
+  write_read("ccic", &my_ccic, &my_ccic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccic.a == my_ccic2.a);
+    test(my_ccic.b == my_ccic2.b);
+    test(my_ccic.c == my_ccic2.c);
+    test(my_ccic.d == my_ccic2.d);
+    if (!failed)
+      VERB0("Passed ccic");
+  }
+  write_read("cclc", &my_cclc, &my_cclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_cclc.a == my_cclc2.a);
+    test(my_cclc.b == my_cclc2.b);
+    test(my_cclc.c == my_cclc2.c);
+    test(my_cclc.d == my_cclc2.d);
+    if (!failed)
+      VERB0("Passed cclc");
+  }
+  write_read("ccLc", &my_ccLc, &my_ccLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccLc.a == my_ccLc2.a);
+    test(my_ccLc.b == my_ccLc2.b);
+    test(my_ccLc.c == my_ccLc2.c);
+    test(my_ccLc.d == my_ccLc2.d);
+    if (!failed)
+      VERB0("Passed ccLc");
+  }
+  write_read("ccfc", &my_ccfc, &my_ccfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccfc.a == my_ccfc2.a);
+    test(my_ccfc.b == my_ccfc2.b);
+    test(my_ccfc.c == my_ccfc2.c);
+    test(my_ccfc.d == my_ccfc2.d);
+    if (!failed)
+      VERB0("Passed ccfc");
+  }
+  write_read("ccdc", &my_ccdc, &my_ccdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccdc.a == my_ccdc2.a);
+    test(my_ccdc.b == my_ccdc2.b);
+    test(my_ccdc.c == my_ccdc2.c);
+    test(my_ccdc.d == my_ccdc2.d);
+    if (!failed)
+      VERB0("Passed ccdc");
+  }
+  write_read("sccc", &my_sccc, &my_sccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_sccc.a == my_sccc2.a);
+    test(my_sccc.b == my_sccc2.b);
+    test(my_sccc.c == my_sccc2.c);
+    test(my_sccc.d == my_sccc2.d);
+    if (!failed)
+      VERB0("Passed sccc");
+  }
+  write_read("scsc", &my_scsc, &my_scsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scsc.a == my_scsc2.a);
+    test(my_scsc.b == my_scsc2.b);
+    test(my_scsc.c == my_scsc2.c);
+    test(my_scsc.d == my_scsc2.d);
+    if (!failed)
+      VERB0("Passed scsc");
+  }
+  write_read("scic", &my_scic, &my_scic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scic.a == my_scic2.a);
+    test(my_scic.b == my_scic2.b);
+    test(my_scic.c == my_scic2.c);
+    test(my_scic.d == my_scic2.d);
+    if (!failed)
+      VERB0("Passed scic");
+  }
+  write_read("sclc", &my_sclc, &my_sclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_sclc.a == my_sclc2.a);
+    test(my_sclc.b == my_sclc2.b);
+    test(my_sclc.c == my_sclc2.c);
+    test(my_sclc.d == my_sclc2.d);
+    if (!failed)
+      VERB0("Passed sclc");
+  }
+  write_read("scLc", &my_scLc, &my_scLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scLc.a == my_scLc2.a);
+    test(my_scLc.b == my_scLc2.b);
+    test(my_scLc.c == my_scLc2.c);
+    test(my_scLc.d == my_scLc2.d);
+    if (!failed)
+      VERB0("Passed scLc");
+  }
+  write_read("scfc", &my_scfc, &my_scfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scfc.a == my_scfc2.a);
+    test(my_scfc.b == my_scfc2.b);
+    test(my_scfc.c == my_scfc2.c);
+    test(my_scfc.d == my_scfc2.d);
+    if (!failed)
+      VERB0("Passed scfc");
+  }
+  write_read("scdc", &my_scdc, &my_scdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scdc.a == my_scdc2.a);
+    test(my_scdc.b == my_scdc2.b);
+    test(my_scdc.c == my_scdc2.c);
+    test(my_scdc.d == my_scdc2.d);
+    if (!failed)
+      VERB0("Passed scdc");
+  }
+  write_read("iccc", &my_iccc, &my_iccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_iccc.a == my_iccc2.a);
+    test(my_iccc.b == my_iccc2.b);
+    test(my_iccc.c == my_iccc2.c);
+    test(my_iccc.d == my_iccc2.d);
+    if (!failed)
+      VERB0("Passed iccc");
+  }
+  write_read("icsc", &my_icsc, &my_icsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icsc.a == my_icsc2.a);
+    test(my_icsc.b == my_icsc2.b);
+    test(my_icsc.c == my_icsc2.c);
+    test(my_icsc.d == my_icsc2.d);
+    if (!failed)
+      VERB0("Passed icsc");
+  }
+  write_read("icic", &my_icic, &my_icic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icic.a == my_icic2.a);
+    test(my_icic.b == my_icic2.b);
+    test(my_icic.c == my_icic2.c);
+    test(my_icic.d == my_icic2.d);
+    if (!failed)
+      VERB0("Passed icic");
+  }
+  write_read("iclc", &my_iclc, &my_iclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_iclc.a == my_iclc2.a);
+    test(my_iclc.b == my_iclc2.b);
+    test(my_iclc.c == my_iclc2.c);
+    test(my_iclc.d == my_iclc2.d);
+    if (!failed)
+      VERB0("Passed iclc");
+  }
+  write_read("icLc", &my_icLc, &my_icLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icLc.a == my_icLc2.a);
+    test(my_icLc.b == my_icLc2.b);
+    test(my_icLc.c == my_icLc2.c);
+    test(my_icLc.d == my_icLc2.d);
+    if (!failed)
+      VERB0("Passed icLc");
+  }
+  write_read("icfc", &my_icfc, &my_icfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icfc.a == my_icfc2.a);
+    test(my_icfc.b == my_icfc2.b);
+    test(my_icfc.c == my_icfc2.c);
+    test(my_icfc.d == my_icfc2.d);
+    if (!failed)
+      VERB0("Passed icfc");
+  }
+  write_read("icdc", &my_icdc, &my_icdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icdc.a == my_icdc2.a);
+    test(my_icdc.b == my_icdc2.b);
+    test(my_icdc.c == my_icdc2.c);
+    test(my_icdc.d == my_icdc2.d);
+    if (!failed)
+      VERB0("Passed icdc");
+  }
+  write_read("lccc", &my_lccc, &my_lccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lccc.a == my_lccc2.a);
+    test(my_lccc.b == my_lccc2.b);
+    test(my_lccc.c == my_lccc2.c);
+    test(my_lccc.d == my_lccc2.d);
+    if (!failed)
+      VERB0("Passed lccc");
+  }
+  write_read("lcsc", &my_lcsc, &my_lcsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcsc.a == my_lcsc2.a);
+    test(my_lcsc.b == my_lcsc2.b);
+    test(my_lcsc.c == my_lcsc2.c);
+    test(my_lcsc.d == my_lcsc2.d);
+    if (!failed)
+      VERB0("Passed lcsc");
+  }
+  write_read("lcic", &my_lcic, &my_lcic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcic.a == my_lcic2.a);
+    test(my_lcic.b == my_lcic2.b);
+    test(my_lcic.c == my_lcic2.c);
+    test(my_lcic.d == my_lcic2.d);
+    if (!failed)
+      VERB0("Passed lcic");
+  }
+  write_read("lclc", &my_lclc, &my_lclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lclc.a == my_lclc2.a);
+    test(my_lclc.b == my_lclc2.b);
+    test(my_lclc.c == my_lclc2.c);
+    test(my_lclc.d == my_lclc2.d);
+    if (!failed)
+      VERB0("Passed lclc");
+  }
+  write_read("lcLc", &my_lcLc, &my_lcLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcLc.a == my_lcLc2.a);
+    test(my_lcLc.b == my_lcLc2.b);
+    test(my_lcLc.c == my_lcLc2.c);
+    test(my_lcLc.d == my_lcLc2.d);
+    if (!failed)
+      VERB0("Passed lcLc");
+  }
+  write_read("lcfc", &my_lcfc, &my_lcfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcfc.a == my_lcfc2.a);
+    test(my_lcfc.b == my_lcfc2.b);
+    test(my_lcfc.c == my_lcfc2.c);
+    test(my_lcfc.d == my_lcfc2.d);
+    if (!failed)
+      VERB0("Passed lcfc");
+  }
+  write_read("lcdc", &my_lcdc, &my_lcdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcdc.a == my_lcdc2.a);
+    test(my_lcdc.b == my_lcdc2.b);
+    test(my_lcdc.c == my_lcdc2.c);
+    test(my_lcdc.d == my_lcdc2.d);
+    if (!failed)
+      VERB0("Passed lcdc");
+  }
+  write_read("Lccc", &my_Lccc, &my_Lccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lccc.a == my_Lccc2.a);
+    test(my_Lccc.b == my_Lccc2.b);
+    test(my_Lccc.c == my_Lccc2.c);
+    test(my_Lccc.d == my_Lccc2.d);
+    if (!failed)
+      VERB0("Passed Lccc");
+  }
+  write_read("Lcsc", &my_Lcsc, &my_Lcsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcsc.a == my_Lcsc2.a);
+    test(my_Lcsc.b == my_Lcsc2.b);
+    test(my_Lcsc.c == my_Lcsc2.c);
+    test(my_Lcsc.d == my_Lcsc2.d);
+    if (!failed)
+      VERB0("Passed Lcsc");
+  }
+  write_read("Lcic", &my_Lcic, &my_Lcic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcic.a == my_Lcic2.a);
+    test(my_Lcic.b == my_Lcic2.b);
+    test(my_Lcic.c == my_Lcic2.c);
+    test(my_Lcic.d == my_Lcic2.d);
+    if (!failed)
+      VERB0("Passed Lcic");
+  }
+  write_read("Lclc", &my_Lclc, &my_Lclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lclc.a == my_Lclc2.a);
+    test(my_Lclc.b == my_Lclc2.b);
+    test(my_Lclc.c == my_Lclc2.c);
+    test(my_Lclc.d == my_Lclc2.d);
+    if (!failed)
+      VERB0("Passed Lclc");
+  }
+  write_read("LcLc", &my_LcLc, &my_LcLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_LcLc.a == my_LcLc2.a);
+    test(my_LcLc.b == my_LcLc2.b);
+    test(my_LcLc.c == my_LcLc2.c);
+    test(my_LcLc.d == my_LcLc2.d);
+    if (!failed)
+      VERB0("Passed LcLc");
+  }
+  write_read("Lcfc", &my_Lcfc, &my_Lcfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcfc.a == my_Lcfc2.a);
+    test(my_Lcfc.b == my_Lcfc2.b);
+    test(my_Lcfc.c == my_Lcfc2.c);
+    test(my_Lcfc.d == my_Lcfc2.d);
+    if (!failed)
+      VERB0("Passed Lcfc");
+  }
+  write_read("Lcdc", &my_Lcdc, &my_Lcdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcdc.a == my_Lcdc2.a);
+    test(my_Lcdc.b == my_Lcdc2.b);
+    test(my_Lcdc.c == my_Lcdc2.c);
+    test(my_Lcdc.d == my_Lcdc2.d);
+    if (!failed)
+      VERB0("Passed Lcdc");
+  }
+  write_read("fccc", &my_fccc, &my_fccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fccc.a == my_fccc2.a);
+    test(my_fccc.b == my_fccc2.b);
+    test(my_fccc.c == my_fccc2.c);
+    test(my_fccc.d == my_fccc2.d);
+    if (!failed)
+      VERB0("Passed fccc");
+  }
+  write_read("fcsc", &my_fcsc, &my_fcsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcsc.a == my_fcsc2.a);
+    test(my_fcsc.b == my_fcsc2.b);
+    test(my_fcsc.c == my_fcsc2.c);
+    test(my_fcsc.d == my_fcsc2.d);
+    if (!failed)
+      VERB0("Passed fcsc");
+  }
+  write_read("fcic", &my_fcic, &my_fcic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcic.a == my_fcic2.a);
+    test(my_fcic.b == my_fcic2.b);
+    test(my_fcic.c == my_fcic2.c);
+    test(my_fcic.d == my_fcic2.d);
+    if (!failed)
+      VERB0("Passed fcic");
+  }
+  write_read("fclc", &my_fclc, &my_fclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fclc.a == my_fclc2.a);
+    test(my_fclc.b == my_fclc2.b);
+    test(my_fclc.c == my_fclc2.c);
+    test(my_fclc.d == my_fclc2.d);
+    if (!failed)
+      VERB0("Passed fclc");
+  }
+  write_read("fcLc", &my_fcLc, &my_fcLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcLc.a == my_fcLc2.a);
+    test(my_fcLc.b == my_fcLc2.b);
+    test(my_fcLc.c == my_fcLc2.c);
+    test(my_fcLc.d == my_fcLc2.d);
+    if (!failed)
+      VERB0("Passed fcLc");
+  }
+  write_read("fcfc", &my_fcfc, &my_fcfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcfc.a == my_fcfc2.a);
+    test(my_fcfc.b == my_fcfc2.b);
+    test(my_fcfc.c == my_fcfc2.c);
+    test(my_fcfc.d == my_fcfc2.d);
+    if (!failed)
+      VERB0("Passed fcfc");
+  }
+  write_read("fcdc", &my_fcdc, &my_fcdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcdc.a == my_fcdc2.a);
+    test(my_fcdc.b == my_fcdc2.b);
+    test(my_fcdc.c == my_fcdc2.c);
+    test(my_fcdc.d == my_fcdc2.d);
+    if (!failed)
+      VERB0("Passed fcdc");
+  }
+  write_read("dccc", &my_dccc, &my_dccc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dccc.a == my_dccc2.a);
+    test(my_dccc.b == my_dccc2.b);
+    test(my_dccc.c == my_dccc2.c);
+    test(my_dccc.d == my_dccc2.d);
+    if (!failed)
+      VERB0("Passed dccc");
+  }
+  write_read("dcsc", &my_dcsc, &my_dcsc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcsc.a == my_dcsc2.a);
+    test(my_dcsc.b == my_dcsc2.b);
+    test(my_dcsc.c == my_dcsc2.c);
+    test(my_dcsc.d == my_dcsc2.d);
+    if (!failed)
+      VERB0("Passed dcsc");
+  }
+  write_read("dcic", &my_dcic, &my_dcic2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcic.a == my_dcic2.a);
+    test(my_dcic.b == my_dcic2.b);
+    test(my_dcic.c == my_dcic2.c);
+    test(my_dcic.d == my_dcic2.d);
+    if (!failed)
+      VERB0("Passed dcic");
+  }
+  write_read("dclc", &my_dclc, &my_dclc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dclc.a == my_dclc2.a);
+    test(my_dclc.b == my_dclc2.b);
+    test(my_dclc.c == my_dclc2.c);
+    test(my_dclc.d == my_dclc2.d);
+    if (!failed)
+      VERB0("Passed dclc");
+  }
+  write_read("dcLc", &my_dcLc, &my_dcLc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcLc.a == my_dcLc2.a);
+    test(my_dcLc.b == my_dcLc2.b);
+    test(my_dcLc.c == my_dcLc2.c);
+    test(my_dcLc.d == my_dcLc2.d);
+    if (!failed)
+      VERB0("Passed dcLc");
+  }
+  write_read("dcfc", &my_dcfc, &my_dcfc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcfc.a == my_dcfc2.a);
+    test(my_dcfc.b == my_dcfc2.b);
+    test(my_dcfc.c == my_dcfc2.c);
+    test(my_dcfc.d == my_dcfc2.d);
+    if (!failed)
+      VERB0("Passed dcfc");
+  }
+  write_read("dcdc", &my_dcdc, &my_dcdc2, sock, direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcdc.a == my_dcdc2.a);
+    test(my_dcdc.b == my_dcdc2.b);
+    test(my_dcdc.c == my_dcdc2.c);
+    test(my_dcdc.d == my_dcdc2.d);
+    if (!failed)
+      VERB0("Passed dcdc");
   }
 }
index ac8e05d..8caa457 100644 (file)
@@ -126,8 +126,8 @@ static void test_dynar_scal(gras_socket_t sock, int direction)
       int ret = xbt_dynar_get_as(j, cpt, int);
       if (cpt != ret) {
         CRITICAL3
-          ("The retrieved value for cpt=%d is not the same than the injected one (%d!=%d)",
-           cpt, ret, cpt);
+            ("The retrieved value for cpt=%d is not the same than the injected one (%d!=%d)",
+             cpt, ret, cpt);
         xbt_abort();
       }
     }
@@ -245,7 +245,8 @@ static void test_hetestruct(gras_socket_t sock, int direction)
   if (direction == READ || direction == COPY) {
     xbt_assert(i->c1 == j->c1);
     xbt_assert(i->c2 == j->c2);
-    xbt_assert2(i->l1 == j->l1, "i->l1(=%ld)  !=  j->l1(=%ld)", i->l1, j->l1);
+    xbt_assert2(i->l1 == j->l1, "i->l1(=%ld)  !=  j->l1(=%ld)", i->l1,
+                j->l1);
     xbt_assert(i->l2 == j->l2);
     free(j);
   }
@@ -456,17 +457,21 @@ static void test_dynar_ref(gras_socket_t sock, int direction)
 
 /**** PBIO *****/
 GRAS_DEFINE_TYPE(s_pbio, struct s_pbio {        /* structure presented in the IEEE article */
-                 int Cnstatv; double Cstatev[12];
-                 int Cnprops;
-                 double Cprops[110]; int Cndi[4]; int Cnshr; int Cnpt;
-                 double Cdtime;
-                 double Ctime[2];
-                 int Cntens; double Cdfgrd0[373][3]; double Cdfgrd1[3][3];
-                 double Cstress[106]; double Cddsdde[106][106];};)
+                 int Cnstatv;
+                 double Cstatev[12]; int Cnprops; double Cprops[110];
+                 int Cndi[4];
+                 int Cnshr;
+                 int Cnpt; double Cdtime; double Ctime[2]; int Cntens;
+                 double Cdfgrd0[373][3];
+                 double Cdfgrd1[3][3]; double Cstress[106];
+                 double Cddsdde[106][106];
+                 };
+
+    )
 
-     typedef struct s_pbio pbio_t;
+typedef struct s_pbio pbio_t;
 
-     static void test_pbio(gras_socket_t sock, int direction)
+static void test_pbio(gras_socket_t sock, int direction)
 {
   int cpt;
   int cpt2;
@@ -474,7 +479,7 @@ GRAS_DEFINE_TYPE(s_pbio, struct s_pbio {        /* structure presented in the IE
   pbio_t i, j;
 
   INFO0
-    ("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
+      ("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
   pbio_type = gras_datadesc_by_symbol(s_pbio);
 
   /* Fill in that damn struct */
@@ -540,20 +545,19 @@ GRAS_DEFINE_TYPE(s_pbio, struct s_pbio {        /* structure presented in the IE
 }
 
 GRAS_DEFINE_TYPE(s_clause, struct s_clause {
-                 int num_lits; int *literals GRAS_ANNOTE(size, num_lits);       /* Tells GRAS where to find the size */
-                 };
-
-  )
+                 int num_lits;
+                 int *literals GRAS_ANNOTE(size, num_lits);     /* Tells GRAS where to find the size */
+                 };)
 
-     typedef struct s_clause Clause;
+typedef struct s_clause Clause;
 
-     static void test_clause(gras_socket_t sock, int direction)
+static void test_clause(gras_socket_t sock, int direction)
 {
   Clause *i, *j;
   int cpt;
 
   INFO0
-    ("---- Test on struct containing dynamic array and its size (cbps test) ----");
+      ("---- Test on struct containing dynamic array and its size (cbps test) ----");
 
   /* create and fill the struct */
   i = xbt_new(Clause, 1);
@@ -583,7 +587,7 @@ static void test_clause_empty(gras_socket_t sock, int direction)
   Clause *i, *j;
 
   INFO0
-    ("---- Test on struct containing dynamic array and its size when size=0 (cbps test) ----");
+      ("---- Test on struct containing dynamic array and its size when size=0 (cbps test) ----");
 
   /* create and fill the struct */
   i = xbt_new(Clause, 1);
@@ -634,7 +638,8 @@ static void register_types(void)
   gras_datadesc_struct_append(my_type, "d", gras_datadesc_by_name("int"));
   gras_datadesc_struct_close(my_type);
   my_type =
-    gras_datadesc_ref("homostruct*", gras_datadesc_by_name("homostruct"));
+      gras_datadesc_ref("homostruct*",
+                        gras_datadesc_by_name("homostruct"));
   gras_msgtype_declare("homostruct*", my_type);
 
   my_type = gras_datadesc_struct("hetestruct");
@@ -648,12 +653,13 @@ static void register_types(void)
                               gras_datadesc_by_name("unsigned long int"));
   gras_datadesc_struct_close(my_type);
   my_type =
-    gras_datadesc_ref("hetestruct*", gras_datadesc_by_name("hetestruct"));
+      gras_datadesc_ref("hetestruct*",
+                        gras_datadesc_by_name("hetestruct"));
   gras_msgtype_declare("hetestruct*", my_type);
 
   my_type =
-    gras_datadesc_array_fixed("hetestruct[10]",
-                              gras_datadesc_by_name("hetestruct"), 10);
+      gras_datadesc_array_fixed("hetestruct[10]",
+                                gras_datadesc_by_name("hetestruct"), 10);
   my_type = gras_datadesc_ref("hetestruct[10]*", my_type);
   gras_msgtype_declare("hetestruct[10]*", my_type);
 
@@ -664,7 +670,8 @@ static void register_types(void)
                               gras_datadesc_by_name("homostruct"));
   gras_datadesc_struct_close(my_type);
   my_type =
-    gras_datadesc_ref("nestedstruct*", gras_datadesc_by_name("nestedstruct"));
+      gras_datadesc_ref("nestedstruct*",
+                        gras_datadesc_by_name("nestedstruct"));
   gras_msgtype_declare("nestedstruct*", my_type);
 
   my_type = gras_datadesc_struct("chained_list_t");
@@ -677,7 +684,7 @@ static void register_types(void)
   gras_msgtype_declare("chained_list_t*", ref_my_type);
 
   my_type =
-    gras_datadesc_dynar(gras_datadesc_by_name("string"), &free_string);
+      gras_datadesc_dynar(gras_datadesc_by_name("string"), &free_string);
   gras_msgtype_declare("xbt_dynar_of_string", my_type);
 
   my_type = gras_datadesc_by_symbol(s_pbio);
@@ -717,13 +724,14 @@ int main(int argc, char *argv[])
       printf(" --write file: writes the description to the given file\n");
       printf(" --copy: copy the description in memory\n");
       printf
-        (" --regen: write the description to the file of the current architecture\n");
+          (" --regen: write the description to the file of the current architecture\n");
       printf(" --help: displays this message\n");
       exit(0);
     } else if (!strcmp(argv[cpt], "--regen")) {
       direction = WRITE;
       filename =
-        bprintf("datadesc.%s", gras_datadesc_arch_name(gras_arch_selfid()));
+          bprintf("datadesc.%s",
+                  gras_datadesc_arch_name(gras_arch_selfid()));
     } else if (!strcmp(argv[cpt], "--read")) {
       direction = READ;
     } else if (!strcmp(argv[cpt], "--write")) {
@@ -736,11 +744,13 @@ int main(int argc, char *argv[])
   }
 
   if (direction == WRITE) {
-    INFO1("Write to file %s", strrchr(filename,'/')?strrchr(filename,'/')+1:filename);
+    INFO1("Write to file %s",
+          strrchr(filename, '/') ? strrchr(filename, '/') + 1 : filename);
     sock = gras_socket_client_from_file(filename);
   }
   if (direction == READ) {
-    INFO1("Read from file %s", strrchr(filename,'/')?strrchr(filename,'/')+1:filename);
+    INFO1("Read from file %s",
+          strrchr(filename, '/') ? strrchr(filename, '/') + 1 : filename);
     sock = gras_socket_server_from_file(filename);
   }
   if (direction == COPY) {
index 678115b..0c57449 100644 (file)
@@ -16,7 +16,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this test");
 int server(int argc, char *argv[]);
 int client(int argc, char *argv[]);
 
-static int server_cb_hello_handler(gras_msg_cb_ctx_t ctx, void *payload_data)
+static int server_cb_hello_handler(gras_msg_cb_ctx_t ctx,
+                                   void *payload_data)
 {
   INFO0("Got the message");
   return 0;
index 1441932..a69d93f 100644 (file)
@@ -14,7 +14,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Messages specific to this example");
 static int send(int argc, char *argv[])
 {
   INFO0("Sending");
-  MSG_task_put(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_self(), 0);
+  MSG_task_put(MSG_task_create("Blah", 0.0, 0.0, NULL), MSG_host_self(),
+               0);
   MSG_process_sleep(1.);        /* FIXME: if the sender exits before the receiver calls get_sender(), bad thing happens */
   INFO0("Exiting");
   return 0;
index a178f22..69c5821 100644 (file)
@@ -40,8 +40,8 @@ int main(int argc, char **argv)
 
   /* let's launch the simulation! */
 
-  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost, no_cost,
-                   -1.0);
+  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost,
+                   no_cost, -1.0);
   SD_task_schedule(taskA, 2, SD_workstation_get_list(), no_cost,
                    communication_amount1, -1.0);
   SD_task_schedule(taskB, 2, SD_workstation_get_list(), no_cost,
index f9e216a..d8b8fc4 100644 (file)
@@ -42,8 +42,8 @@ int main(int argc, char **argv)
   workstation = SD_workstation_get_list();
 
   /* let's launch the simulation! */
-  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), &no_cost, &no_cost,
-                   -1.0);
+  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), &no_cost,
+                   &no_cost, -1.0);
   SD_task_schedule(taskA, 1, &workstation[0], &no_cost,
                    &communication_amount1, -1.0);
   SD_task_schedule(taskB, 1, &workstation[1], &no_cost,
index 2f9d230..0f9f6fc 100644 (file)
@@ -41,8 +41,8 @@ int main(int argc, char **argv)
   workstation = SD_workstation_get_list();
 
   /* let's launch the simulation! */
-  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), &no_cost, &no_cost,
-                   -1.0);
+  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), &no_cost,
+                   &no_cost, -1.0);
   SD_task_schedule(taskA, 1, &workstation[0], &no_cost,
                    &communication_amount1, -1.0);
   SD_task_schedule(taskB, 1, &workstation[1], &no_cost,
index 2fa069a..e0437d6 100644 (file)
@@ -34,8 +34,8 @@ int main(int argc, char **argv)
   taskFin = SD_task_create("Task Fin", NULL, 1.0);
 
   /* let's launch the simulation! */
-  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost, no_cost,
-                   -1.0);
+  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost,
+                   no_cost, -1.0);
   SD_task_schedule(taskA, 2, SD_workstation_get_list(), no_cost, no_cost,
                    -1.0);
   SD_task_schedule(taskFin, 1, SD_workstation_get_list(), no_cost, no_cost,
index 7009d3d..a55cf24 100644 (file)
@@ -38,8 +38,8 @@ int main(int argc, char **argv)
 
 
   /* let's launch the simulation! */
-  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost, no_cost,
-                   -1.0);
+  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost,
+                   no_cost, -1.0);
   SD_task_schedule(taskA, 2, SD_workstation_get_list(), no_cost, amount,
                    -1.0);
   SD_task_schedule(taskFin, 1, SD_workstation_get_list(), no_cost, no_cost,
index 48a988b..2b3a6c9 100644 (file)
@@ -38,8 +38,8 @@ int main(int argc, char **argv)
   taskB = SD_task_create("Task B", NULL, 1.0);
 
   /* let's launch the simulation! */
-  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost, no_cost,
-                   -1.0);
+  SD_task_schedule(taskInit, 1, SD_workstation_get_list(), no_cost,
+                   no_cost, -1.0);
   SD_task_schedule(taskA, 2, SD_workstation_get_list(), no_cost, amount,
                    -1.0);
   SD_task_schedule(taskB, 1, SD_workstation_get_list(), comput, no_cost,
index d5c3078..e2516dd 100644 (file)
@@ -25,10 +25,10 @@ int main(int argc, char **argv)
   taskA = SD_task_create("Task A", NULL, 1.0);
   taskB = SD_task_create("Task B", NULL, 1.0);
 
-  SD_task_schedule(taskA, 1, SD_workstation_get_list(), comp_cost, comm_cost,
-                   -1.0);
-  SD_task_schedule(taskB, 1, SD_workstation_get_list(), comp_cost, comm_cost,
-                   -1.0);
+  SD_task_schedule(taskA, 1, SD_workstation_get_list(), comp_cost,
+                   comm_cost, -1.0);
+  SD_task_schedule(taskB, 1, SD_workstation_get_list(), comp_cost,
+                   comm_cost, -1.0);
 
   SD_simulate(-1.0);
 
index 6b99c39..7a3b152 100644 (file)
@@ -1,5 +1,5 @@
 /* Latency tests                                                            */
-  
+
 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
  * All rights reserved.                                                     */
 
index a29803d..e5e1e4a 100644 (file)
@@ -1,5 +1,5 @@
 /* Latency tests                                                            */
-  
+
 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
  * All rights reserved.                                                     */
 
index cd85602..ff385fb 100644 (file)
@@ -1,5 +1,5 @@
 /* Latency tests                                                            */
-  
+
 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
  * All rights reserved.                                                     */
 
index c506d79..c52cc14 100644 (file)
@@ -1,5 +1,5 @@
 /* Latency tests                                                            */
-  
+
 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
  * All rights reserved.                                                     */
 
index 1fbd3da..c269ba7 100644 (file)
@@ -68,8 +68,8 @@ static SD_task_t create_root_with_costs()
   SD_task_t root;
 
   root = SD_task_create("Root", NULL, 1.0);
-  SD_task_schedule(root, 2, SD_workstation_get_list(), comp_cost, comm_cost,
-                   -1.0);
+  SD_task_schedule(root, 2, SD_workstation_get_list(), comp_cost,
+                   comm_cost, -1.0);
 
   return root;
 }
index 6455f43..1d9f08c 100644 (file)
@@ -20,7 +20,7 @@ int main(int argc, char **argv)
   const SD_link_t *route;
   const char *name1;
   const char *name2;
-  int route_size,i,j,k;
+  int route_size, i, j, k;
   int list_size;
 
   SD_init(&argc, argv);
@@ -30,60 +30,57 @@ int main(int argc, char **argv)
   printf("Workstation number: %d, link number: %d\n",
          SD_workstation_get_number(), SD_link_get_number());
 
-if(argc == 3)
-{
-       if(!strcmp(argv[2],"ONE_LINK"))
-       {
-         workstations = SD_workstation_get_list();
-         w1 = workstations[0];
-         w2 = workstations[1];
-         name1 = SD_workstation_get_name(w1);
-         name2 = SD_workstation_get_name(w2);
+  if (argc == 3) {
+    if (!strcmp(argv[2], "ONE_LINK")) {
+      workstations = SD_workstation_get_list();
+      w1 = workstations[0];
+      w2 = workstations[1];
+      name1 = SD_workstation_get_name(w1);
+      name2 = SD_workstation_get_name(w2);
 
-         printf("Route between %s and %s\n", name1, name2);
-         route = SD_route_get_list(w1, w2);
-         route_size = SD_route_get_size(w1, w2);
-         printf("Route size %d\n", route_size);
-         for (i = 0; i < route_size; i++) {
-                 printf("   Link %s: latency = %f, bandwidth = %f\n",
-                         SD_link_get_name(route[i]), SD_link_get_current_latency(route[i]),
-                         SD_link_get_current_bandwidth(route[i]));
-         }
-         printf("Route latency = %f, route bandwidth = %f\n",
-                       SD_route_get_current_latency(w1, w2),
-                       SD_route_get_current_bandwidth(w1, w2));
+      printf("Route between %s and %s\n", name1, name2);
+      route = SD_route_get_list(w1, w2);
+      route_size = SD_route_get_size(w1, w2);
+      printf("Route size %d\n", route_size);
+      for (i = 0; i < route_size; i++) {
+        printf("   Link %s: latency = %f, bandwidth = %f\n",
+               SD_link_get_name(route[i]),
+               SD_link_get_current_latency(route[i]),
+               SD_link_get_current_bandwidth(route[i]));
+      }
+      printf("Route latency = %f, route bandwidth = %f\n",
+             SD_route_get_current_latency(w1, w2),
+             SD_route_get_current_bandwidth(w1, w2));
 
-       }
-       if(!strcmp(argv[2],"FULL_LINK"))
-       {
-                       workstations = SD_workstation_get_list();
-                       list_size = SD_workstation_get_number();
-                       for(i = 0; i < list_size; i++)
-                       {
-                               w1 = workstations[i];
-                               name1 = SD_workstation_get_name(w1);
-                               for(j = 0 ; j < list_size; j++)
-                               {
-                                                 w2 = workstations[j];
-                                                 name2 = SD_workstation_get_name(w2);
-                                                 printf("Route between %s and %s\n", name1, name2);
-                                                 route = SD_route_get_list(w1, w2);
-                                                 route_size = SD_route_get_size(w1, w2);
-                                                 printf("\tRoute size %d\n", route_size);
-                                                 for (k = 0; k < route_size; k++) {
-                                                         printf("\tLink %s: latency = %f, bandwidth = %f\n",
-                                                                 SD_link_get_name(route[k]), SD_link_get_current_latency(route[k]),
-                                                                 SD_link_get_current_bandwidth(route[k]));
-                                                 }
-                                                 printf("\tRoute latency = %f, route bandwidth = %f\n",
-                                                               SD_route_get_current_latency(w1, w2),
-                                                               SD_route_get_current_bandwidth(w1, w2));
-                               }
-                       }
+    }
+    if (!strcmp(argv[2], "FULL_LINK")) {
+      workstations = SD_workstation_get_list();
+      list_size = SD_workstation_get_number();
+      for (i = 0; i < list_size; i++) {
+        w1 = workstations[i];
+        name1 = SD_workstation_get_name(w1);
+        for (j = 0; j < list_size; j++) {
+          w2 = workstations[j];
+          name2 = SD_workstation_get_name(w2);
+          printf("Route between %s and %s\n", name1, name2);
+          route = SD_route_get_list(w1, w2);
+          route_size = SD_route_get_size(w1, w2);
+          printf("\tRoute size %d\n", route_size);
+          for (k = 0; k < route_size; k++) {
+            printf("\tLink %s: latency = %f, bandwidth = %f\n",
+                   SD_link_get_name(route[k]),
+                   SD_link_get_current_latency(route[k]),
+                   SD_link_get_current_bandwidth(route[k]));
+          }
+          printf("\tRoute latency = %f, route bandwidth = %f\n",
+                 SD_route_get_current_latency(w1, w2),
+                 SD_route_get_current_bandwidth(w1, w2));
+        }
+      }
 
-       }
+    }
 
-}
+  }
 
   SD_exit();
   return 0;
index 3520683..60f3b5b 100644 (file)
@@ -17,8 +17,8 @@ int main(int argc, char **argv)
   int size;
   xbt_dict_t eltms = xbt_dict_new();
   SD_init(&argc, argv);
-  xbt_dict_cursor_t cursor=NULL;
-   char *key,*data;
+  xbt_dict_cursor_t cursor = NULL;
+  char *key, *data;
 
   /* creation of the environment */
   SD_create_environment(argv[1]);
@@ -26,10 +26,12 @@ int main(int argc, char **argv)
   eltms = global_routing->where_network_elements;
   size = xbt_dict_size(eltms);
 
-  printf("Workstation number: %d, link number: %d, elmts number: %d\n",SD_workstation_get_number(), SD_link_get_number(),size);
+  printf("Workstation number: %d, link number: %d, elmts number: %d\n",
+         SD_workstation_get_number(), SD_link_get_number(), size);
 
-  xbt_dict_foreach(eltms,cursor,key,data) {
-     printf("   - Seen: \"%s\" is type : %d\n",key,(int) global_routing->get_network_element_type(key));
+  xbt_dict_foreach(eltms, cursor, key, data) {
+    printf("   - Seen: \"%s\" is type : %d\n", key,
+           (int) global_routing->get_network_element_type(key));
   }
   //printf("%s is router : %d\n",name1,global_routing->is_router(name1));
   xbt_dict_free(&eltms);
index aab5f27..d51d8f3 100644 (file)
@@ -38,8 +38,8 @@ int main(int argc, char *argv[])
 
   xbt_init(&argc, argv);
 
-  INFO10("This is a very large message:\n0%s1%s2%s3%s4%s5%s6%s7%s8%s9%s", tmp,
-         tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp);
+  INFO10("This is a very large message:\n0%s1%s2%s3%s4%s5%s6%s7%s8%s9%s",
+         tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp);
   INFO1("Done (strlen>%d)", (int) (10 * strlen(tmp)));
   free(tmp);
 
index f606f43..7fb2715 100644 (file)
@@ -70,7 +70,9 @@ int crasher(int argc, char *argv[])
   /* spawn threads */
   for (i = 0; i < crasher_amount; i++) {
     char *name = bprintf("thread %d", i);
-    crashers[i] = xbt_thread_create(name, &crasher_thread, &id[i],0/*not joinable*/);
+    crashers[i] =
+        xbt_thread_create(name, &crasher_thread, &id[i],
+                          0 /*not joinable */ );
     free(name);
   }
 
index 3031f31..5f3451b 100644 (file)
@@ -54,9 +54,8 @@ int main(int argc, char **argv)
   workstations = SD_workstation_get_list();
 
 
-  for(i=0 ; i < SD_workstation_get_number() ; i++)
-  {
-         INFO1("name : %s",SD_workstation_get_name(workstations[i]) );
+  for (i = 0; i < SD_workstation_get_number(); i++) {
+    INFO1("name : %s", SD_workstation_get_name(workstations[i]));
   }
 
   w1 = workstations[0];
@@ -73,15 +72,18 @@ int main(int argc, char **argv)
   taskC = SD_task_create("Task C", NULL, 30.0);
   taskD = SD_task_create("Task D", NULL, 60.0);
 
-  INFO3("Computation time for %f flops on %s: %f", computation_amount1, name1,
-        SD_workstation_get_computation_time(w1, computation_amount1));
-  INFO3("Computation time for %f flops on %s: %f", computation_amount2, name2,
-        SD_workstation_get_computation_time(w2, computation_amount2));
+  INFO3("Computation time for %f flops on %s: %f", computation_amount1,
+        name1, SD_workstation_get_computation_time(w1,
+                                                   computation_amount1));
+  INFO3("Computation time for %f flops on %s: %f", computation_amount2,
+        name2, SD_workstation_get_computation_time(w2,
+                                                   computation_amount2));
 
   INFO2("Route between %s and %s:", name1, name2);
   for (i = 0; i < route_size; i++) {
     INFO3("\tLink %s: latency = %f, bandwidth = %f",
-          SD_link_get_name(route[i]), SD_link_get_current_latency(route[i]),
+          SD_link_get_name(route[i]),
+          SD_link_get_current_latency(route[i]),
           SD_link_get_current_bandwidth(route[i]));
   }
   INFO2("Route latency = %f, route bandwidth = %f",
@@ -104,7 +106,8 @@ int main(int argc, char **argv)
 
   TRY {
     SD_task_dependency_add(NULL, NULL, taskA, taskA);   /* shouldn't work and must raise an exception */
-    xbt_assert0(0, "Hey, I can add a dependency between Task A and Task A!");
+    xbt_assert0(0,
+                "Hey, I can add a dependency between Task A and Task A!");
   }
   CATCH(ex) {
   }
@@ -147,7 +150,7 @@ int main(int argc, char **argv)
     const int workstation_number = 2;
     const SD_workstation_t workstation_list[] = { w1, w2 };
     double computation_amount[] =
-      { computation_amount1, computation_amount2 };
+        { computation_amount1, computation_amount2 };
     double communication_amount[] = {
       0, communication_amount12,
       communication_amount21, 0
@@ -178,7 +181,7 @@ int main(int argc, char **argv)
     xbt_dynar_get_cpy(changed_tasks, 0, &checkD);
     xbt_dynar_get_cpy(changed_tasks, 1, &checkC);
     xbt_dynar_get_cpy(changed_tasks, 2, &checkB);
+
     xbt_assert0(checkD == taskD &&
                 checkC == taskC &&
                 checkB == taskB, "Unexpected simulation results");
index b47fbff..5e8f6ab 100644 (file)
@@ -16,7 +16,8 @@
 #include "xbt/module.h"
 #include <math.h>
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
+                             "Messages specific for surf example");
 
 #define PRINT_VAR(var) DEBUG1(#var " = %g",lmm_variable_getvalue(var));
 #define SHOW_EXPR(expr) DEBUG1(#expr " = %g",expr);
@@ -151,7 +152,7 @@ void test1(method_t method)
     lmm_solve(Sys);
   } else if (method == LAGRANGE_VEGAS) {
     double x = 3 * a / 4 - 3 * b / 8 +
-      sqrt(9 * b * b + 4 * a * a - 4 * a * b) / 8;
+        sqrt(9 * b * b + 4 * a * a - 4 * a * b) / 8;
     /* Computed with mupad and D_f=1.0 */
     double max_deviation = 0.0;
     if (x > a) {
@@ -163,12 +164,14 @@ void test1(method_t method)
 
     lagrange_solve(Sys);
 
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
     max_deviation =
-      MAX(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
     max_deviation =
-      MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
+    max_deviation =
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
+    max_deviation =
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
     if (max_deviation > MAXMIN_PRECISION) {
       WARN1("Max Deviation from optimal solution : %g", max_deviation);
@@ -196,12 +199,14 @@ void test1(method_t method)
       x = a;
     lagrange_solve(Sys);
 
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
     max_deviation =
-      MAX(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
+    max_deviation =
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
+    max_deviation =
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
     max_deviation =
-      MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
+        MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
     if (max_deviation > MAXMIN_PRECISION) {
       WARN1("Max Deviation from optimal solution : %g", max_deviation);
@@ -416,7 +421,7 @@ void test3(method_t method)
   for (j = 0; j < 16; j++) {
     tmp_name[i + j] = bprintf("X_%03d", j);
     tmp_var[j] =
-      lmm_variable_new(Sys, (void *) tmp_name[i + j], 1.0, -1.0, 15);
+        lmm_variable_new(Sys, (void *) tmp_name[i + j], 1.0, -1.0, 15);
     lmm_update_variable_weight(Sys, tmp_var[j], 1.0);
   }
 
index 9d5cfed..75c08d3 100644 (file)
@@ -14,7 +14,8 @@
 #include "surf/surf.h"
 
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
+                             "Messages specific for surf example");
 
 const char *string_action(e_surf_action_state_t state);
 const char *string_action(e_surf_action_state_t state)
@@ -58,12 +59,12 @@ void test(char *platform)
 
   /*********************** CPU ***********************************/
   DEBUG1("%p", surf_cpu_model);
-  cpuA = surf_model_resource_by_name(surf_cpu_model,"Cpu A");
-  cpuB = surf_model_resource_by_name(surf_cpu_model,"Cpu B");
+  cpuA = surf_model_resource_by_name(surf_cpu_model, "Cpu A");
+  cpuB = surf_model_resource_by_name(surf_cpu_model, "Cpu B");
 
   /* Let's check that those two processors exist */
-  DEBUG2("%s : %p",surf_resource_name(cpuA), cpuA);
-  DEBUG2("%s : %p",surf_resource_name(cpuB), cpuB);
+  DEBUG2("%s : %p", surf_resource_name(cpuA), cpuA);
+  DEBUG2("%s : %p", surf_resource_name(cpuB), cpuB);
 
   /* Let's do something on it */
   actionA = surf_cpu_model->extension.cpu.execute(cpuA, 1000.0);
@@ -71,9 +72,9 @@ void test(char *platform)
   actionC = surf_cpu_model->extension.cpu.sleep(cpuB, 7.32);
 
   /* Use whatever calling style you want... */
-  stateActionA = surf_cpu_model->action_state_get(actionA);      /* When you know actionA model type */
-  stateActionB = actionB->model_type->action_state_get(actionB); /* If you're unsure about it's model type */
-  stateActionC = surf_cpu_model->action_state_get(actionC);      /* When you know actionA model type */
+  stateActionA = surf_cpu_model->action_state_get(actionA);     /* When you know actionA model type */
+  stateActionB = actionB->model_type->action_state_get(actionB);        /* If you're unsure about it's model type */
+  stateActionC = surf_cpu_model->action_state_get(actionC);     /* When you know actionA model type */
 
   /* And just look at the state of these tasks */
   DEBUG2("actionA : %p (%s)", actionA, string_action(stateActionA));
@@ -82,8 +83,8 @@ void test(char *platform)
 
   /*********************** Network *******************************/
   DEBUG1("%p", surf_network_model);
-  cardA = surf_model_resource_by_name(surf_network_model,"Cpu A");
-  cardB = surf_model_resource_by_name(surf_network_model,"Cpu B");
+  cardA = surf_model_resource_by_name(surf_network_model, "Cpu A");
+  cardB = surf_model_resource_by_name(surf_network_model, "Cpu B");
 
   /* Let's check that those two processors exist */
   DEBUG2("%s : %p", surf_resource_name(cardA), cardA);
@@ -91,8 +92,8 @@ void test(char *platform)
 
   /* Let's do something on it */
   commAB =
-    surf_network_model->extension.network.communicate("Cpu A","Cpu B",
-                                                      150.0, -1.0);
+      surf_network_model->extension.network.communicate("Cpu A", "Cpu B",
+                                                        150.0, -1.0);
 
   surf_solve();                 /* Takes traces into account. Returns 0.0 */
   do {
@@ -112,19 +113,21 @@ void test(char *platform)
     }
     DEBUG0("\t Network actions");
     while ((action =
-            xbt_swag_extract(surf_network_model->states.failed_action_set))) {
+            xbt_swag_extract(surf_network_model->states.
+                             failed_action_set))) {
       DEBUG1("\t * Failed : %p", action);
       action->model_type->action_unref(action);
     }
     while ((action =
-            xbt_swag_extract(surf_network_model->states.done_action_set))) {
+            xbt_swag_extract(surf_network_model->states.
+                             done_action_set))) {
       DEBUG1("\t * Done : %p", action);
       action->model_type->action_unref(action);
     }
 
   } while ((xbt_swag_size(surf_network_model->states.running_action_set) ||
             xbt_swag_size(surf_cpu_model->states.running_action_set)) &&
-            surf_solve() >= 0.0);
+           surf_solve() >= 0.0);
 
   DEBUG0("Simulation Terminated");
 }
index 8be876d..eda5f21 100644 (file)
@@ -13,7 +13,8 @@
 #include "surf/surf.h"
 
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
+                             "Messages specific for surf example");
 
 const char *string_action(e_surf_action_state_t state);
 const char *string_action(e_surf_action_state_t state)
@@ -48,16 +49,21 @@ void test(char *platform)
   int running;
 
   int workstation_id =
-    find_model_description(surf_workstation_model_description, "CLM03");
+      find_model_description(surf_workstation_model_description, "CLM03");
 
-  surf_workstation_model_description[workstation_id].model_init_preparse(platform);
+  surf_workstation_model_description[workstation_id].
+      model_init_preparse(platform);
   parse_platform_file(platform);
-  if (surf_workstation_model_description[workstation_id].model_init_postparse)
-    surf_workstation_model_description[workstation_id].model_init_postparse();
+  if (surf_workstation_model_description[workstation_id].
+      model_init_postparse)
+    surf_workstation_model_description[workstation_id].
+        model_init_postparse();
 
   /*********************** WORKSTATION ***********************************/
-  workstationA = surf_model_resource_by_name(surf_workstation_model,"Cpu A");
-  workstationB = surf_model_resource_by_name(surf_workstation_model,"Cpu B");
+  workstationA =
+      surf_model_resource_by_name(surf_workstation_model, "Cpu A");
+  workstationB =
+      surf_model_resource_by_name(surf_workstation_model, "Cpu B");
 
   /* Let's check that those two processors exist */
   DEBUG2("%s : %p", surf_resource_name(workstationA), workstationA);
@@ -65,16 +71,18 @@ void test(char *platform)
 
   /* Let's do something on it */
   actionA =
-    surf_workstation_model->extension.workstation.execute(workstationA, 1000.0);
+      surf_workstation_model->extension.workstation.execute(workstationA,
+                                                            1000.0);
   actionB =
-    surf_workstation_model->extension.workstation.execute(workstationB, 1000.0);
+      surf_workstation_model->extension.workstation.execute(workstationB,
+                                                            1000.0);
   actionC =
-    surf_workstation_model->extension.workstation.sleep(workstationB, 7.32);
+      surf_workstation_model->extension.workstation.sleep(workstationB,
+                                                          7.32);
 
   commAB =
-    surf_workstation_model->extension.workstation.communicate(workstationA,
-                                                          workstationB, 150.0,
-                                                          -1.0);
+      surf_workstation_model->extension.workstation.
+      communicate(workstationA, workstationB, 150.0, -1.0);
 
   surf_solve();                 /* Takes traces into account. Returns 0.0 */
   do {
@@ -88,13 +96,11 @@ void test(char *platform)
 
     xbt_dynar_foreach(model_list, iter, model) {
       DEBUG1("\t %s actions", model->name);
-      while ((action =
-              xbt_swag_extract(model->states.failed_action_set))) {
+      while ((action = xbt_swag_extract(model->states.failed_action_set))) {
         DEBUG1("\t * Failed : %p", action);
         model->action_unref(action);
       }
-      while ((action =
-              xbt_swag_extract(model->states.done_action_set))) {
+      while ((action = xbt_swag_extract(model->states.done_action_set))) {
         DEBUG1("\t * Done : %p", action);
         model->action_unref(action);
       }
index 53d3e29..ea7b09b 100644 (file)
@@ -16,7 +16,8 @@
 #include "surf/surf.h"
 
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
+                             "Messages specific for surf example");
 
 void test(void);
 void test(void)
index a95b61a..a8f82b8 100644 (file)
@@ -55,13 +55,15 @@ void test(char *graph_file)
   xbt_dynar_t edges = NULL;
   xbt_dynar_t nodes = NULL;
 
-  xbt_graph_t graph = xbt_graph_read(graph_file, &node_label_and_data, NULL);
+  xbt_graph_t graph =
+      xbt_graph_read(graph_file, &node_label_and_data, NULL);
 
   n = xbt_dynar_length(xbt_graph_get_nodes(graph));
 
   if (test_export_xml) {
     INFO0("---- Testing XML export. Exporting to testgraph.xml ----");
-    xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL, NULL);
+    xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL,
+                              NULL);
   }
   if (test_export_dot) {
     INFO0("---- Testing GraphViz export. Exporting to testgraph.dot ----");
index 0c548ef..417f987 100644 (file)
@@ -29,7 +29,7 @@ int compare_double(const void *a, const void *b);
 
 void test_heap_validity(int size);
 void test_heap_mean_operation(int size);
-void test_reset_heap(xbt_heap_t *heap, int size);
+void test_reset_heap(xbt_heap_t * heap, int size);
 
 
 int compare_double(const void *a, const void *b)
@@ -104,7 +104,7 @@ void test_heap_mean_operation(int size)
   xbt_heap_free(heap);
 }
 
-void test_reset_heap(xbt_heap_t *heap, int size)
+void test_reset_heap(xbt_heap_t * heap, int size)
 {
   int i;
   xbt_heap_free(*heap);
index 64a3cd1..707cf02 100644 (file)
@@ -14,7 +14,8 @@
 
 
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top, "Logging specific to this test");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top,
+                                "Logging specific to this test");
 XBT_LOG_NEW_CATEGORY(top, "Useless test channel");
 
 #ifdef __BORLANDC__
index 47dd65a..66c2596 100644 (file)
@@ -58,7 +58,8 @@ static s_process_t process;
 
 static void parse_process_init(void)
 {
-  xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL);
+  xbt_dict_set(process_function_set, A_surfxml_process_function, NULL,
+               NULL);
   xbt_dict_set(machine_set, A_surfxml_process_host, NULL, NULL);
   process.argc = 1;
   process.argv = xbt_new(char *, 1);
@@ -70,7 +71,8 @@ static void parse_process_init(void)
 static void parse_argument(void)
 {
   process.argc++;
-  process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
+  process.argv =
+      xbt_realloc(process.argv, (process.argc) * sizeof(char *));
   process.argv[(process.argc) - 1] = xbt_strdup(A_surfxml_argument_value);
 }
 
@@ -103,8 +105,8 @@ int main(int argc, char *argv[])
   for (i = 1; i < argc; i++) {
     int need_removal = 0;
     if (!strncmp("--extra-process=", argv[i], strlen("--extra-process="))) {
-      xbt_dict_set(process_function_set, argv[i] + strlen("--extra-process="),
-                   NULL, NULL);
+      xbt_dict_set(process_function_set,
+                   argv[i] + strlen("--extra-process="), NULL, NULL);
       need_removal = 1;
     }
 
@@ -130,7 +132,8 @@ int main(int argc, char *argv[])
   DEBUG2("%p %p", parse_process_init, &parse_process_init);
   surfxml_add_callback(STag_surfxml_process_cb_list, &parse_process_init);
   surfxml_add_callback(ETag_surfxml_argument_cb_list, &parse_argument);
-  surfxml_add_callback(ETag_surfxml_process_cb_list, &parse_process_finalize);
+  surfxml_add_callback(ETag_surfxml_process_cb_list,
+                       &parse_process_finalize);
 
   for (i = 2; i < argc; i++) {
     deployment_file = argv[i];
index 2fee052..69d342d 100644 (file)
@@ -65,14 +65,14 @@ char *warning = NULL;
 /**********************************************/
 
 const char *SIM_PREEMBULE =
-  "/* specific to Borland Compiler */\n"
-  "#ifdef __BORLANDC__\n"
-  "#pragma hdrstop\n"
-  "#endif\n\n"
-  "#include <stdlib.h>\n"
-  "#include <stdio.h>\n"
-  "#include \"msg/msg.h\"\n"
-  "#include <gras.h>\n" "\n" "char *gras_log=NULL;\n";
+    "/* specific to Borland Compiler */\n"
+    "#ifdef __BORLANDC__\n"
+    "#pragma hdrstop\n"
+    "#endif\n\n"
+    "#include <stdlib.h>\n"
+    "#include <stdio.h>\n"
+    "#include \"msg/msg.h\"\n"
+    "#include <gras.h>\n" "\n" "char *gras_log=NULL;\n";
 
 
 #define SIM_LAUNCH_FUNC  \
@@ -95,15 +95,15 @@ const char *SIM_PREEMBULE =
 "}\n"
 
 const char *SIM_MAIN_POSTEMBULE = "\n"
-  "\n"
-  "  gras_launch_application(argv[2]);\n"
-  "\n"
-  "  /*  Run the simulation */\n"
-  "  gras_main();\n"
-  "\n"
-  "  /* cleanup the place */\n"
-  "  gras_clean();\n"
-  "  if (gras_log)\n" "    free(gras_log);\n" "  return 0;\n" "}\n";
+    "\n"
+    "  gras_launch_application(argv[2]);\n"
+    "\n"
+    "  /*  Run the simulation */\n"
+    "  gras_main();\n"
+    "\n"
+    "  /* cleanup the place */\n"
+    "  gras_clean();\n"
+    "  if (gras_log)\n" "    free(gras_log);\n" "  return 0;\n" "}\n";
 
 
 
@@ -158,7 +158,8 @@ void generate_sim(char *project)
           "  gras_create_environment(argv[1]);\n"
           "\n" "  /*  Application deployment */\n");
   xbt_dict_foreach(process_function_set, cursor, key, data) {
-    fprintf(FICOUT, "  gras_function_register(\"%s\", launch_%s);\n", key, key);
+    fprintf(FICOUT, "  gras_function_register(\"%s\", launch_%s);\n", key,
+            key);
   }
   fprintf(FICOUT, "%s", SIM_MAIN_POSTEMBULE);
   fclose(FICOUT);
@@ -178,7 +179,8 @@ void generate_rl(char *project)
 
   xbt_dict_foreach(process_function_set, cursor, key, data) {
     filename =
-      xbt_new(char, strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
+        xbt_new(char,
+                strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
 
     sprintf(filename, RL_SOURCENAME, project, key);
 
@@ -290,7 +292,8 @@ void generate_makefile_local(char *project, char *deployment)
   char *filename = NULL;
   FILE *FICOUT = NULL;
 
-  filename = xbt_new(char, strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
+  filename =
+      xbt_new(char, strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
   sprintf(filename, MAKEFILE_FILENAME_LOCAL, project);
 
   FICOUT = fopen(filename, "w");
@@ -325,7 +328,8 @@ void generate_makefile_local(char *project, char *deployment)
   }
   fprintf(FICOUT, "\n");
 
-  fprintf(FICOUT, "OBJ_FILES = $(patsubst %%.c,%%.o,$(PRECIOUS_C_FILES))\n");
+  fprintf(FICOUT,
+          "OBJ_FILES = $(patsubst %%.c,%%.o,$(PRECIOUS_C_FILES))\n");
 
   fprintf(FICOUT, "BIN_FILES = ");
 
@@ -352,13 +356,13 @@ void generate_makefile_local(char *project, char *deployment)
           deployment);
 
   fprintf(FICOUT, "\n## Generate the binaries\n");
-  fprintf(FICOUT, SIM_BINARYNAME ": " SIM_OBJNAME " $(OBJ_FILES)\n", project,
-          project);
+  fprintf(FICOUT, SIM_BINARYNAME ": " SIM_OBJNAME " $(OBJ_FILES)\n",
+          project, project);
   fprintf(FICOUT,
           "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_SIM) $(LIBS) $(LDADD) -o $@ \n");
   xbt_dict_foreach(process_function_set, cursor, key, data) {
-    fprintf(FICOUT, RL_BINARYNAME " : " RL_OBJNAME " $(OBJ_FILES)\n", project,
-            key, project, key);
+    fprintf(FICOUT, RL_BINARYNAME " : " RL_OBJNAME " $(OBJ_FILES)\n",
+            project, key, project, key);
     fprintf(FICOUT,
             "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ \n");
   }
index e8c8d87..585ba12 100644 (file)
@@ -82,7 +82,8 @@ borland_project_write_tabs(borland_project_t project, unsigned int count);
  * @param name The name of the node.
  */
 static void
-borland_project_begin_xml_node(borland_project_t project, const char *name);
+borland_project_begin_xml_node(borland_project_t project,
+                               const char *name);
 
 
 /*
@@ -100,8 +101,8 @@ borland_project_end_xml_node(borland_project_t project, const char *name);
  * @param value The value of the element  
  */
 static void
-borland_project_write_xml_element(borland_project_t project, const char *name,
-                                  const char *value);
+borland_project_write_xml_element(borland_project_t project,
+                                  const char *name, const char *value);
 
 /*
  * Write a FILE xml element in the borland project file.
@@ -184,7 +185,8 @@ find_file_path(const char *root_dir, const char *file_name, char *path);
 
 /*
  * generate a Microsoft Visual project file*/
-static void generate_dsp_project(dsp_t project, int is_rl, const char *name);
+static void generate_dsp_project(dsp_t project, int is_rl,
+                                 const char *name);
 
 static void
 generate_borland_project(borland_project_t project, int is_rl,
@@ -218,16 +220,16 @@ generate_borland_project(borland_project_t project, int is_rl,
 
   /* construct and write the borland project binary path */
   binary_path =
-    xbt_new0(char, strlen(project->name) + strlen(project->bin_dir) + 6);
+      xbt_new0(char, strlen(project->name) + strlen(project->bin_dir) + 6);
   sprintf(binary_path, "%s\\%s.exe", project->bin_dir, project->name);
   borland_project_write_xml_element(project, "PROJECT", binary_path);
   xbt_free(binary_path);
 
   /* construct an write the object files to generate by the compiler */
   obj_path =
-    xbt_new0(char,
-             strlen(project->name) + strlen(name) +
-             (2 * strlen(project->obj_dir)) + 11);
+      xbt_new0(char,
+               strlen(project->name) + strlen(name) +
+               (2 * strlen(project->obj_dir)) + 11);
   sprintf(binary_path, "%s\\%s.obj\n%s\\%s.obj", project->obj_dir,
           project->name, project->obj_dir, name);
   borland_project_write_xml_element(project, "OBJFILES", obj_path);
@@ -256,15 +258,15 @@ generate_borland_project(borland_project_t project, int is_rl,
 
   if (is_rl) {
     lib_files =
-      xbt_new0(char,
-               (2 * (strlen(project->lib_dir) + 1)) + strlen("libgras.lib") +
-               2);
+        xbt_new0(char,
+                 (2 * (strlen(project->lib_dir) + 1)) +
+                 strlen("libgras.lib") + 2);
     sprintf(lib_files, "%s\\libgras.lib", project->lib_dir);
   } else {
     lib_files =
-      xbt_new0(char,
-               (2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") +
-               2);
+        xbt_new0(char,
+                 (2 * (strlen(project->lib_dir) + 1)) +
+                 strlen("simgrid.lib") + 2);
     sprintf(lib_files, "%s\\simgrid.lib", project->lib_dir);
   }
 
@@ -331,7 +333,7 @@ generate_borland_project(borland_project_t project, int is_rl,
   }
 
   include_path =
-    xbt_new0(char, strlen("$(BCB)\\include") + strlen(__gras_path) + 2);
+      xbt_new0(char, strlen("$(BCB)\\include") + strlen(__gras_path) + 2);
   sprintf(include_path, "$(BCB)\\include;%s", __gras_path);
 
   borland_project_write_xml_element(project, "INCLUDEPATH", include_path);
@@ -454,20 +456,21 @@ generate_borland_project(borland_project_t project, int is_rl,
   /* construct and write the list of file elements */
 
   /* add the bpf file to the list */
-  borland_project_write_file_element(project, main_source, "", project->name,
-                                     "BPF", "", "");
+  borland_project_write_file_element(project, main_source, "",
+                                     project->name, "BPF", "", "");
   xbt_free(main_source);
 
   /* FIXME : check the source file directory */
   /* add the generated source file to the list */
 
   file_name =
-    xbt_new0(char, strlen(project->src_dir) + strlen(project->name) + 5);
+      xbt_new0(char, strlen(project->src_dir) + strlen(project->name) + 5);
   sprintf(file_name, "%s\\_%s.c", project->src_dir, project->name);
   borland_project_write_file_element(project, file_name, "", project->name,
                                      "CCompiler", "", "");
 
-  memset(file_name, 0, strlen(project->src_dir) + strlen(project->name) + 4);
+  memset(file_name, 0,
+         strlen(project->src_dir) + strlen(project->name) + 4);
   sprintf(file_name, "%s\\%s.c", project->src_dir, name);
   borland_project_write_file_element(project, file_name, "", name,
                                      "CCompiler", "", "");
@@ -479,16 +482,18 @@ generate_borland_project(borland_project_t project, int is_rl,
 
   if (is_rl) {
     file_name =
-      xbt_new0(char, strlen(project->lib_dir) + strlen("libgras.lib") + 2);
+        xbt_new0(char,
+                 strlen(project->lib_dir) + strlen("libgras.lib") + 2);
     sprintf(file_name, "%s\\libgras.lib", project->lib_dir);
-    borland_project_write_file_element(project, file_name, "", "libgras.lib",
-                                       "LibTool", "", "");
+    borland_project_write_file_element(project, file_name, "",
+                                       "libgras.lib", "LibTool", "", "");
   } else {
     file_name =
-      xbt_new0(char, strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
+        xbt_new0(char,
+                 strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
     sprintf(file_name, "%s\\simgrid.lib", project->lib_dir);
-    borland_project_write_file_element(project, file_name, "", "simgrid.lib",
-                                       "LibTool", "", "");
+    borland_project_write_file_element(project, file_name, "",
+                                       "simgrid.lib", "LibTool", "", "");
   }
 
 
@@ -519,7 +524,8 @@ generate_borland_project(borland_project_t project, int is_rl,
   borland_project_close(project);
 }
 
-void borland_project_write_tabs(borland_project_t project, unsigned int count)
+void borland_project_write_tabs(borland_project_t project,
+                                unsigned int count)
 {
   unsigned int pos;
 
@@ -538,7 +544,8 @@ borland_project_begin_xml_node(borland_project_t project, const char *name)
   level++;
 }
 
-void borland_project_end_xml_node(borland_project_t project, const char *name)
+void borland_project_end_xml_node(borland_project_t project,
+                                  const char *name)
 {
   level--;
 
@@ -550,8 +557,8 @@ void borland_project_end_xml_node(borland_project_t project, const char *name)
 
 
 void
-borland_project_write_xml_element(borland_project_t project, const char *name,
-                                  const char *value)
+borland_project_write_xml_element(borland_project_t project,
+                                  const char *name, const char *value)
 {
   borland_project_write_tabs(project, level);
   fprintf(project->stream, "<%s value=\"%s\"/>\n", name, value);
@@ -607,21 +614,21 @@ void borland_project_write_ide_options(borland_project_t project)
 {
 
   const char *ide_options =
-    "[Version Info]\nIncludeVerInfo=0\nAutoIncBuild=0\nMajorVer=1\nMinorVer=0\nRelease=0\nBuild=0\nDebug=0\nPreRelease=0\nSpecial=0\nPrivate=0\nDLL=0\nLocale=1036\nCodePage=1252\n\n"
-    "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n"
-    "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n"
-    "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n"
-    "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n"
-    "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n"
-    "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n"
-    "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n"
-    "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n"
-    "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n"
-    "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n"
-    "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n"
-    "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n"
-    "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n"
-    "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n";
+      "[Version Info]\nIncludeVerInfo=0\nAutoIncBuild=0\nMajorVer=1\nMinorVer=0\nRelease=0\nBuild=0\nDebug=0\nPreRelease=0\nSpecial=0\nPrivate=0\nDLL=0\nLocale=1036\nCodePage=1252\n\n"
+      "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n"
+      "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n"
+      "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n"
+      "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n"
+      "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n"
+      "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n"
+      "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n"
+      "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n"
+      "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n"
+      "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n"
+      "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n"
+      "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n"
+      "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n"
+      "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n";
 
   fprintf(project->stream, ide_options);
 }
@@ -658,11 +665,11 @@ void generate_borland_simulation_project(const char *name)
   strcpy(borland_project.src_dir, buffer);
 
   borland_project.name =
-    xbt_new0(char, strlen(name) + strlen("simulator") + 2);
+      xbt_new0(char, strlen(name) + strlen("simulator") + 2);
   sprintf(borland_project.name, "%s_simulator", name);
 
   borland_project.bin_dir =
-    xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1);
+      xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1);
   sprintf(borland_project.bin_dir, "%s\\bin", buffer);
 
   hDir = FindFirstFile(borland_project.bin_dir, &wfd);
@@ -671,7 +678,7 @@ void generate_borland_simulation_project(const char *name)
     CreateDirectory(borland_project.bin_dir, NULL);
 
   borland_project.obj_dir =
-    xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1);
+      xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1);
   sprintf(borland_project.obj_dir, "%s\\obj", buffer);
 
   hDir = FindFirstFile(borland_project.obj_dir, &wfd);
@@ -705,7 +712,8 @@ void generate_borland_real_life_project(const char *name)
 
   borland_project.lib_dir = xbt_new0(char, MAX_PATH);
 
-  GetEnvironmentVariable("LIB_GRAS_PATH", borland_project.lib_dir, MAX_PATH);
+  GetEnvironmentVariable("LIB_GRAS_PATH", borland_project.lib_dir,
+                         MAX_PATH);
 
   GetCurrentDirectory(MAX_PATH, buffer);
 
@@ -714,7 +722,7 @@ void generate_borland_real_life_project(const char *name)
   strcpy(borland_project.src_dir, buffer);
 
   borland_project.bin_dir =
-    xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1);
+      xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1);
   sprintf(borland_project.bin_dir, "%s\\bin", buffer);
 
   hDir = FindFirstFile(borland_project.bin_dir, &wfd);
@@ -723,7 +731,7 @@ void generate_borland_real_life_project(const char *name)
     CreateDirectory(borland_project.bin_dir, NULL);
 
   borland_project.obj_dir =
-    xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1);
+      xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1);
   sprintf(borland_project.obj_dir, "%s\\obj", buffer);
 
   hDir = FindFirstFile(borland_project.obj_dir, &wfd);
@@ -923,7 +931,8 @@ void generate_dsp_project(dsp_t project, int is_rl, const char *name)
   fprintf(project->stream,
           "!MESSAGE use the Export Makefile command and run\n");
   fprintf(project->stream, "!MESSAGE\n");
-  fprintf(project->stream, "!MESSAGE NMAKE /f \"%s.mak\".\n", project->name);
+  fprintf(project->stream, "!MESSAGE NMAKE /f \"%s.mak\".\n",
+          project->name);
   fprintf(project->stream, "!MESSAGE\n");
   fprintf(project->stream,
           "!MESSAGE You can specify a configuration when running NMAKE\n");
@@ -1028,7 +1037,8 @@ void generate_dsp_project(dsp_t project, int is_rl, const char *name)
   fprintf(project->stream, "!ENDIF\n\n");
 
   fprintf(project->stream, "# Begin Target\n\n");
-  fprintf(project->stream, "# Name \"%s - Win32 Release\"\n", project->name);
+  fprintf(project->stream, "# Name \"%s - Win32 Release\"\n",
+          project->name);
   fprintf(project->stream, "# Name \"%s - Win32 Debug\"\n", project->name);
   fprintf(project->stream, "# Begin Group \"Source Files\"\n\n");
   fprintf(project->stream,
index 2c92bb7..1b98444 100644 (file)
@@ -40,8 +40,8 @@ static void armageddon_sighandler(int signum)
 
 static void wait_it(rctx_t rctx)
 {
-  VERB2("Join thread %p which were running background cmd <%s>", rctx->runner,
-        rctx->filepos);
+  VERB2("Join thread %p which were running background cmd <%s>",
+        rctx->runner, rctx->filepos);
   xbt_os_thread_join(rctx->runner, NULL);
 }
 
@@ -135,7 +135,8 @@ void rctx_armageddon(rctx_t initiator, int exitcode)
     xbt_os_mutex_release(armageddon_mutex);
     return;
   }
-  DEBUG1("Armageddon request by <%s> got the lock. Let's go amok", filepos);
+  DEBUG1("Armageddon request by <%s> got the lock. Let's go amok",
+         filepos);
   armageddon_initiator = initiator;
   xbt_os_mutex_release(armageddon_mutex);
 
@@ -249,9 +250,9 @@ void rctx_pushline(const char *filepos, char kind, char *line)
     if (rctx->cmd) {
       if (!rctx->is_empty) {
         ERROR2
-          ("[%s] More than one command in this chunk of lines (previous: %s).\n"
-           " Cannot guess which input/output belongs to which command.",
-           filepos, rctx->cmd);
+            ("[%s] More than one command in this chunk of lines (previous: %s).\n"
+             " Cannot guess which input/output belongs to which command.",
+             filepos, rctx->cmd);
         ERROR1("Test suite `%s': NOK (syntax error)", testsuite_name);
         rctx_armageddon(rctx, 1);
         return;
@@ -349,8 +350,8 @@ static void *thread_writer(void *r)
     int got;
     DEBUG1("Still %d chars to write", rctx->input->used - posw);
     got =
-      write(rctx->child_to, rctx->input->data + posw,
-            rctx->input->used - posw);
+        write(rctx->child_to, rctx->input->data + posw,
+              rctx->input->used - posw);
     if (got > 0)
       posw += got;
     if (got < 0) {
@@ -401,8 +402,10 @@ static void *thread_reader(void *r)
   /* let this thread wait for the child so that the main thread can detect the timeout without blocking on the wait */
   got_pid = waitpid(rctx->pid, &rctx->status, 0);
   if (got_pid != rctx->pid) {
-    perror(bprintf("(%s) Cannot wait for the child %s (got pid %d where pid %d were expected;status=%d)",
-                  xbt_thread_self_name(), rctx->cmd, (int)got_pid, (int)rctx->pid,rctx->status));
+    perror(bprintf
+           ("(%s) Cannot wait for the child %s (got pid %d where pid %d were expected;status=%d)",
+            xbt_thread_self_name(), rctx->cmd, (int) got_pid,
+            (int) rctx->pid, rctx->status));
     ERROR1("Test suite `%s': NOK (system error)", testsuite_name);
     rctx_armageddon(rctx, 4);
     return NULL;
@@ -540,9 +543,9 @@ void rctx_start(void)
 
     rctx->reader_done = 0;
     rctx->reader =
-      xbt_os_thread_create("reader", thread_reader, (void *) rctx);
+        xbt_os_thread_create("reader", thread_reader, (void *) rctx);
     rctx->writer =
-      xbt_os_thread_create("writer", thread_writer, (void *) rctx);
+        xbt_os_thread_create("writer", thread_writer, (void *) rctx);
 
   } else {                      /* child */
     xbt_os_mutex_release(armageddon_mutex);
@@ -577,7 +580,8 @@ void rctx_start(void)
     DEBUG2("Launch a thread to wait for %s %d", old->cmd, old->pid);
     runner = xbt_os_thread_create(old->cmd, rctx_wait, (void *) old);
     old->runner = runner;
-    VERB3("Launched thread %p to wait for %s %d", runner, old->cmd, old->pid);
+    VERB3("Launched thread %p to wait for %s %d", runner, old->cmd,
+          old->pid);
     xbt_dynar_push(bg_jobs, &old);
     xbt_os_mutex_release(armageddon_mutex);
   }
@@ -634,7 +638,8 @@ void *rctx_wait(void *r)
 
   /* Check for broken pipe */
   if (rctx->brokenpipe)
-    VERB0("Warning: Child did not consume all its input (I got broken pipe)");
+    VERB0
+        ("Warning: Child did not consume all its input (I got broken pipe)");
 
   /* Check for timeouts */
   if (rctx->timeout) {
@@ -682,9 +687,10 @@ void *rctx_wait(void *r)
     if (WIFEXITED(rctx->status)
         && WEXITSTATUS(rctx->status) != rctx->expected_return) {
       if (rctx->expected_return)
-        ERROR4("Test suite `%s': NOK (<%s> returned code %d instead of %d)",
-               testsuite_name, rctx->filepos,
-               WEXITSTATUS(rctx->status), rctx->expected_return);
+        ERROR4
+            ("Test suite `%s': NOK (<%s> returned code %d instead of %d)",
+             testsuite_name, rctx->filepos, WEXITSTATUS(rctx->status),
+             rctx->expected_return);
       else
         ERROR3("Test suite `%s': NOK (<%s> returned code %d)",
                testsuite_name, rctx->filepos, WEXITSTATUS(rctx->status));
@@ -721,11 +727,12 @@ void *rctx_wait(void *r)
     INFO2("Output of <%s> so far: \n||%s", rctx->filepos, out);
     free(out);
   } else if (rctx->output == e_output_check
-      && (rctx->output_got->used != rctx->output_wanted->used
-          || strcmp(rctx->output_got->data, rctx->output_wanted->data))) {
+             && (rctx->output_got->used != rctx->output_wanted->used
+                 || strcmp(rctx->output_got->data,
+                           rctx->output_wanted->data))) {
     if (XBT_LOG_ISENABLED(tesh, xbt_log_priority_info)) {
       char *diff =
-        xbt_str_diff(rctx->output_wanted->data, rctx->output_got->data);
+          xbt_str_diff(rctx->output_wanted->data, rctx->output_got->data);
       ERROR2("Output of <%s> mismatch:\n%s", rctx->filepos, diff);
       free(diff);
     }
index 203472f..a188bd5 100644 (file)
@@ -89,4 +89,4 @@ void *rctx_wait(void *rctx);
 /* Parse a line comming from the suite file, and add this into the rctx */
 void rctx_pushline(const char *filepos, char kind, char *line);
 
-#endif /* TESH_RUN_CONTEXT_H */
+#endif                          /* TESH_RUN_CONTEXT_H */
index 0a495b8..03f4259 100644 (file)
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
         exit(1);
       }
       INFO1("Change directory to %s", argv[i + 1]);
-      memmove(argv + i, argv + i + 2, (argc - i - 1)*sizeof(char*));
+      memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
       argc -= 2;
       i -= 2;
     }
index 206493b..d393903 100644 (file)
@@ -40,4 +40,4 @@ extern char **environ;
 
 xbt_dict_t env;                 /* the environment, stored as a dict (for variable substitution) */
 
-#endif /* TESH_H */
+#endif                          /* TESH_H */
index 6c78a63..71a19b3 100644 (file)
  *             This file contains all the declarations common declarations and definitions\r
  *             and global variables of tesh.\r
  *\r
- */\r
-\r
+ */ \r
+    \r
 #include <types.h>\r
 #include <ctype.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /* \r
  * the semaphore used by the runner to wait the end of all the units \r
- */\r
-extern xbt_os_sem_t\r
-units_sem;\r
-\r
+ */ \r
+  extern xbt_os_sem_t \r units_sem;
+  \r \r
 /* \r
  * the semaphore used to synchronize the jobs \r
- */\r
-extern xbt_os_sem_t\r
-jobs_sem;\r
-\r
-\r
-/* the list of tesh include directories */\r
-extern xbt_dynar_t\r
-include_dirs;\r
-\r
+ */ \r
+  extern xbt_os_sem_t \r jobs_sem;
+  \r \r \r
+/* the list of tesh include directories */ \r
+  extern xbt_dynar_t \r include_dirs;
+  \r \r
 /*\r
  * if 1, an interruption was requested by a command or a\r
  * unit.\r
- */\r
-extern int\r
-interrupted;\r
-\r
+ */ \r
+  extern int \r interrupted;
+  \r \r
 /*\r
  * if 1, tesh doesn't display the commands launched.\r
- */\r
-extern int\r
-silent_flag;\r
-\r
+ */ \r
+  extern int \r silent_flag;
+  \r \r
 /*\r
  * if 1, tesh simulates the run.\r
- */\r
-extern int\r
-dry_run_flag;\r
-\r
-/* ? */\r
-extern int \r
-just_print_flag;\r
-\r
+ */ \r
+  extern int \r dry_run_flag;
+  \r \r
+/* ? */ \r
+  extern int \r just_print_flag;
+  \r \r
 /* if 1, tesh diplay the current directory.\r
-*/\r
-extern int\r
-print_directory_flag;\r
-\r
+*/ \r
+  extern int \r print_directory_flag;
+  \r \r
 /*\r
  * this directory object represents the root directory.\r
- */\r
-extern directory_t\r
-root_directory;\r
-\r
+ */ \r
+  extern directory_t \r root_directory;
+  \r \r
 /*\r
  * if 1, the summary is detailed.\r
- */\r
-extern int\r
-detail_summary_flag;\r
-\r
+ */ \r
+  extern int \r detail_summary_flag;
+  \r \r
 /* \r
  * the tesh exit code.\r
- */\r
-extern int\r
-exit_code;\r
-\r
-extern int\r
-err_kind;\r
-\r
-extern char*\r
-err_line;\r
-\r
+ */ \r
+  extern int \r exit_code;
+  \r \r extern int \r err_kind;
+  \r \r extern char *\r err_line;
+  \r \r
 /*\r
  * the list of the errors of the run.\r
- */\r
-extern xbt_dynar_t\r
-errors;\r
-\r
+ */ \r
+  extern xbt_dynar_t \r errors;
+  \r \r
 /*\r
  * if 1, it's the tesh root (the parent of all tesh processes).\r
- */\r
-extern int\r
-is_tesh_root;\r
-\r
+ */ \r
+  extern int \r is_tesh_root;
+  \r \r
 /* \r
  * if 1, keep going when some commands can't be founded        \r
- */\r
-extern int \r
-keep_going_flag;\r
-\r
+ */ \r
+  extern int \r keep_going_flag;
+  \r \r
 /* \r
  * if 1, ignore failures of units or commands.                                 \r
- */\r
-extern int\r
-keep_going_unit_flag;\r
-\r
-\r
-\r
+ */ \r
+  extern int \r keep_going_unit_flag;
+  \r \r \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__COM_H */\r
+#endif  /* !__COM_H */\r
index 1d57cb1..c438cd2 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh command type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef __COMMAND_H\r
 #define __COMMAND_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief command_new - create a new fstream.\r
  *\r
  * \param unit                 The unit contained the command.\r
@@ -38,10 +39,10 @@ extern "C" {
  *                                             [EINVAL] if one of the parameters is invalid.\r
  *                                             [ENOMEM] if the system has not enough space to allocate\r
  *                                                              the command.\r
- */\r
-command_t\r
-command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex);\r
-\r
+ */ \r
+  command_t \r
+      command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex);
+  \r \r
 /*! \brief command_free - destroy a command object.\r
  *\r
  * \param ptr                  A pointer to the command object to destroy.\r
@@ -53,10 +54,9 @@ command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex);
  * errors :\r
  *                                             [EINVAL] if the command object pointed to by the ptr parameter is invalid.\r
  *                                     \r
- */\r
-int\r
-command_free(command_t* ptr);\r
-\r
+ */ \r
+  int \r command_free(command_t * ptr);
+  \r \r
 /*! \brief command_run - run a command object.\r
  *\r
  * \param command              The command to run.\r
@@ -72,32 +72,28 @@ command_free(command_t* ptr);
  *                                             The type of running (asynchonus or no) depend of the\r
  *                                             context of the command.\r
  *                                     \r
- */\r
-int\r
-command_run(command_t command);\r
-\r
+ */ \r
+  int \r command_run(command_t command);
+  \r \r
 /*! \brief command_exec - execute a command object.\r
  *\r
  * \param command              The command object to run.\r
  * \param command_line The command line of the process to create.                              \r
- */\r
-void\r
-command_exec(command_t command, const char* command_line);\r
-\r
+ */ \r
+  void \r command_exec(command_t command, const char *command_line);
+  \r\r
 /*! \brief command_wait - wait for the end of a command.\r
  *\r
  * \param command              The command object to wait for.         \r
- */\r
-void\r
-command_wait(command_t command);\r
-\r
+ */ \r
+  void \r command_wait(command_t command);
+  \r \r
 /*! \brief command_interrupt - wait for the end of a command.\r
  *\r
  * \param command              The command object to interrupt.                \r
- */\r
-void\r
-command_interrupt(command_t command);\r
-\r
+ */ \r
+  void \r command_interrupt(command_t command);
+  \r \r
 /*! \brief command_summarize - print the summary of the execution of a command.\r
  *\r
  * \param command              The command object to display the summary.      \r
@@ -106,10 +102,9 @@ command_interrupt(command_t command);
  *                                             The summary of the command is displayed only if the user\r
  *                                             specifies both summary and detail-summary options on the\r
  *                                             tesh command line.\r
- */\r
-void\r
-command_summarize(command_t command);\r
-\r
+ */ \r
+  void \r command_summarize(command_t command);
+  \r \r
 /*! \brief command_handle_failure - handle a failure caused by a command.\r
  *\r
  * \param command              The command to handle the failure.      \r
@@ -121,17 +116,13 @@ command_summarize(command_t command);
  *                                             keep-going on the command line of tesh, only the unit \r
  *                                             containing the failed command is interrupted and all \r
  *                                             other units continue.\r
- */\r
-void\r
-command_handle_failure(command_t command, cs_reason_t reason);\r
-\r
-void command_kill(command_t command);\r
-\r
-void\r
-command_check(command_t command);\r
-\r
+ */ \r
+  void \r command_handle_failure(command_t command, cs_reason_t reason);
+  \r \r void command_kill(command_t command);
+  \r \r void \r command_check(command_t command);
+  \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !_COMMAND_H */\r
+#endif  /* !_COMMAND_H */\r
index a20fb83..494be95 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh context type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef _CONTEXT_H\r
 #define _CONTEXT_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief create_new - create a new context.\r
  *\r
  * \return                     If successful the function returns the newly created\r
@@ -28,10 +29,9 @@ extern "C" {
  *                                     global variable errno with the appropiate error code.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the context.\r
- */\r
-context_t\r
-context_new(void);\r
-\r
+ */ \r
+  context_t \r context_new(void);
+  \r\r
 /*! \brief context_free - destroy a context object.\r
  *\r
  * \param ptr          A pointer to the context object to destroy.\r
@@ -43,10 +43,9 @@ context_new(void);
  * errors :\r
  *                                     [EINVAL] if the context object pointed to by the ptr parameter is invalid.\r
  *                                     \r
- */\r
-int\r
-context_free(context_t* ptr);\r
-\r
+ */ \r
+  int \r context_free(context_t * ptr);
+  \r \r
 /*! \brief context_dup - duplicate a context object.\r
  *\r
  * \param context      The context to duplicate.\r
@@ -59,11 +58,9 @@ context_free(context_t* ptr);
  *                                     [EINVAL] if the parameter is invalid.\r
  *                                     [ENOMEM] if there is not enough memory to allocate the duplicate.\r
  *                                     \r
- */\r
-context_t\r
-context_dup(context_t context);\r
-\r
-\r
+ */ \r
+   context_t \r context_dup(context_t context);
+  \r \r \r
 /*! \brief context_reset - reset a context object.\r
  *\r
  * \param context      The context to reset.\r
@@ -75,23 +72,14 @@ context_dup(context_t context);
  * errors :\r
  *                                     [EINVAL] if the parameter is invalid.\r
  *                                     \r
- */\r
-int\r
-context_reset(context_t context);\r
-\r
-void\r
-context_clear(context_t context);\r
-\r
-void\r
-context_input_write(context_t context, const char* buffer);\r
-\r
-void\r
-context_ouput_read(context_t context, const char* buffer);\r
-\r
-\r
-\r
+ */ \r
+  int \r context_reset(context_t context);
+  \r \r void \r context_clear(context_t context);
+  \r \r void \r context_input_write(context_t context, const char *buffer);
+  \r\rvoid \r context_ouput_read(context_t context, const char *buffer);
+  \r\r\r\r
 #ifdef __cplusplus\r
-extern }\r
-#endif\r
+extern\r
+#endif  /* \r */
 \r
-#endif /* !_CONTEXT_H */\r
+#endif  /* !_CONTEXT_H */\r
index 362448c..0287958 100644 (file)
 /* must be defined first */
 #ifdef _XBT_WIN32
 
-       #define _WIN32_WINNT    0x0400
-       
-       #if (_MSC_VER >= 1400 && !defined(_CRT_SECURE_NO_DEPRECATE))
-               #define _CRT_SECURE_NO_DEPRECATE
-       #endif
-       
-       #include <direct.h> /* for getcwd(), _chdir() */
-       
+#define _WIN32_WINNT   0x0400
+
+#if (_MSC_VER >= 1400 && !defined(_CRT_SECURE_NO_DEPRECATE))
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <direct.h>             /* for getcwd(), _chdir() */
+
 #endif
 
 #include <xerrno.h>
@@ -30,32 +30,32 @@ extern "C" {
 #endif
 
 #ifdef _XBT_WIN32
-       
-       #define strdup                  _strdup
-       #define chdir                   _chdir
-       #define getcwd                  _getcwd
-       
-       #ifndef S_ISDIR
-               #define S_ISDIR(__mode) (((__mode) & S_IFMT) == S_IFDIR)
-       #endif
-
-       #ifndef S_ISREG
-               #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
-       #endif
-       
-       #define INDEFINITE_PID  NULL
-       #define INDEFINITE_FD   NULL
+
+#define strdup                 _strdup
+#define chdir                  _chdir
+#define getcwd                 _getcwd
+
+#ifndef S_ISDIR
+#define        S_ISDIR(__mode) (((__mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
+#endif
+
+#define INDEFINITE_PID NULL
+#define INDEFINITE_FD  NULL
 #else
-       #define INDEFINITE_PID  ((int)-1)
-       #define INDEFINITE_FD   ((int)-1)       
+#define INDEFINITE_PID ((int)-1)
+#define INDEFINITE_FD  ((int)-1)
 #endif
 
 #ifndef PATH_MAX
-       #define PATH_MAX                ((unsigned int)260)
+#define PATH_MAX               ((unsigned int)260)
 #endif
 
 #ifndef VAR_NAME_MAX
-       #define VAR_NAME_MAX    ((unsigned int) 80)
+#define VAR_NAME_MAX   ((unsigned int) 80)
 #endif
 
 #define INDEFINITE                                             ((int)-1)
@@ -66,6 +66,4 @@ extern "C" {
 #ifdef __cplusplus
 }
 #endif
-
-#endif /* !__DEF_H */
-
+#endif                          /* !__DEF_H */
index 75401f5..050ff7b 100644 (file)
@@ -2,35 +2,25 @@
 #define __DIRECTORIES_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-directories_t\r
-directories_new(void);\r
-\r
-int\r
-directories_add(directories_t directories, directory_t directory);\r
-\r
-int\r
-directories_contains(directories_t directories, directory_t directory);\r
-\r
-int\r
-directories_load(directories_t directories, fstreams_t fstreams, xbt_dynar_t suffixes);\r
-\r
-int\r
-directories_free(void** directoriesptr);\r
-\r
-\r
-int\r
-directories_get_size(directories_t directories);\r
-\r
-int\r
-directories_is_empty(directories_t directories);\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r directories_t \r directories_new(void);
+  \r\rint \r
+      directories_add(directories_t directories, directory_t directory);
+  \r \r int \r
+      directories_contains(directories_t directories,
+                           directory_t directory);
+  \r \r int \r directories_load(directories_t directories,
+                             fstreams_t fstreams, xbt_dynar_t suffixes);
+  \r \r int \r directories_free(void **directoriesptr);
+  \r\r\rint \r directories_get_size(directories_t directories);
+  \r \r int \r directories_is_empty(directories_t directories);
+  \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /*!__DIRECTORIES_H */\r
+#endif  /*!__DIRECTORIES_H */\r
index 22c56be..7359f14 100644 (file)
@@ -2,32 +2,22 @@
 #define __DIRECTORY_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-directory_t\r
-directory_new(const char* name);\r
-\r
-int\r
-directory_open(directory_t directory);\r
-\r
-int\r
-directory_close(directory_t directory);\r
-\r
-int\r
-directory_load(directory_t directory, fstreams_t fstreams, xbt_dynar_t suffixes);\r
-\r
-int\r
-directory_free(void** directoryptr);\r
-\r
-const char*\r
-directory_get_name(directory_t directory);\r
-\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r directory_t \r directory_new(const char *name);
+  \r\rint \r directory_open(directory_t directory);
+  \r \r int \r directory_close(directory_t directory);
+  \r \r int \r
+      directory_load(directory_t directory, fstreams_t fstreams,
+                     xbt_dynar_t suffixes);
+  \r \r int \r directory_free(void **directoryptr);
+  \r\rconst char *\r directory_get_name(directory_t directory);
+  \r \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /*!__DIRECTORY_H */\r
+#endif  /*!__DIRECTORY_H */\r
index 4897a65..59a7f1f 100644 (file)
@@ -2,31 +2,20 @@
 #define __EXCLUDES_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-excludes_t\r
-excludes_new(void);\r
-\r
-int\r
-excludes_add(excludes_t excludes, fstream_t fstream);\r
-\r
-int\r
-excludes_contains(excludes_t excludes, fstream_t fstream);\r
-\r
-int\r
-excludes_is_empty(excludes_t excludes);\r
-\r
-int\r
-excludes_check(excludes_t excludes, fstreams_t fstreams);\r
-\r
-int\r
-excludes_free(void** excludesptr);\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r excludes_t \r excludes_new(void);
+  \r\rint \r excludes_add(excludes_t excludes, fstream_t fstream);
+  \r \r int \r excludes_contains(excludes_t excludes, fstream_t fstream);
+  \r \r int \r excludes_is_empty(excludes_t excludes);
+  \r \r int \r excludes_check(excludes_t excludes, fstreams_t fstreams);
+  \r \r int \r excludes_free(void **excludesptr);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /*!__EXCLUDES_H */\r
+#endif  /*!__EXCLUDES_H */\r
index 84c571a..20cb5d3 100644 (file)
@@ -2,18 +2,16 @@
 #define __EXPLODE_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-char** \r
-explode(char separator, const char *string);\r
-\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r char **\r explode(char separator, const char *string);
+  \r\r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__EXPLODE_H */\r
+#endif  /* !__EXPLODE_H */\r
 \r
index 9cb9b40..2183b21 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh fstream type.\r
  *\r
- */\r
+ */  \r
 #ifndef __FSTREAM_H\r
 #define __FSTREAM_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief fstream_new - create a new fstream.\r
  *\r
  * \param directory    The directory of the tesh file.\r
@@ -36,10 +37,9 @@ extern "C" {
  *                                     [EINVAL] if one of the parameters is invalid.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the file stream.\r
- */\r
-fstream_t\r
-fstream_new(const char* directory, const char* name);\r
-\r
+ */ \r
+  fstream_t \r fstream_new(const char *directory, const char *name);
+  \r\r
 /*! \brief fstream_open - open a file stream object.\r
  *\r
  * \param fstream      The file stream to open.\r
@@ -54,10 +54,9 @@ fstream_new(const char* directory, const char* name);
  *                                     \r
  *                                     This function may also fail and set errno for any of \r
  *                                     the errors specified for the function fopen.                    \r
- */\r
-int\r
-fstream_open(fstream_t fstream);\r
-\r
+ */ \r
+  int \r fstream_open(fstream_t fstream);
+  \r \r
 /*! \brief fstream_close - close a file stream object.\r
  *\r
  * \param fstream      The file stream to close.\r
@@ -73,10 +72,9 @@ fstream_open(fstream_t fstream);
  *                                     \r
  *                                     This function may also fail and set errno for any of \r
  *                                     the errors specified for the function fclose.                   \r
- */\r
-int\r
-fstream_close(fstream_t fstream);\r
-\r
+ */ \r
+  int \r fstream_close(fstream_t fstream);
+  \r \r
 /*! \brief fstream_free - destroy a file stream object.\r
  *\r
  * \param ptr          A pointer to the file stream object to destroy.\r
@@ -95,33 +93,28 @@ fstream_close(fstream_t fstream);
  * remarks :\r
  *                                     Il the file stream object is opened the function close it\r
  *                                     before its destruction.                         \r
- */\r
-int\r
-fstream_free(fstream_t* ptr);\r
-\r
-int\r
-fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex);\r
-\r
-void \r
-fstream_lex_line(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char * filepos, char *line);\r
-\r
-void \r
-fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char* filepos, char token, char *line);\r
-\r
-void\r
-fstream_handle_include(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char* file_name, const char* description);\r
-\r
-void\r
-fstream_handle_suite(fstream_t fstream, const char* description, const char* filepos);\r
-\r
-int\r
-fstream_launch_command(fstream_t fstream, context_t context, xbt_os_mutex_t mutex);\r
-\r
-long fstream_getline(fstream_t fstream, char **buf, size_t *n);\r
-\r
+ */ \r
+  int \r fstream_free(fstream_t * ptr);
+  \r \r int \r fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex);
+  \r \r void \r
+      fstream_lex_line(fstream_t fstream, context_t context,
+                       xbt_os_mutex_t mutex, const char *filepos,
+                       char *line);
+  \r\rvoid \r fstream_process_token(fstream_t fstream, context_t context,
+                                 xbt_os_mutex_t mutex, const char *filepos,
+                                 char token, char *line);
+  \r\rvoid \r fstream_handle_include(fstream_t fstream, context_t context,
+                                  xbt_os_mutex_t mutex,
+                                  const char *file_name,
+                                  const char *description);
+  \r\rvoid \r fstream_handle_suite(fstream_t fstream, const char *description,
+                                const char *filepos);
+  \r\rint \r fstream_launch_command(fstream_t fstream, context_t context,
+                                 xbt_os_mutex_t mutex);
+  \r \r long fstream_getline(fstream_t fstream, char **buf, size_t * n);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /*! __FSTREAM_H */\r
+} \r
+#endif  /* \r */
+\r\r
+#endif  /*! __FSTREAM_H */\r
index 4998d74..afff0cb 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh fstreams type.\r
  *\r
- */\r
+ */  \r
 #ifndef __FSTREAMS_H\r
 #define __FSTREAMS_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief fstreams_new - create a new fstreams.\r
  *\r
  * \param directory    The directory of the tesh file.\r
@@ -36,39 +37,19 @@ extern "C" {
  *                                     [EINVAL] if one of the parameters is invalid.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the file stream.\r
- */\r
-fstreams_t\r
-fstreams_new(void_f_pvoid_t fn_finalize);\r
-\r
-int\r
-fstreams_exclude(fstreams_t fstreams, excludes_t excludes);\r
-\r
-int \r
-fstreams_contains(fstreams_t fstreams, fstream_t fstream);\r
-\r
-int\r
-fstreams_add(fstreams_t fstreams, fstream_t fstream);\r
-\r
-int\r
-fstreams_free(void** fstreamsptr);\r
-\r
-int\r
-fstreams_get_size(fstreams_t fstreams);\r
-\r
-int\r
-fstreams_is_empty(fstreams_t fstreams);\r
-\r
-int \r
-fstreams_contains(fstreams_t fstreams, fstream_t fstream);\r
-\r
-int\r
-fstreams_load(fstreams_t fstreams);\r
-\r
-\r
-\r
+ */ \r
+  fstreams_t \r fstreams_new(void_f_pvoid_t fn_finalize);
+  \r \r int \r fstreams_exclude(fstreams_t fstreams, excludes_t excludes);
+  \r \r int \r fstreams_contains(fstreams_t fstreams, fstream_t fstream);
+  \r \r int \r fstreams_add(fstreams_t fstreams, fstream_t fstream);
+  \r \r int \r fstreams_free(void **fstreamsptr);
+  \r\rint \r fstreams_get_size(fstreams_t fstreams);
+  \r \r int \r fstreams_is_empty(fstreams_t fstreams);
+  \r \r int \r fstreams_contains(fstreams_t fstreams, fstream_t fstream);
+  \r \r int \r fstreams_load(fstreams_t fstreams);
+  \r \r \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* !__FSTREAMS_H */\r
+} \r
+#endif  /* \r */
+\r \r
+#endif  /* !__FSTREAMS_H */\r
index 8ddf6b3..cf6f22d 100644 (file)
@@ -1,12 +1,11 @@
 #ifndef __GETPATH_H\r
 #define __GETPATH_H\r
-\r
-\r
-\r
+\r \r\r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /* getpath th    --    get the path of the file name specified by the first parameter\r
  *                                             of the function and store the path in its second parmater.\r
  *                                             the function returns the length of the path of the file.                                 \r
@@ -25,10 +24,9 @@ extern "C" {
  *                                             [ENOMEM]        because this function use calloc, errno can be set with\r
  *                                                                     this error code.                                \r
  *\r
- */\r
-int\r
-getpath(const char* file_name, char** path);\r
-\r
+ */ \r
+  int \r getpath(const char *file_name, char **path);
+  \r\r
 /* translatepath   --  path translation\r
  *\r
  * param totranslate   The path to translate.\r
@@ -42,13 +40,11 @@ getpath(const char* file_name, char** path);
  \r
  *                                             [ENOMEM]        because this function use calloc, errno can be set with\r
  *                                                                     this error code.                                \r
- */\r
-int\r
-translatepath(const char* totranslate, char** translated);\r
-\r
+ */ \r
+  int \r translatepath(const char *totranslate, char **translated);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* !__GETPATH_H */\r
+} \r
+#endif  /* \r */
+\r\r
+#endif  /* !__GETPATH_H */\r
index 4c6d743..112588a 100644 (file)
@@ -2,17 +2,16 @@
 #define __IS_CMD_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-int\r
-is_cmd(char** path, char** builtin, const char* p);\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r int \r is_cmd(char **path, char **builtin, const char *p);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__IS_CMD_H */\r
+#endif  /* !__IS_CMD_H */\r
 \r
index 623f1ff..3a731d2 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh writer type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef __READER_H\r
 #define __READER_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r \r
 /*! \brief reader_new - create a new reader.\r
  *\r
  * \param command      The command owning the stdout readed by the reader.\r
@@ -35,10 +35,9 @@ extern "C" {
  *                                     [EINVAL] if the parameter is invalid.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the reader.\r
- */\r
-reader_t\r
-reader_new(command_t command);\r
-\r
+ */ \r
+  reader_t \r reader_new(command_t command);
+  \r \r
 /*! \brief reader_free - destroy a reader object.\r
  *\r
  * \param ptr          A pointer to the reader object to destroy.\r
@@ -51,18 +50,13 @@ reader_new(command_t command);
  *                                     [EINVAL] if the reader object pointed to by the parameter ptr is invalid.\r
  *                                     \r
  *                                     \r
- */\r
-int\r
-reader_free(reader_t* ptr);\r
-\r
-void\r
-reader_read(reader_t reader);\r
-\r
-void\r
-reader_wait(reader_t reader);\r
-\r
+ */ \r
+  int \r reader_free(reader_t * ptr);
+  \r \r void \r reader_read(reader_t reader);
+  \r \r void \r reader_wait(reader_t reader);
+  \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__READER_H */\r
+#endif  /* !__READER_H */\r
index 2298c3a..8d9297e 100644 (file)
@@ -2,19 +2,16 @@
 #define __READLINE_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-long\r
-readline(FILE* stream, char **buf, size_t *n);\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r long \r readline(FILE * stream, char **buf, size_t * n);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-\r
-#endif /* !__READLINE_H */\r
+} \r
+#endif  /* \r */
+\r\r\r
+#endif  /* !__READLINE_H */\r
 \r
index 836a0db..4166a86 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh runner type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef __RUNNER_H     \r
 #define __RUNNER_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief runner_init - initialize the tesh runner.\r
  *\r
  * \param check_syntax_flag            If 1, the runner check the syntax of all the tesh files before running.\r
@@ -34,37 +35,30 @@ extern "C" {
  *                                                             [EALREADY] if the runner is already initialized.\r
  *                                                             [ENOMEM] if the system has not enough space to initialize the runner.\r
  *                                                             [ESYNTAX] if the parameter check_syntax_flag is 1 and a syntax error is detected.\r
- */                    \r
-int\r
-runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams);\r
-\r
+ */ \r
+  int \r
+      runner_init( /*int check_syntax_flag, */ int timeout,
+                  fstreams_t fstreams);
+  \r\r
 /*! \brief runner_run - run the tesh files.\r
- */                    \r
-void\r
-runner_run(void);\r
-\r
+ */ \r
+  void \r runner_run(void);
+  \r\r
 /*! \brief runner_destroy - destroy the runner (release all the resources allocated by the runner)\r
- */\r
-void\r
-runner_destroy(void);\r
-\r
+ */ \r
+  void \r runner_destroy(void);
+  \r\r
 /*! \brief runner_summarize - display the summary of the execution of all the tests of the tesh files.\r
- */\r
-void\r
-runner_summarize(void);\r
-\r
+ */ \r
+  void \r runner_summarize(void);
+  \r\r
 /*! \brief runner_interrupt - interrupt all the units of the run.\r
- */\r
-void\r
-runner_interrupt(void);\r
-\r
-int\r
-runner_is_timedout(void);\r
-\r
-\r
+ */ \r
+  void \r runner_interrupt(void);
+  \r\rint \r runner_is_timedout(void);
+  \r\r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* !__RUNNER_H */\r
+} \r
+#endif  /* \r */
+\r\r
+#endif  /* !__RUNNER_H */\r
index 4c18e35..8f12af5 100644 (file)
@@ -2,18 +2,19 @@
 #define __STR_REPLACE_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-int\r
-str_replace(char** str, const char *what, const char *with, const char* delimiters);\r
-\r
-int\r
-str_replace_all(char** str, const char* what, const char* with, const char* delimiters);\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  int \r
+      str_replace(char **str, const char *what, const char *with,
+                  const char *delimiters);
+  \r\rint \r str_replace_all(char **str, const char *what, const char *with,
+                          const char *delimiters);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__STR_REPLACE_H */\r
+#endif  /* !__STR_REPLACE_H */\r
index 1b37c9d..65489c0 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh timer type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef __TIMER_H\r
 #define __TIMER_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r \r
 /*! \brief timer_new - create a new timer.\r
  *\r
  * \param command      The command to keep a wath.\r
@@ -35,10 +35,9 @@ extern "C" {
  *                                     [EINVAL] if the parameter is invalid.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the timer.\r
- */\r
-ttimer_t\r
-timer_new(command_t command);\r
-\r
+ */ \r
+  ttimer_t \r timer_new(command_t command);
+  \r \r
 /*! \brief timer_free - destroy a timer object.\r
  *\r
  * \param ptr          A pointer to the timer object to destroy.\r
@@ -51,19 +50,13 @@ timer_new(command_t command);
  *                                     [EINVAL] if the timer object pointed to by the parameter ptr is invalid.\r
  *                                     \r
  *                                     \r
- */\r
-int\r
-timer_free(ttimer_t* ptr);\r
-\r
-void\r
-timer_time(ttimer_t timer);\r
-\r
-void\r
-timer_wait(ttimer_t timer);\r
-\r
+ */ \r
+  int \r timer_free(ttimer_t * ptr);
+  \r \r void \r timer_time(ttimer_t timer);
+  \r \r void \r timer_wait(ttimer_t timer);
+  \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* !__TIMER_H */\r
+} \r
+#endif  /* \r */
+\r \r
+#endif  /* !__TIMER_H */\r
index 322d81c..a9f4d35 100644 (file)
@@ -10,9 +10,9 @@
  *             This file declares the types used to run a set of tesh files.
  *
  */
-#ifndef __TYPES_H      
+
+
+#ifndef __TYPES_H
 #define __TYPES_H
 
 #include <def.h>
@@ -31,8 +31,8 @@ extern "C" {
  * byte type definition 
  */
 #ifndef __BYTE_T_DEFINED
-       typedef unsigned char byte;
-       #define __BYTE_T_DEFINED
+  typedef unsigned char byte;
+#define __BYTE_T_DEFINED
 #endif
 
 /*
@@ -40,329 +40,310 @@ extern "C" {
  */
 
 #ifdef _XBT_WIN32
-       
-       #ifndef __FD_T_DEFINED
-               typedef HANDLE fd_t;
-               #define __FD_T_DEFINED
-       #endif
-       
-       #ifndef __PID_T_DEFINED
-               typedef HANDLE pid_t;
-               #define __PID_T_DEFINED
-       #endif
-       
+
+#ifndef __FD_T_DEFINED
+  typedef HANDLE fd_t;
+#define __FD_T_DEFINED
+#endif
+
+#ifndef __PID_T_DEFINED
+  typedef HANDLE pid_t;
+#define __PID_T_DEFINED
+#endif
+
 #else
 
-       #ifndef __FD_T_DEFINED
-               typedef int fd_t;
-               #define __FD_T_DEFINED
-       #endif
-       
-       #ifndef __PID_T_DEFINED
-               typedef int pid_t;
-               #define __PID_T_DEFINED
-       #endif
+#ifndef __FD_T_DEFINED
+  typedef int fd_t;
+#define __FD_T_DEFINED
+#endif
+
+#ifndef __PID_T_DEFINED
+  typedef int pid_t;
+#define __PID_T_DEFINED
+#endif
 #endif
 
 /* forward declarations */
 
-struct s_unit;                         /* this structure represents a tesh unit        */
-
-struct s_runner;
-struct s_units;
-struct s_unit;
-struct s_excludes;
-struct s_fstreams;
-struct s_fstream;
-struct s_directories;
-struct s_directory;
-struct s_writer;
-struct s_reader;
-struct s_timer;
-struct s_context;
-struct s_command;
-struct s_variable;
-struct s_error;
+  struct s_unit;                /* this structure represents a tesh unit        */
+
+  struct s_runner;
+  struct s_units;
+  struct s_unit;
+  struct s_excludes;
+  struct s_fstreams;
+  struct s_fstream;
+  struct s_directories;
+  struct s_directory;
+  struct s_writer;
+  struct s_reader;
+  struct s_timer;
+  struct s_context;
+  struct s_command;
+  struct s_variable;
+  struct s_error;
 
 
 /* 
  * declaration of the tesh unit type which represents a tesh file
  * to run.     
  */
-typedef struct s_unit
-{
-       char* description;                                      /* an optional description of the unit                                                                  */                              
-       struct s_fstream* fstream;                      /* the file stream used to parse the tesh file                                                  */
-       struct s_runner* runner;                        /* the runner of the unit                                                                                           */
-       xbt_dynar_t commands;                           /* a vector containing all the commands parsed from the tesh file               */
-       int cmd_nb;                                                     /* number of created commands of the unit                                                               */      
-       int started_cmd_nb;                                     /* number of started commands of the unit                                                               */
-       int interrupted_cmd_nb;                         /* number of interrupted commands of the unit                                                   */      
-       int failed_cmd_nb;                                      /* number of failed commands of the unit                                                                */
-       int successeded_cmd_nb;                         /* number of successeded commands of the unit                                                   */
-       int terminated_cmd_nb;                          /* number of ended commands                                                                                             */
-       int waiting_cmd_nb;                                     /* REMOVE THIS FIELD LATER                                                                                              */
-       xbt_os_thread_t thread;                         /* all the units run in its own thread                                                                  */
-       xbt_os_sem_t sem;                                       /* used by the last command of the unit to signal the end of the unit   */
-       xbt_os_mutex_t mutex;                           /* used to synchronously access to the properties of the runner                 */
-       unsigned interrupted : 1;                       /* if 1, the unit is interrupted by the runner                                                  */
-       unsigned failed : 1;                            /* if 1, the unit is failed                                                                                             */
-       unsigned successeded : 1;                       /* if 1, the unit is successeded                                                                                */
-       unsigned parsed : 1;                            /* if 1, the tesh file of the unit is parsed                                                    */
-       unsigned released : 1;                          /* if 1, the unit is released                                                                                   */
-       unsigned is_running_suite : 1;          /* if 1, the unit is running a suite                                                                    */
-       struct s_unit* owner;                           /* the unit owned the unit is included                                                                  */
-       struct s_unit* root;                            /* the root unit                                                                                                                */
-       xbt_dynar_t suites;                                     /* the suites contained by the unit                                                                             */
-       int exit_code;                                          /* the exit code of the unit                                                                                    */
-       int err_kind;
-       char* err_line;
-       xbt_dynar_t includes;
-       char* filepos;
-}s_unit_t,* unit_t;
+  typedef struct s_unit {
+    char *description;          /* an optional description of the unit                                                                  */
+    struct s_fstream *fstream;  /* the file stream used to parse the tesh file                                                  */
+    struct s_runner *runner;    /* the runner of the unit                                                                                           */
+    xbt_dynar_t commands;       /* a vector containing all the commands parsed from the tesh file               */
+    int cmd_nb;                 /* number of created commands of the unit                                                               */
+    int started_cmd_nb;         /* number of started commands of the unit                                                               */
+    int interrupted_cmd_nb;     /* number of interrupted commands of the unit                                                   */
+    int failed_cmd_nb;          /* number of failed commands of the unit                                                                */
+    int successeded_cmd_nb;     /* number of successeded commands of the unit                                                   */
+    int terminated_cmd_nb;      /* number of ended commands                                                                                             */
+    int waiting_cmd_nb;         /* REMOVE THIS FIELD LATER                                                                                              */
+    xbt_os_thread_t thread;     /* all the units run in its own thread                                                                  */
+    xbt_os_sem_t sem;           /* used by the last command of the unit to signal the end of the unit   */
+    xbt_os_mutex_t mutex;       /* used to synchronously access to the properties of the runner                 */
+    unsigned interrupted:1;     /* if 1, the unit is interrupted by the runner                                                  */
+    unsigned failed:1;          /* if 1, the unit is failed                                                                                             */
+    unsigned successeded:1;     /* if 1, the unit is successeded                                                                                */
+    unsigned parsed:1;          /* if 1, the tesh file of the unit is parsed                                                    */
+    unsigned released:1;        /* if 1, the unit is released                                                                                   */
+    unsigned is_running_suite:1;        /* if 1, the unit is running a suite                                                                    */
+    struct s_unit *owner;       /* the unit owned the unit is included                                                                  */
+    struct s_unit *root;        /* the root unit                                                                                                                */
+    xbt_dynar_t suites;         /* the suites contained by the unit                                                                             */
+    int exit_code;              /* the exit code of the unit                                                                                    */
+    int err_kind;
+    char *err_line;
+    xbt_dynar_t includes;
+    char *filepos;
+  } s_unit_t, *unit_t;
 
 /* 
  * declaration of the tesh file stream type used to manage the tesh file.      
  */
-typedef struct s_fstream
-{
-       char* name;                                                     /* the name of the file stream (same as the name of the tesh file)              */
-       char* directory;                                        /* the directory containing the tesh file                                                               */
-       FILE* stream;                                           /* the system file stream                                                                                               */
-       struct s_unit* unit;                            /* a reference to the unit using the file stream object                                 */
-       unsigned parsed:1;
-}s_fstream_t,* fstream_t;
+  typedef struct s_fstream {
+    char *name;                 /* the name of the file stream (same as the name of the tesh file)              */
+    char *directory;            /* the directory containing the tesh file                                                               */
+    FILE *stream;               /* the system file stream                                                                                               */
+    struct s_unit *unit;        /* a reference to the unit using the file stream object                                 */
+    unsigned parsed:1;
+  } s_fstream_t, *fstream_t;
 
 /* 
  * command status 
  */
-typedef enum e_command_status
-{
-       cs_initialized                                  = 0,            /* the is initialized                                                                                           */
-       cs_started                                              = 1,            /* the command is started                                                                                       */      
-       cs_in_progress                                  = 2,            /* the command is execited                                                                                      */
-       cs_waiting                                              = 3,            /* the command is waiting the writer, the reader and the timer          */                              
-       cs_interrupted                                  = 4,            /* the command is interrupted                                                                           */      
-       cs_failed                                               = 5,            /* the command is failed                                                                                        */
-       cs_successeded                                  = 6,            /* the command is successeded                                                                           */
-       cs_killed                                               = 7,            /* the command is killed                                                                                        */
-       csr_fcntl_function_failed               = 8                     /* the fcntl function failed                                                                            */
-}command_status_t;
+  typedef enum e_command_status {
+    cs_initialized = 0,         /* the is initialized                                                                                           */
+    cs_started = 1,             /* the command is started                                                                                       */
+    cs_in_progress = 2,         /* the command is execited                                                                                      */
+    cs_waiting = 3,             /* the command is waiting the writer, the reader and the timer          */
+    cs_interrupted = 4,         /* the command is interrupted                                                                           */
+    cs_failed = 5,              /* the command is failed                                                                                        */
+    cs_successeded = 6,         /* the command is successeded                                                                           */
+    cs_killed = 7,              /* the command is killed                                                                                        */
+    csr_fcntl_function_failed = 8       /* the fcntl function failed                                                                            */
+  } command_status_t;
 
 /* 
  * reason of the status of the command 
  */
-typedef enum e_command_status_raison
-{
-       csr_unknown                                                     = 0,            /* unknown reason                                                                                                       */
-       csr_read_failure                                        = 1,            /* a read operation failed                                                                                      */
-       csr_read_pipe_broken                            = 2,            /* the pipe used to read from the stdout of the command is broken       */
-       csr_timeout                                                     = 3,            /* timeout                                                                                                                      */
-       csr_write_failure                                       = 4,            /* a write operation failed                                                                                     */
-       csr_write_pipe_broken                           = 5,            /* the pipe used to write to the stdin of the command is broken         */
-       csr_fork_function_failure                       = 6,            /* can't execute the command                                                                            */
-       csr_wait_failure                                        = 8,            /* the wait process function failed                                                                     */
-       csr_interruption_request                        = 9,            /* the command has received an interruption request                                     */
-       csr_command_not_found                           = 10,           /* the command is not found                                                                                     */
-       csr_exit_codes_dont_match                       = 11,
-       csr_outputs_dont_match                          = 12,
-       csr_signals_dont_match                          = 13,
-       csr_unexpected_signal_caught            = 14,
-       csr_expected_signal_not_received                = 15,
-       csr_pipe_function_failed                        = 16,           /* the function pipe() or CreatePipe() fails                                            */
-       csr_dup2_function_failure                       = 17,
-       csr_execlp_function_failure                     = 18,
-       csr_create_process_function_failure     = 19,
-       csr_waitpid_function_failure            = 20,
-       csr_get_exit_code_process_function_failure      = 21,
-       csr_shell_failed = 22
-}cs_reason_t;
-
-
-
-
-typedef struct s_variable
-{
-       char* name;
-       char* val;
-       int used;
-       int env;
-       int err;
-}s_variable_t,* variable_t;
+  typedef enum e_command_status_raison {
+    csr_unknown = 0,            /* unknown reason                                                                                                       */
+    csr_read_failure = 1,       /* a read operation failed                                                                                      */
+    csr_read_pipe_broken = 2,   /* the pipe used to read from the stdout of the command is broken       */
+    csr_timeout = 3,            /* timeout                                                                                                                      */
+    csr_write_failure = 4,      /* a write operation failed                                                                                     */
+    csr_write_pipe_broken = 5,  /* the pipe used to write to the stdin of the command is broken         */
+    csr_fork_function_failure = 6,      /* can't execute the command                                                                            */
+    csr_wait_failure = 8,       /* the wait process function failed                                                                     */
+    csr_interruption_request = 9,       /* the command has received an interruption request                                     */
+    csr_command_not_found = 10, /* the command is not found                                                                                     */
+    csr_exit_codes_dont_match = 11,
+    csr_outputs_dont_match = 12,
+    csr_signals_dont_match = 13,
+    csr_unexpected_signal_caught = 14,
+    csr_expected_signal_not_received = 15,
+    csr_pipe_function_failed = 16,      /* the function pipe() or CreatePipe() fails                                            */
+    csr_dup2_function_failure = 17,
+    csr_execlp_function_failure = 18,
+    csr_create_process_function_failure = 19,
+    csr_waitpid_function_failure = 20,
+    csr_get_exit_code_process_function_failure = 21,
+    csr_shell_failed = 22
+  } cs_reason_t;
+
+
+
+
+  typedef struct s_variable {
+    char *name;
+    char *val;
+    int used;
+    int env;
+    int err;
+  } s_variable_t, *variable_t;
 
 /* 
  * declaration of the tesh timer type 
  */
-typedef struct s_timer
-{
-       xbt_os_thread_t thread;                         /* asynchronous timer                                                                                                   */
-       struct s_command* command;                      /* the timed command                                                                                                    */
-       int timeouted;                                          /* if 1, the timer is timeouted                                                                                 */
-       xbt_os_sem_t started;
-}s_timer_t,* ttimer_t;
+  typedef struct s_timer {
+    xbt_os_thread_t thread;     /* asynchronous timer                                                                                                   */
+    struct s_command *command;  /* the timed command                                                                                                    */
+    int timeouted;              /* if 1, the timer is timeouted                                                                                 */
+    xbt_os_sem_t started;
+  } s_timer_t, *ttimer_t;
 
 /* 
  * declaration of the tesh reader type 
  */
-typedef struct s_reader
-{
-       xbt_os_thread_t thread;                         /* asynchonous reader                                                                                                   */
-       struct s_command* command;                      /* the command of the reader                                                                                    */
-       int failed;                                                     /* if 1, the reader failed                                                                                              */
-       int broken_pipe;                                        /* if 1, the pipe used by the reader is broken                                                  */
-       int done;
-       xbt_os_sem_t started;
-}s_reader_t,* reader_t;
+  typedef struct s_reader {
+    xbt_os_thread_t thread;     /* asynchonous reader                                                                                                   */
+    struct s_command *command;  /* the command of the reader                                                                                    */
+    int failed;                 /* if 1, the reader failed                                                                                              */
+    int broken_pipe;            /* if 1, the pipe used by the reader is broken                                                  */
+    int done;
+    xbt_os_sem_t started;
+  } s_reader_t, *reader_t;
 
 /* 
  * declaration of the tesh writer type 
  */
-typedef struct s_writer
-{
-       xbt_os_thread_t thread;                         /* asynchronous writer                                                                                                  */
-       struct s_command* command;                      /* the command of the writer                                                                                    */
-       int failed;                                                     /* if 1, the writer failed                                                                                              */
-       int broken_pipe;                                        /* if 1, the pipe used by the writer is broken                                                  */
-       xbt_os_sem_t written;
-       xbt_os_sem_t can_write;
-       int done;
-}s_writer_t,* writer_t;
-
-
-typedef struct s_units
-{                                                                              
-       xbt_dynar_t items;
-       int number_of_runned_units;                     /* the number of units runned                                                                                   */
-       int number_of_ended_units;                      /* the number of units over                                                                                             */
-       
-}s_units_t,* units_t;
+  typedef struct s_writer {
+    xbt_os_thread_t thread;     /* asynchronous writer                                                                                                  */
+    struct s_command *command;  /* the command of the writer                                                                                    */
+    int failed;                 /* if 1, the writer failed                                                                                              */
+    int broken_pipe;            /* if 1, the pipe used by the writer is broken                                                  */
+    xbt_os_sem_t written;
+    xbt_os_sem_t can_write;
+    int done;
+  } s_writer_t, *writer_t;
+
+
+  typedef struct s_units {
+    xbt_dynar_t items;
+    int number_of_runned_units; /* the number of units runned                                                                                   */
+    int number_of_ended_units;  /* the number of units over                                                                                             */
+
+  } s_units_t, *units_t;
 
 /* 
  * declaration of the tesh runner type 
  */
-typedef struct s_runner
-{
-       struct s_units* units;
-       int timeouted;                                          /* if 1, the runner is timeouted                                                                                */
-       int timeout;                                            /* the timeout of the runner                                                                                    */
-       int interrupted;                                        /* if 1, the runner failed                                                                                              */
-       int number_of_runned_units;                     /* the number of units runned by the runner                                                             */
-       int number_of_ended_units;                      /* the number of ended units                                                                                    */
-       int waiting;                                            /* if 1, the runner is waiting the end of all the units                                 */
-       xbt_os_thread_t thread;                         /* the timer thread                                                                                                             */
-       xbt_dynar_t variables;
-
-       int total_of_tests;
-       int total_of_successeded_tests;
-       int total_of_failed_tests;
-       int total_of_interrupted_tests;
-       
-       int total_of_units;
-       int total_of_successeded_units;
-       int total_of_failed_units;
-       int total_of_interrupted_units;
-       
-       int total_of_suites;
-       int total_of_successeded_suites;
-       int total_of_failed_suites;
-       int total_of_interrupted_suites;
-       char** path;
-       char** builtin;
-}s_runner_t,* runner_t;
-
-
-typedef struct s_fstreams
-{
-       xbt_dynar_t items;
-}s_fstreams_t,* fstreams_t;
-
-
-typedef struct s_excludes
-{
-       xbt_dynar_t items;
-}s_excludes_t,* excludes_t;
-
-typedef struct s_directory
-{
-       char* name;
-       DIR* stream;
-}s_directory_t,* directory_t;
-
-typedef struct s_directories
-{
-       xbt_dynar_t items;
-}s_directories_t,* directories_t;
-
-
-typedef enum 
-{
-       oh_check, 
-       oh_display, 
-       oh_ignore
-}output_handling_t;
+  typedef struct s_runner {
+    struct s_units *units;
+    int timeouted;              /* if 1, the runner is timeouted                                                                                */
+    int timeout;                /* the timeout of the runner                                                                                    */
+    int interrupted;            /* if 1, the runner failed                                                                                              */
+    int number_of_runned_units; /* the number of units runned by the runner                                                             */
+    int number_of_ended_units;  /* the number of ended units                                                                                    */
+    int waiting;                /* if 1, the runner is waiting the end of all the units                                 */
+    xbt_os_thread_t thread;     /* the timer thread                                                                                                             */
+    xbt_dynar_t variables;
+
+    int total_of_tests;
+    int total_of_successeded_tests;
+    int total_of_failed_tests;
+    int total_of_interrupted_tests;
+
+    int total_of_units;
+    int total_of_successeded_units;
+    int total_of_failed_units;
+    int total_of_interrupted_units;
+
+    int total_of_suites;
+    int total_of_successeded_suites;
+    int total_of_failed_suites;
+    int total_of_interrupted_suites;
+    char **path;
+    char **builtin;
+  } s_runner_t, *runner_t;
+
+
+  typedef struct s_fstreams {
+    xbt_dynar_t items;
+  } s_fstreams_t, *fstreams_t;
+
+
+  typedef struct s_excludes {
+    xbt_dynar_t items;
+  } s_excludes_t, *excludes_t;
+
+  typedef struct s_directory {
+    char *name;
+    DIR *stream;
+  } s_directory_t, *directory_t;
+
+  typedef struct s_directories {
+    xbt_dynar_t items;
+  } s_directories_t, *directories_t;
+
+
+  typedef enum {
+    oh_check,
+    oh_display,
+    oh_ignore
+  } output_handling_t;
 /* 
  * declaration of the tesh context type 
  */
-typedef struct s_context
-{
-       char* command_line;                     /* the command line of the command to execute                                                   */
-       const char* line;                                       /* the current parsed line                                                                                              */
-       char* pos;
-       int exit_code;                                          /* the expected exit code of the command                                                                */
-       char* signal;                                           /* the expected signal raised by the command                                                    */
-       int timeout;                                            /* the timeout of the test                                                                                              */
-       xbt_strbuff_t input;                            /* the input to write in the stdin of the command to run                                */
-       xbt_strbuff_t output;                           /* the expected output of the command of the test                                               */
-       output_handling_t output_handling;
-       int async;                                                      /* if 1, the command is asynchronous                                                                    */
-       
-       #ifdef _XBT_WIN32
-       char* t_command_line;                           /* translate the command line on Windows                                                                */
-       unsigned is_not_found:1;
-       #endif
-
-}s_context_t,* context_t;
+  typedef struct s_context {
+    char *command_line;         /* the command line of the command to execute                                                   */
+    const char *line;           /* the current parsed line                                                                                              */
+    char *pos;
+    int exit_code;              /* the expected exit code of the command                                                                */
+    char *signal;               /* the expected signal raised by the command                                                    */
+    int timeout;                /* the timeout of the test                                                                                              */
+    xbt_strbuff_t input;        /* the input to write in the stdin of the command to run                                */
+    xbt_strbuff_t output;       /* the expected output of the command of the test                                               */
+    output_handling_t output_handling;
+    int async;                  /* if 1, the command is asynchronous                                                                    */
+
+#ifdef _XBT_WIN32
+    char *t_command_line;       /* translate the command line on Windows                                                                */
+    unsigned is_not_found:1;
+#endif
+
+  } s_context_t, *context_t;
 
 /* 
  * declaration of the tesh command type 
  */
-typedef struct s_command
-{
-       unit_t root;
-       unit_t unit;                                    /* the unit of the command                                                                                              */
-       struct s_context* context;                      /* the context of the execution of the command                                                  */
-       xbt_os_thread_t thread;                         /* asynchronous command                                                                                                 */
-       struct s_writer* writer;                        /* the writer used to write in the command stdin                                                */
-       struct s_reader* reader;                        /* the reader used to read from the command stout                                               */
-       struct s_timer* timer;                          /* the timer used for the command                                                                               */
-       command_status_t status;                        /* the current status of the command                                                                    */
-       cs_reason_t reason;                                     /* the reason of the state of the command                                                               */
-       int successeded;                                        /* if 1, the command is successeded                                                                             */
-       int interrupted;                                        /* if 1, the command is interrupted                                                                             */
-       int failed;                                                     /* if 1, the command is failed                                                                                  */
-       pid_t pid;                                                      /* the program id of the command                                                                                */
-       xbt_strbuff_t output;                           /* the output of the command                                                                                    */
-       fd_t stdout_fd;                                         /* the stdout fd of the command                                                                                 */
-       fd_t stdin_fd;                                          /* the stdin fd of the command                                                                                  */
-       int exit_code;                                          /* the exit code of the command                                                                                 */
-       #ifdef _XBT_WIN32
-       unsigned long stat_val;
-       #else
-       int stat_val;
-       #endif
-       char* signal;                                           /* the signal raised by the command if any                                                              */
-       xbt_os_mutex_t mutex;
-       
-       #ifndef _XBT_WIN32
-       int killed;                                                     /* if 1, the command was killed                                                                                 */
-       int execlp_errno;
-       #endif
-
-}s_command_t,* command_t;
+  typedef struct s_command {
+    unit_t root;
+    unit_t unit;                /* the unit of the command                                                                                              */
+    struct s_context *context;  /* the context of the execution of the command                                                  */
+    xbt_os_thread_t thread;     /* asynchronous command                                                                                                 */
+    struct s_writer *writer;    /* the writer used to write in the command stdin                                                */
+    struct s_reader *reader;    /* the reader used to read from the command stout                                               */
+    struct s_timer *timer;      /* the timer used for the command                                                                               */
+    command_status_t status;    /* the current status of the command                                                                    */
+    cs_reason_t reason;         /* the reason of the state of the command                                                               */
+    int successeded;            /* if 1, the command is successeded                                                                             */
+    int interrupted;            /* if 1, the command is interrupted                                                                             */
+    int failed;                 /* if 1, the command is failed                                                                                  */
+    pid_t pid;                  /* the program id of the command                                                                                */
+    xbt_strbuff_t output;       /* the output of the command                                                                                    */
+    fd_t stdout_fd;             /* the stdout fd of the command                                                                                 */
+    fd_t stdin_fd;              /* the stdin fd of the command                                                                                  */
+    int exit_code;              /* the exit code of the command                                                                                 */
+#ifdef _XBT_WIN32
+    unsigned long stat_val;
+#else
+    int stat_val;
+#endif
+    char *signal;               /* the signal raised by the command if any                                                              */
+    xbt_os_mutex_t mutex;
 
-#ifdef __cplusplus
-}
+#ifndef _XBT_WIN32
+    int killed;                 /* if 1, the command was killed                                                                                 */
+    int execlp_errno;
 #endif
 
-#endif /* !__TYPES_H */
+  } s_command_t, *command_t;
 
+#ifdef __cplusplus
+}
+#endif
+#endif                          /* !__TYPES_H */
index 7b92ab7..8e9510c 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh unit concept.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef __UNIT_H       \r
 #define __UNIT_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief unit_new - create a new unit.\r
  *\r
  * \param runner       The runner which runs the unit.\r
@@ -35,10 +36,11 @@ extern "C" {
  *                                     [EINVAL] if one of the parameters is invalid.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the unit.\r
- */\r
-unit_t\r
-unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream);\r
-\r
+ */ \r
+  unit_t \r
+      unit_new(runner_t runner, unit_t root, unit_t owner,
+               fstream_t fstream);
+  \r \r
 /*! \brief unit_free - destroy a tesh unit.\r
  *\r
  * \param ptr          A pointer to the unit to destroy.\r
@@ -49,10 +51,9 @@ unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream);
  *\r
  * errors :\r
  *                                     [EINVAL] if the pointer to the unit to destroy is invalid.\r
- */\r
-int\r
-unit_free(unit_t* ptr);\r
-\r
+ */ \r
+  int \r unit_free(unit_t * ptr);
+  \r \r
 /*! \brief unit_run - run a tesh unit.\r
  *\r
  * \param unit         The unit to run.\r
@@ -68,11 +69,9 @@ unit_free(unit_t* ptr);
  *\r
  * remarks :           If the runner is interrupted during a call of this function,\r
  *                                     the unit is not launched but its flag interrupted is signaled.\r
- */\r
-int\r
-unit_run(unit_t unit, xbt_os_mutex_t mutex);\r
-\r
-\r
+ */ \r
+  int \r unit_run(unit_t unit, xbt_os_mutex_t mutex);
+  \r \r \r
 /*! \brief unit_interrupt - interrupt a tesh unit.\r
  *\r
  * \param unit         The unit to interrupt.\r
@@ -87,10 +86,9 @@ unit_run(unit_t unit, xbt_os_mutex_t mutex);
  *\r
  * remarks :           If the runner is interrupted during a call of this function,\r
  *                                     the unit is not launched but its flag interrupted is signaled.\r
- */\r
-int\r
-unit_interrupt(unit_t unit);\r
-\r
+ */ \r
+  int \r unit_interrupt(unit_t unit);
+  \r \r
 /*! \brief unit_summuarize - summarize the run of tesh unit.\r
  *\r
  * \param unit         The unit to summarize the run.\r
@@ -101,19 +99,14 @@ unit_interrupt(unit_t unit);
  *\r
  * errors :\r
  *                                     [EINVAL] if the unit specified as parameter is invalid.\r
- */\r
-int\r
-unit_summuarize(unit_t unit);\r
-\r
-int\r
-unit_reset(unit_t unit);\r
-\r
-void\r
-unit_set_error(unit_t unit, int errcode, int kind, const char* line);\r
-\r
+ */ \r
+  int \r unit_summuarize(unit_t unit);
+  \r \r int \r unit_reset(unit_t unit);
+  \r \r void \r
+      unit_set_error(unit_t unit, int errcode, int kind, const char *line);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* !__UNIT_H */\r
+} \r
+#endif  /* \r */
+\r\r
+#endif  /* !__UNIT_H */\r
index affcc94..46cd698 100644 (file)
@@ -2,45 +2,24 @@
 #define __UNITS_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-units_t\r
-units_new(runner_t runner, fstreams_t fstreams);\r
-\r
-int\r
-units_is_empty(units_t unit);\r
-\r
-int\r
-units_get_size(units_t unit);\r
-\r
-int\r
-units_run_all(units_t units, xbt_os_mutex_t mutex);\r
-\r
-int\r
-units_join_all(units_t units);\r
-\r
-int\r
-units_interrupt_all(units_t units);\r
-\r
-int\r
-units_reset_all(units_t units);\r
-\r
-\r
-int\r
-units_summuarize(units_t units);\r
-\r
-int\r
-units_free(void** unitsptr);\r
-\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r units_t \r units_new(runner_t runner, fstreams_t fstreams);
+  \r \r int \r units_is_empty(units_t unit);
+  \r \r int \r units_get_size(units_t unit);
+  \r \r int \r units_run_all(units_t units, xbt_os_mutex_t mutex);
+  \r \r int \r units_join_all(units_t units);
+  \r \r int \r units_interrupt_all(units_t units);
+  \r \r int \r units_reset_all(units_t units);
+  \r \r \r int \r units_summuarize(units_t units);
+  \r \r int \r units_free(void **unitsptr);
+  \r\r\r
 #ifdef __cplusplus\r
-extern }\r
-#endif\r
-\r
-\r
-#endif /* !__UNITS_H */\r
-\r
-\r
+extern} \r
+#endif  /* \r */
+\r \r
+#endif  /* !__UNITS_H */\r
+\r \r
index 8341c79..64cc65d 100644 (file)
@@ -2,28 +2,19 @@
 #define __VARIABLE_H\r
 \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-variable_t\r
-variable_new(const char* name, const char* val);\r
-\r
-int\r
-variable_free(variable_t* variableptr);\r
-\r
-int\r
-variable_is_used(variable_t variable);\r
-\r
-int\r
-variable_set_used(variable_t variable);\r
-\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r variable_t \r variable_new(const char *name, const char *val);
+  \r\rint \r variable_free(variable_t * variableptr);
+  \r \r int \r variable_is_used(variable_t variable);
+  \r \r int \r variable_set_used(variable_t variable);
+  \r \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /*!__VARIABLE_H */\r
+} \r
+#endif  /* \r */
+\r \r
+#endif  /*!__VARIABLE_H */\r
 \r
index 1fe2c85..40f6cb5 100644 (file)
  *             This file contains all the declarations of the functions related with\r
  *             the tesh writer type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #ifndef __WRITER_H\r
 #define __WRITER_H\r
-\r
+    \r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 /*! \brief writer_new - create a new writer.\r
  *\r
  * \param command      The command owning the stdin written by the writer.\r
@@ -34,11 +35,9 @@ extern "C" {
  *                                     [EINVAL] if the parameter is invalid.\r
  *                                     [ENOMEM] if the system has not enough space to allocate\r
  *                                              the writer.\r
- */\r
-writer_t\r
-writer_new(command_t command);\r
-\r
-\r
+ */ \r
+  writer_t \r writer_new(command_t command);
+  \r \r \r
 /*! \brief writer_free - destroy a writer object.\r
  *\r
  * \param ptr          A pointer to the writer object to destroy.\r
@@ -51,18 +50,13 @@ writer_new(command_t command);
  *                                     [EINVAL] if the writer object pointed to by the parameter ptr is invalid.\r
  *                                     \r
  *                                     \r
- */\r
-int\r
-writer_free(writer_t* ptr);\r
-\r
-void\r
-writer_write(writer_t writer);\r
-\r
-void\r
-writer_wait(writer_t writer);\r
-\r
+ */ \r
+  int \r writer_free(writer_t * ptr);
+  \r \r void \r writer_write(writer_t writer);
+  \r \r void \r writer_wait(writer_t writer);
+  \r \r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__WRITER_H */\r
+#endif  /* !__WRITER_H */\r
index 843bbe4..19db395 100644 (file)
@@ -3,11 +3,12 @@
 \r
 #include <com.h>\r
 #include <errno.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 #define ECMDTIMEDOUT           ((int)102)      /* Command timed out                                                                                                            */\r
 #define ECMDNOTFOUND           ((int)107)      /* the command is not found                                                                                                     */\r
 #define EEXITCODENOTMATCH      ((int)108)      /* the exit codes don't match                                                                                           */\r
@@ -24,21 +25,16 @@ extern "C" {
 #define EINCLUDENOTFOUND       ((int)125)      /* the include file specified by a metacommand is not found                                     */\r
 #define ESUFFIXTOOLONG         ((int)126)      /* the suffix is too long                                                                                                       */\r
 #define EINVCMDLINE                    ((int)139) /* invalid command line                                                                                                              */\r
-\r
+  \r
 #ifndef EALREADY\r
 #define EALREADY                       ((int)131)\r
-#endif\r
-\r
-const char*\r
-error_get_at(int pos, int* code);\r
-\r
-const char*\r
-error_to_string(int errcode, int kind);\r
-\r
+#endif  /* \r */
+  \r const char *\r error_get_at(int pos, int *code);
+  \r\rconst char *\r error_to_string(int errcode, int kind);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* !__XERRNO_H */\r
+} \r
+#endif  /* \r */
+\r\r
+#endif  /* !__XERRNO_H */\r
 \r
index d4d42da..2a562e1 100644 (file)
 \r
 #include <signal.h>\r
 #include <com.h>\r
-\r
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r
 #ifdef _XBT_WIN32\r
-\r
+  \r
 /* terminal line hangup                                                        */ \r
 #ifndef SIGHUP\r
 #define SIGHUP         1\r
-#endif \r
-\r
-/* interrupt program                                                   */\r
+#endif  /* \r */
+  \r
+/* interrupt program                                                   */ \r
 #ifndef        SIGINT\r
 #define SIGINT         2\r
-#endif\r
-\r
-/* quit program                                                                        */\r
+#endif  /* \r */
+  \r
+/* quit program                                                                        */ \r
 #ifndef SIGQUIT\r
 #define SIGQUIT                3\r
-#endif\r
-\r
-/* illegal instruction                                                 */\r
+#endif  /* \r */
+  \r
+/* illegal instruction                                                 */ \r
 #ifndef        SIGILL\r
 #define SIGILL         4\r
-#endif\r
-\r
-/* trace trap                                                                  */\r
+#endif  /* \r */
+  \r
+/* trace trap                                                                  */ \r
 #ifndef        SIGTRAP\r
 #define SIGTRAP                5\r
-#endif\r
-\r
-/* abnormal termination triggered by abort call        */\r
+#endif  /* \r */
+  \r
+/* abnormal termination triggered by abort call        */ \r
 #ifndef        SIGABRT\r
 #define SIGABRT                6\r
-#endif\r
-\r
-/* floating point exception                                            */\r
+#endif  /* \r */
+  \r
+/* floating point exception                                            */ \r
 #ifndef        SIGFPE\r
 #define SIGFPE         8\r
-#endif\r
-\r
-/* kill program                                                                        */\r
+#endif  /* \r */
+  \r
+/* kill program                                                                        */ \r
 #ifndef        SIGKILL\r
 #define SIGKILL                9\r
-#endif\r
-\r
-/* bus error                                                                   */\r
+#endif  /* \r */
+  \r
+/* bus error                                                                   */ \r
 #ifndef SIGBUS\r
 #define SIGBUS         10\r
-#endif\r
-\r
-/* segment violation                                                   */\r
+#endif  /* \r */
+  \r
+/* segment violation                                                   */ \r
 #ifndef        SIGSEGV\r
 #define SIGSEGV                11\r
-#endif\r
-\r
-/* non-existent system call invoked                            */\r
+#endif  /* \r */
+  \r
+/* non-existent system call invoked                            */ \r
 #ifndef SIGSYS\r
 #define SIGSYS         12\r
-#endif\r
-\r
+#endif  /* \r */
+  \r
 /* write on a pipe with no reader                              */ \r
 #ifndef SIGPIPE\r
 #define SIGPIPE                13\r
-#endif\r
-\r
-/* real-time timer expired                                             */\r
+#endif  /* \r */
+  \r
+/* real-time timer expired                                             */ \r
 #ifndef SIGALRM\r
 #define SIGALRM                14\r
-#endif\r
-\r
-/* software termination signal from kill                       */\r
+#endif  /* \r */
+  \r
+/* software termination signal from kill                       */ \r
 #ifdef SIGTERM\r
 #define SIGTERM                15\r
-#endif\r
-\r
-/* urgent condition present on socket                          */\r
+#endif  /* \r */
+  \r
+/* urgent condition present on socket                          */ \r
 #ifndef SIGURG\r
 #define SIGURG         16\r
-#endif\r
-\r
-/* stop (cannot be caught orignored)                           */\r
+#endif  /* \r */
+  \r
+/* stop (cannot be caught orignored)                           */ \r
 #ifndef SIGSTOP\r
 #define SIGSTOP                17\r
-#endif\r
-\r
-/* stop signal generated from keyboard                         */\r
+#endif  /* \r */
+  \r
+/* stop signal generated from keyboard                         */ \r
 #ifndef SIGTSTP\r
 #define SIGTSTP                18\r
-#endif\r
-\r
-/* continue after stop                                                         */\r
+#endif  /* \r */
+  \r
+/* continue after stop                                                         */ \r
 #ifndef SIGCONT\r
 #define SIGCONT                19\r
-#endif\r
-\r
+#endif  /* \r */
+  \r
 /* child status has changed                                                    */ \r
 #ifndef SIGCHLD\r
 #define SIGCHLD                20\r
-#endif\r
-\r
-/* background read attempted from control terminal     */\r
+#endif  /* \r */
+  \r
+/* background read attempted from control terminal     */ \r
 #ifndef SIGTTIN\r
 #define SIGTTIN                21\r
-#endif\r
-\r
-/* background write attempted to control terminal      */\r
+#endif  /* \r */
+  \r
+/* background write attempted to control terminal      */ \r
 #ifndef SIGTTOU\r
 #define SIGTTOU                22\r
-#endif\r
-\r
-/* I/O is possible on a descriptor see fcntl(2))       */\r
+#endif  /* \r */
+  \r
+/* I/O is possible on a descriptor see fcntl(2))       */ \r
 #ifndef SIGIO\r
 #define SIGIO          23\r
-#endif\r
-\r
-/* cpu time limit exceeded (see setrlimit(2))          */\r
+#endif  /* \r */
+  \r
+/* cpu time limit exceeded (see setrlimit(2))          */ \r
 #ifndef SIGXCPU\r
 #define SIGXCPU                24\r
-#endif\r
-\r
-/* file size limit exceeded (see setrlimit(2))         */\r
+#endif  /* \r */
+  \r
+/* file size limit exceeded (see setrlimit(2))         */ \r
 #ifndef SIGXFSZ\r
 #define SIGXFSZ                25\r
-#endif\r
-\r
-/* virtual time alarm (see setitimer(2))                       */\r
+#endif  /* \r */
+  \r
+/* virtual time alarm (see setitimer(2))                       */ \r
 #ifndef SIGVTALRM\r
 #define SIGVTALRM      26\r
-#endif\r
-\r
-/* profiling timer alarm (see setitimer(2))                    */\r
+#endif  /* \r */
+  \r
+/* profiling timer alarm (see setitimer(2))                    */ \r
 #ifndef SIGPROF\r
 #define SIGPROF                27\r
-#endif\r
-\r
-/*  window size change                                                         */\r
+#endif  /* \r */
+  \r
+/*  window size change                                                         */ \r
 #ifndef SIGWINCH\r
 #define SIGWINCH       28\r
-#endif\r
-\r
-/* user defined signal 1                                                       */\r
+#endif  /* \r */
+  \r
+/* user defined signal 1                                                       */ \r
 #ifndef SIGUSR1\r
 #define SIGUSR1                30\r
-#endif\r
-\r
-/* user defined signal 2                                                       */\r
+#endif  /* \r */
+  \r
+/* user defined signal 2                                                       */ \r
 #ifndef SIGUSR2\r
 #define SIGUSR2                31\r
-#endif\r
-\r
-\r
-int\r
-is_an_unhandled_exception(DWORD exit_code);\r
-\r
+#endif  /* \r */
+  \r \r int \r is_an_unhandled_exception(DWORD exit_code);
+  \r \r
 /*  \r
  *return a non-zero value if status was returned for a child process that terminated normally. \r
- */\r
+ */ \r
 #define WIFEXITED(__status)            !is_an_unhandled_exception((__status))\r
-\r
+  \r
 /* if the value of WIFEXITED(__status) is non-zero, this macro evaluates the value the child \r
  * process returned from main().\r
- */\r
+ */ \r
 #define WEXITSTATUS(__status)  (__status)\r
-\r
+  \r
 /* return a non-zero value if status was returned for a child process that terminated due to the \r
  * receipt of a signal that was not caught \r
- */\r
+ */ \r
 #define WIFSIGNALED(__status)  is_an_unhandled_exception((__status))\r
-\r
+  \r
 /* if the value of WIFSIGNALED(__status) is non-zero, this macro evaluates to the number of the \r
  * signal that caused the termination of the child process.\r
- */\r
+ */ \r
 #define WTERMSIG(__status)             (__status)\r
-\r
-#endif /* _XBT_WIN32 */\r
-\r
-\r
+  \r
+#endif  /* _XBT_WIN32 */\r
+  \r \r
 #ifdef _XBT_WIN32\r
-const char* \r
-signal_name(DWORD got, const char* expected);\r
-#else\r
-const char* \r
-signal_name(unsigned int got, char *expected);\r
-#endif\r
-\r
-\r
-int\r
-sig_exists(const char* sig_name);\r
-\r
+  const char *\r signal_name(DWORD got, const char *expected);
+  \r
+#else   /* \r */
+  const char *\r signal_name(unsigned int got, char *expected);
+  \r
+#endif  /* \r */
+  \r\rint \r sig_exists(const char *sig_name);
+  \r\r
 #ifdef __cplusplus\r
-}\r
-#endif\r
+} \r
+#endif  /* \r */
 \r
-#endif /* !__XSIGNAL_H */\r
+#endif  /* !__XSIGNAL_H */\r
index 677979f..d43adf1 100644 (file)
  *             This file contains all the definitions of the functions related with\r
  *             the tesh command type.\r
  *\r
- */\r
+ */  \r
 #include <unit.h>\r
 #include <command.h>\r
 #include <context.h>\r
 #include <writer.h>\r
 #include <reader.h>\r
 #include <timer.h>\r
-\r
+    \r
 #ifndef _XBT_WIN32\r
 #include <sys/types.h>\r
 #include <sys/wait.h>\r
 #include <sys/stat.h>\r
 #include <unistd.h>\r
-#else\r
-char *\r
-tow32cmd(const char* cmd)\r
-{\r
-       static char w32cmd[PATH_MAX + 1] = {0};\r
-       char cmd_buf[PATH_MAX + 1] = {0};\r
-    size_t i,j, len;\r
-\r
-    if(!cmd)\r
-    {\r
-       errno = EINVAL;\r
-               return NULL;\r
-       }\r
-\r
-       /* TODO : if ~*/\r
-       if(cmd[0] != '.')\r
-       {\r
-               strcpy(w32cmd, cmd);\r
-               return w32cmd;\r
-       }\r
-\r
-       i = j = 0;\r
-       len = strlen(cmd);\r
-\r
-       while(i < len)\r
-       {\r
-               if(cmd[i] != ' ' && cmd[i] != '\t' && cmd[i] != '>')\r
-                       cmd_buf[j++] = cmd[i];\r
-               else\r
-                       break;\r
-\r
-               i++;\r
-       }\r
-\r
-   _fullpath(w32cmd, cmd_buf, sizeof(w32cmd));\r
-\r
-   if(!strstr(w32cmd, ".exe"))\r
-               strcat(w32cmd, ".exe ");\r
-\r
-   strcat(w32cmd, cmd + i);\r
-\r
-\r
-   /*printf("w32cmd : %s", w32cmd);*/\r
-\r
-   return w32cmd;\r
-}\r
-#endif\r
-\r
+#else   /* \r */
+char *\r tow32cmd(const char *cmd) \r
+{
+  \rstatic char w32cmd[PATH_MAX + 1] = { 0 };
+  \rchar cmd_buf[PATH_MAX + 1] = { 0 };
+  \rsize_t i, j, len;
+  \r\rif (!cmd)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\r
+      /* TODO : if ~ */ \r
+      if (cmd[0] != '.')
+    \r {
+    \rstrcpy(w32cmd, cmd);
+    \rreturn w32cmd;
+    \r}
+  \r\ri = j = 0;
+  \rlen = strlen(cmd);
+  \r\rwhile (i < len)
+    \r {
+    \rif (cmd[i] != ' ' && cmd[i] != '\t' && cmd[i] != '>')
+      \rcmd_buf[j++] = cmd[i];
+    \r
+    else
+      \rbreak;
+    \r\ri++;
+    \r}
+  \r\r_fullpath(w32cmd, cmd_buf, sizeof(w32cmd));
+  \r\rif (!strstr(w32cmd, ".exe"))
+    \rstrcat(w32cmd, ".exe ");
+  \r\rstrcat(w32cmd, cmd + i);
+  \r\r\r
+      /*printf("w32cmd : %s", w32cmd); */ \r
+      \rreturn w32cmd;
+\r}
+
+\r
+#endif  /* \r */
+    \r
 #include <com.h>\r
-\r
+    \r
 #include <xsignal.h>\r
-\r
+    \r
 #include <is_cmd.h>\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-static void*\r
-command_start(void* p);\r
-\r
-\r
-command_t\r
-command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex)\r
-{\r
-       command_t command;\r
-\r
-       command = xbt_new0(s_command_t, 1);\r
-\r
-       /* get the context of the execution of the command */\r
-       if(!(command->context = context_dup(context)))\r
-       {\r
-               free(command);\r
-               return NULL;\r
-       }\r
-\r
-       /* the exit code of the command is indefinite */\r
-       command->exit_code = INDEFINITE;\r
-\r
-       /* the signal of the command is indefinite */\r
-       command->signal = INDEFINITE_SIGNAL;\r
-\r
-       command->failed = 0;\r
-       command->interrupted = 0;\r
-\r
-       /* the mutex used to safetly access to the command unit properties */\r
-       command->mutex = mutex;\r
-\r
-       command->output = xbt_strbuff_new();\r
-\r
-       command->pid = INDEFINITE_PID;\r
-\r
-       command->stat_val = -1;\r
-\r
-       /* set the unit of the command */\r
-       command->root = unit->root ? unit->root : unit;\r
-       command->unit = unit;\r
-\r
-       /* all the commands are runned in a thread */\r
-       command->thread = NULL;\r
-\r
-       command->successeded = 0;\r
-\r
-       command->reader = reader_new(command);\r
-\r
-       if(context->input->used)\r
-               command->writer = writer_new(command);\r
-       else\r
-               command->writer = NULL;\r
-\r
-       if(context->timeout != INDEFINITE)\r
-               command->timer = timer_new(command);\r
-       else\r
-               command->timer = NULL;\r
-\r
-       command->status = cs_initialized;\r
-       command->reason = csr_unknown;\r
-\r
-       command->stdin_fd = INDEFINITE_FD;\r
-       command->stdout_fd = INDEFINITE_FD;\r
-\r
-\r
-       /* register the command */\r
-       xbt_os_mutex_acquire(mutex);\r
-\r
-       xbt_dynar_push(unit->commands, &command);\r
-       command->root->cmd_nb++;\r
-       xbt_os_mutex_release(mutex);\r
-\r
-       #ifndef _XBT_WIN32\r
-       command->killed = 0;\r
-       command->execlp_errno = 0;\r
-       #endif\r
-\r
-\r
-       return command;\r
-}\r
-\r
-int\r
-command_run(command_t command)\r
-{\r
-       if(!silent_flag && !interrupted)\r
-               INFO2("[%s] %s",command->context->pos, command->context->command_line);\r
-\r
-       if(!just_print_flag)\r
-       {\r
-               if(!interrupted)\r
-               {\r
-                       /* start the command in a thread*/\r
-                       if(command->context->async)\r
-                       {\r
-                               command->thread = xbt_os_thread_create("", command_start, command);\r
-\r
-                       }\r
-                       else\r
-                       {\r
-                               /* start the command in the main thread */\r
-                               command_start(command);\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       command_interrupt(command);\r
-               }\r
-\r
-\r
-       }\r
-\r
-       return 0;\r
-\r
-}\r
-\r
-static void*\r
-command_start(void* p)\r
-{\r
-       command_t command = (command_t)p;\r
-       unit_t root = command->root;\r
-\r
-       /* the command is started */\r
-       command->status = cs_started;\r
-\r
-       /* increment the number of started commands of the unit */\r
-       xbt_os_mutex_acquire(command->mutex);\r
-       (root->started_cmd_nb)++;\r
-       xbt_os_mutex_release(command->mutex);\r
-\r
-       /* execute the command of the test */\r
-\r
-       #ifndef _XBT_WIN32\r
-       command_exec(command, command->context->command_line);\r
-       #else\r
-       /* play the translated command line on Windows */\r
-       command_exec(command, command->context->t_command_line);\r
-       #endif\r
-\r
-       if(cs_in_progress == command->status)\r
-       {\r
-               /* wait the process if it is in progress */\r
-               command_wait(command);\r
-\r
-               if(cs_failed != command->status && cs_interrupted != command->status)\r
-                       command_check(command);\r
-       }\r
-\r
-       xbt_os_mutex_acquire(command->mutex);\r
-\r
-       /* if it's the last command of the root unit */\r
-       if(!root->interrupted && root->parsed && (root->started_cmd_nb == (root->failed_cmd_nb + root->interrupted_cmd_nb + root->successeded_cmd_nb)))\r
-       {\r
-               /* first release the mutex */\r
-               root->released = 1;\r
-               xbt_os_mutex_release(command->mutex);\r
-               /* the last command release the unit */\r
-               xbt_os_sem_release(root->sem);\r
-       }\r
-       else\r
-               xbt_os_mutex_release(command->mutex);\r
-\r
-\r
-       /* wait the end of the timer, the reader and the writer */\r
-       if(command->timer && command->timer->thread)\r
-               timer_wait(command->timer);\r
-\r
-       /* wait the end of the writer */\r
-       if(command->writer && command->writer->thread)\r
-               writer_wait(command->writer);\r
-\r
-       /* wait the end of the reader */\r
-       if(command->reader && command->reader->thread)\r
-               reader_wait(command->reader);\r
-\r
-\r
-\r
-       return NULL;\r
-}\r
-\r
+    \rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rstatic void *\r command_start(void *p);
+\r\r\rcommand_t \r
+command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex) \r
+{
+  \rcommand_t command;
+  \r\rcommand = xbt_new0(s_command_t, 1);
+  \r\r
+      /* get the context of the execution of the command */ \r
+      if (!(command->context = context_dup(context)))
+    \r {
+    \rfree(command);
+    \rreturn NULL;
+    \r}
+  \r\r
+      /* the exit code of the command is indefinite */ \r
+      command->exit_code = INDEFINITE;
+  \r\r
+      /* the signal of the command is indefinite */ \r
+      command->signal = INDEFINITE_SIGNAL;
+  \r\rcommand->failed = 0;
+  \rcommand->interrupted = 0;
+  \r\r
+      /* the mutex used to safetly access to the command unit properties */ \r
+      command->mutex = mutex;
+  \r\rcommand->output = xbt_strbuff_new();
+  \r\rcommand->pid = INDEFINITE_PID;
+  \r\rcommand->stat_val = -1;
+  \r\r
+      /* set the unit of the command */ \r
+      command->root = unit->root ? unit->root : unit;
+  \rcommand->unit = unit;
+  \r\r
+      /* all the commands are runned in a thread */ \r
+      command->thread = NULL;
+  \r\rcommand->successeded = 0;
+  \r\rcommand->reader = reader_new(command);
+  \r\rif (context->input->used)
+    \rcommand->writer = writer_new(command);
+  \r
+  else
+    \rcommand->writer = NULL;
+  \r\rif (context->timeout != INDEFINITE)
+    \rcommand->timer = timer_new(command);
+  \r
+  else
+    \rcommand->timer = NULL;
+  \r\rcommand->status = cs_initialized;
+  \rcommand->reason = csr_unknown;
+  \r\rcommand->stdin_fd = INDEFINITE_FD;
+  \rcommand->stdout_fd = INDEFINITE_FD;
+  \r\r\r
+      /* register the command */ \r
+      xbt_os_mutex_acquire(mutex);
+  \r\rxbt_dynar_push(unit->commands, &command);
+  \rcommand->root->cmd_nb++;
+  \rxbt_os_mutex_release(mutex);
+  \r\r
+#ifndef _XBT_WIN32\r
+      command->killed = 0;
+  \rcommand->execlp_errno = 0;
+  \r
+#endif  /* \r */
+      \r\rreturn command;
+\r}
+
+\r\rint \r command_run(command_t command) \r
+{
+  \rif (!silent_flag && !interrupted)
+    \rINFO2("[%s] %s", command->context->pos,
+           command->context->command_line);
+  \r\rif (!just_print_flag)
+    \r {
+    \rif (!interrupted)
+      \r {
+      \r
+          /* start the command in a thread */ \r
+          if (command->context->async)
+        \r {
+        \rcommand->thread =
+            xbt_os_thread_create("", command_start, command);
+        \r\r}
+      \r
+      else
+        \r {
+        \r
+            /* start the command in the main thread */ \r
+            command_start(command);
+        \r}
+      \r}
+    \r
+    else
+      \r {
+      \rcommand_interrupt(command);
+      \r}
+    \r\r\r}
+  \r\rreturn 0;
+\r\r}
+
+\r\rstatic void *\r command_start(void *p) \r
+{
+  \rcommand_t command = (command_t) p;
+  \runit_t root = command->root;
+  \r\r
+      /* the command is started */ \r
+      command->status = cs_started;
+  \r\r
+      /* increment the number of started commands of the unit */ \r
+      xbt_os_mutex_acquire(command->mutex);
+  \r(root->started_cmd_nb)++;
+  \rxbt_os_mutex_release(command->mutex);
+  \r\r
+      /* execute the command of the test */ \r
+      \r
+#ifndef _XBT_WIN32\r
+      command_exec(command, command->context->command_line);
+  \r
+#else   /* \r */
+      /* play the translated command line on Windows */ \r
+      command_exec(command, command->context->t_command_line);
+  \r
+#endif  /* \r */
+      \rif (cs_in_progress == command->status)
+    \r {
+    \r
+        /* wait the process if it is in progress */ \r
+        command_wait(command);
+    \r\rif (cs_failed != command->status
+          && cs_interrupted != command->status)
+      \rcommand_check(command);
+    \r}
+  \r\rxbt_os_mutex_acquire(command->mutex);
+  \r\r
+      /* if it's the last command of the root unit */ \r
+      if (!root->interrupted && root->parsed
+          && (root->started_cmd_nb ==
+              (root->failed_cmd_nb + root->interrupted_cmd_nb +
+               root->successeded_cmd_nb)))
+    \r {
+    \r
+        /* first release the mutex */ \r
+        root->released = 1;
+    \rxbt_os_mutex_release(command->mutex);
+    \r
+        /* the last command release the unit */ \r
+        xbt_os_sem_release(root->sem);
+    \r}
+  \r
+  else
+    \rxbt_os_mutex_release(command->mutex);
+  \r\r\r
+      /* wait the end of the timer, the reader and the writer */ \r
+      if (command->timer && command->timer->thread)
+    \rtimer_wait(command->timer);
+  \r\r
+      /* wait the end of the writer */ \r
+      if (command->writer && command->writer->thread)
+    \rwriter_wait(command->writer);
+  \r\r
+      /* wait the end of the reader */ \r
+      if (command->reader && command->reader->thread)
+    \rreader_wait(command->reader);
+  \r\r\r\rreturn NULL;
+\r}
+
+\r\r
 #ifdef _XBT_WIN32\r
-\r
+    \r
 #ifndef BUFSIZE\r
 #define BUFSIZE        4096\r
-#endif\r
-void\r
-command_exec(command_t command, const char* command_line)\r
-{\r
-\r
-       STARTUPINFO si = {0};                                   /* contains the informations about the child process windows*/\r
-       PROCESS_INFORMATION pi = {0};                   /* contains child process informations                                          */\r
-       SECURITY_ATTRIBUTES sa = {0};                   /* contains the security descriptor for the pipe handles        */\r
-       HANDLE child_stdin_handle[2] = {NULL};  /* child_stdin_handle[1]        <-> stdout of the child process */\r
-       HANDLE child_stdout_handle[2] = {NULL}; /* child_stdout_handle[0]       <-> stdin of the child process  */\r
-       HANDLE child_stderr = NULL;\r
-\r
-\r
-       sa.nLength = sizeof(SECURITY_ATTRIBUTES);\r
-    sa.lpSecurityDescriptor = NULL;                    /* use default security for the pipe handles                            */\r
-\r
-       sa.bInheritHandle = TRUE;                               /* the pipe handles can be inherited                                            */\r
-\r
-       if(!CreatePipe(&(child_stdin_handle[0]),&(child_stdin_handle[1]),&sa,0))\r
-    {\r
-               ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
-\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-               command->failed = 1;\r
-               command->status = cs_failed;\r
-\r
-               return;\r
-    }\r
-\r
-\r
-       if(!DuplicateHandle(GetCurrentProcess(),(child_stdin_handle[1]),GetCurrentProcess(),&(child_stderr),0,TRUE,DUPLICATE_SAME_ACCESS))\r
-    {\r
-               ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
-\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-               CloseHandle(child_stdin_handle[0]);\r
-               CloseHandle(child_stdin_handle[1]);\r
-\r
-               command->failed = 1;\r
-               command->status = cs_failed;\r
-\r
-               return;\r
-    }\r
-\r
-       if(!CreatePipe(&(child_stdout_handle[0]),&(child_stdout_handle[1]),&sa,0))\r
-    {\r
-               ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-               CloseHandle(child_stdout_handle[0]);\r
-               CloseHandle(child_stdout_handle[1]);\r
-               CloseHandle(child_stdin_handle[0]);\r
-               CloseHandle(child_stdin_handle[1]);\r
-\r
-               command->failed = 1;\r
-               command->status = cs_failed;\r
-\r
-               return;\r
-    }\r
-\r
-       /* Read handle for read operations on the child std output. */\r
-       if(!DuplicateHandle(GetCurrentProcess(),(child_stdin_handle[0]),GetCurrentProcess(),&(command->stdout_fd),0,FALSE, DUPLICATE_SAME_ACCESS))\r
-    {\r
-               CloseHandle(child_stdout_handle[0]);\r
-               CloseHandle(child_stdout_handle[1]);\r
-               CloseHandle(child_stdin_handle[0]);\r
-               CloseHandle(child_stdin_handle[1]);\r
-\r
-               command->failed = 1;\r
-               command->status = cs_failed;\r
-\r
-               ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-               return;\r
-       }\r
-\r
-\r
-       /* Write handle for write operations on the child std input. */\r
-       if(!DuplicateHandle(GetCurrentProcess(),(child_stdout_handle[1]),GetCurrentProcess(),&(command->stdin_fd), 0,FALSE,DUPLICATE_SAME_ACCESS))\r
-    {\r
-               CloseHandle(child_stdout_handle[0]);\r
-               CloseHandle(child_stdout_handle[1]);\r
-               CloseHandle(child_stdin_handle[0]);\r
-               CloseHandle(child_stdin_handle[1]);\r
-\r
-               command->failed = 1;\r
-               command->status = cs_failed;\r
-\r
-               ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
-\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-               return;\r
-    }\r
-\r
-       CloseHandle(child_stdin_handle[0]);\r
-       CloseHandle(child_stdout_handle[1]);\r
-\r
-\r
-       if(command->timer)\r
-       {\r
-               /* launch the timer */\r
-               timer_time(command->timer);\r
-       }\r
-\r
-       if(command->reader)\r
-       {\r
-               /* launch the reader */\r
-               reader_read(command->reader);\r
-       }\r
-\r
-\r
-       if(command->writer)\r
-       {\r
-               /* launch the writer */\r
-               writer_write(command->writer);\r
-       }\r
-\r
-       /* if there is a reader wait for its starting */\r
-       if(command->reader)\r
-               xbt_os_sem_acquire(command->reader->started);\r
-\r
-       /* if there is a reader wait for its ending */\r
-       if(command->writer)\r
-               xbt_os_sem_acquire(command->writer->written);\r
-\r
-       /* if there is a reader wait for its starting */\r
-       if(command->timer)\r
-               xbt_os_sem_acquire(command->timer->started);\r
-\r
-    si.cb = sizeof(STARTUPINFO);\r
-\r
-       si.dwFlags |= STARTF_USESTDHANDLES;\r
-       si.hStdOutput = child_stdin_handle[1];\r
-       si.hStdInput  = child_stdout_handle[0];\r
-       si.hStdError  = child_stderr;\r
-\r
-       /* launch the process */\r
-       if(!CreateProcess(\r
-                                               NULL,\r
-                                               tow32cmd(command_line),\r
-                                               NULL,\r
-                                               NULL,\r
-                                               TRUE,\r
-                                               CREATE_NO_WINDOW,\r
-                                               NULL,\r
-                                               NULL,\r
-                                               &si,\r
-                                               &pi)\r
-       )\r
-       {\r
-\r
-               if(ERROR_FILE_NOT_FOUND == GetLastError())\r
-               {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(ECMDNOTFOUND, 1));\r
-                       unit_set_error(command->unit, ECMDNOTFOUND, 1, command->context->pos);\r
-                       command_handle_failure(command, csr_command_not_found);\r
-               }\r
-               else\r
-               {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
-\r
-                       unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-                       command_handle_failure(command, csr_create_process_function_failure);\r
-               }\r
-\r
-    }\r
-       else\r
-       {\r
-               /* the command is running */\r
-               command->status = cs_in_progress;\r
-\r
-               /* save the pid of the command */\r
-               command->pid = pi.hProcess;\r
-\r
-               /* close non used thread handle */\r
-               CloseHandle(pi.hThread);\r
-\r
-       }\r
-\r
-\r
-       /* close non used handles */\r
-       CloseHandle(child_stdin_handle[1]);\r
-    CloseHandle(child_stdout_handle[0]);\r
-       CloseHandle(child_stderr);\r
-\r
-\r
-}\r
-#else\r
-void\r
-command_exec(command_t command, const char* command_line)\r
-{\r
-       int child_stdin_fd[2] ;\r
-       int child_stdout_fd[2];\r
-\r
-       #ifdef __CHKCMD\r
-       int rv = is_cmd(command->unit->runner->path, command->unit->runner->builtin, command_line);\r
-\r
-       if(rv != 0)\r
-       {\r
-\r
-               if(rv == EINVAL)\r
-               {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(rv, 0));\r
-                       unit_set_error(command->unit, rv, 0, command->context->pos);\r
-               }\r
-               else\r
-               {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(rv, 1));\r
-                       unit_set_error(command->unit, rv, 1, command->context->pos);\r
-               }\r
-\r
-               command_handle_failure(command, csr_command_not_found);\r
-\r
-               return;\r
-       }\r
-\r
-       #endif\r
-\r
-\r
-       if(command->writer)\r
-       {\r
-               if(pipe(child_stdin_fd))\r
-               {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
-\r
-                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-\r
-                       command_handle_failure(command, csr_pipe_function_failed);\r
-\r
-\r
-\r
-                       return;\r
-               }\r
-       }\r
-\r
-       if(command->reader)\r
-       {\r
-               if(pipe(child_stdout_fd))\r
-               {\r
-                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
-\r
-                       if(command->writer)\r
-                       {\r
-                               close(child_stdin_fd[0]);\r
-                               close(child_stdin_fd[1]);\r
-                       }\r
-\r
-                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-\r
-                       command_handle_failure(command, csr_pipe_function_failed);\r
-\r
-                       return;\r
-               }\r
-       }\r
-\r
-       if(command->writer)\r
-       {\r
-               if(fcntl(child_stdin_fd[1], F_SETFL, fcntl(child_stdin_fd[1], F_GETFL) | O_NONBLOCK) < 0)\r
-               {\r
-\r
-                       ERROR3("[%s] `%s'  : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
-\r
-                       close(child_stdin_fd[0]);\r
-                       close(child_stdin_fd[1]);\r
-\r
-                       if(command->reader)\r
-                       {\r
-                               close(child_stdout_fd[0]);\r
-                               close(child_stdout_fd[1]);\r
-                       }\r
-\r
-                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-\r
-                       command_handle_failure(command, csr_fcntl_function_failed);\r
-\r
-                       return;\r
-               }\r
-       }\r
-\r
-       /* to write to the child stdin */\r
-       command->stdin_fd = child_stdin_fd[1];\r
-\r
-       /* to read from the child stdout */\r
-       command->stdout_fd = child_stdout_fd[0];\r
-\r
-       /* launch the reader if any*/\r
-       if(command->reader)\r
-               reader_read(command->reader);\r
-\r
-    /* launch the writer if any */\r
-       if(command->writer)\r
-               writer_write(command->writer);\r
-\r
-       /* launch the timer if any */\r
-       if(command->timer)\r
-               timer_time(command->timer);\r
-\r
-       /* if there is a reader wait for its starting */\r
-       if(command->reader)\r
-               xbt_os_sem_acquire(command->reader->started);\r
-\r
-       /* if there is a reader wait for its ending */\r
-       if(command->writer)\r
-               xbt_os_sem_acquire(command->writer->written);\r
-\r
-       /* if there is a reader wait for its starting */\r
-       if(command->timer)\r
-               xbt_os_sem_acquire(command->timer->started);\r
-\r
-       /* update the state of the command, assume it is in progress */\r
-       command->status = cs_in_progress;\r
-\r
-       command->pid= fork();\r
-\r
-       if(command->pid < 0)\r
-       {/* error */\r
-               if(command->writer)\r
-               {\r
-                       close(child_stdin_fd[0]);\r
-                       close(child_stdin_fd[1]);\r
-               }\r
-\r
-               if(command->reader)\r
-               {\r
-                       close(child_stdout_fd[0]);\r
-                       close(child_stdout_fd[1]);\r
-               }\r
-\r
-               ERROR2("[%s] Cannot fork the command `%s'", command->context->pos, command->context->command_line);\r
-               unit_set_error(command->unit, errno, 0, command->context->pos);\r
-               command_handle_failure(command,csr_fork_function_failure);\r
-       }\r
-       else\r
-       {\r
-               if(command->pid)\r
-               {/* father */\r
-\r
-                       /* close unused file descriptors */\r
-                       if(command->writer)\r
-                               close(child_stdin_fd[0]);\r
-\r
-                       if(command->reader)\r
-                               close(child_stdout_fd[1]);\r
-               }\r
-               else\r
-               {/* child */\r
-\r
-                       /* close unused file descriptors */\r
-                       if(command->writer)\r
-                               close(child_stdin_fd[1]);\r
-\r
-                       if(command->reader)\r
-                               close(child_stdout_fd[0]);\r
-\r
-                       if(command->writer)\r
-                       {\r
-                               /* redirect stdin to child_stdin_fd[0] (now fgets(), getchar() ... read from the pipe */\r
-                               if(dup2(child_stdin_fd[0],STDIN_FILENO) < 0)\r
-                               {\r
-                                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
-                                       command->unit->exit_code = errno;\r
-\r
-                                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-                                       command_handle_failure(command,csr_dup2_function_failure);\r
-                               }\r
-\r
-                               /* close the unused file descriptor  */\r
-                               close(child_stdin_fd[0]);\r
-                       }\r
-\r
-                       if(command->reader)\r
-                       {\r
-\r
-                               /* redirect stdout and stderr to child_stdout_fd[1] (now printf(), perror()... write to the pipe */\r
-                               if(dup2(child_stdout_fd[1],STDOUT_FILENO) < 0)\r
-                               {\r
-                                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
-\r
-                                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-                                       command_handle_failure(command, csr_dup2_function_failure);\r
-                               }\r
-\r
-                               if(dup2(child_stdout_fd[1], STDERR_FILENO) < 0)\r
-                               {\r
-                                       ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
-                                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-                                       command_handle_failure(command, csr_dup2_function_failure);\r
-                               }\r
-\r
-                               /* close the unused file descriptor  */\r
-                               close(child_stdout_fd[1]);\r
-                       }\r
-\r
-                       /* launch the command */\r
-                       if(execlp("/bin/sh", "sh", "-c", command->context->command_line, NULL) < 0)\r
-                               command->execlp_errno = errno;\r
-               }\r
-       }\r
-}\r
-#endif\r
-\r
+#endif  /* \r */
+void \r command_exec(command_t command, const char *command_line) \r
+{
+  \r\rSTARTUPINFO si = {
+  0};                           /* contains the informations about the child process windows */
+  \rPROCESS_INFORMATION pi = {
+  0};                           /* contains child process informations                                          */
+  \rSECURITY_ATTRIBUTES sa = {
+  0};                           /* contains the security descriptor for the pipe handles        */
+  \rHANDLE child_stdin_handle[2] = {
+  NULL};                        /* child_stdin_handle[1]        <-> stdout of the child process */
+  \rHANDLE child_stdout_handle[2] = {
+  NULL};                        /* child_stdout_handle[0]       <-> stdin of the child process  */
+  \rHANDLE child_stderr = NULL;
+  \r\r\rsa.nLength = sizeof(SECURITY_ATTRIBUTES);
+  \rsa.lpSecurityDescriptor = NULL;      /* use default security for the pipe handles                            */
+  \r\rsa.bInheritHandle = TRUE;   /* the pipe handles can be inherited                                            */
+  \r\rif (!CreatePipe
+        (&(child_stdin_handle[0]), &(child_stdin_handle[1]), &sa, 0))
+    \r {
+    \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+            command->context->command_line,
+            error_to_string((int) GetLastError(), 0));
+    \r\runit_set_error(command->unit, (int) GetLastError(), 0,
+                     command->context->pos);
+    \r\rcommand->failed = 1;
+    \rcommand->status = cs_failed;
+    \r\rreturn;
+    \r}
+  \r\r\rif (!DuplicateHandle
+         (GetCurrentProcess(), (child_stdin_handle[1]),
+          GetCurrentProcess(), &(child_stderr), 0, TRUE,
+          DUPLICATE_SAME_ACCESS))
+    \r {
+    \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+            command->context->command_line,
+            error_to_string((int) GetLastError(), 0));
+    \r\runit_set_error(command->unit, (int) GetLastError(), 0,
+                     command->context->pos);
+    \r\rCloseHandle(child_stdin_handle[0]);
+    \rCloseHandle(child_stdin_handle[1]);
+    \r\rcommand->failed = 1;
+    \rcommand->status = cs_failed;
+    \r\rreturn;
+    \r}
+  \r\rif (!CreatePipe
+        (&(child_stdout_handle[0]), &(child_stdout_handle[1]), &sa, 0))
+    \r {
+    \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+            command->context->command_line,
+            error_to_string((int) GetLastError(), 0));
+    \runit_set_error(command->unit, (int) GetLastError(), 0,
+                    command->context->pos);
+    \r\rCloseHandle(child_stdout_handle[0]);
+    \rCloseHandle(child_stdout_handle[1]);
+    \rCloseHandle(child_stdin_handle[0]);
+    \rCloseHandle(child_stdin_handle[1]);
+    \r\rcommand->failed = 1;
+    \rcommand->status = cs_failed;
+    \r\rreturn;
+    \r}
+  \r\r
+      /* Read handle for read operations on the child std output. */ \r
+      if (!DuplicateHandle
+          (GetCurrentProcess(), (child_stdin_handle[0]),
+           GetCurrentProcess(), &(command->stdout_fd), 0, FALSE,
+           DUPLICATE_SAME_ACCESS))
+    \r {
+    \rCloseHandle(child_stdout_handle[0]);
+    \rCloseHandle(child_stdout_handle[1]);
+    \rCloseHandle(child_stdin_handle[0]);
+    \rCloseHandle(child_stdin_handle[1]);
+    \r\rcommand->failed = 1;
+    \rcommand->status = cs_failed;
+    \r\rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+             command->context->command_line,
+             error_to_string((int) GetLastError(), 0));
+    \runit_set_error(command->unit, (int) GetLastError(), 0,
+                    command->context->pos);
+    \r\rreturn;
+    \r}
+  \r\r\r
+      /* Write handle for write operations on the child std input. */ \r
+      if (!DuplicateHandle
+          (GetCurrentProcess(), (child_stdout_handle[1]),
+           GetCurrentProcess(), &(command->stdin_fd), 0, FALSE,
+           DUPLICATE_SAME_ACCESS))
+    \r {
+    \rCloseHandle(child_stdout_handle[0]);
+    \rCloseHandle(child_stdout_handle[1]);
+    \rCloseHandle(child_stdin_handle[0]);
+    \rCloseHandle(child_stdin_handle[1]);
+    \r\rcommand->failed = 1;
+    \rcommand->status = cs_failed;
+    \r\rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+             command->context->command_line,
+             error_to_string((int) GetLastError(), 0));
+    \r\runit_set_error(command->unit, (int) GetLastError(), 0,
+                     command->context->pos);
+    \r\rreturn;
+    \r}
+  \r\rCloseHandle(child_stdin_handle[0]);
+  \rCloseHandle(child_stdout_handle[1]);
+  \r\r\rif (command->timer)
+    \r {
+    \r
+        /* launch the timer */ \r
+        timer_time(command->timer);
+    \r}
+  \r\rif (command->reader)
+    \r {
+    \r
+        /* launch the reader */ \r
+        reader_read(command->reader);
+    \r}
+  \r\r\rif (command->writer)
+    \r {
+    \r
+        /* launch the writer */ \r
+        writer_write(command->writer);
+    \r}
+  \r\r
+      /* if there is a reader wait for its starting */ \r
+      if (command->reader)
+    \rxbt_os_sem_acquire(command->reader->started);
+  \r\r
+      /* if there is a reader wait for its ending */ \r
+      if (command->writer)
+    \rxbt_os_sem_acquire(command->writer->written);
+  \r\r
+      /* if there is a reader wait for its starting */ \r
+      if (command->timer)
+    \rxbt_os_sem_acquire(command->timer->started);
+  \r\rsi.cb = sizeof(STARTUPINFO);
+  \r\rsi.dwFlags |= STARTF_USESTDHANDLES;
+  \rsi.hStdOutput = child_stdin_handle[1];
+  \rsi.hStdInput = child_stdout_handle[0];
+  \rsi.hStdError = child_stderr;
+  \r\r
+      /* launch the process */ \r
+      if (!CreateProcess
+          (\rNULL, \rtow32cmd(command_line), \rNULL, \rNULL, \rTRUE,
+           \rCREATE_NO_WINDOW, \rNULL, \rNULL, \r&si, \r&pi) \r)
+    \r {
+    \r\rif (ERROR_FILE_NOT_FOUND == GetLastError())
+      \r {
+      \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+              command->context->command_line, error_to_string(ECMDNOTFOUND,
+                                                              1));
+      \runit_set_error(command->unit, ECMDNOTFOUND, 1,
+                      command->context->pos);
+      \rcommand_handle_failure(command, csr_command_not_found);
+      \r}
+    \r
+    else
+      \r {
+      \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+              command->context->command_line,
+              error_to_string((int) GetLastError(), 0));
+      \r\runit_set_error(command->unit, (int) GetLastError(), 0,
+                       command->context->pos);
+      \rcommand_handle_failure(command,
+                              csr_create_process_function_failure);
+    \r\r\r}
+  \r
+  else
+    \r {
+    \r
+        /* the command is running */ \r
+        command->status = cs_in_progress;
+    \r\r
+        /* save the pid of the command */ \r
+        command->pid = pi.hProcess;
+    \r\r
+        /* close non used thread handle */ \r
+        CloseHandle(pi.hThread);
+    \r\r}
+  \r\r\r
+      /* close non used handles */ \r
+      CloseHandle(child_stdin_handle[1]);
+  \rCloseHandle(child_stdout_handle[0]);
+  \rCloseHandle(child_stderr);
+\r\r\r}
+
+\r
+#else   /* \r */
+void \r command_exec(command_t command, const char *command_line) \r
+{
+  \rint child_stdin_fd[2];
+  \rint child_stdout_fd[2];
+  \r\r
+#ifdef __CHKCMD\r
+  int rv =
+      is_cmd(command->unit->runner->path, command->unit->runner->builtin,
+             command_line);
+  \r\rif (rv != 0)
+    \r {
+    \r\rif (rv == EINVAL)
+      \r {
+      \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+              command->context->command_line, error_to_string(rv, 0));
+      \runit_set_error(command->unit, rv, 0, command->context->pos);
+      \r}
+    \r
+    else
+      \r {
+      \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+              command->context->command_line, error_to_string(rv, 1));
+      \runit_set_error(command->unit, rv, 1, command->context->pos);
+      \r}
+    \r\rcommand_handle_failure(command, csr_command_not_found);
+    \r\rreturn;
+    \r}
+  \r\r
+#endif  /* \r */
+      \r\rif (command->writer)
+    \r {
+    \rif (pipe(child_stdin_fd))
+      \r {
+      \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+              command->context->command_line, error_to_string(errno, 0));
+      \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+      \r\rcommand_handle_failure(command, csr_pipe_function_failed);
+      \r\r\r\rreturn;
+      \r}
+    \r}
+  \r\rif (command->reader)
+    \r {
+    \rif (pipe(child_stdout_fd))
+      \r {
+      \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+              command->context->command_line, error_to_string(errno, 0));
+      \r\rif (command->writer)
+        \r {
+        \rclose(child_stdin_fd[0]);
+        \rclose(child_stdin_fd[1]);
+        \r}
+      \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+      \r\rcommand_handle_failure(command, csr_pipe_function_failed);
+      \r\rreturn;
+      \r}
+    \r}
+  \r\rif (command->writer)
+    \r {
+    \rif (fcntl
+         (child_stdin_fd[1], F_SETFL,
+          fcntl(child_stdin_fd[1], F_GETFL) | O_NONBLOCK) < 0)
+      \r {
+      \r\rERROR3("[%s] `%s'  : NOK (%s)", command->context->pos,
+               command->context->command_line, error_to_string(errno, 0));
+      \r\rclose(child_stdin_fd[0]);
+      \rclose(child_stdin_fd[1]);
+      \r\rif (command->reader)
+        \r {
+        \rclose(child_stdout_fd[0]);
+        \rclose(child_stdout_fd[1]);
+        \r}
+      \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+      \r\rcommand_handle_failure(command, csr_fcntl_function_failed);
+      \r\rreturn;
+      \r}
+    \r}
+  \r\r
+      /* to write to the child stdin */ \r
+      command->stdin_fd = child_stdin_fd[1];
+  \r\r
+      /* to read from the child stdout */ \r
+      command->stdout_fd = child_stdout_fd[0];
+  \r\r
+      /* launch the reader if any */ \r
+      if (command->reader)
+    \rreader_read(command->reader);
+  \r\r
+      /* launch the writer if any */ \r
+      if (command->writer)
+    \rwriter_write(command->writer);
+  \r\r
+      /* launch the timer if any */ \r
+      if (command->timer)
+    \rtimer_time(command->timer);
+  \r\r
+      /* if there is a reader wait for its starting */ \r
+      if (command->reader)
+    \rxbt_os_sem_acquire(command->reader->started);
+  \r\r
+      /* if there is a reader wait for its ending */ \r
+      if (command->writer)
+    \rxbt_os_sem_acquire(command->writer->written);
+  \r\r
+      /* if there is a reader wait for its starting */ \r
+      if (command->timer)
+    \rxbt_os_sem_acquire(command->timer->started);
+  \r\r
+      /* update the state of the command, assume it is in progress */ \r
+      command->status = cs_in_progress;
+  \r\rcommand->pid = fork();
+  \r\rif (command->pid < 0)
+    \r {                         /* error */
+    \rif (command->writer)
+      \r {
+      \rclose(child_stdin_fd[0]);
+      \rclose(child_stdin_fd[1]);
+      \r}
+    \r\rif (command->reader)
+      \r {
+      \rclose(child_stdout_fd[0]);
+      \rclose(child_stdout_fd[1]);
+      \r}
+    \r\rERROR2("[%s] Cannot fork the command `%s'", command->context->pos,
+             command->context->command_line);
+    \runit_set_error(command->unit, errno, 0, command->context->pos);
+    \rcommand_handle_failure(command, csr_fork_function_failure);
+    \r}
+  \r
+  else
+    \r {
+    \rif (command->pid)
+      \r {                       /* father */
+      \r\r
+          /* close unused file descriptors */ \r
+          if (command->writer)
+        \rclose(child_stdin_fd[0]);
+      \r\rif (command->reader)
+        \rclose(child_stdout_fd[1]);
+      \r}
+    \r
+    else
+      \r {                       /* child */
+      \r\r
+          /* close unused file descriptors */ \r
+          if (command->writer)
+        \rclose(child_stdin_fd[1]);
+      \r\rif (command->reader)
+        \rclose(child_stdout_fd[0]);
+      \r\rif (command->writer)
+        \r {
+        \r
+            /* redirect stdin to child_stdin_fd[0] (now fgets(), getchar() ... read from the pipe */ \r
+            if (dup2(child_stdin_fd[0], STDIN_FILENO) < 0)
+          \r {
+          \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+                  command->context->command_line, error_to_string(errno,
+                                                                  0));
+          \rcommand->unit->exit_code = errno;
+          \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+          \rcommand_handle_failure(command, csr_dup2_function_failure);
+          \r}
+        \r\r
+            /* close the unused file descriptor  */ \r
+            close(child_stdin_fd[0]);
+        \r}
+      \r\rif (command->reader)
+        \r {
+        \r\r
+            /* redirect stdout and stderr to child_stdout_fd[1] (now printf(), perror()... write to the pipe */ \r
+            if (dup2(child_stdout_fd[1], STDOUT_FILENO) < 0)
+          \r {
+          \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+                  command->context->command_line, error_to_string(errno,
+                                                                  0));
+          \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+          \rcommand_handle_failure(command, csr_dup2_function_failure);
+          \r}
+        \r\rif (dup2(child_stdout_fd[1], STDERR_FILENO) < 0)
+          \r {
+          \rERROR3("[%s] `%s' : NOK (%s)", command->context->pos,
+                  command->context->command_line, error_to_string(errno,
+                                                                  0));
+          \runit_set_error(command->unit, errno, 0, command->context->pos);
+          \rcommand_handle_failure(command, csr_dup2_function_failure);
+          \r}
+        \r\r
+            /* close the unused file descriptor  */ \r
+            close(child_stdout_fd[1]);
+        \r}
+      \r\r
+          /* launch the command */ \r
+          if (execlp
+              ("/bin/sh", "sh", "-c", command->context->command_line,
+               NULL) < 0)
+        \rcommand->execlp_errno = errno;
+      \r}
+    \r}
+\r}
+
+\r
+#endif  /* \r */
+    \r
 #ifdef _XBT_WIN32\r
-void\r
-command_wait(command_t command)\r
-{\r
-       /* wait for the command terminaison */\r
-       DWORD rv;\r
-\r
-       if(WAIT_FAILED == WaitForSingleObject(command->pid, INFINITE))\r
-       {\r
-               ERROR2("[%s] Cannot wait for the child`%s'", command->context->pos, command->context->command_line);\r
-\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-               command_handle_failure(command, csr_wait_failure );\r
-               /* TODO : see for the interruption      */\r
-       }\r
-       else\r
-       {\r
-               /* don't take care of the timer or the writer or the reader failue */\r
-               if(cs_failed != command->status && cs_interrupted != command->status)\r
-               {\r
-                       if(!GetExitCodeProcess(command->pid,&rv))\r
-                       {\r
-                               ERROR2("[%s] Cannot get the exit code of the process `%s'",command->context->pos, command->context->command_line);\r
-\r
-                               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-\r
-                               command_handle_failure(command, csr_get_exit_code_process_function_failure );\r
-                       }\r
-                       else\r
-                               command->stat_val = command->exit_code = rv;\r
-               }\r
-       }\r
-}\r
-#else\r
-void\r
-command_wait(command_t command)\r
-{\r
-       if(!command->execlp_errno)\r
-       {\r
-               /* let this thread wait for the child so that the main thread can detect the timeout without blocking on the wait */\r
-               int pid = waitpid(command->pid, &(command->stat_val), 0);\r
-\r
-               if(pid != command->pid)\r
-               {\r
-                       ERROR2("[%s] Cannot wait for the child`%s'", command->context->pos, command->context->command_line);\r
-\r
-                       unit_set_error(command->unit, errno, 0, command->context->pos);\r
-\r
-                       command_handle_failure(command, csr_waitpid_function_failure);\r
-               }\r
-               else\r
-               {\r
-                       if(WIFEXITED(command->stat_val))\r
-                               command->exit_code = WEXITSTATUS(command->stat_val);\r
-               }\r
-       }\r
-       else\r
-       {\r
-               ERROR2("[%s] Cannot execute the command `%s'", command->context->pos, command->context->command_line);\r
-\r
-               unit_set_error(command->unit, command->execlp_errno, 0, command->context->pos);\r
-\r
-               command_handle_failure(command, csr_execlp_function_failure);\r
-       }\r
-}\r
-#endif\r
-\r
-void\r
-command_check(command_t command)\r
-{\r
-       int success = 1;\r
-       cs_reason_t reason;\r
-\r
-       /* we have a signal, store it */\r
-       if(WIFSIGNALED(command->stat_val))\r
-       {\r
-               command->signal = strdup(signal_name(WTERMSIG(command->stat_val),command->context->signal));\r
-       }\r
-\r
-       /* we have a signal and no signal is expected */\r
-       if(WIFSIGNALED(command->stat_val) && !command->context->signal)\r
-       {\r
-               success = 0;\r
-               ERROR3("[%s] `%s' : NOK (unexpected signal `%s' caught)", command->context->pos, command->context->command_line, command->signal);\r
-\r
-               unit_set_error(command->unit, EUNXPSIG, 1, command->context->pos);\r
-\r
-               reason = csr_unexpected_signal_caught;\r
-       }\r
-\r
-       /* we have a signal that differ form the expected signal */\r
-       if(WIFSIGNALED(command->stat_val) && command->context->signal && strcmp(signal_name(WTERMSIG(command->stat_val),command->context->signal),command->context->signal))\r
-       {\r
-\r
-               ERROR4("[%s] `%s' : NOK (got signal `%s' instead of `%s')", command->context->pos, command->context->command_line, command->signal, command->context->signal);\r
-\r
-               if(success)\r
-               {\r
-                       success = 0;\r
-                       unit_set_error(command->unit, ESIGNOTMATCH, 1, command->context->pos);\r
-               }\r
-\r
-               reason = csr_signals_dont_match;\r
-       }\r
-\r
-       /* we don't receive the expected signal */\r
-       if(!WIFSIGNALED(command->stat_val) && command->context->signal)\r
-       {\r
-\r
-               ERROR3("[%s] `%s' : NOK (expected `%s' not received)", command->context->pos, command->context->command_line, command->context->signal);\r
-\r
-               if(success)\r
-               {\r
-                       success = 0;\r
-                       unit_set_error(command->unit, ESIGNOTRECEIVED, 1, command->context->pos);\r
-               }\r
-\r
-               reason = csr_expected_signal_not_received;\r
-       }\r
-\r
-       /* if the command exit normaly and we expect a exit code : test it */\r
-       if(WIFEXITED(command->stat_val) /* && INDEFINITE != command->context->exit_code*/)\r
-       {\r
-               /* the exit codes don't match */\r
-               if(WEXITSTATUS(command->stat_val) != command->context->exit_code)\r
-               {\r
-                       ERROR4("[%s] %s : NOK (returned code `%d' instead `%d')", command->context->pos, command->context->command_line, WEXITSTATUS(command->stat_val), command->context->exit_code);\r
-\r
-                       if(success)\r
-                       {\r
-                               success = 0;\r
-                               unit_set_error(command->unit, EEXITCODENOTMATCH, 1, command->context->pos);\r
-                       }\r
-\r
-                       reason = csr_exit_codes_dont_match;\r
-               }\r
-       }\r
-\r
-       /* make sure the reader done */\r
-       while(!command->reader->done)\r
-               xbt_os_thread_yield();\r
-\r
-       #ifdef _XBT_WIN32\r
-       CloseHandle(command->stdout_fd);\r
-       #else\r
-       close(command->stdout_fd);\r
-       #endif\r
-\r
-       command->stdout_fd = INDEFINITE_FD;\r
-\r
-       xbt_strbuff_chomp(command->output);\r
-       xbt_strbuff_chomp(command->context->output);\r
-       xbt_strbuff_trim(command->output);\r
-       xbt_strbuff_trim(command->context->output);\r
-\r
-       if(!success &&  !strcmp(command->output->data, command->context->output->data))\r
-       {\r
-               xbt_dynar_t a = xbt_str_split(command->output->data, "\n");\r
-               char *out = xbt_str_join(a,"\n||");\r
-               xbt_dynar_free(&a);\r
-               INFO2("Output of <%s> so far: \n||%s", command->context->pos,out);\r
-               free(out);\r
-       }\r
-       /* if ouput handling flag is specified check the output */\r
-       else if(oh_check == command->context->output_handling && command->reader)\r
-       {\r
-               if(command->output->used != command->context->output->used || strcmp(command->output->data, command->context->output->data))\r
-               {\r
-                       char *diff;\r
-\r
-\r
-                       ERROR2("[%s] `%s' : NOK (outputs mismatch):", command->context->pos, command->context->command_line);\r
-\r
-                       if(success)\r
-                       {\r
-                               unit_set_error(command->unit, EOUTPUTNOTMATCH, 1, command->context->pos);\r
-                               success = 0;\r
-                       }\r
-\r
-                       reason = csr_outputs_dont_match;\r
-\r
-                       /* display the diff */\r
-                       diff = xbt_str_diff(command->context->output->data,command->output->data);\r
-                       INFO1("%s",diff);\r
-                       free(diff);\r
-               }\r
-       }\r
-       else if (oh_ignore == command->context->output_handling)\r
-       {\r
-               INFO1("(ignoring the output of <%s> as requested)",command->context->line);\r
-       }\r
-       else if (oh_display == command->context->output_handling)\r
-       {\r
-               xbt_dynar_t a = xbt_str_split(command->output->data, "\n");\r
-               char *out = xbt_str_join(a,"\n||");\r
-               xbt_dynar_free(&a);\r
-               INFO3("[%s] Here is the (ignored) command `%s' output: \n||%s",command->context->pos, command->context->command_line, out);\r
-               free(out);\r
-       }\r
-\r
-       if(success)\r
-       {\r
-               xbt_os_mutex_acquire(command->mutex);\r
-\r
-               if(command->status != cs_interrupted)\r
-               {\r
-                       /* signal the success of the command */\r
-                       command->status = cs_successeded;\r
-                       command->successeded = 1;\r
-\r
-                       /* increment the number of successeded command of the unit */\r
-                       (command->root->successeded_cmd_nb)++;\r
-               }\r
-\r
-               xbt_os_mutex_release(command->mutex);\r
-       }\r
-       else\r
-       {\r
-               command_handle_failure(command, reason);\r
-       }\r
-}\r
-\r
+void \r command_wait(command_t command) \r
+{
+  \r
+      /* wait for the command terminaison */ \r
+      DWORD rv;
+  \r\rif (WAIT_FAILED == WaitForSingleObject(command->pid, INFINITE))
+    \r {
+    \rERROR2("[%s] Cannot wait for the child`%s'", command->context->pos,
+            command->context->command_line);
+    \r\runit_set_error(command->unit, (int) GetLastError(), 0,
+                     command->context->pos);
+    \r\rcommand_handle_failure(command, csr_wait_failure);
+    \r
+        /* TODO : see for the interruption      */ \r
+    }
+  \r
+  else
+    \r {
+    \r
+        /* don't take care of the timer or the writer or the reader failue */ \r
+        if (cs_failed != command->status
+            && cs_interrupted != command->status)
+      \r {
+      \rif (!GetExitCodeProcess(command->pid, &rv))
+        \r {
+        \rERROR2("[%s] Cannot get the exit code of the process `%s'",
+                command->context->pos, command->context->command_line);
+        \r\runit_set_error(command->unit, (int) GetLastError(), 0,
+                         command->context->pos);
+        \r\rcommand_handle_failure(command,
+                                 csr_get_exit_code_process_function_failure);
+        \r}
+      \r
+      else
+        \rcommand->stat_val = command->exit_code = rv;
+      \r}
+    \r}
+\r}
+
+\r
+#else   /* \r */
+void \r command_wait(command_t command) \r
+{
+  \rif (!command->execlp_errno)
+    \r {
+    \r
+        /* let this thread wait for the child so that the main thread can detect the timeout without blocking on the wait */ \r
+    int pid = waitpid(command->pid, &(command->stat_val), 0);
+    \r\rif (pid != command->pid)
+      \r {
+      \rERROR2("[%s] Cannot wait for the child`%s'", command->context->pos,
+              command->context->command_line);
+      \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+      \r\rcommand_handle_failure(command, csr_waitpid_function_failure);
+      \r}
+    \r
+    else
+      \r {
+      \rif (WIFEXITED(command->stat_val))
+        \rcommand->exit_code = WEXITSTATUS(command->stat_val);
+      \r}
+    \r}
+  \r
+  else
+    \r {
+    \rERROR2("[%s] Cannot execute the command `%s'", command->context->pos,
+            command->context->command_line);
+    \r\runit_set_error(command->unit, command->execlp_errno, 0,
+                     command->context->pos);
+    \r\rcommand_handle_failure(command, csr_execlp_function_failure);
+    \r}
+\r}
+
+\r
+#endif  /* \r */
+\rvoid \r command_check(command_t command) \r
+{
+  \rint success = 1;
+  \rcs_reason_t reason;
+  \r\r
+      /* we have a signal, store it */ \r
+      if (WIFSIGNALED(command->stat_val))
+    \r {
+    \rcommand->signal =
+        strdup(signal_name
+               (WTERMSIG(command->stat_val), command->context->signal));
+    \r}
+  \r\r
+      /* we have a signal and no signal is expected */ \r
+      if (WIFSIGNALED(command->stat_val) && !command->context->signal)
+    \r {
+    \rsuccess = 0;
+    \rERROR3("[%s] `%s' : NOK (unexpected signal `%s' caught)",
+            command->context->pos, command->context->command_line,
+            command->signal);
+    \r\runit_set_error(command->unit, EUNXPSIG, 1, command->context->pos);
+    \r\rreason = csr_unexpected_signal_caught;
+    \r}
+  \r\r
+      /* we have a signal that differ form the expected signal */ \r
+      if (WIFSIGNALED(command->stat_val) && command->context->signal
+          &&
+          strcmp(signal_name
+                 (WTERMSIG(command->stat_val), command->context->signal),
+                 command->context->signal))
+    \r {
+    \r\rERROR4("[%s] `%s' : NOK (got signal `%s' instead of `%s')",
+             command->context->pos, command->context->command_line,
+             command->signal, command->context->signal);
+    \r\rif (success)
+      \r {
+      \rsuccess = 0;
+      \runit_set_error(command->unit, ESIGNOTMATCH, 1,
+                      command->context->pos);
+      \r}
+    \r\rreason = csr_signals_dont_match;
+    \r}
+  \r\r
+      /* we don't receive the expected signal */ \r
+      if (!WIFSIGNALED(command->stat_val) && command->context->signal)
+    \r {
+    \r\rERROR3("[%s] `%s' : NOK (expected `%s' not received)",
+             command->context->pos, command->context->command_line,
+             command->context->signal);
+    \r\rif (success)
+      \r {
+      \rsuccess = 0;
+      \runit_set_error(command->unit, ESIGNOTRECEIVED, 1,
+                      command->context->pos);
+      \r}
+    \r\rreason = csr_expected_signal_not_received;
+    \r}
+  \r\r
+      /* if the command exit normaly and we expect a exit code : test it */ \r
+      if (WIFEXITED(command->stat_val)
+          /* && INDEFINITE != command->context->exit_code */ )
+    \r {
+    \r
+        /* the exit codes don't match */ \r
+        if (WEXITSTATUS(command->stat_val) != command->context->exit_code)
+      \r {
+      \rERROR4("[%s] %s : NOK (returned code `%d' instead `%d')",
+              command->context->pos, command->context->command_line,
+              WEXITSTATUS(command->stat_val), command->context->exit_code);
+      \r\rif (success)
+        \r {
+        \rsuccess = 0;
+        \runit_set_error(command->unit, EEXITCODENOTMATCH, 1,
+                        command->context->pos);
+        \r}
+      \r\rreason = csr_exit_codes_dont_match;
+      \r}
+    \r}
+  \r\r
+      /* make sure the reader done */ \r
+      while (!command->reader->done)
+    \rxbt_os_thread_yield();
+  \r\r
 #ifdef _XBT_WIN32\r
-void\r
-command_kill(command_t command)\r
-{\r
-       if(INDEFINITE_PID != command->pid)\r
-       {\r
-               INFO2("[%s] Kill the process `%s'", command->context->pos, command->context->command_line);\r
-               TerminateProcess(command->pid, INDEFINITE);\r
-       }\r
-}\r
-#else\r
-void\r
-command_kill(command_t command)\r
-{\r
-       if(INDEFINITE_PID != command->pid)\r
-       {\r
-               kill(command->pid,SIGTERM);\r
-\r
-               if(!command->context->signal)\r
-                       command->context->signal = strdup("SIGTERM");\r
-\r
-               command->exit_code = INDEFINITE;\r
-               command->killed = 1;\r
-\r
-               usleep(100);\r
-\r
-               INFO2("[%s] Kill the process `%s'", command->context->pos, command->context->command_line);\r
-               kill(command->pid,SIGKILL);\r
-\r
-\r
-       }\r
-}\r
-#endif\r
-\r
-void\r
-command_interrupt(command_t command)\r
-{\r
-       xbt_os_mutex_acquire(command->mutex);\r
-\r
-       if((command->status != cs_interrupted) && (command->status != cs_failed) && (command->status != cs_successeded))\r
-       {\r
-               command->status = cs_interrupted;\r
-               command->reason = csr_interruption_request;\r
-               command->interrupted = 1;\r
-               command->unit->interrupted = 1;\r
-\r
-               xbt_os_mutex_acquire(command->root->mutex);\r
-               (command->root->interrupted_cmd_nb)++;\r
-               xbt_os_mutex_release(command->root->mutex);\r
-\r
-               if(command->pid != INDEFINITE_PID)\r
-                       command_kill(command);\r
-       }\r
-\r
-       xbt_os_mutex_release(command->mutex);\r
-\r
-\r
-}\r
-\r
-void\r
-command_summarize(command_t command)\r
-{\r
-       if(cs_successeded != command->status)\r
-       {\r
-\r
-               #ifndef _XBT_WIN32\r
-               if(command->killed)\r
-                       printf("          <killed command>\n");\r
-               #endif\r
-\r
-               /* display the reason of the status of the command */\r
-               switch(command->reason)\r
-               {\r
-                       /* the function pipe or CreatePipe() fails */\r
-                       case csr_pipe_function_failed :\r
-                       printf("          reason                      : pipe() or CreatePipe() function failed (system error)\n");\r
-                       break;\r
-\r
-                       case csr_shell_failed :\r
-                       printf("          reason                      : shell failed (may be command not found)\n");\r
-                       break;\r
-\r
-                       case csr_get_exit_code_process_function_failure :\r
-                       printf("          reason                      : ExitCodeProcess() function failed (system error)\n");\r
-                       break;\r
-\r
-                       /* reader failure reasons*/\r
-                       case csr_read_pipe_broken :\r
-                       printf("          reason                      : command read pipe broken\n");\r
-                       break;\r
-\r
-                       case csr_read_failure :\r
-                       printf("          reason                      : command stdout read failed\n");\r
-                       break;\r
-\r
-                       /* writer failure reasons */\r
-                       case csr_write_failure :\r
-                       printf("          reason                      : command stdin write failed\n");\r
-                       break;\r
-\r
-                       case csr_write_pipe_broken :\r
-                       printf("          reason                      : command write pipe broken\n");\r
-                       break;\r
-\r
-                       /* timer reason */\r
-                       case csr_timeout :\r
-                       printf("          reason                      : command timeouted\n");\r
-                       break;\r
-\r
-                       /* command failure reason */\r
-                       case csr_command_not_found :\r
-                       printf("          reason                      : command not found\n");\r
-                       break;\r
-\r
-                       /* context failure reasons */\r
-                       case csr_exit_codes_dont_match :\r
-                       printf("          reason                      : exit codes don't match\n");\r
-\r
-                       break;\r
-\r
-                       /* dup2 function failure reasons */\r
-                       case csr_dup2_function_failure :\r
-                       printf("          reason                      : dup2() function failed\n");\r
-\r
-                       break;\r
-\r
-                       /* execlp function failure reasons */\r
-                       case csr_execlp_function_failure :\r
-                       printf("          reason                      : execlp() function failed\n");\r
-\r
-                       break;\r
-\r
-                       /* waitpid function failure reasons */\r
-                       case csr_waitpid_function_failure :\r
-                       printf("          reason                      : waitpid() function failed\n");\r
-\r
-                       break;\r
-\r
-                       /* CreateProcess function failure reasons */\r
-                       case csr_create_process_function_failure :\r
-                       printf("          reason                      : CreateProcesss() function failed\n");\r
-\r
-                       break;\r
-\r
-                       case csr_outputs_dont_match :\r
-                       {\r
-                               /*char *diff;*/\r
-                               printf("          reason                      : ouputs don't match\n");\r
-                               /*diff = xbt_str_diff(command->context->output->data,command->output->data);\r
-                               printf("          output diff :\n%s\n",diff);\r
-                               free(diff);*/\r
-                       }\r
-\r
-                       break;\r
-\r
-                       case csr_signals_dont_match :\r
-                       printf("          reason                      : signals don't match\n");\r
-                       break;\r
-\r
-                       case csr_unexpected_signal_caught:\r
-                       printf("          reason                      : unexpected signal caught\n");\r
-                       break;\r
-\r
-                       case csr_expected_signal_not_received :\r
-                       printf("          reason                      : expected signal not receipt\n");\r
-                       break;\r
-\r
-                       /* system failure reasons */\r
-                       case csr_fork_function_failure :\r
-                       printf("          reason                      : fork function failed\n");\r
-                       break;\r
-\r
-                       case csr_wait_failure :\r
-                       printf("          reason                      : wait command failure\n");\r
-                       break;\r
-\r
-                       /* global/local interruption */\r
-                       case csr_interruption_request :\r
-                       printf("          reason                      : the command receive a interruption request\n");\r
-                       break;\r
-\r
-                       /* unknown ? */\r
-                       case csr_unknown :\r
-                       printf("          reason                      : unknown \n");\r
-               }\r
-       }\r
-\r
-       if(csr_command_not_found != command->reason && csr_fork_function_failure != command->reason  && csr_execlp_function_failure != command->reason)\r
-       {\r
-               if(INDEFINITE != command->exit_code)\r
-                       /* the command exit code */\r
-                       printf("          exit code                   : %d\n",command->exit_code);\r
-\r
-               /* if an expected exit code was specified display it */\r
-               if(INDEFINITE != command->context->exit_code)\r
-                       printf("          expected exit code          : %d\n",command->context->exit_code);\r
-               else\r
-                       printf("          no expected exit code specified\n");\r
-\r
-               /* no expected signal expected */\r
-               if(NULL == command->context->signal)\r
-               {\r
-                       printf("          no expected signal specified\n");\r
-\r
-                       if(command->signal)\r
-                               printf("          but got signal              : %s\n",command->signal);\r
-\r
-               }\r
-               /* if an expected exit code was specified display it */\r
-               else\r
-               {\r
-                       if(NULL != command->signal)\r
-                               printf("          signal                      : %s\n",command->signal);\r
-                       else\r
-                               printf("          no signal caugth\n");\r
-               }\r
-\r
-               /* if the command has out put and the metacommand display output is specified display it  */\r
-               if(command->output && (0 != command->output->used) && (oh_display == command->context->output_handling))\r
-               {\r
-                       xbt_dynar_t a = xbt_str_split(command->output->data, "\n");\r
-                       char *out = xbt_str_join(a,"\n||");\r
-                       xbt_dynar_free(&a);\r
-                       printf("          output :\n||%s",out);\r
-                       free(out);\r
-               }\r
-       }\r
-\r
-       printf("\n");\r
-}\r
-\r
-void\r
-command_handle_failure(command_t command, cs_reason_t reason)\r
-{\r
-       unit_t root = command->root;\r
-\r
-       xbt_os_mutex_acquire(command->mutex);\r
-\r
-       if((command->status != cs_interrupted) && (command->status != cs_failed))\r
-       {\r
-               command->status = cs_failed;\r
-               command->reason = reason;\r
-               command->failed = 1;\r
-\r
-               command->unit->failed = 1;\r
-\r
-               xbt_os_mutex_acquire(root->mutex);\r
-\r
-               /* increment the number of failed command of the unit */\r
-               root->failed_cmd_nb++;\r
-\r
-               /* if the --ignore-failures option is not specified */\r
-               if(!keep_going_unit_flag)\r
-               {\r
-                       if(!root->interrupted)\r
-                       {\r
-                               /* the unit interrupted (exit for the loop) */\r
-                               root->interrupted = 1;\r
-\r
-                               /* release the unit */\r
-                               xbt_os_sem_release(root->sem);\r
-                       }\r
-\r
-                       /* if the --keep-going option is not specified */\r
-                       if(!keep_going_flag)\r
-                       {\r
-                               if(!interrupted)\r
-                               {\r
-                                       /* request an global interruption by the runner */\r
-                                       interrupted = 1;\r
-\r
-                                       /* release the runner */\r
-                                       xbt_os_sem_release(units_sem);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               xbt_os_mutex_release(root->mutex);\r
-       }\r
-\r
-       xbt_os_mutex_release(command->mutex);\r
-}\r
-\r
-int\r
-command_free(command_t* ptr)\r
-{\r
-       /* close the stdin and the stdout pipe handles */\r
-\r
-       #ifdef _XBT_WIN32\r
-       if((*ptr)->stdin_fd != INDEFINITE_FD)\r
-               CloseHandle((*ptr)->stdin_fd);\r
-\r
-       if((*ptr)->stdout_fd != INDEFINITE_FD)\r
-               CloseHandle((*ptr)->stdout_fd);\r
-\r
-       #else\r
-\r
-       if((*ptr)->stdin_fd != INDEFINITE_FD)\r
-               close((*ptr)->stdin_fd);\r
-\r
-       if((*ptr)->stdout_fd != INDEFINITE_FD)\r
-               close((*ptr)->stdout_fd);\r
-       #endif\r
-\r
-       if((*ptr)->timer)\r
-       {\r
-               if(timer_free(&((*ptr)->timer)) < 0)\r
-                       return -1;\r
-       }\r
-\r
-       if((*ptr)->writer)\r
-       {\r
-               if(writer_free(&((*ptr)->writer)) < 0)\r
-                       return -1;\r
-       }\r
-\r
-       if((*ptr)->reader)\r
-       {\r
-               if(reader_free(&((*ptr)->reader)) < 0)\r
-                       return -1;\r
-       }\r
-\r
-       if((*ptr)->output)\r
-               xbt_strbuff_free((*ptr)->output);\r
-\r
-       if((*ptr)->context)\r
-       {\r
-               if(context_free(&((*ptr)->context)) < 0)\r
-                       return -1;\r
-       }\r
-\r
-       if((*ptr)->signal)\r
-               free((*ptr)->signal);\r
-\r
-       free(*ptr);\r
-\r
-       *ptr = NULL;\r
-\r
-       return 0;\r
-}\r
-\r
-\r
-\r
+      CloseHandle(command->stdout_fd);
+  \r
+#else   /* \r */
+      close(command->stdout_fd);
+  \r
+#endif  /* \r */
+      \rcommand->stdout_fd = INDEFINITE_FD;
+  \r\rxbt_strbuff_chomp(command->output);
+  \rxbt_strbuff_chomp(command->context->output);
+  \rxbt_strbuff_trim(command->output);
+  \rxbt_strbuff_trim(command->context->output);
+  \r\rif (!success
+        && !strcmp(command->output->data, command->context->output->data))
+    \r {
+    \rxbt_dynar_t a = xbt_str_split(command->output->data, "\n");
+    \rchar *out = xbt_str_join(a, "\n||");
+    \rxbt_dynar_free(&a);
+    \rINFO2("Output of <%s> so far: \n||%s", command->context->pos, out);
+    \rfree(out);
+    \r}
+  \r
+      /* if ouput handling flag is specified check the output */ \r
+      else if (oh_check == command->context->output_handling
+               && command->reader)
+    \r {
+    \rif (command->output->used != command->context->output->used
+         || strcmp(command->output->data, command->context->output->data))
+      \r {
+      \rchar *diff;
+      \r\r\rERROR2("[%s] `%s' : NOK (outputs mismatch):",
+                command->context->pos, command->context->command_line);
+      \r\rif (success)
+        \r {
+        \runit_set_error(command->unit, EOUTPUTNOTMATCH, 1,
+                        command->context->pos);
+        \rsuccess = 0;
+        \r}
+      \r\rreason = csr_outputs_dont_match;
+      \r\r
+          /* display the diff */ \r
+          diff =
+          xbt_str_diff(command->context->output->data,
+                       command->output->data);
+      \rINFO1("%s", diff);
+      \rfree(diff);
+      \r}
+    \r}
+  \r
+  else if (oh_ignore == command->context->output_handling)
+    \r {
+    \rINFO1("(ignoring the output of <%s> as requested)",
+           command->context->line);
+    \r}
+  \r
+  else if (oh_display == command->context->output_handling)
+    \r {
+    \rxbt_dynar_t a = xbt_str_split(command->output->data, "\n");
+    \rchar *out = xbt_str_join(a, "\n||");
+    \rxbt_dynar_free(&a);
+    \rINFO3("[%s] Here is the (ignored) command `%s' output: \n||%s",
+           command->context->pos, command->context->command_line, out);
+    \rfree(out);
+    \r}
+  \r\rif (success)
+    \r {
+    \rxbt_os_mutex_acquire(command->mutex);
+    \r\rif (command->status != cs_interrupted)
+      \r {
+      \r
+          /* signal the success of the command */ \r
+          command->status = cs_successeded;
+      \rcommand->successeded = 1;
+      \r\r
+          /* increment the number of successeded command of the unit */ \r
+          (command->root->successeded_cmd_nb)++;
+      \r}
+    \r\rxbt_os_mutex_release(command->mutex);
+    \r}
+  \r
+  else
+    \r {
+    \rcommand_handle_failure(command, reason);
+    \r}
+\r}
+
+\r\r
+#ifdef _XBT_WIN32\r
+void \r command_kill(command_t command) \r
+{
+  \rif (INDEFINITE_PID != command->pid)
+    \r {
+    \rINFO2("[%s] Kill the process `%s'", command->context->pos,
+           command->context->command_line);
+    \rTerminateProcess(command->pid, INDEFINITE);
+    \r}
+\r}
+
+\r
+#else   /* \r */
+void \r command_kill(command_t command) \r
+{
+  \rif (INDEFINITE_PID != command->pid)
+    \r {
+    \rkill(command->pid, SIGTERM);
+    \r\rif (!command->context->signal)
+      \rcommand->context->signal = strdup("SIGTERM");
+    \r\rcommand->exit_code = INDEFINITE;
+    \rcommand->killed = 1;
+    \r\rusleep(100);
+    \r\rINFO2("[%s] Kill the process `%s'", command->context->pos,
+            command->context->command_line);
+    \rkill(command->pid, SIGKILL);
+    \r\r\r}
+\r}
+
+\r
+#endif  /* \r */
+\rvoid \r command_interrupt(command_t command) \r
+{
+  \rxbt_os_mutex_acquire(command->mutex);
+  \r\rif ((command->status != cs_interrupted)
+        && (command->status != cs_failed)
+        && (command->status != cs_successeded))
+    \r {
+    \rcommand->status = cs_interrupted;
+    \rcommand->reason = csr_interruption_request;
+    \rcommand->interrupted = 1;
+    \rcommand->unit->interrupted = 1;
+    \r\rxbt_os_mutex_acquire(command->root->mutex);
+    \r(command->root->interrupted_cmd_nb)++;
+    \rxbt_os_mutex_release(command->root->mutex);
+    \r\rif (command->pid != INDEFINITE_PID)
+      \rcommand_kill(command);
+    \r}
+  \r\rxbt_os_mutex_release(command->mutex);
+\r\r\r}
+
+\r\rvoid \r command_summarize(command_t command) \r
+{
+  \rif (cs_successeded != command->status)
+    \r {
+    \r\r
+#ifndef _XBT_WIN32\r
+        if (command->killed)
+      \rprintf("          <killed command>\n");
+    \r
+#endif  /* \r */
+        \r
+        /* display the reason of the status of the command */ \r
+        switch (command->reason)
+      \r {
+      \r
+          /* the function pipe or CreatePipe() fails */ \r
+    case csr_pipe_function_failed:
+      
+      \rprintf
+          ("          reason                      : pipe() or CreatePipe() function failed (system error)\n");
+      \rbreak;
+    \r\rcase csr_shell_failed:
+      \rprintf
+          ("          reason                      : shell failed (may be command not found)\n");
+      \rbreak;
+    \r\rcase csr_get_exit_code_process_function_failure:
+      \rprintf
+          ("          reason                      : ExitCodeProcess() function failed (system error)\n");
+      \rbreak;
+      \r\r
+          /* reader failure reasons */ \r
+    case csr_read_pipe_broken:
+      
+      \rprintf
+          ("          reason                      : command read pipe broken\n");
+      \rbreak;
+    \r\rcase csr_read_failure:
+      \rprintf
+          ("          reason                      : command stdout read failed\n");
+      \rbreak;
+      \r\r
+          /* writer failure reasons */ \r
+    case csr_write_failure:
+      
+      \rprintf
+          ("          reason                      : command stdin write failed\n");
+      \rbreak;
+    \r\rcase csr_write_pipe_broken:
+      \rprintf
+          ("          reason                      : command write pipe broken\n");
+      \rbreak;
+      \r\r
+          /* timer reason */ \r
+    case csr_timeout:
+      
+      \rprintf
+          ("          reason                      : command timeouted\n");
+      \rbreak;
+      \r\r
+          /* command failure reason */ \r
+    case csr_command_not_found:
+      
+      \rprintf
+          ("          reason                      : command not found\n");
+      \rbreak;
+      \r\r
+          /* context failure reasons */ \r
+    case csr_exit_codes_dont_match:
+      
+      \rprintf
+          ("          reason                      : exit codes don't match\n");
+      \r\rbreak;
+      \r\r
+          /* dup2 function failure reasons */ \r
+    case csr_dup2_function_failure:
+      
+      \rprintf
+          ("          reason                      : dup2() function failed\n");
+      \r\rbreak;
+      \r\r
+          /* execlp function failure reasons */ \r
+    case csr_execlp_function_failure:
+      
+      \rprintf
+          ("          reason                      : execlp() function failed\n");
+      \r\rbreak;
+      \r\r
+          /* waitpid function failure reasons */ \r
+    case csr_waitpid_function_failure:
+      
+      \rprintf
+          ("          reason                      : waitpid() function failed\n");
+      \r\rbreak;
+      \r\r
+          /* CreateProcess function failure reasons */ \r
+    case csr_create_process_function_failure:
+      
+      \rprintf
+          ("          reason                      : CreateProcesss() function failed\n");
+      \r\rbreak;
+    \r\rcase csr_outputs_dont_match:
+      \r {
+        \r
+            /*char *diff; */ \r
+            printf
+            ("          reason                      : ouputs don't match\n");
+        \r
+            /*diff = xbt_str_diff(command->context->output->data,command->output->data);\r
+               printf("          output diff :\n%s\n",diff);\r
+               free(diff); */ \r
+      }
+      \r\rbreak;
+    \r\rcase csr_signals_dont_match:
+      \rprintf
+          ("          reason                      : signals don't match\n");
+      \rbreak;
+    \r\rcase csr_unexpected_signal_caught:
+      \rprintf
+          ("          reason                      : unexpected signal caught\n");
+      \rbreak;
+    \r\rcase csr_expected_signal_not_received:
+      \rprintf
+          ("          reason                      : expected signal not receipt\n");
+      \rbreak;
+      \r\r
+          /* system failure reasons */ \r
+    case csr_fork_function_failure:
+      
+      \rprintf
+          ("          reason                      : fork function failed\n");
+      \rbreak;
+    \r\rcase csr_wait_failure:
+      \rprintf
+          ("          reason                      : wait command failure\n");
+      \rbreak;
+      \r\r
+          /* global/local interruption */ \r
+    case csr_interruption_request:
+      
+      \rprintf
+          ("          reason                      : the command receive a interruption request\n");
+      \rbreak;
+      \r\r
+          /* unknown ? */ \r
+    case csr_unknown:
+      \rprintf("          reason                      : unknown \n");
+      \r}
+    \r}
+  \r\rif (csr_command_not_found != command->reason
+        && csr_fork_function_failure != command->reason
+        && csr_execlp_function_failure != command->reason)
+    \r {
+    \rif (INDEFINITE != command->exit_code)
+      \r
+          /* the command exit code */ \r
+          printf("          exit code                   : %d\n",
+                 command->exit_code);
+    \r\r
+        /* if an expected exit code was specified display it */ \r
+        if (INDEFINITE != command->context->exit_code)
+      \rprintf("          expected exit code          : %d\n",
+              command->context->exit_code);
+    \r
+    else
+      \rprintf("          no expected exit code specified\n");
+    \r\r
+        /* no expected signal expected */ \r
+        if (NULL == command->context->signal)
+      \r {
+      \rprintf("          no expected signal specified\n");
+      \r\rif (command->signal)
+        \rprintf("          but got signal              : %s\n",
+                command->signal);
+      \r\r}
+    \r
+        /* if an expected exit code was specified display it */ \r
+        else
+      \r {
+      \rif (NULL != command->signal)
+        \rprintf("          signal                      : %s\n",
+                command->signal);
+      \r
+      else
+        \rprintf("          no signal caugth\n");
+      \r}
+    \r\r
+        /* if the command has out put and the metacommand display output is specified display it  */ \r
+        if (command->output && (0 != command->output->used)
+            && (oh_display == command->context->output_handling))
+      \r {
+      \rxbt_dynar_t a = xbt_str_split(command->output->data, "\n");
+      \rchar *out = xbt_str_join(a, "\n||");
+      \rxbt_dynar_free(&a);
+      \rprintf("          output :\n||%s", out);
+      \rfree(out);
+      \r}
+    \r}
+  \r\rprintf("\n");
+\r\r\rvoid \r command_handle_failure(command_t command, cs_reason_t reason) \r
+{
+  \runit_t root = command->root;
+  \r\rxbt_os_mutex_acquire(command->mutex);
+  \r\rif ((command->status != cs_interrupted)
+        && (command->status != cs_failed))
+    \r {
+    \rcommand->status = cs_failed;
+    \rcommand->reason = reason;
+    \rcommand->failed = 1;
+    \r\rcommand->unit->failed = 1;
+    \r\rxbt_os_mutex_acquire(root->mutex);
+    \r\r
+        /* increment the number of failed command of the unit */ \r
+        root->failed_cmd_nb++;
+    \r\r
+        /* if the --ignore-failures option is not specified */ \r
+        if (!keep_going_unit_flag)
+      \r {
+      \rif (!root->interrupted)
+        \r {
+        \r
+            /* the unit interrupted (exit for the loop) */ \r
+            root->interrupted = 1;
+        \r\r
+            /* release the unit */ \r
+            xbt_os_sem_release(root->sem);
+        \r}
+      \r\r
+          /* if the --keep-going option is not specified */ \r
+          if (!keep_going_flag)
+        \r {
+        \rif (!interrupted)
+          \r {
+          \r
+              /* request an global interruption by the runner */ \r
+              interrupted = 1;
+          \r\r
+              /* release the runner */ \r
+              xbt_os_sem_release(units_sem);
+          \r}
+        \r}
+      \r}
+    \r\rxbt_os_mutex_release(root->mutex);
+    \r}
+  \r\rxbt_os_mutex_release(command->mutex);
+\r}
+
+\r\rint \r command_free(command_t * ptr) \r
+{
+  \r
+      /* close the stdin and the stdout pipe handles */ \r
+      \r
+#ifdef _XBT_WIN32\r
+      if ((*ptr)->stdin_fd != INDEFINITE_FD)
+    \rCloseHandle((*ptr)->stdin_fd);
+  \r\rif ((*ptr)->stdout_fd != INDEFINITE_FD)
+    \rCloseHandle((*ptr)->stdout_fd);
+  \r\r
+#else   /* \r */
+      \rif ((*ptr)->stdin_fd != INDEFINITE_FD)
+    \rclose((*ptr)->stdin_fd);
+  \r\rif ((*ptr)->stdout_fd != INDEFINITE_FD)
+    \rclose((*ptr)->stdout_fd);
+  \r
+#endif  /* \r */
+      \rif ((*ptr)->timer)
+    \r {
+    \rif (timer_free(&((*ptr)->timer)) < 0)
+      \rreturn -1;
+    \r}
+  \r\rif ((*ptr)->writer)
+    \r {
+    \rif (writer_free(&((*ptr)->writer)) < 0)
+      \rreturn -1;
+    \r}
+  \r\rif ((*ptr)->reader)
+    \r {
+    \rif (reader_free(&((*ptr)->reader)) < 0)
+      \rreturn -1;
+    \r}
+  \r\rif ((*ptr)->output)
+    \rxbt_strbuff_free((*ptr)->output);
+  \r\rif ((*ptr)->context)
+    \r {
+    \rif (context_free(&((*ptr)->context)) < 0)
+      \rreturn -1;
+    \r}
+  \r\rif ((*ptr)->signal)
+    \rfree((*ptr)->signal);
+  \r\rfree(*ptr);
+  \r\r*ptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\r\r\r
index 918e810..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 _XBT_WIN32\r
-       context->t_command_line = NULL;\r
-       context->is_not_found = 0;\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 _XBT_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 _XBT_WIN32\r
-       if(context->t_command_line)\r
-       {\r
-               free(context->t_command_line);\r
-               context->t_command_line = NULL;\r
-       }\r
-\r
-       context->is_not_found = 0;\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 _XBT_WIN32\r
-       dup->t_command_line = strdup(context->t_command_line);\r
-       dup->is_not_found = context->is_not_found;\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 _XBT_WIN32\r
-       if(context->t_command_line)\r
-       {\r
-               free(context->t_command_line);\r
-               context->t_command_line = NULL;\r
-       }\r
-       context->is_not_found = 0;\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
index 3b480b0..b57d85c 100644 (file)
 #include <directories.h>\r
 #include <directory.h>\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rdirectories_t \r directories_new(void) \r
+{
+  \rdirectories_t directories = xbt_new0(s_directories_t, 1);
+  \r\rdirectories->items =
+      xbt_dynar_new(sizeof(directory_t), (void_f_pvoid_t) directory_free);
+  \r\rreturn directories;
+\r}
+
+\r\rint \r directories_get_size(directories_t directories) \r
+{
+  \rif (!directories)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rreturn xbt_dynar_length(directories->items);
+\r}
+
+\r\rint \r directories_is_empty(directories_t directories) \r
+{
+  \rif (!directories)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rreturn (0 == xbt_dynar_length(directories->items));
+\r}
+
+\r\rint \r directories_add(directories_t directories, directory_t directory) \r
+{
+  \rdirectory_t cur;
+  \runsigned int i;
+  \r\rif (!directories)
+    \rreturn EINVAL;
+  \r\rxbt_dynar_foreach(directories->items, i, cur) \r {
+    \rif (!strcmp(cur->name, directory->name))
+      \rreturn EEXIST;
+  \r}
+  \r\rxbt_dynar_push(directories->items, &directory);
+  \r\rreturn 0;
+\r}
+
+\r\rint \r
+directories_contains(directories_t directories, directory_t directory) \r
+{
+  \rdirectory_t * cur;
+  \runsigned int i;
+  \r\rif (!directories)
+    \rreturn EINVAL;
+  \r\rxbt_dynar_foreach(directories->items, i, cur) \r {
+    \rif (!strcmp((*cur)->name, directory->name))
+      \rreturn 1;
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r
+directories_load(directories_t directories, fstreams_t fstreams,
+                 xbt_dynar_t suffixes) \r
+{
+  \rdirectory_t directory;
+  \rint rv;
+  \runsigned int i;
+  \r\rif (!directories || !fstreams || !suffixes)
+    \rreturn EINVAL;
+  \r\rxbt_dynar_foreach(directories->items, i, directory) \r {
+    \rif ((rv = directory_open(directory)))
+      \rreturn rv;
+    \r\rif ((rv = directory_load(directory, fstreams, suffixes)))
+      \rreturn rv;
+    \r\rif ((rv = directory_close(directory)))
+      \rreturn rv;
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r directories_free(void **directoriesptr) \r
+{
+  \rdirectories_t directories;
+  \r\rif (!(*directoriesptr))
+    \rreturn EINVAL;
+  \r\rdirectories = (directories_t) (*directoriesptr);
+  \r\rif (directories->items)
+    \rxbt_dynar_free(&(directories->items));
+  \r\rfree(*directoriesptr);
+  \r*directoriesptr = NULL;
+  \r\rreturn 0;
+\r}
+
 \r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-directories_t\r
-directories_new(void)\r
-{\r
-       directories_t directories = xbt_new0(s_directories_t, 1);\r
-       \r
-       directories->items = xbt_dynar_new(sizeof(directory_t), (void_f_pvoid_t)directory_free);\r
-       \r
-       return directories;\r
-}\r
-\r
-int\r
-directories_get_size(directories_t directories)\r
-{\r
-       if(!directories)\r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-\r
-       return xbt_dynar_length(directories->items);\r
-}\r
-\r
-int\r
-directories_is_empty(directories_t directories)\r
-{\r
-       if(!directories)\r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-\r
-       return (0 == xbt_dynar_length(directories->items));\r
-}\r
-\r
-int\r
-directories_add(directories_t directories, directory_t directory)\r
-{\r
-       directory_t cur;\r
-       unsigned int i;\r
-       \r
-       if(!directories)\r
-               return EINVAL;\r
-       \r
-       xbt_dynar_foreach(directories->items, i, cur)\r
-       {\r
-               if(!strcmp(cur->name, directory->name))\r
-                       return EEXIST;\r
-       }\r
-\r
-       xbt_dynar_push(directories->items, &directory);\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-directories_contains(directories_t directories, directory_t directory)\r
-{\r
-       directory_t* cur;\r
-       unsigned int i;\r
-       \r
-       if(!directories)\r
-               return EINVAL;\r
-\r
-       xbt_dynar_foreach(directories->items, i, cur)\r
-       {\r
-               if(!strcmp((*cur)->name, directory->name))\r
-                       return 1;\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-directories_load(directories_t directories, fstreams_t fstreams, xbt_dynar_t suffixes)\r
-{\r
-       directory_t directory;\r
-       int rv;\r
-       unsigned int i;\r
-       \r
-       if(!directories || !fstreams || !suffixes)\r
-               return EINVAL;\r
-       \r
-       xbt_dynar_foreach(directories->items, i, directory)\r
-       {\r
-               if((rv = directory_open(directory)))\r
-                       return rv;\r
-               \r
-               if((rv = directory_load(directory, fstreams, suffixes)))\r
-                       return rv;\r
-                       \r
-               if((rv = directory_close(directory)))\r
-                       return rv;\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-directories_free(void** directoriesptr)\r
-{\r
-       directories_t directories;\r
-       \r
-       if(!(*directoriesptr))\r
-               return EINVAL;\r
-\r
-       directories = (directories_t)(*directoriesptr);\r
-       \r
-       if(directories->items)\r
-               xbt_dynar_free(&(directories->items));\r
-       \r
-       free(*directoriesptr);\r
-       *directoriesptr = NULL;\r
-       \r
-       return 0;       \r
-}\r
index ac6bf4b..756fb43 100644 (file)
 #include <directory.h>\r
 #include <fstreams.h>\r
 #include <fstream.h>\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-directory_t\r
-directory_new(const char* name)\r
-{\r
-       directory_t directory;\r
-       \r
-       if(!name)\r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-       \r
-       directory = xbt_new0(s_directory_t, 1);\r
-       \r
-       \r
-       directory->name = strdup(name); \r
-       \r
-               \r
-       directory->stream = NULL;\r
-       \r
-       return directory;\r
-}\r
-\r
-int\r
-directory_open(directory_t directory)\r
-{\r
-       if(!directory || directory->stream)\r
-               return EINVAL;\r
-               \r
-       if(!(directory->stream = opendir(directory->name)))\r
-               return errno;\r
-       \r
-       return 0;       \r
-}\r
-\r
-\r
-int\r
-directory_close(directory_t directory)\r
-{\r
-       if(!directory)\r
-               return EINVAL;\r
-               \r
-       if(!directory->stream)\r
-               return EBADF;\r
-               \r
-       if(closedir(directory->stream))\r
-               return errno;\r
-               \r
-       directory->stream = NULL;\r
-       return 0;\r
-}\r
-\r
-int\r
-directory_load(directory_t directory, fstreams_t fstreams, xbt_dynar_t suffixes)\r
-{\r
-       struct dirent* entry ={0};\r
-       s_fstream_t sfstream = {0};\r
-       char* suffix;\r
-       unsigned int i;\r
-       int has_valid_suffix;\r
-       int is_empty = 1;\r
-       int rv;\r
-       \r
-       if(!directory || !fstreams)\r
-               return EINVAL;\r
-               \r
-       if(!directory->stream)\r
-               return EBADF;\r
-               \r
-       sfstream.directory = strdup(directory->name);\r
-               \r
-       while((entry = readdir(directory->stream)))\r
-       {\r
-               has_valid_suffix = 0;\r
-               \r
-               xbt_dynar_foreach(suffixes, i, suffix)\r
-               {\r
-                       if(!strncmp(suffix, entry->d_name + (strlen(entry->d_name) - strlen(suffix)), strlen(suffix)))\r
-                       {\r
-                               has_valid_suffix = 1;\r
-                               break;\r
-                       }\r
-               }\r
-               \r
-               if(!has_valid_suffix)\r
-                       continue;\r
-                       \r
-               sfstream.name = strdup(entry->d_name);\r
-               \r
-               /* check first if the file stream is already in the file streams to run */\r
-               if(fstreams_contains(fstreams, &sfstream))\r
-               {\r
-                       WARN1("file %s already registred", entry->d_name);\r
-                       free(sfstream.name);\r
-                       continue;\r
-               }\r
-               \r
-               /* add the fstream to the list of file streams to run */\r
-               if((rv = fstreams_add(fstreams, fstream_new(directory->name, entry->d_name))))\r
-               {\r
-                       free(sfstream.directory);\r
-                       free(sfstream.name);\r
-                       return rv;\r
-               }\r
-                       \r
-               is_empty = 0;\r
-               free(sfstream.name);\r
-       }\r
-       \r
-       if(is_empty)\r
-               WARN1("no tesh file found in the directory %s", directory->name);       \r
-               \r
-       free(sfstream.directory);\r
-       \r
-                       \r
-       return 0;       \r
-}\r
-\r
-int\r
-directory_free(void** directoryptr)\r
-{\r
-       directory_t directory;\r
-       \r
-       if(!(*directoryptr))\r
-               return EINVAL;\r
-               \r
-       directory = *((directory_t*)directoryptr);\r
-       \r
-       if(directory->stream)\r
-               if(directory_close(directory))\r
-                       return errno;\r
-       \r
-       if(directory->name)\r
-               free(directory->name);\r
-       \r
-       free(*directoryptr);\r
-       *directoryptr  = NULL;\r
-       \r
-       return 0;       \r
-}\r
-\r
-const char*\r
-directory_get_name(directory_t directory)\r
-{\r
-       if(!directory)\r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-       \r
-       return (const char*)directory->name;\r
-}\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rdirectory_t \r directory_new(const char *name) \r
+{
+  \rdirectory_t directory;
+  \r\rif (!name)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rdirectory = xbt_new0(s_directory_t, 1);
+  \r\r\rdirectory->name = strdup(name);
+  \r\r\rdirectory->stream = NULL;
+  \r\rreturn directory;
+\r}
+
+\r\rint \r directory_open(directory_t directory) \r
+{
+  \rif (!directory || directory->stream)
+    \rreturn EINVAL;
+  \r\rif (!(directory->stream = opendir(directory->name)))
+    \rreturn errno;
+  \r\rreturn 0;
+\r}
+
+\r\r\rint \r directory_close(directory_t directory) \r
+{
+  \rif (!directory)
+    \rreturn EINVAL;
+  \r\rif (!directory->stream)
+    \rreturn EBADF;
+  \r\rif (closedir(directory->stream))
+    \rreturn errno;
+  \r\rdirectory->stream = NULL;
+  \rreturn 0;
+\r}
+
+\r\rint \r
+directory_load(directory_t directory, fstreams_t fstreams,
+               xbt_dynar_t suffixes) \r
+{
+  \rstruct dirent *entry = { 0 };
+  \rs_fstream_t sfstream = {
+  0};
+  \rchar *suffix;
+  \runsigned int i;
+  \rint has_valid_suffix;
+  \rint is_empty = 1;
+  \rint rv;
+  \r\rif (!directory || !fstreams)
+    \rreturn EINVAL;
+  \r\rif (!directory->stream)
+    \rreturn EBADF;
+  \r\rsfstream.directory = strdup(directory->name);
+  \r\rwhile ((entry = readdir(directory->stream)))
+    \r {
+    \rhas_valid_suffix = 0;
+    \r\rxbt_dynar_foreach(suffixes, i, suffix) \r {
+      \rif (!strncmp
+           (suffix,
+            entry->d_name + (strlen(entry->d_name) - strlen(suffix)),
+            strlen(suffix)))
+        \r {
+        \rhas_valid_suffix = 1;
+        \rbreak;
+        \r}
+    \r}
+    \r\rif (!has_valid_suffix)
+      \rcontinue;
+    \r\rsfstream.name = strdup(entry->d_name);
+    \r\r
+        /* check first if the file stream is already in the file streams to run */ \r
+        if (fstreams_contains(fstreams, &sfstream))
+      \r {
+      \rWARN1("file %s already registred", entry->d_name);
+      \rfree(sfstream.name);
+      \rcontinue;
+      \r}
+    \r\r
+        /* add the fstream to the list of file streams to run */ \r
+        if ((rv =
+             fstreams_add(fstreams,
+                          fstream_new(directory->name, entry->d_name))))
+      \r {
+      \rfree(sfstream.directory);
+      \rfree(sfstream.name);
+      \rreturn rv;
+      \r}
+    \r\ris_empty = 0;
+    \rfree(sfstream.name);
+    \r}
+  \r\rif (is_empty)
+    \rWARN1("no tesh file found in the directory %s", directory->name);
+  \r\rfree(sfstream.directory);
+  \r\r\rreturn 0;
+\r}
+
+\r\rint \r directory_free(void **directoryptr) \r
+{
+  \rdirectory_t directory;
+  \r\rif (!(*directoryptr))
+    \rreturn EINVAL;
+  \r\rdirectory = *((directory_t *) directoryptr);
+  \r\rif (directory->stream)
+    \rif (directory_close(directory))
+      \rreturn errno;
+  \r\rif (directory->name)
+    \rfree(directory->name);
+  \r\rfree(*directoryptr);
+  \r*directoryptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rconst char *\r directory_get_name(directory_t directory) \r
+{
+  \rif (!directory)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rreturn (const char *) directory->name;
+\r\r
index ddfe0e1..d589746 100644 (file)
 #include <excludes.h>\r
 #include <fstream.h>\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rexcludes_t \r excludes_new(void) \r
+{
+  \rexcludes_t excludes = xbt_new0(s_excludes_t, 1);
+  \r\rexcludes->items =
+      xbt_dynar_new(sizeof(fstream_t), (void_f_pvoid_t) fstream_free);
+  \r\rreturn excludes;
+\r}
+
+\r\rint \r excludes_is_empty(excludes_t excludes) \r
+{
+  \rif (!excludes)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn 0;
+    \r}
+  \r\rreturn (0 == xbt_dynar_length(excludes->items));
+\r}
+
+\r\rint \r excludes_contains(excludes_t excludes, fstream_t fstream) \r
+{
+  \rfstream_t cur;
+  \runsigned int i;
+  \r\rif (!excludes || !fstream)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn 0;
+    \r}
+  \r\rxbt_dynar_foreach(excludes->items, i, cur) \r {
+    \rif (!strcmp(fstream->name, cur->name)
+         && !strcmp(fstream->directory, cur->directory))
+      \rreturn 1;
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r excludes_add(excludes_t excludes, fstream_t fstream) \r
+{
+  \rif (!excludes)
+    \rreturn EINVAL;
+  \r\rif (excludes_contains(excludes, fstream))
+    \rreturn EEXIST;
+  \r\rxbt_dynar_push(excludes->items, &fstream);
+  \r\rreturn 0;
+\r}
+
+\r\rint \r excludes_check(excludes_t excludes, fstreams_t fstreams) \r
+{
+  \rfstream_t exclude;
+  \rfstream_t fstream;
+  \rint success = 1;
+  \rint exists;
+  \runsigned int i;
+  \r\rif (!excludes || !fstreams)
+    \rreturn EINVAL;
+  \r\r\rxbt_dynar_foreach(excludes->items, i, exclude) \r {
+    \rexists = 1;
+    \r\rxbt_dynar_foreach(fstreams->items, i, fstream) \r {
+      \rexists = 0;
+      \r\rif (!strcmp(fstream->name, exclude->name)
+            && !strcmp(fstream->directory, exclude->directory))
+        \r {
+        \rexists = 1;
+        \rbreak;
+        \r}
+    \r}
+    \r\rif (!exists)
+      \r {
+      \rsuccess = 0;
+      \rWARN1("cannot exclude the file %s", exclude->name);
+      \r}
+  \r}
+  \r\rreturn success;
+\r}
+
+\r\rint \r excludes_free(void **excludesptr) \r
+{
+  \rif (!(*excludesptr))
+    \rreturn EINVAL;
+  \r\rif ((*((excludes_t *) excludesptr))->items)
+    \rxbt_dynar_free((&(*((excludes_t *) excludesptr))->items));
+  \r\rfree(*excludesptr);
+  \r*excludesptr = NULL;
+  \r\rreturn 0;
+\r}
+
 \r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-excludes_t\r
-excludes_new(void)\r
-{\r
-       excludes_t excludes = xbt_new0(s_excludes_t, 1);\r
-\r
-       excludes->items = xbt_dynar_new(sizeof(fstream_t), (void_f_pvoid_t)fstream_free);\r
-       \r
-       return excludes;\r
-}\r
-\r
-int\r
-excludes_is_empty(excludes_t excludes)\r
-{\r
-       if(!excludes)\r
-       {\r
-               errno = EINVAL;\r
-               return 0;\r
-       }\r
-       \r
-       return (0 == xbt_dynar_length(excludes->items));\r
-}\r
-\r
-int\r
-excludes_contains(excludes_t excludes, fstream_t fstream)\r
-{\r
-       fstream_t cur;\r
-       unsigned int i;\r
-       \r
-       if(!excludes || !fstream)\r
-       {\r
-               errno = EINVAL;\r
-               return 0;\r
-       }\r
-\r
-       xbt_dynar_foreach(excludes->items, i, cur)\r
-       {\r
-               if(!strcmp(fstream->name, cur->name) && !strcmp(fstream->directory, cur->directory))\r
-                       return 1;\r
-       }\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-excludes_add(excludes_t excludes, fstream_t fstream)\r
-{\r
-       if(!excludes)\r
-               return EINVAL;\r
-               \r
-       if(excludes_contains(excludes, fstream))\r
-               return EEXIST;\r
-\r
-       xbt_dynar_push(excludes->items, &fstream);\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-excludes_check(excludes_t excludes, fstreams_t fstreams)\r
-{\r
-       fstream_t exclude;\r
-       fstream_t fstream;\r
-       int success = 1;\r
-       int exists;\r
-       unsigned int i;\r
-       \r
-       if(!excludes || !fstreams)\r
-               return EINVAL;\r
-       \r
-       \r
-               xbt_dynar_foreach(excludes->items, i, exclude)\r
-               {\r
-                       exists = 1;\r
-\r
-                       xbt_dynar_foreach(fstreams->items, i, fstream)\r
-                       {\r
-                               exists = 0;\r
-                               \r
-                               if(!strcmp(fstream->name, exclude->name) && !strcmp(fstream->directory, exclude->directory))\r
-                               {\r
-                                       exists = 1;\r
-                                       break;\r
-                               }\r
-                       }\r
-\r
-                       if(!exists)\r
-                       {\r
-                               success = 0;\r
-                               WARN1("cannot exclude the file %s",exclude->name);      \r
-                       }\r
-       }\r
-               \r
-       return success;\r
-}\r
-\r
-int\r
-excludes_free(void** excludesptr)\r
-{\r
-       if(!(*excludesptr))\r
-               return EINVAL;\r
-       \r
-       if((*((excludes_t*)excludesptr))->items)\r
-               xbt_dynar_free((&(*((excludes_t*)excludesptr))->items));\r
-\r
-       free(*excludesptr);\r
-       *excludesptr = NULL;    \r
-       \r
-       return 0;\r
-}\r
index fd4a49e..63b7993 100644 (file)
@@ -1,45 +1,37 @@
 #include <explode.h>\r
-\r
-char** \r
-explode(char separator, const char *string)\r
-{\r
-    int pos = 0;\r
-    int i, len = 1;\r
-    int number = 2;\r
-    char **table;\r
-    const char* p = string;\r
-    \r
-    for (i = 0; p[i] != '\0'; i++)\r
-        if (p[i] == separator)\r
-            number++;\r
-    \r
\r
-    table = (char**)calloc(number, sizeof(char*));\r
-    \r
-    i = 0;\r
+\r char **\r explode(char separator, const char *string) \r
+{
+  \rint pos = 0;
+  \rint i, len = 1;
+  \rint number = 2;
+  \rchar **table;
+  \rconst char *p = string;
+  \r\rfor (i = 0; p[i] != '\0'; i++)
+    \rif (p[i] == separator)
+      \rnumber++;
+  \r\r\rtable = (char **) calloc(number, sizeof(char *));
+  \r\ri = 0;
+  \r\rwhile (*p++ != '\0')
+    \r {
+    \rif (*p == separator)
+      \r {
+      \rtable[i] = (char *) calloc(len + 1, sizeof(char));
+      \rstrncpy(table[i], string + pos, len);
+      \rpos += len + 1;
+      \rlen = 0;
+      \ri++;
+      \r}
     \r
-    while (*p++ != '\0')\r
-    {\r
-        if(*p == separator)\r
-        {\r
-            table[i] = (char*)calloc(len + 1, sizeof(char));\r
-            strncpy(table[i], string + pos , len);\r
-            pos += len + 1;\r
-            len = 0;\r
-            i++;\r
-        }\r
-        else\r
-               len++;\r
-    }\r
-    \r
-    if(len > 1)\r
-       {\r
-       table[i] = (char*)calloc(len + 1, sizeof(char));\r
-       strncpy(table[i], string + pos , len);\r
-    }\r
-    \r
-   \r
-    table[++i] = NULL;\r
-    \r
-    return table;\r
-}\r
+    else
+      \rlen++;
+    \r}
+  \r\rif (len > 1)
+    \r {
+    \rtable[i] = (char *) calloc(len + 1, sizeof(char));
+    \rstrncpy(table[i], string + pos, len);
+    \r}
+  \r\r\rtable[++i] = NULL;
+  \r\rreturn table;
+\r}
+
+\r
index f0e3911..a0b2dd8 100644 (file)
@@ -10,8 +10,8 @@
  *             This file contains all the definitions of the functions related with\r
  *             the tesh file stream type.\r
  *\r
- */\r
-\r
+ */  \r
+    \r
 #include <fstream.h>\r
 #include <xerrno.h>\r
 #include <context.h>\r
 #include <unit.h>\r
 #include <str_replace.h>\r
 #include <variable.h>\r
-\r
+    \r
 #include <readline.h>\r
-\r
+    \r
 #include <is_cmd.h>\r
 #include <getpath.h>\r
-\r
+    \r
 #ifndef _XBT_WIN32\r
 #include <xsignal.h>\r
-#endif\r
-\r
+#endif  /* \r */
+    \r
 #ifdef _XBT_WIN32\r
-static int\r
-is_w32_cmd(char* cmd, char** path)\r
-{\r
-       size_t i = 0;\r
-       struct stat stat_buff = {0};\r
-       char buff[PATH_MAX + 1] = {0};\r
-       \r
-\r
-\r
-       if(!cmd)\r
-       {\r
-               errno = EINVAL;\r
-               return 0;\r
-       }\r
-       \r
-       if(stat(cmd, &stat_buff) || !S_ISREG(stat_buff.st_mode))\r
-       {\r
-               if(path)\r
-               {\r
-                       for (i = 0; path[i] != NULL; i++)\r
-                       {\r
-                               /* use Cat.exe on Windows */\r
-                               if(!strcmp(cmd, "cat"))\r
-                                       cmd[0] = 'C';\r
-                               \r
-                               sprintf(buff,"%s\\%s",path[i], cmd);\r
-                               \r
-                               if(!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode))\r
-                                       return 1;\r
-                       }\r
-               }\r
-       }\r
-       else\r
-               return 1;\r
-               \r
-\r
-       return 0;\r
-}\r
-#endif\r
-\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-\r
-long fstream_getline(fstream_t fstream, char **buf, size_t *n) {\r
-\r
-       return readline(fstream->stream, buf, n);\r
-       \r
-}\r
-\r
-static void\r
-failure(unit_t unit)\r
-{\r
-       if(!keep_going_unit_flag)\r
-       {\r
-               unit_t root = unit->root ? unit->root : unit;\r
-                       \r
-               if(!root->interrupted)\r
-               {\r
-                       /* the unit interrupted (exit for the loop) */\r
-                       root->interrupted = 1;\r
-\r
-                       /* release the unit */\r
-                       xbt_os_sem_release(root->sem);\r
-               }\r
-\r
-               /* if the --keep-going option is not specified */\r
-               if(!keep_going_flag)\r
-               {\r
-                       if(!interrupted)\r
-                       {\r
-                               /* request an global interruption by the runner */\r
-                               interrupted = 1;\r
-\r
-                               /* release the runner */\r
-                               xbt_os_sem_release(units_sem);\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-fstream_t\r
-fstream_new(const char* directory, const char* name)\r
-{\r
-       fstream_t fstream;\r
-       \r
-       if(!name)\r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-       \r
-       if(!directory && !strcmp("stdin", name))\r
-       {\r
-               fstream = xbt_new0(s_fstream_t, 1);\r
-               fstream->name = strdup("stdin");\r
-               return fstream;\r
-       }\r
-       else if(!directory)\r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-       \r
-       fstream = xbt_new0(s_fstream_t, 1);\r
-       \r
-       if(!(fstream->name = strdup(name)))\r
-       {\r
-               free(fstream);\r
-               return NULL;\r
-       }\r
-       \r
-       if(!(fstream->directory = strdup(directory)))\r
-       {\r
-               free(fstream->name);\r
-               free(fstream);\r
-               return NULL;\r
-       }\r
-       \r
-       fstream->stream = NULL;\r
-       fstream->unit = NULL;\r
-       fstream->parsed = 0;\r
-       \r
-       \r
-       return fstream;\r
-}\r
-\r
-int\r
-fstream_open(fstream_t fstream)\r
-{\r
-       char path[PATH_MAX + 1] = {0};\r
-       \r
-       /* check the parameter */\r
-       if(!(fstream))\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
-       \r
-       if(!fstream || fstream->stream)\r
-       {\r
-               errno = EALREADY;\r
-               return -1;\r
-       }\r
-               \r
-       if(!strcmp(fstream->name, "stdin"))\r
-       {\r
-               fstream->stream = stdin;\r
-               return 0;\r
-       }\r
-       \r
-       #ifndef _XBT_WIN32\r
-       sprintf(path,"%s/%s",fstream->directory, fstream->name);\r
-       #else\r
-       sprintf(path,"%s\\%s",fstream->directory, fstream->name);\r
-    #endif\r
-\r
-       if(!(fstream->stream = fopen(path, "r")))\r
-       {\r
-               return -1;\r
-       }\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-fstream_close(fstream_t fstream)\r
-{\r
-       /* check the parameter */\r
-       if(!(fstream) || !strcmp(fstream->name, "stdin") )\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
-               \r
-       if(!fstream->stream)\r
-               return EBADF;   \r
-       \r
-       if(EOF == fclose(fstream->stream))\r
-               return -1;\r
-               \r
-       fstream->stream = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-fstream_free(fstream_t* ptr)\r
-{\r
-       \r
-       /* check the parameter */\r
-       if(!(*ptr))\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
+static int \r is_w32_cmd(char *cmd, char **path) \r
+{
+  \rsize_t i = 0;
+  \rstruct stat stat_buff = { 0 };
+  \rchar buff[PATH_MAX + 1] = { 0 };
+  \r\r\r\rif (!cmd)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn 0;
+    \r}
+  \r\rif (stat(cmd, &stat_buff) || !S_ISREG(stat_buff.st_mode))
+    \r {
+    \rif (path)
+      \r {
+      \rfor (i = 0; path[i] != NULL; i++)
+        \r {
+        \r
+            /* use Cat.exe on Windows */ \r
+            if (!strcmp(cmd, "cat"))
+          \rcmd[0] = 'C';
+        \r\rsprintf(buff, "%s\\%s", path[i], cmd);
+        \r\rif (!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode))
+          \rreturn 1;
+        \r}
+      \r}
+    \r}
+  \r
+  else
+    \rreturn 1;
+  \r\r\rreturn 0;
+\r}
+
+\r
+#endif  /* \r */
+    \r\rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\r\rlong fstream_getline(fstream_t fstream, char **buf, size_t * n)
+{
+  \r\rreturn readline(fstream->stream, buf, n);
+\r\r}
+
+\r\rstatic void \r failure(unit_t unit) \r
+{
+  \rif (!keep_going_unit_flag)
+    \r {
+    \runit_t root = unit->root ? unit->root : unit;
+    \r\rif (!root->interrupted)
+      \r {
+      \r
+          /* the unit interrupted (exit for the loop) */ \r
+          root->interrupted = 1;
+      \r\r
+          /* release the unit */ \r
+          xbt_os_sem_release(root->sem);
+      \r}
+    \r\r
+        /* if the --keep-going option is not specified */ \r
+        if (!keep_going_flag)
+      \r {
+      \rif (!interrupted)
+        \r {
+        \r
+            /* request an global interruption by the runner */ \r
+            interrupted = 1;
+        \r\r
+            /* release the runner */ \r
+            xbt_os_sem_release(units_sem);
+        \r}
+      \r}
+    \r}
+\r}
+
+\r\rfstream_t \r fstream_new(const char *directory, const char *name) \r
+{
+  \rfstream_t fstream;
+  \r\rif (!name)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rif (!directory && !strcmp("stdin", name))
+    \r {
+    \rfstream = xbt_new0(s_fstream_t, 1);
+    \rfstream->name = strdup("stdin");
+    \rreturn fstream;
+    \r}
+  \r
+  else if (!directory)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rfstream = xbt_new0(s_fstream_t, 1);
+  \r\rif (!(fstream->name = strdup(name)))
+    \r {
+    \rfree(fstream);
+    \rreturn NULL;
+    \r}
+  \r\rif (!(fstream->directory = strdup(directory)))
+    \r {
+    \rfree(fstream->name);
+    \rfree(fstream);
+    \rreturn NULL;
+    \r}
+  \r\rfstream->stream = NULL;
+  \rfstream->unit = NULL;
+  \rfstream->parsed = 0;
+  \r\r\rreturn fstream;
+\r}
+
+\r\rint \r fstream_open(fstream_t fstream) \r
+{
+  \rchar path[PATH_MAX + 1] = { 0 };
+  \r\r
+      /* check the parameter */ \r
+      if (!(fstream))
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rif (!fstream || fstream->stream)
+    \r {
+    \rerrno = EALREADY;
+    \rreturn -1;
+    \r}
+  \r\rif (!strcmp(fstream->name, "stdin"))
+    \r {
+    \rfstream->stream = stdin;
+    \rreturn 0;
+    \r}
+  \r\r
+#ifndef _XBT_WIN32\r
+      sprintf(path, "%s/%s", fstream->directory, fstream->name);
+  \r
+#else   /* \r */
+      sprintf(path, "%s\\%s", fstream->directory, fstream->name);
+  \r
+#endif  /* \r */
+      \rif (!(fstream->stream = fopen(path, "r")))
+    \r {
+    \rreturn -1;
+    \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r fstream_close(fstream_t fstream) \r
+{
+  \r
+      /* check the parameter */ \r
+      if (!(fstream) || !strcmp(fstream->name, "stdin"))
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rif (!fstream->stream)
+    \rreturn EBADF;
+  \r\rif (EOF == fclose(fstream->stream))
+    \rreturn -1;
+  \r\rfstream->stream = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rint \r fstream_free(fstream_t * ptr) \r
+{
+  \r\r
+      /* check the parameter */ \r
+      if (!(*ptr))
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rif (!(*ptr))
+    \rreturn EINVAL;
+  \r\rif ((*ptr)->stream)
+    \rfclose((*ptr)->stream);
+  \r\rif ((*ptr)->name)
+    \rfree((*ptr)->name);
+  \r\rif ((*ptr)->directory)
+    \rfree((*ptr)->directory);
+  \r\rfree(*ptr);
+  \r\r*ptr = NULL;
+  \r\rreturn 0;
+\r\r}
+
+\r\rint \r fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex) \r
+{
+  \rsize_t len;
+  \rchar *line = NULL;
+  \rint line_num = 0;
+  \rchar file_pos[256];
+  \rxbt_strbuff_t buff;
+  \rint buffbegin = 0;
+  \rcontext_t context;
+  \runit_t unit;
+  \r\r
+      /* Count the line length while checking wheather it's blank */ \r
+  int blankline;
+  \rint linelen;
+  \r
+      /* Deal with \ at the end of the line, and call handle_line on result */ \r
+  int to_be_continued;
+  \r\r
+      /* check the parameter */ \r
+      if (!(fstream) || !mutex)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rbuff = xbt_strbuff_new();
+  \r\rif (!(context = context_new()))
+    \rreturn -1;
+  \r\runit = fstream->unit;
+  \r\r
+      /*while(!(unit->root->interrupted)  && getline(&line, &len, fstream->stream) != -1) */ \r
+      while (!(unit->root->interrupted)
+             && fstream_getline(fstream, &line, &len) != -1)
+    \r {
+    \r\rblankline = 1;
+    \rlinelen = 0;
+    \rto_be_continued = 0;
+    \r\rline_num++;
+    \r\rwhile (line[linelen] != '\0')
+      \r {
+      \rif (line[linelen] != ' ' && line[linelen] != '\t'
+           && line[linelen] != '\n' && line[linelen] != '\r')
+        \rblankline = 0;
+      \r\rlinelen++;
+      \r}
+    \r\rif (blankline)
+      \r {
+      \rif (!context->command_line
+           && (context->input->used || context->output->used))
+        \r {
+        \rsnprintf(file_pos, 256, "%s:%d", fstream->name, line_num);
+        \rERROR1("[%s] Error : no command found in the last chunk of lines",
+                file_pos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, file_pos);
+        \r\rfailure(unit);
+        \rbreak;
+        \r}
+      \r
+      else if (unit->is_running_suite)
+        \r {                     /* it's the end of a suite */
+        \r\runit_t * current_suite =
+            xbt_dynar_get_ptr(unit->suites,
+                              xbt_dynar_length(unit->suites) - 1);
+        \r\rif (!xbt_dynar_length((*current_suite)->includes))
+          \r {
+          \rERROR2("[%s] Malformated suite `(%s)' : include missing",
+                  file_pos, (*current_suite)->description);
+          \r\runit_set_error(*current_suite, ESYNTAX, 1, file_pos);
+          \r\rfailure(unit);
+          \r\r}
+        \r\runit->is_running_suite = 0;
+        \r}
+      \r\rif (context->command_line)
+        \r {
+        \r
+#ifdef _XBT_WIN32\r
+            if (!context->is_not_found)
+          \r {
+          \r
+#endif  /* \r */
+              if (fstream_launch_command(fstream, context, mutex) < 0)
+            \rbreak;
+          \r\r
+#ifdef _XBT_WIN32\r
+          }
+        \r
+#endif  /* \r */
+        }
+      \r\rcontinue;
+      \r}
+    \r\rif (linelen > 1 && line[linelen - 2] == '\\')
+      \r {
+      \rif (linelen > 2 && line[linelen - 3] == '\\')
+        \r {
+        \r
+            /* Damn. Escaped \ */ \r
+            line[linelen - 2] = '\n';
+        \rline[linelen - 1] = '\0';
+        \r}
+      \r
+      else
+        \r {
+        \rto_be_continued = 1;
+        \rline[linelen - 2] = '\0';
+        \rlinelen -= 2;
+        \r\rif (!buff->used)
+          \rbuffbegin = line_num;
+        \r}
+      \r}
+    \r\rif (buff->used || to_be_continued)
+      \r {
+      \rxbt_strbuff_append(buff, line);
+      \r\rif (!to_be_continued)
+        \r {
+        \rsnprintf(file_pos, 256, "%s:%d", fstream->name, buffbegin);
+        \rfstream_lex_line(fstream, context, mutex, file_pos, buff->data);
+        \rxbt_strbuff_empty(buff);
+        \r}
+      \r}
     \r
-       if(!(*ptr))\r
-               return EINVAL;\r
-               \r
-       if((*ptr)->stream)\r
-               fclose((*ptr)->stream);\r
-       \r
-       if((*ptr)->name)\r
-               free((*ptr)->name);\r
-       \r
-       if((*ptr)->directory)\r
-               free((*ptr)->directory);\r
-               \r
-       free(*ptr);\r
-\r
-       *ptr = NULL;\r
-       \r
-       return 0;\r
-               \r
-}\r
-\r
-int\r
-fstream_parse(fstream_t fstream, xbt_os_mutex_t mutex)\r
-{\r
-       size_t len;\r
-       char * line = NULL;\r
-       int line_num = 0;\r
-       char file_pos[256];\r
-       xbt_strbuff_t buff;\r
-       int buffbegin = 0; \r
-       context_t context;\r
-       unit_t unit;\r
-       \r
-       /* Count the line length while checking wheather it's blank */\r
-       int blankline;\r
-       int linelen;    \r
-       /* Deal with \ at the end of the line, and call handle_line on result */\r
-       int to_be_continued;\r
-       \r
-       /* check the parameter */\r
-       if(!(fstream) || !mutex)\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
+    else
+      \r {
+      \rsnprintf(file_pos, 256, "%s:%d", fstream->name, line_num);
+      \rfstream_lex_line(fstream, context, mutex, file_pos, line);
+      \r}
+    \r}
+  \r\r
+      /* Check that last command of the file ran well */ \r
+      if (context->command_line)
+    \r {
     \r
-       buff = xbt_strbuff_new();\r
-       \r
-       if(!(context = context_new()))\r
-               return -1;\r
-               \r
-       unit = fstream->unit;\r
-       \r
-       /*while(!(unit->root->interrupted)  && getline(&line, &len, fstream->stream) != -1)*/\r
-       while(!(unit->root->interrupted)  && fstream_getline(fstream, &line, &len) != -1)\r
-       {\r
-               \r
-               blankline=1;\r
-               linelen = 0;    \r
-               to_be_continued = 0;\r
-\r
-               line_num++;\r
-               \r
-               while(line[linelen] != '\0') \r
-               {\r
-                       if (line[linelen] != ' ' && line[linelen] != '\t' && line[linelen]!='\n' && line[linelen]!='\r')\r
-                               blankline = 0;\r
-                       \r
-                       linelen++;\r
-               }\r
-       \r
-               if(blankline) \r
-               {\r
-                       if(!context->command_line && (context->input->used || context->output->used))\r
-                       {\r
-                               snprintf(file_pos,256,"%s:%d",fstream->name, line_num);\r
-                               ERROR1("[%s] Error : no command found in the last chunk of lines", file_pos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, file_pos);\r
-\r
-                               failure(unit);\r
-                               break;\r
-                       }\r
-                       else if(unit->is_running_suite)\r
-                       {/* it's the end of a suite */\r
-                               \r
-                               unit_t* current_suite = xbt_dynar_get_ptr(unit->suites, xbt_dynar_length(unit->suites) - 1);\r
-\r
-                               if(!xbt_dynar_length((*current_suite)->includes))\r
-                               {\r
-                                       ERROR2("[%s] Malformated suite `(%s)' : include missing", file_pos, (*current_suite)->description);\r
-                               \r
-                                       unit_set_error(*current_suite, ESYNTAX, 1, file_pos);\r
-\r
-                                       failure(unit);\r
-                                       \r
-                               }\r
-                       \r
-                               unit->is_running_suite = 0;\r
-                       }\r
-                               \r
-                       if(context->command_line)\r
-                       {\r
-                               #ifdef _XBT_WIN32\r
-                               if(!context->is_not_found)\r
-                               {\r
-                               #endif\r
-                               if(fstream_launch_command(fstream, context, mutex) < 0)\r
-                                               break;\r
-\r
-                               #ifdef _XBT_WIN32\r
-                               }\r
-                               #endif\r
-                       }\r
-               \r
-                       continue;\r
-               }\r
-               \r
-               if(linelen>1 && line[linelen-2]=='\\') \r
-               {\r
-                       if(linelen>2 && line[linelen-3] == '\\') \r
-                       {\r
-                               /* Damn. Escaped \ */\r
-                               line[linelen-2] = '\n';\r
-                               line[linelen-1] = '\0';\r
-                       } \r
-                       else \r
-                       {\r
-                               to_be_continued = 1;\r
-                               line[linelen-2] = '\0';\r
-                               linelen -= 2;  \r
-                               \r
-                               if (!buff->used)\r
-                                       buffbegin = line_num;\r
-                       }\r
-               }\r
-       \r
-               if(buff->used || to_be_continued) \r
-               { \r
-                       xbt_strbuff_append(buff,line);\r
-       \r
-                       if (!to_be_continued) \r
-                       {\r
-                               snprintf(file_pos,256,"%s:%d",fstream->name, buffbegin);\r
-                               fstream_lex_line(fstream, context, mutex, file_pos, buff->data);    \r
-                               xbt_strbuff_empty(buff);\r
-                       }\r
-               } \r
-               else \r
-               {\r
-                       snprintf(file_pos,256,"%s:%d",fstream->name, line_num);\r
-                       fstream_lex_line(fstream, context, mutex, file_pos, line);      \r
-               }\r
-       }\r
-       \r
-       /* Check that last command of the file ran well */\r
-       if(context->command_line)\r
-       {\r
-               #ifdef _XBT_WIN32\r
-               if(!context->is_not_found)\r
-               {\r
-               #endif\r
-\r
-               if(fstream_launch_command(fstream, context, mutex) < 0)\r
-                       return -1;\r
-\r
-               #ifdef _XBT_WIN32\r
-               }\r
-               #endif\r
-       }\r
-       \r
-       /* clear buffers */\r
-       if(line)\r
-               free(line);\r
-               \r
-       xbt_strbuff_free(buff); \r
-       \r
-       if(context_free(&context) < 0)\r
-               return -1;\r
-       \r
-       return (exit_code || errno) ? -1 : 0;\r
-}\r
-\r
-\r
-void \r
-fstream_lex_line(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char * filepos, char *line) \r
-{\r
-       char* line2;\r
-       variable_t variable;\r
-       unsigned int i;\r
-       char exp[PATH_MAX + 1] = {0};\r
-       unit_t unit = fstream->unit;\r
-       xbt_dynar_t variables = unit->runner->variables;\r
-       char* p= NULL;\r
-       char* end = NULL;\r
-       char* val = NULL;\r
-       char buff[PATH_MAX + 1] = {0}; \r
-       size_t len;\r
-       char delimiters[4] = {' ', '\t', '\n', '\0'}; \r
-       \r
-       int j;\r
-       \r
-       if(line[0] == '#')\r
-               return;\r
-\r
-       if(unit->is_running_suite && strncmp(line, "! include", strlen("! include")))\r
-       {/* it's the end of a suite */\r
-               \r
-               unit_t* current_suite = xbt_dynar_get_ptr(unit->suites, xbt_dynar_length(unit->suites) - 1);\r
-\r
-               if(!xbt_dynar_length((*current_suite)->includes))\r
-                       ERROR2("[%s] Malformated suite `(%s)': include missing", filepos, (*current_suite)->description);\r
-               else\r
-                       ERROR2("[%s] Malformated suite `(%s)': blank line missing", filepos, (*current_suite)->description);\r
-               \r
-               unit_set_error(*current_suite, ESYNTAX, 1, filepos);\r
-\r
-               failure(fstream->unit);\r
-       }\r
-       \r
-       context->line = strdup(filepos);\r
-       \r
-       /* search end */\r
-       xbt_str_rtrim(line + 2,"\n");\r
-       \r
-       line2 = strdup(line);\r
-\r
-       len = strlen(line2 + 2) + 1;\r
-\r
-       /* replace each variable by its value */\r
-       xbt_os_mutex_acquire(unit->mutex);\r
-       \r
-\r
-       /* replace all existing\r
-          ${var}\r
-          ${var:=val}\r
-          ${var:+val}\r
-          ${var:-val}\r
-          ${var:?val}\r
-          ${#var}\r
-   */\r
-       \r
-       xbt_dynar_foreach(variables, i, variable)\r
-       {\r
-               if(!(p = strstr(line2 + 2, "${")))\r
-                       break;\r
-\r
-               memset(buff, 0, len);\r
-\r
-               sprintf(buff,"${%s",variable->name);\r
-               \r
-               /* FALSE */\r
-               if((p = strstr(line2 + 2, buff)))\r
-               {\r
-                       memset(buff, 0, len);\r
-                       p--;\r
-                       j = 0;\r
-\r
-                       while(*(p++) != '\0')\r
-                       {\r
-                               buff[j++] = *p;\r
-\r
-                               if(*p == '}')\r
-                                       break;\r
-                       }\r
-\r
-                       if(buff[j - 1] != '}')\r
-                       {\r
-                               xbt_os_mutex_release(unit->mutex);      \r
-                               \r
-                               \r
-                               ERROR2("[%s] Syntax error : `%s'.",filepos, p - j);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               failure(fstream->unit);\r
-                               return;\r
-                       }\r
-\r
-                       if((p = strstr(buff , ":=")))\r
-                       {\r
-                               /* ${var:=val} */\r
-                               \r
-                               /* if the value of the variable is empty, update its value by the value*/\r
-                               p += 2;\r
-                               \r
-                               end = strchr(p, '}');\r
-\r
-                               if(!end || (end == p))\r
-                               {\r
-                                       xbt_os_mutex_release(unit->mutex);      \r
-                               \r
-                               \r
-                                       ERROR2("[%s] Bad substitution : `%s'.",filepos, strstr(buff, "${"));\r
-                               \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(fstream->unit);\r
-                                       return;\r
-                               }\r
-\r
-                               val = (char*) calloc((size_t)(end - p) + 1, sizeof(char));\r
-\r
-                               strncpy(val, p,(end - p));\r
-                               \r
-                               \r
-                               /* replace the expression by the expression of the value of the variable*/\r
-                               sprintf(exp, "${%s:=%s}", variable->name, val);\r
-\r
-                               if(variable->val)\r
-                                       str_replace_all(&line2, exp, variable->val, NULL);\r
-                               else\r
-                               {\r
-                                       str_replace_all(&line2, exp, val, NULL);\r
-\r
-                                       variable->val = strdup(val);\r
-                               }\r
-\r
-                               memset(exp, 0, VAR_NAME_MAX + 1);\r
-\r
-                               if(val)\r
-                               {\r
-                                       free(val);\r
-                                       val = NULL;\r
-                               }\r
-\r
-                       }\r
-                       else if((p = strstr(buff, ":-")))\r
-                       {\r
-                               /* ${var:-val} */\r
-                               \r
-                               /* if the value of the variable is empty, replace the expression by the value */\r
-                               p += 2;\r
-                               end = strchr(p, '}');\r
-\r
-                               if(!end || (end == p))\r
-                               {\r
-                                       xbt_os_mutex_release(unit->mutex);      \r
-                               \r
-                                       ERROR2("[%s] Bad substitution : `%s'.",filepos, strstr(line2, "${"));\r
-                               \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(fstream->unit);\r
-                                       return;\r
-                               }\r
-\r
-                               val = (char*) calloc((size_t)(end - p) + 1, sizeof(char));\r
-\r
-                               strncpy(val, p,(end - p)); \r
-\r
-                               sprintf(exp, "${%s:-%s}", variable->name, val);\r
-                               \r
-                               str_replace_all(&line2, exp, variable->val ? variable->val : val, NULL);\r
-                               \r
-\r
-                               memset(exp, 0, VAR_NAME_MAX + 1);\r
-                               \r
-                               if(val)\r
-                               {\r
-                                       free(val);\r
-                                       val = NULL;\r
-                               }\r
-\r
-                       }\r
-                       else if((p = strstr(buff, ":+")))\r
-                       {\r
-                               /* ${var:+val} */\r
-       \r
-                               /* if the value of the variable is not empty, replace the expression by the value */\r
-                               p += 2;\r
-\r
-                               end = strchr(p, '}');\r
-\r
-                               if(!end || (end == p))\r
-                               {\r
-                                       xbt_os_mutex_release(unit->mutex);      \r
-                               \r
-                               \r
-                                       ERROR2("[%s] Bad substitution : `%s'.",filepos, strstr(line2, "${"));\r
-                               \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(fstream->unit);\r
-                                       return;\r
-                               }\r
-\r
-                               val = (char*) calloc((size_t)(end - p) + 1, sizeof(char));\r
-\r
-                               strncpy(val, p,(end - p));\r
-\r
-                               sprintf(exp, "${%s:+%s}", variable->name, val);\r
-\r
-                               if(variable->val)\r
-                               {\r
-                                       str_replace_all(&line2, exp, val, NULL);\r
-                               }\r
-                               else\r
-                               {\r
-                                       str_replace_all(&line2, exp, NULL , NULL);\r
-                                       variable->val = strdup(val);\r
-                               }\r
-                               \r
-                               memset(exp, 0, VAR_NAME_MAX + 1);\r
-                               \r
-                               if(val)\r
-                               {\r
-                                       free(val);\r
-                                       val = NULL;\r
-                               }\r
-                       }\r
-                       else if((p = strstr(buff, ":?")))\r
-                       {\r
-                               /*  ${var:?val} */\r
-       \r
-                               /* if the value of the variable is not empty, replace the expression by the value */\r
-                               p += 2;\r
-                               end = strchr(p, '}');\r
-\r
-                               if(!end || (end == p))\r
-                               {\r
-                                       xbt_os_mutex_release(unit->mutex);      \r
-                               \r
-                                       ERROR2("[%s] Bad substitution : `%s'.",filepos, strstr(line2, "${"));\r
-                               \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(fstream->unit);\r
-                                       return;\r
-                               }\r
-\r
-                               val = (char*) calloc((size_t)(end - p) + 1, sizeof(char));\r
-\r
-                               strncpy(val, p,(end - p));\r
-\r
-                               sprintf(exp, "${%s:?%s}", variable->name, val);\r
-                               \r
-                               if(variable->val)\r
-                                       str_replace_all(&line2, exp, variable->val, NULL);\r
-                               else\r
-                               {\r
-\r
-                                       xbt_os_mutex_release(unit->mutex);      \r
-\r
-                                       ERROR2("[%s] %s.",filepos, val);\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(fstream->unit);\r
-                                       return;\r
-                               }\r
-                               \r
-                               memset(exp, 0, VAR_NAME_MAX + 1);\r
-                               \r
-                               if(val)\r
-                               {\r
-                                       free(val);\r
-                                       val = NULL;\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       /* replace all existing $var */\r
-       xbt_dynar_foreach(variables, i, variable)\r
-       {\r
-               if(!strchr(line2 + 2, '$'))\r
-                       break;\r
-\r
-               if(strstr(line2 + 2, variable->name))\r
-               {\r
-\r
-                       sprintf(exp, "${#%s}", variable->name);\r
-                       \r
-                       if(strstr(line2 + 2, exp))\r
-                       {\r
-\r
-                               if(variable->val)\r
-                               {\r
-                                       char slen[4] = {0};\r
-                                       sprintf(slen,"%d", (int)strlen(variable->val));\r
-                                       str_replace_all(&line2, exp, slen, NULL);\r
-                               }\r
-                               else\r
-                                       str_replace_all(&line2, exp, "0", NULL);\r
-                       }\r
-\r
-                       memset(exp, 0, VAR_NAME_MAX + 1);\r
-\r
-                       sprintf(exp, "${%s}", variable->name);\r
-\r
-                       if(strstr(line2 + 2, exp))\r
-                       {\r
-                               if(variable->val)\r
-                                       str_replace_all(&line2, exp, variable->val, NULL);\r
-                               else\r
-                                       str_replace_all(&line2, exp, NULL, NULL);\r
-                       }\r
-\r
-                       memset(exp, 0, VAR_NAME_MAX + 1);\r
-\r
-                       sprintf(exp, "$%s", variable->name);\r
-                       \r
-                       if((p = strstr(line2 + 2, exp)))\r
-                       {\r
-                               if((p + strlen(variable->name) + 1)[0] != '\0' && !(isalpha((p + strlen(variable->name) + 1)[0])))\r
-                                       delimiters[0] = (p + strlen(variable->name) + 1)[0];\r
-\r
-                               if(variable->val)\r
-                                       str_replace_all(&line2, exp, variable->val,  delimiters);\r
-                               else\r
-                                       str_replace_all(&line2, exp, NULL, delimiters);\r
-                       }\r
-\r
-                       memset(exp, 0, VAR_NAME_MAX + 1);\r
-\r
-               }\r
-       }\r
-\r
-       while((p = strstr(line2 + 2, "${")))\r
-       {\r
-               /*if(*(p+1) != '{')\r
-               {\r
-                       j = 0;\r
-                       p --;\r
-\r
-                       while(*(p++) != '\0')\r
-                       {\r
-                               if(*p != ' ' && *p !='\t')\r
-                                       exp[j++] = *p;\r
-                               else\r
-                                       break;\r
-\r
-                       }\r
-                       \r
-                       str_replace_all(&line2, exp, NULL, " \t\n\r");\r
-                       memset(exp, 0, VAR_NAME_MAX + 1);\r
-               }.\r
-               else\r
-               */\r
-               {\r
-                       char* begin = NULL;\r
-                       \r
-                       j = 0;\r
-                       p --;\r
-\r
-                       while(*(p++) != '\0')\r
-                       {\r
-                               if((!begin && *p != ' ' && *p !='\t') || begin)\r
-                               {\r
-                                       /* `:' must be before this caracter, bad substitution : exit loop \r
-                                           ||\r
-                                               the current character is already present, bad substitution : exit loop\r
-                                               */\r
-                                       if(\r
-                                                       (\r
-                                                               *(p - 1) != ':' && (\r
-                                                                                                               (*p == '=') || (*p == '-') || (*p == '+') || (*p == '?')\r
-                                                                                                       )\r
-                                                       )\r
-                                               || \r
-                                                       (\r
-                                                               begin &&        (\r
-                                                                                               (*p == ':') || (*p == '=') || (*p == '-') || (*p == '+') || (*p == '?')\r
-                                                                                       )\r
-                                                       )\r
-                                               )\r
-                                               break;\r
-                                       else\r
-                                               exp[j++] = *p;\r
-\r
-                                       if(*p == ':')\r
-                                       {\r
-                                               /* save the begining of the value */\r
-                                               if((*(p+1) == '=') || (*(p+1) == '-') || (*(p+1) == '+') || (*(p+1) == '?'))\r
-                                               {\r
-                                                       begin = p + 2;\r
-                                                       exp[j++] = *(p+1);\r
-                                                       p++;\r
-                                                       continue;\r
-\r
-                                               }\r
-                                               else\r
-                                               /* the current char is `:' but the next is invalid, bad substitution : exit loop */\r
-                                                       break;\r
-                                       }\r
-                                       /* end of the substitution : exit loop */\r
-                                       else if(*p == '}')\r
-                                               break;\r
-                               }\r
-                               else\r
-                                       break;\r
-                       }\r
-                       \r
-                       if(exp[j - 1] == '}')\r
-                       {\r
-                               if(exp[2] == '#')\r
-                               {\r
-                                       /* ${#var} */\r
-\r
-\r
-                                       if(4 == strlen(exp))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-                                       \r
-                                       str_replace_all(&line2, exp, "0", NULL);        \r
-                               }\r
-                               else if(strstr(exp,":="))\r
-                               {\r
-                                       /* ${var:=value} */     \r
-                                       \r
-                                       end = strchr(p, '}');\r
-\r
-                                       if(!end || (end == begin))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-\r
-                                       variable = xbt_new0(s_variable_t, 1);\r
-\r
-                                       variable->val = (char*) calloc((size_t)(end - begin) + 1, sizeof(char));\r
-\r
-                                       strncpy(variable->val, begin ,(end - begin));\r
-\r
-                                       begin = exp + 2;\r
-                                       end = strchr(exp, ':');\r
-\r
-                                       if(!end || (end == begin))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-\r
-                                       variable->name = (char*) calloc((size_t)(end - begin) + 1, sizeof(char));\r
-\r
-                                       strncpy(variable->name, exp + 2 ,(end - begin));\r
-\r
-                                       str_replace_all(&line2, exp, variable->val, NULL);\r
-\r
-                                       xbt_dynar_push(variables, &variable);\r
-\r
-                               }\r
-                               else if(strstr(exp,":-"))\r
-                               {\r
-                                       /* ${var:-value} */     \r
-\r
-                                       \r
-                                       end = strchr(p, '}');\r
-\r
-                                       if(!end || (end == begin))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-\r
-                                       val = (char*) calloc((size_t)(end - begin) + 1, sizeof(char));\r
-\r
-                                       strncpy(val, begin ,(end - begin));\r
-\r
-                                       str_replace_all(&line2, exp, val, NULL);\r
-\r
-                                       if(val)\r
-                                               free(val);\r
-\r
-                               }\r
-                               else if(strstr(exp,":+"))\r
-                               {\r
-                                       /* ${var:+value} */     \r
-\r
-                                       end = strchr(p, '}');\r
-\r
-                                       if(!end || (end == begin))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-\r
-                                       str_replace_all(&line2, exp, NULL, NULL);\r
-                               }\r
-                               else if(strstr(exp,":?"))\r
-                               {\r
-                                       /* ${var:?value} */\r
-                                       \r
-                                       end = strchr(p, '}');\r
-\r
-                                       if(!end || (end == begin))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-\r
-                                       val = (char*) calloc((size_t)(end - begin) + 1, sizeof(char));\r
-\r
-                                       strncpy(val, begin ,(end - begin));\r
-\r
-                                       xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                       ERROR2("[%s] : `%s'.",filepos, val);\r
-\r
-                                       if(val)\r
-                                               free(val);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(fstream->unit);\r
-\r
-                                       return;\r
-                                       \r
-                               }\r
-                               else\r
-                               {\r
-                                       /* ${var} */\r
-\r
-                                       if(3 == strlen(exp))\r
-                                       {\r
-                                               xbt_os_mutex_release(unit->mutex);      \r
-                                       \r
-                                               ERROR2("[%s] Bad substitution : `%s'.",filepos, strchr(line2 + 2, '$'));\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(fstream->unit);\r
-                                               return;\r
-                                       }\r
-\r
-                                       str_replace_all(&line2, exp, NULL, NULL);\r
-                                       \r
-                               }\r
-\r
-                               memset(exp, 0, VAR_NAME_MAX + 1);\r
-                       }\r
-                       else\r
-                       {\r
-                               xbt_os_mutex_release(unit->mutex);      \r
-                               \r
-                               if(strstr(line2 + 2, "${"))\r
-                                       ERROR2("[%s] Bad substitution : `%s'.",filepos, strstr(line2, "${"));\r
-                               else\r
-                                       ERROR2("[%s] Syntax error : `%s'.",filepos, strstr(line2, "${"));\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               failure(fstream->unit);\r
-                               return;\r
-                       }\r
-\r
-               }\r
-               \r
-       }\r
-       \r
-       while(1)\r
-       {\r
-               p = line2 + (line2[0] =='<' ? 4 : 2);\r
-               \r
-               if((p = strchr(p, '$')))\r
-               {\r
-                       if(*(p+1) != ' ')\r
-                       {\r
-                               j = 0;\r
-                               p --;\r
-\r
-                               while(*(p++) != '\0')\r
-                               {\r
-                                       if(*p != ' ' && *p !='\t')\r
-                                               exp[j++] = *p;\r
-                                       else\r
-                                               break;\r
-\r
-                               }\r
-                               \r
-                               str_replace_all(&line2, exp, NULL, " \t\n\r");\r
-                               memset(exp, 0, VAR_NAME_MAX + 1);\r
-                       }\r
-                       else\r
-                       {\r
-                               /* maybe < $ cmd */\r
-                               p++;\r
-                       }\r
-               }\r
-               else\r
-                       break;\r
-       }\r
-\r
-       xbt_os_mutex_release(unit->mutex);      \r
-       \r
-       switch(line2[0]) \r
-       {\r
-               /*case '#': \r
-               break;\r
-               */\r
-               \r
-               case '$':\r
-               case '&':\r
-\r
-               if(line[1] != ' ')\r
-               {\r
-                       \r
-                       if(line2[0] == '$')\r
-                               ERROR1("[%s] Missing space after `$' `(usage : $ <command>)'", filepos);\r
-                       else\r
-                               ERROR1("[%s] Missing space after & `(usage : & <command>)'", filepos);\r
-               \r
-                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                       failure(unit);\r
-                       return;\r
-               }\r
-                       \r
-               context->async = (line2[0] == '&');\r
-\r
-               \r
-               /* further trim useless chars which are significant for in/output */\r
-               xbt_str_rtrim(line2 + 2," \t");\r
-               \r
-               /* deal with CD commands here, not in context */\r
-               if(!strncmp("cd ",line2 + 2, 3)) \r
-               {\r
-                       char* dir = strdup(line2 + 4);\r
-                       \r
-                       if(context->command_line)\r
-                       {\r
-                               if(fstream_launch_command(fstream, context, mutex) < 0)\r
-                                       return;\r
-                       }\r
-               \r
-                       /* search begining */\r
-                       while(*(dir++) == ' ');\r
-                       \r
-                       dir--;\r
-                       \r
-                       if(!dry_run_flag)\r
-                       {\r
-                               if(!silent_flag)\r
-                                       INFO2("[%s] cd %s", filepos, dir);\r
-                               \r
-                               if(!just_print_flag)\r
-                               {\r
-                                       if(chdir(dir))\r
-                                       {\r
-                                               ERROR3("[%s] Chdir to %s failed: %s",filepos, dir,error_to_string(errno, 0));\r
-                                               unit_set_error(fstream->unit, errno, 0, filepos);\r
-\r
-                                               failure(unit);\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-                       break;\r
-               }\r
-               else\r
-               {\r
-                       fstream_process_token(fstream, context, mutex, filepos, line2[0], line2 + 2);\r
-                       break;\r
-               }\r
-               \r
-               case '<':\r
-               case '>':\r
-               case '!':\r
-               \r
-               if(line[0] == '!' && line[1] != ' ')\r
-               {\r
-                       ERROR1("[%s] Missing space after `!' `(usage : ! <command> [[=]value])'", filepos);\r
-               \r
-                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                       failure(unit);\r
-                       return;\r
-               }\r
-\r
-               fstream_process_token(fstream, context, mutex, filepos, line2[0], line2 + 2);    \r
-               break;\r
-               \r
-               case 'p':\r
-               \r
-               {\r
-                       unsigned int j;\r
-                       int is_blank = 1;\r
-                       \r
-                       char* prompt = line2 + 2;\r
-\r
-                       for(j = 0; j < strlen(prompt); j++)\r
-                       {\r
-                               if (prompt[j] != ' ' && prompt[j] != '\t')\r
-                               {\r
-                                       is_blank = 0;\r
-                                       break;\r
-                               }\r
-                       }\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Bad usage of the metacommand p `(usage : p <prompt>)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-\r
-                       if(!dry_run_flag)\r
-                               INFO2("[%s] %s",filepos,prompt);\r
-               }\r
-\r
-               \r
-               break;\r
-               \r
-               case 'P':\r
-               \r
-               {\r
-                       unsigned int j;\r
-                       int is_blank = 1;\r
-                               \r
-                       char* prompt = line2 + 2;\r
-\r
-                       for(j = 0; j < strlen(prompt); j++) \r
-                               if (prompt[j] != ' ' && prompt[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Bad usage of the metacommand P `(usage : P <prompt>)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-\r
-                       if(!dry_run_flag)               \r
-                               CRITICAL2("[%s] %s",filepos, prompt);\r
-               }\r
-\r
-               break;\r
-               \r
-               case 'D':\r
-                       if(unit->description)\r
-                               WARN2("[%s] Description already specified `%s'",filepos, line2 + 2); \r
-                       else\r
-                       {\r
-                               unsigned int j;\r
-                               int is_blank = 1;\r
-                               \r
-                               char* desc = line2 + 2;\r
-\r
-                               for(j = 0; j < strlen(desc); j++) \r
-                                       if (desc[j] != ' ' && desc[j] != '\t')\r
-                                               is_blank = 0;\r
-\r
-                               if(is_blank)\r
-                               {\r
-                                       ERROR1("[%s] Bad usage of the metacommand D `(usage : D <Description>)'", filepos);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-\r
-                               unit->description = strdup(desc);\r
-                       }\r
-               break;\r
-               \r
-               default:\r
-               ERROR2("[%s] Syntax error `%s'", filepos, line2);\r
-               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-               failure(unit);\r
-               break;\r
-       }\r
-       \r
-       free(line2);\r
-}\r
-\r
-void \r
-fstream_process_token(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char* filepos, char token, char *line) \r
-{\r
-       unit_t unit = fstream->unit;\r
-       \r
-       switch (token) \r
-       {\r
-               case '$':\r
-               case '&':\r
-               \r
-               if(context->command_line) \r
-               {\r
-                       \r
-                       if(context->output->used || context->input->used) \r
-                       {\r
-                               ERROR2("[%s] More than one command in this chunk of lines (previous: %s).\nDunno which input/output belongs to which command.",filepos, context->command_line);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       \r
-                       if(fstream_launch_command(fstream, context, mutex) < 0)\r
-                                       return;\r
-                       \r
-                       VERB1("[%s] More than one command in this chunk of lines",filepos);\r
-               }\r
-               \r
-               {\r
-                       size_t j,\r
-                       is_blank = 1;\r
-\r
-                       for(j = 0; j < strlen(line); j++) \r
-                               if (line[j] != ' ' && line[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               if(token == '$')\r
-                               ERROR1("[%s] Undefinite command for `$' `(usage: $ <command>)'", filepos);\r
-                               else\r
-                               ERROR1("[%s] Undefinite command for `&' `(usage: & <command>)'", filepos);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-               }\r
-               \r
-               context->command_line = strdup(line);\r
-\r
-               xbt_str_ltrim(context->command_line," ");\r
-               \r
-               context->line = /*strdup(filepos)*/ filepos;\r
-               context->pos = strdup(filepos);\r
-               \r
-               #ifdef _XBT_WIN32\r
-               {\r
-\r
-               /* translate the command line */\r
-\r
-               char* path = NULL;\r
-               char* delimiter;\r
-               char command_line[PATH_MAX + 1] = {0};\r
-               size_t i = 0;\r
-               char* args = NULL;\r
-\r
-               \r
-\r
-               /*if(strstr(context->command_line,".exe"))\r
-                       strcpy(command_line,context->command_line);*/\r
-               \r
-               {\r
-                       size_t len;\r
-                       \r
-                       size_t j = 0;\r
-       \r
-                       len = strlen(context->command_line);\r
-                       \r
-                       while(i < len)\r
-                       {\r
-                               if(context->command_line[i] != ' ' && context->command_line[i] != '\t' && context->command_line[i] != '>')\r
-                                       command_line[j++] = context->command_line[i];\r
-                               else\r
-                                       break;\r
-                                       \r
-                               i++;\r
-                       }\r
-                       \r
-                       if(!strstr(context->command_line,".exe"))\r
-                               strcat(command_line,".exe");\r
-\r
-                       args = strdup(context->command_line + i);\r
-               }\r
-               \r
-               if(!is_w32_cmd(command_line, fstream->unit->runner->path) && getpath(command_line, &path) < 0)\r
-               {\r
-                       command_t command;\r
-\r
-                       ERROR3("[%s] `%s' : NOK (%s)", filepos, command_line, error_to_string(ECMDNOTFOUND, 1));\r
-                       unit_set_error(fstream->unit, ECMDNOTFOUND, 1, filepos);\r
-\r
-                       context->is_not_found = 1;\r
-                       \r
-                       command = command_new(fstream->unit, context, mutex);\r
-\r
-                       command->status = cs_failed;\r
-                       command->reason = csr_command_not_found;\r
-\r
-                       failure(unit);\r
-                       \r
-                       \r
-                       return;\r
-               }\r
-               \r
-               delimiter = strrchr(command_line,'/');\r
-\r
-               if(!delimiter)\r
-                       delimiter = strrchr(command_line,'\\');\r
-               \r
-               /*free(context->command_line);*/\r
-               \r
-               \r
-               if(path)\r
-               {\r
-                       if(args)\r
-                       {\r
-                               context->t_command_line = (char*)calloc(strlen(path) + strlen(delimiter ? delimiter + 1 : command_line) + strlen(args) + 2, sizeof(char));\r
-                               sprintf(context->t_command_line,"%s\\%s%s",path,delimiter ? delimiter + 1 : command_line, args);\r
-\r
-                               free(args);\r
-\r
-                       }\r
-                       else\r
-                       {\r
-                               context->t_command_line = (char*)calloc(strlen(path) + strlen(delimiter ? delimiter + 1 : command_line) + 2, sizeof(char));\r
-                               sprintf(context->t_command_line,"%s\\%s",path,delimiter ? delimiter + 1 : command_line);\r
-                       }\r
-               \r
-                       free(path);\r
-               }\r
-               else\r
-               {\r
-                       if(args)\r
-                       {\r
-\r
-                               context->t_command_line = (char*)calloc(strlen(command_line) + strlen(args) + 1, sizeof(char));\r
-                               sprintf(context->t_command_line,"%s%s",command_line, args);\r
-\r
-                       \r
-                               free(args);\r
-\r
-                       }\r
-                       else\r
-                       {\r
-                               context->t_command_line = (char*)calloc(strlen(command_line) + 1, sizeof(char));\r
-                               strcpy(context->t_command_line,command_line);\r
-                       }\r
-               }\r
-\r
-\r
-               }\r
-               #endif\r
-\r
-\r
-               break;\r
-               \r
-               case '<':\r
-               xbt_strbuff_append(context->input,line);\r
-               xbt_strbuff_append(context->input,"\n");\r
-               break;\r
-               \r
-               case '>':\r
-               xbt_strbuff_append(context->output,line);\r
-               xbt_strbuff_append(context->output,"\n");\r
-               break;\r
-               \r
-               case '!':\r
-               \r
-               if(context->command_line)\r
-               {\r
-                       if(fstream_launch_command(fstream, context, mutex) < 0)\r
-                                       return;\r
-               }\r
-               \r
-               if(!strncmp(line,"timeout no",strlen("timeout no"))) \r
-               {\r
-                       VERB1("[%s] (disable timeout)", filepos);\r
-                       context->timeout = INDEFINITE;\r
-               } \r
-               else if(!strncmp(line,"timeout ",strlen("timeout "))) \r
-               {\r
-                       int i = 0;\r
-                       unsigned int j;\r
-                       int is_blank = 1;\r
-                       char* p = line + strlen("timeout ");\r
-\r
-\r
-                       for(j = 0; j < strlen(p); j++) \r
-                               if (p[j] != ' ' && p[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Undefinite timeout value `(usage :timeout <seconds>)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-       \r
-                       while(p[i] != '\0')\r
-                       {\r
-                               if(!isdigit(p[i]))\r
-                               {\r
-                                       ERROR2("[%s] Invalid timeout value `(%s)' : `(usage :timeout <seconds>)'", filepos, line + strlen("timeout "));\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-\r
-                               i++;\r
-                       }\r
-                       \r
-                       context->timeout = atoi(line + strlen("timeout"));\r
-                       VERB2("[%s] (new timeout value: %d)",filepos,context->timeout);\r
-               \r
-               } \r
-               else if (!strncmp(line,"expect signal ",strlen("expect signal "))) \r
-               {\r
-                       unsigned int j;\r
-                       int is_blank = 1;\r
-\r
-                       \r
-                       char* p = line + strlen("expect signal ");\r
-\r
-\r
-                       for(j = 0; j < strlen(p); j++) \r
-                               if (p[j] != ' ' && p[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Undefinite signal name `(usage :expect signal <signal name>)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-\r
-                       context->signal = strdup(line + strlen("expect signal "));\r
-                       \r
-                       xbt_str_trim(context->signal," \n");\r
-\r
-                       #ifdef _XBT_WIN32\r
-                       if(!strstr("SIGSEGVSIGTRAPSIGBUSSIGFPESIGILL", context->signal))\r
-                       {\r
-                               ERROR2("[%s] Signal `%s' not supported by this platform", filepos, context->signal);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       #else\r
-                       if(!sig_exists(context->signal))\r
-                       {\r
-                               ERROR2("[%s] Signal `%s' not supported by Tesh", filepos, context->signal);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-\r
-                       #endif\r
-\r
-                       \r
-                       VERB2("[%s] (next command must raise signal %s)", filepos, context->signal);\r
-               \r
-               } \r
-               else if (!strncmp(line,"expect return ",strlen("expect return "))) \r
-               {\r
-\r
-                       int i = 0;\r
-                       unsigned int j;\r
-                       int is_blank = 1;\r
-                       char* p = line + strlen("expect return ");\r
-\r
-\r
-                       for(j = 0; j < strlen(p); j++) \r
-                               if (p[j] != ' ' && p[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Undefinite return value `(usage :expect return <return value>)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       \r
-                       while(p[i] != '\0')\r
-                       {\r
-                               if(!isdigit(p[i]))\r
-                               {\r
-                                       ERROR2("[%s] Invalid exit code value `(%s)' : must be an integer >= 0 and <=255",  filepos, line + strlen("expect return "));\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-\r
-                               i++;\r
-                       }\r
-\r
-                       context->exit_code = atoi(line+strlen("expect return "));\r
-                       VERB2("[%s] (next command must return code %d)",filepos, context->exit_code);\r
-               \r
-               } \r
-               else if (!strncmp(line,"output ignore",strlen("output ignore"))) \r
-               {\r
-                       context->output_handling = oh_ignore;\r
-                       VERB1("[%s] (ignore output of next command)", filepos);\r
-               \r
-               } \r
-               else if (!strncmp(line,"output display",strlen("output display"))) \r
-               {\r
-                       context->output_handling = oh_display;\r
-                       VERB1("[%s] (ignore output of next command)", filepos);\r
-               \r
-               } \r
-               else if(!strncmp(line,"include ", strlen("include ")))\r
-               {\r
-                       char* p1;\r
-                       char* p2;\r
-                       \r
-                       p1 = line + strlen("include");\r
-                       \r
-                       while(*p1 == ' ' || *p1 == '\t')\r
-                               p1++;\r
-                               \r
-                       \r
-                       if(p1[0] == '\0')\r
-                       {\r
-                               ERROR1("[%s] no file specified : `(usage : include <file> [<description>])'", filepos);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       else\r
-                       {\r
-                               char file_name[PATH_MAX + 1] = {0};\r
-                               \r
-                               p2 = p1;\r
-                               \r
-                               while(*p2 != '\0' && *p2 != ' ' && *p2 != '\t')\r
-                                       p2++;\r
-                                       \r
-                               strncpy(file_name, p1, p2 - p1);\r
-                               \r
-                               \r
-                               if(p2[0] != '\0')\r
-                                       while(*p2 == ' ' || *p2 == '\t')\r
-                                               p2++;\r
-                                       \r
-                               fstream_handle_include(fstream, context, mutex, file_name, p2[0] != '\0' ? p2 : NULL);\r
-                               \r
-                       }\r
-               }\r
-               else if(!strncmp(line,"suite ", strlen("suite ")))\r
-               {\r
-                       unsigned int j;\r
-                       int is_blank = 1;\r
-                       char* p = line + strlen("suite ");\r
-\r
-\r
-                       for(j = 0; j < strlen(p); j++) \r
-                               if (p[j] != ' ' && p[j] != '\t')\r
-                                       is_blank = 0;\r
-                       \r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Undefinite suit description : `(usage : suite <description>)", filepos);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-\r
-                       if(unit->is_running_suite)\r
-                       {\r
-                               ERROR1("[%s] Suite already in progress", filepos);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       \r
-                       fstream_handle_suite(fstream, line + strlen("suite "), filepos);\r
-               }\r
-               else if(!strncmp(line,"unsetenv ", strlen("unsetenv ")))\r
-               {\r
-                       unsigned int i, j;\r
-                       int exists = 0;\r
-                       int env = 0;\r
-                       int err = 0;\r
-                       variable_t variable;\r
-                       int is_blank;\r
-\r
-                       char* name = line + strlen("unsetenv ");\r
-\r
-                       is_blank = 1;\r
-\r
-                       for(j = 0; j < strlen(name); j++) \r
-                               if (name[j] != ' ' && name[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               ERROR1("[%s] Bad usage of the metacommand unsetenv : `(usage : unsetenv variable)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       \r
-                       xbt_os_mutex_acquire(unit->mutex);\r
-                       \r
-\r
-                       xbt_dynar_foreach(unit->runner->variables, i, variable)\r
-                       {\r
-                               if(!strcmp(variable->name, name))\r
-                               {\r
-                                       env = variable->env;\r
-                                       err = variable->err;\r
-                                       exists = 1;\r
-                                       break;\r
-                               }\r
-                       }\r
-                               \r
-                       if(env)\r
-                       {\r
-                               if(exists)\r
-                               {\r
-                                       #ifndef _XBT_WIN32\r
-                                       unsetenv(name);\r
-                                       #else\r
-                                       SetEnvironmentVariable(name, NULL);\r
-                                       #endif\r
-                                       xbt_dynar_cursor_rm(unit->runner->variables, &i);\r
-                               }\r
-                               else\r
-                               {\r
-                                       ERROR2("[%s] `(%s)' environment variable not found : impossible to unset it",filepos, name);    \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       xbt_os_mutex_release(unit->mutex);\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               if(exists)\r
-                               {\r
-                                       if(!err)\r
-                                       {\r
-                                               ERROR2("[%s] `(%s)' is not an environment variable : use `unset' instead `unsetenv'",filepos, name);    \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               failure(unit);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-                                               return;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               ERROR2("[%s] `(%s)' is not an environment variable (it's a system variable) : impossible to unset it",filepos, name);   \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                               }\r
-                               else\r
-                               {\r
-                                       ERROR2("[%s] `(%s)' environment variable not found : impossible to unset it",filepos, name);    \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       xbt_os_mutex_release(unit->mutex);\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                       }\r
-                       \r
-                       xbt_os_mutex_release(unit->mutex);      \r
-                       \r
-                               \r
-               }\r
-               else if(!strncmp(line,"setenv ", strlen("setenv ")))\r
-               {\r
-                       char* val;\r
-                       char name[PATH_MAX + 1] = {0};\r
-                       char* p;\r
-                       unsigned int i;\r
-                       int is_blank;\r
-                       unsigned int j;\r
-                       \r
-                       p = line + strlen("setenv ");\r
-                       \r
-                       val = strchr(p, '=');\r
-                       \r
-                       if(val)\r
-                       {\r
-                               variable_t variable;\r
-                               int exists = 0;\r
-                               int env = 0;\r
-                               int err = 0;\r
-                               val++;\r
-                               \r
-                               /* syntax error */\r
-                               if(val[0] == '\0' || val[0] ==' ' || val[0] =='\t')\r
-                               {\r
-                                       ERROR1("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'", filepos);  \r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               \r
-                               \r
-                               \r
-                               strncpy(name, p, (val - p -1));\r
-\r
-                               is_blank = 1;\r
-\r
-                               for(j = 0; j < strlen(name); j++) \r
-                                       if (name[j] != ' ' && name[j] != '\t')\r
-                                               is_blank = 0;\r
-\r
-                               if(is_blank)\r
-                               {\r
-                                       \r
-                                       ERROR1("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'", filepos);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               \r
-                               /* test if the variable is already registred */\r
-                               xbt_os_mutex_acquire(unit->mutex);\r
-\r
-                               xbt_dynar_foreach(unit->runner->variables, i, variable)\r
-                               {\r
-                                       if(!strcmp(variable->name, name))\r
-                                       {\r
-                                               env = variable->env;\r
-                                               err = variable->err;\r
-                                               exists = 1;\r
-                                               break;\r
-                                       }\r
-                               }\r
-                               \r
-                               /* if the variable is already registred, update its value;\r
-                                * otherwise register it.\r
-                                */\r
-                               if(exists)\r
-                               {\r
-                                       if(env)\r
-                                       {\r
-                                               if(!strcmp(val, variable->val))\r
-                                                       WARN3("[%s] This environment variable `(%s)' is already set with the value `(%s)'", filepos, name, val);\r
-\r
-                                               free(variable->val);\r
-                                               variable->val = strdup(val);\r
-\r
-                                               #ifdef _XBT_WIN32\r
-                                               SetEnvironmentVariable(variable->name, variable->val);\r
-                                               #else\r
-                                               setenv(variable->name, variable->val, 1);\r
-                                               #endif\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               if(err)\r
-                                                       ERROR2("[%s] Conflict : a system variable `(%s)' already exists", filepos, name);\r
-                                               else\r
-                                                       ERROR2("[%s] Conflict : (none environment) variable `(%s)' already exists", filepos, name);     \r
-\r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                               }\r
-                               else\r
-                               {\r
-                                       if(err)\r
-                                       {\r
-                                               ERROR2("[%s] A system variable named `(%s)' already exists", filepos, name);\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               variable = variable_new(name, val);\r
-                                               variable->env = 1;\r
-                                               \r
-                                               xbt_dynar_push(unit->runner->variables, &variable);\r
-                                               \r
-                                               #ifdef _XBT_WIN32\r
-                                               SetEnvironmentVariable(variable->name, variable->val);\r
-                                               #else\r
-                                               setenv(variable->name, variable->val, 0);\r
-                                               #endif\r
-                                       }\r
-                               }\r
-                               \r
-                               xbt_os_mutex_release(unit->mutex);\r
-                               \r
-                       }\r
-                       else\r
-                       {\r
-                               ERROR1("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'", filepos);\r
-                                       \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-               }\r
-               else if(!strncmp(line,"unset ", strlen("unset ")))\r
-               {\r
-                       unsigned int i, j;\r
-                       int exists = 0;\r
-                       int env = 0;\r
-                       int err = 0;\r
-                       variable_t variable;\r
-                       int is_blank;\r
-\r
-                       char* name = line + strlen("unset ");\r
-\r
-                       is_blank = 1;\r
-\r
-                       for(j = 0; j < strlen(name); j++) \r
-                               if (name[j] != ' ' && name[j] != '\t')\r
-                                       is_blank = 0;\r
-\r
-                       if(is_blank)\r
-                       {\r
-                               \r
-                               ERROR1("[%s] Bad usage of the metacommand unset `(usage : unset variable)'", filepos);\r
-                               \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-\r
-                       \r
-                       xbt_os_mutex_acquire(unit->mutex);\r
-\r
-                       xbt_dynar_foreach(unit->runner->variables, i, variable)\r
-                       {\r
-                               if(!strcmp(variable->name, name))\r
-                               {\r
-                                       env = variable->env;\r
-                                       err = variable->err;\r
-                                       exists = 1;\r
-                                       break;\r
-                               }\r
-                       }\r
-                               \r
-                       if(!env && !err)\r
-                       {\r
-                               if(exists)\r
-                               {\r
-                                       /*xbt_dynar_remove_at(unit->runner->variables, i, NULL);*/\r
-                                       /*xbt_dynar_cursor_rm(unit->runner->variables, &i);*/\r
-                                       if(variable->val)\r
-                                       {\r
-                                               free(variable->val);\r
-                                               variable->val = NULL;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               WARN2("[%s] Variable `(%s)' already unseted",filepos, variable->name);\r
-                                       }\r
-                               }       \r
-                               else\r
-                               {\r
-                                       ERROR2("[%s] `(%s)' variable not found",filepos, name); \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       xbt_os_mutex_release(unit->mutex);\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                       }\r
-                       else if(env)\r
-                       {\r
-                               ERROR2("[%s] `(%s)' is an environment variable use `unsetenv' instead `unset'",filepos, name);  \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               xbt_os_mutex_release(unit->mutex);\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       else if(err)\r
-                       {\r
-                               ERROR2("[%s] `(%s)' is system variable : you can unset it",filepos, name);      \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               xbt_os_mutex_release(unit->mutex);\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-                       \r
-                       xbt_os_mutex_release(unit->mutex);\r
-                               \r
-               }\r
-               else if(!strncmp(line,"set ", strlen("set ")))\r
-               {\r
-                       char* val;\r
-                       char name[PATH_MAX + 1] = {0};\r
-                       unsigned int j; \r
-                       int is_blank;\r
-                       \r
-                       val = strchr(line + strlen("set "), '=');\r
-                       \r
-                       if(val)\r
-                       {\r
-                               variable_t variable;\r
-                               int exists = 0;\r
-                               unsigned int i;\r
-                               int err;\r
-                               int env;\r
-\r
-                               val++;\r
-                               \r
-                               \r
-                               /* syntax error */\r
-                               if(val[0] == '\0')\r
-                               {\r
-                                       ERROR1("[%s] Bad usage of the metacommand set `(usage : set variable=value)'", filepos);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               else if(val[0] ==' ' || val[0] =='\t')\r
-                               {\r
-                                       strncpy(name, line + strlen("set "), (val - (line + strlen("set "))));\r
-\r
-                                       ERROR2("[%s] No space avaible after`(%s)'", filepos, name);\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               \r
-                               \r
-                               /* assume it's a varibale */\r
-                               \r
-                               strncpy(name, line + strlen("set "), (val - (line + strlen("set ")) -1));\r
-                               \r
-                               is_blank = 1;\r
-\r
-                               for(j = 0; j < strlen(name); j++) \r
-                                       if (name[j] != ' ' && name[j] != '\t')\r
-                                               is_blank = 0;\r
-\r
-                               if(is_blank)\r
-                               {\r
-                                       \r
-                                       ERROR1("[%s] Bad usage of the metacommand set `(usage : set variable=value)'", filepos);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-\r
-                               xbt_os_mutex_acquire(unit->mutex);\r
-                               \r
-                               /* test if the variable is already registred */\r
-                               xbt_dynar_foreach(unit->runner->variables, i, variable)\r
-                               {\r
-                                       if(!strcmp(variable->name, name))\r
-                                       {\r
-                                               exists = 1;\r
-                                               err = variable->err;\r
-                                               env = variable->env;\r
-                                               break;\r
-                                       }\r
-                               }\r
-                               \r
-                               /* if the variable is already registred, update its value (if same value warns);\r
-                                * otherwise register it.\r
-                                */\r
-                               if(exists)\r
-                               {\r
-                                       if(err)\r
-                                       {\r
-                                               ERROR2("[%s] A system variable named `(%s)' already exists", filepos, name);\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                                       if(env)\r
-                                       {\r
-                                               ERROR2("[%s] `(%s)' is an environment variable use `setenv' instead `set'", filepos, name);\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               if(!strcmp(val, variable->val))\r
-                                                       WARN3("[%s] Variable `(%s)' already contains value `<%s>'",filepos, variable->name, val);\r
-\r
-                                               free(variable->val);\r
-                                               variable->val = strdup(val);\r
-                                       }\r
-                               }\r
-                               else\r
-                               {\r
-                                       variable_t new_var = variable_new(name, val);\r
-                                       xbt_dynar_push(unit->runner->variables, &new_var);\r
-                               }\r
-\r
-                                       \r
-                               xbt_os_mutex_release(unit->mutex);\r
-                       }\r
-                       else\r
-                       {\r
-                               ERROR1("[%s] Bad usage of the metacommand set `(usage : set variable=value)'", filepos);\r
-                                       \r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-               }\r
-               else\r
-               {/* assume it's a variable */\r
-                       char* val;\r
-                       char name[PATH_MAX + 1] = {0};\r
-                       unsigned int i, j; \r
-                       int is_blank;\r
-                       \r
-                       val = strchr(line, '=');\r
-\r
-                       if(val)\r
-                       {\r
-                               variable_t variable;\r
-                               int exists = 0;\r
-                               int err;\r
-                               int env;\r
-                               val++;\r
-                               \r
-                               \r
-                               /* syntax error */\r
-                               if(val[0] == '\0')\r
-                               {\r
-                                       strncpy(name, line, (val - line -1));\r
-\r
-                                       is_blank = 1;\r
-\r
-                                       for(j = 0; j < strlen(name); j++) \r
-                                               if (name[j] != ' ' && name[j] != '\t')\r
-                                                       is_blank = 0;\r
-\r
-                                       if(is_blank)\r
-                                               ERROR1("[%s] Bad usage of Tesh variable mechanism `(usage : variable=value)'", filepos);\r
-                                       else if(!strcmp("setenv", name))\r
-                                               ERROR1("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'", filepos);\r
-                                       else if(!strcmp("set", name))\r
-                                               ERROR1("[%s] Bad usage of the metacommand set `(usage : set variable=value)'", filepos);\r
-                                       else\r
-                                               ERROR2("[%s] Undefined variable `(%s)'", filepos, name);\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               else if(val[0] ==' ' || val[0] =='\t')\r
-                               {\r
-                                       strncpy(name, line, (val - line));\r
-\r
-                                       ERROR2("[%s] No space avaible after`(%s)'", filepos, name);\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);   \r
-                               }\r
-                               \r
-                               \r
-                               /* assume it's a varibale */\r
-                               \r
-                               strncpy(name, line, (val - line -1));\r
-\r
-                               is_blank = 1;\r
-\r
-                               for(j = 0; j < strlen(name); j++) \r
-                                       if (name[j] != ' ' && name[j] != '\t')\r
-                                               is_blank = 0;\r
-\r
-                               if(is_blank)\r
-                               {\r
-                                       \r
-                                       ERROR1("[%s] Bad usage of Tesh variable capability `(usage : variable=value)'", filepos);\r
-\r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               \r
-                               if(!strcmp("set", name))\r
-                               {\r
-                                       ERROR1("[%s] Bad usage of the metacommand set `(usage : set variable=value)'", filepos);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-                               else if(!strcmp("setenv", name))\r
-                               {\r
-                                       ERROR1("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'", filepos);\r
-                                       \r
-                                       unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                       failure(unit);\r
-                                       return;\r
-                               }\r
-\r
-                               xbt_os_mutex_acquire(unit->mutex);\r
-                               \r
-                               /* test if the variable is already registred */\r
-                               xbt_dynar_foreach(unit->runner->variables, i, variable)\r
-                               {\r
-                                       if(!strcmp(variable->name, name))\r
-                                       {\r
-                                               exists = 1;\r
-                                               err = variable->err;\r
-                                               env = variable->env;\r
-                                               break;\r
-                                       }\r
-                               }\r
-                               \r
-                               /* if the variable is already registred, update its value (if same value warns);\r
-                                * otherwise register it.\r
-                                */\r
-                               if(exists)\r
-                               {\r
-                                       if(err)\r
-                                       {\r
-                                               ERROR2("[%s] A system variable named `(%s)' already exists", filepos, name);\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                                       if(env)\r
-                                       {\r
-                                               ERROR2("[%s] `(%s)' is an environment variable use `setenv' metacommand", filepos, name);\r
-                                       \r
-                                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-                                               xbt_os_mutex_release(unit->mutex);\r
-\r
-                                               failure(unit);\r
-                                               return;\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               if(!strcmp(val, variable->val))\r
-                                                       WARN3("[%s] Variable `(%s)' already contains value `<%s>'",filepos, variable->name, val);\r
-\r
-                                               free(variable->val);\r
-                                               variable->val = strdup(val);\r
-                                       }\r
-                               }\r
-                               else\r
-                               {\r
-                                       variable_t new_var = variable_new(name, val);\r
-                                       xbt_dynar_push(unit->runner->variables, &new_var);\r
-                               }\r
-\r
-                                       \r
-                               xbt_os_mutex_release(unit->mutex);\r
-                               \r
-                       }\r
-                       else \r
-                       {\r
-                               if(!strncmp("setenv", line, strlen("setenv")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand setenv : `(usage : setenv variable=value)'", filepos);\r
-                               else if(!strncmp("set", line, strlen("set")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand set : `(usage : set variable=value)'", filepos);\r
-                               else if(!strncmp("unsetenv", line, strlen("unsetenv")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand unsetenv : `(usage : unsetenv variable)'", filepos);\r
-                               else if(!strncmp("unset", line, strlen("unset")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand unset : `(usage : unset variable)'", filepos);\r
-                               else if(!strncmp("timeout", line, strlen("timeout")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand timeout : `(usage : timeout <integral positive integer>)'", filepos);\r
-                               else if(!strncmp("expect signal", line, strlen("expect signal")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand expect signal : `(usage : expect signal <sig_name>)'", filepos);\r
-                               else if(!strncmp("expect return", line, strlen("expect return")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand expect return : `(usage : expect return <return value (>=0 <=255)>)'", filepos);\r
-                               else if(!strncmp("include", line, strlen("include")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand include  :`(usage : include <file> [<description>])'", filepos);\r
-                               else if(!strncmp("suite", line, strlen("suite")))\r
-                                       ERROR1("[%s] Bad usage of the metacommand suite : `(usage : suite <description>)'", filepos);\r
-                               else\r
-                                       ERROR2("[%s] Unknown metacommand: `%s'",filepos,line);\r
-\r
-                               unit_set_error(fstream->unit, ESYNTAX, 1, filepos);\r
-\r
-                               failure(unit);\r
-                               return;\r
-                       }\r
-               }\r
-               \r
-               break;\r
-       }\r
-}\r
-\r
-void\r
-fstream_handle_include(fstream_t fstream, context_t context, xbt_os_mutex_t mutex, const char* file_name, const char* description)\r
-{\r
-       directory_t dir;\r
-       char* prev_directory = NULL;\r
-       fstream_t _fstream = NULL;\r
-       struct stat buffer = {0};\r
-       unit_t unit = fstream->unit;\r
-       \r
-       if(!stat(file_name, &buffer) && S_ISREG(buffer.st_mode))\r
-       {\r
-               /* the file is in the current directory */\r
-               _fstream = fstream_new(getcwd(NULL, 0), file_name);\r
-               fstream_open(_fstream);\r
-       }\r
-       /* the file to include is not in the current directory, check if it is in a include directory */\r
-       else\r
-       {\r
-               unsigned int i;\r
-               prev_directory = getcwd(NULL, 0);\r
-               \r
-               xbt_dynar_foreach(include_dirs, i, dir)\r
-               {\r
-                       chdir(dir->name);\r
-                       \r
-                       if(!stat(file_name, &buffer) && S_ISREG(buffer.st_mode))\r
-                       {\r
-                               _fstream = fstream_new(dir->name, file_name);\r
-                               fstream_open(_fstream);\r
-                               break;\r
-                       }\r
-               }\r
-\r
-               chdir(prev_directory);\r
-               free(prev_directory);\r
-       }\r
-       \r
-       /* the file to include is not found handle the failure */\r
-       if(!_fstream)\r
-       {\r
-               if(file_name[0] == '$')\r
-               {\r
-                       ERROR3("[%s] Include file `(%s)' not found or variable `(%s)' doesn't exist",context->line, file_name, file_name + 1);\r
-               \r
-               }\r
-               else\r
-               {\r
-                       /* may be a variable */\r
-                       variable_t variable;\r
-                       int exists = 0;\r
-                       unsigned int i;\r
-\r
-                       xbt_dynar_foreach(unit->runner->variables, i, variable)\r
-                       {\r
-                               if(!strcmp(variable->name, file_name))\r
-                               {\r
-                                       exists = 1;\r
-                                       break;\r
-                               }\r
-                       }\r
-\r
-                       if(exists)\r
-                               ERROR3("[%s] Include file `(%s)' not found (if you want to use the variable <%s> add the prefix `$')",context->line, file_name, file_name);\r
-                       else\r
-                               ERROR2("[%s] Include file `(%s)' not found",context->line, file_name);\r
-               }\r
-               \r
-               unit_set_error(fstream->unit, EINCLUDENOTFOUND, 1, context->line);\r
-\r
-               failure(fstream->unit);\r
-\r
-               return;\r
-       }\r
-       else\r
-       {\r
-               if(!unit->is_running_suite)\r
-               {/* it's the unit of a suite */\r
-                       unit_t include = unit_new(unit->runner, unit->root, unit, _fstream);\r
-                       \r
-                       include->mutex = unit->root->mutex;\r
-               \r
-                       if(description)\r
-                               include->description = strdup(description);\r
-               \r
-                       xbt_dynar_push(unit->includes, &include);\r
-                \r
-                       if(!dry_run_flag)\r
-                       {\r
-                               if(description)\r
-                                       INFO2("Include from %s (%s)", _fstream->name, description);\r
-                               else\r
-                                       INFO1("Include from %s", _fstream->name);\r
-\r
-                       }\r
-                       else\r
-                               INFO1("Checking include %s...",_fstream->name);\r
-                       \r
-                       fstream_parse(_fstream, mutex);\r
-               }\r
-               else\r
-               {/* it's a include */\r
-\r
-                       unit_t* owner;\r
-                       unit_t include;\r
-\r
-                       owner = xbt_dynar_get_ptr(unit->suites, xbt_dynar_length(unit->suites) - 1);\r
-                       \r
-                       include = unit_new(unit->runner, unit->root, *owner, _fstream);\r
-                       \r
-                       include->mutex = unit->root->mutex;\r
-                       \r
-                       if(description)\r
-                               include->description = strdup(description);\r
-               \r
-                       xbt_dynar_push((*owner)->includes, &include);\r
-                       \r
-                       if(!dry_run_flag)\r
-                       {\r
-                               if(description)\r
-                                       INFO2("Include from %s (%s)", _fstream->name, description);\r
-                               else\r
-                                       INFO1("Include from %s", _fstream->name);\r
-                       }\r
-                       else\r
-                               INFO1("Checking include %s...",_fstream->name);\r
-                       \r
-                       fstream_parse(_fstream, mutex);\r
-               }\r
-       }\r
-}\r
-\r
-void\r
-fstream_handle_suite(fstream_t fstream, const char* description, const char* filepos)\r
-{\r
-       unit_t unit = fstream->unit;\r
-       unit_t suite = unit_new(unit->runner, unit->root, unit, NULL);\r
-       \r
-       if(description)\r
-               suite->description = strdup(description);\r
-\r
-       suite->filepos = strdup(filepos); \r
-\r
-       xbt_dynar_push(unit->suites, &suite);\r
-       unit->is_running_suite = 1;\r
-       \r
-       if(!dry_run_flag)\r
-               INFO1("Test suite %s", description);\r
-       else\r
-               INFO1("Checking suite %s...",description);\r
-       \r
-}\r
-\r
-int\r
-fstream_launch_command(fstream_t fstream, context_t context, xbt_os_mutex_t mutex)\r
-{\r
-       unit_t unit = fstream->unit;\r
-\r
-       if(!dry_run_flag)\r
-       {\r
-               command_t command;\r
-               \r
-               if(!(command = command_new(unit, context, mutex)))\r
-               {\r
-                       if(EINVAL == errno)\r
-                       {\r
-                               ERROR3("[%s] Cannot instantiate the command `%s' (%d)",context->pos, strerror(errno), errno);   \r
-\r
-                               unit_set_error(unit, errno, 0, context->pos);\r
-                               failure(unit);\r
-                               return -1;\r
-                       }\r
-                       else if(ENOMEM == errno)\r
-                       {\r
-                               ERROR3("[%s] Cannot instantiate the command `%s' (%d)",context->pos, strerror(errno), errno);\r
-\r
-                               unit_set_error(unit, errno, 0, context->pos);\r
-\r
-                               failure(unit);\r
-                               return -1;\r
-                       }\r
-               }\r
-               \r
-               if(command_run(command) < 0)\r
-               {\r
-                       ERROR3("[%s] Cannot run the command `%s' (%d)",context->pos, strerror(errno), errno);   \r
-                       unit_set_error(unit, errno, 0, context->pos);\r
-                       failure(unit);\r
-                       return -1;      \r
-               }\r
-       }\r
-       \r
-       if(context_reset(context) < 0)\r
-       {\r
-               ERROR3("[%s] Cannot reset the context of the command `%s' (%d)",context->pos, strerror(errno), errno);  \r
-\r
-               unit_set_error(fstream->unit, errno, 0, context->pos);\r
-\r
-               failure(unit);\r
-               return -1;      \r
-       }\r
-       \r
-       return 0;\r
-}\r
-\r
-\r
-\r
-\r
+#ifdef _XBT_WIN32\r
+        if (!context->is_not_found)
+      \r {
+      \r
+#endif  /* \r */
+          \rif (fstream_launch_command(fstream, context, mutex) < 0)
+        \rreturn -1;
+      \r\r
+#ifdef _XBT_WIN32\r
+      }
+    \r
+#endif  /* \r */
+    }
+  \r\r
+      /* clear buffers */ \r
+      if (line)
+    \rfree(line);
+  \r\rxbt_strbuff_free(buff);
+  \r\rif (context_free(&context) < 0)
+    \rreturn -1;
+  \r\rreturn (exit_code || errno) ? -1 : 0;
+\r}
+
+\r\r\rvoid \r
+fstream_lex_line(fstream_t fstream, context_t context,
+                 xbt_os_mutex_t mutex, const char *filepos, char *line) \r
+{
+  \rchar *line2;
+  \rvariable_t variable;
+  \runsigned int i;
+  \rchar exp[PATH_MAX + 1] = { 0 };
+  \runit_t unit = fstream->unit;
+  \rxbt_dynar_t variables = unit->runner->variables;
+  \rchar *p = NULL;
+  \rchar *end = NULL;
+  \rchar *val = NULL;
+  \rchar buff[PATH_MAX + 1] = { 0 };
+  \rsize_t len;
+  \rchar delimiters[4] = { ' ', '\t', '\n', '\0' };
+  \r\rint j;
+  \r\rif (line[0] == '#')
+    \rreturn;
+  \r\rif (unit->is_running_suite
+        && strncmp(line, "! include", strlen("! include")))
+    \r {                         /* it's the end of a suite */
+    \r\runit_t * current_suite =
+        xbt_dynar_get_ptr(unit->suites,
+                          xbt_dynar_length(unit->suites) - 1);
+    \r\rif (!xbt_dynar_length((*current_suite)->includes))
+      \rERROR2("[%s] Malformated suite `(%s)': include missing", filepos,
+              (*current_suite)->description);
+    \r
+    else
+      \rERROR2("[%s] Malformated suite `(%s)': blank line missing", filepos,
+              (*current_suite)->description);
+    \r\runit_set_error(*current_suite, ESYNTAX, 1, filepos);
+    \r\rfailure(fstream->unit);
+    \r}
+  \r\rcontext->line = strdup(filepos);
+  \r\r
+      /* search end */ \r
+      xbt_str_rtrim(line + 2, "\n");
+  \r\rline2 = strdup(line);
+  \r\rlen = strlen(line2 + 2) + 1;
+  \r\r
+      /* replace each variable by its value */ \r
+      xbt_os_mutex_acquire(unit->mutex);
+  \r\r\r
+      /* replace all existing\r
+         ${var}\r
+         ${var:=val}\r
+         ${var:+val}\r
+         ${var:-val}\r
+         ${var:?val}\r
+         ${#var}\r
+       */ \r
+      \rxbt_dynar_foreach(variables, i, variable) \r {
+    \rif (!(p = strstr(line2 + 2, "${")))
+      \rbreak;
+    \r\rmemset(buff, 0, len);
+    \r\rsprintf(buff, "${%s", variable->name);
+    \r\r
+        /* FALSE */ \r
+        if ((p = strstr(line2 + 2, buff)))
+      \r {
+      \rmemset(buff, 0, len);
+      \rp--;
+      \rj = 0;
+      \r\rwhile (*(p++) != '\0')
+        \r {
+        \rbuff[j++] = *p;
+        \r\rif (*p == '}')
+          \rbreak;
+        \r}
+      \r\rif (buff[j - 1] != '}')
+        \r {
+        \rxbt_os_mutex_release(unit->mutex);
+        \r\r\rERROR2("[%s] Syntax error : `%s'.", filepos, p - j);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rfailure(fstream->unit);
+        \rreturn;
+        \r}
+      \r\rif ((p = strstr(buff, ":=")))
+        \r {
+        \r
+            /* ${var:=val} */ \r
+            \r
+            /* if the value of the variable is empty, update its value by the value */ \r
+            p += 2;
+        \r\rend = strchr(p, '}');
+        \r\rif (!end || (end == p))
+          \r {
+          \rxbt_os_mutex_release(unit->mutex);
+          \r\r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                    strstr(buff, "${"));
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(fstream->unit);
+          \rreturn;
+          \r}
+        \r\rval = (char *) calloc((size_t) (end - p) + 1, sizeof(char));
+        \r\rstrncpy(val, p, (end - p));
+        \r\r\r
+            /* replace the expression by the expression of the value of the variable */ \r
+            sprintf(exp, "${%s:=%s}", variable->name, val);
+        \r\rif (variable->val)
+          \rstr_replace_all(&line2, exp, variable->val, NULL);
+        \r
+        else
+          \r {
+          \rstr_replace_all(&line2, exp, val, NULL);
+          \r\rvariable->val = strdup(val);
+          \r}
+        \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+        \r\rif (val)
+          \r {
+          \rfree(val);
+          \rval = NULL;
+          \r}
+        \r\r}
+      \r
+      else if ((p = strstr(buff, ":-")))
+        \r {
+        \r
+            /* ${var:-val} */ \r
+            \r
+            /* if the value of the variable is empty, replace the expression by the value */ \r
+            p += 2;
+        \rend = strchr(p, '}');
+        \r\rif (!end || (end == p))
+          \r {
+          \rxbt_os_mutex_release(unit->mutex);
+          \r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                   strstr(line2, "${"));
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(fstream->unit);
+          \rreturn;
+          \r}
+        \r\rval = (char *) calloc((size_t) (end - p) + 1, sizeof(char));
+        \r\rstrncpy(val, p, (end - p));
+        \r\rsprintf(exp, "${%s:-%s}", variable->name, val);
+        \r\rstr_replace_all(&line2, exp, variable->val ? variable->val : val,
+                          NULL);
+        \r\r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+        \r\rif (val)
+          \r {
+          \rfree(val);
+          \rval = NULL;
+          \r}
+        \r\r}
+      \r
+      else if ((p = strstr(buff, ":+")))
+        \r {
+        \r
+            /* ${var:+val} */ \r
+            \r
+            /* if the value of the variable is not empty, replace the expression by the value */ \r
+            p += 2;
+        \r\rend = strchr(p, '}');
+        \r\rif (!end || (end == p))
+          \r {
+          \rxbt_os_mutex_release(unit->mutex);
+          \r\r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                    strstr(line2, "${"));
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(fstream->unit);
+          \rreturn;
+          \r}
+        \r\rval = (char *) calloc((size_t) (end - p) + 1, sizeof(char));
+        \r\rstrncpy(val, p, (end - p));
+        \r\rsprintf(exp, "${%s:+%s}", variable->name, val);
+        \r\rif (variable->val)
+          \r {
+          \rstr_replace_all(&line2, exp, val, NULL);
+          \r}
+        \r
+        else
+          \r {
+          \rstr_replace_all(&line2, exp, NULL, NULL);
+          \rvariable->val = strdup(val);
+          \r}
+        \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+        \r\rif (val)
+          \r {
+          \rfree(val);
+          \rval = NULL;
+          \r}
+        \r}
+      \r
+      else if ((p = strstr(buff, ":?")))
+        \r {
+        \r
+            /*  ${var:?val} */ \r
+            \r
+            /* if the value of the variable is not empty, replace the expression by the value */ \r
+            p += 2;
+        \rend = strchr(p, '}');
+        \r\rif (!end || (end == p))
+          \r {
+          \rxbt_os_mutex_release(unit->mutex);
+          \r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                   strstr(line2, "${"));
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(fstream->unit);
+          \rreturn;
+          \r}
+        \r\rval = (char *) calloc((size_t) (end - p) + 1, sizeof(char));
+        \r\rstrncpy(val, p, (end - p));
+        \r\rsprintf(exp, "${%s:?%s}", variable->name, val);
+        \r\rif (variable->val)
+          \rstr_replace_all(&line2, exp, variable->val, NULL);
+        \r
+        else
+          \r {
+          \r\rxbt_os_mutex_release(unit->mutex);
+          \r\rERROR2("[%s] %s.", filepos, val);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(fstream->unit);
+          \rreturn;
+          \r}
+        \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+        \r\rif (val)
+          \r {
+          \rfree(val);
+          \rval = NULL;
+          \r}
+        \r}
+      \r}
+  \r}
+  \r\r
+      /* replace all existing $var */ \r
+      xbt_dynar_foreach(variables, i, variable) \r {
+    \rif (!strchr(line2 + 2, '$'))
+      \rbreak;
+    \r\rif (strstr(line2 + 2, variable->name))
+      \r {
+      \r\rsprintf(exp, "${#%s}", variable->name);
+      \r\rif (strstr(line2 + 2, exp))
+        \r {
+        \r\rif (variable->val)
+          \r {
+          \rchar slen[4] = { 0 };
+          \rsprintf(slen, "%d", (int) strlen(variable->val));
+          \rstr_replace_all(&line2, exp, slen, NULL);
+          \r}
+        \r
+        else
+          \rstr_replace_all(&line2, exp, "0", NULL);
+        \r}
+      \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+      \r\rsprintf(exp, "${%s}", variable->name);
+      \r\rif (strstr(line2 + 2, exp))
+        \r {
+        \rif (variable->val)
+          \rstr_replace_all(&line2, exp, variable->val, NULL);
+        \r
+        else
+          \rstr_replace_all(&line2, exp, NULL, NULL);
+        \r}
+      \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+      \r\rsprintf(exp, "$%s", variable->name);
+      \r\rif ((p = strstr(line2 + 2, exp)))
+        \r {
+        \rif ((p + strlen(variable->name) + 1)[0] != '\0'
+             && !(isalpha((p + strlen(variable->name) + 1)[0])))
+          \rdelimiters[0] = (p + strlen(variable->name) + 1)[0];
+        \r\rif (variable->val)
+          \rstr_replace_all(&line2, exp, variable->val, delimiters);
+        \r
+        else
+          \rstr_replace_all(&line2, exp, NULL, delimiters);
+        \r}
+      \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+      \r\r}
+  \r}
+  \r\rwhile ((p = strstr(line2 + 2, "${")))
+    \r {
+    \r
+        /*if(*(p+1) != '{')\r
+           {\r
+           j = 0;\r
+           p --;\r
+           \r
+           while(*(p++) != '\0')\r
+           {\r
+           if(*p != ' ' && *p !='\t')\r
+           exp[j++] = *p;\r
+           else\r
+           break;\r
+           \r
+           }\r
+           \r
+           str_replace_all(&line2, exp, NULL, " \t\n\r");\r
+           memset(exp, 0, VAR_NAME_MAX + 1);\r
+           }.\r
+           else\r
+         */ \r
+    {
+      \rchar *begin = NULL;
+      \r\rj = 0;
+      \rp--;
+      \r\rwhile (*(p++) != '\0')
+        \r {
+        \rif ((!begin && *p != ' ' && *p != '\t') || begin)
+          \r {
+          \r
+              /* `:' must be before this caracter, bad substitution : exit loop \r
+                 ||\r
+                 the current character is already present, bad substitution : exit loop\r
+               */ \r
+              if (\r
+                  (\r*(p - 1) != ':' && (\r
+                                        (*p == '=') || (*p == '-')
+                                        || (*p == '+')
+                                        || (*p == '?') \r\r\r ||\r(\rbegin
+                                                                   &&
+                                                                   (\r
+                                                                    (*p ==
+                                                                     ':')
+                                                                    || (*p
+                                                                        ==
+                                                                        '=')
+                                                                    || (*p
+                                                                        ==
+                                                                        '-')
+                                                                    || (*p
+                                                                        ==
+                                                                        '+')
+                                                                    || (*p
+                                                                        ==
+                                                                        '?')
+                                                                    \r\r)
+                  \r)
+            \rbreak;
+          \r
+          else
+            \rexp[j++] = *p;
+          \r\rif (*p == ':')
+            \r {
+            \r
+                /* save the begining of the value */ \r
+                if ((*(p + 1) == '=') || (*(p + 1) == '-')
+                    || (*(p + 1) == '+') || (*(p + 1) == '?'))
+              \r {
+              \rbegin = p + 2;
+              \rexp[j++] = *(p + 1);
+              \rp++;
+              \rcontinue;
+              \r\r}
+            \r
+            else
+              \r
+                  /* the current char is `:' but the next is invalid, bad substitution : exit loop */ \r
+                  break;
+            \r}
+          \r
+              /* end of the substitution : exit loop */ \r
+              else if (*p == '}')
+            \rbreak;
+          \r}
+        \r
+        else
+          \rbreak;
+        \r}
+      \r\rif (exp[j - 1] == '}')
+        \r {
+        \rif (exp[2] == '#')
+          \r {
+          \r
+              /* ${#var} */ \r
+              \r\rif (4 == strlen(exp))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                     strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rstr_replace_all(&line2, exp, "0", NULL);
+          \r}
+        \r
+        else if (strstr(exp, ":="))
+          \r {
+          \r
+              /* ${var:=value} */ \r
+              \rend = strchr(p, '}');
+          \r\rif (!end || (end == begin))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                      strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rvariable = xbt_new0(s_variable_t, 1);
+          \r\rvariable->val =
+              (char *) calloc((size_t) (end - begin) + 1, sizeof(char));
+          \r\rstrncpy(variable->val, begin, (end - begin));
+          \r\rbegin = exp + 2;
+          \rend = strchr(exp, ':');
+          \r\rif (!end || (end == begin))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                      strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rvariable->name =
+              (char *) calloc((size_t) (end - begin) + 1, sizeof(char));
+          \r\rstrncpy(variable->name, exp + 2, (end - begin));
+          \r\rstr_replace_all(&line2, exp, variable->val, NULL);
+          \r\rxbt_dynar_push(variables, &variable);
+          \r\r}
+        \r
+        else if (strstr(exp, ":-"))
+          \r {
+          \r
+              /* ${var:-value} */ \r
+              \r\rend = strchr(p, '}');
+          \r\rif (!end || (end == begin))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                      strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rval =
+              (char *) calloc((size_t) (end - begin) + 1, sizeof(char));
+          \r\rstrncpy(val, begin, (end - begin));
+          \r\rstr_replace_all(&line2, exp, val, NULL);
+          \r\rif (val)
+            \rfree(val);
+          \r\r}
+        \r
+        else if (strstr(exp, ":+"))
+          \r {
+          \r
+              /* ${var:+value} */ \r
+              \rend = strchr(p, '}');
+          \r\rif (!end || (end == begin))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                     strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rstr_replace_all(&line2, exp, NULL, NULL);
+          \r}
+        \r
+        else if (strstr(exp, ":?"))
+          \r {
+          \r
+              /* ${var:?value} */ \r
+              \rend = strchr(p, '}');
+          \r\rif (!end || (end == begin))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                     strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rval =
+              (char *) calloc((size_t) (end - begin) + 1, sizeof(char));
+          \r\rstrncpy(val, begin, (end - begin));
+          \r\rxbt_os_mutex_release(unit->mutex);
+          \r\rERROR2("[%s] : `%s'.", filepos, val);
+          \r\rif (val)
+            \rfree(val);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(fstream->unit);
+          \r\rreturn;
+          \r\r}
+        \r
+        else
+          \r {
+          \r
+              /* ${var} */ \r
+              \rif (3 == strlen(exp))
+            \r {
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                     strchr(line2 + 2, '$'));
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(fstream->unit);
+            \rreturn;
+            \r}
+          \r\rstr_replace_all(&line2, exp, NULL, NULL);
+          \r\r}
+        \r\rmemset(exp, 0, VAR_NAME_MAX + 1);
+        \r}
+      \r
+      else
+        \r {
+        \rxbt_os_mutex_release(unit->mutex);
+        \r\rif (strstr(line2 + 2, "${"))
+          \rERROR2("[%s] Bad substitution : `%s'.", filepos,
+                  strstr(line2, "${"));
+        \r
+        else
+          \rERROR2("[%s] Syntax error : `%s'.", filepos,
+                  strstr(line2, "${"));
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rfailure(fstream->unit);
+        \rreturn;
+        \r}
+    \r\r}
+    \r\r}
+  \r\rwhile (1)
+    \r {
+    \rp = line2 + (line2[0] == '<' ? 4 : 2);
+    \r\rif ((p = strchr(p, '$')))
+      \r {
+      \rif (*(p + 1) != ' ')
+        \r {
+        \rj = 0;
+        \rp--;
+        \r\rwhile (*(p++) != '\0')
+          \r {
+          \rif (*p != ' ' && *p != '\t')
+            \rexp[j++] = *p;
+          \r
+          else
+            \rbreak;
+          \r\r}
+        \r\rstr_replace_all(&line2, exp, NULL, " \t\n\r");
+        \rmemset(exp, 0, VAR_NAME_MAX + 1);
+        \r}
+      \r
+      else
+        \r {
+        \r
+            /* maybe < $ cmd */ \r
+            p++;
+        \r}
+      \r}
+    \r
+    else
+      \rbreak;
+    \r}
+  \r\rxbt_os_mutex_release(unit->mutex);
+  \r\rswitch (line2[0])
+    \r {
+    \r
+        /*case '#': \r
+           break;\r
+         */ \r
+  \rcase '$':
+  \rcase '&':
+    \r\rif (line[1] != ' ')
+      \r {
+      \r\rif (line2[0] == '$')
+        \rERROR1("[%s] Missing space after `$' `(usage : $ <command>)'",
+                filepos);
+      \r
+      else
+        \rERROR1("[%s] Missing space after & `(usage : & <command>)'",
+                filepos);
+      \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+      \r\rfailure(unit);
+      \rreturn;
+      \r}
+    \r\rcontext->async = (line2[0] == '&');
+    \r\r\r
+        /* further trim useless chars which are significant for in/output */ \r
+        xbt_str_rtrim(line2 + 2, " \t");
+    \r\r
+        /* deal with CD commands here, not in context */ \r
+        if (!strncmp("cd ", line2 + 2, 3))
+      \r {
+      \rchar *dir = strdup(line2 + 4);
+      \r\rif (context->command_line)
+        \r {
+        \rif (fstream_launch_command(fstream, context, mutex) < 0)
+          \rreturn;
+        \r}
+      \r\r
+          /* search begining */ \r
+          while (*(dir++) == ' ');
+      \r\rdir--;
+      \r\rif (!dry_run_flag)
+        \r {
+        \rif (!silent_flag)
+          \rINFO2("[%s] cd %s", filepos, dir);
+        \r\rif (!just_print_flag)
+          \r {
+          \rif (chdir(dir))
+            \r {
+            \rERROR3("[%s] Chdir to %s failed: %s", filepos, dir,
+                    error_to_string(errno, 0));
+            \runit_set_error(fstream->unit, errno, 0, filepos);
+            \r\rfailure(unit);
+            \r}
+          \r}
+        \r}
+      \r\rbreak;
+      \r}
+    \r
+    else
+      \r {
+      \rfstream_process_token(fstream, context, mutex, filepos, line2[0],
+                             line2 + 2);
+      \rbreak;
+      \r}
+  \r\rcase '<':
+  \rcase '>':
+  \rcase '!':
+    \r\rif (line[0] == '!' && line[1] != ' ')
+      \r {
+      \rERROR1
+          ("[%s] Missing space after `!' `(usage : ! <command> [[=]value])'",
+           filepos);
+      \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+      \r\rfailure(unit);
+      \rreturn;
+      \r}
+    \r\rfstream_process_token(fstream, context, mutex, filepos, line2[0],
+                            line2 + 2);
+    \rbreak;
+  \r\rcase 'p':
+    \r\r {
+      \runsigned int j;
+      \rint is_blank = 1;
+      \r\rchar *prompt = line2 + 2;
+      \r\rfor (j = 0; j < strlen(prompt); j++)
+        \r {
+        \rif (prompt[j] != ' ' && prompt[j] != '\t')
+          \r {
+          \ris_blank = 0;
+          \rbreak;
+          \r}
+        \r}
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Bad usage of the metacommand p `(usage : p <prompt>)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rif (!dry_run_flag)
+        \rINFO2("[%s] %s", filepos, prompt);
+    \r}
+    \r\r\rbreak;
+  \r\rcase 'P':
+    \r\r {
+      \runsigned int j;
+      \rint is_blank = 1;
+      \r\rchar *prompt = line2 + 2;
+      \r\rfor (j = 0; j < strlen(prompt); j++)
+        \rif (prompt[j] != ' ' && prompt[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Bad usage of the metacommand P `(usage : P <prompt>)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rif (!dry_run_flag)
+        \rCRITICAL2("[%s] %s", filepos, prompt);
+    \r}
+    \r\rbreak;
+  \r\rcase 'D':
+    \rif (unit->description)
+      \rWARN2("[%s] Description already specified `%s'", filepos,
+             line2 + 2);
+    \r
+    else
+      \r {
+      \runsigned int j;
+      \rint is_blank = 1;
+      \r\rchar *desc = line2 + 2;
+      \r\rfor (j = 0; j < strlen(desc); j++)
+        \rif (desc[j] != ' ' && desc[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Bad usage of the metacommand D `(usage : D <Description>)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\runit->description = strdup(desc);
+      \r}
+    \rbreak;
+  \r\rdefault:
+    \rERROR2("[%s] Syntax error `%s'", filepos, line2);
+    \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+    \rfailure(unit);
+    \rbreak;
+    \r}
+  \r\rfree(line2);
+\r}
+
+\r\rvoid \r
+fstream_process_token(fstream_t fstream, context_t context,
+                      xbt_os_mutex_t mutex, const char *filepos,
+                      char token, char *line) \r
+{
+  \runit_t unit = fstream->unit;
+  \r\rswitch (token)
+    \r {
+  \rcase '$':
+  \rcase '&':
+    \r\rif (context->command_line)
+      \r {
+      \r\rif (context->output->used || context->input->used)
+        \r {
+        \rERROR2
+            ("[%s] More than one command in this chunk of lines (previous: %s).\nDunno which input/output belongs to which command.",
+             filepos, context->command_line);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rif (fstream_launch_command(fstream, context, mutex) < 0)
+        \rreturn;
+      \r\rVERB1("[%s] More than one command in this chunk of lines",
+              filepos);
+      \r}
+    \r\r {
+      \rsize_t j, \ris_blank = 1;
+      \r\rfor (j = 0; j < strlen(line); j++)
+        \rif (line[j] != ' ' && line[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rif (token == '$')
+          \rERROR1("[%s] Undefinite command for `$' `(usage: $ <command>)'",
+                  filepos);
+        \r
+        else
+          \rERROR1("[%s] Undefinite command for `&' `(usage: & <command>)'",
+                  filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+    \r}
+    \r\rcontext->command_line = strdup(line);
+    \r\rxbt_str_ltrim(context->command_line, " ");
+    \r\rcontext->line = /*strdup(filepos) */ filepos;
+    \rcontext->pos = strdup(filepos);
+    \r\r
+#ifdef _XBT_WIN32\r
+    {
+      \r\r
+          /* translate the command line */ \r
+      \rchar *path = NULL;
+      \rchar *delimiter;
+      \rchar command_line[PATH_MAX + 1] = { 0 };
+      \rsize_t i = 0;
+      \rchar *args = NULL;
+      \r\r\r\r
+          /*if(strstr(context->command_line,".exe"))\r
+             strcpy(command_line,context->command_line); */ \r
+          \r {
+        \rsize_t len;
+        \r\rsize_t j = 0;
+        \r\rlen = strlen(context->command_line);
+        \r\rwhile (i < len)
+          \r {
+          \rif (context->command_line[i] != ' '
+               && context->command_line[i] != '\t'
+               && context->command_line[i] != '>')
+            \rcommand_line[j++] = context->command_line[i];
+          \r
+          else
+            \rbreak;
+          \r\ri++;
+          \r}
+        \r\rif (!strstr(context->command_line, ".exe"))
+          \rstrcat(command_line, ".exe");
+        \r\rargs = strdup(context->command_line + i);
+      \r}
+      \r\rif (!is_w32_cmd(command_line, fstream->unit->runner->path)
+            && getpath(command_line, &path) < 0)
+        \r {
+        \rcommand_t command;
+        \r\rERROR3("[%s] `%s' : NOK (%s)", filepos, command_line,
+                 error_to_string(ECMDNOTFOUND, 1));
+        \runit_set_error(fstream->unit, ECMDNOTFOUND, 1, filepos);
+        \r\rcontext->is_not_found = 1;
+        \r\rcommand = command_new(fstream->unit, context, mutex);
+        \r\rcommand->status = cs_failed;
+        \rcommand->reason = csr_command_not_found;
+        \r\rfailure(unit);
+        \r\r\rreturn;
+        \r}
+      \r\rdelimiter = strrchr(command_line, '/');
+      \r\rif (!delimiter)
+        \rdelimiter = strrchr(command_line, '\\');
+      \r\r
+          /*free(context->command_line); */ \r
+          \r\rif (path)
+        \r {
+        \rif (args)
+          \r {
+          \rcontext->t_command_line =
+              (char *) calloc(strlen(path) +
+                              strlen(delimiter ? delimiter +
+                                     1 : command_line) + strlen(args) + 2,
+                              sizeof(char));
+          \rsprintf(context->t_command_line, "%s\\%s%s", path,
+                   delimiter ? delimiter + 1 : command_line, args);
+          \r\rfree(args);
+          \r\r}
+        \r
+        else
+          \r {
+          \rcontext->t_command_line =
+              (char *) calloc(strlen(path) +
+                              strlen(delimiter ? delimiter +
+                                     1 : command_line) + 2, sizeof(char));
+          \rsprintf(context->t_command_line, "%s\\%s", path,
+                   delimiter ? delimiter + 1 : command_line);
+          \r\r\rfree(path);
+        \r}
+      \r
+      else
+        \r {
+        \rif (args)
+          \r {
+          \r\rcontext->t_command_line =
+              (char *) calloc(strlen(command_line) + strlen(args) + 1,
+                              sizeof(char));
+          \rsprintf(context->t_command_line, "%s%s", command_line, args);
+          \r\r\rfree(args);
+          \r\r}
+        \r
+        else
+          \r {
+          \rcontext->t_command_line =
+              (char *) calloc(strlen(command_line) + 1, sizeof(char));
+          \rstrcpy(context->t_command_line, command_line);
+    \r\r\r\r\r\r
+#endif  /* \r */
+        \r\rbreak;
+  \r\rcase '<':
+    \rxbt_strbuff_append(context->input, line);
+    \rxbt_strbuff_append(context->input, "\n");
+    \rbreak;
+  \r\rcase '>':
+    \rxbt_strbuff_append(context->output, line);
+    \rxbt_strbuff_append(context->output, "\n");
+    \rbreak;
+  \r\rcase '!':
+    \r\rif (context->command_line)
+      \r {
+      \rif (fstream_launch_command(fstream, context, mutex) < 0)
+        \rreturn;
+      \r}
+    \r\rif (!strncmp(line, "timeout no", strlen("timeout no")))
+      \r {
+      \rVERB1("[%s] (disable timeout)", filepos);
+      \rcontext->timeout = INDEFINITE;
+      \r}
+    \r
+    else if (!strncmp(line, "timeout ", strlen("timeout ")))
+      \r {
+      \rint i = 0;
+      \runsigned int j;
+      \rint is_blank = 1;
+      \rchar *p = line + strlen("timeout ");
+      \r\r\rfor (j = 0; j < strlen(p); j++)
+        \rif (p[j] != ' ' && p[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Undefinite timeout value `(usage :timeout <seconds>)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rwhile (p[i] != '\0')
+        \r {
+        \rif (!isdigit(p[i]))
+          \r {
+          \rERROR2
+              ("[%s] Invalid timeout value `(%s)' : `(usage :timeout <seconds>)'",
+               filepos, line + strlen("timeout "));
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\ri++;
+        \r}
+      \r\rcontext->timeout = atoi(line + strlen("timeout"));
+      \rVERB2("[%s] (new timeout value: %d)", filepos, context->timeout);
+      \r\r}
+    \r
+    else if (!strncmp(line, "expect signal ", strlen("expect signal ")))
+      \r {
+      \runsigned int j;
+      \rint is_blank = 1;
+      \r\r\rchar *p = line + strlen("expect signal ");
+      \r\r\rfor (j = 0; j < strlen(p); j++)
+        \rif (p[j] != ' ' && p[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Undefinite signal name `(usage :expect signal <signal name>)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rcontext->signal = strdup(line + strlen("expect signal "));
+      \r\rxbt_str_trim(context->signal, " \n");
+      \r\r
+#ifdef _XBT_WIN32\r
+          if (!strstr("SIGSEGVSIGTRAPSIGBUSSIGFPESIGILL", context->signal))
+        \r {
+        \rERROR2("[%s] Signal `%s' not supported by this platform", filepos,
+                context->signal);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r
+#else   /* \r */
+          if (!sig_exists(context->signal))
+        \r {
+        \rERROR2("[%s] Signal `%s' not supported by Tesh", filepos,
+                context->signal);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\r
+#endif  /* \r */
+          \r\rVERB2("[%s] (next command must raise signal %s)", filepos,
+                  context->signal);
+      \r\r}
+    \r
+    else if (!strncmp(line, "expect return ", strlen("expect return ")))
+      \r {
+      \r\rint i = 0;
+      \runsigned int j;
+      \rint is_blank = 1;
+      \rchar *p = line + strlen("expect return ");
+      \r\r\rfor (j = 0; j < strlen(p); j++)
+        \rif (p[j] != ' ' && p[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Undefinite return value `(usage :expect return <return value>)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rwhile (p[i] != '\0')
+        \r {
+        \rif (!isdigit(p[i]))
+          \r {
+          \rERROR2
+              ("[%s] Invalid exit code value `(%s)' : must be an integer >= 0 and <=255",
+               filepos, line + strlen("expect return "));
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\ri++;
+        \r}
+      \r\rcontext->exit_code = atoi(line + strlen("expect return "));
+      \rVERB2("[%s] (next command must return code %d)", filepos,
+             context->exit_code);
+      \r\r}
+    \r
+    else if (!strncmp(line, "output ignore", strlen("output ignore")))
+      \r {
+      \rcontext->output_handling = oh_ignore;
+      \rVERB1("[%s] (ignore output of next command)", filepos);
+      \r\r}
+    \r
+    else if (!strncmp(line, "output display", strlen("output display")))
+      \r {
+      \rcontext->output_handling = oh_display;
+      \rVERB1("[%s] (ignore output of next command)", filepos);
+      \r\r}
+    \r
+    else if (!strncmp(line, "include ", strlen("include ")))
+      \r {
+      \rchar *p1;
+      \rchar *p2;
+      \r\rp1 = line + strlen("include");
+      \r\rwhile (*p1 == ' ' || *p1 == '\t')
+        \rp1++;
+      \r\r\rif (p1[0] == '\0')
+        \r {
+        \rERROR1
+            ("[%s] no file specified : `(usage : include <file> [<description>])'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r
+      else
+        \r {
+        \rchar file_name[PATH_MAX + 1] = { 0 };
+        \r\rp2 = p1;
+        \r\rwhile (*p2 != '\0' && *p2 != ' ' && *p2 != '\t')
+          \rp2++;
+        \r\rstrncpy(file_name, p1, p2 - p1);
+        \r\r\rif (p2[0] != '\0')
+          \rwhile (*p2 == ' ' || *p2 == '\t')
+            \rp2++;
+        \r\rfstream_handle_include(fstream, context, mutex, file_name,
+                                 p2[0] != '\0' ? p2 : NULL);
+        \r\r}
+      \r}
+    \r
+    else if (!strncmp(line, "suite ", strlen("suite ")))
+      \r {
+      \runsigned int j;
+      \rint is_blank = 1;
+      \rchar *p = line + strlen("suite ");
+      \r\r\rfor (j = 0; j < strlen(p); j++)
+        \rif (p[j] != ' ' && p[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Undefinite suit description : `(usage : suite <description>)",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rif (unit->is_running_suite)
+        \r {
+        \rERROR1("[%s] Suite already in progress", filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rfstream_handle_suite(fstream, line + strlen("suite "), filepos);
+      \r}
+    \r
+    else if (!strncmp(line, "unsetenv ", strlen("unsetenv ")))
+      \r {
+      \runsigned int i, j;
+      \rint exists = 0;
+      \rint env = 0;
+      \rint err = 0;
+      \rvariable_t variable;
+      \rint is_blank;
+      \r\rchar *name = line + strlen("unsetenv ");
+      \r\ris_blank = 1;
+      \r\rfor (j = 0; j < strlen(name); j++)
+        \rif (name[j] != ' ' && name[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \rERROR1
+            ("[%s] Bad usage of the metacommand unsetenv : `(usage : unsetenv variable)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rxbt_os_mutex_acquire(unit->mutex);
+      \r\r\rxbt_dynar_foreach(unit->runner->variables, i, variable) \r {
+        \rif (!strcmp(variable->name, name))
+          \r {
+          \renv = variable->env;
+          \rerr = variable->err;
+          \rexists = 1;
+          \rbreak;
+          \r}
+      \r}
+      \r\rif (env)
+        \r {
+        \rif (exists)
+          \r {
+          \r
+#ifndef _XBT_WIN32\r
+              unsetenv(name);
+          \r
+#else   /* \r */
+              SetEnvironmentVariable(name, NULL);
+          \r
+#endif  /* \r */
+              xbt_dynar_cursor_rm(unit->runner->variables, &i);
+          \r}
+        \r
+        else
+          \r {
+          \rERROR2
+              ("[%s] `(%s)' environment variable not found : impossible to unset it",
+               filepos, name);
+          \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rxbt_os_mutex_release(unit->mutex);
+          \rfailure(unit);
+          \rreturn;
+          \r}
+        \r}
+      \r
+      else
+        \r {
+        \rif (exists)
+          \r {
+          \rif (!err)
+            \r {
+            \rERROR2
+                ("[%s] `(%s)' is not an environment variable : use `unset' instead `unsetenv'",
+                 filepos, name);
+            \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rfailure(unit);
+            \rxbt_os_mutex_release(unit->mutex);
+            \rreturn;
+            \r}
+          \r
+          else
+            \r {
+            \rERROR2
+                ("[%s] `(%s)' is not an environment variable (it's a system variable) : impossible to unset it",
+                 filepos, name);
+            \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \rfailure(unit);
+            \rreturn;
+            \r}
+          \r}
+        \r
+        else
+          \r {
+          \rERROR2
+              ("[%s] `(%s)' environment variable not found : impossible to unset it",
+               filepos, name);
+          \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rxbt_os_mutex_release(unit->mutex);
+          \rfailure(unit);
+          \rreturn;
+          \r}
+        \r}
+      \r\rxbt_os_mutex_release(unit->mutex);
+      \r\r\r}
+    \r
+    else if (!strncmp(line, "setenv ", strlen("setenv ")))
+      \r {
+      \rchar *val;
+      \rchar name[PATH_MAX + 1] = { 0 };
+      \rchar *p;
+      \runsigned int i;
+      \rint is_blank;
+      \runsigned int j;
+      \r\rp = line + strlen("setenv ");
+      \r\rval = strchr(p, '=');
+      \r\rif (val)
+        \r {
+        \rvariable_t variable;
+        \rint exists = 0;
+        \rint env = 0;
+        \rint err = 0;
+        \rval++;
+        \r\r
+            /* syntax error */ \r
+            if (val[0] == '\0' || val[0] == ' ' || val[0] == '\t')
+          \r {
+          \rERROR1
+              ("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\r\r\rstrncpy(name, p, (val - p - 1));
+        \r\ris_blank = 1;
+        \r\rfor (j = 0; j < strlen(name); j++)
+          \rif (name[j] != ' ' && name[j] != '\t')
+            \ris_blank = 0;
+        \r\rif (is_blank)
+          \r {
+          \r\rERROR1
+              ("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\r
+            /* test if the variable is already registred */ \r
+            xbt_os_mutex_acquire(unit->mutex);
+        \r\rxbt_dynar_foreach(unit->runner->variables, i, variable) \r {
+          \rif (!strcmp(variable->name, name))
+            \r {
+            \renv = variable->env;
+            \rerr = variable->err;
+            \rexists = 1;
+            \rbreak;
+            \r}
+        \r}
+        \r\r
+            /* if the variable is already registred, update its value;\r
+             * otherwise register it.\r
+             */ \r
+            if (exists)
+          \r {
+          \rif (env)
+            \r {
+            \rif (!strcmp(val, variable->val))
+              \rWARN3
+                  ("[%s] This environment variable `(%s)' is already set with the value `(%s)'",
+                   filepos, name, val);
+            \r\rfree(variable->val);
+            \rvariable->val = strdup(val);
+            \r\r
+#ifdef _XBT_WIN32\r
+                SetEnvironmentVariable(variable->name, variable->val);
+            \r
+#else   /* \r */
+                setenv(variable->name, variable->val, 1);
+            \r
+#endif  /* \r */
+            }
+          \r
+          else
+            \r {
+            \rif (err)
+              \rERROR2
+                  ("[%s] Conflict : a system variable `(%s)' already exists",
+                   filepos, name);
+            \r
+            else
+              \rERROR2
+                  ("[%s] Conflict : (none environment) variable `(%s)' already exists",
+                   filepos, name);
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \rfailure(unit);
+            \rreturn;
+            \r}
+          \r}
+        \r
+        else
+          \r {
+          \rif (err)
+            \r {
+            \rERROR2("[%s] A system variable named `(%s)' already exists",
+                    filepos, name);
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \rfailure(unit);
+            \rreturn;
+            \r}
+          \r
+          else
+            \r {
+            \rvariable = variable_new(name, val);
+            \rvariable->env = 1;
+            \r\rxbt_dynar_push(unit->runner->variables, &variable);
+            \r\r
+#ifdef _XBT_WIN32\r
+                SetEnvironmentVariable(variable->name, variable->val);
+            \r
+#else   /* \r */
+                setenv(variable->name, variable->val, 0);
+            \r
+#endif  /* \r */
+            }
+          \r}
+        \r\rxbt_os_mutex_release(unit->mutex);
+        \r\r}
+      \r
+      else
+        \r {
+        \rERROR1
+            ("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rfailure(unit);
+        \rreturn;
+        \r}
+      \r}
+    \r
+    else if (!strncmp(line, "unset ", strlen("unset ")))
+      \r {
+      \runsigned int i, j;
+      \rint exists = 0;
+      \rint env = 0;
+      \rint err = 0;
+      \rvariable_t variable;
+      \rint is_blank;
+      \r\rchar *name = line + strlen("unset ");
+      \r\ris_blank = 1;
+      \r\rfor (j = 0; j < strlen(name); j++)
+        \rif (name[j] != ' ' && name[j] != '\t')
+          \ris_blank = 0;
+      \r\rif (is_blank)
+        \r {
+        \r\rERROR1
+            ("[%s] Bad usage of the metacommand unset `(usage : unset variable)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r\r\rxbt_os_mutex_acquire(unit->mutex);
+      \r\rxbt_dynar_foreach(unit->runner->variables, i, variable) \r {
+        \rif (!strcmp(variable->name, name))
+          \r {
+          \renv = variable->env;
+          \rerr = variable->err;
+          \rexists = 1;
+          \rbreak;
+          \r}
+      \r}
+      \r\rif (!env && !err)
+        \r {
+        \rif (exists)
+          \r {
+          \r
+              /*xbt_dynar_remove_at(unit->runner->variables, i, NULL); */ \r
+              /*xbt_dynar_cursor_rm(unit->runner->variables, &i); */ \r
+              if (variable->val)
+            \r {
+            \rfree(variable->val);
+            \rvariable->val = NULL;
+            \r}
+          \r
+          else
+            \r {
+            \rWARN2("[%s] Variable `(%s)' already unseted", filepos,
+                   variable->name);
+            \r}
+          \r}
+        \r
+        else
+          \r {
+          \rERROR2("[%s] `(%s)' variable not found", filepos, name);
+          \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rxbt_os_mutex_release(unit->mutex);
+          \rfailure(unit);
+          \rreturn;
+          \r}
+        \r}
+      \r
+      else if (env)
+        \r {
+        \rERROR2
+            ("[%s] `(%s)' is an environment variable use `unsetenv' instead `unset'",
+             filepos, name);
+        \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rxbt_os_mutex_release(unit->mutex);
+        \rfailure(unit);
+        \rreturn;
+        \r}
+      \r
+      else if (err)
+        \r {
+        \rERROR2("[%s] `(%s)' is system variable : you can unset it",
+                filepos, name);
+        \runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rxbt_os_mutex_release(unit->mutex);
+        \rfailure(unit);
+        \rreturn;
+        \r}
+      \r\rxbt_os_mutex_release(unit->mutex);
+      \r\r}
+    \r
+    else if (!strncmp(line, "set ", strlen("set ")))
+      \r {
+      \rchar *val;
+      \rchar name[PATH_MAX + 1] = { 0 };
+      \runsigned int j;
+      \rint is_blank;
+      \r\rval = strchr(line + strlen("set "), '=');
+      \r\rif (val)
+        \r {
+        \rvariable_t variable;
+        \rint exists = 0;
+        \runsigned int i;
+        \rint err;
+        \rint env;
+        \r\rval++;
+        \r\r\r
+            /* syntax error */ \r
+            if (val[0] == '\0')
+          \r {
+          \rERROR1
+              ("[%s] Bad usage of the metacommand set `(usage : set variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r
+        else if (val[0] == ' ' || val[0] == '\t')
+          \r {
+          \rstrncpy(name, line + strlen("set "),
+                   (val - (line + strlen("set "))));
+          \r\rERROR2("[%s] No space avaible after`(%s)'", filepos, name);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\r\r
+            /* assume it's a varibale */ \r
+            \rstrncpy(name, line + strlen("set "),
+                     (val - (line + strlen("set ")) - 1));
+        \r\ris_blank = 1;
+        \r\rfor (j = 0; j < strlen(name); j++)
+          \rif (name[j] != ' ' && name[j] != '\t')
+            \ris_blank = 0;
+        \r\rif (is_blank)
+          \r {
+          \r\rERROR1
+              ("[%s] Bad usage of the metacommand set `(usage : set variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\rxbt_os_mutex_acquire(unit->mutex);
+        \r\r
+            /* test if the variable is already registred */ \r
+            xbt_dynar_foreach(unit->runner->variables, i, variable) \r {
+          \rif (!strcmp(variable->name, name))
+            \r {
+            \rexists = 1;
+            \rerr = variable->err;
+            \renv = variable->env;
+            \rbreak;
+            \r}
+        \r}
+        \r\r
+            /* if the variable is already registred, update its value (if same value warns);\r
+             * otherwise register it.\r
+             */ \r
+            if (exists)
+          \r {
+          \rif (err)
+            \r {
+            \rERROR2("[%s] A system variable named `(%s)' already exists",
+                    filepos, name);
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rfailure(unit);
+            \rreturn;
+            \r}
+          \rif (env)
+            \r {
+            \rERROR2
+                ("[%s] `(%s)' is an environment variable use `setenv' instead `set'",
+                 filepos, name);
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rfailure(unit);
+            \rreturn;
+            \r}
+          \r
+          else
+            \r {
+            \rif (!strcmp(val, variable->val))
+              \rWARN3("[%s] Variable `(%s)' already contains value `<%s>'",
+                     filepos, variable->name, val);
+            \r\rfree(variable->val);
+            \rvariable->val = strdup(val);
+            \r}
+          \r}
+        \r
+        else
+          \r {
+          \rvariable_t new_var = variable_new(name, val);
+          \rxbt_dynar_push(unit->runner->variables, &new_var);
+          \r}
+        \r\r\rxbt_os_mutex_release(unit->mutex);
+        \r}
+      \r
+      else
+        \r {
+        \rERROR1
+            ("[%s] Bad usage of the metacommand set `(usage : set variable=value)'",
+             filepos);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \rfailure(unit);
+        \rreturn;
+        \r}
+      \r}
+    \r
+    else
+      \r {                       /* assume it's a variable */
+      \rchar *val;
+      \rchar name[PATH_MAX + 1] = { 0 };
+      \runsigned int i, j;
+      \rint is_blank;
+      \r\rval = strchr(line, '=');
+      \r\rif (val)
+        \r {
+        \rvariable_t variable;
+        \rint exists = 0;
+        \rint err;
+        \rint env;
+        \rval++;
+        \r\r\r
+            /* syntax error */ \r
+            if (val[0] == '\0')
+          \r {
+          \rstrncpy(name, line, (val - line - 1));
+          \r\ris_blank = 1;
+          \r\rfor (j = 0; j < strlen(name); j++)
+            \rif (name[j] != ' ' && name[j] != '\t')
+              \ris_blank = 0;
+          \r\rif (is_blank)
+            \rERROR1
+                ("[%s] Bad usage of Tesh variable mechanism `(usage : variable=value)'",
+                 filepos);
+          \r
+          else if (!strcmp("setenv", name))
+            \rERROR1
+                ("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'",
+                 filepos);
+          \r
+          else if (!strcmp("set", name))
+            \rERROR1
+                ("[%s] Bad usage of the metacommand set `(usage : set variable=value)'",
+                 filepos);
+          \r
+          else
+            \rERROR2("[%s] Undefined variable `(%s)'", filepos, name);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r
+        else if (val[0] == ' ' || val[0] == '\t')
+          \r {
+          \rstrncpy(name, line, (val - line));
+          \r\rERROR2("[%s] No space avaible after`(%s)'", filepos, name);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \r}
+        \r\r\r
+            /* assume it's a varibale */ \r
+            \rstrncpy(name, line, (val - line - 1));
+        \r\ris_blank = 1;
+        \r\rfor (j = 0; j < strlen(name); j++)
+          \rif (name[j] != ' ' && name[j] != '\t')
+            \ris_blank = 0;
+        \r\rif (is_blank)
+          \r {
+          \r\rERROR1
+              ("[%s] Bad usage of Tesh variable capability `(usage : variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \r\rfailure(unit);
+          \rreturn;
+          \r}
+        \r\rif (!strcmp("set", name))
+          \r {
+          \rERROR1
+              ("[%s] Bad usage of the metacommand set `(usage : set variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(unit);
+          \rreturn;
+          \r}
+        \r
+        else if (!strcmp("setenv", name))
+          \r {
+          \rERROR1
+              ("[%s] Bad usage of the metacommand setenv `(usage : setenv variable=value)'",
+               filepos);
+          \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+          \rfailure(unit);
+          \rreturn;
+          \r}
+        \r\rxbt_os_mutex_acquire(unit->mutex);
+        \r\r
+            /* test if the variable is already registred */ \r
+            xbt_dynar_foreach(unit->runner->variables, i, variable) \r {
+          \rif (!strcmp(variable->name, name))
+            \r {
+            \rexists = 1;
+            \rerr = variable->err;
+            \renv = variable->env;
+            \rbreak;
+            \r}
+        \r}
+        \r\r
+            /* if the variable is already registred, update its value (if same value warns);\r
+             * otherwise register it.\r
+             */ \r
+            if (exists)
+          \r {
+          \rif (err)
+            \r {
+            \rERROR2("[%s] A system variable named `(%s)' already exists",
+                    filepos, name);
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \rfailure(unit);
+            \rreturn;
+            \r}
+          \rif (env)
+            \r {
+            \rERROR2
+                ("[%s] `(%s)' is an environment variable use `setenv' metacommand",
+                 filepos, name);
+            \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+            \rxbt_os_mutex_release(unit->mutex);
+            \r\rfailure(unit);
+            \rreturn;
+            \r}
+          \r
+          else
+            \r {
+            \rif (!strcmp(val, variable->val))
+              \rWARN3("[%s] Variable `(%s)' already contains value `<%s>'",
+                     filepos, variable->name, val);
+            \r\rfree(variable->val);
+            \rvariable->val = strdup(val);
+            \r}
+          \r}
+        \r
+        else
+          \r {
+          \rvariable_t new_var = variable_new(name, val);
+          \rxbt_dynar_push(unit->runner->variables, &new_var);
+          \r}
+        \r\r\rxbt_os_mutex_release(unit->mutex);
+        \r\r}
+      \r
+      else
+        \r {
+        \rif (!strncmp("setenv", line, strlen("setenv")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand setenv : `(usage : setenv variable=value)'",
+               filepos);
+        \r
+        else if (!strncmp("set", line, strlen("set")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand set : `(usage : set variable=value)'",
+               filepos);
+        \r
+        else if (!strncmp("unsetenv", line, strlen("unsetenv")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand unsetenv : `(usage : unsetenv variable)'",
+               filepos);
+        \r
+        else if (!strncmp("unset", line, strlen("unset")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand unset : `(usage : unset variable)'",
+               filepos);
+        \r
+        else if (!strncmp("timeout", line, strlen("timeout")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand timeout : `(usage : timeout <integral positive integer>)'",
+               filepos);
+        \r
+        else if (!strncmp("expect signal", line, strlen("expect signal")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand expect signal : `(usage : expect signal <sig_name>)'",
+               filepos);
+        \r
+        else if (!strncmp("expect return", line, strlen("expect return")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand expect return : `(usage : expect return <return value (>=0 <=255)>)'",
+               filepos);
+        \r
+        else if (!strncmp("include", line, strlen("include")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand include  :`(usage : include <file> [<description>])'",
+               filepos);
+        \r
+        else if (!strncmp("suite", line, strlen("suite")))
+          \rERROR1
+              ("[%s] Bad usage of the metacommand suite : `(usage : suite <description>)'",
+               filepos);
+        \r
+        else
+          \rERROR2("[%s] Unknown metacommand: `%s'", filepos, line);
+        \r\runit_set_error(fstream->unit, ESYNTAX, 1, filepos);
+        \r\rfailure(unit);
+        \rreturn;
+        \r}
+      \r}
+    \r\rbreak;
+    \r}
+\r}
+
+\r\rvoid \r
+fstream_handle_include(fstream_t fstream, context_t context,
+                       xbt_os_mutex_t mutex, const char *file_name,
+                       const char *description) \r
+{
+  \rdirectory_t dir;
+  \rchar *prev_directory = NULL;
+  \rfstream_t _fstream = NULL;
+  \rstruct stat buffer = { 0 };
+  \runit_t unit = fstream->unit;
+  \r\rif (!stat(file_name, &buffer) && S_ISREG(buffer.st_mode))
+    \r {
+    \r
+        /* the file is in the current directory */ \r
+        _fstream = fstream_new(getcwd(NULL, 0), file_name);
+    \rfstream_open(_fstream);
+    \r}
+  \r
+      /* the file to include is not in the current directory, check if it is in a include directory */ \r
+      else
+    \r {
+    \runsigned int i;
+    \rprev_directory = getcwd(NULL, 0);
+    \r\rxbt_dynar_foreach(include_dirs, i, dir) \r {
+      \rchdir(dir->name);
+      \r\rif (!stat(file_name, &buffer) && S_ISREG(buffer.st_mode))
+        \r {
+        \r_fstream = fstream_new(dir->name, file_name);
+        \rfstream_open(_fstream);
+        \rbreak;
+        \r}
+    \r}
+    \r\rchdir(prev_directory);
+    \rfree(prev_directory);
+    \r}
+  \r\r
+      /* the file to include is not found handle the failure */ \r
+      if (!_fstream)
+    \r {
+    \rif (file_name[0] == '$')
+      \r {
+      \rERROR3
+          ("[%s] Include file `(%s)' not found or variable `(%s)' doesn't exist",
+           context->line, file_name, file_name + 1);
+      \r\r}
+    \r
+    else
+      \r {
+      \r
+          /* may be a variable */ \r
+          variable_t variable;
+      \rint exists = 0;
+      \runsigned int i;
+      \r\rxbt_dynar_foreach(unit->runner->variables, i, variable) \r {
+        \rif (!strcmp(variable->name, file_name))
+          \r {
+          \rexists = 1;
+          \rbreak;
+          \r}
+      \r}
+      \r\rif (exists)
+        \rERROR3
+            ("[%s] Include file `(%s)' not found (if you want to use the variable <%s> add the prefix `$')",
+             context->line, file_name, file_name);
+      \r
+      else
+        \rERROR2("[%s] Include file `(%s)' not found", context->line,
+                file_name);
+      \r}
+    \r\runit_set_error(fstream->unit, EINCLUDENOTFOUND, 1, context->line);
+    \r\rfailure(fstream->unit);
+    \r\rreturn;
+    \r}
+  \r
+  else
+    \r {
+    \rif (!unit->is_running_suite)
+      \r {                       /* it's the unit of a suite */
+      \runit_t include = unit_new(unit->runner, unit->root, unit, _fstream);
+      \r\rinclude->mutex = unit->root->mutex;
+      \r\rif (description)
+        \rinclude->description = strdup(description);
+      \r\rxbt_dynar_push(unit->includes, &include);
+      \r\rif (!dry_run_flag)
+        \r {
+        \rif (description)
+          \rINFO2("Include from %s (%s)", _fstream->name, description);
+        \r
+        else
+          \rINFO1("Include from %s", _fstream->name);
+        \r\r}
+      \r
+      else
+        \rINFO1("Checking include %s...", _fstream->name);
+      \r\rfstream_parse(_fstream, mutex);
+      \r}
+    \r
+    else
+      \r {                       /* it's a include */
+      \r\runit_t * owner;
+      \runit_t include;
+      \r\rowner =
+          xbt_dynar_get_ptr(unit->suites,
+                            xbt_dynar_length(unit->suites) - 1);
+      \r\rinclude = unit_new(unit->runner, unit->root, *owner, _fstream);
+      \r\rinclude->mutex = unit->root->mutex;
+      \r\rif (description)
+        \rinclude->description = strdup(description);
+      \r\rxbt_dynar_push((*owner)->includes, &include);
+      \r\rif (!dry_run_flag)
+        \r {
+        \rif (description)
+          \rINFO2("Include from %s (%s)", _fstream->name, description);
+        \r
+        else
+          \rINFO1("Include from %s", _fstream->name);
+        \r}
+      \r
+      else
+        \rINFO1("Checking include %s...", _fstream->name);
+      \r\rfstream_parse(_fstream, mutex);
+      \r}
+    \r}
+\r}
+
+\r\rvoid \r
+fstream_handle_suite(fstream_t fstream, const char *description,
+                     const char *filepos) \r
+{
+  \runit_t unit = fstream->unit;
+  \runit_t suite = unit_new(unit->runner, unit->root, unit, NULL);
+  \r\rif (description)
+    \rsuite->description = strdup(description);
+  \r\rsuite->filepos = strdup(filepos);
+  \r\rxbt_dynar_push(unit->suites, &suite);
+  \runit->is_running_suite = 1;
+  \r\rif (!dry_run_flag)
+    \rINFO1("Test suite %s", description);
+  \r
+  else
+    \rINFO1("Checking suite %s...", description);
+\r\r}
+
+\r\rint \r
+fstream_launch_command(fstream_t fstream, context_t context,
+                       xbt_os_mutex_t mutex) \r
+{
+  \runit_t unit = fstream->unit;
+  \r\rif (!dry_run_flag)
+    \r {
+    \rcommand_t command;
+    \r\rif (!(command = command_new(unit, context, mutex)))
+      \r {
+      \rif (EINVAL == errno)
+        \r {
+        \rERROR3("[%s] Cannot instantiate the command `%s' (%d)",
+                context->pos, strerror(errno), errno);
+        \r\runit_set_error(unit, errno, 0, context->pos);
+        \rfailure(unit);
+        \rreturn -1;
+        \r}
+      \r
+      else if (ENOMEM == errno)
+        \r {
+        \rERROR3("[%s] Cannot instantiate the command `%s' (%d)",
+                context->pos, strerror(errno), errno);
+        \r\runit_set_error(unit, errno, 0, context->pos);
+        \r\rfailure(unit);
+        \rreturn -1;
+        \r}
+      \r}
+    \r\rif (command_run(command) < 0)
+      \r {
+      \rERROR3("[%s] Cannot run the command `%s' (%d)", context->pos,
+              strerror(errno), errno);
+      \runit_set_error(unit, errno, 0, context->pos);
+      \rfailure(unit);
+      \rreturn -1;
+      \r}
+    \r}
+  \r\rif (context_reset(context) < 0)
+    \r {
+    \rERROR3("[%s] Cannot reset the context of the command `%s' (%d)",
+            context->pos, strerror(errno), errno);
+    \r\runit_set_error(fstream->unit, errno, 0, context->pos);
+    \r\rfailure(unit);
+    \rreturn -1;
+    \r}
+  \r\rreturn 0;
+\r}
+
+\r\r\r\r\r
index 5fb75df..66336a3 100644 (file)
 #include <fstreams.h>\r
 #include <excludes.h>\r
 #include <fstream.h>\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rfstreams_t \r fstreams_new(void_f_pvoid_t fn_finalize) \r
+{
+  \rfstreams_t fstreams = xbt_new0(s_fstreams_t, 1);
+  \rfstreams->items = xbt_dynar_new(sizeof(fstream_t), fn_finalize);
+  \r\rreturn fstreams;
+\r}
+
+\r\rint \r fstreams_exclude(fstreams_t fstreams, excludes_t excludes) \r
+{
+  \rfstream_t fstream;
+  \runsigned int i;
+  \r\rif (!fstreams || !excludes)
+    \rreturn EINVAL;
+  \r\rif (excludes_is_empty(excludes))
+    \rreturn 0;
+  \r\r
+      /* collecte the file streams to exclude */ \r
+      xbt_dynar_foreach(fstreams->items, i, fstream) \r {
+    \rif (excludes_contains(excludes, fstream))
+      \r {
+      \rINFO1("excluding %s", fstream->name);
+      \rxbt_dynar_cursor_rm(fstreams->items, &i);
+      \r}
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r fstreams_contains(fstreams_t fstreams, fstream_t fstream) \r
+{
+  \rfstream_t cur;
+  \runsigned int i;
+  \r\rif (!fstreams || !fstream)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn 0;
+    \r}
+  \r\rxbt_dynar_foreach(fstreams->items, i, cur) \r {
+    \rif (!strcmp(cur->name, fstream->name)
+         && !strcmp(cur->directory, fstream->directory))
+      \rreturn 1;
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r fstreams_load(fstreams_t fstreams) \r
+{
+  \rfstream_t fstream;
+  \runsigned int i;
+  \r\rif (!fstreams)
+    \rreturn EINVAL;
+  \r\rxbt_dynar_foreach(fstreams->items, i, fstream) \r {
+    \rfstream_open(fstream);
+  \r}
+  \r\r\rreturn 0;
+\r}
+
+\r\rint \r fstreams_add(fstreams_t fstreams, fstream_t fstream) \r
+{
+  \rif (!fstreams)
+    \rreturn EINVAL;
+  \r\rxbt_dynar_push(fstreams->items, &fstream);
+  \r\rreturn 0;
+\r}
+
+\r\rint \r fstreams_free(void **fstreamsptr) \r
+{
+  \rif (!(*fstreamsptr))
+    \rreturn EINVAL;
+  \r\rif ((*((fstreams_t *) fstreamsptr))->items)
+    \rxbt_dynar_free(&((*((fstreams_t *) fstreamsptr))->items));
+  \r\rfree(*fstreamsptr);
+  \r\r*fstreamsptr = NULL;
+  \rreturn 0;
+\r}
+
+\r\rint \r fstreams_get_size(fstreams_t fstreams) \r
+{
+  \rif (!fstreams)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rreturn xbt_dynar_length(fstreams->items);
+\r}
+
+\r\rint \r fstreams_is_empty(fstreams_t fstreams) \r
+{
+  \rif (!fstreams)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rreturn (0 == xbt_dynar_length(fstreams->items));
+\r}
+
 \r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-fstreams_t\r
-fstreams_new(void_f_pvoid_t fn_finalize)\r
-{\r
-       fstreams_t fstreams = xbt_new0(s_fstreams_t, 1);\r
-       fstreams->items = xbt_dynar_new(sizeof(fstream_t), fn_finalize);\r
-       \r
-       return fstreams;\r
-}\r
-\r
-int\r
-fstreams_exclude(fstreams_t fstreams, excludes_t excludes)\r
-{\r
-       fstream_t fstream;\r
-       unsigned int i;\r
-       \r
-       if(!fstreams || !excludes)\r
-               return EINVAL;\r
-               \r
-       if(excludes_is_empty(excludes))\r
-               return 0;\r
-       \r
-       /* collecte the file streams to exclude */\r
-       xbt_dynar_foreach(fstreams->items, i, fstream)\r
-       {\r
-               if(excludes_contains(excludes, fstream))\r
-               {\r
-                       INFO1("excluding %s",fstream->name);\r
-                       xbt_dynar_cursor_rm(fstreams->items, &i);\r
-               }\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int \r
-fstreams_contains(fstreams_t fstreams, fstream_t fstream)\r
-{\r
-       fstream_t cur;\r
-       unsigned int i;\r
-       \r
-       if(!fstreams || !fstream)\r
-       {\r
-               errno = EINVAL;\r
-               return 0;\r
-       }\r
-\r
-       xbt_dynar_foreach(fstreams->items, i, cur)\r
-       {\r
-               if(!strcmp(cur->name, fstream->name) && !strcmp(cur->directory, fstream->directory))\r
-                       return 1;\r
-       }\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-fstreams_load(fstreams_t fstreams)\r
-{\r
-       fstream_t fstream;\r
-       unsigned int i;\r
-       \r
-       if(!fstreams )\r
-               return EINVAL;\r
-\r
-       xbt_dynar_foreach(fstreams->items, i, fstream)\r
-       {\r
-               fstream_open(fstream);\r
-       }\r
-       \r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-fstreams_add(fstreams_t fstreams, fstream_t fstream)\r
-{\r
-       if(!fstreams)\r
-               return EINVAL;\r
-\r
-       xbt_dynar_push(fstreams->items, &fstream);\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-fstreams_free(void** fstreamsptr)\r
-{\r
-       if(!(* fstreamsptr))\r
-               return EINVAL;\r
-       \r
-       if((*((fstreams_t*)fstreamsptr))->items)\r
-               xbt_dynar_free(&((*((fstreams_t*)fstreamsptr))->items));\r
-               \r
-       free(*fstreamsptr);\r
-       \r
-       *fstreamsptr = NULL;\r
-       return 0;\r
-}\r
-\r
-int\r
-fstreams_get_size(fstreams_t fstreams)\r
-{\r
-       if(!fstreams)\r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-       \r
-       return xbt_dynar_length(fstreams->items);\r
-}\r
-\r
-int\r
-fstreams_is_empty(fstreams_t fstreams)\r
-{\r
-       if(!fstreams)\r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-       \r
-       return (0 == xbt_dynar_length(fstreams->items));\r
-}\r
index 4f768d7..d3e9913 100644 (file)
 #include <com.h>\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\r
 /*#include <stdlib.h>\r
 #include <string.h>\r
 \r
-*/\r
-\r
+*/ \r
+    \r
 #include <sys/types.h>\r
 #include <sys/stat.h>\r
-\r
+    \r
 #ifndef _XBT_WIN32\r
 #include <pwd.h>\r
-#else\r
-#endif\r
-\r
+#else   /* \r */
+#endif  /* \r */
+    \r
 #include <errno.h>\r
 #include <getpath.h>\r
-\r
+    \r
 #ifndef PATH_MAX\r
 #define PATH_MAX 255\r
-#endif\r
-\r
+#endif  /* \r */
+    \r
 #ifndef _XBT_WIN32\r
-int\r
-getpath(const char* file, char** path)\r
-{\r
-       char buffer1[PATH_MAX + 1] = {0};\r
-       char buffer2[PATH_MAX + 1] = {0};\r
-       char buffer3[PATH_MAX + 1] = {0};       \r
-       char *p1,*p2;\r
-       size_t len = strlen(file);\r
-       char* last_delimiter = NULL;\r
-       struct stat buffer = {0};               \r
-       \r
-       strncpy(buffer1, file, len);    \r
-       \r
-       /* remove the /////// */\r
-       while((p1 = strstr(buffer1, "//"))) \r
-       {\r
-               if(p1[2]) \r
-                       strcpy(p1, p1 + 1); \r
-               else \r
-                       p1[1] = '\0';\r
-       }\r
-       \r
-       if(*buffer1 == '~') \r
-       {\r
-               for(p2 = buffer2, p1 = buffer1 + 1; *p1 && (*p1 != '/'); *p2++ = *p1++);\r
-                       *p2 = '\0';                             \r
-               \r
-               if(buffer2[0] == '\0') \r
-               {\r
-                       char* home = getenv("HOME");\r
-       \r
-                       if(home) \r
-                       {\r
-                               strcpy(buffer2, home);          \r
-                       } \r
-                       else \r
-                       {\r
-                               struct passwd* pw = getpwuid(getuid());  \r
-                               \r
-                               if(!pw) \r
-                               {\r
-                                       *path = NULL;\r
-                                       return -1;      \r
-                               }\r
-                               \r
-                               strcpy(buffer2,pw->pw_dir);     \r
-                       }\r
-                       \r
-                       strcat(buffer2, p1);\r
-               } \r
-               \r
-       }\r
-       else if (buffer1[0] != '/') \r
-       {\r
-       \r
-               getcwd(buffer2, PATH_MAX + 1);  \r
-               \r
-               if(buffer1[0] == '.' && buffer1[1] == '/') \r
-               {       /* replace */\r
-                       strcat(buffer2, &buffer1[1]);           \r
-               } \r
-               else \r
-               {       \r
-                       strcat(buffer2, "/");                   \r
-                       strcat(buffer2, buffer1);               \r
-               }\r
-       } \r
-       else \r
-       {       \r
-               strcpy(buffer2, buffer1);                       /* copy */\r
-       }\r
-               \r
-       /*\r
-        * check for /..\r
-        */\r
-       while((p1 = strstr( buffer2, "/.." ))) \r
-       {\r
-               for( p2 = p1; --p2 > buffer2 && *p2 != '/'; );\r
-               \r
-               if (*(p1 + 3)) \r
-                       memmove(p2, p1+3, strlen(p1+3)+1);\r
-               else \r
-                       *p2 = '\0';\r
-       }\r
-       \r
-       /*\r
-        * try to find links, and resolve them.\r
-        */\r
-       p1 = strtok( buffer2, "/" );\r
-       \r
-       *buffer3 = '\0';\r
-       \r
-       while(p1) \r
-       {\r
-               strcat( buffer3, "/" );\r
-               strcat( buffer3, p1 );\r
-               \r
-               len = readlink(buffer3, buffer1, PATH_MAX);\r
-               \r
-               if (len != -1) \r
-               {\r
-                       *(buffer1 + len) = '\0';\r
-                       strcpy(buffer3, buffer1 );\r
-               }\r
-               \r
-               p1 = strtok( NULL, "/" );\r
-       }\r
-       \r
-       if(stat(buffer3, &buffer) || !S_ISREG(buffer.st_mode))\r
-       {\r
-               *path = NULL;\r
-               errno = ENOENT;\r
-               return -1;\r
-       }                                                               \r
-               \r
-       last_delimiter = strrchr(buffer3, '/');\r
-       \r
-       len = strlen(buffer3);\r
-       \r
-       if(last_delimiter)\r
-               len -=strlen(last_delimiter);                    \r
-       \r
-       *path = (char*) calloc(len + 1, sizeof(char));\r
-       \r
-       if(!(*path))\r
-       {\r
-               *path = NULL;\r
-               return -1;\r
-       }\r
-               \r
-       strncpy(*path, buffer3, len);\r
-\r
-       return len;\r
-}\r
-\r
-int\r
-translatepath(const char* totranslate, char** translated)\r
-{\r
-       char buffer1[PATH_MAX + 1] = {0};               \r
-       char buffer2[PATH_MAX + 1] = {0};\r
-       char buffer3[PATH_MAX + 1] = {0};       \r
-       char *p1,*p2;\r
-       size_t len;     \r
-       struct stat buffer = {0};\r
-       \r
-       len = strlen(totranslate);                                              \r
-       \r
-       strncpy(buffer1, totranslate, len);     \r
-       \r
-       if(!strcmp(buffer1,"."))\r
-       {\r
-               *translated = getcwd(NULL,0);\r
-               return strlen(*translated);\r
-       }\r
-       else if(!strcmp(buffer1, "/.."))\r
-       {\r
-               *translated = strdup("/");\r
-               return strlen(*translated);\r
-       }\r
-       \r
-       while((p1 = strstr(buffer1, "//"))) \r
-               if(p1[2]) \r
-                       strcpy(p1, p1 + 1); \r
-               else \r
-                       p1[1] = '\0';\r
-       \r
-       if (buffer1[0] == '~') \r
-       {\r
-               for (p2 = buffer2, p1 = buffer1 + 1; *p1 && (*p1 != '/'); *(p2++) = *(p1++));\r
-               \r
-               *p2 = '\0';                             \r
-               \r
-               if(buffer2[0] == '\0') \r
-               {\r
-                       char* home = getenv("HOME");\r
-       \r
-                       if(home) \r
-                       {\r
-                               strcpy(buffer2, home);\r
-                       } \r
-                       else \r
-                       {\r
-                               struct passwd* pw = getpwuid(getuid());  /* get entry */\r
-                               \r
-                               if(!pw)\r
-                               {\r
-                                       *translated = NULL; \r
-                                       return -1;\r
-                               }\r
-                               \r
-                               strcpy(buffer2,pw->pw_dir);     \r
-                       }\r
-                       \r
-                       strcat(buffer2, p1);\r
-               } \r
-       }\r
-       else if (*buffer1 != '/') \r
-       {\r
-       \r
-               getcwd(buffer2, PATH_MAX + 1);\r
-               \r
-               if (*buffer1 == '.' && *(buffer1 + 1) == '/') \r
-               {\r
-                       strcat(buffer2, buffer1+1);             \r
-               } \r
-               else \r
-               {       \r
-                       strcat(buffer2, "/");                   \r
-                       strcat(buffer2, buffer1);               \r
-               }\r
-       } \r
-       else \r
-       {       \r
-               strcpy(buffer2, buffer1);                       \r
-       }\r
-       \r
-       /*\r
-        * check for /..\r
-        */\r
-       while((p1 = strstr( buffer2, "/.." ))) \r
-       {\r
-               for( p2 = p1; --p2 > buffer2 && *p2 != '/'; );\r
-               \r
-               if (*(p1 + 3)) \r
-                       memmove(p2, p1+3, strlen(p1+3)+1);\r
-               else \r
-                       *p2 = '\0';\r
-       }\r
-       \r
-       /*\r
-        * try to find links.\r
-        */\r
-       p1 = strtok( buffer2, "/" );\r
-       \r
-       \r
-       *buffer3 = '\0';\r
-       \r
-       while(p1) \r
-       {\r
-               strcat( buffer3, "/" );\r
-               strcat( buffer3, p1 );\r
-               \r
-               len = readlink(buffer3, buffer1, PATH_MAX);\r
-               \r
-               if (len != -1) \r
-               {\r
-                       *(buffer1 + len) = '\0';\r
-                       strcpy(buffer3, buffer1 );\r
-               }\r
-               \r
-               p1 = strtok( NULL, "/" );\r
-       }\r
-       \r
-       if (!(*buffer3)) \r
-               strcpy(buffer3, "/" );          \r
-       \r
-       len = strlen(buffer3);\r
-       \r
-       if(stat(buffer3, &buffer) || !S_ISDIR(buffer.st_mode))\r
-       {\r
-               *translated = NULL;\r
-               errno = ENOTDIR;\r
-               return -1;\r
-       }\r
-                                \r
-       \r
-       *translated = (char*) calloc(len + 1, sizeof(char));\r
-       \r
-       if(!(*translated))\r
-       {\r
-               *translated = NULL;\r
-               return -1;\r
-       }\r
-       \r
-       strncpy(*translated, buffer3, len);\r
-       \r
-       return len;\r
-}\r
-#else\r
+int \r getpath(const char *file, char **path) \r
+{
+  \rchar buffer1[PATH_MAX + 1] = { 0 };
+  \rchar buffer2[PATH_MAX + 1] = { 0 };
+  \rchar buffer3[PATH_MAX + 1] = { 0 };
+  \rchar *p1, *p2;
+  \rsize_t len = strlen(file);
+  \rchar *last_delimiter = NULL;
+  \rstruct stat buffer = { 0 };
+  \r\rstrncpy(buffer1, file, len);
+  \r\r
+      /* remove the /////// */ \r
+      while ((p1 = strstr(buffer1, "//")))
+    \r {
+    \rif (p1[2])
+      \rstrcpy(p1, p1 + 1);
+    \r
+    else
+      \rp1[1] = '\0';
+    \r}
+  \r\rif (*buffer1 == '~')
+    \r {
+    \rfor (p2 = buffer2, p1 = buffer1 + 1; *p1 && (*p1 != '/');
+          *p2++ = *p1++);
+    \r*p2 = '\0';
+    \r\rif (buffer2[0] == '\0')
+      \r {
+      \rchar *home = getenv("HOME");
+      \r\rif (home)
+        \r {
+        \rstrcpy(buffer2, home);
+        \r}
+      \r
+      else
+        \r {
+        \rstruct passwd *pw = getpwuid(getuid());
+        \r\rif (!pw)
+          \r {
+          \r*path = NULL;
+          \rreturn -1;
+          \r}
+        \r\rstrcpy(buffer2, pw->pw_dir);
+        \r}
+      \r\rstrcat(buffer2, p1);
+      \r}
+    \r\r}
+  \r
+  else if (buffer1[0] != '/')
+    \r {
+    \r\rgetcwd(buffer2, PATH_MAX + 1);
+    \r\rif (buffer1[0] == '.' && buffer1[1] == '/')
+      \r {                       /* replace */
+      \rstrcat(buffer2, &buffer1[1]);
+      \r}
+    \r
+    else
+      \r {
+      \rstrcat(buffer2, "/");
+      \rstrcat(buffer2, buffer1);
+      \r}
+    \r}
+  \r
+  else
+    \r {
+    \rstrcpy(buffer2, buffer1);  /* copy */
+    \r}
+  \r\r
+      /*\r
+       * check for /..\r
+       */ \r
+      while ((p1 = strstr(buffer2, "/..")))
+    \r {
+    \rfor (p2 = p1; --p2 > buffer2 && *p2 != '/';);
+    \r\rif (*(p1 + 3))
+      \rmemmove(p2, p1 + 3, strlen(p1 + 3) + 1);
+    \r
+    else
+      \r*p2 = '\0';
+    \r}
+  \r\r
+      /*\r
+       * try to find links, and resolve them.\r
+       */ \r
+      p1 = strtok(buffer2, "/");
+  \r\r*buffer3 = '\0';
+  \r\rwhile (p1)
+    \r {
+    \rstrcat(buffer3, "/");
+    \rstrcat(buffer3, p1);
+    \r\rlen = readlink(buffer3, buffer1, PATH_MAX);
+    \r\rif (len != -1)
+      \r {
+      \r*(buffer1 + len) = '\0';
+      \rstrcpy(buffer3, buffer1);
+      \r}
+    \r\rp1 = strtok(NULL, "/");
+    \r}
+  \r\rif (stat(buffer3, &buffer) || !S_ISREG(buffer.st_mode))
+    \r {
+    \r*path = NULL;
+    \rerrno = ENOENT;
+    \rreturn -1;
+    \r}
+  \r\rlast_delimiter = strrchr(buffer3, '/');
+  \r\rlen = strlen(buffer3);
+  \r\rif (last_delimiter)
+    \rlen -= strlen(last_delimiter);
+  \r\r*path = (char *) calloc(len + 1, sizeof(char));
+  \r\rif (!(*path))
+    \r {
+    \r*path = NULL;
+    \rreturn -1;
+    \r}
+  \r\rstrncpy(*path, buffer3, len);
+  \r\rreturn len;
+\r}
+
+\r\rint \r translatepath(const char *totranslate, char **translated) \r
+{
+  \rchar buffer1[PATH_MAX + 1] = { 0 };
+  \rchar buffer2[PATH_MAX + 1] = { 0 };
+  \rchar buffer3[PATH_MAX + 1] = { 0 };
+  \rchar *p1, *p2;
+  \rsize_t len;
+  \rstruct stat buffer = { 0 };
+  \r\rlen = strlen(totranslate);
+  \r\rstrncpy(buffer1, totranslate, len);
+  \r\rif (!strcmp(buffer1, "."))
+    \r {
+    \r*translated = getcwd(NULL, 0);
+    \rreturn strlen(*translated);
+    \r}
+  \r
+  else if (!strcmp(buffer1, "/.."))
+    \r {
+    \r*translated = strdup("/");
+    \rreturn strlen(*translated);
+    \r}
+  \r\rwhile ((p1 = strstr(buffer1, "//")))
+    \rif (p1[2])
+      \rstrcpy(p1, p1 + 1);
+  \r
+    else
+      \rp1[1] = '\0';
+  \r\rif (buffer1[0] == '~')
+    \r {
+    \rfor (p2 = buffer2, p1 = buffer1 + 1; *p1 && (*p1 != '/');
+          *(p2++) = *(p1++));
+    \r\r*p2 = '\0';
+    \r\rif (buffer2[0] == '\0')
+      \r {
+      \rchar *home = getenv("HOME");
+      \r\rif (home)
+        \r {
+        \rstrcpy(buffer2, home);
+        \r}
+      \r
+      else
+        \r {
+        \rstruct passwd *pw = getpwuid(getuid());        /* get entry */
+        \r\rif (!pw)
+          \r {
+          \r*translated = NULL;
+          \rreturn -1;
+          \r}
+        \r\rstrcpy(buffer2, pw->pw_dir);
+        \r}
+      \r\rstrcat(buffer2, p1);
+      \r}
+    \r}
+  \r
+  else if (*buffer1 != '/')
+    \r {
+    \r\rgetcwd(buffer2, PATH_MAX + 1);
+    \r\rif (*buffer1 == '.' && *(buffer1 + 1) == '/')
+      \r {
+      \rstrcat(buffer2, buffer1 + 1);
+      \r}
+    \r
+    else
+      \r {
+      \rstrcat(buffer2, "/");
+      \rstrcat(buffer2, buffer1);
+      \r}
+    \r}
+  \r
+  else
+    \r {
+    \rstrcpy(buffer2, buffer1);
+    \r}
+  \r\r
+      /*\r
+       * check for /..\r
+       */ \r
+      while ((p1 = strstr(buffer2, "/..")))
+    \r {
+    \rfor (p2 = p1; --p2 > buffer2 && *p2 != '/';);
+    \r\rif (*(p1 + 3))
+      \rmemmove(p2, p1 + 3, strlen(p1 + 3) + 1);
+    \r
+    else
+      \r*p2 = '\0';
+    \r}
+  \r\r
+      /*\r
+       * try to find links.\r
+       */ \r
+      p1 = strtok(buffer2, "/");
+  \r\r\r*buffer3 = '\0';
+  \r\rwhile (p1)
+    \r {
+    \rstrcat(buffer3, "/");
+    \rstrcat(buffer3, p1);
+    \r\rlen = readlink(buffer3, buffer1, PATH_MAX);
+    \r\rif (len != -1)
+      \r {
+      \r*(buffer1 + len) = '\0';
+      \rstrcpy(buffer3, buffer1);
+      \r}
+    \r\rp1 = strtok(NULL, "/");
+    \r}
+  \r\rif (!(*buffer3))
+    \rstrcpy(buffer3, "/");
+  \r\rlen = strlen(buffer3);
+  \r\rif (stat(buffer3, &buffer) || !S_ISDIR(buffer.st_mode))
+    \r {
+    \r*translated = NULL;
+    \rerrno = ENOTDIR;
+    \rreturn -1;
+    \r}
+  \r\r\r*translated = (char *) calloc(len + 1, sizeof(char));
+  \r\rif (!(*translated))
+    \r {
+    \r*translated = NULL;
+    \rreturn -1;
+    \r}
+  \r\rstrncpy(*translated, buffer3, len);
+  \r\rreturn len;
+\r}
+
+\r
+#else   /* \r */
 /*int\r
 getpath(const char* file, char** path)\r
 {\r
@@ -332,166 +294,144 @@ getpath(const char* file, char** path)
        *path = strncpy(*path, buffer, strlen(buffer) - strlen(part) - 1);\r
 \r
        return (int)(strlen(buffer) - strlen(part) -1);\r
-}*/\r
-\r
-int\r
-getpath(const char* file, char** path)\r
-{\r
-       char buf1[PATH_MAX + 1] = {0};\r
-       char buf2[PATH_MAX + 1] = {0};\r
-       struct stat info = {0};\r
-\r
-       char* delimiter;\r
-       \r
-       if(!file)\r
-       {\r
-               *path = NULL;\r
-               return -1;\r
-       }\r
-\r
-       delimiter = strrchr(file,'/');\r
-\r
-       if(!delimiter)\r
-               delimiter = strrchr(file,'\\');\r
-\r
-       if(!delimiter)\r
-       {\r
-               *path = getcwd(NULL,0);\r
-       }\r
-       else\r
-       {\r
-               strncpy(buf2, file, (delimiter - file));\r
-\r
-               if(translatepath(buf2, path) < 0)\r
-               {\r
-                       if(errno == ENOTDIR)\r
-                               errno = ENOENT;\r
-\r
-                       return -1;\r
-               }\r
-       }\r
-\r
-       sprintf(buf1,"%s\\%s", *path, delimiter ? delimiter + 1 : file);\r
-\r
-       \r
-       if(stat(buf1, &info) || !S_ISREG(info.st_mode))\r
-       {\r
-               free(*path);\r
-               *path = NULL;\r
-               errno = ENOENT;\r
-               return -1;\r
-       }               \r
-       \r
-       return (int) strlen(*path);\r
-}\r
-\r
-\r
-int\r
-translatepath(const char* totranslate, char** translated)\r
-{\r
-       char buffer1[PATH_MAX + 1] = {0};               \r
-       char buffer2[PATH_MAX + 1] = {0};\r
-       char *p1;\r
-       int i, len;\r
-       \r
-       struct stat stat_buf = {0};\r
-\r
-       len = (int)strlen(totranslate);                                         \r
-       \r
-       strncpy(buffer1, totranslate, len);\r
-\r
-       while((p1 = strstr(buffer1, "//"))) \r
-               if(p1[2]) \r
-                       strcpy(p1, p1 + 1); \r
-               else \r
-                       p1[1] = '\0';\r
-\r
-       if(buffer1[strlen(buffer1) - 1] == '/' || buffer1[strlen(buffer1) - 1] == '\\')\r
-               buffer1[strlen(buffer1) - 1] = '\0';\r
-       \r
-       /* return the current directory */\r
-       if(!strcmp(totranslate,".") || !strcmp(totranslate,"./"))\r
-       {\r
-               *translated = getcwd(NULL,0);\r
-               return (int)strlen(*translated);\r
-       }\r
-       /* return the previous directory */\r
-       else if(!strcmp(totranslate,"..") || !strcmp(totranslate,"../"))\r
-       {\r
-               getcwd(buffer1, PATH_MAX + 1);\r
-               p1 = strrchr(buffer1, '\\');\r
-               *translated = (char*) calloc((p1 - buffer1) + 1, sizeof(char));\r
-               strncpy(*translated, buffer1, (p1 - buffer1));\r
-               \r
-               return (int)strlen(*translated);\r
-       }\r
-       /* return the root directory */\r
-       else if(!strcmp(totranslate, "/"))\r
-       {\r
-               *translated = getcwd(NULL,0);\r
-               (*translated)[2] = '\0';\r
-\r
-               return (int)strlen(*translated);\r
-       }\r
-       /* it's a relative directory name build the full directory name (directory)*/\r
-       else if( buffer1[0] != '.' && buffer1[0] != '/' && buffer1[1] != ':' && !stat(totranslate, &stat_buf) && S_ISDIR(stat_buf.st_mode))\r
-       {\r
-               for(i = 0; buffer1[i] !='\0'; i++)\r
-               {\r
-                       if(buffer1[i] == '/')\r
-                               buffer2[i] = '\\';\r
-                       else\r
-                               buffer2[i] = buffer1[i];\r
-               }\r
-               \r
-               memset(buffer1, 0, PATH_MAX + 1);\r
-               getcwd(buffer1, PATH_MAX + 1);\r
-               strcat(buffer1,"\\");\r
-               strcat(buffer1,buffer2);\r
-               \r
-               *translated = (char*) calloc(strlen(buffer1) + 1, sizeof(char));\r
-               strcpy(*translated, buffer1);\r
-\r
-               return (int)strlen(*translated);\r
-       }\r
-       else if(buffer1[0] == '~') \r
-       {\r
-               /* TODO */\r
-               *translated = NULL;\r
-               errno = ENOSYS;\r
-               return -1;\r
-       }\r
-       else if (*buffer1 == '.') \r
-       {\r
-               _fullpath(buffer2, buffer1, sizeof(buffer1));\r
-       } \r
-       else \r
-               strcpy(buffer2, buffer1);\r
-       \r
-       if(stat(buffer2, &stat_buf) || !S_ISDIR(stat_buf.st_mode))\r
-       {\r
-               *translated = NULL;\r
-               errno = ENOTDIR;\r
-               return -1;\r
-       }\r
-       \r
-\r
-       \r
-       len = (int)strlen(buffer2);\r
-       \r
-\r
-       \r
-       *translated = (char*) calloc(len + 1, sizeof(char));\r
-       strcpy(*translated, buffer2);\r
-       \r
-       if(!(*translated))\r
-       {\r
-               *translated = NULL;\r
-               return -1;\r
-       }\r
-\r
-       return len;\r
-}\r
-#endif\r
-\r
-\r
+}*/ \r
+\rint \r getpath(const char *file, char **path) \r
+{
+  \rchar buf1[PATH_MAX + 1] = { 0 };
+  \rchar buf2[PATH_MAX + 1] = { 0 };
+  \rstruct stat info = { 0 };
+  \r\rchar *delimiter;
+  \r\rif (!file)
+    \r {
+    \r*path = NULL;
+    \rreturn -1;
+    \r}
+  \r\rdelimiter = strrchr(file, '/');
+  \r\rif (!delimiter)
+    \rdelimiter = strrchr(file, '\\');
+  \r\rif (!delimiter)
+    \r {
+    \r*path = getcwd(NULL, 0);
+    \r}
+  \r
+  else
+    \r {
+    \rstrncpy(buf2, file, (delimiter - file));
+    \r\rif (translatepath(buf2, path) < 0)
+      \r {
+      \rif (errno == ENOTDIR)
+        \rerrno = ENOENT;
+      \r\rreturn -1;
+      \r}
+    \r}
+  \r\rsprintf(buf1, "%s\\%s", *path, delimiter ? delimiter + 1 : file);
+  \r\r\rif (stat(buf1, &info) || !S_ISREG(info.st_mode))
+    \r {
+    \rfree(*path);
+    \r*path = NULL;
+    \rerrno = ENOENT;
+    \rreturn -1;
+    \r}
+  \r\rreturn (int) strlen(*path);
+\r\r\r\rint \r translatepath(const char *totranslate, char **translated) \r
+{
+  \rchar buffer1[PATH_MAX + 1] = { 0 };
+  \rchar buffer2[PATH_MAX + 1] = { 0 };
+  \rchar *p1;
+  \rint i, len;
+  \r\rstruct stat stat_buf = { 0 };
+  \r\rlen = (int) strlen(totranslate);
+  \r\rstrncpy(buffer1, totranslate, len);
+  \r\rwhile ((p1 = strstr(buffer1, "//")))
+    \rif (p1[2])
+      \rstrcpy(p1, p1 + 1);
+  \r
+    else
+      \rp1[1] = '\0';
+  \r\rif (buffer1[strlen(buffer1) - 1] == '/'
+        || buffer1[strlen(buffer1) - 1] == '\\')
+    \rbuffer1[strlen(buffer1) - 1] = '\0';
+  \r\r
+      /* return the current directory */ \r
+      if (!strcmp(totranslate, ".") || !strcmp(totranslate, "./"))
+    \r {
+    \r*translated = getcwd(NULL, 0);
+    \rreturn (int) strlen(*translated);
+    \r}
+  \r
+      /* return the previous directory */ \r
+      else if (!strcmp(totranslate, "..") || !strcmp(totranslate, "../"))
+    \r {
+    \rgetcwd(buffer1, PATH_MAX + 1);
+    \rp1 = strrchr(buffer1, '\\');
+    \r*translated = (char *) calloc((p1 - buffer1) + 1, sizeof(char));
+    \rstrncpy(*translated, buffer1, (p1 - buffer1));
+    \r\rreturn (int) strlen(*translated);
+    \r}
+  \r
+      /* return the root directory */ \r
+      else if (!strcmp(totranslate, "/"))
+    \r {
+    \r*translated = getcwd(NULL, 0);
+    \r(*translated)[2] = '\0';
+    \r\rreturn (int) strlen(*translated);
+    \r}
+  \r
+      /* it's a relative directory name build the full directory name (directory) */ \r
+      else if (buffer1[0] != '.' && buffer1[0] != '/' && buffer1[1] != ':'
+               && !stat(totranslate, &stat_buf)
+               && S_ISDIR(stat_buf.st_mode))
+    \r {
+    \rfor (i = 0; buffer1[i] != '\0'; i++)
+      \r {
+      \rif (buffer1[i] == '/')
+        \rbuffer2[i] = '\\';
+      \r
+      else
+        \rbuffer2[i] = buffer1[i];
+      \r}
+    \r\rmemset(buffer1, 0, PATH_MAX + 1);
+    \rgetcwd(buffer1, PATH_MAX + 1);
+    \rstrcat(buffer1, "\\");
+    \rstrcat(buffer1, buffer2);
+    \r\r*translated = (char *) calloc(strlen(buffer1) + 1, sizeof(char));
+    \rstrcpy(*translated, buffer1);
+    \r\rreturn (int) strlen(*translated);
+    \r}
+  \r
+  else if (buffer1[0] == '~')
+    \r {
+    \r
+        /* TODO */ \r
+        *translated = NULL;
+    \rerrno = ENOSYS;
+    \rreturn -1;
+    \r}
+  \r
+  else if (*buffer1 == '.')
+    \r {
+    \r_fullpath(buffer2, buffer1, sizeof(buffer1));
+    \r}
+  \r
+  else
+    \rstrcpy(buffer2, buffer1);
+  \r\rif (stat(buffer2, &stat_buf) || !S_ISDIR(stat_buf.st_mode))
+    \r {
+    \r*translated = NULL;
+    \rerrno = ENOTDIR;
+    \rreturn -1;
+    \r}
+  \r\r\r\rlen = (int) strlen(buffer2);
+  \r\r\r\r*translated = (char *) calloc(len + 1, sizeof(char));
+  \rstrcpy(*translated, buffer2);
+  \r\rif (!(*translated))
+    \r {
+    \r*translated = NULL;
+    \rreturn -1;
+    \r}
+  \r\rreturn len;
+\r}
+
+\r
+#endif  /* \r */
+    \r\r
index 528bc50..fca4fb6 100644 (file)
@@ -2,72 +2,60 @@
 
 #include <explode.h>
 
-int
-is_cmd(char** path, char** builtin, const char* p)
+int is_cmd(char **path, char **builtin, const char *p)
 {
-       size_t i = 0;
-       size_t j = 0;
-       int yes = 0;
+  size_t i = 0;
+  size_t j = 0;
+  int yes = 0;
 
-       struct stat stat_buff = {0};
-       char command[PATH_MAX + 1] = {0};
-       char buff[PATH_MAX + 1] = {0};
-       size_t len;
+  struct stat stat_buff = { 0 };
+  char command[PATH_MAX + 1] = { 0 };
+  char buff[PATH_MAX + 1] = { 0 };
+  size_t len;
 
-       if(!p)
-               return EINVAL;
-       
-       len = strlen(p);
-       while(i < len)
-       {
-               if(p[i] != ' ' && p[i] != '\t' && p[i] != '>')
-                       command[j++] = p[i];
-               else
-                       break;
-                       
-               i++;
-       }
-       
-       
-       /* check first if it's a shell buitin */
-       
-       if(builtin)
-       {
-               for(i = 0; builtin[i] != NULL; i++)
-               {
-                       if(!strcmp(builtin[i], command))
-                               return 0;
-               }
-       }
-       
-       if(stat(command, &stat_buff) || !S_ISREG(stat_buff.st_mode))
-       {
-               if(path)
-               {
-                       for (i = 0; path[i] != NULL; i++)
-                       {
-                               
-                               sprintf(buff,"%s/%s",path[i], command);
-                               
-                               if(!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode))
-                               {
-                                       
-                                       if(!access(buff, X_OK))
-                                       {
-                                               yes = 1;
-                                               break;
-                                       }
-                               }
-                       }
-               }
-       }
-       else
-       {
-               
-               if(!access(command, X_OK))
-                       yes = 1;
-       }
-               
-       return yes ? 0 : ECMDNOTFOUND;  
-}
+  if (!p)
+    return EINVAL;
+
+  len = strlen(p);
+  while (i < len) {
+    if (p[i] != ' ' && p[i] != '\t' && p[i] != '>')
+      command[j++] = p[i];
+    else
+      break;
+
+    i++;
+  }
+
+
+  /* check first if it's a shell buitin */
+
+  if (builtin) {
+    for (i = 0; builtin[i] != NULL; i++) {
+      if (!strcmp(builtin[i], command))
+        return 0;
+    }
+  }
 
+  if (stat(command, &stat_buff) || !S_ISREG(stat_buff.st_mode)) {
+    if (path) {
+      for (i = 0; path[i] != NULL; i++) {
+
+        sprintf(buff, "%s/%s", path[i], command);
+
+        if (!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode)) {
+
+          if (!access(buff, X_OK)) {
+            yes = 1;
+            break;
+          }
+        }
+      }
+    }
+  } else {
+
+    if (!access(command, X_OK))
+      yes = 1;
+  }
+
+  return yes ? 0 : ECMDNOTFOUND;
+}
index c169f1e..9bcd3ed 100644 (file)
 /*
  * entry used to define the parameter of a tesh option.
  */
-typedef struct s_optentry
-{
-       int c;                                                          /* the character of the option                                                                                  */
-       
-       /* 
-        * the type of the argument of the option 
-        */
-       enum                                            
-       {
-               flag,                                                   /* it's a flag option, by default the flag is set to zero                               */                                              
-               string,                                                 /* the option has strings as argument                                                                   */                                      
-               number                                                  /* the option has an integral positive number as argument                               */                      
-       }type;
-       
-       byte* value;                                            /* the value of the option                                                                                              */                      
-       byte* optional_value;                           /* the optional value of the option if not specified                                    */
-       const char * long_name;                         /* the long name of the command                                                                                 */
-}s_optentry_t,* optentry_t;
+typedef struct s_optentry {
+  int c;                        /* the character of the option                                                                                  */
+
+  /* 
+   * the type of the argument of the option 
+   */
+  enum {
+    flag,                       /* it's a flag option, by default the flag is set to zero                               */
+    string,                     /* the option has strings as argument                                                                   */
+    number                      /* the option has an integral positive number as argument                               */
+  } type;
+
+  byte *value;                  /* the value of the option                                                                                              */
+  byte *optional_value;         /* the optional value of the option if not specified                                    */
+  const char *long_name;        /* the long name of the command                                                                                 */
+} s_optentry_t, *optentry_t;
 
 
 /* logs */
-XBT_LOG_NEW_DEFAULT_CATEGORY(tesh,"TEst SHell utility");
+XBT_LOG_NEW_DEFAULT_CATEGORY(tesh, "TEst SHell utility");
 
 #ifdef _XBT_WIN32
 /* Windows specific : the previous process error mode                  */
-static UINT 
-prev_error_mode = 0;
+static UINT prev_error_mode = 0;
 #endif
 
 /* this object represents the root directory */
-directory_t
-root_directory = NULL;
+directory_t root_directory = NULL;
 
 /* the current version of tesh                                                                 */
-static const char* 
-version = "1.0";
+static const char *version = "1.0";
 
 /* ------------------------------------------------------------ */
 /* options                                                                                                             */
@@ -69,43 +64,38 @@ version = "1.0";
 
 
 /* --jobs is specified with arg                                                                        */
-static int 
-jobs_nb = -2;
+static int
+ jobs_nb = -2;
 
 /* --jobs option is not specified (use the default job count)  */
-static int 
-default_jobs_nb = 1;
+static int
+ default_jobs_nb = 1;
 
 /* --jobs is specified but has no arg (one job per unit)               */
-static int 
-optional_jobs_nb = -1;
+static int
+ optional_jobs_nb = -1;
 
 /* the global timeout                                                                                  */
 static int
-timeout = INDEFINITE;
+ timeout = INDEFINITE;
 
 /* ------------------------------------------------------------ */
 /* strings                                                                                     */
 /* ------------------------------------------------------------ */
 
 /* --C change the directory before running the units                   */
-static directories_t 
-directories = NULL;
+static directories_t directories = NULL;
 
 /* the include directories : see the !i metacommand                            */
-xbt_dynar_t
-include_dirs = NULL;
+xbt_dynar_t include_dirs = NULL;
 
 /* the list of tesh files to run                                                               */
-static fstreams_t 
-fstreams = NULL;
+static fstreams_t fstreams = NULL;
 
 /* the list of tesh file suffixes                                                              */
-static xbt_dynar_t
-suffixes = NULL;
+static xbt_dynar_t suffixes = NULL;
 
-static excludes_t
-excludes = NULL;
+static excludes_t excludes = NULL;
 
 
 /* ------------------------------------------------------------ */
@@ -115,323 +105,295 @@ excludes = NULL;
 /* if 1, keep going when some commands can't be found
  * default value 0 : not keep going
  */
-int 
-keep_going_flag = 0;
+int
+ keep_going_flag = 0;
 
 /* if 1, ignore failures from commands
  * default value : do not ignore failures
  */
-int 
-keep_going_unit_flag = 0;
+int
+ keep_going_unit_flag = 0;
 
 /* if 1, display tesh usage                                                                            */
-static int 
-print_usage_flag = 0;
+static int
+ print_usage_flag = 0;
 
 /* if 1, display the tesh version                                                              */
-static int 
-print_version_flag = 0;
+static int
+ print_version_flag = 0;
 
 /* if 1, the status of all the units is display at
  * the end.
  */
 static int
-summary_flag = 0;
+ summary_flag = 0;
 
 /* if 1 and the flag want_summay is set to 1 tesh display the detailed summary of the run */
-int 
-detail_summary_flag = 0;
+int
+ detail_summary_flag = 0;
 
 /* if 1, the directories are displayed                                                 */
-int 
-print_directory_flag = 0;
+int
+ print_directory_flag = 0;
 
 /* if 1, just check the syntax of all the tesh files
  * do not run them.
  */
 int
-dry_run_flag = 0;
+ dry_run_flag = 0;
 
 /* if 1, display the tesh files syntax and exit                                        */
 static int
-print_readme_flag = 0;
+ print_readme_flag = 0;
 
-int 
-silent_flag = 0;
+int
+ silent_flag = 0;
 
-int 
-just_print_flag = 0;
+int
+ just_print_flag = 0;
 
 /* the semaphore used to synchronize the jobs */
-xbt_os_sem_t
-jobs_sem = NULL;
+xbt_os_sem_t jobs_sem = NULL;
 
 /* the semaphore used by the runner to wait the end of all the units */
-xbt_os_sem_t
-units_sem = NULL;
+xbt_os_sem_t units_sem = NULL;
 
 static int
-loaded = 0;
-
-int 
-interrupted = 0;
+ loaded = 0;
 
 int
-exit_code = 0; 
+ interrupted = 0;
 
 int
-err_kind = 0;
+ exit_code = 0;
 
-char* 
-err_line = NULL;
+int
+ err_kind = 0;
 
+char *err_line = NULL;
 
-pid_t
-pid =0;
 
-int 
-is_tesh_root = 1;
+pid_t pid = 0;
 
-/* the table of the entries of the options */ 
-static const struct s_optentry opt_entries[] =
-{
-       { 'C', string, (byte*)NULL, 0, "directory" },
-       { 'x', string, (byte*)&suffixes, 0, "suffix" },
-       { 'f', string, (byte*)&fstreams, 0, "file" },
-       { 'h', flag, (byte*)&print_usage_flag, 0, "help" },
-       { 'a', flag, (byte*)&print_readme_flag, 0, "README" },
-       { 'k', flag, (byte*)&keep_going_flag, 0, "keep-going" },
-       { 'i', flag, (byte*)&keep_going_unit_flag, 0, "keep-going-unit"},
-       { 'I', string, (byte*)&include_dirs, 0, "include-dir" },
-       { 'j', number, (byte*)&jobs_nb, (byte*) &optional_jobs_nb, "jobs" },
-       { 'm', flag, (byte*)&detail_summary_flag, 0, "detail-summary" },
-       { 'c', flag, (byte*)&just_print_flag, 0, "just-print" },
-       { 's', flag, (byte*)&silent_flag, 0, "silent" },
-       { 'V', flag, (byte*)&print_version_flag, 0, "version" },
-       { 'w', flag, (byte*)&print_directory_flag, 0,"dont-print-directory" },
-       { 'n', flag, (byte*)&dry_run_flag, 0, "dry-run"},
-       { 't', number, (byte*)&timeout, 0, "timeout" },
-       { 'r', string, (byte*)&directories, 0, "load-directory"},
-       { 'v', flag, (byte*)&summary_flag, 0, "summary"},
-       { 'F', string,(byte*)&excludes, 0, "exclude"},
-       { 'l', string, (byte*)NULL, 0, "log" },
-       { 0, 0, 0, 0, 0}
+int
+ is_tesh_root = 1;
+
+/* the table of the entries of the options */
+static const struct s_optentry opt_entries[] = {
+  {'C', string, (byte *) NULL, 0, "directory"},
+  {'x', string, (byte *) & suffixes, 0, "suffix"},
+  {'f', string, (byte *) & fstreams, 0, "file"},
+  {'h', flag, (byte *) & print_usage_flag, 0, "help"},
+  {'a', flag, (byte *) & print_readme_flag, 0, "README"},
+  {'k', flag, (byte *) & keep_going_flag, 0, "keep-going"},
+  {'i', flag, (byte *) & keep_going_unit_flag, 0, "keep-going-unit"},
+  {'I', string, (byte *) & include_dirs, 0, "include-dir"},
+  {'j', number, (byte *) & jobs_nb, (byte *) & optional_jobs_nb, "jobs"},
+  {'m', flag, (byte *) & detail_summary_flag, 0, "detail-summary"},
+  {'c', flag, (byte *) & just_print_flag, 0, "just-print"},
+  {'s', flag, (byte *) & silent_flag, 0, "silent"},
+  {'V', flag, (byte *) & print_version_flag, 0, "version"},
+  {'w', flag, (byte *) & print_directory_flag, 0, "dont-print-directory"},
+  {'n', flag, (byte *) & dry_run_flag, 0, "dry-run"},
+  {'t', number, (byte *) & timeout, 0, "timeout"},
+  {'r', string, (byte *) & directories, 0, "load-directory"},
+  {'v', flag, (byte *) & summary_flag, 0, "summary"},
+  {'F', string, (byte *) & excludes, 0, "exclude"},
+  {'l', string, (byte *) NULL, 0, "log"},
+  {0, 0, 0, 0, 0}
 };
 
 /* the tesh usage                                                                                              */
-static const char* usage[] =
-{
-       "Options:\n",
-       "  -C DIRECTORY, --directory=DIRECTORY   Change to DIRECTORY before running any commands.\n",
-       "  -e, --environment-overrides           Environment variables override files.\n",
-       "  -f FILE, --file=FILE                  Read FILE as a teshfile.\n",
-       "                                           remark :\n",
-       "                                           all argument of the command line without\n",
-       "                                           option is dealed as a tesh file.\n",
-       "  -h, --help                            Print this message and exit.\n",
-       "  -i, --keep-going-unit                 Ignore failures from commands.\n",
-       "                                        The possible failures are :\n",
-       "                                         - the exit code differ from the expected\n",
-       "                                         - the signal throw differ from the expected\n",
-       "                                         - the output differ from the expected\n",
-       "                                         - the read pipe is broken\n",
-       "                                         - the write pipe is broken\n",
-       "                                         - the command assigned delay is outdated\n",
-       "  -I DIRECTORY, --include-dir=DIRECTORY Search DIRECTORY for included files.\n",
-       "  -j [N], --jobs[=N]                    Allow N units at once; infinite units with\n"
-       "                                        no arg.\n",
-       "  -k, --keep-going                      Keep going when some commands can't be made or\n",
-       "                                        failed.\n",
-       "  -c, --just-print                      Don't actually run any commands; just print them.\n",
-       "  -s, --silent,                         Don't echo commands.\n",
-       "  -V, --version                         Print the version number of tesh and exit.\n",
-       "  -d, --dont-print-directory            Don't display the current directory.\n",
-       "  -n, --dry-run                         Check the syntax of the specified tesh files, display the result and exit.\n",
-       "  -t, --timeout                         Wait the end of the commands at most timeout seconds.\n",
-       "  -x, --suffix                          Consider the new suffix for the tesh files.\n"
-       "                                           remark :\n",
-       "                                           the default suffix for the tesh files is \".tesh\".\n",
-       " -a, --README                           Print the read me file and exit.\n",
-       " -r, --load-directory                   Run all the tesh files located in the directories specified by the option --directory.\n",
-       " -v, --summary                          Display the status of the commands.\n",
-       " -m, --detail-summary                   Detail the summary of the run.\n",
-       " -F file , --exclude=FILE               Ignore the tesh file FILE.\n",
-       " -l format, --log                       Format of the xbt logs.\n",
-       NULL
+static const char *usage[] = {
+  "Options:\n",
+  "  -C DIRECTORY, --directory=DIRECTORY   Change to DIRECTORY before running any commands.\n",
+  "  -e, --environment-overrides           Environment variables override files.\n",
+  "  -f FILE, --file=FILE                  Read FILE as a teshfile.\n",
+  "                                           remark :\n",
+  "                                           all argument of the command line without\n",
+  "                                           option is dealed as a tesh file.\n",
+  "  -h, --help                            Print this message and exit.\n",
+  "  -i, --keep-going-unit                 Ignore failures from commands.\n",
+  "                                        The possible failures are :\n",
+  "                                         - the exit code differ from the expected\n",
+  "                                         - the signal throw differ from the expected\n",
+  "                                         - the output differ from the expected\n",
+  "                                         - the read pipe is broken\n",
+  "                                         - the write pipe is broken\n",
+  "                                         - the command assigned delay is outdated\n",
+  "  -I DIRECTORY, --include-dir=DIRECTORY Search DIRECTORY for included files.\n",
+  "  -j [N], --jobs[=N]                    Allow N units at once; infinite units with\n"
+      "                                        no arg.\n",
+  "  -k, --keep-going                      Keep going when some commands can't be made or\n",
+  "                                        failed.\n",
+  "  -c, --just-print                      Don't actually run any commands; just print them.\n",
+  "  -s, --silent,                         Don't echo commands.\n",
+  "  -V, --version                         Print the version number of tesh and exit.\n",
+  "  -d, --dont-print-directory            Don't display the current directory.\n",
+  "  -n, --dry-run                         Check the syntax of the specified tesh files, display the result and exit.\n",
+  "  -t, --timeout                         Wait the end of the commands at most timeout seconds.\n",
+  "  -x, --suffix                          Consider the new suffix for the tesh files.\n"
+      "                                           remark :\n",
+  "                                           the default suffix for the tesh files is \".tesh\".\n",
+  " -a, --README                           Print the read me file and exit.\n",
+  " -r, --load-directory                   Run all the tesh files located in the directories specified by the option --directory.\n",
+  " -v, --summary                          Display the status of the commands.\n",
+  " -m, --detail-summary                   Detail the summary of the run.\n",
+  " -F file , --exclude=FILE               Ignore the tesh file FILE.\n",
+  " -l format, --log                       Format of the xbt logs.\n",
+  NULL
 };
 
-/* the string of options of tesh                                                               */                                                              
-static char 
-optstring[1 + sizeof (opt_entries) / sizeof (opt_entries[0]) * 3];
+/* the string of options of tesh                                                               */
+static char
+ optstring[1 + sizeof(opt_entries) / sizeof(opt_entries[0]) * 3];
 
 /* the option table of tesh                                                                            */
-static struct 
-option longopts[(sizeof (opt_entries) / sizeof (s_optentry_t))];
+static struct
+option longopts[(sizeof(opt_entries) / sizeof(s_optentry_t))];
 
-static void
-init_options(void);
+static void init_options(void);
 
-static int
-process_command_line(int argc, char** argv);
+static int process_command_line(int argc, char **argv);
 
-static void
-load(void);
+static void load(void);
 
-static void
-print_usage(void);
+static void print_usage(void);
 
-static void
-print_version(void);
+static void print_version(void);
 
-static void
-finalize(void);
+static void finalize(void);
 
-static void
-print_readme(void);
+static void print_readme(void);
 
-static int
-init(void);
+static int init(void);
 
-static int
-screen_cleaned;
+static int screen_cleaned;
 
-static int
-finalized = 0;
+static int finalized = 0;
 
-static int 
-sig_int = 0;
+static int sig_int = 0;
 
 #ifdef _XBT_WIN32
-static void 
-sig_int_handler(int signum)
+static void sig_int_handler(int signum)
 {
 
-       if(!finalized)
-       {
-               sig_int = 1;
-               runner_interrupt();
-               while(!finalized);
-       }
-       
+  if (!finalized) {
+    sig_int = 1;
+    runner_interrupt();
+    while (!finalized);
+  }
+
 }
 #endif
 
-static void 
-free_string(void* str)
+static void free_string(void *str)
 {
-       free(*(void**)str);
+  free(*(void **) str);
 }
 
-int
-main(int argc, char* argv[])
+int main(int argc, char *argv[])
 {
-       /* set the locale to the default*/
-       setlocale(LC_ALL,"");
-
-       /* xbt initialization */
-       xbt_init(&argc, argv);
-       
-       /* initialize tesh */
-       if(init() < 0)
-               finalize();
-               
-       /* process the command line */
-       if(process_command_line(argc, argv) < 0)
-               finalize();
-       
-       /* move to the root directory (the directory may change during the command line processing) */
-       chdir(root_directory->name);
-               
-       /* the user wants to display the usage of tesh */
-       if(print_version_flag)
-       {
-               print_version();
-
-               if(!print_usage_flag)
-                       finalize();
-       }
-       
-       /* the user wants to display the usage of tesh */
-       if(print_usage_flag)
-       {
-               print_usage();
-               finalize();
-       }
-       
-       /* the user wants to display the semantic of the tesh file metacommands */
-       if(print_readme_flag)
-       {
-               print_readme();
-               finalize();
-       }
-       
-       /* load tesh files */
-       load();
-       
-       
-       /* use by the finalize function to known if it must display the tesh usage */   
-       loaded = 1;
-
-       if(-2 == jobs_nb)
-       {/* --jobs is not specified (use the default value) */
-               jobs_nb = default_jobs_nb;
-       }
-       else if(optional_jobs_nb == jobs_nb)
-       {/* --jobs option is specified with no args (use one job per unit) */
-               jobs_nb = fstreams_get_size(fstreams);
-       }
-
-       if(jobs_nb > fstreams_get_size(fstreams))
-       {/* --jobs = N is specified and N is more than the number of tesh files */
-               
-               WARN0("Number of requested jobs exceed the number of files to run");
-               
-               /* assume one job per file */
-               jobs_nb = fstreams_get_size(fstreams);
-       }
-
-       if(jobs_nb != 1 && dry_run_flag)
-       {
-               jobs_nb = 1;
-               INFO0("Dry run specified : force jobs count to 1");
-       }
-
-       /* initialize the semaphore used to synchronize all the units */
-       jobs_sem = xbt_os_sem_init(jobs_nb);
-
-       /* initialize the semaphore used by the runner to wait for the end of all units */
-       units_sem = xbt_os_sem_init(0);
-       
-       /* initialize the runner */
-       if(runner_init(/*check_syntax_flag,*/ timeout, fstreams) < 0)
-               finalize();
-               
-       if(just_print_flag && silent_flag)
-               silent_flag = 0;
-               
-       if(just_print_flag && dry_run_flag)
-               WARN0("mismatch in the syntax : --just-check-syntax and --just-display options at same time");
-       
-       /* run all the units */
-       runner_run();
-       
-       if(runner_is_timedout())
-               ERROR1("Tesh timed out after `(%d)' seconds", timeout);
-
-       /* show the result of the units */
-       if(detail_summary_flag ||summary_flag || dry_run_flag)
-               runner_summarize();
-               
-       /* all the test are runned, destroy the runner */
-       runner_destroy();
-       
-       /* then, finalize tesh (release all the allocated memory and exits) */
-       finalize();
-       
-       #ifndef _XBT_WIN32
-       return exit_code;
-       #endif
-       
+  /* set the locale to the default */
+  setlocale(LC_ALL, "");
+
+  /* xbt initialization */
+  xbt_init(&argc, argv);
+
+  /* initialize tesh */
+  if (init() < 0)
+    finalize();
+
+  /* process the command line */
+  if (process_command_line(argc, argv) < 0)
+    finalize();
+
+  /* move to the root directory (the directory may change during the command line processing) */
+  chdir(root_directory->name);
+
+  /* the user wants to display the usage of tesh */
+  if (print_version_flag) {
+    print_version();
+
+    if (!print_usage_flag)
+      finalize();
+  }
+
+  /* the user wants to display the usage of tesh */
+  if (print_usage_flag) {
+    print_usage();
+    finalize();
+  }
+
+  /* the user wants to display the semantic of the tesh file metacommands */
+  if (print_readme_flag) {
+    print_readme();
+    finalize();
+  }
+
+  /* load tesh files */
+  load();
+
+
+  /* use by the finalize function to known if it must display the tesh usage */
+  loaded = 1;
+
+  if (-2 == jobs_nb) {          /* --jobs is not specified (use the default value) */
+    jobs_nb = default_jobs_nb;
+  } else if (optional_jobs_nb == jobs_nb) {     /* --jobs option is specified with no args (use one job per unit) */
+    jobs_nb = fstreams_get_size(fstreams);
+  }
+
+  if (jobs_nb > fstreams_get_size(fstreams)) {  /* --jobs = N is specified and N is more than the number of tesh files */
+
+    WARN0("Number of requested jobs exceed the number of files to run");
+
+    /* assume one job per file */
+    jobs_nb = fstreams_get_size(fstreams);
+  }
+
+  if (jobs_nb != 1 && dry_run_flag) {
+    jobs_nb = 1;
+    INFO0("Dry run specified : force jobs count to 1");
+  }
+
+  /* initialize the semaphore used to synchronize all the units */
+  jobs_sem = xbt_os_sem_init(jobs_nb);
+
+  /* initialize the semaphore used by the runner to wait for the end of all units */
+  units_sem = xbt_os_sem_init(0);
+
+  /* initialize the runner */
+  if (runner_init( /*check_syntax_flag, */ timeout, fstreams) < 0)
+    finalize();
+
+  if (just_print_flag && silent_flag)
+    silent_flag = 0;
+
+  if (just_print_flag && dry_run_flag)
+    WARN0
+        ("mismatch in the syntax : --just-check-syntax and --just-display options at same time");
+
+  /* run all the units */
+  runner_run();
+
+  if (runner_is_timedout())
+    ERROR1("Tesh timed out after `(%d)' seconds", timeout);
+
+  /* show the result of the units */
+  if (detail_summary_flag || summary_flag || dry_run_flag)
+    runner_summarize();
+
+  /* all the test are runned, destroy the runner */
+  runner_destroy();
+
+  /* then, finalize tesh (release all the allocated memory and exits) */
+  finalize();
+
+#ifndef _XBT_WIN32
+  return exit_code;
+#endif
+
 }
 
 /* init --     initialize tesh : allocated all the objects needed by tesh to run
@@ -443,261 +405,252 @@ main(int argc, char* argv[])
 
 
 
-static int
-init(void)
+static int init(void)
 {
-       char* buffer;
-       char* suffix = strdup(".tesh");
-       
-       #ifdef _XBT_WIN32
-       /* Windows specific : don't display the general-protection-fault message box and
-        * the the critical-error-handler message box (instead the system send the error
-        * to the calling process : tesh)
-        */
-       prev_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
-       
-       /* handle the interrupt signal */
-       signal(SIGINT, sig_int_handler);
-       #else
-       /* Ignore pipe issues.
-        * They will show up when we try to send data to dead buddies, 
-     * but we will stop doing so when we're done with provided input 
-     */
-       /*
-       struct sigaction act;
-       memset(&act,0, sizeof(struct sigaction));
-       act.sa_handler = SIG_IGN;
-       sigaction(SIGPIPE, &act, NULL);
-       
-       memset(&act,0, sizeof(struct sigaction));
-       act.sa_handler = sig_int_handler;
-       sigaction(SIGINT, &act, NULL);*/
-       
-       #endif
-       
-       
-       
-       
-       /* used to store the files to run */
-       if(!(fstreams = fstreams_new((void_f_pvoid_t)fstream_free)))
-       {
-               ERROR1("(system error) %s", strerror(errno));
-               return -1;
-       }
-       
-       /* register the current directory */
-       if(!(buffer  = getcwd(NULL, 0)))
-       {
-               ERROR1("(system error) %s", strerror(errno));
-               return -1;
-       }
-       
-       /* save the root directory */
-       if(!(root_directory = directory_new(buffer)))
-       {
-               ERROR1("(system error) %s", strerror(errno));
-               return -1;
-       }
-       
-       free(buffer);
-       
-       /* the directories to loads */
-       if(!(directories = directories_new()))
-       {
-               ERROR1("(system error) %s", strerror(errno));
-               return -1;
-       }
-       
-       /* the include directories */
-       include_dirs = xbt_dynar_new(sizeof(directory_t), (void_f_pvoid_t)directory_free);
-       
-       /* the excluded files */
-       if(!(excludes = excludes_new()))
-       {
-               ERROR1("(system error) %s", strerror(errno));
-               return -1;
-       }
-       
-       /* the suffixes */
-       suffixes = xbt_dynar_new(sizeof(char*),free_string);
-       
-       /* register the default suffix ".tesh" */
-       xbt_dynar_push(suffixes, &suffix);
-       
-       return 0;
+  char *buffer;
+  char *suffix = strdup(".tesh");
+
+#ifdef _XBT_WIN32
+  /* Windows specific : don't display the general-protection-fault message box and
+   * the the critical-error-handler message box (instead the system send the error
+   * to the calling process : tesh)
+   */
+  prev_error_mode =
+      SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+
+  /* handle the interrupt signal */
+  signal(SIGINT, sig_int_handler);
+#else
+  /* Ignore pipe issues.
+   * They will show up when we try to send data to dead buddies, 
+   * but we will stop doing so when we're done with provided input 
+   */
+  /*
+     struct sigaction act;
+     memset(&act,0, sizeof(struct sigaction));
+     act.sa_handler = SIG_IGN;
+     sigaction(SIGPIPE, &act, NULL);
+
+     memset(&act,0, sizeof(struct sigaction));
+     act.sa_handler = sig_int_handler;
+     sigaction(SIGINT, &act, NULL); */
+
+#endif
+
+
+
+
+  /* used to store the files to run */
+  if (!(fstreams = fstreams_new((void_f_pvoid_t) fstream_free))) {
+    ERROR1("(system error) %s", strerror(errno));
+    return -1;
+  }
+
+  /* register the current directory */
+  if (!(buffer = getcwd(NULL, 0))) {
+    ERROR1("(system error) %s", strerror(errno));
+    return -1;
+  }
+
+  /* save the root directory */
+  if (!(root_directory = directory_new(buffer))) {
+    ERROR1("(system error) %s", strerror(errno));
+    return -1;
+  }
+
+  free(buffer);
+
+  /* the directories to loads */
+  if (!(directories = directories_new())) {
+    ERROR1("(system error) %s", strerror(errno));
+    return -1;
+  }
+
+  /* the include directories */
+  include_dirs =
+      xbt_dynar_new(sizeof(directory_t), (void_f_pvoid_t) directory_free);
+
+  /* the excluded files */
+  if (!(excludes = excludes_new())) {
+    ERROR1("(system error) %s", strerror(errno));
+    return -1;
+  }
+
+  /* the suffixes */
+  suffixes = xbt_dynar_new(sizeof(char *), free_string);
+
+  /* register the default suffix ".tesh" */
+  xbt_dynar_push(suffixes, &suffix);
+
+  return 0;
 }
 
 /* load -- load the tesh files to run */
-static void
-load(void)
+static void load(void)
 {
-       
-       /* if the directories object is not empty load all the tesh files contained in
-        * the directories specified in the command line (this tesh files must have the
-        * a suffix specified in the suffixes object.
-        */
-       if(!directories_is_empty(directories))
-               directories_load(directories, fstreams, suffixes);
-       
-       /* if no tesh file has been specified in the command line try to load the default tesh file
-        * teshfile from the current directory
-        */
-       if(fstreams_is_empty(fstreams))
-       {
-               struct stat buffer = {0};
-               
-               /* add the default tesh file if it exists in the current directory */
-               if(!stat("teshfile", &buffer) && S_ISREG(buffer.st_mode))
-                       fstreams_add(fstreams, fstream_new(getcwd(NULL, 0), "teshfile"));
-       }
-       
-       /* excludes the files specified in the command line and stored in the excludes object */
-       if(!excludes_is_empty(excludes) && !fstreams_is_empty(fstreams))
-       {
-               /* check the files to excludes before */        
-               excludes_check(excludes, fstreams);
-               
-               /* exclude the specified tesh files */
-               fstreams_exclude(fstreams, excludes);
-       }
-       
-       /* if the fstreams object is empty use the stdin */
-       if(fstreams_is_empty(fstreams))
-               fstreams_add(fstreams, fstream_new(NULL, "stdin"));
-       
-       /* load the tesh files (open them) */
-       fstreams_load(fstreams);
-       
+
+  /* if the directories object is not empty load all the tesh files contained in
+   * the directories specified in the command line (this tesh files must have the
+   * a suffix specified in the suffixes object.
+   */
+  if (!directories_is_empty(directories))
+    directories_load(directories, fstreams, suffixes);
+
+  /* if no tesh file has been specified in the command line try to load the default tesh file
+   * teshfile from the current directory
+   */
+  if (fstreams_is_empty(fstreams)) {
+    struct stat buffer = { 0 };
+
+    /* add the default tesh file if it exists in the current directory */
+    if (!stat("teshfile", &buffer) && S_ISREG(buffer.st_mode))
+      fstreams_add(fstreams, fstream_new(getcwd(NULL, 0), "teshfile"));
+  }
+
+  /* excludes the files specified in the command line and stored in the excludes object */
+  if (!excludes_is_empty(excludes) && !fstreams_is_empty(fstreams)) {
+    /* check the files to excludes before */
+    excludes_check(excludes, fstreams);
+
+    /* exclude the specified tesh files */
+    fstreams_exclude(fstreams, excludes);
+  }
+
+  /* if the fstreams object is empty use the stdin */
+  if (fstreams_is_empty(fstreams))
+    fstreams_add(fstreams, fstream_new(NULL, "stdin"));
+
+  /* load the tesh files (open them) */
+  fstreams_load(fstreams);
+
 }
 
 /* finalize -- cleanup all the allocated objects and display the tesh usage if needed */
-static void
-finalize(void)
+static void finalize(void)
 {
-       /* delete the fstreams object */
-       if(fstreams)
-               fstreams_free((void**)&fstreams);
-       
-       /* delete the excludes object */
-       if(excludes)    
-               excludes_free((void**)&excludes);
-       
-       /* delete the directories object */
-       if(directories)
-               directories_free((void**)&directories);
-               
-       /* delete the root directory object */
-       if(root_directory)
-               directory_free((void**)&root_directory);
-       
-       /* delete the include directories object */
-       if(include_dirs)
-               xbt_dynar_free(&include_dirs);
-       
-       /* delete the list of tesh files suffixes */    
-       if(suffixes)
-               xbt_dynar_free(&suffixes);
-               
-       /* destroy the semaphore used to synchronize the units */
-       if(jobs_sem)
-               xbt_os_sem_destroy(jobs_sem);
-       
-       /* destroy the semaphore used by the runner used to wait for the end of the units */
-       if(units_sem)
-               xbt_os_sem_destroy(units_sem);
-       
-       /* Windows specific (restore the previouse error mode */
-       #ifdef _XBT_WIN32
-       SetErrorMode(prev_error_mode);
-       #endif
-
-       if(sig_int)
-               INFO0("Tesh interrupted (receive a SIGINT)");
-       else if(!summary_flag && !detail_summary_flag && !dry_run_flag && !silent_flag && !just_print_flag && !print_version_flag && !print_usage_flag && is_tesh_root)
-       {
-               if(!exit_code)
-                       INFO2("Tesh terminated with exit code %d : %s",exit_code, "success");
-               else
-               {
-                       if(err_line)
-                               ERROR3("Tesh terminated with exit code `(<%s> %s)' (%d)",err_line, error_to_string(exit_code, err_kind), exit_code);
-                       else
-                               ERROR2("Tesh terminated with exit code `(%s)' (%d)", error_to_string(exit_code, err_kind), exit_code);
-                       
-               }
-       }
-
-       if(err_line)
-               free(err_line);
-       
-       /* exit from the xbt framework */
-
-       finalized = 1;
-       
-       /* exit with the last error code */
-       if(!sig_int)
-               exit(exit_code);
+  /* delete the fstreams object */
+  if (fstreams)
+    fstreams_free((void **) &fstreams);
+
+  /* delete the excludes object */
+  if (excludes)
+    excludes_free((void **) &excludes);
+
+  /* delete the directories object */
+  if (directories)
+    directories_free((void **) &directories);
+
+  /* delete the root directory object */
+  if (root_directory)
+    directory_free((void **) &root_directory);
+
+  /* delete the include directories object */
+  if (include_dirs)
+    xbt_dynar_free(&include_dirs);
+
+  /* delete the list of tesh files suffixes */
+  if (suffixes)
+    xbt_dynar_free(&suffixes);
+
+  /* destroy the semaphore used to synchronize the units */
+  if (jobs_sem)
+    xbt_os_sem_destroy(jobs_sem);
+
+  /* destroy the semaphore used by the runner used to wait for the end of the units */
+  if (units_sem)
+    xbt_os_sem_destroy(units_sem);
+
+  /* Windows specific (restore the previouse error mode */
+#ifdef _XBT_WIN32
+  SetErrorMode(prev_error_mode);
+#endif
+
+  if (sig_int)
+    INFO0("Tesh interrupted (receive a SIGINT)");
+  else if (!summary_flag && !detail_summary_flag && !dry_run_flag
+           && !silent_flag && !just_print_flag && !print_version_flag
+           && !print_usage_flag && is_tesh_root) {
+    if (!exit_code)
+      INFO2("Tesh terminated with exit code %d : %s", exit_code,
+            "success");
+    else {
+      if (err_line)
+        ERROR3("Tesh terminated with exit code `(<%s> %s)' (%d)", err_line,
+               error_to_string(exit_code, err_kind), exit_code);
+      else
+        ERROR2("Tesh terminated with exit code `(%s)' (%d)",
+               error_to_string(exit_code, err_kind), exit_code);
+
+    }
+  }
+
+  if (err_line)
+    free(err_line);
+
+  /* exit from the xbt framework */
+
+  finalized = 1;
+
+  /* exit with the last error code */
+  if (!sig_int)
+    exit(exit_code);
 }
 
 /* init_options -- initialize the options string */
-static void
-init_options (void)
+static void init_options(void)
 {
-       char *p;
-       unsigned int i;
-       
-       /* the function has been already called */
-       if(optstring[0] != '\0')
-               return;
-       
-       p = optstring;
-       
-       *p++ = '-';
-       
-       for (i = 0; opt_entries[i].c != '\0'; ++i)
-       {
-               /* initialize the long name of the option*/
-               longopts[i].name = (opt_entries[i].long_name == 0 ? "" : opt_entries[i].long_name);
-               
-               /* getopt_long returns the value of val */
-               longopts[i].flag = 0;
-               
-               /* the short option */
-               longopts[i].val = opt_entries[i].c;
-               
-               /* add the short option in the options string */
-               *p++ = opt_entries[i].c;
-               
-               switch (opt_entries[i].type)
-               {
-                       /* if this option is used to set a flag or if the argument must be ignored
-                        * the option has no argument
-                        */
-                       case flag:
-                       longopts[i].has_arg = no_argument;
-                       break;
-               
-                       /* the option has an argument */
-                       case string:
-                       case number:
-                       
-                       *p++ = ':';
-                       
-                       if(opt_entries[i].optional_value != 0)
-                       {
-                               *p++ = ':';
-                               
-                               longopts[i].has_arg = optional_argument;
-                       }
-                       else
-                               longopts[i].has_arg = required_argument;
-                       
-                       break;
-               }
-       }
-       
-       *p = '\0';
-       longopts[i].name = 0;
+  char *p;
+  unsigned int i;
+
+  /* the function has been already called */
+  if (optstring[0] != '\0')
+    return;
+
+  p = optstring;
+
+  *p++ = '-';
+
+  for (i = 0; opt_entries[i].c != '\0'; ++i) {
+    /* initialize the long name of the option */
+    longopts[i].name =
+        (opt_entries[i].long_name == 0 ? "" : opt_entries[i].long_name);
+
+    /* getopt_long returns the value of val */
+    longopts[i].flag = 0;
+
+    /* the short option */
+    longopts[i].val = opt_entries[i].c;
+
+    /* add the short option in the options string */
+    *p++ = opt_entries[i].c;
+
+    switch (opt_entries[i].type) {
+      /* if this option is used to set a flag or if the argument must be ignored
+       * the option has no argument
+       */
+    case flag:
+      longopts[i].has_arg = no_argument;
+      break;
+
+      /* the option has an argument */
+    case string:
+    case number:
+
+      *p++ = ':';
+
+      if (opt_entries[i].optional_value != 0) {
+        *p++ = ':';
+
+        longopts[i].has_arg = optional_argument;
+      } else
+        longopts[i].has_arg = required_argument;
+
+      break;
+    }
+  }
+
+  *p = '\0';
+  longopts[i].name = 0;
 }
 
 /* process_command_line --     process the command line
@@ -710,507 +663,457 @@ init_options (void)
  *                                                     and sets the global variable errno to indicate the error.
  *
  * errors      [ENOENT]                A file name specified in the command line does not exist
- */    
+ */
 
-static int
-process_command_line(int argc, char** argv)
+static int process_command_line(int argc, char **argv)
 {
-       register const struct s_optentry* entry;
-       register int c;
-       directory_t directory;
-       fstream_t fstream;
-       
-       /* initialize the options string of tesh */
-       init_options();
-       
-       /* let the function getopt_long display the errors if any */
-       opterr = 1;
-       
-       /* set option index to zero */
-       optind = 0;
-       
-       while (optind < argc)
-       {
-               c = getopt_long(argc, argv, optstring, longopts, (int *) 0);
-               
-               if(c == EOF)
-               {
-                       /* end of the command line or "--".  */
-                       break;
-               }
-               else if (c == 1)
-               {
-                       /* no option specified, assume it's a tesh file to run */
-                       char* path;
-                       char* delimiter;
-                       
-                       /* getpath returns -1 when the file to get the path doesn't exist */
-                       if(getpath(optarg, &path) < 0)
-                       {
-                               exit_code = errno;
-                               err_kind = 0;
-                               
-                               if(ENOENT == errno)
-                                       ERROR1("File %s does not exist", optarg);
-                               else
-                                       ERROR0("Insufficient memory is available to parse the command line : system error");
-                                       
-                               return -1;
-                       }
-                       
-                       /* get to the last / (if any) to get the short name of the file */
-                       delimiter = strrchr(optarg,'/');
-                       
-                       #ifdef _XBT_WIN32
-                       if(!delimiter)
-                               delimiter = strrchr(optarg,'\\');
-                       #endif
-                       
-                       /* create a new file stream which represents the tesh file to run */
-                       fstream = fstream_new(path, delimiter ? delimiter + 1 : optarg);
-                       
-                       free(path);
-                       
-                       /* if the list of all tesh files to run already contains this file
-                        * destroy it and display a warning, otherwise add it in the list.
-                        */
-                       if(fstreams_contains(fstreams, fstream))
-                       {
-                               fstream_free(&fstream);
-                               WARN1("File %s already specified to be run", optarg);
-                       }
-                       else
-                               fstreams_add(fstreams, fstream);
-                       
-               }
-               else if (c == '?')
-               {
-                       /* unknown option, let getopt_long() displays the error */
-                       ERROR0("Command line processing failed : invalid command line");
-                       exit_code = EINVCMDLINE;
-                       err_kind = 1;
-                       return -1;
-               }
-               else
-               {
-                       for(entry = opt_entries; entry->c != '\0'; ++entry)
-                               
-                               if(c == entry->c)
-                               {
-               
-                                       switch (entry->type)
-                                       {
-                                               /* impossible */
-                                               default:
-                                               ERROR0("Command line processing failed : internal error");
-                                               exit_code = EPROCCMDLINE;
-                                               err_kind = 1;
-                                               return -1;
-                                               
-                                               
-                                               /* flag options */
-                                               case flag:
-                                               /* set the flag to one */
-                                               *(int*) entry->value = 1;
-                                               
-                                               break;
-                                               
-                                               /* string options */
-                                               case string:
-               
-                                               if(!optarg)
-                                               {
-                                                       /* an option with a optional arg is specified use the entry->optional_value */
-                                                       optarg = (char*)entry->optional_value;
-                                               }
-                                               else if (*optarg == '\0')
-                                               {
-                                                       /* a non optional argument is not specified */
-                                                       ERROR2("Option %c \"%s\"requires an argument",entry->c,entry->long_name);
-                                                       exit_code = ENOARG;
-                                                       err_kind = 1;
-                                                       return -1;
-                                               }
-                                               
-                                               /* --load-directory option */
-                                               if(!strcmp(entry->long_name,"load-directory"))
-                                               {
-                                                       char* path;
-                                                       
-                                                       if(translatepath(optarg, &path) < 0)
-                                                       {
-                                                               exit_code = errno;
-                                                               err_kind = 0;
-                                                               
-                                                               if(ENOTDIR == errno)
-                                                                       ERROR1("%s is not a directory",optarg);
-                                                               else
-                                                                       ERROR0("Insufficient memory is available to process the command line - system error");
-                                                                       
-                                                               return -1;
-                                                               
-                                                       }
-                                                       else
-                                                       {
-                                                               
-                                                               directory = directory_new(path);
-                                                               free(path);
-                                               
-                                                               if(directories_contains(directories, directory))
-                                                               {
-                                                                       directory_free((void**)&directory);
-                                                                       WARN1("Directory %s already specified to be load",optarg);
-                                                               }
-                                                               else
-                                                                        directories_add(directories, directory);
-                                                                        
-                                                               
-                                                       }                       
-                                               }
-                                               else if(!strcmp(entry->long_name,"directory"))
-                                               {
-                                                       char* path ;
-                                                       
-                                                       if(translatepath(optarg, &path) < 0)
-                                                       {
-                                                               exit_code = errno;
-                                                               err_kind = 0;
-                                                               
-                                                               if(ENOTDIR == errno)
-                                                                       ERROR1("%s is not a directory",optarg);
-                                                               else
-                                                                       ERROR0("Insufficient memory is available to process the command line - system error");
-                                                                       
-                                                               return -1;
-                                                       }
-                                                       else
-                                                       {
-                                                               char* buffer = getcwd(NULL, 0);
-
-                                                               
-                                                               if(!strcmp(buffer, path))
-                                                                       WARN1("Already in the directory %s", optarg);
-                                                               else if(!print_directory_flag)
-                                                                       INFO1("Entering directory \"%s\"",path);
-
-                                                               chdir(path);
-                                                               free(path);
-                                               
-                                                               free(buffer);
-                                                       }       
-                                               }
-                                               
-                                               /* --suffix option */
-                                               else if(!strcmp(entry->long_name,"suffix"))
-                                               {
-                                                       if(strlen(optarg) > MAX_SUFFIX)
-                                                       {
-                                                               ERROR1("Suffix %s too long",optarg);
-                                                               exit_code = ESUFFIXTOOLONG;
-                                                               err_kind = 1;
-                                                               return -1;
-                                                       }
-                                                       
-                                                       if(optarg[0] == '.')
-                                                       {
-                                                               char* cur;
-                                                               unsigned int i;
-                                                               int exists = 0;
-
-                                                               char* suffix = xbt_new0(char, MAX_SUFFIX + 2);
-                                                               sprintf(suffix,".%s",optarg);
-                                                               
-                                                               xbt_dynar_foreach(suffixes, i, cur)
-                                                               {
-                                                                       if(!strcmp(suffix, cur))
-                                                                       {
-                                                                               exists = 1;
-                                                                               break;
-                                                                       }
-                                                               }
-
-                                                               if(exists)
-                                                                       WARN1("Suffix %s already specified to be used", optarg);
-                                                               else
-                                                                       xbt_dynar_push(suffixes, &suffix);
-                                                       }
-                                                       else
-                                                       {
-                                                               char* cur;
-                                                               unsigned int i;
-                                                               int exists = 0;
-
-                                                               xbt_dynar_foreach(suffixes, i, cur)
-                                                               {
-                                                                       if(!strcmp(optarg, cur))
-                                                                       {
-                                                                               exists = 1;
-                                                                               break;
-                                                                       }
-                                                               }
-
-                                                               if(exists)
-                                                                       WARN1("Suffix %s already specified to be used", optarg);
-                                                               else
-                                                               {
-                                                                       char* suffix = strdup(optarg);
-                                                                       xbt_dynar_push(suffixes, &suffix);
-                                                               }
-                                                       }
-                                               }
-                                               /* --file option */
-                                               else if(!strcmp(entry->long_name,"file"))
-                                               {
-                                                       char* path;
-                                                       char* delimiter;
-                                                       
-                                                       if(getpath(optarg, &path) < 0)
-                                                       {
-                                                               exit_code = errno;
-                                                               err_kind = 0;
-                                                               
-                                                               if(ENOENT == errno)
-                                                                       ERROR1("File %s does not exist", optarg);
-                                                               else
-                                                                       ERROR1("System error :`(%s)'", strerror(errno));
-                                                               
-                                                               return -1;
-                                                       }
-                                                       
-                                                       delimiter = strrchr(optarg,'/');
-
-                                                       #ifdef _XBT_WIN32
-                                                       if(!delimiter)
-                                                               delimiter = strrchr(optarg,'\\');
-                                                       #endif
-                                                       
-                                                       fstream = fstream_new(path, delimiter ? delimiter + 1 : optarg);
-                                                       
-                                                       free(path);
-                                                       
-                                                       if(fstreams_contains(fstreams, fstream))
-                                                       {
-                                                               fstream_free(&fstream);
-                                                               WARN1("File %s already specified to run", optarg);
-                                                       }
-                                                       else
-                                                               fstreams_add(fstreams, fstream);
-                                               }
-                                               /* --include-dir option */
-                                               else if(!strcmp(entry->long_name,"include-dir"))
-                                               {
-                                                       
-                                                       char* path ;
-                                                       
-                                                       if(translatepath(optarg, &path) < 0)
-                                                       {
-                                                               exit_code = errno;
-                                                               err_kind = 0;
-                                                               
-                                                               if(ENOTDIR == errno)
-                                                                       ERROR1("%s is not a directory",optarg);
-                                                               else
-                                                                       ERROR0("Insufficient memory is available to process the command line - system error");
-                                                                       
-                                                               return -1;
-                                                       }
-                                                       
-                                                       else
-                                                       {
-                                                               int exists = 0;
-                                                               unsigned int i;
-                                                               directory_t cur;
-                                                               directory = directory_new(path);
-                                                               free(path);
-
-                                                               xbt_dynar_foreach(include_dirs, i , cur)
-                                                               {
-                                                                       if(!strcmp(cur->name, optarg))
-                                                                       {
-                                                                               exists = 1;
-                                                                               break;
-                                                                       }
-                                                               }
-
-                                                               if(exists)
-                                                               {
-                                                                       directory_free((void**)&directory);
-                                                                       WARN1("Include directory %s already specified to be used",optarg);
-                                                                       
-                                                               }
-                                                               else
-                                                                       xbt_dynar_push(include_dirs, &directory);
-
-                                                       }
-                                               }
-                                               /* --exclude option */ 
-                                               else if(!strcmp(entry->long_name,"exclude"))
-                                               {
-                                                       char* path;
-                                                       char* delimiter;
-                       
-                                                       if(getpath(optarg, &path) < 0)
-                                                       {
-                                                               exit_code = errno;
-                                                               err_kind = 0;
-                                                               
-                                                               if(ENOENT == errno)
-                                                                       ERROR1("file %s does not exist", optarg);
-                                                               else
-                                                                       ERROR0("Insufficient memory is available to process the command line - system error");
-                                                                       
-                                                               return -1;
-                                                       }
-                       
-                                                       delimiter = strrchr(optarg,'/');
-
-                                                       #ifdef _XBT_WIN32
-                                                       if(!delimiter)
-                                                               delimiter = strrchr(optarg,'\\');
-                                                       #endif
-                       
-                                                       fstream = fstream_new(path, delimiter ? delimiter + 1 : optarg);
-                                                       free(path);
-                       
-                                                       if(excludes_contains(excludes, fstream))
-                                                       {
-                                                               fstream_free(&fstream);
-                                                               WARN1("File %s already specified to be exclude", optarg);
-                                                       }
-                                                       else
-                                                               excludes_add(excludes, fstream);
-                                                                       
-                                               }
-                                               else if(!strcmp(entry->long_name,"log"))
-                                               {
-                                                       /* NOTHING TODO : log for xbt */
-                                               }
-                                               else
-                                               {
-                                                       INFO1("Unexpected option %s", optarg);
-                                                       return -1;
-                                               }
-                                               
-                                               
-                                               break;
-                                               
-                                               /* strictly positve number options */
-                                               case number:
-                                                       
-                                               if ((NULL == optarg) && (argc > optind))
-                                               {
-                                                       const char* cp;
-                                                       
-                                                       for (cp = argv[optind]; isdigit(cp[0]); ++cp)
-                                                               if(cp[0] == '\0')
-                                                                       optarg = argv[optind++];
-                                               }
-               
-                                               /* the number option is specified */
-                                               if(NULL != optarg)
-                                               {
-                                                       int i = atoi(optarg);
-                                                       const char *cp;
-
-                                                       for (cp = optarg; isdigit(cp[0]); ++cp);
-               
-                                                       if (i < 1 || cp[0] != '\0')
-                                                       {
-                                                               ERROR2("Option %c \"%s\" requires an strictly positive integer as argument",entry->c, entry->long_name);
-                                                               exit_code = ENOTPOSITIVENUM;
-                                                               err_kind = 1;
-                                                               return -1;
-                                                       }
-                                                       else
-                                                               *(int*)entry->value = i;
-                                               }
-                                               /* the number option is specified but has no arg, use the optional value*/
-                                               else
-                                                       *(int*)entry->value = *(int*) entry->optional_value;
-                                               
-                                               break;
-               
-                               }
-                               break;
-                       }
-               }
-       }
-
-       return 0;
+  register const struct s_optentry *entry;
+  register int c;
+  directory_t directory;
+  fstream_t fstream;
+
+  /* initialize the options string of tesh */
+  init_options();
+
+  /* let the function getopt_long display the errors if any */
+  opterr = 1;
+
+  /* set option index to zero */
+  optind = 0;
+
+  while (optind < argc) {
+    c = getopt_long(argc, argv, optstring, longopts, (int *) 0);
+
+    if (c == EOF) {
+      /* end of the command line or "--".  */
+      break;
+    } else if (c == 1) {
+      /* no option specified, assume it's a tesh file to run */
+      char *path;
+      char *delimiter;
+
+      /* getpath returns -1 when the file to get the path doesn't exist */
+      if (getpath(optarg, &path) < 0) {
+        exit_code = errno;
+        err_kind = 0;
+
+        if (ENOENT == errno)
+          ERROR1("File %s does not exist", optarg);
+        else
+          ERROR0
+              ("Insufficient memory is available to parse the command line : system error");
+
+        return -1;
+      }
+
+      /* get to the last / (if any) to get the short name of the file */
+      delimiter = strrchr(optarg, '/');
+
+#ifdef _XBT_WIN32
+      if (!delimiter)
+        delimiter = strrchr(optarg, '\\');
+#endif
+
+      /* create a new file stream which represents the tesh file to run */
+      fstream = fstream_new(path, delimiter ? delimiter + 1 : optarg);
+
+      free(path);
+
+      /* if the list of all tesh files to run already contains this file
+       * destroy it and display a warning, otherwise add it in the list.
+       */
+      if (fstreams_contains(fstreams, fstream)) {
+        fstream_free(&fstream);
+        WARN1("File %s already specified to be run", optarg);
+      } else
+        fstreams_add(fstreams, fstream);
+
+    } else if (c == '?') {
+      /* unknown option, let getopt_long() displays the error */
+      ERROR0("Command line processing failed : invalid command line");
+      exit_code = EINVCMDLINE;
+      err_kind = 1;
+      return -1;
+    } else {
+      for (entry = opt_entries; entry->c != '\0'; ++entry)
+
+        if (c == entry->c) {
+
+          switch (entry->type) {
+            /* impossible */
+          default:
+            ERROR0("Command line processing failed : internal error");
+            exit_code = EPROCCMDLINE;
+            err_kind = 1;
+            return -1;
+
+
+            /* flag options */
+          case flag:
+            /* set the flag to one */
+            *(int *) entry->value = 1;
+
+            break;
+
+            /* string options */
+          case string:
+
+            if (!optarg) {
+              /* an option with a optional arg is specified use the entry->optional_value */
+              optarg = (char *) entry->optional_value;
+            } else if (*optarg == '\0') {
+              /* a non optional argument is not specified */
+              ERROR2("Option %c \"%s\"requires an argument", entry->c,
+                     entry->long_name);
+              exit_code = ENOARG;
+              err_kind = 1;
+              return -1;
+            }
+
+            /* --load-directory option */
+            if (!strcmp(entry->long_name, "load-directory")) {
+              char *path;
+
+              if (translatepath(optarg, &path) < 0) {
+                exit_code = errno;
+                err_kind = 0;
+
+                if (ENOTDIR == errno)
+                  ERROR1("%s is not a directory", optarg);
+                else
+                  ERROR0
+                      ("Insufficient memory is available to process the command line - system error");
+
+                return -1;
+
+              } else {
+
+                directory = directory_new(path);
+                free(path);
+
+                if (directories_contains(directories, directory)) {
+                  directory_free((void **) &directory);
+                  WARN1("Directory %s already specified to be load",
+                        optarg);
+                } else
+                  directories_add(directories, directory);
+
+
+              }
+            } else if (!strcmp(entry->long_name, "directory")) {
+              char *path;
+
+              if (translatepath(optarg, &path) < 0) {
+                exit_code = errno;
+                err_kind = 0;
+
+                if (ENOTDIR == errno)
+                  ERROR1("%s is not a directory", optarg);
+                else
+                  ERROR0
+                      ("Insufficient memory is available to process the command line - system error");
+
+                return -1;
+              } else {
+                char *buffer = getcwd(NULL, 0);
+
+
+                if (!strcmp(buffer, path))
+                  WARN1("Already in the directory %s", optarg);
+                else if (!print_directory_flag)
+                  INFO1("Entering directory \"%s\"", path);
+
+                chdir(path);
+                free(path);
+
+                free(buffer);
+              }
+            }
+
+            /* --suffix option */
+            else if (!strcmp(entry->long_name, "suffix")) {
+              if (strlen(optarg) > MAX_SUFFIX) {
+                ERROR1("Suffix %s too long", optarg);
+                exit_code = ESUFFIXTOOLONG;
+                err_kind = 1;
+                return -1;
+              }
+
+              if (optarg[0] == '.') {
+                char *cur;
+                unsigned int i;
+                int exists = 0;
+
+                char *suffix = xbt_new0(char, MAX_SUFFIX + 2);
+                sprintf(suffix, ".%s", optarg);
+
+                xbt_dynar_foreach(suffixes, i, cur) {
+                  if (!strcmp(suffix, cur)) {
+                    exists = 1;
+                    break;
+                  }
+                }
+
+                if (exists)
+                  WARN1("Suffix %s already specified to be used", optarg);
+                else
+                  xbt_dynar_push(suffixes, &suffix);
+              } else {
+                char *cur;
+                unsigned int i;
+                int exists = 0;
+
+                xbt_dynar_foreach(suffixes, i, cur) {
+                  if (!strcmp(optarg, cur)) {
+                    exists = 1;
+                    break;
+                  }
+                }
+
+                if (exists)
+                  WARN1("Suffix %s already specified to be used", optarg);
+                else {
+                  char *suffix = strdup(optarg);
+                  xbt_dynar_push(suffixes, &suffix);
+                }
+              }
+            }
+            /* --file option */
+            else if (!strcmp(entry->long_name, "file")) {
+              char *path;
+              char *delimiter;
+
+              if (getpath(optarg, &path) < 0) {
+                exit_code = errno;
+                err_kind = 0;
+
+                if (ENOENT == errno)
+                  ERROR1("File %s does not exist", optarg);
+                else
+                  ERROR1("System error :`(%s)'", strerror(errno));
+
+                return -1;
+              }
+
+              delimiter = strrchr(optarg, '/');
+
+#ifdef _XBT_WIN32
+              if (!delimiter)
+                delimiter = strrchr(optarg, '\\');
+#endif
+
+              fstream =
+                  fstream_new(path, delimiter ? delimiter + 1 : optarg);
+
+              free(path);
+
+              if (fstreams_contains(fstreams, fstream)) {
+                fstream_free(&fstream);
+                WARN1("File %s already specified to run", optarg);
+              } else
+                fstreams_add(fstreams, fstream);
+            }
+            /* --include-dir option */
+            else if (!strcmp(entry->long_name, "include-dir")) {
+
+              char *path;
+
+              if (translatepath(optarg, &path) < 0) {
+                exit_code = errno;
+                err_kind = 0;
+
+                if (ENOTDIR == errno)
+                  ERROR1("%s is not a directory", optarg);
+                else
+                  ERROR0
+                      ("Insufficient memory is available to process the command line - system error");
+
+                return -1;
+              }
+
+              else {
+                int exists = 0;
+                unsigned int i;
+                directory_t cur;
+                directory = directory_new(path);
+                free(path);
+
+                xbt_dynar_foreach(include_dirs, i, cur) {
+                  if (!strcmp(cur->name, optarg)) {
+                    exists = 1;
+                    break;
+                  }
+                }
+
+                if (exists) {
+                  directory_free((void **) &directory);
+                  WARN1
+                      ("Include directory %s already specified to be used",
+                       optarg);
+
+                } else
+                  xbt_dynar_push(include_dirs, &directory);
+
+              }
+            }
+            /* --exclude option */
+            else if (!strcmp(entry->long_name, "exclude")) {
+              char *path;
+              char *delimiter;
+
+              if (getpath(optarg, &path) < 0) {
+                exit_code = errno;
+                err_kind = 0;
+
+                if (ENOENT == errno)
+                  ERROR1("file %s does not exist", optarg);
+                else
+                  ERROR0
+                      ("Insufficient memory is available to process the command line - system error");
+
+                return -1;
+              }
+
+              delimiter = strrchr(optarg, '/');
+
+#ifdef _XBT_WIN32
+              if (!delimiter)
+                delimiter = strrchr(optarg, '\\');
+#endif
+
+              fstream =
+                  fstream_new(path, delimiter ? delimiter + 1 : optarg);
+              free(path);
+
+              if (excludes_contains(excludes, fstream)) {
+                fstream_free(&fstream);
+                WARN1("File %s already specified to be exclude", optarg);
+              } else
+                excludes_add(excludes, fstream);
+
+            } else if (!strcmp(entry->long_name, "log")) {
+              /* NOTHING TODO : log for xbt */
+            } else {
+              INFO1("Unexpected option %s", optarg);
+              return -1;
+            }
+
+
+            break;
+
+            /* strictly positve number options */
+          case number:
+
+            if ((NULL == optarg) && (argc > optind)) {
+              const char *cp;
+
+              for (cp = argv[optind]; isdigit(cp[0]); ++cp)
+                if (cp[0] == '\0')
+                  optarg = argv[optind++];
+            }
+
+            /* the number option is specified */
+            if (NULL != optarg) {
+              int i = atoi(optarg);
+              const char *cp;
+
+              for (cp = optarg; isdigit(cp[0]); ++cp);
+
+              if (i < 1 || cp[0] != '\0') {
+                ERROR2
+                    ("Option %c \"%s\" requires an strictly positive integer as argument",
+                     entry->c, entry->long_name);
+                exit_code = ENOTPOSITIVENUM;
+                err_kind = 1;
+                return -1;
+              } else
+                *(int *) entry->value = i;
+            }
+            /* the number option is specified but has no arg, use the optional value */
+            else
+              *(int *) entry->value = *(int *) entry->optional_value;
+
+            break;
+
+          }
+          break;
+        }
+    }
+  }
+
+  return 0;
 }
 
-static void
-print_usage(void)
+static void print_usage(void)
 {
-       const char **cpp;
-       FILE* stream;
-       
-       stream = exit_code ? stderr : stdout;
-
-       if(!screen_cleaned)
-       {
-               #ifdef _XBT_WIN32
-               system("cls");
-               #else
-               system("clear");
-               #endif
-               screen_cleaned = 1;
-       }
-       
-       fprintf (stream, "Usage: tesh [options] [file] ...\n");
-       
-       for (cpp = usage; *cpp; ++cpp)
-               fputs (*cpp, stream);
-       
-       fprintf(stream, "\nReport bugs to <martin.quinson@loria.fr | malek.cherier@loria.fr>\n");
+  const char **cpp;
+  FILE *stream;
+
+  stream = exit_code ? stderr : stdout;
+
+  if (!screen_cleaned) {
+#ifdef _XBT_WIN32
+    system("cls");
+#else
+    system("clear");
+#endif
+    screen_cleaned = 1;
+  }
+
+  fprintf(stream, "Usage: tesh [options] [file] ...\n");
+
+  for (cpp = usage; *cpp; ++cpp)
+    fputs(*cpp, stream);
+
+  fprintf(stream,
+          "\nReport bugs to <martin.quinson@loria.fr | malek.cherier@loria.fr>\n");
 }
 
-static void
-print_version(void)
+static void print_version(void)
 {
-       if(!screen_cleaned)
-       {
-               #ifdef _XBT_WIN32
-               system("cls");
-               #else
-               system("clear");
-               #endif
-               screen_cleaned = 1;
-       }
-
-       /* TODO : display the version of tesh */
-       printf("Version :\n");
-       printf("  tesh version %s : Mini shell specialized in running test units by Martin Quinson \n", version);
-       printf("  and Malek Cherier\n");
-       printf("  Copyright (c) 2007, 2008 Martin Quinson, Malek Cherier\n");
-       printf("  All rights reserved\n");
-       printf("  This program is free software; you can redistribute it and/or modify it\n");
-       printf("  under the terms of the license (GNU LGPL) which comes with this package.\n\n");
-       
-       if(!print_usage_flag)
-               printf("Report bugs to <martin.quinson@loria.fr | malek.cherier@loria.fr>");
+  if (!screen_cleaned) {
+#ifdef _XBT_WIN32
+    system("cls");
+#else
+    system("clear");
+#endif
+    screen_cleaned = 1;
+  }
+
+  /* TODO : display the version of tesh */
+  printf("Version :\n");
+  printf
+      ("  tesh version %s : Mini shell specialized in running test units by Martin Quinson \n",
+       version);
+  printf("  and Malek Cherier\n");
+  printf("  Copyright (c) 2007, 2008 Martin Quinson, Malek Cherier\n");
+  printf("  All rights reserved\n");
+  printf
+      ("  This program is free software; you can redistribute it and/or modify it\n");
+  printf
+      ("  under the terms of the license (GNU LGPL) which comes with this package.\n\n");
+
+  if (!print_usage_flag)
+    printf
+        ("Report bugs to <martin.quinson@loria.fr | malek.cherier@loria.fr>");
 }
 
-static void
-print_readme(void)
+static void print_readme(void)
 {
-       size_t len;
-       char * line = NULL;
-       
-       FILE* stream = fopen("examples/README.tesh", "r");
-       
-       if(!stream)
-       {
-               ERROR0("Unable to locate the README.txt file");
-               exit_code = EREADMENOTFOUND;
-               err_kind = 1;
-               return;
-       }
-       
-       while(getline(&line, &len, stream) != -1)
-               printf("%s",line);
-               
-       fclose(stream);
-}
+  size_t len;
+  char *line = NULL;
+
+  FILE *stream = fopen("examples/README.tesh", "r");
 
+  if (!stream) {
+    ERROR0("Unable to locate the README.txt file");
+    exit_code = EREADMENOTFOUND;
+    err_kind = 1;
+    return;
+  }
 
+  while (getline(&line, &len, stream) != -1)
+    printf("%s", line);
+
+  fclose(stream);
+}
index 6aa254a..1d37853 100644 (file)
  *             This file contains all the definitions of the functions related with\r
  *             the tesh reader type.\r
  *\r
- */\r
-\r
+ */  \r
+    \r
 #include <unit.h>\r
 #include <reader.h>\r
 #include <command.h>\r
-\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-\r
-static void*\r
-reader_start_routine(void* p);\r
-\r
-reader_t\r
-reader_new(command_t command)\r
-{\r
-       reader_t reader;\r
-       \r
-       /* TODO : check the parameter */\r
-       \r
-       reader = xbt_new0(s_reader_t, 1);\r
-       \r
-       reader->thread = NULL;\r
-       reader->command = command;\r
-       reader->broken_pipe = 0;\r
-       reader->failed = 0;\r
-       reader->done = 0;\r
-       \r
-       reader->started = xbt_os_sem_init(0);\r
-       \r
-       return reader;\r
-}\r
-\r
-int\r
-reader_free(reader_t* ptr)\r
-{\r
-       if((*ptr)->started)\r
-               xbt_os_sem_destroy((*ptr)->started);\r
-       \r
-       free(*ptr);\r
-       \r
-       *ptr = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
-void\r
-reader_read(reader_t reader)\r
-{\r
-       reader->thread = xbt_os_thread_create("", reader_start_routine, reader);\r
-}\r
-\r
+    \r\rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\r\rstatic void *\r reader_start_routine(void *p);
+\r\rreader_t \r reader_new(command_t command) \r
+{
+  \rreader_t reader;
+  \r\r
+      /* TODO : check the parameter */ \r
+      \rreader = xbt_new0(s_reader_t, 1);
+  \r\rreader->thread = NULL;
+  \rreader->command = command;
+  \rreader->broken_pipe = 0;
+  \rreader->failed = 0;
+  \rreader->done = 0;
+  \r\rreader->started = xbt_os_sem_init(0);
+  \r\rreturn reader;
+\r}
+
+\r\rint \r reader_free(reader_t * ptr) \r
+{
+  \rif ((*ptr)->started)
+    \rxbt_os_sem_destroy((*ptr)->started);
+  \r\rfree(*ptr);
+  \r\r*ptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rvoid \r reader_read(reader_t reader) \r
+{
+  \rreader->thread = xbt_os_thread_create("", reader_start_routine, reader);
+\r\r\r
+
 #ifdef _XBT_WIN32\r
-static void*\r
-reader_start_routine(void* p)\r
-{\r
-       reader_t reader = (reader_t)p;\r
-       command_t command = reader->command;\r
-       \r
-       xbt_strbuff_t output = command->output;\r
-       HANDLE stdout_fd = command->stdout_fd;\r
-       \r
-       DWORD number_of_bytes_to_read = 1024; /*command->context->output->used;*/\r
-       DWORD number_of_bytes_readed = 0;\r
-       \r
-       char* buffer = (char*)calloc(number_of_bytes_to_read + 1,sizeof(char));\r
-       char* clean = (char*)calloc(number_of_bytes_to_read + 1,sizeof(char));\r
-       size_t i, j;\r
-\r
-       xbt_os_sem_release(reader->started);\r
-\r
-       while(!command->failed && !command->interrupted && !command->successeded && !reader->failed && !reader->broken_pipe)\r
-       {\r
-               if(!ReadFile(stdout_fd, buffer, number_of_bytes_to_read, &number_of_bytes_readed, NULL) || (0 == number_of_bytes_readed))\r
-               {\r
-                       if(GetLastError() == ERROR_BROKEN_PIPE)\r
-                               reader->broken_pipe = 1;\r
-                       else\r
-                       reader->failed = 1;\r
-                               \r
-               }\r
-               else\r
-               {\r
-                       if(number_of_bytes_readed > 0) \r
-                       {\r
-                               for(i= 0, j= 0; i < number_of_bytes_readed; i++)\r
-                                       if((buffer[i]) != '\r')\r
-                                               clean[j++] = buffer[i];\r
-\r
-                               xbt_strbuff_append(output,clean);\r
-\r
-                               memset(buffer, 0, 1024);\r
-                               memset(clean, 0, 1024);\r
-                       } \r
-                       else \r
-                       {\r
-                               xbt_os_thread_yield();\r
-                       }\r
-               }\r
-       }\r
-\r
-       free(clean);\r
-       free(buffer);\r
-\r
-       xbt_strbuff_chomp(command->output);\r
-       xbt_strbuff_trim(command->output);\r
-\r
-       reader->done = 1;\r
-       \r
-       if(command->failed)\r
-       {\r
-               if(command->reason == csr_write_failure)\r
-               {\r
-                       if(command->output->used)\r
-                               INFO2("[%s] Output on write failure:\n%s",command->context->pos, command->output->data);\r
-                       else\r
-                               INFO1("[%s] No output before write failure",command->context->pos);\r
-               }\r
-               else if(command->reason == csr_write_pipe_broken)\r
-               {\r
-                       if(command->output->used)\r
-                               INFO2("[%s] Output on broken pipe:\n%s",command->context->pos, command->output->data);\r
-                       else\r
-                               INFO1("[%s] No output before broken pipe",command->context->pos);\r
-               }\r
-       }\r
-       else if(command->interrupted)\r
-       {\r
-               if(command->output->used)\r
-                       INFO2("[%s] Output on interruption:\n%s",command->context->pos, command->output->data);\r
-               else\r
-                       INFO1("[%s] No output before interruption",command->context->pos);\r
-       }\r
-       else if(reader->failed && !command->failed && !command->interrupted && !command->successeded)\r
-       {\r
-               ERROR2("[%s] Error while reading output of child `%s'", command->context->pos, command->context->command_line);\r
-               \r
-               if(command->output->used)\r
-                       INFO2("[%s] Output on read failure:\n%s",command->context->pos, command->output->data);\r
-               else\r
-                       INFO1("[%s] No output before read failure",command->context->pos);\r
-               \r
-               unit_set_error(command->unit, errno, 0, command->context->pos);\r
-               command_kill(command);\r
-               command_handle_failure(command, csr_read_failure);\r
-       }\r
-\r
-       \r
-       \r
-       return NULL;\r
-}\r
-\r
-#else\r
-static void*\r
-reader_start_routine(void* p) \r
-{\r
-       reader_t reader = (reader_t)p;\r
-       command_t command = reader->command;\r
-       xbt_strbuff_t output = command->output;\r
-       int stdout_fd = command->stdout_fd;\r
-       int number_of_bytes_readed;\r
-       int number_of_bytes_to_read = (1024 > SSIZE_MAX) ? SSIZE_MAX : 1024;\r
-\r
-       int total = 0;\r
-               \r
-       char* buffer = (char*)calloc(number_of_bytes_to_read,sizeof(char));\r
-       xbt_os_sem_release(reader->started);\r
-       \r
-       do \r
-       {\r
-               number_of_bytes_readed = read(stdout_fd, buffer, number_of_bytes_to_read);\r
-               \r
-               if(number_of_bytes_readed < 0 && errno != EINTR && errno != EAGAIN) \r
-               {\r
-                       reader->failed = 1;\r
-               }\r
-               \r
-               if(number_of_bytes_readed > 0) \r
-               {\r
-                       buffer[number_of_bytes_readed]='\0';\r
-                       xbt_strbuff_append(output,buffer);\r
-                       total += total;\r
-               } \r
-               else \r
-               {\r
-                       xbt_os_thread_yield();\r
-               }\r
-       \r
-       }while(!command->failed && !command->interrupted && !command->successeded && !reader->failed && (number_of_bytes_readed != 0 /* end of file <-> normal exit */));\r
-       \r
-       free(buffer);\r
-       \r
-       if(close(command->stdout_fd) < 0)\r
-       {\r
-               /* TODO */\r
-       }\r
-       else\r
-               command->stdout_fd = INDEFINITE_FD;\r
-       \r
-       xbt_strbuff_chomp(command->output);\r
-       xbt_strbuff_trim(command->output);\r
-\r
-       reader->done = 1;\r
-\r
-       if(command->failed)\r
-       {\r
-               if(command->reason == csr_write_failure)\r
-               {\r
-                       if(command->output->used)\r
-                               INFO2("[%s] Output on write failure:\n%s",command->context->pos, command->output->data);\r
-                       else\r
-                               INFO1("[%s] No output before write failur",command->context->pos);\r
-               }\r
-               else if(command->reason == csr_write_pipe_broken)\r
-               {\r
-                       if(command->output->used)\r
-                               INFO2("[%s] Output on broken pipe:\n%s",command->context->pos, command->output->data);\r
-                       else\r
-                               INFO1("[%s] No output before broken pipe",command->context->pos);\r
-               }\r
-       }\r
-       else if(command->interrupted)\r
-       {\r
-               if(command->output->used)\r
-                       INFO2("[%s] Output on interruption:\n%s",command->context->pos, command->output->data);\r
-               else\r
-                       INFO1("[%s] No output before interruption",command->context->pos);\r
-       }\r
-       else if(reader->failed && !command->failed && !command->interrupted && !command->successeded)\r
-       {\r
-               ERROR2("[%s] Error while reading output of child `%s'", command->context->pos, command->context->command_line);\r
-               \r
-               if(command->output->used)\r
-                       INFO2("[%s] Output on read failure:\n%s",command->context->pos, command->output->data);\r
-               else\r
-                       INFO1("[%s] No output before read failure",command->context->pos);\r
-               \r
-               unit_set_error(command->unit, errno, 0, command->context->pos);\r
-               command_kill(command);\r
-               command_handle_failure(command, csr_read_failure);\r
-       }\r
-       \r
-       \r
-       return NULL;\r
-} \r
-#endif\r
+static void *\r reader_start_routine(void *p) \r
+{
+  \rreader_t reader = (reader_t) p;
+  \rcommand_t command = reader->command;
+  \r\rxbt_strbuff_t output = command->output;
+  \rHANDLE stdout_fd = command->stdout_fd;
+  \r\rDWORD number_of_bytes_to_read = 1024;       /*command->context->output->used; */
+  \rDWORD number_of_bytes_readed = 0;
+  \r\rchar *buffer =
+      (char *) calloc(number_of_bytes_to_read + 1, sizeof(char));
+  \rchar *clean =
+      (char *) calloc(number_of_bytes_to_read + 1, sizeof(char));
+  \rsize_t i, j;
+  \r\rxbt_os_sem_release(reader->started);
+  \r\rwhile (!command->failed && !command->interrupted
+           && !command->successeded && !reader->failed
+           && !reader->broken_pipe)
+    \r {
+    \rif (!ReadFile
+         (stdout_fd, buffer, number_of_bytes_to_read,
+          &number_of_bytes_readed, NULL) || (0 == number_of_bytes_readed))
+      \r {
+      \rif (GetLastError() == ERROR_BROKEN_PIPE)
+        \rreader->broken_pipe = 1;
+      \r
+      else
+        \rreader->failed = 1;
+      \r\r}
+    \r
+    else
+      \r {
+      \rif (number_of_bytes_readed > 0)
+        \r {
+        \rfor (i = 0, j = 0; i < number_of_bytes_readed; i++)
+          \rif ((buffer[i]) != '\r')
+            \rclean[j++] = buffer[i];
+        \r\rxbt_strbuff_append(output, clean);
+        \r\rmemset(buffer, 0, 1024);
+        \rmemset(clean, 0, 1024);
+        \r}
+      \r
+      else
+        \r {
+        \rxbt_os_thread_yield();
+        \r}
+      \r}
+    \r}
+  \r\rfree(clean);
+  \rfree(buffer);
+  \r\rxbt_strbuff_chomp(command->output);
+  \rxbt_strbuff_trim(command->output);
+  \r\rreader->done = 1;
+  \r\rif (command->failed)
+    \r {
+    \rif (command->reason == csr_write_failure)
+      \r {
+      \rif (command->output->used)
+        \rINFO2("[%s] Output on write failure:\n%s", command->context->pos,
+               command->output->data);
+      \r
+      else
+        \rINFO1("[%s] No output before write failure",
+               command->context->pos);
+      \r}
+    \r
+    else if (command->reason == csr_write_pipe_broken)
+      \r {
+      \rif (command->output->used)
+        \rINFO2("[%s] Output on broken pipe:\n%s", command->context->pos,
+               command->output->data);
+      \r
+      else
+        \rINFO1("[%s] No output before broken pipe", command->context->pos);
+      \r}
+    \r}
+  \r
+  else if (command->interrupted)
+    \r {
+    \rif (command->output->used)
+      \rINFO2("[%s] Output on interruption:\n%s", command->context->pos,
+             command->output->data);
+    \r
+    else
+      \rINFO1("[%s] No output before interruption", command->context->pos);
+    \r}
+  \r
+  else if (reader->failed && !command->failed && !command->interrupted
+           && !command->successeded)
+    \r {
+    \rERROR2("[%s] Error while reading output of child `%s'",
+            command->context->pos, command->context->command_line);
+    \r\rif (command->output->used)
+      \rINFO2("[%s] Output on read failure:\n%s", command->context->pos,
+             command->output->data);
+    \r
+    else
+      \rINFO1("[%s] No output before read failure", command->context->pos);
+    \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+    \rcommand_kill(command);
+    \rcommand_handle_failure(command, csr_read_failure);
+    \r}
+  \r\r\r\rreturn NULL;
+\r}
+
+\r\r
+#else   /* \r */
+static void *\r reader_start_routine(void *p) \r
+{
+  \rreader_t reader = (reader_t) p;
+  \rcommand_t command = reader->command;
+  \rxbt_strbuff_t output = command->output;
+  \rint stdout_fd = command->stdout_fd;
+  \rint number_of_bytes_readed;
+  \rint number_of_bytes_to_read = (1024 > SSIZE_MAX) ? SSIZE_MAX : 1024;
+  \r\rint total = 0;
+  \r\rchar *buffer = (char *) calloc(number_of_bytes_to_read, sizeof(char));
+  \rxbt_os_sem_release(reader->started);
+  \r\r
+  do
+    \r {
+    \rnumber_of_bytes_readed =
+        read(stdout_fd, buffer, number_of_bytes_to_read);
+    \r\rif (number_of_bytes_readed < 0 && errno != EINTR && errno != EAGAIN)
+      \r {
+      \rreader->failed = 1;
+      \r}
+    \r\rif (number_of_bytes_readed > 0)
+      \r {
+      \rbuffer[number_of_bytes_readed] = '\0';
+      \rxbt_strbuff_append(output, buffer);
+      \rtotal += total;
+      \r}
+    \r
+    else
+      \r {
+      \rxbt_os_thread_yield();
+      \r}
+  \r\r} while (!command->failed && !command->interrupted
+               && !command->successeded && !reader->failed
+               && (number_of_bytes_readed !=
+                     0 /* end of file <-> normal exit */ ));
+  \r\rfree(buffer);
+  \r\rif (close(command->stdout_fd) < 0)
+    \r {
+    \r
+        /* TODO */ \r
+    }
+  \r
+  else
+    \rcommand->stdout_fd = INDEFINITE_FD;
+  \r\rxbt_strbuff_chomp(command->output);
+  \rxbt_strbuff_trim(command->output);
+  \r\rreader->done = 1;
+  \r\rif (command->failed)
+    \r {
+    \rif (command->reason == csr_write_failure)
+      \r {
+      \rif (command->output->used)
+        \rINFO2("[%s] Output on write failure:\n%s", command->context->pos,
+               command->output->data);
+      \r
+      else
+        \rINFO1("[%s] No output before write failur",
+               command->context->pos);
+      \r}
+    \r
+    else if (command->reason == csr_write_pipe_broken)
+      \r {
+      \rif (command->output->used)
+        \rINFO2("[%s] Output on broken pipe:\n%s", command->context->pos,
+               command->output->data);
+      \r
+      else
+        \rINFO1("[%s] No output before broken pipe", command->context->pos);
+      \r}
+    \r}
+  \r
+  else if (command->interrupted)
+    \r {
+    \rif (command->output->used)
+      \rINFO2("[%s] Output on interruption:\n%s", command->context->pos,
+             command->output->data);
+    \r
+    else
+      \rINFO1("[%s] No output before interruption", command->context->pos);
+    \r}
+  \r
+  else if (reader->failed && !command->failed && !command->interrupted
+           && !command->successeded)
+    \r {
+    \rERROR2("[%s] Error while reading output of child `%s'",
+            command->context->pos, command->context->command_line);
+    \r\rif (command->output->used)
+      \rINFO2("[%s] Output on read failure:\n%s", command->context->pos,
+             command->output->data);
+    \r
+    else
+      \rINFO1("[%s] No output before read failure", command->context->pos);
+    \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+    \rcommand_kill(command);
+    \rcommand_handle_failure(command, csr_read_failure);
+    \r}
+  \r\r\rreturn NULL;
+\r}
+
 \r
-void\r
-reader_wait(reader_t reader)\r
-{\r
-       xbt_os_thread_join(reader->thread, NULL);\r
-}\r
+#endif  /* \r */
+\rvoid \r reader_wait(reader_t reader) \r
+{
+  \rxbt_os_thread_join(reader->thread, NULL);
+\r\r
index 6a2c674..02abf77 100644 (file)
@@ -2,79 +2,69 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
 
-long
-readline(FILE* stream, char **buf, size_t *n)
+long readline(FILE * stream, char **buf, size_t * n)
 {
-       size_t i;
-       int ch;
-       int cr = 0;
-       fpos_t pos;
-
-       if (!*buf) {
-       *buf = calloc(512, sizeof(char));
-       *n = 512;
-       }
-
-       if (feof(stream))
-       return (ssize_t)-1;
-
-       for (i=0; (ch = fgetc(stream)) != EOF; i++)  
-       {
-               if (i >= (*n) + 1)
-                       *buf = xbt_realloc(*buf, *n += 512);
-                       
-
-                       (*buf)[i] = ch;
-                       
-                       if(cr && (*buf)[i] != '\n')
-                       {
-                               /* old Mac os uses CR */
-                               i--;
-                               (*buf)[i] = '\n';
-                               
-                               /* move to the previous pos (pos of the CR) */
-                               fsetpos(stream, &pos);
-                               
-                               /* process as linux now */
-                               cr --;
-                       }
-                       
-                       if((*buf)[i] == '\n')  
-                       {
-                               if(cr)
-                               {
-                                       /* Windows uses CRLF */
-                                       (*buf)[i - 1] = '\n';
-                                       (*buf)[i] = '\0';
-                                       break;
-                               }
-                               else
-                               {
-                                       /* Unix use LF */
-                                       i++;
-                                       (*buf)[i] = '\0';
-                                       break;
-                               }
-                       }  
-                       else if(ch == '\r')
-                       {
-                               cr ++;
-                               
-                               /* register the CR position for mac */
-                               fgetpos(stream, &pos);
-                       }
-       }
-       
-       
-       if (i == *n) 
-               *buf = xbt_realloc(*buf, *n += 1);
-
-       /* Mac os file ended with a blank line */
-       if(ch == EOF && (*buf)[i - 1] == '\r')
-               (*buf)[i - 1] = '\n';
-
-       (*buf)[i] = '\0';
-
-       return (ssize_t)i;
-}
+  size_t i;
+  int ch;
+  int cr = 0;
+  fpos_t pos;
+
+  if (!*buf) {
+    *buf = calloc(512, sizeof(char));
+    *n = 512;
+  }
+
+  if (feof(stream))
+    return (ssize_t) - 1;
+
+  for (i = 0; (ch = fgetc(stream)) != EOF; i++) {
+    if (i >= (*n) + 1)
+      *buf = xbt_realloc(*buf, *n += 512);
+
+
+    (*buf)[i] = ch;
+
+    if (cr && (*buf)[i] != '\n') {
+      /* old Mac os uses CR */
+      i--;
+      (*buf)[i] = '\n';
+
+      /* move to the previous pos (pos of the CR) */
+      fsetpos(stream, &pos);
 
+      /* process as linux now */
+      cr--;
+    }
+
+    if ((*buf)[i] == '\n') {
+      if (cr) {
+        /* Windows uses CRLF */
+        (*buf)[i - 1] = '\n';
+        (*buf)[i] = '\0';
+        break;
+      } else {
+        /* Unix use LF */
+        i++;
+        (*buf)[i] = '\0';
+        break;
+      }
+    } else if (ch == '\r') {
+      cr++;
+
+      /* register the CR position for mac */
+      fgetpos(stream, &pos);
+    }
+  }
+
+
+  if (i == *n)
+    *buf = xbt_realloc(*buf, *n += 1);
+
+  /* Mac os file ended with a blank line */
+  if (ch == EOF && (*buf)[i - 1] == '\r')
+    (*buf)[i - 1] = '\n';
+
+  (*buf)[i] = '\0';
+
+  return (ssize_t) i;
+}
index 35f0691..39babd4 100644 (file)
  *             This file contains all the definitions of the functions related with\r
  *             the tesh runner type.\r
  *\r
- */\r
+ */  \r
 #include <runner.h>\r
 #include <units.h>\r
 #include <unit.h>\r
 #include <xerrno.h>\r
 #include <variable.h>\r
-\r
+    \r
 #include <errno.h>     /* for error code       */\r
 #include <stdlib.h>    /* for calloc()         */\r
 #include <stdio.h>\r
-\r
+    \r
 #include <readline.h>\r
 #include <explode.h>\r
-\r
+    \r
 #ifndef _XBT_WIN32\r
 #include <sys/resource.h>\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
+#endif  /* \r */
+    \r\r\r\r\r
 #define _RUNNER_HASHCODE               0xFEFEAAAA      \r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
+    \rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\r
 #if (!defined(__BUILTIN) && defined(__CHKCMD) && !defined(_XBT_WIN32))\r
-static const char* builtin[] =\r
-{\r
-       "alias",\r
-       "bind",\r
-       "builtin",\r
-       "caller",\r
-       "cd",\r
-       "command",\r
-       "compgen",\r
-       "complete",\r
-       "declare",\r
-       "disown",\r
-       "echo",\r
-       "enable",\r
-       "eval",\r
-       "exec",\r
-       "export",\r
-       "false",\r
-       "fc",\r
-       "function",\r
-       "getopts",\r
-       "hash",\r
-       "history",\r
-       "jobs",\r
-       "let",\r
-       "logout",\r
-       "printf",\r
-       "pwd",\r
-       "readonly",\r
-       "shift",\r
-       "shopt",\r
-       "source",\r
-       "suspend",\r
-       "test",\r
-       "time",\r
-       "times",\r
-       "trap",\r
-       "true",\r
-       "type",\r
-       "typeset",\r
-       "ulimit",\r
-       "umask",\r
-       "unalias",\r
-       "unset",\r
-       NULL\r
-};\r
-\r
+static const char *builtin[] = \r
+    { \r"alias", \r"bind", \r"builtin", \r"caller", \r"cd", \r"command",
+\r"compgen", \r"complete", \r"declare", \r"disown", \r"echo", \r"enable", \r"eval", \r"exec", \r"export",
+\r"false", \r"fc", \r"function", \r"getopts", \r"hash", \r"history", \r"jobs", \r"let", \r"logout",
+\r"printf", \r"pwd", \r"readonly", \r"shift", \r"shopt", \r"source", \r"suspend", \r"test", \r"time",
+\r"times", \r"trap", \r"true", \r"type", \r"typeset", \r"ulimit", \r"umask", \r"unalias", \r"unset",
+\rNULL \r
+};
+
+\r\r
 #define __BUILTIN_MAX ((size_t)42)\r
-#endif\r
-\r
-\r
+#endif  /* \r */
+    \r\r
 # ifdef __APPLE__\r
-/* under darwin, the environment gets added to the process at startup time. So, it's not defined at library link time, forcing us to extra tricks */\r
+/* under darwin, the environment gets added to the process at startup time. So, it's not defined at library link time, forcing us to extra tricks */ \r
 # include <crt_externs.h>\r
 # define environ (*_NSGetEnviron())\r
 # else\r
-       #ifdef _XBT_WIN32\r
-        /* the environment, as specified by the opengroup, used to initialize the process properties */\r
-               # define environ **wenviron;\r
-       #else\r
-               extern char **environ;\r
-       #endif\r
-# endif\r
+#ifdef _XBT_WIN32\r
+    /* the environment, as specified by the opengroup, used to initialize the process properties */ \r
+# define environ **wenviron;\r
+#else   /* \r */
+extern char **environ;
 \r
+#endif  /* \r */
+# endif\r
+    \r
 #ifndef _XBT_WIN32\r
-extern char**\r
-environ;\r
-#endif\r
-\r
-/* the unique tesh runner */\r
-static runner_t\r
-runner = NULL;\r
-\r
-/* wait for the tesh runner terminaison        */\r
-static void\r
-runner_wait(void);\r
-\r
-static void*\r
-runner_start_routine(void* p);\r
-\r
+extern char **\r environ;
 \r
+#endif  /* \r */
+    \r
+/* the unique tesh runner */ \r
+static runner_t \r runner = NULL;
+\r\r
+/* wait for the tesh runner terminaison        */ \r
+static void \r runner_wait(void);
+\r\rstatic void *\r runner_start_routine(void *p);
+\r\r\r
 /* check the syntax of the tesh files if \r
  * the check_syntax_flag is specified. Returns\r
  * 0 if the syntax is clean.\r
- */\r
+ */ \r
 /*static void\r
-check_syntax(void);*/\r
-\r
+check_syntax(void);*/ \r
+    \r
 #ifdef _XBT_WIN32\r
-\r
-static HANDLE \r
-timer_handle = NULL;\r
-\r
-\r
-static void*\r
-runner_start_routine(void* p)\r
-{\r
-       \r
-    LARGE_INTEGER li;\r
-\r
-    li.QuadPart=- runner->timeout * 10000000;  /* 10000000 = 10 000 000 * 100 nanoseconds = 1 second */\r
-\r
-    /* create the waitable timer */\r
-    timer_handle = CreateWaitableTimer(NULL, TRUE, NULL);\r
-\r
-    /* set a timer to wait for timeout seconds */\r
-    SetWaitableTimer(timer_handle, &li, 0, NULL, NULL, 0);\r
+\rstatic HANDLE \r timer_handle = NULL;
+\r\r\rstatic void *\r runner_start_routine(void *p) \r
+{
+  \r\rLARGE_INTEGER li;
+  \r\rli.QuadPart = -runner->timeout * 10000000;  /* 10000000 = 10 000 000 * 100 nanoseconds = 1 second */
+  \r\r
+      /* create the waitable timer */ \r
+      timer_handle = CreateWaitableTimer(NULL, TRUE, NULL);
+  \r\r
+      /* set a timer to wait for timeout seconds */ \r
+      SetWaitableTimer(timer_handle, &li, 0, NULL, NULL, 0);
+  \r\r
+      /* wait for the timer */ \r
+      WaitForSingleObject(timer_handle, INFINITE);
+  \r\rif (runner->waiting)
+    \r {
+    \rexit_code = ELEADTIME;
+    \rerr_kind = 1;
+    \rrunner->timeouted = 1;
+    \rxbt_os_sem_release(units_sem);
+    \r}
+  \r\rreturn NULL;
+\r}
+
+\r\r
+#else   /* \r */
+static void *\r runner_start_routine(void *p) \r
+{
+  \rstruct timespec ts;
+  \rint timeout = runner->timeout;
+  \r\r\rwhile (timeout-- && runner->waiting)
+    \r {
+    \rts.tv_sec = 1;
+    \rts.tv_nsec = 0L;
+    \r\r
+    do
+      \r {
+      \rnanosleep(&ts, &ts);
+    \r} while (EINTR == errno);
+    \r}
+  \r\rif (errno)
+    \r {
     \r
-    /* wait for the timer */\r
-    WaitForSingleObject(timer_handle, INFINITE);\r
-\r
-       if(runner->waiting)\r
-       {\r
-               exit_code = ELEADTIME;\r
-               err_kind = 1;\r
-               runner->timeouted = 1;\r
-               xbt_os_sem_release(units_sem);\r
-       }\r
-\r
-       return NULL;\r
-}\r
-\r
-#else\r
-static void*\r
-runner_start_routine(void* p)\r
-{\r
-       struct timespec ts;\r
-       int timeout = runner->timeout;\r
-       \r
-       \r
-       while(timeout-- && runner->waiting)\r
-       {\r
-               ts.tv_sec = 1;\r
-               ts.tv_nsec = 0L;\r
-\r
-               do\r
-               {\r
-                       nanosleep(&ts, &ts);\r
-               }while(EINTR == errno);\r
-       }\r
-       \r
-       if(errno)\r
-       {\r
-               /* TODO process the error */\r
-       }\r
-       else\r
-       {\r
-               if(runner->waiting)\r
-               {\r
-                       exit_code = ELEADTIME;\r
-                       err_kind = 1;\r
-                       runner->timeouted = 1;\r
-                       xbt_os_sem_release(units_sem);\r
-               }\r
-       }\r
-       \r
-       return NULL;\r
-}\r
-#endif\r
-\r
-\r
-int\r
-runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)\r
-{\r
-       \r
-       int i;\r
-       char* val;\r
-       char buffer[PATH_MAX + 1] = {0};\r
-\r
-       int code;\r
-       const char* cstr;\r
-       variable_t variable;\r
-       \r
-       #if (defined(__CHKCMD) && defined(__BUILTIN) && !defined(_XBT_WIN32))\r
-       FILE* s;\r
-       int n = 0;\r
-       size_t len;\r
-       char* line = NULL;\r
-       int is_blank;\r
-       #endif\r
-       \r
-       \r
-       if(runner)\r
-       {\r
-               ERROR0("The runner is already initialized");\r
-               return -1;\r
-       }\r
-               \r
-       runner = xbt_new0(s_runner_t, 1);\r
-       \r
-       runner->path = NULL;\r
-       runner->builtin = NULL;\r
-       \r
-       if(!(runner->units = units_new(runner, fstreams)))\r
-       {\r
-               free(runner);\r
-               runner = NULL;\r
-               return -1;\r
-       }\r
-\r
-       runner->timeout = timeout;\r
-       runner->timeouted = 0;\r
-       runner->interrupted = 0;\r
-       runner->number_of_ended_units = 0;\r
-       runner->number_of_runned_units = 0;\r
-       runner->waiting = 0;\r
-       \r
-       runner->total_of_tests = 0;\r
-       runner->total_of_successeded_tests = 0;\r
-       runner->total_of_failed_tests = 0;\r
-       runner->total_of_interrupted_tests = 0;\r
-       \r
-       runner->total_of_units = 0;\r
-       runner->total_of_successeded_units = 0;\r
-       runner->total_of_failed_units = 0;\r
-       runner->total_of_interrupted_units = 0;\r
-       \r
-       runner->total_of_suites = 0;\r
-       runner->total_of_successeded_suites = 0;\r
-       runner->total_of_failed_suites = 0;\r
-       runner->total_of_interrupted_suites = 0;\r
-       \r
-       /* initialize the vector of variables */\r
-       runner->variables = xbt_dynar_new(sizeof(variable_t), (void_f_pvoid_t)variable_free);\r
-       \r
-       /* add the environment variables in the vector */\r
-       for(i = 0; environ[i] != NULL; i++)\r
-       {\r
-               val = strchr(environ[i], '=');\r
-               \r
-               if(val)\r
-               {\r
-                       val++;\r
-                               \r
-                       if(val[0] != '\0')\r
-                               strncpy(buffer, environ[i], (val - environ[i] -1));\r
-                               \r
-                       if(!strcmp("TESH_PPID", buffer))\r
-                               is_tesh_root = 0;\r
-                       \r
-                       variable = variable_new(buffer, val);\r
-                       variable->env = 1;\r
-                       xbt_dynar_push(runner->variables, &variable);\r
-                       \r
-                       #ifndef _XBT_WIN32\r
-                       if(!strcmp("PATH", buffer))\r
-                       #else\r
-                       if(!strcmp("Path", buffer) || !strcmp("PATH", buffer))\r
-                       #endif\r
-                       {\r
-                               char* p;\r
-                               size_t j,k, len;\r
-                               \r
-                               /* get the list of paths */\r
-                               \r
-                               #ifdef _XBT_WIN32\r
-                               runner->path = explode(';', val);\r
-                               #else\r
-                               runner->path = explode(':', val);\r
-                               #endif\r
-\r
-                               /* remove spaces and backslahes at the end of the path */\r
-                               for (k = 0; runner->path[k] != NULL; k++)\r
-                               {\r
-                               p = runner->path[k];\r
-                               \r
-                               len = strlen(p);\r
-                               \r
-                                       #ifndef _XBT_WIN32\r
-                               for(j = len - 1; p[j] == '/' || p[j] == ' '; j--)\r
-                                       #else\r
-                                       for(j = len - 1; p[j] == '\\' || p[j] == ' '; j--)\r
-                                       #endif\r
-                                       p[j] = '\0';\r
-                               }\r
-                       }\r
-                       \r
-                               \r
-                       memset(buffer, 0, PATH_MAX + 1);\r
-               }\r
-       }\r
-       \r
-       if(is_tesh_root)\r
-       {\r
-               char* tesh_dir = getcwd(NULL, 0);\r
-               \r
-               sprintf(buffer,"%d",getpid());\r
-               \r
-               #ifndef _XBT_WIN32\r
-               setenv("TESH_PPID", buffer, 0);\r
-               setenv("TESH_DIR", tesh_dir, 0);\r
-               #else\r
-               SetEnvironmentVariable("TESH_PPID", buffer);\r
-               SetEnvironmentVariable("TESH_DIR", tesh_dir);\r
-               #endif\r
-               \r
-               variable = variable_new("TESH_PPID", buffer);\r
-               variable->err = 1;\r
-                       \r
-               xbt_dynar_push(runner->variables, &variable);\r
-\r
-               variable = variable_new("TESH_DIR", tesh_dir);\r
-               variable->err = 1;\r
-                       \r
-               xbt_dynar_push(runner->variables, &variable);\r
-               \r
-               free(tesh_dir);\r
-       }\r
-       \r
-       variable = variable_new("EXIT_SUCCESS", "0");\r
-       variable->err = 1;\r
-                       \r
-       xbt_dynar_push(runner->variables, &variable);\r
-\r
-       variable = variable_new("EXIT_FAILURE", "1");\r
-       variable->err = 1;\r
-                       \r
-       xbt_dynar_push(runner->variables, &variable);\r
-\r
-       variable = variable_new("TRUE", "0");\r
-       variable->err = 1;\r
-                       \r
-       xbt_dynar_push(runner->variables, &variable);\r
-\r
-       variable = variable_new("FALSE", "1");\r
-       variable->err = 1;\r
-                       \r
-       xbt_dynar_push(runner->variables, &variable);\r
-\r
-       i = 0;\r
-       \r
-       /* add the errors variables */\r
-       while((cstr = error_get_at(i++, &code)))\r
-       {\r
-               sprintf(buffer,"%d",code);\r
-               variable = variable_new(cstr, buffer);\r
-               variable->err = 1;\r
-               xbt_dynar_push(runner->variables, &variable);\r
-       }\r
-       \r
-       /* if the user want check the syntax, check it */\r
-       /*if(check_syntax_flag)\r
-               check_syntax();\r
-       */\r
-       \r
-       #if (!defined(_XBT_WIN32) && defined(__CHKCMD))\r
-       #if defined(__BUILTIN)\r
-       \r
-       if(!is_tesh_root)\r
-       {\r
-               /* compute the full path the builtin.def file */\r
-               sprintf(buffer,"%s/builtin.def",getenv("TESH_DIR"));\r
-               \r
-               if(!(s = fopen(buffer, "r")))   \r
-               {\r
-                       ERROR1("File `(%s)' not found", buffer);\r
-                       return -1;\r
-               }\r
-               \r
-       }\r
-       else\r
-       {\r
-               if(!(s = fopen("builtin.def", "r")))    \r
-               {\r
-                       ERROR0("File `(builtin.def)' not found");\r
-                       return -1;\r
-               }\r
-       }\r
-       \r
-       if(s)\r
-       {\r
-               fpos_t begin;\r
-\r
-               fgetpos(s, &begin);\r
-\r
-               while(readline(s, &line, &len) != -1)\r
-               {\r
-                       i = 0;\r
-                       is_blank = 1;\r
-                       \r
-\r
-                       while(line[i] != '\0') \r
-                       {\r
-                               if (line[i] != ' ' && line[i] != '\t' && line[i]!='\n' && line[i]!='\r')\r
-                               {\r
-                                       is_blank = 0;\r
-                                       break;\r
-                               }\r
-                               \r
-                               i++;\r
-                       }\r
-\r
-                       if(!is_blank)\r
-                               n++;\r
-               }\r
-\r
-               fsetpos(s, &begin);\r
-               free(line);\r
-               line = NULL;\r
-\r
-               if(n)\r
-               {\r
-                       char* l;\r
-                       \r
-                       runner->builtin = xbt_new0(char*, n + 1); /* (char**) calloc(n + 1, sizeof(char*));*/\r
-                       \r
-                       n = 0;\r
-                       \r
-                       while(readline(s, &line, &len) != -1)\r
-                       {\r
-                               i = 0;\r
-                               is_blank = 1;\r
-\r
-                               while(line[i] != '\0') \r
-                               {\r
-                                       if (line[i] != ' ' && line[i] != '\t' && line[i]!='\n' && line[i]!='\r')\r
-                                       {\r
-                                               is_blank = 0;\r
-                                               break;\r
-                                       }\r
-                                       \r
-                                       i++;\r
-                               }\r
-\r
-                               if(!is_blank)\r
-                               {\r
-                                       l = strdup(line);\r
-\r
-                                       l[strlen(l) - 1] = '\0';\r
-\r
-                                       (runner->builtin)[n++] = l;\r
-                                       \r
-                               }\r
-                       }\r
-                       \r
-               }\r
-               else\r
-               {\r
-                       WARN0("The file `(builtin.def)' is empty");\r
-                       free(runner->builtin);\r
-                       runner->builtin = NULL;\r
-               }\r
-               \r
-\r
-               fclose(s);\r
-               \r
-               if(line)\r
-                       free(line);\r
-               \r
-       }\r
-       \r
-       #else\r
-               runner->builtin = xbt_new0(char*, __BUILTIN_MAX + 1); /* (char**) calloc(__BUILTIN_MAX + 1, sizeof(char*));*/\r
-               \r
-               for(i = 0; i < __BUILTIN_MAX; i++)\r
-                       runner->builtin[i] = strdup(builtin[i]);        \r
-       #endif\r
-       #endif\r
-\r
-       return exit_code ? -1 : 0;\r
-}\r
-\r
-void\r
-runner_destroy(void)\r
-{\r
-       int i;\r
-       \r
-       if(runner->units)\r
-               units_free((void**)(&(runner->units)));\r
-       \r
-       if(runner->variables)\r
-               xbt_dynar_free(&runner->variables);\r
-       \r
-       #ifdef _XBT_WIN32\r
-       CloseHandle(timer_handle);\r
-       #endif\r
-\r
-       if(runner->thread)\r
-               xbt_os_thread_join(runner->thread, NULL);\r
-       \r
-       if(runner->path)\r
-       {\r
-               for (i = 0; runner->path[i] != NULL; i++)\r
-                       free(runner->path[i]);\r
-               \r
-               free(runner->path);\r
-       }\r
-\r
-       if(runner->builtin)\r
-       {\r
-               for (i = 0; runner->builtin[i] != NULL; i++)\r
-                       free(runner->builtin[i]);\r
-               \r
-               free(runner->builtin);\r
-       }\r
-\r
-       free(runner);\r
-       \r
-\r
-       runner = NULL;\r
-}\r
-\r
-void\r
-runner_run(void)\r
-{\r
-       /* allocate the mutex used by the units to asynchronously access \r
-        * to the properties of the runner.\r
-        */\r
-       xbt_os_mutex_t mutex = xbt_os_mutex_init();\r
-       \r
-       /* run all the units */\r
-       units_run_all(runner->units, mutex);\r
-       \r
-       \r
-       if(!interrupted)\r
-               runner_wait();\r
-\r
-       \r
-       /* if the runner is timeouted or receive a interruption request\r
-        * , interrupt all the active units.\r
-        */\r
-       if(runner->timeouted || interrupted)\r
-               runner_interrupt();\r
-       \r
-       /* joins all the units */\r
-       units_join_all(runner->units);\r
-       \r
-       /* release the mutex resource */\r
-       xbt_os_mutex_destroy(mutex);\r
-\r
-}\r
-\r
-static void\r
-runner_wait(void)\r
-{\r
-       if(runner->timeout > 0)\r
-               runner->thread = xbt_os_thread_create("", runner_start_routine, NULL);\r
-       \r
-       /* signal that the runner is waiting */\r
-       runner->waiting = 1;\r
-       \r
-       /* wait for the end of all the units */\r
-       xbt_os_sem_acquire(units_sem);\r
-\r
-       \r
-       runner->waiting = 0;\r
-}\r
-\r
-\r
-\r
+        /* TODO process the error */ \r
+    }
+  \r
+  else
+    \r {
+    \rif (runner->waiting)
+      \r {
+      \rexit_code = ELEADTIME;
+      \rerr_kind = 1;
+      \rrunner->timeouted = 1;
+      \rxbt_os_sem_release(units_sem);
+      \r}
+    \r}
+  \r\rreturn NULL;
+\r}
+
+\r
+#endif  /* \r */
+\r\rint \r
+runner_init( /*int check_syntax_flag, */ int timeout,
+            fstreams_t fstreams) \r
+{
+  \r\rint i;
+  \rchar *val;
+  \rchar buffer[PATH_MAX + 1] = { 0 };
+  \r\rint code;
+  \rconst char *cstr;
+  \rvariable_t variable;
+  \r\r
+#if (defined(__CHKCMD) && defined(__BUILTIN) && !defined(_XBT_WIN32))\r
+      FILE * s;
+  \rint n = 0;
+  \rsize_t len;
+  \rchar *line = NULL;
+  \rint is_blank;
+  \r
+#endif  /* \r */
+      \r\rif (runner)
+    \r {
+    \rERROR0("The runner is already initialized");
+    \rreturn -1;
+    \r}
+  \r\rrunner = xbt_new0(s_runner_t, 1);
+  \r\rrunner->path = NULL;
+  \rrunner->builtin = NULL;
+  \r\rif (!(runner->units = units_new(runner, fstreams)))
+    \r {
+    \rfree(runner);
+    \rrunner = NULL;
+    \rreturn -1;
+    \r}
+  \r\rrunner->timeout = timeout;
+  \rrunner->timeouted = 0;
+  \rrunner->interrupted = 0;
+  \rrunner->number_of_ended_units = 0;
+  \rrunner->number_of_runned_units = 0;
+  \rrunner->waiting = 0;
+  \r\rrunner->total_of_tests = 0;
+  \rrunner->total_of_successeded_tests = 0;
+  \rrunner->total_of_failed_tests = 0;
+  \rrunner->total_of_interrupted_tests = 0;
+  \r\rrunner->total_of_units = 0;
+  \rrunner->total_of_successeded_units = 0;
+  \rrunner->total_of_failed_units = 0;
+  \rrunner->total_of_interrupted_units = 0;
+  \r\rrunner->total_of_suites = 0;
+  \rrunner->total_of_successeded_suites = 0;
+  \rrunner->total_of_failed_suites = 0;
+  \rrunner->total_of_interrupted_suites = 0;
+  \r\r
+      /* initialize the vector of variables */ \r
+      runner->variables =
+      xbt_dynar_new(sizeof(variable_t), (void_f_pvoid_t) variable_free);
+  \r\r
+      /* add the environment variables in the vector */ \r
+      for (i = 0; environ[i] != NULL; i++)
+    \r {
+    \rval = strchr(environ[i], '=');
+    \r\rif (val)
+      \r {
+      \rval++;
+      \r\rif (val[0] != '\0')
+        \rstrncpy(buffer, environ[i], (val - environ[i] - 1));
+      \r\rif (!strcmp("TESH_PPID", buffer))
+        \ris_tesh_root = 0;
+      \r\rvariable = variable_new(buffer, val);
+      \rvariable->env = 1;
+      \rxbt_dynar_push(runner->variables, &variable);
+      \r\r
+#ifndef _XBT_WIN32\r
+          if (!strcmp("PATH", buffer))
+        \r
+#else   /* \r */
+          if (!strcmp("Path", buffer) || !strcmp("PATH", buffer))
+        \r
+#endif  /* \r */
+      {
+        \rchar *p;
+        \rsize_t j, k, len;
+        \r\r
+            /* get the list of paths */ \r
+            \r
+#ifdef _XBT_WIN32\r
+            runner->path = explode(';', val);
+        \r
+#else   /* \r */
+            runner->path = explode(':', val);
+        \r
+#endif  /* \r */
+            \r
+            /* remove spaces and backslahes at the end of the path */ \r
+            for (k = 0; runner->path[k] != NULL; k++)
+          \r {
+          \rp = runner->path[k];
+          \r\rlen = strlen(p);
+          \r\r
+#ifndef _XBT_WIN32\r
+              for (j = len - 1; p[j] == '/' || p[j] == ' '; j--)
+            \r
+#else   /* \r */
+              for (j = len - 1; p[j] == '\\' || p[j] == ' '; j--)
+            \r
+#endif  /* \r */
+                p[j] = '\0';
+          \r}
+      \r}
+      \r\r\rmemset(buffer, 0, PATH_MAX + 1);
+      \r}
+    \r}
+  \r\rif (is_tesh_root)
+    \r {
+    \rchar *tesh_dir = getcwd(NULL, 0);
+    \r\rsprintf(buffer, "%d", getpid());
+    \r\r
+#ifndef _XBT_WIN32\r
+        setenv("TESH_PPID", buffer, 0);
+    \rsetenv("TESH_DIR", tesh_dir, 0);
+    \r
+#else   /* \r */
+        SetEnvironmentVariable("TESH_PPID", buffer);
+    \rSetEnvironmentVariable("TESH_DIR", tesh_dir);
+    \r
+#endif  /* \r */
+        \rvariable = variable_new("TESH_PPID", buffer);
+    \rvariable->err = 1;
+    \r\rxbt_dynar_push(runner->variables, &variable);
+    \r\rvariable = variable_new("TESH_DIR", tesh_dir);
+    \rvariable->err = 1;
+    \r\rxbt_dynar_push(runner->variables, &variable);
+    \r\rfree(tesh_dir);
+    \r}
+  \r\rvariable = variable_new("EXIT_SUCCESS", "0");
+  \rvariable->err = 1;
+  \r\rxbt_dynar_push(runner->variables, &variable);
+  \r\rvariable = variable_new("EXIT_FAILURE", "1");
+  \rvariable->err = 1;
+  \r\rxbt_dynar_push(runner->variables, &variable);
+  \r\rvariable = variable_new("TRUE", "0");
+  \rvariable->err = 1;
+  \r\rxbt_dynar_push(runner->variables, &variable);
+  \r\rvariable = variable_new("FALSE", "1");
+  \rvariable->err = 1;
+  \r\rxbt_dynar_push(runner->variables, &variable);
+  \r\ri = 0;
+  \r\r
+      /* add the errors variables */ \r
+      while ((cstr = error_get_at(i++, &code)))
+    \r {
+    \rsprintf(buffer, "%d", code);
+    \rvariable = variable_new(cstr, buffer);
+    \rvariable->err = 1;
+    \rxbt_dynar_push(runner->variables, &variable);
+    \r}
+  \r\r
+      /* if the user want check the syntax, check it */ \r
+      /*if(check_syntax_flag)\r
+         check_syntax();\r
+       */ \r
+      \r
+#if (!defined(_XBT_WIN32) && defined(__CHKCMD))\r
+#if defined(__BUILTIN)\r
+      \rif (!is_tesh_root)
+    \r {
+    \r
+        /* compute the full path the builtin.def file */ \r
+        sprintf(buffer, "%s/builtin.def", getenv("TESH_DIR"));
+    \r\rif (!(s = fopen(buffer, "r")))
+      \r {
+      \rERROR1("File `(%s)' not found", buffer);
+      \rreturn -1;
+      \r}
+    \r\r}
+  \r
+  else
+    \r {
+    \rif (!(s = fopen("builtin.def", "r")))
+      \r {
+      \rERROR0("File `(builtin.def)' not found");
+      \rreturn -1;
+      \r}
+    \r}
+  \r\rif (s)
+    \r {
+    \rfpos_t begin;
+    \r\rfgetpos(s, &begin);
+    \r\rwhile (readline(s, &line, &len) != -1)
+      \r {
+      \ri = 0;
+      \ris_blank = 1;
+      \r\r\rwhile (line[i] != '\0')
+        \r {
+        \rif (line[i] != ' ' && line[i] != '\t' && line[i] != '\n'
+             && line[i] != '\r')
+          \r {
+          \ris_blank = 0;
+          \rbreak;
+          \r}
+        \r\ri++;
+        \r}
+      \r\rif (!is_blank)
+        \rn++;
+      \r}
+    \r\rfsetpos(s, &begin);
+    \rfree(line);
+    \rline = NULL;
+    \r\rif (n)
+      \r {
+      \rchar *l;
+      \r\rrunner->builtin = xbt_new0(char *, n + 1);      /* (char**) calloc(n + 1, sizeof(char*)); */
+      \r\rn = 0;
+      \r\rwhile (readline(s, &line, &len) != -1)
+        \r {
+        \ri = 0;
+        \ris_blank = 1;
+        \r\rwhile (line[i] != '\0')
+          \r {
+          \rif (line[i] != ' ' && line[i] != '\t' && line[i] != '\n'
+               && line[i] != '\r')
+            \r {
+            \ris_blank = 0;
+            \rbreak;
+            \r}
+          \r\ri++;
+          \r}
+        \r\rif (!is_blank)
+          \r {
+          \rl = strdup(line);
+          \r\rl[strlen(l) - 1] = '\0';
+          \r\r(runner->builtin)[n++] = l;
+          \r\r}
+        \r}
+      \r\r}
+    \r
+    else
+      \r {
+      \rWARN0("The file `(builtin.def)' is empty");
+      \rfree(runner->builtin);
+      \rrunner->builtin = NULL;
+      \r}
+    \r\r\rfclose(s);
+    \r\rif (line)
+      \rfree(line);
+    \r\r}
+  \r\r
+#else   /* \r */
+      runner->builtin = xbt_new0(char *, __BUILTIN_MAX + 1);    /* (char**) calloc(__BUILTIN_MAX + 1, sizeof(char*)); */
+  \r\rfor (i = 0; i < __BUILTIN_MAX; i++)
+    \rrunner->builtin[i] = strdup(builtin[i]);
+  \r
+#endif  /* \r */
+#endif  /* \r */
+      \rreturn exit_code ? -1 : 0;
+\r}
+
+\r\rvoid \r runner_destroy(void) \r
+{
+  \rint i;
+  \r\rif (runner->units)
+    \runits_free((void **) (&(runner->units)));
+  \r\rif (runner->variables)
+    \rxbt_dynar_free(&runner->variables);
+  \r\r
+#ifdef _XBT_WIN32\r
+      CloseHandle(timer_handle);
+  \r
+#endif  /* \r */
+      \rif (runner->thread)
+    \rxbt_os_thread_join(runner->thread, NULL);
+  \r\rif (runner->path)
+    \r {
+    \rfor (i = 0; runner->path[i] != NULL; i++)
+      \rfree(runner->path[i]);
+    \r\rfree(runner->path);
+    \r}
+  \r\rif (runner->builtin)
+    \r {
+    \rfor (i = 0; runner->builtin[i] != NULL; i++)
+      \rfree(runner->builtin[i]);
+    \r\rfree(runner->builtin);
+    \r}
+  \r\rfree(runner);
+  \r\r\rrunner = NULL;
+\r}
+
+\r\rvoid \r runner_run(void) \r
+{
+  \r
+      /* allocate the mutex used by the units to asynchronously access \r
+       * to the properties of the runner.\r
+       */ \r
+      xbt_os_mutex_t mutex = xbt_os_mutex_init();
+  \r\r
+      /* run all the units */ \r
+      units_run_all(runner->units, mutex);
+  \r\r\rif (!interrupted)
+    \rrunner_wait();
+  \r\r\r
+      /* if the runner is timeouted or receive a interruption request\r
+       * , interrupt all the active units.\r
+       */ \r
+      if (runner->timeouted || interrupted)
+    \rrunner_interrupt();
+  \r\r
+      /* joins all the units */ \r
+      units_join_all(runner->units);
+  \r\r
+      /* release the mutex resource */ \r
+      xbt_os_mutex_destroy(mutex);
+\r\r}
+
+\r\rstatic void \r runner_wait(void) \r
+{
+  \rif (runner->timeout > 0)
+    \rrunner->thread = xbt_os_thread_create("", runner_start_routine, NULL);
+  \r\r
+      /* signal that the runner is waiting */ \r
+      runner->waiting = 1;
+  \r\r
+      /* wait for the end of all the units */ \r
+      xbt_os_sem_acquire(units_sem);
+  \r\r\rrunner->waiting = 0;
+\r}
+
+\r\r\r\r
 /*\r
  * interrupt all the active units.\r
  * this function is called when the lead time of the execution is reached\r
  * or when a failed unit requests an interruption of the execution.\r
- */\r
-void\r
-runner_interrupt(void)\r
-{\r
-       units_interrupt_all(runner->units);\r
-}\r
-\r
-void\r
-runner_summarize(void)\r
-{\r
-       \r
-       if(!dry_run_flag)\r
-       {\r
-               #ifndef _XBT_WIN32\r
-               struct rusage r_usage;\r
-               #else\r
-               FILETIME start_time;\r
-               FILETIME exit_time;\r
-               FILETIME kernel_time;\r
-               FILETIME user_time;\r
-               SYSTEMTIME si;\r
-               #endif\r
-               \r
-               printf("\n  TEst SHell utility - mini shell specialized in running test units.\n");\r
-               printf(" =============================================================================\n");\r
-               \r
-               units_summuarize(runner->units);\r
-               \r
-               printf(" =====================================================================%s\n",\r
-               runner->total_of_failed_tests ? "== FAILED": (runner->total_of_interrupted_tests || runner->total_of_interrupted_units) ? "==== INTR" : "====== OK");\r
-               \r
-               printf(" TOTAL : Suite(s): %.0f%% ok (%d suite(s): %d ok",\r
-               (runner->total_of_suites ? (1-((double)runner->total_of_failed_suites + (double)runner->total_of_interrupted_suites)/(double)runner->total_of_suites)*100.0 : 100.0),\r
-               runner->total_of_suites, runner->total_of_successeded_suites);\r
-               \r
-               if(runner->total_of_failed_suites > 0)\r
-                       printf(", %d failed", runner->total_of_failed_suites);\r
-               \r
-               if(runner->total_of_interrupted_suites > 0)\r
-                       printf(", %d interrupted)", runner->total_of_interrupted_suites);\r
-               \r
-               printf(")\n");  \r
-               \r
-               printf("         Unit(s):  %.0f%% ok (%d unit(s): %d ok",\r
-               (runner->total_of_units ? (1-((double)runner->total_of_failed_units + (double)runner->total_of_interrupted_units)/(double)runner->total_of_units)*100.0 : 100.0),\r
-               runner->total_of_units, runner->total_of_successeded_units);\r
-               \r
-               if(runner->total_of_failed_units > 0)\r
-                       printf(", %d failed", runner->total_of_failed_units);\r
-               \r
-               if(runner->total_of_interrupted_units > 0)\r
-                       printf(", %d interrupted)", runner->total_of_interrupted_units);\r
-               \r
-               printf(")\n");\r
-               \r
-               printf("         Test(s):  %.0f%% ok (%d test(s): %d ok",\r
-               (runner->total_of_tests ? (1-((double)runner->total_of_failed_tests + (double)runner->total_of_interrupted_tests)/(double)runner->total_of_tests)*100.0 : 100.0),\r
-               runner->total_of_tests, runner->total_of_successeded_tests);\r
-               \r
-               if(runner->total_of_failed_tests > 0)\r
-                       printf(", %d failed", runner->total_of_failed_tests);\r
-               \r
-               if(runner->total_of_interrupted_tests > 0)\r
-                       printf(", %d interrupted)", runner->total_of_interrupted_tests);\r
-               \r
-               printf(")\n\n");\r
-               \r
-               #ifndef _XBT_WIN32\r
-               if(!getrusage(RUSAGE_SELF, &r_usage))\r
-               {\r
-               \r
-                       printf("         Total tesh user time used:       %ld second(s) %ld microsecond(s)\n", r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec);\r
-                       printf("         Total tesh system time used:     %ld second(s) %ld microsecond(s)\n\n", r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);\r
-               \r
-                       if(!getrusage(RUSAGE_CHILDREN, &r_usage))\r
-                       {\r
-                               printf("         Total children user time used:   %ld second(s) %ld microsecond(s)\n", r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec);\r
-                               printf("         Total children system time used: %ld second(s) %ld microsecond(s)\n\n", r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);\r
-               \r
-                       }       \r
-               }\r
-               #else\r
-       \r
-               if(GetProcessTimes(GetCurrentProcess(), &start_time, &exit_time, &kernel_time, &user_time))\r
-               {\r
-                       FileTimeToSystemTime(&user_time, &si);\r
-                       \r
-                       printf(" User time used:   %2u Hour(s) %2u Minute(s) %2u Second(s) %3u Millisecond(s)\n", si.wHour, si.wMinute, si.wSecond, si.wMilliseconds );\r
-                       \r
-                       FileTimeToSystemTime(&kernel_time, &si);\r
-                       \r
-                       printf(" Kernel time used: %2u Hour(s) %2u Minute(s) %2u Second(s) %3u Millisecond(s)\n", si.wHour, si.wMinute, si.wSecond, si.wMilliseconds );\r
-               }\r
-\r
-\r
-\r
-               #endif\r
-       }\r
-       else\r
-       {\r
-               if(exit_code)\r
-                       ERROR0("Syntax NOK");\r
-               else if(!exit_code)\r
-                       INFO0("Syntax 0K");\r
-       }\r
-}\r
-\r
-int\r
-runner_is_timedout(void)\r
-{\r
-       return runner->timeouted;\r
-}\r
-\r
+ */ \r
+void \r runner_interrupt(void) \r
+{
+  \runits_interrupt_all(runner->units);
+\r\r\rvoid \r runner_summarize(void) \r
+{
+  \r\rif (!dry_run_flag)
+    \r {
+    \r
+#ifndef _XBT_WIN32\r
+    struct rusage r_usage;
+    \r
+#else   /* \r */
+        FILETIME start_time;
+    \rFILETIME exit_time;
+    \rFILETIME kernel_time;
+    \rFILETIME user_time;
+    \rSYSTEMTIME si;
+    \r
+#endif  /* \r */
+        \rprintf
+        ("\n  TEst SHell utility - mini shell specialized in running test units.\n");
+    \rprintf
+        (" =============================================================================\n");
+    \r\runits_summuarize(runner->units);
+    \r\rprintf
+        (" =====================================================================%s\n",
+         \rrunner->total_of_failed_tests ? "== FAILED" : (runner->
+                                                         total_of_interrupted_tests
+                                                         || runner->
+                                                         total_of_interrupted_units)
+         ? "==== INTR" : "====== OK");
+    \r\rprintf(" TOTAL : Suite(s): %.0f%% ok (%d suite(s): %d ok",
+             \r(runner->
+               total_of_suites ? (1 -
+                                  ((double) runner->
+                                   total_of_failed_suites +
+                                   (double) runner->
+                                   total_of_interrupted_suites) /
+                                  (double) runner->total_of_suites) *
+               100.0 : 100.0), \rrunner->total_of_suites,
+             runner->total_of_successeded_suites);
+    \r\rif (runner->total_of_failed_suites > 0)
+      \rprintf(", %d failed", runner->total_of_failed_suites);
+    \r\rif (runner->total_of_interrupted_suites > 0)
+      \rprintf(", %d interrupted)", runner->total_of_interrupted_suites);
+    \r\rprintf(")\n");
+    \r\rprintf("         Unit(s):  %.0f%% ok (%d unit(s): %d ok", \r
+             (runner->
+              total_of_units ? (1 -
+                                ((double) runner->total_of_failed_units +
+                                 (double) runner->
+                                 total_of_interrupted_units) /
+                                (double) runner->total_of_units) *
+              100.0 : 100.0), \rrunner->total_of_units,
+             runner->total_of_successeded_units);
+    \r\rif (runner->total_of_failed_units > 0)
+      \rprintf(", %d failed", runner->total_of_failed_units);
+    \r\rif (runner->total_of_interrupted_units > 0)
+      \rprintf(", %d interrupted)", runner->total_of_interrupted_units);
+    \r\rprintf(")\n");
+    \r\rprintf("         Test(s):  %.0f%% ok (%d test(s): %d ok", \r
+             (runner->
+              total_of_tests ? (1 -
+                                ((double) runner->total_of_failed_tests +
+                                 (double) runner->
+                                 total_of_interrupted_tests) /
+                                (double) runner->total_of_tests) *
+              100.0 : 100.0), \rrunner->total_of_tests,
+             runner->total_of_successeded_tests);
+    \r\rif (runner->total_of_failed_tests > 0)
+      \rprintf(", %d failed", runner->total_of_failed_tests);
+    \r\rif (runner->total_of_interrupted_tests > 0)
+      \rprintf(", %d interrupted)", runner->total_of_interrupted_tests);
+    \r\rprintf(")\n\n");
+    \r\r
+#ifndef _XBT_WIN32\r
+        if (!getrusage(RUSAGE_SELF, &r_usage))
+      \r {
+      \r\rprintf
+          ("         Total tesh user time used:       %ld second(s) %ld microsecond(s)\n",
+           r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec);
+      \rprintf
+          ("         Total tesh system time used:     %ld second(s) %ld microsecond(s)\n\n",
+           r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);
+      \r\rif (!getrusage(RUSAGE_CHILDREN, &r_usage))
+        \r {
+        \rprintf
+            ("         Total children user time used:   %ld second(s) %ld microsecond(s)\n",
+             r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec);
+        \rprintf
+            ("         Total children system time used: %ld second(s) %ld microsecond(s)\n\n",
+             r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);
+        \r\r}
+      \r}
+    \r
+#else   /* \r */
+        \rif (GetProcessTimes
+             (GetCurrentProcess(), &start_time, &exit_time, &kernel_time,
+              &user_time))
+      \r {
+      \rFileTimeToSystemTime(&user_time, &si);
+      \r\rprintf
+          (" User time used:   %2u Hour(s) %2u Minute(s) %2u Second(s) %3u Millisecond(s)\n",
+           si.wHour, si.wMinute, si.wSecond, si.wMilliseconds);
+      \r\rFileTimeToSystemTime(&kernel_time, &si);
+      \r\rprintf
+          (" Kernel time used: %2u Hour(s) %2u Minute(s) %2u Second(s) %3u Millisecond(s)\n",
+           si.wHour, si.wMinute, si.wSecond, si.wMilliseconds);
+      \r}
+    \r\r\r\r
+#endif  /* \r */
+    }
+  \r
+  else
+    \r {
+    \rif (exit_code)
+      \rERROR0("Syntax NOK");
+    \r
+    else if (!exit_code)
+      \rINFO0("Syntax 0K");
+    \r}
+\r}
+
+\r\rint \r runner_is_timedout(void) \r
+{
+  \rreturn runner->timeouted;
+\r}
+
+\r\r
index df147e4..976d93c 100644 (file)
 #include <stdlib.h>\r
 \r
 #include <stdio.h>\r
-\r
-int\r
-str_replace(char** str, const char* what, const char* with, const char* delimiters)\r
-{\r
-       size_t pos, i, len;\r
-       char* begin = NULL;\r
-       char* buf;\r
-       int size;\r
-\r
-       if(!*str || !what)\r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-\r
-       if(delimiters)\r
-       {\r
-               char* delimited;\r
-\r
-               if(!(delimited = (char*) calloc((strlen(what) + 2) , sizeof(char))))\r
-                       return -1;\r
-\r
-               len = strlen(delimiters);\r
-\r
-               for(i = 0; i < len; i++)\r
-               {\r
-                       memset(delimited, 0, (strlen(what) + 2));\r
-\r
-                       sprintf(delimited,"%s%c", what, delimiters[i]);\r
-\r
-                       if((begin = strstr(*str, delimited)))\r
-                               break;\r
-               }\r
-\r
-               free(delimited);\r
-       }\r
-       else\r
-               begin = strstr(*str, what);\r
-\r
-\r
-       if(!begin && (size = (int)strlen(*str) - (int)strlen(what)) >= 0 && !strcmp(*str + size, what))\r
-               begin = strstr(*str, what);\r
-\r
-       if(!begin)\r
-       {\r
-               errno = ESRCH;\r
-               return -1;\r
-       }\r
-\r
-       pos = begin - *str;\r
-\r
-       i = 0;\r
-\r
-       pos += strlen(what);\r
-\r
-       if(begin == *str)\r
-       {\r
-               if(!(buf = (char*) calloc((with ? strlen(with) : 0) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
-                       return -1;\r
-\r
-               if(with)\r
-                       strcpy(buf, with);\r
-\r
-               if(pos < strlen(*str))\r
-                       strcpy(buf + (with ? strlen(with) : 0), *str + pos);\r
-       }\r
-       else\r
-       {\r
-               if(!(buf = (char*) calloc((begin - *str) + (with ? strlen(with) : 0) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
-                       return -1;\r
-\r
-               strncpy(buf, *str,  (begin - *str));\r
-\r
-               if(with)\r
-                       strcpy(buf + (begin - *str) , with);\r
-\r
-               if(pos < strlen(*str))\r
-                       strcpy(buf + (begin - *str) + (with ? strlen(with) : 0), *str + pos);\r
-       }\r
-\r
-       free(*str);\r
-\r
-       *str = buf;\r
-\r
-       return 0;\r
-\r
-}\r
-\r
-int\r
-str_replace_all(char** str, const char* what, const char* with, const char* delimiters)\r
-{\r
-       int rv;\r
-\r
-       while(!(rv = str_replace(str, what, with, delimiters)));\r
-\r
-       return (errno == ESRCH) ? 0 : -1;\r
-}\r
-\r
-\r
-\r
-\r
-\r
+\rint \r
+str_replace(char **str, const char *what, const char *with,
+            const char *delimiters) \r
+{
+  \rsize_t pos, i, len;
+  \rchar *begin = NULL;
+  \rchar *buf;
+  \rint size;
+  \r\rif (!*str || !what)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rif (delimiters)
+    \r {
+    \rchar *delimited;
+    \r\rif (!(delimited = (char *) calloc((strlen(what) + 2), sizeof(char))))
+      \rreturn -1;
+    \r\rlen = strlen(delimiters);
+    \r\rfor (i = 0; i < len; i++)
+      \r {
+      \rmemset(delimited, 0, (strlen(what) + 2));
+      \r\rsprintf(delimited, "%s%c", what, delimiters[i]);
+      \r\rif ((begin = strstr(*str, delimited)))
+        \rbreak;
+      \r}
+    \r\rfree(delimited);
+    \r}
+  \r
+  else
+    \rbegin = strstr(*str, what);
+  \r\r\rif (!begin && (size = (int) strlen(*str) - (int) strlen(what)) >= 0
+         && !strcmp(*str + size, what))
+    \rbegin = strstr(*str, what);
+  \r\rif (!begin)
+    \r {
+    \rerrno = ESRCH;
+    \rreturn -1;
+    \r}
+  \r\rpos = begin - *str;
+  \r\ri = 0;
+  \r\rpos += strlen(what);
+  \r\rif (begin == *str)
+    \r {
+    \rif (!
+         (buf =
+          (char *) calloc((with ? strlen(with) : 0) +
+                          ((pos <
+                            strlen(*str)) ? strlen(*str + pos) : 0) + 1,
+                          sizeof(char))))
+      \rreturn -1;
+    \r\rif (with)
+      \rstrcpy(buf, with);
+    \r\rif (pos < strlen(*str))
+      \rstrcpy(buf + (with ? strlen(with) : 0), *str + pos);
+    \r}
+  \r
+  else
+    \r {
+    \rif (!
+         (buf =
+          (char *) calloc((begin - *str) + (with ? strlen(with) : 0) +
+                          ((pos <
+                            strlen(*str)) ? strlen(*str + pos) : 0) + 1,
+                          sizeof(char))))
+      \rreturn -1;
+    \r\rstrncpy(buf, *str, (begin - *str));
+    \r\rif (with)
+      \rstrcpy(buf + (begin - *str), with);
+    \r\rif (pos < strlen(*str))
+      \rstrcpy(buf + (begin - *str) + (with ? strlen(with) : 0),
+              *str + pos);
+    \r}
+  \r\rfree(*str);
+  \r\r*str = buf;
+  \r\rreturn 0;
+\r\r}
+
+\r\rint \r
+str_replace_all(char **str, const char *what, const char *with,
+                const char *delimiters) \r
+{
+  \rint rv;
+  \r\rwhile (!(rv = str_replace(str, what, with, delimiters)));
+  \r\rreturn (errno == ESRCH) ? 0 : -1;
+\r}
+
+\r\r\r\r\r\r
index 44a6c32..550f8ae 100644 (file)
  *             This file contains all the definitions of the functions related with\r
  *             the tesh timer type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #include <timer.h>\r
 #include <command.h>\r
 #include <unit.h>\r
-\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-static void*\r
-timer_start_routine(void* p);\r
-\r
-ttimer_t\r
-timer_new(command_t command)\r
-{\r
-       ttimer_t timer;\r
-       \r
-       timer = xbt_new0(s_timer_t, 1);\r
-       \r
-       timer->command = command;\r
-       timer->thread = NULL;\r
-       timer->timeouted = 0;\r
-       timer->started = xbt_os_sem_init(0);\r
-\r
-       return timer;\r
-}\r
-\r
-int\r
-timer_free(ttimer_t* ptr)\r
-{\r
-       if((*ptr)->started)\r
-               xbt_os_sem_destroy((*ptr)->started);\r
-\r
-       free(*ptr);\r
-\r
-       *ptr = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
-void\r
-timer_time(ttimer_t timer)\r
-{\r
-       timer->thread = xbt_os_thread_create("", timer_start_routine, timer);\r
-}\r
-\r
-static void*\r
-timer_start_routine(void* p)\r
-{\r
-       ttimer_t timer = (ttimer_t)p;\r
-       command_t command = timer->command;\r
-       \r
-       int now = (int)time(NULL);\r
-       int lead_time = now + command->context->timeout;\r
-       \r
-       xbt_os_sem_release(timer->started);\r
-       \r
-       while(!command->failed && !command->interrupted && !command->successeded && !timer->timeouted) \r
-       {\r
-               if(lead_time >= now)\r
-               {\r
-                       xbt_os_thread_yield();\r
-                       now = (int)time(NULL);\r
-               }\r
-               else\r
-               {\r
-                       timer->timeouted = 1;\r
-               }\r
-       }\r
-\r
-       if(timer->timeouted && !command->failed && !command->successeded  && !command->interrupted)\r
-       {\r
-               ERROR3("[%s] `%s' timed out after %d sec", command->context->pos, command->context->command_line, command->context->timeout);\r
-\r
-\r
-               unit_set_error(command->unit, ECMDTIMEDOUT, 1, command->context->pos);\r
-\r
-               command_kill(command);\r
-               command_handle_failure(command, csr_timeout);\r
-\r
-               while(!command->reader->done)\r
-                       xbt_os_thread_yield();\r
-\r
-               if(command->output->used)\r
-                       INFO2("[%s] Output on timeout:\n%s",command->context->pos, command->output->data);\r
-               else\r
-                       INFO1("[%s] No output before timeout",command->context->pos);\r
-       }\r
-       \r
-       return NULL;\r
-}\r
-\r
-void\r
-timer_wait(ttimer_t timer)\r
-{\r
-       xbt_os_thread_join(timer->thread, NULL);\r
-}\r
+    \r\rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rstatic void *\r timer_start_routine(void *p);
+\r\rttimer_t \r timer_new(command_t command) \r
+{
+  \rttimer_t timer;
+  \r\rtimer = xbt_new0(s_timer_t, 1);
+  \r\rtimer->command = command;
+  \rtimer->thread = NULL;
+  \rtimer->timeouted = 0;
+  \rtimer->started = xbt_os_sem_init(0);
+  \r\rreturn timer;
+\r}
+
+\r\rint \r timer_free(ttimer_t * ptr) \r
+{
+  \rif ((*ptr)->started)
+    \rxbt_os_sem_destroy((*ptr)->started);
+  \r\rfree(*ptr);
+  \r\r*ptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rvoid \r timer_time(ttimer_t timer) \r
+{
+  \rtimer->thread = xbt_os_thread_create("", timer_start_routine, timer);
+\r\r\rstatic void *\r timer_start_routine(void *p) \r
+{
+  \rttimer_t timer = (ttimer_t) p;
+  \rcommand_t command = timer->command;
+  \r\rint now = (int) time(NULL);
+  \rint lead_time = now + command->context->timeout;
+  \r\rxbt_os_sem_release(timer->started);
+  \r\rwhile (!command->failed && !command->interrupted
+           && !command->successeded && !timer->timeouted)
+    \r {
+    \rif (lead_time >= now)
+      \r {
+      \rxbt_os_thread_yield();
+      \rnow = (int) time(NULL);
+      \r}
+    \r
+    else
+      \r {
+      \rtimer->timeouted = 1;
+      \r}
+    \r}
+  \r\rif (timer->timeouted && !command->failed && !command->successeded
+        && !command->interrupted)
+    \r {
+    \rERROR3("[%s] `%s' timed out after %d sec", command->context->pos,
+            command->context->command_line, command->context->timeout);
+    \r\r\runit_set_error(command->unit, ECMDTIMEDOUT, 1,
+                      command->context->pos);
+    \r\rcommand_kill(command);
+    \rcommand_handle_failure(command, csr_timeout);
+    \r\rwhile (!command->reader->done)
+      \rxbt_os_thread_yield();
+    \r\rif (command->output->used)
+      \rINFO2("[%s] Output on timeout:\n%s", command->context->pos,
+             command->output->data);
+    \r
+    else
+      \rINFO1("[%s] No output before timeout", command->context->pos);
+    \r}
+  \r\rreturn NULL;
+\r}
+
+\r\rvoid \r timer_wait(ttimer_t timer) \r
+{
+  \rxbt_os_thread_join(timer->thread, NULL);
+\r\r
index afadd9b..566c6e4 100644 (file)
@@ -10,8 +10,8 @@
  *             This file contains all the definitions of the functions related with\r
  *             the tesh unit concept.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #include <unit.h>\r
 #include <command.h>\r
 #include <context.h>\r
 #include <variable.h>\r
 #include <str_replace.h>\r
 #include <xerrno.h>\r
-\r
-\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
+    \r\r\rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\r
 /*! \brief unit_start - start the processing of the tesh file representing by the unit\r
  *\r
  * \param p            A void pointer to the unit representing the tesh file to process.\r
@@ -47,899 +44,817 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
  *     6) Its release the next waiting unit (if any) by releasing the jobs semaphore.\r
  *     7) If its the last unit, it release the runner by releasing the semaphore used to wait for the end of all the units.\r
  *         \r
- */\r
-static void*\r
-unit_start(void* p) \r
-{\r
-       xbt_os_thread_t thread;\r
-       xbt_os_mutex_t mutex;\r
-       unit_t include, suite;\r
-       unsigned int itc, itu, its;\r
-       int include_nb, suite_nb;\r
-       command_t command;\r
-       \r
-       unit_t root = (unit_t)p;\r
-       \r
-       /* increment the number of running units */\r
-       xbt_os_mutex_acquire(root->mutex);\r
-       root->runner->number_of_runned_units++;\r
-       xbt_os_mutex_release(root->mutex);\r
-\r
-       /* must acquire the jobs semaphore to start */\r
-       /*xbt_os_sem_acquire(jobs_sem);*/\r
-       \r
-       /* initialize the mutex used to synchronize the access to the properties of this unit */\r
-       mutex = xbt_os_mutex_init();\r
-       \r
-       if(!dry_run_flag)\r
-               INFO1("Test unit from %s",root->fstream->name);\r
-       else\r
-               INFO1("Checking unit %s...",root->fstream->name); \r
-       \r
-       /* launch the parsing of the unit */\r
-       fstream_parse(root->fstream, mutex);\r
-       \r
-       /* if the unit is not interrupted and not failed the unit, all the file is parsed\r
-        * so all the command are launched\r
-        */\r
-       if(!root->interrupted)\r
-       {\r
-               root->parsed = 1;\r
-               \r
-               /* all the commands have terminated before the end of the parsing of the tesh file\r
-                * so the unit release the semaphore itself\r
-                */\r
-               if(!root->released && (root->started_cmd_nb == (root->failed_cmd_nb + root->interrupted_cmd_nb + root->successeded_cmd_nb)))\r
-                       xbt_os_sem_release(root->sem);  \r
-       }\r
-       \r
-       /* wait the end of all the commands or a command failure or an interruption */\r
-\r
-       xbt_os_sem_acquire(root->sem);\r
-       \r
-\r
-       if(root->interrupted)\r
-       {\r
-\r
-               xbt_dynar_foreach(root->commands, itc , command)\r
-               {\r
-                       if(command->status == cs_in_progress)\r
-                               command_interrupt(command);\r
-               }\r
-\r
-               /* interrupt all the running commands of the included units */\r
-               include_nb = xbt_dynar_length(root->includes);\r
-               \r
-               xbt_dynar_foreach(root->includes, itu, include)\r
-               {\r
-                       xbt_dynar_foreach(include->commands, itc, command)\r
-                       {\r
-                               if(command->status == cs_in_progress)\r
-                                       command_interrupt(command);\r
-                       }\r
-               }\r
-               \r
-               /* interrupt all the running commands of the unit */\r
-               suite_nb = xbt_dynar_length(root->suites);\r
-               \r
-               xbt_dynar_foreach(root->suites, its, suite)\r
-               {\r
-                       include_nb = xbt_dynar_length(suite->includes);\r
-\r
-                       xbt_dynar_foreach(suite->includes, itu, include)\r
-                       {\r
-                               xbt_dynar_foreach(include->commands, itc, command)\r
-                               {\r
-                                       if(command->status == cs_in_progress)\r
-                                               command_interrupt(command);\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       /* wait the end of the command threads of the unit */\r
-       xbt_dynar_foreach(root->commands, itc, command)\r
-       {\r
-               thread = command->thread;\r
-               \r
-               if(thread)\r
-                       xbt_os_thread_join(thread,NULL);\r
-       }\r
-       \r
-       /* wait the end of the command threads of the included units of the unit */\r
-       include_nb = xbt_dynar_length(root->includes);\r
-        \r
-       xbt_dynar_foreach(root->includes, itu, include)\r
-       {\r
-               xbt_dynar_foreach(include->commands, itc, command)\r
-               {\r
-                       thread = command->thread;\r
-               \r
-                       if(thread)\r
-                               xbt_os_thread_join(thread,NULL);\r
-               }\r
-\r
-               if(!dry_run_flag)\r
-               {\r
-                       if(!include->exit_code && !include->interrupted)\r
-                               INFO1("Include from %s OK",include->fstream->name);\r
-                       else if(include->exit_code)\r
-                               ERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name, include->err_line, error_to_string(include->exit_code, include->err_kind));\r
-                       else if(include->interrupted && !include->exit_code)\r
-                               INFO1("Include `(%s)' INTR",include->fstream->name);\r
-               }\r
-       }\r
-       \r
-       /* interrupt all the running commands of the unit */\r
-       suite_nb = xbt_dynar_length(root->suites);\r
-       \r
-       xbt_dynar_foreach(root->suites, its, suite)\r
-       {\r
-               include_nb = xbt_dynar_length(suite->includes);\r
-\r
-               if(!include_nb)\r
-               {\r
-                       if(!suite->exit_code)\r
-                       {\r
-                               unit_set_error(suite, ESYNTAX, 1, suite->filepos);\r
-                               ERROR2("[%s] Empty suite `(%s)' detected (no includes added)", suite->filepos, suite->description);\r
-\r
-                               /* if the --keep-going option is not specified */\r
-                               if(!keep_going_flag)\r
-                               {\r
-                                       if(!interrupted)\r
-                                       {\r
-                                               /* request an global interruption by the runner */\r
-                                               interrupted = 1;\r
-\r
-                                               /* release the runner */\r
-                                               xbt_os_sem_release(units_sem);\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               xbt_dynar_foreach(suite->includes, itu, include)\r
-               {\r
-                       xbt_dynar_foreach(include->commands, itc, command)\r
-                       {\r
-                               thread = command->thread;\r
-               \r
-                               if(thread)\r
-                                       xbt_os_thread_join(thread,NULL);\r
-                       }\r
-                       \r
-                       if(!include->exit_code && !include->interrupted)\r
-                       {\r
-                               if(!dry_run_flag)\r
-                                       INFO1("Include from %s OK",include->fstream->name);\r
-                       }\r
-                       else if(include->exit_code)\r
-                       {\r
-                               if(!dry_run_flag)\r
-                                       ERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name, command->context->pos, error_to_string(include->exit_code, include->err_kind));\r
-\r
-                               suite->exit_code = include->exit_code;\r
-                               suite->err_kind = include->err_kind;\r
-                               suite->err_line = strdup(include->err_line);\r
-                       }\r
-                       else if(include->interrupted && !include->exit_code)\r
-                       {\r
-                               if(!dry_run_flag)\r
-                                       INFO1("Include `(%s)' INTR",include->fstream->name);\r
-\r
-                               suite->interrupted = 1;\r
-                       }\r
-                       \r
-               }\r
-               \r
-               if(!dry_run_flag )\r
-               {\r
-                       if(!suite->exit_code && !suite->interrupted)\r
-                               INFO1("Test suite from %s OK",suite->description);\r
-                       else if(suite->exit_code)\r
-                               ERROR3("Test suite `%s' NOK : (<%s> %s) ", suite->description, suite->err_line, error_to_string(suite->exit_code, suite->err_kind));\r
-                       else if(suite->interrupted && !suite->exit_code)\r
-                               INFO1("Test suite `(%s)' INTR",suite->description);\r
-               }\r
-       }\r
-       \r
-       /* you can now destroy the mutex used to synchrone the command accesses to the properties of the unit */\r
-       xbt_os_mutex_destroy(mutex);\r
-\r
-       /* update the number of ended units of the runner */\r
-       xbt_os_mutex_acquire(root->mutex);\r
-       \r
-       /* increment the number of ended units */\r
-       root->runner->number_of_ended_units++;\r
-       \r
-       if(!dry_run_flag )\r
-       {\r
-               if(root->interrupted && !root->exit_code)\r
-                       INFO1("Test unit from %s INTR",root->fstream->name);\r
-               else if(!root->exit_code)\r
-                               INFO1("Test unit from %s OK",root->fstream->name);\r
-               else if(root->exit_code)\r
-                       ERROR3("Test unit `%s': NOK (<%s> %s)",root->fstream->name, root->err_line, error_to_string(root->exit_code, root->err_kind));  \r
-       }\r
-       \r
-       /* if it's the last unit, release the runner */\r
-       if((root->runner->number_of_runned_units == root->runner->number_of_ended_units))\r
-       {\r
-               /* if all the commands of the unit are successeded itc's a successeded unit */\r
-               if(root->successeded_cmd_nb == root->cmd_nb && !root->exit_code /* case of only one cd : nb = successeded = 0)*/)\r
-                       root->successeded = 1; \r
-                       \r
-               /* first release the mutex */\r
-               xbt_os_mutex_release(root->mutex);\r
-               \r
-               /* release the runner */\r
-               xbt_os_sem_release(units_sem);\r
-       }\r
-       else\r
-               xbt_os_mutex_release(root->mutex);\r
-       \r
-       /* release the jobs semaphore, then the next waiting unit can start */\r
-       xbt_os_sem_release(jobs_sem);\r
-       \r
-       return NULL;\r
-\r
-}\r
-\r
-\r
-unit_t\r
-unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream)\r
-{\r
-       unit_t unit;\r
-       \r
-       unit = xbt_new0(s_unit_t, 1);\r
-       \r
-       /* instantiate the vector used to store all the commands of the unit */\r
-       unit->commands = xbt_dynar_new(sizeof(command_t), (void_f_pvoid_t)command_free);\r
-       \r
-       /* instantiate the vector used to store all the included units */\r
-       unit->includes = xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t)unit_free);\r
-       \r
-       /* instantiate the vector used to store all the included suites */\r
-       unit->suites = xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t)unit_free);\r
-       \r
-       /* the runner used to launch the tesh unit */\r
-       unit->runner = runner;\r
-       \r
-       /* the file stream object to use to parse the tesh file */\r
-       unit->fstream = fstream;\r
-       \r
-       if(fstream)\r
-               fstream->unit = unit;\r
-       \r
-       /* if no root parameter specified assume that itc's the root of all the units */\r
-       unit->root = root ?  root : unit;\r
-       \r
-       /* the owner of the suite */\r
-       unit->owner = owner;\r
-       \r
-       unit->thread = NULL;\r
-       unit->started_cmd_nb = 0;\r
-       unit->interrupted_cmd_nb = 0;\r
-       unit->failed_cmd_nb = 0;\r
-       unit->successeded_cmd_nb = 0;\r
-       unit->terminated_cmd_nb = 0;\r
-       unit->waiting_cmd_nb = 0;\r
-       unit->interrupted = 0;\r
-       unit->failed = 0;\r
-       unit->successeded = 0;\r
-       unit->parsed = 0;\r
-       unit->released = 0;\r
-       unit->owner = owner;\r
-       unit->is_running_suite = 0;\r
-       unit->description = NULL;\r
-       unit->sem = NULL;\r
-       unit->exit_code = 0;\r
-       unit->err_kind = 0;\r
-       unit->err_line = NULL;\r
-       unit->filepos = NULL;\r
-       \r
-       \r
-\r
-       return unit;\r
-}\r
-\r
-void\r
-unit_set_error(unit_t unit, int errcode, int kind, const char* line)\r
-{\r
-       if(!unit->exit_code)\r
-       {\r
-               unit->exit_code = errcode;\r
-               unit->err_kind = kind;\r
-               unit->err_line = strdup(line);\r
-\r
-               if(unit->root && !unit->root->exit_code)\r
-               {\r
-                       unit->root->exit_code = errcode;\r
-                       unit->root->err_kind = kind;\r
-                       unit->root->err_line = strdup(line);\r
-               }\r
-               \r
-               if(!exit_code)\r
-               {\r
-               \r
-                       exit_code = errcode;\r
-                       err_kind = kind;\r
-                       err_line = strdup(line);\r
-               }\r
-       }\r
-       \r
-}\r
-\r
-int\r
-unit_free(unit_t* ptr)\r
-{\r
-       if(!(*ptr))\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
-       \r
-       if((*ptr)->commands)\r
-               xbt_dynar_free(&((*ptr)->commands));\r
-       \r
-       if((*ptr)->includes)\r
-               xbt_dynar_free(&((*ptr)->includes));\r
-       \r
-       if((*ptr)->suites)\r
-               xbt_dynar_free(&((*ptr)->suites));\r
-       \r
-       /* if the unit is interrupted during its run, the semaphore is NULL */\r
-       if((*ptr)->sem)\r
-               xbt_os_sem_destroy((*ptr)->sem);\r
-               \r
-       if((*ptr)->description)\r
-               free((*ptr)->description);\r
-\r
-       if((*ptr)->err_line)\r
-               free((*ptr)->err_line);\r
-\r
-       if((*ptr)->filepos)\r
-               free((*ptr)->filepos);\r
-\r
-       free(*ptr);\r
-       *ptr = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-unit_run(unit_t unit, xbt_os_mutex_t mutex)\r
-{\r
-       /* check the parameters */\r
-       if(!(unit) || !mutex)\r
-    {\r
-        errno = EINVAL;\r
-               xbt_os_sem_release(jobs_sem);\r
-        return -1;\r
-               \r
-    }\r
-\r
-       if(!interrupted)\r
-       {\r
-               unit->mutex = mutex;\r
-               \r
-               unit->sem = xbt_os_sem_init(0);\r
-\r
-               /* start the unit */\r
-               unit->thread = xbt_os_thread_create("", unit_start, unit);\r
-       }\r
-       else\r
-       {\r
-               /* the unit is interrupted by the runner before its starting \r
-                * in this case the unit semaphore is NULL take care of that\r
-                * in the function unit_free()\r
-                */\r
-               unit->interrupted = 1;\r
-               xbt_os_sem_release(jobs_sem);\r
-       }\r
-               \r
-       return 0;\r
-       \r
-}\r
-\r
-int\r
-unit_interrupt(unit_t unit)\r
-{\r
-       /* check the parameter */\r
-       if(!(unit))\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
+ */ \r
+static void *\r unit_start(void *p) \r
+{
+  \rxbt_os_thread_t thread;
+  \rxbt_os_mutex_t mutex;
+  \runit_t include, suite;
+  \runsigned int itc, itu, its;
+  \rint include_nb, suite_nb;
+  \rcommand_t command;
+  \r\runit_t root = (unit_t) p;
+  \r\r
+      /* increment the number of running units */ \r
+      xbt_os_mutex_acquire(root->mutex);
+  \rroot->runner->number_of_runned_units++;
+  \rxbt_os_mutex_release(root->mutex);
+  \r\r
+      /* must acquire the jobs semaphore to start */ \r
+      /*xbt_os_sem_acquire(jobs_sem); */ \r
+      \r
+      /* initialize the mutex used to synchronize the access to the properties of this unit */ \r
+      mutex = xbt_os_mutex_init();
+  \r\rif (!dry_run_flag)
+    \rINFO1("Test unit from %s", root->fstream->name);
+  \r
+  else
+    \rINFO1("Checking unit %s...", root->fstream->name);
+  \r\r
+      /* launch the parsing of the unit */ \r
+      fstream_parse(root->fstream, mutex);
+  \r\r
+      /* if the unit is not interrupted and not failed the unit, all the file is parsed\r
+       * so all the command are launched\r
+       */ \r
+      if (!root->interrupted)
+    \r {
+    \rroot->parsed = 1;
+    \r\r
+        /* all the commands have terminated before the end of the parsing of the tesh file\r
+         * so the unit release the semaphore itself\r
+         */ \r
+        if (!root->released
+            && (root->started_cmd_nb ==
+                (root->failed_cmd_nb + root->interrupted_cmd_nb +
+                 root->successeded_cmd_nb)))
+      \rxbt_os_sem_release(root->sem);
+    \r}
+  \r\r
+      /* wait the end of all the commands or a command failure or an interruption */ \r
+      \rxbt_os_sem_acquire(root->sem);
+  \r\r\rif (root->interrupted)
+    \r {
+    \r\rxbt_dynar_foreach(root->commands, itc, command) \r {
+      \rif (command->status == cs_in_progress)
+        \rcommand_interrupt(command);
+    \r}
+    \r\r
+        /* interrupt all the running commands of the included units */ \r
+        include_nb = xbt_dynar_length(root->includes);
+    \r\rxbt_dynar_foreach(root->includes, itu, include) \r {
+      \rxbt_dynar_foreach(include->commands, itc, command) \r {
+        \rif (command->status == cs_in_progress)
+          \rcommand_interrupt(command);
+      \r}
+    \r}
+    \r\r
+        /* interrupt all the running commands of the unit */ \r
+        suite_nb = xbt_dynar_length(root->suites);
+    \r\rxbt_dynar_foreach(root->suites, its, suite) \r {
+      \rinclude_nb = xbt_dynar_length(suite->includes);
+      \r\rxbt_dynar_foreach(suite->includes, itu, include) \r {
+        \rxbt_dynar_foreach(include->commands, itc, command) \r {
+          \rif (command->status == cs_in_progress)
+            \rcommand_interrupt(command);
+        \r}
+      \r}
+    \r}
+    \r}
+  \r\r
+      /* wait the end of the command threads of the unit */ \r
+      xbt_dynar_foreach(root->commands, itc, command) \r {
+    \rthread = command->thread;
+    \r\rif (thread)
+      \rxbt_os_thread_join(thread, NULL);
+  \r}
+  \r\r
+      /* wait the end of the command threads of the included units of the unit */ \r
+      include_nb = xbt_dynar_length(root->includes);
+  \r\rxbt_dynar_foreach(root->includes, itu, include) \r {
+    \rxbt_dynar_foreach(include->commands, itc, command) \r {
+      \rthread = command->thread;
+      \r\rif (thread)
+        \rxbt_os_thread_join(thread, NULL);
+    \r}
+    \r\rif (!dry_run_flag)
+      \r {
+      \rif (!include->exit_code && !include->interrupted)
+        \rINFO1("Include from %s OK", include->fstream->name);
+      \r
+      else if (include->exit_code)
+        \rERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name,
+                include->err_line, error_to_string(include->exit_code,
+                                                   include->err_kind));
+      \r
+      else if (include->interrupted && !include->exit_code)
+        \rINFO1("Include `(%s)' INTR", include->fstream->name);
+      \r}
+  \r}
+  \r\r
+      /* interrupt all the running commands of the unit */ \r
+      suite_nb = xbt_dynar_length(root->suites);
+  \r\rxbt_dynar_foreach(root->suites, its, suite) \r {
+    \rinclude_nb = xbt_dynar_length(suite->includes);
+    \r\rif (!include_nb)
+      \r {
+      \rif (!suite->exit_code)
+        \r {
+        \runit_set_error(suite, ESYNTAX, 1, suite->filepos);
+        \rERROR2("[%s] Empty suite `(%s)' detected (no includes added)",
+                suite->filepos, suite->description);
+        \r\r
+            /* if the --keep-going option is not specified */ \r
+            if (!keep_going_flag)
+          \r {
+          \rif (!interrupted)
+            \r {
+            \r
+                /* request an global interruption by the runner */ \r
+                interrupted = 1;
+            \r\r
+                /* release the runner */ \r
+                xbt_os_sem_release(units_sem);
+            \r}
+          \r}
+        \r}
+      \r}
+    \r\rxbt_dynar_foreach(suite->includes, itu, include) \r {
+      \rxbt_dynar_foreach(include->commands, itc, command) \r {
+        \rthread = command->thread;
+        \r\rif (thread)
+          \rxbt_os_thread_join(thread, NULL);
+      \r}
+      \r\rif (!include->exit_code && !include->interrupted)
+        \r {
+        \rif (!dry_run_flag)
+          \rINFO1("Include from %s OK", include->fstream->name);
+        \r}
+      \r
+      else if (include->exit_code)
+        \r {
+        \rif (!dry_run_flag)
+          \rERROR3("Include `%s' NOK : (<%s> %s)", include->fstream->name,
+                  command->context->pos,
+                  error_to_string(include->exit_code, include->err_kind));
+        \r\rsuite->exit_code = include->exit_code;
+        \rsuite->err_kind = include->err_kind;
+        \rsuite->err_line = strdup(include->err_line);
+        \r}
+      \r
+      else if (include->interrupted && !include->exit_code)
+        \r {
+        \rif (!dry_run_flag)
+          \rINFO1("Include `(%s)' INTR", include->fstream->name);
+        \r\rsuite->interrupted = 1;
+        \r}
+    \r\r}
+    \r\rif (!dry_run_flag)
+      \r {
+      \rif (!suite->exit_code && !suite->interrupted)
+        \rINFO1("Test suite from %s OK", suite->description);
+      \r
+      else if (suite->exit_code)
+        \rERROR3("Test suite `%s' NOK : (<%s> %s) ", suite->description,
+                suite->err_line, error_to_string(suite->exit_code,
+                                                 suite->err_kind));
+      \r
+      else if (suite->interrupted && !suite->exit_code)
+        \rINFO1("Test suite `(%s)' INTR", suite->description);
+      \r}
+  \r}
+  \r\r
+      /* you can now destroy the mutex used to synchrone the command accesses to the properties of the unit */ \r
+      xbt_os_mutex_destroy(mutex);
+  \r\r
+      /* update the number of ended units of the runner */ \r
+      xbt_os_mutex_acquire(root->mutex);
+  \r\r
+      /* increment the number of ended units */ \r
+      root->runner->number_of_ended_units++;
+  \r\rif (!dry_run_flag)
+    \r {
+    \rif (root->interrupted && !root->exit_code)
+      \rINFO1("Test unit from %s INTR", root->fstream->name);
     \r
-    /* if the unit is already interrupted, signal the error */\r
-    if(unit->interrupted)\r
-    {\r
-       errno = EALREADY;\r
-       return -1;\r
-    }\r
+    else if (!root->exit_code)
+      \rINFO1("Test unit from %s OK", root->fstream->name);
     \r
-       /* interrupt the run of the specified unit */\r
-       unit->interrupted = 1;\r
-       xbt_os_sem_release(unit->sem);\r
-       \r
-       return 0;\r
-}\r
-\r
-/* just print the title of the root unit or a suite (if any) */\r
-static void \r
-print_title(const char* description)\r
-{\r
-       register int i;\r
-       char title[80];\r
-       size_t len = strlen(description);\r
-               \r
-       title[0]=' ';\r
-               \r
-       for (i = 1; i < 79; i++)\r
-               title[i]='=';\r
-               \r
-       title[i++]='\n';\r
-       title[79]='\0';\r
-       \r
-       sprintf(title + 40 - (len + 4)/2, "[ %s ]",description);\r
-       title[40 + (len + 5 ) / 2] = '=';\r
-               \r
-       printf("\n%s\n",title); \r
-}\r
-\r
-int\r
-unit_summuarize(unit_t unit)\r
-{\r
-       command_t command;\r
-       unsigned int itc, itu, its;\r
-       unit_t include;\r
-       unit_t suite;\r
-       char* p;\r
-       char title[PATH_MAX + 1] = {0};\r
-       \r
-       int number_of_tests = 0;                                                /* number of tests of a unit contained by this unit                                     */\r
-       int number_of_failed_tests = 0;                                 /* number of failed test of a unit contained by this unit                       */\r
-       int number_of_successeded_tests = 0;                    /* number of successeded tests of a unit contained by this unit         */\r
-       int number_of_interrupted_tests = 0;                    /* number of interrupted tests of a unit contained by this unit         */\r
-       \r
-       int number_of_tests_of_suite = 0;                               /* number of tests of a suite contained by this unit                            */\r
-       int number_of_interrupted_tests_of_suite = 0;   /* number of interrupted tests of a suite contained by this unit        */      \r
-       int number_of_failed_tests_of_suite = 0;                /* number of failed tests of a suite contained by this unit                                     */\r
-       int number_of_successeded_tests_of_suite = 0;   /* number of successeded tests of a suite contained by this                     */\r
-       \r
-       int number_of_units = 0;                                                /* number of units contained by a suite                                                         */\r
-       int number_of_failed_units = 0;                                 /* number of failed units contained by a suite                                          */\r
-       int number_of_successeded_units = 0;                    /* number of successeded units contained by a suite                                     */\r
-       int number_of_interrupted_units = 0;                    /* number of interrupted units contained by a suite                                     */\r
-       \r
-       int total_of_tests = 0;                                                 /* total of the tests contained by this unit                                            */\r
-       int total_of_failed_tests = 0;                                  /* total of failed tests contained by this unit                                         */\r
-       int total_of_successeded_tests = 0;                     /* total of successeded tests contained by this unit                            */\r
-       int total_of_interrupted_tests = 0;                             /* total of interrupted tests contained by this unit                            */\r
-       \r
-       int total_of_units = 0;                                                 /* total of units contained by this unit                                                        */\r
-       int total_of_failed_units = 0;                                  /* total of failed units contained by this unit                                         */\r
-       int total_of_successeded_units = 0;                             /* total of successeded units contained by this unit                            */\r
-       int total_of_interrupted_units = 0;                             /* total of interrutped units contained by this unit                            */\r
-       \r
-       int total_of_suites = 0;                                                /* total of suites contained by this unit                                                       */\r
-       int total_of_failed_suites = 0;                                 /* total of failed suites contained by this unit                                        */\r
-       int total_of_successeded_suites = 0;                    /* total of successeded suites contained by this unit                           */ \r
-       int total_of_interrupted_suites = 0;                    /* total of interrupted suites contained by this unit                           */\r
-       \r
-       /* check the parameter */\r
-       if(!(unit))\r
-    {\r
-        errno = EINVAL;\r
-        return -1;\r
-    }\r
-       \r
-       if((unit->description) && strlen(unit->description) < 76)\r
-               strcpy(title, unit->description);\r
-       else\r
-               sprintf(title, "file : %s",unit->fstream->name);\r
-               \r
-       if(unit->interrupted)\r
-       {\r
-               if(strlen(title) + strlen(" (interrupted)") < 76)\r
-                       strcat(title, " (interrupted)");\r
-               else\r
-               {\r
-                       memset(title, 0, PATH_MAX + 1);\r
-                       sprintf(title, "file : %s",unit->fstream->name);\r
-                       strcat(title, " (interrupted)");\r
-\r
-               }\r
-       }\r
-               \r
-       print_title(title);\r
-       \r
-       number_of_tests = xbt_dynar_length(unit->commands);\r
-       \r
-       /* tests */\r
-       xbt_dynar_foreach(unit->commands, itc, command)\r
-       {\r
-               if(command->status == cs_interrupted)\r
-                       number_of_interrupted_tests++;\r
-               else if(command->status == cs_failed)\r
-                       number_of_failed_tests++;\r
-               else if(command->status == cs_successeded)\r
-                       number_of_successeded_tests++;\r
-       }\r
-\r
-       \r
-       if(number_of_tests)\r
-       {\r
-               asprintf(&p," Test(s): .........................................................................");\r
-                       \r
-               p[70] = '\0';\r
-               printf("%s", p);\r
-               free(p);        \r
-       \r
-               if(number_of_failed_tests > 0) \r
-                       printf(".. failed\n");\r
-               else if(number_of_interrupted_tests > 0) \r
-                       printf("interrupt\n");\r
-               else \r
-                       printf(".... ..ok\n"); \r
-\r
-               xbt_dynar_foreach(unit->commands, itc, command)\r
-               {\r
-                       printf("        %s: %s [%s]\n", \r
-                               command->status == cs_interrupted ? "INTR  " \r
-                               : command->status == cs_failed ? "FAILED" \r
-                               : command->status == cs_successeded ? "PASS  " \r
-                               : "UNKNWN",\r
-                               command->context->command_line, \r
-                               command->context->pos);\r
-                               \r
-                       if(detail_summary_flag)\r
-                               command_summarize(command);\r
-               }\r
-       \r
-               printf(" =====================================================================%s\n",\r
-               number_of_failed_tests ? "== FAILED": number_of_interrupted_tests ? "==== INTR" : "====== OK");\r
-               \r
-               printf("    Summary: Test(s): %.0f%% ok (%d test(s): %d ok",\r
-               ((1-((double)number_of_failed_tests + (double)number_of_interrupted_tests)/(double)number_of_tests)*100.0),\r
-                number_of_tests, number_of_successeded_tests);\r
-               \r
-               if(number_of_failed_tests > 0)\r
-                       printf(", %d failed", number_of_failed_tests);\r
-               \r
-               if(number_of_interrupted_tests > 0)\r
-                       printf(", %d interrupted)", number_of_interrupted_tests);\r
-                       \r
-                printf(")\n\n");\r
-                               \r
-               total_of_tests = number_of_tests;\r
-               total_of_failed_tests = number_of_failed_tests;\r
-               total_of_interrupted_tests = number_of_interrupted_tests;\r
-               total_of_successeded_tests = number_of_successeded_tests;\r
-       }\r
-       \r
-       \r
-       \r
-       /* includes */\r
-       total_of_failed_units = total_of_interrupted_units = total_of_successeded_units = 0;\r
-       number_of_failed_units = number_of_successeded_units = number_of_interrupted_units = 0;\r
-       number_of_units = xbt_dynar_length(unit->includes);\r
-       \r
-       xbt_dynar_foreach(unit->includes, itu, include)\r
-       {\r
-               \r
-               number_of_interrupted_tests = number_of_failed_tests = number_of_successeded_tests = 0;\r
-               \r
-               number_of_tests = xbt_dynar_length(include->commands);\r
-\r
-               xbt_dynar_foreach(include->commands, itc, command)\r
-               {\r
-                       if(command->status == cs_interrupted)\r
-                               number_of_interrupted_tests++;\r
-                       else if(command->status == cs_failed)\r
-                               number_of_failed_tests++;\r
-                       else if(command->status == cs_successeded)\r
-                               number_of_successeded_tests++;  \r
-               }\r
-               \r
-               asprintf(&p," Unit: %s ............................................................................", include->description && strlen(include->description) < 60 ? include->description : include->fstream->name);\r
-                       \r
-               p[70] = '\0';\r
-               printf("%s", p);\r
-               free(p);        \r
-               \r
-               if(number_of_failed_tests > 0) \r
-               {\r
-                       total_of_failed_units++;\r
-                       printf(".. failed\n");\r
-               }\r
-               else if(number_of_interrupted_tests > 0) \r
-               {\r
-                       total_of_interrupted_units++;\r
-                       printf("interrupt\n");\r
-               }\r
-               else \r
-               {\r
-                       total_of_successeded_units++;\r
-                       printf(".... ..ok\n"); \r
-               }\r
-               \r
-               if(detail_summary_flag)\r
-               {               \r
-\r
-                       xbt_dynar_foreach(include->commands, itc, command)\r
-                       {\r
-                               printf("        %s: %s [%s]\n", \r
-                               command->status == cs_interrupted ? "INTR  " \r
-                               : command->status == cs_failed ? "FAILED" \r
-                               : command->status == cs_successeded ? "PASS  " \r
-                               : "UNKNWN",\r
-                               command->context->command_line, \r
-                               command->context->pos);\r
-                               \r
-                               command_summarize(command);\r
-                       }\r
-                       \r
-                                       \r
-               }\r
-               \r
-               printf(" =====================================================================%s\n",\r
-               number_of_failed_tests ? "== FAILED": number_of_interrupted_tests ? "==== INTR" : "====== OK");\r
-       \r
-               \r
-               printf("    Summary: Test(s): %.0f%% ok (%d test(s): %d ok",\r
-               (number_of_tests ? (1-((double)number_of_failed_tests + (double)number_of_interrupted_tests)/(double)number_of_tests)*100.0 : 100.0),\r
-                number_of_tests, number_of_successeded_tests);\r
-               \r
-               if(number_of_failed_tests > 0)\r
-                       printf(", %d failed", number_of_failed_tests);\r
-               \r
-               if(number_of_interrupted_tests > 0)\r
-                       printf(", %d interrupted)", number_of_interrupted_tests);\r
-                       \r
-                printf(")\n\n");       \r
-                \r
-               \r
-               total_of_tests += number_of_tests;\r
-               total_of_failed_tests += number_of_failed_tests;\r
-               total_of_interrupted_tests += number_of_interrupted_tests;\r
-               total_of_successeded_tests += number_of_successeded_tests;\r
-       }\r
-       \r
-       /* suites */\r
-       total_of_units = number_of_units;\r
-       \r
-       total_of_failed_suites = total_of_successeded_suites = total_of_interrupted_suites = 0;\r
-       \r
-       total_of_suites = xbt_dynar_length(unit->suites);\r
-\r
-       xbt_dynar_foreach(unit->suites, its, suite)\r
-       {\r
-               print_title(suite->description);\r
-               \r
-               number_of_tests_of_suite = number_of_interrupted_tests_of_suite = number_of_failed_tests_of_suite = number_of_successeded_tests_of_suite = 0;\r
-               \r
-               number_of_interrupted_units = number_of_failed_units = number_of_successeded_units = 0;\r
-               \r
-               number_of_units = xbt_dynar_length(suite->includes);\r
-               \r
-               xbt_dynar_foreach(suite->includes, itu, include)\r
-               {\r
-                       number_of_interrupted_tests = number_of_failed_tests = number_of_successeded_tests = 0;\r
-                       \r
-                       number_of_tests = xbt_dynar_length(include->commands);\r
-                       \r
-                       \r
-                       xbt_dynar_foreach(include->commands, itc, command)\r
-                       {\r
-                               if(command->status == cs_interrupted)\r
-                                       number_of_interrupted_tests++;\r
-                               else if(command->status == cs_failed)\r
-                                       number_of_failed_tests++;\r
-                               else if(command->status == cs_successeded)\r
-                                       number_of_successeded_tests++;\r
-                       }\r
-                       \r
-                       asprintf(&p," Unit: %s ............................................................................", include->description && strlen(include->description) < 60 ? include->description : include->fstream->name);\r
-                       \r
-                       p[70] = '\0';\r
-                       printf("%s", p);\r
-                       free(p);        \r
-               \r
-                       if(number_of_failed_tests > 0) \r
-                       {\r
-                               number_of_failed_units++;\r
-                               printf(".. failed\n");\r
-                       }\r
-                       else if(number_of_interrupted_tests > 0) \r
-                       {\r
-                               number_of_interrupted_units++;\r
-                               printf("interrupt\n");\r
-                       }\r
-                       else \r
-                       {\r
-                               number_of_successeded_units++;\r
-                               printf(".... ..ok\n"); \r
-                       } \r
-                       \r
-                       number_of_interrupted_tests_of_suite += number_of_interrupted_tests;\r
-                       number_of_failed_tests_of_suite += number_of_failed_tests;\r
-                       number_of_successeded_tests_of_suite += number_of_successeded_tests;\r
-                       \r
-                       number_of_tests_of_suite += number_of_tests;\r
-                       \r
-                       total_of_tests += number_of_tests;\r
-                       total_of_failed_tests += number_of_failed_tests;\r
-                       total_of_interrupted_tests += number_of_interrupted_tests;\r
-                       total_of_successeded_tests += number_of_successeded_tests;\r
-                       \r
-                       if(detail_summary_flag)\r
-                       {\r
-\r
-                               xbt_dynar_foreach(include->commands, itc, command)\r
-                               {\r
-                                       printf("        %s: %s [%s]\n", \r
-                                       command->status == cs_interrupted ? "INTR  " \r
-                                       : command->status == cs_failed ? "FAILED" \r
-                                       : command->status == cs_successeded ? "PASS  " \r
-                                       : "UNKNWN",\r
-                                       command->context->command_line, \r
-                                       command->context->pos);\r
-                                       \r
-                                       command_summarize(command);\r
-                               }\r
-                               \r
-                               \r
-                       }\r
-                               \r
-               }\r
-               \r
-               printf(" =====================================================================%s\n",\r
-               number_of_failed_tests_of_suite ? "== FAILED": number_of_interrupted_tests_of_suite ? "==== INTR" : "====== OK");\r
-               \r
-               if(number_of_failed_tests_of_suite > 0)\r
-                       total_of_failed_suites++;\r
-               else if(number_of_interrupted_tests_of_suite)\r
-                       total_of_interrupted_suites++;\r
-               else\r
-                       total_of_successeded_suites++;\r
-                       \r
-               total_of_failed_units += number_of_failed_units;\r
-               total_of_interrupted_units += number_of_interrupted_units;\r
-               total_of_successeded_units += number_of_successeded_units;\r
-                       \r
-               total_of_units += number_of_units;\r
-               \r
-               printf("    Summary: Unit(s): %.0f%% ok (%d unit(s): %d ok",\r
-               (number_of_units ? (1-((double)number_of_failed_units + (double)number_of_interrupted_units)/(double)number_of_units)*100.0 : 100.0),\r
-                number_of_units, number_of_successeded_units);\r
-                \r
-               if(number_of_failed_units > 0)\r
-                       printf(", %d failed", number_of_failed_units);\r
-               \r
-               if(number_of_interrupted_units > 0)\r
-                       printf(", %d interrupted)", number_of_interrupted_units);\r
-                       \r
-               printf(")\n");  \r
-               \r
-               printf("             Test(s): %.0f%% ok (%d test(s): %d ok",\r
-               (number_of_tests_of_suite ? (1-((double)number_of_failed_tests_of_suite + (double)number_of_interrupted_tests_of_suite)/(double)number_of_tests_of_suite)*100.0 : 100.0),\r
-               number_of_tests_of_suite, number_of_successeded_tests_of_suite);\r
-                \r
-               if(number_of_failed_tests_of_suite > 0)\r
-                       printf(", %d failed", number_of_failed_tests_of_suite);\r
-               \r
-               if(number_of_interrupted_tests_of_suite > 0)\r
-                       printf(", %d interrupted)", number_of_interrupted_tests_of_suite);\r
-                       \r
-                printf(")\n\n");       \r
-       }\r
-       \r
-       printf(" TOTAL : Suite(s): %.0f%% ok (%d suite(s): %d ok",\r
-               (total_of_suites ? (1-((double)total_of_failed_suites + (double)total_of_interrupted_suites)/(double)total_of_suites)*100.0 : 100.0),\r
-                total_of_suites, total_of_successeded_suites);\r
-       \r
-       if(total_of_failed_suites > 0)\r
-                       printf(", %d failed", total_of_failed_suites);\r
-               \r
-       if(total_of_interrupted_suites > 0)\r
-               printf(", %d interrupted)", total_of_interrupted_suites);\r
-               \r
-       printf(")\n");  \r
-       \r
-       printf("         Unit(s):  %.0f%% ok (%d unit(s): %d ok",\r
-               (total_of_units ? (1-((double)total_of_failed_units + (double)total_of_interrupted_units)/(double)total_of_units)*100.0 : 100.0),\r
-                total_of_units, total_of_successeded_units);\r
-       \r
-       if(total_of_failed_units > 0)\r
-                       printf(", %d failed", total_of_failed_units);\r
-               \r
-       if(total_of_interrupted_units > 0)\r
-               printf(", %d interrupted)", total_of_interrupted_units);\r
-               \r
-       printf(")\n");\r
-       \r
-       printf("         Test(s):  %.0f%% ok (%d test(s): %d ok",\r
-               (total_of_tests ? (1-((double)total_of_failed_tests + (double)total_of_interrupted_tests)/(double)total_of_tests)*100.0 : 100.0),\r
-                total_of_tests, total_of_successeded_tests); \r
-                \r
-       if(total_of_failed_tests > 0)\r
-                       printf(", %d failed", total_of_failed_tests);\r
-               \r
-       if(total_of_interrupted_tests > 0)\r
-               printf(", %d interrupted)", total_of_interrupted_tests);\r
-               \r
-       printf(")\n\n");\r
-       \r
-       if(unit->interrupted)\r
-               unit->runner->total_of_interrupted_units++;\r
-       else if(total_of_failed_tests > 0)\r
-               unit->runner->total_of_failed_units++;\r
-       else\r
-               unit->runner->total_of_successeded_units++;\r
-       \r
-       unit->runner->total_of_tests += total_of_tests;\r
-       unit->runner->total_of_failed_tests += total_of_failed_tests;\r
-       unit->runner->total_of_successeded_tests += total_of_successeded_tests;\r
-       unit->runner->total_of_interrupted_tests += total_of_interrupted_tests;\r
-       \r
-       unit->runner->total_of_units += total_of_units + 1;\r
-       unit->runner->total_of_successeded_units += total_of_successeded_units;\r
-       unit->runner->total_of_failed_units += total_of_failed_units;\r
-       unit->runner->total_of_interrupted_units += total_of_interrupted_units;\r
-       \r
-       unit->runner->total_of_suites += total_of_suites;\r
-       unit->runner->total_of_successeded_suites += total_of_successeded_suites;\r
-       unit->runner->total_of_failed_suites += total_of_failed_suites;\r
-       unit->runner->total_of_interrupted_suites += total_of_interrupted_suites;\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-unit_reset(unit_t unit)\r
-{\r
-       unit_t cur;\r
-       unsigned int i;\r
-\r
-       /* reset all the suites of the unit */\r
-       xbt_dynar_foreach(unit->suites, i, cur)\r
-       {\r
-               unit_reset(cur);\r
-       }\r
-\r
-\r
-       /* reset all the includes of the unit */\r
-       xbt_dynar_foreach(unit->includes, i, cur)\r
-       {\r
-               unit_reset(cur);\r
-       }\r
-\r
-       fseek(unit->fstream->stream,0L, SEEK_SET);\r
-       unit->parsed = 0;\r
-       unit->cmd_nb = 0;\r
-       unit->started_cmd_nb = 0;\r
-       unit->interrupted_cmd_nb = 0;\r
-       unit->failed_cmd_nb = 0;\r
-       unit->successeded_cmd_nb = 0;\r
-       unit->terminated_cmd_nb = 0;\r
-       unit->waiting_cmd_nb = 0;\r
-       unit->interrupted = 0;\r
-       unit->failed = 0;\r
-       unit->successeded = 0;\r
-       unit->parsed = 0;\r
-       unit->released = 0;\r
-       unit->is_running_suite = 0;\r
-       \r
-       if(unit->description)\r
-       {\r
-               free(unit->description);\r
-               unit->description = NULL;\r
-       }\r
+    else if (root->exit_code)
+      \rERROR3("Test unit `%s': NOK (<%s> %s)", root->fstream->name,
+              root->err_line, error_to_string(root->exit_code,
+                                              root->err_kind));
+    \r}
+  \r\r
+      /* if it's the last unit, release the runner */ \r
+      if ((root->runner->number_of_runned_units ==
+           root->runner->number_of_ended_units))
+    \r {
+    \r
+        /* if all the commands of the unit are successeded itc's a successeded unit */ \r
+        if (root->successeded_cmd_nb == root->cmd_nb
+            && !root->
+            exit_code /* case of only one cd : nb = successeded = 0) */ )
+      \rroot->successeded = 1;
+    \r\r
+        /* first release the mutex */ \r
+        xbt_os_mutex_release(root->mutex);
+    \r\r
+        /* release the runner */ \r
+        xbt_os_sem_release(units_sem);
+    \r}
+  \r
+  else
+    \rxbt_os_mutex_release(root->mutex);
+  \r\r
+      /* release the jobs semaphore, then the next waiting unit can start */ \r
+      xbt_os_sem_release(jobs_sem);
+  \r\rreturn NULL;
+\r\r}
+
+\r\r\runit_t \r
+unit_new(runner_t runner, unit_t root, unit_t owner, fstream_t fstream) \r
+{
+  \runit_t unit;
+  \r\runit = xbt_new0(s_unit_t, 1);
+  \r\r
+      /* instantiate the vector used to store all the commands of the unit */ \r
+      unit->commands =
+      xbt_dynar_new(sizeof(command_t), (void_f_pvoid_t) command_free);
+  \r\r
+      /* instantiate the vector used to store all the included units */ \r
+      unit->includes =
+      xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t) unit_free);
+  \r\r
+      /* instantiate the vector used to store all the included suites */ \r
+      unit->suites =
+      xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t) unit_free);
+  \r\r
+      /* the runner used to launch the tesh unit */ \r
+      unit->runner = runner;
+  \r\r
+      /* the file stream object to use to parse the tesh file */ \r
+      unit->fstream = fstream;
+  \r\rif (fstream)
+    \rfstream->unit = unit;
+  \r\r
+      /* if no root parameter specified assume that itc's the root of all the units */ \r
+      unit->root = root ? root : unit;
+  \r\r
+      /* the owner of the suite */ \r
+      unit->owner = owner;
+  \r\runit->thread = NULL;
+  \runit->started_cmd_nb = 0;
+  \runit->interrupted_cmd_nb = 0;
+  \runit->failed_cmd_nb = 0;
+  \runit->successeded_cmd_nb = 0;
+  \runit->terminated_cmd_nb = 0;
+  \runit->waiting_cmd_nb = 0;
+  \runit->interrupted = 0;
+  \runit->failed = 0;
+  \runit->successeded = 0;
+  \runit->parsed = 0;
+  \runit->released = 0;
+  \runit->owner = owner;
+  \runit->is_running_suite = 0;
+  \runit->description = NULL;
+  \runit->sem = NULL;
+  \runit->exit_code = 0;
+  \runit->err_kind = 0;
+  \runit->err_line = NULL;
+  \runit->filepos = NULL;
+  \r\r\r\rreturn unit;
+\r}
+
+\r\rvoid \r
+unit_set_error(unit_t unit, int errcode, int kind, const char *line) \r
+{
+  \rif (!unit->exit_code)
+    \r {
+    \runit->exit_code = errcode;
+    \runit->err_kind = kind;
+    \runit->err_line = strdup(line);
+    \r\rif (unit->root && !unit->root->exit_code)
+      \r {
+      \runit->root->exit_code = errcode;
+      \runit->root->err_kind = kind;
+      \runit->root->err_line = strdup(line);
+      \r}
+    \r\rif (!exit_code)
+      \r {
+      \r\rexit_code = errcode;
+      \rerr_kind = kind;
+      \rerr_line = strdup(line);
+      \r}
+    \r}
+\r\r}
+
+\r\rint \r unit_free(unit_t * ptr) \r
+{
+  \rif (!(*ptr))
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rif ((*ptr)->commands)
+    \rxbt_dynar_free(&((*ptr)->commands));
+  \r\rif ((*ptr)->includes)
+    \rxbt_dynar_free(&((*ptr)->includes));
+  \r\rif ((*ptr)->suites)
+    \rxbt_dynar_free(&((*ptr)->suites));
+  \r\r
+      /* if the unit is interrupted during its run, the semaphore is NULL */ \r
+      if ((*ptr)->sem)
+    \rxbt_os_sem_destroy((*ptr)->sem);
+  \r\rif ((*ptr)->description)
+    \rfree((*ptr)->description);
+  \r\rif ((*ptr)->err_line)
+    \rfree((*ptr)->err_line);
+  \r\rif ((*ptr)->filepos)
+    \rfree((*ptr)->filepos);
+  \r\rfree(*ptr);
+  \r*ptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rint \r unit_run(unit_t unit, xbt_os_mutex_t mutex) \r
+{
+  \r
+      /* check the parameters */ \r
+      if (!(unit) || !mutex)
+    \r {
+    \rerrno = EINVAL;
+    \rxbt_os_sem_release(jobs_sem);
+    \rreturn -1;
+    \r\r}
+  \r\rif (!interrupted)
+    \r {
+    \runit->mutex = mutex;
+    \r\runit->sem = xbt_os_sem_init(0);
+    \r\r
+        /* start the unit */ \r
+        unit->thread = xbt_os_thread_create("", unit_start, unit);
+    \r}
+  \r
+  else
+    \r {
+    \r
+        /* the unit is interrupted by the runner before its starting \r
+         * in this case the unit semaphore is NULL take care of that\r
+         * in the function unit_free()\r
+         */ \r
+        unit->interrupted = 1;
+    \rxbt_os_sem_release(jobs_sem);
+    \r}
+  \r\rreturn 0;
+\r\r}
+
+\r\rint \r unit_interrupt(unit_t unit) \r
+{
+  \r
+      /* check the parameter */ \r
+      if (!(unit))
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\r
+      /* if the unit is already interrupted, signal the error */ \r
+      if (unit->interrupted)
+    \r {
+    \rerrno = EALREADY;
+    \rreturn -1;
+    \r}
+  \r\r
+      /* interrupt the run of the specified unit */ \r
+      unit->interrupted = 1;
+  \rxbt_os_sem_release(unit->sem);
+  \r\rreturn 0;
+\r}
+
+\r\r
+/* just print the title of the root unit or a suite (if any) */ \r
+static void \r print_title(const char *description) \r
+{
+  \rregister int i;
+  \rchar title[80];
+  \rsize_t len = strlen(description);
+  \r\rtitle[0] = ' ';
+  \r\rfor (i = 1; i < 79; i++)
+    \rtitle[i] = '=';
+  \r\rtitle[i++] = '\n';
+  \rtitle[79] = '\0';
+  \r\rsprintf(title + 40 - (len + 4) / 2, "[ %s ]", description);
+  \rtitle[40 + (len + 5) / 2] = '=';
+  \r\rprintf("\n%s\n", title);
+\r}
+
+\r\rint \r unit_summuarize(unit_t unit) \r
+{
+  \rcommand_t command;
+  \runsigned int itc, itu, its;
+  \runit_t include;
+  \runit_t suite;
+  \rchar *p;
+  \rchar title[PATH_MAX + 1] = { 0 };
+  \r\rint number_of_tests = 0;    /* number of tests of a unit contained by this unit                                     */
+  \rint number_of_failed_tests = 0;      /* number of failed test of a unit contained by this unit                       */
+  \rint number_of_successeded_tests = 0; /* number of successeded tests of a unit contained by this unit         */
+  \rint number_of_interrupted_tests = 0; /* number of interrupted tests of a unit contained by this unit         */
+  \r\rint number_of_tests_of_suite = 0;   /* number of tests of a suite contained by this unit                            */
+  \rint number_of_interrupted_tests_of_suite = 0;        /* number of interrupted tests of a suite contained by this unit        */
+  \rint number_of_failed_tests_of_suite = 0;     /* number of failed tests of a suite contained by this unit                                     */
+  \rint number_of_successeded_tests_of_suite = 0;        /* number of successeded tests of a suite contained by this                     */
+  \r\rint number_of_units = 0;    /* number of units contained by a suite                                                         */
+  \rint number_of_failed_units = 0;      /* number of failed units contained by a suite                                          */
+  \rint number_of_successeded_units = 0; /* number of successeded units contained by a suite                                     */
+  \rint number_of_interrupted_units = 0; /* number of interrupted units contained by a suite                                     */
+  \r\rint total_of_tests = 0;     /* total of the tests contained by this unit                                            */
+  \rint total_of_failed_tests = 0;       /* total of failed tests contained by this unit                                         */
+  \rint total_of_successeded_tests = 0;  /* total of successeded tests contained by this unit                            */
+  \rint total_of_interrupted_tests = 0;  /* total of interrupted tests contained by this unit                            */
+  \r\rint total_of_units = 0;     /* total of units contained by this unit                                                        */
+  \rint total_of_failed_units = 0;       /* total of failed units contained by this unit                                         */
+  \rint total_of_successeded_units = 0;  /* total of successeded units contained by this unit                            */
+  \rint total_of_interrupted_units = 0;  /* total of interrutped units contained by this unit                            */
+  \r\rint total_of_suites = 0;    /* total of suites contained by this unit                                                       */
+  \rint total_of_failed_suites = 0;      /* total of failed suites contained by this unit                                        */
+  \rint total_of_successeded_suites = 0; /* total of successeded suites contained by this unit                           */
+  \rint total_of_interrupted_suites = 0; /* total of interrupted suites contained by this unit                           */
+  \r\r
+      /* check the parameter */ \r
+      if (!(unit))
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rif ((unit->description) && strlen(unit->description) < 76)
+    \rstrcpy(title, unit->description);
+  \r
+  else
+    \rsprintf(title, "file : %s", unit->fstream->name);
+  \r\rif (unit->interrupted)
+    \r {
+    \rif (strlen(title) + strlen(" (interrupted)") < 76)
+      \rstrcat(title, " (interrupted)");
+    \r
+    else
+      \r {
+      \rmemset(title, 0, PATH_MAX + 1);
+      \rsprintf(title, "file : %s", unit->fstream->name);
+      \rstrcat(title, " (interrupted)");
+      \r\r}
+    \r}
+  \r\rprint_title(title);
+  \r\rnumber_of_tests = xbt_dynar_length(unit->commands);
+  \r\r
+      /* tests */ \r
+      xbt_dynar_foreach(unit->commands, itc, command) \r {
+    \rif (command->status == cs_interrupted)
+      \rnumber_of_interrupted_tests++;
+    \r
+    else if (command->status == cs_failed)
+      \rnumber_of_failed_tests++;
+    \r
+    else if (command->status == cs_successeded)
+      \rnumber_of_successeded_tests++;
+  \r}
+  \r\r\rif (number_of_tests)
+    \r {
+    \rasprintf(&p,
+              " Test(s): .........................................................................");
+    \r\rp[70] = '\0';
+    \rprintf("%s", p);
+    \rfree(p);
+    \r\rif (number_of_failed_tests > 0)
+      \rprintf(".. failed\n");
+    \r
+    else if (number_of_interrupted_tests > 0)
+      \rprintf("interrupt\n");
+    \r
+    else
+      \rprintf(".... ..ok\n");
+    \r\rxbt_dynar_foreach(unit->commands, itc, command) \r {
+      \rprintf("        %s: %s [%s]\n",
+              \rcommand->status ==
+              cs_interrupted ? "INTR  " \r : command->status ==
+              cs_failed ? "FAILED" \r : command->status ==
+              cs_successeded ? "PASS  " \r : "UNKNWN",
+              \rcommand->context->command_line, \rcommand->context->pos);
+      \r\rif (detail_summary_flag)
+        \rcommand_summarize(command);
+    \r}
+    \r\rprintf
+        (" =====================================================================%s\n",
+         \rnumber_of_failed_tests ? "== FAILED" :
+         number_of_interrupted_tests ? "==== INTR" : "====== OK");
+    \r\rprintf("    Summary: Test(s): %.0f%% ok (%d test(s): %d ok",
+             \r((1 -
+                ((double) number_of_failed_tests +
+                 (double) number_of_interrupted_tests) /
+                (double) number_of_tests) * 100.0), \rnumber_of_tests,
+             number_of_successeded_tests);
+    \r\rif (number_of_failed_tests > 0)
+      \rprintf(", %d failed", number_of_failed_tests);
+    \r\rif (number_of_interrupted_tests > 0)
+      \rprintf(", %d interrupted)", number_of_interrupted_tests);
+    \r\rprintf(")\n\n");
+    \r\rtotal_of_tests = number_of_tests;
+    \rtotal_of_failed_tests = number_of_failed_tests;
+    \rtotal_of_interrupted_tests = number_of_interrupted_tests;
+    \rtotal_of_successeded_tests = number_of_successeded_tests;
+    \r}
+  \r\r\r\r
+      /* includes */ \r
+      total_of_failed_units = total_of_interrupted_units =
+      total_of_successeded_units = 0;
+  \rnumber_of_failed_units = number_of_successeded_units =
+      number_of_interrupted_units = 0;
+  \rnumber_of_units = xbt_dynar_length(unit->includes);
+  \r\rxbt_dynar_foreach(unit->includes, itu, include) \r {
+    \r\rnumber_of_interrupted_tests = number_of_failed_tests =
+        number_of_successeded_tests = 0;
+    \r\rnumber_of_tests = xbt_dynar_length(include->commands);
+    \r\rxbt_dynar_foreach(include->commands, itc, command) \r {
+      \rif (command->status == cs_interrupted)
+        \rnumber_of_interrupted_tests++;
+      \r
+      else if (command->status == cs_failed)
+        \rnumber_of_failed_tests++;
+      \r
+      else if (command->status == cs_successeded)
+        \rnumber_of_successeded_tests++;
+    \r}
+    \r\rasprintf(&p,
+               " Unit: %s ............................................................................",
+               include->description
+               && strlen(include->description) <
+               60 ? include->description : include->fstream->name);
+    \r\rp[70] = '\0';
+    \rprintf("%s", p);
+    \rfree(p);
+    \r\rif (number_of_failed_tests > 0)
+      \r {
+      \rtotal_of_failed_units++;
+      \rprintf(".. failed\n");
+      \r}
+    \r
+    else if (number_of_interrupted_tests > 0)
+      \r {
+      \rtotal_of_interrupted_units++;
+      \rprintf("interrupt\n");
+      \r}
+    \r
+    else
+      \r {
+      \rtotal_of_successeded_units++;
+      \rprintf(".... ..ok\n");
+      \r}
+    \r\rif (detail_summary_flag)
+      \r {
+      \r\rxbt_dynar_foreach(include->commands, itc, command) \r {
+        \rprintf("        %s: %s [%s]\n",
+                \rcommand->status ==
+                cs_interrupted ? "INTR  " \r : command->status ==
+                cs_failed ? "FAILED" \r : command->status ==
+                cs_successeded ? "PASS  " \r : "UNKNWN",
+                \rcommand->context->command_line, \rcommand->context->pos);
+        \r\rcommand_summarize(command);
+      \r}
+      \r\r\r}
+    \r\rprintf
+        (" =====================================================================%s\n",
+         \rnumber_of_failed_tests ? "== FAILED" :
+         number_of_interrupted_tests ? "==== INTR" : "====== OK");
+    \r\r\rprintf("    Summary: Test(s): %.0f%% ok (%d test(s): %d ok",
+              \r(number_of_tests
+                ? (1 -
+                   ((double) number_of_failed_tests +
+                    (double) number_of_interrupted_tests) /
+                   (double) number_of_tests) * 100.0 : 100.0),
+              \rnumber_of_tests, number_of_successeded_tests);
+    \r\rif (number_of_failed_tests > 0)
+      \rprintf(", %d failed", number_of_failed_tests);
+    \r\rif (number_of_interrupted_tests > 0)
+      \rprintf(", %d interrupted)", number_of_interrupted_tests);
+    \r\rprintf(")\n\n");
+    \r\r\rtotal_of_tests += number_of_tests;
+    \rtotal_of_failed_tests += number_of_failed_tests;
+    \rtotal_of_interrupted_tests += number_of_interrupted_tests;
+    \rtotal_of_successeded_tests += number_of_successeded_tests;
+  \r}
+  \r\r
+      /* suites */ \r
+      total_of_units = number_of_units;
+  \r\rtotal_of_failed_suites = total_of_successeded_suites =
+      total_of_interrupted_suites = 0;
+  \r\rtotal_of_suites = xbt_dynar_length(unit->suites);
+  \r\rxbt_dynar_foreach(unit->suites, its, suite) \r {
+    \rprint_title(suite->description);
+    \r\rnumber_of_tests_of_suite = number_of_interrupted_tests_of_suite =
+        number_of_failed_tests_of_suite =
+        number_of_successeded_tests_of_suite = 0;
+    \r\rnumber_of_interrupted_units = number_of_failed_units =
+        number_of_successeded_units = 0;
+    \r\rnumber_of_units = xbt_dynar_length(suite->includes);
+    \r\rxbt_dynar_foreach(suite->includes, itu, include) \r {
+      \rnumber_of_interrupted_tests = number_of_failed_tests =
+          number_of_successeded_tests = 0;
+      \r\rnumber_of_tests = xbt_dynar_length(include->commands);
+      \r\r\rxbt_dynar_foreach(include->commands, itc, command) \r {
+        \rif (command->status == cs_interrupted)
+          \rnumber_of_interrupted_tests++;
+        \r
+        else if (command->status == cs_failed)
+          \rnumber_of_failed_tests++;
+        \r
+        else if (command->status == cs_successeded)
+          \rnumber_of_successeded_tests++;
+      \r}
+      \r\rasprintf(&p,
+                 " Unit: %s ............................................................................",
+                 include->description
+                 && strlen(include->description) <
+                 60 ? include->description : include->fstream->name);
+      \r\rp[70] = '\0';
+      \rprintf("%s", p);
+      \rfree(p);
+      \r\rif (number_of_failed_tests > 0)
+        \r {
+        \rnumber_of_failed_units++;
+        \rprintf(".. failed\n");
+        \r}
+      \r
+      else if (number_of_interrupted_tests > 0)
+        \r {
+        \rnumber_of_interrupted_units++;
+        \rprintf("interrupt\n");
+        \r}
+      \r
+      else
+        \r {
+        \rnumber_of_successeded_units++;
+        \rprintf(".... ..ok\n");
+        \r}
+      \r\rnumber_of_interrupted_tests_of_suite +=
+          number_of_interrupted_tests;
+      \rnumber_of_failed_tests_of_suite += number_of_failed_tests;
+      \rnumber_of_successeded_tests_of_suite += number_of_successeded_tests;
+      \r\rnumber_of_tests_of_suite += number_of_tests;
+      \r\rtotal_of_tests += number_of_tests;
+      \rtotal_of_failed_tests += number_of_failed_tests;
+      \rtotal_of_interrupted_tests += number_of_interrupted_tests;
+      \rtotal_of_successeded_tests += number_of_successeded_tests;
+      \r\rif (detail_summary_flag)
+        \r {
+        \r\rxbt_dynar_foreach(include->commands, itc, command) \r {
+          \rprintf("        %s: %s [%s]\n",
+                  \rcommand->status ==
+                  cs_interrupted ? "INTR  " \r : command->status ==
+                  cs_failed ? "FAILED" \r : command->status ==
+                  cs_successeded ? "PASS  " \r : "UNKNWN",
+                  \rcommand->context->command_line, \rcommand->context->pos);
+          \r\rcommand_summarize(command);
+        \r}
+        \r\r\r}
+    \r\r}
+    \r\rprintf
+        (" =====================================================================%s\n",
+         \rnumber_of_failed_tests_of_suite ? "== FAILED" :
+         number_of_interrupted_tests_of_suite ? "==== INTR" : "====== OK");
+    \r\rif (number_of_failed_tests_of_suite > 0)
+      \rtotal_of_failed_suites++;
+    \r
+    else if (number_of_interrupted_tests_of_suite)
+      \rtotal_of_interrupted_suites++;
+    \r
+    else
+      \rtotal_of_successeded_suites++;
+    \r\rtotal_of_failed_units += number_of_failed_units;
+    \rtotal_of_interrupted_units += number_of_interrupted_units;
+    \rtotal_of_successeded_units += number_of_successeded_units;
+    \r\rtotal_of_units += number_of_units;
+    \r\rprintf("    Summary: Unit(s): %.0f%% ok (%d unit(s): %d ok", \r
+             (number_of_units
+              ? (1 -
+                 ((double) number_of_failed_units +
+                  (double) number_of_interrupted_units) /
+                 (double) number_of_units) * 100.0 : 100.0),
+             \rnumber_of_units, number_of_successeded_units);
+    \r\rif (number_of_failed_units > 0)
+      \rprintf(", %d failed", number_of_failed_units);
+    \r\rif (number_of_interrupted_units > 0)
+      \rprintf(", %d interrupted)", number_of_interrupted_units);
+    \r\rprintf(")\n");
+    \r\rprintf("             Test(s): %.0f%% ok (%d test(s): %d ok", \r
+             (number_of_tests_of_suite
+              ? (1 -
+                 ((double) number_of_failed_tests_of_suite +
+                  (double) number_of_interrupted_tests_of_suite) /
+                 (double) number_of_tests_of_suite) * 100.0 : 100.0),
+             \rnumber_of_tests_of_suite,
+             number_of_successeded_tests_of_suite);
+    \r\rif (number_of_failed_tests_of_suite > 0)
+      \rprintf(", %d failed", number_of_failed_tests_of_suite);
+    \r\rif (number_of_interrupted_tests_of_suite > 0)
+      \rprintf(", %d interrupted)", number_of_interrupted_tests_of_suite);
+    \r\rprintf(")\n\n");
+  \r}
+  \r\rprintf(" TOTAL : Suite(s): %.0f%% ok (%d suite(s): %d ok", \r
+           (total_of_suites
+            ? (1 -
+               ((double) total_of_failed_suites +
+                (double) total_of_interrupted_suites) /
+               (double) total_of_suites) * 100.0 : 100.0),
+           \rtotal_of_suites, total_of_successeded_suites);
+  \r\rif (total_of_failed_suites > 0)
+    \rprintf(", %d failed", total_of_failed_suites);
+  \r\rif (total_of_interrupted_suites > 0)
+    \rprintf(", %d interrupted)", total_of_interrupted_suites);
+  \r\rprintf(")\n");
+  \r\rprintf("         Unit(s):  %.0f%% ok (%d unit(s): %d ok", \r
+           (total_of_units
+            ? (1 -
+               ((double) total_of_failed_units +
+                (double) total_of_interrupted_units) /
+               (double) total_of_units) * 100.0 : 100.0), \rtotal_of_units,
+           total_of_successeded_units);
+  \r\rif (total_of_failed_units > 0)
+    \rprintf(", %d failed", total_of_failed_units);
+  \r\rif (total_of_interrupted_units > 0)
+    \rprintf(", %d interrupted)", total_of_interrupted_units);
+  \r\rprintf(")\n");
+  \r\rprintf("         Test(s):  %.0f%% ok (%d test(s): %d ok", \r
+           (total_of_tests
+            ? (1 -
+               ((double) total_of_failed_tests +
+                (double) total_of_interrupted_tests) /
+               (double) total_of_tests) * 100.0 : 100.0), \rtotal_of_tests,
+           total_of_successeded_tests);
+  \r\rif (total_of_failed_tests > 0)
+    \rprintf(", %d failed", total_of_failed_tests);
+  \r\rif (total_of_interrupted_tests > 0)
+    \rprintf(", %d interrupted)", total_of_interrupted_tests);
+  \r\rprintf(")\n\n");
+  \r\rif (unit->interrupted)
+    \runit->runner->total_of_interrupted_units++;
+  \r
+  else if (total_of_failed_tests > 0)
+    \runit->runner->total_of_failed_units++;
+  \r
+  else
+    \runit->runner->total_of_successeded_units++;
+  \r\runit->runner->total_of_tests += total_of_tests;
+  \runit->runner->total_of_failed_tests += total_of_failed_tests;
+  \runit->runner->total_of_successeded_tests += total_of_successeded_tests;
+  \runit->runner->total_of_interrupted_tests += total_of_interrupted_tests;
+  \r\runit->runner->total_of_units += total_of_units + 1;
+  \runit->runner->total_of_successeded_units += total_of_successeded_units;
+  \runit->runner->total_of_failed_units += total_of_failed_units;
+  \runit->runner->total_of_interrupted_units += total_of_interrupted_units;
+  \r\runit->runner->total_of_suites += total_of_suites;
+  \runit->runner->total_of_successeded_suites +=
+      total_of_successeded_suites;
+  \runit->runner->total_of_failed_suites += total_of_failed_suites;
+  \runit->runner->total_of_interrupted_suites +=
+      total_of_interrupted_suites;
+  \r\rreturn 0;
+\r}
+
+\r\rint \r unit_reset(unit_t unit) \r
+{
+  \runit_t cur;
+  \runsigned int i;
+  \r\r
+      /* reset all the suites of the unit */ \r
+      xbt_dynar_foreach(unit->suites, i, cur) \r {
+    \runit_reset(cur);
+  \r\r\r\r
+      /* reset all the includes of the unit */ \r
+      xbt_dynar_foreach(unit->includes, i, cur) \r {
+    \runit_reset(cur);
+  \r\r\rfseek(unit->fstream->stream, 0L, SEEK_SET);
+  \runit->parsed = 0;
+  \runit->cmd_nb = 0;
+  \runit->started_cmd_nb = 0;
+  \runit->interrupted_cmd_nb = 0;
+  \runit->failed_cmd_nb = 0;
+  \runit->successeded_cmd_nb = 0;
+  \runit->terminated_cmd_nb = 0;
+  \runit->waiting_cmd_nb = 0;
+  \runit->interrupted = 0;
+  \runit->failed = 0;
+  \runit->successeded = 0;
+  \runit->parsed = 0;
+  \runit->released = 0;
+  \runit->is_running_suite = 0;
+  \r\rif (unit->description)
+    \r {
+    \rfree(unit->description);
+    \runit->description = NULL;
+    \r}
+  \r\runit->exit_code = 0;
+  \r\rreturn 0;
+\r}
+
 \r
-       unit->exit_code = 0;\r
-       \r
-       return 0;\r
-}\r
index b590f22..f18b6db 100644 (file)
 #include <units.h>\r
 #include <unit.h>\r
 #include <fstreams.h>\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-units_t\r
-units_new(runner_t runner, fstreams_t fstreams)\r
-{\r
-       fstream_t fstream;\r
-       unsigned int i;\r
-       unit_t unit;\r
-       \r
-       units_t units =  xbt_new0(s_units_t, 1);\r
-\r
-       units->items = xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t)unit_free);\r
-\r
-       xbt_dynar_foreach(fstreams->items, i, fstream)\r
-       {\r
-               unit = unit_new(runner, NULL, NULL, fstream);\r
-               xbt_dynar_push(units->items, &unit);\r
-       }\r
-       \r
-       return units;\r
-}\r
-\r
-\r
-int\r
-units_is_empty(units_t units)\r
-{\r
-       if(!units)\r
-       {\r
-               errno = EINVAL;\r
-               return 0;\r
-       }\r
-       \r
-       return (0 == xbt_dynar_length(units->items));\r
-}\r
-\r
-int\r
-units_get_size(units_t units)\r
-{\r
-       if(!units)\r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-\r
-       return xbt_dynar_length(units->items);\r
-}\r
-\r
-\r
-int\r
-units_run_all(units_t units, xbt_os_mutex_t mutex)\r
-{\r
-       unit_t unit;\r
-       unsigned int i;\r
-       \r
-       if(!units)\r
-               return EINVAL;\r
-               \r
-       if(!xbt_dynar_length(units->items))\r
-               return EAGAIN;\r
-\r
-       xbt_dynar_foreach(units->items, i, unit)\r
-       {\r
-               xbt_os_sem_acquire(jobs_sem);\r
-               unit_run(unit, mutex);\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-units_join_all(units_t units)\r
-{\r
-       unit_t unit;\r
-       unsigned int i;\r
-       \r
-       if(!units)\r
-               return EINVAL;\r
-               \r
-       if(!xbt_dynar_length(units->items))\r
-               return EAGAIN;\r
-\r
-       xbt_dynar_foreach(units->items, i, unit)\r
-       {\r
-               if(unit->thread)\r
-                       xbt_os_thread_join(unit->thread, NULL);\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-units_interrupt_all(units_t units)\r
-{\r
-       unit_t unit;\r
-       unsigned int i;\r
-       \r
-       if(!units)\r
-               return EINVAL;\r
-\r
-       if(!xbt_dynar_length(units->items))\r
-               return EAGAIN;\r
-\r
-       xbt_dynar_foreach(units->items, i, unit)\r
-       {\r
-               if(!(unit->successeded) && !(unit->interrupted))\r
-                       unit_interrupt(unit);\r
-               else\r
-               {\r
-                       if(!unit->released && unit->sem)\r
-                       {\r
-                               unit->released = 1;\r
-                               xbt_os_sem_release(unit->sem);\r
-                       }\r
-               }\r
-                       \r
-       }\r
-       \r
-       return 0;\r
-}\r
-\r
-int\r
-units_summuarize(units_t units)\r
-{\r
-       unit_t unit;\r
-       unsigned int i;\r
-\r
-       if(!units)\r
-               return EINVAL;\r
-\r
-       if(!xbt_dynar_length(units->items))\r
-               return EAGAIN;\r
-\r
-       xbt_dynar_foreach(units->items, i, unit)\r
-       {\r
-               unit_summuarize(unit);\r
-       }\r
-       \r
-       return 0;\r
-       \r
-}\r
-\r
-int\r
-units_reset_all(units_t units)\r
-{\r
-       unit_t unit;\r
-       unsigned int i;\r
-       \r
-       if(!units)\r
-               return EINVAL;\r
-       \r
-       if(!xbt_dynar_length(units->items))\r
-               return EAGAIN;\r
-\r
-       xbt_dynar_foreach(units->items, i, unit)\r
-       {\r
-               unit_reset(unit);\r
-       }\r
-       return 0;\r
-}\r
-\r
-int\r
-units_free(void** unitsptr)\r
-{\r
-       if(!(*unitsptr))\r
-               return EINVAL;\r
-       \r
-       if((*((units_t*)unitsptr))->items)\r
-               xbt_dynar_free(&((*((units_t*)unitsptr))->items));\r
-               \r
-       free(*unitsptr);\r
-       *unitsptr = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\runits_t \r units_new(runner_t runner, fstreams_t fstreams) \r
+{
+  \rfstream_t fstream;
+  \runsigned int i;
+  \runit_t unit;
+  \r\runits_t units = xbt_new0(s_units_t, 1);
+  \r\runits->items =
+      xbt_dynar_new(sizeof(unit_t), (void_f_pvoid_t) unit_free);
+  \r\rxbt_dynar_foreach(fstreams->items, i, fstream) \r {
+    \runit = unit_new(runner, NULL, NULL, fstream);
+    \rxbt_dynar_push(units->items, &unit);
+  \r}
+  \r\rreturn units;
+\r}
+
+\r\r\rint \r units_is_empty(units_t units) \r
+{
+  \rif (!units)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn 0;
+    \r}
+  \r\rreturn (0 == xbt_dynar_length(units->items));
+\r}
+
+\r\rint \r units_get_size(units_t units) \r
+{
+  \rif (!units)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rreturn xbt_dynar_length(units->items);
+\r}
+
+\r\r\rint \r units_run_all(units_t units, xbt_os_mutex_t mutex) \r
+{
+  \runit_t unit;
+  \runsigned int i;
+  \r\rif (!units)
+    \rreturn EINVAL;
+  \r\rif (!xbt_dynar_length(units->items))
+    \rreturn EAGAIN;
+  \r\rxbt_dynar_foreach(units->items, i, unit) \r {
+    \rxbt_os_sem_acquire(jobs_sem);
+    \runit_run(unit, mutex);
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r units_join_all(units_t units) \r
+{
+  \runit_t unit;
+  \runsigned int i;
+  \r\rif (!units)
+    \rreturn EINVAL;
+  \r\rif (!xbt_dynar_length(units->items))
+    \rreturn EAGAIN;
+  \r\rxbt_dynar_foreach(units->items, i, unit) \r {
+    \rif (unit->thread)
+      \rxbt_os_thread_join(unit->thread, NULL);
+  \r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r units_interrupt_all(units_t units) \r
+{
+  \runit_t unit;
+  \runsigned int i;
+  \r\rif (!units)
+    \rreturn EINVAL;
+  \r\rif (!xbt_dynar_length(units->items))
+    \rreturn EAGAIN;
+  \r\rxbt_dynar_foreach(units->items, i, unit) \r {
+    \rif (!(unit->successeded) && !(unit->interrupted))
+      \runit_interrupt(unit);
+    \r
+    else
+      \r {
+      \rif (!unit->released && unit->sem)
+        \r {
+        \runit->released = 1;
+        \rxbt_os_sem_release(unit->sem);
+        \r}
+      \r}
+  \r\r}
+  \r\rreturn 0;
+\r}
+
+\r\rint \r units_summuarize(units_t units) \r
+{
+  \runit_t unit;
+  \runsigned int i;
+  \r\rif (!units)
+    \rreturn EINVAL;
+  \r\rif (!xbt_dynar_length(units->items))
+    \rreturn EAGAIN;
+  \r\rxbt_dynar_foreach(units->items, i, unit) \r {
+    \runit_summuarize(unit);
+  \r}
+  \r\rreturn 0;
+\r\r}
+
+\r\rint \r units_reset_all(units_t units) \r
+{
+  \runit_t unit;
+  \runsigned int i;
+  \r\rif (!units)
+    \rreturn EINVAL;
+  \r\rif (!xbt_dynar_length(units->items))
+    \rreturn EAGAIN;
+  \r\rxbt_dynar_foreach(units->items, i, unit) \r {
+    \runit_reset(unit);
+  \r}
+  \rreturn 0;
+\r}
+
+\r\rint \r units_free(void **unitsptr) \r
+{
+  \rif (!(*unitsptr))
+    \rreturn EINVAL;
+  \r\rif ((*((units_t *) unitsptr))->items)
+    \rxbt_dynar_free(&((*((units_t *) unitsptr))->items));
+  \r\rfree(*unitsptr);
+  \r*unitsptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\r
index 77268da..5c885a9 100644 (file)
@@ -1,72 +1,52 @@
 #include <variable.h>\r
+\r XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rvariable_t \r variable_new(const char *name, const char *val) \r
+{
+  \rvariable_t variable;
+  \r\rif (!name)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rvariable = xbt_new0(s_variable_t, 1);
+  \r\rvariable->name = strdup(name);
+  \r\rif (val)
+    \rvariable->val = strdup(val);
+  \r\rvariable->used = 0;
+  \rvariable->env = 0;
+  \rvariable->err = 0;
+  \r\rreturn variable;
+\r\r}
+
+\r\rint \r variable_free(variable_t * variableptr) \r
+{
+  \rif (!(*variableptr))
+    \rreturn EINVAL;
+  \r\rif ((*((variable_t *) (variableptr)))->name)
+    \rfree((*((variable_t *) (variableptr)))->name);
+  \r\rif ((*((variable_t *) (variableptr)))->val)
+    \rfree((*((variable_t *) (variableptr)))->val);
+  \r\rfree(*variableptr);
+  \r\r*variableptr = NULL;
+  \rreturn 0;
+\r}
+
+\r\r\rint \r variable_is_used(variable_t variable) \r
+{
+  \rif (!variable)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn 0;
+    \r}
+  \r\rreturn variable->used;
+\r}
+
+\r\r\rint \r variable_set_used(variable_t variable) \r
+{
+  \rif (!variable)
+    \rreturn EINVAL;
+  \r\rvariable->used = 1;
+  \r\rreturn 0;
+\r}
+
 \r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-variable_t\r
-variable_new(const char* name, const char* val)\r
-{\r
-       variable_t variable;\r
-       \r
-       if(!name)\r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-       \r
-       variable = xbt_new0(s_variable_t, 1);\r
-       \r
-       variable->name = strdup(name);\r
-\r
-       if(val)\r
-               variable->val = strdup(val);\r
-\r
-       variable->used = 0;\r
-       variable->env = 0;\r
-       variable->err = 0;\r
-       \r
-       return variable;\r
-       \r
-}\r
-\r
-int\r
-variable_free(variable_t* variableptr)\r
-{\r
-       if(!(*variableptr))\r
-               return EINVAL;\r
-       \r
-       if((*((variable_t*)(variableptr)))->name)\r
-               free((*((variable_t*)(variableptr)))->name);\r
-       \r
-       if((*((variable_t*)(variableptr)))->val)\r
-               free((*((variable_t*)(variableptr)))->val);\r
-       \r
-       free(*variableptr);\r
-       \r
-       *variableptr = NULL;\r
-       return 0;\r
-}\r
-\r
-\r
-int\r
-variable_is_used(variable_t variable)\r
-{\r
-       if(!variable)\r
-       {\r
-               errno = EINVAL;\r
-               return 0;\r
-       }\r
-               \r
-       return variable->used;\r
-}\r
-\r
-\r
-int\r
-variable_set_used(variable_t variable)\r
-{\r
-       if(!variable)\r
-               return EINVAL;\r
-       \r
-       variable->used = 1;\r
-       \r
-       return 0;\r
-}\r
index f1f13c5..25ef8e2 100644 (file)
  *             This file contains all the definitions of the functions related with\r
  *             the tesh writer type.\r
  *\r
- */\r
\r
+ */  \r
+    \r
 #include <writer.h>\r
 #include <command.h>\r
 #include <unit.h>\r
-\r
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
-\r
-static void*\r
-writer_start_routine(void* p);\r
-\r
-writer_t\r
-writer_new(command_t command)\r
-{\r
-       writer_t writer;\r
-       /* TODO : check the parameter */\r
-       \r
-       writer = xbt_new0(s_writer_t, 1);\r
-\r
-       writer->thread = NULL;\r
-       writer->command = command;\r
-       writer->written = xbt_os_sem_init(0);\r
-       writer->can_write = xbt_os_sem_init(0);\r
-       \r
-       writer->done = 0;\r
-\r
-       return writer;\r
-}\r
-\r
-int\r
-writer_free(writer_t* ptr)\r
-{\r
-\r
-       if((*ptr)->written)\r
-               xbt_os_sem_destroy((*ptr)->written);\r
-       \r
-       if((*ptr)->can_write)\r
-               xbt_os_sem_destroy((*ptr)->can_write);\r
-       \r
-       free(*ptr);\r
-\r
-       *ptr = NULL;\r
-       \r
-       return 0;\r
-}\r
-\r
-void\r
-writer_write(writer_t writer)\r
-{\r
-       writer->thread = xbt_os_thread_create("", writer_start_routine, writer);\r
-}\r
-\r
+    \rXBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+\r\rstatic void *\r writer_start_routine(void *p);
+\r\rwriter_t \r writer_new(command_t command) \r
+{
+  \rwriter_t writer;
+  \r
+      /* TODO : check the parameter */ \r
+      \rwriter = xbt_new0(s_writer_t, 1);
+  \r\rwriter->thread = NULL;
+  \rwriter->command = command;
+  \rwriter->written = xbt_os_sem_init(0);
+  \rwriter->can_write = xbt_os_sem_init(0);
+  \r\rwriter->done = 0;
+  \r\rreturn writer;
+\r}
+
+\r\rint \r writer_free(writer_t * ptr) \r
+{
+  \r\rif ((*ptr)->written)
+    \rxbt_os_sem_destroy((*ptr)->written);
+  \r\rif ((*ptr)->can_write)
+    \rxbt_os_sem_destroy((*ptr)->can_write);
+  \r\rfree(*ptr);
+  \r\r*ptr = NULL;
+  \r\rreturn 0;
+\r}
+
+\r\rvoid \r writer_write(writer_t writer) \r
+{
+  \rwriter->thread = xbt_os_thread_create("", writer_start_routine, writer);
+\r\r\r
+
 #ifdef _XBT_WIN32\r
-static void*\r
-writer_start_routine(void* p)\r
-{\r
-       writer_t writer = (writer_t)p;\r
-       command_t command = writer->command;\r
-       \r
-       char* input = (char*)(command->context->input->data);\r
-       \r
-       DWORD number_of_bytes_to_write = command->context->input->used;\r
-       DWORD number_of_bytes_written = 0;\r
-\r
-       xbt_os_sem_release(writer->written);\r
-\r
-       while(!command->failed && !command->interrupted && !command->successeded && ! writer->failed && ! writer->broken_pipe && number_of_bytes_to_write)\r
-       {\r
-               if(!WriteFile(writer->command->stdin_fd, input, number_of_bytes_to_write, &number_of_bytes_written, NULL))\r
-               {\r
-                       if(GetLastError() ==  ERROR_NO_DATA)\r
-                               writer->broken_pipe = 1;\r
-                       else\r
-                       writer->failed = 1;\r
-                               \r
-               }\r
-               else\r
-               {\r
-                       input += number_of_bytes_written;\r
-                       number_of_bytes_to_write -= number_of_bytes_written;\r
-               }\r
-       }\r
-       \r
-       command->context->input->data[0]='\0';\r
-       command->context->input->used=0;\r
-       \r
-       if(writer->failed  && !command->successeded && !command->failed && !command->interrupted)\r
-       {\r
-               ERROR2("[%s] Error while writing input to child `%s'", command->context->pos, command->context->command_line);\r
-               unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
-               command_handle_failure(command, csr_write_failure);\r
-       }\r
-       /*else if(writer->broken_pipe && !command->successeded && !command->failed && !command->interrupted)\r
-       {\r
-\r
-               ERROR2("[%s] Pipe broken while writing input to child `%s'", command->context->pos, command->context->command_line);\r
-               unit_set_error(command->unit, (int)GetLastError(), 0);\r
-               command_kill(command);\r
-               command_handle_failure(command, csr_write_pipe_broken);\r
-       }*/\r
-\r
-       CloseHandle(command->stdin_fd);\r
-       command->stdin_fd = INDEFINITE_FD;\r
-\r
-       return NULL;\r
-}\r
-#else\r
-static void* \r
-writer_start_routine(void* p) \r
-{\r
-       writer_t writer = (writer_t)p;\r
-       command_t command = writer->command;\r
-       int number_of_bytes_to_write = command->context->input->used;\r
-       char* input = (char*)(command->context->input->data);\r
-       int got;\r
-       int released = 0;\r
-       \r
-       while(!command->failed && !command->interrupted && !command->successeded && number_of_bytes_to_write > 0)\r
-       {\r
-               got = number_of_bytes_to_write > PIPE_BUF ? PIPE_BUF : number_of_bytes_to_write;\r
-               got = write(writer->command->stdin_fd, input, got );\r
-               \r
-               if(got < 0) \r
-               {\r
-                       if(EINTR == errno)\r
-                               continue;\r
-                               \r
-                       else if(EAGAIN == errno)\r
-                       {/* the pipe is full */\r
-                               if(!released)\r
-                               {\r
-                                       xbt_os_sem_release(writer->written);\r
-                                       released = 1;\r
-                                       xbt_os_thread_yield();\r
-                               }\r
-                               \r
-                               continue;\r
-                       }\r
-                       else if(EPIPE == errno) \r
-                       {\r
-                               writer->broken_pipe = 1;\r
-                               break;\r
-                       } \r
-                       else\r
-                       {\r
-                               writer->failed = 1;\r
-                               break;\r
-                       }\r
-                       \r
-               }\r
-               \r
-               number_of_bytes_to_write -= got;\r
-               input += got;\r
-               \r
-               if(got == 0)\r
-                       xbt_os_thread_yield();\r
-               \r
-       }\r
-       \r
-       if(!released)\r
-               xbt_os_sem_release(writer->written);\r
-       \r
-       \r
-       if(close(command->stdin_fd) < 0)\r
-       {\r
-               /* TODO */\r
-       }\r
-       else\r
-               command->stdin_fd = INDEFINITE_FD;\r
-       \r
-       command->context->input->data[0]='\0';\r
-       command->context->input->used=0;\r
-       \r
-       if(writer->failed && !command->successeded && !command->failed && !command->interrupted)\r
-       {\r
-               command_kill(command);\r
-               ERROR2("[%s] Error while writing input to child `%s'", command->context->pos, command->context->command_line);\r
-               \r
-               unit_set_error(command->unit, errno, 0, command->context->pos);\r
-               command_handle_failure(command, csr_write_failure);\r
-       }\r
-       else if(writer->broken_pipe && !command->successeded && !command->failed && !command->interrupted)\r
-       {\r
-               ERROR2("[%s] Pipe broken while writing input to child `%s'", command->context->pos, command->context->command_line);\r
-\r
-               unit_set_error(command->unit, errno, 0, command->context->pos);\r
-               command_kill(command);\r
-               command_handle_failure(command, csr_write_pipe_broken);\r
-       }\r
-       \r
-       writer->done = 1;\r
-       \r
-       return NULL;\r
-       \r
-}\r
-\r
-#endif\r
-void\r
-writer_wait(writer_t writer)\r
-{\r
-       xbt_os_thread_join(writer->thread, NULL);\r
-\r
-}\r
+static void *\r writer_start_routine(void *p) \r
+{
+  \rwriter_t writer = (writer_t) p;
+  \rcommand_t command = writer->command;
+  \r\rchar *input = (char *) (command->context->input->data);
+  \r\rDWORD number_of_bytes_to_write = command->context->input->used;
+  \rDWORD number_of_bytes_written = 0;
+  \r\rxbt_os_sem_release(writer->written);
+  \r\rwhile (!command->failed && !command->interrupted
+           && !command->successeded && !writer->failed
+           && !writer->broken_pipe && number_of_bytes_to_write)
+    \r {
+    \rif (!WriteFile
+         (writer->command->stdin_fd, input, number_of_bytes_to_write,
+          &number_of_bytes_written, NULL))
+      \r {
+      \rif (GetLastError() == ERROR_NO_DATA)
+        \rwriter->broken_pipe = 1;
+      \r
+      else
+        \rwriter->failed = 1;
+      \r\r}
+    \r
+    else
+      \r {
+      \rinput += number_of_bytes_written;
+      \rnumber_of_bytes_to_write -= number_of_bytes_written;
+      \r}
+    \r}
+  \r\rcommand->context->input->data[0] = '\0';
+  \rcommand->context->input->used = 0;
+  \r\rif (writer->failed && !command->successeded && !command->failed
+        && !command->interrupted)
+    \r {
+    \rERROR2("[%s] Error while writing input to child `%s'",
+            command->context->pos, command->context->command_line);
+    \runit_set_error(command->unit, (int) GetLastError(), 0,
+                    command->context->pos);
+    \rcommand_handle_failure(command, csr_write_failure);
+    \r}
+  \r
+      /*else if(writer->broken_pipe && !command->successeded && !command->failed && !command->interrupted)\r
+         {\r
+         \r
+         ERROR2("[%s] Pipe broken while writing input to child `%s'", command->context->pos, command->context->command_line);\r
+         unit_set_error(command->unit, (int)GetLastError(), 0);\r
+         command_kill(command);\r
+         command_handle_failure(command, csr_write_pipe_broken);\r
+         } */ \r
+      \rCloseHandle(command->stdin_fd);
+  \rcommand->stdin_fd = INDEFINITE_FD;
+  \r\rreturn NULL;
+\r}
+
+\r
+#else   /* \r */
+static void *\r writer_start_routine(void *p) \r
+{
+  \rwriter_t writer = (writer_t) p;
+  \rcommand_t command = writer->command;
+  \rint number_of_bytes_to_write = command->context->input->used;
+  \rchar *input = (char *) (command->context->input->data);
+  \rint got;
+  \rint released = 0;
+  \r\rwhile (!command->failed && !command->interrupted
+           && !command->successeded && number_of_bytes_to_write > 0)
+    \r {
+    \rgot =
+        number_of_bytes_to_write >
+        PIPE_BUF ? PIPE_BUF : number_of_bytes_to_write;
+    \rgot = write(writer->command->stdin_fd, input, got);
+    \r\rif (got < 0)
+      \r {
+      \rif (EINTR == errno)
+        \rcontinue;
+      \r\r
+      else if (EAGAIN == errno)
+        \r {                     /* the pipe is full */
+        \rif (!released)
+          \r {
+          \rxbt_os_sem_release(writer->written);
+          \rreleased = 1;
+          \rxbt_os_thread_yield();
+          \r}
+        \r\rcontinue;
+        \r}
+      \r
+      else if (EPIPE == errno)
+        \r {
+        \rwriter->broken_pipe = 1;
+        \rbreak;
+        \r}
+      \r
+      else
+        \r {
+        \rwriter->failed = 1;
+        \rbreak;
+        \r}
+      \r\r}
+    \r\rnumber_of_bytes_to_write -= got;
+    \rinput += got;
+    \r\rif (got == 0)
+      \rxbt_os_thread_yield();
+    \r\r}
+  \r\rif (!released)
+    \rxbt_os_sem_release(writer->written);
+  \r\r\rif (close(command->stdin_fd) < 0)
+    \r {
+    \r
+        /* TODO */ \r
+    }
+  \r
+  else
+    \rcommand->stdin_fd = INDEFINITE_FD;
+  \r\rcommand->context->input->data[0] = '\0';
+  \rcommand->context->input->used = 0;
+  \r\rif (writer->failed && !command->successeded && !command->failed
+        && !command->interrupted)
+    \r {
+    \rcommand_kill(command);
+    \rERROR2("[%s] Error while writing input to child `%s'",
+            command->context->pos, command->context->command_line);
+    \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+    \rcommand_handle_failure(command, csr_write_failure);
+    \r}
+  \r
+  else if (writer->broken_pipe && !command->successeded && !command->failed
+           && !command->interrupted)
+    \r {
+    \rERROR2("[%s] Pipe broken while writing input to child `%s'",
+            command->context->pos, command->context->command_line);
+    \r\runit_set_error(command->unit, errno, 0, command->context->pos);
+    \rcommand_kill(command);
+    \rcommand_handle_failure(command, csr_write_pipe_broken);
+    \r}
+  \r\rwriter->done = 1;
+  \r\rreturn NULL;
+\r\r}
+
+\r\r
+#endif  /* \r */
+void \r writer_wait(writer_t writer) \r
+{
+  \rxbt_os_thread_join(writer->thread, NULL);
+\r\r\r
index 0b8deff..91c474f 100644 (file)
 #include <xerrno.h>\r
-\r
-typedef struct s_entry\r
-{\r
-       const char* name;\r
-       int code;\r
-       unsigned kind : 1;              /* if 1 it's an error of the application else assume it's a system error */\r
-       const char* string;\r
-       \r
-}entry_t;\r
-\r
-\r
-static const\r
-entry_t err[] =\r
-{\r
-       \r
-       #ifdef E2BIG\r
-       {"E2BIG", E2BIG, 0, "argument list too long"},\r
-       #endif\r
-       \r
-       #ifdef EACCES\r
-       {"EACCES", EACCES, 0, "permission denied"},\r
-       #endif\r
-       \r
-       #ifdef EADDRINUSE\r
-       {"EADDRINUSE", EADDRINUSE, 0, "address in use"},\r
-       #endif\r
-       \r
-       #ifdef EADDRNOTAVAIL\r
-       {"EADDRNOTAVAIL", EADDRNOTAVAIL, 0, "address not available"},\r
-       #endif\r
-       \r
-       #ifdef EAFNOSUPPORT\r
-       {"EAFNOSUPPORT", EAFNOSUPPORT, 0, "address family not supported"},\r
-       #endif\r
-       \r
-       #ifdef EAGAIN\r
-       {"EAGAIN", EAGAIN, 0, "resource unavailable, try again"},\r
-       #endif\r
-       \r
-       #ifdef EALREADY\r
-       {"EALREADY", EALREADY, 0, "connection already in progress"},\r
-       #endif\r
-       \r
-       #ifdef EBADF\r
-       {"EBADF", EBADF, 0, "bad file descriptor"},\r
-       #endif\r
-       \r
-       #ifdef EBADMSG\r
-       {"EBADMSG", EBADMSG, 0, "bad message"},\r
-       #endif\r
-       \r
-       #ifdef EBUSY\r
-       {"EBUSY", EBUSY, 0, "device or resource busy"},\r
-       #endif\r
-       \r
-       #ifdef ECANCELED\r
-       {"ECANCELED", ECANCELED, 0, "operation canceled"},\r
-       #endif\r
-       \r
-       #ifdef ECHILD\r
-       {"ECHILD", ECHILD, 0, "no child processes"},\r
-       #endif\r
-       \r
-       #ifdef ECONNABORTED\r
-       {"ECONNABORTED", ECONNABORTED, 0, "connection aborted"},\r
-       #endif\r
-       \r
-       #ifdef ECONNREFUSED\r
-       {"ECONNREFUSED", ECONNREFUSED, 0, "connection refused"},\r
-       #endif\r
-       \r
-       #ifdef ECONNRESET\r
-       {"ECONNRESET", ECONNRESET, 0, "connection reset"},\r
-       #endif\r
-       \r
-       #ifdef EDEADLK\r
-       {"EDEADLK", EDEADLK, 0, "resource deadlock would occur"},\r
-       #endif\r
-       \r
-       #ifdef EDESTADDRREQ\r
-       {"EDESTADDRREQ", EDESTADDRREQ, 0, "destination address required"},\r
-       #endif\r
-       \r
-       #ifdef EDOM\r
-       {"EDOM", EDOM, 0, "mathematics argument out of domain of function"},\r
-       #endif \r
-       \r
-       #ifdef EEXIST\r
-       {"EEXIST", EEXIST, 0, "file exists"},\r
-       #endif\r
-       \r
-       #ifdef EFAULT\r
-       {"EFAULT", EFAULT, 0, "bad address"},\r
-       #endif\r
-       \r
-       #ifdef EFBIG\r
-       {"EFBIG", EFBIG, 0, "file too large"},\r
-       #endif\r
-       \r
-       #ifdef EHOSTUNREACH\r
-       {"EHOSTUNREACH", EHOSTUNREACH, 0, "host is unreachable"},\r
-       #endif\r
-       \r
-       #ifdef EIDRM\r
-       {"EIDRM", EIDRM, 0, "identifier removed"},\r
-       #endif\r
-       \r
-       #ifdef EILSEQ\r
-       {"EILSEQ", EILSEQ, 0, "illegal byte sequence"},\r
-       #endif\r
-       \r
-       #ifdef EINPROGRESS\r
-       {"EINPROGRESS", EINPROGRESS, 0, "operation in progress"},\r
-       #endif\r
-       \r
-       #ifdef EINTR\r
-       {"EINTR", EINTR, 0, "interrupted function"},\r
-       #endif\r
-       \r
-       #ifdef EINVAL\r
-       {"EINVAL", EINVAL, 0, "invalid argument"},\r
-       #endif\r
-       \r
-       #ifdef EIO\r
-       {"EIO", EIO, 0, "I/O error"},\r
-       #endif\r
-       \r
-       #ifdef EISCONN\r
-       {"EISCONN", EISCONN, 0, "socket is connected"},\r
-       #endif\r
-       \r
-       #ifdef EISDIR\r
-       {"EISDIR", EISDIR, 0, "is a directory"},\r
-       #endif\r
-       \r
-       #ifdef ELOOP\r
-       {"ELOOP", ELOOP, 0, "too many levels of symbolic links"},\r
-       #endif\r
-       \r
-       #ifdef EMFILE\r
-       {"EMFILE", EMFILE, 0, "too many open files"},\r
-       #endif\r
-       \r
-       #ifdef EMLINK\r
-       {"EMLINK", EMLINK, 0, "too many links"},\r
-       #endif\r
-       \r
-       #ifdef EMSGSIZE\r
-       {"EMSGSIZE", EMSGSIZE, 0, "message too large"},\r
-       #endif\r
-       \r
-       #ifdef ENAMETOOLONG\r
-       {"ENAMETOOLONG", ENAMETOOLONG, 0, "filename too long"},\r
-       #endif\r
-       \r
-       #ifdef ENETDOWN\r
-       {"ENETDOWN", ENETDOWN, 0, "network is down"},\r
-       #endif\r
-       \r
-       #ifdef ENETRESET\r
-       {"ENETRESET", ENETRESET, 0, "connection aborted by network"},\r
-       #endif\r
-       \r
-       #ifdef ENETUNREACH\r
-       {"ENETUNREACH", ENETUNREACH, 0, "network unreachable"},\r
-       #endif\r
-       \r
-       #ifdef ENFILE\r
-       {"ENFILE", ENFILE, 0, "too many files open in system"},\r
-       #endif\r
-       \r
-       #ifdef ENOBUFS\r
-       {"ENOBUFS", ENOBUFS, 0, "no buffer space available"},\r
-       #endif\r
-       \r
-       #ifdef ENODATA\r
-       {"ENODATA", ENODATA, 0, "no message is available on the STREAM head read queue"},\r
-       #endif\r
-       \r
-       #ifdef ENODEV\r
-       {"ENODEV", ENODEV, 0, "no such device"},\r
-       #endif\r
-       \r
-       #ifdef ENOENT\r
-       {"ENOENT", ENOENT, 0, "no such file or directory"},\r
-       #endif\r
-       \r
-       #ifdef ENOEXEC\r
-       {"ENOEXEC", ENOEXEC, 0, "executable file format error"},\r
-       #endif\r
-       \r
-       #ifdef ENOLCK\r
-       {"ENOLCK", ENOLCK, 0, "no locks available"},\r
-       #endif\r
-       \r
-       #ifdef ENOMEM\r
-       {"ENOMEM", ENOMEM, 0, "not enough space"},\r
-       #endif\r
-       \r
-       #ifdef ENOMSG\r
-       {"ENOMSG", ENOMSG, 0, "no message of the desired type"},\r
-       #endif\r
-       \r
-       #ifdef ENOPROTOOPT\r
-       {"ENOPROTOOPT", ENOPROTOOPT, 0, "protocol not available"},\r
-       #endif\r
-       \r
-       #ifdef ENOSPC\r
-       {"ENOSPC", ENOSPC, 0, "no space left on device"},\r
-       #endif\r
-       \r
-       #ifdef ENOSR\r
-       {"ENOSR", ENOSR, 0, "no stream resources"},\r
-       #endif\r
-       \r
-       #ifdef ENOSTR\r
-       {"ENOSTR", ENOSTR, 0, "not a stream"},\r
-       #endif\r
-       \r
-       #ifdef ENOSYS\r
-       {"ENOSYS", ENOSYS, 0, "function not supported"},\r
-       #endif\r
-       \r
-       #ifdef ENOTCONN\r
-       {"ENOTCONN", ENOTCONN, 0, "the socket is not connected"},\r
-       #endif\r
-       \r
-       #ifdef ENOTDIR\r
-       {"ENOTDIR", ENOTDIR, 0, "not a directory"},\r
-       #endif\r
-       \r
-       #ifdef ENOTEMPTY\r
-       {"ENOTEMPTY", ENOTEMPTY, 0, "directory not empty"},\r
-       #endif\r
-       \r
-       #ifdef ENOTSOCK\r
-       {"ENOTSOCK", ENOTSOCK, 0, "not a socket"},\r
-       #endif\r
-       \r
-       #ifdef ENOTSUP\r
-       {"ENOTSUP", ENOTSUP, 0, "not supported"},\r
-       #endif\r
-       \r
-       #ifdef ENOTTY\r
-       {"ENOTTY", ENOTTY, 0, "inappropriate I/O control operation"},\r
-       #endif\r
-       \r
-       #ifdef ENXIO\r
-       {"ENXIO", ENXIO, 0, "no such device or address"},\r
-       #endif\r
-       \r
-       #ifdef EOPNOTSUPP\r
-       {"EOPNOTSUPP", EOPNOTSUPP, 0, "operation not supported on socket"},\r
-       #endif\r
-       \r
-       #ifdef EOVERFLOW\r
-       {"EOVERFLOW", EOVERFLOW, 0, "value too large to be stored in data type"},\r
-       #endif\r
-       \r
-       #ifdef EPERM\r
-       {"EPERM", EPERM, 0, "operation not permitted"},\r
-       #endif\r
-       \r
-       #ifdef EPIPE\r
-       {"EPIPE", EPIPE, 0, "broken pipe"},\r
-       #endif\r
-       \r
-       #ifdef EPROTO\r
-       {"EPROTO", EPROTO, 0, "protocol error"},\r
-       #endif\r
-       \r
-       #ifdef EPROTONOSUPPORT\r
-       {"EPROTONOSUPPORT", EPROTONOSUPPORT, 0, "protocol not supported"},\r
-       #endif\r
-       \r
-       #ifdef EPROTOTYPE\r
-       {"EPROTOTYPE", EPROTOTYPE, 0, "protocol wrong type for socket"},\r
-       #endif\r
-       \r
-       #ifdef ERANGE\r
-       {"ERANGE", ERANGE, 0, "result too large"},\r
-       #endif\r
-       \r
-       #ifdef EROFS\r
-       {"EROFS", EROFS, 0, "read-only file system"},\r
-       #endif\r
-       \r
-       #ifdef ESPIPE\r
-       {"ESPIPE", ESPIPE, 0, "invalid seek"},\r
-       #endif\r
-       \r
-       #ifdef ESRCH\r
-       {"ESRCH", ESRCH, 0, "no such process"},\r
-       #endif\r
-       \r
-       #ifdef ETIME\r
-       {"ETIME", ETIME, 0, "stream ioctl() timeout"},\r
-       #endif\r
-       \r
-       #ifdef ETIMEDOUT\r
-       {"ETIMEDOUT", ETIMEDOUT, 0, "connection timed out"},\r
-       #endif\r
-       \r
-       #ifdef ETXTBSY\r
-       {"ETXTBSY", ETXTBSY, 0, "text file busy"},\r
-       #endif\r
-       \r
-       #ifdef EWOULDBLOCK\r
-       {"EWOULDBLOCK", EWOULDBLOCK, 0, "operation would block"},\r
-       #endif\r
-       \r
-       #ifdef EXDEV\r
-       {"EXDEV", EXDEV, 0, "cross-device link"},\r
-       #endif\r
-       \r
-       {"ECMDTIMEDOUT", ECMDTIMEDOUT, 1, "command timed out"},\r
-\r
-       {"ECMDNOTFOUND", ECMDNOTFOUND,1,  "command not found"},\r
-\r
-       {"EEXITCODENOTMATCH", EEXITCODENOTMATCH,1,  "exit code mismatch"},\r
-\r
-       {"EOUTPUTNOTMATCH", EOUTPUTNOTMATCH,1,  "output mismatch"},\r
-\r
-       {"ESIGNOTMATCH", ESIGNOTMATCH,1,  "signal mismatch"},\r
-\r
-       {"EUNXPSIG", EUNXPSIG,1,  "unexpected signal caught"},\r
-\r
-       {"ESIGNOTRECEIPT", ESIGNOTRECEIVED,1,  "expected signal not receipt"},\r
-\r
-       {"EPROCCMDLINE", EPROCCMDLINE, 1, "command line processing failed"},\r
-\r
-       {"ENOARG", ENOARG, 1, "none optional argument not specified"},\r
-\r
-       {"ENOTPOSITIVENUM", ENOTPOSITIVENUM, 1, "argument option not strictly positive"},\r
-\r
-       {"ESYNTAX", ESYNTAX,1,  "syntax error"},\r
-\r
-       {"ELEADTIME", ELEADTIME, 1, "timed out"},\r
-\r
-       {"EREADMENOTFOUND", EREADMENOTFOUND,1,  "unable to locate the README.txt file"},\r
-\r
-       {"EINCLUDENOTFOUND", EINCLUDENOTFOUND, 1,  "include file not found"},\r
-\r
-       {"ESUFFIXTOOLONG", ESUFFIXTOOLONG,1,  "suffix too long"},\r
-\r
-       {"EINVCMDLINE", EINVCMDLINE,1,  "invalid command line"},\r
-\r
-       {"unkwown", -1, 0, "unknown"}\r
-};\r
-\r
+\r typedef struct s_entry \r {
+  \rconst char *name;
+  \r int code;
+  \r unsigned kind:1;            /* if 1 it's an error of the application else assume it's a system error */
+  \r const char *string;
+\r \r} entry_t;
+\r\r\rstatic const \r entry_t err[] = \r\r\r
+#ifdef E2BIG\r
+  {"E2BIG", E2BIG, 0, "argument list too long"}, \r
+#endif  /* \r */
+      \r
+#ifdef EACCES\r
+  {"EACCES", EACCES, 0, "permission denied"}, \r
+#endif  /* \r */
+      \r
+#ifdef EADDRINUSE\r
+  {"EADDRINUSE", EADDRINUSE, 0, "address in use"}, \r
+#endif  /* \r */
+      \r
+#ifdef EADDRNOTAVAIL\r
+  {"EADDRNOTAVAIL", EADDRNOTAVAIL, 0, "address not available"}, \r
+#endif  /* \r */
+      \r
+#ifdef EAFNOSUPPORT\r
+  {"EAFNOSUPPORT", EAFNOSUPPORT, 0, "address family not supported"}, \r
+#endif  /* \r */
+      \r
+#ifdef EAGAIN\r
+  {"EAGAIN", EAGAIN, 0, "resource unavailable, try again"}, \r
+#endif  /* \r */
+      \r
+#ifdef EALREADY\r
+  {"EALREADY", EALREADY, 0, "connection already in progress"}, \r
+#endif  /* \r */
+      \r
+#ifdef EBADF\r
+  {"EBADF", EBADF, 0, "bad file descriptor"}, \r
+#endif  /* \r */
+      \r
+#ifdef EBADMSG\r
+  {"EBADMSG", EBADMSG, 0, "bad message"}, \r
+#endif  /* \r */
+      \r
+#ifdef EBUSY\r
+  {"EBUSY", EBUSY, 0, "device or resource busy"}, \r
+#endif  /* \r */
+      \r
+#ifdef ECANCELED\r
+  {"ECANCELED", ECANCELED, 0, "operation canceled"}, \r
+#endif  /* \r */
+      \r
+#ifdef ECHILD\r
+  {"ECHILD", ECHILD, 0, "no child processes"}, \r
+#endif  /* \r */
+      \r
+#ifdef ECONNABORTED\r
+  {"ECONNABORTED", ECONNABORTED, 0, "connection aborted"}, \r
+#endif  /* \r */
+      \r
+#ifdef ECONNREFUSED\r
+  {"ECONNREFUSED", ECONNREFUSED, 0, "connection refused"}, \r
+#endif  /* \r */
+      \r
+#ifdef ECONNRESET\r
+  {"ECONNRESET", ECONNRESET, 0, "connection reset"}, \r
+#endif  /* \r */
+      \r
+#ifdef EDEADLK\r
+  {"EDEADLK", EDEADLK, 0, "resource deadlock would occur"}, \r
+#endif  /* \r */
+      \r
+#ifdef EDESTADDRREQ\r
+  {"EDESTADDRREQ", EDESTADDRREQ, 0, "destination address required"}, \r
+#endif  /* \r */
+      \r
+#ifdef EDOM\r
+  {"EDOM", EDOM, 0, "mathematics argument out of domain of function"}, \r
+#endif  /* \r */
+      \r
+#ifdef EEXIST\r
+  {"EEXIST", EEXIST, 0, "file exists"}, \r
+#endif  /* \r */
+      \r
+#ifdef EFAULT\r
+  {"EFAULT", EFAULT, 0, "bad address"}, \r
+#endif  /* \r */
+      \r
+#ifdef EFBIG\r
+  {"EFBIG", EFBIG, 0, "file too large"}, \r
+#endif  /* \r */
+      \r
+#ifdef EHOSTUNREACH\r
+  {"EHOSTUNREACH", EHOSTUNREACH, 0, "host is unreachable"}, \r
+#endif  /* \r */
+      \r
+#ifdef EIDRM\r
+  {"EIDRM", EIDRM, 0, "identifier removed"}, \r
+#endif  /* \r */
+      \r
+#ifdef EILSEQ\r
+  {"EILSEQ", EILSEQ, 0, "illegal byte sequence"}, \r
+#endif  /* \r */
+      \r
+#ifdef EINPROGRESS\r
+  {"EINPROGRESS", EINPROGRESS, 0, "operation in progress"}, \r
+#endif  /* \r */
+      \r
+#ifdef EINTR\r
+  {"EINTR", EINTR, 0, "interrupted function"}, \r
+#endif  /* \r */
+      \r
+#ifdef EINVAL\r
+  {"EINVAL", EINVAL, 0, "invalid argument"}, \r
+#endif  /* \r */
+      \r
+#ifdef EIO\r
+  {"EIO", EIO, 0, "I/O error"}, \r
+#endif  /* \r */
+      \r
+#ifdef EISCONN\r
+  {"EISCONN", EISCONN, 0, "socket is connected"}, \r
+#endif  /* \r */
+      \r
+#ifdef EISDIR\r
+  {"EISDIR", EISDIR, 0, "is a directory"}, \r
+#endif  /* \r */
+      \r
+#ifdef ELOOP\r
+  {"ELOOP", ELOOP, 0, "too many levels of symbolic links"}, \r
+#endif  /* \r */
+      \r
+#ifdef EMFILE\r
+  {"EMFILE", EMFILE, 0, "too many open files"}, \r
+#endif  /* \r */
+      \r
+#ifdef EMLINK\r
+  {"EMLINK", EMLINK, 0, "too many links"}, \r
+#endif  /* \r */
+      \r
+#ifdef EMSGSIZE\r
+  {"EMSGSIZE", EMSGSIZE, 0, "message too large"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENAMETOOLONG\r
+  {"ENAMETOOLONG", ENAMETOOLONG, 0, "filename too long"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENETDOWN\r
+  {"ENETDOWN", ENETDOWN, 0, "network is down"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENETRESET\r
+  {"ENETRESET", ENETRESET, 0, "connection aborted by network"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENETUNREACH\r
+  {"ENETUNREACH", ENETUNREACH, 0, "network unreachable"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENFILE\r
+  {"ENFILE", ENFILE, 0, "too many files open in system"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOBUFS\r
+  {"ENOBUFS", ENOBUFS, 0, "no buffer space available"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENODATA\r
+  {"ENODATA", ENODATA, 0,
+   "no message is available on the STREAM head read queue"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENODEV\r
+  {"ENODEV", ENODEV, 0, "no such device"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOENT\r
+  {"ENOENT", ENOENT, 0, "no such file or directory"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOEXEC\r
+  {"ENOEXEC", ENOEXEC, 0, "executable file format error"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOLCK\r
+  {"ENOLCK", ENOLCK, 0, "no locks available"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOMEM\r
+  {"ENOMEM", ENOMEM, 0, "not enough space"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOMSG\r
+  {"ENOMSG", ENOMSG, 0, "no message of the desired type"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOPROTOOPT\r
+  {"ENOPROTOOPT", ENOPROTOOPT, 0, "protocol not available"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOSPC\r
+  {"ENOSPC", ENOSPC, 0, "no space left on device"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOSR\r
+  {"ENOSR", ENOSR, 0, "no stream resources"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOSTR\r
+  {"ENOSTR", ENOSTR, 0, "not a stream"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOSYS\r
+  {"ENOSYS", ENOSYS, 0, "function not supported"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOTCONN\r
+  {"ENOTCONN", ENOTCONN, 0, "the socket is not connected"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOTDIR\r
+  {"ENOTDIR", ENOTDIR, 0, "not a directory"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOTEMPTY\r
+  {"ENOTEMPTY", ENOTEMPTY, 0, "directory not empty"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOTSOCK\r
+  {"ENOTSOCK", ENOTSOCK, 0, "not a socket"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOTSUP\r
+  {"ENOTSUP", ENOTSUP, 0, "not supported"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENOTTY\r
+  {"ENOTTY", ENOTTY, 0, "inappropriate I/O control operation"}, \r
+#endif  /* \r */
+      \r
+#ifdef ENXIO\r
+  {"ENXIO", ENXIO, 0, "no such device or address"}, \r
+#endif  /* \r */
+      \r
+#ifdef EOPNOTSUPP\r
+  {"EOPNOTSUPP", EOPNOTSUPP, 0, "operation not supported on socket"}, \r
+#endif  /* \r */
+      \r
+#ifdef EOVERFLOW\r
+  {"EOVERFLOW", EOVERFLOW, 0, "value too large to be stored in data type"}, \r
+#endif  /* \r */
+      \r
+#ifdef EPERM\r
+  {"EPERM", EPERM, 0, "operation not permitted"}, \r
+#endif  /* \r */
+      \r
+#ifdef EPIPE\r
+  {"EPIPE", EPIPE, 0, "broken pipe"}, \r
+#endif  /* \r */
+      \r
+#ifdef EPROTO\r
+  {"EPROTO", EPROTO, 0, "protocol error"}, \r
+#endif  /* \r */
+      \r
+#ifdef EPROTONOSUPPORT\r
+  {"EPROTONOSUPPORT", EPROTONOSUPPORT, 0, "protocol not supported"}, \r
+#endif  /* \r */
+      \r
+#ifdef EPROTOTYPE\r
+  {"EPROTOTYPE", EPROTOTYPE, 0, "protocol wrong type for socket"}, \r
+#endif  /* \r */
+      \r
+#ifdef ERANGE\r
+  {"ERANGE", ERANGE, 0, "result too large"}, \r
+#endif  /* \r */
+      \r
+#ifdef EROFS\r
+  {"EROFS", EROFS, 0, "read-only file system"}, \r
+#endif  /* \r */
+      \r
+#ifdef ESPIPE\r
+  {"ESPIPE", ESPIPE, 0, "invalid seek"}, \r
+#endif  /* \r */
+      \r
+#ifdef ESRCH\r
+  {"ESRCH", ESRCH, 0, "no such process"}, \r
+#endif  /* \r */
+      \r
+#ifdef ETIME\r
+  {"ETIME", ETIME, 0, "stream ioctl() timeout"}, \r
+#endif  /* \r */
+      \r
+#ifdef ETIMEDOUT\r
+  {"ETIMEDOUT", ETIMEDOUT, 0, "connection timed out"}, \r
+#endif  /* \r */
+      \r
+#ifdef ETXTBSY\r
+  {"ETXTBSY", ETXTBSY, 0, "text file busy"}, \r
+#endif  /* \r */
+      \r
+#ifdef EWOULDBLOCK\r
+  {"EWOULDBLOCK", EWOULDBLOCK, 0, "operation would block"}, \r
+#endif  /* \r */
+      \r
+#ifdef EXDEV\r
+  {"EXDEV", EXDEV, 0, "cross-device link"}, \r
+#endif  /* \r */
+  \r
+      {"ECMDTIMEDOUT", ECMDTIMEDOUT, 1, "command timed out"}, \r\r
+      {"ECMDNOTFOUND", ECMDNOTFOUND, 1, "command not found"}, \r\r
+      {"EEXITCODENOTMATCH", EEXITCODENOTMATCH, 1, "exit code mismatch"}, \r\r
+      {"EOUTPUTNOTMATCH", EOUTPUTNOTMATCH, 1, "output mismatch"}, \r\r
+      {"ESIGNOTMATCH", ESIGNOTMATCH, 1, "signal mismatch"}, \r\r
+      {"EUNXPSIG", EUNXPSIG, 1, "unexpected signal caught"}, \r\r
+      {"ESIGNOTRECEIPT", ESIGNOTRECEIVED, 1,
+       "expected signal not receipt"}, \r\r{"EPROCCMDLINE", EPROCCMDLINE, 1,
+                                          "command line processing failed"},
+      \r\r{"ENOARG", ENOARG, 1, "none optional argument not specified"},
+      \r\r{"ENOTPOSITIVENUM", ENOTPOSITIVENUM, 1,
+         "argument option not strictly positive"}, \r\r{"ESYNTAX", ESYNTAX,
+                                                      1, "syntax error"},
+      \r\r{"ELEADTIME", ELEADTIME, 1, "timed out"}, \r\r{"EREADMENOTFOUND",
+                                                     EREADMENOTFOUND, 1,
+                                                     "unable to locate the README.txt file"},
+      \r\r{"EINCLUDENOTFOUND", EINCLUDENOTFOUND, 1,
+         "include file not found"}, \r\r{"ESUFFIXTOOLONG", ESUFFIXTOOLONG, 1,
+                                       "suffix too long"},
+      \r\r{"EINVCMDLINE", EINVCMDLINE, 1, "invalid command line"},
+      \r\r{"unkwown", -1, 0, "unknown"} \r
+};
+
+\r\r
 #include <stdio.h>\r
-\r
+    \r
 #ifdef _XBT_WIN32\r
-static char *\r
-w32error_to_string(DWORD errcode) \r
-{\r
-       static char buffer[128];\r
-\r
-       /*\r
-        *  Special code for winsock error handling.\r
-        */\r
-       if (errcode > WSABASEERR) \r
-       {\r
-               HMODULE hModule = GetModuleHandle("wsock32");\r
-               \r
-               if(hModule) \r
-               {\r
-                       FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,hModule, errcode, LANG_NEUTRAL, buffer, 128, NULL);\r
-                       FreeLibrary(hModule);\r
-               }\r
-       } \r
-       else \r
-       {\r
-               /*\r
-                *  Default system message handling\r
-                */\r
-       FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errcode, LANG_NEUTRAL, buffer, 128, NULL);\r
-       }\r
-\r
-    return buffer;\r
-}\r
-#endif\r
-\r
-const char*\r
-error_to_string(int errcode, int kind)\r
-{\r
-       int i;\r
-       \r
-       for(i = 0; err[i].code != -1; i++)\r
-               if(err[i].code == errcode && err[i].kind == kind)\r
-                       return err[i].string;\r
-\r
-       #ifdef _XBT_WIN32\r
-\r
-       /* assume it's a W32 error */\r
-       return w32error_to_string((DWORD)errcode);\r
-       #else\r
-       return "unknow error";  \r
-       #endif\r
-       \r
-}\r
-\r
-const char*\r
-error_get_at(int pos, int* code)\r
-{\r
-       if(pos < 0 || (pos > (sizeof(err)/sizeof(entry_t)) - 2))\r
-       {\r
-               errno = ERANGE;\r
-               return NULL;\r
-       }\r
-       \r
-       *code = err[pos].code;\r
-       return err[pos].name;\r
-}\r
+static char *\r w32error_to_string(DWORD errcode) \r
+{
+  \rstatic char buffer[128];
+  \r\r
+      /*\r
+       *  Special code for winsock error handling.\r
+       */ \r
+      if (errcode > WSABASEERR)
+    \r {
+    \rHMODULE hModule = GetModuleHandle("wsock32");
+    \r\rif (hModule)
+      \r {
+      \rFormatMessage(FORMAT_MESSAGE_FROM_HMODULE, hModule, errcode,
+                     LANG_NEUTRAL, buffer, 128, NULL);
+      \rFreeLibrary(hModule);
+      \r}
+    \r}
+  \r
+  else
+    \r {
+    \r
+        /*\r
+         *  Default system message handling\r
+         */ \r
+        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errcode,
+                      LANG_NEUTRAL, buffer, 128, NULL);
+    \r}
+  \r\rreturn buffer;
+\r}
+
 \r
+#endif  /* \r */
+\rconst char *\r error_to_string(int errcode, int kind) \r
+{
+  \rint i;
+  \r\rfor (i = 0; err[i].code != -1; i++)
+    \rif (err[i].code == errcode && err[i].kind == kind)
+      \rreturn err[i].string;
+  \r\r
+#ifdef _XBT_WIN32\r
+      \r
+      /* assume it's a W32 error */ \r
+      return w32error_to_string((DWORD) errcode);
+  \r
+#else   /* \r */
+      return "unknow error";
+  \r
+#endif  /* \r */
+\r}
+
+\r\rconst char *\r error_get_at(int pos, int *code) \r
+{
+  \rif (pos < 0 || (pos > (sizeof(err) / sizeof(entry_t)) - 2))
+    \r {
+    \rerrno = ERANGE;
+    \rreturn NULL;
+    \r}
+  \r\r*code = err[pos].code;
+  \rreturn err[pos].name;
+\r}
+
+\r\r
index 3b0755c..28e8f31 100644 (file)
-/* $Id: signal.c 3483 2007-05-07 11:18:56Z mquinson $ */\r
-\r
-/* signal -- what TESH needs to know about signals                          */\r
-\r
-/* Copyright (c) 2007 Martin Quinson.                                       */\r
-/* All rights reserved.                                                     */\r
-\r
+/* $Id: signal.c 3483 2007-05-07 11:18:56Z mquinson $ */  \r
+    \r
+/* signal -- what TESH needs to know about signals                          */ \r
+    \r
+/* Copyright (c) 2007 Martin Quinson.                                       */ \r
+/* All rights reserved.                                                     */ \r
+    \r
 /* This program is free software; you can redistribute it and/or modify it\r
- * under the terms of the license (GNU LGPL) which comes with this package. */\r
-\r
+ * under the terms of the license (GNU LGPL) which comes with this package. */ \r
+    \r
 #include <xsignal.h>\r
-\r
+    \r
 #ifdef _XBT_WIN32\r
-int\r
-is_an_unhandled_exception(DWORD exit_code);\r
-\r
-typedef struct s_exception_entry\r
-{\r
-       DWORD value;\r
-       const char* signal;\r
-}s_exception_entry_t,* exception_entry_t;\r
-   \r
-static const s_exception_entry_t exceptions[] =\r
-{\r
-       {EXCEPTION_ACCESS_VIOLATION, "SIGSEGV"},\r
-       {EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "SIGSEGV"},\r
-       {EXCEPTION_BREAKPOINT, "SIGTRAP"},\r
-       {EXCEPTION_DATATYPE_MISALIGNMENT, "SIGBUS"},\r
-       {EXCEPTION_FLT_DENORMAL_OPERAND, "SIGFPE"},\r
-       {EXCEPTION_FLT_DIVIDE_BY_ZERO, "SIGFPE"},\r
-       {EXCEPTION_FLT_INEXACT_RESULT, "SIGFPE"},\r
-       {EXCEPTION_FLT_INVALID_OPERATION, "SIGFPE"},\r
-       {EXCEPTION_FLT_OVERFLOW, "SIGFPE"},\r
-       {EXCEPTION_FLT_STACK_CHECK, "SIGFPE"},\r
-       {EXCEPTION_FLT_UNDERFLOW, "SIGFPE"},\r
-       {EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL"},\r
-       {EXCEPTION_IN_PAGE_ERROR, "SIGSEGV"},\r
-       {EXCEPTION_INT_DIVIDE_BY_ZERO, "SIGFPE"},\r
-       {EXCEPTION_INT_OVERFLOW, "SIGFPE"},\r
-       {EXCEPTION_STACK_OVERFLOW, "SIGILL"},\r
-       {EXCEPTION_SINGLE_STEP, "SIGTRAP"},\r
-       {EXCEPTION_NONCONTINUABLE_EXCEPTION, "SIGILL"},\r
-       {EXCEPTION_PRIV_INSTRUCTION, "SIGILL"}\r
-};\r
-/* number of the entries in the table of exceptions */\r
+int \r is_an_unhandled_exception(DWORD exit_code);
+\r\rtypedef struct s_exception_entry \r {
+  \rDWORD value;
+  \rconst char *signal;
+\r} s_exception_entry_t, *exception_entry_t;
+\r\rstatic const s_exception_entry_t exceptions[] = \r
+    { \r
+{EXCEPTION_ACCESS_VIOLATION, "SIGSEGV"}, \r
+{EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "SIGSEGV"}, \r
+{EXCEPTION_BREAKPOINT, "SIGTRAP"}, \r
+{EXCEPTION_DATATYPE_MISALIGNMENT, "SIGBUS"}, \r
+{EXCEPTION_FLT_DENORMAL_OPERAND, "SIGFPE"}, \r
+{EXCEPTION_FLT_DIVIDE_BY_ZERO, "SIGFPE"}, \r
+{EXCEPTION_FLT_INEXACT_RESULT, "SIGFPE"}, \r
+{EXCEPTION_FLT_INVALID_OPERATION, "SIGFPE"}, \r
+{EXCEPTION_FLT_OVERFLOW, "SIGFPE"}, \r
+{EXCEPTION_FLT_STACK_CHECK, "SIGFPE"}, \r
+{EXCEPTION_FLT_UNDERFLOW, "SIGFPE"}, \r
+{EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL"}, \r
+{EXCEPTION_IN_PAGE_ERROR, "SIGSEGV"}, \r
+{EXCEPTION_INT_DIVIDE_BY_ZERO, "SIGFPE"}, \r
+{EXCEPTION_INT_OVERFLOW, "SIGFPE"}, \r
+{EXCEPTION_STACK_OVERFLOW, "SIGILL"}, \r
+{EXCEPTION_SINGLE_STEP, "SIGTRAP"}, \r
+{EXCEPTION_NONCONTINUABLE_EXCEPTION, "SIGILL"}, \r{EXCEPTION_PRIV_INSTRUCTION, "SIGILL"} \r
+};
+
+\r
+/* number of the entries in the table of exceptions */ \r
 #define MAX_EXECPTION                  ((unsigned int)19)\r
-\r
-#endif\r
-\r
-typedef struct s_signal_entry {\r
-  const char* name;\r
-  int number;\r
-} s_signal_entry_t,* signal_entry_t;\r
-\r
-static const s_signal_entry_t signals[] = {\r
-       {"SIGHUP"       ,SIGHUP},\r
-       {"SIGINT"       ,SIGINT},\r
-       {"SIGQUIT"      ,SIGQUIT},\r
-       {"SIGILL"       ,SIGILL},\r
-       {"SIGTRAP"      ,SIGTRAP},\r
-       {"SIGABRT"      ,SIGABRT},\r
-       {"SIGFPE"       ,SIGFPE},\r
-       {"SIGKILL"      ,SIGKILL},\r
-       {"SIGBUS"       ,SIGBUS},\r
-       {"SIGSEGV"      ,SIGSEGV},\r
-       {"SIGSYS"       ,SIGSYS},\r
-       {"SIGPIPE"      ,SIGPIPE},\r
-       {"SIGALRM"      ,SIGALRM},\r
-       {"SIGTERM"      ,SIGTERM},\r
-       {"SIGURG"       ,SIGURG},\r
-       {"SIGSTOP"      ,SIGSTOP},\r
-       {"SIGTSTP"      ,SIGTSTP},\r
-       {"SIGCONT"      ,SIGCONT},\r
-       {"SIGCHLD"      ,SIGCHLD},\r
-       {"SIGTTIN"      ,SIGTTIN},\r
-       {"SIGTTOU"      ,SIGTTOU},\r
-       {"SIGIO"        ,SIGIO},\r
-       {"SIGXCPU"      ,SIGXCPU},\r
-       {"SIGXFSZ"      ,SIGXFSZ},\r
-       {"SIGVTALRM",SIGVTALRM},\r
-       {"SIGPROF"      ,SIGPROF},\r
-       {"SIGWINCH"     ,SIGWINCH},\r
-       {"SIGUSR1"      ,SIGUSR1},\r
-       {"SIGUSR2"      ,SIGUSR2},\r
-       {"SIG UNKNOWN"  ,-1}\r
-};\r
-\r
+    \r
+#endif  /* \r */
+    \rtypedef struct s_signal_entry {
+  \rconst char *name;
+  \r int number;
+\r} s_signal_entry_t, *signal_entry_t;
+\r\rstatic const s_signal_entry_t signals[] = { \r
+      {"SIGHUP", SIGHUP}, \r
+    {"SIGINT", SIGINT}, \r
+    {"SIGQUIT", SIGQUIT}, \r
+    {"SIGILL", SIGILL}, \r
+    {"SIGTRAP", SIGTRAP}, \r
+    {"SIGABRT", SIGABRT}, \r
+    {"SIGFPE", SIGFPE}, \r
+    {"SIGKILL", SIGKILL}, \r
+    {"SIGBUS", SIGBUS}, \r
+    {"SIGSEGV", SIGSEGV}, \r
+    {"SIGSYS", SIGSYS}, \r
+    {"SIGPIPE", SIGPIPE}, \r
+    {"SIGALRM", SIGALRM}, \r
+    {"SIGTERM", SIGTERM}, \r
+    {"SIGURG", SIGURG}, \r
+    {"SIGSTOP", SIGSTOP}, \r
+    {"SIGTSTP", SIGTSTP}, \r
+    {"SIGCONT", SIGCONT}, \r
+    {"SIGCHLD", SIGCHLD}, \r
+    {"SIGTTIN", SIGTTIN}, \r
+    {"SIGTTOU", SIGTTOU}, \r
+    {"SIGIO", SIGIO}, \r
+    {"SIGXCPU", SIGXCPU}, \r
+    {"SIGXFSZ", SIGXFSZ}, \r
+    {"SIGVTALRM", SIGVTALRM}, \r
+    {"SIGPROF", SIGPROF}, \r
+    {"SIGWINCH", SIGWINCH}, \r
+    {"SIGUSR1", SIGUSR1}, \r{"SIGUSR2", SIGUSR2}, \r{"SIG UNKNOWN", -1} \r
+};
+
+\r\r
 #ifdef _XBT_WIN32\r
-const char* signal_name(DWORD got, const char* expected) \r
-#else\r
-const char* signal_name(unsigned int got, char *expected) \r
-#endif\r
-{\r
-       int i;\r
-       \r
-       #ifdef _XBT_WIN32\r
-\r
-       for (i=0; i < MAX_EXECPTION; i++)\r
-               if (exceptions[i].value == got)\r
-                       return (exceptions[i].signal);\r
-       #else\r
-       if((got == SIGBUS) && !strcmp("SIGSEGV",expected))\r
-               got = SIGSEGV;\r
-\r
-       for (i=0; signals[i].number != -1; i++)\r
-               if (signals[i].number == got)\r
-                       return (signals[i].name);\r
-       \r
-       #endif\r
-       return bprintf("SIG UNKNOWN (%d)", got);\r
-}\r
-\r
-int\r
-sig_exists(const char* sig_name)\r
-{\r
-       int i;\r
-\r
-       for (i=0; signals[i].number != -1; i++)\r
-               if (!strcmp(signals[i].name, sig_name))\r
-                       return 1; \r
-\r
-       /* not found */\r
-       return 0;\r
-}\r
-\r
-\r
+const char *signal_name(DWORD got, const char *expected) \r
+#else   /* \r */
+const char *signal_name(unsigned int got, char *expected) \r
+#endif  /* \r */
+{
+  \rint i;
+  \r\r
 #ifdef _XBT_WIN32\r
-int\r
-is_an_unhandled_exception(DWORD exit_code)\r
-{\r
-       unsigned int i;\r
-\r
-       for(i = 0; i < MAX_EXECPTION; i++)\r
-               if(exceptions[i].value == exit_code)\r
-                       return 1;\r
-       \r
-       return 0;       \r
-}\r
-#endif\r
+      \rfor (i = 0; i < MAX_EXECPTION; i++)
+    \rif (exceptions[i].value == got)
+      \rreturn (exceptions[i].signal);
+  \r
+#else   /* \r */
+      if ((got == SIGBUS) && !strcmp("SIGSEGV", expected))
+    \rgot = SIGSEGV;
+  \r\rfor (i = 0; signals[i].number != -1; i++)
+    \rif (signals[i].number == got)
+      \rreturn (signals[i].name);
+  \r\r
+#endif  /* \r */
+      return bprintf("SIG UNKNOWN (%d)", got);
+\r}
+
+\r\rint \r sig_exists(const char *sig_name) \r
+{
+  \rint i;
+  \r\rfor (i = 0; signals[i].number != -1; i++)
+    \rif (!strcmp(signals[i].name, sig_name))
+      \rreturn 1;
+  \r\r
+      /* not found */ \r
+      return 0;
+\r}
+
+\r\r\r
+#ifdef _XBT_WIN32\r
+int \r is_an_unhandled_exception(DWORD exit_code) \r
+{
+  \runsigned int i;
+  \r\rfor (i = 0; i < MAX_EXECPTION; i++)
+    \rif (exceptions[i].value == exit_code)
+      \rreturn 1;
+  \r\rreturn 0;
+\r}
+
+\r
+#endif  /* \r */
index 2838021..a20f2b5 100644 (file)
@@ -3,49 +3,33 @@
 \r
 #include <windows.h>\r
 #include <sys/types.h>\r
-\r
-\r
+    \r\r
 #ifndef S_ISDIR\r
 #define        S_ISDIR(__mode) (((__mode) & S_IFMT) == S_IFDIR)\r
-#endif\r
-\r
+#endif  /* \r */
+    \r
 #ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-struct dirent\r
-{\r
-  char d_name[MAX_PATH + 1];\r
-};\r
-\r
-typedef struct s_DIR \r
-{\r
-       HANDLE  file_handle;\r
-       DWORD   pos;\r
-       char    directory_name[MAX_PATH+1];\r
-       struct dirent entry;\r
-}DIR,* DIR_t;\r
-\r
-DIR* \r
-opendir(const char* directory_name);\r
-\r
-struct dirent*\r
-readdir(DIR* dir);\r
-\r
-void \r
-rewinddir(DIR* dir);\r
-\r
-int \r
-closedir(DIR* dir);\r
-\r
-off_t \r
-telldir(DIR* dir);\r
-\r
-void \r
-seekdir(DIR* dir, off_t offset);\r
-\r
+extern "C" {
+  \r
+#endif  /* \r */
+  \r struct dirent \r {
+    \rchar d_name[MAX_PATH + 1];
+  \r};
+  \r \r typedef struct s_DIR \r {
+    \rHANDLE file_handle;
+    \rDWORD pos;
+    \rchar directory_name[MAX_PATH + 1];
+    \r struct dirent entry;
+  \r} DIR, *DIR_t;
+  \r\rDIR * \ropendir(const char *directory_name);
+  \r\rstruct dirent *\rreaddir(DIR * dir);
+  \r\rvoid \r rewinddir(DIR * dir);
+  \r \r int \r closedir(DIR * dir);
+  \r \r off_t \r telldir(DIR * dir);
+  \r \r void \r seekdir(DIR * dir, off_t offset);
+  \r \r
 #ifdef __cplusplus\r
-extern }\r
-#endif\r
+extern\r
+#endif  /* \r */
 \r
-#endif /* !__DIRENT_H */\r
+#endif  /* !__DIRENT_H */\r
index 451dc42..71013cd 100644 (file)
@@ -4,51 +4,34 @@
 #define        no_argument                     0\r
 #define required_argument      1\r
 #define optional_argument      2\r
-\r
-struct option\r
-{\r
-       const char *name;       /* name of the long option      */\r
-       \r
-       int has_arg;            /*\r
-                                                * has_arg is : no_argument (or 0), if the option doesn't take an argument, \r
-                                                * required_argument (or 1) if the option takes an argument,\r
-                                                * optional_argument (or 2) if the option takes an optional argument.\r
-                                                */\r
-       \r
-       int *flag;                      /* specify the mean used to return a result for a long option:\r
-                                                * if flag is NULL, then getopt_long() returns val\r
-                                                * in the other case getopt_long() returns 0, and flag points to the  \r
-                                                * variable specified bay the content of the field val when the option \r
-                                                * is found but it is not update if the option is not found.\r
-                                                */\r
-                                                                               \r
-       int val;                        /* val is the value returned by getopt_long() when the pointer flag\r
-                                                * is NULL or the value of the variable referenced by the pointer flag\r
-                                                * when the option is found.\r
-                                                */\r
-};\r
-\r
-extern int \r
-optind;\r
-\r
-extern char* \r
-optarg;\r
-\r
-extern int \r
-opterr;\r
-\r
-extern int \r
-optopt;\r
-\r
-\r
-int \r
-getopt (int argc, char * const argv[], const char *optstring);\r
-\r
-int\r
-getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);\r
-\r
-int\r
-getopt_long_only (int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);\r
-\r
-\r
-#endif /* !__GETOPT_H */\r
+\rstruct option \r {
+  \rconst char *name;            /* name of the long option      */
+  \r \r int has_arg;              /*\r
+                                 * has_arg is : no_argument (or 0), if the option doesn't take an argument, \r
+                                 * required_argument (or 1) if the option takes an argument,\r
+                                 * optional_argument (or 2) if the option takes an optional argument.\r
+                                 */
+  \r \r int *flag;                /* specify the mean used to return a result for a long option:\r
+                                 * if flag is NULL, then getopt_long() returns val\r
+                                 * in the other case getopt_long() returns 0, and flag points to the  \r
+                                 * variable specified bay the content of the field val when the option \r
+                                 * is found but it is not update if the option is not found.\r
+                                 */
+  \r \r int val;                  /* val is the value returned by getopt_long() when the pointer flag\r
+                                 * is NULL or the value of the variable referenced by the pointer flag\r
+                                 * when the option is found.\r
+                                 */
+\r};
+\r\rextern int \r optind;
+\r\rextern char *\r optarg;
+\r\rextern int \r opterr;
+\r\rextern int \r optopt;
+\r\r\rint \r getopt(int argc, char *const argv[], const char *optstring);
+\r\rint \r
+getopt_long(int argc, char *const argv[], const char *optstring,
+            const struct option *longopts, int *longindex);
+\r\rint \r getopt_long_only(int argc, char *const argv[],
+                         const char *optstring,
+                         const struct option *longopts, int *longindex);
+\r\r\r
+#endif  /* !__GETOPT_H */\r
index 06f24c7..6516aff 100644 (file)
@@ -2,7 +2,7 @@
 
 /* must be defined before */
 #ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE 
+#define _CRT_SECURE_NO_DEPRECATE
 #endif
 
 #include <windows.h>
@@ -16,7 +16,7 @@
 #include <io.h>
 
 #ifdef _MSC_VER
-#define _CRT_SECURE_NO_DEPRECATE 
+#define _CRT_SECURE_NO_DEPRECATE
 #define strdup _strdup
 #define fileno _fileno
 #define creat  _creat
 #endif
 
 #ifdef max
-       #undef max
-       #define max(h,i) ((h) > (i) ? (h) : (i))
+#undef max
+#define max(h,i) ((h) > (i) ? (h) : (i))
 #endif
-       
+
 #ifndef S_ISREG
-       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
+#define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
 #endif
 
 #ifndef STDIN_FILENO
 #endif
 
 
-static 
+static
 int exit_code = EXIT_SUCCESS;
 
-static char*
-rfname;
+static char *rfname;
 
-static char*
-wfname = NULL;
+static char *wfname = NULL;
 
 static
 int wfd;
 
 #ifndef _MSC_VER
-static size_t 
+static size_t
 #else
 static int
 #endif
-bsize;
+ bsize;
 
-static char *
-buf = NULL;
+static char *buf = NULL;
 
-static int 
-fnumber = 0;
+static int
+ fnumber = 0;
 
-int
-cat_files(char** fnames);
+int cat_files(char **fnames);
 
-int
-cat(int);
+int cat(int);
 
-char** 
-fnames = NULL;
+char **fnames = NULL;
 
-void
-exit0(int errcode)
+void exit0(int errcode)
 {
-       if(fnames)
-       {
-               int i;
-               
-               for(i = 0; i < fnumber; i++)
-                               free(fnames[i]);
-                               
-               free(fnames);
-       }
-       
-       if(buf)         
-               free(buf);
-               
-       if(wfname)
-               free(wfname);
-               
-       
-       exit(errcode);
+  if (fnames) {
+    int i;
+
+    for (i = 0; i < fnumber; i++)
+      free(fnames[i]);
+
+    free(fnames);
+  }
+
+  if (buf)
+    free(buf);
+
+  if (wfname)
+    free(wfname);
+
+
+  exit(errcode);
 }
 
-int
-main(int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-       int i, j;
-       int success = 1;
-       int redirect = 0;
-       int exists = 0;
-       
-       struct stat stat_buf = {0};
-       
-       setlocale(LC_ALL, "");
-       
-       bsize = BUFSIZ; 
-               
-       if(!(buf = (char*)malloc(bsize)))
-       {
-               fprintf(stderr, "[ERROR/cat] not enough memory\n");
-               exit0(EXIT_FAILURE);
-       }
-       
-       if(argc > 1)
-       {
-               if(!(fnames = (char**)calloc(argc, sizeof(char*))))
-               {
-                       fprintf(stderr, "[ERROR/cat]  not enough memory\n");
-                       exit0(EXIT_FAILURE);
-               }
-               
-               for(i = 1, j= 0; i < argc; i++)
-               {
-                       if(!strcmp(argv[i], ">"))
-                       {
-                               redirect = 1;
-                               break;
-                       }
-                       else if(!strcmp(argv[i], ">>"))
-                       {
-                               redirect = 1;
-                               exists = 1;
-                               break;
-                       }
-                       else
-                       {
-                               if(stat(argv[i], &stat_buf))
-                               {
-                                       fprintf(stderr, "[ERROR/cat (1)] could not get information about %s\n",argv[i]);
-                                       success = 0;
-                                       break;
-                               }
-                               else
-                               {
-                                       if(S_ISREG(stat_buf.st_mode))
-                                       {
-                                               fnames[j++] = strdup(argv[i]);
-                                               fnumber++;      
-                                       }
-                                       else
-                                       {
-                                               fprintf(stderr, "[ERROR/cat] %s is not a file\n",argv[i]);
-                                               success = 0;
-                                               break;
-                                       }
-                               }       
-                       }               
-               }
-               
-               if(!success)
-                       exit0(EXIT_FAILURE);
-       }
-       
-       if(redirect)
-       {
-               if(i != argc - 2)
-               {
-                       if(exists)
-                               fprintf(stderr, "[ERROR/cat] syntax error near `>>' (i : %d - argc : %d\n", i , argc);
-                       else
-                               fprintf(stderr, "[ERROR/cat] syntax error near `>' (i : %d - argc : %d\n", i , argc);
-                                       
-                       exit0(EXIT_FAILURE);
-               }
-               else
-               {
-                       wfname = strdup(argv[i + 1]);
-                       
-                       if(!exists)
-                       {
-                               if((wfd = creat(wfname, _S_IREAD | _S_IWRITE)) < 0)
-                               {
-                                       fprintf(stderr, "[ERROR/cat] could not create %s file\n",wfname);
-                                       
-                                       exit0(EXIT_FAILURE);
-                               }       
-                       }
-                       else
-                       {
-                               if((wfd = open(wfname, O_WRONLY | O_APPEND, 0)) < 0)
-                               {
-                                       fprintf(stderr, "[ERROR/cat] could not open %s file\n",wfname);
-                                       
-                                       exit0(EXIT_FAILURE);
-                               }
-                       }
-               }                       
-       }
-       else
-       {
-               wfd = STDOUT_FILENO;
-               
-               if(fstat(wfd, &stat_buf))
-               {       
-                       fprintf(stderr, "[ERROR/cat (3)] could not get information about stdout\n");
-                       exit0(EXIT_FAILURE);
-               }
-       }
-       
-       exit_code = cat_files(fnames);
-       
-       if(wfd == STDOUT_FILENO)
-       {
-               if(fclose(stdout))
-               {
-                       fprintf(stderr, "[ERROR/cat] could not close stdout\n");
-                       exit_code = EXIT_FAILURE;
-               }
-       }
-       else
-       {
-               if(close(wfd))
-               {
-                       fprintf(stderr, "[ERROR/cat] could not close %s\n", wfname);
-                       exit_code = EXIT_FAILURE;
-               }       
-       }
-       
-       exit0(exit_code);
+  int i, j;
+  int success = 1;
+  int redirect = 0;
+  int exists = 0;
+
+  struct stat stat_buf = { 0 };
+
+  setlocale(LC_ALL, "");
+
+  bsize = BUFSIZ;
+
+  if (!(buf = (char *) malloc(bsize))) {
+    fprintf(stderr, "[ERROR/cat] not enough memory\n");
+    exit0(EXIT_FAILURE);
+  }
+
+  if (argc > 1) {
+    if (!(fnames = (char **) calloc(argc, sizeof(char *)))) {
+      fprintf(stderr, "[ERROR/cat]  not enough memory\n");
+      exit0(EXIT_FAILURE);
+    }
+
+    for (i = 1, j = 0; i < argc; i++) {
+      if (!strcmp(argv[i], ">")) {
+        redirect = 1;
+        break;
+      } else if (!strcmp(argv[i], ">>")) {
+        redirect = 1;
+        exists = 1;
+        break;
+      } else {
+        if (stat(argv[i], &stat_buf)) {
+          fprintf(stderr,
+                  "[ERROR/cat (1)] could not get information about %s\n",
+                  argv[i]);
+          success = 0;
+          break;
+        } else {
+          if (S_ISREG(stat_buf.st_mode)) {
+            fnames[j++] = strdup(argv[i]);
+            fnumber++;
+          } else {
+            fprintf(stderr, "[ERROR/cat] %s is not a file\n", argv[i]);
+            success = 0;
+            break;
+          }
+        }
+      }
+    }
+
+    if (!success)
+      exit0(EXIT_FAILURE);
+  }
+
+  if (redirect) {
+    if (i != argc - 2) {
+      if (exists)
+        fprintf(stderr,
+                "[ERROR/cat] syntax error near `>>' (i : %d - argc : %d\n",
+                i, argc);
+      else
+        fprintf(stderr,
+                "[ERROR/cat] syntax error near `>' (i : %d - argc : %d\n",
+                i, argc);
+
+      exit0(EXIT_FAILURE);
+    } else {
+      wfname = strdup(argv[i + 1]);
+
+      if (!exists) {
+        if ((wfd = creat(wfname, _S_IREAD | _S_IWRITE)) < 0) {
+          fprintf(stderr, "[ERROR/cat] could not create %s file\n",
+                  wfname);
+
+          exit0(EXIT_FAILURE);
+        }
+      } else {
+        if ((wfd = open(wfname, O_WRONLY | O_APPEND, 0)) < 0) {
+          fprintf(stderr, "[ERROR/cat] could not open %s file\n", wfname);
+
+          exit0(EXIT_FAILURE);
+        }
+      }
+    }
+  } else {
+    wfd = STDOUT_FILENO;
+
+    if (fstat(wfd, &stat_buf)) {
+      fprintf(stderr,
+              "[ERROR/cat (3)] could not get information about stdout\n");
+      exit0(EXIT_FAILURE);
+    }
+  }
+
+  exit_code = cat_files(fnames);
+
+  if (wfd == STDOUT_FILENO) {
+    if (fclose(stdout)) {
+      fprintf(stderr, "[ERROR/cat] could not close stdout\n");
+      exit_code = EXIT_FAILURE;
+    }
+  } else {
+    if (close(wfd)) {
+      fprintf(stderr, "[ERROR/cat] could not close %s\n", wfname);
+      exit_code = EXIT_FAILURE;
+    }
+  }
+
+  exit0(exit_code);
 }
 
-int
-cat_files(char **fnames)
+int cat_files(char **fnames)
 {
-       int rfd, i;
-       int failure = 0;
-       
-       rfd = STDIN_FILENO;
-       
-       rfname = "stdin";
-       
-       if(fnumber)
-       {
-               
-               for(i = 0; i < fnumber && !failure; i++) 
-               {
-                       if (!strcmp(fnames[i], "-"))
-                               rfd = fileno(stdin);
-                       else if ((rfd = open(fnames[i], O_RDONLY, 0)) < 0) 
-                       {
-                               fprintf(stderr, "[WARN/cat] could not open %s file", fnames[i]);
-                               exit_code = EXIT_FAILURE;
-                               continue;
-                       }
-                       
-                       rfname = fnames[i];
-                       
-                       failure = cat(rfd);
-                       
-                       close(rfd);
-                               
-               }
-       }
-       else
-               failure = cat(rfd);
-       
-       return failure ? 1 : 0;
+  int rfd, i;
+  int failure = 0;
+
+  rfd = STDIN_FILENO;
+
+  rfname = "stdin";
+
+  if (fnumber) {
+
+    for (i = 0; i < fnumber && !failure; i++) {
+      if (!strcmp(fnames[i], "-"))
+        rfd = fileno(stdin);
+      else if ((rfd = open(fnames[i], O_RDONLY, 0)) < 0) {
+        fprintf(stderr, "[WARN/cat] could not open %s file", fnames[i]);
+        exit_code = EXIT_FAILURE;
+        continue;
+      }
+
+      rfname = fnames[i];
+
+      failure = cat(rfd);
+
+      close(rfd);
+
+    }
+  } else
+    failure = cat(rfd);
+
+  return failure ? 1 : 0;
 }
 
-int
-cat(int rfd)
+int cat(int rfd)
 {
 
-       #ifndef _MSC_VER 
-       size_t bytes_readed_nb;
-       #else
-       int bytes_readed_nb;
-       #endif
-       int bytes_written_nb, pos;
-       
-       while ((bytes_readed_nb = read(rfd, buf, bsize)) != -1 && bytes_readed_nb != 0)
-       {
-               for (pos = 0; bytes_readed_nb; bytes_readed_nb -= bytes_written_nb, pos += bytes_written_nb)
-               {
-                       if ((bytes_written_nb = write(wfd, buf + pos, bytes_readed_nb)) == 0 || bytes_written_nb == -1)
-                       {
-                               fprintf(stderr, "[ERROR/cat] could not write to %s\n", wfd == fileno(stdout) ? "stdout" : wfname);
-                               return 1;
-                       }
-               }
-       }
-               
-       if(bytes_readed_nb < 0)
-       {
-               fprintf(stderr, "[WARN/cat] could not read %s file", rfname);
-               return 1;
-       }
-       
-       return 0;
+#ifndef _MSC_VER
+  size_t bytes_readed_nb;
+#else
+  int bytes_readed_nb;
+#endif
+  int bytes_written_nb, pos;
+
+  while ((bytes_readed_nb = read(rfd, buf, bsize)) != -1
+         && bytes_readed_nb != 0) {
+    for (pos = 0; bytes_readed_nb;
+         bytes_readed_nb -= bytes_written_nb, pos += bytes_written_nb) {
+      if ((bytes_written_nb = write(wfd, buf + pos, bytes_readed_nb)) == 0
+          || bytes_written_nb == -1) {
+        fprintf(stderr, "[ERROR/cat] could not write to %s\n",
+                wfd == fileno(stdout) ? "stdout" : wfname);
+        return 1;
+      }
+    }
+  }
+
+  if (bytes_readed_nb < 0) {
+    fprintf(stderr, "[WARN/cat] could not read %s file", rfname);
+    return 1;
+  }
+
+  return 0;
 }
index b80b336..317dbba 100644 (file)
 #include <stdio.h>\r
 #include <dirent.h>\r
 #include <errno.h>\r
+    \r\rDIR * \ropendir(const char *directory_name) \r
+{
+  \rstruct stat sb;
+  \rDIR * dir;
+  \r\rif (NULL == directory_name)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rif (0 != stat(directory_name, &sb))
+    \r {
+    \r
+        /* directory not found */ \r
+        errno = ENOENT;
+    \rreturn NULL;
+    \r}
+  \r\rif (0 == S_ISDIR(sb.st_mode))
+    \r {
+    \r
+        /* it's not a directory */ \r
+        errno = ENOTDIR;
+    \rreturn NULL;
+    \r}
+  \r\r\rdir = (DIR *) calloc(1, sizeof(DIR));
+  \r\rif (NULL == dir)
+    \r {
+    \rerrno = ENOMEM;
+    \rreturn NULL;
+    \r}
+  \r\rif ('\\' != dir->directory_name[strlen(directory_name) - 1])
+    \rsprintf(dir->directory_name, "%s\\*", directory_name);
+  \r
+  else
+    \rsprintf(dir->directory_name, "%s*", directory_name);
+  \r\rdir->file_handle = INVALID_HANDLE_VALUE;
+  \r\rreturn dir;
+\r}
+
+\r\rint \r closedir(DIR * dir) \r
+{
+  \rif (NULL == dir)
+    \rreturn EINVAL;
+  \r\rif (INVALID_HANDLE_VALUE != dir->file_handle)
+    \rFindClose(dir->file_handle);
+  \r
+  else
+    \rreturn EBADF;
+  \r\rfree(dir);
+  \r\rreturn 0;
+\r\r}
+
+\r\rstruct dirent *\rreaddir(DIR * dir) \r
+{
+  \rWIN32_FIND_DATA wfd = {
+  0};
+  \r\rif (!dir)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn NULL;
+    \r}
+  \r\rif (!dir->pos)
+    \rdir->file_handle = FindFirstFile(dir->directory_name, &wfd);
+  \r\rif (!FindNextFile(dir->file_handle, &wfd))
+    \rreturn NULL;
+  \r\rdir->pos++;
+  \r\rstrcpy(dir->entry.d_name, wfd.cFileName);
+  \r\rreturn &(dir->entry);
+\r}
+
+\r\rvoid \r rewinddir(DIR * dir) \r
+{
+  \rif (NULL == dir)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn;
+    \r}
+  \r\rif (INVALID_HANDLE_VALUE != dir->file_handle)
+    \r {
+    \rFindClose(dir->file_handle);
+    \rdir->file_handle = INVALID_HANDLE_VALUE;
+    \rdir->pos = 0;
+    \r}
+\r}
+
+\r\roff_t \r telldir(DIR * dir) \r
+{
+  \rif (NULL == dir)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn -1;
+    \r}
+  \r\rreturn dir->pos;
+\r}
+
+\r\rvoid \r seekdir(DIR * dir, off_t offset) \r
+{
+  \rWIN32_FIND_DATA wfd = {
+  0};
+  \r\rif (NULL == dir)
+    \r {
+    \rerrno = EINVAL;
+    \rreturn;
+    \r}
+  \r\rif (INVALID_HANDLE_VALUE != dir->file_handle)
+    \r {
+    \rFindClose(dir->file_handle);
+    \rdir->file_handle = INVALID_HANDLE_VALUE;
+    \rdir->pos = 0;
+    \r}
+  \r\rdir->file_handle = FindFirstFile(dir->directory_name, &wfd);
+  \r\rdir->pos += offset;
+  \r\rwhile (--offset)
+    \r {
+    \rif (!FindNextFile(dir->file_handle, &wfd))
+      \rerrno = EINVAL;
+    \r}
+\r}
+
 \r
-\r
-DIR*\r
-opendir(const char* directory_name)\r
-{\r
-       struct stat sb;\r
-       DIR* dir;\r
-\r
-       if(NULL == directory_name) \r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-       \r
-       if(0 != stat(directory_name, &sb)) \r
-       {\r
-               /* directory not found */\r
-               errno = ENOENT;\r
-               return NULL;\r
-       }\r
-       \r
-       if(0 == S_ISDIR(sb.st_mode)) \r
-       {\r
-               /* it's not a directory */\r
-               errno = ENOTDIR;\r
-               return NULL;\r
-       }\r
-\r
-       \r
-       dir = (DIR *)calloc(1,sizeof(DIR));\r
-\r
-       if (NULL == dir)\r
-       {\r
-               errno = ENOMEM;\r
-               return NULL;\r
-       }\r
-\r
-       if('\\' != dir->directory_name[strlen(directory_name) - 1])\r
-               sprintf(dir->directory_name,"%s\\*",directory_name);\r
-       else\r
-               sprintf(dir->directory_name,"%s*",directory_name);\r
-\r
-       dir->file_handle = INVALID_HANDLE_VALUE;\r
-\r
-       return dir;\r
-}\r
-\r
-int\r
-closedir(DIR* dir)\r
-{\r
-       if(NULL == dir) \r
-               return EINVAL;\r
-       \r
-       if(INVALID_HANDLE_VALUE != dir->file_handle)\r
-               FindClose(dir->file_handle);\r
-       else\r
-               return EBADF;\r
-       \r
-       free(dir);\r
-\r
-       return 0;\r
-\r
-}\r
-\r
-struct dirent*\r
-readdir(DIR* dir)\r
-{\r
-       WIN32_FIND_DATA wfd = {0};\r
-\r
-       if(!dir) \r
-       {\r
-               errno = EINVAL;\r
-               return NULL;\r
-       }\r
-\r
-       if(!dir->pos) \r
-               dir->file_handle = FindFirstFile(dir->directory_name, &wfd);\r
-       \r
-       if(!FindNextFile(dir->file_handle, &wfd))\r
-               return NULL;\r
-                       \r
-       dir->pos++;\r
-\r
-       strcpy(dir->entry.d_name, wfd.cFileName);\r
-\r
-       return &(dir->entry);\r
-}\r
-\r
-void\r
-rewinddir(DIR* dir)\r
-{\r
-       if(NULL == dir) \r
-       {\r
-               errno = EINVAL;\r
-               return;\r
-       }\r
-\r
-       if(INVALID_HANDLE_VALUE != dir->file_handle)\r
-       {\r
-               FindClose(dir->file_handle);\r
-               dir->file_handle = INVALID_HANDLE_VALUE;\r
-               dir->pos = 0;\r
-       }\r
-}\r
-\r
-off_t\r
-telldir(DIR* dir)\r
-{\r
-       if(NULL == dir) \r
-       {\r
-               errno = EINVAL;\r
-               return -1;\r
-       }\r
-       \r
-       return dir->pos;\r
-}\r
-\r
-void\r
-seekdir(DIR* dir, off_t offset)\r
-{\r
-       WIN32_FIND_DATA wfd = {0};\r
-       \r
-       if(NULL == dir)\r
-       {\r
-               errno = EINVAL;\r
-               return;\r
-       }\r
-\r
-       if(INVALID_HANDLE_VALUE != dir->file_handle)\r
-       {\r
-               FindClose(dir->file_handle);\r
-               dir->file_handle = INVALID_HANDLE_VALUE;\r
-               dir->pos = 0;\r
-       }\r
-       \r
-       dir->file_handle = FindFirstFile(dir->directory_name, &wfd);\r
-       \r
-       dir->pos += offset;\r
-       \r
-       while(--offset)\r
-       {\r
-               if(!FindNextFile(dir->file_handle, &wfd))\r
-                       errno = EINVAL;\r
-       }\r
-}\r
index 4525144..0a1c4a5 100644 (file)
 #include <string.h>\r
 \r
 #include <getopt.h>\r
-\r
-char* \r
-optarg = NULL;\r
-\r
-int \r
-optind = 0;\r
-\r
-int \r
-optopt = '?';\r
-\r
-int \r
-opterr = 1;\r
-\r
-static char*\r
-nextchar;\r
-\r
-static \r
-int first_nonopt;\r
-\r
-static int \r
-last_nonopt;\r
-\r
-\r
-static enum\r
-{\r
-       REQUIRE_ORDER, \r
-       PERMUTE, \r
-       RETURN_IN_ORDER\r
-}ordering;\r
-\r
-\r
-static const char *\r
-__getopt_initialize (const char *optstring);\r
-\r
-static int\r
-__getopt_internal (int argc, char *const *argv, const char* optstring, const struct option *longopts, int* longind, int long_only);\r
-\r
-static void\r
-__exchange (char **argv);\r
-\r
-int \r
-getopt (int argc, char * const argv[], const char *optstring)\r
-{\r
-       return __getopt_internal(argc, argv, optstring,(const struct option *) 0,(int *) 0,0);\r
-}\r
-\r
-static const char *\r
-__getopt_initialize (const char *optstring)\r
-{\r
-       /* Start processing options with ARGV-element 1 (since ARGV-element 0\r
-       is the program name); the sequence of previously skipped\r
-       non-option ARGV-elements is empty.  */\r
-       \r
-       first_nonopt = last_nonopt = optind = 1;\r
-       nextchar = NULL;\r
-       \r
-       /* Determine how to handle the ordering of options and nonoptions.  */\r
-       \r
-       if (optstring[0] == '-')\r
-       {\r
-               ordering = RETURN_IN_ORDER;\r
-               ++optstring;\r
-       }\r
-       /* si la chaîne d'options commence par un + alors la fonction getopt() s'arrête\r
-        * dès qu'un argument de la ligne de commande n'est pas une option\r
-        */\r
-       else if (optstring[0] == '+')\r
-       {\r
-               ordering = REQUIRE_ORDER;\r
-               ++optstring;\r
-       }\r
-       else\r
-       {\r
-               ordering = PERMUTE;\r
-       }\r
-       \r
-       return optstring;\r
-}\r
-\r
-int\r
-__getopt_internal (int argc, char *const *argv, const char* optstring, const struct option *longopts, int* longind, int long_only)\r
-{\r
-       optarg = NULL;\r
-       \r
-       if (optind == 0)\r
-               optstring = __getopt_initialize (optstring);\r
-       \r
-       if (nextchar == NULL || *nextchar == '\0')\r
-       {\r
-               /* Advance to the next ARGV-element.  */\r
-       \r
-               if (ordering == PERMUTE)\r
-               {\r
-                       /* If we have just processed some options following some non-options,\r
-                       __exchange them so that the options come first.  */\r
-       \r
-                       if (first_nonopt != last_nonopt && last_nonopt != optind)\r
-                               __exchange ((char **) argv);\r
-                       else if (last_nonopt != optind)\r
-                               first_nonopt = optind;\r
-       \r
-                       /* Skip any additional non-options\r
-                       and extend the range of non-options previously skipped.  */\r
-       \r
-                       while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0'))\r
-                               optind++;\r
-                       \r
-                       last_nonopt = optind;\r
-               }\r
-       \r
-               /* The special ARGV-element `--' means premature end of options.\r
-               Skip it like a null option,\r
-               then __exchange with previous non-options as if it were an option,\r
-               then skip everything else like a non-option.  */\r
-       \r
-               if (optind != argc && !strcmp (argv[optind], "--"))\r
-               {\r
-                       optind++;\r
-       \r
-                       if (first_nonopt != last_nonopt && last_nonopt != optind)\r
-                               __exchange ((char **) argv);\r
-                       else if (first_nonopt == last_nonopt)\r
-                               first_nonopt = optind;\r
-                       \r
-                       last_nonopt = argc;\r
-       \r
-                       optind = argc;\r
-               }\r
-       \r
-               /* If we have done all the ARGV-elements, stop the scan\r
-               and back over any non-options that we skipped and permuted.  */\r
-       \r
-               if (optind == argc)\r
-               {\r
-                       /* Set the next-arg-index to point at the non-options\r
-                       that we previously skipped, so the caller will digest them.  */\r
-                       if (first_nonopt != last_nonopt)\r
-                               optind = first_nonopt;\r
-                       \r
-                       return EOF;\r
-               }\r
-       \r
-               /* If we have come to a non-option and did not permute it,\r
-               either stop the scan or describe it to the caller and pass it by.  */\r
-       \r
-               if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))\r
-               {\r
-                       if (ordering == REQUIRE_ORDER)\r
-                               return EOF;\r
-                       optarg = argv[optind++];\r
-                               return 1;\r
-               }\r
-       \r
-               /* We have found another option-ARGV-element.\r
-               Skip the initial punctuation.  */\r
-       \r
-               nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-'));\r
-       }\r
-       \r
-       /* Decode the current option-ARGV-element.  */\r
-       \r
-       /* Check whether the ARGV-element is a long option.\r
-       \r
-       If long_only and the ARGV-element has the form "-f", where f is\r
-       a valid short option, don't consider it an abbreviated form of\r
-       a long option that starts with f.  Otherwise there would be no\r
-       way to give the -f short option.\r
-       \r
-       On the other hand, if there's a long option "fubar" and\r
-       the ARGV-element is "-fu", do consider that an abbreviation of\r
-       the long option, just like "--fu", and not "-f" with arg "u".\r
-       \r
-       This distinction seems to be the most useful approach.  */\r
-       \r
-       if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !strchr (optstring, argv[optind][1])))))\r
-       {\r
-               char *nameend;\r
-               const struct option *p;\r
-               const struct option *pfound = NULL;\r
-               int exact = 0;\r
-               int ambig = 0;\r
-               int indfound = 0;\r
-               int option_index;\r
-       \r
-               for (nameend = nextchar; *nameend !='\0' && *nameend != '='; nameend++)\r
-                       /* Do nothing.  */ ;\r
-       \r
-               /* Test all long options for either exact match\r
-               or abbreviated matches.  */\r
-               for (p = longopts, option_index = 0; p->name; p++, option_index++)\r
-               {\r
-                       if(!strncmp (p->name, nextchar, nameend - nextchar))\r
-                       {\r
-\r
-                               if (nameend - nextchar == strlen (p->name))\r
-                               {\r
-                                       /* Exact match found.  */\r
-                                       pfound = p;\r
-                                       indfound = option_index;\r
-                                       exact = 1;\r
-                                       break;\r
-                               }\r
-                               else if (pfound == NULL)\r
-                               {\r
-                                       /* First nonexact match found.  */\r
-                                       exact = 0;\r
-                                       /* begin change\r
-                                       pfound = p;\r
-                                       indfound = option_index;\r
-                                       end change */\r
-                                       break;\r
-                               }\r
-                               else\r
-                               {\r
-\r
-                                       /* Second or later nonexact match found.  */\r
-                                       ambig = 1;\r
-                               }\r
-                       }\r
-               }\r
-       \r
-               if (ambig && !exact)\r
-               {\r
-                       if (opterr)\r
-                               fprintf (stderr, "error   : %s: option `%s' is ambiguous\n",argv[0], argv[optind]);\r
-                       \r
-                       nextchar += strlen (nextchar);\r
-                       optind++;\r
-                       return '?';\r
-               }\r
-       \r
-               if (pfound != NULL)\r
-               {\r
-                       option_index = indfound;\r
-                       optind++;\r
-                       \r
-                       if (*nameend)\r
-                       {\r
-                               /* Don't test has_arg with >, because some C compilers don't\r
-                               allow it to be used on enums.  */\r
-                               if (pfound->has_arg)\r
-                                       optarg = nameend + 1;\r
-                               else\r
-                               {\r
-                                       if (opterr)\r
-                                       {\r
-                                               if (argv[optind - 1][1] == '-')\r
-                                                       /* --option */\r
-                                                       fprintf (stderr,"error   : %s: option `--%s' doesn't allow an argument\n",argv[0], pfound->name);\r
-                                               else\r
-                                                       /* +option or -option */\r
-                                                       fprintf (stderr,"error   : %s: option `%c%s' doesn't allow an argument\n",argv[0], argv[optind - 1][0], pfound->name);\r
-                                       }\r
-                                       \r
-                                       nextchar += strlen (nextchar);\r
-                                       return '?';\r
-                               }\r
-                       }\r
-                       else if (pfound->has_arg == 1)\r
-                       {\r
-                               if (optind < argc)\r
-                                       optarg = argv[optind++];\r
-                               else\r
-                               {\r
-                                       if (opterr)\r
-                                               fprintf (stderr, "error   : %s: option `%s' requires an argument\n",argv[0], argv[optind - 1]);\r
-                                       \r
-                                       nextchar += strlen (nextchar);\r
-                                       return optstring[0] == ':' ? ':' : '?';\r
-                               }\r
-                       }\r
-                       \r
-                       nextchar += strlen (nextchar);\r
-                       \r
-                       if (longind != NULL)\r
-                               *longind = option_index;\r
-                       \r
-                       if (pfound->flag)\r
-                       {\r
-                               *(pfound->flag) = pfound->val;\r
-                               return 0;\r
-                       }\r
-                       \r
-                       return pfound->val;\r
-               }\r
-       \r
-               /* Can't find it as a long option.  If this is not getopt_long_only,\r
-               or the option starts with '--' or is not a valid short\r
-               option, then it's an error.\r
-               Otherwise interpret it as a short option.  */\r
-               if (!long_only || argv[optind][1] == '-'|| strchr (optstring, *nextchar) == NULL)\r
-               {\r
-                       if (opterr)\r
-                       {\r
-                               if (argv[optind][1] == '-')\r
-                                       /* --option */\r
-                                       fprintf (stderr, "error   : %s: unrecognized option `--%s'\n",argv[0], nextchar);\r
-                               else\r
-                                       /* +option or -option */\r
-                                       fprintf (stderr, "error   : %s: unrecognized option `%c%s'\n",argv[0], argv[optind][0], nextchar);\r
-                       }\r
-                       \r
-                       nextchar = (char *) "";\r
-                       optind++;\r
-                       return '?';\r
-               }\r
-       }\r
-       \r
-       /* Look at and handle the next short option-character.  */\r
-       \r
-       {\r
-               char c = *nextchar++;\r
-               char *temp = strchr (optstring, c);\r
-       \r
-               /* Increment `optind' when we start to process its last character.  */\r
-               if (*nextchar == '\0')\r
-                       ++optind;\r
-       \r
-               if (temp == NULL || c == ':')\r
-               {\r
-                       if (opterr)\r
-                                       fprintf (stderr, "error   : %s: invalid option -- %c\n", argv[0], c);\r
-                       \r
-                       optopt = c;\r
-                       return '?';\r
-               }\r
-               \r
-               if (temp[1] == ':')\r
-               {\r
-                       if (temp[2] == ':')\r
-                       {\r
-                               /* This is an option that accepts an argument optionally.  */\r
-                               if (*nextchar != '\0')\r
-                               {\r
-                                       optarg = nextchar;\r
-                                       optind++;\r
-                               }\r
-                               else\r
-                                       optarg = NULL;\r
-                               \r
-                               nextchar = NULL;\r
-                       }\r
-                       else\r
-                       {\r
-                               /* This is an option that requires an argument.  */\r
-                               if (*nextchar != '\0')\r
-                               {\r
-                                       optarg = nextchar;\r
-                                       /* If we end this ARGV-element by taking the rest as an arg,\r
-                                       we must advance to the next element now.  */\r
-                                       optind++;\r
-                               }\r
-                               else if (optind == argc)\r
-                               {\r
-                                       if (opterr)\r
-                                       {\r
-                                               /* 1003.2 specifies the format of this message.  */\r
-                                               fprintf (stderr, "error   : %s: option requires an argument -- %c\n",argv[0], c);\r
-                                       }\r
-                                       optopt = c;\r
-                                       \r
-                                       if (optstring[0] == ':')\r
-                                               c = ':';\r
-                                       else\r
-                                               c = '?';\r
-                               }\r
-                               else\r
-                                       /* We already incremented `optind' once;\r
-                                       increment it again when taking next ARGV-elt as argument.  */\r
-                                       optarg = argv[optind++];\r
-                               \r
-                               nextchar = NULL;\r
-                       }\r
-               }\r
-       return c;\r
-       \r
-       }\r
-}\r
-\r
-\r
-static void\r
-__exchange (char **argv)\r
-{\r
-       int bottom = first_nonopt;\r
-       int middle = last_nonopt;\r
-       int top = optind;\r
-       char *tem;\r
-       \r
-       /* Exchange the shorter segment with the far end of the longer segment.\r
-       That puts the shorter segment into the right place.\r
-       It leaves the longer segment in the right place overall,\r
-       but it consists of two parts that need to be swapped next.  */\r
-       \r
-       while (top > middle && middle > bottom)\r
-       {\r
-               if (top - middle > middle - bottom)\r
-               {\r
-                       /* Bottom segment is the short one.  */\r
-                       int len = middle - bottom;\r
-                       register int i;\r
-       \r
-                       /* Swap it with the top part of the top segment.  */\r
-                       for (i = 0; i < len; i++)\r
-                       {\r
-                               tem = argv[bottom + i];\r
-                               argv[bottom + i] = argv[top - (middle - bottom) + i];\r
-                               argv[top - (middle - bottom) + i] = tem;\r
-                       }\r
-                       /* Exclude the moved bottom segment from further swapping.  */\r
-                       \r
-                       top -= len;\r
-               }\r
-               else\r
-               {\r
-                       /* Top segment is the short one.  */\r
-                       int len = top - middle;\r
-                       register int i;\r
-               \r
-                       /* Swap it with the bottom part of the bottom segment.  */\r
-                       for (i = 0; i < len; i++)\r
-                       {\r
-                               tem = argv[bottom + i];\r
-                               argv[bottom + i] = argv[middle + i];\r
-                               argv[middle + i] = tem;\r
-                       }\r
-                       /* Exclude the moved top segment from further swapping.  */\r
-                       bottom += len;\r
-               }\r
-       }\r
-       \r
-       /* Update records for the slots the non-options now occupy.  */\r
-       \r
-       first_nonopt += (optind - last_nonopt);\r
-       last_nonopt = optind;\r
-}\r
-\r
-int\r
-getopt_long (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index)\r
-{\r
-       return __getopt_internal (argc, argv, options, long_options, opt_index, 0);\r
-}\r
-\r
-\r
-int\r
-getopt_long_only(int argc, char *const *argv, const char *options, const struct option *long_options,int *opt_index)\r
-{\r
-       return __getopt_internal (argc, argv, options, long_options, opt_index, 1);\r
-}\r
-\r
-\r
+\rchar *\r optarg = NULL;
+\r\rint \r optind = 0;
+\r\rint \r optopt = '?';
+\r\rint \r opterr = 1;
+\r\rstatic char *\r nextchar;
+\r\rstatic \r int first_nonopt;
+\r\rstatic int \r last_nonopt;
+\r\r\rstatic enum \r { \rREQUIRE_ORDER, \rPERMUTE, \rRETURN_IN_ORDER \r
+} ordering;
+\r\r\rstatic const char *\r __getopt_initialize(const char *optstring);
+\r\rstatic int \r
+__getopt_internal(int argc, char *const *argv, const char *optstring,
+                  const struct option *longopts, int *longind,
+                  int long_only);
+\r\rstatic void \r __exchange(char **argv);
+\r\rint \r getopt(int argc, char *const argv[], const char *optstring) \r
+{
+  \rreturn __getopt_internal(argc, argv, optstring,
+                            (const struct option *) 0, (int *) 0, 0);
+\r\r\rstatic const char *\r __getopt_initialize(const char *optstring) \r
+{
+  \r
+      /* Start processing options with ARGV-element 1 (since ARGV-element 0\r
+         is the program name); the sequence of previously skipped\r
+         non-option ARGV-elements is empty.  */ \r
+      \rfirst_nonopt = last_nonopt = optind = 1;
+  \rnextchar = NULL;
+  \r\r
+      /* Determine how to handle the ordering of options and nonoptions.  */ \r
+      \rif (optstring[0] == '-')
+    \r {
+    \rordering = RETURN_IN_ORDER;
+    \r++optstring;
+    \r}
+  \r
+      /* si la chaîne d'options commence par un + alors la fonction getopt() s'arrête\r
+       * dès qu'un argument de la ligne de commande n'est pas une option\r
+       */ \r
+      else if (optstring[0] == '+')
+    \r {
+    \rordering = REQUIRE_ORDER;
+    \r++optstring;
+    \r}
+  \r
+  else
+    \r {
+    \rordering = PERMUTE;
+    \r}
+  \r\rreturn optstring;
+\r}
+
+\r\rint \r
+__getopt_internal(int argc, char *const *argv, const char *optstring,
+                  const struct option *longopts, int *longind,
+                  int long_only) \r
+{
+  \roptarg = NULL;
+  \r\rif (optind == 0)
+    \roptstring = __getopt_initialize(optstring);
+  \r\rif (nextchar == NULL || *nextchar == '\0')
+    \r {
+    \r
+        /* Advance to the next ARGV-element.  */ \r
+        \rif (ordering == PERMUTE)
+      \r {
+      \r
+          /* If we have just processed some options following some non-options,\r
+             __exchange them so that the options come first.  */ \r
+          \rif (first_nonopt != last_nonopt && last_nonopt != optind)
+        \r__exchange((char **) argv);
+      \r
+      else if (last_nonopt != optind)
+        \rfirst_nonopt = optind;
+      \r\r
+          /* Skip any additional non-options\r
+             and extend the range of non-options previously skipped.  */ \r
+          \rwhile (optind < argc
+                  && (argv[optind][0] != '-' || argv[optind][1] == '\0'))
+        \roptind++;
+      \r\rlast_nonopt = optind;
+      \r}
+    \r\r
+        /* The special ARGV-element `--' means premature end of options.\r
+           Skip it like a null option,\r
+           then __exchange with previous non-options as if it were an option,\r
+           then skip everything else like a non-option.  */ \r
+        \rif (optind != argc && !strcmp(argv[optind], "--"))
+      \r {
+      \roptind++;
+      \r\rif (first_nonopt != last_nonopt && last_nonopt != optind)
+        \r__exchange((char **) argv);
+      \r
+      else if (first_nonopt == last_nonopt)
+        \rfirst_nonopt = optind;
+      \r\rlast_nonopt = argc;
+      \r\roptind = argc;
+      \r}
+    \r\r
+        /* If we have done all the ARGV-elements, stop the scan\r
+           and back over any non-options that we skipped and permuted.  */ \r
+        \rif (optind == argc)
+      \r {
+      \r
+          /* Set the next-arg-index to point at the non-options\r
+             that we previously skipped, so the caller will digest them.  */ \r
+          if (first_nonopt != last_nonopt)
+        \roptind = first_nonopt;
+      \r\rreturn EOF;
+      \r}
+    \r\r
+        /* If we have come to a non-option and did not permute it,\r
+           either stop the scan or describe it to the caller and pass it by.  */ \r
+        \rif ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
+      \r {
+      \rif (ordering == REQUIRE_ORDER)
+        \rreturn EOF;
+      \roptarg = argv[optind++];
+      \rreturn 1;
+      \r}
+    \r\r
+        /* We have found another option-ARGV-element.\r
+           Skip the initial punctuation.  */ \r
+        \rnextchar =
+        (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-'));
+    \r}
+  \r\r
+      /* Decode the current option-ARGV-element.  */ \r
+      \r
+      /* Check whether the ARGV-element is a long option.\r
+         \r
+         If long_only and the ARGV-element has the form "-f", where f is\r
+         a valid short option, don't consider it an abbreviated form of\r
+         a long option that starts with f.  Otherwise there would be no\r
+         way to give the -f short option.\r
+         \r
+         On the other hand, if there's a long option "fubar" and\r
+         the ARGV-element is "-fu", do consider that an abbreviation of\r
+         the long option, just like "--fu", and not "-f" with arg "u".\r
+         \r
+         This distinction seems to be the most useful approach.  */ \r
+      \rif (longopts != NULL
+           && (argv[optind][1] == '-'
+               || (long_only
+                   && (argv[optind][2]
+                       || !strchr(optstring, argv[optind][1])))))
+    \r {
+    \rchar *nameend;
+    \rconst struct option *p;
+    \rconst struct option *pfound = NULL;
+    \rint exact = 0;
+    \rint ambig = 0;
+    \rint indfound = 0;
+    \rint option_index;
+    \r\rfor (nameend = nextchar; *nameend != '\0' && *nameend != '=';
+           nameend++)
+      \r
+          /* Do nothing.  */ ;
+    \r\r
+        /* Test all long options for either exact match\r
+           or abbreviated matches.  */ \r
+        for (p = longopts, option_index = 0; p->name; p++, option_index++)
+      \r {
+      \rif (!strncmp(p->name, nextchar, nameend - nextchar))
+        \r {
+        \r\rif (nameend - nextchar == strlen(p->name))
+          \r {
+          \r
+              /* Exact match found.  */ \r
+              pfound = p;
+          \rindfound = option_index;
+          \rexact = 1;
+          \rbreak;
+          \r}
+        \r
+        else if (pfound == NULL)
+          \r {
+          \r
+              /* First nonexact match found.  */ \r
+              exact = 0;
+          \r
+              /* begin change\r
+                 pfound = p;\r
+                 indfound = option_index;\r
+                 end change */ \r
+              break;
+          \r}
+        \r
+        else
+          \r {
+          \r\r
+              /* Second or later nonexact match found.  */ \r
+              ambig = 1;
+          \r}
+        \r}
+      \r}
+    \r\rif (ambig && !exact)
+      \r {
+      \rif (opterr)
+        \rfprintf(stderr, "error   : %s: option `%s' is ambiguous\n",
+                 argv[0], argv[optind]);
+      \r\rnextchar += strlen(nextchar);
+      \roptind++;
+      \rreturn '?';
+      \r}
+    \r\rif (pfound != NULL)
+      \r {
+      \roption_index = indfound;
+      \roptind++;
+      \r\rif (*nameend)
+        \r {
+        \r
+            /* Don't test has_arg with >, because some C compilers don't\r
+               allow it to be used on enums.  */ \r
+            if (pfound->has_arg)
+          \roptarg = nameend + 1;
+        \r
+        else
+          \r {
+          \rif (opterr)
+            \r {
+            \rif (argv[optind - 1][1] == '-')
+              \r
+                  /* --option */ \r
+                  fprintf(stderr,
+                          "error   : %s: option `--%s' doesn't allow an argument\n",
+                          argv[0], pfound->name);
+            \r
+            else
+              \r
+                  /* +option or -option */ \r
+                  fprintf(stderr,
+                          "error   : %s: option `%c%s' doesn't allow an argument\n",
+                          argv[0], argv[optind - 1][0], pfound->name);
+            \r}
+          \r\rnextchar += strlen(nextchar);
+          \rreturn '?';
+          \r}
+        \r}
+      \r
+      else if (pfound->has_arg == 1)
+        \r {
+        \rif (optind < argc)
+          \roptarg = argv[optind++];
+        \r
+        else
+          \r {
+          \rif (opterr)
+            \rfprintf(stderr,
+                     "error   : %s: option `%s' requires an argument\n",
+                     argv[0], argv[optind - 1]);
+          \r\rnextchar += strlen(nextchar);
+          \rreturn optstring[0] == ':' ? ':' : '?';
+          \r}
+        \r}
+      \r\rnextchar += strlen(nextchar);
+      \r\rif (longind != NULL)
+        \r*longind = option_index;
+      \r\rif (pfound->flag)
+        \r {
+        \r*(pfound->flag) = pfound->val;
+        \rreturn 0;
+        \r}
+      \r\rreturn pfound->val;
+      \r}
+    \r\r
+        /* Can't find it as a long option.  If this is not getopt_long_only,\r
+           or the option starts with '--' or is not a valid short\r
+           option, then it's an error.\r
+           Otherwise interpret it as a short option.  */ \r
+        if (!long_only || argv[optind][1] == '-'
+            || strchr(optstring, *nextchar) == NULL)
+      \r {
+      \rif (opterr)
+        \r {
+        \rif (argv[optind][1] == '-')
+          \r
+              /* --option */ \r
+              fprintf(stderr, "error   : %s: unrecognized option `--%s'\n",
+                      argv[0], nextchar);
+        \r
+        else
+          \r
+              /* +option or -option */ \r
+              fprintf(stderr, "error   : %s: unrecognized option `%c%s'\n",
+                      argv[0], argv[optind][0], nextchar);
+        \r}
+      \r\rnextchar = (char *) "";
+      \roptind++;
+      \rreturn '?';
+      \r}
+    \r}
+  \r\r
+      /* Look at and handle the next short option-character.  */ \r
+      \r {
+    \rchar c = *nextchar++;
+    \rchar *temp = strchr(optstring, c);
+    \r\r
+        /* Increment `optind' when we start to process its last character.  */ \r
+        if (*nextchar == '\0')
+      \r++optind;
+    \r\rif (temp == NULL || c == ':')
+      \r {
+      \rif (opterr)
+        \rfprintf(stderr, "error   : %s: invalid option -- %c\n", argv[0],
+                 c);
+      \r\roptopt = c;
+      \rreturn '?';
+      \r}
+    \r\rif (temp[1] == ':')
+      \r {
+      \rif (temp[2] == ':')
+        \r {
+        \r
+            /* This is an option that accepts an argument optionally.  */ \r
+            if (*nextchar != '\0')
+          \r {
+          \roptarg = nextchar;
+          \roptind++;
+          \r}
+        \r
+        else
+          \roptarg = NULL;
+        \r\rnextchar = NULL;
+        \r}
+      \r
+      else
+        \r {
+        \r
+            /* This is an option that requires an argument.  */ \r
+            if (*nextchar != '\0')
+          \r {
+          \roptarg = nextchar;
+          \r
+              /* If we end this ARGV-element by taking the rest as an arg,\r
+                 we must advance to the next element now.  */ \r
+              optind++;
+          \r}
+        \r
+        else if (optind == argc)
+          \r {
+          \rif (opterr)
+            \r {
+            \r
+                /* 1003.2 specifies the format of this message.  */ \r
+                fprintf(stderr,
+                        "error   : %s: option requires an argument -- %c\n",
+                        argv[0], c);
+            \r}
+          \roptopt = c;
+          \r\rif (optstring[0] == ':')
+            \rc = ':';
+          \r
+          else
+            \rc = '?';
+          \r}
+        \r
+        else
+          \r
+              /* We already incremented `optind' once;\r
+                 increment it again when taking next ARGV-elt as argument.  */ \r
+              optarg = argv[optind++];
+        \r\rnextchar = NULL;
+        \r}
+      \r}
+    \rreturn c;
+  \r\r}
+\r}
+
+\r\r\rstatic void \r __exchange(char **argv) \r
+{
+  \rint bottom = first_nonopt;
+  \rint middle = last_nonopt;
+  \rint top = optind;
+  \rchar *tem;
+  \r\r
+      /* Exchange the shorter segment with the far end of the longer segment.\r
+         That puts the shorter segment into the right place.\r
+         It leaves the longer segment in the right place overall,\r
+         but it consists of two parts that need to be swapped next.  */ \r
+      \rwhile (top > middle && middle > bottom)
+    \r {
+    \rif (top - middle > middle - bottom)
+      \r {
+      \r
+          /* Bottom segment is the short one.  */ \r
+      int len = middle - bottom;
+      \rregister int i;
+      \r\r
+          /* Swap it with the top part of the top segment.  */ \r
+          for (i = 0; i < len; i++)
+        \r {
+        \rtem = argv[bottom + i];
+        \rargv[bottom + i] = argv[top - (middle - bottom) + i];
+        \rargv[top - (middle - bottom) + i] = tem;
+        \r}
+      \r
+          /* Exclude the moved bottom segment from further swapping.  */ \r
+          \rtop -= len;
+      \r}
+    \r
+    else
+      \r {
+      \r
+          /* Top segment is the short one.  */ \r
+      int len = top - middle;
+      \rregister int i;
+      \r\r
+          /* Swap it with the bottom part of the bottom segment.  */ \r
+          for (i = 0; i < len; i++)
+        \r {
+        \rtem = argv[bottom + i];
+        \rargv[bottom + i] = argv[middle + i];
+        \rargv[middle + i] = tem;
+        \r}
+      \r
+          /* Exclude the moved top segment from further swapping.  */ \r
+          bottom += len;
+      \r}
+    \r}
+  \r\r
+      /* Update records for the slots the non-options now occupy.  */ \r
+      \rfirst_nonopt += (optind - last_nonopt);
+  \rlast_nonopt = optind;
+\r}
+
+\r\rint \r
+getopt_long(int argc, char *const *argv, const char *options,
+            const struct option *long_options, int *opt_index) \r
+{
+  \rreturn __getopt_internal(argc, argv, options, long_options, opt_index,
+                            0);
+\r}
+
+\r\r\rint \r
+getopt_long_only(int argc, char *const *argv, const char *options,
+                 const struct option *long_options, int *opt_index) \r
+{
+  \rreturn __getopt_internal(argc, argv, options, long_options, opt_index,
+                            1);
+\r}
+
+\r\r\r
index a7262c4..c5166e3 100644 (file)
@@ -6,12 +6,11 @@
 #include <stdlib.h>
 
 /* struct s_Buffer declaration. */
-typedef struct s_Buffer
-{
-       char* data;             /* the buffer data.                                     */
-       size_t size;            /* the buffer size (in bytes).          */
-       size_t capacity;        /* the buffer capacity (in bytes).      */
-}s_Buffer_t,* Buffer_t;
+typedef struct s_Buffer {
+  char *data;                   /* the buffer data.                                     */
+  size_t size;                  /* the buffer size (in bytes).          */
+  size_t capacity;              /* the buffer capacity (in bytes).      */
+} s_Buffer_t, *Buffer_t;
 
 /* Asserts that a s_Buffer is valid. */
 #define ASSERT_VALID_Buffer(p) ( ASSERT_NOT_NULL((p)) /*&& ASSERT_NOT_NULL((p)->data)*/ )
@@ -30,14 +29,14 @@ Buffer_t Buffer_new(void);
 
 /* Clears the buffer (this function don't destroy it,
  * see Buffer_free function). 
- */ 
+ */
 void Buffer_clear(Buffer_t buffer);
 
 /* Appends a string in the buffer. If successful, 
  * the function returns true. Otherwise the function
  * returns false.
  */
-bool Buffer_append(Buffer_t buffer,char* str);
+bool Buffer_append(Buffer_t buffer, char *str);
 
 /* 
  * Removes all the linefeed from the buffer. 
@@ -58,4 +57,4 @@ bool Buffer_empty(Buffer_t buffer);
 
 
 
-#endif /* #ifndef __BUFFER_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __BUFFER_H__ */
index c88c444..e0852f0 100644 (file)
 #else
 #define NULL ((void *)0)
 #endif
-#endif /* #ifndef NULL*/
+#endif                          /* #ifndef NULL */
 
 #if !defined(__cplusplus) && !defined(__BOOL_TYPE_DEFINED)
 typedef int bool;
 #define __BOOL_TYPE_DEFINED
-#endif /* #ifndef __cplusplus*/
+#endif                          /* #ifndef __cplusplus */
 
 #ifndef __SSIZE_TYPE_DEFINED
 typedef int ssize_t;
 #define __SSIZE_TYPE_DEFINED
-#endif /* #ifndef __SSIZE_TYPE_DEFINED */
+#endif                          /* #ifndef __SSIZE_TYPE_DEFINED */
 
 #ifndef true
 #define true 1
-#endif /* #ifndef true*/
+#endif                          /* #ifndef true */
 
 #ifndef false
 #define false 0
-#endif /* #ifndef false*/
+#endif                          /* #ifndef false */
 
 /* Asserts that a condition is true.*/
 #define ASSERT(c)                                              assert(c)
@@ -39,9 +39,9 @@ typedef int ssize_t;
 #ifndef __ERRNO_TYPE_DEFINED
 typedef int errno_t;
 #define __ERRNO_TYPE_DEFINED
-#endif /* #ifndef __ERRNO_TYPE_DEFINED */
+#endif                          /* #ifndef __ERRNO_TYPE_DEFINED */
 
 /* comment this line if you don't want activate the verbose mode. */
-#define __VERBOSE 
+#define __VERBOSE
 
-#endif /*  #ifndef __DEFS_H__ */
+#endif                          /*  #ifndef __DEFS_H__ */
index b7f8c5e..16e359d 100644 (file)
 #include <string.h>
 #include <windows.h>
 
-#define E_SUCCESS                                                                                      ((errno_t)0)                    /* Success                                                                                                                      */
-#define E_TEST_RUNNER_ALLOCATION_FAILED                                        ((errno_t)1)                    /* Test runner allocation failed                                                                        */
-#define E_TEST_CASE_CONTEXT_ALLOCATION_FAILED                          ((errno_t)2)                    /* Test case context allocation failed                                                          */
-#define E_BUFFER_ALLOCATION_FAILED                                                     ((errno_t)3)                    /* Buffer allocation failed                                                                                     */
-#define E_BUFFER_DATA_ALLOCATION_FAILED                                                ((errno_t)4)                    /* Buffer data allocation failed                                                                        */
-#define E_TEST_SUITE_ALLOCATION_FAILED                                         ((errno_t)5)                    /* Test suite allocation failed                                                                         */
-#define E_FILE_NOT_FOUND                                                                       ((errno_t)6)                    /* Ffile not found                                                                                                              */
-#define E_BAD_USAGE                                                                                    ((errno_t)7)                    /* Bad usage                                                                                                            */
-#define E_INVALID_FILE_Stream                                                          ((errno_t)8)                    /* Invalid file stream                  */
-#define E_STREAM_ALLOCATION_FAILED                                                     ((errno_t)9)                    /* Stream allocation failed                                     */
-#define E_Buffer_DATA_REALLOCATION_FAILED                                      ((errno_t)10)                   /* Buffer data reallocation failed                                                                      */
-#define E_STREAM_LINE_ALLOCATION_FAILED                                                ((errno_t)11)                   /* Stream line allocation failed */
-#define E_STREAM_LINE_REALLOCATION_FAILED                                      ((errno_t)12)                   /* Stream line reallocation failed */
-#define E_STREAM_EMPTY                                                                         ((errno_t)13)                   /* File empty   */
-#define E_STREAM_ERROR                                                                         ((errno_t)14)                   /* File error   */
-#define E_UNKWN_META_COMMAND                                                           ((errno_t)15)                   /* Unknown meta command detected */
-#define E_INVALID_TIMEOUT_VALUE                                                                ((errno_t)16)                   /* Invalid timeout value                        */
-#define E_INVALID_EXIT_CODE_VALUE                                                      ((errno_t)17)                   /* Invalid exit code                            */
-#define E_INVALID_EXPORT                                                                       ((errno_t)18)                   /* Invalid export meta command          */
-#define E_INVALID_UNSET                                                                                ((errno_t)19)                   /* Invalid unset meta command           */
-#define E_EXPORT_FAILED                                                                                ((errno_t)20)                   /* Export failed*/
-#define E_UNSET_FAILED                                                                         ((errno_t)21)                   /* Unset failed*/
-#define E_SYNC_TEST_CASE_ALLOCATION_FAILED                                     ((errno_t)22)                   /* Synchrone test case allocation failed        */
-#define E_CANNOT_CREATE_CHILD_STDOUT_READ_HANDLE                       ((errno_t)23)                   /* Can't create the child std output read handle */
-#define E_CANNOT_CREATE_CHILD_STDERR_READ_HANDLE                       ((errno_t)24)                   /* Can't create the child std error read handle */ 
-#define E_CANNOT_CREATE_CHILD_STDIN_WRITE_HANDLE                       ((errno_t)25)                   /* Can't create the child std input write handle*/
-#define E_CANNOT_CREATE_STDOUT_READ_HANDLE                                     ((errno_t)26)                   /* Can't create the std output handle                   */
-#define E_CANNOT_CREATE_STDIN_WRITE_HANDLE                                     ((errno_t)27)                   /* Can't create the std input handle                    */
-#define E_CANNOT_CLOSE_CHILD_STDIN_TEMPORY_HANDLE                      ((errno_t)28)                   /* Can't close the tempory child std input handle*/
-#define E_CANNOT_CLOSE_CHILD_STDOUT_TEMPORY_HANDLE                     ((errno_t)29)                   /* Can't close the tempory child std output handle*/
-#define E_CANNOT_CREATE_CHILD_PROCESS                                          ((errno_t)30)                   /* Can't create the child process                                       */
-#define E_CANNOT_CLOSE_PROCESS_THREAD_HANDLE                           ((errno_t)31)                   /* Can't close the child process handle                         */
-#define E_CANNOT_CLOSE_CHILD_STDOUT_HANDLE                                     ((errno_t)32)                   /* Can't close the child std output handle                      */
-#define E_CANNOT_CLOSE_CHILD_STDIN_HANDLE                                      ((errno_t)33)                   /* Can't close the child std input handle                       */
-#define E_CANNOT_CLOSE_CHILD_STDERR_HANDLE                                     ((errno_t)34)                   /* Can't close the child std error handle                       */
-#define E_CANNOT_WRITE_ON_CHILD_STDIN                                          ((errno_t)35)                   /* Can't write on child std output                                      */
-#define E_CANNOT_CREATE_READ_CHILD_OUTPUT_THREAD                       ((errno_t)36)                   /* Can't create the read child output thread            */
-#define E_WAIT_THREAD_FAILED                                                           ((errno_t)37)                   /* Wait thread failed                                                           */
-#define E_CANNOT_CLOSE_THREAD_HANDLE                                           ((errno_t)38)                   /* Can't close thread handle                                            */
-#define E_CANNOT_CLOSE_READ_HANDLE                                                     ((errno_t)39)                   /* Can't close the read handle                                          */
-#define E_CANNOT_CLOSE_WRITE_HANDLE                                                    ((errno_t)40)                   /* Can't close the write handle                                         */
-#define E_WAIT_FAILURE                                                                         ((errno_t)41)                   /* Wait failure                                                                         */
-#define E_CANNOT_CLOSE_PROCESS_HANDLE                                          ((errno_t)42)                   /* Can't close the process handle                                       */
-#define E_OUTPUT_DONT_MATCH                                                                    ((errno_t)43)                   /* Output don't match                                                           */
-#define E_OPEN_FILE_FAILED                                  ((errno_t)44)           /* Open file failed*/
-#define E_INVALID_TOKEN                                     ((errno_t)45)           /* Invalid token*/
-#define E_WAIT_TIMEOUT                                      ((errno_t)46)           /* Wait timeout detected  */
-#define E_EXIT_CODE_DONT_MATCH                              ((errno_t)47)           /* Exit code don't match    */
-#define E_CHANGE_DIRECTORY_FAILED                           ((errno_t)48)           /* Change directory failed  */
+#define E_SUCCESS                                                                                      ((errno_t)0)    /* Success                                                                                                                      */
+#define E_TEST_RUNNER_ALLOCATION_FAILED                                        ((errno_t)1)    /* Test runner allocation failed                                                                        */
+#define E_TEST_CASE_CONTEXT_ALLOCATION_FAILED                          ((errno_t)2)    /* Test case context allocation failed                                                          */
+#define E_BUFFER_ALLOCATION_FAILED                                                     ((errno_t)3)    /* Buffer allocation failed                                                                                     */
+#define E_BUFFER_DATA_ALLOCATION_FAILED                                                ((errno_t)4)    /* Buffer data allocation failed                                                                        */
+#define E_TEST_SUITE_ALLOCATION_FAILED                                         ((errno_t)5)    /* Test suite allocation failed                                                                         */
+#define E_FILE_NOT_FOUND                                                                       ((errno_t)6)    /* Ffile not found                                                                                                              */
+#define E_BAD_USAGE                                                                                    ((errno_t)7)    /* Bad usage                                                                                                            */
+#define E_INVALID_FILE_Stream                                                          ((errno_t)8)    /* Invalid file stream                  */
+#define E_STREAM_ALLOCATION_FAILED                                                     ((errno_t)9)    /* Stream allocation failed                                     */
+#define E_Buffer_DATA_REALLOCATION_FAILED                                      ((errno_t)10)   /* Buffer data reallocation failed                                                                      */
+#define E_STREAM_LINE_ALLOCATION_FAILED                                                ((errno_t)11)   /* Stream line allocation failed */
+#define E_STREAM_LINE_REALLOCATION_FAILED                                      ((errno_t)12)   /* Stream line reallocation failed */
+#define E_STREAM_EMPTY                                                                         ((errno_t)13)   /* File empty   */
+#define E_STREAM_ERROR                                                                         ((errno_t)14)   /* File error   */
+#define E_UNKWN_META_COMMAND                                                           ((errno_t)15)   /* Unknown meta command detected */
+#define E_INVALID_TIMEOUT_VALUE                                                                ((errno_t)16)   /* Invalid timeout value                        */
+#define E_INVALID_EXIT_CODE_VALUE                                                      ((errno_t)17)   /* Invalid exit code                            */
+#define E_INVALID_EXPORT                                                                       ((errno_t)18)   /* Invalid export meta command          */
+#define E_INVALID_UNSET                                                                                ((errno_t)19)   /* Invalid unset meta command           */
+#define E_EXPORT_FAILED                                                                                ((errno_t)20)   /* Export failed */
+#define E_UNSET_FAILED                                                                         ((errno_t)21)   /* Unset failed */
+#define E_SYNC_TEST_CASE_ALLOCATION_FAILED                                     ((errno_t)22)   /* Synchrone test case allocation failed        */
+#define E_CANNOT_CREATE_CHILD_STDOUT_READ_HANDLE                       ((errno_t)23)   /* Can't create the child std output read handle */
+#define E_CANNOT_CREATE_CHILD_STDERR_READ_HANDLE                       ((errno_t)24)   /* Can't create the child std error read handle */
+#define E_CANNOT_CREATE_CHILD_STDIN_WRITE_HANDLE                       ((errno_t)25)   /* Can't create the child std input write handle */
+#define E_CANNOT_CREATE_STDOUT_READ_HANDLE                                     ((errno_t)26)   /* Can't create the std output handle                   */
+#define E_CANNOT_CREATE_STDIN_WRITE_HANDLE                                     ((errno_t)27)   /* Can't create the std input handle                    */
+#define E_CANNOT_CLOSE_CHILD_STDIN_TEMPORY_HANDLE                      ((errno_t)28)   /* Can't close the tempory child std input handle */
+#define E_CANNOT_CLOSE_CHILD_STDOUT_TEMPORY_HANDLE                     ((errno_t)29)   /* Can't close the tempory child std output handle */
+#define E_CANNOT_CREATE_CHILD_PROCESS                                          ((errno_t)30)   /* Can't create the child process                                       */
+#define E_CANNOT_CLOSE_PROCESS_THREAD_HANDLE                           ((errno_t)31)   /* Can't close the child process handle                         */
+#define E_CANNOT_CLOSE_CHILD_STDOUT_HANDLE                                     ((errno_t)32)   /* Can't close the child std output handle                      */
+#define E_CANNOT_CLOSE_CHILD_STDIN_HANDLE                                      ((errno_t)33)   /* Can't close the child std input handle                       */
+#define E_CANNOT_CLOSE_CHILD_STDERR_HANDLE                                     ((errno_t)34)   /* Can't close the child std error handle                       */
+#define E_CANNOT_WRITE_ON_CHILD_STDIN                                          ((errno_t)35)   /* Can't write on child std output                                      */
+#define E_CANNOT_CREATE_READ_CHILD_OUTPUT_THREAD                       ((errno_t)36)   /* Can't create the read child output thread            */
+#define E_WAIT_THREAD_FAILED                                                           ((errno_t)37)   /* Wait thread failed                                                           */
+#define E_CANNOT_CLOSE_THREAD_HANDLE                                           ((errno_t)38)   /* Can't close thread handle                                            */
+#define E_CANNOT_CLOSE_READ_HANDLE                                                     ((errno_t)39)   /* Can't close the read handle                                          */
+#define E_CANNOT_CLOSE_WRITE_HANDLE                                                    ((errno_t)40)   /* Can't close the write handle                                         */
+#define E_WAIT_FAILURE                                                                         ((errno_t)41)   /* Wait failure                                                                         */
+#define E_CANNOT_CLOSE_PROCESS_HANDLE                                          ((errno_t)42)   /* Can't close the process handle                                       */
+#define E_OUTPUT_DONT_MATCH                                                                    ((errno_t)43)   /* Output don't match                                                           */
+#define E_OPEN_FILE_FAILED                                  ((errno_t)44)       /* Open file failed */
+#define E_INVALID_TOKEN                                     ((errno_t)45)       /* Invalid token */
+#define E_WAIT_TIMEOUT                                      ((errno_t)46)       /* Wait timeout detected  */
+#define E_EXIT_CODE_DONT_MATCH                              ((errno_t)47)       /* Exit code don't match    */
+#define E_CHANGE_DIRECTORY_FAILED                           ((errno_t)48)       /* Change directory failed  */
 
 /* error message list */
-static const char * __errlist[ ] =
-{
-       "Success",
-       "Test runner allocation failed",
-       "Test case context allocation failed",
-       "Buffer allocation failed",
-       "Buffer data allocation failed",
-       "Test suite allocation failed",
-       "File not found",
-       "Bad usage",
-       "Invalid file stream",
-       "Stream allocation failed",
-       "Buffer data reallocation failed",
-       "Stream line allocation failed",
-       "Stream line reallocation failed",
-       "File empty",
-       "File error",
-       "Unknown meta command detected",
-       "Invalid timeout value",
-       "Invalid exit code",
-       "Invalid export meta command",
-       "Invalid unset meta command",
-       "Export failed",
-       "Unset failed",
-       "Synchrone test case allocation failed",
-       "Can't create the child std output read handle",
-       "Can't create the child std error read handle",
-       "Can't create the child std input write handle",
-       "Can't create the std output handle",
-       "Can't create the std input handle",
-       "Can't close the tempory child std input handle",
-       "Can't close the tempory child std output handle",
-       "Can't create the child process",
-       "Can't close the child process handle",
-       "Can't close the child std output handle",
-       "Can't close the child std input handle",
-       "Can't close the child std error handle",
-       "Can't write on child std output",
-       "Can't create the read child output thread",
-       "Wait thread failed",
-       "Can't close thread handle",
-       "Can't close the read handle",
-       "Can't close the write handle",
-       "Wait failure",
-       "Can't close the process handle",
-       "Output don't match",
-       "Open file failed",
-       "Invalid token",
-       "Wait timeout detected",
-       "Exit code don't match",
-    "Change directory failed"
+static const char *__errlist[] = {
+  "Success",
+  "Test runner allocation failed",
+  "Test case context allocation failed",
+  "Buffer allocation failed",
+  "Buffer data allocation failed",
+  "Test suite allocation failed",
+  "File not found",
+  "Bad usage",
+  "Invalid file stream",
+  "Stream allocation failed",
+  "Buffer data reallocation failed",
+  "Stream line allocation failed",
+  "Stream line reallocation failed",
+  "File empty",
+  "File error",
+  "Unknown meta command detected",
+  "Invalid timeout value",
+  "Invalid exit code",
+  "Invalid export meta command",
+  "Invalid unset meta command",
+  "Export failed",
+  "Unset failed",
+  "Synchrone test case allocation failed",
+  "Can't create the child std output read handle",
+  "Can't create the child std error read handle",
+  "Can't create the child std input write handle",
+  "Can't create the std output handle",
+  "Can't create the std input handle",
+  "Can't close the tempory child std input handle",
+  "Can't close the tempory child std output handle",
+  "Can't create the child process",
+  "Can't close the child process handle",
+  "Can't close the child std output handle",
+  "Can't close the child std input handle",
+  "Can't close the child std error handle",
+  "Can't write on child std output",
+  "Can't create the read child output thread",
+  "Wait thread failed",
+  "Can't close thread handle",
+  "Can't close the read handle",
+  "Can't close the write handle",
+  "Wait failure",
+  "Can't close the process handle",
+  "Output don't match",
+  "Open file failed",
+  "Invalid token",
+  "Wait timeout detected",
+  "Exit code don't match",
+  "Change directory failed"
 };
 
 extern void initializeErrno(void);
@@ -117,4 +116,4 @@ extern void setErrno(errno_t e);
 
 extern errno_t getErrno(void);
 
-#endif /* #ifndef __ERRNO_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __ERRNO_H__ */
index 6fd72b7..2d09f9d 100644 (file)
  * which represents a file stream.
  */
 
-typedef struct s_Stream
-{
-       FILE* file;                             /* the file stream.                                     */
-       char* line;                             /* the current text line                                */
-       size_t line_number;             /* line number in the testsuite file    */
-    CRITICAL_SECTION cs;    /* std output managment                 */
-}s_Stream_t,* Stream_t;
+typedef struct s_Stream {
+  FILE *file;                   /* the file stream.                                     */
+  char *line;                   /* the current text line                                */
+  size_t line_number;           /* line number in the testsuite file    */
+  CRITICAL_SECTION cs;          /* std output managment                 */
+} s_Stream_t, *Stream_t;
 
 /* Line type. */
-typedef enum
-{
-       comment_line_type,                                              /* the text line is a comment                                                                                   */
-       invalid_token_line_type,                                /* the text line contains a invalid token                                                               */
-       unknwn_meta_command_line_type,                  /* the text line contains a unknown macro command                                               */
-       invalid_timeout_value_line_type,                /* the text line contains a invalid timeout value                                               */
-       timeout_value_line_type,                                /* the text line contains a valid timeout value                                                 */
-       invalid_exit_code_line_type,                    /* the text line contains a invalid exit code value                                             */
-       exit_code_line_type,                                    /* the text line contains a valid exit code value                                               */
-       invalid_export_line_type,                               /* the text line contains a invalid export meta command                                 */
-       export_line_type,                                               /* the text line contains a valid export meta command                                   */
-       invalid_unset_line_type,                                /* the text line contains a invalid unset meta command                                  */
-       unset_line_type,                                                /* the text line contains a valid unset meta command                                    */
-       enable_output_checking_line_type,               /* the text line contains a enable output checking meta command                 */
-       disable_output_checking_line_type,              /* the text line contains a disable output checking meta command                */
-       enable_post_output_checking_line_type,  /* the text line contains a enable post output checking meta command    */      
-       disable_post_output_checking_line_type, /* the text line contains a disable post output checking meta command   */
-       export_failed_line_type,                                /* the text line contains a export meta command which failed                    */
-       unset_failed_line_type,                                 /* the text line contains a unset meta command which failed                             */
-    create_console_line_type,               /* the text line contains a create console meta command                 */
-    create_no_console_line_type,            /* the text line contains a create no console meta command              */
-    enable_exit_code_checking_line_type,    /* the text line contains a enable exit code checking                   */
-    disable_exit_code_checking_line_type,    /* the text line contains a disable exit code checking                  */
-    change_directory_line_type,              /* the text line contains a change directory command                   */
-    command_line_line_type                  /* the text line contains a command line                                */
-    }line_type_t;
+typedef enum {
+  comment_line_type,            /* the text line is a comment                                                                                   */
+  invalid_token_line_type,      /* the text line contains a invalid token                                                               */
+  unknwn_meta_command_line_type,        /* the text line contains a unknown macro command                                               */
+  invalid_timeout_value_line_type,      /* the text line contains a invalid timeout value                                               */
+  timeout_value_line_type,      /* the text line contains a valid timeout value                                                 */
+  invalid_exit_code_line_type,  /* the text line contains a invalid exit code value                                             */
+  exit_code_line_type,          /* the text line contains a valid exit code value                                               */
+  invalid_export_line_type,     /* the text line contains a invalid export meta command                                 */
+  export_line_type,             /* the text line contains a valid export meta command                                   */
+  invalid_unset_line_type,      /* the text line contains a invalid unset meta command                                  */
+  unset_line_type,              /* the text line contains a valid unset meta command                                    */
+  enable_output_checking_line_type,     /* the text line contains a enable output checking meta command                 */
+  disable_output_checking_line_type,    /* the text line contains a disable output checking meta command                */
+  enable_post_output_checking_line_type,        /* the text line contains a enable post output checking meta command    */
+  disable_post_output_checking_line_type,       /* the text line contains a disable post output checking meta command   */
+  export_failed_line_type,      /* the text line contains a export meta command which failed                    */
+  unset_failed_line_type,       /* the text line contains a unset meta command which failed                             */
+  create_console_line_type,     /* the text line contains a create console meta command                 */
+  create_no_console_line_type,  /* the text line contains a create no console meta command              */
+  enable_exit_code_checking_line_type,  /* the text line contains a enable exit code checking                   */
+  disable_exit_code_checking_line_type, /* the text line contains a disable exit code checking                  */
+  change_directory_line_type,   /* the text line contains a change directory command                   */
+  command_line_line_type        /* the text line contains a command line                                */
+} line_type_t;
 
 /* 
  * Buffer size used in the getline function. 
@@ -56,7 +54,7 @@ typedef enum
 /* 
  * s_Stream struct connected functions.
  */
+
 /*
  * Create a new s_Stream struct and return
  * a pointer to self
@@ -73,20 +71,20 @@ bool Stream_lineIsBlank(Stream_t stream);
  * Return true if the caracter is space or tab.
  */
 bool Stream_isBlankChar(char ch);
+
 
 /*
  * Return E_SUCCESS if the file is valid. 
  * Otherwise the fuction returns E_INVALID_FILE.
  */
-errno_t Stream_isValidFile(const charfile_name);
+errno_t Stream_isValidFile(const char *file_name);
 
 
 /* 
  * Return E_SUCCESS is the open file operation succeeded.
  * Otherwise the functions returns E_OPEN_FILE_FAILED.
  */
-errno_t Stream_openFile(Stream_t ptr,const char* file_name);
+errno_t Stream_openFile(Stream_t ptr, const char *file_name);
 
 /*
  * This function reads an entire line, storing 
@@ -146,7 +144,7 @@ bool Stream_isInvalidUnset(Stream_t stream);
  * expected child output. Otherwhise the function
  * returns false.
  */
-bool Stream_lineIsExpectedChildOutput(Stream_t stream); 
+bool Stream_lineIsExpectedChildOutput(Stream_t stream);
 
 /* 
  * Return true if the stream line contains a 
@@ -173,7 +171,7 @@ bool Stream_lineIsInvalidMetaCommand(Stream_t stream);
 /*
  * Print the file line.
  */
-void  Stream_printLine(Stream_t stream,line_type_t line_type);
+void Stream_printLine(Stream_t stream, line_type_t line_type);
 
 void Stream_lock(Stream_t ptr);
 void Stream_unlock(Stream_t ptr);
@@ -185,8 +183,8 @@ extern CRITICAL_SECTION cs;
 /* 
  * Free a s_Stream.
  */
- void Stream_free(Stream_t ptr);
+
+void Stream_free(Stream_t ptr);
 
 
-#endif /* #ifndef __STREAM_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __STREAM_H__ */
index df38103..99c6a99 100644 (file)
@@ -9,35 +9,34 @@
  * which represents the context of a test case during his
  * execution.
  */
-typedef struct s_TestCaseContext
-{
-       char* name;                                                             /* the test case name                                                                   */
-       int timeoutValue;                                               /* the timeout value                                                                    */
-       bool isOutputCheckingEnabled;                   /* if true, output checking is enable                                   */
-       bool isPostOutputCheckingEnabled;               /* if true, the post output checking mode is enable             */
-       Buffer_t inputBuffer;                                   /* buffer that contains child input                                             */
-       Buffer_t outputBuffer;                                  /* the child output buffer                                                              */
-       Buffer_t expectedOutputBuffer;          /* buffer that contains child expected output                   */
-       int expectedExitCode;                                   /* the child expected exit code                                                 */
-       int threadExitCode;                                     /* the thread exit code                                                                                         */
-       int exitCode;                                                   /* the child process exit code                                                                          */
-    bool runThread;                                            /* false if the thread of the test case must terminate                          */      
-       HANDLE hThread;                                                 /* the handle of the thread                                                                                     */                      
-       HANDLE hOutputRead;                                             /* handle to the read pipe                                                                                      */
-       HANDLE hInputWrite;                                             /* handle to the write pipe                                                                                     */
-       HANDLE hChildStdInRead;                                 /* handle to the pipe used to read the child std input                          */ 
-       HANDLE hChildStdOutWrite;                               /* handle to the pipe used to write to the chil std output                      */
-       HANDLE hChildStderr;                                    /* handle to the pipe used to read the child std error                          */
-       PROCESS_INFORMATION pi;                                 /* this structure contains child process informations                           */ 
-       HANDLE hChildStdoutReadTmp;                             /* tempory handle                                                                                                       */
-       HANDLE hChildStdinWriteTmp;                             /* tempory handle                                                                                                       */
-    bool createConsole;                    /* true if we can create a console for the child process            */
-    bool exitCodeCheckingEnabled;         /* true if we want to check the child exit code                     */
-    HANDLE hConsole;                        /* handle to the console                                            */
-    bool started;                           /* true if the child process started                                */
-    Buffer_t commandLineBuffer;                 /* command line buffer                                              */
-
-}s_TestCaseContext_t,* TestCaseContext_t;
+typedef struct s_TestCaseContext {
+  char *name;                   /* the test case name                                                                   */
+  int timeoutValue;             /* the timeout value                                                                    */
+  bool isOutputCheckingEnabled; /* if true, output checking is enable                                   */
+  bool isPostOutputCheckingEnabled;     /* if true, the post output checking mode is enable             */
+  Buffer_t inputBuffer;         /* buffer that contains child input                                             */
+  Buffer_t outputBuffer;        /* the child output buffer                                                              */
+  Buffer_t expectedOutputBuffer;        /* buffer that contains child expected output                   */
+  int expectedExitCode;         /* the child expected exit code                                                 */
+  int threadExitCode;           /* the thread exit code                                                                                         */
+  int exitCode;                 /* the child process exit code                                                                          */
+  bool runThread;               /* false if the thread of the test case must terminate                          */
+  HANDLE hThread;               /* the handle of the thread                                                                                     */
+  HANDLE hOutputRead;           /* handle to the read pipe                                                                                      */
+  HANDLE hInputWrite;           /* handle to the write pipe                                                                                     */
+  HANDLE hChildStdInRead;       /* handle to the pipe used to read the child std input                          */
+  HANDLE hChildStdOutWrite;     /* handle to the pipe used to write to the chil std output                      */
+  HANDLE hChildStderr;          /* handle to the pipe used to read the child std error                          */
+  PROCESS_INFORMATION pi;       /* this structure contains child process informations                           */
+  HANDLE hChildStdoutReadTmp;   /* tempory handle                                                                                                       */
+  HANDLE hChildStdinWriteTmp;   /* tempory handle                                                                                                       */
+  bool createConsole;           /* true if we can create a console for the child process            */
+  bool exitCodeCheckingEnabled; /* true if we want to check the child exit code                     */
+  HANDLE hConsole;              /* handle to the console                                            */
+  bool started;                 /* true if the child process started                                */
+  Buffer_t commandLineBuffer;   /* command line buffer                                              */
+
+} s_TestCaseContext_t, *TestCaseContext_t;
 
 /* Output checking is disabled by default*/
 #define DEFAULT_OUTPUT_CHECKING_MODE           false
@@ -46,8 +45,8 @@ typedef struct s_TestCaseContext
 #define DEFAULT_POST_OUTPUT_CHECKING_MODE      false
 
 /* The default timeout value is 5 seconds*/
- #define DEFAULT_TIMEOUT_VALUE                         ((int)120000)
+#define DEFAULT_TIMEOUT_VALUE                          ((int)120000)
+
 /* Invalid exit code value (default value)*/
 #define INVALID_EXIT_CODE                                      ((int)0xFFFFFF)
 
@@ -73,7 +72,7 @@ void TestCaseContext_clear(TestCaseContext_t context);
 /* 
  * Set the timeout of the test case context.
  */
-void TestCaseContext_setTimeout(TestCaseContext_t context,int timeout);
+void TestCaseContext_setTimeout(TestCaseContext_t context, int timeout);
 
 /*
  * Enable the output checking of the test case context.
@@ -88,7 +87,8 @@ void TestCaseContext_disableOutputChecking(TestCaseContext_t context);
 /*
  * Enable the post output checking of the test case context.
  */
-void TestCaseContext_enable_post_output_checking(TestCaseContext_t context);
+void TestCaseContext_enable_post_output_checking(TestCaseContext_t
+                                                 context);
 
 /*
  * Disable the post output checking of the test case context.
@@ -98,7 +98,8 @@ void TestCaseContext_disablePostOutputChecking(TestCaseContext_t context);
 /*
  * Set the expected exit code of the test case context.
  */
-void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,int expected_code);
+void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,
+                                         int expected_code);
 
 /*
  * Return true if the output checking mode is enabled for this
@@ -110,18 +111,20 @@ bool TestCaseContext_isOutputCheckingEnabled(TestCaseContext_t context);
  * Append a child output to check in the 
  * test case context.
  */
-void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,char* expected_output);
+void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,
+                                          char *expected_output);
 
 /*
  * Append a child output to check in the 
  * test case context.
  */
-void TestCaseContext_appendChildInput(TestCaseContext_t context,char* input);
+void TestCaseContext_appendChildInput(TestCaseContext_t context,
+                                      char *input);
 
 /*
  * Set the name of the test case name.
  */
-void TestCaseContext_setName(TestCaseContext_t context,char* name);
+void TestCaseContext_setName(TestCaseContext_t context, char *name);
 
 void TestCaseContext_createConsole(TestCaseContext_t context);
 
@@ -132,9 +135,10 @@ void TestCaseContext_enableExitCodeChecking(TestCaseContext_t context);
 void TestCaseContext_disableExitCodeChecking(TestCaseContext_t context);
 
 
-void TestCaseContext_setCommandLine(TestCaseContext_t context,char* cmdLine);
+void TestCaseContext_setCommandLine(TestCaseContext_t context,
+                                    char *cmdLine);
+
 
 
 
-#endif /* #ifndef __TestCaseContext_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __TestCaseContext_H__ */
index 17871d7..ee61b01 100644 (file)
@@ -8,18 +8,17 @@
  * Declaration of the s_TestRunner structure, which represents
  * a test runner used to run suites of tests.
  */
-typedef struct s_TestRunner
-{
-       Buffer_t buffer;                                        /* a single buffer                                              */
-       TestSuite_t testSuite;                  /* the test suite to run                                */
-               
-}s_TestRunner_t,*TestRunner_t;
+typedef struct s_TestRunner {
+  Buffer_t buffer;              /* a single buffer                                              */
+  TestSuite_t testSuite;        /* the test suite to run                                */
+
+} s_TestRunner_t, *TestRunner_t;
 
 
 /* 
  * s_TestRunner structure connected functions.
  */
+
 /* 
  * Create an new s_TestRunner struct and 
  * returns a pointer to self.
@@ -29,7 +28,7 @@ TestRunner_t TestRunner_new(void);
 /* 
  * Initialize the s_TestRunner struct.
  */
-errno_t TestRunner_initialize(TestRunner_t runner,int argc,char *argv[]);
+errno_t TestRunner_initialize(TestRunner_t runner, int argc, char *argv[]);
 
 /* 
  * Launch the test runner.
@@ -47,4 +46,4 @@ void TestRunner_free(TestRunner_t runner);
 
 
 
-#endif /* #ifndef __TestRunner_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __TestRunner_H__ */
index c1cf571..25a7d8e 100644 (file)
@@ -8,18 +8,17 @@
  * Declaration of the s_TestSuite, which represents
  * a suite of tests.
  */
-typedef struct s_TestSuite
-{
-       TestCaseContext_t test_case_context;    /* the context of the current test case */
-       Stream_t stream;                                                /* stdin or file stream                                 */
-       size_t testCaseCount;                                   /* test case count                                              */
-       size_t successCount;                                    /* test case success count                              */
-       size_t failureCount;                                    /* test case failure count                              */
-       #ifdef __VERBOSE
-       char currentTime[30];                                   /* the current time                                             */
-       #endif /* #ifdef __VERBOSE */
-    ThreadDynarray_t threads;
-}s_TestSuite_t,* TestSuite_t;
+typedef struct s_TestSuite {
+  TestCaseContext_t test_case_context;  /* the context of the current test case */
+  Stream_t stream;              /* stdin or file stream                                 */
+  size_t testCaseCount;         /* test case count                                              */
+  size_t successCount;          /* test case success count                              */
+  size_t failureCount;          /* test case failure count                              */
+#ifdef __VERBOSE
+  char currentTime[30];         /* the current time                                             */
+#endif                          /* #ifdef __VERBOSE */
+  ThreadDynarray_t threads;
+} s_TestSuite_t, *TestSuite_t;
 
 /* 
  * s_TestSuite connected functions.
@@ -33,12 +32,12 @@ TestSuite_t TestSuite_new(void);
 /* 
  * Free the s_TestSuite pointed to by ptr.
  */
- void TestSuite_free(TestSuite_t ptr);
+void TestSuite_free(TestSuite_t ptr);
+
  /*
- * Initialize the s_TestSuite structure.
- */
-errno_t TestSuite_initialize(TestSuite_t ptr,int argc,char *argv[]);
 * Initialize the s_TestSuite structure.
 */
+errno_t TestSuite_initialize(TestSuite_t ptr, int argc, char *argv[]);
 
 
 /*
@@ -46,7 +45,7 @@ errno_t TestSuite_initialize(TestSuite_t ptr,int argc,char *argv[]);
  * the address of the buffer containing the  text into  
  * s_TestSuite.current_line. 
  */
-ssize_t TestSuite_getline(TestSuite_t ptr,size_t* len);
+ssize_t TestSuite_getline(TestSuite_t ptr, size_t * len);
 
 /* 
  * Launch the test suite. 
@@ -112,11 +111,11 @@ errno_t TestSuite_checkChildOutput(TestCaseContext_t context);
 /*
  * Print message
  */
-void TestSuite_print(const charstr);
+void TestSuite_print(const char *str);
 
 /*
  * Check the child process exit code.
- */ 
+ */
 errno_t TestSuite_checkChildExitCode(TestCaseContext_t context);
 
 errno_t TestSuite_unset(TestSuite_t testSuite);
@@ -129,16 +128,16 @@ void TestSuite_enableExitCodeChecking(TestSuite_t testSuite);
 
 void TestSuite_disableExitCodeChecking(TestSuite_t testSuite);
 
-unsigned long WINAPI TestSuite_runSyncTestCase(voidparam);
+unsigned long WINAPI TestSuite_runSyncTestCase(void *param);
 
-errno_t  TestSuite_runAsyncTestCase(TestSuite_t testSuite);
+errno_t TestSuite_runAsyncTestCase(TestSuite_t testSuite);
 
 /* 
  * Terminate the test suite.
  */
 void TestSuite_terminate(TestSuite_t testSuite);
 
-unsigned long WINAPI TestSuite_asyncReadChildOutput(voidparam);
+unsigned long WINAPI TestSuite_asyncReadChildOutput(void *param);
 
 bool TestSuite_iSPostOutputCheckingEnabled(TestCaseContext_t context);
 
@@ -154,8 +153,8 @@ void TestSuite_setCommandLine(TestSuite_t testSuite);
  * Update the current time. 
  */
 void TestSuite_update_current_time(TestSuite_t ptr);
-#endif /* #ifdef __VERBOSE */
+#endif                          /* #ifdef __VERBOSE */
 
 
 
-#endif /* #ifndef __TestSuite_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __TestSuite_H__ */
index 96eabc8..e7bb219 100644 (file)
@@ -1,62 +1,63 @@
 #ifndef __THREAD_DYNARRAY_H__
 #define __THREAD_DYNARRAY_H__
 
-#include <stddef.h> 
-#include <stdlib.h> 
-#include <string.h>    
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
 #include <windows.h>
 #include <TTestCaseContext.h>
 
 
-typedef struct s_ThreadEntry
-{
-       HANDLE hThread;
-    DWORD threadId;
-       TestCaseContext_t context;
-}s_ThreadEntry_t,* ThreadEntry_t;      
+typedef struct s_ThreadEntry {
+  HANDLE hThread;
+  DWORD threadId;
+  TestCaseContext_t context;
+} s_ThreadEntry_t, *ThreadEntry_t;
 /*
  * s_ThreadDynarray struct declaration.
  */
-typedef struct s_ThreadDynarray
-{
-       /* threads */
-       ThreadEntry_t threads;
-       /* thread count */
-       unsigned long count;
-       /* Storage capacity */
-       unsigned long capacity;
-       CRITICAL_SECTION cs;
-       bool is_locked;
 
-}s_ThreadDynarray_t,* ThreadDynarray_t;
+typedef struct s_ThreadDynarray {
+  /* threads */
+  ThreadEntry_t threads;
+  /* thread count */
+  unsigned long count;
+  /* Storage capacity */
+  unsigned long capacity;
+  CRITICAL_SECTION cs;
+  bool is_locked;
+
+} s_ThreadDynarray_t, *ThreadDynarray_t;
 
 /*
  * Constructs a ThreadDynarray with the specified capacity.
  */
- ThreadDynarray_t ThreadDynarray_new(unsigned long capacity);
+ThreadDynarray_t ThreadDynarray_new(unsigned long capacity);
 
 /* 
  * Destroy the ThreadDynarray 
  */
- void ThreadDynarray_destroy(ThreadDynarray_t ptr);
+void ThreadDynarray_destroy(ThreadDynarray_t ptr);
 
 /*
  * Returns an const pointer THREAD_entry pointed to by index.
  */
- ThreadEntry_t const ThreadDynarray_at(ThreadDynarray_t ptr, unsigned long index);   
+ThreadEntry_t const ThreadDynarray_at(ThreadDynarray_t ptr,
+                                      unsigned long index);
 
 /*
  * Fill the content of the entry addressed by the __entry with the content
  * of the entry pointed to by index.
  */
- void ThreadDynarray_get(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t const __entry);
+void ThreadDynarray_get(ThreadDynarray_t ptr, unsigned long index,
+                        ThreadEntry_t const __entry);
 
 /* 
  * Fill the content of the entry pointed to by index with the content of
  * the entry addressed by __entry.
  */
- void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t const __entry);
+void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index,
+                        ThreadEntry_t const __entry);
 
 /*
  * Returns a const pointer to the first entry.
@@ -66,142 +67,155 @@ ThreadEntry_t const ThreadDynarray_getFront(ThreadDynarray_t ptr);
 /*
  * Returns a const pointer to the last entry.
  */
- ThreadEntry_t const ThreadDynarray_getBack(ThreadDynarray_t ptr);
+ThreadEntry_t const ThreadDynarray_getBack(ThreadDynarray_t ptr);
 
 /*
  * Inserts a copy of __entry at the front
  */
- void ThreadDynarray_pushFront(ThreadDynarray_t ptr, ThreadEntry_t const __entry);
+void ThreadDynarray_pushFront(ThreadDynarray_t ptr,
+                              ThreadEntry_t const __entry);
 
 /*
  * Appends a copy of __entry to the end.
  */
- void ThreadDynarray_pushBack(ThreadDynarray_t ptr, ThreadEntry_t const __entry);
+void ThreadDynarray_pushBack(ThreadDynarray_t ptr,
+                             ThreadEntry_t const __entry);
 
 /* 
  * Inserts __entry at the position pointed to by index.
  */
- void ThreadDynarray_insert(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t const __entry);
+void ThreadDynarray_insert(ThreadDynarray_t ptr, unsigned long index,
+                           ThreadEntry_t const __entry);
 
 /*
  * Deletes the entry pointed to by index. If __entry is not NULL the
  * fuction saves the entry threads at this address before.
  */
- void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,ThreadEntry_t const __entry);
+void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,
+                          ThreadEntry_t const __entry);
 
 /*
  * Find the first entry with the same content of the entry addressed by
  * __entry.The function returns the index of the founded entry, -1 if
  * no entry is founded.
  */
- long ThreadDynarray_getIndex(ThreadDynarray_t ptr, ThreadEntry_t const __entry);
+long ThreadDynarray_getIndex(ThreadDynarray_t ptr,
+                             ThreadEntry_t const __entry);
 
 /* 
  * Returns true if the entry exist.
  */
- bool ThreadDynarray_exist(ThreadDynarray_t ptr, ThreadEntry_t const __entry);
+bool ThreadDynarray_exist(ThreadDynarray_t ptr,
+                          ThreadEntry_t const __entry);
 
 /* Deletes the first entry with the same content of the entry addressed
  * by __entry.The function returns true if the entry is deleted, false
  * if no entry is founded.
  */
- bool ThreadDynarray_remove(ThreadDynarray_t ptr, ThreadEntry_t const __entry);
+bool ThreadDynarray_remove(ThreadDynarray_t ptr,
+                           ThreadEntry_t const __entry);
 
 /*
  * Erase all elements of the self.
  */
- void ThreadDynarray_clear(ThreadDynarray_t ptr);
+void ThreadDynarray_clear(ThreadDynarray_t ptr);
 
 /*
  * Resets entry count to zero.
  */
- void ThreadDynarray_reset(ThreadDynarray_t ptr);
+void ThreadDynarray_reset(ThreadDynarray_t ptr);
 
 /*
  * Moves count elements from src index to dst index.
  */
- void ThreadDynarray_move(ThreadDynarray_t ptr, const unsigned long dst,const unsigned long src,unsigned long count);
+void ThreadDynarray_move(ThreadDynarray_t ptr, const unsigned long dst,
+                         const unsigned long src, unsigned long count);
 
 /* Compare the content of the entry pointed to by index with the content of
  * the entry addressed by __entry. The function returns true if the contents
  * are same.
  */
- bool ThreadDynarray_compare(ThreadDynarray_t ptr, const unsigned long index,ThreadEntry_t const __entry);
+bool ThreadDynarray_compare(ThreadDynarray_t ptr,
+                            const unsigned long index,
+                            ThreadEntry_t const __entry);
 
 /*
  * Returns a reference to a new ThreadDynarray new set is a clone of the self.
  */
- ThreadDynarray_t ThreadDynarray_clone(ThreadDynarray_t ptr);
+ThreadDynarray_t ThreadDynarray_clone(ThreadDynarray_t ptr);
 
 /*
  * Extends the capacity when the container is full.
  */
- void ThreadDynarray_resize(ThreadDynarray_t ptr);
+void ThreadDynarray_resize(ThreadDynarray_t ptr);
 
 /*
  * Returns the number of elements.
  */
- unsigned long ThreadDynarray_getCount(ThreadDynarray_t ptr);
+unsigned long ThreadDynarray_getCount(ThreadDynarray_t ptr);
 
 /*
  * Returns the current storage capacity of the ThreadDynarray. This is guaranteed
  * to be at least as large as count().
  */
- unsigned long ThreadDynarray_getCapacity(ThreadDynarray_t ptr); 
+unsigned long ThreadDynarray_getCapacity(ThreadDynarray_t ptr);
 
 /*
  * Returns upper bound of self (max index).
  */
- unsigned long ThreadDynarray_getUpperBound(ThreadDynarray_t ptr);
+unsigned long ThreadDynarray_getUpperBound(ThreadDynarray_t ptr);
 
 /*
  * Returns lower bound of self (always zero).
  */
- unsigned long ThreadDynarray_getLowerBound(ThreadDynarray_t ptr); 
+unsigned long ThreadDynarray_getLowerBound(ThreadDynarray_t ptr);
 
 /*
  * Returns the size of the elements.
  */
- unsigned long ThreadDynarray_getElementSize(ThreadDynarray_t ptr);
+unsigned long ThreadDynarray_getElementSize(ThreadDynarray_t ptr);
 
 /*
  * Returns true if the size of self is zero.
  */
- bool ThreadDynarray_isEmpty(ThreadDynarray_t ptr);
+bool ThreadDynarray_isEmpty(ThreadDynarray_t ptr);
 
 /*
  * Returns true if capacity available.
  */
- bool ThreadDynarray(ThreadDynarray_t ptr);
+bool ThreadDynarray(ThreadDynarray_t ptr);
 
 /*
  * Returns true if the container is full.
  */
- bool ThreadDynarray_is_full(ThreadDynarray_t ptr); 
+bool ThreadDynarray_is_full(ThreadDynarray_t ptr);
 
  /*
- * Returns true if capacity available.
- */
 * Returns true if capacity available.
 */
 bool ThreadDynarray_getCapacityAvailable(ThreadDynarray_t ptr);
 
 /* 
  * Assignement.
  */
-ThreadDynarray_t ThreadDynarray_assign(ThreadDynarray_t src,ThreadDynarray_t dst);
+ThreadDynarray_t ThreadDynarray_assign(ThreadDynarray_t src,
+                                       ThreadDynarray_t dst);
 
 /* 
  * Returns true if the dynamic arrays are equal.
- */ 
- bool ThreadDynarray_areEquals(ThreadDynarray_t ptr1,ThreadDynarray_t ptr2);
+ */
+bool ThreadDynarray_areEquals(ThreadDynarray_t ptr1,
+                              ThreadDynarray_t ptr2);
 
 /* 
  * Returns true if the dynamic arrays are not equal.
- */ 
-bool ThreadDynarray_areNotEquals(ThreadDynarray_t ptr1,ThreadDynarray_t ptr2);
+ */
+bool ThreadDynarray_areNotEquals(ThreadDynarray_t ptr1,
+                                 ThreadDynarray_t ptr2);
+
 void ThreadDynarray_lock(ThreadDynarray_t ptr);
 
 void ThreadDynarray_unlock(ThreadDynarray_t ptr);
 
 
-#endif /* #ifndef __THREAD_DYNARRAY_H__ */
+#endif                          /* #ifndef __THREAD_DYNARRAY_H__ */
index 3a179e0..b82bcbd 100644 (file)
@@ -6,7 +6,7 @@
 #include <stdio.h>
 
 
-void __time(chart);
+void __time(char *t);
 
 
-#endif /* #ifndef __TIME_H__ */
\ No newline at end of file
+#endif                          /* #ifndef __TIME_H__ */
index d7a6cce..787b3f9 100644 (file)
@@ -9,74 +9,70 @@
  */
 Buffer_t Buffer_new(void)
 {
-       Buffer_t buffer = (Buffer_t)calloc(1,sizeof(s_Buffer_t));
-       
-       if(NULL == buffer)
-       {
-               setErrno(E_BUFFER_ALLOCATION_FAILED);
-               return NULL;
-       }
-       
-       buffer->data = (char*)calloc(1,DEFAULT_Buffer_CAPACITY);
-       
-       
-       if(NULL == buffer->data)
-       {
-               Buffer_free(buffer);
-               setErrno(E_BUFFER_DATA_ALLOCATION_FAILED);
-               return NULL;
-       }
-       
-       buffer->capacity = DEFAULT_Buffer_CAPACITY;
-       Buffer_clear(buffer);
-       return buffer;
+  Buffer_t buffer = (Buffer_t) calloc(1, sizeof(s_Buffer_t));
+
+  if (NULL == buffer) {
+    setErrno(E_BUFFER_ALLOCATION_FAILED);
+    return NULL;
+  }
+
+  buffer->data = (char *) calloc(1, DEFAULT_Buffer_CAPACITY);
+
+
+  if (NULL == buffer->data) {
+    Buffer_free(buffer);
+    setErrno(E_BUFFER_DATA_ALLOCATION_FAILED);
+    return NULL;
+  }
+
+  buffer->capacity = DEFAULT_Buffer_CAPACITY;
+  Buffer_clear(buffer);
+  return buffer;
 }
 
 /* Clears the buffer (this function don't destroy it,
  * see Buffer_free function.). 
- */ 
+ */
 void Buffer_clear(Buffer_t buffer)
 {
-        /* must be a valid buffer. */
-       ASSERT_VALID_Buffer(buffer);
-       
-       buffer->size = 0;
-       buffer->data[0]='\n';
-       buffer->data[1]='\0';
+  /* must be a valid buffer. */
+  ASSERT_VALID_Buffer(buffer);
+
+  buffer->size = 0;
+  buffer->data[0] = '\n';
+  buffer->data[1] = '\0';
 }
 
 /* Appends a string in the buffer. If successful, 
  * the function returns true. Otherwise the function
  * returns false.
  */
-bool Buffer_append(Buffer_t buffer,char* str)
+bool Buffer_append(Buffer_t buffer, char *str)
 {
-       size_t len= strlen(str);
-       size_t capacity_needed = buffer->size + len + 1;
-       size_t capacity_available = buffer->capacity - buffer->size;
-       
-       /* must be a valid buffer. */
-       ASSERT_VALID_Buffer(buffer);
-       /* must be a valid string. */
-       ASSERT_NOT_NULL(str);
-       
-       if(capacity_available < capacity_needed) 
-       {
-               buffer->data = (char*)realloc(buffer->data, capacity_needed);
-               
-               if(NULL == buffer->data)
-               {
-                       setErrno(E_Buffer_DATA_REALLOCATION_FAILED);
-                       return false;           
-               }
-               
-               buffer->capacity = capacity_needed;
-       }
-       
-       strcpy(buffer->data + buffer->size,str);
-       buffer->size += len;/*  + 1*/ ;  
-       
-       return true;
+  size_t len = strlen(str);
+  size_t capacity_needed = buffer->size + len + 1;
+  size_t capacity_available = buffer->capacity - buffer->size;
+
+  /* must be a valid buffer. */
+  ASSERT_VALID_Buffer(buffer);
+  /* must be a valid string. */
+  ASSERT_NOT_NULL(str);
+
+  if (capacity_available < capacity_needed) {
+    buffer->data = (char *) realloc(buffer->data, capacity_needed);
+
+    if (NULL == buffer->data) {
+      setErrno(E_Buffer_DATA_REALLOCATION_FAILED);
+      return false;
+    }
+
+    buffer->capacity = capacity_needed;
+  }
+
+  strcpy(buffer->data + buffer->size, str);
+  buffer->size += len; /*  + 1 */ ;
+
+  return true;
 }
 
 /* 
@@ -84,16 +80,16 @@ bool Buffer_append(Buffer_t buffer,char* str)
  */
 void Buffer_chomp(Buffer_t buffer)
 {
-       /* must be a valid buffer. */
-       ASSERT_VALID_Buffer(buffer);
-       
-       while ((buffer->data[buffer->size-1] == '\n') || (buffer->data[buffer->size-1] == '\r'))
-       {
-               buffer->data[buffer->size-1] = '\0';
-               
-               if(buffer->size)
-                       (buffer->size)--;
-       }
+  /* must be a valid buffer. */
+  ASSERT_VALID_Buffer(buffer);
+
+  while ((buffer->data[buffer->size - 1] == '\n')
+         || (buffer->data[buffer->size - 1] == '\r')) {
+    buffer->data[buffer->size - 1] = '\0';
+
+    if (buffer->size)
+      (buffer->size)--;
+  }
 }
 
 /* 
@@ -101,23 +97,23 @@ void Buffer_chomp(Buffer_t buffer)
  */
 void Buffer_free(Buffer_t buffer)
 {
-       if(NULL == buffer)
-               return;
-               
-       if(NULL != buffer->data)
-               free(buffer->data);
-       
-       if(NULL != buffer)
-               free(buffer);
+  if (NULL == buffer)
+    return;
+
+  if (NULL != buffer->data)
+    free(buffer->data);
+
+  if (NULL != buffer)
+    free(buffer);
 }
 
 /* 
  * This function returns true is the buffer is empty.
  * Otherwrise the function returns false.
  */
-bool Buffer_empty(Buffer_t buffer) 
+bool Buffer_empty(Buffer_t buffer)
 {
-        /* must be a valid buffer. */
-        ASSERT_VALID_Buffer(buffer);
-        return (buffer->size) == 0;
+  /* must be a valid buffer. */
+  ASSERT_VALID_Buffer(buffer);
+  return (buffer->size) == 0;
 }
index 6fc7c01..59b51fc 100644 (file)
@@ -8,42 +8,39 @@ static is_last_errno = false;
 
 void initializeErrno(void)
 {
-       if(!errno_cs_initialized)
-       {
-               memset(&errno_cs,0,sizeof(CRITICAL_SECTION)) ;
-               InitializeCriticalSection(&errno_cs);
-               errno_cs_initialized = true;
-       }
+  if (!errno_cs_initialized) {
+    memset(&errno_cs, 0, sizeof(CRITICAL_SECTION));
+    InitializeCriticalSection(&errno_cs);
+    errno_cs_initialized = true;
+  }
 }
 
 void terminateErrno(void)
 {
-       if(errno_cs_initialized)
-       {
-               DeleteCriticalSection(&errno_cs);
-       }
+  if (errno_cs_initialized) {
+    DeleteCriticalSection(&errno_cs);
+  }
 }
 
 
 void setErrno(errno_t e)
 {
-       EnterCriticalSection(&errno_cs);
-
-    if((E_SUCCESS != e) && !is_last_errno)
-    {
-           __errno = e;
-        is_last_errno = true;
-    }
-        
-   LeaveCriticalSection(&errno_cs);
+  EnterCriticalSection(&errno_cs);
+
+  if ((E_SUCCESS != e) && !is_last_errno) {
+    __errno = e;
+    is_last_errno = true;
+  }
+
+  LeaveCriticalSection(&errno_cs);
 }
 
 errno_t getErrno(void)
 {
-       errno_t e;
-       EnterCriticalSection(&errno_cs);
-       e = __errno;
-       LeaveCriticalSection(&errno_cs);
-       
-       return e;
-}
\ No newline at end of file
+  errno_t e;
+  EnterCriticalSection(&errno_cs);
+  e = __errno;
+  LeaveCriticalSection(&errno_cs);
+
+  return e;
+}
index a395c03..d2517ff 100644 (file)
@@ -1,25 +1,24 @@
 #include <TStream.h>
 
-extern const charTOKENS = "$<>#!p&";
+extern const char *TOKENS = "$<>#!p&";
 
 CRITICAL_SECTION cs;
 
-const char * __metacommandlist[ ] =
-{
-       "set timeout ",
-       "enable output checking",
-       "disable output checking",
-       "enable post output checking",
-       "disable post output checking",
-       "expect exit code ",
-       "export ",
-       "unset ",
-    "create console",
-    "create no console",
-    "enable exit code checking",
-    "disable exit code checking",
-    "command line ",
-       NULL
+const char *__metacommandlist[] = {
+  "set timeout ",
+  "enable output checking",
+  "disable output checking",
+  "enable post output checking",
+  "disable post output checking",
+  "expect exit code ",
+  "export ",
+  "unset ",
+  "create console",
+  "create no console",
+  "enable exit code checking",
+  "disable exit code checking",
+  "command line ",
+  NULL
 };
 
 /*
@@ -29,21 +28,20 @@ const char * __metacommandlist[ ] =
 
 Stream_t Stream_new(void)
 {
-       Stream_t ptr = (Stream_t)calloc(1,sizeof(s_Stream_t));
-       
-       if(NULL == ptr)
-       {
-               setErrno(E_STREAM_ALLOCATION_FAILED);
-               Stream_free(ptr);
-       }
-
-    memset(&cs,0,sizeof(CRITICAL_SECTION)) ;
-       InitializeCriticalSection(&cs);
-       
-       ptr->line = NULL;
-       ptr->line_number = 0;
-
-    return ptr;
+  Stream_t ptr = (Stream_t) calloc(1, sizeof(s_Stream_t));
+
+  if (NULL == ptr) {
+    setErrno(E_STREAM_ALLOCATION_FAILED);
+    Stream_free(ptr);
+  }
+
+  memset(&cs, 0, sizeof(CRITICAL_SECTION));
+  InitializeCriticalSection(&cs);
+
+  ptr->line = NULL;
+  ptr->line_number = 0;
+
+  return ptr;
 }
 
 /*
@@ -51,18 +49,17 @@ Stream_t Stream_new(void)
  */
 bool Stream_lineIsBlank(Stream_t stream)
 {
-    size_t i = 0;
-       char* p = (char*)stream->line;
-    
-       while(p[i] != '\n')
-       {
-               if(!Stream_isBlankChar(p[i]))
-                       return false;
-        i++;
-                                       
-       }
-       
-       return true;
+  size_t i = 0;
+  char *p = (char *) stream->line;
+
+  while (p[i] != '\n') {
+    if (!Stream_isBlankChar(p[i]))
+      return false;
+    i++;
+
+  }
+
+  return true;
 }
 
 /* 
@@ -70,40 +67,39 @@ bool Stream_lineIsBlank(Stream_t stream)
  */
 bool Stream_isBlankChar(char ch)
 {
-       return ((ch ==' ') || ch == ('\t'));
+  return ((ch == ' ') || ch == ('\t'));
 }
 
 /*
  * Return E_SUCCESS if the file is valid. 
  * Otherwise the fuction returns E_INVALID_FILE.
  */
-errno_t Stream_isValidFile(const charfile_name)
+errno_t Stream_isValidFile(const char *file_name)
 {
-       WIN32_FIND_DATA wfd ={0};
-       HANDLE hFile = FindFirstFile(file_name,&wfd);
-       
-       if(INVALID_HANDLE_VALUE == hFile)
-               return E_FILE_NOT_FOUND;
-       
-       FindClose(hFile);
-       return E_SUCCESS;
+  WIN32_FIND_DATA wfd = { 0 };
+  HANDLE hFile = FindFirstFile(file_name, &wfd);
+
+  if (INVALID_HANDLE_VALUE == hFile)
+    return E_FILE_NOT_FOUND;
+
+  FindClose(hFile);
+  return E_SUCCESS;
 }
 
 /* 
  * Return E_SUCCESS is the open file operation succeeded.
  * Otherwise the functions returns E_OPEN_FILE_FAILED.
  */
-errno_t Stream_openFile(Stream_t ptr,const char* file_name)
+errno_t Stream_openFile(Stream_t ptr, const char *file_name)
 {
-       ptr->file = fopen(file_name,"r");
-       
-       if(NULL == ptr->file)
-       {
-               setErrno(E_OPEN_FILE_FAILED);
-               return getErrno();
-       }
-       
-       return E_SUCCESS;       
+  ptr->file = fopen(file_name, "r");
+
+  if (NULL == ptr->file) {
+    setErrno(E_OPEN_FILE_FAILED);
+    return getErrno();
+  }
+
+  return E_SUCCESS;
 }
 
 /*
@@ -113,124 +109,112 @@ errno_t Stream_openFile(Stream_t ptr,const char* file_name)
  */
 ssize_t Stream_getLine(Stream_t stream)
 {
-               size_t capacity_available;              /* capacity available in the buffer                             */
-               char* pos;                                      /* read operation position                                                      */
-               ssize_t size;                                   /* the size of the text line (minus the 0 terminal      */
-               static size_t len = 0;
-               register int ch;                                        /* the current character                                                        */      
-               FILE* file = stream->file;
-               
-               if(NULL == file)
-               {
-                       setErrno(E_INVALID_FILE_Stream);
-                       return -1;
-               }
-
-               if(NULL == stream->line)
-               {
-                       len = DEFAULT_ALLOC_SIZE;
-                       stream->line = (char*)calloc(1,len);
-                       
-                       if (NULL == stream->line)
-                       {
-                               setErrno(E_STREAM_LINE_ALLOCATION_FAILED);
-                               return -1;
-                       }
-               }
-        else
-        {
-            memset(stream->line,0,len);
-        }
-
-               capacity_available = len ;
-               pos = stream->line;
-               
-               while(true)
-               {
-                       ch = getc(file);
-                       
-                       /* un byte for the next char and one byte for the zero terminal. */
-                       if (capacity_available < 2)
-                       {
-                               if (len > DEFAULT_ALLOC_SIZE)
-                                       len = len << 1;
-                               else
-                                       len += DEFAULT_ALLOC_SIZE;
-               
-                               capacity_available =stream->line + len - pos;
-                               stream->line = realloc (stream->line,len);
-                               
-                               if (NULL ==stream->line)
-                               {
-                                       setErrno(E_STREAM_LINE_REALLOCATION_FAILED);
-                                       return -1;
-                               }
-                               
-                               pos = stream->line + len - capacity_available ;
-                       }
-                       
-                       if(ferror(file))
-                       { 
-                               /* file error exit on error*/
-                               setErrno(E_STREAM_ERROR);
-                               return -1;
-                       }
-                       
-                       if((EOF == ch))
-                       {
-                /* Empty file */
-                if(!strlen(stream->line) && !stream->line_number)
-                {
-                    setErrno(E_STREAM_EMPTY);
-                                       return -1;
-                }
-                /* end of file */
-                else if(!strlen(stream->line) && stream->line_number)
-                {
-                    return -1;
-                }
-
-                break;
-                       }
-                       
-                       *pos++ = ch;
-                       capacity_available--;
-               
-                       /* we have a line, exit loop */
-                       if (ch == '\n')
-                               break;
-               }
-
-               /* append the zero terminal */
-
-               *pos = '\0';
-               size = pos - stream->line;
-               
-               stream->line_number++;
-               
-               /* size of texte line without zero terminal */
-               return size;
+  size_t capacity_available;    /* capacity available in the buffer                             */
+  char *pos;                    /* read operation position                                                      */
+  ssize_t size;                 /* the size of the text line (minus the 0 terminal      */
+  static size_t len = 0;
+  register int ch;              /* the current character                                                        */
+  FILE *file = stream->file;
+
+  if (NULL == file) {
+    setErrno(E_INVALID_FILE_Stream);
+    return -1;
+  }
+
+  if (NULL == stream->line) {
+    len = DEFAULT_ALLOC_SIZE;
+    stream->line = (char *) calloc(1, len);
+
+    if (NULL == stream->line) {
+      setErrno(E_STREAM_LINE_ALLOCATION_FAILED);
+      return -1;
+    }
+  } else {
+    memset(stream->line, 0, len);
+  }
+
+  capacity_available = len;
+  pos = stream->line;
+
+  while (true) {
+    ch = getc(file);
+
+    /* un byte for the next char and one byte for the zero terminal. */
+    if (capacity_available < 2) {
+      if (len > DEFAULT_ALLOC_SIZE)
+        len = len << 1;
+      else
+        len += DEFAULT_ALLOC_SIZE;
+
+      capacity_available = stream->line + len - pos;
+      stream->line = realloc(stream->line, len);
+
+      if (NULL == stream->line) {
+        setErrno(E_STREAM_LINE_REALLOCATION_FAILED);
+        return -1;
+      }
+
+      pos = stream->line + len - capacity_available;
+    }
+
+    if (ferror(file)) {
+      /* file error exit on error */
+      setErrno(E_STREAM_ERROR);
+      return -1;
+    }
+
+    if ((EOF == ch)) {
+      /* Empty file */
+      if (!strlen(stream->line) && !stream->line_number) {
+        setErrno(E_STREAM_EMPTY);
+        return -1;
+      }
+      /* end of file */
+      else if (!strlen(stream->line) && stream->line_number) {
+        return -1;
+      }
+
+      break;
+    }
+
+    *pos++ = ch;
+    capacity_available--;
+
+    /* we have a line, exit loop */
+    if (ch == '\n')
+      break;
+  }
+
+  /* append the zero terminal */
+
+  *pos = '\0';
+  size = pos - stream->line;
+
+  stream->line_number++;
+
+  /* size of texte line without zero terminal */
+  return size;
 }
 
 
 /* 
  * Free a s_Stream.
  */
+
 void Stream_free(Stream_t ptr)
 {
-       if(NULL == ptr)
-               return;
-       
-       if((NULL !=ptr->file) && (stdin != ptr->file))
-               fclose(ptr->file);
-               
-       if(NULL != ptr->line)
-               free(ptr->line);
-
-    DeleteCriticalSection(&cs);
-               
-       free(ptr);
+  if (NULL == ptr)
+    return;
+
+  if ((NULL != ptr->file) && (stdin != ptr->file))
+    fclose(ptr->file);
+
+  if (NULL != ptr->line)
+    free(ptr->line);
+
+  DeleteCriticalSection(&cs);
+
+  free(ptr);
 }
 
 /*
@@ -239,7 +223,7 @@ void Stream_free(Stream_t ptr)
  */
 bool Stream_lineIsComment(Stream_t stream)
 {
-       return stream->line[0] == '#';
+  return stream->line[0] == '#';
 }
 
 /* Return true if the current line contains a invalide token.
@@ -247,14 +231,13 @@ bool Stream_lineIsComment(Stream_t stream)
  */
 bool Stream_lineContainsInvalidToken(Stream_t stream)
 {
-       if(strchr(TOKENS,stream->line[0]) == NULL)
-       {
-               Stream_printLine(stream,invalid_token_line_type);
-               setErrno(E_INVALID_TOKEN);
-               return true;
-       }
-       
-       return false;
+  if (strchr(TOKENS, stream->line[0]) == NULL) {
+    Stream_printLine(stream, invalid_token_line_type);
+    setErrno(E_INVALID_TOKEN);
+    return true;
+  }
+
+  return false;
 }
 
 /*
@@ -263,7 +246,7 @@ bool Stream_lineContainsInvalidToken(Stream_t stream)
  */
 bool Stream_lineIsMetacommand(Stream_t stream)
 {
-       return stream->line[0] == '!';
+  return stream->line[0] == '!';
 }
 
 /* Retun true if the text line contains a unknown meta command.
@@ -271,18 +254,19 @@ bool Stream_lineIsMetacommand(Stream_t stream)
  */
 bool Stream_lineIsUnknwnMetaCommand(Stream_t stream)
 {
-       size_t i = 0;
-       while(__metacommandlist[i])
-       {
-               if(!strncmp(__metacommandlist[i],stream->line + 2,strlen(__metacommandlist[i])))
-                       return false;
-        i++;
-       }
-       
-       Stream_printLine(stream,unknwn_meta_command_line_type);
-               
-       setErrno(E_UNKWN_META_COMMAND);
-       return true;
+  size_t i = 0;
+  while (__metacommandlist[i]) {
+    if (!strncmp
+        (__metacommandlist[i], stream->line + 2,
+         strlen(__metacommandlist[i])))
+      return false;
+    i++;
+  }
+
+  Stream_printLine(stream, unknwn_meta_command_line_type);
+
+  setErrno(E_UNKWN_META_COMMAND);
+  return true;
 }
 
 /*
@@ -291,65 +275,66 @@ bool Stream_lineIsUnknwnMetaCommand(Stream_t stream)
  */
 bool Stream_lineIsInvalidMetaCommand(Stream_t stream)
 {
-       if(!strncmp("set timeout ",stream->line + 2,strlen("set timeout ")))
-       {
-        return Stream_isInvalidTimeout(stream);
-       }
-    else if(!strncmp("command line ",stream->line + 2,strlen("command line ")))
-       {
-               Stream_printLine(stream,command_line_line_type);
-       }
-       else if(!strncmp("enable output checking",stream->line + 2,strlen("enable output checking")))
-       {
-               Stream_printLine(stream,enable_output_checking_line_type);
-       }
-       else if(!strncmp("disable output checking",stream->line + 2,strlen("disable output checking")))
-       {
-               Stream_printLine(stream,disable_output_checking_line_type);
-       }       
-       else if(!strncmp("enable post output checking",stream->line + 2,strlen("enable post output checking")))
-       {
-               Stream_printLine(stream,enable_post_output_checking_line_type); 
-       }       
-       else if(!strncmp("disable post output checking",stream->line + 2,strlen("disable post output checking")))
-       {
-               Stream_printLine(stream,disable_post_output_checking_line_type);
-       }       
-       else if(!strncmp("expect exit code ",stream->line + 2,strlen("expect exit code ")))
-       {
-               return Stream_isInvalidExpectedCode(stream);
-       }
-       else if(!strncmp("export ",stream->line + 2,strlen("export ")))
-       {
-               return Stream_isInvalidExport(stream);          
-       }       
-       else if(!strncmp("unset ",stream->line + 2,strlen("unset ")))
-       {
-               return Stream_isInvalidUnset(stream);           
-       }
-    else if(!strncmp("create console",stream->line + 2,strlen("create console")))
-       {
-               Stream_printLine(stream,create_console_line_type);
-       }
-       else if(!strncmp("create no console",stream->line + 2,strlen("create no console")))
-       {
-               Stream_printLine(stream,create_no_console_line_type);
-       }
-    else if(!strncmp("enable exit code checking",stream->line + 2,strlen("enable exit code checking")))
-       {
-               Stream_printLine(stream,enable_exit_code_checking_line_type);
-       }
-       else if(!strncmp("disable exit code checking",stream->line + 2,strlen("disaable exit code checking")))
-       {
-               Stream_printLine(stream,disable_exit_code_checking_line_type);
-       }
-       else
-       {
-               return true;
-       }
+  if (!strncmp("set timeout ", stream->line + 2, strlen("set timeout "))) {
+    return Stream_isInvalidTimeout(stream);
+  } else
+      if (!strncmp
+          ("command line ", stream->line + 2, strlen("command line "))) {
+    Stream_printLine(stream, command_line_line_type);
+  } else
+      if (!strncmp
+          ("enable output checking", stream->line + 2,
+           strlen("enable output checking"))) {
+    Stream_printLine(stream, enable_output_checking_line_type);
+  } else
+      if (!strncmp
+          ("disable output checking", stream->line + 2,
+           strlen("disable output checking"))) {
+    Stream_printLine(stream, disable_output_checking_line_type);
+  } else
+      if (!strncmp
+          ("enable post output checking", stream->line + 2,
+           strlen("enable post output checking"))) {
+    Stream_printLine(stream, enable_post_output_checking_line_type);
+  } else
+      if (!strncmp
+          ("disable post output checking", stream->line + 2,
+           strlen("disable post output checking"))) {
+    Stream_printLine(stream, disable_post_output_checking_line_type);
+  } else
+      if (!strncmp
+          ("expect exit code ", stream->line + 2,
+           strlen("expect exit code "))) {
+    return Stream_isInvalidExpectedCode(stream);
+  } else if (!strncmp("export ", stream->line + 2, strlen("export "))) {
+    return Stream_isInvalidExport(stream);
+  } else if (!strncmp("unset ", stream->line + 2, strlen("unset "))) {
+    return Stream_isInvalidUnset(stream);
+  } else
+      if (!strncmp
+          ("create console", stream->line + 2, strlen("create console"))) {
+    Stream_printLine(stream, create_console_line_type);
+  } else
+      if (!strncmp
+          ("create no console", stream->line + 2,
+           strlen("create no console"))) {
+    Stream_printLine(stream, create_no_console_line_type);
+  } else
+      if (!strncmp
+          ("enable exit code checking", stream->line + 2,
+           strlen("enable exit code checking"))) {
+    Stream_printLine(stream, enable_exit_code_checking_line_type);
+  } else
+      if (!strncmp
+          ("disable exit code checking", stream->line + 2,
+           strlen("disaable exit code checking"))) {
+    Stream_printLine(stream, disable_exit_code_checking_line_type);
+  } else {
+    return true;
+  }
+
+  return false;
 
-    return false;
-       
 }
 
 
@@ -357,127 +342,151 @@ bool Stream_lineIsInvalidMetaCommand(Stream_t stream)
 /*
  * Print the file line.
  */
-void  Stream_printLine(Stream_t stream,line_type_t line_type)
+void Stream_printLine(Stream_t stream, line_type_t line_type)
 {
-       char* __date = NULL;
-    __date = (char*)calloc(1,30);
-        
-       __time(__date);
-
-
-    Stream_lock(stream);
-
-       switch(line_type)
-       {
-               #ifdef __VERBOSE
-               case comment_line_type:
-
-        if(*(stream->line+2) != '\0')
-                   printf("%s   <COMMENT                     >  %3d %s",__date,stream->line_number,stream->line + 2);
-        else
-            /* empty comment */
-            printf("%s   <COMMENT                     >  %3d %s",__date,stream->line_number," \n");
-               break;
-
-               case timeout_value_line_type:
-               printf("%s   <TIMEOUT VALUE IS NOW        >  %3d %s",__date,stream->line_number,stream->line + 2 + strlen("set timeout "));
-               break;
-               
-               case exit_code_line_type:
-               printf("%s   <EXPECTED EXIT CODE          >  %3d %s",__date,stream->line_number,stream->line + 2 + strlen("expect exit code "));
-               break;
-               
-               case export_line_type:
-               printf("%s   <EXPORT                      >  %3d %s",__date,stream->line_number,stream->line + 2);
-               break;
-               
-               case unset_line_type:
-               printf("%s   <UNSET                       >  %3d %s",__date,stream->line_number,stream->line + 2);
-               break;
-               
-               case enable_output_checking_line_type:
-               printf("%s   <OUTPUT CHECKING ENABLED     >  %3d\n",__date,stream->line_number);
-               break;
-               
-               case disable_output_checking_line_type:
-               printf("%s   <OUTPUT CHECKING DISABLED    >  %3d\n",__date,stream->line_number);
-               break;
-               
-               case enable_post_output_checking_line_type:
-               printf("%s   <POST OUTPUT CHECKING ENABLED>  %3d\n",__date,stream->line_number);
-               break;
-               
-               case disable_post_output_checking_line_type:
-               printf("%s   <POST OUTPUT CHECKING DISABLED>  %3d\n",__date,stream->line_number);
-               break;
-
-               case create_console_line_type:
-               printf("%s   <CREATE CONSOLE SELECTED     >  %3d\n",__date,stream->line_number);
-               break;
-
-        case create_no_console_line_type:
-               printf("%s   <CREATE NO CONSOLE SELECTED  >  %3d\n",__date,stream->line_number);
-               break;
-
-        case enable_exit_code_checking_line_type:
-               printf("%s   <EXIT CODE CHECKING ENABLED  >  %3d\n",__date,stream->line_number);
-               break;
-
-        case disable_exit_code_checking_line_type:
-               printf("%s   <EXIT CODE CHECKING DISABLED >  %3d\n",__date,stream->line_number);
-               break;
-
-        case change_directory_line_type:
-        printf("%s   <DIRECTORY IS NOW            >  %3d %s\n",__date,stream->line_number,stream->line + 5);
-        break;
-
-        case command_line_line_type:
-        printf("%s   <COMMAND LINE                >  %3d %s",__date,stream->line_number,stream->line + 2);
-        break;
-
-               #endif /* #ifdef __VERBOSE */
-               
-               case invalid_token_line_type:
-               printf("%s   <INVALIDE TOKEN              >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case unknwn_meta_command_line_type:
-               printf("%s   <UNKNOWN META COMMAND        >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case invalid_timeout_value_line_type:
-               printf("%s   <INVALID TIMEOUT VALUE       >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case invalid_exit_code_line_type:
-               printf("%s   <INVALID EXIT CODE           >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case invalid_export_line_type:
-               printf("%s   <INVALID EXPORT              >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case invalid_unset_line_type:
-               printf("%s   <INVALID UNSET               >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case export_failed_line_type:
-               printf("%s   <EXPORT FAILED               >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               case unset_failed_line_type:
-               printf("%s   <UNSET FAILED                >  %3d %s",__date,stream->line_number,stream->line);
-               break;
-               
-               /* default:
-               ASSERT(false);
-        */
-        }
-
-        if(__date)
-            free(__date);
-
-        Stream_unlock(stream);
+  char *__date = NULL;
+  __date = (char *) calloc(1, 30);
+
+  __time(__date);
+
+
+  Stream_lock(stream);
+
+  switch (line_type) {
+#ifdef __VERBOSE
+  case comment_line_type:
+
+    if (*(stream->line + 2) != '\0')
+      printf("%s   <COMMENT                     >  %3d %s", __date,
+             stream->line_number, stream->line + 2);
+    else
+      /* empty comment */
+      printf("%s   <COMMENT                     >  %3d %s", __date,
+             stream->line_number, " \n");
+    break;
+
+  case timeout_value_line_type:
+    printf("%s   <TIMEOUT VALUE IS NOW        >  %3d %s", __date,
+           stream->line_number, stream->line + 2 + strlen("set timeout "));
+    break;
+
+  case exit_code_line_type:
+    printf("%s   <EXPECTED EXIT CODE          >  %3d %s", __date,
+           stream->line_number,
+           stream->line + 2 + strlen("expect exit code "));
+    break;
+
+  case export_line_type:
+    printf("%s   <EXPORT                      >  %3d %s", __date,
+           stream->line_number, stream->line + 2);
+    break;
+
+  case unset_line_type:
+    printf("%s   <UNSET                       >  %3d %s", __date,
+           stream->line_number, stream->line + 2);
+    break;
+
+  case enable_output_checking_line_type:
+    printf("%s   <OUTPUT CHECKING ENABLED     >  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case disable_output_checking_line_type:
+    printf("%s   <OUTPUT CHECKING DISABLED    >  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case enable_post_output_checking_line_type:
+    printf("%s   <POST OUTPUT CHECKING ENABLED>  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case disable_post_output_checking_line_type:
+    printf("%s   <POST OUTPUT CHECKING DISABLED>  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case create_console_line_type:
+    printf("%s   <CREATE CONSOLE SELECTED     >  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case create_no_console_line_type:
+    printf("%s   <CREATE NO CONSOLE SELECTED  >  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case enable_exit_code_checking_line_type:
+    printf("%s   <EXIT CODE CHECKING ENABLED  >  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case disable_exit_code_checking_line_type:
+    printf("%s   <EXIT CODE CHECKING DISABLED >  %3d\n", __date,
+           stream->line_number);
+    break;
+
+  case change_directory_line_type:
+    printf("%s   <DIRECTORY IS NOW            >  %3d %s\n", __date,
+           stream->line_number, stream->line + 5);
+    break;
+
+  case command_line_line_type:
+    printf("%s   <COMMAND LINE                >  %3d %s", __date,
+           stream->line_number, stream->line + 2);
+    break;
+
+#endif                          /* #ifdef __VERBOSE */
+
+  case invalid_token_line_type:
+    printf("%s   <INVALIDE TOKEN              >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case unknwn_meta_command_line_type:
+    printf("%s   <UNKNOWN META COMMAND        >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case invalid_timeout_value_line_type:
+    printf("%s   <INVALID TIMEOUT VALUE       >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case invalid_exit_code_line_type:
+    printf("%s   <INVALID EXIT CODE           >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case invalid_export_line_type:
+    printf("%s   <INVALID EXPORT              >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case invalid_unset_line_type:
+    printf("%s   <INVALID UNSET               >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case export_failed_line_type:
+    printf("%s   <EXPORT FAILED               >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+  case unset_failed_line_type:
+    printf("%s   <UNSET FAILED                >  %3d %s", __date,
+           stream->line_number, stream->line);
+    break;
+
+    /* default:
+       ASSERT(false);
+     */
+  }
+
+  if (__date)
+    free(__date);
+
+  Stream_unlock(stream);
 }
 
 
@@ -485,25 +494,23 @@ void  Stream_printLine(Stream_t stream,line_type_t line_type)
  * Returns true if the timeout value is invalid.
  * Otherwise the function returns false.
  */
-bool Stream_isInvalidTimeout(Stream_t stream) 
+bool Stream_isInvalidTimeout(Stream_t stream)
 {
-size_t i = 0;
-       char* p = stream->line + 2 + strlen("set timeout ");
-       
-       while(p[i] != '\n')
-       {
-               if(!isdigit(p[i]))
-               {
-                       setErrno(E_INVALID_TIMEOUT_VALUE);
-                       Stream_printLine(stream,invalid_timeout_value_line_type);
-                       return true;
-               }
-
-                i++;
-       }
-       
-       Stream_printLine(stream,timeout_value_line_type);
-       return false;   
+  size_t i = 0;
+  char *p = stream->line + 2 + strlen("set timeout ");
+
+  while (p[i] != '\n') {
+    if (!isdigit(p[i])) {
+      setErrno(E_INVALID_TIMEOUT_VALUE);
+      Stream_printLine(stream, invalid_timeout_value_line_type);
+      return true;
+    }
+
+    i++;
+  }
+
+  Stream_printLine(stream, timeout_value_line_type);
+  return false;
 }
 
 
@@ -511,24 +518,22 @@ size_t i = 0;
  * Returns true if the expected code value is invalid.
  * Otherwise the function returns false.
  */
-bool Stream_isInvalidExpectedCode(Stream_t stream) 
+bool Stream_isInvalidExpectedCode(Stream_t stream)
 {
-    size_t i = 0;
-       char* p = stream->line + 2 + strlen("expect exit code ");
-       
-       while(p[i] != '\n')
-       {
-               if(!isdigit(p[i]))
-               {
-                       setErrno(E_INVALID_EXIT_CODE_VALUE);
-                       Stream_printLine(stream,invalid_exit_code_line_type);
-                       return true;
-               }
-        i++;
-       }
-       
-       Stream_printLine(stream,exit_code_line_type);
-       return false;   
+  size_t i = 0;
+  char *p = stream->line + 2 + strlen("expect exit code ");
+
+  while (p[i] != '\n') {
+    if (!isdigit(p[i])) {
+      setErrno(E_INVALID_EXIT_CODE_VALUE);
+      Stream_printLine(stream, invalid_exit_code_line_type);
+      return true;
+    }
+    i++;
+  }
+
+  Stream_printLine(stream, exit_code_line_type);
+  return false;
 }
 
 
@@ -538,18 +543,17 @@ bool Stream_isInvalidExpectedCode(Stream_t stream)
  */
 bool Stream_isInvalidExport(Stream_t stream)
 {
-       /* todo trim*/
-       const char* ptr = strchr(stream->line,'=');
-
-       if(ptr && (*(++ptr) != '\n'))
-       {
-        Stream_printLine(stream,export_line_type);
-               return false;
-       }
-
-    setErrno(E_INVALID_EXPORT);
-    Stream_printLine(stream,invalid_export_line_type);
-       return true;    
+  /* todo trim */
+  const char *ptr = strchr(stream->line, '=');
+
+  if (ptr && (*(++ptr) != '\n')) {
+    Stream_printLine(stream, export_line_type);
+    return false;
+  }
+
+  setErrno(E_INVALID_EXPORT);
+  Stream_printLine(stream, invalid_export_line_type);
+  return true;
 }
 
 /*
@@ -558,20 +562,19 @@ bool Stream_isInvalidExport(Stream_t stream)
  */
 bool Stream_isInvalidUnset(Stream_t stream)
 {
-       /* todo trim */
-       const char* ptr = strchr(stream->line,' ');
-       
-       if((*(++ptr) != '\n'))
-       {
-        Stream_printLine(stream,unset_line_type);
-               return false;
-       }
-
-    setErrno(E_INVALID_UNSET);
-    Stream_printLine(stream,invalid_unset_line_type);
-       
-
-       return true; 
+  /* todo trim */
+  const char *ptr = strchr(stream->line, ' ');
+
+  if ((*(++ptr) != '\n')) {
+    Stream_printLine(stream, unset_line_type);
+    return false;
+  }
+
+  setErrno(E_INVALID_UNSET);
+  Stream_printLine(stream, invalid_unset_line_type);
+
+
+  return true;
 }
 
 
@@ -583,7 +586,7 @@ bool Stream_isInvalidUnset(Stream_t stream)
 
 bool Stream_lineIsExpectedChildOutput(Stream_t stream)
 {
-       return stream->line[0] == '>';  
+  return stream->line[0] == '>';
 }
 
 /* 
@@ -593,7 +596,7 @@ bool Stream_lineIsExpectedChildOutput(Stream_t stream)
  */
 bool Stream_lineIsChildInput(Stream_t stream)
 {
-       return stream->line[0] == '<';
+  return stream->line[0] == '<';
 }
 
 
@@ -605,25 +608,26 @@ bool Stream_lineIsChildInput(Stream_t stream)
  */
 bool Stream_lineIsSyncTestCase(Stream_t stream)
 {
-       return stream->line[0] == '$';
+  return stream->line[0] == '$';
 }
 
 bool Stream_lineIsAsyncTestCase(Stream_t stream)
 {
-       return stream->line[0] == '&';
+  return stream->line[0] == '&';
 }
 
 bool Stream_lineIsChangeDir(Stream_t stream)
 {
-    return ((stream->line[0] == '$') && (!strncmp(stream->line+2,"cd ",strlen("cd "))));
+  return ((stream->line[0] == '$')
+          && (!strncmp(stream->line + 2, "cd ", strlen("cd "))));
 }
 
 void Stream_lock(Stream_t ptr)
 {
-               EnterCriticalSection(&cs);
+  EnterCriticalSection(&cs);
 }
 
 void Stream_unlock(Stream_t ptr)
 {
-               LeaveCriticalSection(&cs);
+  LeaveCriticalSection(&cs);
 }
index f2ce0f7..1682238 100644 (file)
@@ -9,73 +9,68 @@
  */
 TestCaseContext_t TestCaseContext_new(void)
 {
-       TestCaseContext_t context = calloc(1,sizeof(s_TestCaseContext_t));
-       
-       if(NULL == context)
-       {
-               setErrno(E_TEST_CASE_CONTEXT_ALLOCATION_FAILED);
-               return NULL;
-       }
-       
-       context->inputBuffer = Buffer_new();
-       
-       if(NULL == context->inputBuffer)
-       {
-               TestCaseContext_free(context);
-               return NULL;
-       }
-               
-       context->outputBuffer = Buffer_new();
-       
-       if(NULL == context->outputBuffer)
-       {
-               TestCaseContext_free(context);
-               return NULL;    
-       }
-       
-       context->expectedOutputBuffer = Buffer_new();
-       
-       if(NULL == context->expectedOutputBuffer)
-       {
-               TestCaseContext_free(context);
-               return NULL;
-       }
-
-    context->commandLineBuffer = Buffer_new();
-
-    if(NULL == context->commandLineBuffer)
-       {
-               TestCaseContext_free(context);
-               return NULL;
-       }
-
-       
-       context->isOutputCheckingEnabled = DEFAULT_OUTPUT_CHECKING_MODE;
-    context->isPostOutputCheckingEnabled       = DEFAULT_POST_OUTPUT_CHECKING_MODE;
-       context->timeoutValue = DEFAULT_TIMEOUT_VALUE;
-       context->expectedExitCode = INVALID_EXIT_CODE;
-    context->exitCode = INVALID_EXIT_CODE;
-    context->name = NULL;
-    
-    context->runThread = true;
-       context->hThread = NULL;
-       context->hOutputRead = NULL;                                            
-       context->hInputWrite = NULL;                                            
-       context->hChildStdInRead = NULL;                                        
-       context->hChildStdOutWrite = NULL;                              
-       context->hChildStderr = NULL;
-       context->hChildStdoutReadTmp = NULL;
-       context->hChildStdinWriteTmp = NULL;
-    context->hConsole = NULL;
-
-    context->createConsole = false;
-    context->exitCodeCheckingEnabled = false;
-
-    context->started = false;
-
-       memset(&(context->pi),0,sizeof(PROCESS_INFORMATION));
-       
-       return context; 
+  TestCaseContext_t context = calloc(1, sizeof(s_TestCaseContext_t));
+
+  if (NULL == context) {
+    setErrno(E_TEST_CASE_CONTEXT_ALLOCATION_FAILED);
+    return NULL;
+  }
+
+  context->inputBuffer = Buffer_new();
+
+  if (NULL == context->inputBuffer) {
+    TestCaseContext_free(context);
+    return NULL;
+  }
+
+  context->outputBuffer = Buffer_new();
+
+  if (NULL == context->outputBuffer) {
+    TestCaseContext_free(context);
+    return NULL;
+  }
+
+  context->expectedOutputBuffer = Buffer_new();
+
+  if (NULL == context->expectedOutputBuffer) {
+    TestCaseContext_free(context);
+    return NULL;
+  }
+
+  context->commandLineBuffer = Buffer_new();
+
+  if (NULL == context->commandLineBuffer) {
+    TestCaseContext_free(context);
+    return NULL;
+  }
+
+
+  context->isOutputCheckingEnabled = DEFAULT_OUTPUT_CHECKING_MODE;
+  context->isPostOutputCheckingEnabled = DEFAULT_POST_OUTPUT_CHECKING_MODE;
+  context->timeoutValue = DEFAULT_TIMEOUT_VALUE;
+  context->expectedExitCode = INVALID_EXIT_CODE;
+  context->exitCode = INVALID_EXIT_CODE;
+  context->name = NULL;
+
+  context->runThread = true;
+  context->hThread = NULL;
+  context->hOutputRead = NULL;
+  context->hInputWrite = NULL;
+  context->hChildStdInRead = NULL;
+  context->hChildStdOutWrite = NULL;
+  context->hChildStderr = NULL;
+  context->hChildStdoutReadTmp = NULL;
+  context->hChildStdinWriteTmp = NULL;
+  context->hConsole = NULL;
+
+  context->createConsole = false;
+  context->exitCodeCheckingEnabled = false;
+
+  context->started = false;
+
+  memset(&(context->pi), 0, sizeof(PROCESS_INFORMATION));
+
+  return context;
 }
 
 /* 
@@ -83,73 +78,71 @@ TestCaseContext_t TestCaseContext_new(void)
  */
 void TestCaseContext_free(TestCaseContext_t context)
 {
-       if(NULL == context)
-               return;
-               
-       if(NULL !=context->inputBuffer)
-               Buffer_free(context->inputBuffer);
-       
-       if(NULL !=context->outputBuffer)
-               Buffer_free(context->outputBuffer);
-       
-       if(NULL !=context->expectedOutputBuffer)
-               Buffer_free(context->expectedOutputBuffer);
-
-    if(NULL !=context->commandLineBuffer)
-               Buffer_free(context->commandLineBuffer);
-               
-       if(NULL == context->name)
-               free(context->name);
-               
-               
-       /* Close all pipe handles. */   
-       if(context->hChildStdoutReadTmp)
-               CloseHandle(context->hChildStdoutReadTmp);
-               
-       if(context->hChildStdInRead)
-               CloseHandle(context->hChildStdInRead);
-       
-       if(context->hChildStdinWriteTmp)
-               CloseHandle(context->hChildStdinWriteTmp);
-       
-       if(context->hChildStdOutWrite)
-               CloseHandle(context->hChildStdOutWrite);
-               
-       if(context->hOutputRead)
-               CloseHandle(context->hOutputRead);
-               
-       if(context->pi.hThread)
-               CloseHandle(context->pi.hThread);
-       
-       /* Use some violence, no choice. */     
-       if(context->pi.hProcess)
-       {
-               /* Kill the child process. */
-               TerminateProcess(context->pi.hProcess,0);
-       }
-       
-       if(context->hThread)
-       {
-               /* Terminate the thread */
-               TerminateThread(context->hThread,0);
-    }
-
-     if(context->hInputWrite)
-        CloseHandle(context->hInputWrite);
-               
-       if(context->hChildStderr)
-               CloseHandle(context->hChildStderr);
-       
-       free(context);
-       context = NULL;
+  if (NULL == context)
+    return;
+
+  if (NULL != context->inputBuffer)
+    Buffer_free(context->inputBuffer);
+
+  if (NULL != context->outputBuffer)
+    Buffer_free(context->outputBuffer);
+
+  if (NULL != context->expectedOutputBuffer)
+    Buffer_free(context->expectedOutputBuffer);
+
+  if (NULL != context->commandLineBuffer)
+    Buffer_free(context->commandLineBuffer);
+
+  if (NULL == context->name)
+    free(context->name);
+
+
+  /* Close all pipe handles. */
+  if (context->hChildStdoutReadTmp)
+    CloseHandle(context->hChildStdoutReadTmp);
+
+  if (context->hChildStdInRead)
+    CloseHandle(context->hChildStdInRead);
+
+  if (context->hChildStdinWriteTmp)
+    CloseHandle(context->hChildStdinWriteTmp);
+
+  if (context->hChildStdOutWrite)
+    CloseHandle(context->hChildStdOutWrite);
+
+  if (context->hOutputRead)
+    CloseHandle(context->hOutputRead);
+
+  if (context->pi.hThread)
+    CloseHandle(context->pi.hThread);
+
+  /* Use some violence, no choice. */
+  if (context->pi.hProcess) {
+    /* Kill the child process. */
+    TerminateProcess(context->pi.hProcess, 0);
+  }
+
+  if (context->hThread) {
+    /* Terminate the thread */
+    TerminateThread(context->hThread, 0);
+  }
+
+  if (context->hInputWrite)
+    CloseHandle(context->hInputWrite);
+
+  if (context->hChildStderr)
+    CloseHandle(context->hChildStderr);
+
+  free(context);
+  context = NULL;
 }
 
 /* 
  * Set the timeout of the test case context.
  */
-void TestCaseContext_setTimeout(TestCaseContext_t context,int timeout)
+void TestCaseContext_setTimeout(TestCaseContext_t context, int timeout)
 {
-       context->timeoutValue = timeout;
+  context->timeoutValue = timeout;
 }
 
 /*
@@ -157,7 +150,7 @@ void TestCaseContext_setTimeout(TestCaseContext_t context,int timeout)
  */
 void TestCaseContext_enableOutputChecking(TestCaseContext_t context)
 {
-       context->isOutputCheckingEnabled = true;
+  context->isOutputCheckingEnabled = true;
 }
 
 /*
@@ -165,9 +158,9 @@ void TestCaseContext_enableOutputChecking(TestCaseContext_t context)
  */
 void TestCaseContext_disableOutputChecking(TestCaseContext_t context)
 {
-       /* If the post output checking mode is enable, disable it*/
-       context->isPostOutputCheckingEnabled = false;
-       context->isOutputCheckingEnabled = false;
+  /* If the post output checking mode is enable, disable it */
+  context->isPostOutputCheckingEnabled = false;
+  context->isOutputCheckingEnabled = false;
 }
 
 /*
@@ -175,9 +168,9 @@ void TestCaseContext_disableOutputChecking(TestCaseContext_t context)
  */
 void TestCaseContext_enable_post_output_checking(TestCaseContext_t context)
 {
-       /* enable the post output checking mode if the output checking mode is enabled*/
-       if(context->isOutputCheckingEnabled)
-               context->isPostOutputCheckingEnabled = true;
+  /* enable the post output checking mode if the output checking mode is enabled */
+  if (context->isOutputCheckingEnabled)
+    context->isPostOutputCheckingEnabled = true;
 }
 
 /*
@@ -185,25 +178,26 @@ void TestCaseContext_enable_post_output_checking(TestCaseContext_t context)
  */
 void TestCaseContext_disablePostOutputChecking(TestCaseContext_t context)
 {
-       context->isPostOutputCheckingEnabled = false;
+  context->isPostOutputCheckingEnabled = false;
 }
 
 void TestCaseContext_createConsole(TestCaseContext_t context)
 {
-    context->createConsole = true;
+  context->createConsole = true;
 }
 
 void TestCaseContext_createNoConsole(TestCaseContext_t context)
 {
-    context->createConsole = false;
+  context->createConsole = false;
 }
 
 /*
  * Set the expected exit code of the test case context.
  */
-void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,int expected_code)
+void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,
+                                         int expected_code)
 {
-       context->expectedExitCode = expected_code;
+  context->expectedExitCode = expected_code;
 }
 
 /*
@@ -212,22 +206,23 @@ void TestCaseContext_setExpectedExitCode(TestCaseContext_t context,int expected_
  */
 bool TestCaseContext_isOutputCheckingEnabled(TestCaseContext_t context)
 {
-       return context->isOutputCheckingEnabled;
+  return context->isOutputCheckingEnabled;
 }
 
 void TestCaseContext_enableExitCodeChecking(TestCaseContext_t context)
 {
-    context->exitCodeCheckingEnabled = true;
+  context->exitCodeCheckingEnabled = true;
 }
 
 void TestCaseContext_disableExitCodeChecking(TestCaseContext_t context)
 {
-    context->exitCodeCheckingEnabled = false;
+  context->exitCodeCheckingEnabled = false;
 }
 
-void TestCaseContext_setCommandLine(TestCaseContext_t context,char* cmdLine)
+void TestCaseContext_setCommandLine(TestCaseContext_t context,
+                                    char *cmdLine)
 {
-    Buffer_append(context->commandLineBuffer,cmdLine);
+  Buffer_append(context->commandLineBuffer, cmdLine);
 }
 
 
@@ -235,44 +230,45 @@ void TestCaseContext_setCommandLine(TestCaseContext_t context,char* cmdLine)
  * Append a child output to check in the 
  * test case context.
  */
-void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,char* expected_output)
+void TestCaseContext_appendExpectedOutput(TestCaseContext_t context,
+                                          char *expected_output)
 {
-       Buffer_append(context->expectedOutputBuffer,expected_output);
+  Buffer_append(context->expectedOutputBuffer, expected_output);
 }
 
 /*
  * Append a child output to check in the 
  * test case context.
  */
-void TestCaseContext_appendChildInput(TestCaseContext_t context,char* input)
+void TestCaseContext_appendChildInput(TestCaseContext_t context,
+                                      char *input)
 {
-       Buffer_append(context->inputBuffer,input);
+  Buffer_append(context->inputBuffer, input);
 }
 
 /*
  * Set the name of the test case name.
  */
-void TestCaseContext_setName(TestCaseContext_t context,char* name)
+void TestCaseContext_setName(TestCaseContext_t context, char *name)
 {
-    size_t size;
-
-       if(NULL != context->name)
-    {
-        free(context->name);
-    }
-               
-       context->name = strdup(name);
-    size = strlen(name);
-
-    while ((context->name[size-1] == '\n') || (context->name[size-1] == '\r'))
-       {
-               context->name[size-1] = '\0';
-               
-               if(size)
-                       size--;
-       }
-
-       /*context->name[strlen(context->name) - 1] ='\0';*/     
+  size_t size;
+
+  if (NULL != context->name) {
+    free(context->name);
+  }
+
+  context->name = strdup(name);
+  size = strlen(name);
+
+  while ((context->name[size - 1] == '\n')
+         || (context->name[size - 1] == '\r')) {
+    context->name[size - 1] = '\0';
+
+    if (size)
+      size--;
+  }
+
+  /*context->name[strlen(context->name) - 1] ='\0'; */
 }
 
 /* 
@@ -280,27 +276,26 @@ void TestCaseContext_setName(TestCaseContext_t context,char* name)
  */
 void TestCaseContext_clear(TestCaseContext_t context)
 {
-       if(!Buffer_empty(context->inputBuffer))
-               Buffer_clear(context->inputBuffer);                     
-       
-       if(!Buffer_empty(context->outputBuffer))
-               Buffer_clear(context->outputBuffer);
-               
-       if(!Buffer_empty(context->expectedOutputBuffer))
-               Buffer_clear(context->expectedOutputBuffer);
-
-    if(!Buffer_empty(context->commandLineBuffer))
-        Buffer_clear(context->commandLineBuffer);
-               
-       if(NULL == context->name)
-       {
-               free(context->name);
-               context->name = NULL;
-       }
-                                               
-       context->isOutputCheckingEnabled = DEFAULT_OUTPUT_CHECKING_MODE;
-        context->isPostOutputCheckingEnabled   = DEFAULT_POST_OUTPUT_CHECKING_MODE;
-       context->timeoutValue = DEFAULT_TIMEOUT_VALUE;
-       context->expectedExitCode = INVALID_EXIT_CODE;
-        context->exitCode = INVALID_EXIT_CODE;
-}
\ No newline at end of file
+  if (!Buffer_empty(context->inputBuffer))
+    Buffer_clear(context->inputBuffer);
+
+  if (!Buffer_empty(context->outputBuffer))
+    Buffer_clear(context->outputBuffer);
+
+  if (!Buffer_empty(context->expectedOutputBuffer))
+    Buffer_clear(context->expectedOutputBuffer);
+
+  if (!Buffer_empty(context->commandLineBuffer))
+    Buffer_clear(context->commandLineBuffer);
+
+  if (NULL == context->name) {
+    free(context->name);
+    context->name = NULL;
+  }
+
+  context->isOutputCheckingEnabled = DEFAULT_OUTPUT_CHECKING_MODE;
+  context->isPostOutputCheckingEnabled = DEFAULT_POST_OUTPUT_CHECKING_MODE;
+  context->timeoutValue = DEFAULT_TIMEOUT_VALUE;
+  context->expectedExitCode = INVALID_EXIT_CODE;
+  context->exitCode = INVALID_EXIT_CODE;
+}
index f27a2d3..3855f96 100644 (file)
@@ -7,41 +7,41 @@
  */
 TestRunner_t TestRunner_new(void)
 {
-       TestRunner_t ptr = calloc(1,sizeof(s_TestRunner_t));
-       
-       if(NULL == ptr){
-               setErrno(E_TEST_RUNNER_ALLOCATION_FAILED);
-               return NULL;
-       }
-       
-       ptr->buffer = Buffer_new();
-       
-       if(NULL == ptr->buffer){
-               TestRunner_free(ptr);
-               return NULL;
-       }
-       
-       ptr->testSuite = TestSuite_new();
-       
-       if(NULL == ptr->testSuite){
-               TestRunner_free(ptr);
-               return NULL;
-       }
-                
-       setErrno(E_SUCCESS);
-       return ptr;
+  TestRunner_t ptr = calloc(1, sizeof(s_TestRunner_t));
+
+  if (NULL == ptr) {
+    setErrno(E_TEST_RUNNER_ALLOCATION_FAILED);
+    return NULL;
+  }
+
+  ptr->buffer = Buffer_new();
+
+  if (NULL == ptr->buffer) {
+    TestRunner_free(ptr);
+    return NULL;
+  }
+
+  ptr->testSuite = TestSuite_new();
+
+  if (NULL == ptr->testSuite) {
+    TestRunner_free(ptr);
+    return NULL;
+  }
+
+  setErrno(E_SUCCESS);
+  return ptr;
 }
 
 /* 
  * Initialize the s_TestRunner struct 
  * by processing the command line.
  */
-errno_t TestRunner_initialize(TestRunner_t runner,int argc,char *argv[])
+errno_t TestRunner_initialize(TestRunner_t runner, int argc, char *argv[])
 {
-       if(E_SUCCESS != TestSuite_initialize(runner->testSuite,argc,argv))
-               return getErrno();
-               
-       return E_SUCCESS;       
+  if (E_SUCCESS != TestSuite_initialize(runner->testSuite, argc, argv))
+    return getErrno();
+
+  return E_SUCCESS;
 }
 
 /* 
@@ -49,7 +49,7 @@ errno_t TestRunner_initialize(TestRunner_t runner,int argc,char *argv[])
  */
 void TestRunner_run(TestRunner_t runner)
 {
-       TestSuite_run(runner->testSuite);
+  TestSuite_run(runner->testSuite);
 }
 
 /* 
@@ -57,14 +57,12 @@ void TestRunner_run(TestRunner_t runner)
  */
 void TestRunner_free(TestRunner_t runner)
 {
-       if(NULL == runner)
-               return;
-       
-       if(NULL != runner->buffer)
-               Buffer_free(runner->buffer);
-               
-       if(NULL != runner->testSuite)
-               TestSuite_free(runner->testSuite);
-}
+  if (NULL == runner)
+    return;
 
+  if (NULL != runner->buffer)
+    Buffer_free(runner->buffer);
 
+  if (NULL != runner->testSuite)
+    TestSuite_free(runner->testSuite);
+}
index 854b222..e2c49be 100644 (file)
@@ -6,74 +6,73 @@
  */
 TestSuite_t TestSuite_new(void)
 {
-       TestSuite_t testSuite = calloc(1,sizeof(s_TestSuite_t));
-       
-       if(NULL == testSuite){
-               setErrno(E_TEST_SUITE_ALLOCATION_FAILED);
-               TestSuite_free(testSuite);
-        return NULL;
-       }
-       
-       testSuite->stream = Stream_new();
-       
-       if(NULL == testSuite->stream){
-               TestSuite_free(testSuite);
-               return NULL;
-       }
-       
-       testSuite->test_case_context = TestCaseContext_new();
-       
-       if(NULL == testSuite->test_case_context){
-               TestSuite_free(testSuite);
-               return NULL;
-       }
-
-    testSuite->test_case_context->hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
-
-    testSuite->threads = ThreadDynarray_new(15);
-
-    if(NULL == testSuite->threads){
-        TestSuite_free(testSuite);
-        return NULL;
-    }
+  TestSuite_t testSuite = calloc(1, sizeof(s_TestSuite_t));
+
+  if (NULL == testSuite) {
+    setErrno(E_TEST_SUITE_ALLOCATION_FAILED);
+    TestSuite_free(testSuite);
+    return NULL;
+  }
+
+  testSuite->stream = Stream_new();
+
+  if (NULL == testSuite->stream) {
+    TestSuite_free(testSuite);
+    return NULL;
+  }
+
+  testSuite->test_case_context = TestCaseContext_new();
+
+  if (NULL == testSuite->test_case_context) {
+    TestSuite_free(testSuite);
+    return NULL;
+  }
 
-       testSuite->successCount = 0;
-       testSuite->failureCount = 0;
-       
-       return testSuite;
+  testSuite->test_case_context->hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+
+  testSuite->threads = ThreadDynarray_new(15);
+
+  if (NULL == testSuite->threads) {
+    TestSuite_free(testSuite);
+    return NULL;
+  }
+
+  testSuite->successCount = 0;
+  testSuite->failureCount = 0;
+
+  return testSuite;
 }
 
 /*
  * Initialize the s_TestSuite structure.
  */
-errno_t TestSuite_initialize(TestSuite_t ptr,int argc,char *argv[])
+errno_t TestSuite_initialize(TestSuite_t ptr, int argc, char *argv[])
 {
-       switch(argc)
-       {
-               case 1:
-               TestSuite_print("Run the test case from the console.\n"); 
-               
-               ptr->stream->file = stdin;
-               return E_SUCCESS;
-
-               case 2:
-                       
-               if(E_SUCCESS != Stream_isValidFile(argv[1]))
-                       return getErrno();
-
-               printf("\n\n Test runner : %s\n\n",argv[1]);
-               
-               if(E_SUCCESS != Stream_openFile(ptr->stream,argv[1]))
-                       return getErrno();
-               
-               return E_SUCCESS;
-                       
-               default:
-               {
-                       setErrno(E_BAD_USAGE);
-                       return getErrno();
-               }
-       }       
+  switch (argc) {
+  case 1:
+    TestSuite_print("Run the test case from the console.\n");
+
+    ptr->stream->file = stdin;
+    return E_SUCCESS;
+
+  case 2:
+
+    if (E_SUCCESS != Stream_isValidFile(argv[1]))
+      return getErrno();
+
+    printf("\n\n Test runner : %s\n\n", argv[1]);
+
+    if (E_SUCCESS != Stream_openFile(ptr->stream, argv[1]))
+      return getErrno();
+
+    return E_SUCCESS;
+
+  default:
+    {
+      setErrno(E_BAD_USAGE);
+      return getErrno();
+    }
+  }
 }
 
 /* 
@@ -81,171 +80,174 @@ errno_t TestSuite_initialize(TestSuite_t ptr,int argc,char *argv[])
  */
 void TestSuite_run(TestSuite_t testSuite)
 {
-       Stream_t stream = testSuite->stream;
-
-       /* Handle all lines in the testsuite file (or from stdin) */
-       while((Stream_getLine(stream) != -1) && (E_SUCCESS  == getErrno()))
-       {
-               /* Don't process blank lines. */
-               if (Stream_lineIsBlank(stream))
-                       continue;
-               
-               /* Check if the current text line contains a invalid token. */
-               if(Stream_lineContainsInvalidToken(stream))
-                       return;
-
-         /* Check if the text line contains a meta command. */
-               if(Stream_lineIsMetaCommand(stream)){
-                       /* Check if the current text line contains a unknown meta command. */
-            if(Stream_lineIsUnknwnMetaCommand(stream))
-                return;
-
-                       /* Check the meta command validity.*/
-            if(Stream_lineIsInvalidMetaCommand(stream))
-                return;
-                               
-                       /* We have a valid meta command, process it */
-                       if(E_SUCCESS != TestSuite_processMetaCommand(testSuite))
-                               return;
-                               
-                       continue;
-               }
-
-               /* Handle the comment. */
-               if(Stream_lineIsComment(stream)){
-                       Stream_printLine(testSuite->stream,comment_line_type);
-                       continue;
-               }       
-               
-               /* Handle expected child output. */
-               if(Stream_lineIsExpectedChildOutput(stream)){
-                       if(E_SUCCESS != TestSuite_processExpectedChildOutput(testSuite))
-                               return;
-                
-                       continue;
-               }
-
-               /* Handle expected child input. */
-               if(Stream_lineIsChildInput(stream)){
-                       if(E_SUCCESS != TestSuite_processChildInput(testSuite))
-                               return;
-                       
-                       continue;
-               }
-
-        if(Stream_lineIsChangeDir(stream)){
-            if(E_SUCCESS != TestSuite_changeDir(testSuite))
-                return;
-
-            continue;
-        }
-               
-               /* Handle synchrone synchrone test case. */
-               if(Stream_lineIsSyncTestCase(stream)){
-                       TestCaseContext_setName(testSuite->test_case_context,stream->line + 2);
-                       
-                       TestSuite_runSyncTestCase(testSuite->test_case_context);
-
-
-            if(TestSuite_iSPostOutputCheckingEnabled(testSuite->test_case_context)){
-                           TestSuite_checkChildOutput(testSuite->test_case_context);
-            }
-
-                   if(TestSuite_iSExitCodeCheckingEnabled(testSuite->test_case_context)){
-                       if(E_SUCCESS != TestSuite_checkChildExitCode(testSuite->test_case_context))
-                    return;
-            }
-
-
-            if(E_SUCCESS != getErrno())
-                return;
-               }
-        /* Handle asynchrone synchrone test case. */
-               else if(Stream_lineIsAsyncTestCase(stream))
-               {
-                       TestCaseContext_setName(testSuite->test_case_context,stream->line + 2);
-                       
-                       if(E_SUCCESS != TestSuite_runAsyncTestCase(testSuite))
-                               return;
-               }
-               else
-               {
-                       ASSERT(false);
-               }
-
-        /* Clear the child input stream. */
-        Buffer_clear(testSuite->test_case_context->inputBuffer);
-        /* Clear the command line buffer. */
-        Buffer_clear(testSuite->test_case_context->commandLineBuffer);
-       }
+  Stream_t stream = testSuite->stream;
+
+  /* Handle all lines in the testsuite file (or from stdin) */
+  while ((Stream_getLine(stream) != -1) && (E_SUCCESS == getErrno())) {
+    /* Don't process blank lines. */
+    if (Stream_lineIsBlank(stream))
+      continue;
+
+    /* Check if the current text line contains a invalid token. */
+    if (Stream_lineContainsInvalidToken(stream))
+      return;
+
+    /* Check if the text line contains a meta command. */
+    if (Stream_lineIsMetaCommand(stream)) {
+      /* Check if the current text line contains a unknown meta command. */
+      if (Stream_lineIsUnknwnMetaCommand(stream))
+        return;
+
+      /* Check the meta command validity. */
+      if (Stream_lineIsInvalidMetaCommand(stream))
+        return;
+
+      /* We have a valid meta command, process it */
+      if (E_SUCCESS != TestSuite_processMetaCommand(testSuite))
+        return;
+
+      continue;
+    }
+
+    /* Handle the comment. */
+    if (Stream_lineIsComment(stream)) {
+      Stream_printLine(testSuite->stream, comment_line_type);
+      continue;
+    }
+
+    /* Handle expected child output. */
+    if (Stream_lineIsExpectedChildOutput(stream)) {
+      if (E_SUCCESS != TestSuite_processExpectedChildOutput(testSuite))
+        return;
+
+      continue;
+    }
+
+    /* Handle expected child input. */
+    if (Stream_lineIsChildInput(stream)) {
+      if (E_SUCCESS != TestSuite_processChildInput(testSuite))
+        return;
+
+      continue;
+    }
+
+    if (Stream_lineIsChangeDir(stream)) {
+      if (E_SUCCESS != TestSuite_changeDir(testSuite))
+        return;
+
+      continue;
+    }
+
+    /* Handle synchrone synchrone test case. */
+    if (Stream_lineIsSyncTestCase(stream)) {
+      TestCaseContext_setName(testSuite->test_case_context,
+                              stream->line + 2);
+
+      TestSuite_runSyncTestCase(testSuite->test_case_context);
+
+
+      if (TestSuite_iSPostOutputCheckingEnabled
+          (testSuite->test_case_context)) {
+        TestSuite_checkChildOutput(testSuite->test_case_context);
+      }
+
+      if (TestSuite_iSExitCodeCheckingEnabled
+          (testSuite->test_case_context)) {
+        if (E_SUCCESS !=
+            TestSuite_checkChildExitCode(testSuite->test_case_context))
+          return;
+      }
+
+
+      if (E_SUCCESS != getErrno())
+        return;
+    }
+    /* Handle asynchrone synchrone test case. */
+    else if (Stream_lineIsAsyncTestCase(stream)) {
+      TestCaseContext_setName(testSuite->test_case_context,
+                              stream->line + 2);
+
+      if (E_SUCCESS != TestSuite_runAsyncTestCase(testSuite))
+        return;
+    } else {
+      ASSERT(false);
+    }
+
+    /* Clear the child input stream. */
+    Buffer_clear(testSuite->test_case_context->inputBuffer);
+    /* Clear the command line buffer. */
+    Buffer_clear(testSuite->test_case_context->commandLineBuffer);
+  }
 }
+
 /* 
  * Meta command processing.
  */
 errno_t TestSuite_processMetaCommand(TestSuite_t testSuite)
 {
-    Stream_t stream = testSuite->stream;
-    
-       if(!strncmp("set timeout ",stream->line + 2,strlen("set timeout ")))
-       {
-               TestSuite_setTimeout(testSuite);        
-       }
-    else if(!strncmp("command line ",stream->line + 2,strlen("command line")))
-       {
-               TestSuite_setCommandLine(testSuite);
-       }
-       else if(!strncmp("enable output checking",stream->line + 2,strlen("enable output checking")))
-       {
-               TestSuite_enableOutputChecking(testSuite);
-       }
-       else if(!strncmp("disable output checking",stream->line + 2,strlen("disable output checking")))
-       {
-               TestSuite_disableOutputChecking(testSuite);
-       }       
-       else if(!strncmp("enable post output checking",stream->line + 2,strlen("enable post output checking")))
-       {
-               TestSuite_enablePostOutputChecking(testSuite);  
-       }       
-       else if(!strncmp("disable post output checking",stream->line + 2,strlen("disable post output checking")))
-       {
-               TestSuite_disablePostOutputChecking(testSuite);
-       }       
-       else if(!strncmp("expect exit code ",stream->line + 2,strlen("expect exit code ")))
-       {
-               TestSuite_setExpectedExitCode(testSuite);
-       }
-       else if(!strncmp("export ",stream->line + 2,strlen("export ")))
-       {
-               TestSuite_export(testSuite);
-       }
-       else if(!strncmp("unset ",stream->line + 2,strlen("unset ")))
-       {
-               TestSuite_unset(testSuite);
-       }
-    else if(!strncmp("create console",stream->line + 2,strlen("create console")))
-       {
-               TestSuite_createConsole(testSuite);
-       }
-       else if(!strncmp("create no console",stream->line + 2,strlen("create no console")))
-       {
-               TestSuite_createNoConsole(testSuite);
-       }
-    else if(!strncmp("enable exit code checking",stream->line + 2,strlen("enable exit code checking")))
-       {
-               TestSuite_enableExitCodeChecking(testSuite);
-       }
-    else if(!strncmp("disable exit code checking",stream->line + 2,strlen("disable exit code checking")))
-       {
-               TestSuite_disableExitCodeChecking(testSuite);
-       }
-       else
-       {
-        /* TODO */
-               ASSERT(false);
-       }       
-       
-       return E_SUCCESS;
-               
+  Stream_t stream = testSuite->stream;
+
+  if (!strncmp("set timeout ", stream->line + 2, strlen("set timeout "))) {
+    TestSuite_setTimeout(testSuite);
+  } else
+      if (!strncmp
+          ("command line ", stream->line + 2, strlen("command line"))) {
+    TestSuite_setCommandLine(testSuite);
+  } else
+      if (!strncmp
+          ("enable output checking", stream->line + 2,
+           strlen("enable output checking"))) {
+    TestSuite_enableOutputChecking(testSuite);
+  } else
+      if (!strncmp
+          ("disable output checking", stream->line + 2,
+           strlen("disable output checking"))) {
+    TestSuite_disableOutputChecking(testSuite);
+  } else
+      if (!strncmp
+          ("enable post output checking", stream->line + 2,
+           strlen("enable post output checking"))) {
+    TestSuite_enablePostOutputChecking(testSuite);
+  } else
+      if (!strncmp
+          ("disable post output checking", stream->line + 2,
+           strlen("disable post output checking"))) {
+    TestSuite_disablePostOutputChecking(testSuite);
+  } else
+      if (!strncmp
+          ("expect exit code ", stream->line + 2,
+           strlen("expect exit code "))) {
+    TestSuite_setExpectedExitCode(testSuite);
+  } else if (!strncmp("export ", stream->line + 2, strlen("export "))) {
+    TestSuite_export(testSuite);
+  } else if (!strncmp("unset ", stream->line + 2, strlen("unset "))) {
+    TestSuite_unset(testSuite);
+  } else
+      if (!strncmp
+          ("create console", stream->line + 2, strlen("create console"))) {
+    TestSuite_createConsole(testSuite);
+  } else
+      if (!strncmp
+          ("create no console", stream->line + 2,
+           strlen("create no console"))) {
+    TestSuite_createNoConsole(testSuite);
+  } else
+      if (!strncmp
+          ("enable exit code checking", stream->line + 2,
+           strlen("enable exit code checking"))) {
+    TestSuite_enableExitCodeChecking(testSuite);
+  } else
+      if (!strncmp
+          ("disable exit code checking", stream->line + 2,
+           strlen("disable exit code checking"))) {
+    TestSuite_disableExitCodeChecking(testSuite);
+  } else {
+    /* TODO */
+    ASSERT(false);
+  }
+
+  return E_SUCCESS;
+
 }
 
 /* 
@@ -254,9 +256,9 @@ errno_t TestSuite_processMetaCommand(TestSuite_t testSuite)
  */
 void TestSuite_setTimeout(TestSuite_t testSuite)
 {
-       
-       int timeout = atoi(testSuite->stream->line + 2 + strlen("set timeout "));
-       TestCaseContext_setTimeout(testSuite->test_case_context,timeout);       
+
+  int timeout = atoi(testSuite->stream->line + 2 + strlen("set timeout "));
+  TestCaseContext_setTimeout(testSuite->test_case_context, timeout);
 }
 
 /*
@@ -264,12 +266,14 @@ void TestSuite_setTimeout(TestSuite_t testSuite)
  */
 void TestSuite_enableOutputChecking(TestSuite_t testSuite)
 {
-       TestCaseContext_enableOutputChecking(testSuite->test_case_context);
+  TestCaseContext_enableOutputChecking(testSuite->test_case_context);
 }
 
 void TestSuite_setCommandLine(TestSuite_t testSuite)
 {
-    TestCaseContext_setCommandLine(testSuite->test_case_context,testSuite->stream->line + 2 + strlen("command line "));
+  TestCaseContext_setCommandLine(testSuite->test_case_context,
+                                 testSuite->stream->line + 2 +
+                                 strlen("command line "));
 }
 
 /*
@@ -277,7 +281,7 @@ void TestSuite_setCommandLine(TestSuite_t testSuite)
  */
 void TestSuite_disableOutputChecking(TestSuite_t testSuite)
 {
-       TestCaseContext_disableOutputChecking(testSuite->test_case_context);
+  TestCaseContext_disableOutputChecking(testSuite->test_case_context);
 }
 
 /*
@@ -285,17 +289,18 @@ void TestSuite_disableOutputChecking(TestSuite_t testSuite)
  */
 void TestSuite_enablePostOutputChecking(TestSuite_t testSuite)
 {
-       TestCaseContext_enable_post_output_checking(testSuite->test_case_context);
+  TestCaseContext_enable_post_output_checking(testSuite->
+                                              test_case_context);
 }
 
 void TestSuite_createConsole(TestSuite_t testSuite)
 {
-    TestCaseContext_createConsole(testSuite->test_case_context);
+  TestCaseContext_createConsole(testSuite->test_case_context);
 }
 
 void TestSuite_createNoConsole(TestSuite_t testSuite)
 {
-    TestCaseContext_createNoConsole(testSuite->test_case_context);
+  TestCaseContext_createNoConsole(testSuite->test_case_context);
 }
 
 /*
@@ -303,7 +308,7 @@ void TestSuite_createNoConsole(TestSuite_t testSuite)
  */
 void TestSuite_disablePostOutputChecking(TestSuite_t testSuite)
 {
-       TestCaseContext_disablePostOutputChecking(testSuite->test_case_context);
+  TestCaseContext_disablePostOutputChecking(testSuite->test_case_context);
 }
 
 /*
@@ -311,18 +316,20 @@ void TestSuite_disablePostOutputChecking(TestSuite_t testSuite)
  */
 void TestSuite_setExpectedExitCode(TestSuite_t testSuite)
 {
-       int expectedExitCode = atoi(testSuite->stream->line + 2 + strlen("expect exit code "));
-       TestCaseContext_setExpectedExitCode(testSuite->test_case_context,expectedExitCode);
+  int expectedExitCode =
+      atoi(testSuite->stream->line + 2 + strlen("expect exit code "));
+  TestCaseContext_setExpectedExitCode(testSuite->test_case_context,
+                                      expectedExitCode);
 }
 
 void TestSuite_enableExitCodeChecking(TestSuite_t testSuite)
 {
-    TestCaseContext_enableExitCodeChecking(testSuite->test_case_context);
+  TestCaseContext_enableExitCodeChecking(testSuite->test_case_context);
 }
 
 void TestSuite_disableExitCodeChecking(TestSuite_t testSuite)
 {
-    TestCaseContext_disableExitCodeChecking(testSuite->test_case_context);
+  TestCaseContext_disableExitCodeChecking(testSuite->test_case_context);
 }
 
 
@@ -331,46 +338,44 @@ void TestSuite_disableExitCodeChecking(TestSuite_t testSuite)
  */
 errno_t TestSuite_export(TestSuite_t testSuite)
 {
-       /* TODO trim */
-       const char* ptr;
-    const char* pos;
-    char __buffer[50] = {0};
-    char* line = testSuite->stream->line + strlen("export ");
-
-    line[strlen(line) -1] = '\0';
-
-    ptr = strchr(line,' ');
-    pos= ++ptr;
-    ptr =  strchr(line,'=');
-    strncpy(__buffer,pos,ptr - pos);
-       if(!SetEnvironmentVariable(__buffer,++ptr))
-       {
-               setErrno(E_EXPORT_FAILED);
-               Stream_printLine(testSuite->stream,export_failed_line_type);
-               return getErrno();
-               
-       }
-
-       return E_SUCCESS;
+  /* TODO trim */
+  const char *ptr;
+  const char *pos;
+  char __buffer[50] = { 0 };
+  char *line = testSuite->stream->line + strlen("export ");
+
+  line[strlen(line) - 1] = '\0';
+
+  ptr = strchr(line, ' ');
+  pos = ++ptr;
+  ptr = strchr(line, '=');
+  strncpy(__buffer, pos, ptr - pos);
+  if (!SetEnvironmentVariable(__buffer, ++ptr)) {
+    setErrno(E_EXPORT_FAILED);
+    Stream_printLine(testSuite->stream, export_failed_line_type);
+    return getErrno();
+
+  }
+
+  return E_SUCCESS;
 }
 
 errno_t TestSuite_unset(TestSuite_t testSuite)
 {
-       char line[128] = {0};
-    const char* ptr;
-    strcpy(line,testSuite->stream->line +2);
-       ptr = strchr(line,' ');
-    line[strlen(line) -1] = '\0';
-
-       if(!SetEnvironmentVariable(++ptr,NULL))
-       {
-
-               setErrno(E_UNSET_FAILED);
-               Stream_printLine(testSuite->stream,unset_failed_line_type);
-               return getErrno();
-       }
-       
-       return E_SUCCESS;
+  char line[128] = { 0 };
+  const char *ptr;
+  strcpy(line, testSuite->stream->line + 2);
+  ptr = strchr(line, ' ');
+  line[strlen(line) - 1] = '\0';
+
+  if (!SetEnvironmentVariable(++ptr, NULL)) {
+
+    setErrno(E_UNSET_FAILED);
+    Stream_printLine(testSuite->stream, unset_failed_line_type);
+    return getErrno();
+  }
+
+  return E_SUCCESS;
 }
 
 /*
@@ -378,14 +383,16 @@ errno_t TestSuite_unset(TestSuite_t testSuite)
  */
 errno_t TestSuite_processExpectedChildOutput(TestSuite_t testSuite)
 {
-       /* TODO : logic error*/
-       if(!TestCaseContext_isOutputCheckingEnabled(testSuite->test_case_context))
-               return E_SUCCESS;
-       
-       /* TODO : trim */
-       TestCaseContext_appendExpectedOutput(testSuite->test_case_context,testSuite->stream->line + 2);
-       
-       return E_SUCCESS;
+  /* TODO : logic error */
+  if (!TestCaseContext_isOutputCheckingEnabled
+      (testSuite->test_case_context))
+    return E_SUCCESS;
+
+  /* TODO : trim */
+  TestCaseContext_appendExpectedOutput(testSuite->test_case_context,
+                                       testSuite->stream->line + 2);
+
+  return E_SUCCESS;
 }
 
 /*
@@ -393,10 +400,11 @@ errno_t TestSuite_processExpectedChildOutput(TestSuite_t testSuite)
  */
 errno_t TestSuite_processChildInput(TestSuite_t testSuite)
 {
-       /* TODO : trim */
-       TestCaseContext_appendChildInput(testSuite->test_case_context,testSuite->stream->line + 2);
+  /* TODO : trim */
+  TestCaseContext_appendChildInput(testSuite->test_case_context,
+                                   testSuite->stream->line + 2);
 
-       return E_SUCCESS;       
+  return E_SUCCESS;
 }
 
 /* 
@@ -404,87 +412,79 @@ errno_t TestSuite_processChildInput(TestSuite_t testSuite)
  */
 void TestSuite_free(TestSuite_t testSuite)
 {
-    ThreadEntry_t entry;
-    unsigned long count;
-    unsigned long i;
-    DWORD dwWaitResult;
-    bool steel_running;
-    bool last_async_process_error = false;
-    DWORD ExitCode = 0;
-    errno_t e = getErrno();
-
-       if(NULL == testSuite)
-               return;
-
-    count = ThreadDynarray_getCount(testSuite->threads);
-
-    /* Wait for all asynchrone process */
-    if(NULL != testSuite->threads && count)
-    {
-        while(true)
-        {
-            steel_running = false;
-
-               for(i = 0;i < count ; i++)
-           {
-                       entry = ThreadDynarray_at(testSuite->threads,i);
-                
-                       GetExitCodeThread(entry->hThread,&ExitCode);
-                       
-                       if(STILL_ACTIVE == ExitCode)
-                {
-                    Sleep(0);
-                               steel_running = true;
-                }
-               }
-
-               if(!steel_running)
-                       break;
+  ThreadEntry_t entry;
+  unsigned long count;
+  unsigned long i;
+  DWORD dwWaitResult;
+  bool steel_running;
+  bool last_async_process_error = false;
+  DWORD ExitCode = 0;
+  errno_t e = getErrno();
+
+  if (NULL == testSuite)
+    return;
+
+  count = ThreadDynarray_getCount(testSuite->threads);
+
+  /* Wait for all asynchrone process */
+  if (NULL != testSuite->threads && count) {
+    while (true) {
+      steel_running = false;
+
+      for (i = 0; i < count; i++) {
+        entry = ThreadDynarray_at(testSuite->threads, i);
+
+        GetExitCodeThread(entry->hThread, &ExitCode);
+
+        if (STILL_ACTIVE == ExitCode) {
+          Sleep(0);
+          steel_running = true;
         }
+      }
+
+      if (!steel_running)
+        break;
+    }
 
-        for(i = 0;i <count;i++)
-        {
-            entry = ThreadDynarray_at(testSuite->threads,i);
-
-            if(entry->context->pi.hProcess)
-            {
-                dwWaitResult=WaitForSingleObject(entry->hThread,INFINITE);
-
-                if((WAIT_FAILED == dwWaitResult))
-                    TerminateThread(entry->hThread,0);
-                else
-                    CloseHandle(entry->hThread);
-            }
-
-            /*if(((E_SUCCESS == e) || (E_EXIT_CODE_DONT_MATCH == e) || (E_OUTPUT_DONT_MATCH == e)) && !last_async_process_error)
-            {*/
-                /* Child output and exit code checking */
-                if(TestSuite_iSPostOutputCheckingEnabled(entry->context))
-                {
-                    if(E_SUCCESS != TestSuite_checkChildOutput(entry->context))
-                        last_async_process_error = true;
-                }
-
-                if(TestSuite_iSExitCodeCheckingEnabled(entry->context))
-                {
-                           if(E_SUCCESS != TestSuite_checkChildExitCode(entry->context))
-                        last_async_process_error = true;
-                }
-            }
-
-            TestCaseContext_free(entry->context);
-        /*}*/
-
-        ThreadDynarray_destroy(testSuite->threads);
+    for (i = 0; i < count; i++) {
+      entry = ThreadDynarray_at(testSuite->threads, i);
+
+      if (entry->context->pi.hProcess) {
+        dwWaitResult = WaitForSingleObject(entry->hThread, INFINITE);
+
+        if ((WAIT_FAILED == dwWaitResult))
+          TerminateThread(entry->hThread, 0);
+        else
+          CloseHandle(entry->hThread);
+      }
+
+      /*if(((E_SUCCESS == e) || (E_EXIT_CODE_DONT_MATCH == e) || (E_OUTPUT_DONT_MATCH == e)) && !last_async_process_error)
+         { */
+      /* Child output and exit code checking */
+      if (TestSuite_iSPostOutputCheckingEnabled(entry->context)) {
+        if (E_SUCCESS != TestSuite_checkChildOutput(entry->context))
+          last_async_process_error = true;
+      }
+
+      if (TestSuite_iSExitCodeCheckingEnabled(entry->context)) {
+        if (E_SUCCESS != TestSuite_checkChildExitCode(entry->context))
+          last_async_process_error = true;
+      }
     }
 
-    if(NULL != testSuite->test_case_context)
-               TestCaseContext_free(testSuite->test_case_context);
-    
-       if(NULL != testSuite->stream)
-               Stream_free(testSuite->stream);
-        
-       free(testSuite);
+    TestCaseContext_free(entry->context);
+    /*} */
+
+    ThreadDynarray_destroy(testSuite->threads);
+  }
+
+  if (NULL != testSuite->test_case_context)
+    TestCaseContext_free(testSuite->test_case_context);
+
+  if (NULL != testSuite->stream)
+    Stream_free(testSuite->stream);
+
+  free(testSuite);
 }
 
 /*
@@ -492,114 +492,114 @@ void TestSuite_free(TestSuite_t testSuite)
  */
 errno_t TestSuite_checkChildOutput(TestCaseContext_t context)
 {
-       bool are_equals = false;
-       char str[256] = {0};
-
-       
-       if (context->expectedOutputBuffer->size==0 && context->outputBuffer->size==0)
-               return E_SUCCESS;
-       
-       Buffer_chomp(context->outputBuffer);
-       Buffer_chomp(context->expectedOutputBuffer);
-       
-       
-       if (context->outputBuffer->size != context->expectedOutputBuffer->size || strcmp(context->outputBuffer->data, context->expectedOutputBuffer->data))
-       {
-               strcpy(str,"<OUTPUT NOT MATCH            >  \n");
-               TestSuite_print(str);
-               
-       }
-    else
-    {
-               are_equals = true;
-               strcpy(str,"<OUTPUT MATCH                >  \n");
-               TestSuite_print(str);
-               
-               
-    }
-    
-    memset(str,0,256);
-    
-    if(context->expectedOutputBuffer->size)
-    {
-       sprintf(str,"<EXPECTED                    >      SIZE (%4d) DATA (%s)\n",context->expectedOutputBuffer->size,context->expectedOutputBuffer->data);
-               TestSuite_print(str);
-       }
-    else
-    {
-       scanf(str,"<EXPECTED                    >      SIZE (%4d) DATA (%s)\n",context->expectedOutputBuffer->size,"empty");
-               TestSuite_print(str);
-       }
-       
-       memset(str,0,256);
-    
-       if(context->outputBuffer->size)
-       {
-               sprintf(str,"<RECEIVED                    >      SIZE (%4d) DATA (%s)\n",context->outputBuffer->size,context->outputBuffer->data);
-               TestSuite_print(str);
-       }
-       else
-       {
-               sprintf(str,"<RECEIVED                    >      SIZE (%4d) DATA (%s)\n",context->outputBuffer->size,"empty");
-               TestSuite_print(str);
-       }
-               
-       Buffer_clear(context->expectedOutputBuffer);
-       Buffer_clear(context->outputBuffer);
-       
-       if(!are_equals)
-    {
-        setErrno(E_OUTPUT_DONT_MATCH);
-               return getErrno();
-    }
-       
-       return E_SUCCESS;
+  bool are_equals = false;
+  char str[256] = { 0 };
+
+
+  if (context->expectedOutputBuffer->size == 0
+      && context->outputBuffer->size == 0)
+    return E_SUCCESS;
+
+  Buffer_chomp(context->outputBuffer);
+  Buffer_chomp(context->expectedOutputBuffer);
+
+
+  if (context->outputBuffer->size != context->expectedOutputBuffer->size
+      || strcmp(context->outputBuffer->data,
+                context->expectedOutputBuffer->data)) {
+    strcpy(str, "<OUTPUT NOT MATCH            >  \n");
+    TestSuite_print(str);
+
+  } else {
+    are_equals = true;
+    strcpy(str, "<OUTPUT MATCH                >  \n");
+    TestSuite_print(str);
+
+
+  }
+
+  memset(str, 0, 256);
+
+  if (context->expectedOutputBuffer->size) {
+    sprintf(str,
+            "<EXPECTED                    >      SIZE (%4d) DATA (%s)\n",
+            context->expectedOutputBuffer->size,
+            context->expectedOutputBuffer->data);
+    TestSuite_print(str);
+  } else {
+    scanf(str,
+          "<EXPECTED                    >      SIZE (%4d) DATA (%s)\n",
+          context->expectedOutputBuffer->size, "empty");
+    TestSuite_print(str);
+  }
+
+  memset(str, 0, 256);
+
+  if (context->outputBuffer->size) {
+    sprintf(str,
+            "<RECEIVED                    >      SIZE (%4d) DATA (%s)\n",
+            context->outputBuffer->size, context->outputBuffer->data);
+    TestSuite_print(str);
+  } else {
+    sprintf(str,
+            "<RECEIVED                    >      SIZE (%4d) DATA (%s)\n",
+            context->outputBuffer->size, "empty");
+    TestSuite_print(str);
+  }
+
+  Buffer_clear(context->expectedOutputBuffer);
+  Buffer_clear(context->outputBuffer);
+
+  if (!are_equals) {
+    setErrno(E_OUTPUT_DONT_MATCH);
+    return getErrno();
+  }
+
+  return E_SUCCESS;
 }
 
 /*
  * Check the child process exit code.
- */ 
+ */
 errno_t TestSuite_checkChildExitCode(TestCaseContext_t context)
 {
-               bool __success = false;
-               char str[256] = {0};
-               
-               sprintf(str,"<TEST CASE TERMINATED        >      %s %3ld\n",context->name,context->exitCode);
-               TestSuite_print(str);
-               
-               memset(str,0,256);
-
-               /* if a expected exit code was signaled, compare it with the real. */
-               if(context->expectedExitCode != INVALID_EXIT_CODE)
-               {
-                       if(context->expectedExitCode  != context->exitCode )
-                       {
-                               
-                               TestSuite_print("<EXIT CODE DON'T MATCH       >\n");
-                       }
-                       else
-                       {
-                __success = true;
-                               TestSuite_print("<EXIT CODE MATCH             >\n");
-                       }
-            sprintf(str,"<EXIT CODE EXPECTED          >      (%3d)\n",context->expectedExitCode);
-            TestSuite_print(str);
-
-            memset(str,0,256);
-
-            sprintf(str,"<EXIT CODE RETURNED          >      (%3d)\n",context->exitCode);
-             TestSuite_print(str);
-               
-                       context->expectedExitCode = INVALID_EXIT_CODE;
-               }
-
-        if(!__success)
-        {
-            setErrno(E_EXIT_CODE_DONT_MATCH);
-            return getErrno();
-        }
+  bool __success = false;
+  char str[256] = { 0 };
+
+  sprintf(str, "<TEST CASE TERMINATED        >      %s %3ld\n",
+          context->name, context->exitCode);
+  TestSuite_print(str);
+
+  memset(str, 0, 256);
 
-        return E_SUCCESS;
+  /* if a expected exit code was signaled, compare it with the real. */
+  if (context->expectedExitCode != INVALID_EXIT_CODE) {
+    if (context->expectedExitCode != context->exitCode) {
+
+      TestSuite_print("<EXIT CODE DON'T MATCH       >\n");
+    } else {
+      __success = true;
+      TestSuite_print("<EXIT CODE MATCH             >\n");
+    }
+    sprintf(str, "<EXIT CODE EXPECTED          >      (%3d)\n",
+            context->expectedExitCode);
+    TestSuite_print(str);
+
+    memset(str, 0, 256);
+
+    sprintf(str, "<EXIT CODE RETURNED          >      (%3d)\n",
+            context->exitCode);
+    TestSuite_print(str);
+
+    context->expectedExitCode = INVALID_EXIT_CODE;
+  }
+
+  if (!__success) {
+    setErrno(E_EXIT_CODE_DONT_MATCH);
+    return getErrno();
+  }
+
+  return E_SUCCESS;
 }
 
 /* 
@@ -607,453 +607,474 @@ errno_t TestSuite_checkChildExitCode(TestCaseContext_t context)
  */
 void TestSuite_terminate(TestSuite_t testSuite)
 {
-       TestCaseContext_t context = testSuite->test_case_context;
-       
-       /* cleanup the child_input_stream/output buffers.       */
-       if(NULL != context->inputBuffer)
-               Buffer_free(context->inputBuffer);
-       
-       if(NULL != context->outputBuffer)
-               Buffer_free(context->outputBuffer);
-               
-       if(NULL != context->expectedOutputBuffer)
-               Buffer_free(context->expectedOutputBuffer);
-               
-       /* close the file stream.                               */
-       if(NULL != testSuite->stream)
-               Stream_free(testSuite->stream);
-       
-       
+  TestCaseContext_t context = testSuite->test_case_context;
+
+  /* cleanup the child_input_stream/output buffers.       */
+  if (NULL != context->inputBuffer)
+    Buffer_free(context->inputBuffer);
+
+  if (NULL != context->outputBuffer)
+    Buffer_free(context->outputBuffer);
+
+  if (NULL != context->expectedOutputBuffer)
+    Buffer_free(context->expectedOutputBuffer);
+
+  /* close the file stream.                               */
+  if (NULL != testSuite->stream)
+    Stream_free(testSuite->stream);
+
+
 }
 
 
 /*
  * Print message
  */
-void TestSuite_print(const charstr)
+void TestSuite_print(const char *str)
 {
-     char* t = (char*)calloc(1,20);
-     
-    __time(t);
+  char *t = (char *) calloc(1, 20);
 
-       EnterCriticalSection(&cs);
-    printf("%s   %s",t,str);
-    LeaveCriticalSection(&cs);
+  __time(t);
 
-    free(t);
+  EnterCriticalSection(&cs);
+  printf("%s   %s", t, str);
+  LeaveCriticalSection(&cs);
+
+  free(t);
 
 }
 
-unsigned long WINAPI TestSuite_asyncReadChildOutput(voidparam)
+unsigned long WINAPI TestSuite_asyncReadChildOutput(void *param)
 {
-  char str[1024] = {0};
-  char __buffer[1024] = {0};
-  
+  char str[1024] = { 0 };
+  char __buffer[1024] = { 0 };
+
   DWORD nBytesRead;
   DWORD nCharsWritten;
-  TestCaseContext_t context = (TestCaseContext_t)param;
+  TestCaseContext_t context = (TestCaseContext_t) param;
   HANDLE hPipeRead = context->hOutputRead;
 
-  while (context->runThread)
-  {
-     if (!ReadFile(hPipeRead,str,sizeof(str),&nBytesRead,NULL) || !nBytesRead){
-        if (GetLastError() == ERROR_BROKEN_PIPE){
-           break;
-        }
-        else{
-                /* TODO */
-                context->threadExitCode = 1;
-                exit(1);
-        }
-     }
-     
-     if(nBytesRead){
-       if(context->isOutputCheckingEnabled){
-            if(!Buffer_empty(context->outputBuffer))
-                Buffer_clear(context->outputBuffer);
 
-                TestSuite_print(str);
+  while (context->runThread) {
+    if (!ReadFile(hPipeRead, str, sizeof(str), &nBytesRead, NULL)
+        || !nBytesRead) {
+      if (GetLastError() == ERROR_BROKEN_PIPE) {
+        break;
+      } else {
+        /* TODO */
+        context->threadExitCode = 1;
+        exit(1);
+      }
+    }
+
+    if (nBytesRead) {
+      if (context->isOutputCheckingEnabled) {
+        if (!Buffer_empty(context->outputBuffer))
+          Buffer_clear(context->outputBuffer);
+
+        TestSuite_print(str);
+
 
+        Buffer_append(context->outputBuffer, str);
+      }
 
-            Buffer_append(context->outputBuffer,str);
-       }
-        
-        memset(str,0,1024);
-        memset(__buffer,0,1024);
+      memset(str, 0, 1024);
+      memset(__buffer, 0, 1024);
     }
-     
+
   }
-       context->threadExitCode = 0;
-       return 0;
+  context->threadExitCode = 0;
+  return 0;
 }
 
 errno_t TestSuite_runAsyncTestCase(TestSuite_t testSuite)
 {
-    DWORD ThreadId;
-    s_ThreadEntry_t entry;
-    /* = (ThreadEntry_t)calloc(1,sizeof(s_ThreadEntry_t));*/
-
-    TestCaseContext_t context = testSuite->test_case_context;
-    memset(&entry,0,sizeof(s_ThreadEntry_t));
-    entry.context = TestCaseContext_new();
-
-    Buffer_append(entry.context->inputBuffer,context->inputBuffer->data);
-    Buffer_append(entry.context->outputBuffer,context->outputBuffer->data);
-    Buffer_append(entry.context->expectedOutputBuffer,context->expectedOutputBuffer->data);
-    Buffer_append(entry.context->commandLineBuffer,context->commandLineBuffer->data);
-    entry.context->name = strdup(context->name);
-    entry.context->timeoutValue = context->timeoutValue;
-    entry.context->isOutputCheckingEnabled = context->isOutputCheckingEnabled;
-    entry.context->isPostOutputCheckingEnabled = context->isPostOutputCheckingEnabled;
-    entry.context->expectedExitCode = context->expectedExitCode;
-    entry.context->createConsole = context->createConsole;
-    entry.context->exitCodeCheckingEnabled = context->exitCodeCheckingEnabled;
-    entry.context->hConsole = context->hConsole;
-    Buffer_clear(context->inputBuffer);
-    Buffer_clear(context->outputBuffer);
-    Buffer_clear(context->expectedOutputBuffer);
-    memset(&(entry.context->pi),0,sizeof(PROCESS_INFORMATION));
-    entry.context->runThread = true;
-
-    entry.hThread = CreateThread(NULL,0,TestSuite_runSyncTestCase,(LPVOID)entry.context,CREATE_SUSPENDED,&ThreadId);
-    entry.threadId = ThreadId;
-    ThreadDynarray_pushBack(testSuite->threads,&entry);
-    ResumeThread(entry.hThread);
-    Sleep(0);
-    setErrno(E_SUCCESS);
-
-    return getErrno();
+  DWORD ThreadId;
+  s_ThreadEntry_t entry;
+  /* = (ThreadEntry_t)calloc(1,sizeof(s_ThreadEntry_t)); */
+
+  TestCaseContext_t context = testSuite->test_case_context;
+  memset(&entry, 0, sizeof(s_ThreadEntry_t));
+  entry.context = TestCaseContext_new();
+
+  Buffer_append(entry.context->inputBuffer, context->inputBuffer->data);
+  Buffer_append(entry.context->outputBuffer, context->outputBuffer->data);
+  Buffer_append(entry.context->expectedOutputBuffer,
+                context->expectedOutputBuffer->data);
+  Buffer_append(entry.context->commandLineBuffer,
+                context->commandLineBuffer->data);
+  entry.context->name = strdup(context->name);
+  entry.context->timeoutValue = context->timeoutValue;
+  entry.context->isOutputCheckingEnabled =
+      context->isOutputCheckingEnabled;
+  entry.context->isPostOutputCheckingEnabled =
+      context->isPostOutputCheckingEnabled;
+  entry.context->expectedExitCode = context->expectedExitCode;
+  entry.context->createConsole = context->createConsole;
+  entry.context->exitCodeCheckingEnabled =
+      context->exitCodeCheckingEnabled;
+  entry.context->hConsole = context->hConsole;
+  Buffer_clear(context->inputBuffer);
+  Buffer_clear(context->outputBuffer);
+  Buffer_clear(context->expectedOutputBuffer);
+  memset(&(entry.context->pi), 0, sizeof(PROCESS_INFORMATION));
+  entry.context->runThread = true;
+
+  entry.hThread =
+      CreateThread(NULL, 0, TestSuite_runSyncTestCase,
+                   (LPVOID) entry.context, CREATE_SUSPENDED, &ThreadId);
+  entry.threadId = ThreadId;
+  ThreadDynarray_pushBack(testSuite->threads, &entry);
+  ResumeThread(entry.hThread);
+  Sleep(0);
+  setErrno(E_SUCCESS);
+
+  return getErrno();
 }
 
-unsigned long WINAPI TestSuite_runSyncTestCase( void* param)
+unsigned long WINAPI TestSuite_runSyncTestCase(void *param)
 {
-    STARTUPINFO si = {0};
-    SECURITY_ATTRIBUTES sa = {0};
-       DWORD dwWaitResult = 0;
-       DWORD dwExitCode = 0;
-       DWORD ThreadId;
-       DWORD nBytes = 0;
-    DWORD dwCreationMode = CREATE_NO_WINDOW;
-    char cmdLine[4098] = {0};
-
-    TestCaseContext_t context = (TestCaseContext_t)param;
-    context->started = true;
-       
-       
-       sa.nLength = sizeof(SECURITY_ATTRIBUTES);
-    sa.lpSecurityDescriptor = NULL;
-       /* The pipe handes can be inherited by the child. */
-       sa.bInheritHandle = TRUE;
-       
-       /* Create a write pipe handle for the child std output */
-       if(!CreatePipe(&(context->hChildStdoutReadTmp),&(context->hChildStdOutWrite),&sa,0))
-    {
-        setErrno(E_CANNOT_CREATE_CHILD_STDOUT_READ_HANDLE);
-               return getErrno();
-    }
-       
-       /* 
-        * Create a duplicate of the output write handle for the std error
-        * write handle. This is necessary in case the child application closes
-        * one of its std output handles.
-        */
-       if(!DuplicateHandle(GetCurrentProcess(),(context->hChildStdOutWrite),GetCurrentProcess(),&(context->hChildStderr),0,TRUE,DUPLICATE_SAME_ACCESS))
-    {
-        setErrno(E_CANNOT_CREATE_CHILD_STDERR_READ_HANDLE);
-               return getErrno();
-    }
-       
-       /* Create a read pipe handle for the child std input */
-       if(!CreatePipe(&(context->hChildStdInRead),&(context->hChildStdinWriteTmp),&sa,0))
-    {
-        setErrno(E_CANNOT_CREATE_CHILD_STDIN_WRITE_HANDLE);
-               return getErrno();
-    }
-               
-       
-       /* Create new output read handle and the input write handle use by 
-        * the parent process to communicate with his child. Set the Properties  
-        * to FALSE. Otherwise, the child inherits the properties and, as a 
-        * result, non-closeable  handles to the pipes are created. 
-        */
-       
-       /* Read handle for read operations on the child std output. */
-       if(!DuplicateHandle(GetCurrentProcess(),(context->hChildStdoutReadTmp),GetCurrentProcess(),&(context->hOutputRead),0,FALSE, DUPLICATE_SAME_ACCESS))
-    {
-        setErrno(E_CANNOT_CREATE_STDOUT_READ_HANDLE);
-               return getErrno();
-    }
-       
-       
-       /* Write handle for write operations on the child std input. */
-       if(!DuplicateHandle(GetCurrentProcess(),(context->hChildStdinWriteTmp),GetCurrentProcess(),&(context->hInputWrite), 0,FALSE,DUPLICATE_SAME_ACCESS))
-    {
-        setErrno(E_CANNOT_CREATE_STDIN_WRITE_HANDLE);
-               return getErrno();
-    }
-       
-       
-       /* Close inheritable copies of the handles you do not want to be inherited. */
-       if(!CloseHandle((context->hChildStdoutReadTmp)))
-    {
-        setErrno(E_CANNOT_CLOSE_CHILD_STDIN_TEMPORY_HANDLE);
-               return getErrno();
-    }
+  STARTUPINFO si = { 0 };
+  SECURITY_ATTRIBUTES sa = { 0 };
+  DWORD dwWaitResult = 0;
+  DWORD dwExitCode = 0;
+  DWORD ThreadId;
+  DWORD nBytes = 0;
+  DWORD dwCreationMode = CREATE_NO_WINDOW;
+  char cmdLine[4098] = { 0 };
+
+  TestCaseContext_t context = (TestCaseContext_t) param;
+  context->started = true;
+
+
+  sa.nLength = sizeof(SECURITY_ATTRIBUTES);
+  sa.lpSecurityDescriptor = NULL;
+  /* The pipe handes can be inherited by the child. */
+  sa.bInheritHandle = TRUE;
+
+  /* Create a write pipe handle for the child std output */
+  if (!CreatePipe
+      (&(context->hChildStdoutReadTmp), &(context->hChildStdOutWrite), &sa,
+       0)) {
+    setErrno(E_CANNOT_CREATE_CHILD_STDOUT_READ_HANDLE);
+    return getErrno();
+  }
 
-       context->hChildStdoutReadTmp = NULL;
-       
-       if(!CloseHandle((context->hChildStdinWriteTmp)))
-    {
-        setErrno(E_CANNOT_CLOSE_CHILD_STDOUT_TEMPORY_HANDLE);
-               return getErrno();
-    }
-       
-       
-       context->hChildStdinWriteTmp = NULL;
-
-    si.cb = sizeof(STARTUPINFO);
-       /* Set the child std handles. */
-       si.dwFlags = STARTF_USESTDHANDLES;
-       si.hStdOutput = context->hChildStdOutWrite;
-       si.hStdInput  = context->hChildStdInRead;
-       si.hStdError  = context->hChildStderr;
-
-    if(context->createConsole)
-        dwCreationMode = CREATE_NEW_CONSOLE;
-
-    if(!Buffer_empty(context->commandLineBuffer)){
-        Buffer_chomp(context->commandLineBuffer);
-        sprintf(cmdLine,"%s %s",context->name,context->commandLineBuffer->data);
-    }
-    else
-        strcpy(cmdLine,context->name);
+  /* 
+   * Create a duplicate of the output write handle for the std error
+   * write handle. This is necessary in case the child application closes
+   * one of its std output handles.
+   */
+  if (!DuplicateHandle
+      (GetCurrentProcess(), (context->hChildStdOutWrite),
+       GetCurrentProcess(), &(context->hChildStderr), 0, TRUE,
+       DUPLICATE_SAME_ACCESS)) {
+    setErrno(E_CANNOT_CREATE_CHILD_STDERR_READ_HANDLE);
+    return getErrno();
+  }
 
+  /* Create a read pipe handle for the child std input */
+  if (!CreatePipe
+      (&(context->hChildStdInRead), &(context->hChildStdinWriteTmp), &sa,
+       0)) {
+    setErrno(E_CANNOT_CREATE_CHILD_STDIN_WRITE_HANDLE);
+    return getErrno();
+  }
 
-    /* Create the child process. */
-    if(!CreateProcess(NULL,cmdLine,NULL,NULL,TRUE,dwCreationMode,NULL,NULL,&si,&(context->pi))){
-        setErrno(E_CANNOT_CREATE_CHILD_PROCESS);
-        return getErrno();
-    }
-    
-    if(!CloseHandle(context->pi.hThread)){
-        setErrno(E_CANNOT_CLOSE_PROCESS_THREAD_HANDLE);
-       return getErrno();
-    }
-    
-       
-       context->pi.hThread = NULL;
-       
-       /* close unnessary pipe handles. */
-       if(!CloseHandle(context->hChildStdOutWrite)){
-        setErrno(E_CANNOT_CLOSE_CHILD_STDOUT_HANDLE);
-       return getErrno();
-    }
-    
-    context->hChildStdOutWrite = NULL;
-    
-    if(!CloseHandle(context->hChildStdInRead)){
-        setErrno(E_CANNOT_CLOSE_CHILD_STDIN_HANDLE);
-       return getErrno();
-    }
 
-    context->hChildStdInRead = NULL;
+  /* Create new output read handle and the input write handle use by 
+   * the parent process to communicate with his child. Set the Properties  
+   * to FALSE. Otherwise, the child inherits the properties and, as a 
+   * result, non-closeable  handles to the pipes are created. 
+   */
 
-    if(!CloseHandle(context->hChildStderr)){
-        setErrno(E_CANNOT_CLOSE_CHILD_STDERR_HANDLE);
-       return getErrno();
-    }
+  /* Read handle for read operations on the child std output. */
+  if (!DuplicateHandle
+      (GetCurrentProcess(), (context->hChildStdoutReadTmp),
+       GetCurrentProcess(), &(context->hOutputRead), 0, FALSE,
+       DUPLICATE_SAME_ACCESS)) {
+    setErrno(E_CANNOT_CREATE_STDOUT_READ_HANDLE);
+    return getErrno();
+  }
 
-    context->hChildStderr = NULL;
 
-    if(!Buffer_empty(context->inputBuffer)){
-               if(!WriteFile(context->hInputWrite,context->inputBuffer->data,context->inputBuffer->size,&nBytes,NULL)){
-            setErrno(E_CANNOT_WRITE_ON_CHILD_STDIN);
-               return getErrno();
-        }
-       }
-    
-    context->hThread = CreateThread(&sa,0,TestSuite_asyncReadChildOutput,(LPVOID)context,0,&ThreadId);
-    Sleep(0);
-    
-    if(NULL == context->hThread){
-        setErrno(E_CANNOT_CREATE_READ_CHILD_OUTPUT_THREAD);
-       return getErrno();
-    }
-    
+  /* Write handle for write operations on the child std input. */
+  if (!DuplicateHandle
+      (GetCurrentProcess(), (context->hChildStdinWriteTmp),
+       GetCurrentProcess(), &(context->hInputWrite), 0, FALSE,
+       DUPLICATE_SAME_ACCESS)) {
+    setErrno(E_CANNOT_CREATE_STDIN_WRITE_HANDLE);
+    return getErrno();
+  }
 
-    dwWaitResult = WaitForSingleObject(context->pi.hProcess,context->timeoutValue);
 
-    if(WAIT_FAILED == dwWaitResult)
-    {
-            TerminateProcess(context->pi.hProcess,0);
-            context->pi.hProcess = NULL;
-            context->runThread = false;
+  /* Close inheritable copies of the handles you do not want to be inherited. */
+  if (!CloseHandle((context->hChildStdoutReadTmp))) {
+    setErrno(E_CANNOT_CLOSE_CHILD_STDIN_TEMPORY_HANDLE);
+    return getErrno();
+  }
 
-            if(WAIT_FAILED == WaitForSingleObject(context->hThread,INFINITE)){
-                setErrno(E_WAIT_THREAD_FAILED);
-               return getErrno();
-            }
+  context->hChildStdoutReadTmp = NULL;
 
-            if(!CloseHandle(context->hThread)){
-                setErrno(E_CANNOT_CLOSE_THREAD_HANDLE);
-               return getErrno();
-            }
+  if (!CloseHandle((context->hChildStdinWriteTmp))) {
+    setErrno(E_CANNOT_CLOSE_CHILD_STDOUT_TEMPORY_HANDLE);
+    return getErrno();
+  }
 
-            context->hThread = NULL;
 
-            if(!CloseHandle(context->hOutputRead)){
-                setErrno(E_CANNOT_CLOSE_READ_HANDLE);
-               return getErrno();
-            }
+  context->hChildStdinWriteTmp = NULL;
 
-            context->hOutputRead = NULL;
+  si.cb = sizeof(STARTUPINFO);
+  /* Set the child std handles. */
+  si.dwFlags = STARTF_USESTDHANDLES;
+  si.hStdOutput = context->hChildStdOutWrite;
+  si.hStdInput = context->hChildStdInRead;
+  si.hStdError = context->hChildStderr;
 
-            if(!CloseHandle(context->hInputWrite)){
-                setErrno(E_CANNOT_CLOSE_WRITE_HANDLE);
-               return getErrno();
-            }
+  if (context->createConsole)
+    dwCreationMode = CREATE_NEW_CONSOLE;
 
-            context->hInputWrite = NULL;
-            setErrno(E_WAIT_FAILURE);
-            return getErrno();
-    }
+  if (!Buffer_empty(context->commandLineBuffer)) {
+    Buffer_chomp(context->commandLineBuffer);
+    sprintf(cmdLine, "%s %s", context->name,
+            context->commandLineBuffer->data);
+  } else
+    strcpy(cmdLine, context->name);
 
-    if(WAIT_TIMEOUT == dwWaitResult)
-    {
-            TerminateProcess(context->pi.hProcess,0);
-            context->pi.hProcess = NULL;
-            context->runThread = false;
 
-            if(WAIT_FAILED == WaitForSingleObject(context->hThread,INFINITE)){
-                setErrno(E_WAIT_THREAD_FAILED);
-               return getErrno();
-            }
+  /* Create the child process. */
+  if (!CreateProcess
+      (NULL, cmdLine, NULL, NULL, TRUE, dwCreationMode, NULL, NULL, &si,
+       &(context->pi))) {
+    setErrno(E_CANNOT_CREATE_CHILD_PROCESS);
+    return getErrno();
+  }
+
+  if (!CloseHandle(context->pi.hThread)) {
+    setErrno(E_CANNOT_CLOSE_PROCESS_THREAD_HANDLE);
+    return getErrno();
+  }
+
 
-            if(!CloseHandle(context->hThread)){
-                setErrno(E_CANNOT_CLOSE_THREAD_HANDLE);
-               return getErrno();
-            }
+  context->pi.hThread = NULL;
+
+  /* close unnessary pipe handles. */
+  if (!CloseHandle(context->hChildStdOutWrite)) {
+    setErrno(E_CANNOT_CLOSE_CHILD_STDOUT_HANDLE);
+    return getErrno();
+  }
 
-            context->hThread = NULL;
+  context->hChildStdOutWrite = NULL;
 
-            if(!CloseHandle(context->hOutputRead)){
-                setErrno(E_CANNOT_CLOSE_READ_HANDLE);
-               return getErrno();
-            }
+  if (!CloseHandle(context->hChildStdInRead)) {
+    setErrno(E_CANNOT_CLOSE_CHILD_STDIN_HANDLE);
+    return getErrno();
+  }
 
+  context->hChildStdInRead = NULL;
 
-            context->hOutputRead = NULL;
+  if (!CloseHandle(context->hChildStderr)) {
+    setErrno(E_CANNOT_CLOSE_CHILD_STDERR_HANDLE);
+    return getErrno();
+  }
 
-            if(!CloseHandle(context->hInputWrite)){
-                setErrno(E_CANNOT_CLOSE_WRITE_HANDLE);
-               return getErrno();
-            }
+  context->hChildStderr = NULL;
 
-            context->hInputWrite = NULL;
-            setErrno(E_WAIT_TIMEOUT);
-            return getErrno();
+  if (!Buffer_empty(context->inputBuffer)) {
+    if (!WriteFile
+        (context->hInputWrite, context->inputBuffer->data,
+         context->inputBuffer->size, &nBytes, NULL)) {
+      setErrno(E_CANNOT_WRITE_ON_CHILD_STDIN);
+      return getErrno();
     }
+  }
+
+  context->hThread =
+      CreateThread(&sa, 0, TestSuite_asyncReadChildOutput,
+                   (LPVOID) context, 0, &ThreadId);
+  Sleep(0);
+
+  if (NULL == context->hThread) {
+    setErrno(E_CANNOT_CREATE_READ_CHILD_OUTPUT_THREAD);
+    return getErrno();
+  }
+
 
-    /* all is ok . */
+  dwWaitResult =
+      WaitForSingleObject(context->pi.hProcess, context->timeoutValue);
 
+  if (WAIT_FAILED == dwWaitResult) {
+    TerminateProcess(context->pi.hProcess, 0);
+    context->pi.hProcess = NULL;
     context->runThread = false;
 
-    if(WAIT_FAILED == WaitForSingleObject(context->hThread,INFINITE)){
-        setErrno(E_WAIT_THREAD_FAILED);
-       return getErrno();
+    if (WAIT_FAILED == WaitForSingleObject(context->hThread, INFINITE)) {
+      setErrno(E_WAIT_THREAD_FAILED);
+      return getErrno();
     }
 
-    if(!CloseHandle(context->hThread)){
-        setErrno(E_CANNOT_CLOSE_THREAD_HANDLE);
-       return getErrno();
+    if (!CloseHandle(context->hThread)) {
+      setErrno(E_CANNOT_CLOSE_THREAD_HANDLE);
+      return getErrno();
     }
 
     context->hThread = NULL;
 
-    if(!CloseHandle(context->hOutputRead)){
-        setErrno(E_CANNOT_CLOSE_READ_HANDLE);
-       return getErrno();
+    if (!CloseHandle(context->hOutputRead)) {
+      setErrno(E_CANNOT_CLOSE_READ_HANDLE);
+      return getErrno();
     }
 
     context->hOutputRead = NULL;
 
-    if(!CloseHandle(context->hInputWrite)){
-        setErrno(E_CANNOT_CLOSE_WRITE_HANDLE);
-        return getErrno();
+    if (!CloseHandle(context->hInputWrite)) {
+      setErrno(E_CANNOT_CLOSE_WRITE_HANDLE);
+      return getErrno();
     }
 
     context->hInputWrite = NULL;
-       
-
-    /* Get the child exit code before close it. */
-       GetExitCodeProcess(context->pi.hProcess,&dwExitCode);
-    
-    context->exitCode = (int)dwExitCode;
-    
-    if(!CloseHandle(context->pi.hProcess)){
-        setErrno(E_CANNOT_CLOSE_PROCESS_HANDLE);
-       return getErrno();
+    setErrno(E_WAIT_FAILURE);
+    return getErrno();
+  }
+
+  if (WAIT_TIMEOUT == dwWaitResult) {
+    TerminateProcess(context->pi.hProcess, 0);
+    context->pi.hProcess = NULL;
+    context->runThread = false;
+
+    if (WAIT_FAILED == WaitForSingleObject(context->hThread, INFINITE)) {
+      setErrno(E_WAIT_THREAD_FAILED);
+      return getErrno();
     }
 
-    context->runThread = true;
+    if (!CloseHandle(context->hThread)) {
+      setErrno(E_CANNOT_CLOSE_THREAD_HANDLE);
+      return getErrno();
+    }
 
-     if(TestSuite_iSPostOutputCheckingEnabled(context)){
-        if (context->expectedOutputBuffer->size !=0 || context->outputBuffer->size !=0){
-            Buffer_chomp(context->outputBuffer);
-            Buffer_chomp(context->expectedOutputBuffer);
+    context->hThread = NULL;
 
-            if (context->outputBuffer->size != context->expectedOutputBuffer->size || strcmp(context->outputBuffer->data, context->expectedOutputBuffer->data)){
-                setErrno(E_OUTPUT_DONT_MATCH);
-            }
-        }
-     }
+    if (!CloseHandle(context->hOutputRead)) {
+      setErrno(E_CANNOT_CLOSE_READ_HANDLE);
+      return getErrno();
+    }
 
-     if(TestSuite_iSExitCodeCheckingEnabled(context)){
-        if(context->expectedExitCode != INVALID_EXIT_CODE){
-                       if(context->expectedExitCode  != context->exitCode ){
-                               setErrno(E_EXIT_CODE_DONT_MATCH);
-                       }
-        }
-     }
-    
-    context->pi.hProcess = NULL;
-       return getErrno();
+
+    context->hOutputRead = NULL;
+
+    if (!CloseHandle(context->hInputWrite)) {
+      setErrno(E_CANNOT_CLOSE_WRITE_HANDLE);
+      return getErrno();
+    }
+
+    context->hInputWrite = NULL;
+    setErrno(E_WAIT_TIMEOUT);
+    return getErrno();
+  }
+
+  /* all is ok . */
+
+  context->runThread = false;
+
+  if (WAIT_FAILED == WaitForSingleObject(context->hThread, INFINITE)) {
+    setErrno(E_WAIT_THREAD_FAILED);
+    return getErrno();
+  }
+
+  if (!CloseHandle(context->hThread)) {
+    setErrno(E_CANNOT_CLOSE_THREAD_HANDLE);
+    return getErrno();
+  }
+
+  context->hThread = NULL;
+
+  if (!CloseHandle(context->hOutputRead)) {
+    setErrno(E_CANNOT_CLOSE_READ_HANDLE);
+    return getErrno();
+  }
+
+  context->hOutputRead = NULL;
+
+  if (!CloseHandle(context->hInputWrite)) {
+    setErrno(E_CANNOT_CLOSE_WRITE_HANDLE);
+    return getErrno();
+  }
+
+  context->hInputWrite = NULL;
+
+
+  /* Get the child exit code before close it. */
+  GetExitCodeProcess(context->pi.hProcess, &dwExitCode);
+
+  context->exitCode = (int) dwExitCode;
+
+  if (!CloseHandle(context->pi.hProcess)) {
+    setErrno(E_CANNOT_CLOSE_PROCESS_HANDLE);
+    return getErrno();
+  }
+
+  context->runThread = true;
+
+  if (TestSuite_iSPostOutputCheckingEnabled(context)) {
+    if (context->expectedOutputBuffer->size != 0
+        || context->outputBuffer->size != 0) {
+      Buffer_chomp(context->outputBuffer);
+      Buffer_chomp(context->expectedOutputBuffer);
+
+      if (context->outputBuffer->size !=
+          context->expectedOutputBuffer->size
+          || strcmp(context->outputBuffer->data,
+                    context->expectedOutputBuffer->data)) {
+        setErrno(E_OUTPUT_DONT_MATCH);
+      }
+    }
+  }
+
+  if (TestSuite_iSExitCodeCheckingEnabled(context)) {
+    if (context->expectedExitCode != INVALID_EXIT_CODE) {
+      if (context->expectedExitCode != context->exitCode) {
+        setErrno(E_EXIT_CODE_DONT_MATCH);
+      }
+    }
+  }
+
+  context->pi.hProcess = NULL;
+  return getErrno();
 }
 
 bool TestSuite_iSPostOutputCheckingEnabled(TestCaseContext_t context)
 {
-    if(!context->isPostOutputCheckingEnabled && context->isOutputCheckingEnabled){
-                       return true;
-    }
+  if (!context->isPostOutputCheckingEnabled
+      && context->isOutputCheckingEnabled) {
+    return true;
+  }
 
-    return false;
+  return false;
 }
 
 bool TestSuite_iSExitCodeCheckingEnabled(TestCaseContext_t context)
 {
-    return context->exitCodeCheckingEnabled;
+  return context->exitCodeCheckingEnabled;
 }
 
 errno_t TestSuite_changeDir(TestSuite_t testSuite)
 {
-    char* line = testSuite->stream->line + 5;
-    size_t size = strlen(line);
-
-    while ((line[size-1] == '\n') || (line[size-1] == '\r')){
-               line[size-1] = '\0';
-               
-               if(size)
-                       (size)--;
-       }
-
-    if(!SetCurrentDirectory(line)){
-        setErrno(E_CHANGE_DIRECTORY_FAILED);
-        return E_CHANGE_DIRECTORY_FAILED;
-    }
+  char *line = testSuite->stream->line + 5;
+  size_t size = strlen(line);
 
-    Stream_printLine(testSuite->stream,change_directory_line_type);
+  while ((line[size - 1] == '\n') || (line[size - 1] == '\r')) {
+    line[size - 1] = '\0';
 
-    return E_SUCCESS;
-}
+    if (size)
+      (size)--;
+  }
 
+  if (!SetCurrentDirectory(line)) {
+    setErrno(E_CHANGE_DIRECTORY_FAILED);
+    return E_CHANGE_DIRECTORY_FAILED;
+  }
+
+  Stream_printLine(testSuite->stream, change_directory_line_type);
+
+  return E_SUCCESS;
+}
index 7c51b40..73f7543 100644 (file)
@@ -6,21 +6,22 @@
  */
 ThreadDynarray_t ThreadDynarray_new(unsigned long capacity)
 {
-       ThreadDynarray_t ptr = calloc(1,sizeof(s_ThreadDynarray_t));
+  ThreadDynarray_t ptr = calloc(1, sizeof(s_ThreadDynarray_t));
 
-       ptr->count = 0;
-       ptr->capacity = capacity;
-       
-       memset(&(ptr->cs),0,sizeof(CRITICAL_SECTION)) ;
-       InitializeCriticalSection(&(ptr->cs));
-       ptr->is_locked = false;
+  ptr->count = 0;
+  ptr->capacity = capacity;
 
-       if(capacity)
-               ptr->threads = (ThreadEntry_t)calloc(capacity,sizeof(s_ThreadEntry_t));
-    else
-               ptr->threads = NULL;
+  memset(&(ptr->cs), 0, sizeof(CRITICAL_SECTION));
+  InitializeCriticalSection(&(ptr->cs));
+  ptr->is_locked = false;
 
-       return ptr;
+  if (capacity)
+    ptr->threads =
+        (ThreadEntry_t) calloc(capacity, sizeof(s_ThreadEntry_t));
+  else
+    ptr->threads = NULL;
+
+  return ptr;
 }
 
 /* 
@@ -28,45 +29,49 @@ ThreadDynarray_t ThreadDynarray_new(unsigned long capacity)
  */
 void ThreadDynarray_destroy(ThreadDynarray_t ptr)
 {
-       ThreadDynarray_clear(ptr);      
-       DeleteCriticalSection(&(ptr->cs));
-       free(ptr);
-       ptr = NULL;             
+  ThreadDynarray_clear(ptr);
+  DeleteCriticalSection(&(ptr->cs));
+  free(ptr);
+  ptr = NULL;
 }
 
 /*
  * Returns an const pointer to entry pointed to by index.
  */
-ThreadEntry_t const ThreadDynarray_at(ThreadDynarray_t ptr, unsigned long index)
+ThreadEntry_t const ThreadDynarray_at(ThreadDynarray_t ptr,
+                                      unsigned long index)
 {
-        ThreadEntry_t __entry;
-        ThreadDynarray_lock(ptr);
-        __entry = &(ptr->threads)[index];
-        ThreadDynarray_unlock(ptr);
-        return __entry;
+  ThreadEntry_t __entry;
+  ThreadDynarray_lock(ptr);
+  __entry = &(ptr->threads)[index];
+  ThreadDynarray_unlock(ptr);
+  return __entry;
 }
 
 /*
  * Fill the content of the entry addressed by __entry with the content
  * of the entry pointed to by index.
  */
-void ThreadDynarray_get(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t const __entry)
+void ThreadDynarray_get(ThreadDynarray_t ptr, unsigned long index,
+                        ThreadEntry_t const __entry)
 {
-        ThreadDynarray_lock(ptr);
-    ::memcpy(__entry,ThreadDynarray_at(ptr,index),sizeof(s_ThreadEntry_t));
-     ThreadDynarray_unlock(ptr);
+  ThreadDynarray_lock(ptr);
+  ::memcpy(__entry, ThreadDynarray_at(ptr, index),
+           sizeof(s_ThreadEntry_t));
+  ThreadDynarray_unlock(ptr);
 }
 
 /* 
  * Fill the content of the entry pointed to by index with the content of
  * the entry addressed by __entry.
  */
-void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t const __entry)
+void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index,
+                        ThreadEntry_t const __entry)
 {
 
-        ThreadDynarray_lock(ptr);
-        memcpy(ThreadDynarray_at(ptr,index),__entry,sizeof(s_ThreadEntry_t));
-        ThreadDynarray_unlock(ptr);
+  ThreadDynarray_lock(ptr);
+  memcpy(ThreadDynarray_at(ptr, index), __entry, sizeof(s_ThreadEntry_t));
+  ThreadDynarray_unlock(ptr);
 }
 
 /*
@@ -74,11 +79,11 @@ void ThreadDynarray_set(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t
  */
 ThreadEntry_t const ThreadDynarray_getFront(ThreadDynarray_t ptr)
 {
-       ThreadEntry_t __entry;
-       ThreadDynarray_lock(ptr);
-       __entry = ThreadDynarray_at(ptr,0);
-       ThreadDynarray_unlock(ptr);
-       return __entry;
+  ThreadEntry_t __entry;
+  ThreadDynarray_lock(ptr);
+  __entry = ThreadDynarray_at(ptr, 0);
+  ThreadDynarray_unlock(ptr);
+  return __entry;
 }
 
 /*
@@ -86,82 +91,87 @@ ThreadEntry_t const ThreadDynarray_getFront(ThreadDynarray_t ptr)
  */
 ThreadEntry_t const ThreadDynarray_getBack(ThreadDynarray_t ptr)
 {
-       ThreadEntry_t __entry;
-       ThreadDynarray_lock(ptr);
-       __entry = ThreadDynarray_at(ptr,ptr->count - 1);;
-       ThreadDynarray_unlock(ptr);
-       return __entry;
+  ThreadEntry_t __entry;
+  ThreadDynarray_lock(ptr);
+  __entry = ThreadDynarray_at(ptr, ptr->count - 1);;
+  ThreadDynarray_unlock(ptr);
+  return __entry;
 }
 
 /*
  * Inserts a copy of __entry at the front
  */
-void ThreadDynarray_pushFront(ThreadDynarray_t ptr, ThreadEntry_t const __entry)
+void ThreadDynarray_pushFront(ThreadDynarray_t ptr,
+                              ThreadEntry_t const __entry)
 {
-       ThreadDynarray_lock(ptr);
+  ThreadDynarray_lock(ptr);
+
+  if (!ThreadDynarray_getCapacityAvailable(ptr))
+    ThreadDynarray_resize(ptr);
 
-       if(!ThreadDynarray_getCapacityAvailable(ptr))
-               ThreadDynarray_resize(ptr);
-       
-       ptr->count++;
-       ThreadDynarray_move(ptr,1,ThreadDynarray_getLowerBound(ptr),ThreadDynarray_getUpperBound(ptr));
-       ThreadDynarray_set(ptr,ThreadDynarray_getLowerBound(ptr),__entry);
+  ptr->count++;
+  ThreadDynarray_move(ptr, 1, ThreadDynarray_getLowerBound(ptr),
+                      ThreadDynarray_getUpperBound(ptr));
+  ThreadDynarray_set(ptr, ThreadDynarray_getLowerBound(ptr), __entry);
 
-       ThreadDynarray_unlock(ptr);
+  ThreadDynarray_unlock(ptr);
 }
 
 /*
  * Appends a copy of __entry to the end.
  */
-void ThreadDynarray_pushBack(ThreadDynarray_t ptr, ThreadEntry_t const __entry)
+void ThreadDynarray_pushBack(ThreadDynarray_t ptr,
+                             ThreadEntry_t const __entry)
 {
-       ThreadDynarray_lock(ptr);
+  ThreadDynarray_lock(ptr);
+
+  if (!ThreadDynarray_getCapacityAvailable(ptr))
+    ThreadDynarray_resize(ptr);
 
-       if(!ThreadDynarray_getCapacityAvailable(ptr))
-               ThreadDynarray_resize(ptr);
-       
-       ptr->count++;
-       ThreadDynarray_set(ptr,ThreadDynarray_getUpperBound(ptr),__entry);
+  ptr->count++;
+  ThreadDynarray_set(ptr, ThreadDynarray_getUpperBound(ptr), __entry);
 
-       ThreadDynarray_unlock(ptr);
+  ThreadDynarray_unlock(ptr);
 }
 
 
 /* 
  * Inserts __entry at the position pointed to by index.
  */
-void ThreadDynarray_insert(ThreadDynarray_t ptr, unsigned long index, ThreadEntry_t const __entry)
+void ThreadDynarray_insert(ThreadDynarray_t ptr, unsigned long index,
+                           ThreadEntry_t const __entry)
 {
-       ThreadDynarray_lock(ptr);
+  ThreadDynarray_lock(ptr);
 
-       if(!ThreadDynarray_getCapacityAvailable(ptr))
-               ThreadDynarray_resize(ptr);
-       
-       ThreadDynarray_move(ptr,index + 1,index,ptr->count - index);
-       ptr->count++;
-       ThreadDynarray_set(ptr,index,__entry);
+  if (!ThreadDynarray_getCapacityAvailable(ptr))
+    ThreadDynarray_resize(ptr);
 
-       ThreadDynarray_unlock(ptr);
+  ThreadDynarray_move(ptr, index + 1, index, ptr->count - index);
+  ptr->count++;
+  ThreadDynarray_set(ptr, index, __entry);
+
+  ThreadDynarray_unlock(ptr);
 }
 
 /*
  * Deletes the entry pointed to by index. If __entry is not NULL the
  * fuction saves the entry threads at this address before.
  */
-void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,ThreadEntry_t const __entry)
+void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,
+                          ThreadEntry_t const __entry)
 {
-       
-       ThreadDynarray_lock(ptr);
 
-       if(__entry)
-               ThreadDynarray_set(ptr,index,__entry);
-       
-       if(index != ThreadDynarray_getUpperBound(ptr))
-               ThreadDynarray_move(ptr,index,index + 1,(ptr->count - (index + 1)));
-       
-       ptr->count--;
+  ThreadDynarray_lock(ptr);
+
+  if (__entry)
+    ThreadDynarray_set(ptr, index, __entry);
+
+  if (index != ThreadDynarray_getUpperBound(ptr))
+    ThreadDynarray_move(ptr, index, index + 1, (ptr->count - (index + 1)));
 
-       ThreadDynarray_unlock(ptr);
+  ptr->count--;
+
+  ThreadDynarray_unlock(ptr);
 }
 
 /*
@@ -169,56 +179,59 @@ void ThreadDynarray_erase(ThreadDynarray_t ptr, unsigned long index,ThreadEntry_
  * __entry.The function returns the index of the founded entry, -1 if
  * no entry is founded.
  */
-long ThreadDynarray_getIndex(ThreadDynarray_t ptr, ThreadEntry_t const __entry)
+long ThreadDynarray_getIndex(ThreadDynarray_t ptr,
+                             ThreadEntry_t const __entry)
 {
-       
-    unsigned long i ;
-       ThreadDynarray_lock(ptr);
 
-       for(i = 0; i < ptr->count; i++){
-               if(ThreadDynarray_compare(ptr,i,__entry)){
-                       ThreadDynarray_unlock(ptr);
-                       return i;
-               }
-       }
+  unsigned long i;
+  ThreadDynarray_lock(ptr);
+
+  for (i = 0; i < ptr->count; i++) {
+    if (ThreadDynarray_compare(ptr, i, __entry)) {
+      ThreadDynarray_unlock(ptr);
+      return i;
+    }
+  }
 
-       ThreadDynarray_unlock(ptr);
-       return -1;  
+  ThreadDynarray_unlock(ptr);
+  return -1;
 }
 
 /* 
  * Returns true if the entry exist.
  */
-bool ThreadDynarray_exist(ThreadDynarray_t ptr, ThreadEntry_t const __entry)
+bool ThreadDynarray_exist(ThreadDynarray_t ptr,
+                          ThreadEntry_t const __entry)
 {
-       bool exist;
-       
-       ThreadDynarray_lock(ptr);
-       exist = (-1 != ThreadDynarray_getIndex(ptr,__entry));
-       ThreadDynarray_unlock(ptr); 
-       return exist;
+  bool exist;
+
+  ThreadDynarray_lock(ptr);
+  exist = (-1 != ThreadDynarray_getIndex(ptr, __entry));
+  ThreadDynarray_unlock(ptr);
+  return exist;
 }
 
 /* Deletes the first entry with the same content of the entry addressed
  * by __entry.The function returns true if the entry is deleted, false
  * if no entry is founded.
  */
-bool ThreadDynarray_remove(ThreadDynarray_t ptr, ThreadEntry_t const __entry)
-{
-       /* assert(!empty(ptr)); */
-       
-       long __index;
-       ThreadDynarray_lock(ptr);
-       __index = ThreadDynarray_getIndex(ptr,__entry);
-       
-       if(__index == -1){
-               ThreadDynarray_unlock(ptr);
-               return false;
-       }
-       
-       ThreadDynarray_set(ptr,(unsigned long)__index,NULL);
-       ThreadDynarray_unlock(ptr);
-       return true;
+bool ThreadDynarray_remove(ThreadDynarray_t ptr,
+                           ThreadEntry_t const __entry)
+{
+  /* assert(!empty(ptr)); */
+
+  long __index;
+  ThreadDynarray_lock(ptr);
+  __index = ThreadDynarray_getIndex(ptr, __entry);
+
+  if (__index == -1) {
+    ThreadDynarray_unlock(ptr);
+    return false;
+  }
+
+  ThreadDynarray_set(ptr, (unsigned long) __index, NULL);
+  ThreadDynarray_unlock(ptr);
+  return true;
 }
 
 /*
@@ -226,16 +239,16 @@ bool ThreadDynarray_remove(ThreadDynarray_t ptr, ThreadEntry_t const __entry)
  */
 void ThreadDynarray_clear(ThreadDynarray_t ptr)
 {
-       ThreadDynarray_lock(ptr);
+  ThreadDynarray_lock(ptr);
 
-       if(ptr->threads){
-               free(ptr->threads);
-               ptr->threads = NULL;
-       }
+  if (ptr->threads) {
+    free(ptr->threads);
+    ptr->threads = NULL;
+  }
 
-       ptr->count = 0;
-       ptr->capacity = 0;
-       ThreadDynarray_unlock(ptr);     
+  ptr->count = 0;
+  ptr->capacity = 0;
+  ThreadDynarray_unlock(ptr);
 }
 
 /*
@@ -243,35 +256,41 @@ void ThreadDynarray_clear(ThreadDynarray_t ptr)
  */
 void ThreadDynarray_reset(ThreadDynarray_t ptr)
 {
-        ThreadDynarray_lock(ptr);
-        ptr->count = 0;
-        ThreadDynarray_unlock(ptr);
+  ThreadDynarray_lock(ptr);
+  ptr->count = 0;
+  ThreadDynarray_unlock(ptr);
 }
 
 /*
  * Moves count elements from src index to dst index.
  */
-void ThreadDynarray_move(ThreadDynarray_t ptr, const unsigned long dst,const unsigned long src,unsigned long count)
+void ThreadDynarray_move(ThreadDynarray_t ptr, const unsigned long dst,
+                         const unsigned long src, unsigned long count)
 {
-       ThreadDynarray_lock(ptr);
+  ThreadDynarray_lock(ptr);
 
-       if(ptr->count)
-               memmove(ThreadDynarray_at(ptr,dst),ThreadDynarray_at(ptr,src),count * sizeof(s_ThreadEntry_t));
+  if (ptr->count)
+    memmove(ThreadDynarray_at(ptr, dst), ThreadDynarray_at(ptr, src),
+            count * sizeof(s_ThreadEntry_t));
 
-       ThreadDynarray_unlock(ptr);
+  ThreadDynarray_unlock(ptr);
 }
 
 /* Compare the content of the entry pointed to by index with the content of
  * the entry addressed by __entry. The function returns true if the contents
  * are same.
  */
-bool ThreadDynarray_compare(ThreadDynarray_t ptr, const unsigned long index,ThreadEntry_t const __entry)
+bool ThreadDynarray_compare(ThreadDynarray_t ptr,
+                            const unsigned long index,
+                            ThreadEntry_t const __entry)
 {
-       bool are_equals;
-       ThreadDynarray_lock(ptr);
-       are_equals = (!memcmp(ThreadDynarray_at(ptr,index),__entry,sizeof(s_ThreadEntry_t)));
-       ThreadDynarray_unlock(ptr);
-       return are_equals;
+  bool are_equals;
+  ThreadDynarray_lock(ptr);
+  are_equals =
+      (!memcmp
+       (ThreadDynarray_at(ptr, index), __entry, sizeof(s_ThreadEntry_t)));
+  ThreadDynarray_unlock(ptr);
+  return are_equals;
 }
 
 /*
@@ -279,16 +298,17 @@ bool ThreadDynarray_compare(ThreadDynarray_t ptr, const unsigned long index,Thre
  */
 ThreadDynarray_t ThreadDynarray_clone(ThreadDynarray_t ptr)
 {
-       ThreadDynarray_t new_ptr;
-       ThreadDynarray_lock(ptr);
-       ptr = ThreadDynarray_new(ptr->capacity);
-       
-       if(ptr->count){
-               memcpy(new_ptr->threads,ptr->threads,ptr->count * sizeof(s_ThreadEntry_t));
-               new_ptr->count=ThreadDynarray_getCount(ptr);
-       }
-       ThreadDynarray_unlock(ptr);
-       return new_ptr;
+  ThreadDynarray_t new_ptr;
+  ThreadDynarray_lock(ptr);
+  ptr = ThreadDynarray_new(ptr->capacity);
+
+  if (ptr->count) {
+    memcpy(new_ptr->threads, ptr->threads,
+           ptr->count * sizeof(s_ThreadEntry_t));
+    new_ptr->count = ThreadDynarray_getCount(ptr);
+  }
+  ThreadDynarray_unlock(ptr);
+  return new_ptr;
 }
 
 /*
@@ -296,12 +316,14 @@ ThreadDynarray_t ThreadDynarray_clone(ThreadDynarray_t ptr)
  */
 void ThreadDynarray_resize(ThreadDynarray_t ptr)
 {
-       ThreadDynarray_lock(ptr);
-       
-       ptr->capacity = (!ptr->capacity) ? 1 : (ptr->count << 1);
-       ptr->threads = (ThreadEntry_t)realloc(ptr->threads, ptr->capacity * sizeof(s_ThreadEntry_t));
-       
-       ThreadDynarray_unlock(ptr);
+  ThreadDynarray_lock(ptr);
+
+  ptr->capacity = (!ptr->capacity) ? 1 : (ptr->count << 1);
+  ptr->threads =
+      (ThreadEntry_t) realloc(ptr->threads,
+                              ptr->capacity * sizeof(s_ThreadEntry_t));
+
+  ThreadDynarray_unlock(ptr);
 }
 
 
@@ -310,11 +332,11 @@ void ThreadDynarray_resize(ThreadDynarray_t ptr)
  */
 unsigned long ThreadDynarray_getCount(ThreadDynarray_t ptr)
 {
-       unsigned count;
-       ThreadDynarray_lock(ptr);
-       count = ptr->count;     
-       ThreadDynarray_unlock(ptr);
-       return count;
+  unsigned count;
+  ThreadDynarray_lock(ptr);
+  count = ptr->count;
+  ThreadDynarray_unlock(ptr);
+  return count;
 }
 
 /*
@@ -323,11 +345,11 @@ unsigned long ThreadDynarray_getCount(ThreadDynarray_t ptr)
  */
 unsigned long ThreadDynarray_getCapacity(ThreadDynarray_t ptr)
 {
-       unsigned capacity;
-       ThreadDynarray_lock(ptr);
-       capacity = ptr->capacity;
-       ThreadDynarray_unlock(ptr);
-       return capacity;
+  unsigned capacity;
+  ThreadDynarray_lock(ptr);
+  capacity = ptr->capacity;
+  ThreadDynarray_unlock(ptr);
+  return capacity;
 }
 
 
@@ -336,11 +358,11 @@ unsigned long ThreadDynarray_getCapacity(ThreadDynarray_t ptr)
  */
 unsigned long ThreadDynarray_getUpperBound(ThreadDynarray_t ptr)
 {
-       unsigned long upper_bound;
-       ThreadDynarray_lock(ptr);
-       upper_bound = (ptr->count - 1);
-       ThreadDynarray_unlock(ptr);
-       return upper_bound;
+  unsigned long upper_bound;
+  ThreadDynarray_lock(ptr);
+  upper_bound = (ptr->count - 1);
+  ThreadDynarray_unlock(ptr);
+  return upper_bound;
 }
 
 /*
@@ -348,7 +370,7 @@ unsigned long ThreadDynarray_getUpperBound(ThreadDynarray_t ptr)
  */
 unsigned long ThreadDynarray_getLowerBound(ThreadDynarray_t ptr)
 {
-       return 0;
+  return 0;
 }
 
 /*
@@ -356,7 +378,7 @@ unsigned long ThreadDynarray_getLowerBound(ThreadDynarray_t ptr)
  */
 unsigned long ThreadDynarray_getElementSize(ThreadDynarray_t ptr)
 {
-       return sizeof(s_ThreadEntry_t);
+  return sizeof(s_ThreadEntry_t);
 }
 
 /*
@@ -364,11 +386,11 @@ unsigned long ThreadDynarray_getElementSize(ThreadDynarray_t ptr)
  */
 bool ThreadDynarray_isEmpty(ThreadDynarray_t ptr)
 {
-       bool is_empty;
-       ThreadDynarray_lock(ptr);
-       is_empty = (ptr->count == 0);
-       ThreadDynarray_unlock(ptr);
-       return is_empty;
+  bool is_empty;
+  ThreadDynarray_lock(ptr);
+  is_empty = (ptr->count == 0);
+  ThreadDynarray_unlock(ptr);
+  return is_empty;
 }
 
 /*
@@ -376,11 +398,11 @@ bool ThreadDynarray_isEmpty(ThreadDynarray_t ptr)
  */
 bool ThreadDynarray_getCapacityAvailable(ThreadDynarray_t ptr)
 {
-       bool capacity_available;
-       ThreadDynarray_lock(ptr);
-       capacity_available = (ptr->capacity > ptr->count);
-       ThreadDynarray_unlock(ptr);
-       return capacity_available;
+  bool capacity_available;
+  ThreadDynarray_lock(ptr);
+  capacity_available = (ptr->capacity > ptr->count);
+  ThreadDynarray_unlock(ptr);
+  return capacity_available;
 }
 
 /*
@@ -388,81 +410,82 @@ bool ThreadDynarray_getCapacityAvailable(ThreadDynarray_t ptr)
  */
 bool ThreadDynarray_is_full(ThreadDynarray_t ptr)
 {
-       bool is_full;
-       ThreadDynarray_lock(ptr);
-       is_full = (!ThreadDynarray_isEmpty(ptr) && !ThreadDynarray_getCapacityAvailable(ptr));
-       ThreadDynarray_unlock(ptr);
-       return is_full;
+  bool is_full;
+  ThreadDynarray_lock(ptr);
+  is_full = (!ThreadDynarray_isEmpty(ptr)
+             && !ThreadDynarray_getCapacityAvailable(ptr));
+  ThreadDynarray_unlock(ptr);
+  return is_full;
 }
 
 /* 
  * Assignement.
  */
-ThreadDynarray_t ThreadDynarray_assign(ThreadDynarray_t src,ThreadDynarray_t dst)
-{
-       ThreadDynarray_lock(src);
-       ThreadDynarray_lock(dst);
-       
-       if(src != dst)
-       {
-               ThreadDynarray_clear(dst);
-       
-               if(src->count)
-               {
-                       dst->count = src->count;
-                       dst->capacity = src->capacity;
-                       dst->threads = (ThreadEntry_t)malloc(src->capacity * sizeof(s_ThreadEntry_t));
-                       memcpy(dst->threads,src->threads,src->count * sizeof(s_ThreadEntry_t));
-               }
-       }
-       ThreadDynarray_unlock(src);
-       ThreadDynarray_unlock(dst);
-       
-       return dst;     
+ThreadDynarray_t ThreadDynarray_assign(ThreadDynarray_t src,
+                                       ThreadDynarray_t dst)
+{
+  ThreadDynarray_lock(src);
+  ThreadDynarray_lock(dst);
+
+  if (src != dst) {
+    ThreadDynarray_clear(dst);
+
+    if (src->count) {
+      dst->count = src->count;
+      dst->capacity = src->capacity;
+      dst->threads =
+          (ThreadEntry_t) malloc(src->capacity * sizeof(s_ThreadEntry_t));
+      memcpy(dst->threads, src->threads,
+             src->count * sizeof(s_ThreadEntry_t));
+    }
+  }
+  ThreadDynarray_unlock(src);
+  ThreadDynarray_unlock(dst);
+
+  return dst;
 }
 
 /* 
  * Returns true if the dynamic arrays are equal.
- */ 
-bool ThreadDynarray_areEquals(ThreadDynarray_t ptr1,ThreadDynarray_t ptr2)
+ */
+bool ThreadDynarray_areEquals(ThreadDynarray_t ptr1, ThreadDynarray_t ptr2)
 {
-       bool are_equals;
-       
-       ThreadDynarray_lock(ptr1);
-       ThreadDynarray_lock(ptr2);
+  bool are_equals;
 
-       are_equals = (
-                       ptr1->count == ptr2->count                              &&
-                       ptr1->capacity == ptr2->capacity                        &&
-                       !memcmp(ptr2->threads,ptr1->threads,ptr1->capacity)
-       );
+  ThreadDynarray_lock(ptr1);
+  ThreadDynarray_lock(ptr2);
 
-       ThreadDynarray_unlock(ptr1);
-       ThreadDynarray_unlock(ptr2);
-       
-       return are_equals;      
+  are_equals = (ptr1->count == ptr2->count &&
+                ptr1->capacity == ptr2->capacity &&
+                !memcmp(ptr2->threads, ptr1->threads, ptr1->capacity)
+      );
+
+  ThreadDynarray_unlock(ptr1);
+  ThreadDynarray_unlock(ptr2);
+
+  return are_equals;
 }
 
 /* 
  * Returns true if the dynamic arrays are not equal.
- */ 
-ThreadDynarray_areNotEquals(ThreadDynarray_t ptr1,ThreadDynarray_t ptr2)
+ */
+ThreadDynarray_areNotEquals(ThreadDynarray_t ptr1, ThreadDynarray_t ptr2)
 {
-       return !ThreadDynarray_areEquals(ptr1,ptr2);    
+  return !ThreadDynarray_areEquals(ptr1, ptr2);
 }
 
 void ThreadDynarray_lock(ThreadDynarray_t ptr)
 {
-       if(!ptr->is_locked){
-               EnterCriticalSection(&(ptr->cs));
-               ptr->is_locked = true;
-       }
+  if (!ptr->is_locked) {
+    EnterCriticalSection(&(ptr->cs));
+    ptr->is_locked = true;
+  }
 }
 
 void ThreadDynarray_unlock(ThreadDynarray_t ptr)
 {
-       if(ptr->is_locked){
-               LeaveCriticalSection(&(ptr->cs));
-               ptr->is_locked = false;
-       }
+  if (ptr->is_locked) {
+    LeaveCriticalSection(&(ptr->cs));
+    ptr->is_locked = false;
+  }
 }
index 97511a8..1094d22 100644 (file)
@@ -1,12 +1,13 @@
 #include <TTime.h>
 
-void __time(chart)
+void __time(char *t)
 {
 
-       time_t timer;
-       struct tm *tblock;
-       timer = time(NULL);
-       tblock = localtime(&timer);
-       
-       sprintf(t,"%02d/%02d/%d  %02d:%02d",tblock->tm_mday,tblock->tm_mon,tblock->tm_year + 1900,tblock->tm_hour,tblock->tm_min);
-}
\ No newline at end of file
+  time_t timer;
+  struct tm *tblock;
+  timer = time(NULL);
+  tblock = localtime(&timer);
+
+  sprintf(t, "%02d/%02d/%d  %02d:%02d", tblock->tm_mday, tblock->tm_mon,
+          tblock->tm_year + 1900, tblock->tm_hour, tblock->tm_min);
+}
index c7c73b0..590437b 100644 (file)
@@ -9,48 +9,43 @@ void terminate(void);
 
 #pragma argsused
 
-int main(int argc,char *argv[])
+int main(int argc, char *argv[])
 {
-    errno_t e;
-    initializeErrno();
+  errno_t e;
+  initializeErrno();
 
-       /* Create a test runner. */
-       test_runner = TestRunner_new();
+  /* Create a test runner. */
+  test_runner = TestRunner_new();
 
-       if(NULL == test_runner)
-               terminate();
+  if (NULL == test_runner)
+    terminate();
 
-       /* Initialize the test runner. */
-       if(E_SUCCESS != TestRunner_initialize(test_runner,argc,argv))
-               terminate();
+  /* Initialize the test runner. */
+  if (E_SUCCESS != TestRunner_initialize(test_runner, argc, argv))
+    terminate();
 
-       /* Launch the test runner. */
-       TestRunner_run(test_runner);
+  /* Launch the test runner. */
+  TestRunner_run(test_runner);
 
-    e = getErrno();
+  e = getErrno();
 
-       terminate();
+  terminate();
 
-    return e;
+  return e;
 }
 
 
 void terminate(void)
 {
-    errno_t e = getErrno();
-
-       if(NULL != test_runner)
-               TestRunner_free(test_runner);
-       
-       printf("\n Program terminated with the exit code : %3d (%s)\n",getErrno(),__errlist[getErrno()]);
-
-    terminateErrno();
-    
-       exit(e);
-}
+  errno_t e = getErrno();
 
+  if (NULL != test_runner)
+    TestRunner_free(test_runner);
 
+  printf("\n Program terminated with the exit code : %3d (%s)\n",
+         getErrno(), __errlist[getErrno()]);
 
+  terminateErrno();
 
-
+  exit(e);
+}
index 23da4a6..e214ace 100644 (file)
@@ -2,7 +2,8 @@
 
 #include "gras.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,"Logs about the gigantic struct test");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs, test,
+                                "Logs about the gigantic struct test");
 
 
 #define READ  0
@@ -18,550 +19,1091 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,"Logs about the gigantic struct tes
 
 */
 
-void write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);
-
-GRAS_DEFINE_TYPE(cccc,struct cccc { char a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(ccsc,struct ccsc { char a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(ccic,struct ccic { char a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(cclc,struct cclc { char a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(ccLc,struct ccLc { char a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(ccfc,struct ccfc { char a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(ccdc,struct ccdc { char a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(sccc,struct sccc { short int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(scsc,struct scsc { short int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(scic,struct scic { short int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(sclc,struct sclc { short int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(scLc,struct scLc { short int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(scfc,struct scfc { short int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(scdc,struct scdc { short int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(iccc,struct iccc { int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(icsc,struct icsc { int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(icic,struct icic { int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(iclc,struct iclc { int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(icLc,struct icLc { int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(icfc,struct icfc { int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(icdc,struct icdc { int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(lccc,struct lccc { long int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(lcsc,struct lcsc { long int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(lcic,struct lcic { long int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(lclc,struct lclc { long int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(lcLc,struct lcLc { long int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(lcfc,struct lcfc { long int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(lcdc,struct lcdc { long int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(Lccc,struct Lccc { long long int a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(Lcsc,struct Lcsc { long long int a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(Lcic,struct Lcic { long long int a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(Lclc,struct Lclc { long long int a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(LcLc,struct LcLc { long long int a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(Lcfc,struct Lcfc { long long int a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(Lcdc,struct Lcdc { long long int a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(fccc,struct fccc { float a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(fcsc,struct fcsc { float a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(fcic,struct fcic { float a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(fclc,struct fclc { float a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(fcLc,struct fcLc { float a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(fcfc,struct fcfc { float a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(fcdc,struct fcdc { float a; char b; double c;char d;};)
-GRAS_DEFINE_TYPE(dccc,struct dccc { double a; char b; char c;char d;};)
-GRAS_DEFINE_TYPE(dcsc,struct dcsc { double a; char b; short int c;char d;};)
-GRAS_DEFINE_TYPE(dcic,struct dcic { double a; char b; int c;char d;};)
-GRAS_DEFINE_TYPE(dclc,struct dclc { double a; char b; long int c;char d;};)
-GRAS_DEFINE_TYPE(dcLc,struct dcLc { double a; char b; long long int c;char d;};)
-GRAS_DEFINE_TYPE(dcfc,struct dcfc { double a; char b; float c;char d;};)
-GRAS_DEFINE_TYPE(dcdc,struct dcdc { double a; char b; double c;char d;};)
+void write_read(gras_datadesc_type_t type, void *src, void *dst,
+                gras_socket_t * sock, int direction);
 
+GRAS_DEFINE_TYPE(cccc, struct cccc {
+                 char a;
+                 char b;
+                 char c;
+                 char d;
+                 };
+
+    )
+    GRAS_DEFINE_TYPE(ccsc, struct ccsc {
+                     char a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccic, struct ccic {
+                     char a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(cclc, struct cclc {
+                     char a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccLc, struct ccLc {
+                     char a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccfc, struct ccfc {
+                     char a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(ccdc, struct ccdc {
+                     char a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(sccc, struct sccc {
+                     short int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scsc, struct scsc {
+                     short int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scic, struct scic {
+                     short int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(sclc, struct sclc {
+                     short int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scLc, struct scLc {
+                     short int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scfc, struct scfc {
+                     short int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(scdc, struct scdc {
+                     short int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(iccc, struct iccc {
+                     int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icsc, struct icsc {
+                     int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icic, struct icic {
+                     int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(iclc, struct iclc {
+                     int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icLc, struct icLc {
+                     int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icfc, struct icfc {
+                     int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(icdc, struct icdc {
+                     int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lccc, struct lccc {
+                     long int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcsc, struct lcsc {
+                     long int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcic, struct lcic {
+                     long int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lclc, struct lclc {
+                     long int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcLc, struct lcLc {
+                     long int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcfc, struct lcfc {
+                     long int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(lcdc, struct lcdc {
+                     long int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lccc, struct Lccc {
+                     long long int a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcsc, struct Lcsc {
+                     long long int a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcic, struct Lcic {
+                     long long int a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lclc, struct Lclc {
+                     long long int a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(LcLc, struct LcLc {
+                     long long int a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcfc, struct Lcfc {
+                     long long int a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(Lcdc, struct Lcdc {
+                     long long int a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fccc, struct fccc {
+                     float a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcsc, struct fcsc {
+                     float a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcic, struct fcic {
+                     float a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fclc, struct fclc {
+                     float a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcLc, struct fcLc {
+                     float a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcfc, struct fcfc {
+                     float a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(fcdc, struct fcdc {
+                     float a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dccc, struct dccc {
+                     double a;
+                     char b;
+                     char c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcsc, struct dcsc {
+                     double a;
+                     char b;
+                     short int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcic, struct dcic {
+                     double a;
+                     char b;
+                     int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dclc, struct dclc {
+                     double a;
+                     char b;
+                     long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcLc, struct dcLc {
+                     double a;
+                     char b;
+                     long long int c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcfc, struct dcfc {
+                     double a;
+                     char b;
+                     float c;
+                     char d;
+                     };
+
+    )
+    GRAS_DEFINE_TYPE(dcdc, struct dcdc {
+                     double a;
+                     char b;
+                     double c;
+                     char d;
+                     };
+
+    )
 #define test(a) xbt_assert(a)
-void test_structures(gras_socket_t *sock, int direction);
-void test_structures(gras_socket_t *sock, int direction) {
-  struct cccc my_cccc = {'w'+(char)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_cccc2;
-  struct ccsc my_ccsc = {'w'+(char)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_ccsc2;
-  struct ccic my_ccic = {'w'+(char)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_ccic2;
-  struct cclc my_cclc = {'w'+(char)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_cclc2;
-  struct ccLc my_ccLc = {'w'+(char)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_ccLc2;
-  struct ccfc my_ccfc = {'w'+(char)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_ccfc2;
-  struct ccdc my_ccdc = {'w'+(char)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_ccdc2;
-  struct sccc my_sccc = {134+(short int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_sccc2;
-  struct scsc my_scsc = {134+(short int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_scsc2;
-  struct scic my_scic = {134+(short int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_scic2;
-  struct sclc my_sclc = {134+(short int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_sclc2;
-  struct scLc my_scLc = {134+(short int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_scLc2;
-  struct scfc my_scfc = {134+(short int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_scfc2;
-  struct scdc my_scdc = {134+(short int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_scdc2;
-  struct iccc my_iccc = {-11249+(int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_iccc2;
-  struct icsc my_icsc = {-11249+(int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_icsc2;
-  struct icic my_icic = {-11249+(int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_icic2;
-  struct iclc my_iclc = {-11249+(int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_iclc2;
-  struct icLc my_icLc = {-11249+(int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_icLc2;
-  struct icfc my_icfc = {-11249+(int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_icfc2;
-  struct icdc my_icdc = {-11249+(int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_icdc2;
-  struct lccc my_lccc = {31319919+(long int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_lccc2;
-  struct lcsc my_lcsc = {31319919+(long int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_lcsc2;
-  struct lcic my_lcic = {31319919+(long int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_lcic2;
-  struct lclc my_lclc = {31319919+(long int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_lclc2;
-  struct lcLc my_lcLc = {31319919+(long int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_lcLc2;
-  struct lcfc my_lcfc = {31319919+(long int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_lcfc2;
-  struct lcdc my_lcdc = {31319919+(long int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_lcdc2;
-  struct Lccc my_Lccc = {-232130010+(long long int)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_Lccc2;
-  struct Lcsc my_Lcsc = {-232130010+(long long int)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_Lcsc2;
-  struct Lcic my_Lcic = {-232130010+(long long int)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_Lcic2;
-  struct Lclc my_Lclc = {-232130010+(long long int)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_Lclc2;
-  struct LcLc my_LcLc = {-232130010+(long long int)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_LcLc2;
-  struct Lcfc my_Lcfc = {-232130010+(long long int)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_Lcfc2;
-  struct Lcdc my_Lcdc = {-232130010+(long long int)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_Lcdc2;
-  struct fccc my_fccc = {-11313.1135+(float)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_fccc2;
-  struct fcsc my_fcsc = {-11313.1135+(float)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_fcsc2;
-  struct fcic my_fcic = {-11313.1135+(float)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_fcic2;
-  struct fclc my_fclc = {-11313.1135+(float)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_fclc2;
-  struct fcLc my_fcLc = {-11313.1135+(float)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_fcLc2;
-  struct fcfc my_fcfc = {-11313.1135+(float)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_fcfc2;
-  struct fcdc my_fcdc = {-11313.1135+(float)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_fcdc2;
-  struct dccc my_dccc = {1424420.11331+(double)1,'w'+(char)2,'w'+(char)3,'w'+(char)4}, my_dccc2;
-  struct dcsc my_dcsc = {1424420.11331+(double)1,'w'+(char)2,134+(short int)3,'w'+(char)4}, my_dcsc2;
-  struct dcic my_dcic = {1424420.11331+(double)1,'w'+(char)2,-11249+(int)3,'w'+(char)4}, my_dcic2;
-  struct dclc my_dclc = {1424420.11331+(double)1,'w'+(char)2,31319919+(long int)3,'w'+(char)4}, my_dclc2;
-  struct dcLc my_dcLc = {1424420.11331+(double)1,'w'+(char)2,-232130010+(long long int)3,'w'+(char)4}, my_dcLc2;
-  struct dcfc my_dcfc = {1424420.11331+(double)1,'w'+(char)2,-11313.1135+(float)3,'w'+(char)4}, my_dcfc2;
-  struct dcdc my_dcdc = {1424420.11331+(double)1,'w'+(char)2,1424420.11331+(double)3,'w'+(char)4}, my_dcdc2;
-  INFO0("---- Test on all possible struct having 3 fields (49 structs) ----");
-  write_read(gras_datadesc_by_symbol(cccc), &my_cccc, &my_cccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_cccc.a == my_cccc2.a);
-     test(my_cccc.b == my_cccc2.b);
-     test(my_cccc.c == my_cccc2.c);
-     test(my_cccc.d == my_cccc2.d);
-     if (!failed) VERB0("Passed cccc");
-  }
-  write_read(gras_datadesc_by_symbol(ccsc), &my_ccsc, &my_ccsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccsc.a == my_ccsc2.a);
-     test(my_ccsc.b == my_ccsc2.b);
-     test(my_ccsc.c == my_ccsc2.c);
-     test(my_ccsc.d == my_ccsc2.d);
-     if (!failed) VERB0("Passed ccsc");
-  }
-  write_read(gras_datadesc_by_symbol(ccic), &my_ccic, &my_ccic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccic.a == my_ccic2.a);
-     test(my_ccic.b == my_ccic2.b);
-     test(my_ccic.c == my_ccic2.c);
-     test(my_ccic.d == my_ccic2.d);
-     if (!failed) VERB0("Passed ccic");
-  }
-  write_read(gras_datadesc_by_symbol(cclc), &my_cclc, &my_cclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_cclc.a == my_cclc2.a);
-     test(my_cclc.b == my_cclc2.b);
-     test(my_cclc.c == my_cclc2.c);
-     test(my_cclc.d == my_cclc2.d);
-     if (!failed) VERB0("Passed cclc");
-  }
-  write_read(gras_datadesc_by_symbol(ccLc), &my_ccLc, &my_ccLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccLc.a == my_ccLc2.a);
-     test(my_ccLc.b == my_ccLc2.b);
-     test(my_ccLc.c == my_ccLc2.c);
-     test(my_ccLc.d == my_ccLc2.d);
-     if (!failed) VERB0("Passed ccLc");
-  }
-  write_read(gras_datadesc_by_symbol(ccfc), &my_ccfc, &my_ccfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccfc.a == my_ccfc2.a);
-     test(my_ccfc.b == my_ccfc2.b);
-     test(my_ccfc.c == my_ccfc2.c);
-     test(my_ccfc.d == my_ccfc2.d);
-     if (!failed) VERB0("Passed ccfc");
-  }
-  write_read(gras_datadesc_by_symbol(ccdc), &my_ccdc, &my_ccdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_ccdc.a == my_ccdc2.a);
-     test(my_ccdc.b == my_ccdc2.b);
-     test(my_ccdc.c == my_ccdc2.c);
-     test(my_ccdc.d == my_ccdc2.d);
-     if (!failed) VERB0("Passed ccdc");
-  }
-  write_read(gras_datadesc_by_symbol(sccc), &my_sccc, &my_sccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_sccc.a == my_sccc2.a);
-     test(my_sccc.b == my_sccc2.b);
-     test(my_sccc.c == my_sccc2.c);
-     test(my_sccc.d == my_sccc2.d);
-     if (!failed) VERB0("Passed sccc");
-  }
-  write_read(gras_datadesc_by_symbol(scsc), &my_scsc, &my_scsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scsc.a == my_scsc2.a);
-     test(my_scsc.b == my_scsc2.b);
-     test(my_scsc.c == my_scsc2.c);
-     test(my_scsc.d == my_scsc2.d);
-     if (!failed) VERB0("Passed scsc");
-  }
-  write_read(gras_datadesc_by_symbol(scic), &my_scic, &my_scic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scic.a == my_scic2.a);
-     test(my_scic.b == my_scic2.b);
-     test(my_scic.c == my_scic2.c);
-     test(my_scic.d == my_scic2.d);
-     if (!failed) VERB0("Passed scic");
-  }
-  write_read(gras_datadesc_by_symbol(sclc), &my_sclc, &my_sclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_sclc.a == my_sclc2.a);
-     test(my_sclc.b == my_sclc2.b);
-     test(my_sclc.c == my_sclc2.c);
-     test(my_sclc.d == my_sclc2.d);
-     if (!failed) VERB0("Passed sclc");
-  }
-  write_read(gras_datadesc_by_symbol(scLc), &my_scLc, &my_scLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scLc.a == my_scLc2.a);
-     test(my_scLc.b == my_scLc2.b);
-     test(my_scLc.c == my_scLc2.c);
-     test(my_scLc.d == my_scLc2.d);
-     if (!failed) VERB0("Passed scLc");
-  }
-  write_read(gras_datadesc_by_symbol(scfc), &my_scfc, &my_scfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scfc.a == my_scfc2.a);
-     test(my_scfc.b == my_scfc2.b);
-     test(my_scfc.c == my_scfc2.c);
-     test(my_scfc.d == my_scfc2.d);
-     if (!failed) VERB0("Passed scfc");
-  }
-  write_read(gras_datadesc_by_symbol(scdc), &my_scdc, &my_scdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_scdc.a == my_scdc2.a);
-     test(my_scdc.b == my_scdc2.b);
-     test(my_scdc.c == my_scdc2.c);
-     test(my_scdc.d == my_scdc2.d);
-     if (!failed) VERB0("Passed scdc");
-  }
-  write_read(gras_datadesc_by_symbol(iccc), &my_iccc, &my_iccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_iccc.a == my_iccc2.a);
-     test(my_iccc.b == my_iccc2.b);
-     test(my_iccc.c == my_iccc2.c);
-     test(my_iccc.d == my_iccc2.d);
-     if (!failed) VERB0("Passed iccc");
-  }
-  write_read(gras_datadesc_by_symbol(icsc), &my_icsc, &my_icsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icsc.a == my_icsc2.a);
-     test(my_icsc.b == my_icsc2.b);
-     test(my_icsc.c == my_icsc2.c);
-     test(my_icsc.d == my_icsc2.d);
-     if (!failed) VERB0("Passed icsc");
-  }
-  write_read(gras_datadesc_by_symbol(icic), &my_icic, &my_icic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icic.a == my_icic2.a);
-     test(my_icic.b == my_icic2.b);
-     test(my_icic.c == my_icic2.c);
-     test(my_icic.d == my_icic2.d);
-     if (!failed) VERB0("Passed icic");
-  }
-  write_read(gras_datadesc_by_symbol(iclc), &my_iclc, &my_iclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_iclc.a == my_iclc2.a);
-     test(my_iclc.b == my_iclc2.b);
-     test(my_iclc.c == my_iclc2.c);
-     test(my_iclc.d == my_iclc2.d);
-     if (!failed) VERB0("Passed iclc");
-  }
-  write_read(gras_datadesc_by_symbol(icLc), &my_icLc, &my_icLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icLc.a == my_icLc2.a);
-     test(my_icLc.b == my_icLc2.b);
-     test(my_icLc.c == my_icLc2.c);
-     test(my_icLc.d == my_icLc2.d);
-     if (!failed) VERB0("Passed icLc");
-  }
-  write_read(gras_datadesc_by_symbol(icfc), &my_icfc, &my_icfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icfc.a == my_icfc2.a);
-     test(my_icfc.b == my_icfc2.b);
-     test(my_icfc.c == my_icfc2.c);
-     test(my_icfc.d == my_icfc2.d);
-     if (!failed) VERB0("Passed icfc");
-  }
-  write_read(gras_datadesc_by_symbol(icdc), &my_icdc, &my_icdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_icdc.a == my_icdc2.a);
-     test(my_icdc.b == my_icdc2.b);
-     test(my_icdc.c == my_icdc2.c);
-     test(my_icdc.d == my_icdc2.d);
-     if (!failed) VERB0("Passed icdc");
-  }
-  write_read(gras_datadesc_by_symbol(lccc), &my_lccc, &my_lccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lccc.a == my_lccc2.a);
-     test(my_lccc.b == my_lccc2.b);
-     test(my_lccc.c == my_lccc2.c);
-     test(my_lccc.d == my_lccc2.d);
-     if (!failed) VERB0("Passed lccc");
-  }
-  write_read(gras_datadesc_by_symbol(lcsc), &my_lcsc, &my_lcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcsc.a == my_lcsc2.a);
-     test(my_lcsc.b == my_lcsc2.b);
-     test(my_lcsc.c == my_lcsc2.c);
-     test(my_lcsc.d == my_lcsc2.d);
-     if (!failed) VERB0("Passed lcsc");
-  }
-  write_read(gras_datadesc_by_symbol(lcic), &my_lcic, &my_lcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcic.a == my_lcic2.a);
-     test(my_lcic.b == my_lcic2.b);
-     test(my_lcic.c == my_lcic2.c);
-     test(my_lcic.d == my_lcic2.d);
-     if (!failed) VERB0("Passed lcic");
-  }
-  write_read(gras_datadesc_by_symbol(lclc), &my_lclc, &my_lclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lclc.a == my_lclc2.a);
-     test(my_lclc.b == my_lclc2.b);
-     test(my_lclc.c == my_lclc2.c);
-     test(my_lclc.d == my_lclc2.d);
-     if (!failed) VERB0("Passed lclc");
-  }
-  write_read(gras_datadesc_by_symbol(lcLc), &my_lcLc, &my_lcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcLc.a == my_lcLc2.a);
-     test(my_lcLc.b == my_lcLc2.b);
-     test(my_lcLc.c == my_lcLc2.c);
-     test(my_lcLc.d == my_lcLc2.d);
-     if (!failed) VERB0("Passed lcLc");
-  }
-  write_read(gras_datadesc_by_symbol(lcfc), &my_lcfc, &my_lcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcfc.a == my_lcfc2.a);
-     test(my_lcfc.b == my_lcfc2.b);
-     test(my_lcfc.c == my_lcfc2.c);
-     test(my_lcfc.d == my_lcfc2.d);
-     if (!failed) VERB0("Passed lcfc");
-  }
-  write_read(gras_datadesc_by_symbol(lcdc), &my_lcdc, &my_lcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_lcdc.a == my_lcdc2.a);
-     test(my_lcdc.b == my_lcdc2.b);
-     test(my_lcdc.c == my_lcdc2.c);
-     test(my_lcdc.d == my_lcdc2.d);
-     if (!failed) VERB0("Passed lcdc");
-  }
-  write_read(gras_datadesc_by_symbol(Lccc), &my_Lccc, &my_Lccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lccc.a == my_Lccc2.a);
-     test(my_Lccc.b == my_Lccc2.b);
-     test(my_Lccc.c == my_Lccc2.c);
-     test(my_Lccc.d == my_Lccc2.d);
-     if (!failed) VERB0("Passed Lccc");
-  }
-  write_read(gras_datadesc_by_symbol(Lcsc), &my_Lcsc, &my_Lcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcsc.a == my_Lcsc2.a);
-     test(my_Lcsc.b == my_Lcsc2.b);
-     test(my_Lcsc.c == my_Lcsc2.c);
-     test(my_Lcsc.d == my_Lcsc2.d);
-     if (!failed) VERB0("Passed Lcsc");
-  }
-  write_read(gras_datadesc_by_symbol(Lcic), &my_Lcic, &my_Lcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcic.a == my_Lcic2.a);
-     test(my_Lcic.b == my_Lcic2.b);
-     test(my_Lcic.c == my_Lcic2.c);
-     test(my_Lcic.d == my_Lcic2.d);
-     if (!failed) VERB0("Passed Lcic");
-  }
-  write_read(gras_datadesc_by_symbol(Lclc), &my_Lclc, &my_Lclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lclc.a == my_Lclc2.a);
-     test(my_Lclc.b == my_Lclc2.b);
-     test(my_Lclc.c == my_Lclc2.c);
-     test(my_Lclc.d == my_Lclc2.d);
-     if (!failed) VERB0("Passed Lclc");
-  }
-  write_read(gras_datadesc_by_symbol(LcLc), &my_LcLc, &my_LcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_LcLc.a == my_LcLc2.a);
-     test(my_LcLc.b == my_LcLc2.b);
-     test(my_LcLc.c == my_LcLc2.c);
-     test(my_LcLc.d == my_LcLc2.d);
-     if (!failed) VERB0("Passed LcLc");
-  }
-  write_read(gras_datadesc_by_symbol(Lcfc), &my_Lcfc, &my_Lcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcfc.a == my_Lcfc2.a);
-     test(my_Lcfc.b == my_Lcfc2.b);
-     test(my_Lcfc.c == my_Lcfc2.c);
-     test(my_Lcfc.d == my_Lcfc2.d);
-     if (!failed) VERB0("Passed Lcfc");
-  }
-  write_read(gras_datadesc_by_symbol(Lcdc), &my_Lcdc, &my_Lcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_Lcdc.a == my_Lcdc2.a);
-     test(my_Lcdc.b == my_Lcdc2.b);
-     test(my_Lcdc.c == my_Lcdc2.c);
-     test(my_Lcdc.d == my_Lcdc2.d);
-     if (!failed) VERB0("Passed Lcdc");
-  }
-  write_read(gras_datadesc_by_symbol(fccc), &my_fccc, &my_fccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fccc.a == my_fccc2.a);
-     test(my_fccc.b == my_fccc2.b);
-     test(my_fccc.c == my_fccc2.c);
-     test(my_fccc.d == my_fccc2.d);
-     if (!failed) VERB0("Passed fccc");
-  }
-  write_read(gras_datadesc_by_symbol(fcsc), &my_fcsc, &my_fcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcsc.a == my_fcsc2.a);
-     test(my_fcsc.b == my_fcsc2.b);
-     test(my_fcsc.c == my_fcsc2.c);
-     test(my_fcsc.d == my_fcsc2.d);
-     if (!failed) VERB0("Passed fcsc");
-  }
-  write_read(gras_datadesc_by_symbol(fcic), &my_fcic, &my_fcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcic.a == my_fcic2.a);
-     test(my_fcic.b == my_fcic2.b);
-     test(my_fcic.c == my_fcic2.c);
-     test(my_fcic.d == my_fcic2.d);
-     if (!failed) VERB0("Passed fcic");
-  }
-  write_read(gras_datadesc_by_symbol(fclc), &my_fclc, &my_fclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fclc.a == my_fclc2.a);
-     test(my_fclc.b == my_fclc2.b);
-     test(my_fclc.c == my_fclc2.c);
-     test(my_fclc.d == my_fclc2.d);
-     if (!failed) VERB0("Passed fclc");
-  }
-  write_read(gras_datadesc_by_symbol(fcLc), &my_fcLc, &my_fcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcLc.a == my_fcLc2.a);
-     test(my_fcLc.b == my_fcLc2.b);
-     test(my_fcLc.c == my_fcLc2.c);
-     test(my_fcLc.d == my_fcLc2.d);
-     if (!failed) VERB0("Passed fcLc");
-  }
-  write_read(gras_datadesc_by_symbol(fcfc), &my_fcfc, &my_fcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcfc.a == my_fcfc2.a);
-     test(my_fcfc.b == my_fcfc2.b);
-     test(my_fcfc.c == my_fcfc2.c);
-     test(my_fcfc.d == my_fcfc2.d);
-     if (!failed) VERB0("Passed fcfc");
-  }
-  write_read(gras_datadesc_by_symbol(fcdc), &my_fcdc, &my_fcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_fcdc.a == my_fcdc2.a);
-     test(my_fcdc.b == my_fcdc2.b);
-     test(my_fcdc.c == my_fcdc2.c);
-     test(my_fcdc.d == my_fcdc2.d);
-     if (!failed) VERB0("Passed fcdc");
-  }
-  write_read(gras_datadesc_by_symbol(dccc), &my_dccc, &my_dccc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dccc.a == my_dccc2.a);
-     test(my_dccc.b == my_dccc2.b);
-     test(my_dccc.c == my_dccc2.c);
-     test(my_dccc.d == my_dccc2.d);
-     if (!failed) VERB0("Passed dccc");
-  }
-  write_read(gras_datadesc_by_symbol(dcsc), &my_dcsc, &my_dcsc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcsc.a == my_dcsc2.a);
-     test(my_dcsc.b == my_dcsc2.b);
-     test(my_dcsc.c == my_dcsc2.c);
-     test(my_dcsc.d == my_dcsc2.d);
-     if (!failed) VERB0("Passed dcsc");
-  }
-  write_read(gras_datadesc_by_symbol(dcic), &my_dcic, &my_dcic2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcic.a == my_dcic2.a);
-     test(my_dcic.b == my_dcic2.b);
-     test(my_dcic.c == my_dcic2.c);
-     test(my_dcic.d == my_dcic2.d);
-     if (!failed) VERB0("Passed dcic");
-  }
-  write_read(gras_datadesc_by_symbol(dclc), &my_dclc, &my_dclc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dclc.a == my_dclc2.a);
-     test(my_dclc.b == my_dclc2.b);
-     test(my_dclc.c == my_dclc2.c);
-     test(my_dclc.d == my_dclc2.d);
-     if (!failed) VERB0("Passed dclc");
-  }
-  write_read(gras_datadesc_by_symbol(dcLc), &my_dcLc, &my_dcLc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcLc.a == my_dcLc2.a);
-     test(my_dcLc.b == my_dcLc2.b);
-     test(my_dcLc.c == my_dcLc2.c);
-     test(my_dcLc.d == my_dcLc2.d);
-     if (!failed) VERB0("Passed dcLc");
-  }
-  write_read(gras_datadesc_by_symbol(dcfc), &my_dcfc, &my_dcfc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcfc.a == my_dcfc2.a);
-     test(my_dcfc.b == my_dcfc2.b);
-     test(my_dcfc.c == my_dcfc2.c);
-     test(my_dcfc.d == my_dcfc2.d);
-     if (!failed) VERB0("Passed dcfc");
-  }
-  write_read(gras_datadesc_by_symbol(dcdc), &my_dcdc, &my_dcdc2, sock,direction);
-  if (direction == READ || direction == RW) {
-     int failed = 0;
-     test(my_dcdc.a == my_dcdc2.a);
-     test(my_dcdc.b == my_dcdc2.b);
-     test(my_dcdc.c == my_dcdc2.c);
-     test(my_dcdc.d == my_dcdc2.d);
-     if (!failed) VERB0("Passed dcdc");
+void test_structures(gras_socket_t * sock, int direction);
+void test_structures(gras_socket_t * sock, int direction)
+{
+  struct cccc my_cccc =
+      { 'w' + (char) 1, 'w' + (char) 2, 'w' + (char) 3, 'w' + (char) 4 },
+      my_cccc2;
+  struct ccsc my_ccsc =
+      { 'w' + (char) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_ccsc2;
+  struct ccic my_ccic =
+      { 'w' + (char) 1, 'w' + (char) 2, -11249 + (int) 3, 'w' + (char) 4 },
+      my_ccic2;
+  struct cclc my_cclc =
+      { 'w' + (char) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_cclc2;
+  struct ccLc my_ccLc =
+      { 'w' + (char) 1, 'w' + (char) 2, -232130010 + (long long int) 3,
+'w' + (char) 4 }, my_ccLc2;
+  struct ccfc my_ccfc =
+      { 'w' + (char) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_ccfc2;
+  struct ccdc my_ccdc =
+      { 'w' + (char) 1, 'w' + (char) 2, 1424420.11331 + (double) 3,
+'w' + (char) 4 }, my_ccdc2;
+  struct sccc my_sccc =
+      { 134 + (short int) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_sccc2;
+  struct scsc my_scsc =
+      { 134 + (short int) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_scsc2;
+  struct scic my_scic =
+      { 134 + (short int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_scic2;
+  struct sclc my_sclc =
+      { 134 + (short int) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_sclc2;
+  struct scLc my_scLc =
+      { 134 + (short int) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_scLc2;
+  struct scfc my_scfc =
+      { 134 + (short int) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_scfc2;
+  struct scdc my_scdc =
+      { 134 + (short int) 1, 'w' + (char) 2, 1424420.11331 + (double) 3,
+'w' + (char) 4 }, my_scdc2;
+  struct iccc my_iccc =
+      { -11249 + (int) 1, 'w' + (char) 2, 'w' + (char) 3, 'w' + (char) 4 },
+      my_iccc2;
+  struct icsc my_icsc =
+      { -11249 + (int) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_icsc2;
+  struct icic my_icic =
+      { -11249 + (int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_icic2;
+  struct iclc my_iclc =
+      { -11249 + (int) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_iclc2;
+  struct icLc my_icLc =
+      { -11249 + (int) 1, 'w' + (char) 2, -232130010 + (long long int) 3,
+'w' + (char) 4 }, my_icLc2;
+  struct icfc my_icfc =
+      { -11249 + (int) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_icfc2;
+  struct icdc my_icdc =
+      { -11249 + (int) 1, 'w' + (char) 2, 1424420.11331 + (double) 3,
+'w' + (char) 4 }, my_icdc2;
+  struct lccc my_lccc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_lccc2;
+  struct lcsc my_lcsc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_lcsc2;
+  struct lcic my_lcic =
+      { 31319919 + (long int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_lcic2;
+  struct lclc my_lclc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_lclc2;
+  struct lcLc my_lcLc =
+      { 31319919 + (long int) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_lcLc2;
+  struct lcfc my_lcfc =
+      { 31319919 + (long int) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_lcfc2;
+  struct lcdc my_lcdc =
+      { 31319919 + (long int) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_lcdc2;
+  struct Lccc my_Lccc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_Lccc2;
+  struct Lcsc my_Lcsc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+134 + (short int) 3, 'w' + (char) 4 }, my_Lcsc2;
+  struct Lcic my_Lcic =
+      { -232130010 + (long long int) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_Lcic2;
+  struct Lclc my_Lclc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+31319919 + (long int) 3, 'w' + (char) 4 }, my_Lclc2;
+  struct LcLc my_LcLc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_LcLc2;
+  struct Lcfc my_Lcfc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+-11313.1135 + (float) 3, 'w' + (char) 4 }, my_Lcfc2;
+  struct Lcdc my_Lcdc =
+      { -232130010 + (long long int) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_Lcdc2;
+  struct fccc my_fccc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_fccc2;
+  struct fcsc my_fcsc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_fcsc2;
+  struct fcic my_fcic =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_fcic2;
+  struct fclc my_fclc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, 31319919 + (long int) 3,
+'w' + (char) 4 }, my_fclc2;
+  struct fcLc my_fcLc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_fcLc2;
+  struct fcfc my_fcfc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2, -11313.1135 + (float) 3,
+'w' + (char) 4 }, my_fcfc2;
+  struct fcdc my_fcdc =
+      { -11313.1135 + (float) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_fcdc2;
+  struct dccc my_dccc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2, 'w' + (char) 3,
+'w' + (char) 4 }, my_dccc2;
+  struct dcsc my_dcsc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2, 134 + (short int) 3,
+'w' + (char) 4 }, my_dcsc2;
+  struct dcic my_dcic =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2, -11249 + (int) 3,
+'w' + (char) 4 }, my_dcic2;
+  struct dclc my_dclc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+31319919 + (long int) 3, 'w' + (char) 4 }, my_dclc2;
+  struct dcLc my_dcLc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+-232130010 + (long long int) 3, 'w' + (char) 4 }, my_dcLc2;
+  struct dcfc my_dcfc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+-11313.1135 + (float) 3, 'w' + (char) 4 }, my_dcfc2;
+  struct dcdc my_dcdc =
+      { 1424420.11331 + (double) 1, 'w' + (char) 2,
+1424420.11331 + (double) 3, 'w' + (char) 4 }, my_dcdc2;
+  INFO0
+      ("---- Test on all possible struct having 3 fields (49 structs) ----");
+  write_read(gras_datadesc_by_symbol(cccc), &my_cccc, &my_cccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_cccc.a == my_cccc2.a);
+    test(my_cccc.b == my_cccc2.b);
+    test(my_cccc.c == my_cccc2.c);
+    test(my_cccc.d == my_cccc2.d);
+    if (!failed)
+      VERB0("Passed cccc");
+  }
+  write_read(gras_datadesc_by_symbol(ccsc), &my_ccsc, &my_ccsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccsc.a == my_ccsc2.a);
+    test(my_ccsc.b == my_ccsc2.b);
+    test(my_ccsc.c == my_ccsc2.c);
+    test(my_ccsc.d == my_ccsc2.d);
+    if (!failed)
+      VERB0("Passed ccsc");
+  }
+  write_read(gras_datadesc_by_symbol(ccic), &my_ccic, &my_ccic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccic.a == my_ccic2.a);
+    test(my_ccic.b == my_ccic2.b);
+    test(my_ccic.c == my_ccic2.c);
+    test(my_ccic.d == my_ccic2.d);
+    if (!failed)
+      VERB0("Passed ccic");
+  }
+  write_read(gras_datadesc_by_symbol(cclc), &my_cclc, &my_cclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_cclc.a == my_cclc2.a);
+    test(my_cclc.b == my_cclc2.b);
+    test(my_cclc.c == my_cclc2.c);
+    test(my_cclc.d == my_cclc2.d);
+    if (!failed)
+      VERB0("Passed cclc");
+  }
+  write_read(gras_datadesc_by_symbol(ccLc), &my_ccLc, &my_ccLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccLc.a == my_ccLc2.a);
+    test(my_ccLc.b == my_ccLc2.b);
+    test(my_ccLc.c == my_ccLc2.c);
+    test(my_ccLc.d == my_ccLc2.d);
+    if (!failed)
+      VERB0("Passed ccLc");
+  }
+  write_read(gras_datadesc_by_symbol(ccfc), &my_ccfc, &my_ccfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccfc.a == my_ccfc2.a);
+    test(my_ccfc.b == my_ccfc2.b);
+    test(my_ccfc.c == my_ccfc2.c);
+    test(my_ccfc.d == my_ccfc2.d);
+    if (!failed)
+      VERB0("Passed ccfc");
+  }
+  write_read(gras_datadesc_by_symbol(ccdc), &my_ccdc, &my_ccdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_ccdc.a == my_ccdc2.a);
+    test(my_ccdc.b == my_ccdc2.b);
+    test(my_ccdc.c == my_ccdc2.c);
+    test(my_ccdc.d == my_ccdc2.d);
+    if (!failed)
+      VERB0("Passed ccdc");
+  }
+  write_read(gras_datadesc_by_symbol(sccc), &my_sccc, &my_sccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_sccc.a == my_sccc2.a);
+    test(my_sccc.b == my_sccc2.b);
+    test(my_sccc.c == my_sccc2.c);
+    test(my_sccc.d == my_sccc2.d);
+    if (!failed)
+      VERB0("Passed sccc");
+  }
+  write_read(gras_datadesc_by_symbol(scsc), &my_scsc, &my_scsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scsc.a == my_scsc2.a);
+    test(my_scsc.b == my_scsc2.b);
+    test(my_scsc.c == my_scsc2.c);
+    test(my_scsc.d == my_scsc2.d);
+    if (!failed)
+      VERB0("Passed scsc");
+  }
+  write_read(gras_datadesc_by_symbol(scic), &my_scic, &my_scic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scic.a == my_scic2.a);
+    test(my_scic.b == my_scic2.b);
+    test(my_scic.c == my_scic2.c);
+    test(my_scic.d == my_scic2.d);
+    if (!failed)
+      VERB0("Passed scic");
+  }
+  write_read(gras_datadesc_by_symbol(sclc), &my_sclc, &my_sclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_sclc.a == my_sclc2.a);
+    test(my_sclc.b == my_sclc2.b);
+    test(my_sclc.c == my_sclc2.c);
+    test(my_sclc.d == my_sclc2.d);
+    if (!failed)
+      VERB0("Passed sclc");
+  }
+  write_read(gras_datadesc_by_symbol(scLc), &my_scLc, &my_scLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scLc.a == my_scLc2.a);
+    test(my_scLc.b == my_scLc2.b);
+    test(my_scLc.c == my_scLc2.c);
+    test(my_scLc.d == my_scLc2.d);
+    if (!failed)
+      VERB0("Passed scLc");
+  }
+  write_read(gras_datadesc_by_symbol(scfc), &my_scfc, &my_scfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scfc.a == my_scfc2.a);
+    test(my_scfc.b == my_scfc2.b);
+    test(my_scfc.c == my_scfc2.c);
+    test(my_scfc.d == my_scfc2.d);
+    if (!failed)
+      VERB0("Passed scfc");
+  }
+  write_read(gras_datadesc_by_symbol(scdc), &my_scdc, &my_scdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_scdc.a == my_scdc2.a);
+    test(my_scdc.b == my_scdc2.b);
+    test(my_scdc.c == my_scdc2.c);
+    test(my_scdc.d == my_scdc2.d);
+    if (!failed)
+      VERB0("Passed scdc");
+  }
+  write_read(gras_datadesc_by_symbol(iccc), &my_iccc, &my_iccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_iccc.a == my_iccc2.a);
+    test(my_iccc.b == my_iccc2.b);
+    test(my_iccc.c == my_iccc2.c);
+    test(my_iccc.d == my_iccc2.d);
+    if (!failed)
+      VERB0("Passed iccc");
+  }
+  write_read(gras_datadesc_by_symbol(icsc), &my_icsc, &my_icsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icsc.a == my_icsc2.a);
+    test(my_icsc.b == my_icsc2.b);
+    test(my_icsc.c == my_icsc2.c);
+    test(my_icsc.d == my_icsc2.d);
+    if (!failed)
+      VERB0("Passed icsc");
+  }
+  write_read(gras_datadesc_by_symbol(icic), &my_icic, &my_icic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icic.a == my_icic2.a);
+    test(my_icic.b == my_icic2.b);
+    test(my_icic.c == my_icic2.c);
+    test(my_icic.d == my_icic2.d);
+    if (!failed)
+      VERB0("Passed icic");
+  }
+  write_read(gras_datadesc_by_symbol(iclc), &my_iclc, &my_iclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_iclc.a == my_iclc2.a);
+    test(my_iclc.b == my_iclc2.b);
+    test(my_iclc.c == my_iclc2.c);
+    test(my_iclc.d == my_iclc2.d);
+    if (!failed)
+      VERB0("Passed iclc");
+  }
+  write_read(gras_datadesc_by_symbol(icLc), &my_icLc, &my_icLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icLc.a == my_icLc2.a);
+    test(my_icLc.b == my_icLc2.b);
+    test(my_icLc.c == my_icLc2.c);
+    test(my_icLc.d == my_icLc2.d);
+    if (!failed)
+      VERB0("Passed icLc");
+  }
+  write_read(gras_datadesc_by_symbol(icfc), &my_icfc, &my_icfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icfc.a == my_icfc2.a);
+    test(my_icfc.b == my_icfc2.b);
+    test(my_icfc.c == my_icfc2.c);
+    test(my_icfc.d == my_icfc2.d);
+    if (!failed)
+      VERB0("Passed icfc");
+  }
+  write_read(gras_datadesc_by_symbol(icdc), &my_icdc, &my_icdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_icdc.a == my_icdc2.a);
+    test(my_icdc.b == my_icdc2.b);
+    test(my_icdc.c == my_icdc2.c);
+    test(my_icdc.d == my_icdc2.d);
+    if (!failed)
+      VERB0("Passed icdc");
+  }
+  write_read(gras_datadesc_by_symbol(lccc), &my_lccc, &my_lccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lccc.a == my_lccc2.a);
+    test(my_lccc.b == my_lccc2.b);
+    test(my_lccc.c == my_lccc2.c);
+    test(my_lccc.d == my_lccc2.d);
+    if (!failed)
+      VERB0("Passed lccc");
+  }
+  write_read(gras_datadesc_by_symbol(lcsc), &my_lcsc, &my_lcsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcsc.a == my_lcsc2.a);
+    test(my_lcsc.b == my_lcsc2.b);
+    test(my_lcsc.c == my_lcsc2.c);
+    test(my_lcsc.d == my_lcsc2.d);
+    if (!failed)
+      VERB0("Passed lcsc");
+  }
+  write_read(gras_datadesc_by_symbol(lcic), &my_lcic, &my_lcic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcic.a == my_lcic2.a);
+    test(my_lcic.b == my_lcic2.b);
+    test(my_lcic.c == my_lcic2.c);
+    test(my_lcic.d == my_lcic2.d);
+    if (!failed)
+      VERB0("Passed lcic");
+  }
+  write_read(gras_datadesc_by_symbol(lclc), &my_lclc, &my_lclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lclc.a == my_lclc2.a);
+    test(my_lclc.b == my_lclc2.b);
+    test(my_lclc.c == my_lclc2.c);
+    test(my_lclc.d == my_lclc2.d);
+    if (!failed)
+      VERB0("Passed lclc");
+  }
+  write_read(gras_datadesc_by_symbol(lcLc), &my_lcLc, &my_lcLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcLc.a == my_lcLc2.a);
+    test(my_lcLc.b == my_lcLc2.b);
+    test(my_lcLc.c == my_lcLc2.c);
+    test(my_lcLc.d == my_lcLc2.d);
+    if (!failed)
+      VERB0("Passed lcLc");
+  }
+  write_read(gras_datadesc_by_symbol(lcfc), &my_lcfc, &my_lcfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcfc.a == my_lcfc2.a);
+    test(my_lcfc.b == my_lcfc2.b);
+    test(my_lcfc.c == my_lcfc2.c);
+    test(my_lcfc.d == my_lcfc2.d);
+    if (!failed)
+      VERB0("Passed lcfc");
+  }
+  write_read(gras_datadesc_by_symbol(lcdc), &my_lcdc, &my_lcdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_lcdc.a == my_lcdc2.a);
+    test(my_lcdc.b == my_lcdc2.b);
+    test(my_lcdc.c == my_lcdc2.c);
+    test(my_lcdc.d == my_lcdc2.d);
+    if (!failed)
+      VERB0("Passed lcdc");
+  }
+  write_read(gras_datadesc_by_symbol(Lccc), &my_Lccc, &my_Lccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lccc.a == my_Lccc2.a);
+    test(my_Lccc.b == my_Lccc2.b);
+    test(my_Lccc.c == my_Lccc2.c);
+    test(my_Lccc.d == my_Lccc2.d);
+    if (!failed)
+      VERB0("Passed Lccc");
+  }
+  write_read(gras_datadesc_by_symbol(Lcsc), &my_Lcsc, &my_Lcsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcsc.a == my_Lcsc2.a);
+    test(my_Lcsc.b == my_Lcsc2.b);
+    test(my_Lcsc.c == my_Lcsc2.c);
+    test(my_Lcsc.d == my_Lcsc2.d);
+    if (!failed)
+      VERB0("Passed Lcsc");
+  }
+  write_read(gras_datadesc_by_symbol(Lcic), &my_Lcic, &my_Lcic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcic.a == my_Lcic2.a);
+    test(my_Lcic.b == my_Lcic2.b);
+    test(my_Lcic.c == my_Lcic2.c);
+    test(my_Lcic.d == my_Lcic2.d);
+    if (!failed)
+      VERB0("Passed Lcic");
+  }
+  write_read(gras_datadesc_by_symbol(Lclc), &my_Lclc, &my_Lclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lclc.a == my_Lclc2.a);
+    test(my_Lclc.b == my_Lclc2.b);
+    test(my_Lclc.c == my_Lclc2.c);
+    test(my_Lclc.d == my_Lclc2.d);
+    if (!failed)
+      VERB0("Passed Lclc");
+  }
+  write_read(gras_datadesc_by_symbol(LcLc), &my_LcLc, &my_LcLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_LcLc.a == my_LcLc2.a);
+    test(my_LcLc.b == my_LcLc2.b);
+    test(my_LcLc.c == my_LcLc2.c);
+    test(my_LcLc.d == my_LcLc2.d);
+    if (!failed)
+      VERB0("Passed LcLc");
+  }
+  write_read(gras_datadesc_by_symbol(Lcfc), &my_Lcfc, &my_Lcfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcfc.a == my_Lcfc2.a);
+    test(my_Lcfc.b == my_Lcfc2.b);
+    test(my_Lcfc.c == my_Lcfc2.c);
+    test(my_Lcfc.d == my_Lcfc2.d);
+    if (!failed)
+      VERB0("Passed Lcfc");
+  }
+  write_read(gras_datadesc_by_symbol(Lcdc), &my_Lcdc, &my_Lcdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_Lcdc.a == my_Lcdc2.a);
+    test(my_Lcdc.b == my_Lcdc2.b);
+    test(my_Lcdc.c == my_Lcdc2.c);
+    test(my_Lcdc.d == my_Lcdc2.d);
+    if (!failed)
+      VERB0("Passed Lcdc");
+  }
+  write_read(gras_datadesc_by_symbol(fccc), &my_fccc, &my_fccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fccc.a == my_fccc2.a);
+    test(my_fccc.b == my_fccc2.b);
+    test(my_fccc.c == my_fccc2.c);
+    test(my_fccc.d == my_fccc2.d);
+    if (!failed)
+      VERB0("Passed fccc");
+  }
+  write_read(gras_datadesc_by_symbol(fcsc), &my_fcsc, &my_fcsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcsc.a == my_fcsc2.a);
+    test(my_fcsc.b == my_fcsc2.b);
+    test(my_fcsc.c == my_fcsc2.c);
+    test(my_fcsc.d == my_fcsc2.d);
+    if (!failed)
+      VERB0("Passed fcsc");
+  }
+  write_read(gras_datadesc_by_symbol(fcic), &my_fcic, &my_fcic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcic.a == my_fcic2.a);
+    test(my_fcic.b == my_fcic2.b);
+    test(my_fcic.c == my_fcic2.c);
+    test(my_fcic.d == my_fcic2.d);
+    if (!failed)
+      VERB0("Passed fcic");
+  }
+  write_read(gras_datadesc_by_symbol(fclc), &my_fclc, &my_fclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fclc.a == my_fclc2.a);
+    test(my_fclc.b == my_fclc2.b);
+    test(my_fclc.c == my_fclc2.c);
+    test(my_fclc.d == my_fclc2.d);
+    if (!failed)
+      VERB0("Passed fclc");
+  }
+  write_read(gras_datadesc_by_symbol(fcLc), &my_fcLc, &my_fcLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcLc.a == my_fcLc2.a);
+    test(my_fcLc.b == my_fcLc2.b);
+    test(my_fcLc.c == my_fcLc2.c);
+    test(my_fcLc.d == my_fcLc2.d);
+    if (!failed)
+      VERB0("Passed fcLc");
+  }
+  write_read(gras_datadesc_by_symbol(fcfc), &my_fcfc, &my_fcfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcfc.a == my_fcfc2.a);
+    test(my_fcfc.b == my_fcfc2.b);
+    test(my_fcfc.c == my_fcfc2.c);
+    test(my_fcfc.d == my_fcfc2.d);
+    if (!failed)
+      VERB0("Passed fcfc");
+  }
+  write_read(gras_datadesc_by_symbol(fcdc), &my_fcdc, &my_fcdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_fcdc.a == my_fcdc2.a);
+    test(my_fcdc.b == my_fcdc2.b);
+    test(my_fcdc.c == my_fcdc2.c);
+    test(my_fcdc.d == my_fcdc2.d);
+    if (!failed)
+      VERB0("Passed fcdc");
+  }
+  write_read(gras_datadesc_by_symbol(dccc), &my_dccc, &my_dccc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dccc.a == my_dccc2.a);
+    test(my_dccc.b == my_dccc2.b);
+    test(my_dccc.c == my_dccc2.c);
+    test(my_dccc.d == my_dccc2.d);
+    if (!failed)
+      VERB0("Passed dccc");
+  }
+  write_read(gras_datadesc_by_symbol(dcsc), &my_dcsc, &my_dcsc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcsc.a == my_dcsc2.a);
+    test(my_dcsc.b == my_dcsc2.b);
+    test(my_dcsc.c == my_dcsc2.c);
+    test(my_dcsc.d == my_dcsc2.d);
+    if (!failed)
+      VERB0("Passed dcsc");
+  }
+  write_read(gras_datadesc_by_symbol(dcic), &my_dcic, &my_dcic2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcic.a == my_dcic2.a);
+    test(my_dcic.b == my_dcic2.b);
+    test(my_dcic.c == my_dcic2.c);
+    test(my_dcic.d == my_dcic2.d);
+    if (!failed)
+      VERB0("Passed dcic");
+  }
+  write_read(gras_datadesc_by_symbol(dclc), &my_dclc, &my_dclc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dclc.a == my_dclc2.a);
+    test(my_dclc.b == my_dclc2.b);
+    test(my_dclc.c == my_dclc2.c);
+    test(my_dclc.d == my_dclc2.d);
+    if (!failed)
+      VERB0("Passed dclc");
+  }
+  write_read(gras_datadesc_by_symbol(dcLc), &my_dcLc, &my_dcLc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcLc.a == my_dcLc2.a);
+    test(my_dcLc.b == my_dcLc2.b);
+    test(my_dcLc.c == my_dcLc2.c);
+    test(my_dcLc.d == my_dcLc2.d);
+    if (!failed)
+      VERB0("Passed dcLc");
+  }
+  write_read(gras_datadesc_by_symbol(dcfc), &my_dcfc, &my_dcfc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcfc.a == my_dcfc2.a);
+    test(my_dcfc.b == my_dcfc2.b);
+    test(my_dcfc.c == my_dcfc2.c);
+    test(my_dcfc.d == my_dcfc2.d);
+    if (!failed)
+      VERB0("Passed dcfc");
+  }
+  write_read(gras_datadesc_by_symbol(dcdc), &my_dcdc, &my_dcdc2, sock,
+             direction);
+  if (direction == READ || direction == RW) {
+    int failed = 0;
+    test(my_dcdc.a == my_dcdc2.a);
+    test(my_dcdc.b == my_dcdc2.b);
+    test(my_dcdc.c == my_dcdc2.c);
+    test(my_dcdc.d == my_dcdc2.d);
+    if (!failed)
+      VERB0("Passed dcdc");
   }
 }
index e133fbf..b5027f6 100644 (file)
@@ -15,7 +15,7 @@
 #include "..\..\..\..\include\gras\datadesc.h"
 
 #include "gras/DataDesc/datadesc_interface.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this test");
 
 #define READ  0
 #define WRITE 1
@@ -23,37 +23,39 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 #define RW    3
 
 int r_arch;
-const char *filename = "datadesc_usage.out";  
+const char *filename = "datadesc_usage.out";
 
 void
-write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t sock, int direction);
+write_read(gras_datadesc_type_t type, void *src, void *dst,
+           gras_socket_t sock, int direction);
 
 void
-write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t sock, int direction) 
+write_read(gras_datadesc_type_t type, void *src, void *dst,
+           gras_socket_t sock, int direction)
 {
-   
-       /* write */
-       if (direction == RW) 
-               sock = gras_socket_client_from_file(filename);
-       
-       if (direction == WRITE || direction == RW)
-               gras_datadesc_send(sock, type, src);
-       
-       if (direction == RW) 
-               gras_socket_close(sock);
-       
-       /* read */
-       if (direction == RW) 
-               sock = gras_socket_server_from_file(filename);
-       
-       if (direction == READ || direction == RW)
-               gras_datadesc_recv(sock, type, r_arch, dst);
-       
-       if (direction == RW) 
-               gras_socket_close(sock);
-       
-       if (direction == COPY)
-               gras_datadesc_copy(type, src, dst);
+
+  /* write */
+  if (direction == RW)
+    sock = gras_socket_client_from_file(filename);
+
+  if (direction == WRITE || direction == RW)
+    gras_datadesc_send(sock, type, src);
+
+  if (direction == RW)
+    gras_socket_close(sock);
+
+  /* read */
+  if (direction == RW)
+    sock = gras_socket_server_from_file(filename);
+
+  if (direction == READ || direction == RW)
+    gras_datadesc_recv(sock, type, r_arch, dst);
+
+  if (direction == RW)
+    gras_socket_close(sock);
+
+  if (direction == COPY)
+    gras_datadesc_copy(type, src, dst);
 }
 
 void test_int(gras_socket_t sock, int direction);
@@ -75,190 +77,188 @@ void test_pbio(gras_socket_t sock, int direction);
 void test_clause(gras_socket_t sock, int direction);
 
 /* defined in datadesc_structures.c, which in perl generated */
-void test_structures(gras_socket_t sock, int direction); 
+void test_structures(gras_socket_t sock, int direction);
 
-void test_int(gras_socket_t sock, int direction) 
+void test_int(gras_socket_t sock, int direction)
 {
-       int i=5,j;
-       
-       INFO0("---- Test on integer ----");
+  int i = 5, j;
+
+  INFO0("---- Test on integer ----");
 
-       write_read(gras_datadesc_by_name("int"), &i,&j, sock,direction);
+  write_read(gras_datadesc_by_name("int"), &i, &j, sock, direction);
 
-       if (direction == READ || direction == RW || direction == COPY)
-               xbt_assert(i == j);
+  if (direction == READ || direction == RW || direction == COPY)
+    xbt_assert(i == j);
 }
-void test_float(gras_socket_t sock, int direction) 
+
+void test_float(gras_socket_t sock, int direction)
 {
-       float i=5.0,j;
-       
-       INFO0("---- Test on float ----");
-       write_read(gras_datadesc_by_name("float"), &i,&j, sock,direction);
-       
-       if (direction == READ || direction == RW || direction == COPY)
-               xbt_assert2(i == j,"%f != %f",i,j);
+  float i = 5.0, j;
+
+  INFO0("---- Test on float ----");
+  write_read(gras_datadesc_by_name("float"), &i, &j, sock, direction);
+
+  if (direction == READ || direction == RW || direction == COPY)
+    xbt_assert2(i == j, "%f != %f", i, j);
 }
-void test_double(gras_socket_t sock, int direction) 
+
+void test_double(gras_socket_t sock, int direction)
 {
-       double i=-3252355.1234,j;
-       
-       INFO0("---- Test on double ----");
-       write_read(gras_datadesc_by_name("double"), &i,&j, sock,direction);
-       
-       if (direction == READ || direction == RW || direction == COPY)
-               xbt_assert2(i == j,"%f != %f",i,j);
+  double i = -3252355.1234, j;
+
+  INFO0("---- Test on double ----");
+  write_read(gras_datadesc_by_name("double"), &i, &j, sock, direction);
+
+  if (direction == READ || direction == RW || direction == COPY)
+    xbt_assert2(i == j, "%f != %f", i, j);
 }
 
 #define SIZE 5
 typedef int array[SIZE];
 
-void test_array(gras_socket_t sock, int direction) 
+void test_array(gras_socket_t sock, int direction)
 {
-       gras_datadesc_type_t my_type;
-       
-       array i = { 35212,-6226,74337,11414,7733};
-       array j;
-       int cpt;
-       
-       INFO0("---- Test on fixed array ----");
-       
-       my_type=gras_datadesc_array_fixed("fixed int array", gras_datadesc_by_name("int"),SIZE);
-       
-       write_read(my_type, &i,&j, sock,direction);
-       
-       if (direction == READ || direction == RW || direction == COPY) 
-       {
-               for (cpt=0; cpt<SIZE; cpt++) 
-               {
-                       DEBUG1("Test spot %d",cpt);
-                       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%d  !=  j[%d]=%d",cpt,i[cpt],cpt,j[cpt]);
-               }
-       }
+  gras_datadesc_type_t my_type;
+
+  array i = { 35212, -6226, 74337, 11414, 7733 };
+  array j;
+  int cpt;
+
+  INFO0("---- Test on fixed array ----");
+
+  my_type =
+      gras_datadesc_array_fixed("fixed int array",
+                                gras_datadesc_by_name("int"), SIZE);
+
+  write_read(my_type, &i, &j, sock, direction);
+
+  if (direction == READ || direction == RW || direction == COPY) {
+    for (cpt = 0; cpt < SIZE; cpt++) {
+      DEBUG1("Test spot %d", cpt);
+      xbt_assert4(i[cpt] == j[cpt], "i[%d]=%d  !=  j[%d]=%d", cpt, i[cpt],
+                  cpt, j[cpt]);
+    }
+  }
 }
+
 /*** Dynar of scalar ***/
 
 void test_dynar_scal(gras_socket_t sock, int direction)
 {
-       gras_datadesc_type_t my_type;
-       xbt_dynar_t i,j;
-       int cpt;
-       
-       INFO0("---- Test on dynar containing integers ----");
-       my_type = gras_datadesc_dynar(gras_datadesc_by_name("int"),NULL);
-       i = xbt_dynar_new(sizeof(int),NULL);
-
-       for (cpt=0; cpt<64; cpt++) 
-       {
-               xbt_dynar_push_as(i,int,cpt); 
-               DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(i));
-       }
-       
-       /*  xbt_dynar_dump(i);*/
-       write_read(my_type, &i,&j, sock, direction);
-       
-       /*  xbt_dynar_dump(j);*/
-       if (direction == READ || direction == RW || direction == COPY) 
-       {
-               for (cpt=0; cpt<64; cpt++)
-               {
-                       int ret=xbt_dynar_get_as(j,cpt,int);
-                       
-                       if (cpt != ret) 
-                       {
-                               CRITICAL3("The retrieved value for cpt=%d is not the same than the injected one (%d!=%d)",cpt,ret,cpt);
-                               xbt_abort();
-                       }
-               }
-               
-               xbt_dynar_free(&j);
-       }
-       
-       xbt_dynar_free(&i);
+  gras_datadesc_type_t my_type;
+  xbt_dynar_t i, j;
+  int cpt;
+
+  INFO0("---- Test on dynar containing integers ----");
+  my_type = gras_datadesc_dynar(gras_datadesc_by_name("int"), NULL);
+  i = xbt_dynar_new(sizeof(int), NULL);
+
+  for (cpt = 0; cpt < 64; cpt++) {
+    xbt_dynar_push_as(i, int, cpt);
+    DEBUG2("Push %d, length=%lu", cpt, xbt_dynar_length(i));
+  }
+
+  /*  xbt_dynar_dump(i); */
+  write_read(my_type, &i, &j, sock, direction);
+
+  /*  xbt_dynar_dump(j); */
+  if (direction == READ || direction == RW || direction == COPY) {
+    for (cpt = 0; cpt < 64; cpt++) {
+      int ret = xbt_dynar_get_as(j, cpt, int);
+
+      if (cpt != ret) {
+        CRITICAL3
+            ("The retrieved value for cpt=%d is not the same than the injected one (%d!=%d)",
+             cpt, ret, cpt);
+        xbt_abort();
+      }
+    }
+
+    xbt_dynar_free(&j);
+  }
+
+  xbt_dynar_free(&i);
 }
 
-void test_intref(gras_socket_t sock, int direction) 
+void test_intref(gras_socket_t sock, int direction)
 {
-       gras_datadesc_type_t my_type;
-       int *i,*j;
-       
-       i=xbt_new(int,1);
-       *i=12345;
-       
-       INFO1("---- Test on a reference to an integer (%p) ----",i);
-       
-       my_type = gras_datadesc_ref("int*",gras_datadesc_by_name("int"));
-       
-       write_read(my_type, &i,&j, sock,direction);
-       if (direction == READ || direction == RW || direction == COPY) 
-       {
-               xbt_assert2(*i == *j,"*i != *j (%d != %d)",*i,*j);
-               free(j);
-       }
-       
-       free(i);
+  gras_datadesc_type_t my_type;
+  int *i, *j;
+
+  i = xbt_new(int, 1);
+  *i = 12345;
+
+  INFO1("---- Test on a reference to an integer (%p) ----", i);
+
+  my_type = gras_datadesc_ref("int*", gras_datadesc_by_name("int"));
+
+  write_read(my_type, &i, &j, sock, direction);
+  if (direction == READ || direction == RW || direction == COPY) {
+    xbt_assert2(*i == *j, "*i != *j (%d != %d)", *i, *j);
+    free(j);
+  }
+
+  free(i);
 }
 
 /***
  *** string (dynamic array)
- ***/ 
+ ***/
 void test_string(gras_socket_t sock, int direction)
 {
-       char *i=xbt_strdup("Some data"), *j=NULL;
-       int cpt;
-       
-       INFO0("---- Test on string (ref to dynamic array) ----");
-       write_read(gras_datadesc_by_name("string"), &i,&j,sock,direction);
-       
-       if (direction == READ || direction == RW || direction == COPY) 
-       {
-               for (cpt=0; cpt<strlen(i); cpt++)
-               {
-                       xbt_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",cpt,i[cpt],cpt,j[cpt]);
-               }
-               
-               free(j);
-       }
-       
-       free(i);
+  char *i = xbt_strdup("Some data"), *j = NULL;
+  int cpt;
+
+  INFO0("---- Test on string (ref to dynamic array) ----");
+  write_read(gras_datadesc_by_name("string"), &i, &j, sock, direction);
+
+  if (direction == READ || direction == RW || direction == COPY) {
+    for (cpt = 0; cpt < strlen(i); cpt++) {
+      xbt_assert4(i[cpt] == j[cpt], "i[%d]=%c  !=  j[%d]=%c", cpt, i[cpt],
+                  cpt, j[cpt]);
+    }
+
+    free(j);
+  }
+
+  free(i);
 }
 
 
 /***
  *** homogeneous struct
- ***/ 
-typedef struct 
-{
-  int a,b,c,d;
+ ***/
+typedef struct {
+  int a, b, c, d;
 } homostruct;
 
-void test_homostruct(gras_socket_t sock, int direction) 
+void test_homostruct(gras_socket_t sock, int direction)
 {
   gras_datadesc_type_t my_type;
-  homostruct *i, *j; 
+  homostruct *i, *j;
 
   INFO0("---- Test on homogeneous structure ----");
   /* create descriptor */
-  my_type=gras_datadesc_struct("homostruct");
-  gras_datadesc_struct_append(my_type,"a",
-                             gras_datadesc_by_name("signed int"));
-  gras_datadesc_struct_append(my_type,"b",
-                             gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(my_type,"c",
-                             gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(my_type,"d",
-                             gras_datadesc_by_name("int"));
+  my_type = gras_datadesc_struct("homostruct");
+  gras_datadesc_struct_append(my_type, "a",
+                              gras_datadesc_by_name("signed int"));
+  gras_datadesc_struct_append(my_type, "b", gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(my_type, "c", gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(my_type, "d", gras_datadesc_by_name("int"));
   gras_datadesc_struct_close(my_type);
-  my_type=gras_datadesc_ref("homostruct*",
-                           gras_datadesc_by_name("homostruct"));
+  my_type = gras_datadesc_ref("homostruct*",
+                              gras_datadesc_by_name("homostruct"));
 
-  /* init a value, exchange it and check its validity*/
-  i=xbt_new(homostruct,1);
-  i->a = 2235;    i->b = 433425;
-  i->c = -23423;  i->d = -235235;
+  /* init a value, exchange it and check its validity */
+  i = xbt_new(homostruct, 1);
+  i->a = 2235;
+  i->b = 433425;
+  i->c = -23423;
+  i->d = -235235;
 
-  write_read(my_type, &i,&j, sock,direction);
+  write_read(my_type, &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
-    xbt_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
+    xbt_assert2(i->a == j->a, "i->a=%d != j->a=%d", i->a, j->a);
     xbt_assert(i->b == j->b);
     xbt_assert(i->c == j->c);
     xbt_assert(i->d == j->d);
@@ -269,42 +269,48 @@ void test_homostruct(gras_socket_t sock, int direction)
 
 /***
  *** heterogeneous struct
- ***/ 
+ ***/
 typedef struct {
   unsigned char c1;
   unsigned long int l1;
   unsigned char c2;
   unsigned long int l2;
 } hetestruct;
-void test_hetestruct(gras_socket_t sock, int direction) {
+void test_hetestruct(gras_socket_t sock, int direction)
+{
   gras_datadesc_type_t my_type;
-  hetestruct *i, *j; 
+  hetestruct *i, *j;
 
   INFO0("---- Test on heterogeneous structure ----");
   /* create descriptor */
-  my_type=gras_datadesc_struct("hetestruct");
-  gras_datadesc_struct_append(my_type,"c1",
-                             gras_datadesc_by_name("unsigned char"));
-  gras_datadesc_struct_append(my_type,"l1",
-                             gras_datadesc_by_name("unsigned long int"));
-  gras_datadesc_struct_append(my_type,"c2",
-                             gras_datadesc_by_name("unsigned char"));
-  gras_datadesc_struct_append(my_type,"l2",
-                             gras_datadesc_by_name("unsigned long int"));
+  my_type = gras_datadesc_struct("hetestruct");
+  gras_datadesc_struct_append(my_type, "c1",
+                              gras_datadesc_by_name("unsigned char"));
+  gras_datadesc_struct_append(my_type, "l1",
+                              gras_datadesc_by_name("unsigned long int"));
+  gras_datadesc_struct_append(my_type, "c2",
+                              gras_datadesc_by_name("unsigned char"));
+  gras_datadesc_struct_append(my_type, "l2",
+                              gras_datadesc_by_name("unsigned long int"));
   gras_datadesc_struct_close(my_type);
-  my_type=gras_datadesc_ref("hetestruct*", gras_datadesc_by_name("hetestruct"));
+  my_type =
+      gras_datadesc_ref("hetestruct*",
+                        gras_datadesc_by_name("hetestruct"));
 
 
-  /* init a value, exchange it and check its validity*/
-  i=xbt_new(hetestruct,1);
-  i->c1 = 's'; i->l1 = 123455;
-  i->c2 = 'e'; i->l2 = 774531;
+  /* init a value, exchange it and check its validity */
+  i = xbt_new(hetestruct, 1);
+  i->c1 = 's';
+  i->l1 = 123455;
+  i->c2 = 'e';
+  i->l2 = 774531;
 
-  write_read(my_type, &i,&j, sock,direction);
+  write_read(my_type, &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
     xbt_assert(i->c1 == j->c1);
     xbt_assert(i->c2 == j->c2);
-    xbt_assert2(i->l1 == j->l1,"i->l1(=%ld)  !=  j->l1(=%ld)",i->l1,j->l1);
+    xbt_assert2(i->l1 == j->l1, "i->l1(=%ld)  !=  j->l1(=%ld)", i->l1,
+                j->l1);
     xbt_assert(i->l2 == j->l2);
     free(j);
   }
@@ -313,34 +319,41 @@ void test_hetestruct(gras_socket_t sock, int direction) {
 
 /***
  *** nested struct
- ***/ 
+ ***/
 typedef struct {
   hetestruct hete;
   homostruct homo;
 } nestedstruct;
-void test_nestedstruct(gras_socket_t sock, int direction) {
+void test_nestedstruct(gras_socket_t sock, int direction)
+{
   gras_datadesc_type_t my_type;
-  nestedstruct *i, *j; 
+  nestedstruct *i, *j;
 
   INFO0("---- Test on nested structures ----");
   /* create descriptor */
-  my_type=gras_datadesc_struct("nestedstruct");
+  my_type = gras_datadesc_struct("nestedstruct");
 
-  gras_datadesc_struct_append(my_type,"hete",
-                             gras_datadesc_by_name("hetestruct"));
-  gras_datadesc_struct_append(my_type,"homo",
-                             gras_datadesc_by_name("homostruct"));
+  gras_datadesc_struct_append(my_type, "hete",
+                              gras_datadesc_by_name("hetestruct"));
+  gras_datadesc_struct_append(my_type, "homo",
+                              gras_datadesc_by_name("homostruct"));
   gras_datadesc_struct_close(my_type);
-  my_type=gras_datadesc_ref("nestedstruct*", gras_datadesc_by_name("nestedstruct"));
-
-  /* init a value, exchange it and check its validity*/
-  i=xbt_new(nestedstruct,1);
-  i->homo.a = 235231;  i->homo.b = -124151;
-  i->homo.c = 211551;  i->homo.d = -664222;
-  i->hete.c1 = 's'; i->hete.l1 = 123455;
-  i->hete.c2 = 'e'; i->hete.l2 = 774531;
-
-  write_read(my_type, &i,&j, sock,direction);
+  my_type =
+      gras_datadesc_ref("nestedstruct*",
+                        gras_datadesc_by_name("nestedstruct"));
+
+  /* init a value, exchange it and check its validity */
+  i = xbt_new(nestedstruct, 1);
+  i->homo.a = 235231;
+  i->homo.b = -124151;
+  i->homo.c = 211551;
+  i->homo.d = -664222;
+  i->hete.c1 = 's';
+  i->hete.l1 = 123455;
+  i->hete.c2 = 'e';
+  i->hete.l2 = 774531;
+
+  write_read(my_type, &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
     xbt_assert(i->homo.a == j->homo.a);
     xbt_assert(i->homo.b == j->homo.b);
@@ -357,182 +370,193 @@ void test_nestedstruct(gras_socket_t sock, int direction) {
 
 /***
  *** chained list
- ***/ 
+ ***/
 typedef struct s_chained_list chained_list_t;
 struct s_chained_list {
-  int          v;
+  int v;
   chained_list_t *l;
 };
 void declare_chained_list_type(void);
-chained_list_t *cons(int v, chained_list_t *l);
-void list_free(chained_list_t *l);
-int list_eq(chained_list_t*i,chained_list_t*j);
+chained_list_t *cons(int v, chained_list_t * l);
+void list_free(chained_list_t * l);
+int list_eq(chained_list_t * i, chained_list_t * j);
 
-void declare_chained_list_type(void) {
-  gras_datadesc_type_t my_type,ref_my_type;
+void declare_chained_list_type(void)
+{
+  gras_datadesc_type_t my_type, ref_my_type;
 
-  my_type=gras_datadesc_struct("chained_list_t");
-  ref_my_type=gras_datadesc_ref("chained_list_t*",my_type);
+  my_type = gras_datadesc_struct("chained_list_t");
+  ref_my_type = gras_datadesc_ref("chained_list_t*", my_type);
 
-  gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int"));
-  gras_datadesc_struct_append(my_type,"l", ref_my_type);
+  gras_datadesc_struct_append(my_type, "v", gras_datadesc_by_name("int"));
+  gras_datadesc_struct_append(my_type, "l", ref_my_type);
   gras_datadesc_struct_close(my_type);
 }
 
-chained_list_t * cons(int v, chained_list_t *l) {
-  chained_list_t *nl = xbt_new(chained_list_t,1);
-  
+chained_list_t *cons(int v, chained_list_t * l)
+{
+  chained_list_t *nl = xbt_new(chained_list_t, 1);
+
   nl->v = v;
   nl->l = l;
-  
+
   return nl;
 }
-void list_free(chained_list_t*l) {
+
+void list_free(chained_list_t * l)
+{
   if (l) {
     list_free(l->l);
     free(l);
   }
 }
-int list_eq(chained_list_t*i,chained_list_t*j) {
-  if (!i || !j) return i == j;
+
+int list_eq(chained_list_t * i, chained_list_t * j)
+{
+  if (!i || !j)
+    return i == j;
   if (i->v != j->v)
     return 0;
-  return list_eq(i->l, j->l); 
+  return list_eq(i->l, j->l);
 }
-void test_chain_list(gras_socket_t sock, int direction) {
-  chained_list_t *i, *j; 
+
+void test_chain_list(gras_socket_t sock, int direction)
+{
+  chained_list_t *i, *j;
 
   INFO0("---- Test on chained list ----");
 
-  /* init a value, exchange it and check its validity*/
-  i = cons( 12355, cons( 246264 , cons( 23263, NULL)));
+  /* init a value, exchange it and check its validity */
+  i = cons(12355, cons(246264, cons(23263, NULL)));
   j = NULL;
 
   write_read(gras_datadesc_by_name("chained_list_t*"),
-            &i,&j,  sock,direction);
+             &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
-    xbt_assert(list_eq(i,j));    
+    xbt_assert(list_eq(i, j));
     list_free(j);
   }
 
   list_free(i);
 }
+
 /***
  *** graph
  ***/
-void test_graph(gras_socket_t sock, int direction) {
-  chained_list_t *i, *j; 
+void test_graph(gras_socket_t sock, int direction)
+{
+  chained_list_t *i, *j;
 
   INFO0("---- Test on graph (cyclique chained list of 3 items) ----");
-  /* init a value, exchange it and check its validity*/
-  i = cons( 1151515, cons( -232362 , cons( 222552, NULL)));
+  /* init a value, exchange it and check its validity */
+  i = cons(1151515, cons(-232362, cons(222552, NULL)));
   i->l->l->l = i;
   j = NULL;
 
   gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
   write_read(gras_datadesc_by_name("chained_list_t*"),
-            &i,&j, sock,direction);
+             &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
-    
-    DEBUG1("i=%p"         ,i);
-    DEBUG1("i->l=%p"      ,i->l);
-    DEBUG1("i->l->l=%p"   ,i->l->l);
-    DEBUG1("i->l->l->l=%p",i->l->l->l);
-    DEBUG1("j=%p"         ,j);
-    DEBUG1("j->l=%p"      ,j->l);
-    DEBUG1("j->l->l=%p"   ,j->l->l);
-    DEBUG1("j->l->l->l=%p",j->l->l->l);
+
+    DEBUG1("i=%p"i);
+    DEBUG1("i->l=%p"i->l);
+    DEBUG1("i->l->l=%p"i->l->l);
+    DEBUG1("i->l->l->l=%p", i->l->l->l);
+    DEBUG1("j=%p"j);
+    DEBUG1("j->l=%p"j->l);
+    DEBUG1("j->l->l=%p"j->l->l);
+    DEBUG1("j->l->l->l=%p", j->l->l->l);
     xbt_assert4(j->l->l->l == j,
-                "Received list is not cyclic. j=%p != j->l->l->l=%p\n"
-                "j=%p; &j=%p",
-                j,j->l->l->l, 
-                j ,&j);
+                "Received list is not cyclic. j=%p != j->l->l->l=%p\n"
+                "j=%p; &j=%p", j, j->l->l->l, j, &j);
     j->l->l->l = NULL;
     i->l->l->l = NULL;
-    xbt_assert(list_eq(i,j));
+    xbt_assert(list_eq(i, j));
 
     list_free(j);
   }
-  i->l->l->l = NULL; /* do this even in WRITE mode */
+  i->l->l->l = NULL;            /* do this even in WRITE mode */
   list_free(i);
 }
 
 
 /*** Dynar of references ***/
-static void free_string(void *d){ /* used to free the data in dynar */
-     free(*(void**)d);
+static void free_string(void *d)
+{                               /* used to free the data in dynar */
+  free(*(void **) d);
 }
-void test_dynar_ref(gras_socket_t sock, int direction){
+
+void test_dynar_ref(gras_socket_t sock, int direction)
+{
   gras_datadesc_type_t my_type;
-  xbt_dynar_t i,j;
+  xbt_dynar_t i, j;
   char buf[1024];
-  char *s1,*s2;
+  char *s1, *s2;
   int cpt;
-   
-  INFO0("---- Test on dynar containing integers ----");
-  my_type = gras_datadesc_dynar(gras_datadesc_by_name("string"),&free_string);
 
-  i=xbt_dynar_new(sizeof(char*),&free_string);   
-  for (cpt=0; cpt< 64; cpt++) {
-    sprintf(buf,"%d",cpt);
-    s1=strdup(buf);
-    xbt_dynar_push(i,&s1);
+  INFO0("---- Test on dynar containing integers ----");
+  my_type =
+      gras_datadesc_dynar(gras_datadesc_by_name("string"), &free_string);
+
+  i = xbt_dynar_new(sizeof(char *), &free_string);
+  for (cpt = 0; cpt < 64; cpt++) {
+    sprintf(buf, "%d", cpt);
+    s1 = strdup(buf);
+    xbt_dynar_push(i, &s1);
   }
 
-  write_read(my_type, &i,&j, sock, direction);
+  write_read(my_type, &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
-     for (cpt=0; cpt< 64; cpt++) {
-       sprintf(buf,"%d",cpt);
-       xbt_dynar_shift(j,&s2);
-       xbt_assert2 (!strcmp(buf,s2),
-                    "The retrieved value is not the same than the injected one (%s!=%s)",
-                    buf,s2);
-       free(s2);
-     }
-     xbt_dynar_free(&j);
+    for (cpt = 0; cpt < 64; cpt++) {
+      sprintf(buf, "%d", cpt);
+      xbt_dynar_shift(j, &s2);
+      xbt_assert2(!strcmp(buf, s2),
+                  "The retrieved value is not the same than the injected one (%s!=%s)",
+                  buf, s2);
+      free(s2);
+    }
+    xbt_dynar_free(&j);
   }
   xbt_dynar_free(&i);
 }
 
 
 /**** PBIO *****/
-GRAS_DEFINE_TYPE(s_pbio,
-struct s_pbio{ /* structure presented in the IEEE article */
-  int Cnstatv;
-  double Cstatev[12];
-  int Cnprops;
-  double Cprops[110];
-  int Cndi[4];
-  int Cnshr;
-  int Cnpt;
-  double Cdtime;
-  double Ctime[2];
-  int Cntens;
-  double Cdfgrd0[373][3];
-  double Cdfgrd1[3][3];
-  double Cstress[106];
-  double Cddsdde[106][106];
-};
-                )
+GRAS_DEFINE_TYPE(s_pbio, struct s_pbio {        /* structure presented in the IEEE article */
+                 int Cnstatv;
+                 double Cstatev[12];
+                 int Cnprops;
+                 double Cprops[110];
+                 int Cndi[4];
+                 int Cnshr;
+                 int Cnpt;
+                 double Cdtime;
+                 double Ctime[2];
+                 int Cntens;
+                 double Cdfgrd0[373][3];
+                 double Cdfgrd1[3][3];
+                 double Cstress[106]; double Cddsdde[106][106];};)
 typedef struct s_pbio pbio_t;
 
-void test_pbio(gras_socket_t sock, int direction) {
+void test_pbio(gras_socket_t sock, int direction)
+{
   int cpt;
   int cpt2;
   gras_datadesc_type_t pbio_type;
   pbio_t i, j;
 
-  INFO0("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
+  INFO0
+      ("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
   pbio_type = gras_datadesc_by_symbol(s_pbio);
 
   /* Fill in that damn struct */
   i.Cnstatv = 325115;
-  for (cpt=0; cpt<12; cpt++) 
+  for (cpt = 0; cpt < 12; cpt++)
     i.Cstatev[cpt] = ((double) cpt) * -2361.11;
   i.Cnprops = -37373;
-  for (cpt=0; cpt<110; cpt++)
+  for (cpt = 0; cpt < 110; cpt++)
     i.Cprops[cpt] = cpt * 100.0;
-  for (cpt=0; cpt<4; cpt++)
+  for (cpt = 0; cpt < 4; cpt++)
     i.Cndi[cpt] = cpt * 23262;
   i.Cnshr = -4634;
   i.Cnpt = 114142;
@@ -540,31 +564,30 @@ void test_pbio(gras_socket_t sock, int direction) {
   i.Ctime[0] = 332523.226;
   i.Ctime[1] = -26216.113;
   i.Cntens = 235211411;
-  
-  for (cpt=0; cpt<3; cpt++) {
-    for (cpt2=0; cpt2<373; cpt2++)
-      i.Cdfgrd0[cpt2][cpt] = ((double)cpt) * ((double)cpt2);
-    for (cpt2=0; cpt2<3; cpt2++)
-      i.Cdfgrd1[cpt][cpt2] = -((double)cpt) * ((double)cpt2);
+
+  for (cpt = 0; cpt < 3; cpt++) {
+    for (cpt2 = 0; cpt2 < 373; cpt2++)
+      i.Cdfgrd0[cpt2][cpt] = ((double) cpt) * ((double) cpt2);
+    for (cpt2 = 0; cpt2 < 3; cpt2++)
+      i.Cdfgrd1[cpt][cpt2] = -((double) cpt) * ((double) cpt2);
   }
-  for (cpt=0; cpt<106; cpt++) {
-    i.Cstress[cpt]=(double)cpt * 22.113;
-    for (cpt2=0; cpt2<106; cpt2++) 
-      i.Cddsdde[cpt][cpt2] = ((double)cpt) * ((double)cpt2);
+  for (cpt = 0; cpt < 106; cpt++) {
+    i.Cstress[cpt] = (double) cpt *22.113;
+    for (cpt2 = 0; cpt2 < 106; cpt2++)
+      i.Cddsdde[cpt][cpt2] = ((double) cpt) * ((double) cpt2);
   }
-  write_read(gras_datadesc_by_symbol(s_pbio),
-            &i,&j, sock,direction);
+  write_read(gras_datadesc_by_symbol(s_pbio), &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
     /* Check that the data match */
     xbt_assert(i.Cnstatv == j.Cnstatv);
-    for (cpt=0; cpt<12; cpt++)
+    for (cpt = 0; cpt < 12; cpt++)
       xbt_assert4(i.Cstatev[cpt] == j.Cstatev[cpt],
-                 "i.Cstatev[%d] (=%f) != j.Cstatev[%d] (=%f)",
-                 cpt,i.Cstatev[cpt],cpt,j.Cstatev[cpt]);
+                  "i.Cstatev[%d] (=%f) != j.Cstatev[%d] (=%f)",
+                  cpt, i.Cstatev[cpt], cpt, j.Cstatev[cpt]);
     xbt_assert(i.Cnprops == j.Cnprops);
-    for (cpt=0; cpt<110; cpt++)
+    for (cpt = 0; cpt < 110; cpt++)
       xbt_assert(i.Cprops[cpt] == j.Cprops[cpt]);
-    for (cpt=0; cpt<4; cpt++) 
+    for (cpt = 0; cpt < 4; cpt++)
       xbt_assert(i.Cndi[cpt] == j.Cndi[cpt]);
     xbt_assert(i.Cnshr == j.Cnshr);
     xbt_assert(i.Cnpt == j.Cnpt);
@@ -572,58 +595,60 @@ void test_pbio(gras_socket_t sock, int direction) {
     xbt_assert(i.Ctime[0] == j.Ctime[0]);
     xbt_assert(i.Ctime[1] == j.Ctime[1]);
     xbt_assert(i.Cntens == j.Cntens);
-    for (cpt=0; cpt<3; cpt++) {
-      for (cpt2=0; cpt2<373; cpt2++)
-       xbt_assert(i.Cdfgrd0[cpt2][cpt] == j.Cdfgrd0[cpt2][cpt]);
-      for (cpt2=0; cpt2<3; cpt2++)
-       xbt_assert(i.Cdfgrd1[cpt][cpt2] == j.Cdfgrd1[cpt][cpt2]);
+    for (cpt = 0; cpt < 3; cpt++) {
+      for (cpt2 = 0; cpt2 < 373; cpt2++)
+        xbt_assert(i.Cdfgrd0[cpt2][cpt] == j.Cdfgrd0[cpt2][cpt]);
+      for (cpt2 = 0; cpt2 < 3; cpt2++)
+        xbt_assert(i.Cdfgrd1[cpt][cpt2] == j.Cdfgrd1[cpt][cpt2]);
     }
-    for (cpt=0; cpt<106; cpt++) {
+    for (cpt = 0; cpt < 106; cpt++) {
       xbt_assert(i.Cstress[cpt] == j.Cstress[cpt]);
-      for (cpt2=0; cpt2<106; cpt2++) 
-       xbt_assert4(i.Cddsdde[cpt][cpt2] == j.Cddsdde[cpt][cpt2],
-                    "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
-                    i.Cddsdde[cpt][cpt2],cpt,cpt2,j.Cddsdde[cpt][cpt2]);
+      for (cpt2 = 0; cpt2 < 106; cpt2++)
+        xbt_assert4(i.Cddsdde[cpt][cpt2] == j.Cddsdde[cpt][cpt2],
+                    "%f=i.Cddsdde[%d][%d] != j.Cddsdde[cpt][cpt2]=%f",
+                    i.Cddsdde[cpt][cpt2], cpt, cpt2, j.Cddsdde[cpt][cpt2]);
     }
   }
 }
 
-GRAS_DEFINE_TYPE(s_clause,
-struct s_clause {
-   int num_lits;
-   int *literals GRAS_ANNOTE(size,num_lits); /* Tells GRAS where to find the size */
-};)
+GRAS_DEFINE_TYPE(s_clause, struct s_clause {
+                 int num_lits; int *literals GRAS_ANNOTE(size, num_lits);       /* Tells GRAS where to find the size */
+                 };
+
+    )
 typedef struct s_clause Clause;
 
-void test_clause(gras_socket_t sock, int direction) {
+void test_clause(gras_socket_t sock, int direction)
+{
   gras_datadesc_type_t ddt;
-  Clause *i,*j;
+  Clause *i, *j;
   int cpt;
-  
-  INFO0("---- Test on struct containing dynamic array and its size (cbps test) ----");
+
+  INFO0
+      ("---- Test on struct containing dynamic array and its size (cbps test) ----");
 
   /* create and fill the struct */
-  i=xbt_new(Clause,1);
+  i = xbt_new(Clause, 1);
 
   i->num_lits = 5432;
   i->literals = xbt_new(int, i->num_lits);
-  for (cpt=0; cpt<i->num_lits; cpt++)
+  for (cpt = 0; cpt < i->num_lits; cpt++)
     i->literals[cpt] = cpt * cpt - ((cpt * cpt) / 2);
-  DEBUG3("created data=%p (within %p @%p)",&(i->num_lits),i,&i);
-  DEBUG1("created count=%d",i->num_lits);
+  DEBUG3("created data=%p (within %p @%p)", &(i->num_lits), i, &i);
+  DEBUG1("created count=%d", i->num_lits);
 
   /* create the damn type descriptor */
   ddt = gras_datadesc_by_symbol(s_clause);
 /*  gras_datadesc_type_dump(ddt); */
 
-  ddt=gras_datadesc_ref("Clause*",ddt);
+  ddt = gras_datadesc_ref("Clause*", ddt);
 
-  write_read(ddt, &i,&j, sock,direction);
+  write_read(ddt, &i, &j, sock, direction);
   if (direction == READ || direction == RW || direction == COPY) {
     xbt_assert(i->num_lits == j->num_lits);
-    for (cpt=0; cpt<i->num_lits; cpt++)
+    for (cpt = 0; cpt < i->num_lits; cpt++)
       xbt_assert(i->literals[cpt] == j->literals[cpt]);
-    
+
     free(j->literals);
     free(j);
   }
@@ -633,87 +658,79 @@ void test_clause(gras_socket_t sock, int direction) {
 
 #pragma argsused
 
-int main(int argc,char *argv[])
+int main(int argc, char *argv[])
 {
-       gras_socket_t sock=NULL;
-       int direction =WRITE ; /* RW; */
-       int cpt;
-       char r_arch_char = gras_arch_selfid();
-       
-       gras_init(&argc,argv);
-       
-       for (cpt=1; cpt<argc; cpt++) 
-       {
-               if (!strcmp(argv[cpt], "--read")) 
-               {
-                       direction = READ;
-               }
-               else if (!strcmp(argv[cpt], "--write")) 
-               {
-                       direction = WRITE;
-               } 
-               else if (!strcmp(argv[cpt], "--copy")) 
-               {
-                       direction = COPY;
-               } 
-               else 
-               {
-                       filename=argv[cpt];
-               }
-       }
-       
-       if (direction == WRITE) 
-       {
-               sock = gras_socket_client_from_file(filename);
-               gras_datadesc_send(sock, gras_datadesc_by_name("char"),&r_arch_char);
-       }
-       if (direction == READ) 
-       {
-               sock = gras_socket_server_from_file(filename);
-               gras_datadesc_recv(sock, gras_datadesc_by_name("char"),gras_arch_selfid(), &r_arch_char);
-               INFO3("This datafile was generated on %s (%d), I'm %s.",gras_datadesc_arch_name(r_arch_char),(int)r_arch_char,gras_datadesc_arch_name(gras_arch_selfid()));
-       }
-       r_arch = (int)r_arch_char;
-       
-       test_int(sock,direction);    
-       
-       test_float(sock,direction);  
-       
-       test_double(sock,direction);  
-       
-       test_array(sock,direction);
-       
-       test_intref(sock,direction); 
-       
-       test_string(sock,direction); 
-       
-       test_dynar_scal(sock,direction);  
-       
-       test_structures(sock,direction);
-       
-       test_homostruct(sock,direction);
-       
-       test_hetestruct(sock,direction);
-       
-       test_nestedstruct(sock,direction);
-       
-       declare_chained_list_type();
-       
-       test_chain_list(sock,direction);
-       
-       test_graph(sock,direction); 
-       
-       test_dynar_ref(sock,direction);  
-       
-       test_pbio(sock,direction);
-       
-       test_clause(sock,direction);
-       
-       if (direction != RW && direction != COPY) 
-               gras_socket_close(sock);
-       
-       gras_exit();
-       
-       return 0;
-}
+  gras_socket_t sock = NULL;
+  int direction = WRITE;        /* RW; */
+  int cpt;
+  char r_arch_char = gras_arch_selfid();
+
+  gras_init(&argc, argv);
+
+  for (cpt = 1; cpt < argc; cpt++) {
+    if (!strcmp(argv[cpt], "--read")) {
+      direction = READ;
+    } else if (!strcmp(argv[cpt], "--write")) {
+      direction = WRITE;
+    } else if (!strcmp(argv[cpt], "--copy")) {
+      direction = COPY;
+    } else {
+      filename = argv[cpt];
+    }
+  }
+
+  if (direction == WRITE) {
+    sock = gras_socket_client_from_file(filename);
+    gras_datadesc_send(sock, gras_datadesc_by_name("char"), &r_arch_char);
+  }
+  if (direction == READ) {
+    sock = gras_socket_server_from_file(filename);
+    gras_datadesc_recv(sock, gras_datadesc_by_name("char"),
+                       gras_arch_selfid(), &r_arch_char);
+    INFO3("This datafile was generated on %s (%d), I'm %s.",
+          gras_datadesc_arch_name(r_arch_char), (int) r_arch_char,
+          gras_datadesc_arch_name(gras_arch_selfid()));
+  }
+  r_arch = (int) r_arch_char;
+
+  test_int(sock, direction);
+
+  test_float(sock, direction);
+
+  test_double(sock, direction);
+
+  test_array(sock, direction);
+
+  test_intref(sock, direction);
 
+  test_string(sock, direction);
+
+  test_dynar_scal(sock, direction);
+
+  test_structures(sock, direction);
+
+  test_homostruct(sock, direction);
+
+  test_hetestruct(sock, direction);
+
+  test_nestedstruct(sock, direction);
+
+  declare_chained_list_type();
+
+  test_chain_list(sock, direction);
+
+  test_graph(sock, direction);
+
+  test_dynar_ref(sock, direction);
+
+  test_pbio(sock, direction);
+
+  test_clause(sock, direction);
+
+  if (direction != RW && direction != COPY)
+    gras_socket_close(sock);
+
+  gras_exit();
+
+  return 0;
+}
index bd140bf..ec09345 100644 (file)
 #include "surf/surf.h"
 
 #include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
+                             "Messages specific for surf example");
 
 void test(void);
 void test(void)
 {
-               tmgr_history_t history = tmgr_history_new();
-               tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt");
-               tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt");
-               double next_event_date = -1.0;
-               double value = -1.0;
-               char *resource = NULL;
-               char *host_A = strdup("Host A");
-               char *host_B = strdup("Host B");
-               
-               tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
-               tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
-               
-               while ((next_event_date = tmgr_history_next_date(history)) != -1.0) 
-               {
-                       DEBUG1("%g" " : \n", next_event_date);
-                       while (tmgr_history_get_next_event_leq(history, next_event_date,&value, (void **) &resource)) {
-                       DEBUG2("\t %s : " "%g" "\n", resource, value);
-               }
-               
-               if (next_event_date > 1000)
-                       break;
-       }
-               
-       tmgr_history_free(history);
-       free(host_B);
-       free(host_A);
+  tmgr_history_t history = tmgr_history_new();
+  tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt");
+  tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt");
+  double next_event_date = -1.0;
+  double value = -1.0;
+  char *resource = NULL;
+  char *host_A = strdup("Host A");
+  char *host_B = strdup("Host B");
+
+  tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
+  tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);
+
+  while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
+    DEBUG1("%g" " : \n", next_event_date);
+    while (tmgr_history_get_next_event_leq
+           (history, next_event_date, &value, (void **) &resource)) {
+      DEBUG2("\t %s : " "%g" "\n", resource, value);
+    }
+
+    if (next_event_date > 1000)
+      break;
+  }
+
+  tmgr_history_free(history);
+  free(host_B);
+  free(host_A);
 }
 
 
 #pragma argsused
-int main(int argc, charargv[])
+int main(int argc, char *argv[])
 {
-        surf_init(&argc,argv);
-        test();
-        surf_exit();
+  surf_init(&argc, argv);
+  test();
+  surf_exit();
 
-        return 0;
+  return 0;
 }
+
 //---------------------------------------------------------------------------
index 8b24c42..f8b3ed7 100644 (file)
@@ -18,99 +18,103 @@ xbt_context_t cB = NULL;
 xbt_context_t cC = NULL;
 xbt_fifo_t fifo = NULL;
 
-void print_args(int argc, char** argv);
-void print_args(int argc, char** argv)
+void print_args(int argc, char **argv);
+void print_args(int argc, char **argv)
 {
-       int i ; 
-       
-       printf("args=<");
-       
-       for(i=0; i<argc; i++) 
-               printf("%s ",argv[i]);
-       
-       printf(">\n");
+  int i;
+
+  printf("args=<");
+
+  for (i = 0; i < argc; i++)
+    printf("%s ", argv[i]);
+
+  printf(">\n");
 }
 
-int fA(int argc, char** argv);
-int fA(int argc, char** argv)
+int fA(int argc, char **argv);
+int fA(int argc, char **argv)
 {
-       printf("Here is fA: ");
-       print_args(argc,argv);
-       
-       printf("\tContext A: Yield\n");
-       xbt_context_yield();
-       
-       xbt_fifo_push(fifo,cB);
-       printf("\tPush context B from context A\n");
-       
-       printf("\tContext A: Yield\n");
-       xbt_context_yield();
-       printf("\tContext A : bye\n");
-       
-       return 0;
+  printf("Here is fA: ");
+  print_args(argc, argv);
+
+  printf("\tContext A: Yield\n");
+  xbt_context_yield();
+
+  xbt_fifo_push(fifo, cB);
+  printf("\tPush context B from context A\n");
+
+  printf("\tContext A: Yield\n");
+  xbt_context_yield();
+  printf("\tContext A : bye\n");
+
+  return 0;
 }
 
-int fB(int argc, char** argv);
-int fB(int argc, char** argv)
+int fB(int argc, char **argv);
+int fB(int argc, char **argv)
 {
-       printf("Here is fB: ");
-       print_args(argc,argv);
-       xbt_fifo_push(fifo,cA);
-       printf("\tPush context A from context B\n");
-       printf("\tContext B: Yield\n");
-       xbt_context_yield();
-       printf("\tContext B : bye\n");
-       return 0;
+  printf("Here is fB: ");
+  print_args(argc, argv);
+  xbt_fifo_push(fifo, cA);
+  printf("\tPush context A from context B\n");
+  printf("\tContext B: Yield\n");
+  xbt_context_yield();
+  printf("\tContext B : bye\n");
+  return 0;
 }
 
-int fC(int argc, char** argv);
-int fC(int argc, char** argv)
+int fC(int argc, char **argv);
+int fC(int argc, char **argv)
 {
-       printf("Here is fC: ");
-       print_args(argc,argv);
-       
-       
-       printf("\tContext C: Yield (and exit)\n");
-       xbt_context_yield();
-       
-       
-       return 0;
+  printf("Here is fC: ");
+  print_args(argc, argv);
+
+
+  printf("\tContext C: Yield (and exit)\n");
+  xbt_context_yield();
+
+
+  return 0;
 }
+
 #pragma argsused
 
 int main(int argc, char **argv)
 {
-       xbt_context_t context = NULL;
-       
-       printf("XXX Test the simgrid context API\n");
-       printf("    If it fails, try another context backend.\n    For example, to force the pthread backend, use:\n       ./configure --with-context=pthread\n\n");
-       
-       xbt_context_init();
-       
-       cA = xbt_context_new(fA, NULL, NULL, NULL, NULL, 0, NULL);
-       cB = xbt_context_new(fB, NULL, NULL, NULL, NULL, 0, NULL);
-       cC = xbt_context_new(fC, NULL, NULL, NULL, NULL, 0, NULL);
-       
-       fifo = xbt_fifo_new();
-       
-       printf("Here is context 'main'\n");
-       xbt_context_start(cA);
-       printf("\tPush context 'A' from context 'main'\n");xbt_fifo_push(fifo,cA);
-       xbt_context_start(cB);
-       printf("\tPush context 'B' from context 'main'\n");xbt_fifo_push(fifo,cB);
-       xbt_context_start(cC);xbt_fifo_push(fifo,cC);
-       printf("\tPush context 'C' from context 'main'\n");xbt_fifo_push(fifo,cC);
-       
-       while((context=xbt_fifo_shift(fifo))) 
-       {
-               printf("Context main: Yield\n");
-               xbt_context_schedule(context);
-       }
-       
-       xbt_fifo_free(fifo);
-       xbt_context_exit();
-       
-       cA=cB=cC=NULL;
-       return 0;
-}
+  xbt_context_t context = NULL;
+
+  printf("XXX Test the simgrid context API\n");
+  printf
+      ("    If it fails, try another context backend.\n    For example, to force the pthread backend, use:\n       ./configure --with-context=pthread\n\n");
+
+  xbt_context_init();
+
+  cA = xbt_context_new(fA, NULL, NULL, NULL, NULL, 0, NULL);
+  cB = xbt_context_new(fB, NULL, NULL, NULL, NULL, 0, NULL);
+  cC = xbt_context_new(fC, NULL, NULL, NULL, NULL, 0, NULL);
 
+  fifo = xbt_fifo_new();
+
+  printf("Here is context 'main'\n");
+  xbt_context_start(cA);
+  printf("\tPush context 'A' from context 'main'\n");
+  xbt_fifo_push(fifo, cA);
+  xbt_context_start(cB);
+  printf("\tPush context 'B' from context 'main'\n");
+  xbt_fifo_push(fifo, cB);
+  xbt_context_start(cC);
+  xbt_fifo_push(fifo, cC);
+  printf("\tPush context 'C' from context 'main'\n");
+  xbt_fifo_push(fifo, cC);
+
+  while ((context = xbt_fifo_shift(fifo))) {
+    printf("Context main: Yield\n");
+    xbt_context_schedule(context);
+  }
+
+  xbt_fifo_free(fifo);
+  xbt_context_exit();
+
+  cA = cB = cC = NULL;
+  return 0;
+}
index 0e56806..241df8b 100644 (file)
 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to graphxml test");
 
 
-static void *node_label_and_data(xbt_node_t node, const char *label,const char *data)
+static void *node_label_and_data(xbt_node_t node, const char *label,
+                                 const char *data)
 {
-       char *lbl = xbt_strdup(label);
-       return lbl;
+  char *lbl = xbt_strdup(label);
+  return lbl;
 }
 
 #define free_label free
 
 static const char *node_name(xbt_node_t n)
 {
-       return xbt_graph_node_get_data(n);
+  return xbt_graph_node_get_data(n);
 }
 
 void test(char *graph_file);
 void test(char *graph_file)
 {
-       int test_node_deletion = 0;
-       int test_edge_deletion = 0;
-       int test_export_xml = 1;
-       int test_export_dot = 1;
-       int test_export_length = 1;
-       int test_shortest_paths = 1;
-       int test_topo_sort = 1;
-       
-       int i, j;
-       unsigned long n;
-       
-       xbt_dynar_t edges = NULL;
-       xbt_dynar_t nodes = NULL;
-       
-       xbt_graph_t graph =
-       xbt_graph_read(graph_file, &node_label_and_data, NULL);
-       
-       n = xbt_dynar_length(xbt_graph_get_nodes(graph));
-       
-       if (test_export_xml) 
-       {
-               INFO0("---- Testing XML export. Exporting to testgraph.xml ----");
-               xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL,NULL);
-       }
-       
-       if (test_export_dot) 
-       {
-               INFO0("---- Testing GraphViz export. Exporting to testgraph.dot ----");
-               xbt_graph_export_graphviz(graph, "testgraph.dot", node_name, NULL);
-       }
-       
-       if (test_export_length) 
-       {
-               char *buf = NULL;
-               double *adj = NULL;
-       
-               INFO0("---- Dumping Edge lengths ----");
-               adj = xbt_graph_get_length_matrix(graph);
-               buf = calloc(n * 20, sizeof(char));
-               
-               for (i = 0; i < n; i++) 
-               {
-                       for (j = 0; j < n; j++) 
-                       {
-                               sprintf(buf + strlen(buf), "%le\t", adj[i * n + j]);
-                       }
-                       
-                       INFO1("%s", buf);
-                       buf[0] = '\000';
-               }
-               
-               free(buf);
-               free(adj);
-       }
-       
-       if (test_shortest_paths) 
-       {
-               char *buf = NULL;
-               xbt_node_t *route = NULL;
-       
-               INFO0("---- Testing Shortest Paths ----");
-               route = xbt_graph_shortest_paths(graph);
-               buf = calloc(n * 40, sizeof(char));
-               
-               for (i = 0; i < n; i++) 
-               {
-                       for (j = 0; j < n; j++) 
-                       {
-                               if (route[i * n + j])
-                                       snprintf(buf+strlen(buf), 40, "%s\t", node_name(route[i * n + j]));
-                       }
-                       
-                       INFO1("%s", buf);
-                       buf[0] = '\000';
-               }
-               
-               free(buf);
-               free(route);
-       }
-       
-       if(test_topo_sort) 
-       {
-               xbt_node_t *sorted = NULL;
-       
-               INFO0("---- Testing Topological Sort ----");
-               sorted = xbt_graph_topo_sort(graph);
-               
-               for (i = 0; i < n; i++) 
-               {
-                       if (sorted[i]) 
-                       {
-                               INFO3("sorted[%d] = %s (%p)", i, node_name(sorted[i]), sorted[i]);
-                       }
-               }
-               
-               free(sorted);
-       }
-       
-       
-       if (test_node_deletion) 
-       {
-               INFO0("---- Testing Node Deletion ----");
-               nodes = xbt_graph_get_nodes(graph);
-               edges = xbt_graph_get_edges(graph);
-               INFO2("Before Node deletion: %lu nodes, %lu edges",xbt_dynar_length(nodes), xbt_dynar_length(edges));
-       
-               while (xbt_dynar_length(nodes))
-                       xbt_graph_free_node(graph,*((xbt_node_t *) xbt_dynar_get_ptr(nodes, 0)),free_label, NULL);
-               
-               INFO2("After Node deletion:  %lu nodes, %lu edges",
-               xbt_dynar_length(nodes), xbt_dynar_length(edges));
-       }
-       
-       if (test_edge_deletion) 
-       {
-               INFO0("---- Testing Edge Deletion ----");
-               nodes = xbt_graph_get_nodes(graph);
-               edges = xbt_graph_get_edges(graph);
-               INFO2("Before Edge deletion: %lu nodes, %lu edges",
-               xbt_dynar_length(nodes), xbt_dynar_length(edges));
-       
-               while (xbt_dynar_length(edges))
-                       xbt_graph_free_edge(graph,*((xbt_edge_t *) xbt_dynar_get_ptr(edges, 0)),NULL);
-       
-               INFO2("After Edge deletion:  %lu nodes, %lu edges",xbt_dynar_length(nodes), xbt_dynar_length(edges));
-       }
-       
-       xbt_graph_free_graph(graph, free_label, NULL, NULL);
+  int test_node_deletion = 0;
+  int test_edge_deletion = 0;
+  int test_export_xml = 1;
+  int test_export_dot = 1;
+  int test_export_length = 1;
+  int test_shortest_paths = 1;
+  int test_topo_sort = 1;
+
+  int i, j;
+  unsigned long n;
+
+  xbt_dynar_t edges = NULL;
+  xbt_dynar_t nodes = NULL;
+
+  xbt_graph_t graph =
+      xbt_graph_read(graph_file, &node_label_and_data, NULL);
+
+  n = xbt_dynar_length(xbt_graph_get_nodes(graph));
+
+  if (test_export_xml) {
+    INFO0("---- Testing XML export. Exporting to testgraph.xml ----");
+    xbt_graph_export_graphxml(graph, "testgraph.xml", NULL, NULL, NULL,
+                              NULL);
+  }
+
+  if (test_export_dot) {
+    INFO0("---- Testing GraphViz export. Exporting to testgraph.dot ----");
+    xbt_graph_export_graphviz(graph, "testgraph.dot", node_name, NULL);
+  }
+
+  if (test_export_length) {
+    char *buf = NULL;
+    double *adj = NULL;
+
+    INFO0("---- Dumping Edge lengths ----");
+    adj = xbt_graph_get_length_matrix(graph);
+    buf = calloc(n * 20, sizeof(char));
+
+    for (i = 0; i < n; i++) {
+      for (j = 0; j < n; j++) {
+        sprintf(buf + strlen(buf), "%le\t", adj[i * n + j]);
+      }
+
+      INFO1("%s", buf);
+      buf[0] = '\000';
+    }
+
+    free(buf);
+    free(adj);
+  }
+
+  if (test_shortest_paths) {
+    char *buf = NULL;
+    xbt_node_t *route = NULL;
+
+    INFO0("---- Testing Shortest Paths ----");
+    route = xbt_graph_shortest_paths(graph);
+    buf = calloc(n * 40, sizeof(char));
+
+    for (i = 0; i < n; i++) {
+      for (j = 0; j < n; j++) {
+        if (route[i * n + j])
+          snprintf(buf + strlen(buf), 40, "%s\t",
+                   node_name(route[i * n + j]));
+      }
+
+      INFO1("%s", buf);
+      buf[0] = '\000';
+    }
+
+    free(buf);
+    free(route);
+  }
+
+  if (test_topo_sort) {
+    xbt_node_t *sorted = NULL;
+
+    INFO0("---- Testing Topological Sort ----");
+    sorted = xbt_graph_topo_sort(graph);
+
+    for (i = 0; i < n; i++) {
+      if (sorted[i]) {
+        INFO3("sorted[%d] = %s (%p)", i, node_name(sorted[i]), sorted[i]);
+      }
+    }
+
+    free(sorted);
+  }
+
+
+  if (test_node_deletion) {
+    INFO0("---- Testing Node Deletion ----");
+    nodes = xbt_graph_get_nodes(graph);
+    edges = xbt_graph_get_edges(graph);
+    INFO2("Before Node deletion: %lu nodes, %lu edges",
+          xbt_dynar_length(nodes), xbt_dynar_length(edges));
+
+    while (xbt_dynar_length(nodes))
+      xbt_graph_free_node(graph,
+                          *((xbt_node_t *) xbt_dynar_get_ptr(nodes, 0)),
+                          free_label, NULL);
+
+    INFO2("After Node deletion:  %lu nodes, %lu edges",
+          xbt_dynar_length(nodes), xbt_dynar_length(edges));
+  }
+
+  if (test_edge_deletion) {
+    INFO0("---- Testing Edge Deletion ----");
+    nodes = xbt_graph_get_nodes(graph);
+    edges = xbt_graph_get_edges(graph);
+    INFO2("Before Edge deletion: %lu nodes, %lu edges",
+          xbt_dynar_length(nodes), xbt_dynar_length(edges));
+
+    while (xbt_dynar_length(edges))
+      xbt_graph_free_edge(graph,
+                          *((xbt_edge_t *) xbt_dynar_get_ptr(edges, 0)),
+                          NULL);
+
+    INFO2("After Edge deletion:  %lu nodes, %lu edges",
+          xbt_dynar_length(nodes), xbt_dynar_length(edges));
+  }
+
+  xbt_graph_free_graph(graph, free_label, NULL, NULL);
 }
 
 #pragma argsused
 
 int main(int argc, char **argv)
 {
-       xbt_init(&argc, argv);
-       
-       if (argc == 1) 
-       {
-               fprintf(stderr, "Usage : %s graph.xml\n", argv[0]);
-               return 1;
-       }
-       
-       test(argv[1]);
-       
-       return 0;
-}
+  xbt_init(&argc, argv);
+
+  if (argc == 1) {
+    fprintf(stderr, "Usage : %s graph.xml\n", argv[0]);
+    return 1;
+  }
 
+  test(argv[1]);
+
+  return 0;
+}
index 571105d..b5e5997 100644 (file)
 #include <stdio.h>
 
 #include "xbt/heap.h"
-#include "gras/virtu.h"                /* time manipulation in bench */
+#include "gras/virtu.h"         /* time manipulation in bench */
 
 #define MAX_TEST 1000000
 
 int _XBT_CALL compare_double(const void *a, const void *b);
 void test_heap_validity(int size);
 void test_heap_mean_operation(int size);
-void test_reset_heap(xbt_heap_t heap,int size);
+void test_reset_heap(xbt_heap_t heap, int size);
 
 
 int _XBT_CALL compare_double(const void *a, const void *b)
 {
-       double pa, pb;
-       
-       pa = *((double *) a);
-       pb = *((double *) b);
-       
-       if (pa > pb)
-               return 1;
-       
-       if (pa == pb)
-               return 0;
-       
-       return -1;
+  double pa, pb;
+
+  pa = *((double *) a);
+  pb = *((double *) b);
+
+  if (pa > pb)
+    return 1;
+
+  if (pa == pb)
+    return 0;
+
+  return -1;
 }
 
 void test_heap_validity(int size)
 {
-       xbt_heap_t heap = xbt_heap_new(size, NULL);
-       double *tab = calloc(size, sizeof(double));
-       int i;
-       
-       for (i = 0; i < size; i++) 
-       {
-               tab[i] = (10.0 * rand() / (RAND_MAX + 1.0));
-               xbt_heap_push(heap, NULL, tab[i]);
-       }
-       
-       qsort(tab, size, sizeof(double), compare_double);
-       
-       for (i = 0; i < size; i++) 
-       {
-               /*     printf("%lg" " ", xbt_heap_maxkey(heap)); */
-               if (xbt_heap_maxkey(heap) != tab[i]) 
-               {
-                       fprintf(stderr, "Problem !\n");
-                       exit(1);
-               }
-               
-               xbt_heap_pop(heap);
-       }
-       
-       xbt_heap_free(heap);
-       free(tab);
-       printf("Validity test complete!\n");
+  xbt_heap_t heap = xbt_heap_new(size, NULL);
+  double *tab = calloc(size, sizeof(double));
+  int i;
+
+  for (i = 0; i < size; i++) {
+    tab[i] = (10.0 * rand() / (RAND_MAX + 1.0));
+    xbt_heap_push(heap, NULL, tab[i]);
+  }
+
+  qsort(tab, size, sizeof(double), compare_double);
+
+  for (i = 0; i < size; i++) {
+    /*     printf("%lg" " ", xbt_heap_maxkey(heap)); */
+    if (xbt_heap_maxkey(heap) != tab[i]) {
+      fprintf(stderr, "Problem !\n");
+      exit(1);
+    }
+
+    xbt_heap_pop(heap);
+  }
+
+  xbt_heap_free(heap);
+  free(tab);
+  printf("Validity test complete!\n");
 }
 
 void test_heap_mean_operation(int size)
 {
-       xbt_heap_t heap = xbt_heap_new(size, NULL);
-       double val;
-       double date = 0;
-       int i, j;
-       
-       date = gras_os_time() * 1000000;
-
-       for (i = 0; i < size; i++)
-               xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0)));
-       
-       date = gras_os_time() * 1000000 - date;
-       
-       printf("Creation time  %d size heap : %g\n", size, date);
-       
-       date = gras_os_time() * 1000000;
-       
-       for (j = 0; j < MAX_TEST; j++) 
-       {
-       
-               if(!(j%size) && j)
-                       test_reset_heap(heap,size);
-       
-               val = xbt_heap_maxkey(heap);
-               xbt_heap_pop(heap);
-               xbt_heap_push(heap, NULL, 3.0 * val);
-       }
-       
-       date = gras_os_time() * 1000000 - date;
-       printf("Mean access time for a %d size heap : %g\n", size,date * 1.0 / (MAX_TEST + 0.0));
-       
-       xbt_heap_free(heap);
+  xbt_heap_t heap = xbt_heap_new(size, NULL);
+  double val;
+  double date = 0;
+  int i, j;
+
+  date = gras_os_time() * 1000000;
+
+  for (i = 0; i < size; i++)
+    xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0)));
+
+  date = gras_os_time() * 1000000 - date;
+
+  printf("Creation time  %d size heap : %g\n", size, date);
+
+  date = gras_os_time() * 1000000;
+
+  for (j = 0; j < MAX_TEST; j++) {
+
+    if (!(j % size) && j)
+      test_reset_heap(heap, size);
+
+    val = xbt_heap_maxkey(heap);
+    xbt_heap_pop(heap);
+    xbt_heap_push(heap, NULL, 3.0 * val);
+  }
+
+  date = gras_os_time() * 1000000 - date;
+  printf("Mean access time for a %d size heap : %g\n", size,
+         date * 1.0 / (MAX_TEST + 0.0));
+
+  xbt_heap_free(heap);
 }
 
-void test_reset_heap(xbt_heap_t heap,int size)
+void test_reset_heap(xbt_heap_t heap, int size)
 {
-       int i;
-       xbt_heap_free(heap);
-       heap = xbt_heap_new(size, NULL);
-       
-       for (i = 0; i < size; i++)
-       {
-               xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0)));
-       }
+  int i;
+  xbt_heap_free(heap);
+  heap = xbt_heap_new(size, NULL);
+
+  for (i = 0; i < size; i++) {
+    xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0)));
+  }
 }
 
 
@@ -125,13 +121,13 @@ void test_reset_heap(xbt_heap_t heap,int size)
 
 int main(int argc, char **argv)
 {
-        int size;
-
-       for (size = 100; size < 10000; size *= 10)
-       {
-               test_heap_validity(size);
-               test_heap_mean_operation(size);
-       }
-       return 0;
+  int size;
+
+  for (size = 100; size < 10000; size *= 10) {
+    test_heap_validity(size);
+    test_heap_mean_operation(size);
+  }
+  return 0;
 }
+
 //---------------------------------------------------------------------------
index e5922d1..7cd1afc 100644 (file)
 
 #include <gras.h>
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top,"Logging specific to this test");
-XBT_LOG_NEW_CATEGORY(top,"Useless test channel");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top,
+                                "Logging specific to this test");
+XBT_LOG_NEW_CATEGORY(top, "Useless test channel");
 
 #pragma argsused
 
 int main(int argc, char **argv)
 {
-       xbt_init(&argc,argv);
-       
-       DEBUG1("val=%d", 1);
-       WARN1("val=%d", 2);
-       CDEBUG2(top, "val=%d%s", 3, "!");
-       CRITICAL6("false alarm%s%s%s%s%s%s", "","","","","","!");
-       
-       return 0;
-}
+  xbt_init(&argc, argv);
+
+  DEBUG1("val=%d", 1);
+  WARN1("val=%d", 2);
+  CDEBUG2(top, "val=%d%s", 3, "!");
+  CRITICAL6("false alarm%s%s%s%s%s%s", "", "", "", "", "", "!");
 
+  return 0;
+}