• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Private image library definitions for CUPS.
3  *
4  * Copyright © 2007-2019 by Apple Inc.
5  * Copyright © 1993-2006 by Easy Software Products.
6  *
7  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
8  * information.
9  */
10 
11 #ifndef _CUPS_RASTER_PRIVATE_H_
12 #  define _CUPS_RASTER_PRIVATE_H_
13 
14 /*
15  * Include necessary headers...
16  */
17 
18 #  include "raster.h"
19 #  include <cups/cups.h>
20 #  include <cups/debug-private.h>
21 #  include <cups/string-private.h>
22 #  ifdef _WIN32
23 #    include <io.h>
24 #    include <winsock2.h>		/* for htonl() definition */
25 #  else
26 #    include <unistd.h>
27 #    include <fcntl.h>
28 #  endif /* _WIN32 */
29 
30 #  ifdef __cplusplus
31 extern "C" {
32 #  endif /* __cplusplus */
33 
34 
35 /*
36  * Structure...
37  */
38 
39 struct _cups_raster_s			/**** Raster stream data ****/
40 {
41   unsigned		sync;		/* Sync word from start of stream */
42   void			*ctx;		/* File descriptor */
43   cups_raster_iocb_t	iocb;		/* IO callback */
44   cups_mode_t		mode;		/* Read/write mode */
45   cups_page_header2_t	header;		/* Raster header for current page */
46   unsigned		rowheight,	/* Row height in lines */
47 			count,		/* Current row run-length count */
48 			remaining,	/* Remaining rows in page image */
49 			bpp;		/* Bytes per pixel/color */
50   unsigned char		*pixels,	/* Pixels for current row */
51 			*pend,		/* End of pixel buffer */
52 			*pcurrent;	/* Current byte in pixel buffer */
53   int			compressed,	/* Non-zero if data is compressed */
54 			swapped;	/* Non-zero if data is byte-swapped */
55   unsigned char		*buffer,	/* Read/write buffer */
56 			*bufptr,	/* Current (read) position in buffer */
57 			*bufend;	/* End of current (read) buffer */
58   size_t		bufsize;	/* Buffer size */
59 #  ifdef DEBUG
60   size_t		iostart,	/* Start of read/write buffer */
61 			iocount;	/* Number of bytes read/written */
62 #  endif /* DEBUG */
63   unsigned		apple_page_count;/* Apple raster page count */
64 };
65 
66 
67 #if 0
68 /*
69  * min/max macros...
70  */
71 
72 #  ifndef max
73 #    define 	max(a,b)	((a) > (b) ? (a) : (b))
74 #  endif /* !max */
75 #  ifndef min
76 #    define 	min(a,b)	((a) < (b) ? (a) : (b))
77 #  endif /* !min */
78 #endif // 0
79 
80 
81 /*
82  * Prototypes...
83  */
84 
85 extern void		_cupsRasterAddError(const char *f, ...) _CUPS_FORMAT(1,2) _CUPS_PRIVATE;
86 extern void		_cupsRasterClearError(void) _CUPS_PRIVATE;
87 extern const char	*_cupsRasterColorSpaceString(cups_cspace_t cspace) _CUPS_PRIVATE;
88 extern void		_cupsRasterDelete(cups_raster_t *r) _CUPS_PRIVATE;
89 extern const char	*_cupsRasterErrorString(void) _CUPS_PRIVATE;
90 extern int		_cupsRasterInitPWGHeader(cups_page_header2_t *h, pwg_media_t *media, const char *type, int xdpi, int ydpi, const char *sides, const char *sheet_back) _CUPS_PRIVATE;
91 extern cups_raster_t	*_cupsRasterNew(cups_raster_iocb_t iocb, void *ctx, cups_mode_t mode) _CUPS_PRIVATE;
92 extern unsigned		_cupsRasterReadHeader(cups_raster_t *r) _CUPS_PRIVATE;
93 extern unsigned		_cupsRasterReadPixels(cups_raster_t *r, unsigned char *p, unsigned len) _CUPS_PRIVATE;
94 extern unsigned		_cupsRasterWriteHeader(cups_raster_t *r) _CUPS_PRIVATE;
95 extern unsigned		_cupsRasterWritePixels(cups_raster_t *r, unsigned char *p, unsigned len) _CUPS_PRIVATE;
96 
97 #  ifdef __cplusplus
98 }
99 #  endif /* __cplusplus */
100 
101 #endif /* !_CUPS_RASTER_PRIVATE_H_ */
102