home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 446.lha / parseargs / syserr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-06  |  1.9 KB  |  110 lines

  1. #include <useful.h>
  2. #include <funclist.h>
  3.  
  4. VERSIONID("$Header: syserr.c,v 2.0 89/12/24 00:56:31 eric Exp $");
  5.  
  6. /*
  7. **  SYSERR -- indicate a system error
  8. **
  9. **    Parameters:
  10. **        m -- the printf() message to print.
  11. **        a, b, c, d, e -- parameters to the message
  12. **
  13. **    Returns:
  14. **        never
  15. **
  16. **    Side Effects:
  17. **        Terminates the process if no acceptable recover takes place.
  18. **
  19. **    Globals:
  20. **        SyserrFuncs -- a list of functions to call.
  21. **
  22. **    Author:
  23. **        Eric Allman
  24. **        University of California, Berkeley
  25. */
  26.  
  27. VOID
  28. syserr(m, a, b, c, d, e)
  29.     char *m;
  30. {
  31.     static BOOL exiting = FALSE;
  32.  
  33.     /* print the error message */
  34.     _error_message(m, a, b, c, d, e);
  35.  
  36.     /* if we recursively syserr during exit, drop out now! */
  37.     if (exiting)
  38.         _exit(1);
  39.  
  40.     /* try a clean exit */
  41.     exiting = TRUE;
  42.     exit(1);
  43.     /*NOTREACHED*/
  44. }
  45. /*
  46. **  USRERR -- print a user error
  47. **
  48. **    Parameters:
  49. **        m -- the printf() message to print.
  50. **        a, b, c, d, e -- parameters to the message
  51. **
  52. **    Returns:
  53. **        none.
  54. **
  55. **    Side Effects:
  56. **        clears the global error number.
  57. */
  58.  
  59. VOID
  60. usrerr(m, a, b, c, d, e)
  61.     char *m;
  62. {
  63.     extern int errno;
  64.  
  65.     /* print the error message */
  66.     _error_message(m, a, b, c, d, e);
  67.  
  68.     /* give us a clean slate */
  69.     errno = 0;
  70. }
  71. /*
  72. **  _ERROR_MESSAGE -- generic message printing routine.
  73. **
  74. **    Includes the program name with the message, as well as the
  75. **    various possible error codes.
  76. **
  77. **    Parameters:
  78. **        m -- the printf() message to print.
  79. **        a, b, c, d, e -- parameters to the message
  80. **
  81. **    Returns:
  82. **        none.
  83. **
  84. **    Side Effects:
  85. **        none.
  86. **
  87. **    Globals:
  88. **        ProgName -- the name of the program.
  89. */
  90.  
  91. STATIC VOID
  92. _error_message(m, a, b, c, d, e)
  93.     char *m;
  94. {
  95.     extern char *ProgName;
  96.     int saveerr;
  97.     extern int errno;
  98.  
  99.     saveerr = errno;
  100.     if (ProgName != CHARNULL)
  101.         fprintf(stderr, "%s: ", ProgName);
  102.     fprintf(stderr, m, a, b, c, d, e);
  103.     fprintf(stderr, "\n");
  104.     if (saveerr != 0)
  105.     {
  106.         errno = saveerr;
  107.         perror("System error");
  108.     }
  109. }
  110.