tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / printfault.c
blob0d6dfa3270196bcf5cc2f9cd4ae76456b214d08d
1 /* $Id$
2 *
3 * printfault.c - Print a socket error message (DOS)
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 * Copyright © 2005 Pavel Fedin
9 */
11 /****** net.lib/PrintNetFault ************************************************
13 NAME
14 PrintNetFault - socket error messages
16 SYNOPSIS
17 PrintNetFault(code, banner)
18 void PrintNetFault(LONG, const UBYTE *)
20 FUNCTION
21 The PrintNetFault() function finds the error message corresponding
22 to the code and writes it, followed by a newline, to the standard
23 error or Output() filehandle. If the argument string is non-NULL it
24 is preappended to the message string and separated from it by a
25 colon and space (`: '). If string is NULL only the error message
26 string is printed.
28 NOTES
29 The PrintNetFault() function uses the DOS IO functions.
31 SEE ALSO
32 strerror(), perror(), <netinclude:sys/errno.h>
34 ******************************************************************************
37 #include <errno.h>
38 #include <clib/netlib_protos.h>
40 #include <exec/execbase.h>
41 extern struct ExecBase *SysBase;
43 #include <dos/dos.h>
44 #include <dos/dosextens.h>
46 #include <proto/dos.h>
47 #include <proto/exec.h>
49 void
50 PrintNetFault(LONG code, const UBYTE *banner)
52 struct Process *p = (struct Process *)FindTask(NULL);
53 BPTR Stderr = p->pr_CES ? p->pr_CES : p->pr_COS;
54 const UBYTE *err = strerror(errno);
56 if (banner != NULL) {
57 FPuts(Stderr, (STRPTR)banner);
58 FPuts(Stderr, ": ");
60 FPuts(Stderr, (STRPTR)err);
61 FPuts(Stderr, "\n");
62 Flush(Stderr);