2003-11-13 00:12:56 +00:00
|
|
|
;
|
2000-05-28 13:40:48 +00:00
|
|
|
; Ullrich von Bassewitz, 31.05.1998
|
|
|
|
;
|
|
|
|
; Several small file stream functions
|
|
|
|
;
|
|
|
|
|
|
|
|
.export _clearerr, _feof, _ferror, _fileno, _fflush
|
|
|
|
.import return0
|
|
|
|
.importzp ptr1
|
|
|
|
|
2002-11-25 21:59:35 +00:00
|
|
|
.include "_file.inc"
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Get the FILE* parameter, check if the file is open
|
|
|
|
;
|
|
|
|
|
|
|
|
getf: sta ptr1
|
|
|
|
stx ptr1+1
|
2003-12-03 10:15:33 +00:00
|
|
|
ldy #_FILE::f_flags
|
2002-11-25 21:59:35 +00:00
|
|
|
lda (ptr1),y ; get f->f_flags
|
|
|
|
and #_FOPEN ; file open?
|
|
|
|
beq @L1 ; jump if no
|
|
|
|
clc ; ok
|
2000-05-28 13:40:48 +00:00
|
|
|
rts
|
|
|
|
@L1: sec
|
|
|
|
rts
|
|
|
|
|
|
|
|
;
|
|
|
|
; void clearerr (FILE* f);
|
|
|
|
;
|
|
|
|
|
|
|
|
_clearerr:
|
|
|
|
jsr getf
|
|
|
|
bcs err
|
|
|
|
lda (ptr1),y
|
2002-11-25 21:59:35 +00:00
|
|
|
and #<~(_FEOF | _FERROR)
|
2000-05-28 13:40:48 +00:00
|
|
|
sta (ptr1),y
|
|
|
|
err: rts
|
|
|
|
|
|
|
|
;
|
|
|
|
; int feof (FILE* f);
|
|
|
|
;
|
|
|
|
|
|
|
|
_feof:
|
|
|
|
jsr getf
|
|
|
|
; bcs err
|
|
|
|
lda (ptr1),y
|
2002-11-25 21:59:35 +00:00
|
|
|
and #_FEOF
|
2000-05-28 13:40:48 +00:00
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
|
|
|
;
|
|
|
|
; int ferror (FILE* f);
|
|
|
|
;
|
|
|
|
|
|
|
|
_ferror:
|
|
|
|
jsr getf
|
|
|
|
; bcs err
|
|
|
|
lda (ptr1),y
|
2002-11-25 21:59:35 +00:00
|
|
|
and #_FERROR
|
2000-05-28 13:40:48 +00:00
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
|
|
|
;
|
|
|
|
; int fileno (FILE* f);
|
|
|
|
;
|
|
|
|
|
|
|
|
_fileno:
|
|
|
|
jsr getf
|
|
|
|
; bcs err
|
2004-05-12 13:16:36 +00:00
|
|
|
ldy #_FILE::f_fd
|
2000-05-28 13:40:48 +00:00
|
|
|
lda (ptr1),y
|
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
|
|
|
;
|
|
|
|
; int __fastcall__ fflush (FILE* f);
|
|
|
|
;
|
|
|
|
|
|
|
|
_fflush = return0
|
|
|
|
|
|
|
|
|