Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / sana2perror.c
blob416f5345fe9cef63277d11fa8aa09a2e97f5147a
1 /* $Id$
3 * sana2perror.c - print SANA-II error message
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 */
10 #include <stdio.h>
12 #include <devices/sana2.h>
13 #include <net/sana2errno.h>
15 /****** sana2.lib/sana2perror *************************************************
17 NAME
18 sana2perror - print SANA-II device error messages
20 SYNOPSIS
21 #include <devices/sana2.h>
23 sana2perror(banner, ios2request)
25 void sana2perror(const char *, struct IOSana2Req *)
27 FUNCTION
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
33 printed.
35 NOTES
36 The sana2perror() function requires the stdio functions to be linked.
38 SEE ALSO
39 Sana2PrintFault()
41 *******************************************************************************
44 void
45 sana2perror(const char *banner, struct IOSana2Req *ios2)
47 register WORD err = ios2->ios2_Req.io_Error;
48 register ULONG werr = ios2->ios2_WireError;
49 const char *errstr;
51 if (err >= sana2io_nerr || -err > io_nerr) {
52 errstr = io_errlist[0];
53 } else {
54 if (err < 0)
55 /* Negative error codes are common with all IO devices */
56 errstr = io_errlist[-err];
57 else
58 /* Positive error codes are SANA-II specific */
59 errstr = sana2io_errlist[err];
62 if (werr == 0 || werr >= sana2wire_nerr) {
63 if (banner != NULL)
64 fprintf(stderr, "%s: %s\n", banner, errstr);
65 else
66 fprintf(stderr, "%s\n", errstr);
67 } else {
68 if (banner != NULL)
69 fprintf(stderr, "%s: %s (%s)\n", banner, errstr, sana2wire_errlist[werr]);
70 else
71 fprintf(stderr, "%s (%s)\n", errstr, sana2wire_errlist[werr]);