Index: trunk/SophyaLib/BaseTools/Makefile
===================================================================
--- trunk/SophyaLib/BaseTools/Makefile	(revision 219)
+++ trunk/SophyaLib/BaseTools/Makefile	(revision 219)
@@ -0,0 +1,27 @@
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libSysTools.a
+clean:
+	rm -f $(OBJ)ctimer.o $(OBJ)exceptions.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)ppersist.o $(OBJ)psighand.o $(OBJ)timing.o
+	rm $(LIB)libSysTools.a
+$(LIB)libSysTools.a : $(OBJ)ctimer.o $(OBJ)exceptions.o $(OBJ)pdlmgr.o $(OBJ)periodic.o $(OBJ)ppersist.o $(OBJ)psighand.o $(OBJ)timing.o
+	$(AR) $(ARFLAGS) $@ $?
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lSysTools -o $(OBJ)xx.x -Hf
+endif 
+ 
+$(OBJ)ctimer.o: ctimer.cc defs.h ctimer.h /home/ansari/DPC/Include/peida.h \
+ /home/ansari/DPC/Include/defs.h /home/ansari/DPC/Include/utils.h \
+ /home/ansari/DPC/Include/machine.h /home/ansari/DPC/Include/perrors.h \
+ /home/ansari/DPC/Include/exceptions.h \
+ /home/ansari/DPC/Include/peidainit.h /home/ansari/DPC/Include/fmath.h
+$(OBJ)exceptions.o: exceptions.cc defs.h exceptions.h peidainit.h perrors.h
+$(OBJ)pdlmgr.o: pdlmgr.cc pdlmgr.h defs.h
+$(OBJ)periodic.o: periodic.cc defs.h periodic.h
+$(OBJ)ppersist.o: ppersist.cc defs.h peidainit.h ppersist.h machine.h \
+ perrors.h exceptions.h /home/ansari/DPC/Include/pclassids.h \
+ /home/ansari/DPC/Include/dates.h \
+ /home/ansari/DPC/Include/exceptions.h
+$(OBJ)psighand.o: psighand.cc psighand.h defs.h perrors.h exceptions.h \
+ peidainit.h
+$(OBJ)timing.o: timing.c
Index: trunk/SophyaLib/BaseTools/SysTools.o.list
===================================================================
--- trunk/SophyaLib/BaseTools/SysTools.o.list	(revision 219)
+++ trunk/SophyaLib/BaseTools/SysTools.o.list	(revision 219)
@@ -0,0 +1,7 @@
+ctimer.o
+exceptions.o
+pdlmgr.o
+periodic.o
+ppersist.o
+psighand.o
+timing.o
Index: trunk/SophyaLib/BaseTools/defs.h
===================================================================
--- trunk/SophyaLib/BaseTools/defs.h	(revision 219)
+++ trunk/SophyaLib/BaseTools/defs.h	(revision 219)
@@ -0,0 +1,263 @@
+#ifndef DEFS_SEEN
+#define DEFS_SEEN
+
+/*#define DEBUG*/
+
+#ifdef DEBUG
+#define IMGRGCHECK
+#define IMGVOIDCHECK
+#endif
+
+/* Sur mac, PP utilise fp.h plutot que math.h, et les deux sont incompatibles... */
+#ifdef __MWERKS__
+/* 
+  #include <fp.h>
+  #define __MATH__
+*/
+#endif
+
+
+/********************************************************/
+/* Outil d'impressions pour debug */
+#define PR(_data_)  {cout<<" "<<#_data_<<" "<<_data_;}
+#define CR {cout<<"\n"<<flush;}
+/* ********************************************************/
+
+/* Sur quelle machine sommes-nous ?                                       */
+/* Il faudrait uniformiser tous les sources avec les memes conventions... */
+
+#if defined(__alpha) || defined(__alpha__) || defined(OSF1) || defined(DECALPHA)
+#undef OSF1
+#define OSF1
+#undef DECALPHA
+#define DECALPHA 
+#undef __alpha__
+#define __alpha__
+#endif
+
+
+#if defined(_AIX) && !defined(AIX)
+#define AIX 1
+#endif
+
+#if defined(__hpux__) && !defined(HPUX)
+#define HPUX  1
+#endif
+
+
+#ifdef ultrix
+#define DECULTRIX 1
+#endif
+
+#ifdef __ultrix__
+#define DECULTRIX 1
+#endif
+
+#ifdef THINK_CPLUS
+#define __mac__
+#endif
+
+#ifdef __MWERKS__
+#define __mac__
+#endif
+
+/* Quelques variantes du C++ selon le compilateur */
+
+#define USESTRING
+
+#define HAS_VEC_NEW
+
+#ifdef __MWERKS__
+#define __ANSI_TEMPLATES__
+#undef HAS_VEC_NEW
+#define COMPILER_EXCEPTIONS
+#define NO_STRSTREAM
+#define STREAMPOS_IS_CLASS
+#define ITER_TAG
+#endif
+
+#ifdef __GNUG__
+#define __GNU_TEMPLATES__
+#endif
+
+#ifdef __DECCXX
+#if __DECCXX_VER > 60000000
+#define CXX6 1
+#define ITER_TAG
+/*  #define __GNU_TEMPLATES__ */
+#define __CXX_PRAGMA_TEMPLATES__
+#else
+#define CXX5 1
+#define __CXX_PRAGMA_TEMPLATES__
+/*  Pour definir bool   Reza 20/05/97  */
+#include <stl_macros>
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#endif
+
+#endif
+
+/* GCC 2.8.0 : exception, string::npos */
+#ifdef __GNUC__
+#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#undef  COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#define NPOS string::npos
+#endif
+#endif
+
+
+#ifndef __GNUG__
+/*typedef int bool;*/
+#define __PRETTY_FUNCTION__ __FILE__ " __LINE__ "
+#ifndef __FUNCTION__
+#define __FUNCTION__ __FILE__ " __LINE__ "
+#endif
+#ifndef __KCC__
+#define __attribute__(_x_)
+#endif
+#endif
+
+#ifdef __GNUG__
+#define HAS_NAMED_RETURN 0
+#else
+#define HAS_NAMED_RETURN 0
+#endif
+
+#ifdef THINK_CPLUS
+#define ARG_FUNC_CPP_C 0
+#else
+#define ARG_FUNC_CPP_C 1
+#endif
+
+#ifdef __GNUG__
+#define HAS_EXPLICIT
+#endif
+
+#ifdef HAS_EXPLICIT
+#define EXPLICIT explicit
+#else
+#define EXPLICIT
+#endif
+/* Quelques variantes de la librairie C++.                 */
+/* La librairie est AT&T par defaut, sauf si __ANSI_IO__   */
+
+/* $CHECK$ EA : a uniformiser */
+/* remplacer HAS_IOS_BIN par un selecteur qui indique si c'est ios::binary ou */
+/* ios::bin */
+
+#ifdef __MWERKS__
+/* #define __ANSI_IO__ */
+#endif
+
+#if defined(THINK_CPLUS)
+#define HAS_IOS_BIN 0
+#define HAS_IOS_NOCREATE 1
+#define FITS_IOS_IN_OPT  ios::in | ios::nocreate
+#define FITS_IOS_OUT_OPT ios::out
+
+#elif defined(__MWERKS__)
+#define HAS_IOS_BIN 1
+#define HAS_IOS_NOCREATE 1
+#define NPOS string::npos
+
+#elif defined(__GNUG__)
+#define HAS_IOS_BIN 1
+#define HAS_IOS_NOCREATE 1
+#define FITS_IOS_IN_OPT  ios::in | ios::bin | ios::nocreate
+#define FITS_IOS_OUT_OPT ios::out | ios::bin
+
+#else
+#define HAS_IOS_BIN 0
+#define HAS_IOS_NOCREATE 0
+#endif
+
+#ifdef __ANSI_IO__
+#define seekg(p_, m_) rdbuf()->pubseekoff(p_,m_)
+#define seekp(p_, m_) rdbuf()->pubseekoff(p_,m_)
+#endif
+
+
+#define STR2CH(x) ((string(x)).c_str())
+
+/* Des fonctions qui manquent sur certaines machines  */
+
+#if defined(__DECCXX) 
+/* a cause des exceptions dans math.h */
+#define exception math_exception
+#include <math.h>
+#undef exception
+#else
+#include <math.h>
+#endif
+
+#if defined(__DECCXX) 
+/*  Pour definir bool   Reza 20/05/97  */
+#include <stl_macros>
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#endif
+
+#if defined(__xlC)  && defined (__cplusplus) 
+#include <bool.h>
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+// NPOS - On utilise la STL de g++ 2.7.2 
+#endif
+#endif
+
+#if defined( __DECCXX ) || defined (__aCC__)  
+/* en fait si c'est RogueWave */
+/*  Remis par Reza  20/05/97  */
+#define NPOS (size_t)-1
+#endif
+
+#if defined (__aCC__)  
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#ifndef  __ANSI_TEMPLATES__
+#define __ANSI_TEMPLATES__
+#endif
+#endif
+
+#if defined(__KCC__)
+/* KCC V 3.2 ne compile pas  i/ostream s ; long p = s.tellg();  OK en  V 3.3 */
+#define STREAMPOS_IS_CLASS
+#define NPOS string::npos
+
+#ifndef COMPILER_EXCEPTIONS
+#define COMPILER_EXCEPTIONS
+#endif
+#ifndef  __ANSI_TEMPLATES__
+#define __ANSI_TEMPLATES__
+#endif
+#endif
+
+#ifndef M_PI
+#define M_PI 3.1415926535
+#endif
+
+#ifdef __mac__
+#define hypot(_x_,_y_) sqrt((_x_)*(_x_) + (_y_)*(_y_))
+/* #define nintf(x) ((int) (x))  */
+#define random() (rand()*65538.0 + rand()*2. + rand())
+#define srandom srand
+#define initstate(seed, tab, n) srand(seed)
+#define nice(_x)
+/*#define getpid() 1 */
+
+#ifdef __cplusplus
+#include <string.h>
+#include <string>
+inline bool operator< (string const& s1, string const& s2)
+{ return (strcmp(s1.c_str(), s2.c_str()) < 0); }
+#endif
+#endif
+
+
+
+#endif
+
Index: trunk/SophyaLib/BaseTools/exceptions.cc
===================================================================
--- trunk/SophyaLib/BaseTools/exceptions.cc	(revision 219)
+++ trunk/SophyaLib/BaseTools/exceptions.cc	(revision 219)
@@ -0,0 +1,235 @@
+#include "defs.h"
+#include "exceptions.h"
+#include <iostream.h>
+#include <new.h>
+#ifndef __mac__
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include "perrors.h"
+
+#ifdef __mac__
+#include "unixmac.h"
+#include <SIOUX.h>
+#endif
+
+//#define LAL
+
+#ifndef EXC_MSG
+#define EXC_MSG(i) "Exception " << i
+#endif
+
+#define kDynAllocBlock 10
+
+void EAFailHandler(void); 
+
+#ifndef COMPILER_EXCEPTIONS
+
+#ifndef NO_EXCEPTIONS
+
+ExcHndl::ExcHndl(ExcHndl* up)
+: nextHandler(up), 
+  theExc(0), hadExc(0),
+  nObj(0), nObjAlloc(kDynAllocBlock), objects((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))), 
+  nDyn(0), nDynAlloc(kDynAllocBlock), dynObjs((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))),
+  nDynTab(0), nDynTabAlloc(kDynAllocBlock), 
+  dynTabObjs((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))),
+  dynTabSz((size_t*)malloc(kDynAllocBlock*sizeof(size_t)))
+{
+ //  cerr << "TRY : " << hex << this << "  <-  " << nextHandler << dec << endl;
+}
+
+ExcHndl::~ExcHndl()
+{
+  free(objects);
+  free(dynObjs);
+  free(dynTabObjs);
+  free(dynTabSz);
+ // cerr << "~TRY: " << hex << this << "  <-  " << nextHandler << dec << endl;
+}
+
+void ExcHndl::Add(ExcAwareObject* obj)
+{
+  // on verifie s'il est dans la liste a ignorer
+  int trouve=0;
+  int i;
+  for (i=0; i<nDyn; i++)
+    if (dynObjs[i] == obj) {
+      trouve = true;
+      break;
+    }
+  if (trouve) {   // On le vire de la table des news.
+    nDyn--;
+    for (int j=i; j<nDyn; j++)
+      dynObjs[j] = dynObjs[j+1];
+    return;
+  }
+  
+  // Dans les tableaux ?
+  for (i=0; i<nDynTab; i++)
+    if ((dynTabObjs[i] <= obj) && ((char*)(dynTabObjs[i]) + dynTabSz[i] >= (char*)obj)) {
+      return;
+    }
+
+  // on l'ajoute a la liste des objets
+  nObj++;
+  if (nObj>nObjAlloc) {
+    nObjAlloc += kDynAllocBlock;
+    objects = (ExcAwareObject**) realloc(objects, nObjAlloc*sizeof(void*));
+  }
+
+  objects[nObj-1] = obj;
+}
+
+void ExcHndl::Forget(ExcAwareObject* obj)
+{
+  // on verifie s'il est dans la liste
+  int trouve=0;
+  int i=0;
+  for (i=0; i<nObj; i++)
+    if (objects[i] == obj) {
+      trouve = true;
+      break;
+    }
+  if (trouve) {
+    nObj--;
+    for (int j=i; j<nObj; j++)
+      objects[j] = objects[j+1];
+  }
+}
+
+void ExcHndl::Ignore(ExcAwareObject* obj)
+{
+  // on l'ajoute a la liste des objets
+  nDyn++;
+  if (nDyn>nDynAlloc) {
+    nDynAlloc += kDynAllocBlock;
+    dynObjs = (ExcAwareObject**) realloc(dynObjs, nDynAlloc*sizeof(void*));
+  }
+
+  dynObjs[nDyn-1] = obj;
+}
+
+void ExcHndl::IgnoreTab(ExcAwareObject* obj, size_t sz)
+{
+  // on l'ajoute a la liste des objets
+  nDynTab++;
+  if (nDynTab>nDynTabAlloc) {
+    nDynTabAlloc += kDynAllocBlock;
+    dynTabObjs =(ExcAwareObject**) realloc(dynTabObjs, nDynTabAlloc*sizeof(void*));
+    dynTabSz   = (size_t*) realloc(dynTabSz,   nDynTabAlloc*sizeof(size_t));
+  }
+
+  dynTabObjs[nDynTab-1] = obj;
+  dynTabSz  [nDynTab-1] = sz;
+}
+
+void ExcHndl::DelTab(ExcAwareObject* obj)
+{
+  // on le supprime
+
+  int trouve=0;
+  int i=0;
+  for (i=0; i<nDynTab; i++)
+    if (dynTabObjs[i] == obj) {
+      trouve = true;
+      break;
+    }
+  if (trouve) {
+    nDynTab--;
+    for (int j=i; j<nDynTab; j++) {
+      dynTabObjs[j] = dynTabObjs[j+1];
+      dynTabSz  [j] = dynTabSz  [j+1];
+    }
+  }
+}
+
+
+
+// End Constructor : ne pas se preoccuper des objets qui sont
+// a l'interieur de cet objet.
+void ExcHndl::EndConstructor(void* obj, size_t s)
+{
+  for (int i=0; i<nObj; i++)
+    if ((char*)objects[i] > (char*)obj && (char*)objects[i] < (char*)obj + s) {
+      nObj--;
+      for (int j=i; j<nObj; j++)
+	objects[j] = objects[j+1];
+      i--;
+    }
+}
+
+#undef DEBUG
+
+void ExcHndl::Throw(int i, char* file, int line)
+{
+  if (_ExcAbortAll || (i<0 && _ExcAbortNeg)) {
+    cerr << EXC_MSG(i);
+    if (file) cerr << " file " << file << " line " << line;
+    cerr << endl;
+    abort();
+  } else {
+    #ifdef DEBUG
+    cerr << "caught " << EXC_MSG(i);
+    if (file) cerr << " file " << file << " line " << line;
+    cerr << endl;
+    #endif
+    theExc = i;
+    hadExc = 1;
+    
+    // On detruit tous les objets crees depuis le TRY
+    // ExcAwareObject a un destructeur virtuel...
+    // Le tableau est dans l'ordre de creation. donc i--
+    
+    for (int i=nObj-1; i>=0; i--)
+      objects[i]->~ExcAwareObject();
+    
+    // et maintenant on saute...
+    
+    longjmp(env, 1);
+  }
+}
+
+
+void ExcHndl::NoHandler(int i, char* file, int line)
+{
+  cerr << "No handler : ";
+  cerr << EXC_MSG(i);
+  if (file) cerr << " file " << file << " line " << line;
+  cerr << endl;
+  terminate();
+}
+
+ExcHndl* topExcHndl = 0;
+int      _ExcAbortNeg = 1;
+int      _ExcAbortAll = 0;
+
+#endif
+#endif
+
+
+void EAFailHandler(void)
+{
+        set_new_handler(NULL);
+	cerr << "Allocation exception -- out of memory" << endl;
+        THROW(allocationErr);
+}
+
+void InitFailNewHandler()
+{
+        set_new_handler(EAFailHandler);
+}
+
+
+#ifdef THINK_CPLUS
+void terminate()
+{
+	DebugStr("\pTerminate...");
+	abort();
+}
+#endif
+
+#ifdef x__GNUG__
+void terminate()
+{ abort(); }
+#endif
Index: trunk/SophyaLib/BaseTools/exceptions.h
===================================================================
--- trunk/SophyaLib/BaseTools/exceptions.h	(revision 219)
+++ trunk/SophyaLib/BaseTools/exceptions.h	(revision 219)
@@ -0,0 +1,267 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef EXCEPTIONS_SEEN
+#define EXCEPTIONS_SEEN
+
+// Gestion des exceptions, conformemnt au manuel de reference C++
+// en attendant que les compilateurs le fassent tous seuls
+//
+// Eric Aubourg, la Silla fevrier 95
+// Pour le moment, on ne sait gerer qu'un seul type d'exception, int.
+// 
+// La syntaxe est
+//    TRY {
+//          ....
+//        }
+//    CATCH(i) {
+//        ...
+//    }
+//    ENDTRY
+
+// ou bien CATCHALL a la place de CATCH.
+//
+
+// On peut faire THROW_ tout court, qui est pareil que THROW(0)
+// ou bien THROW(n)
+// ou bien THROW_SAME dans un bloc CATCH
+
+// IMPORTANT
+// Tout objet susceptible d'etre cree automatiquement au cours d'un bloc
+// try doit etre declare EXC_AWARE (class x EXC_AWARE {...};) ou bien
+// deriver d'une telle classe.
+
+// Tout constructeur d'une classe qui contient d'autres objets parmi ses
+// champs doit se terminer par END_CONSTRUCTOR.
+
+#include "defs.h"
+
+#include <iostream.h>
+#include "peidainit.h"
+
+//#define NO_EXCEPTIONS
+#ifdef NO_EXCEPTIONS
+
+#define EXC_ABORT_NEG(_x)
+#define EXC_ABORT_ALL(_x)
+
+#define EXC_AWARE
+
+#define END_CONSTRUCTOR
+
+#define TRY if (1) {
+#define CATCH(_var) } else { long _var;
+#define CATCHALL } else {
+#define ENDTRY }
+
+#define THROW(_i) \
+      {cerr << "Throw " << _i << " file " << __FILE__ << " line " << __LINE__;	\
+       cerr << endl;											\
+       abort();}
+
+#define THROW_ THROW(0)
+
+#define THROW_SAME THROW(0)
+
+#define ASSERT(_a_) if (!(_a_)) { \
+     cerr << "Assertion failed " #_a_ " file " __FILE__ " line " << __LINE__ \
+          << endl; \
+     THROW_ }
+
+#define RETURN(x) return(x)
+#define RETURN_ return
+
+#else
+#ifdef COMPILER_EXCEPTIONS
+
+#define EXC_ABORT_NEG(_x)
+#define EXC_ABORT_ALL(_x)
+
+#define EXC_AWARE
+
+#define END_CONSTRUCTOR
+
+#define TRY try
+#define CATCH(_var) catch(long _var)
+#define CATCHALL catch(...)
+#define ENDTRY
+
+#define THROW(_i) throw((long) _i);
+
+#define THROW_ THROW(0)
+
+#define THROW_SAME throw;
+
+#define ASSERT(_a_) if (!(_a_)) { \
+     cerr << "Assertion failed " #_a_ " file " __FILE__ " line " << __LINE__ \
+          << endl; \
+     THROW_ }
+
+#define RETURN(x) return(x)
+#define RETURN_ return
+
+void InitFailNewHandler();
+#else
+
+#include <setjmp.h>
+#include <stdlib.h>
+
+class ExcAwareObject;
+
+class ExcHndl {
+public:
+  ExcHndl(ExcHndl* up);
+  ~ExcHndl();
+
+  void SetEnv(jmp_buf& theEnv)
+#ifndef __GNUG__
+	{memcpy(env, theEnv, sizeof(jmp_buf));}
+#else
+  	{env = theEnv;}
+#endif
+  void Throw(int exc=0, char* file=0, int line=0);
+  void Add(ExcAwareObject*);
+  void Forget(ExcAwareObject*);
+  void Ignore(ExcAwareObject*);
+  void IgnoreTab(ExcAwareObject*, size_t);
+  void DelTab(ExcAwareObject*);
+  void EndConstructor(void*, size_t);
+  static void NoHandler(int exc=0, char* file=0, int line=0);
+
+  ExcHndl*         nextHandler;
+  
+  int              theExc;
+  int              hadExc;
+
+private:
+  jmp_buf          env;
+  int              nObj, nObjAlloc;
+  ExcAwareObject** objects;
+  int              nDyn, nDynAlloc;
+  ExcAwareObject** dynObjs;
+  int              nDynTab, nDynTabAlloc;
+  ExcAwareObject** dynTabObjs;
+  size_t*          dynTabSz;
+};
+
+extern ExcHndl* topExcHndl;
+extern int      _ExcAbortNeg;
+extern int      _ExcAbortAll;
+
+class ExcAwareObject {
+friend class ExcHndl;
+public:
+  ExcAwareObject() {
+    if (topExcHndl) topExcHndl->Add(this);
+  }
+  
+  virtual ~ExcAwareObject() {
+    if (topExcHndl) topExcHndl->Forget(this);
+  }
+  
+#ifdef HAS_VEC_NEW
+  void* operator new(size_t s) {
+    void* p = ::operator new(s);
+    if (topExcHndl) topExcHndl->Ignore((ExcAwareObject*)p);
+    return p;
+  }
+
+  void* operator new(size_t /*s*/, void* p) {
+    if (topExcHndl) topExcHndl->Ignore((ExcAwareObject*)p);
+    return p;
+  }
+  
+  void* operator new[](size_t s) {
+    void* p = ::operator new[](s);
+    if (topExcHndl) topExcHndl->IgnoreTab((ExcAwareObject*)p,s);
+    return p;
+  }
+
+  void operator delete[](void* p) {
+    if (topExcHndl) topExcHndl->DelTab((ExcAwareObject*)p);
+    ::operator delete[](p);
+  }
+#else
+  void* operator new(size_t s) {
+    void* p = ::operator new(s);
+    if (topExcHndl) topExcHndl->IgnoreTab((ExcAwareObject*)p,s);
+    return p;
+  }
+
+  void* operator new(size_t s, void* p) {
+    if (topExcHndl) topExcHndl->IgnoreTab((ExcAwareObject*)p,s);
+    return p;
+  }
+
+  void operator delete(void* p) {
+    if (topExcHndl) topExcHndl->DelTab((ExcAwareObject*)p);
+    ::operator delete(p);
+  }
+#endif
+};
+
+//extern "C" void terminate();
+
+void InitFailNewHandler();
+
+// Et maintenant les macros!
+
+// TRY cree un nouveau handler, et fait le setjmp
+
+#define _UPHANDLER \
+    { ExcHndl* tmp = topExcHndl->nextHandler; \
+      delete topExcHndl;                      \
+      topExcHndl = tmp; }
+
+#define EXC_ABORT_NEG(_x) _ExcAbortNeg = _x;
+#define EXC_ABORT_ALL(_x) _ExcAbortAll = _x;
+
+#define EXC_AWARE : public virtual ExcAwareObject
+
+#define END_CONSTRUCTOR \
+if (topExcHndl) topExcHndl->EndConstructor(this, sizeof(*this));
+
+#define TRY \
+    {  topExcHndl = new ExcHndl(topExcHndl); \
+       jmp_buf _jmpBuffer;                   \
+       volatile int _excCaught = 0;          \
+       if (!setjmp(_jmpBuffer)) {            \
+	  topExcHndl->SetEnv(_jmpBuffer);
+
+#define CATCH(_var)                          \
+         _UPHANDLER                          \
+       } else if (topExcHndl->hadExc) {      \
+	  int _caughtException = topExcHndl->theExc; \
+          int _var = _caughtException;       \
+          _excCaught = 1;                    \
+	  _UPHANDLER
+
+#define CATCHALL \
+         _UPHANDLER \
+       } else if (topExcHndl->hadExc) {       \
+	  int _caughtException = topExcHndl->theExc;\
+          _excCaught = _caughtException;                 \
+          _excCaught = 1;                    \
+	  _UPHANDLER
+
+#define ENDTRY \
+       } else _UPHANDLER\
+     }
+
+#define THROW(_i) \
+      {if (!topExcHndl) ExcHndl::NoHandler(_i,__FILE__,__LINE__); \
+       topExcHndl->Throw(_i,__FILE__,__LINE__);}
+
+#define THROW_ THROW(0)
+
+#define THROW_SAME THROW(_caughtException)
+
+#define ASSERT(_a_) if (!(_a_)) { \
+     cerr << "Assertion failed " #_a_ " file " __FILE__ " line " << __LINE__ \
+          << endl; \
+     THROW_ }
+
+#define RETURN(x) { _UPHANDLER; return(x); }
+#define RETURN_ { _UPHANDLER; return; }
+
+#endif
+#endif
+#endif
Index: trunk/SophyaLib/BaseTools/machine.h
===================================================================
--- trunk/SophyaLib/BaseTools/machine.h	(revision 219)
+++ trunk/SophyaLib/BaseTools/machine.h	(revision 219)
@@ -0,0 +1,124 @@
+#ifndef MACHINE_H_SEEN
+#define MACHINE_H_SEEN
+
+#include "defs.h"
+
+#if defined(DECULTRIX)  || defined(ULTRIX)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef long int_4;
+  typedef unsigned long uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 1
+#define  SWAPDEFAUT 1
+
+#elif defined(DECALPHA) || defined(OSF1)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 1
+#define  SWAPDEFAUT 1
+
+#elif  defined(HPUX)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4 ;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+
+#elif  defined( AIX )
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+#elif  defined( sun )
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+#elif defined(Linux)  || defined(linux)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef int int_4;
+  typedef unsigned int uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 1
+#define  SWAPDEFAUT   1
+
+#elif defined(__mac__)
+
+  typedef signed char int_1;
+  typedef unsigned char uint_1;
+  typedef long int_4;
+  typedef unsigned long uint_4;
+  typedef short int_2;
+  typedef unsigned short uint_2;
+  typedef float r_4;
+  typedef double r_8;
+  typedef long long int_8;
+  typedef unsigned long long uint_8;
+
+#define  SWAP 0
+#define  SWAPDEFAUT   0
+
+#else
+#error  Undefined Machine type in machine.h
+#endif
+
+#endif
+
Index: trunk/SophyaLib/BaseTools/peidainit.h
===================================================================
--- trunk/SophyaLib/BaseTools/peidainit.h	(revision 219)
+++ trunk/SophyaLib/BaseTools/peidainit.h	(revision 219)
@@ -0,0 +1,26 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d'initialiseur de module de PEIDA 
+
+#ifndef PEIDAINIT_H_SEEN
+#define PEIDAINIT_H_SEEN
+
+#include "defs.h"
+
+void PrintPeidaVersion(void);
+double PeidaVersion(void); /* Version + (Revision/1000) */
+
+// Classe d''initialisation pour les modules de PEIDA++
+
+class PeidaInitiator {
+private:
+  static int FgInit;
+public:
+  			PeidaInitiator();
+  virtual		~PeidaInitiator();
+  virtual double 	Version(bool fgprt=true);
+};
+
+#define PeidaInit() PeidaInitiator peidainitiator
+
+#endif
+
Index: trunk/SophyaLib/BaseTools/perrors.h
===================================================================
--- trunk/SophyaLib/BaseTools/perrors.h	(revision 219)
+++ trunk/SophyaLib/BaseTools/perrors.h	(revision 219)
@@ -0,0 +1,105 @@
+#ifndef PERRORS_SEEN
+#define PERRORS_SEEN
+
+// Erreurs PEIDA
+// Les erreurs graves sont negatives. Par defaut elles causent
+// un abort, alors que les erreurs positives propagent une
+// exception.
+// voir les macros EXC_ABORT_NEG(flag) et EXC_ABORT_ALL(flag)
+
+#include "exceptions.h"
+enum {
+  allocationErr    = -1,
+  nullPtrErr       = -2,
+  sizeMismatchErr  = -3,
+  rangeCheckErr    = -4,
+  parmErr          = -5,
+  forbiddenErr     = -6,
+  assertionFailErr = -7,
+
+  typeMismatchErr  = 1,
+  fileErr             ,
+  fitsImageErr        ,
+  endOfFileErr        ,
+  tapeErr             ,
+  tapeNoLogErr        ,
+  tapeNoLabelErr      ,
+  tapeEndMediaErr     ,
+  tapeNotReadyErr     ,
+  acqTapeErr          ,
+  acqRobotErr         ,
+  tarFileErr          ,
+  tarFileNoHeaderErr  ,
+  noStarsErr          ,
+  transfoErr          ,
+  fitsHeaderErr       ,
+  singMatxErr         ,
+  noCvgErr            ,
+  notFoundErr         ,
+  dupIdErr            ,
+  getEnvErr           ,
+  catchedSIGFPE       ,
+  catchedSIGSEGV      ,
+  catchedSIGINT       ,
+  catchedSIGQUIT      ,
+  catchedSIGUSR1      ,
+  catchedSIGUSR2      ,
+  inconsistentErr
+};
+
+static inline char* PeidaExc(int i) {
+  switch (i) {
+  case allocationErr:       return "Allocation Exception";
+  case nullPtrErr:          return "Null Pointer Exception";
+  case sizeMismatchErr:     return "Size Mismatch Exception";
+  case rangeCheckErr:       return "Range Check Exception";
+  case parmErr:             return "Invalid Parameter Exception";
+  case forbiddenErr:        return "Forbidden Function Exception";
+  case assertionFailErr:    return "Assertion Failed Exception";
+  case typeMismatchErr:     return "Type Mismatch Exception";
+  case fileErr:             return "File Error Exception";
+  case fitsImageErr:        return "FitsImage Error Exception";
+  case endOfFileErr:        return "End of File Error Exception";
+  case tapeErr:             return "Tape Error Exception";
+  case tapeNoLogErr:        return "Tape No Log File Exception";
+  case tapeNoLabelErr:      return "Tape No label Exception";
+  case tapeEndMediaErr:     return "Tape end data Exception";
+  case tapeNotReadyErr:     return "Tape not ready Exception";
+  case acqTapeErr:          return "Acq Tape Error Exception";
+  case acqRobotErr:         return "Acq Robot Error Exception";
+  case tarFileErr:          return "TarFile Error Exception";
+  case tarFileNoHeaderErr:  return "TarFile No Header Error Exception";
+  case noStarsErr:          return "No/Not Enough Stars Exception";
+  case transfoErr:          return "Transformation finding Exception";
+  case fitsHeaderErr:       return "Fits Header Exception";
+  case singMatxErr:         return "Singular Matrix Exception";
+  case noCvgErr:            return "No Convergence Exception";
+  case notFoundErr:         return "Not Found Exception";
+  case dupIdErr:            return "Duplicate Id Exception";
+  case getEnvErr:           return "GetEnv no var Exception";
+  case inconsistentErr:     return "Inconsistent Data Exception";
+  case catchedSIGFPE:       return "catched SIGFPE (floating point exception) Exception";
+  case catchedSIGSEGV:      return "catched SIGSEGV (segmentation fault) Exception";
+  case catchedSIGINT:       return "catched SIGINT (Interrupt signal) Exception";
+  case catchedSIGQUIT:      return "catched SIGQUIT (Quit signal) Exception";
+  case catchedSIGUSR1:      return "catched SIGUSR1 (User1 signal) Exception";
+  case catchedSIGUSR2:      return "catched SIGUSR2 (User2 signal) Exception";
+  }
+  return "Unkown Exception";
+}
+
+
+#define FAILNIL(_x_) \
+       if (!(_x_)) THROW(nullPtrErr)
+
+#define EXC_MSG(i) PeidaExc(i) << "(" << i << ")"
+
+#ifdef DEBUG
+#define DBFAILNIL(_x_) FAILNIL(_x_)
+#define DBASSERT(_x_) ASSERT(_x_)
+#else
+#define DBFAILNIL(_x_)
+#define DBASSERT(_x_)
+#endif
+
+#endif
Index: trunk/SophyaLib/BaseTools/ppersist.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.cc	(revision 219)
+++ trunk/SophyaLib/BaseTools/ppersist.cc	(revision 219)
@@ -0,0 +1,1220 @@
+#include "defs.h"
+#include <stdio.h>
+#include "peidainit.h"
+#include "ppersist.h"
+#include "dates.h"
+
+#ifndef RFIO
+#include <fstream.h>
+#endif
+
+
+#ifdef __mac__
+#include "unixmac.h"
+#include <SIOUX.h>
+#endif
+
+#if SWAP==1
+#define IS_BIG_ENDIAN 0
+#else
+#define IS_BIG_ENDIAN 1
+#endif
+
+//++
+// Class	PPersistMgr
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Classe gestionnaire d'objets persistants. Les méthodes statiques
+//	de cette classe permettent d'enregistrer des classes persistantes,
+//	et de relire automatiquement des objets.
+//--
+
+//++
+// Links	Voir
+// PPersist
+// PShPersist
+//--
+
+PPersistMgr::ClassList* PPersistMgr::classList = NULL;
+PShPersist::ObjList*    PShPersist::objList = NULL;
+
+//++
+void
+PPersistMgr::RegisterClass(int_4 classId, ClassCreatorFunc f, bool shared)
+//
+//	Enregistre une nouvelle classe auprès du gestionnaire. classId doit
+//	identifier de façon unique la classe. f doit créer un nouvel objet
+//	de cette classe (qui doit hériter de PPersist), non initialisé, et qui
+//	sera relu à partir du fichier d'objets persistants.
+//
+//	Si shared est true, la classe doit hériter de PShPersist, et la persistance
+//	gère le fait que plusieurs objets Xi puissent faire référence à un même objet A.
+//	A, qui hérite donc de PShPersist, ne sera écrit qu'une seule fois dans le fichier
+//	lorsque les Xi sont écrits, et la référence à A sera mise à jour lors de la lecture
+//	des Xi...
+//--
+{
+  DBASSERT(classList);
+  if (classList->size() && (classList->find(classId) != classList->end())) {
+      cerr << "RegisterClass : Error, " << hex << classId << dec 
+           << " already registered." << endl;
+      THROW(dupIdErr);
+    }
+  
+  ClassListEntry entry = {shared, f};
+  (*classList)[classId] = entry;
+}
+
+
+PPersistMgr::ClassCreatorFunc
+PPersistMgr::FindCreatorFunc(int_4 classId)
+{
+  DBASSERT(classList);
+  return (*classList)[classId].f;
+}
+
+PPersistMgr::ClassCreatorFunc
+PPersistMgr::FindCreatorFunc(int_4 classId, bool& isShared)
+{
+  DBASSERT(classList);
+  ClassListEntry entry = (*classList)[classId];
+  isShared = entry.shared;
+  return entry.f;
+}
+
+//++
+PPersist*
+PPersistMgr::ReadObject(PInPersist& s)
+//
+//	Lit un objet dans le stream s, en créant automatiquement un
+//	objet du bon type.
+//--
+{
+  DBASSERT(classList);
+  DBASSERT(PShPersist::objList);
+  // On commence par lire le type de l'objet
+  int_4 classId;
+  s >> classId;
+
+  // On recupere le createur, et on regarde si l'objet est partage
+  bool shared;
+  if (!classList->size() || (classList->find(classId) == classList->end())) {
+    cerr << "PPersistMgr::ReadObject Error : Class " << classId << " not registered" << endl;
+    THROW(notFoundErr);
+  }
+  PPersistMgr::ClassCreatorFunc f = FindCreatorFunc(classId, shared);
+  
+  if (!f) THROW(notFoundErr);
+  
+  PPersist* object;
+  if (shared) {
+    // Si l'objet est partage, ce qui suit est son identificateur, sur 4 octets
+    // et un octet ensuite qui dit si l'objet est present.
+  
+    int_4 objectId;
+    char objectSaved;
+    
+    s >> objectId >> objectSaved;
+
+#if 0
+    // On regarde si l'objet est deja en memoire
+    object = PShPersist::FindObject(objectId);
+    
+    // On verifie qu'on est dans une situation coherente...
+    if ((!objectSaved) == (!object)) THROW(inconsistentErr);
+#else
+    if (!objectSaved) {
+      object = PShPersist::FindObject(objectId);
+      if (!object) THROW(inconsistentErr);
+    }
+#endif
+    if (objectSaved) {
+      object = f();
+      object->ReadSelf(s);
+      ((PShPersist*)object)->mObjectID = objectId;
+      (*PShPersist::objList)[objectId] = (PShPersist*)object; 
+    }
+  } else {
+    object = f();
+    object->ReadSelf(s);
+  }
+  
+  return object;
+}
+
+//++
+// Class	PPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Classe de base pour des objets persistants. Pour créer un objet
+//	persistant :
+//	- Hériter de PPersist.
+//	- Définir un numéro d'identification de la classe, unique dans Peida
+//	- Implémenter "ClassId()"
+//	- Implémenter "WriteSelf" et "ReadSelf", qui doivent écrire toutes les variables
+//	  membres que l'on souhaite écrire, et les relire dans le même ordre.
+//	  Pour écrire une référence à un objet : l'objet doit être un PPersist,
+//	  et il suffit d'appeler "Write" sur cet objet, et "PPersistMgr::ReadObject".
+//	  Si plusieurs objets font référence au même, pour éviter de l'écrire plusieurs
+//	  fois, il faut que cet objet soit un PShPersist.
+//	- Pour que le fichier soit portable, écrire et lire les variables membres en utilisant
+//	  les fonctions PutXX/GetXX de PInPersist/POutPersist.
+//
+//	Attention: les méthodes à redéfinir sont WriteSelf et ReadSelf, mais il ne faut jamais
+//	les appeler directement. Seuls Write et Read peuvent être appelées par l'utilisateur.
+//--
+
+//++
+// Links	Voir
+// PInPersist
+// POutPersist
+// PPersistMgr
+// PShPersist
+//--
+
+PShPersist*
+PShPersist::FindObject(int_4 objId)
+{
+  DBASSERT(objList);
+  return (*objList)[objId];
+}
+  
+//++
+void
+PPersist::Write(string const& fn) const
+//
+//	Ecrit l'objet dans un nouveau fichier ppersist "fn".
+//--
+{
+  POutPersist of(fn);
+  Write(of);
+}
+
+//++
+void
+PPersist::Read(string const& fn) 
+//
+//	Relit l'objet dans le fichier ppersist "fn". Il faut connaître a priori
+//	le type de l'objet. Pour une relecture avec création automatique du bon
+//	objet, utiliser PPersistMgr::ReadObject.
+//--
+{
+  PInPersist inf(fn);
+  Read(inf);
+}
+
+//++
+void
+PPersist::Write(POutPersist& s) const
+//
+//	Ecrit l'objet dans le fichier PPersist.
+//--
+{
+   // On doit tout d'abord ecrire notre type
+   s << ClassId();
+   // Puis on s'ecrit, tout betement...
+   WriteSelf(s);
+}
+
+
+//++
+void
+PPersist::Read(PInPersist& s)
+//
+//	Relit l'objet dans le fichier ppersist. Il faut connaître a priori
+//	le type de l'objet. Pour une relecture avec création automatique du bon
+//	objet, utiliser PPersistMgr::ReadObject.
+//--
+{
+   // A n'utiliser que si on connait a priori
+   // le vrai type de l'objet.
+
+   // On doit tout d'abord lire notre type
+   int_4 classId;
+   s >> classId;
+   if (classId != ClassId()) {
+    cerr << "PPersist::Read() Object type (=" << ClassId() << ") mismatch (type in file="  
+         << classId << ")" << endl;
+    THROW(typeMismatchErr); }
+   // Puis on se lit, tout betement...
+   
+   ReadSelf(s);
+}
+
+//++
+int_4
+PPersist::Write(POutPersist& s, int_4 key) const
+//
+//	Ecrit l'objet dans le fichier PPersist avec un tag ayant "key" comme 
+//	valeur du champ clé du tag.
+//--
+{
+  int_4 rc;
+  // On ecrit le tag de positionnement et on recupere le numero de tag
+  rc = s.WriteTag(key, NULL);
+  // avant d'ecrire l'objet lui-meme
+  Write(s);
+  return(rc);
+}
+
+//++
+int_4
+PPersist::Write(POutPersist& s, int_4 key, string& nom) const
+//
+//	Ecrit l'objet dans le fichier PPersist avec un tag ayant "key", nom comme 
+//	valeurs des champs clé et nom  du tag.
+//--
+{
+  int_4 rc;
+  // On ecrit le tag de positionnement et on recupere le numero de tag
+  rc = s.WriteTag(key, nom.c_str());
+  // avant d'ecrire l'objet lui-meme
+  Write(s);
+  return(rc);
+}
+
+//++
+void
+PPersist::ReadAtTag(PInPersist& s, int_4 tagid)
+//
+//	Lit l'objet à la position du tag numéro "tagid".
+//--
+{
+  if (s.GotoTag(tagid))  Read(s);
+  else {
+    cerr << "PInPersist::GotoTag()  Error ! \n" << 
+	    "From PPersist::ReadAtTag(PInPersist, tag= " << tagid << ") " << endl; 
+    THROW(fileErr);
+  }
+  return;    
+}
+
+//++
+void
+PPersist::ReadAtKey(PInPersist& s, int_4 key)
+//
+//	Lit l'objet à la position du tag contenant la clé "key".
+//--
+{
+  if (s.GotoKey(key))  Read(s);
+  else {
+    cerr << "PInPersist::GotoKey()  Error ! \n" << 
+	    "From PPersist::ReadAtKey(PInPersist, key= " << key << ") " << endl; 
+    THROW(fileErr);
+  }
+  return;    
+}
+
+//++
+//  virtual void PPersist::ReadSelf(PInPersist&)=0
+//	Méthode virtuelle pure à redéfinir. Elle est appelée par Read
+//	et PPersistMgr::ReadObject. Il faut relire les variables membres,
+//	dans l'ordre où elles ont été écrites par WriteSelf.
+//  virtual void PPersist::WriteSelf(POutPersist&) const=0
+//	Méthode virtuelle pure à redéfinir. Elle est appelée par Write.
+//	Il faut écrire les variables membres,
+//	dans l'ordre où elles seront relues par ReadSelf.
+//--
+
+
+//++
+// Class	PShPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Classe de base pour des objets persistants partagés.
+//	Un tel objet ne sera écrit qu'une seule fois dans un fichier
+//	donné. Les tentatives suivantes d'écriture n'écrivent qu'une
+//	référence à la première écriture.
+//
+//	Lors de la lecture, l'objet est créé lors de la première lecture,
+//	puis l'adresse de cet objet est retournée lors des lectures suivantes.
+//--
+
+//++
+// Links	Parents
+// PPersist
+//--
+
+//++
+void
+PShPersist::Write(POutPersist& s) const
+//
+//	Ecrit l'objet dans le fichier s.
+//
+//	En fait, l'objet est physiquement écrit une seule fois.
+//--
+{
+  DBASSERT(objList);
+   // On doit tout d'abord ecrire notre type
+   
+   s << ClassId();
+
+   // On doit ensuite ecrire notre identificateur et le flag d'ecriture
+   
+   char write = (mObjectID == 0) ? 255 : 0;
+   if (mObjectID == 0) {
+     (int_4&)mObjectID = (*objList).size() ? (*((*objList).rbegin())).first+1 : 1;
+     (*objList)[mObjectID] = (PShPersist*)this; 
+   }
+
+   s << mObjectID << write ;
+   
+   // Puis, si necessaire, on s'ecrit
+   
+   if (write)
+     WriteSelf(s);
+}
+
+PShPersist::~PShPersist()  // Une securite peut-etre facultative
+{
+  DBASSERT(objList);
+  if (mObjectID) {
+    DBASSERT(!objList->size() && (objList->find(mObjectID) != objList->end()));
+    objList->erase(mObjectID);
+  }
+}
+
+void
+PPersistMgr::Reset()
+{
+  DBASSERT(PShPersist::objList);
+  for (PShPersist::ObjList::iterator i = PShPersist::objList->begin(); 
+       i != PShPersist::objList->end(); i++)
+    (*i).second->mObjectID = 0; // Une securite peut-etre facultative
+
+  PShPersist::objList->erase(PShPersist::objList->begin(), PShPersist::objList->end());
+}
+
+#define PIOP_Delim  '\n'   // Delimiteur de ligne 
+//  Les noms ne peuvent depasser 255 caracteres  
+#define MAXTAGNAMELEN  255   
+
+//++
+// Class	PInPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Fichier d'objets persistants, en lecture.
+//--
+
+//++
+PInPersist::PInPersist(string const& flnm, bool scan)
+//
+//	Constructeur. Ouvre le fichier.
+//--
+{
+  mSbsz = 0;     // Pour conserver les noms des tags ( V4 et au dela )
+  mSbuf = NULL;
+  mTags = NULL;
+  mNTags = 0;    //    "        "        "           "
+  fName = flnm;
+#ifdef RFIO
+  s = new erosifstream(flnm.c_str(),"rb");
+#else
+// $CHECK$ EA  ios::binary (ou ios::bin) doit exister PARTOUT.
+// Voir note dans defs.h pres de HAS_IOS_BIN
+#if defined(__MWERKS__)
+  s = new ifstream(flnm.c_str(),ios::in | ios::binary); // ios::binary pas connnu partout - $CHECK$ Reza 13/02/98
+#else
+  s = new ifstream(flnm.c_str(),ios::in );
+#endif
+#endif
+  PPersistMgr::Reset();
+  char rbuf[36];
+  GetBytes(rbuf, 32);
+  if (strncmp(rbuf,"PEIDA-PPersistFile", 18) != 0)  {
+    cerr << "PInPersist::PInPersist Error : File " << flnm << " (empty file or bad header)" 
+         << endl;
+    THROW(fileErr); }
+  version = atoi(rbuf+20);
+  bigEndian = IS_BIG_ENDIAN; // Les V2 sont relus en mode natif
+  if (version >= 3) {
+    GetBytes(rbuf, 32);
+    if (strncmp(rbuf,"BIG-ENDIAN",10) == 0)
+      bigEndian = true;
+    else if (strncmp(rbuf,"LITTLE-ENDIAN",13) == 0)
+      bigEndian = false;
+    else {
+      cerr << "PInPersist::PInPersist Error : File" << flnm;
+      cerr << " (V>=3 et ni BIG-ENDIAN, ni LITTLE-ENDIAN" << endl;
+      THROW(fileErr);
+    }
+  }
+  if (version >= 5) {   // On lit la date de creation (V5 et au-dela)
+    GetBytes(rbuf, 32);
+    rbuf[32] = '\0'; 
+    for(int k=0; k<32; k++) 
+      if (rbuf[k] == ' ') { rbuf[k] = '\0';  break; }
+    creationdate = rbuf;
+    }  // Fin de lecture de date
+  else creationdate = "??/??/??" ;
+  // Le fichier peut contenir des tag  (V4 et au dela)
+  if ( (version >= 4) && scan )  Scan();
+}
+
+
+
+PInPersist::~PInPersist()
+{
+  list<char*>::iterator it;
+  for(it = mSbuffs.begin(); it != mSbuffs.end(); it++)  delete[] (*it);
+  if (mTags)  delete[] mTags;
+  delete s;
+  PPersistMgr::Reset();
+}
+
+// A cause de aCC qui ne veut pas char* b = ""
+static char ChaineVide[2] = {'\0', '\0'};
+
+void
+PInPersist::Scan()
+{
+// On parcourt le fichier depuis la fin pour identifier tous les tags
+  int_8 debut, prev, premier;
+  int_4 ntag, ntc, ll;
+  uint_2 ln;
+  char pad[4];
+
+  #if defined(STREAMPOS_IS_CLASS) && !defined(RFIO)
+  debut = s->tellg().offset();
+  #else
+  debut = s->tellg();
+  #endif
+
+  premier = 0;
+  s->seekg(-(sizeof(int_8)+sizeof(int_4)), ios::end);
+  GetI8(prev);
+  GetI4(ntag);
+  if ( (ntag <= 0) || (prev < 0) )  
+    { s->seekg(debut,ios::beg); return; }
+
+  mNTags = ntag;
+  mTags = new PPFTag[ntag];
+
+  PPFTag* tag;
+  while( (prev > 0)  && (ntag > 0) ) {
+    s->seekg(prev);
+    if (ntag == 1)   premier = prev;
+    GetI8(prev);
+    GetI4(ntc);
+    ntag--;
+    if (ntc != ntag) {
+      cerr << "PInPersist::Scan() / Error: NTag,TC= " << ntag << "," << ntc << endl;
+      THROW(fileErr);
+    }
+    tag = mTags+ntag;
+    GetI4(tag->key);
+    GetU2(ln);  
+    if (ln > 0) {
+      tag->lnom = ln;
+      tag->nom = GetCStr(ln);
+      GetBytes(tag->nom, ln+1); 
+      ll = 3-((ln+2)%4);
+      GetBytes(pad, ll);
+    }
+    else { 
+      GetU2(ln);
+      tag->lnom = 0;
+      tag->nom = ChaineVide;
+    }
+// On recupere la position pour l'objet qui suit
+  #ifdef STREAMPOS_IS_CLASS
+  tag->popos = s->tellg().offset();
+  #else
+  tag->popos = s->tellg();
+  #endif
+
+  GetI4(tag->cid); 
+  }
+
+  if ( (ntag != 0) || (prev >= 0) ) {  // En principe , ca ne doit pas arriver
+    cerr << "PInPersist::Scan() / Error: (End: ntag=" << ntag <<
+            " prev=" << (int_4)prev << endl;
+    THROW(fileErr);
+  }
+// on se repositionne au debut du 1er objet du fichier 
+  if (premier == debut)  GotoTag(0); 
+  else s->seekg(debut);
+  return;
+}
+
+char*
+PInPersist::GetCStr(uint_2 sz)
+{
+char* rs;
+sz += 1;  // Pour le 0 de la fin
+if (sz > mSbsz)
+  { mSbsz = (sz > (MAXTAGNAMELEN+1)) ? sz : (MAXTAGNAMELEN+1);
+  mSbuf = new char[mSbsz];  mSbuffs.push_back(mSbuf); }
+
+rs = mSbuf;
+mSbuf += sz;
+mSbsz -= sz;
+return(rs);
+}
+
+bool 
+PInPersist::GotoTag(int_4 num)
+{
+  if ( (num < 0) || (num >= mNTags) )  return(false);
+  s->seekg(mTags[num].popos);
+  return(true); 
+}
+
+bool 
+PInPersist::GotoKey(int_4 key, int rang)
+{
+  if (rang < 0)  return(false);
+  int n = 0, i; 
+  int fnd = -1;
+  for(i=0; i<mNTags; i++) 
+    if (mTags[i].key == key) { 
+      if (n == rang) { fnd = i;   break; }
+      n++; }
+    
+  if (fnd >= 0) return(GotoTag(fnd));
+  else return(false);
+}
+
+int 
+PInPersist::NbKey(int_4 key)
+{
+  int n = 0, i;
+  for(i=0; i<mNTags; i++) 
+    if (mTags[i].key == key)  n++;
+  return(n);
+}
+
+void
+PInPersist::ListTags()
+{
+  cout << "PInPersist/ File " << fName << "\n";
+  cout << "Nb Tags in file : " << mNTags << "\n";
+  string str;
+  int i;
+  for(i=0; i<mNTags; i++) {
+    str = mTags[i].nom;
+    cout << i << "- CId= " << mTags[i].cid << " Key= " 
+         << mTags[i].key << " ( " << str << " )\n" ;
+  }
+  cout << endl;
+  return;  
+}
+
+int_4
+PInPersist::TagKey(int_4 num, int_4& cid, int_4& ln)
+{
+  if ( (num < 0) || (num >= mNTags) )  return(0);
+  cid = mTags[num].cid; ln = mTags[num].lnom; 
+  return(mTags[num].key);
+}
+
+string
+PInPersist::TagName(int_4 num)
+{
+  if ( (num < 0) || (num >= mNTags) )  return("");
+  return((string)mTags[num].nom);
+}
+
+//++
+// void PInPersist::GetByte(char& c)
+// void PInPersist::GetBytes(void* ptr, size_t bytes)
+// void PInPersist::GetR4   (r_4& result)
+// void PInPersist::GetR4s  (r_4* tab, size_t n)
+// void PInPersist::GetR8   (r_8& result)
+// void PInPersist::GetR8s  (r_8* tab, size_t n)
+// void PInPersist::GetI2   (int_2& result)
+// void PInPersist::GetI2s  (int_2* tab, size_t n)
+// void PInPersist::GetU2   (uint_2& result)
+// void PInPersist::GetU2s  (uint_2* tab, size_t n)
+// void PInPersist::GetI4   (int_4& result)
+// void PInPersist::GetI4s  (int_4* tab, size_t n)
+// void PInPersist::GetU4   (uint_4& result)
+// void PInPersist::GetU4s  (uint_4* tab, size_t n)
+// void PInPersist::GetI8   (int_8& result)
+// void PInPersist::GetI8s  (int_8* tab, size_t n)
+// void PInPersist::GetU8   (uint_8& result)
+// void PInPersist::GetU8s  (uint_8* tab, size_t n)
+//	Lecture de données portables depuis le fichier PPersist. Pour chaque type
+//	de données, on peut lire une valeur, ou un tableau de valeurs.
+// void PInPersist::GetLine(char* ptr, size_t len)
+//	Lecture d'une ligne de texte depuis le fichier PPersist.
+//--
+
+void
+PInPersist::GetByte(char& c)
+{
+  GetBytes(&c, 1);
+}
+
+void
+PInPersist::GetBytes(void* ptr, size_t bytes)
+{
+  s->read((char*)ptr, bytes);
+}
+
+static inline void bswap8(void* p)
+{
+  uint_8 tmp = *(uint_8*)p;
+  *(uint_8*)p = ((tmp >> (7*8)) & 0x000000FF) | 
+                ((tmp >> (5*8)) & 0x0000FF00) |
+                ((tmp >> (3*8)) & 0x00FF0000) |
+                ((tmp >> (1*8)) & 0xFF000000) |
+                ((tmp & 0xFF000000) << (1*8))  |
+                ((tmp & 0x00FF0000) << (3*8))  |
+                ((tmp & 0x0000FF00) << (5*8))  |
+                ((tmp & 0x000000FF) << (7*8));
+}
+
+static inline void bswap4(void* p)
+{
+  uint_4 tmp = *(uint_4*)p;
+  *(uint_4*)p = ((tmp >> 24) & 0x000000FF) | 
+                ((tmp >> 8)  & 0x0000FF00) |
+                ((tmp & 0x0000FF00) << 8)  |
+                ((tmp & 0x000000FF) << 24);
+}
+
+static inline void bswap2(void* p)
+{
+  uint_2 tmp = *(uint_2*)p;
+  *(uint_2*)p = ((tmp >> 8) & 0x00FF) | 
+                ((tmp & 0x00FF) << 8);
+}
+
+void
+PInPersist::GetR4   (r_4& result)
+{
+  GetBytes(&result, sizeof(r_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+
+void
+PInPersist::GetR4s  (r_4* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(r_4));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap4(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetR8   (r_8& result)
+{
+  GetBytes(&result, sizeof(r_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PInPersist::GetR8s  (r_8* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(r_8));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap8(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetI2   (int_2& result)
+{
+  GetBytes(&result, sizeof(int_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PInPersist::GetI2s  (int_2* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(int_2));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap2(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetU2   (uint_2& result)
+{
+  GetBytes(&result, sizeof(uint_2));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&result);
+}
+
+void
+PInPersist::GetU2s  (uint_2* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(uint_2));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap2(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetI4   (int_4& result)
+{
+  GetBytes(&result, sizeof(int_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PInPersist::GetI4s  (int_4* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(int_4));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap4(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetU4   (uint_4& result)
+{
+  GetBytes(&result, sizeof(uint_4));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&result);
+}
+
+void
+PInPersist::GetU4s  (uint_4* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(uint_4));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap4(tab+i);
+
+  return;
+}
+
+
+void
+PInPersist::GetI8   (int_8& result)
+{
+  GetBytes(&result, sizeof(int_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PInPersist::GetI8s  (int_8* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(int_8));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap8(tab+i);
+
+  return;
+}
+
+void
+PInPersist::GetU8   (uint_8& result)
+{
+  GetBytes(&result, sizeof(uint_8));
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&result);
+}
+
+void
+PInPersist::GetU8s  (uint_8* tab, size_t n)
+{
+  GetBytes(tab, n*sizeof(uint_8));
+  if (bigEndian == IS_BIG_ENDIAN) return;
+
+  for (unsigned int i=0; i<n; i++)
+    bswap8(tab+i);
+
+  return;
+}
+
+
+void
+PInPersist::GetLine(char* ptr, size_t len)
+{
+  s->getline(ptr, len, PIOP_Delim);
+}
+
+
+//++
+// Class	POutPersist
+// Lib		Outils++
+// include	ppersist.h
+//
+//	Fichier d'objets persistants, en écriture.
+//--
+
+
+//++
+//  POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE)
+//
+//	Crée un nouveau fichier ppersist. Par défaut, il est petit=boutien
+//	sur machines petit-boutiennes, et gros-boutien sur machines
+//	gros-boutiennes. On peut explicitement spécifier PPersist::PPS_LITTLE_ENDIAN
+//	ou PPersist::PPS_BIG_ENDIAN.
+//--
+POutPersist::POutPersist(string const& flnm, int endianness)
+{
+  if (endianness == -1)
+    bigEndian = IS_BIG_ENDIAN;
+  else
+    bigEndian = endianness;
+
+#ifdef RFIO
+  s = new erosofstream(flnm.c_str(),"wb");
+#else
+#if defined(__MWERKS__)
+  s = new ofstream(flnm.c_str(),ios::out | ios::binary);   // ios::binary pas connnu partout - $CHECK$ Reza 13/02/98
+#else
+  s = new ofstream(flnm.c_str(),ios::out );
+#endif
+#endif
+  PPersistMgr::Reset();
+  PutBytes("PEIDA-PPersistFile V5           ",32);
+  PutBytes(bigEndian 
+	   ? "BIG-ENDIAN                      "
+	   : "LITTLE-ENDIAN                   ",32);
+// ---- On ecrit la date de creation a partir de V5 
+  Date today;
+  string stod = today.DateStr(Date::kLocalTime) + "#" + today.TimeStr(Date::kLocalTime);
+  char buff[36];
+  int l = stod.length();
+  if (l < 33) strcpy(buff, stod.c_str()); 
+  else strncpy(buff, stod.c_str(), 33);
+  for(int i=l+1; i<32; i++)  buff[i] = ' ';
+  buff[32] = '\0'; 
+  PutBytes(buff, 32);
+//  Fin d'ecriture de date --------
+  previous = -1;  // Pas de Tag precedant
+  numTag = 0;
+}
+
+POutPersist::~POutPersist()
+{
+  PutI8(previous);
+  PutI4(numTag);
+  delete s;
+  PPersistMgr::Reset();
+}
+
+
+int_4 
+POutPersist::WriteTag(int_4 key, char const * nom)
+{
+  int_8 nexprev;
+  uint_2 l;
+  int ll;
+  char pad[4] = {'\0', '\0', '\0', '\0'};
+
+  #ifdef STREAMPOS_IS_CLASS
+  nexprev = s->tellp().offset();
+  #else
+  nexprev = s->tellp();
+  #endif
+// On ecrit dans l'ordre 
+//  - La position du tag precedant (-1 s'il n'y en a pas)
+//  - Le numero de tag ( qui s incremete automatiquement )
+//  - La cle utilisateur  (key)
+//  - La longueur du nom 
+//  - le nom lui-meme    (Avec un pad afin de faire nom+longueur=multiple de 4)
+  PutI8(previous);
+  PutI4(numTag);
+  PutI4(key);
+  if (nom==NULL)   { 
+    PutU2(0);  PutU2(0);
+  }  
+  else {
+    ll = strlen(nom);
+    if (ll <= 0) {
+      PutU2(0);  PutU2(0);
+    } 
+    l = (ll <=  MAXTAGNAMELEN) ? ll : MAXTAGNAMELEN ; 
+    PutU2(l);
+    PutBytes(nom,l+1); 
+    ll = 3-((ll+2)%4);
+    PutBytes(pad, ll);
+  }
+  previous = nexprev;
+  numTag++;
+  return((numTag-1));
+}
+
+//++
+// void POutPersist::PutByte(char& c)
+// void POutPersist::PutBytes(void const* ptr, size_t bytes)
+// void POutPersist::PutR4   (r_4 result)
+// void POutPersist::PutR4s  (r_4 const* tab, size_t n)
+// void POutPersist::PutR8   (r_8 result)
+// void POutPersist::PutR8s  (r_8 const* tab, size_t n)
+// void POutPersist::PutI2   (int_2 result)
+// void POutPersist::PutI2s  (int_2 const* tab, size_t n)
+// void POutPersist::PutU2   (uint_2 result)
+// void POutPersist::PutU2s  (uint_2 const* tab, size_t n)
+// void POutPersist::PutI4   (int_4 result)
+// void POutPersist::PutI4s  (int_4 const* tab, size_t n)
+// void POutPersist::PutU4   (uint_4 result)
+// void POutPersist::PutU4s  (uint_4 const* tab, size_t n)
+// void POutPersist::PutI8   (int_8 result)
+// void POutPersist::PutI8s  (int_8 const* tab, size_t n)
+// void POutPersist::PutU8   (uint_8 result)
+// void POutPersist::PutU8s  (uint_8 const* tab, size_t n)
+//	Ecriture de données portables.. Pour chaque type
+//	de données, on peut écrire une valeur, ou un tableau de valeurs.
+// void POutPersist::PutLine(char const* ptr, size_t len)
+//	Ecriture d'une ligne de texte dans le fichier PPersist.
+//--
+
+
+
+
+void
+POutPersist::PutByte(char c)
+{
+  PutBytes(&c, 1);
+}
+
+void
+POutPersist::PutBytes(void const* ptr, size_t bytes)
+{
+  s->write((char const*)ptr, bytes);
+}
+
+void
+POutPersist::PutR4   (r_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutBytes(&val, sizeof(r_4));
+}
+
+void
+POutPersist::PutR4s  (r_4 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(r_4));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutR4(tab[i]);
+}
+
+void
+POutPersist::PutR8   (r_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutBytes(&val, sizeof(r_8));
+}
+
+void
+POutPersist::PutR8s  (r_8 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(r_8));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutR8(tab[i]);
+}
+
+void
+POutPersist::PutI2   (int_2 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutBytes(&val, sizeof(int_2));
+}
+
+void
+POutPersist::PutI2s  (int_2 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(int_2));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutI2(tab[i]);
+}
+
+void
+POutPersist::PutU2   (uint_2 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap2(&val);
+
+  PutBytes(&val, sizeof(uint_2));
+}
+
+void
+POutPersist::PutU2s  (uint_2 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(uint_2));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutU2(tab[i]);
+}
+
+void
+POutPersist::PutI4   (int_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutBytes(&val, sizeof(int_4));
+}
+
+void
+POutPersist::PutI4s  (int_4 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(int_4));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutI4(tab[i]);
+}
+
+void
+POutPersist::PutU4   (uint_4 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap4(&val);
+
+  PutBytes(&val, sizeof(uint_4));
+}
+
+void
+POutPersist::PutU4s  (uint_4 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(uint_4));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutU4(tab[i]);
+}
+
+void
+POutPersist::PutI8   (int_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutBytes(&val, sizeof(int_8));
+}
+
+void
+POutPersist::PutI8s  (int_8 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(int_8));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutI8(tab[i]);
+}
+
+void
+POutPersist::PutU8   (uint_8 val)
+{
+  if (bigEndian != IS_BIG_ENDIAN)
+    bswap8(&val);
+
+  PutBytes(&val, sizeof(uint_8));
+}
+
+void
+POutPersist::PutU8s  (uint_8 const* tab, size_t n)
+{
+  if (bigEndian == IS_BIG_ENDIAN)
+    PutBytes(tab, n*sizeof(uint_8));
+  else
+    for (unsigned int i=0; i<n; i++)
+      PutU8(tab[i]);
+}
+
+void
+POutPersist::PutLine(char const* ptr, size_t len)
+{
+  if (len == 0)  len = strlen(ptr);
+  s->write(ptr, len);
+#ifdef RFIO
+  char cd = PIOP_Delim;
+  s->write(&cd, 1);
+#else
+  s->put(PIOP_Delim);
+#endif  
+  
+}
+
+
+// ---  Classe d'initialisation de PEIDA++, (PPersistMgr en particulier)
+int PeidaInitiator::FgInit = 0;
+
+PeidaInitiator::PeidaInitiator()
+{
+  FgInit++;
+  if (FgInit > 1)  return;
+
+  InitFailNewHandler();
+
+  #ifdef xx__mac__
+  //InitToolBox();
+  //SIOUXSettings.initializeTB = FALSE;
+  SIOUXSettings.autocloseonquit = FALSE;
+  SIOUXSettings.asktosaveonclose = FALSE;
+  SIOUXSettings.showstatusline = TRUE;
+  #endif
+
+  PPersistMgr::classList = new PPersistMgr::ClassList;
+  PShPersist::objList    = new PShPersist::ObjList;
+  
+
+#if (!defined(__GNUG__) && !defined(__MWERKS__) && !defined(HPUX))
+  // pas de bufferisation pour printf   cmv 18/3/97 selon E.A.
+  // setvbuf(stdout,NULL,_IOLBF,0); setvbuf(stderr,NULL,_IOLBF,0);
+  setlinebuf(stdout);
+  setlinebuf(stderr);
+#endif
+
+  // si var env PEIDA_NOPRTVER definie pas de print
+  if(!getenv("PEIDA_NOPRTVER")) PrintPeidaVersion();
+}
+
+PeidaInitiator::~PeidaInitiator()
+{
+  FgInit--;
+  if (FgInit == 0)
+    {
+    delete PPersistMgr::classList; PPersistMgr::classList = NULL;
+    delete PShPersist::objList;    PShPersist::objList = NULL;
+    }
+}
+
+double PeidaInitiator::Version(bool fgprt)
+{
+if (fgprt)  PrintPeidaVersion();
+return(PeidaVersion());
+}
+ 
+// On met un objet initiator en statique, pour les loaders qui savent 
+// appeler le constructeur des objets statiques   Reza 08/98
+static PeidaInitiator ppeidainit;
+
Index: trunk/SophyaLib/BaseTools/ppersist.h
===================================================================
--- trunk/SophyaLib/BaseTools/ppersist.h	(revision 219)
+++ trunk/SophyaLib/BaseTools/ppersist.h	(revision 219)
@@ -0,0 +1,326 @@
+#ifndef PPERSIST_H_SEEN
+#define PPERSIST_H_SEEN
+
+// Classe mixin pour implementer une persistance pas trop bete.
+
+#include "defs.h"
+#include "machine.h"
+#include "perrors.h"
+#include "pclassids.h"
+
+#include <string>
+#include <list>
+#include <map>
+#include <functional>
+
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#include <functional.h>
+#endif
+
+#ifdef RFIO
+#include "erostream.h"
+#else
+#include <iostream.h>
+#endif
+
+
+class PPersistMgr;
+class PPersist;
+class PShPersist;
+class PInPersist;
+class POutPersist;
+
+typedef less<int_4> Int4Compare;
+
+class PPersistMgr {
+public:
+  typedef PPersist*           (*ClassCreatorFunc)();
+  
+  static void                  RegisterClass(int_4 classId, ClassCreatorFunc f,
+                                             bool shared=false);
+  static PPersist*             ReadObject(PInPersist&);
+  
+  static ClassCreatorFunc      FindCreatorFunc(int_4 classId);
+  static ClassCreatorFunc      FindCreatorFunc(int_4 classId, bool& isShared);
+  
+  static void                  Reset();  // Nouveau fichier, on oublie les objets partages.
+
+#ifndef __DECCXX
+private:
+#endif
+  struct  ClassListEntry {
+    bool             shared;
+    ClassCreatorFunc f;
+  };
+#ifdef __DECCXX
+private:
+#endif
+
+  typedef map<int_4, ClassListEntry, Int4Compare> ClassList;
+
+
+  static ClassList*            classList;
+  friend class                 PeidaInitiator;
+};
+
+
+
+class PPersist EXC_AWARE {
+public:
+  enum {PPS_NATIVE = -1, PPS_LITTLE_ENDIAN = 0, PPS_BIG_ENDIAN = 1};
+  virtual                   ~PPersist() {}
+  virtual int_4              ClassId() const=0;
+
+          void               Write(string const& fn) const;
+          void               Read(string const& fn);
+
+  virtual void               Write(POutPersist&) const;
+          void               Read(PInPersist& s);  // Se lit, y compris le tag de type.
+          int_4              Write(POutPersist&, int_4 key) const; 
+          int_4              Write(POutPersist&, int_4 key, string& nom) const; 
+          void               ReadAtTag(PInPersist& s, int_4 tagid);
+          void               ReadAtKey(PInPersist& s, int_4 key);
+protected:  
+  virtual void               ReadSelf(PInPersist&)=0;        // A redefinir...
+  virtual void               WriteSelf(POutPersist&) const=0; // A redefinir...
+
+  friend class               PPersistMgr;
+};
+
+class PShPersist : public PPersist{
+public:
+                             PShPersist() :mObjectID(0) {}
+  virtual                   ~PShPersist();
+  virtual void               Write(POutPersist&) const;
+  static PShPersist*         FindObject(int_4 objId);
+  
+private:
+  typedef map<int_4, PShPersist*, Int4Compare> ObjList;
+
+  static ObjList*            objList;
+  /*mutable*/ int_4          mObjectID;
+  friend class               PPersistMgr;
+  friend class               PeidaInitiator;
+};
+
+
+
+class PInPersist {
+public:
+  PInPersist(string const& flnm, bool scan=true);
+  ~PInPersist();
+
+  bool   GotoTag(int_4 num);
+  bool   GotoKey(int_4 key, int rang=0);
+  int    NbKey(int_4 key);
+  void   ListTags();
+  inline int_4   NbTags() { return(mNTags); } 
+  int_4  TagKey(int_4 num, int_4& cid, int_4& ln);
+  string TagName(int_4 num);
+
+  void   GetByte (char& c);
+  void   GetBytes(void* ptr, size_t bytes);
+  void   GetR4   (r_4&);
+  void   GetR4s  (r_4*, size_t);
+  void   GetR8   (r_8&);
+  void   GetR8s  (r_8*, size_t);
+  void   GetI2   (int_2&);
+  void   GetI2s  (int_2*, size_t);
+  void   GetU2   (uint_2&);
+  void   GetU2s  (uint_2*, size_t);
+  void   GetI4   (int_4&);
+  void   GetI4s  (int_4*, size_t);
+  void   GetU4   (uint_4&);
+  void   GetU4s  (uint_4*, size_t);
+  void   GetI8   (int_8&);
+  void   GetI8s  (int_8*, size_t);
+  void   GetU8   (uint_8&);
+  void   GetU8s  (uint_8*, size_t);
+  void   GetLine (char* ptr, size_t len);
+
+  void   Get(char&   c) {GetByte(c);}
+  void   Get(r_4&    x) {GetR4(x);}
+  void   Get(r_8&    x) {GetR8(x);}
+  void   Get(uint_2& x) {GetU2(x);}
+  void   Get(int_2&  x) {GetI2(x);}
+  void   Get(uint_4& x) {GetU4(x);}
+  void   Get(int_4&  x) {GetI4(x);}
+  void   Get(uint_8& x) {GetU8(x);}
+  void   Get(int_8&  x) {GetI8(x);}
+  void   Get(r_4*    x, size_t n) {GetR4s(x,n);}
+  void   Get(r_8*    x, size_t n) {GetR8s(x,n);}
+  void   Get(uint_2* x, size_t n) {GetU2s(x,n);}
+  void   Get(int_2*  x, size_t n) {GetI2s(x,n);}
+  void   Get(uint_4* x, size_t n) {GetU4s(x,n);}
+  void   Get(int_4*  x, size_t n) {GetI4s(x,n);}
+  void   Get(uint_8* x, size_t n) {GetU8s(x,n);}
+  void   Get(int_8*  x, size_t n) {GetI8s(x,n);}
+
+  int    Version() {return version;}
+  string CreationDate() { return creationdate; }
+
+protected:
+  void      Scan();
+  char*     GetCStr(uint_2 l);
+#ifdef RFIO
+  erosifstream *s;
+#else
+  istream* s;
+#endif
+  int bigEndian;
+  int version;
+
+  string fName;
+  string creationdate;
+
+  struct PPFTag {
+    int_8 popos;
+    int_4 cid;
+    int_4 key;
+    uint_2 lnom;
+    char* nom;
+  };    
+  PPFTag* mTags;
+  int_4 mNTags;
+  list<char*> mSbuffs;
+  char* mSbuf;
+  int mSbsz;
+};
+
+class POutPersist {
+public:
+  POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE);
+  ~POutPersist();
+
+  int_4 WriteTag(int_4 key, char const * name=NULL);
+  void PutByte (char c);
+  void PutBytes(void const* ptr, size_t bytes);
+  void PutR4   (r_4);
+  void PutR4s  (r_4 const*, size_t);
+  void PutR8   (r_8);
+  void PutR8s  (r_8 const*, size_t);
+  void PutI2   (int_2);
+  void PutI2s  (int_2 const*, size_t);
+  void PutU2   (uint_2);
+  void PutU2s  (uint_2 const*, size_t);
+  void PutI4   (int_4);
+  void PutI4s  (int_4 const*, size_t);
+  void PutU4   (uint_4);
+  void PutU4s  (uint_4 const*, size_t);
+  void PutI8   (int_8);
+  void PutI8s  (int_8 const*, size_t);
+  void PutU8   (uint_8);
+  void PutU8s  (uint_8 const*, size_t);
+  void PutLine (char const* ptr, size_t len=0);
+
+  void   Put(char   c) {PutByte(c);}
+  void   Put(r_4    x) {PutR4(x);}
+  void   Put(r_8    x) {PutR8(x);}
+  void   Put(uint_2 x) {PutU2(x);}
+  void   Put(int_2  x) {PutI2(x);}
+  void   Put(uint_4 x) {PutU4(x);}
+  void   Put(int_4  x) {PutI4(x);}
+  void   Put(uint_8 x) {PutU8(x);}
+  void   Put(int_8  x) {PutI8(x);}
+  void   Put(r_4 const*    x, size_t n) {PutR4s(x,n);}
+  void   Put(r_8 const*    x, size_t n) {PutR8s(x,n);}
+  void   Put(uint_2 const* x, size_t n) {PutU2s(x,n);}
+  void   Put(int_2 const*  x, size_t n) {PutI2s(x,n);}
+  void   Put(uint_4 const* x, size_t n) {PutU4s(x,n);}
+  void   Put(int_4 const*  x, size_t n) {PutI4s(x,n);}
+  void   Put(uint_8 const* x, size_t n) {PutU8s(x,n);}
+  void   Put(int_8 const*  x, size_t n) {PutI8s(x,n);}
+
+
+protected:
+#ifdef RFIO
+  erosofstream *s;
+#else
+  ostream* s;
+#endif
+  int bigEndian;
+  int_4 numTag;
+  int_8 previous;
+};
+
+/* 
+// Ceci est dangereux car un template a priorite sur un changement de type, meme trivial...
+
+template <class T>
+POutPersist& operator << (POutPersist& c, T const& data)
+{
+  c.PutBytes(&data, sizeof(T));
+  return c;
+}
+
+template <class T>
+PInPersist& operator >> (PInPersist& c, T& data)
+{
+  c.GetBytes(&data, sizeof(T));
+  return c;
+}
+*/
+
+#define RAWPERSISTIO(_Type_,_xtyp_)                                             \
+inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
+{                                                                               \
+  c.Put##_xtyp_(data);                                                        \
+  return c;                                                                     \
+}                                                                               \
+                                                                                \
+inline PInPersist& operator >> (PInPersist& c, _Type_& data)                    \
+{                                                                               \
+  c.Get##_xtyp_(data);                                                        \
+  return c;                                                                     \
+}                                                                               
+
+RAWPERSISTIO(int_4,I4)
+RAWPERSISTIO(uint_4,U4)
+RAWPERSISTIO(int_2,I2)
+RAWPERSISTIO(uint_2,U2)
+RAWPERSISTIO(char,Byte)
+RAWPERSISTIO(r_4,R4)
+RAWPERSISTIO(r_8,R8)
+
+#if 0
+#define STRUCTPERSISTIO(_Type_, _field_, _size_)                                \
+inline POutPersist& operator << (POutPersist& c, _Type_ const& data)            \
+{                                                                               \
+  c.PutBytes(&data._field_, _size_);                                            \
+  return c;                                                                     \
+}                                                                               \
+                                                                                \
+inline PInPersist& operator >> (PInPersist& c, _Type_& data)                    \
+{                                                                               \
+  c.GetBytes(&data._field_, _size_);                                            \
+  return c;                                                                     \
+}                                                                               
+
+#endif
+
+inline POutPersist& operator << (POutPersist& c, PPersist const& obj)
+{
+  obj.Write(c);
+  return c;
+}
+
+inline PInPersist& operator >> (PInPersist& c, PPersist& obj)
+{
+  obj.Read(c);
+  return c;
+}
+
+// Fabrication de fonction Create automatique, et enregistrement...
+template <class T>
+class PPersistRegistrar {
+public:
+  static PPersist* Create() {return new T();}
+  static void Register() {PPersistMgr::RegisterClass(T::classId,Create);}
+};
+
+#define PPRegister(className) PPersistRegistrar<className>::Register();
+
+#endif
Index: trunk/SophyaLib/SysTools/ctimer.cc
===================================================================
--- trunk/SophyaLib/SysTools/ctimer.cc	(revision 219)
+++ trunk/SophyaLib/SysTools/ctimer.cc	(revision 219)
@@ -0,0 +1,92 @@
+//
+// $Id: ctimer.cc,v 1.1.1.1 1999-04-09 17:57:04 ansari Exp $
+//
+
+#include "defs.h"
+#include "ctimer.h"
+
+//++
+// Class	Timer
+// Lib  	Outils++
+// include	ctimer.h
+//
+//	Chronométrage de programmes. Le constructeur mémorise l'heure et
+//      le temps CPU, ainsi qu'un message éventuel.
+//
+//	Split affiche le temps partiel.
+//
+//	Le destructeur affiche le temps total (CPU, et écoulé).
+//    
+//      Des macros permettent une utilisation simplifiée :
+//      * TIMEF   crée un objet de type Timer, avec le nom de la function 
+//	courante comme message. Le temps écoulé sera affiché à la sortie 
+//	de la function.
+//      * SPLITTIME affiche le temps partiel du compteur crée par TIMEF
+//      * TIMEN(nom) permet de donner un autre nom que le nom de la fonction.
+//--
+
+
+//++
+// Titre	Constructeurs
+//--
+
+//++
+// Timer::Timer(const char* name)
+//	Crée un objet qui mémorise l'heure et le temps CPU du process courant.
+//	Le destructeur affiche les temps écoulé et CPU utilisé.
+//--
+
+Timer::Timer(const char* name)
+: timerName(name)
+{
+  cpu0 = cpuSplit = clock();
+  elapse0 = elapseSplit = time(0);
+  END_CONSTRUCTOR
+}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// Timer::Split(const char* comm)
+//	Affiche le temps partiel.
+//--
+
+
+void Timer::Split(const char* comm)
+{
+  time_t elapse = time(0);
+  clock_t cpu   = clock();
+
+  float cpuSecT = ((float)cpu - (float)cpu0) / (float)(CLOCKS_PER_SEC);
+  float cpuSecP = ((float)cpu - (float)cpuSplit) / (float)(CLOCKS_PER_SEC);
+  
+  int etm  = elapse - elapseSplit;
+  int etmt = elapse - elapse0;
+
+  cout << "***Timing " << (comm ? comm : timerName) << endl;
+
+// Pour des formats comme ca, la syntaxe printf est plus agreable.
+// Pour ne pas melanger stdio/iostream (pb de desynchronisation sur
+// autres C++ que GNU), on fait un cout << chaine.
+
+  char out[200];
+  sprintf(out,"CPU     Time: Total= %g (Partial= %g) Sec.",
+	  cpuSecT, cpuSecP);
+  cout << out << endl;
+
+  sprintf(out,"Elapsed Time: Total= %02d:%02d:%02d (Partial=%02d:%02d:%02d)",
+	  etmt/3600, (etmt%3600)/60, etmt%60, 
+	  etm/3600,  (etm%3600)/60,  etm%60);
+
+  cout << out << endl;
+
+  elapseSplit = elapse;
+  cpuSplit    = cpu;
+}
+
+Timer::~Timer()
+{
+  Split();
+}
Index: trunk/SophyaLib/SysTools/ctimer.h
===================================================================
--- trunk/SophyaLib/SysTools/ctimer.h	(revision 219)
+++ trunk/SophyaLib/SysTools/ctimer.h	(revision 219)
@@ -0,0 +1,49 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// $Id: ctimer.h,v 1.1.1.1 1999-04-09 17:57:04 ansari Exp $
+//
+
+
+#ifndef CTIMER_SEEN
+#define CTIMER_SEEN
+
+#include <sys/types.h>
+#include <time.h>
+#include <iostream.h>
+#include <stdio.h>
+#include "peida.h"
+
+// <summary> Permet de chronometrer des fonctions. </summary>
+// La macro TIMEF cree un objet de class Timer qui memorise
+// l'heure de sa creation, et le temps CPU.
+
+// A la fin du bloc ou de la procedure, l'objet est detruit,
+// et son destructeur affiche le temps ecoule.
+
+// La macro SPLITTIME lui permet d'afficher des temps partiels.
+class Timer EXC_AWARE {
+public:
+  // L'objet memorise le temps CPU et l'heure, et le nom donne
+  Timer(const char* name=0);
+
+  // Le destructeur appelle split sans parametre.
+  virtual ~Timer();
+
+  // Affiche le temps ecoule total/partiel, avec le nom eventuel.
+  // Si pas de parametre affiche le nom donne a la creation.
+  void Split(const char* comm=0);
+
+  // Sert a eviter que GNU ne pretende qu'on utilise pas l'objet...
+  void Nop() {}
+
+private:
+  clock_t cpu0, cpuSplit;
+  time_t  elapse0, elapseSplit;
+  const char* timerName;
+};
+
+#define TIMEN(x)  Timer timer(x); timer.Nop();
+#define TIMEF     Timer timer(__PRETTY_FUNCTION__); timer.Nop();
+#define SPLITTIME timer.Split();
+
+#endif // CTIMER_SEEN
Index: trunk/SophyaLib/SysTools/pdlmgr.cc
===================================================================
--- trunk/SophyaLib/SysTools/pdlmgr.cc	(revision 219)
+++ trunk/SophyaLib/SysTools/pdlmgr.cc	(revision 219)
@@ -0,0 +1,152 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Gestionnaire de lien dynamique   -   R. Ansari 12/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <iostream.h>
+
+#include "pdlmgr.h"
+
+// Extension de noms de fichiers Shared libs
+static const char* sofext = ".so";
+static const char* sofext_HPUX = ".sl";
+
+// Variables et methodes static
+int PDynLinkMgr::numSO = 0;
+string*  PDynLinkMgr::tmpDir = NULL;
+
+/* --Methode-Static-- */
+void PDynLinkMgr::SetTmpDir(string const & path)
+{
+if ( (path.length() > 0) && (path[path.length()] != '/')  ) GetTmpDir() = path + '/';
+else GetTmpDir() = path;
+return;
+}
+
+/* --Methode-Static-- */
+string& PDynLinkMgr::GetTmpDir()
+{
+if (tmpDir == NULL) { 
+  tmpDir = new string("");
+  char* varenv;
+  if ( (varenv=getenv("PEIDA_TMP")) != NULL )  *tmpDir = varenv; 
+  else if ( (varenv=getenv("TMPDIR")) != NULL )  *tmpDir = varenv; 
+  }
+return(*tmpDir);
+}
+
+/* --Methode-Static-- */
+PDynLinkMgr* PDynLinkMgr::BuildFromCFile(string const & fname)
+{
+size_t l = fname.length();
+if (l < 1)  return(NULL);
+string fnameobj = GetTmpDir()+"tmp_pdl.o";
+
+string cmd;
+int rc;
+
+// Compilation du fichier
+#if defined(OSF1) || defined(Linux)
+cmd = "cc -c -o " + fnameobj + " " + fname;
+#endif
+rc = system(cmd.c_str());
+if (rc != 0)  { 
+  cerr << "PDynLinkMgr::BuildFromCFile() Error Rc(" << cmd <<")= "<< rc << endl; 
+  return(NULL);
+  }
+
+char buff[32];
+numSO++;
+#ifndef HPUX
+sprintf(buff,"pdlmgr%d%s", numSO,sofext);
+#endif
+string fnameso = GetTmpDir()+buff;
+
+// Creation du shared-lib
+#if defined(OSF1) 
+  cmd = "ld -shared -o " + fnameso + " -all " + fnameobj + " -none -lm -lc";
+#else
+  cmd = "ld -shared -o " + fnameso + " " + fnameobj + " -lm -lc";
+#endif
+rc = system(cmd.c_str());
+if (rc != 0)  { 
+  cerr << "PDynLinkMgr::BuildFromCFile() Error Rc(" << cmd <<")= "<< rc << endl; 
+  return(NULL);
+  }
+
+return(new PDynLinkMgr(fnameso, false));
+
+}
+
+/* --Methode-- */
+PDynLinkMgr::PDynLinkMgr(string& soname, bool cp)
+{
+dlhandle = NULL;
+soName = "";
+
+if (soname.find_last_of(".") > soname.length())  
+#ifdef HPUX
+  soname += sofext_HPUX;
+#else
+  soname += sofext;
+#endif
+
+string fnameso;
+if (cp) {
+  numSO++;
+  char buff[32];
+#ifndef HPUX
+  sprintf(buff,"pdlmgr%d%s", numSO,sofext);
+#else
+  sprintf(buff,"pdlmgr%d%s", numSO,sofext_HPUX);
+#endif
+  fnameso = GetTmpDir()+buff;
+  string cmd = "cp " + soname + " " + fnameso;
+  int rc = system(cmd.c_str());
+  if (rc != 0)  { 
+    cerr << "PDynLinkMgr::PDynLinkMgr() Error Rc(" << cmd <<")= "<< rc << endl; 
+    return;
+    }
+  } 
+else fnameso = soname;
+copy = cp;
+soName = fnameso;
+
+#if defined(OSF1) || defined(Linux)
+dlhandle =  dlopen(fnameso.c_str(), RTLD_NOW);
+if (dlhandle == NULL) { 
+  cerr << "PDynLinkMgr::PDynLinkMgr(): Error opening SO " << fnameso 
+       << " (" << soname << ")" << endl; 
+  string sn = dlerror();
+  cerr << "Loader Error (dlerror()) :" << sn << endl;
+  return; 
+  }
+#endif
+}
+
+/* --Methode-- */
+PDynLinkMgr::~PDynLinkMgr()
+{
+#if defined(OSF1) || defined(Linux)
+if (dlhandle) dlclose(dlhandle);    dlhandle = NULL;
+#endif
+if (copy) {
+  string cmd = "rm " + soName;
+  system(cmd.c_str());
+  }
+}
+
+/* --Methode-- */
+DlFunction PDynLinkMgr::GetFunction(string const & funcname)
+{
+DlFunction f = NULL;
+#if defined(OSF1) || defined(Linux)
+if (dlhandle != NULL)  
+  f = (DlFunction)dlsym(dlhandle, funcname.c_str());
+#endif
+if (f == NULL) cerr << "PDynLinkMgr::PDynLinkMgr(): Error linking " << funcname << endl;
+return(f);
+}
+
Index: trunk/SophyaLib/SysTools/pdlmgr.h
===================================================================
--- trunk/SophyaLib/SysTools/pdlmgr.h	(revision 219)
+++ trunk/SophyaLib/SysTools/pdlmgr.h	(revision 219)
@@ -0,0 +1,52 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Gestionnaire de lien dynamique   -   R. Ansari 12/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PDYNLINKMGR_SEEN
+#define PDYNLINKMGR_SEEN
+
+#include "defs.h"
+#include <string>
+#if defined(__KCC__)
+using std::string ;
+#endif
+
+#if defined(OSF1) || defined(Linux) || defined(AIX)
+#include <dlfcn.h>
+#endif
+
+#if defined(HPUX)
+#include <dl.h>
+#endif
+
+typedef void (* DlFunction) (void);
+
+class PDynLinkMgr {
+public:
+  // ---- Methodes globales (static)
+  static PDynLinkMgr*   BuildFromCFile(string const & fname);  // Compil+link fichier C
+  static void		SetTmpDir(string const & path);        // Repertoire des fichiers temporaires
+
+  // ---- Constructeur et methodes 
+  // Constructeur a partir d'un shared lib - copie en zone temporaire si cp==true
+			PDynLinkMgr(string& soname, bool cp=true);  
+  virtual		~PDynLinkMgr();
+
+  virtual DlFunction	GetFunction(string const & funcname);              
+
+protected :
+  static string&	GetTmpDir();
+  static int	  numSO;
+  static string*  tmpDir;
+
+#if defined(OSF1) || defined(Linux) || defined(AIX)
+  void * dlhandle;
+#endif
+#if defined(HPUX)
+  shl_t dlhandle;
+#endif
+  string soName;
+  bool copy;
+};
+
+#endif
Index: trunk/SophyaLib/SysTools/periodic.cc
===================================================================
--- trunk/SophyaLib/SysTools/periodic.cc	(revision 219)
+++ trunk/SophyaLib/SysTools/periodic.cc	(revision 219)
@@ -0,0 +1,109 @@
+/* Classe d'objets avec une methode (DoPeriodic()) appelee periodiquement */
+/*                                  Eric Aubourg     04/96                */
+/*                                  Reza Ansari      06/96                */
+/*                      LAL/IN2P3 (Orsay)  DAPNIA/CEA (Saclay)            */
+
+#include "defs.h"
+#include <signal.h>
+#include <unistd.h>
+
+#include "periodic.h"
+
+/* --Methode-- */
+Periodic::Periodic(int dt, UsPeriodicAction act, void * usp)
+{
+mDt = dt;
+mAct = act;
+mUsp = usp;
+if (mDt < 1)  mDt = 5;
+mDtms = 1000*mDt;
+mFgact = false;
+it = -1;
+}
+
+/* --Methode-- */
+Periodic::~Periodic()
+{
+if (mFgact) Stop();
+}
+
+/* --Methode-- */
+void Periodic::SetAction(UsPeriodicAction act, void * usp)
+{
+mAct = act;
+mUsp = usp;
+}
+
+/* --Methode-- */
+void Periodic::SetInterval(int dt)
+{
+mDt = dt;
+if (mDt < 1)  mDt = 5;
+mDtms = 1000*mDt;
+}
+
+/* --Methode-- */
+void Periodic::SetIntervalms(int dtms)
+{
+if (dtms < 1) dtms = 5;
+mDtms = dtms;
+mDt = mDtms/1000;
+if (mDt < 1)  mDt = 1;
+}
+
+/* --Methode-- */
+void Periodic::Start(int dt)
+{
+if (mFgact)  return;
+if (dt > 0)  { mDt = dt;  mDtms = dt*1000; }
+if (!actifs) actifs = new PeriodicList;
+it = 0;
+if (actifs->size() == 0) {
+  signal(SIGALRM, CallBack);
+  alarm(1);
+  }
+actifs->push_back(this);
+mFgact = true;
+return;
+}
+
+/* --Methode-- */
+void Periodic::Stop()
+{
+if (!mFgact)  return;
+
+//remove(actifs->begin(), actifs->end(), this);  // $CHECK$ - Reza
+actifs->remove(this);    // $CHECK$ 
+if (actifs->size() == 0) {
+  signal(SIGALRM, SIG_IGN);
+  alarm(0);
+  delete actifs;
+  actifs = NULL;
+  }
+it = -1;  mFgact = false;
+return;
+}
+
+/* --Methode-- */
+void Periodic::DoPeriodic()
+{
+if (mAct)   mAct(mUsp);
+}
+
+PeriodicList* Periodic::actifs = NULL;
+
+void Periodic::CallBack(int)
+{
+  if (!actifs) return;
+
+  for (PeriodicList::iterator i = actifs->begin(); i != actifs->end(); i++) {
+    Periodic* p = (Periodic*) *i;
+    p->it ++;
+    if (p->it >= p->mDt) {
+      p->it = 0;
+      p->DoPeriodic();
+    }
+  }
+  alarm(1);
+}
+
Index: trunk/SophyaLib/SysTools/periodic.h
===================================================================
--- trunk/SophyaLib/SysTools/periodic.h	(revision 219)
+++ trunk/SophyaLib/SysTools/periodic.h	(revision 219)
@@ -0,0 +1,47 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d'objets avec une methode (DoPeriodic()) appelee periodiquement 
+#ifndef PERIODIC_H
+#define PERIODIC_H
+
+#include "defs.h"
+#include <list>
+#if defined(__KCC__)
+#include <list.h>
+#endif
+
+class Periodic;
+typedef list<Periodic*> PeriodicList;
+
+typedef void (* UsPeriodicAction) (void *);
+
+class Periodic 
+{
+public:
+  Periodic(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  virtual ~Periodic();
+
+  void SetAction(UsPeriodicAction act, void * usp=NULL);
+
+  virtual void SetInterval(int dt);
+  virtual void SetIntervalms(int dtms);
+
+  inline int Interval() { return(mDt); }
+  inline int Intervalms() { return(mDtms); }
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+
+  virtual void DoPeriodic();
+
+  static PeriodicList* actifs;
+  static void CallBack(int);
+
+protected:
+  int mDt, mDtms, it;
+  UsPeriodicAction mAct;
+  void * mUsp;
+  bool mFgact;
+};
+
+
+#endif
Index: trunk/SophyaLib/SysTools/psighand.cc
===================================================================
--- trunk/SophyaLib/SysTools/psighand.cc	(revision 219)
+++ trunk/SophyaLib/SysTools/psighand.cc	(revision 219)
@@ -0,0 +1,120 @@
+//  Pour la gestion des signaux a travers des exceptions
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include "psighand.h"
+#include "perrors.h"
+
+static bool sigprstate[5] = {false, false, false, false};
+
+void PeidaProcessSignal(int s);
+
+/* Nouvelle-Fonction */
+void PeidaConfigureSignalhandling(bool cfpe, bool csegv, bool cquit, bool cusr1, bool cusr2) 
+{
+  struct sigaction ae, ad;
+
+  ae.sa_handler = PeidaProcessSignal;
+  ad.sa_handler = SIG_DFL;
+  memset( &(ae.sa_mask), 0, sizeof(sigset_t) ); 
+  ae.sa_flags = 0;
+  memset( &(ad.sa_mask), 0, sizeof(sigset_t) ); 
+  ad.sa_flags = 0;
+#ifdef  OSF1
+  ae.sa_flags = SA_RESTART;
+  ad.sa_mask = 0;
+#endif
+
+// SIGFPE 
+  if (sigprstate[0] != cfpe) {
+    if (cfpe)   { 
+      sigaction(SIGFPE, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGFPE handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGFPE, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGFPE handling ...");
+      }
+    sigprstate[0] = cfpe;
+    }
+// SIGSEGV 
+  if (sigprstate[1] != csegv) {
+    if (csegv)   { 
+      sigaction(SIGSEGV, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGSEGV handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGSEGV, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGSEGV handling ...");
+      }
+    sigprstate[1] = csegv;
+    }
+// SIGQUIT
+  if (sigprstate[2] != cquit) {
+    if (cquit)   { 
+      sigaction(SIGQUIT, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGQUIT handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGQUIT, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGQUIT handling ...");
+      }
+    sigprstate[2] = cquit; 
+    }
+  
+// SIGUSR1
+  if (sigprstate[3] != cusr1) {
+    if (cusr1)   { 
+      sigaction(SIGUSR1, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGUSR1 handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGUSR1, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGUSR1 handling ...");
+      }
+    sigprstate[3] = cusr1;
+    }
+// SIGUSR1
+  if (sigprstate[4] != cusr2) {
+    if (cusr2)   { 
+      sigaction(SIGUSR2, &ae, NULL);
+      puts("PeidaConfigureSignalhandling(): Activating SIGUSR2 handling (-> throw) ...");
+      }
+    else  { 
+      sigaction(SIGUSR2, &ad, NULL);
+      puts("PeidaConfigureSignalhandling(): Back to default SIGUSR2 handling ...");
+      }
+    sigprstate[4] = cusr2;
+    }    
+}
+/* Nouvelle-Fonction */
+void PeidaProcessSignal(int s)
+{
+switch(s)
+  {
+  case SIGFPE :
+    puts("PeidaProcessSignal: ###Signal SIGFPE catched, throw catchedSIGFPE ###");
+    THROW(catchedSIGFPE);
+  case SIGSEGV :
+    puts("PeidaProcessSignal: ###Signal SIGSEGV catched, throw catchedSIGSEGV ###");
+    THROW(catchedSIGSEGV);
+  case SIGINT :
+    puts("PeidaProcessSignal: ###Signal SIGINT catched, throw catchedSIGINT ###");
+    THROW(catchedSIGINT);
+  case SIGQUIT :
+    puts("PeidaProcessSignal: ###Signal SIGQUIT catched, throw catchedSIGQUIT ###");
+    THROW(catchedSIGQUIT);
+  case SIGUSR1 :
+    puts("PeidaProcessSignal: ###Signal SIGUSR1 catched, throw catchedSIGUSR1 ###");
+    THROW(catchedSIGQUIT);
+  case SIGUSR2 :
+    puts("PeidaProcessSignal: ###Signal SIGUSR2 catched, throw catchedSIGUSR2 ###");
+    THROW(catchedSIGQUIT);
+  default :
+    printf("PeidaProcessSignal: ###Signal %d catched, throw  inconsistentErr ### \n", s);
+    THROW(inconsistentErr);
+  }
+
+return;
+}
Index: trunk/SophyaLib/SysTools/psighand.h
===================================================================
--- trunk/SophyaLib/SysTools/psighand.h	(revision 219)
+++ trunk/SophyaLib/SysTools/psighand.h	(revision 219)
@@ -0,0 +1,9 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Pour la gestion des signaux a travers des exceptions
+
+#ifndef PSIGHANDLE_SEEN
+#define PSIGHANDLE_SEEN
+
+#include "defs.h"
+void PeidaConfigureSignalhandling(bool cfpe=false, bool csegv=false, bool cquit=false, bool cusr1=false, bool cusr2=false); 
+#endif
Index: trunk/SophyaLib/SysTools/timing.c
===================================================================
--- trunk/SophyaLib/SysTools/timing.c	(revision 219)
+++ trunk/SophyaLib/SysTools/timing.c	(revision 219)
@@ -0,0 +1,69 @@
+/*    Fonction d'impression de temps de calcul et de temps passe  */
+/*                               R.Ansari    Juin 93              */
+
+/*
+++
+  Module	Temps CPU, passé (C)
+  Lib	LibsUtil
+  include	timing.h
+
+	Fonctions permettant d'imprimer le temps CPU consommé et le temps 
+	passé.
+--
+*/ 
+
+/*
+++
+  void InitTim()
+	Initialisation des chronomètres
+  void PrtTim(char *comm)
+	Imprime le temps CPU, et le temps passé depuis 
+	le dernier appel à "PrtTim()" avec le commentaire
+	"comm". Imprime aussi le cumul du temps CPU et du 
+	temps passé depuis l'appel à "InitTim()".
+--
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+ 
+clock_t CPUT0, CPUT;
+time_t ELT0, ELT;
+ 
+void InitTim(void);
+void PrtTim(char *Comm);
+ 
+/* Nouvelle-Fonction */
+void InitTim(void)
+{
+CPUT0 = CPUT = clock();
+ELT0 = ELT = time(NULL);
+return;
+}
+ 
+/* Nouvelle-Fonction */
+void PrtTim(char *Comm)
+{
+float tcal,tcalt;
+clock_t cput;
+time_t elt;
+int etm,etmt;
+ 
+elt = time(NULL);  cput = clock();
+tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC);
+tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC);
+etm = elt - ELT;
+etmt = elt - ELT0;
+printf("%s CPUTime: Total= %g  (Partial= %g) Sec. \n",
+       Comm, tcalt, tcal);
+printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ",
+       etmt/3600, (etmt%3600)/60, etmt%60);
+printf(" (Partial= %02d:%02d:%02d)\n",
+       etm/3600, (etm%3600)/60, etm%60);
+ 
+ELT = elt;
+CPUT = cput;
+return;
+}
Index: trunk/SophyaLib/SysTools/timing.h
===================================================================
--- trunk/SophyaLib/SysTools/timing.h	(revision 219)
+++ trunk/SophyaLib/SysTools/timing.h	(revision 219)
@@ -0,0 +1,19 @@
+/*   Impression temps elapsed / Temps CPU     */
+/*                           Reza  -  93/94   */
+
+#ifndef TIMING_H_SEEN
+#define TIMING_H_SEEN
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void InitTim(void);                                                             
+void PrtTim(char *Comm);                                                        
+                                                                                
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
