-- Copyright (C) 1986 by Xerox Corporation. All rights reserved. -- CIOLib.mesa -- NFS 11-Feb-86 17:02:35 -- C I/O library DIRECTORY CBasics USING [FilePtr], CString USING [CString], Stream USING [ Byte, DeleteProcedure, GetProcedure, GetByteProcedure, PutProcedure, PutByteProcedure, SetPositionProcedure]; CIOLib: DEFINITIONS = { EOF: INTEGER = -1; success: INTEGER = 0; failure: INTEGER = -1; -- constants for the fseek parameter ptrname seekSet: INTEGER = 0; seekCur: INTEGER = 1; seekEnd: INTEGER = 2; FilePtr: TYPE = CBasics.FilePtr; -- file operations fopen: PROCEDURE [filename, type: CString.CString] RETURNS [FilePtr]; fclose: PROCEDURE [stream: FilePtr] RETURNS [INTEGER]; freopen: PROCEDURE [filename, type: CString.CString, stream: FilePtr] RETURNS [FilePtr]; fflush: PROCEDURE [stream: FilePtr] RETURNS [INTEGER]; tmpfile: PROCEDURE RETURNS [FilePtr]; rename: PROCEDURE [old, new: CString.CString] RETURNS [INTEGER]; -- character i/o (getc, putc, getchar, and putchar are macros) fgetc: PROCEDURE [stream: FilePtr] RETURNS [INTEGER]; fputc: PROCEDURE [c: INTEGER, stream: FilePtr] RETURNS [INTEGER]; ungetc: PROCEDURE [c: INTEGER, stream: FilePtr] RETURNS [INTEGER]; -- formatted i/o fscanf: PROCEDURE RETURNS [INTEGER]; sscanf: PROCEDURE RETURNS [INTEGER]; scanf: PROCEDURE RETURNS [INTEGER]; fprintf: PROCEDURE RETURNS [INTEGER]; sprintf: PROCEDURE RETURNS [CString.CString]; printf: PROCEDURE RETURNS [INTEGER]; -- string i/o fgets: PROCEDURE [s: CString.CString, n: INTEGER, stream: FilePtr] RETURNS [CString.CString]; gets: PROCEDURE [s: CString.CString] RETURNS [CString.CString]; fputs: PROCEDURE [s: CString.CString, stream: FilePtr] RETURNS [c: INTEGER]; puts: PROCEDURE [s: CString.CString] RETURNS [INTEGER]; -- direct i/o fread: PROCEDURE [ptr: CString.CString, size, count: CARDINAL, iop: FilePtr] RETURNS [itemsRead: INTEGER]; fwrite: PROCEDURE [ptr: CString.CString, size, count: CARDINAL, iop: FilePtr] RETURNS [itemsWritten: INTEGER]; -- random access functions fseek: PROCEDURE [stream: FilePtr, offset: LONG INTEGER, ptrname: INTEGER] RETURNS [INTEGER]; ftell: PROCEDURE [stream: FilePtr] RETURNS [LONG INTEGER]; rewind: PROCEDURE [stream: FilePtr] RETURNS [INTEGER]; -- stream status feof: PROCEDURE [stream: FilePtr] RETURNS [INTEGER]; -- standard streams GetStdin: PROCEDURE RETURNS [sH: FilePtr]; GetStdout: PROCEDURE RETURNS [sH: FilePtr]; GetStderr: PROCEDURE RETURNS [sH: FilePtr]; SetStdin: PROCEDURE [sH: FilePtr] RETURNS [INTEGER]; SetStdout: PROCEDURE [sH: FilePtr] RETURNS [INTEGER]; SetStderr: PROCEDURE [sH: FilePtr] RETURNS [INTEGER]; unlink: PROCEDURE [path: CString.CString] RETURNS [INTEGER]; <<RestoreStreamAndPut is in an interface for testing if the unget() function has been called on a stream, and the original stream procs. have not yet been restored.>> RestoreStreamAndPut: Stream.PutByteProcedure; <<ClientDataObject is what the clienData field of a Stream.Object points to after an ungetc is called and before the stream is restored.>> ClientDataObject: TYPE = MACHINE DEPENDENT RECORD [ oldClientData: LONG POINTER, c: Stream.Byte, blank: Stream.Byte, -- to fill up word -- oldGetByteProc: Stream.GetByteProcedure, oldPutByteProc: Stream.PutByteProcedure, oldSetPositionProc: Stream.SetPositionProcedure, oldDeleteProc: Stream.DeleteProcedure, oldGetProc: Stream.GetProcedure, oldPutProc: Stream.PutProcedure]; }.