Exemple #1
0
BOOL
bSendPSProcSet(
    PDEVDATA    pdev,
    ULONG       ulPSid
)

/*++

Routine Description:

    Load the specified procset from the resource file and
    then output it to printer.

Arguments:

    pdev        Pointer to DEVDATA structure
    ulPSid      Resource ID of the procset

Return Value:

    TRUE if successful. FALSE otherwise.

--*/

{
    PVOID   pres;
    ULONG   size;

    if (pdev->dwFlags & PDEV_CANCELDOC)
        return FALSE;

    // Retrieve the specified procset from resource file

    pres = EngFindResource(pdev->hModule, ulPSid, PSPROC, &size);

    if (pres == NULL || size == 0) {

        DBGERRMSG("EngFindResource");
        pdev->dwFlags |= PDEV_CANCELDOC;
        return FALSE;
    }

    // Output the procset to printer

    return pswrite(pdev, pres, size);
}
Exemple #2
0
static void write_string(struct oport *p, prt_level level, struct string *print)
{
  uvalue l = string_len(print);

  if (level == prt_display)
    pswrite(p, print, 0, l);
  else
    {
      unsigned char *str = (unsigned char *)alloca(l + 1);
      unsigned char *endstr;

      memcpy((char *)str, print->str, l + 1);
      GCPRO1(p);
      /* The NULL byte at the end doesn't count */
      endstr = str + l;

      pputc('"', p);
      while (str < endstr)
	{
	  unsigned char *pos = str;

	  while (pos < endstr && writable(*pos)) pos++;
	  opwrite(p, (char *)str, pos - str);
	  if (pos < endstr)	/* We stopped for a \ */
	    {
	      pputc('\\', p);
	      switch (*pos)
		{
		case '\\': case '"': pputc(*pos, p); break;
		case '\n': pputc('n', p); break;
		case '\r': pputc('r', p); break;
		case '\t': pputc('t', p); break;
		case '\f': pputc('f', p); break;
		default: pprintf(p, "%o", *pos); break;
		}
	      str = pos + 1;
	    }
	  else str = pos;
	}
      pputc('"', p);
      GCPOP(1);
    }
}
Exemple #3
0
int					/* O - Exit status */
main(int  argc,				/* I - Number of command-line args */
     char *argv[])			/* I - Command-line arguments */
{
  FILE		*fp;			/* File to print */
  int		copies;			/* Number of copies left */
  char		line[1024];		/* Line/buffer from stream/file */
  size_t	linelen;		/* Length of line */
  ppd_file_t	*ppd;			/* PPD file */


 /*
  * Check command-line...
  */

  if (argc < 6 || argc > 7)
  {
    _cupsLangPrintf(stderr,
                    _("Usage: %s job-id user title copies options [file]"),
		    argv[0]);
    return (1);
  }

  if (argc == 6)
  {
    copies = 1;
    fp     = stdin;
  }
  else
  {
    copies = atoi(argv[4]);
    fp     = fopen(argv[6], "rb");

    if (!fp)
    {
      perror(argv[6]);
      return (1);
    }
  }

 /*
  * Open the PPD file as needed...
  */

  ppd = ppdOpenFile(getenv("PPD"));

 /*
  * Copy the print file to stdout...
  */

  while (copies > 0)
  {
    copies --;

    if (ppd && ppd->jcl_begin)
      fputs(ppd->jcl_begin, stdout);
    if (ppd && ppd->jcl_ps)
      fputs(ppd->jcl_ps, stdout);

    if (!ppd || ppd->language_level == 1)
    {
     /*
      * Use setsoftwareiomode for BCP mode...
      */

      puts("%!PS-Adobe-3.0 ExitServer");
      puts("%%Title: (BCP - Level 1)");
      puts("%%EndComments");
      puts("%%BeginExitServer: 0");
      puts("serverdict begin 0 exitserver");
      puts("%%EndExitServer");
      puts("statusdict begin");
      puts("/setsoftwareiomode known {100 setsoftwareiomode}");
      puts("end");
      puts("%EOF");
    }
    else
    {
     /*
      * Use setdevparams for BCP mode...
      */

      puts("%!PS-Adobe-3.0");
      puts("%%Title: (BCP - Level 2)");
      puts("%%EndComments");
      puts("currentsysparams");
      puts("/CurInputDevice 2 copy known {");
      puts("get");
      puts("<</Protocol /Binary>> setdevparams");
      puts("}{");
      puts("pop pop");
      puts("} ifelse");
      puts("%EOF");
    }

    if (ppd && ppd->jcl_end)
      fputs(ppd->jcl_end, stdout);
    else if (!ppd || ppd->num_filters == 0)
      putchar(0x04);

   /*
    * Loop until we see end-of-file...
    */

    do
    {
      linelen = sizeof(line);
      if (psgets(line, &linelen, fp) == NULL)
	break;
    }
    while (pswrite(line, linelen) > 0);

    fflush(stdout);
  }

  return (0);
}
Exemple #4
0
int					/* O - Exit status */
main(int  argc,				/* I - Number of command-line args */
     char *argv[])			/* I - Command-line arguments */
{
  FILE		*fp;			/* File to print */
  int		copies;			/* Number of copies left */
  char		line[1024];		/* Line/buffer from stream/file */
  size_t	linelen;		/* Length of line */


 /*
  * Check command-line...
  */

  if (argc < 6 || argc > 7)
  {
    _cupsLangPrintf(stderr,
                    _("Usage: %s job-id user title copies options [file]"),
		    argv[0]);
    return (1);
  }

  if (argc == 6)
  {
    copies = 1;
    fp     = stdin;
  }
  else
  {
    copies = atoi(argv[4]);
    fp     = fopen(argv[6], "rb");

    if (!fp)
    {
      perror(argv[6]);
      return (1);
    }
  }

 /*
  * Copy the print file to stdout...
  */

  while (copies > 0)
  {
    copies --;

   /*
    * Read the first line...
    */

    linelen = sizeof(line);
    if (!psgets(line, &linelen, fp))
      break;

   /*
    * Handle leading PJL fun...
    */

    if (!strncmp(line, "\033%-12345X", 9) || !strncmp(line, "@PJL ", 5))
    {
     /*
      * Yup, we have leading PJL fun, so copy it until we hit a line
      * with "ENTER LANGUAGE"...
      */

      while (strstr(line, "ENTER LANGUAGE") == NULL)
      {
        fwrite(line, 1, linelen, stdout);

	linelen = sizeof(line);
	if (psgets(line, &linelen, fp) == NULL)
          break;
      }
    }
    else
    {
     /*
      * No PJL stuff, just add the UEL...
      */

      fputs("\033%-12345X", stdout);
    }

   /*
    * Switch to TBCP mode...
    */

    fputs("\001M", stdout);

   /*
    * Loop until we see end-of-file...
    */

    while (pswrite(line, linelen, stdout) > 0)
    {
      linelen = sizeof(line);
      if (psgets(line, &linelen, fp) == NULL)
	break;
    }

    fflush(stdout);
  }

  return (0);
}
Exemple #5
0
BOOL
bOutputHeader(
    PDEVDATA pdev
)

/*++

Routine Description:

    Send PostScript output header to the printer

Arguments:

    pdev - Pointer to our DEVDATA

Return Value:

    TRUE if successful, FALSE otherwise

--*/

{
    CHAR           *pstr;
    HPPD            hppd = pdev->hppd;
    ENG_TIME_FIELDS localtime;

    //
    // Process information in the public devmode fields and map it to printer
    // feature selections. This must be called before PsSelectPrinterFeatures.
    //

    HandlePublicDevmodeOptions(pdev);

    //
    // Spit out job control stuff at the beginning of a job if necessary
    //

    if (! bPageIndependence(pdev) &&
            ! (pdev->dm.dmPrivate.dwFlags & PSDEVMODE_NO_JOB_CONTROL))
    {
        if (PpdSupportsProtocol(hppd, PROTOCOL_PJL)) {

            // Universal exit language

            if (hppd->pJclBegin != NULL) {

                psputs(pdev, hppd->pJclBegin);
            } else {

                DBGMSG(DBG_LEVEL_TERSE, "No JCLBegin code.\n");
                psputs(pdev, "\033%-12345X");
            }

            // If the printer uses PJL commands to set resolution,
            // then do it before the job.

            SetResolution(pdev, pdev->dm.dmPublic.dmPrintQuality, RESTYPE_JCL);

            // Select printer specific features - JCLSetup

            PsSelectPrinterFeatures(pdev, ODS_JCLSETUP);

            // if the printer supports job switching, put the printer into
            // postscript mode now.

            if (hppd->pJclToPs != NULL) {

                psputs(pdev, hppd->pJclToPs);
            } else {

                DBGMSG(DBG_LEVEL_TERSE, "No JCLToPSInterpreter code.\n");
                psputs(pdev, "@PJL ENTER LANGUAGE=POSTSCRIPT\n");
            }

        } else if (PpdSupportsProtocol(hppd, PROTOCOL_SIC)) {

            // directly call pswrite to output the necessary escape commands.
            // psputs will NOT output '\000'.

            pswrite(pdev, "\033\133\113\030\000\006\061\010\000\000\000\000\000", 13);
            pswrite(pdev, "\000\000\000\000\000\000\000\000\004\033\133\113\003", 13);
            pswrite(pdev, "\000\006\061\010\004", 5);

        } else if (pdev->dm.dmPrivate.dwFlags & PSDEVMODE_CTRLD_BEFORE) {

            // send a ^D before the job

            pswrite(pdev, "\004", 1);
        }
    }

    psputs(pdev, "%!PS-Adobe-3.0\n");

    // output the title of the document.

    if (pdev->pwstrDocName) {

        CHAR    buf[128];

        CopyUnicode2Str(buf, pdev->pwstrDocName, 128);

        psprintf(pdev, "%%%%Title: %s\n", buf);
    } else
        psputs(pdev, "%%Title: Untitled Document\n");

    // let the world know who we are.

    psputs(pdev, "%%Creator: Windows NT 4.0\n");

    // print the date and time of creation.

    EngQueryLocalTime(&localtime);

    psprintf(pdev, "%%%%CreationDate: %d:%d %d/%d/%d\n",
             localtime.usHour,
             localtime.usMinute,
             localtime.usMonth,
             localtime.usDay,
             localtime.usYear);

    if (! (pdev->dwFlags & PDEV_EPSPRINTING_ESCAPE))
        psputs(pdev, "%%Pages: (atend)\n");

    // mark the bounding box of the document.

    psputs(pdev, "%%BoundingBox: ");

    psprintf(pdev, "%d %d %d %d\n",
             PSREAL2INT(pdev->CurForm.ImageArea.left),
             PSREAL2INT(pdev->CurForm.ImageArea.bottom),
             PSREAL2INT(pdev->CurForm.ImageArea.right),
             PSREAL2INT(pdev->CurForm.ImageArea.top));


    if (pdev->cCopies > 1)
        psprintf(pdev, "%%%%Requirements: numcopies(%d) collate\n", pdev->cCopies);

    DscLanguageLevel(pdev, pdev->hppd->dwLangLevel);
    DscOutputFontComments(pdev, FALSE);

    // we are done with the comments portion of the document.

    psputs(pdev, "%%EndComments\n");

    // If the printer uses exitserver commands to set
    // resolution, then do it before any other PS code.

    SetResolution(pdev, pdev->dm.dmPublic.dmPrintQuality, RESTYPE_EXITSERVER);

    // define our procedure set.

    if (!(pdev->dwFlags & PDEV_EPSPRINTING_ESCAPE)) {

        psputs(pdev, "%%BeginProlog\n");
        DownloadNTProcSet(pdev, TRUE);
        psputs(pdev, "%%EndProlog\n");
    }

    // do the device setup.

    psputs(pdev, "%%BeginSetup\n");

    // set job and wait timeout values

    SetTimeoutValues(pdev);

    // Set number of copies

    psprintf(pdev, "/#copies %d def\n", pdev->cCopies);

    // Select printer specific features - DocumentSetup and AnySetup

    PsSelectPrinterFeatures(pdev, ODS_DOCSETUP|ODS_ANYSETUP);

    // The implemention of EPSPRINTING escape here just follows Win31

    if ((pdev->dwFlags & PDEV_EPSPRINTING_ESCAPE) &&
            (pdev->dm.dmPublic.dmOrientation == DMORIENT_LANDSCAPE))
    {
        SetLandscape(pdev, TRUE, pdev->CurForm.PaperSize.height, pdev->CurForm.PaperSize.width);
    }

    //
    // Invert the default transfer function if Negative Output option is selected
    //

    if (pdev->dm.dmPrivate.dwFlags & PSDEVMODE_NEG) {

        psputs(pdev, "[currenttransfer /exec load {1 exch sub} /exec load] cvx settransfer\n");
    }

    psputs(pdev, "%%EndSetup\n");

    // the form-tray information has already been sent for the first page.

    pdev->dwFlags &= ~PDEV_RESETPDEV;

    return(TRUE);
}
Exemple #6
0
void outputGraph(Agraph_t * g, FILE * fp, int expMode)
{
    pswrite(g, fp, expMode);
}