home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / condor40.zip / CONDOR / src / util_lib / perror.c < prev    next >
C/C++ Source or Header  |  1989-06-18  |  2KB  |  71 lines

  1. /* 
  2. ** Copyright 1986, 1987, 1988, 1989 University of Wisconsin
  3. ** 
  4. ** Permission to use, copy, modify, and distribute this software and its
  5. ** documentation for any purpose and without fee is hereby granted,
  6. ** provided that the above copyright notice appear in all copies and that
  7. ** both that copyright notice and this permission notice appear in
  8. ** supporting documentation, and that the name of the University of
  9. ** Wisconsin not be used in advertising or publicity pertaining to
  10. ** distribution of the software without specific, written prior
  11. ** permission.  The University of Wisconsin makes no representations about
  12. ** the suitability of this software for any purpose.  It is provided "as
  13. ** is" without express or implied warranty.
  14. ** 
  15. ** THE UNIVERSITY OF WISCONSIN DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. ** THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. ** FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN  BE LIABLE FOR
  18. ** ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  21. ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22. ** 
  23. ** Authors:  Allan Bricker and Michael J. Litzkow,
  24. **              University of Wisconsin, Computer Sciences Dept.
  25. ** 
  26. */ 
  27.  
  28.  
  29. #ifndef LINT
  30. #include <sys/types.h>
  31. #include <sys/uio.h>
  32.  
  33. int    errno;
  34.  
  35. int    sys_nerr;
  36. extern char *sys_errlist[];
  37.  
  38. int condor_nerr;
  39. extern char *condor_errlist[];
  40.  
  41. perror(s)
  42. char *s;
  43. {
  44.     struct iovec iov[4];
  45.     register struct iovec *v = iov;
  46.  
  47.     if (s && *s) {
  48.         v->iov_base = s;
  49.         v->iov_len = strlen(s);
  50.         v++;
  51.         v->iov_base = ": ";
  52.         v->iov_len = 2;
  53.         v++;
  54.     }
  55.  
  56.     if( errno < 0 ) {
  57.         errno = -errno;
  58.         v->iov_base = errno < condor_nerr ? condor_errlist[errno] :
  59.                                                     "Unknown CONDOR error";
  60.     } else {
  61.         v->iov_base = errno < sys_nerr ? sys_errlist[errno] : "Unknown error";
  62.     }
  63.  
  64.     v->iov_len = strlen(v->iov_base);
  65.     v++;
  66.     v->iov_base = "\n";
  67.     v->iov_len = 1;
  68.     writev(2, iov, (v - iov) + 1);
  69. }
  70. #endif LINT
  71.