source: Sophya/trunk/SophyaProg/Tests/piapp.cc@ 1198

Last change on this file since 1198 was 575, checked in by ansari, 26 years ago

MAJ tspm.cc et piapp.cc , Reza 12/11/99

File size: 1.9 KB
Line 
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
22int main(int narg, char *arg[])
23{
24int ofa;
25int fgsig, fgred;
26
27SambaInitiator sambainit;
28
29InitTim();
30
31ofa = 1;
32if (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
42ofa = 1;
43fgred = fgsig = true;
44if ( (narg > 1) && (strcmp(arg[1],"-nored") == 0) ) { fgred=false; ofa = 2; }
45if ( (narg > 1) && (strcmp(arg[1],"-nosig") == 0) ) { fgsig=false; ofa = 2; }
46if ( (narg > 2) && (strcmp(arg[2],"-nored") == 0) ) { fgred=false; ofa = 3; }
47if ( (narg > 2) && (strcmp(arg[2],"-nosig") == 0) ) { fgsig=false; ofa = 3; }
48
49
50PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa);
51if (!fgred) app->RedirectStdOutErr(false);
52else app->RedirectStdOutErr(true);
53if (fgsig) app->CatchSignals(true);
54
55int rc = 0;
56bool cont = true;
57while(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
79app->RedirectStdOutErr(false);
80delete app;
81printf("piapp : Exiting .... Rc= %d \n", rc);
82exit(rc);
83}
84
Note: See TracBrowser for help on using the repository browser.