|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
Data Structures | |
| struct | rec |
| struct | bfile |
Macros | |
| #define | __NOLIBBASE__ |
| #define | DOS_BASE_NAME dosbase |
| #define | FLAGSVALID(f) |
Functions | |
| void | dofileoutput (void) |
| void | dofileinput (void) |
| void | doloc (void) |
| void | doeof (void) |
| void | dodbufflen (void) |
| void | fileiolib_codeinit (void) |
| void | racchk (void) |
| void | fileiolib_fchk (void) |
| void | dbchk (void) |
| ULONG | doexists (const UBYTE *name, struct Library *dosbase) |
| Exists(Filename$): the size of a file. | |
| void | dowritemem (ULONG fileno, struct bfile *f, const UBYTE *mem, ULONG len, struct Library *dosbase) |
| WriteMem File#,Address,Length: write memory to a file. | |
| void | doreadmem (ULONG fileno, struct bfile *f, UBYTE *mem, ULONG len, struct Library *dosbase) |
| ReadMem File#,Address,Length: read from a file into memory. | |
| ULONG | dolof (struct bfile *f, struct Library *dosbase) |
| Lof(File#): the length of the file. | |
| void | dofileseek (ULONG fileno, struct bfile *f, ULONG where, struct Library *dosbase) |
| FileSeek File#,Position: set the position in the file. | |
| void | dofreefile (struct Library *dosbase) |
| CloseFile File#, and _free of a File object: close the file. | |
| BB_BOOL | doopenfile (struct bfile *f, UBYTE *name, const ULONG *lens, struct Library *dosbase) |
| OpenFile(File#,Filename$): open a file for reading and writing. | |
| BB_BOOL | doreadfile (struct bfile *f, UBYTE *name, const ULONG *lens, struct Library *dosbase) |
| ReadFile(File#,Filename$): open an existing file. | |
| BB_BOOL | dowritefile (struct bfile *f, UBYTE *name, const ULONG *lens, struct Library *dosbase) |
| WriteFile(File#,Filename$): create a new file. | |
| static void | dorecord (UWORD n, const UBYTE *args) |
| Fields File#,Var1[,Var2...]: the variables of a record. | |
| void | doput (ULONG fileno, UWORD record, struct Library *dosbase) |
| Put File#,Record: write the fields of a record. | |
| void | doget (ULONG fileno, UWORD record, struct Library *dosbase) |
| Get File#,Record: read the fields of a record. | |
| void | dokillfile (const UBYTE *name, struct Library *dosbase) |
| KillFile Filename$: delete a file. | |
| static void | myflush (struct bfile *f, struct Library *dosbase) |
| static ULONG | mywrite (ULONG result, struct bfile *f, const UBYTE *src, ULONG len, struct Library *dosbase) |
| static ULONG | myread (ULONG result, struct bfile *f, UBYTE *dst, ULONG len, struct Library *dosbase) |
| static ULONG | myseek (ULONG result, struct bfile *f, ULONG where, LONG mode, struct Library *dosbase) |
| static void | dodbufflen_c (ULONG n) |
| DosBuffLen Bytes: the size of the buffer of files opened later. | |
| BLITZ_ALIAS (dodbufflen, dodbufflen_c) | |
| static BB_BOOL | doeof_c (ULONG fileno, struct bfile *f, struct Library *dosbase) |
| Eof(File#): at the end of the file? | |
| BLITZ_ALIAS (doeof, doeof_c) | |
| static ULONG | doloc_c (const struct bfile *f) |
| Loc(File#): the position in the file. | |
| BLITZ_ALIAS (doloc, doloc_c) | |
| static void | codeinit_c (struct Library *dos) |
| static void | freefile (struct bfile *f, struct Library *dosbase) |
| static BB_BOOL | realopen (WORD mode, struct bfile *f, UBYTE *name, const ULONG *lens, struct Library *dosbase) |
| static void | transdata (int put, ULONG fileno, UWORD record, struct Library *dosbase) |
| void | inputhandler (void) |
| void | outputhandler (void) |
| static void | dofileinput_c (void) |
| FileInput File#: read the input from a file. | |
| BLITZ_ALIAS (dofileinput, dofileinput_c) | |
| static void | dofileoutput_c (void) |
| FileOutput File#: send the output to a file. | |
| BLITZ_ALIAS (dofileoutput, dofileoutput_c) | |
| static ULONG | inchar_c (void) |
| static ULONG | instring_c (UBYTE *buf, ULONG max) |
| static ULONG | outchar_c (UBYTE c) |
| static ULONG | outstring_c (const UBYTE *s, ULONG len) |
| static void | outcstring_c (const UBYTE *s) |
| void | inhandle2 (void) |
| void | outhandle2 (void) |
| void | outhandle3 (void) |
| void | handlers (void) |
| static void | racchk_c (void) |
| static void | fchk_c (const struct bfile *f) |
| static void | dbchk_c (ULONG n) |
Variables | |
| static struct Library * | dosbase_g |
| static UBYTE | iobyte |
| static struct bfile * | infile |
| static struct bfile * | outfile |
| static ULONG | doslen = 2048 |
| static const char | mess1 [] = "Invalid Input File" |
| static const char | mess2 [] = "Invalid Output File" |
| static const char | mess3 [] = "Can't Find Record" |
| static const char | mess6 [] = "Can't FileSeek Position" |
| static const char | mess7 [] = "Error Reading/Writing File" |
| #define __NOLIBBASE__ |
| #define DOS_BASE_NAME dosbase |
| BLITZ_ALIAS | ( | dodbufflen | , |
| dodbufflen_c | ) |
| BLITZ_ALIAS | ( | dofileinput | , |
| dofileinput_c | ) |
| BLITZ_ALIAS | ( | dofileoutput | , |
| dofileoutput_c | ) |
|
static |
| void dbchk | ( | void | ) |
|
static |
| void dodbufflen | ( | void | ) |
|
static |
DosBuffLen Bytes: the size of the buffer of files opened later.
MOVE.l d0,doslen (default 2048). Errors (debugger, dbchk): "Illegal Dos Buffer Length" above 32767.
| n | d0: the size in bytes |
| void doeof | ( | void | ) |
Eof(File#): at the end of the file?
False while the position is in the buffer's valid bytes; otherwise true if a dos seek one byte further fails (else it seeks back). Fixed (#144): the failed seek leaves the position as it was (the original's Loc and Lof were 1 too high afterwards). The original keeps a0/a1 when the position is in the buffer. Errors (debugger, fchk): "Non-Existant File".
| fileno | d0: File# |
| f | a2: the file (!libs fileiolib,$1280) |
| dosbase | a6: dos.library |
| ULONG doexists | ( | const UBYTE * | name, |
| struct Library * | dosbase ) |
Exists(Filename$): the size of a file.
Lock, Examine into a FileInfoBlock from memlib globalloc (not checked, #139), UnLock. BUG(orig) (#143), won't fix: an empty file gives 0 like a missing one (Exists returns the length, the manual says so, and programs use it as the length). Fixed (#1026): -1 for every directory type, 0 if Examine fails (the original: -1 only for type 2, and the FileInfoBlock's contents after a failed Examine).
| void dofileinput | ( | void | ) |
|
static |
FileInput File#: read the input from a file.
a3 = the file; it becomes the input file and inputhandler the input handler of inputoutputlib (setin, keeps d1/a1). The handler reads one character (-1 at the end) or a line up to CR/LF. Errors (handler, in the normal code, DIFF): "Invalid Input File", "Error Reading/Writing File".
| void dofileoutput | ( | void | ) |
|
static |
FileOutput File#: send the output to a file.
a3 = the file; it becomes the output file and outputhandler the output handler of inputoutputlib (setout, keeps d1/a1). Errors (handler, in the normal code, DIFF): "Invalid Output File", "Error Reading/Writing File".
| void dofileseek | ( | ULONG | fileno, |
| struct bfile * | f, | ||
| ULONG | where, | ||
| struct Library * | dosbase ) |
FileSeek File#,Position: set the position in the file.
Inside the buffer only the position in it changes, otherwise the buffer is flushed and dos Seek called. Errors: "Can't FileSeek Position" if Seek fails (in the normal code, DIFF: the original jumps into the error check area); debugger (fchk): "Non-Existant File".
| fileno | d0: File# |
| f | a2: the file (!libs fileiolib,$1280) |
| where | d1: the position from the beginning |
| dosbase | a6: dos.library |
| void dofreefile | ( | struct Library * | dosbase | ) |
CloseFile File#, and _free of a File object: close the file.
a3 = the file. If it is open: flush the buffer, Close, free the buffer and the record fields. Fixed (#140): the pointer to the record fields and the record length are cleared (the original left them).
| dosbase | a6: dos.library |
| void doget | ( | ULONG | fileno, |
| UWORD | record, | ||
| struct Library * | dosbase ) |
| void dokillfile | ( | const UBYTE * | name, |
| struct Library * | dosbase ) |
| void doloc | ( | void | ) |
|
static |
Loc(File#): the position in the file.
The file position of the buffer + the position in it. Errors (debugger, fchk): "Non-Existant File".
| f | a2: the file (!libs fileiolib,$1280) |
| ULONG dolof | ( | struct bfile * | f, |
| struct Library * | dosbase ) |
Lof(File#): the length of the file.
The dos length (seek to the end and back), at least the end of the buffer: not a bug, it does not flush and counts the buffered data. Errors (debugger, fchk): "Non-Existant File".
| f | a2: the file (!libs fileiolib,$1280) |
| dosbase | a6: dos.library |
OpenFile(File#,Filename$): open a file for reading and writing.
Closes the File# first, then opens an existing file, or a new one if it is not found (realopen, mode 0). The record fields and the buffer (DosBuffLen bytes, memlib globalloc, not checked: #139) are set up. Fixed (#138): the original read the name length from -4(0) if the old file had Fields, and cut the name there.
| f | a1: the file (!libs fileiolib,$1180) |
| name | d1: the file name |
| lens | a2: the argument stack, its length at -4 |
| dosbase | a6: dos.library |
| void doput | ( | ULONG | fileno, |
| UWORD | record, | ||
| struct Library * | dosbase ) |
Put File#,Record: write the fields of a record.
a3 = the file. Seeks to record * record length (word multiply), then writes every field. Errors: "Can't Find Record" if the seek fails, "Error Reading/Writing File" (in the normal code, DIFF); debugger (racchk): "Non-Existant File", "No Record Set".
ReadFile(File#,Filename$): open an existing file.
As OpenFile, but only an existing file (MODE_OLDFILE). Fixed (#138) as OpenFile.
| f | a1: the file (!libs fileiolib,$1180) |
| name | d1: the file name |
| lens | a2: the argument stack, its length at -4 |
| dosbase | a6: dos.library |
| void doreadmem | ( | ULONG | fileno, |
| struct bfile * | f, | ||
| UBYTE * | mem, | ||
| ULONG | len, | ||
| struct Library * | dosbase ) |
ReadMem File#,Address,Length: read from a file into memory.
Through the file's buffer (myread; more than the buffer length is read directly). Errors of Read are ignored. Errors (debugger, fchk): "Non-Existant File".
|
static |
Fields File#,Var1[,Var2...]: the variables of a record.
a3 = the file. Per variable on the argument stack (read downwards from a2): the type (word), then the address (long). Types 1/2/7 have 1/2/(long at address-8)+6 bytes (strings start at address-4), all others 4. The list is built backwards: Put/Get transfer the fields in the reverse order (#142, not a bug). Not a defect (#141): it adds to the fields already set and to the record length ("record len so far"), a further Fields continues the record. The field nodes come from memlib globalloc (not checked).
| BB_BOOL dowritefile | ( | struct bfile * | f, |
| UBYTE * | name, | ||
| const ULONG * | lens, | ||
| struct Library * | dosbase ) |
WriteFile(File#,Filename$): create a new file.
As OpenFile, but always a new file (MODE_NEWFILE). Fixed (#138) as OpenFile.
| f | a1: the file (!libs fileiolib,$1180) |
| name | d1: the file name |
| lens | a2: the argument stack, its length at -4 |
| dosbase | a6: dos.library |
| void dowritemem | ( | ULONG | fileno, |
| struct bfile * | f, | ||
| const UBYTE * | mem, | ||
| ULONG | len, | ||
| struct Library * | dosbase ) |
WriteMem File#,Address,Length: write memory to a file.
Through the file's buffer (mywrite; more than the buffer length is written directly). Errors of Write are ignored. Errors (debugger, fchk): "Non-Existant File".
|
static |
| void fileiolib_codeinit | ( | void | ) |
| void fileiolib_fchk | ( | void | ) |
|
static |
| void handlers | ( | void | ) |
|
static |
| void inhandle2 | ( | void | ) |
| void inputhandler | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void outhandle2 | ( | void | ) |
| void outhandle3 | ( | void | ) |
| void outputhandler | ( | void | ) |
|
static |
| void racchk | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |