| 1 |
(* RTgen.def provide a generic device interface used by ISO. |
| 2 |
|
| 3 |
Copyright (C) 2008-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE RTgen ; |
| 28 |
|
| 29 |
(* |
| 30 |
Title : RTgen |
| 31 |
Author : Gaius Mulley |
| 32 |
System : GNU Modula-2 |
| 33 |
Date : Mon Sep 22 18:15:35 2008 |
| 34 |
Revision : $Version$ |
| 35 |
Description: provides a generic device interface between |
| 36 |
ISO channels and the underlying PIM style |
| 37 |
FIO procedure calls. |
| 38 |
*) |
| 39 |
|
| 40 |
FROM RTgenif IMPORT GenDevIF ; |
| 41 |
FROM IOLink IMPORT DeviceId, DeviceTablePtr; |
| 42 |
FROM IOConsts IMPORT ReadResults ; |
| 43 |
FROM SYSTEM IMPORT ADDRESS ; |
| 44 |
|
| 45 |
|
| 46 |
TYPE |
| 47 |
ChanDev ; |
| 48 |
DeviceType = (seqfile, streamfile, programargs, stdchans, term, socket, rndfile) ; |
| 49 |
|
| 50 |
|
| 51 |
(* |
| 52 |
InitChanDev - initialize and return a ChanDev. |
| 53 |
*) |
| 54 |
|
| 55 |
PROCEDURE InitChanDev (t: DeviceType; d: DeviceId; g: GenDevIF) : ChanDev ; |
| 56 |
|
| 57 |
|
| 58 |
(* |
| 59 |
KillChanDev - deallocates, g. |
| 60 |
*) |
| 61 |
|
| 62 |
PROCEDURE KillChanDev (g: GenDevIF) : GenDevIF ; |
| 63 |
|
| 64 |
|
| 65 |
(* |
| 66 |
RaiseEOFinLook - returns TRUE if the Look procedure |
| 67 |
should raise an exception if it |
| 68 |
sees end of file. |
| 69 |
*) |
| 70 |
|
| 71 |
PROCEDURE RaiseEOFinLook (g: ChanDev) : BOOLEAN ; |
| 72 |
|
| 73 |
|
| 74 |
(* |
| 75 |
RaiseEOFinSkip - returns TRUE if the Skip procedure |
| 76 |
should raise an exception if it |
| 77 |
sees end of file. |
| 78 |
*) |
| 79 |
|
| 80 |
PROCEDURE RaiseEOFinSkip (g: ChanDev) : BOOLEAN ; |
| 81 |
|
| 82 |
|
| 83 |
PROCEDURE doLook (g: ChanDev; |
| 84 |
d: DeviceTablePtr; |
| 85 |
VAR ch: CHAR; |
| 86 |
VAR r: ReadResults) ; |
| 87 |
|
| 88 |
PROCEDURE doSkip (g: ChanDev; |
| 89 |
d: DeviceTablePtr) ; |
| 90 |
|
| 91 |
PROCEDURE doSkipLook (g: ChanDev; |
| 92 |
d: DeviceTablePtr; |
| 93 |
VAR ch: CHAR; |
| 94 |
VAR r: ReadResults) ; |
| 95 |
|
| 96 |
PROCEDURE doWriteLn (g: ChanDev; |
| 97 |
d: DeviceTablePtr) ; |
| 98 |
|
| 99 |
PROCEDURE doReadText (g: ChanDev; |
| 100 |
d: DeviceTablePtr; |
| 101 |
to: ADDRESS; |
| 102 |
maxChars: CARDINAL; |
| 103 |
VAR charsRead: CARDINAL) ; |
| 104 |
|
| 105 |
PROCEDURE doWriteText (g: ChanDev; |
| 106 |
d: DeviceTablePtr; |
| 107 |
from: ADDRESS; |
| 108 |
charsToWrite: CARDINAL) ; |
| 109 |
|
| 110 |
PROCEDURE doReadLocs (g: ChanDev; |
| 111 |
d: DeviceTablePtr; |
| 112 |
to: ADDRESS; |
| 113 |
maxLocs: CARDINAL; |
| 114 |
VAR locsRead: CARDINAL) ; |
| 115 |
|
| 116 |
PROCEDURE doWriteLocs (g: ChanDev; |
| 117 |
d: DeviceTablePtr; |
| 118 |
from: ADDRESS; |
| 119 |
locsToWrite: CARDINAL) ; |
| 120 |
|
| 121 |
(* |
| 122 |
checkErrno - checks a number of errno conditions and raises |
| 123 |
appropriate ISO exceptions if they occur. |
| 124 |
*) |
| 125 |
|
| 126 |
PROCEDURE checkErrno (g: ChanDev; d: DeviceTablePtr) ; |
| 127 |
|
| 128 |
|
| 129 |
END RTgen. |