home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / gutil / syserr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-18  |  1.2 KB  |  69 lines

  1. # include    <stdio.h>
  2. # include    <errno.h>
  3. # include    <stdlib.h>
  4. # include    <sccs.h>
  5.  
  6. SCCSID(@(#)syserr.c    8.1    12/31/84)
  7.  
  8. /*
  9. **  SYSERR -- SYStem ERRor message print and abort
  10. **
  11. **    Syserr acts like a printf with up to five arguments.
  12. **
  13. **    If the first argument to syserr is not zero,
  14. **    the message "SYSERR:" is prepended.
  15. **
  16. **    If the extern variable `Proc_name' is assigned to a
  17. **    string, that string is prepended to the message.
  18. **
  19. **    All arguments must be null-terminated.
  20. **
  21. **    The function pointed to by `ExitFn' is then called.
  22. **    It is initialized to be `exit'.
  23. */
  24.  
  25. char    *Proc_name;
  26. int    Accerror;
  27. void    (*ExitFn)()     = exit;
  28.  
  29. syserr(pv)
  30. char    *pv;
  31. {
  32.     int        pid;
  33.     register char    **p;
  34.     register int    usererr;
  35.     register int    exitvalue;
  36.  
  37.     p = &pv;
  38.     printf("\n");
  39.     usererr = pv == 0;
  40.  
  41.     if (!usererr)
  42.     {
  43.         if (Proc_name)
  44.             printf("%s ", Proc_name);
  45.         printf("\007SYSERR: ");
  46.     }
  47.     else
  48.         p++;
  49.     printf(p[0], p[1], p[2], p[3], p[4], p[5]);
  50.     printf("\007\n");
  51.     exitvalue = -1;
  52.     if (!usererr)
  53.     {
  54.         if (errno)
  55.         {
  56.             exitvalue = errno;
  57.             perror("UNIX error");
  58.         }
  59.         if (Accerror != 0)
  60.         {
  61.             printf("\taccess method error %d\n", Accerror);
  62.         }
  63.     }
  64.     fflush(stdout);
  65.     if (ExitFn == exit)
  66.         ExitFn = abort;
  67.     (*ExitFn)(exitvalue);
  68. }
  69.