~ubuntu-branches/ubuntu/natty/foomatic-filters/natty

« back to all changes in this revision

Viewing changes to foomaticrip.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-08-19 20:13:17 UTC
  • mfrom: (1.1.31 upstream)
  • Revision ID: james.westby@ubuntu.com-20090819201317-vcjm7b2jburausgy
Tags: 4.0.3-0ubuntu1
* New upstream release
   - Do PDF-to-PostScript conversion with Poppler, as Ghostscript produces
     huge files (Upstream bug #365).
   - Fixed LPRng support (Upstream bug #337).
   - Do not use JCL which is preceeded to the input data by a CUPS filter, as
     this does not get merged with the driver's JCL.
   - When merging the JCL from the PPD options with the JCL of the driver,
     make sure that no "@PJL SET ..." commands gets before a "@PJL JOB ..."
     command as such commands get ignored.
* debian/patches/10_jcl-merge-fixes.patch: Removed patch with upstream fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
965
965
    n = fread(buf, 1, sizeof(buf) - 1, file);
966
966
    buf[n] = '\0';
967
967
    type = guess_file_type(buf, n, &startpos);
968
 
    if (startpos > 0) {
 
968
    /* We do not use any JCL preceeded to the inputr data, as it is simply
 
969
       the PJL commands from the PPD file, and these commands we can also
 
970
       generate, end we even merge them with PJl from the driver */
 
971
    /*if (startpos > 0) {
969
972
        jobhasjcl = 1;
970
973
        write_output(buf, startpos);
971
 
    }
 
974
    }*/
972
975
    if (file != stdin)
973
976
        rewind(file);
974
977
 
983
986
                char pdf2ps_cmd[PATH_MAX];
984
987
                FILE *out, *in;
985
988
                int renderer_pid;
 
989
                char tmpfilename[PATH_MAX] = "";
986
990
 
987
991
                _log("Driver does not understand PDF input, "
988
992
                     "converting to PostScript\n");
989
993
 
990
994
                pdfconvertedtops = 1;
 
995
 
 
996
                /* If reading from stdin, write everything into a temporary file */
 
997
                if (file == stdin)
 
998
                {
 
999
                    int fd;
 
1000
                    FILE *tmpfile;
 
1001
                    
 
1002
                    snprintf(tmpfilename, PATH_MAX, "%s/foomatic-XXXXXX", temp_dir());
 
1003
                    fd = mkstemp(tmpfilename);
 
1004
                    if (fd < 0) {
 
1005
                        _log("Could not create temporary file: %s\n", strerror(errno));
 
1006
                        return EXIT_PRNERR_NORETRY_BAD_SETTINGS;
 
1007
                    }
 
1008
                    tmpfile = fdopen(fd, "r+");
 
1009
                    copy_file(tmpfile, stdin, buf, n);
 
1010
                    fclose(tmpfile);
 
1011
                    
 
1012
                    filename = tmpfilename;
 
1013
                }
 
1014
 
991
1015
                snprintf(pdf2ps_cmd, PATH_MAX,
 
1016
                         "pdftops -level2 -origpagesizes %s - 2>/dev/null || "
992
1017
                         "gs -q -sstdout=%%stderr -sDEVICE=pswrite -sOutputFile=- "
993
 
                            "-dBATCH -dNOPAUSE -dPARANOIDSAFER %s",
994
 
                         file == stdin ? "-" : filename);
 
1018
                            "-dBATCH -dNOPAUSE -dPARANOIDSAFER %s 2>/dev/null",
 
1019
                         filename, filename);
995
1020
 
996
1021
                renderer_pid = start_system_process("pdf-to-ps", pdf2ps_cmd, &in, &out);
997
1022
 
998
 
                if (file == stdin)
999
 
                {
1000
 
                    fwrite(buf, 1, n, in);
1001
 
                    while ((n = fread(buf, 1, sizeof(buf), file)))
1002
 
                        fwrite(buf, 1, n, in);
1003
 
                    fclose(in);
1004
 
                }
1005
 
 
1006
1023
                if (dup2(fileno(out), fileno(stdin)) < 0)
1007
1024
                    rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS,
1008
1025
                            "Couldn't dup stdout of pdf-to-ps\n");
1192
1209
        spooler = SPOOLER_LPRNG;
1193
1210
        if ((str = strstr(getenv("PRINTCAP_ENTRY"), "ppd=")))
1194
1211
            str += 4;
1195
 
        else if ((str = strstr(getenv("PRINTCAP_ENTRY"), "ppdfile=")));
1196
 
        str += 8;
 
1212
        else if ((str = strstr(getenv("PRINTCAP_ENTRY"), "ppdfile=")))
 
1213
            str += 8;
1197
1214
        if (str) {
1198
1215
            while (isspace(*str)) str++;
1199
1216
            p = job->ppdfile;
1200
 
            while (*str != '\0' && !isspace(*str) && *str != '\n') {
 
1217
            while (*str != '\0' && !isspace(*str) && *str != '\n' &&
 
1218
                   *str != ':') {
1201
1219
                if (isprint(*str) && strchr(shellescapes, *str) == NULL)
1202
1220
                    *p++ = *str;
1203
1221
                str++;
1306
1324
            init_cups(arglist, filelist, job);
1307
1325
            break;
1308
1326
 
 
1327
        case SPOOLER_LPRNG:
 
1328
            if (job->ppdfile[0] != '\0') break;
1309
1329
        case SPOOLER_LPD:
1310
 
        case SPOOLER_LPRNG:
1311
1330
        case SPOOLER_GNULPR:
1312
1331
            /* Get PPD file name as the last command line argument */
1313
1332
            if (arglist->last)