From 1a03de334fd4e6aafb91b806ea35092a7774a8d7 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Mon, 19 Jul 2010 15:56:58 +0200 Subject: Imported Upstream version 4.0.4 --- renderer.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'renderer.c') diff --git a/renderer.c b/renderer.c index 48a56aa..4a46e9c 100644 --- a/renderer.c +++ b/renderer.c @@ -1,3 +1,25 @@ +/* renderer.c + * + * Copyright (C) 2008 Till Kamppeter + * Copyright (C) 2008 Lars Uebernickel + * + * This file is part of foomatic-rip. + * + * Foomatic-rip is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Foomatic-rip is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ #define _GNU_SOURCE @@ -139,7 +161,7 @@ char * read_line(FILE *stream, size_t *readbytes) return line; } -write_binary_data(FILE *stream, const char *data, size_t bytes) +void write_binary_data(FILE *stream, const char *data, size_t bytes) { int i; for (i=0; i < bytes; i++) @@ -248,7 +270,7 @@ static int write_merged_jcl_options(FILE *stream, { char *p = strstr(original_opts[0], jclstr); char header[128]; - char **optsp; + char **optsp1 = NULL, **optsp2 = NULL; /* No JCL options in original_opts, just prepend opts */ if (argv_count(original_opts) == 1) @@ -284,18 +306,30 @@ static int write_merged_jcl_options(FILE *stream, header[p - original_opts[0]] = '\0'; fprintf(stream, "%s", header); - for (optsp = opts; *optsp; optsp++) - if (!jcl_options_find_keyword(original_opts, *optsp, jclstr)) - fprintf(stream, "%s\n", *optsp); - - for (optsp = original_opts; *(optsp + 1); optsp++) { - if (optsp != original_opts) p = *optsp; + /* Insert the JCL commands from the PPD file right before the first + "@PJL SET ..." line from the, if there are no "@PJL SET ..." lines, + directly before "@PJL ENTER LANGUAGE ...", otherwise after the JCL + commands from the driver */ + for (optsp1 = original_opts; *(optsp1 + 1); optsp1++) { + if (optsp2 == NULL && + ((strstr(*optsp1, "ENTER LANGUAGE") != NULL) || + (strncasecmp(*optsp1, "@PJL SET ", 9) == 0))) { + for (optsp2 = opts; *optsp2; optsp2++) + if (!jcl_options_find_keyword(original_opts, *optsp2, jclstr)) + fprintf(stream, "%s\n", *optsp2); + } + if (optsp1 != original_opts) p = *optsp1; if (jcl_options_find_keyword(opts, p, jclstr)) fprintf(stream, "%s\n", jcl_options_find_keyword(opts, p, jclstr)); else fprintf(stream, "%s\n", p); } - write_binary_data(stream, *optsp, readbinarybytes); + if (optsp2 == NULL) + for (optsp2 = opts; *optsp2; optsp2++) + if (!jcl_options_find_keyword(original_opts, *optsp2, jclstr)) + fprintf(stream, "%s\n", *optsp2); + + write_binary_data(stream, *optsp1, readbinarybytes); return 1; } -- cgit v1.2.3