revert between 56095 -> 55830 in arch
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / printuserfault.c
blob09fecf948afcd1e744666ed68187cfc44d8a439f
1 /* $Id$
2 *
3 * printuserfault.c - Print a usergroup 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/PrintUserFault ************************************************
13 NAME
14 PrintUserFault - socket error messages
16 SYNOPSIS
17 PrintUserFault(code, banner)
18 void PrintUserFault(LONG, const UBYTE *)
20 FUNCTION
21 The PrintUserFault() function finds the error message corresponding to
22 the code and writes it, followed by a newline, to the standard error
23 or Output() filehandle. If the argument string is non-NULL it is
24 preappended to the message string and separated from it by a colon and
25 space (`: '). If string is NULL only the error message string is
26 printed.
28 NOTES
29 The PrintUserFault() function used the DOS io functions. It is
30 recommended to use PrintUserFault() when the standard C IO functions
31 are not otherwise in use.
33 SEE ALSO
34 strerror(), perror(), <netinclude:sys/errno.h>
36 ******************************************************************************
39 #include <errno.h>
41 #include <exec/execbase.h>
42 extern struct ExecBase *SysBase;
44 #include <dos/dos.h>
45 #include <dos/dosextens.h>
46 #include <proto/dos.h>
47 #include <proto/usergroup.h>
48 #include <proto/exec.h>
50 void PrintUserFault(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;
55 if (banner != NULL) {
56 FPuts(Stderr, (STRPTR)banner);
57 FPuts(Stderr, ": ");
59 FPuts(Stderr, (STRPTR)ug_StrError(code));
60 FPuts(Stderr, "\n");
61 Flush(Stderr);