errors.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* Copyright (C) 1989, 1995, 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: errors.h,v 1.4 2001/03/12 04:05:19 ghostgum Exp $ */
  16. /* Definition of error codes */
  17. #ifndef errors_INCLUDED
  18. # define errors_INCLUDED
  19. /*
  20. * A procedure that may return an error always returns
  21. * a non-negative value (zero, unless otherwise noted) for success,
  22. * or negative for failure.
  23. * We use ints rather than an enum to avoid a lot of casting.
  24. */
  25. /* Define the error name table */
  26. extern const char *const gs_error_names[];
  27. /* ------ PostScript Level 1 errors ------ */
  28. #define e_unknownerror (-1) /* unknown error */
  29. #define e_dictfull (-2)
  30. #define e_dictstackoverflow (-3)
  31. #define e_dictstackunderflow (-4)
  32. #define e_execstackoverflow (-5)
  33. #define e_interrupt (-6)
  34. /* We also need to define gs_error_interrupt, for gpcheck.h. */
  35. #undef gs_error_interrupt
  36. #define gs_error_interrupt e_interrupt
  37. #define e_invalidaccess (-7)
  38. #define e_invalidexit (-8)
  39. #define e_invalidfileaccess (-9)
  40. #define e_invalidfont (-10)
  41. #define e_invalidrestore (-11)
  42. #define e_ioerror (-12)
  43. #define e_limitcheck (-13)
  44. #define e_nocurrentpoint (-14)
  45. #define e_rangecheck (-15)
  46. #define e_stackoverflow (-16)
  47. #define e_stackunderflow (-17)
  48. #define e_syntaxerror (-18)
  49. #define e_timeout (-19)
  50. #define e_typecheck (-20)
  51. #define e_undefined (-21)
  52. #define e_undefinedfilename (-22)
  53. #define e_undefinedresult (-23)
  54. #define e_unmatchedmark (-24)
  55. #define e_VMerror (-25)
  56. #define LEVEL1_ERROR_NAMES\
  57. "unknownerror", "dictfull", "dictstackoverflow", "dictstackunderflow",\
  58. "execstackoverflow", "interrupt", "invalidaccess", "invalidexit",\
  59. "invalidfileaccess", "invalidfont", "invalidrestore", "ioerror",\
  60. "limitcheck", "nocurrentpoint", "rangecheck", "stackoverflow",\
  61. "stackunderflow", "syntaxerror", "timeout", "typecheck", "undefined",\
  62. "undefinedfilename", "undefinedresult", "unmatchedmark", "VMerror"
  63. /* ------ Additional Level 2 and DPS errors ------ */
  64. #define e_configurationerror (-26)
  65. #define e_invalidcontext (-27)
  66. #define e_undefinedresource (-28)
  67. #define e_unregistered (-29)
  68. /* invalidid is for the NeXT DPS extension. */
  69. #define e_invalidid (-30)
  70. #define LEVEL2_ERROR_NAMES\
  71. "configurationerror", "invalidcontext", "undefinedresource",\
  72. "unregistered", "invalidid"
  73. #define ERROR_NAMES LEVEL1_ERROR_NAMES, LEVEL2_ERROR_NAMES
  74. /* ------ Pseudo-errors used internally ------ */
  75. /*
  76. * Internal code for a fatal error.
  77. * gs_interpret also returns this for a .quit with a positive exit code.
  78. */
  79. #define e_Fatal (-100)
  80. /*
  81. * Internal code for the .quit operator.
  82. * The real quit code is an integer on the operand stack.
  83. * gs_interpret returns this only for a .quit with a zero exit code.
  84. */
  85. #define e_Quit (-101)
  86. /*
  87. * Internal code for a normal exit from the interpreter.
  88. * Do not use outside of interp.c.
  89. */
  90. #define e_InterpreterExit (-102)
  91. /*
  92. * Internal code that indicates that a procedure has been stored in the
  93. * remap_proc of the graphics state, and should be called before retrying
  94. * the current token. This is used for color remapping involving a call
  95. * back into the interpreter -- inelegant, but effective.
  96. */
  97. #define e_RemapColor (-103)
  98. /*
  99. * Internal code to indicate we have underflowed the top block
  100. * of the e-stack.
  101. */
  102. #define e_ExecStackUnderflow (-104)
  103. /*
  104. * Internal code for the vmreclaim operator with a positive operand.
  105. * We need to handle this as an error because otherwise the interpreter
  106. * won't reload enough of its state when the operator returns.
  107. */
  108. #define e_VMreclaim (-105)
  109. /*
  110. * Internal code for requesting more input from run_string.
  111. */
  112. #define e_NeedInput (-106)
  113. /*
  114. * Internal code for stdin callout.
  115. */
  116. #define e_NeedStdin (-107)
  117. /*
  118. * Internal code for stdout callout.
  119. */
  120. #define e_NeedStdout (-108)
  121. /*
  122. * Internal code for stderr callout.
  123. */
  124. #define e_NeedStderr (-109)
  125. /*
  126. * Internal code for a normal exit when usage info is displayed.
  127. * This allows Window versions of Ghostscript to pause until
  128. * the message can be read.
  129. */
  130. #define e_Info (-110)
  131. /*
  132. * Define which error codes require re-executing the current object.
  133. */
  134. #define ERROR_IS_INTERRUPT(ecode)\
  135. ((ecode) == e_interrupt || (ecode) == e_timeout)
  136. #endif /* errors_INCLUDED */