writec.c
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/writec.c 92.3 06/21/99 10:37:55"
00039
00040
00041
00042
00043
00044 #include <errno.h>
00045 #include <foreign.h>
00046 #include <liberrno.h>
00047 #include "fio.h"
00048
00049 #define STATUS 4
00050
00051 static void __WRITEC();
00052
00053
00054
00055
00056 void
00057 WRITEC(
00058 _f_int *unump,
00059 _f_int *uda,
00060 _f_int *charsp,
00061 _f_int *status)
00062 {
00063 _f_int *statp;
00064
00065 statp = (_numargs() < STATUS) ? NULL : status;
00066
00067 __WRITEC(FULL, unump, uda, charsp, statp);
00068
00069 return;
00070 }
00071
00072
00073
00074
00075 void
00076 WRITECP(
00077 _f_int *unump,
00078 _f_int *uda,
00079 _f_int *charsp,
00080 _f_int *status)
00081 {
00082 _f_int *statp;
00083
00084 statp = (_numargs() < STATUS) ? NULL : status;
00085
00086 __WRITEC(PARTIAL, unump, uda, charsp, statp);
00087
00088 return;
00089 }
00090
00091
00092
00093
00094 static void
00095 __WRITEC(
00096 int fulp,
00097 _f_int *unump,
00098 _f_int *uda,
00099 _f_int *charsp,
00100 _f_int *status)
00101 {
00102 register int ret;
00103 register int errn;
00104 long chars;
00105 unum_t unum;
00106 unit *cup;
00107 struct fiostate cfs;
00108
00109 chars = *charsp;
00110 unum = *unump;
00111 errn = 0;
00112
00113 STMT_BEGIN(unum, 0, T_WSF, NULL, &cfs, cup);
00114
00115
00116
00117 if (cup == NULL) {
00118 int ostat;
00119
00120 cup = _imp_open(&cfs, SEQ, FMT, unum, (status != NULL),
00121 &ostat);
00122
00123 if (cup == NULL) {
00124 errn = ostat;
00125 goto done;
00126 }
00127 }
00128
00129 if (!cup->ok_wr_seq_fmt) {
00130 errn = _get_mismatch_error(1, T_WSF, cup, &cfs);
00131 goto done;
00132 }
00133
00134 cup->uwrt = 1;
00135
00136 if (cup->uend) {
00137
00138
00139
00140
00141 if (!cup->umultfil && !cup->uspcproc) {
00142 errn = FEWRAFEN;
00143 goto done;
00144 }
00145
00146
00147
00148
00149
00150 if ((cup->uend == LOGICAL_ENDFILE) && !(cup->uspcproc)) {
00151 if (XRCALL(cup->ufp.fdc, weofrtn)cup->ufp.fdc,
00152 &cup->uffsw) < 0) {
00153 errn = cup->uffsw.sw_error;
00154 goto done;
00155 }
00156 }
00157 cup->uend = BEFORE_ENDFILE;
00158 }
00159
00160 ret = _fwch(cup, (long *) uda, chars, fulp);
00161
00162 if ( ret == IOERR ) {
00163 errn = errno;
00164 goto done;
00165 }
00166
00167 if (status != NULL)
00168 *status = 0;
00169
00170 done:
00171 if (errn != 0) {
00172 if (status == NULL)
00173 _ferr(&cfs, errn);
00174 else
00175 *status = errn;
00176 }
00177
00178 STMT_END(cup, TF_WRITE, NULL, &cfs);
00179
00180 return;
00181 }