/*
- * "$Id$"
+ * Hewlett-Packard Page Control Language filter for CUPS.
*
- * Hewlett-Packard Page Control Language filter for CUPS.
+ * Copyright 2007-2015 by Apple Inc.
+ * Copyright 1993-2007 by Easy Software Products.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * missing or damaged, see the license at "http://www.cups.org/".
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * Setup() - Prepare the printer for printing.
- * StartPage() - Start a page of graphics.
- * EndPage() - Finish a page of graphics.
- * Shutdown() - Shutdown the printer.
- * CancelJob() - Cancel the current job...
- * CompressData() - Compress a line of graphics.
- * OutputLine() - Output a line of graphics.
- * main() - Main entry and processing of driver.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
unsigned char *Planes[4], /* Output buffers */
*CompBuffer, /* Compression buffer */
*BitBuffer; /* Buffer for output bits */
-int NumPlanes, /* Number of color planes */
+unsigned NumPlanes, /* Number of color planes */
ColorBits, /* Number of bits per color */
- Feed, /* Number of lines to skip */
- Duplex, /* Current duplex mode */
+ Feed; /* Number of lines to skip */
+int Duplex, /* Current duplex mode */
Page, /* Current page number */
Canceled; /* Has the current job been canceled? */
void Shutdown(void);
void CancelJob(int sig);
-void CompressData(unsigned char *line, int length, int plane, int type);
+void CompressData(unsigned char *line, unsigned length, unsigned plane, unsigned type);
void OutputLine(cups_page_header2_t *header);
StartPage(ppd_file_t *ppd, /* I - PPD file */
cups_page_header2_t *header) /* I - Page header */
{
- int plane; /* Looping var */
+ unsigned plane; /* Looping var */
/*
*/
fprintf(stderr, "DEBUG: StartPage...\n");
- fprintf(stderr, "DEBUG: MediaClass = \"%s\"\n", header->MediaClass);
- fprintf(stderr, "DEBUG: MediaColor = \"%s\"\n", header->MediaColor);
- fprintf(stderr, "DEBUG: MediaType = \"%s\"\n", header->MediaType);
- fprintf(stderr, "DEBUG: OutputType = \"%s\"\n", header->OutputType);
-
- fprintf(stderr, "DEBUG: AdvanceDistance = %d\n", header->AdvanceDistance);
- fprintf(stderr, "DEBUG: AdvanceMedia = %d\n", header->AdvanceMedia);
- fprintf(stderr, "DEBUG: Collate = %d\n", header->Collate);
- fprintf(stderr, "DEBUG: CutMedia = %d\n", header->CutMedia);
fprintf(stderr, "DEBUG: Duplex = %d\n", header->Duplex);
- fprintf(stderr, "DEBUG: HWResolution = [ %d %d ]\n", header->HWResolution[0],
- header->HWResolution[1]);
- fprintf(stderr, "DEBUG: ImagingBoundingBox = [ %d %d %d %d ]\n",
- header->ImagingBoundingBox[0], header->ImagingBoundingBox[1],
- header->ImagingBoundingBox[2], header->ImagingBoundingBox[3]);
- fprintf(stderr, "DEBUG: InsertSheet = %d\n", header->InsertSheet);
- fprintf(stderr, "DEBUG: Jog = %d\n", header->Jog);
- fprintf(stderr, "DEBUG: LeadingEdge = %d\n", header->LeadingEdge);
- fprintf(stderr, "DEBUG: Margins = [ %d %d ]\n", header->Margins[0],
- header->Margins[1]);
+ fprintf(stderr, "DEBUG: HWResolution = [ %d %d ]\n", header->HWResolution[0], header->HWResolution[1]);
+ fprintf(stderr, "DEBUG: ImagingBoundingBox = [ %d %d %d %d ]\n", header->ImagingBoundingBox[0], header->ImagingBoundingBox[1], header->ImagingBoundingBox[2], header->ImagingBoundingBox[3]);
+ fprintf(stderr, "DEBUG: Margins = [ %d %d ]\n", header->Margins[0], header->Margins[1]);
fprintf(stderr, "DEBUG: ManualFeed = %d\n", header->ManualFeed);
fprintf(stderr, "DEBUG: MediaPosition = %d\n", header->MediaPosition);
- fprintf(stderr, "DEBUG: MediaWeight = %d\n", header->MediaWeight);
- fprintf(stderr, "DEBUG: MirrorPrint = %d\n", header->MirrorPrint);
- fprintf(stderr, "DEBUG: NegativePrint = %d\n", header->NegativePrint);
fprintf(stderr, "DEBUG: NumCopies = %d\n", header->NumCopies);
fprintf(stderr, "DEBUG: Orientation = %d\n", header->Orientation);
- fprintf(stderr, "DEBUG: OutputFaceUp = %d\n", header->OutputFaceUp);
- fprintf(stderr, "DEBUG: PageSize = [ %d %d ]\n", header->PageSize[0],
- header->PageSize[1]);
- fprintf(stderr, "DEBUG: Separations = %d\n", header->Separations);
- fprintf(stderr, "DEBUG: TraySwitch = %d\n", header->TraySwitch);
- fprintf(stderr, "DEBUG: Tumble = %d\n", header->Tumble);
+ fprintf(stderr, "DEBUG: PageSize = [ %d %d ]\n", header->PageSize[0], header->PageSize[1]);
fprintf(stderr, "DEBUG: cupsWidth = %d\n", header->cupsWidth);
fprintf(stderr, "DEBUG: cupsHeight = %d\n", header->cupsHeight);
fprintf(stderr, "DEBUG: cupsMediaType = %d\n", header->cupsMediaType);
printf("\033*g26W");
putchar(2); /* Format 2 */
- putchar(NumPlanes); /* Output planes */
+ putchar((int)NumPlanes); /* Output planes */
- putchar(header->HWResolution[0] >> 8); /* Black resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Black resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of black levels */
- putchar(header->HWResolution[0] >> 8); /* Cyan resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Cyan resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of cyan levels */
- putchar(header->HWResolution[0] >> 8); /* Magenta resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Magenta resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of magenta levels */
- putchar(header->HWResolution[0] >> 8); /* Yellow resolution */
- putchar(header->HWResolution[0]);
- putchar(header->HWResolution[1] >> 8);
- putchar(header->HWResolution[1]);
+ putchar((int)(header->HWResolution[0] >> 8));/* Yellow resolution */
+ putchar((int)header->HWResolution[0]);
+ putchar((int)(header->HWResolution[1] >> 8));
+ putchar((int)header->HWResolution[1]);
putchar(0);
putchar(1 << ColorBits); /* # of yellow levels */
}
else
{
- printf("\033*t%dR", header->HWResolution[0]);
+ printf("\033*t%uR", header->HWResolution[0]);
/* Set resolution */
if (header->cupsColorSpace == CUPS_CSPACE_KCMY)
* Set size and position of graphics...
*/
- printf("\033*r%dS", header->cupsWidth); /* Set width */
- printf("\033*r%dT", header->cupsHeight); /* Set height */
+ printf("\033*r%uS", header->cupsWidth); /* Set width */
+ printf("\033*r%uT", header->cupsHeight); /* Set height */
printf("\033&a0H"); /* Set horizontal position */
printf("\033*r1A"); /* Start graphics */
if (header->cupsCompression)
- printf("\033*b%dM", /* Set compression */
+ printf("\033*b%uM", /* Set compression */
header->cupsCompression);
Feed = 0; /* No blank lines yet */
* Allocate memory for a line of graphics...
*/
- if ((Planes[0] = malloc(header->cupsBytesPerLine)) == NULL)
+ if ((Planes[0] = malloc(header->cupsBytesPerLine + NumPlanes)) == NULL)
{
fputs("ERROR: Unable to allocate memory\n", stderr);
exit(1);
BitBuffer = NULL;
if (header->cupsCompression)
- CompBuffer = malloc(header->cupsBytesPerLine * 2);
+ CompBuffer = malloc(header->cupsBytesPerLine * 2 + 2);
else
CompBuffer = NULL;
}
void
CompressData(unsigned char *line, /* I - Data to compress */
- int length, /* I - Number of bytes */
- int plane, /* I - Color plane */
- int type) /* I - Type of compression */
+ unsigned length, /* I - Number of bytes */
+ unsigned plane, /* I - Color plane */
+ unsigned type) /* I - Type of compression */
{
unsigned char *line_ptr, /* Current byte pointer */
*line_end, /* End-of-line byte pointer */
*comp_ptr, /* Pointer into compression buffer */
*start; /* Start of compression sequence */
- int count; /* Count of bytes for output */
+ unsigned count; /* Count of bytes for output */
switch (type)
count < 256;
count ++);
- comp_ptr[0] = count - 1;
+ comp_ptr[0] = (unsigned char)(count - 1);
comp_ptr[1] = line_ptr[0];
}
count ++;
}
- *comp_ptr++ = 257 - count;
+ *comp_ptr++ = (unsigned char)(257 - count);
*comp_ptr++ = *line_ptr++;
}
else
count ++;
}
- *comp_ptr++ = count - 1;
+ *comp_ptr++ = (unsigned char)(count - 1);
memcpy(comp_ptr, start, count);
comp_ptr += count;
*/
printf("\033*b%d%c", (int)(line_end - line_ptr), plane);
- fwrite(line_ptr, line_end - line_ptr, 1, stdout);
+ fwrite(line_ptr, (size_t)(line_end - line_ptr), 1, stdout);
}
void
OutputLine(cups_page_header2_t *header) /* I - Page header */
{
- int plane, /* Current plane */
+ unsigned plane, /* Current plane */
bytes, /* Bytes to write */
count; /* Bytes to convert */
unsigned char bit, /* Current plane data */
{
bit = plane_ptr[0];
- bit0 = ((bit & 64) << 1) | ((bit & 16) << 2) | ((bit & 4) << 3) | ((bit & 1) << 4);
- bit1 = (bit & 128) | ((bit & 32) << 1) | ((bit & 8) << 2) | ((bit & 2) << 3);
+ bit0 = (unsigned char)(((bit & 64) << 1) | ((bit & 16) << 2) | ((bit & 4) << 3) | ((bit & 1) << 4));
+ bit1 = (unsigned char)((bit & 128) | ((bit & 32) << 1) | ((bit & 8) << 2) | ((bit & 2) << 3));
if (count > 1)
{
bit = plane_ptr[1];
- bit0 |= (bit & 1) | ((bit & 4) >> 1) | ((bit & 16) >> 2) | ((bit & 64) >> 3);
- bit1 |= ((bit & 2) >> 1) | ((bit & 8) >> 2) | ((bit & 32) >> 3) | ((bit & 128) >> 4);
+ bit0 |= (unsigned char)((bit & 1) | ((bit & 4) >> 1) | ((bit & 16) >> 2) | ((bit & 64) >> 3));
+ bit1 |= (unsigned char)(((bit & 2) >> 1) | ((bit & 8) >> 2) | ((bit & 32) >> 3) | ((bit & 128) >> 4));
}
bit_ptr[0] = bit0;
int fd; /* File descriptor */
cups_raster_t *ras; /* Raster stream for printing */
cups_page_header2_t header; /* Page header from file */
- int y; /* Current line */
+ unsigned y; /* Current line */
ppd_file_t *ppd; /* PPD file */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
if ((y & 127) == 0)
{
_cupsLangPrintFilter(stderr, "INFO",
- _("Printing page %d, %d%% complete."),
+ _("Printing page %d, %u%% complete."),
Page, 100 * y / header.cupsHeight);
- fprintf(stderr, "ATTR: job-media-progress=%d\n",
+ fprintf(stderr, "ATTR: job-media-progress=%u\n",
100 * y / header.cupsHeight);
}
else
return (0);
}
-
-
-/*
- * End of "$Id$".
- */