home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / PRERROR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.7 KB  |  72 lines

  1. /**
  2. *
  3. * Name        PRERROR -- Return a string corresponding to one
  4. *               of the errors returned by the PR
  5. *               function family.
  6. *
  7. * Synopsis    errstr = prerror (errnum);
  8. *
  9. *        const char *errstr  Pointer to a static string (null-
  10. *                    terminated) that explains the
  11. *                    errnum error code.
  12. *
  13. *        int errnum        Error code received from another
  14. *                    PR call.
  15. *
  16. * Description    This function returns a pointer to a static
  17. *        text representation of a print spooler error.
  18. *
  19. *        Note: If the string returned is modified, there
  20. *        will be unknown consequences.
  21. *
  22. * Special    If the errnum passed to the function is unknown,
  23. * Cases     the error string returned is "unknown error".
  24. *
  25. * Returns    errstr            Address of a static string
  26. *                    describing the spooler error
  27. *                    reported by another PR function.
  28. *
  29. * Version    6.00 (C)Copyright Blaise Computing Inc. 1987,1989
  30. *
  31. **/
  32.  
  33. #include <bprint.h>
  34.  
  35. #define PR_NUM_MAP  16        /* Number of elements in the error        */
  36.                 /* mapping array.                */
  37.  
  38. #define PR_NUM_ERRS 13        /* Number of actual error messages.     */
  39.  
  40.  
  41. static const int err_map[] =
  42.     {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, 10, -1, -1, 11, 12};
  43.  
  44. static const char *errors [] =
  45. {
  46.     "no error",
  47.     "spooler not installed",
  48.     "file not found",
  49.     "path not found",
  50.     "out of handles",
  51.     "access denied",
  52.     "queue empty",
  53.     "out of range",
  54.     "queue full",
  55.     "spooler busy",
  56.     "path too long",
  57.     "invalid drive",
  58.     "unknown error"
  59. };
  60.  
  61.  
  62. const char *prerror (err)
  63.  
  64. int err;
  65.  
  66. {
  67.     if ((err < 0) || (err > PR_NUM_MAP) || (err_map [err] == -1))
  68.     err = PR_NUM_MAP;
  69.  
  70.     return (errors [err_map [err]]);
  71. }
  72.