Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
00074 errno=FEFMTTIV;
00075
00076
00077
00078
00079
00080
00081 return(-1);
00082 }
00083
00084
00085 if (!cup->ok_wr_dir_unf) {
00086
00087
00088 errno = FENOWRIT;
00089 return(-1);
00090 }
00091 if (cup->ufs != STD) {
00092
00093 errno = FDC_ERR_NOSTRM;
00094 return(-1);
00095 }
00096
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
00129 errno=FEFMTTIV;
00130
00131
00132
00133
00134
00135
00136 return(-1);
00137 }
00138
00139
00140 if (!cup->ok_wr_dir_unf) {
00141
00142
00143 errno = FENOWRIT;
00144 return(-1);
00145 }
00146 if (cup->ufs != STD) {
00147
00148 errno = FDC_ERR_NOSTRM;
00149 return(-1);
00150 }
00151
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 }