[165] | 1 | #include <stdlib.h>
|
---|
| 2 | #include <stdio.h>
|
---|
| 3 | #ifdef OSF1
|
---|
| 4 | #include <dlfcn.h>
|
---|
| 5 | #else
|
---|
| 6 | #define C_NO_SHLIBS
|
---|
| 7 | #endif
|
---|
| 8 |
|
---|
| 9 | #include <string>
|
---|
| 10 | #include "psighand.h"
|
---|
| 11 | #include "dynccd.h"
|
---|
| 12 |
|
---|
| 13 | #include "timing.h"
|
---|
| 14 | #include "piinit.h"
|
---|
| 15 | #ifndef SANS_StarReco
|
---|
| 16 | #include "strecinit.h"
|
---|
| 17 | #endif
|
---|
| 18 |
|
---|
| 19 | #include "pistdimgapp.h"
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | /* ================================ MAIN() ================================= */
|
---|
| 24 |
|
---|
| 25 | int main(int narg, char *arg[])
|
---|
| 26 | {
|
---|
| 27 | int ofa;
|
---|
| 28 | int fgsig, fgred;
|
---|
| 29 |
|
---|
| 30 | PeidaInteractiveInitiator piinit;
|
---|
| 31 | #ifndef SANS_StarReco
|
---|
| 32 | PeidaStarRecoInitiator strecinit;
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | InitTim();
|
---|
| 36 |
|
---|
| 37 | ofa = 1;
|
---|
| 38 | if (narg > 1)
|
---|
| 39 | {
|
---|
| 40 | if (strcmp(arg[1],"-h") == 0)
|
---|
| 41 | {
|
---|
| 42 | puts("\n piapp: Programme d'analyse interactive ");
|
---|
| 43 | puts("Usage: piapp [-nored] [-nosig]");
|
---|
| 44 | exit(0);
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | ofa = 1;
|
---|
| 49 | fgred = fgsig = true;
|
---|
| 50 | if ( (narg > 1) && (strcmp(arg[1],"-nored") == 0) ) { fgred=false; ofa = 2; }
|
---|
| 51 | if ( (narg > 1) && (strcmp(arg[1],"-nosig") == 0) ) { fgsig=false; ofa = 2; }
|
---|
| 52 | if ( (narg > 2) && (strcmp(arg[2],"-nored") == 0) ) { fgred=false; ofa = 3; }
|
---|
| 53 | if ( (narg > 2) && (strcmp(arg[2],"-nosig") == 0) ) { fgsig=false; ofa = 3; }
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa);
|
---|
| 57 | if (!fgred) app->RedirectStdOutErr(false);
|
---|
| 58 | else app->RedirectStdOutErr(true);
|
---|
| 59 | if (fgsig) app->CatchSignals(true);
|
---|
| 60 |
|
---|
| 61 | int rc = 0;
|
---|
| 62 | bool cont = true;
|
---|
| 63 | while(cont) {
|
---|
| 64 | rc = 0; cont = false;
|
---|
| 65 | app->SetReady();
|
---|
| 66 | if (fgred) app->RedirectStdOutErr(true);
|
---|
| 67 | TRY {
|
---|
| 68 | app->Run();
|
---|
| 69 | } CATCH(merr) {
|
---|
| 70 | char ans[32],rep;
|
---|
| 71 | app->Stop();
|
---|
| 72 | app->RedirectStdOutErr(false);
|
---|
| 73 | fflush(stdout);
|
---|
| 74 | cout << endl;
|
---|
| 75 | cerr << endl;
|
---|
| 76 | printf("PIStdImg/main() Exception catched ! = %ld (%s) \n", (long)merr, PeidaExc(merr));
|
---|
| 77 | printf(" exit <CR> , continue c<CR> , close-windows, continue k<cr> ? "); gets(ans);
|
---|
| 78 | rc = merr;
|
---|
| 79 | rep = toupper(ans[0]);
|
---|
| 80 | if ((rep != 'C')||(rep != 'K')) cont = false;
|
---|
| 81 | else { cont = true; if (rep == 'K') app->CloseAllWindows(); }
|
---|
| 82 | } ENDTRY;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | app->RedirectStdOutErr(false);
|
---|
| 86 | delete app;
|
---|
| 87 | printf("piapp : Exiting .... Rc= %d \n", rc);
|
---|
| 88 | exit(rc);
|
---|
| 89 | }
|
---|
| 90 |
|
---|