1 /* Copyright (C) 1994, 2000 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: ifilter.h,v 1.6 2002/06/16 04:47:10 lpd Exp $ */ 18 /* Interpreter filter support */ 19 /* Requires oper.h, stream.h, strimpl.h */ 20 21 #ifndef ifilter_INCLUDED 22 # define ifilter_INCLUDED 23 24 #include "istream.h" 25 #include "ivmspace.h" 26 27 /* 28 * Define the utility procedures for creating filters. 29 * Note that a filter will be allocated in global VM iff the source/target 30 * and all relevant parameters (if any) are in global VM. 31 */ 32 int filter_read( 33 /* Operator arguments that were passed to zfxxx operator */ 34 i_ctx_t *i_ctx_p, 35 /* # of parameters to pop off o-stack, */ 36 /* not counting the source/target and also not counting any */ 37 /* top dictionary operand (both of which will always be popped) */ 38 int npop, 39 /* Template for stream */ 40 const stream_template * template, 41 /* Initialized s_xxx_state, 0 if no separate state */ 42 stream_state * st, 43 /* Max of space attributes of all parameters referenced by */ 44 /* the state, 0 if no such parameters */ 45 uint space 46 ); 47 int filter_write(i_ctx_t *i_ctx_p, int npop, 48 const stream_template * template, 49 stream_state * st, uint space); 50 51 /* 52 * Define a simplified interface for streams with no parameters (except 53 * an optional dictionary) or state. 54 */ 55 int filter_read_simple(i_ctx_t *i_ctx_p, 56 const stream_template * template); 57 int filter_write_simple(i_ctx_t *i_ctx_p, 58 const stream_template * template); 59 60 /* Mark a filter stream as temporary. */ 61 /* See stream.h for the meaning of is_temp. */ 62 void filter_mark_temp(const ref * fop, int is_temp); 63 64 /* Mark the source or target of a filter as temporary, and propagate */ 65 /* close_strm from the temporary stream to the filter. */ 66 void filter_mark_strm_temp(const ref * fop, int is_temp); 67 68 /* Define a standard report_error procedure for filters, */ 69 /* that records the error message in $error.errorinfo. */ 70 stream_proc_report_error(filter_report_error); 71 72 /* 73 * Define the state of a procedure-based stream. 74 * Note that procedure-based streams are defined at the Ghostscript 75 * interpreter level, unlike all other stream types which depend only 76 * on the stream package and the memory manager. 77 */ 78 typedef struct stream_proc_state_s { 79 stream_state_common; 80 bool eof; 81 uint index; /* current index within data */ 82 ref proc; 83 ref data; 84 } stream_proc_state; 85 86 #define private_st_stream_proc_state() /* in zfproc.c */\ 87 gs_private_st_complex_only(st_sproc_state, stream_proc_state,\ 88 "procedure stream state", sproc_clear_marks, sproc_enum_ptrs, sproc_reloc_ptrs, 0) 89 90 /* Test whether a stream is procedure-based. */ 91 bool s_is_proc(const stream *s); 92 93 #endif /* ifilter_INCLUDED */ 94