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/ru90.c 92.1 06/21/99 10:37:55"
00039
00040 #include <stdio.h>
00041 #include "fio.h"
00042 #include "f90io.h"
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 int
00076 _FRU(ControlListType *cilist, iolist_header *iolist, void *stck)
00077 {
00078 register int errf;
00079 register int errn;
00080 register int endf;
00081 register int iost;
00082 register int retval;
00083 register recn_t errarg;
00084 register unum_t unum;
00085 unit *cup;
00086 FIOSPTR css;
00087
00088
00089
00090
00091
00092 assert ( cilist->stksize >= sizeof(struct fiostate)/sizeof(long) );
00093
00094
00095 css = stck;
00096 errn = 0;
00097 errarg = 0;
00098 retval = IO_OKAY;
00099
00100 if (iolist->iolfirst == 0) {
00101 cup = css->f_cu;
00102 goto data_transfer;
00103 }
00104
00105
00106
00107
00108
00109
00110
00111 errf = (cilist->errflag || cilist->iostatflg);
00112 endf = (cilist->endflag || cilist->iostatflg);
00113 unum = *cilist->unit.wa;
00114 iost = cilist->dflag ? T_RDU : T_RSU;
00115
00116 STMT_BEGIN(unum, 0, iost, NULL, css, cup);
00117
00118 if (cup == NULL) {
00119 int stat;
00120
00121 cup = _imp_open(css, (cilist->dflag ? DIR : SEQ), UNF,
00122 unum, errf, &stat);
00123
00124
00125
00126
00127 if (cup == NULL) {
00128 errn = stat;
00129 goto handle_exception;
00130 }
00131 }
00132
00133
00134
00135 cup->uflag = (cilist->errflag ? _UERRF : 0) |
00136 (cilist->endflag ? _UENDF : 0) |
00137 (cilist->iostat_spec != NULL ? _UIOSTF : 0);
00138
00139
00140
00141 if (cup->useq && cup->uwrt != 0) {
00142 errn = FERDAFWR;
00143 goto handle_exception;
00144 }
00145
00146
00147
00148 cup->ueor_found = NO;
00149 cup->uwrt = 0;
00150 cup->ulastyp = DVTYPE_TYPELESS;
00151
00152 if (cilist->dflag) {
00153
00154 if (!cup->ok_rd_dir_unf)
00155 errn = _get_mismatch_error(errf, iost, cup, css);
00156 else {
00157 register recn_t recn;
00158
00159 recn = (recn_t) *cilist->rec_spec;
00160 errarg = recn;
00161 errn = _unit_seek(cup, recn, iost);
00162 }
00163 }
00164 else
00165 if (!cup->ok_rd_seq_unf)
00166 errn = _get_mismatch_error(errf, iost, cup, css);
00167
00168 if (errn != 0)
00169 goto handle_exception;
00170
00171
00172
00173
00174
00175
00176
00177 data_transfer:
00178
00179 errn = _xfer_iolist(css, cup, iolist, _rdunf);
00180
00181 if (errn != 0)
00182 goto handle_exception;
00183
00184 if (! iolist->iollast)
00185 return(IO_OKAY);
00186
00187
00188
00189
00190
00191
00192 finalization:
00193
00194 if (cup != NULL) {
00195 cup->ulrecl = cup->urecpos;
00196 cup->urecpos = 0;
00197 }
00198
00199 #ifdef _CRAYMPP
00200 if (css->f_shrdput) {
00201 css->f_shrdput = 0;
00202 _remote_write_barrier();
00203 }
00204 #endif
00205
00206 if (errn == 0 && cup->useq) {
00207
00208 if (cup->ufs == FS_FDC) {
00209
00210
00211
00212
00213
00214 if (cup->ublkd && !cup->ueor_found) {
00215 char dummy;
00216 int ubc = 0;
00217 struct ffsw fst;
00218
00219 (void) XRCALL(cup->ufp.fdc, readrtn)
00220 cup->ufp.fdc,
00221 CPTR2BP(&dummy), 0,
00222 &fst, FULL, &ubc);
00223
00224 switch (fst.sw_stat) {
00225 case FFERR:
00226 errn = fst.sw_error;
00227 break;
00228
00229 case FFEOF:
00230 cup->uend = PHYSICAL_ENDFILE;
00231 errn = FERDPEOF;
00232 break;
00233
00234 case FFEOD:
00235 if (cup->uend == BEFORE_ENDFILE) {
00236 cup->uend = LOGICAL_ENDFILE;
00237 errn = FERDPEOF;
00238 }
00239 else
00240 errn = FERDENDR;
00241 break;
00242 }
00243 }
00244 }
00245
00246 if (errn != 0)
00247 goto handle_exception;
00248 }
00249
00250 out_a_here:
00251
00252
00253
00254 if (cilist->iostat_spec != NULL)
00255 *cilist->iostat_spec = errn;
00256
00257 STMT_END(cup, TF_READ, NULL, css);
00258
00259 return(retval);
00260
00261
00262
00263
00264
00265
00266 handle_exception:
00267
00268 retval = (errn < 0) ? IO_END : IO_ERR;
00269
00270 if (retval == IO_ERR && ! cilist->errflag && ! cilist->iostatflg)
00271 _ferr(css, errn, errarg);
00272
00273 if (retval == IO_END && ! cilist->endflag && ! cilist->iostatflg)
00274 _ferr(css, errn, errarg);
00275
00276 if (cup == NULL)
00277 goto out_a_here;
00278
00279 goto finalization;
00280 }