Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1991, 1995, 1997, 1998, 1999 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: iutil.h,v 1.8 2004/08/19 19:33:09 stefan Exp $ */
18
/* Interface to interpreter utilities */
19
/* Requires imemory.h, ostack.h */
20
 
21
#ifndef iutil_INCLUDED
22
#  define iutil_INCLUDED
23
 
24
/* ------ Object utilities ------ */
25
 
26
/* Copy refs from one place to another. */
27
/* (If we are copying to the stack, we can just use memcpy.) */
28
void refcpy_to_new(ref * to, const ref * from, uint size,
29
		   gs_dual_memory_t *dmem);
30
int refcpy_to_old(ref * aref, uint index, const ref * from, uint size,
31
		  gs_dual_memory_t *dmem, client_name_t cname);
32
 
33
/*
34
 * Fill an array with nulls.
35
 * For backward compatibility, we define the procedure with a new name.
36
 */
37
void refset_null_new(ref * to, uint size, uint new_mask);
38
#define refset_null(to, size) refset_null_new(to, size, ialloc_new_mask)
39
 
40
/* Compare two objects for equality. */
41
bool obj_eq(const gs_memory_t *mem, const ref *, const ref *);
42
 
43
/* Compare two objects for identity. */
44
/* (This is not a standard PostScript concept.) */
45
bool obj_ident_eq(const gs_memory_t *mem, const ref *, const ref *);
46
 
47
/*
48
 * Set *pchars and *plen to point to the data of a name or string, and
49
 * return 0.  If the object isn't a name or string, return e_typecheck.
50
 * If the object is a string without read access, return e_invalidaccess.
51
 */
52
int obj_string_data(const gs_memory_t *mem, const ref *op, const byte **pchars, uint *plen);
53
 
54
/*
55
 * Create a printable representation of an object, a la cvs and =
56
 * (full_print = 0), == (full_print = 1), or === (full_print = 2).  Return 0
57
 * if OK, 1 if the destination wasn't large enough, e_invalidaccess if the
58
 * object's contents weren't readable.  If the return value is 0 or 1,
59
 * *prlen contains the amount of data returned.  start_pos is the starting
60
 * output position -- the first start_pos bytes of output are discarded.
61
 *
62
 * The mem argument is only used for getting the type of structures,
63
 * not for allocating; if it is NULL and full_print != 0, structures will
64
 * print as --(struct)--.
65
 */
66
#define CVP_MAX_STRING 200  /* strings are truncated here if full_print = 1 */
67
int obj_cvp(const ref * op, byte *str, uint len, uint * prlen,
68
	    int full_print, uint start_pos, const gs_memory_t *mem);
69
 
70
/*
71
 * Create a printable representation of an object, a la cvs and =.  Return 0
72
 * if OK, e_rangecheck if the destination wasn't large enough,
73
 * e_invalidaccess if the object's contents weren't readable.  If pchars !=
74
 * NULL, then if the object was a string or name, store a pointer to its
75
 * characters in *pchars even if it was too large; otherwise, set *pchars =
76
 * str.  In any case, store the length in *prlen.
77
 *
78
 * obj_cvs is different from obj_cvp in two respects: if the printed
79
 * representation is too large, it returns e_rangecheck rather than 1;
80
 * and it can return a pointer to the data for names and strings, like
81
 * obj_string_data.
82
 */
83
int obj_cvs(const gs_memory_t *mem, const ref * op, byte * str, uint len, uint * prlen,
84
	    const byte ** pchars);
85
 
86
/* Get an element from an array (packed or not). */
87
int array_get(const gs_memory_t *mem, const ref *, long, ref *);
88
 
89
/* Get an element from a packed array. */
90
/* (This works for ordinary arrays too.) */
91
/* Source and destination are allowed to overlap if the source is packed, */
92
/* or if they are identical. */
93
void packed_get(const gs_memory_t *mem, const ref_packed *, ref *);
94
 
95
/* Check to make sure an interval contains no object references */
96
/* to a space younger than a given one. */
97
/* Return 0 or e_invalidaccess. */
98
int refs_check_space(const ref * refs, uint size, uint space);
99
 
100
/* ------ String utilities ------ */
101
 
102
/* Convert a C string to a string object. */
103
int string_to_ref(const char *, ref *, gs_ref_memory_t *, client_name_t);
104
 
105
/* Convert a string object to a C string. */
106
/* Return 0 iff the buffer can't be allocated. */
107
char *ref_to_string(const ref *, gs_memory_t *, client_name_t);
108
 
109
/* ------ Operand utilities ------ */
110
 
111
/* Get N numeric operands from the stack or an array. */
112
int num_params(const ref *, int, double *);
113
 
114
/* float_params can lose accuracy for large integers. */
115
int float_params(const ref *, int, float *);
116
 
117
/* process_float_array can lose accuracy for large integers */
118
int process_float_array(const gs_memory_t *mem, const ref *, int, float *);
119
 
120
/* Get a single real parameter. */
121
/* The only possible error is e_typecheck. */
122
int real_param(const ref *, double *);
123
 
124
/* float_param can lose accuracy for large integers. */
125
int float_param(const ref *, float *);
126
 
127
/* Get an integer parameter in a given range. */
128
int int_param(const ref *, int, int *);
129
 
130
/* Make real values on the stack. */
131
/* Return e_limitcheck for infinities or double->float overflow. */
132
int make_reals(ref *, const double *, int);
133
int make_floats(ref *, const float *, int);
134
 
135
/* Define the gs_matrix type if necessary. */
136
#ifndef gs_matrix_DEFINED
137
#  define gs_matrix_DEFINED
138
typedef struct gs_matrix_s gs_matrix;
139
#endif
140
 
141
/* Read a matrix operand. */
142
int read_matrix(const gs_memory_t *mem, const ref *, gs_matrix *);
143
 
144
/* Write a matrix operand. */
145
/* If dmem is NULL, the array is guaranteed newly allocated in imem. */
146
/* If dmem is not NULL, imem is ignored. */
147
int write_matrix_in(ref *op, const gs_matrix *pmat, gs_dual_memory_t *dmem,
148
		    gs_ref_memory_t *imem);
149
#define write_matrix_new(op, pmat, imem)\
150
  write_matrix_in(op, pmat, NULL, imem)
151
#define write_matrix(op, pmat)\
152
  write_matrix_in(op, pmat, idmemory, NULL)
153
 
154
#endif /* iutil_INCLUDED */