/*
- * "$Id: cupstestppd.c 6509 2007-05-03 22:58:41Z mike $"
+ * "$Id: cupstestppd.c 6927 2007-09-07 16:51:00Z mike $"
*
* PPD test program for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* 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/".
*
* PostScript is a trademark of Adobe Systems, Inc.
*
*
* Contents:
*
- * main() - Main entry for test program.
- * show_conflicts() - Show option conflicts in a PPD file.
- * usage() - Show program usage...
- * valid_utf8() - Check whether a string contains valid UTF-8 text.
+ * main() - Main entry for test program.
+ * check_basics() - Check for CR LF, mixed line endings, and blank lines.
+ * check_constraints() - Check UIConstraints in the PPD file.
+ * check_defaults() - Check default option keywords in the PPD file.
+ * check_filters() - Check filters in the PPD file.
+ * check_translations() - Check translations in the PPD file.
+ * show_conflicts() - Show option conflicts in a PPD file.
+ * test_raster() - Test PostScript commands for raster printers.
+ * usage() - Show program usage...
+ * valid_utf8() - Check whether a string contains valid UTF-8 text.
*/
/*
#include <cups/string.h>
#include <cups/cups.h>
#include <cups/i18n.h>
+#include <filter/raster.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
* Local functions...
*/
-void check_basics(const char *filename);
-int check_constraints(ppd_file_t *ppd, int errors, int verbose, int warn);
-int check_defaults(ppd_file_t *ppd, int errors, int verbose, int warn);
-int check_filters(ppd_file_t *ppd, const char *root, int errors,
- int verbose, int warn);
-int check_translations(ppd_file_t *ppd, int errors, int verbose, int warn);
-void show_conflicts(ppd_file_t *ppd);
-void usage(void);
-int valid_utf8(const char *s);
+static void check_basics(const char *filename);
+static int check_constraints(ppd_file_t *ppd, int errors, int verbose,
+ int warn);
+static int check_defaults(ppd_file_t *ppd, int errors, int verbose,
+ int warn);
+static int check_filters(ppd_file_t *ppd, const char *root, int errors,
+ int verbose, int warn);
+static int check_translations(ppd_file_t *ppd, int errors, int verbose,\
+ int warn);
+static void show_conflicts(ppd_file_t *ppd);
+static int test_raster(ppd_file_t *ppd, int verbose);
+static void usage(void);
+static int valid_utf8(const char *s);
/*
attr->value)
ppdversion = (int)(10 * atof(attr->value) + 0.5);
+ for (j = 0; j < ppd->num_filters; j ++)
+ if (strstr(ppd->filters[j], "application/vnd.cups-raster"))
+ {
+ if (!test_raster(ppd, verbose))
+ errors ++;
+ break;
+ }
+
/*
* Look for default keywords with no matching option...
*/
else
ydpi = xdpi;
- if (xdpi <= 0 || ydpi <= 0 || strcmp(ptr, "dpi"))
+ if (xdpi <= 0 || xdpi > 99999 || ydpi <= 0 || ydpi > 99999 ||
+ strcmp(ptr, "dpi"))
{
if (verbose >= 0)
{
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
- _cupsLangPrintf(stderr,
+ _cupsLangPrintf(stdout,
_(" **FAIL** Bad LanguageEncoding %s - "
"must be ISOLatin1!\n"),
attr->value ? attr->value : "(null)");
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
- _cupsLangPrintf(stderr,
+ _cupsLangPrintf(stdout,
_(" **FAIL** Bad LanguageVersion %s - "
"must be English!\n"),
ppd->lang_version ? ppd->lang_version : "(null)");
if (!strcmp(attr->name, "DefaultColorSpace") ||
!strcmp(attr->name, "DefaultColorSep") ||
!strcmp(attr->name, "DefaultFont") ||
+ !strcmp(attr->name, "DefaultHalftoneType") ||
!strcmp(attr->name, "DefaultImageableArea") ||
+ !strcmp(attr->name, "DefaultLeadingEdge") ||
!strcmp(attr->name, "DefaultOutputOrder") ||
!strcmp(attr->name, "DefaultPaperDimension") ||
+ !strcmp(attr->name, "DefaultResolution") ||
!strcmp(attr->name, "DefaultScreenProc") ||
!strcmp(attr->name, "DefaultTransfer"))
continue;
}
}
+ _cupsLangPrintf(stdout, " num_consts = %d\n",
+ ppd->num_consts);
+ for (j = 0; j < ppd->num_consts; j ++)
+ _cupsLangPrintf(stdout,
+ " consts[%d] = *%s %s *%s %s\n",
+ j, ppd->consts[j].option1, ppd->consts[j].choice1,
+ ppd->consts[j].option2, ppd->consts[j].choice2);
+
_cupsLangPrintf(stdout, " num_profiles = %d\n",
ppd->num_profiles);
for (j = 0; j < ppd->num_profiles; j ++)
* 'check_basics()' - Check for CR LF, mixed line endings, and blank lines.
*/
-void
+static void
check_basics(const char *filename) /* I - PPD file to check */
{
cups_file_t *fp; /* File pointer */
* 'check_constraints()' - Check UIConstraints in the PPD file.
*/
-int /* O - Errors found */
+static int /* O - Errors found */
check_constraints(ppd_file_t *ppd, /* I - PPD file */
int errors, /* I - Errors found */
int verbose, /* I - Verbosity level */
* 'check_defaults()' - Check default option keywords in the PPD file.
*/
-int /* O - Errors found */
+static int /* O - Errors found */
check_defaults(ppd_file_t *ppd, /* I - PPD file */
int errors, /* I - Errors found */
int verbose, /* I - Verbosity level */
if (!strcmp(attr->name, "DefaultColorSpace") ||
!strcmp(attr->name, "DefaultFont") ||
+ !strcmp(attr->name, "DefaultHalftoneType") ||
!strcmp(attr->name, "DefaultImageableArea") ||
+ !strcmp(attr->name, "DefaultLeadingEdge") ||
!strcmp(attr->name, "DefaultOutputOrder") ||
!strcmp(attr->name, "DefaultPaperDimension") ||
!strcmp(attr->name, "DefaultResolution") ||
* 'check_filters()' - Check filters in the PPD file.
*/
-int /* O - Errors found */
+static int /* O - Errors found */
check_filters(ppd_file_t *ppd, /* I - PPD file */
const char *root, /* I - Root directory */
int errors, /* I - Errors found */
* 'check_translations()' - Check translations in the PPD file.
*/
-int /* O - Errors found */
+static int /* O - Errors found */
check_translations(ppd_file_t *ppd, /* I - PPD file */
int errors, /* I - Errors found */
int verbose, /* I - Verbosity level */
continue;
}
+ if (!strcmp(langstart, "en"))
+ continue;
+
cupsArrayAdd(langlist, langstart);
strlcpy(ll, langstart, sizeof(ll));
option;
option = ppdNextOption(ppd))
{
+ if (!strcmp(option->keyword, "PageRegion"))
+ continue;
+
snprintf(keyword, sizeof(keyword), "%s.Translation", langstart);
snprintf(llkeyword, sizeof(llkeyword), "%s.Translation", ll);
* 'show_conflicts()' - Show option conflicts in a PPD file.
*/
-void
+static void
show_conflicts(ppd_file_t *ppd) /* I - PPD to check */
{
int i, j; /* Looping variables */
}
+/*
+ * 'test_raster()' - Test PostScript commands for raster printers.
+ */
+
+static int /* O - 1 on success, 0 on failure */
+test_raster(ppd_file_t *ppd, /* I - PPD file */
+ int verbose) /* I - Verbosity */
+{
+ cups_page_header2_t header; /* Page header */
+
+
+ ppdMarkDefaults(ppd);
+ if (cupsRasterInterpretPPD(&header, ppd, 0, NULL, 0))
+ {
+ if (!verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout,
+ _(" **FAIL** Default option code cannot be "
+ "interpreted: %s\n"), cupsRasterErrorString());
+
+ return (0);
+ }
+
+ /*
+ * Try a test of custom page size code, if available...
+ */
+
+ if (!ppdPageSize(ppd, "Custom.612x792"))
+ return (1);
+
+ ppdMarkOption(ppd, "PageSize", "Custom.612x792");
+
+ if (cupsRasterInterpretPPD(&header, ppd, 0, NULL, 0))
+ {
+ if (!verbose)
+ _cupsLangPuts(stdout, _(" FAIL\n"));
+
+ if (verbose >= 0)
+ _cupsLangPrintf(stdout,
+ _(" **FAIL** Default option code cannot be "
+ "interpreted: %s\n"), cupsRasterErrorString());
+
+ return (0);
+ }
+
+ return (1);
+}
+
+
/*
* 'usage()' - Show program usage...
*/
-void
+static void
usage(void)
{
_cupsLangPuts(stdout,
* 'valid_utf8()' - Check whether a string contains valid UTF-8 text.
*/
-int /* O - 1 if valid, 0 if not */
+static int /* O - 1 if valid, 0 if not */
valid_utf8(const char *s) /* I - String to check */
{
while (*s)
/*
- * End of "$Id: cupstestppd.c 6509 2007-05-03 22:58:41Z mike $".
+ * End of "$Id: cupstestppd.c 6927 2007-09-07 16:51:00Z mike $".
*/