/*
- * "$Id: common.c 4494 2005-02-18 02:18:11Z mike $"
+ * "$Id$"
*
- * Common filter routines for the Common UNIX Printing System (CUPS).
+ * Common filter routines for CUPS.
*
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Easy Software Products 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 please contact Easy Software Products
- * at:
+ * 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/".
*
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
- *
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * SetCommonOptions() - Set common filter options for media size,
- * etc.
- * UpdatePageVars() - Update the page variables for the orientation.
- * WriteCommon() - Write common procedures...
- * WriteLabelProlog() - Write the prolog with the classification
- * and page label.
- * WriteLabels() - Write the actual page labels.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Globals...
*/
-int Orientation = 0, /* 0 = portrait, 1 = landscape, etc. */
- Duplex = 0, /* Duplexed? */
- LanguageLevel = 1, /* Language level of printer */
- ColorDevice = 1; /* Do color text? */
-float PageLeft = 18.0f, /* Left margin */
- PageRight = 594.0f, /* Right margin */
- PageBottom = 36.0f, /* Bottom margin */
- PageTop = 756.0f, /* Top margin */
- PageWidth = 612.0f, /* Total page width */
- PageLength = 792.0f; /* Total page length */
+int Orientation = 0, /* 0 = portrait, 1 = landscape, etc. */
+ Duplex = 0, /* Duplexed? */
+ LanguageLevel = 1, /* Language level of printer */
+ ColorDevice = 1; /* Do color text? */
+float PageLeft = 18.0f, /* Left margin */
+ PageRight = 594.0f, /* Right margin */
+ PageBottom = 36.0f, /* Bottom margin */
+ PageTop = 756.0f, /* Top margin */
+ PageWidth = 612.0f, /* Total page width */
+ PageLength = 792.0f; /* Total page length */
/*
* 'SetCommonOptions()' - Set common filter options for media size, etc.
*/
-ppd_file_t * /* O - PPD file */
-SetCommonOptions(int num_options, /* I - Number of options */
- cups_option_t *options, /* I - Options */
- int change_size) /* I - Change page size? */
+ppd_file_t * /* O - PPD file */
+SetCommonOptions(
+ int num_options, /* I - Number of options */
+ cups_option_t *options, /* I - Options */
+ int change_size) /* I - Change page size? */
{
- ppd_file_t *ppd; /* PPD file */
- ppd_size_t *pagesize; /* Current page size */
- const char *val; /* Option value */
+ ppd_file_t *ppd; /* PPD file */
+ ppd_size_t *pagesize; /* Current page size */
+ const char *val; /* Option value */
#ifdef LC_TIME
if ((val = cupsGetOption("landscape", num_options, options)) != NULL)
{
- if (strcasecmp(val, "no") != 0 && strcasecmp(val, "off") != 0 &&
- strcasecmp(val, "false") != 0)
+ if (_cups_strcasecmp(val, "no") != 0 && _cups_strcasecmp(val, "off") != 0 &&
+ _cups_strcasecmp(val, "false") != 0)
{
if (ppd && ppd->landscape > 0)
Orientation = 1;
void
UpdatePageVars(void)
{
- float temp; /* Swapping variable */
+ float temp; /* Swapping variable */
switch (Orientation & 3)
/*
- * End of "$Id: common.c 4494 2005-02-18 02:18:11Z mike $".
+ * 'WriteTextComment()' - Write a DSC text comment.
+ */
+
+void
+WriteTextComment(const char *name, /* I - Comment name ("Title", etc.) */
+ const char *value) /* I - Comment value */
+{
+ int len; /* Current line length */
+
+
+ /*
+ * DSC comments are of the form:
+ *
+ * %%name: value
+ *
+ * The name and value must be limited to 7-bit ASCII for most printers,
+ * so we escape all non-ASCII and ASCII control characters as described
+ * in the Adobe Document Structuring Conventions specification.
+ */
+
+ printf("%%%%%s: (", name);
+ len = 5 + (int)strlen(name);
+
+ while (*value)
+ {
+ if (*value < ' ' || *value >= 127)
+ {
+ /*
+ * Escape this character value...
+ */
+
+ if (len >= 251) /* Keep line < 254 chars */
+ break;
+
+ printf("\\%03o", *value & 255);
+ len += 4;
+ }
+ else if (*value == '\\')
+ {
+ /*
+ * Escape the backslash...
+ */
+
+ if (len >= 253) /* Keep line < 254 chars */
+ break;
+
+ putchar('\\');
+ putchar('\\');
+ len += 2;
+ }
+ else
+ {
+ /*
+ * Put this character literally...
+ */
+
+ if (len >= 254) /* Keep line < 254 chars */
+ break;
+
+ putchar(*value);
+ len ++;
+ }
+
+ value ++;
+ }
+
+ puts(")");
+}
+
+
+/*
+ * End of "$Id$".
*/