/*
- * "$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.
*
/*
* '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 */
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)
_cupsRasterAddError("cleartomark: Stack underflow!\n");
#ifdef DEBUG
- fputs(" dup: ", stdout);
+ DEBUG_puts(" dup: ");
DEBUG_stack(st);
#endif /* DEBUG */
break;
copy_stack(st, (int)obj->value.number);
#ifdef DEBUG
- fputs(" copy: ", stdout);
+ DEBUG_puts("_cupsRasterExecPS: copy");
DEBUG_stack(st);
#endif /* DEBUG */
}
copy_stack(st, 1);
#ifdef DEBUG
- fputs(" dup: ", stdout);
+ DEBUG_puts("_cupsRasterExecPS: dup");
DEBUG_stack(st);
#endif /* DEBUG */
break;
index_stack(st, (int)obj->value.number);
#ifdef DEBUG
- fputs(" index: ", stdout);
+ DEBUG_puts("_cupsRasterExecPS: index");
DEBUG_stack(st);
#endif /* DEBUG */
}
pop_stack(st);
#ifdef DEBUG
- fputs(" pop: ", stdout);
+ DEBUG_puts("_cupsRasterExecPS: pop");
DEBUG_stack(st);
#endif /* DEBUG */
break;
roll_stack(st, (int)obj->value.number, c);
#ifdef DEBUG
- fputs(" roll:", stdout);
+ DEBUG_puts("_cupsRasterExecPS: roll");
DEBUG_stack(st);
#endif /* DEBUG */
}
setpagedevice(st, h, preferred_bits);
#ifdef DEBUG
- fputs(" setpagedevice: ", stdout);
+ DEBUG_puts("_cupsRasterExecPS: setpagedevice");
DEBUG_stack(st);
#endif /* DEBUG */
break;
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;
}
error_stack(st, "Stack not empty:");
#ifdef DEBUG
- fputs(" Stack not empty:", stdout);
+ DEBUG_puts("_cupsRasterExecPS: Stack not empty:");
DEBUG_stack(st);
#endif /* DEBUG */
* Now pull /name and value pairs from the dictionary...
*/
- DEBUG_puts(" Dictionary:");
+ DEBUG_puts("setpagedevice: Dictionary:");
for (obj ++; obj < end; obj ++)
{
obj ++;
#ifdef DEBUG
- printf(" /%s ", name);
+ DEBUG_printf(("setpagedevice: /%s ", name));
DEBUG_object(obj);
- putchar('\n');
#endif /* DEBUG */
/*
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;
}
}
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 $".
*/