]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirror 1.1.x changes.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 1 Aug 2003 15:00:30 +0000 (15:00 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 1 Aug 2003 15:00:30 +0000 (15:00 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3843 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES-1.1.txt
cups/ppd.c
cups/ppd.h
systemv/cupstestppd.c

index b8f86736ae51ff1babb559894cfd1cfdc17cf7de..00d0269d5141cd9a3d2b478e942866b063187390 100644 (file)
@@ -3,6 +3,11 @@ CHANGES-1.1.txt
 
 CHANGES IN CUPS V1.1.20rc1
 
+       - Added a new ppdSetConformance() function to set the
+         conformance requirements for PPD files. Currently only
+         two levels are defined, PPD_CONFORM_RELAXED and
+         PPD_CONFORM_STRICT, and the default is the relaxed
+         level (STR #212)
        - The IPP backend did not correctly execute the
          pictwpstops filter on OSX (STR #210)
        - The LPD backend did not set the banner class when the
index a719bb3f6abb7232c1662b619b540e3c1466a181..3737c249debd2ddfc207662b9003a9325fe89ce7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppd.c,v 1.51.2.56 2003/07/20 12:51:41 mike Exp $"
+ * "$Id: ppd.c,v 1.51.2.57 2003/08/01 15:00:28 mike Exp $"
  *
  *   PPD file routines for the Common UNIX Printing System (CUPS).
  *
@@ -41,6 +41,7 @@
  *   ppdOpen()             - Read a PPD file into memory.
  *   ppdOpenFd()           - Read a PPD file into memory.
  *   ppdOpenFile()         - Read a PPD file into memory.
+ *   ppdSetConformance()   - Set the conformance level for PPD files.
  *   ppd_add_attr()        - Add an attribute to the PPD data.
  *   ppd_add_choice()      - Add a choice to an option.
  *   ppd_add_size()        - Add a page size.
@@ -98,6 +99,8 @@
 static ppd_status_t    ppd_status = PPD_OK;
                                        /* Status of last ppdOpen*() */
 static int             ppd_line = 0;   /* Current line number */
+static ppd_conform_t   ppd_conform = PPD_CONFORM_RELAXED;
+                                       /* Level of conformance required */
 
 
 /*
@@ -332,11 +335,12 @@ ppdErrorString(ppd_status_t status)       /* I - PPD status */
                  "Illegal control character",
                  "Illegal main keyword string",
                  "Illegal option keyword string",
-                 "Illegal translation string"
+                 "Illegal translation string",
+                 "Illegal whitespace character"
                };
 
 
-  if (status < PPD_OK || status > PPD_ILLEGAL_TRANSLATION)
+  if (status < PPD_OK || status > PPD_ILLEGAL_WHITESPACE)
     return ("Unknown");
   else
     return (messages[status]);
@@ -2001,6 +2005,17 @@ ppdOpenFile(const char *filename)        /* I - File to read from */
 }
 
 
+/*
+ * 'ppdSetConformance()' - Set the conformance level for PPD files.
+ */
+
+void
+ppdSetConformance(ppd_conform_t c)     /* I - Conformance level */
+{
+  ppd_conform = c;
+}
+
+
 /*
  * 'ppd_add_attr()' - Add an attribute to the PPD data.
  */
@@ -2613,7 +2628,7 @@ ppd_read(FILE *fp,                        /* I - File to read from */
 
        *lineptr++ = '\n';
       }
-      else if (ch < ' ' && ch != '\t' && ch != 0x1a)
+      else if (ch < ' ' && ch != '\t' && ppd_conform == PPD_CONFORM_STRICT)
       {
        /*
         * Other control characters...
@@ -2681,7 +2696,7 @@ ppd_read(FILE *fp,                        /* I - File to read from */
 
          ch = '\n';
        }
-       else if (ch < ' ' && ch != '\t' && ch != 0x1a)
+       else if (ch < ' ' && ch != '\t' && ppd_conform == PPD_CONFORM_STRICT)
        {
         /*
           * Other control characters...
@@ -2740,7 +2755,7 @@ ppd_read(FILE *fp,                        /* I - File to read from */
 
          break;
        }
-       else if (ch < ' ' && ch != '\t' && ch != 0x1a)
+       else if (ch < ' ' && ch != '\t' && ppd_conform == PPD_CONFORM_STRICT)
        {
         /*
           * Other control characters...
@@ -2791,7 +2806,6 @@ ppd_read(FILE *fp,                        /* I - File to read from */
     *string    = NULL;
 
     if (!line[0] ||                    /* Blank line */
-        strcmp(line, "*") == 0 ||      /* (Bad) comment line */
         strncmp(line, "*%", 2) == 0 || /* Comment line */
         strcmp(line, "*End") == 0)     /* End of multi-line string */
     {
@@ -2799,8 +2813,30 @@ ppd_read(FILE *fp,                       /* I - File to read from */
       continue;
     }
 
+    if (strcmp(line, "*") == 0)                /* (Bad) comment line */
+    {
+      if (ppd_conform == PPD_CONFORM_RELAXED)
+      {
+       startline = ppd_line + 1;
+       continue;
+      }
+      else
+      {
+        ppd_line   = startline;
+        ppd_status = PPD_ILLEGAL_MAIN_KEYWORD;
+
+        return (0);
+      }
+    }
+
     if (line[0] != '*')                        /* All lines start with an asterisk */
     {
+      if (ppd_conform == PPD_CONFORM_STRICT)
+      {
+        ppd_status = PPD_MISSING_ASTERISK;
+        return (0);
+      }
+
      /*
       * Allow lines consisting of just whitespace...
       */
@@ -2870,6 +2906,13 @@ ppd_read(FILE *fp,                       /* I - File to read from */
       }
 
       *optptr = '\0';
+
+      if (!option[0] && ppd_conform == PPD_CONFORM_STRICT)
+      {
+        ppd_status = PPD_ILLEGAL_WHITESPACE;
+       return (0);
+      }
+
       mask |= PPD_OPTION;
 
 /*      DEBUG_printf(("option = \"%s\", lineptr = \"%s\"\n", option, lineptr));*/
@@ -2905,13 +2948,23 @@ ppd_read(FILE *fp,                      /* I - File to read from */
 /*      DEBUG_printf(("text = \"%s\", lineptr = \"%s\"\n", text, lineptr));*/
     }
 
+    if (isspace(*lineptr) && ppd_conform == PPD_CONFORM_STRICT)
+    {
+      ppd_status = PPD_ILLEGAL_WHITESPACE;
+      return (0);
+    }
+
+    while (isspace(*lineptr))
+      lineptr ++;
+
     if (*lineptr == ':')
     {
      /*
       * Get string after triming leading and trailing whitespace...
       */
 
-      while (*lineptr == ':' || isspace(*lineptr))
+      lineptr ++;
+      while (isspace(*lineptr))
         lineptr ++;
 
       strptr = lineptr + strlen(lineptr) - 1;
@@ -2949,5 +3002,5 @@ ppd_read(FILE *fp,                        /* I - File to read from */
 
 
 /*
- * End of "$Id: ppd.c,v 1.51.2.56 2003/07/20 12:51:41 mike Exp $".
+ * End of "$Id: ppd.c,v 1.51.2.57 2003/08/01 15:00:28 mike Exp $".
  */
index c4b9f1800859f957f13d5116bc820cd4782fc55c..0193310b81df4f33679367a875319cb16928b50b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppd.h,v 1.24.2.17 2003/04/10 03:01:49 mike Exp $"
+ * "$Id: ppd.h,v 1.24.2.18 2003/08/01 15:00:29 mike Exp $"
  *
  *   PostScript Printer Description definitions for the Common UNIX Printing
  *   System (CUPS).
@@ -120,9 +120,16 @@ typedef enum                       /**** Status Codes ****/
   PPD_ILLEGAL_CHARACTER,       /* Illegal control character */
   PPD_ILLEGAL_MAIN_KEYWORD,    /* Illegal main keyword string */
   PPD_ILLEGAL_OPTION_KEYWORD,  /* Illegal option keyword string */
-  PPD_ILLEGAL_TRANSLATION      /* Illegal translation string */
+  PPD_ILLEGAL_TRANSLATION,     /* Illegal translation string */
+  PPD_ILLEGAL_WHITESPACE       /* Illegal whitespace character */
 } ppd_status_t;
 
+typedef enum                   /**** Conformance Levels ****/
+{
+  PPD_CONFORM_RELAXED,         /* Relax whitespace and control char */
+  PPD_CONFORM_STRICT           /* Require strict conformance */
+} ppd_conform_t;
+
 typedef struct                 /**** PPD Attribute Structure ****/
 {
   char         name[PPD_MAX_NAME],
@@ -402,6 +409,9 @@ extern int          ppdMarkXYArray(ppd_file_t *ppd, const char *keyword,
                                       const char *param, int num_values,
                                       const float *values);
 
+/**** New in CUPS 1.1.20 ****/
+extern void            ppdSetConformance(ppd_conform_t c);
+
 /**** New in CUPS 1.2 ****/
 extern int             ppdSave(ppd_file_t *ppd, FILE *fp);
 extern int             ppdSaveFd(ppd_file_t *ppd, int fd);
@@ -418,5 +428,5 @@ extern int          ppdSaveFile(ppd_file_t *ppd, const char *filename);
 #endif /* !_CUPS_PPD_H_ */
 
 /*
- * End of "$Id: ppd.h,v 1.24.2.17 2003/04/10 03:01:49 mike Exp $".
+ * End of "$Id: ppd.h,v 1.24.2.18 2003/08/01 15:00:29 mike Exp $".
  */
index 2e207c76ac7f65f8e2da163c2718e6e2b9b39e7a..26f20b8cf490be2a513af255ac58759cdca074c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cupstestppd.c,v 1.1.2.24 2003/07/20 02:34:29 mike Exp $"
+ * "$Id: cupstestppd.c,v 1.1.2.25 2003/08/01 15:00:30 mike Exp $"
  *
  *   PPD test program for the Common UNIX Printing System (CUPS).
  *
@@ -93,12 +93,12 @@ main(int  argc,                     /* I - Number of command-line arguments */
                                 "JCL", "PAGE", "PROLOG" };
 
 
-  setbuf(stdout, NULL);
-
  /*
   * Display PPD files for each file listed on the command-line...
   */
 
+  ppdSetConformance(PPD_CONFORM_STRICT);
+
   verbose = 0;
   ppd     = NULL;
   files   = 0;
@@ -110,7 +110,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
       for (opt = argv[i] + 1; *opt; opt ++)
         switch (*opt)
        {
-         case 'q' :
+         case 'q' :                    /* Quiet mode */
              if (verbose > 0)
              {
                fputs("cupstestppd: The -q option is incompatible with the -v option.\n",
@@ -121,7 +121,11 @@ main(int  argc,                    /* I - Number of command-line arguments */
              verbose --;
              break;
 
-         case 'v' :
+         case 'r' :                    /* Relaxed mode */
+              ppdSetConformance(PPD_CONFORM_RELAXED);
+             break;
+
+         case 'v' :                    /* Verbose mode */
              if (verbose < 0)
              {
                fputs("cupstestppd: The -v option is incompatible with the -q option.\n",
@@ -1008,13 +1012,13 @@ show_conflicts(ppd_file_t *ppd)         /* I - PPD to check */
 void
 usage(void)
 {
-  puts("Usage: cupstestppd [-q] [-v[v]] filename1.ppd[.gz] [... filenameN.ppd[.gz]]");
-  puts("       program | cupstestppd [-q] [-v[v]] -");
+  puts("Usage: cupstestppd [-q] [-r] [-v[v]] filename1.ppd[.gz] [... filenameN.ppd[.gz]]");
+  puts("       program | cupstestppd [-q] [-r] [-v[v]] -");
 
   exit(ERROR_USAGE);
 }
 
 
 /*
- * End of "$Id: cupstestppd.c,v 1.1.2.24 2003/07/20 02:34:29 mike Exp $".
+ * End of "$Id: cupstestppd.c,v 1.1.2.25 2003/08/01 15:00:30 mike Exp $".
  */