/**************************************************************************/
/*                                                                        */
/*                                 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_sexs.c,v 1.2 1997/09/25 17:22:28 ae59 Exp $ */
/*
$Log: f_sexs.c,v $
 * Revision 1.2  1997/09/25  17:22:28  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:22:37  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : f_sexs.c                              */
/*                                                              */
/*      Entry           : a_bool f_sexs(name)                   */
/*                        s_trng name;                          */
/*                                                              */
/*      Arguments       : name   - filename                     */
/*                                                              */
/*      Function value  : TRUE if file exists                   */
/*                                                              */
/*      Description     : Test for existing file                */
/*                                                              */
/*      Date            : 1992-01-16                            */
/*      1992-01-16 : result initialized to be FALSE             */
/*      1991-12-03 : TRUE returned if empty string              */
/*      1991-02-13 : copy string if substring                   */
/*      1990-12-18 : append '\0' to end of string/free temporary*/
/*      1990-11-15 : E_TPUSH+E_TPOPP                            */
/****************************************************************/

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

#ifdef LINT_ARGS
local a_bool f_sexs(s_trng name)
#else
local a_bool f_sexs(name)

s_trng name;
#endif

        {
        FILE *fp;
        a_bool res;
        char ch;

        E_TPUSH("f_sexs")

        res = FALSE;

        if (name.clen==0)
           {
           res = TRUE;
           }
        else if (name.ptr==NULL || name.ptr[0]=='\0')
           {
           e_trap(I_O_ERROR,2,E_TMSG,45);
           }
        else if (name.clen>=BUFFERSIZE-1)
           {
           e_trap(I_O_BUFFER,4,E_TMSG,29,E_TMSG,30);
           }
        else
           {
           if (name.suba) s_asgn(&name,name);
           ch = name.ptr[name.clen];
           name.ptr[name.clen] = '\0';
           if ((fp=fopen(name.ptr,"r"))!=NULL)
              {
              fclose(fp);
              res = TRUE;
              }
           name.ptr[name.clen] = ch;
           }

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

        E_TPOPP("f_sexs")
        return(res);
        }

