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/ttynam.c 92.3 11/16/99 15:43:33" 00039 00040 /* 00041 * Return name of tty port associated with lunit 00042 * 00043 * calling sequence: 00044 * 00045 * character*19 string, ttynam 00046 * string = ttynam (lunit) 00047 * 00048 * where: 00049 * 00050 * the character string will be filled with the name of 00051 * the port, preceded with '/dev/', and blank padded. 00052 * (19 is the max length ever required) 00053 */ 00054 00055 #include <stdio.h> 00056 #include <foreign.h> 00057 #include <errno.h> 00058 #include <liberrno.h> 00059 #include <sys/types.h> 00060 #include <sys/stat.h> 00061 #include <stdlib.h> 00062 #include "fio.h" 00063 00064 extern void __ttynam_f90 (char *name, int strlen, int *u); 00065 extern void ttynamf90_(char *name, _f_int strlen, int *u); 00066 extern void ttynamf90_8_(char *name, _f_int strlen, _f_int8 *u); 00067 00068 void 00069 __ttynam_f90 (char *name, int strlen, int *u) 00070 { 00071 ttynamf90_(name,strlen,u); 00072 return; 00073 } 00074 00075 void 00076 ttynamf90_(char *name, int strlen, int *u) 00077 { 00078 int rtrn, errval; 00079 unum_t unum; 00080 unit *cup; 00081 struct fiostate cfs; 00082 char *t = NULL; 00083 00084 #if defined(_LITTLE_ENDIAN) 00085 char *ttyname(int); 00086 #endif 00087 unum = *u; 00088 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup); 00089 00090 errval = 0; 00091 if (cup == NULL && !GOOD_UNUM(unum)) 00092 _ferr(&cfs, FEIVUNIT, unum); /* invalid unit number */ 00093 00094 if (cup == NULL) 00095 errval = FEIVUNIT; /* unit is not open */ 00096 else if (cup->usysfd == -1) 00097 errval = FEIVUNIT; /* file is not disk-resident */ 00098 else { 00099 t = ttyname(cup->usysfd); 00100 } 00101 00102 STMT_END(cup, T_INQU, NULL, &cfs); /* unlock the unit */ 00103 00104 if (t==NULL) 00105 t=""; 00106 _b_char(t, name, strlen); 00107 return; 00108 } 00109 00110 #if defined(_LITTLE_ENDIAN) 00111 void 00112 ttynam_ (char *name, int strlen, int *u) 00113 { 00114 ttynamf90_(name,strlen,u); 00115 return; 00116 } 00117 #endif 00118 00119 void 00120 ttynamf90_8_(char *name, int strlen, _f_int8 *u) 00121 { 00122 int rtrn, errval; 00123 unum_t unum; 00124 unit *cup; 00125 struct fiostate cfs; 00126 char *t = NULL; 00127 00128 #if defined(_LITTLE_ENDIAN) && !defined(__sv2) 00129 char *ttyname(int); 00130 #endif 00131 unum = *u; 00132 STMT_BEGIN(unum, 0, T_INQU, NULL, &cfs, cup); 00133 00134 errval = 0; 00135 if (cup == NULL && !GOOD_UNUM(unum)) 00136 _ferr(&cfs, FEIVUNIT, unum); /* invalid unit number */ 00137 00138 if (cup == NULL) 00139 errval = FEIVUNIT; /* unit is not open */ 00140 else if (cup->usysfd == -1) 00141 errval = FEIVUNIT; /* file is not disk-resident */ 00142 else { 00143 t = ttyname(cup->usysfd); 00144 } 00145 00146 STMT_END(cup, T_INQU, NULL, &cfs); /* unlock the unit */ 00147 00148 if (t==NULL) 00149 t=""; 00150 _b_char(t, name, strlen); 00151 return; 00152 }