/*
- * "$Id: textcommon.c 4559 2005-08-04 18:40:13Z mike $"
+ * "$Id: textcommon.c 6649 2007-07-11 21:46:42Z mike $"
*
- * Common text filter routines for the Common UNIX Printing System (CUPS).
+ * Common text filter routines for CUPS.
*
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2011 by Apple Inc.
+ * Copyright 1997-2007 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:
- *
- * 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
+ * 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.
*
*/
#include "textcommon.h"
+#include <cups/language-private.h>
/*
int NumPages = 0; /* Number of pages in document */
float CharsPerInch = 10; /* Number of character columns per inch */
float LinesPerInch = 6; /* Number of lines per inch */
-int UTF8 = 0; /* Use UTF-8 encoding? */
int NumKeywords = 0; /* Number of known keywords */
char **Keywords = NULL; /* List of known keywords */
if (argc < 6 || argc > 7)
{
- fprintf(stderr, "ERROR: %s job-id user title copies options [file]\n",
- name);
+ _cupsLangPrintf(stderr,
+ _("Usage: %s job-id user title copies options [file]"),
+ name);
return (1);
}
if ((fp = fopen(argv[6], "rb")) == NULL)
{
- perror("ERROR: unable to open print file - ");
+ perror("DEBUG: unable to open print file - ");
return (1);
}
}
num_options = cupsParseOptions(argv[5], 0, &options);
if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
- strcasecmp(val, "no") && strcasecmp(val, "off") &&
- strcasecmp(val, "false"))
+ _cups_strcasecmp(val, "no") && _cups_strcasecmp(val, "off") &&
+ _cups_strcasecmp(val, "false"))
{
PageLeft = 72.0f;
PageRight = PageWidth - 36.0f;
NumKeywords = 0;
Keywords = NULL;
}
- else if (strcasecmp(val, "application/x-cshell") == 0)
+ else if (_cups_strcasecmp(val, "application/x-cshell") == 0)
{
PrettyPrint = PRETTY_SHELL;
NumKeywords = sizeof(csh_keywords) / sizeof(csh_keywords[0]);
Keywords = csh_keywords;
}
- else if (strcasecmp(val, "application/x-csource") == 0)
+ else if (_cups_strcasecmp(val, "application/x-csource") == 0)
{
PrettyPrint = PRETTY_CODE;
NumKeywords = sizeof(code_keywords) / sizeof(code_keywords[0]);
Keywords = code_keywords;
}
- else if (strcasecmp(val, "application/x-perl") == 0)
+ else if (_cups_strcasecmp(val, "application/x-perl") == 0)
{
PrettyPrint = PRETTY_PERL;
NumKeywords = sizeof(perl_keywords) / sizeof(perl_keywords[0]);
Keywords = perl_keywords;
}
- else if (strcasecmp(val, "application/x-shell") == 0)
+ else if (_cups_strcasecmp(val, "application/x-shell") == 0)
{
PrettyPrint = PRETTY_SHELL;
NumKeywords = sizeof(sh_keywords) / sizeof(sh_keywords[0]);
if ((val = cupsGetOption("wrap", num_options, options)) == NULL)
WrapLines = 1;
else
- WrapLines = !strcasecmp(val, "true") || !strcasecmp(val, "on") ||
- !strcasecmp(val, "yes");
+ WrapLines = !_cups_strcasecmp(val, "true") || !_cups_strcasecmp(val, "on") ||
+ !_cups_strcasecmp(val, "yes");
if ((val = cupsGetOption("columns", num_options, options)) != NULL)
+ {
PageColumns = atoi(val);
+ if (PageColumns < 1)
+ {
+ _cupsLangPrintFilter(stderr, "ERROR", _("Bad columns value %d."),
+ PageColumns);
+ return (1);
+ }
+ }
+
if ((val = cupsGetOption("cpi", num_options, options)) != NULL)
+ {
CharsPerInch = atof(val);
+ if (CharsPerInch <= 0.0)
+ {
+ _cupsLangPrintFilter(stderr, "ERROR", _("Bad cpi value %f."),
+ CharsPerInch);
+ return (1);
+ }
+ }
+
if ((val = cupsGetOption("lpi", num_options, options)) != NULL)
+ {
LinesPerInch = atof(val);
+ if (LinesPerInch <= 0.0)
+ {
+ _cupsLangPrintFilter(stderr, "ERROR", _("Bad lpi value %f."),
+ LinesPerInch);
+ return (1);
+ }
+ }
+
if (PrettyPrint)
PageTop -= 216.0f / LinesPerInch;
}
column ++;
- break;
+ break;
}
/*
if ((ch = getc(fp)) == EOF)
return (EOF);
- if (ch < 0xc0 || !UTF8) /* One byte character? */
+ if (ch < 0xc0) /* One byte character? */
return (ch);
else if ((ch & 0xe0) == 0xc0)
{
/*
- * End of "$Id: textcommon.c 4559 2005-08-04 18:40:13Z mike $".
+ * End of "$Id: textcommon.c 6649 2007-07-11 21:46:42Z mike $".
*/