/*
- * "$Id: gziptoany.c 6649 2007-07-11 21:46:42Z mike $"
+ * GZIP/raw pre-filter for CUPS.
*
- * GZIP/raw pre-filter for CUPS.
+ * Copyright 2007-2015 by Apple Inc.
+ * Copyright 1993-2007 by Easy Software Products.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1993-2007 by Easy Software Products.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * missing or damaged, see the license at "http://www.cups.org/".
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Copy (and uncompress) files to stdout.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
{
cups_file_t *fp; /* File */
char buffer[8192]; /* Data buffer */
- int bytes; /* Number of bytes read/written */
+ ssize_t bytes; /* Number of bytes read/written */
int copies; /* Number of copies */
* Check command-line...
*/
- if (argc != 7)
+ if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options file"),
+ _("Usage: %s job-id user title copies options [file]"),
argv[0]);
return (1);
}
* Open the file...
*/
- if ((fp = cupsFileOpen(argv[6], "r")) == NULL)
+ if (argc == 6)
+ {
+ copies = 1;
+ fp = cupsFileStdin();
+ }
+ else if ((fp = cupsFileOpen(argv[6], "r")) == NULL)
{
+ fprintf(stderr, "DEBUG: Unable to open \"%s\".\n", argv[6]);
_cupsLangPrintError("ERROR", _("Unable to open print file"));
return (1);
}
cupsFileRewind(fp);
while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0)
- if (write(1, buffer, bytes) < bytes)
+ if (write(1, buffer, (size_t)bytes) < bytes)
{
_cupsLangPrintFilter(stderr, "ERROR",
_("Unable to write uncompressed print data: %s"),
strerror(errno));
- cupsFileClose(fp);
+ if (argc == 7)
+ cupsFileClose(fp);
return (1);
}
* Close the file and return...
*/
- cupsFileClose(fp);
+ if (argc == 7)
+ cupsFileClose(fp);
return (0);
}
-
-
-/*
- * End of "$Id: gziptoany.c 6649 2007-07-11 21:46:42Z mike $".
- */