]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/cupstestppd.c
Load cups into easysw/current.
[thirdparty/cups.git] / systemv / cupstestppd.c
index 6f013c56a503e5bf5b231483fc4e1489d56370d8..09a361b99c481b5989650847fdd7963c1b20b930 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: cupstestppd.c 6509 2007-05-03 22:58:41Z mike $"
+ * "$Id: cupstestppd.c 6649 2007-07-11 21:46:42Z 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.
  */
 
 /*
@@ -40,6 +37,7 @@
 #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>
@@ -91,15 +89,19 @@ enum
  * 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);
 
 
 /*
@@ -364,6 +366,14 @@ main(int  argc,                            /* I - Number of command-line args */
           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...
       */
@@ -1080,7 +1090,7 @@ main(int  argc,                           /* I - Number of command-line args */
              _cupsLangPuts(stdout, _(" FAIL\n"));
 
             if (verbose >= 0)
-             _cupsLangPrintf(stderr,
+             _cupsLangPrintf(stdout,
                              _("      **FAIL**  Bad LanguageEncoding %s - "
                                "must be ISOLatin1!\n"),
                              attr->value ? attr->value : "(null)");
@@ -1094,7 +1104,7 @@ main(int  argc,                           /* I - Number of command-line args */
              _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)");
@@ -1203,9 +1213,12 @@ main(int  argc,                          /* I - Number of command-line args */
           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;
@@ -1540,6 +1553,14 @@ main(int  argc,                          /* I - Number of command-line args */
          }
        }
 
+       _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 ++)
@@ -1589,7 +1610,7 @@ main(int  argc,                           /* I - Number of command-line args */
  * '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 */
@@ -1674,7 +1695,7 @@ check_basics(const char *filename)        /* I - PPD file to check */
  * '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 */
@@ -1758,7 +1779,7 @@ check_constraints(ppd_file_t *ppd,        /* I - PPD file */
  * '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 */
@@ -1778,7 +1799,9 @@ check_defaults(ppd_file_t *ppd,           /* I - PPD file */
 
     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") ||
@@ -1823,7 +1846,7 @@ check_defaults(ppd_file_t *ppd,           /* I - PPD file */
  * '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 */
@@ -1953,7 +1976,7 @@ check_filters(ppd_file_t *ppd,            /* I - PPD file */
  * '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 */
@@ -2041,6 +2064,9 @@ check_translations(ppd_file_t *ppd,       /* I - PPD file */
           option;
           option = ppdNextOption(ppd))
       {
+        if (!strcmp(option->keyword, "PageRegion"))
+         continue;
+
        snprintf(keyword, sizeof(keyword), "%s.Translation", langstart);
        snprintf(llkeyword, sizeof(llkeyword), "%s.Translation", ll);
 
@@ -2247,7 +2273,7 @@ check_translations(ppd_file_t *ppd,       /* I - PPD file */
  * '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 */
@@ -2343,11 +2369,40 @@ show_conflicts(ppd_file_t *ppd)         /* I - PPD to check */
 }
 
 
+/*
+ * '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);
+  }
+  else
+    return (1);
+}
+
+
 /*
  * 'usage()' - Show program usage...
  */
 
-void
+static void
 usage(void)
 {
   _cupsLangPuts(stdout,
@@ -2373,7 +2428,7 @@ usage(void)
  * '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)
@@ -2446,5 +2501,5 @@ valid_utf8(const char *s)         /* I - String to check */
 
 
 /*
- * End of "$Id: cupstestppd.c 6509 2007-05-03 22:58:41Z mike $".
+ * End of "$Id: cupstestppd.c 6649 2007-07-11 21:46:42Z mike $".
  */