ifilter.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright (C) 1994, 2000 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: ifilter.h,v 1.3 2000/09/19 19:00:43 lpd Exp $ */
  16. /* Interpreter filter support */
  17. /* Requires oper.h, stream.h, strimpl.h */
  18. #ifndef ifilter_INCLUDED
  19. # define ifilter_INCLUDED
  20. #include "istream.h"
  21. #include "ivmspace.h"
  22. /*
  23. * Define the utility procedures for creating filters.
  24. * Note that a filter will be allocated in global VM iff the source/target
  25. * and all relevant parameters (if any) are in global VM.
  26. */
  27. int filter_read(P5(
  28. /* Operator arguments that were passed to zfxxx operator */
  29. i_ctx_t *i_ctx_p,
  30. /* # of parameters to pop off o-stack, */
  31. /* not counting the source/target and also not counting any */
  32. /* top dictionary operand (both of which will always be popped) */
  33. int npop,
  34. /* Template for stream */
  35. const stream_template * template,
  36. /* Initialized s_xxx_state, 0 if no separate state */
  37. stream_state * st,
  38. /* Max of space attributes of all parameters referenced by */
  39. /* the state, 0 if no such parameters */
  40. uint space
  41. ));
  42. int filter_write(P5(i_ctx_t *i_ctx_p, int npop,
  43. const stream_template * template,
  44. stream_state * st, uint space));
  45. /*
  46. * Define a simplified interface for streams with no parameters (except
  47. * an optional dictionary) or state.
  48. */
  49. int filter_read_simple(P2(i_ctx_t *i_ctx_p,
  50. const stream_template * template));
  51. int filter_write_simple(P2(i_ctx_t *i_ctx_p,
  52. const stream_template * template));
  53. /* Mark a filter stream as temporary. */
  54. /* See stream.h for the meaning of is_temp. */
  55. void filter_mark_temp(P2(const ref * fop, int is_temp));
  56. /* Mark the source or target of a filter as temporary, and propagate */
  57. /* close_strm from the temporary stream to the filter. */
  58. void filter_mark_strm_temp(P2(const ref * fop, int is_temp));
  59. /* Define a standard report_error procedure for filters, */
  60. /* that records the error message in $error.errorinfo. */
  61. stream_proc_report_error(filter_report_error);
  62. /*
  63. * Define the state of a procedure-based stream.
  64. * Note that procedure-based streams are defined at the Ghostscript
  65. * interpreter level, unlike all other stream types which depend only
  66. * on the stream package and the memory manager.
  67. */
  68. typedef struct stream_proc_state_s {
  69. stream_state_common;
  70. bool eof;
  71. uint index; /* current index within data */
  72. ref proc;
  73. ref data;
  74. } stream_proc_state;
  75. #define private_st_stream_proc_state() /* in zfproc.c */\
  76. gs_private_st_complex_only(st_sproc_state, stream_proc_state,\
  77. "procedure stream state", sproc_clear_marks, sproc_enum_ptrs, sproc_reloc_ptrs, 0)
  78. /* Test whether a stream is procedure-based. */
  79. bool s_is_proc(P1(const stream *s));
  80. #endif /* ifilter_INCLUDED */