File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / usr.lib / libI77 / inquire.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:28:06 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*
 * Copyright (c) 1980 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)inquire.c	5.1	6/7/85
 */

/*
 * inquire.c - f77 i/o inquire statement routine
 */

#include "fio.h"

f_inqu(a) inlist *a;
{	flag byfile;
	int i;
	unit *p;
	char buf[256], *s;
	long x_inode;
	if(a->infile!=NULL)
	{	byfile=1;
		g_char(a->infile,a->infilen,buf);
		x_inode=inode(buf);
		for(i=0,p=NULL;i<MXUNIT;i++)
			if(units[i].uinode==x_inode && units[i].ufd!=NULL)
				p = &units[i];
	}
	else
	{
		byfile=0;
		if(a->inunit<MXUNIT && a->inunit>=0)
		{
			p= &units[a->inunit];
		}
		else
		{
			p=NULL;
		}
	}
	if(a->inex!=NULL)
		if(byfile && x_inode>0 || !byfile && p!=NULL)
			*a->inex=1;
		else *a->inex=0;
	if(a->inopen!=NULL)
		if(byfile) *a->inopen=(p!=NULL);
		else *a->inopen=(p!=NULL && p->ufd!=NULL);
	if(a->innum) *a->innum= (p?(p-units):-1);
	if(a->innamed) *a->innamed= (byfile || (p && p->ufnm));
	if(a->inname)
	{
		if(byfile) s = buf;
		else if(p && p->ufnm) s = p->ufnm;
		else s="";
		b_char(s,a->inname,a->innamlen);
	}
	if(a->inacc && p)
	{
		if(p->url) s = "DIRECT";
		else	s = "SEQUENTIAL";
		b_char(s,a->inacc,a->inacclen);
	}
	if(a->inseq)
	{
		s= ((byfile && !p) || (p && !p->url))? "YES" : "NO";
		b_char(s,a->inseq,a->inseqlen);
	}
	if(a->indir)
	{
		s= ((byfile && !p) || (p && p->useek && p->url))? "YES" : "NO";
		b_char(s,a->indir,a->indirlen);
	}
	if(a->inform)
	{	if(p)
		{
#ifndef KOSHER
			if(p->uprnt) s = "PRINT"; /*** NOT STANDARD FORTRAN ***/
			else
#endif
				s = p->ufmt?"FORMATTED":"UNFORMATTED";
		}
		else s = "UNKNOWN";
		b_char(s,a->inform,a->informlen);
	}
	if(a->infmt)
	{
		if (p) s= p->ufmt? "YES" : "NO";
		else s= "unknown";
		b_char(s,a->infmt,a->infmtlen);
	}
	if(a->inunf)
	{
		if (p) s= p->ufmt? "NO" : "YES";
		else s= "UNKNOWN";
		b_char(s,a->inunf,a->inunflen);
	}
	if(a->inrecl && p) *a->inrecl=p->url;
	if(a->innrec && p && p->url)
		*a->innrec=((ftell(p->ufd) + p->url - 1)/p->url) + 1;
	if(a->inblank && p && p->ufmt)
	{
		b_char(p->ublnk? "ZERO" : "NULL",a->inblank,a->inblanklen);
	}
	return(OK);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.