tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / herror.c
blob6ee306599780c02f44b8a30cd5ed89e17f5965a0
1 /* $Id$
3 * herror.c - print host error message
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
7 * All rights reserved.
8 * Copyright © 2005 Pavel Fedin
9 */
11 /****** net.lib/herror *******************************************************
13 NAME
14 herror - print name resolver error message to stderr.
16 SYNOPSIS
17 #include <clib/netlib_protos.h>
19 herror(banner)
20 void herror(const char *)
22 FUNCTION
23 The herror() function finds the error message corresponding to the
24 current value of host error using the SocketBaseTags() and writes
25 it, followed by a newline, to the stderr. If the argument string
26 is non-NULL it is used as a prefix to the message string and
27 separated from it by a colon and space (`: '). If the argument is
28 NULL only the error message string is printed.
30 NOTES
31 The herror() function requires the stdio functions to be linked.
33 SEE ALSO
34 <netinclude:netdb.h>, SocketBaseTagList(), perror()
36 ******************************************************************************
39 #include <stdio.h>
40 #include <string.h>
41 #include <proto/socket.h>
42 #include <bsdsocket/socketbasetags.h>
44 void
45 herror(const char *banner)
47 const char *err;
50 * First fetch the h_errno value to (ULONG)err, and then convert it to
51 * error string pointer.
53 SocketBaseTags(SBTM_GETREF(SBTC_HERRNO), &err,
54 SBTM_GETREF(SBTC_HERRNOSTRPTR), &err,
55 TAG_END);
57 if (banner != NULL) {
58 fputs(banner, stderr);
59 fputs(": ", stderr);
61 fputs(err, stderr);
62 fputc('\n', stderr);
63 fflush(stderr);