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/setpos.c 92.1 06/18/99 18:41:02" 00039 00040 #include <foreign.h> 00041 #include <errno.h> 00042 #include <liberrno.h> 00043 #include "fio.h" 00044 00045 /* 00046 * SETPOS 00047 * 00048 * Seek to a position in the file. If the position passed is 00049 * -1, seek to the end of the file. The position is a byte offset 00050 * within the file, stored in the style of C character pointers: 00051 * 00052 * bits 0-2 - byte offset within the word. 00053 * bits 3-63 - word offset within the file. 00054 * 00055 * Can be called as: 00056 * 00057 * CALL SETPOS(IUN, PA) 00058 * CALL SETPOS(IUN, LEN, PA [,ISTAT] ) 00059 */ 00060 00061 #define OLD 2 /* number of arguments in old SETPOS version */ 00062 #define STAT 4 /* argument number for optional stat parameter */ 00063 00064 void 00065 SETPOS( 00066 _f_int *unump, 00067 _f_int *len, 00068 _f_int *pa, 00069 _f_int *stat) 00070 { 00071 register int errn; 00072 register int narg; 00073 register unum_t unum; 00074 unit *cup; 00075 struct fiostate cfs; 00076 00077 unum = *unump; 00078 00079 STMT_BEGIN(unum, 0, T_SETPOS, NULL, &cfs, cup); /* lock the unit */ 00080 /* 00081 * If not connected, do an implicit open. Abort if the open fails. 00082 */ 00083 if (cup == NULL) 00084 cup = _imp_open(&cfs, SEQ, UNF, unum, 0, NULL); 00085 00086 if (cup->useq == 0) /* If direct access file */ 00087 _ferr(&cfs, FEBIONDA, "SETPOS"); 00088 00089 /* 00090 * Do the setpos. 00091 */ 00092 narg = _numargs(); 00093 00094 if ( narg == OLD ) { 00095 errn = _setpos(&cfs, cup, len, 1); 00096 } 00097 else { 00098 if (*len <= 0) 00099 errn = FEBIOSNT; 00100 else 00101 errn = _setpos(&cfs, cup, pa, *len); 00102 } 00103 00104 if (narg >= STAT) 00105 *stat = errn; 00106 else if (errn != OK) 00107 _ferr(&cfs, errn); 00108 00109 STMT_END(cup, T_SETPOS, NULL, &cfs); /* unlock the unit */ 00110 }