MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsRasterExecPS

Function _cupsRasterExecPS

cups/raster-interpret.c:504–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502 */
503
504int /* O - 0 on success, -1 on error */
505_cupsRasterExecPS(
506 cups_page_header2_t *h, /* O - Page header */
507 int *preferred_bits,/* O - Preferred bits per color */
508 const char *code) /* I - PS code to execute */
509{
510 int error = 0; /* Error condition? */
511 _cups_ps_stack_t *st; /* PostScript value stack */
512 _cups_ps_obj_t *obj; /* Object from top of stack */
513 char *codecopy, /* Copy of code */
514 *codeptr; /* Pointer into copy of code */
515
516
517 DEBUG_printf(("_cupsRasterExecPS(h=%p, preferred_bits=%p, code=\"%s\")\n",
518 h, preferred_bits, code));
519
520 /*
521 * Copy the PostScript code and create a stack...
522 */
523
524 if ((codecopy = strdup(code)) == NULL)
525 {
526 _cupsRasterAddError("Unable to duplicate code string.\n");
527 return (-1);
528 }
529
530 if ((st = new_stack()) == NULL)
531 {
532 _cupsRasterAddError("Unable to create stack.\n");
533 free(codecopy);
534 return (-1);
535 }
536
537 /*
538 * Parse the PS string until we run out of data...
539 */
540
541 codeptr = codecopy;
542
543 while ((obj = scan_ps(st, &codeptr)) != NULL)
544 {
545#ifdef DEBUG
546 DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)", st->num_objs));
547 DEBUG_object("_cupsRasterExecPS", obj);
548#endif /* DEBUG */
549
550 switch (obj->type)
551 {
552 default :
553 /* Do nothing for regular values */
554 break;
555
556 case CUPS_PS_CLEARTOMARK :
557 pop_stack(st);
558
559 if (cleartomark_stack(st))
560 _cupsRasterAddError("cleartomark: Stack underflow.\n");
561

Callers 2

do_ps_testsFunction · 0.85
_cupsRasterInterpretPPDFunction · 0.85

Calls 13

_cupsRasterAddErrorFunction · 0.85
new_stackFunction · 0.85
scan_psFunction · 0.85
DEBUG_objectFunction · 0.85
pop_stackFunction · 0.85
cleartomark_stackFunction · 0.85
DEBUG_stackFunction · 0.85
copy_stackFunction · 0.85
index_stackFunction · 0.85
roll_stackFunction · 0.85
setpagedeviceFunction · 0.85
error_stackFunction · 0.85

Tested by 1

do_ps_testsFunction · 0.68