inquire.c
Go to the documentation of this file.
00001 #include "f2c.h"
00002 #include "fio.h"
00003 #include "string.h"
00004 #ifdef NON_UNIX_STDIO
00005 #ifndef MSDOS
00006 #include "unistd.h" /* for access() */
00007 #endif
00008 #endif
00009 #ifdef KR_headers
00010 integer f_inqu(a) inlist *a;
00011 #else
00012 #ifdef __cplusplus
00013 extern "C" integer f_inqu(inlist*);
00014 #endif
00015 #ifdef MSDOS
00016 #undef abs
00017 #undef min
00018 #undef max
00019 #include "io.h"
00020 #endif
00021 integer f_inqu(inlist *a)
00022 #endif
00023 {       flag byfile;
00024         int i;
00025 #ifndef NON_UNIX_STDIO
00026         int n;
00027 #endif
00028         unit *p;
00029         char buf[256];
00030         long x;
00031         if(a->infile!=NULL)
00032         {       byfile=1;
00033                 g_char(a->infile,a->infilen,buf);
00034 #ifdef NON_UNIX_STDIO
00035                 x = access(buf,0) ? -1 : 0;
00036                 for(i=0,p=NULL;i<MXUNIT;i++)
00037                         if(f__units[i].ufd != NULL
00038                          && f__units[i].ufnm != NULL
00039                          && !strcmp(f__units[i].ufnm,buf)) {
00040                                 p = &f__units[i];
00041                                 break;
00042                                 }
00043 #else
00044                 x=f__inode(buf, &n);
00045                 for(i=0,p=NULL;i<MXUNIT;i++)
00046                         if(f__units[i].uinode==x
00047                         && f__units[i].ufd!=NULL
00048                         && f__units[i].udev == n) {
00049                                 p = &f__units[i];
00050                                 break;
00051                                 }
00052 #endif
00053         }
00054         else
00055         {
00056                 byfile=0;
00057                 if(a->inunit<MXUNIT && a->inunit>=0)
00058                 {
00059                         p= &f__units[a->inunit];
00060                 }
00061                 else
00062                 {
00063                         p=NULL;
00064                 }
00065         }
00066         if(a->inex!=NULL)
00067                 if(byfile && x != -1 || !byfile && p!=NULL)
00068                         *a->inex=1;
00069                 else *a->inex=0;
00070         if(a->inopen!=NULL)
00071                 if(byfile) *a->inopen=(p!=NULL);
00072                 else *a->inopen=(p!=NULL && p->ufd!=NULL);
00073         if(a->innum!=NULL) *a->innum= p-f__units;
00074         if(a->innamed!=NULL)
00075                 if(byfile || p!=NULL && p->ufnm!=NULL)
00076                         *a->innamed=1;
00077                 else    *a->innamed=0;
00078         if(a->inname!=NULL)
00079                 if(byfile)
00080                         b_char(buf,a->inname,a->innamlen);
00081                 else if(p!=NULL && p->ufnm!=NULL)
00082                         b_char(p->ufnm,a->inname,a->innamlen);
00083         if(a->inacc!=NULL && p!=NULL && p->ufd!=NULL)
00084                 if(p->url)
00085                         b_char("DIRECT",a->inacc,a->inacclen);
00086                 else    b_char("SEQUENTIAL",a->inacc,a->inacclen);
00087         if(a->inseq!=NULL)
00088                 if(p!=NULL && p->url)
00089                         b_char("NO",a->inseq,a->inseqlen);
00090                 else    b_char("YES",a->inseq,a->inseqlen);
00091         if(a->indir!=NULL)
00092                 if(p==NULL || p->url)
00093                         b_char("YES",a->indir,a->indirlen);
00094                 else    b_char("NO",a->indir,a->indirlen);
00095         if(a->infmt!=NULL)
00096                 if(p!=NULL && p->ufmt==0)
00097                         b_char("UNFORMATTED",a->infmt,a->infmtlen);
00098                 else    b_char("FORMATTED",a->infmt,a->infmtlen);
00099         if(a->inform!=NULL)
00100                 if(p!=NULL && p->ufmt==0)
00101                 b_char("NO",a->inform,a->informlen);
00102                 else b_char("YES",a->inform,a->informlen);
00103         if(a->inunf)
00104                 if(p!=NULL && p->ufmt==0)
00105                         b_char("YES",a->inunf,a->inunflen);
00106                 else if (p!=NULL) b_char("NO",a->inunf,a->inunflen);
00107                 else b_char("UNKNOWN",a->inunf,a->inunflen);
00108         if(a->inrecl!=NULL && p!=NULL)
00109                 *a->inrecl=p->url;
00110         if(a->innrec!=NULL && p!=NULL && p->url>0)
00111                 *a->innrec=(ftnint)(FTELL(p->ufd)/p->url+1);
00112         if(a->inblank && p!=NULL && p->ufmt)
00113                 if(p->ublnk)
00114                         b_char("ZERO",a->inblank,a->inblanklen);
00115                 else    b_char("NULL",a->inblank,a->inblanklen);
00116         return(0);
00117 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:50