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/ftell.c 92.1 06/18/99 19:52:04" 00039 00040 #include <errno.h> 00041 #include <ffio.h> 00042 #include <liberrno.h> 00043 #include "fio.h" 00044 #include "fstats.h" 00045 00046 extern long long __ftell64_f90( _f_int *unump); 00047 extern _f_int8 ftellf90_8_4_( _f_int *unump); 00048 extern _f_int8 ftellf90_8_( _f_int8 *unump); 00049 extern _f_int ftell90_ (_f_int *u); 00050 00051 /* 00052 * __ftell64_f90, _ftell 00053 * 00054 * ftell64_f90 - the ftell_ and ftell64_ functions use part of 00055 * the GETPOS routine to return the current file 00056 * position. 00057 * 00058 * A module interface will call these directly. 00059 * 00060 * calling sequence: 00061 * 00062 * INTEGER CURPOS, FTELL, LUNIT 00063 * CURPOS = ftell(LUNIT) 00064 * 00065 * or: 00066 * 00067 * INTEGER LUNIT 00068 * INTEGER*8 FTELL64, CURPOS64 00069 * CURPOS64 = ftell64(LUNIT) 00070 * 00071 * where: 00072 * 00073 * lunit: 00074 * - an open logical unit 00075 * 00076 * curpos or curpos64: 00077 * 00078 * - current offset in bytes from the start of the 00079 * file associated with that logical unit or a 00080 * negative system error code. 00081 * 00082 */ 00083 00084 long long 00085 __ftell64_f90( _f_int *unump) 00086 { 00087 return ftellf90_8_4_(unump); 00088 } 00089 00090 _f_int8 00091 ftellf90_8_4_( _f_int *unump) 00092 { 00093 _f_int8 pos; 00094 register unum_t unum; 00095 unit *cup; 00096 struct fiostate cfs; 00097 00098 unum = *unump; 00099 00100 /* lock the unit */ 00101 STMT_BEGIN(unum, 0, T_GETPOS, NULL, &cfs, cup); 00102 00103 /* 00104 * If not connected, do implicit open. Abort if open fails. 00105 */ 00106 if (cup == NULL) 00107 cup = _imp_open(&cfs, SEQ, UNF, unum, 0, NULL); 00108 00109 /* if direct access file */ 00110 if (cup->useq == 0) 00111 _ferr(&cfs, FEBIONDA, "GETPOS"); 00112 00113 /* 00114 * Make the appropriate call depending on file structure to 00115 * get the current file position. Postion routines are file 00116 * structure dependent. 00117 * 00118 * Simulate the IPOS=GETPOS(IUN) call 00119 */ 00120 pos = 0; 00121 switch( cup->ufs ) { 00122 00123 case FS_TEXT: 00124 case STD: 00125 pos = ftell64(cup->ufp.std); 00126 break; 00127 00128 case FS_FDC: 00129 _ferr(&cfs, FDC_ERR_NOSUP); 00130 break; 00131 00132 case FS_AUX: 00133 _ferr(&cfs, FEMIXAUX); 00134 break; 00135 default: 00136 _ferr(&cfs, FEINTFST); 00137 00138 } 00139 00140 getpos_done: 00141 STMT_END(cup, T_GETPOS, NULL, &cfs); 00142 return(pos); 00143 } 00144 00145 _f_int8 00146 ftellf90_8_( _f_int8 *unump) 00147 { 00148 _f_int8 pos; 00149 register unum_t unum; 00150 unit *cup; 00151 struct fiostate cfs; 00152 00153 unum = *unump; 00154 00155 /* lock the unit */ 00156 STMT_BEGIN(unum, 0, T_GETPOS, NULL, &cfs, cup); 00157 00158 /* 00159 * If not connected, do implicit open. Abort if open fails. 00160 */ 00161 if (cup == NULL) 00162 cup = _imp_open(&cfs, SEQ, UNF, unum, 0, NULL); 00163 00164 /* if direct access file */ 00165 if (cup->useq == 0) 00166 _ferr(&cfs, FEBIONDA, "GETPOS"); 00167 00168 /* 00169 * Make the appropriate call depending on file structure to 00170 * get the current file position. Postion routines are file 00171 * structure dependent. 00172 * 00173 * Simulate the IPOS=GETPOS(IUN) call 00174 */ 00175 pos = 0; 00176 switch( cup->ufs ) { 00177 00178 case FS_TEXT: 00179 case STD: 00180 pos = ftell64(cup->ufp.std); 00181 break; 00182 00183 case FS_FDC: 00184 _ferr(&cfs, FDC_ERR_NOSUP); 00185 break; 00186 00187 case FS_AUX: 00188 _ferr(&cfs, FEMIXAUX); 00189 break; 00190 default: 00191 _ferr(&cfs, FEINTFST); 00192 00193 } 00194 00195 getpos_done: 00196 STMT_END(cup, T_GETPOS, NULL, &cfs); 00197 return(pos); 00198 } 00199 00200 _f_int 00201 ftell90_(_f_int *u) 00202 { 00203 return( (_f_int) ftellf90_8_4_(u)); 00204 } 00205 00206 #if 0 00207 extern int ftell_(_f_int *u); 00208 int 00209 ftell_(_f_int *u) 00210 { 00211 return( (int) ftellf90_8_4_(u)); 00212 } 00213 #endif