summaryrefslogtreecommitdiff
path: root/renderer.c
diff options
context:
space:
mode:
authorDidier Raboud <didier@raboud.com>2010-07-19 15:56:58 +0200
committerDidier Raboud <didier@raboud.com>2010-07-19 15:56:58 +0200
commit1a03de334fd4e6aafb91b806ea35092a7774a8d7 (patch)
tree122dc48818d103149727c7212f3d551e63aa2039 /renderer.c
parent7b7bb0240eda341c29d786e97f6ad7c52d10cac7 (diff)
Imported Upstream version 4.0.4upstream/4.0.4
Diffstat (limited to 'renderer.c')
-rw-r--r--renderer.c52
1 files changed, 43 insertions, 9 deletions
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 <till.kamppeter@gmail.com>
+ * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ *
+ * 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;
}