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