home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / 2014.11.minnie.tuhs.org.tar / minnie.tuhs.org / UnixArchive / PDP-11 / Trees / V6 / usr / source / s5 / perror.c < prev    next >
C/C++ Source or Header  |  1975-05-14  |  487b  |  41 lines

  1. /*
  2.  * Print the error indicated
  3.  * in the cerror cell.
  4.  */
  5.  
  6. int    errno;
  7. int    sys_nerr;
  8. char    *sys_errlist[];
  9. perror(s)
  10. char *s;
  11. {
  12.     register char *c;
  13.     register n;
  14.  
  15.     c = "Unknown error";
  16.     if(errno < sys_nerr)
  17.         c = sys_errlist[errno];
  18.     n = strlen(s);
  19.     if(n) {
  20.         write(2, s, n);
  21.         write(2, ": ", 2);
  22.     }
  23.     write(2, c, strlen(c));
  24.     write(2, "\n", 1);
  25. }
  26.  
  27. /*
  28.  * Return the number of bytes in a string
  29.  */
  30.  
  31. strlen(str)
  32. char *str;
  33. {
  34.     register char *s;
  35.  
  36.     s = str;
  37.     while(*s++)
  38.         ;
  39.     return(s-str-1);
  40. }
  41.