1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
.AUTHOR K. Banse DMD-ESO Garching
33
.KEYWORDS logging, display
34
.PURPOSE this module is executed via
35
$ xterm -e logviewer.exe ...
36
thus at termination the xterm window disappears,
37
=> we need to put sleep() into the code, to be
38
able to read any error message
40
display info in separate xterm, parallel to application
41
by displaying the contents of a given file
47
------------------------------------------------------------*/
49
/* Define _POSIX_SOURCE to indicate that this is a POSIX program */
51
#define _POSIX_SOURCE 1
53
#define LIMIT_LINES 100
59
#include <sys/types.h>
74
static int baselen, count, swindx;
77
static char filename[168], switchy[4] = "AB ";
81
/* a pair of ASCII infofiles is used to display
83
written to the infofiles by the application
84
after LIMIT_LINES lines of text, the infofiles are switched
85
from blablaA to blablaB and vice versa
86
this limit must be synchronized with `logview_init()'
87
in .../prim/general/libsrc/logview.c */
90
baselen = (int)strlen(argv[1]);
93
printf(">>> file:\n%s\n>>> way to long for us...\n",argv[1]);
98
(void) strcpy(filename,argv[1]);
101
filename[baselen] = switchy[swindx]; filename[baselen+1] = '\0';
106
fd = open(filename,O_RDONLY); /* open for reading */
114
printf("could not open infofile %s ...\n",filename);
121
input_loop: /* use 100 bytes buffer */
122
mm = read(fd,cbuf,100); /* in sync with logview.c */
125
if (strncmp(cbuf,"EOF",3) == 0) /* check for end of program */
127
printf("\n... terminating parallel log ...\n");
134
if (count == LIMIT_LINES)
137
mm = unlink(filename);
140
printf("we could not delete: %s\n",filename);
145
swindx = 1 - swindx; /* 0 -> 1, 1 -> 0 */
146
filename[baselen] = switchy[swindx];