]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Only convert PICTWPS files when printing to a server without support for
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 20 Feb 2003 03:49:50 +0000 (03:49 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 20 Feb 2003 03:49:50 +0000 (03:49 +0000)
PICTWPS files.

Allow trailing whitespace on a line.

Add additional checks for main keywords with a common prefix.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@3389 7a7537e8-13f0-0310-91df-b6672ffda945

backend/ipp.c
cups/ppd.c
systemv/cupstestppd.c

index fd41e6466321951ee2e1d6be29150e33f560937e..6cb4609adb42bcfb3644f5b70ce6176a27c97862 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c,v 1.73 2003/02/07 12:03:43 mike Exp $"
+ * "$Id: ipp.c,v 1.74 2003/02/20 03:49:48 mike Exp $"
  *
  *   IPP backend for the Common UNIX Printing System (CUPS).
  *
@@ -231,23 +231,6 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
 
     close(fd);
   }
-#ifdef __APPLE__
-  else if (strcasecmp(content_type, "application/pictwps") == 0)
-  {
-   /*
-    * Convert to PostScript...
-    */
-
-    if (run_pictwps_filter(argv, filename, sizeof(filename)))
-      return (1);
-
-   /*
-    * Change the MIME type to application/vnd.cups-postscript...
-    */
-
-    content_type = "application/postscript";
-  }
-#endif /* __APPLE__ */
   else
     strlcpy(filename, argv[6], sizeof(filename));
 
@@ -612,6 +595,35 @@ main(int  argc,            /* I - Number of command-line arguments (6 or 7) */
     options     = NULL;
     num_options = cupsParseOptions(argv[5], 0, &options);
 
+#ifdef __APPLE__
+    if (content_type != NULL && strcasecmp(content_type, "application/pictwps") == 0)
+    {
+      if (format_sup != NULL)
+      {
+       for (i = 0; i < format_sup->num_values; i ++)
+         if (strcasecmp(content_type, format_sup->values[i].string.text) == 0)
+           break;
+      }
+
+      if (format_sup == NULL || i >= format_sup->num_values)
+      {
+       /*
+       * Remote doesn't support "application/pictwps" (i.e. it's not MacOS X)
+       * so convert the document to PostScript...
+       */
+
+       if (run_pictwps_filter(argv, filename, sizeof(filename)))
+         return (1);
+
+       /*
+       * Change the MIME type to application/postscript...
+       */
+
+       content_type = "application/postscript";
+      }
+    }
+#endif /* __APPLE__ */
+
     if (content_type != NULL && format_sup != NULL)
     {
       for (i = 0; i < format_sup->num_values; i ++)
@@ -1137,5 +1149,5 @@ run_pictwps_filter(char **argv,                   /* I - Command-line arguments */
 
 
 /*
- * End of "$Id: ipp.c,v 1.73 2003/02/07 12:03:43 mike Exp $".
+ * End of "$Id: ipp.c,v 1.74 2003/02/20 03:49:48 mike Exp $".
  */
index d44ec1a4147c578d9c83d6f5bd250bed891274cd..a42ba7ce3a1f8f7a20126cf805eea3ef2ae1ad26 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppd.c,v 1.95 2003/02/19 22:02:39 mike Exp $"
+ * "$Id: ppd.c,v 1.96 2003/02/20 03:49:49 mike Exp $"
  *
  *   PPD file routines for the Common UNIX Printing System (CUPS).
  *
@@ -2590,9 +2590,6 @@ ppd_read(FILE *fp,                        /* I - File to read from */
         ppd_line ++;
        col = 0;
 
-       if (lineptr == line)            /* Skip blank lines */
-          continue;
-
        if (ch == '\r')
        {
         /*
@@ -2605,6 +2602,9 @@ ppd_read(FILE *fp,                        /* I - File to read from */
            ungetc(ch, fp);
        }
 
+       if (lineptr == line)            /* Skip blank lines */
+          continue;
+
        ch = '\n';
 
        if (!endquote)                  /* Continue for multi-line text */
@@ -2954,14 +2954,18 @@ ppd_read(FILE *fp,                      /* I - File to read from */
     if (*lineptr == ':')
     {
      /*
-      * Get string...
+      * Get string after triming leading and trailing whitespace...
       */
 
-      *string = malloc(strlen(lineptr) + 1);
-
       while (*lineptr == ':' || isspace(*lineptr))
         lineptr ++;
 
+      strptr = lineptr + strlen(lineptr);
+      while (*strptr == '\0' || isspace(*strptr))
+        *strptr-- = '\0';
+
+      *string = malloc(strlen(lineptr) + 1);
+
       strptr = *string;
 
       for (; *lineptr != '\0'; lineptr ++)
@@ -2982,5 +2986,5 @@ ppd_read(FILE *fp,                        /* I - File to read from */
 
 
 /*
- * End of "$Id: ppd.c,v 1.95 2003/02/19 22:02:39 mike Exp $".
+ * End of "$Id: ppd.c,v 1.96 2003/02/20 03:49:49 mike Exp $".
  */
index be72bfed50ab86ea645580dc972c39e1e07d3b94..ba489ec71b6d1190168ac67924701950d028b925 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cupstestppd.c,v 1.13 2003/02/19 17:38:20 mike Exp $"
+ * "$Id: cupstestppd.c,v 1.14 2003/02/20 03:49:50 mike Exp $"
  *
  *   PPD test program for the Common UNIX Printing System (CUPS).
  *
@@ -67,7 +67,8 @@ int                           /* O - Exit status */
 main(int  argc,                        /* I - Number of command-line arguments */
      char *argv[])             /* I - Command-line arguments */
 {
-  int          i, j, k, m;     /* Looping vars */
+  int          i, j, k, m, n;  /* Looping vars */
+  int          len;            /* Length of option name */
   char         *opt;           /* Option character */
   const char   *ptr;           /* Pointer into string */
   int          files;          /* Number of files */
@@ -81,6 +82,8 @@ main(int  argc,                       /* I - Number of command-line arguments */
   ppd_size_t   *size;          /* Size record */
   ppd_group_t  *group;         /* UI group */
   ppd_option_t *option;        /* Standard UI option */
+  ppd_group_t  *group2;        /* UI group */
+  ppd_option_t *option2;       /* Standard UI option */
   ppd_choice_t *choice;        /* Standard UI option choice */
   static char  *uis[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
   static char  *sections[] = { "ANY", "DOCUMENT", "EXIT",
@@ -310,6 +313,11 @@ main(int  argc,                    /* I - Number of command-line arguments */
 
       for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++)
        for (k = 0, option = group->options; k < group->num_options; k ++, option ++)
+       {
+        /*
+         * Verify that we have a default choice...
+         */
+
          if (option->defchoice[0])
          {
            if (verbose > 0)
@@ -329,6 +337,36 @@ main(int  argc,                    /* I - Number of command-line arguments */
            errors ++;
          }
 
+         /*
+         * Then verify that no other options share a common root name.
+         */
+
+         len = strlen(option->keyword);
+
+         for (m = 0, group2 = ppd->groups;
+              m < ppd->num_groups;
+              m ++, group2 ++)
+           for (n = 0, option2 = group2->options;
+                n < group2->num_options;
+                n ++, option2 ++)
+             if (option != option2 &&
+                 len < strlen(option2->keyword) &&
+                 !strncmp(option->keyword, option2->keyword, len))
+             {
+               if (verbose >= 0)
+               {
+                 if (!errors && !verbose)
+                   puts(" FAIL");
+
+                 printf("      **FAIL**  %s shares a common prefix with %s\n",
+                        option->keyword, option2->keyword);
+                 puts("                REF: Page 15, section 3.2.");
+               }
+
+               errors ++;
+             }
+       }
+
       if (ppdFindAttr(ppd, "FileVersion", NULL) != NULL)
       {
        if (verbose > 0)
@@ -831,5 +869,5 @@ usage(void)
 
 
 /*
- * End of "$Id: cupstestppd.c,v 1.13 2003/02/19 17:38:20 mike Exp $".
+ * End of "$Id: cupstestppd.c,v 1.14 2003/02/20 03:49:50 mike Exp $".
  */