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/usdumplock.c 92.1 06/18/99 18:38:26" 00039 00040 #include <sys/types.h> 00041 #include <ulocks.h> 00042 #include <stdio.h> 00043 #include <stdlib.h> 00044 #include "fio.h" 00045 #include <string.h> 00046 00047 extern int32 __usdumplock_f90(ulock_t *l, int32 *u, char *str, int32 len); 00048 extern _f_int usdumplockf90_(ulock_t *l, _f_int *u, char *str, int len); 00049 extern _f_int4 usdumplockf90_4_8_4_(ulock_t *l, _f_int4 *u, char *str, int len); 00050 extern _f_int8 usdumplockf90_8_(ulock_t *l, _f_int8 *u, char *str, int len); 00051 00052 int32 00053 __usdumplock_f90(ulock_t *l, int32 *u, char *str, int32 len) 00054 { 00055 return usdumplockf90_(l, u, str, len); 00056 } 00057 00058 _f_int 00059 usdumplockf90_(ulock_t *l, _f_int *u, char *str, int len) 00060 { 00061 char *buff; 00062 unit *cup; 00063 FILE *fd; 00064 unum_t unum; 00065 00066 unum = *u; 00067 cup = _get_cup(unum); 00068 if (unum < 0 || !cup) 00069 return((errno=FEIVUNIT)); 00070 00071 if (cup->ufmt == NO && cup->useq == NO) { 00072 00073 /* not formatted and not sequential */ 00074 errno=FEFMTTIV; 00075 00076 /* 00077 * A formatted read or write is not allowed on an 00078 * unformatted file. We really want to say operation 00079 * only allowed on formatted sequential files 00080 */ 00081 return(-1); 00082 } 00083 00084 /* check to see if write is allowed on file. */ 00085 if (!cup->ok_wr_dir_unf) { 00086 00087 /* write not allowed. */ 00088 errno = FENOWRIT; 00089 return(-1); 00090 } 00091 if (cup->ufs != STD) { 00092 /* not an "stdio" file */ 00093 errno = FDC_ERR_NOSTRM; /* NOT the right msg - DLAI */ 00094 return(-1); 00095 } 00096 /* get the FILE */ 00097 fd = cup->ufp.std; 00098 buff = (char *) malloc( len + 1 ); 00099 strncpy( buff, str, len ); 00100 buff[len] = '\0'; 00101 usdumplock( *l, fd, buff ); 00102 free( buff ); 00103 return(0); 00104 } 00105 00106 _f_int4 00107 usdumplockf90_4_8_4_(ulock_t *l, _f_int *u, char *str, int len) 00108 { 00109 _f_int8 unum = *u; 00110 return (_f_int4)usdumplockf90_8_(l,&unum,str,len); 00111 } 00112 00113 _f_int8 00114 usdumplockf90_8_(ulock_t *l, _f_int8 *u, char *str, int len) 00115 { 00116 char *buff; 00117 unit *cup; 00118 FILE *fd; 00119 unum_t unum; 00120 00121 unum = *u; 00122 cup = _get_cup(unum); 00123 if (unum < 0 || !cup) 00124 return((errno=FEIVUNIT)); 00125 00126 if (cup->ufmt == NO && cup->useq == NO) { 00127 00128 /* not formatted and not sequential */ 00129 errno=FEFMTTIV; 00130 00131 /* 00132 * A formatted read or write is not allowed on an 00133 * unformatted file. We really want to say operation 00134 * only allowed on formatted sequential files 00135 */ 00136 return(-1); 00137 } 00138 00139 /* check to see if write is allowed on file. */ 00140 if (!cup->ok_wr_dir_unf) { 00141 00142 /* write not allowed. */ 00143 errno = FENOWRIT; 00144 return(-1); 00145 } 00146 if (cup->ufs != STD) { 00147 /* not an "stdio" file */ 00148 errno = FDC_ERR_NOSTRM; /* NOT the right msg - DLAI */ 00149 return(-1); 00150 } 00151 /* get the FILE */ 00152 fd = cup->ufp.std; 00153 buff = (char *) malloc( len + 1 ); 00154 strncpy( buff, str, len ); 00155 buff[len] = '\0'; 00156 usdumplock( *l, fd, buff ); 00157 free( buff ); 00158 return(0); 00159 }