1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)herror.c	6.1 (Berkeley) 12/4/87";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: #include <sys/types.h>
  12: #include <sys/uio.h>
  13: 
  14: char    *h_errlist[] = {
  15:     "Error 0",
  16:     "Unknown host",             /* 1 HOST_NOT_FOUND */
  17:     "Host name lookup failure",     /* 2 TRY_AGAIN */
  18:     "Unknown server error",         /* 3 NO_RECOVERY */
  19:     "No address associated with name",  /* 4 NO_ADDRESS */
  20: };
  21: int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
  22: 
  23: extern int  h_errno;
  24: 
  25: /*
  26:  * herror --
  27:  *	print the error indicated by the h_errno value.
  28:  */
  29: herror(s)
  30:     char *s;
  31: {
  32:     struct iovec iov[4];
  33:     register struct iovec *v = iov;
  34: 
  35:     if (s && *s) {
  36:         v->iov_base = s;
  37:         v->iov_len = strlen(s);
  38:         v++;
  39:         v->iov_base = ": ";
  40:         v->iov_len = 2;
  41:         v++;
  42:     }
  43:     v->iov_base = h_errno < h_nerr ? h_errlist[h_errno] : "Unknown error";
  44:     v->iov_len = strlen(v->iov_base);
  45:     v++;
  46:     v->iov_base = "\n";
  47:     v->iov_len = 1;
  48:     writev(2, iov, (v - iov) + 1);
  49: }

Defined functions

Defined variables

h_errlist defined in line 14; used 3 times
h_nerr defined in line 21; used 1 times
  • in line 43
sccsid defined in line 8; never used
Last modified: 1988-09-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 514
Valid CSS Valid XHTML 1.0 Strict