aboutsummaryrefslogtreecommitdiff
path: root/sys/etc/syserr.x
blob: a14d516dbfa63092319267e9188921dab933581c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

define	SZ_ERRMSG	SZ_LINE

# SYSERR -- Process a system error.  No arguments; print only the error
# message from the system error message file.

procedure syserr (errcode)

int	errcode

begin
	call syserrs (errcode, "")
end


# SYSERRS -- System error, with a user supplied string argument.   We do not
# want to search the system error message file until ERRACT is called to
# output the error message and initiate error recovery, because if an IFERR
# error handler is posted the message will never be used.  Hence we encode
# an error message of the form "123 user_string", where "123" is the encoded
# system error message number.  If a message is ever actually output the
# 123 will be expanded into a readable error message.

procedure syserrs (errcode, user_string)

int	errcode
char	user_string[ARB]

char	buf[SZ_ERRMSG]
int	ip, op
int	itoc()

begin
	# Encode error code, to be used to search error message file.
	op = itoc (errcode, buf, SZ_ERRMSG) + 1

	if (user_string[1] != EOS) {
	    buf[op] = ' '
	    op = op + 1
	    for (ip=1;  op <= SZ_ERRMSG && user_string[ip] != EOS;  ip=ip+1) {
		buf[op] = user_string[ip]
		op = op + 1
	    }
	}
	buf[op] = EOS

	call error (errcode, buf)
end