3 * sana2perror.c - print SANA-II error message
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
12 #include <devices/sana2.h>
13 #include <net/sana2errno.h>
15 /****** sana2.lib/sana2perror *************************************************
18 sana2perror - print SANA-II device error messages
21 #include <devices/sana2.h>
23 sana2perror(banner, ios2request)
25 void sana2perror(const char *, struct IOSana2Req *)
28 The sana2perror() function finds the error message corresponding to
29 the error in the given SANA-II IO request and writes it, followed by a
30 newline, to the stderr. If the argument string is non-NULL it is
31 preappended to the message string and separated from it by a colon and
32 space (`: '). If string is NULL only the error message string is
36 The sana2perror() function requires the stdio functions to be linked.
41 *******************************************************************************
45 sana2perror(const char *banner
, struct IOSana2Req
*ios2
)
47 register WORD err
= ios2
->ios2_Req
.io_Error
;
48 register ULONG werr
= ios2
->ios2_WireError
;
51 if (err
>= sana2io_nerr
|| -err
> io_nerr
) {
52 errstr
= io_errlist
[0];
55 /* Negative error codes are common with all IO devices */
56 errstr
= io_errlist
[-err
];
58 /* Positive error codes are SANA-II specific */
59 errstr
= sana2io_errlist
[err
];
62 if (werr
== 0 || werr
>= sana2wire_nerr
) {
64 fprintf(stderr
, "%s: %s\n", banner
, errstr
);
66 fprintf(stderr
, "%s\n", errstr
);
69 fprintf(stderr
, "%s: %s (%s)\n", banner
, errstr
, sana2wire_errlist
[werr
]);
71 fprintf(stderr
, "%s (%s)\n", errstr
, sana2wire_errlist
[werr
]);