CHANGES IN CUPS V1.1.20rc1
+ - The PDF filter always scaled and offset pages; this
+ caused problems under MacOS X, so now the "fitplot"
+ option controls whether PDF files are scaled to fit
+ within the printable area of the page (STR #250)
+ - The LPD backend did not support the port number in a
+ URI (STR #247)
+ - Some filters didn't properly support boolean options
+ (STR #249)
+ - Landscape PDF files were not always offset by the
+ correct amount when rotating (STR #243)
- The scheduler could hang in a call to localtime() when
logging messages from the signal handler (STR #242)
- The PDF filter no longer prints form widgets; this
/*
- * "$Id: lpd.c,v 1.28.2.23 2003/07/29 12:53:01 mike Exp $"
+ * "$Id: lpd.c,v 1.28.2.24 2003/08/28 14:36:51 mike Exp $"
*
* Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
*
*/
static int lpd_command(int lpd_fd, int timeout, char *format, ...);
-static int lpd_queue(char *hostname, char *printer, char *filename,
- char *user, char *title, int copies,
+static int lpd_queue(const char *hostname, int port, const char *printer,
+ const char *filename,
+ const char *user, const char *title, int copies,
int banner, int format, int order, int reserve,
int manual_copies, int timeout);
static void lpd_timeout(int sig);
copies = atoi(argv[4]);
}
- status = lpd_queue(hostname, resource + 1, filename,
+ status = lpd_queue(hostname, port, resource + 1, filename,
argv[2] /* user */, title, copies,
banner, format, order, reserve, manual_copies, timeout);
fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4]));
}
else
- status = lpd_queue(hostname, resource + 1, filename,
+ status = lpd_queue(hostname, port, resource + 1, filename,
argv[2] /* user */, title, 1,
banner, format, order, reserve, 1, timeout);
*/
static int /* O - Zero on success, non-zero on failure */
-lpd_queue(char *hostname, /* I - Host to connect to */
- char *printer, /* I - Printer/queue name */
- char *filename, /* I - File to print */
- char *user, /* I - Requesting user */
- char *title, /* I - Job title */
- int copies, /* I - Number of copies */
- int banner, /* I - Print LPD banner? */
- int format, /* I - Format specifier */
- int order, /* I - Order of data/control files */
- int reserve, /* I - Reserve ports? */
- int manual_copies, /* I - Do copies by hand... */
- int timeout) /* I - Timeout... */
+lpd_queue(const char *hostname, /* I - Host to connect to */
+ int port, /* I - Port to connect on */
+ const char *printer, /* I - Printer/queue name */
+ const char *filename, /* I - File to print */
+ const char *user, /* I - Requesting user */
+ const char *title, /* I - Job title */
+ int copies, /* I - Number of copies */
+ int banner, /* I - Print LPD banner? */
+ int format, /* I - Format specifier */
+ int order, /* I - Order of data/control files */
+ int reserve, /* I - Reserve ports? */
+ int manual_copies, /* I - Do copies by hand... */
+ int timeout) /* I - Timeout... */
{
FILE *fp; /* Job file */
char localhost[255]; /* Local host name */
int error; /* Error number */
struct stat filestats; /* File statistics */
- int port; /* LPD connection port */
+ int lport; /* LPD connection local port */
int fd; /* LPD socket */
char control[10240], /* LPD control 'file' */
*cptr; /* Pointer into control file string */
memset(&addr, 0, sizeof(addr));
memcpy(&(addr.sin_addr), hostaddr->h_addr, hostaddr->h_length);
addr.sin_family = hostaddr->h_addrtype;
- addr.sin_port = htons(515); /* LPD/printer service */
+ addr.sin_port = htons(port);
- for (port = 732;;)
+ for (lport = 732;;)
{
if (getuid() || !reserve)
{
return (1);
}
- port = 515;
+ lport = 0;
}
else
{
/*
* We're running as root and want to comply with RFC 1179. Reserve a
- * priviledged port between 721 and 732...
+ * priviledged lport between 721 and 732...
*/
- if ((fd = rresvport(&port)) < 0)
+ if ((fd = rresvport(&lport)) < 0)
{
perror("ERROR: Unable to reserve port");
sleep(30);
break;
}
- fprintf(stderr, "INFO: Connected from port %d...\n", port);
+ fprintf(stderr, "INFO: Connected to %s...\n", hostname);
+ fprintf(stderr, "DEBUG: Connected on ports %d (local %d)...\n", port,
+ lport);
/*
* Next, open the print file and figure out its size...
/*
- * End of "$Id: lpd.c,v 1.28.2.23 2003/07/29 12:53:01 mike Exp $".
+ * End of "$Id: lpd.c,v 1.28.2.24 2003/08/28 14:36:51 mike Exp $".
*/
/*
- * "$Id: http-support.c,v 1.1.2.3 2003/02/04 05:10:17 mike Exp $"
+ * "$Id: http-support.c,v 1.1.2.4 2003/08/28 14:36:52 mike Exp $"
*
* HTTP support routines for the Common UNIX Printing System (CUPS) scheduler.
*
*port = 443;
else if (strcasecmp(method, "ipp") == 0)
*port = ippPort();
+ else if (strcasecmp(method, "lpd") == 0)
+ *port = 515;
else if (strcasecmp(method, "socket") == 0) /* Not registered yet... */
*port = 9100;
else
/*
- * End of "$Id: http-support.c,v 1.1.2.3 2003/02/04 05:10:17 mike Exp $".
+ * End of "$Id: http-support.c,v 1.1.2.4 2003/08/28 14:36:52 mike Exp $".
*/
/*
- * "$Id: hpgl-main.c,v 1.22.2.4 2003/03/21 02:45:03 mike Exp $"
+ * "$Id: hpgl-main.c,v 1.22.2.5 2003/08/28 14:36:53 mike Exp $"
*
* HP-GL/2 filter main entry for the Common UNIX Printing System (CUPS).
*
shading = 1;
PenWidth = 1.0;
- if ((val = cupsGetOption("blackplot", num_options, options)) != NULL)
+ if ((val = cupsGetOption("blackplot", num_options, options)) != NULL &&
+ strcasecmp(val, "no") && strcasecmp(val, "off") &&
+ strcasecmp(val, "false"))
shading = 0;
- if ((val = cupsGetOption("fitplot", num_options, options)) != NULL)
+ if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+ strcasecmp(val, "no") && strcasecmp(val, "off") &&
+ strcasecmp(val, "false"))
FitPlot = 1;
if ((val = cupsGetOption("penwidth", num_options, options)) != NULL)
/*
- * End of "$Id: hpgl-main.c,v 1.22.2.4 2003/03/21 02:45:03 mike Exp $".
+ * End of "$Id: hpgl-main.c,v 1.22.2.5 2003/08/28 14:36:53 mike Exp $".
*/
/*
- * "$Id: pstops.c,v 1.54.2.44 2003/08/11 18:40:58 mike Exp $"
+ * "$Id: pstops.c,v 1.54.2.45 2003/08/28 14:36:53 mike Exp $"
*
* PostScript filter for the Common UNIX Printing System (CUPS).
*
}
if ((val = cupsGetOption("Collate", num_options, options)) != NULL &&
- !strcasecmp(val, "True"))
+ (!strcasecmp(val, "true") ||!strcasecmp(val, "on") ||
+ !strcasecmp(val, "yes")))
Collate = 1;
if ((val = cupsGetOption("OutputOrder", num_options, options)) != NULL &&
b = atoi(val) * 0.01f;
if ((val = cupsGetOption("mirror", num_options, options)) != NULL &&
- !strcasecmp(val, "True"))
+ (!strcasecmp(val, "true") ||!strcasecmp(val, "on") ||
+ !strcasecmp(val, "yes")))
Flip = 1;
/*
/*
- * End of "$Id: pstops.c,v 1.54.2.44 2003/08/11 18:40:58 mike Exp $".
+ * End of "$Id: pstops.c,v 1.54.2.45 2003/08/28 14:36:53 mike Exp $".
*/
/*
- * "$Id: textcommon.c,v 1.16.2.12 2003/04/25 14:42:38 mike Exp $"
+ * "$Id: textcommon.c,v 1.16.2.13 2003/08/28 14:36:54 mike Exp $"
*
* Common text filter routines for the Common UNIX Printing System (CUPS).
*
num_options = cupsParseOptions(argv[5], 0, &options);
if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
- strcasecmp(val, "no") != 0 && strcasecmp(val, "off") != 0 &&
- strcasecmp(val, "false") != 0)
+ strcasecmp(val, "no") && strcasecmp(val, "off") &&
+ strcasecmp(val, "false"))
{
PageLeft = 72.0f;
PageRight = PageWidth - 36.0f;
if ((val = cupsGetOption("wrap", num_options, options)) == NULL)
WrapLines = 1;
else
- WrapLines = strcasecmp(val, "true") == 0;
+ WrapLines = !strcasecmp(val, "true") || !strcasecmp(val, "on") ||
+ !strcasecmp(val, "yes");
if ((val = cupsGetOption("columns", num_options, options)) != NULL)
PageColumns = atoi(val);
/*
- * End of "$Id: textcommon.c,v 1.16.2.12 2003/04/25 14:42:38 mike Exp $".
+ * End of "$Id: textcommon.c,v 1.16.2.13 2003/08/28 14:36:54 mike Exp $".
*/
return d;
}
+GBool GlobalParams::getPSFit() {
+ GBool d;
+
+ globalParamsLock;
+ d = psFit;
+ globalParamsUnlock;
+ return d;
+}
+
PSLevel GlobalParams::getPSLevel() {
PSLevel level;
globalParamsUnlock;
}
+void GlobalParams::setPSFit(GBool fit) {
+ globalParamsLock;
+ psFit = fit;
+ globalParamsUnlock;
+}
+
void GlobalParams::setPSLevel(PSLevel level) {
globalParamsLock;
psLevel = level;
int getPSPaperWidth();
int getPSPaperHeight();
GBool getPSDuplex();
+ GBool getPSFit();
PSLevel getPSLevel();
PSFontParam *getPSFont(GString *fontName);
PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
void setPSPaperWidth(int width);
void setPSPaperHeight(int height);
void setPSDuplex(GBool duplex);
+ void setPSFit(GBool fit);
void setPSLevel(PSLevel level);
void setPSEmbedType1(GBool embed);
void setPSEmbedTrueType(GBool embed);
int psRight; // ...
int psTop; // ...
GBool psDuplex; // enable duplexing in PostScript?
+ GBool psFit; // fit pages to device?
PSLevel psLevel; // PostScript level to generate
GHash *psFonts; // PostScript font info, indexed by PDF
// font name [PSFontParam]
int imageWidth, imageHeight;
int left, bottom, right, top;
- globalParams->getPSImageableArea(left, bottom, right, top);
+ if (globalParams->getPSFit()) {
+ globalParams->getPSImageableArea(left, bottom, right, top);
+ } else {
+ left = bottom = 0;
+ right = globalParams->getPSPaperWidth();
+ top = globalParams->getPSPaperHeight();
+ }
+
imageWidth = right - left;
imageHeight = top - bottom;
case psModePS:
writePSFmt("%%%%Page: %d %d\n", pageNum, seqPage);
- // rotate, translate, and scale page
+ // possibly rotate, translate, and scale page
x1 = (int)(state->getX1() + 0.5);
y1 = (int)(state->getY1() + 0.5);
x2 = (int)(state->getX2() + 0.5);
writePS("%%BeginPageSetup\n");
width = x2 - x1;
height = y2 - y1;
+ tx = 0;
+ ty = 0;
if (width > height && width > imageWidth) {
landscape = gTrue;
writePSFmt("%%%%PageOrientation: %s\n",
state->getCTM()[0] ? "Landscape" : "Portrait");
writePS("pdfStartPage\n");
writePS("90 rotate\n");
- tx = -x1;
- ty = -(y1 + imageWidth);
+ ty = -globalParams->getPSPaperWidth();
t = width;
width = height;
height = t;
writePSFmt("%%%%PageOrientation: %s\n",
state->getCTM()[0] ? "Portrait" : "Landscape");
writePS("pdfStartPage\n");
- tx = -x1;
- ty = -y1;
+ }
+ if (globalParams->getPSFit()) {
+ tx -= x1;
+ ty -= y1;
}
tx += left;
ty += bottom;
if (tx != 0 || ty != 0) {
writePSFmt("%g %g translate\n", tx, ty);
}
- if (width > imageWidth || height > imageHeight) {
+ if ((width > imageWidth || height > imageHeight) && globalParams->getPSFit()) {
xScale = (double)imageWidth / (double)width;
yScale = (double)imageHeight / (double)height;
if (yScale < xScale) {
//
-// "$Id: pdftops.cxx,v 1.6.2.6 2003/07/25 20:26:21 mike Exp $"
+// "$Id: pdftops.cxx,v 1.6.2.7 2003/08/28 14:36:57 mike Exp $"
//
// PDF to PostScript filter front-end for the Common UNIX Printing
// System (CUPS).
main(int argc, // I - Number of command-line args
char *argv[]) // I - Command-line arguments
{
- PDFDoc *doc;
- GString *fileName;
- GString *psFileName;
- PSLevel level;
- PSOutputDev *psOut;
- int num_options;
- cups_option_t *options;
- const char *val;
- ppd_file_t *ppd;
- ppd_size_t *size;
- FILE *fp;
- const char *server_root;
- char tempfile[1024];
- char buffer[8192];
- int bytes;
- int width, length;
+ PDFDoc *doc; // Input file
+ GString *fileName; // Input filename
+ GString *psFileName; // Output filename
+ PSLevel level; // PostScript level
+ PSOutputDev *psOut; // Output device
+ int num_options; // Number of options
+ cups_option_t *options; // Options
+ const char *val; // Option value
+ ppd_file_t *ppd; // Current PPD
+ ppd_size_t *size; // Current media size
+ FILE *fp; // Copy file
+ const char *server_root; // Location of config files
+ char tempfile[1024]; // Temporary file
+ char buffer[8192]; // Copy buffer
+ int bytes; // Bytes copied
+ int width, length; // Size in points
int left, bottom, right, top;
- int orientation;
- int temp;
- int duplex;
+ // Imageable area in points
+ int orientation; // Orientation
+ int temp; // Temporary var
+ int duplex; // Duplex the output?
+ int fit; // Fit the pages to the output
// Make sure status messages are not buffered...
length = 792;
level = psLevel2;
duplex = 0;
+ fit = 0;
// Get PPD and initialize options as needed...
num_options = cupsParseOptions(argv[5], 0, &options);
break;
}
+ if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+ strcasecmp(val, "no") && strcasecmp(val, "off") &&
+ strcasecmp(val, "false"))
+ fit = 1;
+
if ((val = cupsGetOption("sides", num_options, options)) != NULL &&
strncasecmp(val, "two-", 4) == 0)
duplex = 1;
globalParams->setPSPaperHeight(length);
globalParams->setPSImageableArea(left, bottom, right, top);
globalParams->setPSDuplex(duplex);
+ globalParams->setPSFit(fit);
globalParams->setPSLevel(level);
globalParams->setPSASCIIHex(level == psLevel1);
globalParams->setPSEmbedType1(1);
//
-// End of "$Id: pdftops.cxx,v 1.6.2.6 2003/07/25 20:26:21 mike Exp $".
+// End of "$Id: pdftops.cxx,v 1.6.2.7 2003/08/28 14:36:57 mike Exp $".
//