2 ; Ullrich von Bassewitz, 31.05.1998
4 ; Data for the stdio file stream.
6 ; Be sure to keep the value priority of closeallstreams lower than that of
7 ; closeallfiles (which is the low level POSIX counterpart and must be
8 ; called after closeallstreams).
10 .export __filetab, _stdin, _stdout, _stderr
11 .destructor closeallstreams, 16
17 ;----------------------------------------------------------------------------
18 ; Close all files on exit
22 ldy #((FOPEN_MAX - 1) * _FILE_size)
23 loop: sty index ; Save the index
24 lda __filetab + _FILE_f_flags,y ; Load file flags
25 and #_FOPEN ; Is it open?
26 beq next ; jump if closed
30 lda __filetab + _FILE_f_fd,y
46 ;----------------------------------------------------------------------------
52 .byte 0, _FOPEN ; stdin
53 .byte 1, _FOPEN ; stdout
54 .byte 2, _FOPEN ; stderr
56 .byte 0, _FCLOSED ; free slot
60 ; Standard file descriptors
63 .word __filetab + (STDIN_FILENO * _FILE_size)
66 .word __filetab + (STDOUT_FILENO * _FILE_size)
69 .word __filetab + (STDERR_FILENO * _FILE_size)
72 ; Temp storage for closeallstreams