1
/* @(#)misc.c 19.1 (ES0-DMD) 02/25/03 13:39:46 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/* @(#)misc.c 1.0.0.0 (ESO-La Silla) 10/08/91 12:00:00 */
30
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34
.AUTHOR Cristian Levin - ESO La Silla
35
.PURPOSE Miscelaneous functions:
36
- Checking of the existence of a Unix file.
37
- Checking of the Midas graphics window.
38
.KEYWORDS file checking, graphics window
39
.VERSION 1.0 1-Apr-1991 Implementation
41
------------------------------------------------------------*/
45
#include <sys/types.h>
50
/* check for the existence of 'file' with the extension 'ext' (incl. dot) */
51
int file_exists( file, ext )
54
char fileext[MAXLINE];
58
if ( file[0] == '\0' )
61
for ( i = 0; file[i] != '\0'; i++ )
62
if ( file[i] == ' ' ) {
67
if ( strstrs(file, ext) == (char *)NULL )
68
sprintf( fileext, "%s%s", file, ext );
70
strcpy( fileext, file );
72
if ( stat(fileext, &statbuf) == -1 )
81
char file_old[MAXLINE], file[MAXLINE];
82
char midwork[MAXLINE];
84
osfphname("MID_WORK", midwork);
85
osfphname("DAZUNIT", unit);
88
sprintf(file_old, "%s%sXW", midwork, unit);
89
sprintf(file, "%smidas_xw%s", midwork, unit);
90
return(file_exists(file_old, ".soc") || file_exists(file_old, ".soc=") ||
91
file_exists(file, "") || file_exists(file, "=") );
94
void DropTrailingBlanks(str)
99
for ( i = 0; str[i] != '\0'; i++ )
100
if ( str[i] == ' ' ) {