Commits

R. V. Urvashi authored 84f68f591fe Merge
Merge branch 'master' into CAS-13010
No tags

casa5/code/casaqt/apps/casaplotserver/casaplotserver.cc

Modified
1 -#include <signal.h>
2 1 #include <math.h>
2 +#include <unistd.h>
3 +#include <signal.h>
3 4 #include <QApplication>
4 5 #include <casaqt/QtPlotServer/QtPlotServer.qo.h>
5 6 #include <casaqt/QtPlotServer/QtPlotSvrPanel.qo.h>
6 7
8 +#if defined(CASATOOLS)
9 +static void preprocess_args( int argc, const char *argv[], int &numargs, char **&args,
10 + char *&server_string, char *&event_sink, char *&logfile );
11 +#else
7 12 static void preprocess_args( int argc, const char *argv[], int &numargs, char **&args,
8 13 char *&dbus_name, bool &casapy_start );
14 +#endif
15 +
9 16
10 17 int main( int argc, const char *argv[] ) {
11 18
12 19 // don't let ^C [from casapy] kill the plot server...
13 20
14 - char *dbus_name = 0;
15 - bool casapy_start = false;
16 -
17 21 char **args;
18 22 int numargs;
23 +
24 +#if defined(CASATOOLS)
25 + char *server_string;
26 + char *event_sink;
27 + char *logfile;
28 + preprocess_args( argc, argv, numargs, args, server_string, event_sink, logfile );
29 + signal(SIGINT,SIG_IGN);
30 +
31 +// QApplication qapp(qargc, qargs);
32 + QApplication qapp(numargs, args);
33 + casa::QtPlotServer plot_server(server_string,event_sink,logfile);
34 +
35 +#else
36 + char *dbus_name = 0;
37 + bool casapy_start = false;
19 38 preprocess_args( argc, argv, numargs, args, dbus_name, casapy_start );
20 39
21 40 if ( casapy_start ) {
22 41 signal(SIGINT,SIG_IGN);
23 42 }
24 43
25 44 QApplication qapp(numargs, args);
26 45
27 46 casa::QtPlotServer plot_server(dbus_name);
47 +#endif
28 48
29 49 return qapp.exec();
30 50
31 51 }
32 52
33 53 // processes argv into args stripping out the the viewer setup flags... numargs has the number
34 54 // of args, and the last arg (not included in numargs count) is null (for execvp)
55 +#if defined(CASATOOLS)
56 +static void preprocess_args( int argc, const char *argv[], int &numargs, char **&args,
57 + char *&server_string, char *&event_sink, char *&logfile ) {
58 +#else
35 59 static void preprocess_args( int argc, const char *argv[], int &numargs, char **&args,
36 60 char *&dbus_name, bool &casapy_start ) {
37 -
38 61 casapy_start = false;
39 62 dbus_name = 0;
63 +#endif
40 64
41 65 // pre-process the command line arguments (for now), it looks like
42 66 // the current scheme is to hard-wire a limited set of command line
43 67 // parameters... should be reworked in the future.
44 68 args = (char**) malloc(sizeof(char*)*(argc+2));
45 69 numargs = 0;
46 70
47 71 args[numargs++] = strdup(argv[0]);
48 - for ( int x = 0; x < argc; ++x ) {
72 + for ( int x = 1; x < argc; ++x ) {
73 +#if defined(CASATOOLS)
74 + if ( ! strncmp(argv[x], "--server=", 9) ) {
75 + char *sink = strdup( &argv[x][9] );
76 + if ( strlen(sink) <= 0 ) {
77 + free( sink );
78 + } else {
79 + server_string = sink;
80 + }
81 + } else if ( ! strncmp(argv[x], "--event-uri=", 12) ) {
82 + char *uri = strdup( &argv[x][12] );
83 + if ( strlen(uri) <= 0 ) {
84 + free( uri );
85 + } else {
86 + event_sink = uri;
87 + }
88 + } else if ( ! strncmp(argv[x], "--logfile=", 10) ) {
89 + char *lf = strdup( &argv[x][10] );
90 + if ( strlen(lf) <= 0 ) {
91 + free( lf );
92 + } else {
93 + logfile = lf;
94 + }
95 +#else
49 96 if ( ! strncmp(argv[x],"--dbusname",10) ) {
50 97 if ( argv[x][10] == '=' ) {
51 98 char *name = strdup( &argv[x][11] );
52 99 if ( strlen(name) <= 0 ) {
53 100 free( name );
54 101 } else {
55 102 dbus_name = name;
56 103 }
57 104 } else if ( x + 1 < argc ) {
58 105 dbus_name = strdup(argv[++x]);
59 106 }
60 107 } else if ( ! strcmp(argv[x],"--casapy") ) {
61 108 casapy_start = true;
109 +#endif
62 110 } else {
63 111 args[numargs++] = strdup(argv[x]);
64 112 }
65 113 }
66 114
67 115 args[numargs] = 0;
68 116 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut