1 /* Copyright (C) 1990, 1995, 1997, 1998 Aladdin Enterprises. All rights reserved.
3 This file is part of GNU Ghostscript.
5 GNU Ghostscript is distributed in the hope that it will be useful, but
6 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
7 to anyone for the consequences of using it or for whether it serves any
8 particular purpose or works at all, unless he says so in writing. Refer
9 to the GNU General Public License for full details.
11 Everyone is granted permission to copy, modify and redistribute GNU
12 Ghostscript, but only under the conditions described in the GNU General
13 Public License. A copy of this license is supposed to have been given
14 to you along with GNU Ghostscript so you can know your rights and
15 responsibilities. It should be in a file named COPYING. Among other
16 things, the copyright notice and this notice must be preserved on all
19 Aladdin Enterprises supports the work of the GNU Project, but is not
20 affiliated with the Free Software Foundation or the GNU Project. GNU
21 Ghostscript, as distributed by Aladdin Enterprises, does not require any
22 GNU software to build or run it.
26 /* Level 2 binary object sequence operators */
34 /* Current binary format (in iscan.c) */
35 extern ref ref_binary_object_format
;
37 /* System and user name arrays. */
38 ref binary_token_names
; /* array of size 2 */
39 private ref
*const binary_token_names_p
= &binary_token_names
;
41 /* Import the Level 2 scanner extensions. */
42 typedef struct scanner_state_s scanner_state
;
43 extern int scan_binary_token(P3(stream
*, ref
*, scanner_state
*));
44 extern int (*scan_btoken_proc
) (P3(stream
*, ref
*, scanner_state
*));
46 /* Initialize the binary token machinery. */
50 /* Initialize fake system and user name tables. */
51 /* PostScript code will install the real system name table. */
52 ialloc_ref_array(&binary_token_names
, 0 /*a_noaccess */ , 2,
53 "binary token names");
54 make_empty_array(system_names_p
, a_readonly
);
55 make_empty_array(user_names_p
, a_all
);
56 gs_register_ref_root(imemory
, NULL
, (void **)&binary_token_names_p
,
57 "binary token names");
59 /* Set up Level 2 scanning constants. */
60 scan_btoken_proc
= scan_binary_token
;
63 /* <names> .installsystemnames - */
65 zinstallsystemnames(register os_ptr op
)
67 if (r_space(op
) != avm_global
)
68 return_error(e_invalidaccess
);
69 check_read_type(*op
, t_shortarray
);
70 ref_assign_old(NULL
, system_names_p
, op
, ".installsystemnames");
75 /* - currentobjectformat <int> */
77 zcurrentobjectformat(register os_ptr op
)
80 *op
= ref_binary_object_format
;
84 /* <int> setobjectformat - */
86 zsetobjectformat(register os_ptr op
)
88 check_type(*op
, t_integer
);
89 if (op
->value
.intval
< 0 || op
->value
.intval
> 4)
90 return_error(e_rangecheck
);
91 ref_assign_old(NULL
, &ref_binary_object_format
, op
, "setobjectformat");
96 /* <ref_offset> <char_offset> <obj> <string8> .bosobject */
97 /* <ref_offset'> <char_offset'> <string8> */
99 * This converts a single object to its binary object sequence
100 * representation, doing the dirty work of printobject and writeobject.
101 * (The main control is in PostScript code, so that we don't have to worry
102 * about interrupts or callouts in the middle of writing the various data
103 * items.) Note that this may or may not modify the 'unused' field.
107 zbosobject(os_ptr op
)
111 check_type(op
[-3], t_integer
);
112 check_type(op
[-2], t_integer
);
113 check_write_type(*op
, t_string
);
115 return_error(e_rangecheck
);
116 code
= encode_binary_token(op
- 1, &op
[-3].value
.intval
,
117 &op
[-2].value
.intval
, op
->value
.bytes
);
121 r_set_size(op
- 1, 8);
126 /* ------ Initialization procedure ------ */
128 const op_def zbseq_l2_op_defs
[] =
130 op_def_begin_level2(),
131 {"1.installsystemnames", zinstallsystemnames
},
132 {"0currentobjectformat", zcurrentobjectformat
},
133 {"1setobjectformat", zsetobjectformat
},
134 {"4.bosobject", zbosobject
},
135 op_def_end(zbseq_init
)