socket backend ignores number of copies when receiving data through stdin #808

Closed
michaelrsweet opened this Issue Jul 8, 2004 · 4 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Jul 8, 2004

Version: 1.1.19
CUPS.org User: juergen.braun.materna

We're printing compressed PCL data from one CUPS server to a second one over a WAN connection. To save bandwith the data is compressed with gzip (lpr -P printer -# 2 -o raw file.gz).
The socket backend on the second CUPS Server that sends the data to the printer ignores the copy counter and only sends the data to the printer one time.
I assume this is because the socket backend becomes the data through a pipe from gziptoany and so sets copies = 1 (socket.c:145)

Collaborator

michaelrsweet commented Jul 17, 2004

CUPS.org User: mike

I don't know if this is something we can fix in CUPS 1.1. We will investigate some possible solutions and get back to you...

Collaborator

michaelrsweet commented Aug 19, 2004

CUPS.org User: mike

Please try the attached patch and let me know if you still have problems.

Collaborator

michaelrsweet commented Aug 19, 2004

CUPS.org User: mike

Fixed in CVS - the anonymous CVS repository will be updated at midnight EST.

Collaborator

michaelrsweet commented Aug 28, 2004

"str808.patch":

Index: gziptoany.c

RCS file: /development/cvs/cups/filter/gziptoany.c,v
retrieving revision 1.2
diff -u -r1.2 gziptoany.c
--- gziptoany.c 25 Feb 2004 20:14:51 -0000 1.2
+++ gziptoany.c 19 Aug 2004 14:15:07 -0000
@@ -15,9 +15,9 @@

  •   Attn: CUPS Licensing Information
    
  •   Easy Software Products
    
  •   44141 Airport View Drive, Suite 204
    
    • * Hollywood, Maryland 20636-3111 USA
    • * Hollywood, Maryland 20636 USA
      *
    • * Voice: (301) 373-9603
    • * Voice: (301) 373-9600
  •   EMail: cups-info@cups.org
    
  •     WWW: http://www.cups.org
    

    @@ -33,6 +33,7 @@
    */

    #include <cups/string.h>
    +#include <stdlib.h>
    #include <errno.h>

    #ifdef HAVE_LIBZ
    @@ -52,6 +53,8 @@
    gzFile fp; /* GZIP'd file /
    char buffer[8192]; /
    Data buffer /
    int bytes; /
    Number of bytes read/written */

    • int copies; /* Number of copies */
    • const char content_type; / Content type for file... */

    /*
    @@ -65,6 +68,17 @@
    }

    /*

    • * Get the copy count; if the MIME type is "application/vnd.cups-raw" then
    • * make copies since the file is going straight to a backend...
    • */
    • if ((content_type = getenv("CONTENT_TYPE")) != NULL &&
    •  !strcasecmp(content_type, "application/vnd.cups-raw"))
      
    • copies = atoi(argv[4]);
    • else
    • copies = 1;
    • /*
    • Open the gzip file...
      */

@@ -80,15 +94,22 @@

setbuf(stdout, NULL);

  • while ((bytes = gzread(fp, buffer, sizeof(buffer))) > 0)
  • if (fwrite(buffer, 1, bytes, stdout) < bytes)
  • {
  •  fprintf(stderr, "ERROR: Unable to write uncompressed document data: %s\n",
    
  •          strerror(ferror(stdout)));
    
  •  gzclose(fp);
    
  • while (copies > 0)
  • {
  • gzrewind(fp);
  • while ((bytes = gzread(fp, buffer, sizeof(buffer))) > 0)
  •  if (fwrite(buffer, 1, bytes, stdout) < bytes)
    
  •  {
    
  • fprintf(stderr, "ERROR: Unable to write uncompressed document data: %s\n",
  •       strerror(ferror(stdout)));
    
  • gzclose(fp);
  •  return (1);
    
  • }
  • return (1);
  •  }
    
  • copies --;
  • }

/*

  • Close the file and return...

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment