2014-10-13 04:12:09 +00:00
|
|
|
; stdio.h
|
|
|
|
; Definitions for stream input/output.
|
|
|
|
|
|
|
|
_NFILE equ 20
|
|
|
|
|
|
|
|
; Bufferisation type to be used as 3rd argument for "setvbuf" function
|
|
|
|
_IOFBF equ 0
|
|
|
|
_IOLBF equ 1
|
|
|
|
_IONBF equ 2
|
|
|
|
|
|
|
|
; "flags" bits definitions
|
|
|
|
_F_RDWR equ 00003h ; Read/write flag
|
|
|
|
_F_READ equ 00001h ; Read only file
|
|
|
|
_F_WRIT equ 00002h ; Write only file
|
|
|
|
_F_BUF equ 00004h ; Malloc'ed Buffer data
|
|
|
|
_F_LBUF equ 00008h ; line-buffered file
|
|
|
|
_F_ERR equ 00010h ; Error indicator
|
|
|
|
_F_EOF equ 00020h ; EOF indicator
|
|
|
|
_F_BIN equ 00040h ; Binary file indicator
|
|
|
|
_F_IN equ 00080h ; Data is incoming
|
|
|
|
_F_OUT equ 00100h ; Data is outgoing
|
|
|
|
_F_TERM equ 00200h ; File is a terminal
|
|
|
|
|
|
|
|
; End-of-file constant definition
|
|
|
|
EOF equ (-1) ; End of file indicator
|
|
|
|
|
|
|
|
; Default buffer size use by "setbuf" function
|
|
|
|
STDIO_BUFSIZ equ 512 ; Buffer size for stdio
|
|
|
|
|
|
|
|
; Size of an arry large enough to hold a temporary file name string
|
|
|
|
L_ctermid equ 5 ; CON: plus null byte
|
|
|
|
P_tmpdir equ "" ; temporary directory
|
|
|
|
L_tmpnam equ 13 ; tmpnam buffer size
|
|
|
|
|
|
|
|
; Constants to be used as 3rd argument for "fseek" function
|
|
|
|
SEEK_CUR equ 1
|
|
|
|
SEEK_END equ 2
|
|
|
|
SEEK_SET equ 0
|
|
|
|
|
|
|
|
; Number of unique file names that shall be generated by "tmpnam" function
|
|
|
|
TMP_MAX equ 0FFFFh
|
|
|
|
|
|
|
|
; Definition of the control structure for streams
|
|
|
|
FILE struc
|
|
|
|
level dw ? ; fill/empty level of buffer
|
|
|
|
flags dw ? ; File status flags
|
|
|
|
fd db ? ; File descriptor
|
|
|
|
hold db ? ; Ungetc char if no buffer
|
|
|
|
_bsize dw ? ; Buffer size. Yes, calling it just "bsize" crashes TASM.
|
[JWasm move] Fix improper structure declarations
Really, Borland? You considered it necessary to add directives for object-
oriented programming (in Assembly!) and convenience features like bitfield
records or PUSHSTATE/POPSTATE, yet you never came up with the actually
*helpful* idea of just adding a simple basic pointer data type that depends
on the current memory model's data size?
Like, something like DP... oh wait, that's already taken, as an alias for
DF, the 48-bit 80386 far pointer type.
And this, exactly, is the problem with assemblers. The language itself is
undefined beyond the instructions themselves, but it's obviously very
uncomfortable to program anything with just that, so your assembler needs to
add custom directives on top of that, and of course everyone has different
ideas of the features and use cases that should (and should not) be covered by
syntax. (I'm looking especially at you, NASM.)
And then one of those developers sells their compiler division to a different
company, which then subsequently discontinues all products without ever
releasing the source code, trapping their nice extensions in a single
executable for a single platform that is not even legally available anymore.
tl;dr: http://xkcd.com/927/
2014-11-20 03:55:57 +00:00
|
|
|
if LDATA
|
|
|
|
buffer dd ? ; Data transfer buffer
|
|
|
|
curp dd ? ; Current active pointer
|
|
|
|
else
|
|
|
|
buffer dw ? ; Data transfer buffer
|
|
|
|
curp dw ? ; Current active pointer
|
|
|
|
endif
|
2014-10-13 04:12:09 +00:00
|
|
|
istemp dw ? ; Temporary file indicator
|
|
|
|
token dw ? ; Used for validity checking
|
2014-11-06 05:45:35 +00:00
|
|
|
FILE ends
|
2014-10-13 04:12:09 +00:00
|
|
|
|
2014-10-18 00:20:40 +00:00
|
|
|
FOPEN_MAX equ _NFILE
|
|
|
|
SYS_OPEN equ _NFILE
|
2014-10-13 04:12:09 +00:00
|
|
|
FILENAME_MAX equ 80
|