| 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 "sambainit.h" | 
|---|
| 15 |  | 
|---|
| 16 | #include "pistdimgapp.h" | 
|---|
| 17 |  | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | /*  ================================ MAIN() =================================  */ | 
|---|
| 21 |  | 
|---|
| 22 | int main(int narg, char *arg[]) | 
|---|
| 23 | { | 
|---|
| 24 | int ofa; | 
|---|
| 25 | int fgsig, fgred; | 
|---|
| 26 |  | 
|---|
| 27 | SambaInitiator sambainit; | 
|---|
| 28 |  | 
|---|
| 29 | InitTim(); | 
|---|
| 30 |  | 
|---|
| 31 | ofa = 1; | 
|---|
| 32 | if (narg > 1) | 
|---|
| 33 | { | 
|---|
| 34 | if (strcmp(arg[1],"-h") == 0) | 
|---|
| 35 | { | 
|---|
| 36 | puts("\n piapp: Programme d'analyse interactive "); | 
|---|
| 37 | puts("Usage: piapp [-nored] [-nosig]"); | 
|---|
| 38 | exit(0); | 
|---|
| 39 | } | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | ofa = 1; | 
|---|
| 43 | fgred = fgsig = true; | 
|---|
| 44 | if (  (narg > 1) && (strcmp(arg[1],"-nored") == 0) )  { fgred=false;  ofa = 2; } | 
|---|
| 45 | if (  (narg > 1) && (strcmp(arg[1],"-nosig") == 0) )  { fgsig=false;  ofa = 2; } | 
|---|
| 46 | if (  (narg > 2) && (strcmp(arg[2],"-nored") == 0) )  { fgred=false;  ofa = 3; } | 
|---|
| 47 | if (  (narg > 2) && (strcmp(arg[2],"-nosig") == 0) )  { fgsig=false;  ofa = 3; } | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa); | 
|---|
| 51 | if (!fgred) app->RedirectStdOutErr(false); | 
|---|
| 52 | else app->RedirectStdOutErr(true); | 
|---|
| 53 | if (fgsig)  app->CatchSignals(true); | 
|---|
| 54 |  | 
|---|
| 55 | int rc = 0; | 
|---|
| 56 | bool cont = true; | 
|---|
| 57 | while(cont) { | 
|---|
| 58 | rc = 0;   cont = false; | 
|---|
| 59 | app->SetReady(); | 
|---|
| 60 | if (fgred) app->RedirectStdOutErr(true); | 
|---|
| 61 | try { | 
|---|
| 62 | app->Run(); | 
|---|
| 63 | }  catch (PException exc) { | 
|---|
| 64 | char ans[32],rep; | 
|---|
| 65 | app->Stop(); | 
|---|
| 66 | app->RedirectStdOutErr(false); | 
|---|
| 67 | fflush(stdout); | 
|---|
| 68 | cout << endl; | 
|---|
| 69 | cerr << endl; | 
|---|
| 70 | cout << "PIStdImg/main() Exception catched ! " << exc.Msg() << endl; | 
|---|
| 71 | cout << " exit <CR> , continue c<CR> , close-windows, continue k<cr> ? " << endl; | 
|---|
| 72 | gets(ans); | 
|---|
| 73 | rep = toupper(ans[0]); | 
|---|
| 74 | if ((rep != 'C')||(rep != 'K'))  { cont = false; rc = 99; } | 
|---|
| 75 | else { cont = true; if (rep == 'K') app->CloseAllWindows(); } | 
|---|
| 76 | } | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | app->RedirectStdOutErr(false); | 
|---|
| 80 | delete app; | 
|---|
| 81 | printf("piapp : Exiting .... Rc= %d \n", rc); | 
|---|
| 82 | exit(rc); | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|