Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / network / stacks / AROSTCP / netlib / sana2printfault.c
blob18855854210beb1207b996e0b18af16f0cbbe1b7
1 /* $Id$
3 * sana2printfault.c - print SANA-II error message
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 */
10 #include <devices/sana2.h>
11 #include <net/sana2errno.h>
12 #ifdef __SASC
13 #include <proto/dos.h>
14 #else
15 #include <clib/dos_protos.h>
16 #endif
18 /****** sana2.lib/sana2PrintFault *********************************************
20 NAME
21 Sana2PrintFault - print SANA-II device error messages
23 SYNOPSIS
24 #include <devices/sana2.h>
26 Sana2PrintFault(banner, ios2request)
28 void Sana2PrintFault(const char *, struct IOSana2Req *)
30 FUNCTION
31 The Sana2PrintFault() function finds the error message corresponding
32 to the error in the given SANA-II IO request and writes it, followed
33 by a newline, to the Output(). If the argument string is non-NULL it
34 is preappended to the message string and separated from it by a colon
35 and space (`: '). If string is NULL only the error message string is
36 printed.
38 SEE ALSO
39 Sana2PrintFault()
41 *******************************************************************************
45 void
46 Sana2PrintFault(const char *banner, struct IOSana2Req *ios2)
48 register WORD err = ios2->ios2_Req.io_Error;
49 register ULONG werr = ios2->ios2_WireError;
50 LONG args[3];
51 char * format;
53 args[0] = (LONG)banner;
55 if (err >= sana2io_nerr || -err > io_nerr) {
56 args[1] = (LONG)io_errlist[0];
57 } else {
58 if (err < 0)
59 args[1] = (LONG)io_errlist[-err];
60 else
61 args[1] = (LONG)sana2io_errlist[err];
63 if (werr == 0 || werr >= sana2wire_nerr) {
64 if (banner != NULL)
65 format = "%s: %s\n";
66 else
67 format = "%s\n";
68 } else {
69 if (banner != NULL)
70 format = "%s: %s (%s)\n";
71 else
72 format = "%s (%s)\n";
73 args[2] = (LONG)sana2wire_errlist[werr];
76 VPrintf(format, banner != NULL ? args : args + 1);