home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1621 / err.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  1.1 KB  |  93 lines

  1. /* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  2.  
  3. #include <stdio.h>
  4. #include "config.h"
  5. #include "pty.h"
  6. #include "err.h"
  7.  
  8. static void perr(e)
  9. int e;
  10. {
  11.  if (!flagquiet)
  12.   {
  13.    if ((e < 0) || (e > sys_nerr))
  14.      (void) fprintf(stderr,"error %d",e);
  15.    else
  16.      (void) fputs(sys_errlist[e],stderr);
  17.   }
  18. }
  19.  
  20. static void serr(s)
  21. char *s;
  22. {
  23.  if (!flagquiet)
  24.    (void) fputs(s,stderr);
  25. }
  26.  
  27. void warnerr2(p,s)
  28. char *p;
  29. char *s;
  30. {
  31.  if (!flagquiet)
  32.    (void) fprintf(stderr,p,s);
  33. }
  34.  
  35. /* Note that accounting is based on the real uid, as it should be. */
  36.  
  37. void fatal(x)
  38. int x;
  39. {
  40.  (void) setreuid(uid,uid);
  41.  (void) exit(x);
  42.  /*NOTREACHED*/
  43. }
  44.  
  45. void fatalinfo(x,s)
  46. int x;
  47. char **s;
  48. {
  49.  while (*s)
  50.   {
  51.    serr(*(s++));
  52.    serr("\n");
  53.   }
  54.  fatal(x);
  55.  /*NOTREACHED*/
  56. }
  57.  
  58. void fatalerr(x,s)
  59. int x;
  60. char *s;
  61. {
  62.  serr(s);
  63.  fatal(x);
  64.  /*NOTREACHED*/
  65. }
  66.  
  67. void fatalerr2p(x,p,s,e)
  68. int x;
  69. char *p;
  70. char *s;
  71. int e;
  72. {
  73.  warnerr2(p,s);
  74.  serr(": ");
  75.  perr(e);
  76.  serr("\n");
  77.  fatal(x);
  78.  /*NOTREACHED*/
  79. }
  80.  
  81. void fatalerrp(x,s,e)
  82. int x;
  83. char *s;
  84. int e;
  85. {
  86.  serr(s);
  87.  serr(": ");
  88.  perr(e);
  89.  serr("\n");
  90.  fatal(x);
  91.  /*NOTREACHED*/
  92. }
  93.