From: mike Date: Sun, 30 Mar 2003 21:49:23 +0000 (+0000) Subject: Mirror 1.1.x changes. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d59a189ce03a0065e70caf10601f88b6ec331b03;p=thirdparty%2Fcups.git Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3540 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index 5677d035b9..bac0614fff 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -3,6 +3,8 @@ CHANGES-1.1.txt CHANGES IN CUPS V1.1.19 + - The scheduler now supports print files that have been + compressed using gzip. - The scheduler used the stdio functions to read any job ticket information in a PostScript print job. Since some platforms limit the number of stdio files to 256, diff --git a/cups.list.in b/cups.list.in index c28525d4e2..1f1ff743fe 100644 --- a/cups.list.in +++ b/cups.list.in @@ -1,5 +1,5 @@ # -# "$Id: cups.list.in,v 1.13.2.13 2003/03/19 15:37:44 mike Exp $" +# "$Id: cups.list.in,v 1.13.2.14 2003/03/30 21:49:14 mike Exp $" # # ESP Package Manager (EPM) file list for the Common UNIX Printing # System (CUPS). @@ -132,15 +132,16 @@ d 0555 root sys $SERVERBIN/daemon - f 0555 root sys $SERVERBIN/daemon/cups-lpd scheduler/cups-lpd f 0555 root sys $SERVERBIN/daemon/cups-polld scheduler/cups-polld d 0555 root sys $SERVERBIN/filter - -f 0555 root sys $SERVERBIN/filter/pdftops pdftops/pdftops +f 0555 root sys $SERVERBIN/filter/gziptoany filter/gziptoany +f 0555 root sys $SERVERBIN/filter/hpgltops filter/hpgltops f 0555 root sys $SERVERBIN/filter/imagetops filter/imagetops +f 0555 root sys $SERVERBIN/filter/imagetoraster filter/imagetoraster +f 0555 root sys $SERVERBIN/filter/pdftops pdftops/pdftops f 0555 root sys $SERVERBIN/filter/pstops filter/pstops -f 0555 root sys $SERVERBIN/filter/texttops filter/texttops f 0555 root sys $SERVERBIN/filter/rastertodymo filter/rastertodymo f 0555 root sys $SERVERBIN/filter/rastertoepson filter/rastertoepson f 0555 root sys $SERVERBIN/filter/rastertohp filter/rastertohp -f 0555 root sys $SERVERBIN/filter/hpgltops filter/hpgltops -f 0555 root sys $SERVERBIN/filter/imagetoraster filter/imagetoraster +f 0555 root sys $SERVERBIN/filter/texttops filter/texttops # Admin commands l 0555 root sys $BINDIR/disable $SBINDIR/accept @@ -388,5 +389,5 @@ f 0444 root sys $AMANDIR/man$MAN8DIR/lpmove.$MAN8EXT man/lpmove.man i 0555 root sys cups cups.sh # -# End of "$Id: cups.list.in,v 1.13.2.13 2003/03/19 15:37:44 mike Exp $". +# End of "$Id: cups.list.in,v 1.13.2.14 2003/03/30 21:49:14 mike Exp $". # diff --git a/filter/Makefile b/filter/Makefile index a1a22057a4..dcce8c2c32 100644 --- a/filter/Makefile +++ b/filter/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.41.2.21 2003/01/07 18:26:50 mike Exp $" +# "$Id: Makefile,v 1.41.2.22 2003/03/30 21:49:14 mike Exp $" # # Filter makefile for the Common UNIX Printing System (CUPS). # @@ -26,9 +26,9 @@ include ../Makedefs -TARGETS = hpgltops texttops pstops imagetops imagetoraster \ - rastertodymo rastertoepson rastertohp rastertortl \ - testraster +FILTERS = gziptoany hpgltops texttops pstops imagetops imagetoraster \ + rastertodymo rastertoepson rastertohp rastertortl +TARGETS = $(FILTERS) testraster HPGLOBJS = hpgl-attr.o hpgl-config.o hpgl-main.o hpgl-prolog.o \ hpgl-char.o hpgl-input.o hpgl-polygon.o hpgl-vector.o @@ -73,7 +73,7 @@ depend: install: all installhdrs $(INSTALL_DIR) $(SERVERBIN)/filter - for file in $(TARGETS); do \ + for file in $(FILTERS); do \ $(INSTALL_BIN) $$file $(SERVERBIN)/filter; \ done $(INSTALL_DIR) $(LIBDIR) @@ -107,6 +107,15 @@ formtops: $(FORMOBJS) common.o ../cups/$(LIBCUPS) $(CC) $(LDFLAGS) -o $@ $(FORMOBJS) common.o $(LIBS) -lm +# +# gziptoany +# + +gziptoany: gziptoany.o + echo Linking $@... + $(CC) $(LDFLAGS) -o $@ gziptoany.o $(LIBZ) + + # # hpgltops # @@ -279,5 +288,5 @@ include Dependencies # -# End of "$Id: Makefile,v 1.41.2.21 2003/01/07 18:26:50 mike Exp $". +# End of "$Id: Makefile,v 1.41.2.22 2003/03/30 21:49:14 mike Exp $". # diff --git a/filter/gziptoany.c b/filter/gziptoany.c index 764722d031..9d16ffd97c 100644 --- a/filter/gziptoany.c +++ b/filter/gziptoany.c @@ -1,5 +1,5 @@ /* - * "$Id: gziptoany.c,v 1.1 2003/03/30 21:43:00 mike Exp $" + * "$Id: gziptoany.c,v 1.1.2.1 2003/03/30 21:49:14 mike Exp $" * * GZIP pre-filter for the Common UNIX Printing System (CUPS). * @@ -106,5 +106,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: gziptoany.c,v 1.1 2003/03/30 21:43:00 mike Exp $". + * End of "$Id: gziptoany.c,v 1.1.2.1 2003/03/30 21:49:14 mike Exp $". */ diff --git a/scheduler/banners.c b/scheduler/banners.c index d7a89bd174..ac7b9feb07 100644 --- a/scheduler/banners.c +++ b/scheduler/banners.c @@ -1,5 +1,5 @@ /* - * "$Id: banners.c,v 1.5.2.4 2003/01/07 18:27:15 mike Exp $" + * "$Id: banners.c,v 1.5.2.5 2003/03/30 21:49:15 mike Exp $" * * Banner routines for the Common UNIX Printing System (CUPS). * @@ -59,7 +59,7 @@ AddBanner(const char *name, /* I - Name of banner */ * See what the filetype is... */ - if ((filetype = mimeFileType(MimeDatabase, filename)) == NULL) + if ((filetype = mimeFileType(MimeDatabase, filename, NULL)) == NULL) { LogMessage(L_WARN, "AddBanner: Banner \"%s\" is of an unknown file type - skipping!", name); @@ -211,5 +211,5 @@ compare(const banner_t *b0, /* I - First banner */ /* - * End of "$Id: banners.c,v 1.5.2.4 2003/01/07 18:27:15 mike Exp $". + * End of "$Id: banners.c,v 1.5.2.5 2003/03/30 21:49:15 mike Exp $". */ diff --git a/scheduler/classes.c b/scheduler/classes.c index 3ce6683659..2570404231 100644 --- a/scheduler/classes.c +++ b/scheduler/classes.c @@ -1,5 +1,5 @@ /* - * "$Id: classes.c,v 1.34.2.13 2003/03/30 20:01:42 mike Exp $" + * "$Id: classes.c,v 1.34.2.14 2003/03/30 21:49:15 mike Exp $" * * Printer class routines for the Common UNIX Printing System (CUPS). * @@ -600,7 +600,7 @@ SaveAllClasses(void) */ fchown(cupsFileNumber(fp), User, Group); - fchmod(cupsFileNumber(fp), 0600); + fchmod(cupsFileNumber(fp), ConfigFilePerm); /* * Write a small header to the file... @@ -675,5 +675,5 @@ SaveAllClasses(void) /* - * End of "$Id: classes.c,v 1.34.2.13 2003/03/30 20:01:42 mike Exp $". + * End of "$Id: classes.c,v 1.34.2.14 2003/03/30 21:49:15 mike Exp $". */ diff --git a/scheduler/client.c b/scheduler/client.c index 0c1a9960b9..9c64e2588b 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1,5 +1,5 @@ /* - * "$Id: client.c,v 1.91.2.55 2003/03/30 20:01:42 mike Exp $" + * "$Id: client.c,v 1.91.2.56 2003/03/30 21:49:15 mike Exp $" * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -1307,7 +1307,7 @@ ReadClient(client_t *con) /* I - Client to read from */ break; } - type = mimeFileType(MimeDatabase, filename); + type = mimeFileType(MimeDatabase, filename, NULL); if (IsCGI(con, filename, &filestats, type)) { @@ -1456,7 +1456,7 @@ ReadClient(client_t *con) /* I - Client to read from */ break; } - type = mimeFileType(MimeDatabase, filename); + type = mimeFileType(MimeDatabase, filename, NULL); if (!IsCGI(con, filename, &filestats, type)) { @@ -1642,7 +1642,7 @@ ReadClient(client_t *con) /* I - Client to read from */ * Serve a file... */ - type = mimeFileType(MimeDatabase, filename); + type = mimeFileType(MimeDatabase, filename, NULL); if (type == NULL) strcpy(line, "text/plain"); else @@ -2777,7 +2777,7 @@ install_conf_file(client_t *con) /* I - Connection */ { confinfo.st_uid = User; confinfo.st_gid = Group; - confinfo.st_mode = 0640; + confinfo.st_mode = ConfigFilePerm; } /* @@ -3330,5 +3330,5 @@ CDSAWriteFunc(SSLConnectionRef connection, /* I - SSL/TLS connection */ /* - * End of "$Id: client.c,v 1.91.2.55 2003/03/30 20:01:42 mike Exp $". + * End of "$Id: client.c,v 1.91.2.56 2003/03/30 21:49:15 mike Exp $". */ diff --git a/scheduler/file.h b/scheduler/file.h index 280488ec64..ce07276ec4 100644 --- a/scheduler/file.h +++ b/scheduler/file.h @@ -1,5 +1,5 @@ /* - * "$Id: file.h,v 1.1.2.2 2003/03/30 20:01:44 mike Exp $" + * "$Id: file.h,v 1.1.2.3 2003/03/30 21:49:17 mike Exp $" * * File definitions for the Common UNIX Printing System (CUPS). * @@ -48,6 +48,14 @@ extern "C" { # endif /* _cplusplus */ +/* + * CUPS file definitions... + */ + +# define CUPS_FILE_NONE 0 /* No compression */ +# define CUPS_FILE_GZIP 1 /* GZIP compression */ + + /* * CUPS file structure... */ @@ -75,7 +83,7 @@ typedef struct */ extern int cupsFileClose(cups_file_t *fp); -#define cupsFileCompressed(fp) (fp)->compressed +#define cupsFileCompression(fp) (fp)->compressed extern int cupsFileFlush(cups_file_t *fp); extern int cupsFileGetChar(cups_file_t *fp); extern char *cupsFileGets(cups_file_t *fp, char *buf, int buflen); @@ -96,5 +104,5 @@ extern int cupsFileWrite(cups_file_t *fp, const char *buf, int bytes); #endif /* !_CUPS_FILE_H_ */ /* - * End of "$Id: file.h,v 1.1.2.2 2003/03/30 20:01:44 mike Exp $". + * End of "$Id: file.h,v 1.1.2.3 2003/03/30 21:49:17 mike Exp $". */ diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 736af043ef..e479fbe12b 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c,v 1.127.2.55 2003/03/30 20:01:44 mike Exp $" + * "$Id: ipp.c,v 1.127.2.56 2003/03/30 21:49:17 mike Exp $" * * IPP routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -88,7 +88,8 @@ static void accept_jobs(client_t *con, ipp_attribute_t *uri); static void add_class(client_t *con, ipp_attribute_t *uri); -static int add_file(client_t *con, job_t *job, mime_type_t *filetype); +static int add_file(client_t *con, job_t *job, mime_type_t *filetype, + int compression); static void add_job_state_reasons(client_t *con, job_t *job); static void add_printer(client_t *con, ipp_attribute_t *uri); static void add_printer_state_reasons(client_t *con, printer_t *p); @@ -847,26 +848,36 @@ add_class(client_t *con, /* I - Client connection */ static int /* O - 0 on success, -1 on error */ add_file(client_t *con, /* I - Connection to client */ job_t *job, /* I - Job to add to */ - mime_type_t *filetype) /* I - Type of file */ + mime_type_t *filetype, /* I - Type of file */ + int compression) /* I - Compression */ { mime_type_t **filetypes; /* New filetypes array... */ + int *compressions; /* New compressions array... */ - LogMessage(L_DEBUG2, "add_file(%d, %d, %s/%s)\n", con->http.fd, - job->id, filetype->super, filetype->type); + LogMessage(L_DEBUG2, "add_file(con=%p[%d], job=%d, filetype=%s/%s, compression=%d)\n", + con, con->http.fd, job->id, filetype->super, filetype->type, + compression); /* * Add the file to the job... */ if (job->num_files == 0) - filetypes = (mime_type_t **)malloc(sizeof(mime_type_t *)); + { + compressions = (int *)malloc(sizeof(int)); + filetypes = (mime_type_t **)malloc(sizeof(mime_type_t *)); + } else - filetypes = (mime_type_t **)realloc(job->filetypes, - (job->num_files + 1) * - sizeof(mime_type_t)); + { + compressions = (int *)realloc(job->compressions, + (job->num_files + 1) * sizeof(int)); + filetypes = (mime_type_t **)realloc(job->filetypes, + (job->num_files + 1) * + sizeof(mime_type_t *)); + } - if (filetypes == NULL) + if (compressions == NULL || filetypes == NULL) { CancelJob(job->id, 1); LogMessage(L_ERROR, "add_file: unable to allocate memory for file types!"); @@ -874,8 +885,10 @@ add_file(client_t *con, /* I - Connection to client */ return (-1); } - job->filetypes = filetypes; - job->filetypes[job->num_files] = filetype; + job->compressions = compressions; + job->compressions[job->num_files] = compression; + job->filetypes = filetypes; + job->filetypes[job->num_files] = filetype; job->num_files ++; @@ -2613,7 +2626,7 @@ copy_banner(client_t *con, /* I - Client connection */ * Open the banner and job files... */ - if (add_file(con, job, banner->filetype)) + if (add_file(con, job, banner->filetype, 0)) return (0); snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id, @@ -4034,6 +4047,7 @@ print_job(client_t *con, /* I - Client connection */ int kbytes; /* Size of file */ int i; /* Looping var */ int lowerpagerange; /* Page range bound */ + int compression; /* Document compression */ LogMessage(L_DEBUG2, "print_job(%d, %s)\n", con->http.fd, @@ -4086,18 +4100,31 @@ print_job(client_t *con, /* I - Client connection */ /* * OK, see if the client is sending the document compressed - CUPS - * doesn't support compression yet... + * only supports "none" and "gzip". */ - if ((attr = ippFindAttribute(con->request, "compression", IPP_TAG_KEYWORD)) != NULL && - strcmp(attr->values[0].string.text, "none") == 0) + compression = CUPS_FILE_NONE; + + if ((attr = ippFindAttribute(con->request, "compression", IPP_TAG_KEYWORD)) != NULL) { - LogMessage(L_ERROR, "print_job: Unsupported compression attribute %s!", - attr->values[0].string.text); - send_ipp_error(con, IPP_ATTRIBUTES); - ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD, - "compression", NULL, attr->values[0].string.text); - return; + if (strcmp(attr->values[0].string.text, "none") +#ifdef HAVE_LIBZ + && strcmp(attr->values[0].string.text, "gzip") +#endif /* HAVE_LIBZ */ + ) + { + LogMessage(L_ERROR, "print_job: Unsupported compression \"%s\"!", + attr->values[0].string.text); + send_ipp_error(con, IPP_ATTRIBUTES); + ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD, + "compression", NULL, attr->values[0].string.text); + return; + } + +#ifdef HAVE_LIBZ + if (!strcmp(attr->values[0].string.text, "gzip")) + compression = CUPS_FILE_GZIP; +#endif /* HAVE_LIBZ */ } /* @@ -4148,7 +4175,7 @@ print_job(client_t *con, /* I - Client connection */ LogMessage(L_DEBUG, "print_job: auto-typing file..."); - filetype = mimeFileType(MimeDatabase, con->filename); + filetype = mimeFileType(MimeDatabase, con->filename, &compression); if (filetype != NULL) { @@ -4531,7 +4558,7 @@ print_job(client_t *con, /* I - Client connection */ * Add the job file... */ - if (add_file(con, job, filetype)) + if (add_file(con, job, filetype, compression)) return; snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id, @@ -4594,97 +4621,6 @@ print_job(client_t *con, /* I - Client connection */ } -/* - * PostScript line buffer structure for lines up to 255 chars... - */ - -typedef struct -{ - char buffer[256], /* Line buffer (max 255 chars) */ - *bufptr; /* Pointer to next line */ - int bufused; /* Number of bytes used */ -} cups_psline_t; - - -/* - * 'read_ps_line()' - Read a line from a PS file... - */ - -static char * /* O - Line or NULL on EOF/error */ -read_ps_line(int fd, /* I - File descriptor to read from */ - cups_psline_t *line) /* IO - Line data */ -{ - int bytes; /* Bytes read */ - char *cr, *lf; /* Pointers into buffer */ - - - if (line->bufused > 0 && line->bufptr > line->buffer) - { - /* - * Remove the last line that was read from the buffer... - */ - - bytes = line->bufptr - line->buffer; - - strcpy(line->buffer, line->bufptr); - - line->bufused -= bytes; - - if (line->bufused < 0) - line->bufused = 0; - } - - /* - * Read more data into the buffer... - */ - - bytes = sizeof(line->buffer) - line->bufused - 1; - if ((bytes = read(fd, line->buffer + line->bufused, bytes)) < 0) - return (NULL); - - /* - * Nul-terminate the string buffer... - */ - - line->bufused += bytes; - line->buffer[line->bufused] = '\0'; - - /* - * Check for CR and/or LF. - */ - - cr = strchr(line->buffer, '\r'); - lf = strchr(line->buffer, '\n'); - - if (!cr && !lf) - return (NULL); - - if (cr && cr < lf) - { - /* - * CR and possibly LF terminate this line... - */ - - *cr++ = '\0'; - if (*cr == '\n') - *cr++ = '\0'; - - line->bufptr = cr; - } - else - { - /* - * LF terminates this line... - */ - - *lf++ = '\0'; - line->bufptr = lf; - } - - return (line->buffer); -} - - /* * 'read_ps_job_ticket()' - Reads a job ticket embedded in a PS file. * @@ -4721,8 +4657,8 @@ read_ps_line(int fd, /* I - File descriptor to read from */ static void read_ps_job_ticket(client_t *con) /* I - Client connection */ { - int fd; /* File to read from */ - cups_psline_t line; /* Line data */ + cups_file_t *fp; /* File to read from */ + char line[256]; /* Line data */ int num_options; /* Number of options */ cups_option_t *options; /* Options */ ipp_t *ticket; /* New attributes */ @@ -4735,34 +4671,32 @@ read_ps_job_ticket(client_t *con) /* I - Client connection */ * First open the print file... */ - if ((fd = open(con->filename, O_RDONLY)) < 0) + if ((fp = cupsFileOpen(con->filename, "rb")) == NULL) { LogMessage(L_ERROR, "read_ps_job_ticket: Unable to open PostScript print file - %s", strerror(errno)); return; } - memset(&line, 0, sizeof(line)); - /* * Skip the first line... */ - if (read_ps_line(fd, &line) == NULL) + if (cupsFileGets(fp, line, sizeof(line)) == NULL) { LogMessage(L_ERROR, "read_ps_job_ticket: Unable to read from PostScript print file - %s", strerror(errno)); - close(fd); + cupsFileClose(fp); return; } - if (strncmp(line.buffer, "%!PS-Adobe-", 11) != 0) + if (strncmp(line, "%!PS-Adobe-", 11) != 0) { /* * Not a DSC-compliant file, so no job ticket info will be available... */ - close(fd); + cupsFileClose(fp); return; } @@ -4773,27 +4707,27 @@ read_ps_job_ticket(client_t *con) /* I - Client connection */ num_options = 0; options = NULL; - while (read_ps_line(fd, &line) != NULL) + while (cupsFileGets(fp, line, sizeof(line)) != NULL) { /* * Stop at the first non-ticket line... */ - if (strncmp(line.buffer, "%cupsJobTicket:", 15) != 0) + if (strncmp(line, "%cupsJobTicket:", 15) != 0) break; /* * Add the options to the option array... */ - num_options = cupsParseOptions(line.buffer + 15, num_options, &options); + num_options = cupsParseOptions(line + 15, num_options, &options); } /* * Done with the file; see if we have any options... */ - close(fd); + cupsFileClose(fp); if (num_options == 0) return; @@ -5296,6 +5230,7 @@ send_document(client_t *con, /* I - Client connection */ printer_t *printer; /* Current printer */ struct stat fileinfo; /* File information */ int kbytes; /* Size of file */ + int compression; /* Type of compression */ LogMessage(L_DEBUG2, "send_document(%d, %s)\n", con->http.fd, @@ -5386,18 +5321,31 @@ send_document(client_t *con, /* I - Client connection */ /* * OK, see if the client is sending the document compressed - CUPS - * doesn't support compression yet... + * only supports "none" and "gzip". */ - if ((attr = ippFindAttribute(con->request, "compression", IPP_TAG_KEYWORD)) != NULL && - strcmp(attr->values[0].string.text, "none") == 0) + compression = CUPS_FILE_NONE; + + if ((attr = ippFindAttribute(con->request, "compression", IPP_TAG_KEYWORD)) != NULL) { - LogMessage(L_ERROR, "send_document: Unsupported compression attribute %s!", - attr->values[0].string.text); - send_ipp_error(con, IPP_ATTRIBUTES); - ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD, - "compression", NULL, attr->values[0].string.text); - return; + if (strcmp(attr->values[0].string.text, "none") +#ifdef HAVE_LIBZ + && strcmp(attr->values[0].string.text, "gzip") +#endif /* HAVE_LIBZ */ + ) + { + LogMessage(L_ERROR, "print_job: Unsupported compression \"%s\"!", + attr->values[0].string.text); + send_ipp_error(con, IPP_ATTRIBUTES); + ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD, + "compression", NULL, attr->values[0].string.text); + return; + } + +#ifdef HAVE_LIBZ + if (!strcmp(attr->values[0].string.text, "gzip")) + compression = CUPS_FILE_GZIP; +#endif /* HAVE_LIBZ */ } /* @@ -5448,7 +5396,7 @@ send_document(client_t *con, /* I - Client connection */ LogMessage(L_DEBUG, "send_document: auto-typing file..."); - filetype = mimeFileType(MimeDatabase, con->filename); + filetype = mimeFileType(MimeDatabase, con->filename, &compression); if (filetype != NULL) { @@ -5495,7 +5443,7 @@ send_document(client_t *con, /* I - Client connection */ * Add the file to the job... */ - if (add_file(con, job, filetype)) + if (add_file(con, job, filetype, compression)) return; if (job->dtype & CUPS_PRINTER_CLASS) @@ -6336,5 +6284,5 @@ validate_user(client_t *con, /* I - Client connection */ /* - * End of "$Id: ipp.c,v 1.127.2.55 2003/03/30 20:01:44 mike Exp $". + * End of "$Id: ipp.c,v 1.127.2.56 2003/03/30 21:49:17 mike Exp $". */ diff --git a/scheduler/job.c b/scheduler/job.c index 712a24e9a5..1e3bd89900 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,5 +1,5 @@ /* - * "$Id: job.c,v 1.124.2.58 2003/03/24 21:30:08 mike Exp $" + * "$Id: job.c,v 1.124.2.59 2003/03/30 21:49:20 mike Exp $" * * Job management routines for the Common UNIX Printing System (CUPS). * @@ -63,6 +63,19 @@ #include +/* + * Local globals... + */ + +static mime_filter_t gziptoany_filter = + { + NULL, /* Source type */ + NULL, /* Destination type */ + 0, /* Cost */ + "gziptoany" /* Filter program to run */ + }; + + /* * Local functions... */ @@ -200,7 +213,11 @@ CancelJob(int id, /* I - Job to cancel */ if (current->attrs != NULL) ippDelete(current->attrs); - free(current->filetypes); + if (current->num_files > 0) + { + free(current->compressions); + free(current->filetypes); + } ClearString(¤t->username); ClearString(¤t->dest); @@ -385,7 +402,13 @@ FreeAllJobs(void) next = job->next; ippDelete(job->attrs); - free(job->filetypes); + + if (job->num_files > 0) + { + free(job->compressions); + free(job->filetypes); + } + free(job); } @@ -510,6 +533,7 @@ LoadAllJobs(void) printer_t *p; /* Printer or class */ const char *dest; /* Destination */ mime_type_t **filetypes; /* New filetypes array */ + int *compressions; /* New compressions array */ /* @@ -733,22 +757,31 @@ LoadAllJobs(void) if (fileid > job->num_files) { if (job->num_files == 0) - filetypes = (mime_type_t **)calloc(sizeof(mime_type_t *), fileid); + { + compressions = (int *)calloc(fileid, sizeof(int)); + filetypes = (mime_type_t **)calloc(fileid, sizeof(mime_type_t *)); + } else - filetypes = (mime_type_t **)realloc(job->filetypes, - sizeof(mime_type_t *) * fileid); + { + compressions = (int *)realloc(job->compressions, + sizeof(int) * fileid); + filetypes = (mime_type_t **)realloc(job->filetypes, + sizeof(mime_type_t *) * fileid); + } - if (filetypes == NULL) + if (compressions == NULL || filetypes == NULL) { LogMessage(L_ERROR, "LoadAllJobs: Ran out of memory for job file types!"); continue; } - job->filetypes = filetypes; - job->num_files = fileid; + job->compressions = compressions; + job->filetypes = filetypes; + job->num_files = fileid; } - job->filetypes[fileid - 1] = mimeFileType(MimeDatabase, filename); + job->filetypes[fileid - 1] = mimeFileType(MimeDatabase, filename, + job->compressions + fileid - 1); if (job->filetypes[fileid - 1] == NULL) job->filetypes[fileid - 1] = mimeType(MimeDatabase, "application", @@ -1284,6 +1317,44 @@ StartJob(int id, /* I - Job ID */ FilterLevel += current->cost; + /* + * Add decompression filters, if any... + */ + + if (current->compressions[current->current_file]) + { + /* + * Add gziptoany filter to the front of the list... + */ + + mime_filter_t *temp_filters; + + if (num_filters == 0) + temp_filters = malloc(sizeof(mime_filter_t)); + else + temp_filters = realloc(filters, + sizeof(mime_filter_t) * (num_filters + 1)); + + if (temp_filters == NULL) + { + LogMessage(L_ERROR, "Unable to add decompression filter - %s", + strerror(errno)); + + free(filters); + + current->current_file ++; + + if (current->current_file == current->num_files) + CancelJob(current->id, 0); + + return; + } + + filters = temp_filters; + filters[num_filters] = gziptoany_filter; + num_filters ++; + } + /* * Update the printer and job state to "processing"... */ @@ -2633,5 +2704,5 @@ start_process(const char *command, /* I - Full path to command */ /* - * End of "$Id: job.c,v 1.124.2.58 2003/03/24 21:30:08 mike Exp $". + * End of "$Id: job.c,v 1.124.2.59 2003/03/30 21:49:20 mike Exp $". */ diff --git a/scheduler/job.h b/scheduler/job.h index b5485ac33a..1057ae5277 100644 --- a/scheduler/job.h +++ b/scheduler/job.h @@ -1,5 +1,5 @@ /* - * "$Id: job.h,v 1.25.2.9 2003/03/12 21:27:38 mike Exp $" + * "$Id: job.h,v 1.25.2.10 2003/03/30 21:49:21 mike Exp $" * * Print job definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -48,6 +48,7 @@ typedef struct job_str int num_files; /* Number of files in job */ int current_file; /* Current file in job */ mime_type_t **filetypes; /* File types */ + int *compressions; /* Compression status of each file */ ipp_t *attrs; /* Job attributes */ int status_pipe; /* Status pipe for this job */ int print_pipes[2], /* Print data pipes */ @@ -108,5 +109,5 @@ extern void UpdateJob(job_t *job); /* - * End of "$Id: job.h,v 1.25.2.9 2003/03/12 21:27:38 mike Exp $". + * End of "$Id: job.h,v 1.25.2.10 2003/03/30 21:49:21 mike Exp $". */ diff --git a/scheduler/mime.h b/scheduler/mime.h index fbcece38fb..d8ba3ffde2 100644 --- a/scheduler/mime.h +++ b/scheduler/mime.h @@ -1,5 +1,5 @@ /* - * "$Id: mime.h,v 1.3.2.6 2003/03/28 22:29:49 mike Exp $" + * "$Id: mime.h,v 1.3.2.7 2003/03/30 21:49:22 mike Exp $" * * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS). * @@ -127,7 +127,8 @@ extern mime_t *mimeNew(void); extern mime_type_t *mimeAddType(mime_t *mime, const char *super, const char *type); extern int mimeAddTypeRule(mime_type_t *mt, const char *rule); -extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname); +extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname, + int *compression); extern mime_type_t *mimeType(mime_t *mime, const char *super, const char *type); extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst, @@ -141,5 +142,5 @@ extern mime_filter_t *mimeFilter(mime_t *mime, mime_type_t *src, mime_type_t *ds #endif /* !_CUPS_MIME_H_ */ /* - * End of "$Id: mime.h,v 1.3.2.6 2003/03/28 22:29:49 mike Exp $". + * End of "$Id: mime.h,v 1.3.2.7 2003/03/30 21:49:22 mike Exp $". */ diff --git a/scheduler/printers.c b/scheduler/printers.c index 6175ac61f8..3266e8830e 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1,5 +1,5 @@ /* - * "$Id: printers.c,v 1.93.2.44 2003/03/30 20:01:48 mike Exp $" + * "$Id: printers.c,v 1.93.2.45 2003/03/30 21:49:22 mike Exp $" * * Printer routines for the Common UNIX Printing System (CUPS). * @@ -843,7 +843,7 @@ SaveAllPrinters(void) */ fchown(cupsFileNumber(fp), User, Group); - fchmod(cupsFileNumber(fp), 0600); + fchmod(cupsFileNumber(fp), ConfigFilePerm); /* * Write a small header to the file... @@ -1036,6 +1036,15 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ "koi8-r", "koi8-u", }; + const char *compressions[] = + { +#ifdef HAVE_LIBZ + "none", + "gzip" +#else + "none" +#endif /* HAVE_LIBZ */ + }; int num_finishings; ipp_finish_t finishings[5]; const char *multiple_document_handling[] = @@ -1087,8 +1096,10 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ ippAddStrings(CommonData, IPP_TAG_PRINTER, (ipp_tag_t)(IPP_TAG_MIMETYPE | IPP_TAG_COPY), "document-format-supported", NumMimeTypes, NULL, MimeTypes); - ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, - "compression-supported", NULL, "none"); + ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, + "compression-supported", + sizeof(compressions) / sizeof(compressions[0]), + NULL, compressions); ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "job-priority-supported", 100); ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER, @@ -2359,5 +2370,5 @@ write_irix_state(printer_t *p) /* I - Printer to update */ /* - * End of "$Id: printers.c,v 1.93.2.44 2003/03/30 20:01:48 mike Exp $". + * End of "$Id: printers.c,v 1.93.2.45 2003/03/30 21:49:22 mike Exp $". */ diff --git a/scheduler/testmime.c b/scheduler/testmime.c index 6e0c9e2dab..ef863f1830 100644 --- a/scheduler/testmime.c +++ b/scheduler/testmime.c @@ -1,5 +1,5 @@ /* - * "$Id: testmime.c,v 1.4.2.3 2003/01/07 18:27:28 mike Exp $" + * "$Id: testmime.c,v 1.4.2.4 2003/03/30 21:49:23 mike Exp $" * * MIME test program for the Common UNIX Printing System (CUPS). * @@ -54,6 +54,7 @@ main(int argc, /* I - Number of command-line args */ int i; /* Looping var */ char super[MIME_MAX_SUPER], /* Super-type name */ type[MIME_MAX_TYPE]; /* Type name */ + int compression; /* Compression of file */ mime_t *mime; /* MIME database */ mime_type_t *src, /* Source type */ *dst, /* Destination type */ @@ -79,10 +80,11 @@ main(int argc, /* I - Number of command-line args */ if (!mime) mime = mimeLoad("../conf", "../filter"); - src = mimeFileType(mime, argv[i]); + src = mimeFileType(mime, argv[i], &compression); if (src != NULL) - printf("%s: %s/%s\n", argv[i], src->super, src->type); + printf("%s: %s/%s%s\n", argv[i], src->super, src->type, + compression ? " (gzipped)" : ""); else { printf("%s: unknown\n", argv[i]); @@ -232,5 +234,5 @@ print_rules(mime_magic_t *rules) /* I - Rules to print */ /* - * End of "$Id: testmime.c,v 1.4.2.3 2003/01/07 18:27:28 mike Exp $". + * End of "$Id: testmime.c,v 1.4.2.4 2003/03/30 21:49:23 mike Exp $". */ diff --git a/scheduler/type.c b/scheduler/type.c index 1f90aa7c66..b6fe6eafcc 100644 --- a/scheduler/type.c +++ b/scheduler/type.c @@ -1,5 +1,5 @@ /* - * "$Id: type.c,v 1.11.2.9 2003/03/28 22:29:49 mike Exp $" + * "$Id: type.c,v 1.11.2.10 2003/03/30 21:49:23 mike Exp $" * * MIME typing routines for the Common UNIX Printing System (CUPS). * @@ -536,7 +536,8 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ mime_type_t * /* O - Type of file */ mimeFileType(mime_t *mime, /* I - MIME database */ - const char *pathname) /* I - Name of file to check */ + const char *pathname, /* I - Name of file to check */ + int *compression) /* O - Is the file compressed? */ { int i; /* Looping var */ cups_file_t *fp; /* File pointer */ @@ -579,6 +580,9 @@ mimeFileType(mime_t *mime, /* I - MIME database */ * Finally, close the file and return a match (if any)... */ + if (compression) + *compression = cupsFileCompression(fp); + cupsFileClose(fp); if (i > 0) @@ -1092,5 +1096,5 @@ patmatch(const char *s, /* I - String to match against */ /* - * End of "$Id: type.c,v 1.11.2.9 2003/03/28 22:29:49 mike Exp $". + * End of "$Id: type.c,v 1.11.2.10 2003/03/30 21:49:23 mike Exp $". */