[224] | 1 | #include <stdlib.h>
|
---|
| 2 | #include <stdio.h>
|
---|
[573] | 3 | #ifdef OSF1
|
---|
| 4 | #include <dlfcn.h>
|
---|
| 5 | #else
|
---|
| 6 | #define C_NO_SHLIBS
|
---|
| 7 | #endif
|
---|
[224] | 8 |
|
---|
[573] | 9 | #include <string>
|
---|
| 10 | #include "psighand.h"
|
---|
| 11 | #include "dynccd.h"
|
---|
[224] | 12 |
|
---|
| 13 | #include "timing.h"
|
---|
[575] | 14 | #include "sambainit.h"
|
---|
[224] | 15 |
|
---|
[573] | 16 | #include "pistdimgapp.h"
|
---|
[224] | 17 |
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | /* ================================ MAIN() ================================= */
|
---|
| 21 |
|
---|
| 22 | int main(int narg, char *arg[])
|
---|
| 23 | {
|
---|
| 24 | int ofa;
|
---|
[573] | 25 | int fgsig, fgred;
|
---|
[224] | 26 |
|
---|
[575] | 27 | SambaInitiator sambainit;
|
---|
[224] | 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 ");
|
---|
[573] | 37 | puts("Usage: piapp [-nored] [-nosig]");
|
---|
[224] | 38 | exit(0);
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | ofa = 1;
|
---|
[573] | 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; }
|
---|
[224] | 48 |
|
---|
| 49 |
|
---|
[573] | 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);
|
---|
[224] | 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);
|
---|
[575] | 61 | try {
|
---|
[224] | 62 | app->Run();
|
---|
[575] | 63 | } catch (PException exc) {
|
---|
[224] | 64 | char ans[32],rep;
|
---|
| 65 | app->Stop();
|
---|
| 66 | app->RedirectStdOutErr(false);
|
---|
| 67 | fflush(stdout);
|
---|
| 68 | cout << endl;
|
---|
| 69 | cerr << endl;
|
---|
[575] | 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);
|
---|
[224] | 73 | rep = toupper(ans[0]);
|
---|
[575] | 74 | if ((rep != 'C')||(rep != 'K')) { cont = false; rc = 99; }
|
---|
[573] | 75 | else { cont = true; if (rep == 'K') app->CloseAllWindows(); }
|
---|
[575] | 76 | }
|
---|
[224] | 77 | }
|
---|
| 78 |
|
---|
| 79 | app->RedirectStdOutErr(false);
|
---|
| 80 | delete app;
|
---|
| 81 | printf("piapp : Exiting .... Rc= %d \n", rc);
|
---|
| 82 | exit(rc);
|
---|
| 83 | }
|
---|
| 84 |
|
---|