1 /* Copyright (C) 2001-2012 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied,
8    modified or distributed except as expressly authorized under the terms
9    of the license contained in the file LICENSE in this distribution.
10 
11    Refer to licensing information at http://www.artifex.com or contact
12    Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
13    CA  94903, U.S.A., +1(415)492-9861, for further information.
14 */
15 
16 
17 /* Utilities for PCL XL generation */
18 /* Requires gdevpxat.h, gdevpxen.h, gdevpxop.h */
19 
20 #ifndef gdevpxut_INCLUDED
21 #  define gdevpxut_INCLUDED
22 
23 /* ---------------- High-level constructs ---------------- */
24 
25 /* Write the file header, including the resolution. */
26 int px_write_file_header(stream *s, const gx_device *dev);
27 
28 /* Write the page header, including orientation. */
29 int px_write_page_header(stream *s, const gx_device *dev);
30 
31 /* Write the media selection command if needed, updating the media size. */
32 int px_write_select_media(stream *s, const gx_device *dev,
33                           pxeMediaSize_t *pms,
34                           byte *media_source,
35                           int page, bool Duplex, bool Tumble);
36 
37 /*
38  * Write the file trailer.  Note that this takes a FILE *, not a stream *,
39  * since it may be called after the stream is closed.
40  */
41 int px_write_file_trailer(FILE *file);
42 
43 /* ---------------- Low-level data output ---------------- */
44 
45 /* Write a sequence of bytes. */
46 #define PX_PUT_LIT(s, bytes) px_put_bytes(s, bytes, sizeof(bytes))
47 void px_put_bytes(stream * s, const byte * data, uint count);
48 
49 /* Utilities for writing data values. */
50 /* H-P printers only support little-endian data, so that's what we emit. */
51 
52 #define DA(a) pxt_attr_ubyte, (a)
53 void px_put_a(stream * s, px_attribute_t a);
54 void px_put_ac(stream *s, px_attribute_t a, px_tag_t op);
55 
56 #define DUB(b) pxt_ubyte, (byte)(b)
57 void px_put_ub(stream * s, byte b);
58 void px_put_uba(stream *s, byte b, px_attribute_t a);
59 
60 /* signed and unsigned shorts */
61 #define DS(i) (byte)(i), (byte)(((i) >= 0 ? (i) : ((i)|0x8000)) >> 8)
62 #define US(i) (byte)(i), (byte)((i) >> 8)
63 void px_put_s(stream * s, int i);
64 
65 #define DUS(i) pxt_uint16, US(i)
66 void px_put_us(stream * s, uint i);
67 void px_put_usa(stream *s, uint i, px_attribute_t a);
68 void px_put_u(stream * s, uint i);
69 
70 #define DUSP(ix,iy) pxt_uint16_xy, US(ix), US(iy)
71 void px_put_usp(stream * s, uint ix, uint iy);
72 void px_put_usq_fixed(stream * s, fixed x0, fixed y0, fixed x1, fixed y1);
73 
74 void px_put_ss(stream * s, int i);
75 void px_put_ssp(stream * s, int ix, int iy);
76 
77 void px_put_l(stream * s, ulong l);
78 
79 void px_put_r(stream * s, floatp r);  /* no tag */
80 void px_put_rl(stream * s, floatp r);  /* pxt_real32 tag */
81 void px_put_rp(stream * s, floatp rx, floatp ry);
82 void px_put_rpa(stream * s, floatp rx, floatp ry, px_attribute_t a);
83 
84 void px_put_data_length(stream * s, uint num_bytes);
85 
86 #endif /* gdevpxut_INCLUDED */
87