add ftpd.8 to SEE ALSO, so admin's can find out about /etc/shells
[unix-history] / usr / src / lib / libc / net / herror.c
CommitLineData
5b6e7185
KB
1/*
2 * Copyright (c) 1987 Regents of the University of California.
6b2f9dd0
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
5b6e7185
KB
11 */
12
ebfe7813 13#if defined(LIBC_SCCS) && !defined(lint)
6b2f9dd0
KB
14static char sccsid[] = "@(#)herror.c 6.2 (Berkeley) %G%";
15#endif /* LIBC_SCCS and not lint */
5b6e7185
KB
16
17#include <sys/types.h>
18#include <sys/uio.h>
19
20char *h_errlist[] = {
21 "Error 0",
22 "Unknown host", /* 1 HOST_NOT_FOUND */
23 "Host name lookup failure", /* 2 TRY_AGAIN */
24 "Unknown server error", /* 3 NO_RECOVERY */
25 "No address associated with name", /* 4 NO_ADDRESS */
26};
27int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
28
29extern int h_errno;
30
31/*
32 * herror --
33 * print the error indicated by the h_errno value.
34 */
35herror(s)
36 char *s;
37{
38 struct iovec iov[4];
39 register struct iovec *v = iov;
40
41 if (s && *s) {
42 v->iov_base = s;
43 v->iov_len = strlen(s);
44 v++;
45 v->iov_base = ": ";
46 v->iov_len = 2;
47 v++;
48 }
49 v->iov_base = h_errno < h_nerr ? h_errlist[h_errno] : "Unknown error";
50 v->iov_len = strlen(v->iov_base);
51 v++;
52 v->iov_base = "\n";
53 v->iov_len = 1;
54 writev(2, iov, (v - iov) + 1);
55}