1 #include "f2c.h"
2 #include "fio.h"
3 #ifdef KR_headers
f_inqu(a)4 integer f_inqu(a) inlist *a;
5 #else
6 #ifdef MSDOS
7 #undef abs
8 #undef min
9 #undef max
10 #include "string.h"
11 #include "io.h"
12 #endif
13
14 #include <unistd.h>
15 #include <string.h>
16
17 integer f_inqu(inlist *a)
18 #endif
19 { flag byfile;
20 int i, n;
21 unit *p;
22 char buf[256];
23 long x=0;
24 if(a->infile!=NULL)
25 { byfile=1;
26 g_char(a->infile,a->infilen,buf);
27 #ifdef NON_UNIX_STDIO
28 x = access(buf,0) ? -1 : 0;
29 for(i=0,p=NULL;i<MXUNIT;i++)
30 if(f__units[i].ufd != NULL
31 && f__units[i].ufnm != NULL
32 && !strcmp(f__units[i].ufnm,buf)) {
33 p = &f__units[i];
34 break;
35 }
36 #else
37 x=f__inode(buf, &n);
38 for(i=0,p=NULL;i<MXUNIT;i++)
39 if(f__units[i].uinode==x
40 && f__units[i].ufd!=NULL
41 && f__units[i].udev == n) {
42 p = &f__units[i];
43 break;
44 }
45 #endif
46 }
47 else
48 {
49 byfile=0;
50 if(a->inunit<MXUNIT && a->inunit>=0)
51 {
52 p= &f__units[a->inunit];
53 }
54 else
55 {
56 p=NULL;
57 }
58 }
59 if(a->inex!=NULL)
60 if(byfile && x != -1 || !byfile && p!=NULL)
61 *a->inex=1;
62 else *a->inex=0;
63 if(a->inopen!=NULL)
64 if(byfile) *a->inopen=(p!=NULL);
65 else *a->inopen=(p!=NULL && p->ufd!=NULL);
66 if(a->innum!=NULL) *a->innum= p-f__units;
67 if(a->innamed!=NULL)
68 if(byfile || p!=NULL && p->ufnm!=NULL)
69 *a->innamed=1;
70 else *a->innamed=0;
71 if(a->inname!=NULL)
72 if(byfile)
73 b_char(buf,a->inname,a->innamlen);
74 else if(p!=NULL && p->ufnm!=NULL)
75 b_char(p->ufnm,a->inname,a->innamlen);
76 if(a->inacc!=NULL && p!=NULL && p->ufd!=NULL)
77 if(p->url)
78 b_char("DIRECT",a->inacc,a->inacclen);
79 else b_char("SEQUENTIAL",a->inacc,a->inacclen);
80 if(a->inseq!=NULL)
81 if(p!=NULL && p->url)
82 b_char("NO",a->inseq,a->inseqlen);
83 else b_char("YES",a->inseq,a->inseqlen);
84 if(a->indir!=NULL)
85 if(p==NULL || p->url)
86 b_char("YES",a->indir,a->indirlen);
87 else b_char("NO",a->indir,a->indirlen);
88 if(a->infmt!=NULL)
89 if(p!=NULL && p->ufmt==0)
90 b_char("UNFORMATTED",a->infmt,a->infmtlen);
91 else b_char("FORMATTED",a->infmt,a->infmtlen);
92 if(a->inform!=NULL)
93 if(p!=NULL && p->ufmt==0)
94 b_char("NO",a->inform,a->informlen);
95 else b_char("YES",a->inform,a->informlen);
96 if(a->inunf)
97 if(p!=NULL && p->ufmt==0)
98 b_char("YES",a->inunf,a->inunflen);
99 else if (p!=NULL) b_char("NO",a->inunf,a->inunflen);
100 else b_char("UNKNOWN",a->inunf,a->inunflen);
101 if(a->inrecl!=NULL && p!=NULL)
102 *a->inrecl=p->url;
103 if(a->innrec!=NULL && p!=NULL && p->url>0)
104 *a->innrec=ftell(p->ufd)/p->url+1;
105 if(a->inblank && p!=NULL && p->ufmt)
106 if(p->ublnk)
107 b_char("ZERO",a->inblank,a->inblanklen);
108 else b_char("NULL",a->inblank,a->inblanklen);
109 return(0);
110 }
111