xref: /plan9/sys/src/cmd/gs/src/gslibctx.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Portions Copyright (C) 2003 artofcode LLC.
2    Portions Copyright (C) 2003 Artifex Software Inc.
3    This software is based in part on the work of the Independent JPEG Group.
4    All Rights Reserved.
5 
6    This software is distributed under license and may not be copied, modified
7    or distributed except as expressly authorized under the terms of that
8    license.  Refer to licensing information at http://www.artifex.com/ or
9    contact Artifex Software, Inc., 101 Lucas Valley Road #110,
10    San Rafael, CA  94903, (415)492-9861, for further information. */
11 
12 /*$Id: gslibctx.h,v 1.5 2004/11/03 17:46:16 giles Exp $ */
13 #ifndef GSLIBCTX_H
14 #define GSLIBCTX_H
15 
16 #include "std.h"
17 #include "stdio_.h"
18 #include "gs_dll_call.h"
19 
20 
21 typedef struct name_table_s *name_table_ptr;
22 
23 typedef struct gs_lib_ctx_s
24 {
25     gs_memory_t *memory;  /* mem->gs_lib_ctx->memory == mem */
26     FILE *fstdin;
27     FILE *fstdout;
28     FILE *fstderr;
29     FILE *fstdout2;		/* for redirecting %stdout and diagnostics */
30     bool stdout_is_redirected;	/* to stderr or fstdout2 */
31     bool stdout_to_stderr;
32     bool stdin_is_interactive;
33     void *caller_handle;	/* identifies caller of GS DLL/shared object */
34     int (GSDLLCALL *stdin_fn)(void *caller_handle, char *buf, int len);
35     int (GSDLLCALL *stdout_fn)(void *caller_handle, const char *str, int len);
36     int (GSDLLCALL *stderr_fn)(void *caller_handle, const char *str, int len);
37     int (GSDLLCALL *poll_fn)(void *caller_handle);
38     ulong gs_next_id; /* gs_id initialized here, private variable of gs_next_ids() */
39     void *top_of_system;  /* use accessor functions to walk down the system
40 			   * to the desired structure gs_lib_ctx_get_*()
41 			   */
42     name_table_ptr gs_name_table;  /* hack this is the ps interpreters name table
43 				    * doesn't belong here
44 				    */
45     /* Define whether dictionaries expand automatically when full. */
46     bool dict_auto_expand;  /* ps dictionary: false level 1 true level 2 or 3 */
47 } gs_lib_ctx_t;
48 
49 /** initializes and stores itself in the given gs_memory_t pointer.
50  * it is the responsibility of the gs_memory_t objects to copy
51  * the pointer to subsequent memory objects.
52  */
53 int gs_lib_ctx_init( gs_memory_t *mem );
54 
55 void *gs_lib_ctx_get_interp_instance( gs_memory_t *mem );
56 
57 /* HACK to get at non garbage collection memory pointer
58  *
59  */
60 const gs_memory_t * gs_lib_ctx_get_non_gc_memory_t(void);
61 
62 #endif /* GSLIBCTX_H */
63