2001-06-13 23:06:15 +02:00
|
|
|
#include "config.h"
|
1998-02-01 02:37:08 +01:00
|
|
|
#include "f2c.h"
|
|
|
|
#include "fio.h"
|
|
|
|
#include <string.h>
|
|
|
|
#if defined (MSDOS) && !defined (GO32)
|
|
|
|
#undef abs
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
#include "io.h"
|
|
|
|
#endif
|
2002-06-01 14:38:32 +02:00
|
|
|
integer
|
|
|
|
f_inqu (inlist * a)
|
|
|
|
{
|
|
|
|
flag byfile;
|
|
|
|
int i, n;
|
|
|
|
unit *p;
|
|
|
|
char buf[256];
|
|
|
|
long x;
|
|
|
|
if (f__init & 2)
|
|
|
|
f__fatal (131, "I/O recursion");
|
|
|
|
if (a->infile != NULL)
|
|
|
|
{
|
|
|
|
byfile = 1;
|
|
|
|
g_char (a->infile, a->infilen, buf);
|
1998-02-01 02:37:08 +01:00
|
|
|
#ifdef NON_UNIX_STDIO
|
2002-06-01 14:38:32 +02:00
|
|
|
x = access (buf, 0) ? -1 : 0;
|
|
|
|
for (i = 0, p = NULL; i < MXUNIT; i++)
|
|
|
|
if (f__units[i].ufd != NULL
|
|
|
|
&& f__units[i].ufnm != NULL && !strcmp (f__units[i].ufnm, buf))
|
|
|
|
{
|
|
|
|
p = &f__units[i];
|
|
|
|
break;
|
|
|
|
}
|
1998-02-01 02:37:08 +01:00
|
|
|
#else
|
2002-06-01 14:38:32 +02:00
|
|
|
x = f__inode (buf, &n);
|
|
|
|
for (i = 0, p = NULL; i < MXUNIT; i++)
|
|
|
|
if (f__units[i].uinode == x
|
|
|
|
&& f__units[i].ufd != NULL && f__units[i].udev == n)
|
|
|
|
{
|
|
|
|
p = &f__units[i];
|
|
|
|
break;
|
|
|
|
}
|
1998-02-01 02:37:08 +01:00
|
|
|
#endif
|
2002-06-01 14:38:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
byfile = 0;
|
|
|
|
if (a->inunit < MXUNIT && a->inunit >= 0)
|
|
|
|
{
|
|
|
|
p = &f__units[a->inunit];
|
1998-02-01 02:37:08 +01:00
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
else
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
2002-06-01 14:38:32 +02:00
|
|
|
p = NULL;
|
1998-02-01 02:37:08 +01:00
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
}
|
|
|
|
if (a->inex != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
2002-06-04 04:24:26 +02:00
|
|
|
if ((byfile && x != -1) || (!byfile && p != NULL))
|
2002-06-02 14:57:28 +02:00
|
|
|
*a->inex = 1;
|
|
|
|
else
|
|
|
|
*a->inex = 0;
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inopen != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (byfile)
|
|
|
|
*a->inopen = (p != NULL);
|
|
|
|
else
|
|
|
|
*a->inopen = (p != NULL && p->ufd != NULL);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->innum != NULL)
|
|
|
|
*a->innum = p - f__units;
|
|
|
|
if (a->innamed != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
2002-06-04 04:24:26 +02:00
|
|
|
if (byfile || (p != NULL && p->ufnm != NULL))
|
2002-06-02 14:57:28 +02:00
|
|
|
*a->innamed = 1;
|
|
|
|
else
|
|
|
|
*a->innamed = 0;
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inname != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (byfile)
|
|
|
|
b_char (buf, a->inname, a->innamlen);
|
|
|
|
else if (p != NULL && p->ufnm != NULL)
|
|
|
|
b_char (p->ufnm, a->inname, a->innamlen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inacc != NULL && p != NULL && p->ufd != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p->url)
|
|
|
|
b_char ("DIRECT", a->inacc, a->inacclen);
|
|
|
|
else
|
|
|
|
b_char ("SEQUENTIAL", a->inacc, a->inacclen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inseq != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p != NULL && p->url)
|
|
|
|
b_char ("NO", a->inseq, a->inseqlen);
|
|
|
|
else
|
|
|
|
b_char ("YES", a->inseq, a->inseqlen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->indir != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p == NULL || p->url)
|
|
|
|
b_char ("YES", a->indir, a->indirlen);
|
|
|
|
else
|
|
|
|
b_char ("NO", a->indir, a->indirlen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->infmt != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p != NULL && p->ufmt == 0)
|
|
|
|
b_char ("UNFORMATTED", a->infmt, a->infmtlen);
|
|
|
|
else
|
|
|
|
b_char ("FORMATTED", a->infmt, a->infmtlen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inform != NULL)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p != NULL && p->ufmt == 0)
|
|
|
|
b_char ("NO", a->inform, a->informlen);
|
|
|
|
else
|
|
|
|
b_char ("YES", a->inform, a->informlen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inunf)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p != NULL && p->ufmt == 0)
|
|
|
|
b_char ("YES", a->inunf, a->inunflen);
|
|
|
|
else if (p != NULL)
|
|
|
|
b_char ("NO", a->inunf, a->inunflen);
|
|
|
|
else
|
|
|
|
b_char ("UNKNOWN", a->inunf, a->inunflen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
if (a->inrecl != NULL && p != NULL)
|
|
|
|
*a->inrecl = p->url;
|
|
|
|
if (a->innrec != NULL && p != NULL && p->url > 0)
|
|
|
|
*a->innrec = FTELL (p->ufd) / p->url + 1;
|
|
|
|
if (a->inblank && p != NULL && p->ufmt)
|
2002-06-02 14:57:28 +02:00
|
|
|
{
|
|
|
|
if (p->ublnk)
|
|
|
|
b_char ("ZERO", a->inblank, a->inblanklen);
|
|
|
|
else
|
|
|
|
b_char ("NULL", a->inblank, a->inblanklen);
|
|
|
|
}
|
2002-06-01 14:38:32 +02:00
|
|
|
return (0);
|
1998-02-01 02:37:08 +01:00
|
|
|
}
|