/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: f_op88.c,v 1.2 1997/09/25 17:19:40 ae59 Exp $ */
/*
$Log: f_op88.c,v $
 * Revision 1.2  1997/09/25  17:19:40  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:22:28  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : f_op88.c                              */
/*                                                              */
/*      Entry           : a_intg f_op88(desc,name,level)        */
/*                        f_text *desc;                         */
/*                        s_trng name;                          */
/*                        a_intg level;                         */
/*                                                              */
/*      Arguments       : desc   - descriptor of opened file    */
/*                        name   - filename to be searched for  */
/*                        level  - search level                 */
/*                                                              */
/*      Return value    : level on which files is found         */
/*                           0 = not found                      */
/*                          10 = found in sysdir                */
/*                          20 = found in PXSC_SYS              */
/*                          50 = found in usrdir                */
/*                          60 = found in PXSC_USR              */
/*                          90 = found in current directory     */
/*                                                              */
/*      Description     : Open a system file for reading.       */
/*                        File must be a text file.             */
/*                        Filename must not exceed 'f_fnsz-1'.  */
/*                                                              */
/*      Date            : 1991-03-08                            */
/*      1991-03-08 : length of filename less than 'f_fnsz-1'    */
/*      1991-02-13 : e_trap() called with E_TSTG                */
/*      1991-02-01 : f_getc() used instead of fgetc()           */
/****************************************************************/

#ifndef ALL_IN_ONE
#define local static
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#undef local
#define local
#endif

#define not_found_level          0

#ifdef LINT_ARGS
local a_intg f_op88(f_text *desc,s_trng name,a_intg level)
#else
local a_intg f_op88(desc,name,level)

f_text *desc;
s_trng name;
a_intg level;
#endif
 
        {
        E_TPUSH("f_op88")

        if (desc->text==FALSE)
           {
           e_trap(I_O_ERROR,2,E_TMSG,19);
           level = not_found_level;
           }
        else if (name.clen==0)
           {
           e_trap(I_O_ERROR,2,E_TMSG,62);
           level = not_found_level;
           }
        else if (name.clen>=f_fnsz)
           {
           e_trap(I_O_ERROR,4,E_TMSG,30,E_TSTG+E_TEXT(8),&name);
           }
        else if ((level = b_op88(desc,name,level))>0)
           f_getc(desc);

        if (name.tmp) s_free(&name);

        E_TPOPP("f_op88")
        return(level);
        }
