/**************************************************************************/
/*                                                                        */
/*                                 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_quer.c,v 1.2 1997/09/25 17:20:10 ae59 Exp $ */
/*
$Log: f_quer.c,v $
 * Revision 1.2  1997/09/25  17:20:10  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:22:29  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : f_quer.c                              */
/*                                                              */
/*      Entry           : void f_quer(desc,status,name)         */
/*                        f_text *desc;                         */
/*                        a_intg *status;                       */
/*                        s_trng *name;                         */
/*                                                              */
/*      Arguments       : desc   - file descriptor              */
/*                        status - status information           */
/*                             1 - file assigned                */
/*                             2 - file open                    */
/*                             4 - ... with existing pp-name    */
/*                             8 - ... for reading              */
/*                            16 - ... from standard I/O device */
/*                            32 - ... with end-of-line status  */
/*                            64 - ... with end-of-file status  */
/*                           128 - ... with error status        */
/*                        name   - assigned file name           */
/*                                                              */
/*      Description     : Query file descriptor.                */
/*                                                              */
/*      Date            : 1991-01-29                            */
/****************************************************************/

#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 void f_quer(f_text *desc,a_intg *status,s_trng *name)
#else
local void f_quer(desc,status,name)

f_text *desc;
a_intg *status;
s_trng *name;
#endif
        {

#define ASSIGNED_STATUS         1
#define OPEN_STATUS             2
#define PP_NAME_STATUS          4
#define READING_STATUS          8
#define STANDARD_STATUS        16
#define END_OF_LINE_STATUS     32
#define END_OF_FILE_STATUS     64
#define ERROR_STATUS          128

        *status = 0;

        if (desc->asgd)
           {
           (*status) += ASSIGNED_STATUS;
           if (desc->org!=NULL) (*status) += PP_NAME_STATUS;
           if (desc->outf || desc->infl)
              {
              (*status) += OPEN_STATUS;
              if (desc->infl) (*status) += READING_STATUS;
              if (desc->stdi || desc->stdo) (*status) += STANDARD_STATUS;
              if (desc->eoln) (*status) += END_OF_LINE_STATUS;
              if (desc->eof) (*status) += END_OF_FILE_STATUS;
              if (desc->err) (*status) += ERROR_STATUS;
              }

           s_asta(name,(a_char *)desc->name,(a_intg)strlen(desc->name));
           }
        else
           s_free(name);

        return;
        }
