Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
usdumpsema.c
Go to the documentation of this file.
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/usdumpsema.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 __usdumpsema_f90(usema_t **s, int32 *u, char *str, int32 len);
00048 extern _f_int usdumpsemaf90_(usema_t **s, _f_int *u, char *str, int len);
00049 extern _f_int4 usdumpsemaf90_4_8_4_(usema_t **s, _f_int4 *u, char *str, int len);
00050 extern _f_int8 usdumpsemaf90_8_(usema_t **s, _f_int8 *u, char *str, int len);
00051 
00052 int32
00053 __usdumpsema_f90(usema_t **s, int32 *u, char *str, int32 len)
00054 {
00055         return usdumpsemaf90_(s,u,str,len);
00056 }
00057 
00058 _f_int
00059 usdumpsemaf90_(usema_t **s, _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                 /* A formatted read or write is not allowed on an
00077                  * unformatted file.  We really want to say operation
00078                  * only allowed on formatted sequential files
00079                  */
00080                 return(-1);
00081         }
00082 
00083 /*      check to see if file is write-able */
00084         if (!cup->ok_wr_dir_unf) {
00085 
00086                 /* not writeable */
00087                 errno   = FENOWRIT;
00088                 return(-1);
00089         }
00090         if (cup->ufs != STD) {
00091 
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         usdumpsema( *s, fd, buff );
00102         free( buff );
00103         return(0);
00104 }
00105 
00106 _f_int4
00107 usdumpsemaf90_4_8_4_(usema_t **s, _f_int4 *u, char *str, int len)
00108 {
00109         _f_int8         unum = *u;
00110         return (_f_int4)usdumpsemaf90_8_(s,&unum,str,len);
00111 }
00112 
00113 _f_int8
00114 usdumpsemaf90_8_(usema_t **s, _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                 /* A formatted read or write is not allowed on an
00132                  * unformatted file.  We really want to say operation
00133                  * only allowed on formatted sequential files
00134                  */
00135                 return(-1);
00136         }
00137 
00138 /*      check to see if file is write-able */
00139         if (!cup->ok_wr_dir_unf) {
00140 
00141                 /* not writeable */
00142                 errno   = FENOWRIT;
00143                 return(-1);
00144         }
00145         if (cup->ufs != STD) {
00146 
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         usdumpsema( *s, fd, buff );
00157         free( buff );
00158         return(0);
00159 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines