VOID spol_gblk(VOID) { BYTE handle; #if GEMDOS handle = Fopen( (const char *)spol_path, 0x0000 ); #else handle = dos_open( spol_path, 0x0000 ); #endif if (handle) { #if GEMDOS Fseek( spol_fcnt, handle, 0x0000 ); spol_cntr = (WORD)Fread( handle, SPLSIZE, (VOID *)spol_pbuf ); #else dos_lseek( handle, 0x0000, spol_fcnt ); spol_cntr = dos_read( handle, SPLSIZE, spol_pbuf ); #endif if ( spol_cntr != SPLSIZE ) spol_sts = TRUE; spol_fcnt += LW( spol_cntr ); #if GEMDOS Fclose( handle ); #else dos_close( handle ); #endif spol_ptr = spol_bufr; } else { spol_sts = TRUE; spol_cntr = 0; } }
COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) { sft FAR *s; ULONG lrx; /* Test for invalid mode */ if (mode < 0 || mode > 2) return DE_INVLDFUNC; /* Test that the handle is valid */ if (hndl < 0) return DE_INVLDHNDL; /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) return DE_INVLDHNDL; lpCurSft = (sfttbl FAR *) s; if (s->sft_flags & SFT_FSHARED) { if (mode == 2) { /* seek from end of file */ int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, 0); *set_pos = s->sft_posit; return SUCCESS; } if (mode == 0) { s->sft_posit = new_pos; *set_pos = new_pos; return SUCCESS; } if (mode == 1) { s->sft_posit += new_pos; *set_pos = s->sft_posit; return SUCCESS; } return DE_INVLDFUNC; } /* Do special return for character devices */ if (s->sft_flags & SFT_FDEVICE) { *set_pos = 0l; return SUCCESS; } else { *set_pos = dos_lseek(s->sft_status, new_pos, mode); if ((LONG) * set_pos < 0) return (int)*set_pos; else return SUCCESS; } }
BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) { sft FAR *s; LONG lPosit; COUNT nWritten; psp FAR *p = MK_FP(cu_psp, 0); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Get the SFT block that contains the SFT */ if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) return FALSE; /* If this is not opened another error */ if (s->sft_count == 0) return FALSE; /* Now update the fcb and compute where we need to position */ /* to. */ lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) * lpFcb->fcb_recsiz; if (dos_lseek(s->sft_status, lPosit, 0) < 0) { *nErrorCode = FCB_ERR_EOF; return FALSE; } if (s->sft_flags & SFT_FSHARED) { nWritten = Remote_RW(REM_WRITE, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode); } else { /* Do the read */ nWritten = dos_write(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); } /* Now find out how we will return and do it. */ if (nWritten == lpFcb->fcb_recsiz) { lpFcb->fcb_fsize = dos_getcufsize(s->sft_status); FcbNextRecord(lpFcb); *nErrorCode = FCB_SUCCESS; return TRUE; } else if (nWritten <= 0) { *nErrorCode = FCB_ERR_WRITE; return TRUE; } *nErrorCode = FCB_ERR_WRITE; return FALSE; }
BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) { sft FAR *s; LONG lPosit; COUNT nRead; psp FAR *p = MK_FP(cu_psp, 0); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Get the SFT block that contains the SFT */ if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) return FALSE; /* If this is not opened another error */ if (s->sft_count == 0) return FALSE; /* Now update the fcb and compute where we need to position */ /* to. */ lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) * lpFcb->fcb_recsiz; if (dos_lseek(s->sft_status, lPosit, 0) < 0) { *nErrorCode = FCB_ERR_EOF; return FALSE; } if (s->sft_flags & SFT_FSHARED) { nRead = Remote_RW(REM_READ, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode); } else { /* Do the read */ nRead = dos_read(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); } /* Now find out how we will return and do it. */ if (nRead == lpFcb->fcb_recsiz) { *nErrorCode = FCB_SUCCESS; FcbNextRecord(lpFcb); return TRUE; } else if (nRead < 0) { *nErrorCode = FCB_ERR_EOF; return TRUE; } else if (nRead == 0) { *nErrorCode = FCB_ERR_NODATA; return FALSE; } else { COUNT nIdx, nCount; BYTE FAR *lpDta; nCount = lpFcb->fcb_recsiz - nRead; lpDta = (BYTE FAR *) & (p->ps_dta[nRead]); for (nIdx = 0; nIdx < nCount; nIdx++) *lpDta++ = 0; *nErrorCode = FCB_ERR_EOF; FcbNextRecord(lpFcb); return FALSE; } }