2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
7 IMPLEMENTATION MODULE Traps
;
9 Module: Facility for handling traps
10 Author: Ceriel J.H. Jacobs
14 FROM EM
IMPORT SIG
, LINO
, FILN
, TRP
;
15 FROM Unix
IMPORT write
;
16 FROM SYSTEM
IMPORT ADDRESS
, ADR
;
20 PROCEDURE InstallTrapHandler(t
: TrapHandler
): TrapHandler
;
21 (* Install a new trap handler, and return the previous one.
22 Parameter of trap handler is the trap number.
26 END InstallTrapHandler
;
28 PROCEDURE Message(str
: ARRAY OF CHAR);
29 (* Write message "str" on standard error, preceeded by filename and
30 linenumber if possible
32 VAR p
: POINTER TO CHAR;
35 buf
, buf2
: ARRAY [0.
.255] OF CHAR;
49 IF write(2, ADR(buf
), i
) < 0 THEN END;
52 IF write(2, ADR(buf
), l
-1) < 0 THEN END;
58 buf
[0] := ','; buf
[1] := ' ';
59 buf
[2] := 'l'; buf
[3] := 'i'; buf
[4] := 'n'; buf
[5] := 'e';
68 buf2
[j
] := CHR(CARDINAL(lino
) MOD 10 + ORD('0'));
80 IF write(2, ADR(buf
), i
+2) < 0 THEN END;
82 WHILE (i
<= HIGH(str
)) AND (str
[i
] #
0C
) DO
85 IF write(2, ADR(str
), i
) < 0 THEN END;
87 IF write(2, ADR(buf
), 1) < 0 THEN END;
90 PROCEDURE Trap(n
: INTEGER);
91 (* cause trap number "n" to occur *)