]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/interpret.c
Import CUPS 1.4svn-r7464.
[thirdparty/cups.git] / filter / interpret.c
index dedc86d2f580cd206c9508525230465e44a5f075..945c8f40a9a1a2217a48b8b84e8190cfecc1ecd6 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: interpret.c 6575 2007-06-19 23:56:24Z mike $"
+ * "$Id: interpret.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   PPD command interpreter for the Common UNIX Printing System (CUPS).
  *
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1993-2007 by Easy Software Products.
  *
  *   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/".
  *
  *   This file is subject to the Apple OS-Developed Software exception.
  *
@@ -131,31 +122,40 @@ static void               DEBUG_stack(_cups_ps_stack_t *st);
 /*
  * 'cupsRasterInterpretPPD()' - Interpret PPD commands to create a page header.
  *
- * This function does not mark the options in the PPD using the "num_options"
- * and "options" arguments.  Instead, mark the options prior to calling
- * cupsRasterInterpretPPD() - this allows you to do per-page options
- * without manipulating the options array.
+ * This function is used by raster image processing (RIP) filters like
+ * cgpdftoraster and imagetoraster when writing CUPS raster data for a page.
+ * It is not used by raster printer driver filters which only read CUPS
+ * raster data.
+ *
+ *
+ * @code cupsRasterInterpretPPD@ does not mark the options in the PPD using
+ * the "num_options" and "options" arguments.  Instead, mark the options with
+ * @code cupsMarkOptions@ and @code ppdMarkOption@ prior to calling it -
+ * this allows for per-page options without manipulating the options array.
  *
  * The "func" argument specifies an optional callback function that is
  * called prior to the computation of the final raster data.  The function
- * can make changes to the cups_page_header2_t data as needed to use a
+ * can make changes to the @link cups_page_header2_t@ data as needed to use a
  * supported raster format and then returns 0 on success and -1 if the
  * requested attributes cannot be supported.
  *
- * cupsRasterInterpretPPD() supports a subset of the PostScript language.
- * Currently only the [, ], <<, >>, {, }, cleartomark, copy, dup, index,
- * pop, roll, setpagedevice, and stopped operators are supported.
  *
- * @since CUPS 1.2@
+ * @code cupsRasterInterpretPPD@ supports a subset of the PostScript language.
+ * Currently only the @code [@, @code ]@, @code <<@, @code >>@, @code {@,
+ * @code }@, @code cleartomark@, @code copy@, @code dup@, @code index@,
+ * @code pop@, @code roll@, @code setpagedevice@, and @code stopped@ operators
+ * are supported.
+ *
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 int                                    /* O - 0 on success, -1 on failure */
 cupsRasterInterpretPPD(
-    cups_page_header2_t *h,            /* O - Page header */
+    cups_page_header2_t *h,            /* O - Page header to create */
     ppd_file_t          *ppd,          /* I - PPD file */
     int                 num_options,   /* I - Number of options */
     cups_option_t       *options,      /* I - Options */
-    cups_interpret_cb_t func)          /* I - Optional page header callback */
+    cups_interpret_cb_t func)          /* I - Optional page header callback (@code NULL@ for none) */
 {
   int          status;                 /* Cummulative status */
   char         *code;                  /* Code to run */
@@ -468,9 +468,8 @@ _cupsRasterExecPS(
   while ((obj = scan_ps(st, &codeptr)) != NULL)
   {
 #ifdef DEBUG
-    printf("    (%d): ", st->num_objs);
+    DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)\n", st->num_objs));
     DEBUG_object(obj);
-    putchar('\n');
 #endif /* DEBUG */
 
     switch (obj->type)
@@ -486,7 +485,7 @@ _cupsRasterExecPS(
            _cupsRasterAddError("cleartomark: Stack underflow!\n");
 
 #ifdef DEBUG
-          fputs("    dup: ", stdout);
+          DEBUG_puts("    dup: ");
          DEBUG_stack(st);
 #endif /* DEBUG */
           break;
@@ -498,7 +497,7 @@ _cupsRasterExecPS(
            copy_stack(st, (int)obj->value.number);
 
 #ifdef DEBUG
-            fputs("    copy: ", stdout);
+            DEBUG_puts("_cupsRasterExecPS: copy");
            DEBUG_stack(st);
 #endif /* DEBUG */
           }
@@ -509,7 +508,7 @@ _cupsRasterExecPS(
          copy_stack(st, 1);
 
 #ifdef DEBUG
-          fputs("    dup: ", stdout);
+          DEBUG_puts("_cupsRasterExecPS: dup");
          DEBUG_stack(st);
 #endif /* DEBUG */
           break;
@@ -521,7 +520,7 @@ _cupsRasterExecPS(
            index_stack(st, (int)obj->value.number);
 
 #ifdef DEBUG
-            fputs("    index: ", stdout);
+            DEBUG_puts("_cupsRasterExecPS: index");
            DEBUG_stack(st);
 #endif /* DEBUG */
           }
@@ -532,7 +531,7 @@ _cupsRasterExecPS(
           pop_stack(st);
 
 #ifdef DEBUG
-          fputs("    pop: ", stdout);
+          DEBUG_puts("_cupsRasterExecPS: pop");
          DEBUG_stack(st);
 #endif /* DEBUG */
           break;
@@ -551,7 +550,7 @@ _cupsRasterExecPS(
              roll_stack(st, (int)obj->value.number, c);
 
 #ifdef DEBUG
-              fputs("    roll:", stdout);
+              DEBUG_puts("_cupsRasterExecPS: roll");
              DEBUG_stack(st);
 #endif /* DEBUG */
             }
@@ -563,7 +562,7 @@ _cupsRasterExecPS(
          setpagedevice(st, h, preferred_bits);
 
 #ifdef DEBUG
-          fputs("    setpagedevice: ", stdout);
+          DEBUG_puts("_cupsRasterExecPS: setpagedevice");
          DEBUG_stack(st);
 #endif /* DEBUG */
           break;
@@ -576,11 +575,12 @@ _cupsRasterExecPS(
 
       case CUPS_PS_OTHER :
           _cupsRasterAddError("Unknown operator \"%s\"!\n", obj->value.other);
-          DEBUG_printf(("    Unknown operator \"%s\"!\n", obj->value.other));
+          DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\"!\n",
+                       obj->value.other));
           break;
     }
 
-    if (obj->type == CUPS_PS_OTHER)
+    if (obj && obj->type == CUPS_PS_OTHER)
       break;
   }
 
@@ -595,7 +595,7 @@ _cupsRasterExecPS(
     error_stack(st, "Stack not empty:");
 
 #ifdef DEBUG
-    fputs("    Stack not empty:", stdout);
+    DEBUG_puts("_cupsRasterExecPS: Stack not empty:");
     DEBUG_stack(st);
 #endif /* DEBUG */
 
@@ -1353,7 +1353,7 @@ setpagedevice(
   * Now pull /name and value pairs from the dictionary...
   */
 
-  DEBUG_puts("    Dictionary:");
+  DEBUG_puts("setpagedevice: Dictionary:");
 
   for (obj ++; obj < end; obj ++)
   {
@@ -1368,9 +1368,8 @@ setpagedevice(
     obj ++;
 
 #ifdef DEBUG
-    printf("        /%s ", name);
+    DEBUG_printf(("setpagedevice: /%s ", name));
     DEBUG_object(obj);
-    putchar('\n');
 #endif /* DEBUG */
 
    /*
@@ -1542,86 +1541,86 @@ DEBUG_object(_cups_ps_obj_t *obj)       /* I - Object to print */
   switch (obj->type)
   {
     case CUPS_PS_NAME :
-       printf("/%s", obj->value.name);
+       DEBUG_printf(("/%s\n", obj->value.name));
        break;
 
     case CUPS_PS_NUMBER :
-       printf("%g", obj->value.number);
+       DEBUG_printf(("%g\n", obj->value.number));
        break;
 
     case CUPS_PS_STRING :
-       printf("(%s)", obj->value.string);
+       DEBUG_printf(("(%s)\n", obj->value.string));
        break;
 
     case CUPS_PS_BOOLEAN :
        if (obj->value.boolean)
-         fputs("true", stdout);
+         DEBUG_puts("true");
        else
-         fputs("false", stdout);
+         DEBUG_puts("false");
        break;
 
     case CUPS_PS_NULL :
-       fputs("null", stdout);
+       DEBUG_puts("null");
        break;
 
     case CUPS_PS_START_ARRAY :
-       fputs("[", stdout);
+       DEBUG_puts("[");
        break;
 
     case CUPS_PS_END_ARRAY :
-       fputs("]", stdout);
+       DEBUG_puts("]");
        break;
 
     case CUPS_PS_START_DICT :
-       fputs("<<", stdout);
+       DEBUG_puts("<<");
        break;
 
     case CUPS_PS_END_DICT :
-       fputs(">>", stdout);
+       DEBUG_puts(">>");
        break;
 
     case CUPS_PS_START_PROC :
-       fputs("{", stdout);
+       DEBUG_puts("{");
        break;
 
     case CUPS_PS_END_PROC :
-       fputs("}", stdout);
+       DEBUG_puts("}");
        break;
 
     case CUPS_PS_CLEARTOMARK :
-       fputs("--cleartomark--", stdout);
+       DEBUG_puts("--cleartomark--");
         break;
 
     case CUPS_PS_COPY :
-       fputs("--copy--", stdout);
+       DEBUG_puts("--copy--");
         break;
 
     case CUPS_PS_DUP :
-       fputs("--dup--", stdout);
+       DEBUG_puts("--dup--");
         break;
 
     case CUPS_PS_INDEX :
-       fputs("--index--", stdout);
+       DEBUG_puts("--index--");
         break;
 
     case CUPS_PS_POP :
-       fputs("--pop--", stdout);
+       DEBUG_puts("--pop--");
         break;
 
     case CUPS_PS_ROLL :
-       fputs("--roll--", stdout);
+       DEBUG_puts("--roll--");
         break;
 
     case CUPS_PS_SETPAGEDEVICE :
-       fputs("--setpagedevice--", stdout);
+       DEBUG_puts("--setpagedevice--");
         break;
 
     case CUPS_PS_STOPPED :
-       fputs("--stopped--", stdout);
+       DEBUG_puts("--stopped--");
         break;
 
     case CUPS_PS_OTHER :
-       printf("--%s--", obj->value.other);
+       DEBUG_printf(("--%s--\n", obj->value.other));
        break;
   }
 }
@@ -1639,16 +1638,11 @@ DEBUG_stack(_cups_ps_stack_t *st)       /* I - Stack */
 
 
   for (obj = st->objs, c = st->num_objs; c > 0; c --, obj ++)
-  {
-    putchar(' ');
     DEBUG_object(obj);
-  }
-
-  putchar('\n');
 }
 #endif /* DEBUG */
 
 
 /*
- * End of "$Id: interpret.c 6575 2007-06-19 23:56:24Z mike $".
+ * End of "$Id: interpret.c 6649 2007-07-11 21:46:42Z mike $".
  */