| [224] | 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 |  | 
|---|
|  | 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 | PeidaInteractiveInitiator piinit; | 
|---|
|  | 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(merr) { | 
|---|
|  | 64 | char ans[32],rep; | 
|---|
|  | 65 | app->Stop(); | 
|---|
|  | 66 | app->RedirectStdOutErr(false); | 
|---|
|  | 67 | fflush(stdout); | 
|---|
|  | 68 | cout << endl; | 
|---|
|  | 69 | cerr << endl; | 
|---|
|  | 70 | printf("PIStdImg/main() Exception catched ! = %ld (%s) \n", (long)merr, PeidaExc(merr)); | 
|---|
|  | 71 | printf(" exit <CR> , continue c<CR> , close-windows, continue k<cr> ? ");  gets(ans); | 
|---|
|  | 72 | rc = merr; | 
|---|
|  | 73 | rep = toupper(ans[0]); | 
|---|
|  | 74 | if ((rep != 'C')||(rep != 'K'))  cont = false; | 
|---|
|  | 75 | else { cont = true; if (rep == 'K') app->CloseAllWindows(); } | 
|---|
|  | 76 | } ENDTRY; | 
|---|
|  | 77 | } | 
|---|
|  | 78 |  | 
|---|
|  | 79 | app->RedirectStdOutErr(false); | 
|---|
|  | 80 | delete app; | 
|---|
|  | 81 | printf("piapp : Exiting .... Rc= %d \n", rc); | 
|---|
|  | 82 | exit(rc); | 
|---|
|  | 83 | } | 
|---|
|  | 84 |  | 
|---|