From ae90e3358706c48ff51bbbaa169d1338b9f07d34 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 2 Jun 2003 20:08:50 +0000 Subject: [PATCH] Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3759 7a7537e8-13f0-0310-91df-b6672ffda945 --- CHANGES-1.1.txt | 7 +++- cups/emit.c | 92 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index fbcb7aff80..f86d635bbe 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -3,8 +3,13 @@ CHANGES-1.1.txt CHANGES IN CUPS V1.1.20rc1 + - The cupsEmitJCL() function not outputs an empty @PJL + command after the PJL language escape to work around + bugs in certain PJL implementations (STR #131) + - The cupsEmit*() functions didn't set the orientation + value properly (STR #127) - The cups.spec file didn't list the rc2.d init - directory or the cupstestppd file. + directory or the cupstestppd file (STR #134) CHANGES IN CUPS V1.1.19 diff --git a/cups/emit.c b/cups/emit.c index b680c3cb1f..67c1575724 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -1,5 +1,5 @@ /* - * "$Id: emit.c,v 1.23.2.8 2003/05/25 14:43:34 mike Exp $" + * "$Id: emit.c,v 1.23.2.9 2003/06/02 20:08:50 mike Exp $" * * PPD code emission routines for the Common UNIX Printing System (CUPS). * @@ -207,7 +207,8 @@ ppdEmit(ppd_file_t *ppd, /* I - PPD file record */ ppd_attr_t *attr; /* PPD attribute */ int pos, /* Position of custom value */ - values[5]; /* Values for custom command */ + values[5], /* Values for custom command */ + orientation; /* Orientation to use */ fputs("%%BeginFeature: *CustomPageSize True\n", fp); @@ -240,6 +241,36 @@ ppdEmit(ppd_file_t *ppd, /* I - PPD file record */ values[pos] = (int)size->length; + if (size->width < size->length) + orientation = 1; + else + orientation = 0; + + if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", + "Orientation")) != NULL) + { + int min_orient, max_orient; /* Minimum and maximum orientations */ + + + if (sscanf(attr->value, "%d%*s%d%d", &pos, &min_orient, + &max_orient) != 3) + pos = 4; + else + { + if (pos < 0 || pos > 4) + pos = 4; + + if (orientation > max_orient) + orientation = max_orient; + else if (orientation < min_orient) + orientation = min_orient; + } + } + else + pos = 4; + + values[pos] = orientation; + fprintf(fp, "%d %d %d %d %d\n", values[0], values[1], values[2], values[3], values[4]); @@ -377,7 +408,8 @@ ppdEmitFd(ppd_file_t *ppd, /* I - PPD file record */ ppd_attr_t *attr; /* PPD attribute */ int pos, /* Position of custom value */ - values[5]; /* Values for custom command */ + values[5], /* Values for custom command */ + orientation; /* Orientation to use */ size = ppdPageSize(ppd, "Custom"); @@ -408,6 +440,36 @@ ppdEmitFd(ppd_file_t *ppd, /* I - PPD file record */ values[pos] = (int)size->length; + if (size->width < size->length) + orientation = 1; + else + orientation = 0; + + if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", + "Orientation")) != NULL) + { + int min_orient, max_orient; /* Minimum and maximum orientations */ + + + if (sscanf(attr->value, "%d%*s%d%d", &pos, &min_orient, + &max_orient) != 3) + pos = 4; + else + { + if (pos < 0 || pos > 4) + pos = 4; + + if (orientation > max_orient) + orientation = max_orient; + else if (orientation < min_orient) + orientation = min_orient; + } + } + else + pos = 4; + + values[pos] = orientation; + snprintf(buf, sizeof(buf), "%d %d %d %d %d\n", values[0], values[1], values[2], values[3], values[4]); @@ -477,6 +539,7 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ const char *title) /* I - Title */ { const char *ptr; /* Pointer into JCL string */ + char temp[81]; /* Local title string */ if (ppd == NULL || ppd->jcl_begin == NULL || ppd->jcl_ps == NULL) @@ -487,9 +550,13 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ /* * This printer uses HP PJL commands for output; filter the output * so that we only have a single "@PJL JOB" command in the header... + * + * To avoid bugs in the PJL implementation of certain vendors' products + * (Xerox in particular), we add a dummy "@PJL" command at the beginning + * of the PJL commands to initialize PJL processing. */ - fputs("\033%-12345X", fp); + fputs("\033%-12345X@PJL\n", fp); for (ptr = ppd->jcl_begin + 9; *ptr;) if (strncmp(ptr, "@PJL JOB", 8) == 0) { @@ -521,12 +588,23 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ ptr ++; } + /* + * Replace double quotes with single quotes so that the title + * does not cause a PJL syntax error. + */ + + strlcpy(temp, title, sizeof(temp)); + + for (ptr = temp; *ptr; ptr ++) + if (*ptr == '\"') + *ptr = '\''; + /* * Send PJL JOB command before we enter PostScript mode... */ - fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%d %s %s\"\n", title, - job_id, user, title); + fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%d %s %s\"\n", temp, + job_id, user, temp); } else fputs(ppd->jcl_begin, stdout); @@ -631,5 +709,5 @@ ppd_sort(ppd_choice_t **c1, /* I - First choice */ /* - * End of "$Id: emit.c,v 1.23.2.8 2003/05/25 14:43:34 mike Exp $". + * End of "$Id: emit.c,v 1.23.2.9 2003/06/02 20:08:50 mike Exp $". */ -- 2.47.2