diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 20:52:35 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 20:52:35 +0000 |
| commit | 46439007cf417cbd9ac8049bb4122c890097a0fa (patch) | |
| tree | 6fdb25e5f3a2b6d5657eb23b35774b631d4d97e4 /module/bufio.m | |
| parent | 37da2899f40661e3e9631e497da8dc59b971cbd0 (diff) | |
20060303-partial
Diffstat (limited to 'module/bufio.m')
| -rw-r--r-- | module/bufio.m | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/module/bufio.m b/module/bufio.m new file mode 100644 index 00000000..1b392fff --- /dev/null +++ b/module/bufio.m @@ -0,0 +1,70 @@ +Bufio: module +{ + PATH: con "/dis/lib/bufio.dis"; + + SEEKSTART: con Sys->SEEKSTART; + SEEKRELA: con Sys->SEEKRELA; + SEEKEND: con Sys->SEEKEND; + + OREAD: con Sys->OREAD; + OWRITE: con Sys->OWRITE; + ORDWR: con Sys->ORDWR; + + EOF: con -1; + ERROR: con -2; + + Iobuf: adt { + seek: fn(b: self ref Iobuf, n: big, where: int): big; + offset: fn(b: self ref Iobuf): big; + + read: fn(b: self ref Iobuf, a: array of byte, n: int): int; + write: fn(b: self ref Iobuf, a: array of byte, n: int): int; + + getb: fn(b: self ref Iobuf): int; + getc: fn(b: self ref Iobuf): int; + gets: fn(b: self ref Iobuf, sep: int): string; + gett: fn(b: self ref Iobuf, sep: string): string; + + ungetb: fn(b: self ref Iobuf): int; + ungetc: fn(b: self ref Iobuf): int; + + putb: fn(b: self ref Iobuf, b: byte): int; + putc: fn(b: self ref Iobuf, c: int): int; + puts: fn(b: self ref Iobuf, s: string): int; + + flush: fn(b: self ref Iobuf): int; + close: fn(b: self ref Iobuf); + + setfill: fn(b: self ref Iobuf, f: BufioFill); + + # Internal variables + fd: ref Sys->FD; # the file + buffer: array of byte; # the buffer + index: int; # read/write pointer in buffer + size: int; # characters remaining/written + dirty: int; # needs flushing + bufpos: big; # position in file of buf[0] + filpos: big; # current file pointer + lastop: int; # OREAD or OWRITE + mode: int; # mode of open + }; + + open: fn(name: string, mode: int): ref Iobuf; + create: fn(name: string, mode, perm: int): ref Iobuf; + fopen: fn(fd: ref Sys->FD, mode: int): ref Iobuf; + sopen: fn(input: string): ref Iobuf; + aopen: fn(input: array of byte): ref Iobuf; +}; + +BufioFill: module +{ + fill: fn(b: ref Bufio->Iobuf): int; +}; + +ChanFill: module +{ + PATH: con "/dis/lib/chanfill.dis"; + + init: fn(data: array of byte, fid: int, wc: Sys->Rwrite, r: ref Sys->FileIO, b: Bufio): ref Bufio->Iobuf; + fill: fn(b: ref Bufio->Iobuf): int; +}; |
