]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/cupstestppd.c
Fixed deprecation warnings for many functions on OS X so they are tied
[thirdparty/cups.git] / systemv / cupstestppd.c
index b841b975b3f36c160a9d97a0ec00265f93b714e5..7c080a9369c91a4c51a2a576c14664090a34825f 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: cupstestppd.c 7807 2008-07-28 21:54:24Z mike $"
+ * "$Id$"
  *
  *   PPD test program for CUPS.
  *
- *   Copyright 2007-2011 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -129,7 +129,7 @@ static int  check_translations(ppd_file_t *ppd, int errors, int verbose,
                                   int warn);
 static void    show_conflicts(ppd_file_t *ppd, const char *prefix);
 static int     test_raster(ppd_file_t *ppd, int verbose);
-static void    usage(void);
+static void    usage(void) __attribute__((noreturn));
 static int     valid_path(const char *keyword, const char *path, int errors,
                           int verbose, int warn);
 static int     valid_utf8(const char *s);
@@ -147,6 +147,7 @@ main(int  argc,                             /* I - Number of command-line args */
   int          len;                    /* Length of option name */
   char         *opt;                   /* Option character */
   const char   *ptr;                   /* Pointer into string */
+  cups_file_t  *fp;                    /* PPD file */
   int          files;                  /* Number of files */
   int          verbose;                /* Want verbose output? */
   int          warn;                   /* Which errors to just warn about */
@@ -303,7 +304,7 @@ main(int  argc,                             /* I - Number of command-line args */
         * Read from stdin...
        */
 
-        ppd = ppdOpen(stdin);
+        ppd = _ppdOpen(cupsFileStdin(), _PPD_LOCALIZATION_ALL);
 
         if (verbose >= 0)
           printf("%s:", (ppd && ppd->pcfilename) ? ppd->pcfilename : "(stdin)");
@@ -317,7 +318,24 @@ main(int  argc,                            /* I - Number of command-line args */
         if (verbose >= 0)
           printf("%s:", argv[i]);
 
-        ppd = ppdOpenFile(argv[i]);
+        if ((fp = cupsFileOpen(argv[i], "r")) != NULL)
+        {
+          ppd = _ppdOpen(fp, _PPD_LOCALIZATION_ALL);
+          cupsFileClose(fp);
+        }
+        else
+        {
+         status = ERROR_FILE_OPEN;
+
+         if (verbose >= 0)
+          {
+            _cupsLangPuts(stdout, _(" FAIL"));
+            _cupsLangPrintf(stdout,
+                           _("      **FAIL**  Unable to open PPD file - %s on "
+                             "line %d."), strerror(errno), 0);
+           continue;
+          }
+        }
       }
 
       if (ppd == NULL)
@@ -332,8 +350,8 @@ main(int  argc,                             /* I - Number of command-line args */
           {
             _cupsLangPuts(stdout, _(" FAIL"));
             _cupsLangPrintf(stdout,
-                           _("      **FAIL**  Unable to open PPD file - %s"),
-                           strerror(errno));
+                           _("      **FAIL**  Unable to open PPD file - %s on "
+                             "line %d."), strerror(errno), 0);
           }
        }
        else
@@ -439,13 +457,29 @@ main(int  argc,                           /* I - Number of command-line args */
           attr->value)
         ppdversion = (int)(10 * _cupsStrScand(attr->value, NULL, loc) + 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;
+      if ((attr = ppdFindAttr(ppd, "cupsFilter2", NULL)) != NULL)
+      {
+        do
+        {
+         if (strstr(attr->value, "application/vnd.cups-raster"))
+         {
+           if (!test_raster(ppd, verbose))
+             errors ++;
+           break;
+         }
        }
+       while ((attr = ppdFindNextAttr(ppd, "cupsFilter2", NULL)) != NULL);
+      }
+      else
+      {
+       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...
@@ -477,7 +511,7 @@ main(int  argc,                             /* I - Number of command-line args */
            _cupsLangPuts(stdout, _(" FAIL"));
 
          _cupsLangPrintf(stdout,
-                         _("      **FAIL**  BAD DefaultImageableArea %s\n"
+                         _("      **FAIL**  Bad DefaultImageableArea %s\n"
                            "                REF: Page 102, section 5.15."),
                          attr->value);
        }
@@ -513,7 +547,7 @@ main(int  argc,                             /* I - Number of command-line args */
            _cupsLangPuts(stdout, _(" FAIL"));
 
          _cupsLangPrintf(stdout,
-                         _("      **FAIL**  BAD DefaultPaperDimension %s\n"
+                         _("      **FAIL**  Bad DefaultPaperDimension %s\n"
                            "                REF: Page 103, section 5.15."),
                          attr->value);
        }
@@ -543,7 +577,7 @@ main(int  argc,                             /* I - Number of command-line args */
                  _cupsLangPuts(stdout, _(" FAIL"));
 
                _cupsLangPrintf(stdout,
-                               _("      **FAIL**  BAD Default%s %s\n"
+                               _("      **FAIL**  Bad Default%s %s\n"
                                  "                REF: Page 40, section 4.5."),
                                option->keyword, option->defchoice);
              }
@@ -616,7 +650,7 @@ main(int  argc,                             /* I - Number of command-line args */
         ptr = attr->value;
        if (*ptr == '4' && ptr[1] == '.')
        {
-         
+
          for (ptr += 2; *ptr; ptr ++)
            if (!isdigit(*ptr & 255))
              break;
@@ -697,34 +731,36 @@ main(int  argc,                           /* I - Number of command-line args */
 
       if (ppd->manufacturer != NULL)
       {
-        if (!strncasecmp(ppd->manufacturer, "Hewlett-Packard", 15) ||
-           !strncasecmp(ppd->manufacturer, "Hewlett Packard", 15))
+        if (!_cups_strncasecmp(ppd->manufacturer, "Hewlett-Packard", 15) ||
+           !_cups_strncasecmp(ppd->manufacturer, "Hewlett Packard", 15))
        {
          if (verbose >= 0)
          {
            if (!errors && !verbose)
              _cupsLangPuts(stdout, _(" FAIL"));
 
-           _cupsLangPuts(stdout,
-                         _("      **FAIL**  BAD Manufacturer (should be "
-                           "\"HP\")\n"
-                           "                REF: Page 211, table D.1."));
+           _cupsLangPrintf(stdout,
+                           _("      **FAIL**  Bad Manufacturer (should be "
+                             "\"%s\")\n"
+                             "                REF: Page 211, table D.1."),
+                           "HP");
           }
 
          errors ++;
        }
-        else if (!strncasecmp(ppd->manufacturer, "OkiData", 7) ||
-                !strncasecmp(ppd->manufacturer, "Oki Data", 8))
+        else if (!_cups_strncasecmp(ppd->manufacturer, "OkiData", 7) ||
+                !_cups_strncasecmp(ppd->manufacturer, "Oki Data", 8))
        {
          if (verbose >= 0)
          {
            if (!errors && !verbose)
              _cupsLangPuts(stdout, _(" FAIL"));
 
-           _cupsLangPuts(stdout,
-                         _("      **FAIL**  BAD Manufacturer (should be "
-                           "\"Oki\")\n"
-                           "                REF: Page 211, table D.1."));
+           _cupsLangPrintf(stdout,
+                           _("      **FAIL**  Bad Manufacturer (should be "
+                             "\"%s\")\n"
+                             "                REF: Page 211, table D.1."),
+                           "Oki");
           }
 
          errors ++;
@@ -761,7 +797,7 @@ main(int  argc,                             /* I - Number of command-line args */
              _cupsLangPuts(stdout, _(" FAIL"));
 
            _cupsLangPrintf(stdout,
-                           _("      **FAIL**  BAD ModelName - \"%c\" not "
+                           _("      **FAIL**  Bad ModelName - \"%c\" not "
                              "allowed in string.\n"
                              "                REF: Pages 59-60, section 5.3."),
                            *ptr);
@@ -878,7 +914,7 @@ main(int  argc,                             /* I - Number of command-line args */
              _cupsLangPuts(stdout, _(" FAIL"));
 
            _cupsLangPuts(stdout,
-                         _("      **FAIL**  BAD Product - not \"(string)\".\n"
+                         _("      **FAIL**  Bad Product - not \"(string)\".\n"
                            "                REF: Page 62, section 5.3."));
           }
 
@@ -917,7 +953,7 @@ main(int  argc,                             /* I - Number of command-line args */
              _cupsLangPuts(stdout, _(" FAIL"));
 
            _cupsLangPuts(stdout,
-                         _("      **FAIL**  BAD PSVersion - not \"(string) "
+                         _("      **FAIL**  Bad PSVersion - not \"(string) "
                            "int\".\n"
                            "                REF: Pages 62-64, section 5.3."));
           }
@@ -952,7 +988,7 @@ main(int  argc,                             /* I - Number of command-line args */
              _cupsLangPuts(stdout, _(" FAIL"));
 
            _cupsLangPuts(stdout,
-                         _("      **FAIL**  BAD ShortNickName - longer "
+                         _("      **FAIL**  Bad ShortNickName - longer "
                            "than 31 chars.\n"
                            "                REF: Pages 64-65, section 5.3."));
           }
@@ -986,7 +1022,7 @@ main(int  argc,                            /* I - Number of command-line args */
            _cupsLangPuts(stdout, _(" FAIL"));
 
          _cupsLangPuts(stdout,
-                       _("      **FAIL**  BAD JobPatchFile attribute in file\n"
+                       _("      **FAIL**  Bad JobPatchFile attribute in file\n"
                          "                REF: Page 24, section 3.4."));
         }
 
@@ -1051,7 +1087,7 @@ main(int  argc,                           /* I - Number of command-line args */
          * Check for PaperDimension...
          */
 
-          if (size->width == 0.0 && size->length == 0.0)
+          if (size->width <= 0.0 && size->length <= 0.0)
          {
            if (verbose >= 0)
            {
@@ -1110,7 +1146,7 @@ main(int  argc,                           /* I - Number of command-line args */
                _cupsLangPuts(stdout, _(" FAIL"));
 
              _cupsLangPrintf(stdout,
-                             _("      **FAIL**  Bad %s choice %s\n"
+                             _("      **FAIL**  Bad option %s choice %s\n"
                                "                REF: Page 84, section 5.9"),
                              option->keyword, choice->choice);
             }
@@ -1194,7 +1230,7 @@ main(int  argc,                           /* I - Number of command-line args */
 
             errors ++;
          }
-         
+
         /*
          * Loop through all options and choices...
          */
@@ -1332,7 +1368,7 @@ main(int  argc,                           /* I - Number of command-line args */
              !strcmp(attr->name, "DefaultTransfer"))
            continue;
 
-         if (!strncmp(attr->name, "Default", 7) && 
+         if (!strncmp(attr->name, "Default", 7) &&
              !ppdFindOption(ppd, attr->name + 7))
             _cupsLangPrintf(stdout,
                            _("        WARN    %s has no corresponding "
@@ -1380,7 +1416,7 @@ main(int  argc,                           /* I - Number of command-line args */
                            "5.3."));
          }
 
-         if (!strcasecmp(ppd->pcfilename, "unused.ppd"))
+         if (!_cups_strcasecmp(ppd->pcfilename, "unused.ppd"))
            _cupsLangPuts(stdout,
                          _("        WARN    PCFileName should contain a "
                            "unique filename.\n"
@@ -1466,7 +1502,7 @@ main(int  argc,                           /* I - Number of command-line args */
 
      /*
       * Then list the options, if "-v" was provided...
-      */ 
+      */
 
       if (verbose > 1)
       {
@@ -1684,7 +1720,7 @@ check_basics(const char *filename)        /* I - PPD file to check */
         else if (eol != EOL_CR)
          mixed = 1;
       }
-      
+
       if (col > 0 && whitespace)
        _cupsLangPrintf(stdout,
                        _("        WARN    Line %d only contains whitespace."),
@@ -1841,10 +1877,10 @@ check_constraints(ppd_file_t *ppd,      /* I - PPD file */
          *ptr = '\0';
        }
 
-        if (!strncasecmp(option, "Custom", 6) && !strcasecmp(choice, "True"))
+        if (!_cups_strncasecmp(option, "Custom", 6) && !_cups_strcasecmp(choice, "True"))
        {
          _cups_strcpy(option, option + 6);
-         strcpy(choice, "Custom");
+         strlcpy(choice, "Custom", sizeof(choice));
        }
 
         if ((o = ppdFindOption(ppd, option)) == NULL)
@@ -1856,7 +1892,7 @@ check_constraints(ppd_file_t *ppd,        /* I - PPD file */
                          _("      %s  Missing option %s in "
                            "cupsUIConstraints %s: \"%s\""),
                          prefix, option, constattr->spec, constattr->value);
-         
+
          if (!warn)
            errors ++;
 
@@ -1885,9 +1921,9 @@ check_constraints(ppd_file_t *ppd,        /* I - PPD file */
        else
        {
          for (i = 0; i < o->num_choices; i ++)
-           if (strcasecmp(o->choices[i].choice, "None") &&
-               strcasecmp(o->choices[i].choice, "Off") &&
-               strcasecmp(o->choices[i].choice, "False"))
+           if (_cups_strcasecmp(o->choices[i].choice, "None") &&
+               _cups_strcasecmp(o->choices[i].choice, "Off") &&
+               _cups_strcasecmp(o->choices[i].choice, "False"))
             {
              num_options = cupsAddOption(option, o->choices[i].choice,
                                          num_options, &options);
@@ -1942,16 +1978,16 @@ check_constraints(ppd_file_t *ppd,      /* I - PPD file */
 
     for (i = ppd->num_consts, c = ppd->consts; i > 0; i --, c ++)
     {
-      if (!strncasecmp(c->option1, "Custom", 6) &&
-          !strcasecmp(c->choice1, "True"))
+      if (!_cups_strncasecmp(c->option1, "Custom", 6) &&
+          !_cups_strcasecmp(c->choice1, "True"))
       {
-       strcpy(option, c->option1 + 6);
-       strcpy(choice, "Custom");
+       strlcpy(option, c->option1 + 6, sizeof(option));
+       strlcpy(choice, "Custom", sizeof(choice));
       }
       else
       {
-       strcpy(option, c->option1);
-       strcpy(choice, c->choice1);
+       strlcpy(option, c->option1, sizeof(option));
+       strlcpy(choice, c->choice1, sizeof(choice));
       }
 
       if ((o = ppdFindOption(ppd, option)) == NULL)
@@ -1983,16 +2019,16 @@ check_constraints(ppd_file_t *ppd,      /* I - PPD file */
          errors ++;
       }
 
-      if (!strncasecmp(c->option2, "Custom", 6) &&
-          !strcasecmp(c->choice2, "True"))
+      if (!_cups_strncasecmp(c->option2, "Custom", 6) &&
+          !_cups_strcasecmp(c->choice2, "True"))
       {
-       strcpy(option, c->option2 + 6);
-       strcpy(choice, "Custom");
+       strlcpy(option, c->option2 + 6, sizeof(option));
+       strlcpy(choice, "Custom", sizeof(choice));
       }
       else
       {
-       strcpy(option, c->option2);
-       strcpy(choice, c->choice2);
+       strlcpy(option, c->option2, sizeof(option));
+       strlcpy(choice, c->choice2, sizeof(choice));
       }
 
       if ((o = ppdFindOption(ppd, option)) == NULL)
@@ -2055,7 +2091,7 @@ check_case(ppd_file_t *ppd,               /* I - PPD file */
 
   for (i = ppd->num_groups, groupa = ppd->groups; i > 1; i --, groupa ++)
     for (j = i - 1, groupb = groupa + 1; j > 0; j --, groupb ++)
-      if (!strcasecmp(groupa->name, groupb->name))
+      if (!_cups_strcasecmp(groupa->name, groupb->name))
       {
        if (!errors && !verbose)
          _cupsLangPuts(stdout, _(" FAIL"));
@@ -2077,7 +2113,7 @@ check_case(ppd_file_t *ppd,               /* I - PPD file */
   {
     cupsArraySave(ppd->options);
     for (optionb = ppdNextOption(ppd); optionb; optionb = ppdNextOption(ppd))
-      if (!strcasecmp(optiona->keyword, optionb->keyword))
+      if (!_cups_strcasecmp(optiona->keyword, optionb->keyword))
       {
        if (!errors && !verbose)
          _cupsLangPuts(stdout, _(" FAIL"));
@@ -2107,8 +2143,8 @@ check_case(ppd_file_t *ppd,               /* I - PPD file */
 
          if (verbose >= 0)
            _cupsLangPrintf(stdout,
-                           _("      **FAIL**  Multiple occurrences of %s "
-                             "choice name %s."),
+                           _("      **FAIL**  Multiple occurrences of "
+                             "option %s choice name %s."),
                            optiona->keyword, choicea->choice);
 
          errors ++;
@@ -2117,15 +2153,15 @@ check_case(ppd_file_t *ppd,             /* I - PPD file */
          i --;
          break;
        }
-        else if (!strcasecmp(choicea->choice, choiceb->choice))
+        else if (!_cups_strcasecmp(choicea->choice, choiceb->choice))
        {
          if (!errors && !verbose)
            _cupsLangPuts(stdout, _(" FAIL"));
 
          if (verbose >= 0)
            _cupsLangPrintf(stdout,
-                           _("      **FAIL**  %s choice names %s and %s "
-                             "differ only by case."),
+                           _("      **FAIL**  Option %s choice names %s and "
+                             "%s differ only by case."),
                            optiona->keyword, choicea->choice, choiceb->choice);
 
          errors ++;
@@ -2304,11 +2340,12 @@ check_filters(ppd_file_t *ppd,          /* I - PPD file */
              int        verbose,       /* I - Verbosity level */
              int        warn)          /* I - Warnings only? */
 {
-  int          i;                      /* Looping var */
   ppd_attr_t   *attr;                  /* PPD attribute */
   const char   *ptr;                   /* Pointer into string */
   char         super[16],              /* Super-type for filter */
                type[256],              /* Type for filter */
+               dstsuper[16],           /* Destination super-type for filter */
+               dsttype[256],           /* Destination type for filter */
                program[1024],          /* Program/filter name */
                pathprog[1024];         /* Complete path to program/filter */
   int          cost;                   /* Cost of filter */
@@ -2322,9 +2359,26 @@ check_filters(ppd_file_t *ppd,           /* I - PPD file */
   * cupsFilter
   */
 
-  for (i = 0; i < ppd->num_filters; i ++)
+  for (attr = ppdFindAttr(ppd, "cupsFilter", NULL);
+       attr;
+       attr = ppdFindNextAttr(ppd, "cupsFilter", NULL))
   {
-    if (sscanf(ppd->filters[i], "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type,
+    if (strcmp(attr->name, "cupsFilter"))
+    {
+      if (!warn && !errors && !verbose)
+       _cupsLangPuts(stdout, _(" FAIL"));
+
+      if (verbose >= 0)
+       _cupsLangPrintf(stdout,
+                       _("      %s  Bad spelling of %s - should be %s."),
+                       prefix, attr->name, "cupsFilter");
+
+      if (!warn)
+        errors ++;
+    }
+
+    if (!attr->value ||
+        sscanf(attr->value, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type,
                &cost, program) != 4)
     {
       if (!warn && !errors && !verbose)
@@ -2333,7 +2387,7 @@ check_filters(ppd_file_t *ppd,            /* I - PPD file */
       if (verbose >= 0)
        _cupsLangPrintf(stdout,
                        _("      %s  Bad cupsFilter value \"%s\"."),
-                       prefix, ppd->filters[i]);
+                       prefix, attr->value);
 
       if (!warn)
         errors ++;
@@ -2387,6 +2441,102 @@ check_filters(ppd_file_t *ppd,          /* I - PPD file */
     }
   }
 
+ /*
+  * cupsFilter2
+  */
+
+  for (attr = ppdFindAttr(ppd, "cupsFilter2", NULL);
+       attr;
+       attr = ppdFindNextAttr(ppd, "cupsFilter2", NULL))
+  {
+    if (strcmp(attr->name, "cupsFilter2"))
+    {
+      if (!warn && !errors && !verbose)
+       _cupsLangPuts(stdout, _(" FAIL"));
+
+      if (verbose >= 0)
+       _cupsLangPrintf(stdout,
+                       _("      %s  Bad spelling of %s - should be %s."),
+                       prefix, attr->name, "cupsFilter2");
+
+      if (!warn)
+        errors ++;
+    }
+
+    if (!attr->value ||
+       sscanf(attr->value, "%15[^/]/%255s%*[ \t]%15[^/]/%255s%d%*[ \t]%1023[^\n]",
+              super, type, dstsuper, dsttype, &cost, program) != 6)
+    {
+      if (!warn && !errors && !verbose)
+       _cupsLangPuts(stdout, _(" FAIL"));
+
+      if (verbose >= 0)
+       _cupsLangPrintf(stdout,
+                       _("      %s  Bad cupsFilter2 value \"%s\"."),
+                       prefix, attr->value);
+
+      if (!warn)
+        errors ++;
+    }
+    else if (strcmp(program, "-"))
+    {
+      if (strncmp(program, "maxsize(", 8) &&
+          (ptr = strchr(program + 8, ')')) != NULL)
+      {
+       ptr ++;
+       while (_cups_isspace(*ptr))
+         ptr ++;
+
+       _cups_strcpy(program, ptr);
+      }
+
+      if (program[0] == '/')
+       snprintf(pathprog, sizeof(pathprog), "%s%s", root, program);
+      else
+      {
+       if ((ptr = getenv("CUPS_SERVERBIN")) == NULL)
+         ptr = CUPS_SERVERBIN;
+
+       if (*ptr == '/' || !*root)
+         snprintf(pathprog, sizeof(pathprog), "%s%s/filter/%s", root, ptr,
+                  program);
+       else
+         snprintf(pathprog, sizeof(pathprog), "%s/%s/filter/%s", root, ptr,
+                  program);
+      }
+
+      if (stat(pathprog, &fileinfo))
+      {
+       if (!warn && !errors && !verbose)
+         _cupsLangPuts(stdout, _(" FAIL"));
+
+       if (verbose >= 0)
+         _cupsLangPrintf(stdout, _("      %s  Missing %s file \"%s\"."),
+                         prefix, "cupsFilter2", pathprog);
+
+       if (!warn)
+         errors ++;
+      }
+      else if (fileinfo.st_uid != 0 ||
+               (fileinfo.st_mode & MODE_WRITE) ||
+              (fileinfo.st_mode & MODE_MASK) != MODE_PROGRAM)
+      {
+       if (!warn && !errors && !verbose)
+         _cupsLangPuts(stdout, _(" FAIL"));
+
+       if (verbose >= 0)
+         _cupsLangPrintf(stdout,
+                         _("      %s  Bad permissions on %s file \"%s\"."),
+                         prefix, "cupsFilter2", pathprog);
+
+       if (!warn)
+         errors ++;
+      }
+      else
+        errors = valid_path("cupsFilter2", pathprog, errors, verbose, warn);
+    }
+  }
+
  /*
   * cupsPreFilter
   */
@@ -2478,8 +2628,8 @@ check_filters(ppd_file_t *ppd,            /* I - PPD file */
   * APDialogExtension
   */
 
-  for (attr = ppdFindAttr(ppd, "APDialogExtension", NULL); 
-       attr != NULL; 
+  for (attr = ppdFindAttr(ppd, "APDialogExtension", NULL);
+       attr != NULL;
        attr = ppdFindNextAttr(ppd, "APDialogExtension", NULL))
   {
     if (strcmp(attr->name, "APDialogExtension"))
@@ -2495,7 +2645,7 @@ check_filters(ppd_file_t *ppd,            /* I - PPD file */
       if (!warn)
         errors ++;
     }
-    
+
     snprintf(pathprog, sizeof(pathprog), "%s%s", root,
              attr->value ? attr->value : "(null)");
 
@@ -2930,8 +3080,8 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
   const char   *prefix;                /* WARN/FAIL prefix */
   ppd_option_t *page_size,             /* PageSize option */
                *page_region;           /* PageRegion option */
-  _pwg_media_t  *pwg_media;             /* PWG media */
-  char          buf[1024];              /* PapeSize name that is supposed to be */
+  _pwg_media_t *pwg_media;             /* PWG media */
+  char         buf[PPD_MAX_NAME];      /* PapeSize name that is supposed to be */
   const char   *ptr;                   /* Pointer into string */
   int          width_2540ths,          /* PageSize width in 2540ths */
                length_2540ths;         /* PageSize length in 2540ths */
@@ -2990,8 +3140,9 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
 
       continue;
     }
-    else if (warn != 2 && size->name[0] == 'w' &&
-             sscanf(size->name, "w%dh%d", &width, &length) == 2)
+
+    if (warn != 2 && size->name[0] == 'w' &&
+        sscanf(size->name, "w%dh%d", &width, &length) == 2)
     {
      /*
       * Validate device-specific size wNNNhNNN should have proper width and
@@ -3050,7 +3201,7 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
 
    /*
     * Verify that the size name is Adobe standard name if it's a standard size
-    * and the dementional name if it's not a standard size.  Suffix should be
+    * and the dimentional name if it's not a standard size.  Suffix should be
     * .Fullbleed, etc., or numeric, e.g., Letter, Letter.Fullbleed,
     * Letter.Transverse, Letter1, Letter2, 4x8, 55x91mm, 55x91mm.Fullbleed, etc.
     */
@@ -3059,48 +3210,66 @@ check_sizes(ppd_file_t *ppd,            /* I - PPD file */
     {
       is_ok          = 1;
       width_2540ths  = (size->length > size->width) ?
-                           _PWG_FROMPTS(size->width) :
-                          _PWG_FROMPTS(size->length);
+                           PWG_FROM_POINTS(size->width) :
+                          PWG_FROM_POINTS(size->length);
       length_2540ths = (size->length > size->width) ?
-                           _PWG_FROMPTS(size->length) :
-                          _PWG_FROMPTS(size->width);
-      pwg_media      = _pwgMediaForSize(width_2540ths, length_2540ths);
+                           PWG_FROM_POINTS(size->length) :
+                          PWG_FROM_POINTS(size->width);
+      pwg_media      = pwgMediaForSize(width_2540ths, length_2540ths);
+
+      if (pwg_media &&
+          (fabs(pwg_media->width - width_2540ths) > 34 ||
+           fabs(pwg_media->length - length_2540ths) > 34))
+        pwg_media = NULL;              /* Only flag matches within a point */
 
-      if (pwg_media && pwg_media->ppd)
+      if (pwg_media && pwg_media->ppd &&
+          (pwg_media->ppd[0] < 'a' || pwg_media->ppd[0] > 'z'))
       {
+        size_t ppdlen = strlen(pwg_media->ppd);
+                                       /* Length of standard PPD name */
+
         strlcpy(buf, pwg_media->ppd, sizeof(buf));
 
-        if (size->left == 0 && size->bottom == 0 &&
-           size->right == size->width && size->top == size->length)
+        if (strcmp(size->name, buf) && size->width > size->length)
         {
-          snprintf(buf, sizeof(buf), "%s.Fullbleed", pwg_media->ppd);
-         if (strcmp(size->name, buf))
-           is_ok = 0;                                  
+          if (!strcmp(pwg_media->ppd, "DoublePostcardRotated"))
+            strlcpy(buf, "DoublePostcard", sizeof(buf));
+          else if (strstr(size->name, ".Transverse"))
+            snprintf(buf, sizeof(buf), "%s.Transverse", pwg_media->ppd);
+          else
+            snprintf(buf, sizeof(buf), "%sRotated", pwg_media->ppd);
+
+         ppdlen = strlen(buf);
         }
-        else if (size->width > size->length)
+
+        if (size->left == 0 && size->bottom == 0 &&
+           size->right == size->width && size->top == size->length)
         {
-         if ((ptr = pwg_media->ppd + strlen(pwg_media->ppd) - 7)
-                 >= pwg_media->ppd && !strcmp(ptr, "Rotated"))
+          strlcat(buf, ".Fullbleed", sizeof(buf) - strlen(buf));
+         if (_cups_strcasecmp(size->name, buf))
          {
-           if (strcmp(size->name, buf))
+          /*
+           * Allow an additional qualifier such as ".WithTab"...
+           */
+
+           size_t buflen = strlen(buf);/* Length of full bleed name */
+
+            if (_cups_strncasecmp(size->name, buf, buflen) ||
+                size->name[buflen] != '.')
              is_ok = 0;
          }
-         else
-         {
-           snprintf(buf, sizeof(buf), "%sRotated", pwg_media->ppd);
-           if (strcmp(size->name, buf))
-           {
-             snprintf(buf, sizeof(buf), "%s.Transverse", pwg_media->ppd);
-             if (strcmp(size->name, buf))
-               is_ok = 0;                                      
-           }
-         }
         }
-       else
-        {
-         if ((!strncmp(size->name, pwg_media->ppd, strlen(pwg_media->ppd))))
+       else if (!strncmp(size->name, pwg_media->ppd, ppdlen))
+       {
+        /*
+         * Check for a proper qualifier (number, "Small", or .something)...
+         */
+
+         ptr = size->name + ppdlen;
+
+         if (isdigit(*ptr & 255))
           {
-            for (ptr = size->name + strlen(pwg_media->ppd); *ptr; ptr ++)
+            for (ptr ++; *ptr; ptr ++)
             {
               if (!isdigit(*ptr & 255))
              {
@@ -3109,10 +3278,23 @@ check_sizes(ppd_file_t *ppd,            /* I - PPD file */
              }
             }
           }
-          else
-            is_ok = 0;
+          else if (*ptr != '.' && *ptr && strcmp(ptr, "Small"))
+           is_ok = 0;
         }
-        
+       else
+       {
+        /*
+         * Check for EnvSizeName as well...
+         */
+
+         if (strncmp(pwg_media->ppd, "Env", 3) &&
+             !strncmp(size->name, "Env", 3))
+            snprintf(buf, sizeof(buf), "Env%s", pwg_media->ppd);
+
+         if (strcmp(size->name, buf))
+           is_ok = 0;
+       }
+
         if (!is_ok)
           _cupsLangPrintf(stdout,
                           _("      %s  Size \"%s\" should be the Adobe "
@@ -3126,7 +3308,7 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
         length_tmp = (fabs(size->length - ceil(size->length)) < 0.1) ?
                         ceil(size->length) : size->length;
 
-        if (fmod(width_tmp, 18.0) == 0.0 && fmod(length_tmp, 18.0) == 0.0)
+        if (fmod(width_tmp, 9.0) == 0.0 && fmod(length_tmp, 9.0) == 0.0)
         {
           width_inch  = width_tmp / 72.0;
           length_inch = length_tmp / 72.0;
@@ -3147,10 +3329,29 @@ check_sizes(ppd_file_t *ppd,            /* I - PPD file */
         else if (size->width > size->length)
           strlcat(buf, ".Transverse", sizeof(buf));
 
-        if (strcmp(size->name, buf))
-          _cupsLangPrintf(stdout,
-                          _("      %s  Size \"%s\" should be \"%s\"."),
-                          prefix, size->name, buf);
+        if (_cups_strcasecmp(size->name, buf))
+        {
+          size_t       buflen = strlen(buf);
+                                       /* Length of proposed name */
+
+          if (_cups_strncasecmp(size->name, buf, buflen) ||
+              (strcmp(size->name + buflen, "in") &&
+               size->name[buflen] != '.'))
+          {
+           char        altbuf[PPD_MAX_NAME];
+                                       /* Alternate "wNNNhNNN" name */
+           size_t      altlen;         /* Length of alternate name */
+
+           snprintf(altbuf, sizeof(altbuf), "w%.0fh%.0f", size->width,
+                    size->length);
+           altlen = strlen(altbuf);
+           if (_cups_strncasecmp(size->name, altbuf, altlen) ||
+               (size->name[altlen] && size->name[altlen] != '.'))
+             _cupsLangPrintf(stdout,
+                             _("      %s  Size \"%s\" should be \"%s\"."),
+                             prefix, size->name, buf);
+         }
+        }
       }
     }
   }
@@ -3288,7 +3489,7 @@ check_translations(ppd_file_t *ppd,       /* I - PPD file */
          * Check custom choices differently...
          */
 
-         if (!strcasecmp(option->choices[j].choice, "Custom") &&
+         if (!_cups_strcasecmp(option->choices[j].choice, "Custom") &&
              (coption = ppdFindCustomOption(ppd,
                                             option->keyword)) != NULL)
          {
@@ -3314,7 +3515,7 @@ check_translations(ppd_file_t *ppd,       /* I - PPD file */
                errors ++;
            }
 
-           if (strcasecmp(option->keyword, "PageSize"))
+           if (_cups_strcasecmp(option->keyword, "PageSize"))
            {
              for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);
                   cparam;
@@ -3498,9 +3699,9 @@ show_conflicts(ppd_file_t *ppd,           /* I - PPD to check */
          break;
 
       if (j == 0 ||
-          !strcasecmp(c1->choice, "None") ||
-          !strcasecmp(c1->choice, "Off") ||
-          !strcasecmp(c1->choice, "False"))
+          !_cups_strcasecmp(c1->choice, "None") ||
+          !_cups_strcasecmp(c1->choice, "Off") ||
+          !_cups_strcasecmp(c1->choice, "False"))
         c1 = NULL;
     }
 
@@ -3531,9 +3732,9 @@ show_conflicts(ppd_file_t *ppd,           /* I - PPD to check */
          break;
 
       if (j == 0 ||
-          !strcasecmp(c2->choice, "None") ||
-          !strcasecmp(c2->choice, "Off") ||
-          !strcasecmp(c2->choice, "False"))
+          !_cups_strcasecmp(c2->choice, "None") ||
+          !_cups_strcasecmp(c2->choice, "Off") ||
+          !_cups_strcasecmp(c2->choice, "False"))
         c2 = NULL;
     }
 
@@ -3624,7 +3825,7 @@ usage(void)
                           "errors."));
   _cupsLangPuts(stdout, _("  -q                      Run silently."));
   _cupsLangPuts(stdout, _("  -r                      Use 'relaxed' open mode."));
-  _cupsLangPuts(stdout, _("  -v                      Be slightly verbose."));
+  _cupsLangPuts(stdout, _("  -v                      Be verbose."));
   _cupsLangPuts(stdout, _("  -vv                     Be very verbose."));
 
   exit(ERROR_USAGE);
@@ -3791,5 +3992,5 @@ valid_utf8(const char *s)         /* I - String to check */
 
 
 /*
- * End of "$Id: cupstestppd.c 7807 2008-07-28 21:54:24Z mike $".
+ * End of "$Id$".
  */