Commit | Line | Data |
---|---|---|
77cee3e1 | 1 | /* |
161423a6 RE |
2 | * Copyright (c) 1980 Regents of the University of California. |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
77cee3e1 | 5 | * |
49be84cd | 6 | * @(#)inquire.c 5.2 %G% |
161423a6 RE |
7 | */ |
8 | ||
9 | /* | |
77cee3e1 DW |
10 | * inquire.c - f77 i/o inquire statement routine |
11 | */ | |
12 | ||
13 | #include "fio.h" | |
14 | ||
15 | f_inqu(a) inlist *a; | |
16 | { char *byfile; | |
17 | int i; | |
49be84cd | 18 | int exist; |
77cee3e1 DW |
19 | unit *p; |
20 | char buf[256], *s; | |
21 | long x_inode; | |
22 | ||
23 | elist = NO; | |
24 | lfname = a->infile; | |
25 | lunit = a->inunit; | |
26 | external = YES; | |
27 | p = NULL; | |
28 | if(byfile=a->infile) | |
29 | { | |
30 | g_char(a->infile,a->infilen,buf); | |
31 | if((x_inode=inode(buf))==-1) | |
49be84cd JB |
32 | { exist = NO; /* file doesn't exist */ |
33 | } | |
34 | else | |
35 | { exist = YES; /* file does exist */ | |
36 | for(i=0;i<MXUNIT;i++) | |
37 | if(units[i].ufd && (units[i].uinode==x_inode)) | |
38 | { | |
39 | p = &units[i]; | |
40 | break; | |
41 | } | |
77cee3e1 | 42 | } |
77cee3e1 DW |
43 | } |
44 | else | |
45 | { | |
49be84cd JB |
46 | if (not_legal(lunit)) |
47 | { exist = NO; /* unit doesn't exist */ | |
48 | } | |
77cee3e1 | 49 | else |
49be84cd | 50 | { exist = YES; |
77cee3e1 DW |
51 | if (units[lunit].ufd) |
52 | { p= &units[lunit]; | |
53 | lfname = p->ufnm; | |
54 | } | |
49be84cd | 55 | } |
77cee3e1 | 56 | } |
49be84cd | 57 | if(a->inex) *a->inex = exist; |
77cee3e1 | 58 | if(a->inopen) *a->inopen=(p!=NULL); |
49be84cd | 59 | if(a->innum) *a->innum = byfile?(p?(p-units):-1):lunit; |
77cee3e1 DW |
60 | if(a->innamed) *a->innamed= (byfile || (p && p->ufnm)); |
61 | if(a->inname) | |
62 | { | |
63 | if(byfile) s = buf; | |
64 | else if(p && p->ufnm) s = p->ufnm; | |
65 | else s=""; | |
66 | b_char(s,a->inname,a->innamlen); | |
67 | } | |
49be84cd | 68 | if(a->inacc) |
77cee3e1 | 69 | { |
49be84cd JB |
70 | if(!p) s = "unknown"; |
71 | else if(p->url) s = "direct"; | |
77cee3e1 DW |
72 | else s = "sequential"; |
73 | b_char(s,a->inacc,a->inacclen); | |
74 | } | |
75 | if(a->inseq) | |
76 | { | |
49be84cd JB |
77 | if(!p) s = "unknown"; |
78 | else s = (p && !p->url)? "yes" : "no"; | |
77cee3e1 DW |
79 | b_char(s,a->inseq,a->inseqlen); |
80 | } | |
81 | if(a->indir) | |
82 | { | |
49be84cd JB |
83 | if(!p) s = "unknown"; |
84 | else s = (p && p->useek && p->url)? "yes" : "no"; | |
77cee3e1 DW |
85 | b_char(s,a->indir,a->indirlen); |
86 | } | |
87 | if(a->inform) | |
88 | { if(p) | |
89 | { | |
90 | #ifndef KOSHER | |
91 | if(p->uprnt) s = "print"; /*** NOT STANDARD FORTRAN ***/ | |
92 | else | |
93 | #endif | |
94 | s = p->ufmt?"formatted":"unformatted"; | |
95 | } | |
96 | else s = "unknown"; | |
97 | b_char(s,a->inform,a->informlen); | |
98 | } | |
99 | if(a->infmt) | |
100 | { | |
101 | if (p) s= p->ufmt? "yes" : "no"; | |
102 | else s= "unknown"; | |
103 | b_char(s,a->infmt,a->infmtlen); | |
104 | } | |
105 | if(a->inunf) | |
106 | { | |
107 | if (p) s= p->ufmt? "no" : "yes"; | |
108 | else s= "unknown"; | |
109 | b_char(s,a->inunf,a->inunflen); | |
110 | } | |
49be84cd JB |
111 | if(a->inrecl) *a->inrecl = p ? p->url : -1; |
112 | if(a->innrec) { | |
113 | if(p && p->url) | |
114 | *a->innrec = ((ftell(p->ufd) + p->url - 1)/p->url) + 1; | |
115 | else | |
116 | *a->innrec = -1; | |
117 | } | |
118 | if(a->inblank) | |
77cee3e1 | 119 | { |
49be84cd JB |
120 | if( p && p->ufmt) |
121 | s = p->ublnk ? "zero" : "null" ; | |
122 | else | |
123 | s = "unknown"; | |
124 | b_char(s,a->inblank,a->inblanklen); | |
77cee3e1 DW |
125 | } |
126 | return(OK); | |
127 | } |