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