Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001, Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 00038 #pragma ident "@(#) libf/fio/isatty.c 92.1 06/21/99 10:37:55" 00039 00040 /* 00041 * 00042 * isatty_ - determine if stream is associated with tty (async port) 00043 * 00044 * calling sequence: 00045 * 00046 * LOGICAL isatty, val 00047 * INTEGER lunit 00048 * val = isatty (lunit) 00049 * 00050 * where: 00051 * 00052 * val will be .TRUE. if lunit is associated with a 'tty' 00053 * 00054 * Note: the return value will not indicate if there is an error, 00055 * errno should be checked. 00056 * 00057 * Entry point __isatty_f90 is called for MIPS f77 or for f90 when 00058 * there is no compatibility module. 00059 * 00060 * Entry point isattyf90_ is called for MIPS f90 when there is a 00061 * compatibility module. 00062 * 00063 * Entry point isattyf90_8_ is called for MIPS f90 when there is a 00064 * compatibility module. 00065 * 00066 */ 00067 00068 #include <stdio.h> 00069 #include <foreign.h> 00070 #include <errno.h> 00071 #include <liberrno.h> 00072 #include <sys/types.h> 00073 #include <sys/stat.h> 00074 #include "fio.h" 00075 00076 extern _f_int __isatty_f90 (_f_int *u); 00077 extern _f_int isattyf90_(_f_int *u); 00078 extern _f_int8 isattyf90_8_(_f_int8 *u); 00079 00080 _f_int 00081 __isatty_f90 (_f_int *u) 00082 { 00083 return isattyf90_(u); 00084 } 00085 00086 _f_int 00087 isattyf90_(_f_int *u) 00088 { 00089 int rtrn, errval; 00090 unum_t unum; 00091 unit *cup; 00092 struct fiostate cfs; 00093 00094 unum = *u; 00095 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup); 00096 00097 errval = 0; 00098 if (cup == NULL && !GOOD_UNUM(unum)) 00099 _ferr(&cfs, FEIVUNIT, unum); /* invalid unit number */ 00100 00101 if (cup == NULL) 00102 errval = FEIVUNIT; /* unit is not open */ 00103 else if (cup->usysfd == -1) 00104 errval = FEIVUNIT; /* file is not disk-resident */ 00105 else { 00106 rtrn = isatty(cup->usysfd); 00107 } 00108 00109 STMT_END(cup, T_INQU, NULL, &cfs); /* unlock the unit */ 00110 00111 if (errval!=0) 00112 errno = errval; 00113 return (_btol(rtrn)); 00114 } 00115 00116 _f_int8 00117 isattyf90_8_(_f_int8 *u) 00118 { 00119 int rtrn, errval; 00120 unum_t unum; 00121 unit *cup; 00122 struct fiostate cfs; 00123 00124 unum = *u; 00125 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup); 00126 00127 errval = 0; 00128 if (cup == NULL && !GOOD_UNUM(unum)) 00129 _ferr(&cfs, FEIVUNIT, unum); /* invalid unit number */ 00130 00131 if (cup == NULL) 00132 errval = FEIVUNIT; /* unit is not open */ 00133 else if (cup->usysfd == -1) 00134 errval = FEIVUNIT; /* file is not disk-resident */ 00135 else { 00136 rtrn = isatty(cup->usysfd); 00137 } 00138 00139 STMT_END(cup, T_INQU, NULL, &cfs); /* unlock the unit */ 00140 00141 if (errval!=0) 00142 errno = errval; 00143 return (_btol(rtrn)); 00144 }