1 /* $Id: inquire.c,v 1.3 2008/03/01 13:44:12 ragge Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code and documentation must retain the above
10 * copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditionsand the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed or owned by Caldera
17 * International, Inc.
18 * Neither the name of Caldera International, Inc. nor the names of other
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27 * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35 #include "fio.h"
36
37 int
f_inqu(inlist * a)38 f_inqu(inlist *a)
39 {
40 flag byfile,legal;
41 int i;
42 unit *p;
43 char buf[256];
44 long x;
45
46 x = 0; /* XXX - check correctness */
47 if(a->infile!=NULL) {
48 byfile=1;
49 g_char(a->infile,a->infilen,buf);
50 x=inode(buf);
51 for(i=0,p=NULL;i<MXUNIT;i++)
52 if(units[i].uinode==x && units[i].ufd!=NULL)
53 p = &units[i];
54 } else {
55 byfile=0;
56 if(a->inunit<MXUNIT && a->inunit>=0) {
57 legal=1;
58 p= &units[a->inunit];
59 } else {
60 legal=0;
61 p=NULL;
62 }
63 }
64 if(a->inex!=NULL) {
65 if((byfile && x>0) || (!byfile && p!=NULL))
66 *a->inex=1;
67 else *a->inex=0;
68 }
69 if(a->inopen!=NULL) {
70 if(byfile) *a->inopen=(p!=NULL);
71 else *a->inopen=(p!=NULL && p->ufd!=NULL);
72 }
73 if(a->innum!=NULL) *a->innum= p-units;
74 if(a->innamed!=NULL) {
75 if(byfile || (p!=NULL && p->ufnm!=NULL))
76 *a->innamed=1;
77 else *a->innamed=0;
78 }
79 if(a->inname!=NULL) {
80 if(byfile)
81 b_char(buf,a->inname,a->innamlen);
82 else if(p!=NULL && p->ufnm!=NULL)
83 b_char(p->ufnm,a->inname,a->innamlen);
84 }
85 if(a->inacc!=NULL && p!=NULL && p->ufd!=NULL) {
86 if(p->url)
87 b_char("direct",a->inacc,a->inacclen);
88 else b_char("sequential",a->inacc,a->inacclen);
89 }
90 if(a->inseq!=NULL) {
91 if(byfile || (p!=NULL && p->useek))
92 b_char("yes",a->inseq,a->inseqlen);
93 else b_char("no",a->inseq,a->inseqlen);
94 }
95 if(a->indir!=NULL) {
96 if(byfile || (p!=NULL && p->useek))
97 b_char("yes",a->indir,a->indirlen);
98 else b_char("no",a->indir,a->indirlen);
99 }
100 if(a->infmt!=NULL) {
101 if(p!=NULL && p->ufmt)
102 b_char("formatted",a->infmt,a->infmtlen);
103 else if(p!=NULL)
104 b_char("unformatted",a->infmt,a->infmtlen);
105 }
106 if(a->inform!=NULL)
107 b_char("yes",a->inform,a->informlen);
108 if(a->inunf) {
109 if(byfile || (p!=NULL && p->useek))
110 b_char("yes",a->inunf,a->inunflen);
111 else b_char("unknown",a->inunf,a->inunflen);
112 }
113 if(a->inrecl!=NULL && p!=NULL)
114 *a->inrecl=p->url;
115 if(a->innrec!=NULL && p!=NULL && p->url>0)
116 *a->innrec=ftell(p->ufd)/p->url+1;
117 if(a->inblank && p!=NULL && p->ufmt) {
118 if(p->ublnk)
119 b_char("zero",a->inblank,a->inblanklen);
120 else b_char("blank",a->inblank,a->inblanklen);
121 }
122 return(0);
123 }
124