Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
inq.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001, Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2.1 of the GNU Lesser General Public License 
00007   as published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU Lesser General Public 
00021   License along with this program; if not, write the Free Software 
00022   Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 
00023   USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 
00037 
00038 #pragma ident "@(#) libf/fio/inq.c      92.1    06/21/99 10:37:55"
00039 
00040 #include <liberrno.h>
00041 #include <fortran.h>
00042 #include <string.h>
00043 #include <cray/nassert.h>
00044 #include "fio.h"
00045 #include "f90io.h"
00046 #ifdef _CRAYMPP
00047 #include <stdarg.h>
00048 #endif
00049 /*
00050  *      _INQ - Fortran runtime entry for INQUIRE
00051  */
00052 #ifdef _UNICOS
00053 #pragma _CRI duplicate _INQ as $INQ             /* for cf77 */
00054 #endif
00055 
00056 #ifdef _CRAYMPP
00057 _INQ(
00058 _f_int  *unitn,
00059 _f_int  *iostat,
00060 int     errf,
00061 _f_log  *exist,
00062 _f_log  *opened,
00063 _f_int  *number,
00064 _f_log  *named,
00065 ...
00066 )
00067 #else
00068 _INQ(
00069 _f_int  *unitn,
00070 _f_int  *iostat,
00071 int     errf,
00072 _f_log  *exist,
00073 _f_log  *opened,
00074 _f_int  *number,
00075 _f_log  *named,
00076 _fcd    name,
00077 _fcd    access,
00078 _fcd    sequent,
00079 _fcd    direct,
00080 _fcd    form,
00081 _fcd    formatt,
00082 _fcd    unform,
00083 _f_int  *recl,
00084 _f_int  *nextrec,
00085 _fcd    blank,
00086 _fcd    file,
00087 _fcd    pos,
00088 _fcd    action,
00089 _fcd    red,
00090 _fcd    writ,
00091 _fcd    redwrit,
00092 _fcd    delim,
00093 _fcd    pad
00094 )
00095 #endif
00096 {
00097         inlist  a;              /* INQUIRE parameter list               */
00098         int     errn;           /* IOSTAT error number                  */
00099         int     error;          /* Error flag                           */
00100         unum_t  unum;           /* Unit number                          */
00101         long    stmt;           /* Statement type                       */
00102         unit    *cup;           /* Unit pointer if inquire by unit      */
00103         struct fiostate cfs;
00104 #ifdef _CRAYMPP
00105         va_list args;
00106         _fcd    name;
00107         _fcd    access;
00108         _fcd    sequent;
00109         _fcd    direct;
00110         _fcd    form;
00111         _fcd    formatt;
00112         _fcd    unform;
00113         _f_int  *recl;
00114         _f_int  *nextrec;
00115         _fcd    blank;
00116         _fcd    file;
00117         _fcd    pos;
00118         _fcd    action;
00119         _fcd    red;
00120         _fcd    writ;
00121         _fcd    redwrit;
00122         _fcd    delim;
00123         _fcd    pad;
00124         va_start(args,named);
00125         name    = va_arg(args, _fcd);
00126         access  = va_arg(args, _fcd);
00127         sequent = va_arg(args, _fcd);
00128         direct  = va_arg(args, _fcd);
00129         form    = va_arg(args, _fcd);
00130         formatt = va_arg(args, _fcd);
00131         unform  = va_arg(args, _fcd);
00132         recl    = va_arg(args, _f_int *);
00133         nextrec = va_arg(args, _f_int *);
00134         blank   = va_arg(args, _fcd);
00135         file    = va_arg(args, _fcd);
00136 #endif
00137 
00138         /* Initialize the inlist structure */
00139 
00140         (void) memset(&a, 0, sizeof(inlist));
00141         a.inunit        = -1;
00142 
00143         /* Determine type of INQUIRE */
00144 
00145         if (_fcdtocp(file) != NULL) {
00146                 a.infile        = _fcdtocp(file);
00147                 a.infilen       = _fcdlen (file);       /* CFT77 */
00148                 stmt            = T_INQF;               /* INQUIRE by FILE */
00149                 unum            = -1;
00150         }
00151         else {
00152                 stmt            = T_INQU;               /* INQUIRE by UNIT */
00153                 unum            = *unitn;
00154                 a.inunit        = unum;
00155         }
00156 
00157 /*
00158  *      Here unum is -1 if this is an inquire by file.  This will suppress
00159  *      any unit locking in STMT_BEGIN.
00160  */
00161 
00162         STMT_BEGIN(unum, 0, stmt, NULL, &cfs, cup);
00163 
00164         /* Process rest of parameters */
00165 
00166         if (_fcdtocp(name) != NULL) {
00167                 a.inname        = _fcdtocp(name);
00168                 a.innamlen      = _fcdlen (name);       /* CFT77 */
00169 
00170                 if (a.innamlen == 0)
00171                         a.innamlen      = strlen(a.inname);     /* CFT2 */
00172         }
00173 
00174         if (_fcdtocp(access) != NULL) {
00175                 a.inacc         = _fcdtocp(access);
00176                 a.inacclen      = _fcdlen (access);
00177         }
00178 
00179         if (_fcdtocp(sequent) != NULL) {
00180                 a.inseq         = _fcdtocp(sequent);
00181                 a.inseqlen      = _fcdlen (sequent);
00182         }
00183 
00184         if (_fcdtocp(direct) != NULL) {
00185                 a.indir         = _fcdtocp(direct);
00186                 a.indirlen      = _fcdlen (direct);
00187         }
00188 
00189         if (_fcdtocp(form) != NULL) {
00190                 a.inform        = _fcdtocp(form);
00191                 a.informlen     = _fcdlen (form);
00192         }
00193 
00194         if (_fcdtocp(formatt) != NULL) {
00195                 a.infmt         = _fcdtocp(formatt);
00196                 a.infmtlen      = _fcdlen (formatt);
00197         }
00198 
00199         if (_fcdtocp(unform) != NULL) {
00200                 a.inunf         = _fcdtocp(unform);
00201                 a.inunflen      = _fcdlen (unform);
00202         }
00203 
00204         if (_fcdtocp(blank) != NULL) {
00205                 a.inblank       = _fcdtocp(blank);
00206                 a.inblanklen    = _fcdlen (blank);
00207         }
00208 
00209 #ifdef  _UNICOS
00210         if (_numargs() <= (9 + 9*sizeof(_fcd)/sizeof(long)))
00211                 goto old_inq;
00212 #endif
00213 
00214 #ifdef _CRAYMPP
00215         pos     = va_arg(args, _fcd);
00216         action  = va_arg(args, _fcd);
00217         red     = va_arg(args, _fcd);
00218         writ    = va_arg(args, _fcd);
00219         redwrit = va_arg(args, _fcd);
00220         delim   = va_arg(args, _fcd);
00221         pad     = va_arg(args, _fcd);
00222 #endif
00223         if (_fcdtocp(pos) != NULL) {
00224                 a.inposit       = _fcdtocp(pos);
00225                 a.inpositlen    = _fcdlen (pos);
00226         }
00227 
00228         if (_fcdtocp(action) != NULL) {
00229                 a.inaction      = _fcdtocp(action);
00230                 a.inactonlen    = _fcdlen (action);
00231         }
00232 
00233         if (_fcdtocp(red) != NULL) {
00234                 a.inread        = _fcdtocp(red);
00235                 a.inreadlen     = _fcdlen (red);
00236         }
00237 
00238         if (_fcdtocp(writ) != NULL) {
00239                 a.inwrite       = _fcdtocp(writ);
00240                 a.inwritelen    = _fcdlen (writ);
00241         }
00242 
00243         if (_fcdtocp(redwrit) != NULL) {
00244                 a.inredwrit     = _fcdtocp(redwrit);
00245                 a.inrdwrtlen    = _fcdlen (redwrit);
00246         }
00247 
00248         if (_fcdtocp(delim) != NULL) {
00249                 a.indelim       = _fcdtocp(delim);
00250                 a.indelimlen    = _fcdlen (delim);
00251         }
00252 
00253         if (_fcdtocp(pad) != NULL) {
00254                 a.inpad         = _fcdtocp(pad);
00255                 a.inpadlen      = _fcdlen (pad);
00256         }
00257 
00258 old_inq:
00259 
00260         a.inerr         = (errf || iostat) ? 1 : 0;
00261         a.inex          = exist;
00262         a.inopen        = opened;
00263         a.innum         = number;
00264         a.innamed       = named;
00265         a.inrecl        = recl;
00266         a.innrec        = nextrec;
00267         errn            = _f_inqu(&cfs, cup, &a);
00268         error           = (errn != 0) ? IO_ERR : IO_OKAY;
00269 
00270         if (iostat != NULL)
00271                 *iostat = errn;
00272 
00273 #ifdef _CRAYMPP
00274         va_end(args);
00275 #endif
00276         STMT_END(NULL, 0, NULL, NULL);  
00277 
00278         return(CFT77_RETVAL(error));
00279 }
00280 
00281 /*
00282  *      _INQUIRE - Fortran 90 INQUIRE statement processing.
00283  */
00284 int
00285 _INQUIRE(struct inquire_spec_list *i)
00286 {
00287         assert( i->version == 0 );
00288 
00289         return( _INQ(i->unit, i->iostat, i->err, i->exist, i->opened,
00290                      i->number, i->named, i->name, i->access, i->sequential,
00291                      i->direct, i->form, i->formatted, i->unformatted, i->recl,
00292                      i->nextrec, i->blank, i->file, i->position, i->action,
00293                      i->read, i->write, i->readwrite, i->delim, i->pad) );
00294 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines