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

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

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

File size: 1.9 KB
RevLine 
[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
22int main(int narg, char *arg[])
23{
24int ofa;
[573]25int fgsig, fgred;
[224]26
[575]27SambaInitiator sambainit;
[224]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 ");
[573]37 puts("Usage: piapp [-nored] [-nosig]");
[224]38 exit(0);
39 }
40 }
41
42ofa = 1;
[573]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; }
[224]48
49
[573]50PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa);
51if (!fgred) app->RedirectStdOutErr(false);
52else app->RedirectStdOutErr(true);
53if (fgsig) app->CatchSignals(true);
[224]54
55int rc = 0;
56bool cont = true;
57while(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
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.