Index: trunk/SophyaProg/Tests/piapp.cc
===================================================================
--- trunk/SophyaProg/Tests/piapp.cc	(revision 499)
+++ trunk/SophyaProg/Tests/piapp.cc	(revision 573)
@@ -1,13 +1,18 @@
 #include <stdlib.h>
 #include <stdio.h>
+#ifdef OSF1
+#include <dlfcn.h>
+#else
+#define C_NO_SHLIBS
+#endif
+
+#include <string>
+#include "psighand.h"
+#include "dynccd.h"
+
+#include "timing.h"
+#include "piinit.h"
 
 #include "pistdimgapp.h"
-#include "piacmd.h"
-#include "piversion.h"
-#include "piaversion.h"
-
-#include "timing.h"
-#include "outilsinit.h"
-
 
 
@@ -18,7 +23,7 @@
 {
 int ofa;
-int fgfpe, fgsegv, fgred, fgexec;
+int fgsig, fgred;
 
-PeidaInit();
+PeidaInteractiveInitiator piinit;
    
 InitTim();
@@ -30,10 +35,5 @@
     {
     puts("\n piapp: Programme d'analyse interactive ");
-    puts("Usage: piapp [-nored] [-nosig] [-nosigfpe] [-nosigsegv] [-help2tex] [-exec file [args]]");
-    puts("  -nored : NoRedirect StdOut/StdErr");
-    puts("  -nosig : Don't catch SigFPE, SigSEGV");
-    puts("  -nosigfpe -nosigsegv: Don't catch SigFPE / SigSEGV");
-    puts("  -help2tex: Create a LaTeX help file (piahelp.tex)");
-    puts("  -exec file [args] : Execute command file \n");
+    puts("Usage: piapp [-nored] [-nosig]");
     exit(0);
     }
@@ -41,49 +41,15 @@
 
 ofa = 1;
-fgred = fgfpe = fgsegv = true;
-fgexec = false;
-string exfc;
-// Pour fabriquer le help
-bool fgtexh = false;
-int ka;
-for(ka=1; ka<narg; ka++) {
-  if (strcmp(arg[ka],"-nored") == 0)   fgred=false; 
-  else if (strcmp(arg[ka],"-nosig") == 0)   fgfpe=fgsegv=false; 
-  else if (strcmp(arg[ka],"-nosigfpe") == 0)   fgfpe=false; 
-  else if (strcmp(arg[ka],"-nosigsegv") == 0)   fgsegv=false; 
-  else if (strcmp(arg[ka],"-help2tex") == 0) { fgtexh=true; fgred=false; }
-  else if (strcmp(arg[ka],"-exec") == 0) {
-    if (ka < narg-1) {
-      fgexec = true;
-      exfc = "exec";
-      for(int kaa=ka+1; kaa<narg; kaa++)  { exfc += ' ';  exfc +=  arg[kaa]; }
-      }
-    break;
-    }
-  }
+fgred = fgsig = true;
+if (  (narg > 1) && (strcmp(arg[1],"-nored") == 0) )  { fgred=false;  ofa = 2; }
+if (  (narg > 1) && (strcmp(arg[1],"-nosig") == 0) )  { fgsig=false;  ofa = 2; }
+if (  (narg > 2) && (strcmp(arg[2],"-nored") == 0) )  { fgred=false;  ofa = 3; }
+if (  (narg > 2) && (strcmp(arg[2],"-nosig") == 0) )  { fgsig=false;  ofa = 3; }
 
-if (fgexec) printf(">>>>> Starting piapp , Executing %s \n", exfc.c_str()); 
-else printf(">>>>> Starting piapp <<<<< \n");
-printf("Version: piapp=%g  PI=%g  PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER, 
-              (double)PI_VERSIONNUMBER, (float)PeidaVersion());
 
-PIStdImgApp * app = new PIStdImgApp(narg, arg);
-
-// Gestion de redirection stdout/err et Signaux
-if (fgred) app->RedirectStdOutErr(true);
-else app->RedirectStdOutErr(false);
-app->CatchSignals(fgfpe, fgsegv);
-
-// S'il y a un fichier de commande a executer
-if (fgexec) app->CmdInterpreter()->Interpret(exfc);
-
-// S'il y a besoin de faire le fichier Help
-if (fgtexh) { 
-  string thf = "piahelp.tex";
-  app->CmdInterpreter()->HelptoLaTex(thf);
-  printf("piapp : Help file piahelp.tex created --> exit(0) \n"); 
-  delete app;
-  exit(0);
-}
+PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa);
+if (!fgred) app->RedirectStdOutErr(false);
+else app->RedirectStdOutErr(true);
+if (fgsig)  app->CatchSignals(true);
 
 int rc = 0;
@@ -93,7 +59,7 @@
   app->SetReady();
   if (fgred) app->RedirectStdOutErr(true);
-  try {
+  TRY {
   app->Run();
-  }  catch ( PException exc ) {
+  }  CATCH(merr) {
      char ans[32],rep;
      app->Stop();
@@ -102,24 +68,15 @@
      cout << endl; 
      cerr << endl;
-     cerr << "PIStdImg/main() Exception catched ! " << exc.Msg() << endl;
-     cerr << " continue <CR> , Stop program S<CR> ? " << endl;  gets(ans);
-     rc = 9;
+     printf("PIStdImg/main() Exception catched ! = %ld (%s) \n", (long)merr, PeidaExc(merr));
+     printf(" exit <CR> , continue c<CR> , close-windows, continue k<cr> ? ");  gets(ans);
+     rc = merr;
      rep = toupper(ans[0]);  
-     if (rep == 'S')  { 
-       printf(" !!!! Stopping piapp !!!! \n"); 
-       cont = false;
-       }
-     else { 
-       printf(" *** piapp - Continuing event loop *** \n");
-       cont = true;
-       }
-//     else { cont = true; if (rep == 'K') app->CloseAllWindows(); }
+     if ((rep != 'C')||(rep != 'K'))  cont = false;
+     else { cont = true; if (rep == 'K') app->CloseAllWindows(); }
   } ENDTRY;
 }
 
 app->RedirectStdOutErr(false);  
-// On de-charge le module erospiamodule
 delete app;
-
 printf("piapp : Exiting .... Rc= %d \n", rc); 
 exit(rc);
