~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to libsrc/agl/ag_stdo.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)ag_stdo.c        19.1 (ES0-DMD) 02/25/03 13:53:01 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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, 
 
18
  MA 02139, USA.
 
19
 
 
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 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/* @(#)ag_stdo.c        19.1  (OAA-ASTRONET) 02/25/03 13:53:01   */
 
30
/*
 
31
 * HEADER : ag_stdo.c      - Vers 3.6.000  - Oct 1991 -  L. Fini, OAA
 
32
 *
 
33
 *
 
34
 *                           C INTERFACE MODULE
 
35
 */
 
36
 
 
37
 
 
38
#include <aglenvr.h>
 
39
#include <aglstat.h>
 
40
 
 
41
 
 
42
 
 
43
/*****************************************************************************/
 
44
/*CC                           AG_STDO (C callable)                          */
 
45
 
 
46
/* AG_STDO    Open given file for read on hierarchy of directories           */
 
47
 
 
48
 
 
49
/* This function opens a given file for read on a fixed set of directories   */
 
50
/* In the following order:                                                   */
 
51
 
 
52
 
 
53
FILE *AG_STDO (fname,ext,flag)
 
54
                              /* returns file pointer or NULL on failure     */
 
55
 
 
56
 char *fname;                 /* File name                                   */
 
57
 char *ext;                   /* File extension. This string is concatenated */
 
58
                              /* to file name above to get the full name     */
 
59
 int  flag;                   /* Directory search disable flag. It is the    */
 
60
                              /* sum of the following values                 */
 
61
 
 
62
                              /*   1 - Disable search on current directory   */
 
63
                              /*   2 - Disable search on HOME directory (*)  */
 
64
                              /*   4 - Disable search on AGL standard dir.   */
 
65
                              /* Note: the AGL standard directory name is    */
 
66
                              /*       searched among environment variable in*/
 
67
                              /*       order to allow a runtime definition   */
 
68
 
 
69
                              /* (*): not yet implemented                    */
 
70
                                                                         /*--*/
 
71
{
 
72
char aux[PHNAMLNG];
 
73
FILE *temp=NULL;
 
74
static char *try = "Opening file:";
 
75
static char *done = "... done";
 
76
static char *notdone = "... not found";
 
77
 
 
78
strcpy(aux,fname);
 
79
strcat(aux,ext);
 
80
 
 
81
if(!(flag&1)) {                 /* Search on current directory             */
 
82
        AG_DMSG(try,aux);
 
83
        temp=fopen(aux,"r");
 
84
        if(temp!=NULL) {
 
85
                AG_DMSG(done,"");
 
86
                return(temp);
 
87
        } else
 
88
                AG_DMSG(notdone,"");
 
89
}
 
90
 
 
91
if(!(flag&4)) {
 
92
        AG_DMSG(AGLSTDIR,"Translated");
 
93
        AGL_trns(AGLSTDIR,PHNAMLNG,aux);        /* Search into environment */
 
94
        AG_DMSG("..into",aux);
 
95
        strcat(aux,fname);
 
96
        strcat(aux,ext);
 
97
        AG_DMSG(try,aux);
 
98
        temp=fopen(aux,"r");
 
99
        if(temp!=NULL) {
 
100
                AG_DMSG(done,"");
 
101
                return(temp);
 
102
        } else
 
103
                AG_DMSG(notdone,"");
 
104
}
 
105
return temp;
 
106
}
 
107