From 0268488e2f31bbec0c6b02ff7b7594b3191e6177 Mon Sep 17 00:00:00 2001 From: msweet Date: Mon, 17 Jan 2011 23:54:15 +0000 Subject: [PATCH] Merge changes from CUPS 1.5svn-r9491. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@2949 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.4.txt | 45 ++ CHANGES.txt | 8 +- README.txt | 4 +- backend/dnssd.c | 14 +- backend/easysw-firewire-design.txt | 71 --- backend/easysw-firewire-linux.txt | 35 -- backend/ipp.c | 627 +++++++++++++++---------- backend/lpd.c | 57 +-- backend/socket.c | 21 +- backend/usb-libusb.c | 6 +- cgi-bin/admin.c | 32 +- cgi-bin/classes.c | 20 +- cgi-bin/html.c | 34 +- cgi-bin/printers.c | 20 +- config-scripts/cups-common.m4 | 41 +- config-scripts/cups-ssl.m4 | 12 +- config.h.in | 3 +- cups/adminutil.c | 4 +- cups/conflicts.c | 14 +- cups/custom.c | 13 +- cups/http-private.h | 4 +- cups/http.c | 19 +- cups/http.h | 4 +- cups/mark.c | 201 +++++--- cups/ppd.c | 33 +- cups/ppd.h | 3 +- cups/pwg-ppd.c | 74 +-- cups/request.c | 17 +- cups/testi18n.c | 4 +- doc/Makefile | 6 +- doc/cups.css | 2 + doc/de/index.html.in | 2 +- doc/es/index.html.in | 2 +- doc/eu/index.html.in | 2 +- doc/help/api-array.html | 57 +-- doc/help/api-cgi.html | 93 ++-- doc/help/api-cups.html | 145 +++--- doc/help/api-driver.html | 69 +-- doc/help/api-filedir.html | 71 +-- doc/help/api-filter.html | 47 +- doc/help/api-httpipp.html | 265 +++++------ doc/help/api-mime.html | 47 +- doc/help/api-overview.html | 13 +- doc/help/api-ppd.html | 107 +++-- doc/help/api-ppdc.html | 47 +- doc/help/api-raster.html | 33 +- doc/help/postscript-driver.html | 11 +- doc/help/ppd-compiler.html | 27 +- doc/help/raster-driver.html | 9 +- doc/help/ref-cupsd-conf.html.in | 18 +- doc/help/spec-ppd.html | 93 ++-- doc/help/spec-raster.html | 250 +++++----- doc/id/index.html.in | 2 +- doc/images/raster-organization.png | Bin 0 -> 20974 bytes doc/images/raster-organization.svg | 189 ++++++++ doc/images/sample-image.png | Bin 0 -> 3541 bytes doc/index.html.in | 2 +- doc/it/index.html.in | 2 +- doc/ja/index.html.in | 2 +- doc/pl/index.html.in | 2 +- doc/ru/index.html.in | 2 +- man/cups-driverd.man.in | 31 +- man/cupsctl.man | 10 +- man/lpadmin.man | 10 +- ppdc/Makefile | 4 +- ppdc/sample.drv | 4 +- scheduler/Dependencies | 1 + scheduler/Makefile | 17 +- scheduler/client.c | 34 +- scheduler/conf.c | 14 +- scheduler/cups-exec.c | 90 ++++ scheduler/cups-polld.c | 2 +- scheduler/cupsd.h | 3 +- scheduler/dirsvc.c | 130 ++--- scheduler/env.c | 95 ++-- scheduler/ipp.c | 15 +- scheduler/job.c | 110 ++--- scheduler/printers.c | 147 ++++-- scheduler/process.c | 76 +-- scheduler/subscriptions.c | 4 +- systemv/cupsctl.c | 9 +- systemv/lpadmin.c | 4 +- templates/add-rss-subscription.tmpl | 2 +- templates/choose-uri.tmpl | 2 +- templates/class.tmpl | 1 + templates/de/add-rss-subscription.tmpl | 2 +- templates/de/choose-uri.tmpl | 2 +- templates/de/class.tmpl | 1 + templates/de/option-pickone.tmpl | 4 +- templates/de/trailer.tmpl | 2 +- templates/es/add-rss-subscription.tmpl | 2 +- templates/es/choose-uri.tmpl | 2 +- templates/es/class.tmpl | 1 + templates/es/option-pickone.tmpl | 4 +- templates/es/trailer.tmpl | 2 +- templates/eu/add-rss-subscription.tmpl | 2 +- templates/eu/choose-uri.tmpl | 2 +- templates/eu/class.tmpl | 1 + templates/eu/option-pickone.tmpl | 4 +- templates/eu/trailer.tmpl | 2 +- templates/id/add-rss-subscription.tmpl | 2 +- templates/id/choose-uri.tmpl | 2 +- templates/id/class.tmpl | 1 + templates/id/option-pickone.tmpl | 4 +- templates/id/trailer.tmpl | 2 +- templates/it/add-rss-subscription.tmpl | 2 +- templates/it/choose-uri.tmpl | 2 +- templates/it/class.tmpl | 1 + templates/it/option-pickone.tmpl | 4 +- templates/it/trailer.tmpl | 2 +- templates/ja/add-rss-subscription.tmpl | 2 +- templates/ja/choose-uri.tmpl | 2 +- templates/ja/class.tmpl | 1 + templates/ja/option-pickone.tmpl | 4 +- templates/ja/trailer.tmpl | 2 +- templates/jobs.tmpl | 2 +- templates/option-pickone.tmpl | 4 +- templates/pl/add-rss-subscription.tmpl | 2 +- templates/pl/choose-uri.tmpl | 2 +- templates/pl/class.tmpl | 1 + templates/pl/option-pickone.tmpl | 4 +- templates/pl/trailer.tmpl | 2 +- templates/ru/add-rss-subscription.tmpl | 2 +- templates/ru/choose-uri.tmpl | 2 +- templates/ru/class.tmpl | 1 + templates/ru/option-pickone.tmpl | 4 +- templates/ru/trailer.tmpl | 2 +- templates/trailer.tmpl | 2 +- test/ippserver.c | 55 ++- test/ipptool.c | 3 +- test/run-stp-tests.sh | 87 ++-- 131 files changed, 2385 insertions(+), 1728 deletions(-) create mode 100644 doc/images/raster-organization.png create mode 100644 doc/images/raster-organization.svg create mode 100644 doc/images/sample-image.png create mode 100644 scheduler/cups-exec.c diff --git a/CHANGES-1.4.txt b/CHANGES-1.4.txt index 97ccb0631..cb42517ca 100644 --- a/CHANGES-1.4.txt +++ b/CHANGES-1.4.txt @@ -3,6 +3,50 @@ CHANGES-1.4.txt CHANGES IN CUPS V1.4.7 + - Documentation changes (STR #3710, STR #3720, STR #3745, STR #3750, + STR #3757, STR #3758) + - Web interface fixes (STR #3412, STR #3345, STR #3455, STR #3707, + STR #3755, STR #3769) + - Configure script fixes (STR #3659, STR #3691) + - Compilation fixes (STR #3718, STR #3771, STR #3774) + - The scheduler did not retry fax jobs properly. + - The scheduler now recognizes an empty cupsCommands PPD keyword as + meaning that CUPS commands are not supported for a printer (STR #3773) + - Fixed a crash bug in the scheduler when the application/octet-stream + MIME type was not defined (STR #3690) + - Polled printers were advertised more slowly than necessary (STR #3574) + - cupsResolveConflicts() did not handle resolving multiple UIConstraints + issues (STR #3705) + - The SetEnv and PassEnv directives had no effect (STR #3664) + - The libusb-based USB backend printed slowly to the LaserJet 1300 and + other printers (STR #3405) + - "lp" and "lpr" failed to print with Kerberos enabled (STR #3768) + - The cupsctl program now displays an error if you try to directly set + the Port or Listen directives (STR #3749) + - PPD files with "*JobPatchFile: bla" no longer fail to load in relaxed + conformance mode (STR #3747) + - The scheduler generated a bad notify-text string for printer state + change notifications (STR #3739) + - The scheduler incorrectly updated printers.conf when it really needed + to update classes.conf or remote.cache (STR #3726) + - Hardwired remote printers with options did not work (STR #3717) + - Accessing the CUPS web interface using a CNAME-based hostname would + sometimes fail due to redirection to the actual hostname (STR #3701) + - Subscription events had a misspelled attribute (STR #3693) + - "make check" failed if LC_MESSAGES was set (STR #3765) + - Fixed the configure script to always look for the pkg-config script + (STR #3761) + - The scheduler now only looks up interface hostnames if HostNameLookups + are enabled (STR #3737) + - Fixed a compilation problem on DragonFly BSD (STR #3738) + - The default PageLogFormat value had the username and job ID swapped + from CUPS 1.3.x (STR #3727) + - The scheduler could crash if a browsed printer times out while a job + is printing (STR #3754) + - The scheduler incorrectly mapped custom page sizes to standard sizes + (STR #3764) + - cupsfilter and pstops did not map IPP attributes to PPD options due to + a change in cupsMarkOptions (STR #3756) - The scheduler did not always show the most recent status message from the print filters (STR #3731) - The PostScript filter did not apply the mirror and number-up options @@ -13,6 +57,7 @@ CHANGES IN CUPS V1.4.7 CHANGES IN CUPS V1.4.6 + - Fixed a "make check" issue on Solaris (STR #3729) - Regression: The pstops filter did not support landscape printing of PostScript files (STR #3722) - The scheduler killed retried (fax) jobs after restarting them diff --git a/CHANGES.txt b/CHANGES.txt index 66066105b..b3ba2f351 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,14 @@ -CHANGES.txt - 2010-12-01 +CHANGES.txt - 2011-01-10 ------------------------ CHANGES IN CUPS V1.5b1 + - The cupstestppd program now shows an error for files missing a + CloseGroup keyword (STR #3668) + - Name resolution errors no longer cause queues to stop (STR #3719, + STR #3753) + - Added a new cups-exec helper program that applies security profiles + to filters, port monitors, backends, CGI programs, and mini-daemons. - The web interface can now be disabled using the WebInterface directive in cupsd.conf (STR #2625) - The scheduler now provides privacy controls for jobs and subscriptions diff --git a/README.txt b/README.txt index d0a8957b5..8bfcbd4dc 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -README - CUPS v1.5svn - 2010-04-07 +README - CUPS v1.5svn - 2011-01-03 ---------------------------------- Looking for compile instructions? Read the file "INSTALL.txt" @@ -150,7 +150,7 @@ PRINTING FILES LEGAL STUFF - CUPS is Copyright 2007-2010 by Apple Inc. CUPS and the CUPS logo are + CUPS is Copyright 2007-2011 by Apple Inc. CUPS and the CUPS logo are trademarks of Apple Inc. The MD5 Digest code is Copyright 1999 Aladdin Enterprises. diff --git a/backend/dnssd.c b/backend/dnssd.c index 57ecc6cb9..3e527c6a6 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -1,9 +1,9 @@ /* * "$Id$" * - * DNS-SD discovery backend for the Common UNIX Printing System (CUPS). + * DNS-SD discovery backend for CUPS. * - * Copyright 2008-2009 by Apple Inc. + * Copyright 2008-2011 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -492,8 +492,14 @@ exec_backend(char **argv) /* I - Command-line arguments */ job_canceled = -1; - if ((resolved_uri = cupsBackendDeviceURI(argv)) == NULL) - exit(CUPS_BACKEND_FAILED); + while ((resolved_uri = cupsBackendDeviceURI(argv)) == NULL) + { + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer.")); + sleep(10); + + if (getenv("CLASS") != NULL) + exit(CUPS_BACKEND_FAILED); + } /* * Extract the scheme from the URI... diff --git a/backend/easysw-firewire-design.txt b/backend/easysw-firewire-design.txt index 194c487ed..e69de29bb 100644 --- a/backend/easysw-firewire-design.txt +++ b/backend/easysw-firewire-design.txt @@ -1,71 +0,0 @@ -Preliminary Design for CUPS Firewire Printer Backend - 03/19/2002 ------------------------------------------------------------------ - -OVERVIEW - - Easy Software Products will develop an IEEE-1394, a.k.a. - Firewire, printing interface for its Common UNIX Printing - System ("CUPS") for initial use under the Linux operating - system. A follow-on implementation for MacOS X is - anticipated as well. - - The operating system interfaces for IEEE-1394 ports vary - widely; the CUPS printing interface will abstract the OS - layer to a simpler interface geared towards discovering, - opening, reading from, writing to, and closing IEEE-1394 - printers. - - The initial development of the CUPS backend will be targeted - at the EPSON Stylus Pro 10000 large format printer, which - requires the bandwidth provided by Firewire in order to - print at full speed. This printer supports printing via - Serial Bus Protocol 2 (SBP-2) using the SCSI and PWG command - sets. The CUPS backend will implement the PWG command set on - LUN 0 only. - - -OS ABSTRACTION LAYER - - The OS abstraction layer will be a thin client library that - implements the following functions: - - ieee1394_list - ieee1394_open - ieee1394_close - ieee1394_read - ieee1394_write - ieee1394_error - - The "ieee1394_list" function will list all of the available - printer devices on the bus. The device information will - consist of the device URI (ieee1394:/something) used to - access the device and the make and model information, if - available, for the device ("EPSON Stylus Printer"). - - The "ieee1394_open" and "ieee1394_close" functions will open - and close a connection to the printer, respectively. - - The "ieee1394_read" and "ieee1394_write" functions will read - and write data to and from the printer, respectively. The - read function will be non-blocking, returning data only if - there is data coming back from the printer. - - The "ieee1394_error" function will return a string - describing the last error or NULL if no error occurred. - - The library will be responsible for creating any background - threads that are needed to monitor the connection to the - printer. - - -CUPS BACKEND - - The CUPS backend will use the OS abstraction layer to list - and access the Firewire printers. The "main" function will - read and write printer data, while the "list_devices" - function will be called as necessary to identify the - available devices. - - The CUPS 1.1 backend will record any status information in - the error log file, while the 1.2 backend will supply it to - the printer driver process. diff --git a/backend/easysw-firewire-linux.txt b/backend/easysw-firewire-linux.txt index a8e461189..e69de29bb 100644 --- a/backend/easysw-firewire-linux.txt +++ b/backend/easysw-firewire-linux.txt @@ -1,35 +0,0 @@ -Easy Software Products -44141 Airport View Drive -Suite 204 -Hollywood, Maryland 20636 -+1.301.373.9600 -March 8, 2002 - - -Subject: EPSON Firewire Printer Driver for Linux - -Currently, no Firewire printer support exists for Linux. Since -the latest EPSON printer products depend on the Firewire -interface to print at full speed, a solution is needed to -support customers using Linux as their server platform. - -The Linux Firewire subsystem provides a user-mode driver -interface that allows driver programs to access Firewire -devices. Easy Software Products will utilize this interface to -develop a "backend" program for the Common UNIX Printing System -that will allow users to print to EPSON printers using the -Firewire interface. - -After examining the Linux interface, we estimate that it will -require approximately 30 hours of development time to write, -test, and document the Firewire backend, for a total cost of -$3,000. The new backend will become a standard part of the CUPS -software distribution and will be included with at least the -following Linux distributions: - - - Caldera Linux - - Mandrake Linux - - Red Hat Linux - - SuSE Linux - -ESP will provide EPSON with binaries for Red Hat Linux 7.2. diff --git a/backend/ipp.c b/backend/ipp.c index d88fdeba8..b09cc729a 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -3,7 +3,7 @@ * * IPP backend for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -21,6 +21,7 @@ * check_printer_state() - Check the printer state. * compress_files() - Compress print files... * monitor_printer() - Monitor the printer state... + * new_request() - Create a new print creation or validation request. * password_cb() - Disable the password prompt for * cupsDoFileRequest(). * report_attr() - Report an IPP attribute value. @@ -109,6 +110,12 @@ static ipp_pstate_t check_printer_state(http_t *http, const char *uri, static void compress_files(int num_files, char **files); #endif /* HAVE_LIBZ */ static void *monitor_printer(_cups_monitor_t *monitor); +static ipp_t *new_request(ipp_op_t op, int version, const char *uri, + const char *user, const char *title, + int num_options, cups_option_t *options, + const char *compression, int copies, + const char *format, _pwg_t *pwg, + ipp_attribute_t *media_col_sup); static const char *password_cb(const char *); static void report_attr(ipp_attribute_t *attr); static int report_printer_state(ipp_t *ipp, int job_id); @@ -158,8 +165,8 @@ main(int argc, /* I - Number of command-line args */ time_t start_time; /* Time of first connect */ int contimeout; /* Connection timeout */ int delay; /* Delay for retries... */ - int compression, /* Do compression of the job data? */ - waitjob, /* Wait for job complete? */ + const char *compression; /* Compression mode */ + int waitjob, /* Wait for job complete? */ waitprinter; /* Wait for printer ready? */ _cups_monitor_t monitor; /* Monitoring data */ ipp_attribute_t *job_id_attr; /* job-id attribute */ @@ -170,12 +177,15 @@ main(int argc, /* I - Number of command-line args */ ipp_attribute_t *cups_version; /* cups-version */ ipp_attribute_t *format_sup; /* document-format-supported */ ipp_attribute_t *media_col_sup; /* media-col-supported */ + ipp_attribute_t *operations_sup; /* operations-supported */ ipp_attribute_t *printer_state; /* printer-state attribute */ ipp_attribute_t *printer_accepting; /* printer-is-accepting-jobs */ + int validate_job; /* Does printer support Validate-Job? */ int copies, /* Number of copies for job */ copies_remaining; /* Number of copies remaining */ const char *content_type, /* CONTENT_TYPE environment variable */ - *final_content_type; /* FINAL_CONTENT_TYPE environment var */ + *final_content_type, /* FINAL_CONTENT_TYPE environment var */ + *document_format; /* document-format value */ int fd; /* File descriptor */ off_t bytes; /* Bytes copied */ char buffer[16384]; /* Copy buffer */ @@ -183,6 +193,8 @@ main(int argc, /* I - Number of command-line args */ struct sigaction action; /* Actions for POSIX signals */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ int version; /* IPP version */ + ppd_file_t *ppd; /* PPD file */ + _pwg_t *pwg; /* PWG<->PPD mapping data */ /* @@ -257,8 +269,14 @@ main(int argc, /* I - Number of command-line args */ * Extract the hostname and printer name from the URI... */ - if ((device_uri = cupsBackendDeviceURI(argv)) == NULL) - return (CUPS_BACKEND_FAILED); + while ((device_uri = cupsBackendDeviceURI(argv)) == NULL) + { + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer.")); + sleep(10); + + if (getenv("CLASS") != NULL) + return (CUPS_BACKEND_FAILED); + } httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme), username, sizeof(username), hostname, sizeof(hostname), &port, @@ -276,7 +294,7 @@ main(int argc, /* I - Number of command-line args */ * See if there are any options... */ - compression = 0; + compression = NULL; version = 20; waitjob = 1; waitprinter = 1; @@ -393,10 +411,9 @@ main(int argc, /* I - Number of command-line args */ #ifdef HAVE_LIBZ else if (!strcasecmp(name, "compression")) { - compression = !strcasecmp(value, "true") || - !strcasecmp(value, "yes") || - !strcasecmp(value, "on") || - !strcasecmp(value, "gzip"); + if (!strcasecmp(value, "true") || !strcasecmp(value, "yes") || + !strcasecmp(value, "on") || !strcasecmp(value, "gzip")) + compression = "gzip"; } #endif /* HAVE_LIBZ */ else if (!strcasecmp(name, "contimeout")) @@ -432,8 +449,7 @@ main(int argc, /* I - Number of command-line args */ num_files = 0; send_options = !strcasecmp(final_content_type, "application/pdf") || !strcasecmp(final_content_type, "application/vnd.cups-pdf") || - !strcasecmp(final_content_type, "image/jpeg") || - !strcasecmp(final_content_type, "image/png"); + !strncasecmp(final_content_type, "image/", 6); fputs("DEBUG: Sending stdin for job...\n", stderr); } @@ -500,7 +516,8 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "DEBUG: Connecting to %s:%d\n", hostname, port); _cupsLangPrintFilter(stderr, "INFO", _("Connecting to printer.")); - if ((http = httpConnectEncrypt(hostname, port, cupsEncryption())) == NULL) + if ((http = httpConnectEncrypt(hostname, port, + cupsEncryption())) == NULL) { #if 0 /* These need to go in here someplace when we see HTTP_PKI_ERROR or IPP_PKI_ERROR */ fputs("STATE: +cups-certificate-error\n", stderr); @@ -637,11 +654,13 @@ main(int argc, /* I - Number of command-line args */ * copies... */ - copies_sup = NULL; - cups_version = NULL; - format_sup = NULL; - media_col_sup = NULL; - supported = NULL; + copies_sup = NULL; + cups_version = NULL; + format_sup = NULL; + media_col_sup = NULL; + supported = NULL; + operations_sup = NULL; + validate_job = 0; do { @@ -812,6 +831,34 @@ main(int argc, /* I - Number of command-line args */ media_col_sup->values[i].string.text); } + if ((operations_sup = ippFindAttribute(supported, "operations-supported", + IPP_TAG_ENUM)) != NULL) + { + for (i = 0; i < operations_sup->num_values; i ++) + if (operations_sup->values[i].integer == IPP_VALIDATE_JOB) + { + validate_job = 1; + break; + } + + if (!validate_job) + { + _cupsLangPrintFilter(stderr, "WARNING", + _("This printer does not conform to the IPP " + "standard and may not work.")); + fputs("DEBUG: operations-supported does not list Validate-Job.\n", + stderr); + } + } + else + { + _cupsLangPrintFilter(stderr, "WARNING", + _("This printer does not conform to the IPP " + "standard and may not work.")); + fputs("DEBUG: operations-supported not returned in " + "Get-Printer-Attributes request.\n", stderr); + } + report_printer_state(supported, 0); } while (ipp_status > IPP_OK_CONFLICT); @@ -874,6 +921,44 @@ main(int argc, /* I - Number of command-line args */ else copies_remaining = copies; + /* + * Prepare remaining printing options... + */ + + options = NULL; + pwg = NULL; + + if (send_options) + { + num_options = cupsParseOptions(argv[5], 0, &options); + + if (!cups_version && media_col_sup) + { + /* + * Load the PPD file and generate PWG attribute mapping information... + */ + + ppd = ppdOpenFile(getenv("PPD")); + pwg = _pwgCreateWithPPD(ppd); + + ppdClose(ppd); + } + } + else + num_options = 0; + + document_format = NULL; + + if (format_sup != NULL) + { + for (i = 0; i < format_sup->num_values; i ++) + if (!strcasecmp(final_content_type, format_sup->values[i].string.text)) + { + document_format = final_content_type; + break; + } + } + /* * Start monitoring the printer in the background... */ @@ -892,252 +977,89 @@ main(int argc, /* I - Number of command-line args */ _cupsThreadCreate((_cups_thread_func_t)monitor_printer, &monitor); /* - * Then issue the print-job request... + * Validate access to the printer... */ - job_id = 0; - - while (copies_remaining > 0) + while (!job_canceled) { - /* - * Check for side-channel requests... - */ - - backendCheckSideChannel(snmp_fd, http->hostaddr); - - /* - * Build the IPP request... - */ - - if (job_canceled) - break; - - if (num_files > 1) - request = ippNewRequest(IPP_CREATE_JOB); - else - request = ippNewRequest(IPP_PRINT_JOB); - - request->request.op.version[0] = version / 10; - request->request.op.version[1] = version % 10; - - fprintf(stderr, "DEBUG: %s IPP/%d.%d\n", - ippOpString(request->request.op.operation_id), - request->request.op.version[0], - request->request.op.version[1]); - - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", - NULL, uri); - fprintf(stderr, "DEBUG: printer-uri=\"%s\"\n", uri); - - if (argv[2][0]) - { - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, - "requesting-user-name", NULL, argv[2]); - fprintf(stderr, "DEBUG: requesting-user-name=\"%s\"\n", argv[2]); - } - - if (argv[3][0]) - { - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL, - argv[3]); - fprintf(stderr, "DEBUG: job-name=\"%s\"\n", argv[3]); - } - -#ifdef HAVE_LIBZ - if (compression) - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, - "compression", NULL, "gzip"); -#endif /* HAVE_LIBZ */ + request = new_request(IPP_VALIDATE_JOB, version, uri, argv[2], argv[3], + num_options, options, compression, + copies_sup ? copies : 1, document_format, pwg, + media_col_sup); - /* - * Handle options on the command-line... - */ + ippDelete(cupsDoRequest(http, request, resource)); - options = NULL; - num_options = cupsParseOptions(argv[5], 0, &options); + ipp_status = cupsLastError(); - if (format_sup != NULL) + if (ipp_status > IPP_OK_CONFLICT) { - for (i = 0; i < format_sup->num_values; i ++) - if (!strcasecmp(final_content_type, format_sup->values[i].string.text)) - break; - - if (i < format_sup->num_values) - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, - "document-format", NULL, final_content_type); - } + if (job_canceled) + break; - if (send_options) - { - if (cups_version || !media_col_sup) + if (ipp_status == IPP_SERVICE_UNAVAILABLE || + ipp_status == IPP_PRINTER_BUSY) { - /* - * When talking to another CUPS server, send all options... - */ - - cupsEncodeOptions(request, num_options, options); + _cupsLangPrintFilter(stderr, "INFO", + _("Printer busy; will retry in 10 seconds.")); + sleep(10); } else { /* - * Otherwise send standard IPP attributes... + * Update auth-info-required as needed... */ - char cachefile[1024];/* Printer PWG cache file */ - const char *cups_cachedir; /* Location of cache file */ - _pwg_t *pwg; /* PWG mapping data */ - const char *keyword; /* PWG keyword */ - _pwg_size_t *size; /* PWG media size */ + _cupsLangPrintFilter(stderr, "ERROR", "%s", cupsLastErrorString()); - - if ((cups_cachedir = getenv("CUPS_CACHEDIR")) == NULL) - cups_cachedir = CUPS_CACHEDIR; - - snprintf(cachefile, sizeof(cachefile), "%s/%s.pwg", cups_cachedir, - getenv("PRINTER")); - - if ((keyword = cupsGetOption("PageSize", num_options, options)) == NULL) - keyword = cupsGetOption("media", num_options, options); - - pwg = _pwgCreateWithFile(cachefile); - size = _pwgGetSize(pwg, keyword); - - if (media_col_sup && size) + if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN) { - ipp_t *media_col, /* media-col value */ - *media_size; /* media-size value */ - const char *media_source, /* media-source value */ - *media_type; /* media-type value */ - - media_size = ippNew(); - ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER, - "x-dimension", size->width); - ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER, - "y-dimension", size->length); - - media_col = ippNew(); - ippAddCollection(media_col, IPP_TAG_ZERO, "media-size", media_size); - - media_source = _pwgGetSource(pwg, cupsGetOption("InputSlot", - num_options, - options)); - media_type = _pwgGetType(pwg, cupsGetOption("MediaType", - num_options, options)); - - for (i = 0; i < media_col_sup->num_values; i ++) - { - if (!strcmp(media_col_sup->values[i].string.text, - "media-left-margin")) - ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, - "media-left-margin", size->left); - else if (!strcmp(media_col_sup->values[i].string.text, - "media-bottom-margin")) - ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, - "media-bottom-margin", size->left); - else if (!strcmp(media_col_sup->values[i].string.text, - "media-right-margin")) - ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, - "media-right-margin", size->left); - else if (!strcmp(media_col_sup->values[i].string.text, - "media-top-margin")) - ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, - "media-top-margin", size->left); - else if (!strcmp(media_col_sup->values[i].string.text, - "media-source") && media_source) - ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, - "media-source", NULL, media_source); - else if (!strcmp(media_col_sup->values[i].string.text, - "media-type") && media_type) - ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, - "media-type", NULL, media_type); - } - - ippAddCollection(request, IPP_TAG_JOB, "media-col", media_col); - } - else if (size) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "media", - NULL, size->map.pwg); - else if (keyword) - { - _pwg_media_t *found; /* PWG media */ - + fprintf(stderr, "DEBUG: WWW-Authenticate=\"%s\"\n", + httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE)); - if ((found = _pwgMediaForPPD(keyword)) != NULL) - keyword = found->pwg; - else if ((found = _pwgMediaForLegacy(keyword)) != NULL) - keyword = found->pwg; + /* + * Normal authentication goes through the password callback, which sets + * auth_info_required to "username,password". Kerberos goes directly + * through GSSAPI, so look for Negotiate in the WWW-Authenticate header + * here and set auth_info_required as needed... + */ - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "media", - NULL, keyword); - } + if (!strncmp(httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE), + "Negotiate", 9)) + auth_info_required = "negotiate"; + } - if ((keyword = cupsGetOption("output-bin", num_options, - options)) == NULL) - keyword = _pwgGetBin(pwg, cupsGetOption("OutputBin", num_options, - options)); + goto cleanup; + } + } + else + break; + } - if (keyword) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-bin", - NULL, keyword); + /* + * Then issue the print-job request... + */ - if ((keyword = cupsGetOption("output-mode", num_options, - options)) != NULL) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-mode", - NULL, keyword); - else if ((keyword = cupsGetOption("ColorModel", num_options, - options)) != NULL) - { - if (!strcasecmp(keyword, "Gray")) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-mode", - NULL, "monochrome"); - else if (!strcasecmp(keyword, "Color")) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-mode", - NULL, "color"); - } + job_id = 0; - if ((keyword = cupsGetOption("print-quality", num_options, - options)) != NULL) - ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", - atoi(keyword)); - else if ((keyword = cupsGetOption("cupsPrintQuality", num_options, - options)) != NULL) - { - if (!strcasecmp(keyword, "draft")) - ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", - IPP_QUALITY_DRAFT); - else if (!strcasecmp(keyword, "normal")) - ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", - IPP_QUALITY_NORMAL); - else if (!strcasecmp(keyword, "high")) - ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", - IPP_QUALITY_HIGH); - } + while (!job_canceled && copies_remaining > 0) + { + /* + * Check for side-channel requests... + */ - if ((keyword = cupsGetOption("sides", num_options, options)) != NULL) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", - NULL, keyword); - else if ((keyword = cupsGetOption("Duplex", num_options, - options)) != NULL) - { - if (!strcasecmp(keyword, "None")) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", - NULL, "one-sided"); - else if (!strcasecmp(keyword, "DuplexNoTumble")) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", - NULL, "two-sided-long-edge"); - if (!strcasecmp(keyword, "DuplexTumble")) - ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", - NULL, "two-sided-short-edge"); - } + backendCheckSideChannel(snmp_fd, http->hostaddr); - _pwgDestroy(pwg); - } + /* + * Build the IPP job creation request... + */ - if (copies_sup && copies > 1) - ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies", copies); - } + if (job_canceled) + break; - cupsFreeOptions(num_options, options); + request = new_request(num_files > 1 ? IPP_CREATE_JOB : IPP_PRINT_JOB, + version, uri, argv[2], argv[3], num_options, options, + compression, copies_sup ? copies : 1, document_format, + pwg, media_col_sup); /* * Do the request... @@ -1490,6 +1412,11 @@ main(int argc, /* I - Number of command-line args */ * Free memory... */ + cleanup: + + cupsFreeOptions(num_options, options); + _pwgDestroy(pwg); + httpClose(http); ippDelete(supported); @@ -1813,6 +1740,230 @@ monitor_printer( } +/* + * 'new_request()' - Create a new print creation or validation request. + */ + +static ipp_t * /* O - Request data */ +new_request( + ipp_op_t op, /* I - IPP operation code */ + int version, /* I - IPP version number */ + const char *uri, /* I - printer-uri value */ + const char *user, /* I - requesting-user-name value */ + const char *title, /* I - job-name value */ + int num_options, /* I - Number of options to send */ + cups_option_t *options, /* I - Options to send */ + const char *compression, /* I - compression value or NULL */ + int copies, /* I - copies value or 0 */ + const char *format, /* I - documet-format value or NULL */ + _pwg_t *pwg, /* I - PWG<->PPD mapping data */ + ipp_attribute_t *media_col_sup) /* I - media-col-supported values */ +{ + int i; /* Looping var */ + ipp_t *request; /* Request data */ + const char *keyword; /* PWG keyword */ + _pwg_size_t *size; /* PWG media size */ + ipp_t *media_col, /* media-col value */ + *media_size; /* media-size value */ + const char *media_source, /* media-source value */ + *media_type; /* media-type value */ + + + /* + * Create the IPP request... + */ + + request = ippNewRequest(op); + request->request.op.version[0] = version / 10; + request->request.op.version[1] = version % 10; + + fprintf(stderr, "DEBUG: %s IPP/%d.%d\n", + ippOpString(request->request.op.operation_id), + request->request.op.version[0], + request->request.op.version[1]); + + /* + * Add standard attributes... + */ + + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", + NULL, uri); + fprintf(stderr, "DEBUG: printer-uri=\"%s\"\n", uri); + + if (user && *user) + { + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + "requesting-user-name", NULL, user); + fprintf(stderr, "DEBUG: requesting-user-name=\"%s\"\n", user); + } + + if (title && *title) + { + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL, + title); + fprintf(stderr, "DEBUG: job-name=\"%s\"\n", title); + } + + if (format) + { + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, + "document-format", NULL, format); + fprintf(stderr, "DEBUG: document-format=\"%s\"\n", format); + } + +#ifdef HAVE_LIBZ + if (compression) + { + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, + "compression", NULL, compression); + fprintf(stderr, "DEBUG: compression=\"%s\"\n", compression); + } +#endif /* HAVE_LIBZ */ + + /* + * Handle options on the command-line... + */ + + if (num_options > 0) + { + if (pwg) + { + /* + * Send standard IPP attributes... + */ + + if ((keyword = cupsGetOption("PageSize", num_options, options)) == NULL) + keyword = cupsGetOption("media", num_options, options); + + if ((size = _pwgGetSize(pwg, keyword)) != NULL) + { + /* + * Add a media-col value... + */ + + media_size = ippNew(); + ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER, + "x-dimension", size->width); + ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER, + "y-dimension", size->length); + + media_col = ippNew(); + ippAddCollection(media_col, IPP_TAG_ZERO, "media-size", media_size); + + media_source = _pwgGetSource(pwg, cupsGetOption("InputSlot", + num_options, + options)); + media_type = _pwgGetType(pwg, cupsGetOption("MediaType", + num_options, options)); + + for (i = 0; i < media_col_sup->num_values; i ++) + { + if (!strcmp(media_col_sup->values[i].string.text, + "media-left-margin")) + ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + "media-left-margin", size->left); + else if (!strcmp(media_col_sup->values[i].string.text, + "media-bottom-margin")) + ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + "media-bottom-margin", size->left); + else if (!strcmp(media_col_sup->values[i].string.text, + "media-right-margin")) + ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + "media-right-margin", size->left); + else if (!strcmp(media_col_sup->values[i].string.text, + "media-top-margin")) + ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, + "media-top-margin", size->left); + else if (!strcmp(media_col_sup->values[i].string.text, + "media-source") && media_source) + ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, + "media-source", NULL, media_source); + else if (!strcmp(media_col_sup->values[i].string.text, + "media-type") && media_type) + ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, + "media-type", NULL, media_type); + } + + ippAddCollection(request, IPP_TAG_JOB, "media-col", media_col); + } + + if ((keyword = cupsGetOption("output-bin", num_options, + options)) == NULL) + keyword = _pwgGetBin(pwg, cupsGetOption("OutputBin", num_options, + options)); + + if (keyword) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-bin", + NULL, keyword); + + if ((keyword = cupsGetOption("output-mode", num_options, + options)) != NULL) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-mode", + NULL, keyword); + else if ((keyword = cupsGetOption("ColorModel", num_options, + options)) != NULL) + { + if (!strcasecmp(keyword, "Gray")) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-mode", + NULL, "monochrome"); + else + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-mode", + NULL, "color"); + } + + if ((keyword = cupsGetOption("print-quality", num_options, + options)) != NULL) + ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", + atoi(keyword)); + else if ((keyword = cupsGetOption("cupsPrintQuality", num_options, + options)) != NULL) + { + if (!strcasecmp(keyword, "draft")) + ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", + IPP_QUALITY_DRAFT); + else if (!strcasecmp(keyword, "normal")) + ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", + IPP_QUALITY_NORMAL); + else if (!strcasecmp(keyword, "high")) + ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", + IPP_QUALITY_HIGH); + } + + if ((keyword = cupsGetOption("sides", num_options, options)) != NULL) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", + NULL, keyword); + else if (pwg->sides_option && + (keyword = cupsGetOption(pwg->sides_option, num_options, + options)) != NULL) + { + if (!strcasecmp(keyword, pwg->sides_1sided)) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", + NULL, "one-sided"); + else if (!strcasecmp(keyword, pwg->sides_2sided_long)) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", + NULL, "two-sided-long-edge"); + if (!strcasecmp(keyword, pwg->sides_2sided_short)) + ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", + NULL, "two-sided-short-edge"); + } + } + else + { + /* + * When talking to another CUPS server, send all options... + */ + + cupsEncodeOptions(request, num_options, options); + } + + if (copies > 1) + ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies", copies); + } + + return (request); +} + + /* * 'password_cb()' - Disable the password prompt for cupsDoFileRequest(). */ diff --git a/backend/lpd.c b/backend/lpd.c index ccc88bace..914ffc2cf 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -3,7 +3,7 @@ * * Line Printer Daemon backend for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -191,8 +191,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and printer name from the URI... */ - if ((device_uri = cupsBackendDeviceURI(argv)) == NULL) - return (CUPS_BACKEND_FAILED); + while ((device_uri = cupsBackendDeviceURI(argv)) == NULL) + { + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer.")); + sleep(10); + + if (getenv("CLASS") != NULL) + return (CUPS_BACKEND_FAILED); + } httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme), username, sizeof(username), hostname, sizeof(hostname), &port, @@ -225,36 +231,15 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ #ifdef __APPLE__ /* - * We want to pass utf-8 characters, not re-map them (3071945) + * We want to pass UTF-8 characters by default, not re-map them (3071945) */ sanitize_title = 0; - +#else /* - * Get the default timeout from a system preference... + * Otherwise we want to re-map UTF-8 to "safe" characters by default... */ - { - CFPropertyListRef pvalue; /* Preference value */ - SInt32 toval; /* Timeout value */ - - - pvalue = CFPreferencesCopyValue(CFSTR("timeout"), - CFSTR("com.apple.print.backends"), - kCFPreferencesAnyUser, - kCFPreferencesCurrentHost); - if (pvalue) - { - if (CFGetTypeID(pvalue) == CFNumberGetTypeID()) - { - CFNumberGetValue(pvalue, kCFNumberSInt32Type, &toval); - contimeout = (int)toval; - } - - CFRelease(pvalue); - } - } -#else sanitize_title = 1; #endif /* __APPLE__ */ @@ -432,11 +417,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ fputs("STATE: +connecting-to-device\n", stderr); fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); - if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, "1")) == NULL) + while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, "1")) == NULL) { - _cupsLangPrintFilter(stderr, "ERROR", + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer \"%s\"."), hostname); - return (CUPS_BACKEND_STOP); + sleep(10); + + if (getenv("CLASS") != NULL) + exit(CUPS_BACKEND_FAILED); } snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family); @@ -687,11 +675,14 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ fputs("STATE: +connecting-to-device\n", stderr); fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); - if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) + while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) { - _cupsLangPrintFilter(stderr, "ERROR", _("Unable to locate printer \"%s\"."), + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer \"%s\"."), hostname); - return (CUPS_BACKEND_STOP); + sleep(10); + + if (getenv("CLASS") != NULL) + exit(CUPS_BACKEND_FAILED); } /* diff --git a/backend/socket.c b/backend/socket.c index ae9e03f69..6f64fb0c0 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -3,7 +3,7 @@ * * AppSocket backend for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -164,8 +164,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and port number from the URI... */ - if ((device_uri = cupsBackendDeviceURI(argv)) == NULL) - return (CUPS_BACKEND_FAILED); + while ((device_uri = cupsBackendDeviceURI(argv)) == NULL) + { + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer.")); + sleep(10); + + if (getenv("CLASS") != NULL) + return (CUPS_BACKEND_FAILED); + } httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme), username, sizeof(username), hostname, sizeof(hostname), &port, @@ -261,11 +267,14 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ fputs("STATE: +connecting-to-device\n", stderr); fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname); - if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) + while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL) { - _cupsLangPrintFilter(stderr, "ERROR", + _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer \"%s\"."), hostname); - return (CUPS_BACKEND_STOP); + sleep(10); + + if (getenv("CLASS") != NULL) + return (CUPS_BACKEND_STOP); } fprintf(stderr, "DEBUG: Connecting to %s:%d\n", hostname, port); diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index 71d2a3a54..2c2d73e56 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -3,7 +3,7 @@ * * Libusb interface code for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -101,7 +101,7 @@ print_device(const char *uri, /* I - Device URI */ usb_printer_t *printer; /* Printer */ ssize_t bytes, /* Bytes read/written */ tbytes; /* Total bytes written */ - char buffer[8192]; /* Print data buffer */ + char buffer[512]; /* Print data buffer */ struct sigaction action; /* Actions for POSIX signals */ struct pollfd pfds[2]; /* Poll descriptors */ @@ -748,7 +748,7 @@ side_cb(usb_printer_t *printer, /* I - Printer */ { ssize_t bytes, /* Bytes read/written */ tbytes; /* Total bytes written */ - char buffer[8192]; /* Print data buffer */ + char buffer[512]; /* Print data buffer */ struct pollfd pfd; /* Poll descriptor */ cups_sc_command_t command; /* Request command */ cups_sc_status_t status; /* Request/response status */ diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index a5250dc10..f8cbba1ea 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1,9 +1,9 @@ /* * "$Id: admin.c 8029 2008-10-08 21:07:45Z mike $" * - * Administration CGI for the Common UNIX Printing System (CUPS). + * Administration CGI for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -145,7 +145,30 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "DEBUG: op=\"%s\"...\n", op); - if (!strcmp(op, "set-allowed-users")) + if (!*op) + { + const char *printer = getenv("PRINTER_NAME"), + /* Printer or class name */ + *server_port = getenv("SERVER_PORT"); + /* Port number string */ + int port = atoi(server_port ? server_port : "0"); + /* Port number */ + char uri[1024]; /* URL */ + + if (printer) + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), + getenv("HTTPS") ? "https" : "http", NULL, + getenv("SERVER_NAME"), port, "/%s/%s", + cgiGetVariable("IS_CLASS") ? "classes" : "printers", + printer); + else + httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), + getenv("HTTPS") ? "https" : "http", NULL, + getenv("SERVER_NAME"), port, "/admin"); + + printf("Location: %s\n\n", uri); + } + else if (!strcmp(op, "set-allowed-users")) do_set_allowed_users(http); else if (!strcmp(op, "set-as-default")) do_set_default(http); @@ -1040,7 +1063,8 @@ do_am_printer(http_t *http, /* I - HTTP connection */ } } } - else if (strchr(var, '/') == NULL) + else if (!strchr(var, '/') || + (!strncmp(var, "lpd://", 6) && !strchr(var + 6, '/'))) { if ((attr = ippFindAttribute(oldinfo, "device-uri", IPP_TAG_URI)) != NULL) { diff --git a/cgi-bin/classes.c b/cgi-bin/classes.c index 7fa7eb80e..d0f4b0a20 100644 --- a/cgi-bin/classes.c +++ b/cgi-bin/classes.c @@ -1,9 +1,9 @@ /* * "$Id: classes.c 7940 2008-09-16 00:45:16Z mike $" * - * Class status CGI for the Common UNIX Printing System (CUPS). + * Class status CGI for CUPS. * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -147,7 +147,21 @@ main(int argc, /* I - Number of command-line arguments */ } else if (pclass) { - if (!strcmp(op, "start-class")) + if (!*op) + { + const char *server_port = getenv("SERVER_PORT"); + /* Port number string */ + int port = atoi(server_port ? server_port : "0"); + /* Port number */ + char uri[1024]; /* URL */ + + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), + getenv("HTTPS") ? "https" : "http", NULL, + getenv("SERVER_NAME"), port, "/classes/%s", pclass); + + printf("Location: %s\n\n", uri); + } + else if (!strcmp(op, "start-class")) do_class_op(http, pclass, IPP_RESUME_PRINTER, cgiText(_("Resume Class"))); else if (!strcmp(op, "stop-class")) do_class_op(http, pclass, IPP_PAUSE_PRINTER, cgiText(_("Pause Class"))); diff --git a/cgi-bin/html.c b/cgi-bin/html.c index 5d0a39fdd..ea2b3f705 100644 --- a/cgi-bin/html.c +++ b/cgi-bin/html.c @@ -1,9 +1,9 @@ /* * "$Id: html.c 6649 2007-07-11 21:46:42Z mike $" * - * HTML support functions for the Common UNIX Printing System (CUPS). + * HTML support functions for CUPS. * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -208,31 +208,13 @@ cgiStartMultipart(void) int /* O - 1 if multi-part supported, 0 otherwise */ cgiSupportsMultipart(void) { - const char *user_agent; /* User-Agent string */ - static int supports_multipart = -1;/* Cached value */ - - - if (supports_multipart < 0) - { - /* - * CUPS STR #3049: Apparently some browsers don't support multi-part - * documents, which makes them useless for many web sites. Rather than - * abandoning those users, we'll offer a degraded single-part mode... - * - * Currently we know that anything based on Gecko, MSIE, and Safari all - * work. We'll add more as they are reported/tested. - */ - - if ((user_agent = getenv("HTTP_USER_AGENT")) != NULL && - (strstr(user_agent, " Gecko/") != NULL || - strstr(user_agent, " MSIE ") != NULL || - strstr(user_agent, " Safari/") != NULL)) - supports_multipart = 1; - else - supports_multipart = 0; - } + /* + * Too many bug reports for browsers that don't support it, and too much pain + * to whitelist known-good browsers, so for now we just punt on multi-part + * support... :( + */ - return (supports_multipart); + return (0); } diff --git a/cgi-bin/printers.c b/cgi-bin/printers.c index f57a4251e..8b613f3b7 100644 --- a/cgi-bin/printers.c +++ b/cgi-bin/printers.c @@ -1,9 +1,9 @@ /* * "$Id: printers.c 7940 2008-09-16 00:45:16Z mike $" * - * Printer status CGI for the Common UNIX Printing System (CUPS). + * Printer status CGI for CUPS. * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -148,7 +148,21 @@ main(int argc, /* I - Number of command-line arguments */ } else if (printer) { - if (!strcmp(op, "start-printer")) + if (!*op) + { + const char *server_port = getenv("SERVER_PORT"); + /* Port number string */ + int port = atoi(server_port ? server_port : "0"); + /* Port number */ + char uri[1024]; /* URL */ + + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), + getenv("HTTPS") ? "https" : "http", NULL, + getenv("SERVER_NAME"), port, "/printers/%s", printer); + + printf("Location: %s\n\n", uri); + } + else if (!strcmp(op, "start-printer")) do_printer_op(http, printer, IPP_RESUME_PRINTER, cgiText(_("Resume Printer"))); else if (!strcmp(op, "stop-printer")) diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index 1c2f4d25b..72bc505fe 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -3,7 +3,7 @@ dnl "$Id: cups-common.m4 8781 2009-08-28 17:34:54Z mike $" dnl dnl Common configuration stuff for CUPS. dnl -dnl Copyright 2007-2010 by Apple Inc. +dnl Copyright 2007-2011 by Apple Inc. dnl Copyright 1997-2007 by Easy Software Products, all rights reserved. dnl dnl These coded instructions, statements, and computer programs are the @@ -88,6 +88,9 @@ fi AC_SUBST(INSTALLSTATIC) +dnl Check for pkg-config, which is used for some other tests later on... +AC_PATH_PROG(PKGCONFIG, pkg-config) + dnl Check for libraries... AC_SEARCH_LIBS(crypt, crypt) AC_SEARCH_LIBS(getspent, sec gen) @@ -216,7 +219,7 @@ else fi if test $check_libusb = yes; then - AC_CHECK_LIB(usb, usb_init,[ + AC_CHECK_LIB(usb, usb_get_string_simple,[ AC_CHECK_HEADER(usb.h, AC_DEFINE(HAVE_USB_H) LIBUSB="-lusb")]) @@ -277,24 +280,22 @@ AC_ARG_WITH(dbusdir, [ --with-dbusdir set DBUS configuration directory DBUS_NOTIFIER="" DBUS_NOTIFIERLIBS="" -if test "x$enable_dbus" != xno; then - AC_PATH_PROG(PKGCONFIG, pkg-config) - if test "x$PKGCONFIG" != x; then - AC_MSG_CHECKING(for DBUS) - if $PKGCONFIG --exists dbus-1; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DBUS) - CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE" - SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`" - DBUS_NOTIFIER="dbus" - DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`" - AC_CHECK_LIB(dbus-1, - dbus_message_iter_init_append, - AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND),, - `$PKGCONFIG --libs dbus-1`) - else - AC_MSG_RESULT(no) - fi +if test "x$enable_dbus" != xno -a "x$PKGCONFIG" != x; then + AC_MSG_CHECKING(for DBUS) + if $PKGCONFIG --exists dbus-1; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DBUS) + CFLAGS="$CFLAGS `$PKGCONFIG --cflags dbus-1` -DDBUS_API_SUBJECT_TO_CHANGE" + SERVERLIBS="$SERVERLIBS `$PKGCONFIG --libs dbus-1`" + DBUS_NOTIFIER="dbus" + DBUS_NOTIFIERLIBS="`$PKGCONFIG --libs dbus-1`" + SAVELIBS="$LIBS" + LIBS="$LIBS $DBUS_NOTIFIERLIBS" + AC_CHECK_FUNC(dbus_message_iter_init_append, + AC_DEFINE(HAVE_DBUS_MESSAGE_ITER_INIT_APPEND)) + LIBS="$SAVELIBS" + else + AC_MSG_RESULT(no) fi fi diff --git a/config-scripts/cups-ssl.m4 b/config-scripts/cups-ssl.m4 index 86faf5f9d..2bb6b62b2 100644 --- a/config-scripts/cups-ssl.m4 +++ b/config-scripts/cups-ssl.m4 @@ -3,7 +3,7 @@ dnl "$Id: cups-ssl.m4 7241 2008-01-22 22:34:52Z mike $" dnl dnl OpenSSL/GNUTLS stuff for CUPS. dnl -dnl Copyright 2007-2010 by Apple Inc. +dnl Copyright 2007-2011 by Apple Inc. dnl Copyright 1997-2007 by Easy Software Products, all rights reserved. dnl dnl These coded instructions, statements, and computer programs are the @@ -30,7 +30,7 @@ have_ssl=0 if test x$enable_ssl != xno; then dnl Look for CDSA... - if test $have_ssl = 0 -a "x${enable_cdsassl}" != "xno"; then + if test $have_ssl = 0 -a "x$enable_cdsassl" != "xno"; then if test $uname = Darwin; then AC_CHECK_HEADER(Security/SecureTransport.h, [ have_ssl=1 @@ -40,6 +40,8 @@ if test x$enable_ssl != xno; then dnl Check for the various security headers... AC_CHECK_HEADER(Security/SecCertificate.h, AC_DEFINE(HAVE_SECCERTIFICATE_H)) + AC_CHECK_HEADER(Security/SecItem.h, + AC_DEFINE(HAVE_SECITEM_H)) AC_CHECK_HEADER(Security/SecItemPriv.h, AC_DEFINE(HAVE_SECITEMPRIV_H)) AC_CHECK_HEADER(Security/SecPolicy.h, @@ -74,7 +76,7 @@ if test x$enable_ssl != xno; then fi dnl Then look for GNU TLS... - if test $have_ssl = 0 -a "x${enable_gnutls}" != "xno" -a "x$PKGCONFIG" != x; then + if test $have_ssl = 0 -a "x$enable_gnutls" != "xno" -a "x$PKGCONFIG" != x; then AC_PATH_PROG(LIBGNUTLSCONFIG,libgnutls-config) AC_PATH_PROG(LIBGCRYPTCONFIG,libgcrypt-config) if $PKGCONFIG --exists gnutls; then @@ -111,7 +113,7 @@ if test x$enable_ssl != xno; then fi dnl Check for the OpenSSL library last... - if test $have_ssl = 0 -a "x${enable_openssl}" != "xno"; then + if test $have_ssl = 0 -a "x$enable_openssl" != "xno"; then AC_CHECK_HEADER(openssl/ssl.h, dnl Save the current libraries so the crypto stuff isn't always dnl included... @@ -148,6 +150,8 @@ fi if test $have_ssl = 1; then AC_MSG_RESULT([ Using SSLLIBS="$SSLLIBS"]) AC_MSG_RESULT([ Using SSLFLAGS="$SSLFLAGS"]) +elif test x$enable_cdsa = xyes -o x$enable_gnutls = xyes -o x$enable_openssl = xyes; then + AC_MSG_ERROR([Unable to enable SSL support.]) fi AC_SUBST(SSLFLAGS) diff --git a/config.h.in b/config.h.in index 1e0c22d2f..42a2b0f32 100644 --- a/config.h.in +++ b/config.h.in @@ -3,7 +3,7 @@ * * Configuration file for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -297,6 +297,7 @@ #undef HAVE_AUTHORIZATION_H #undef HAVE_SECCERTIFICATE_H +#undef HAVE_SECITEM_H #undef HAVE_SECITEMPRIV_H #undef HAVE_SECPOLICY_H #undef HAVE_SECPOLICYPRIV_H diff --git a/cups/adminutil.c b/cups/adminutil.c index 872a90e56..8ceb55086 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -3,7 +3,7 @@ * * Administration utility API definitions for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 2001-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -2034,6 +2034,8 @@ cupsAdminSetServerSettings( for (i = num_settings, setting = settings; i > 0; i --, setting ++) if (setting->name[0] != '_' && + strcasecmp(setting->name, "Listen") && + strcasecmp(setting->name, "Port") && !cupsGetOption(setting->name, cupsd_num_settings, cupsd_settings)) { /* diff --git a/cups/conflicts.c b/cups/conflicts.c index 95c7b28ac..0ccc3b624 100644 --- a/cups/conflicts.c +++ b/cups/conflicts.c @@ -3,7 +3,7 @@ * * Option marking routines for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -482,13 +482,13 @@ cupsResolveConflicts( } } } + } - if (!changed) - { - DEBUG_puts("1ppdResolveConflicts: Unable to automatically resolve " - "constraint!"); - goto error; - } + if (!changed) + { + DEBUG_puts("1ppdResolveConflicts: Unable to automatically resolve " + "constraint!"); + goto error; } cupsArrayClear(pass); diff --git a/cups/custom.c b/cups/custom.c index 9826ad241..d4b959256 100644 --- a/cups/custom.c +++ b/cups/custom.c @@ -3,7 +3,7 @@ * * PPD custom option routines for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -69,14 +69,19 @@ ppd_cparam_t * /* O - Custom parameter or NULL */ ppdFindCustomParam(ppd_coption_t *opt, /* I - Custom option */ const char *name) /* I - Parameter name */ { - ppd_cparam_t key; /* Custom parameter search key */ + ppd_cparam_t *param; /* Current custom parameter */ if (!opt) return (NULL); - strlcpy(key.name, name, sizeof(key.name)); - return ((ppd_cparam_t *)cupsArrayFind(opt->params, &key)); + for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params); + param; + param = (ppd_cparam_t *)cupsArrayNext(opt->params)) + if (!strcasecmp(param->name, name)) + break; + + return (param); } diff --git a/cups/http-private.h b/cups/http-private.h index 51b612987..932259ddc 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -120,7 +120,9 @@ extern ssize_t _httpWriteGNUTLS(gnutls_transport_ptr ptr, const void *data, # include # include # include -# include +# ifdef HAVE_SECITEM_H +# include +# endif /* HAVE_SECITEM_H */ # ifdef HAVE_SECBASEPRIV_H # include # elif defined(HAVE_CSSMERRORSTRING) /* Declare prototype for function in that header... */ diff --git a/cups/http.c b/cups/http.c index dc117224c..834f61c4c 100644 --- a/cups/http.c +++ b/cups/http.c @@ -3,7 +3,7 @@ * * HTTP routines for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * This file contains Kerberos support code, copyright 2006 by @@ -159,7 +159,9 @@ static int http_write_chunk(http_t *http, const char *buffer, int length); #ifdef HAVE_SSL static int http_read_ssl(http_t *http, char *buf, int len); +# ifdef HAVE_CDSASSL static int http_set_credentials(http_t *http); +# endif /* HAVE_CDSASSL */ static int http_setup_ssl(http_t *http); static void http_shutdown_ssl(http_t *http); static int http_upgrade(http_t *http); @@ -3594,6 +3596,7 @@ http_send(http_t *http, /* I - Connection to server */ #ifdef HAVE_SSL +# ifdef HAVE_CDSASSL /* * 'http_set_credentials()' - Set the SSL/TLS credentials. */ @@ -3602,22 +3605,13 @@ static int /* O - Status of connection */ http_set_credentials(http_t *http) /* I - Connection to server */ { _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ -# ifdef HAVE_CDSASSL OSStatus error = 0; /* Error code */ http_tls_credentials_t credentials = NULL; /* TLS credentials */ -# endif /* HAVE_CDSASSL */ DEBUG_printf(("7http_set_credentials(%p)", http)); -# ifdef HAVE_LIBSSL - return (-1); - -# elif defined(HAVE_GNUTLS) - return (-1); - -# elif defined(HAVE_CDSASSL) /* * Prefer connection specific credentials... */ @@ -3692,11 +3686,8 @@ http_set_credentials(http_t *http) /* I - Connection to server */ DEBUG_puts("4http_set_credentials: No credentials to set."); return (error); - -# elif defined(HAVE_SSPISSL) - return (-1); -# endif /* HAVE_LIBSSL */ } +# endif /* HAVE_CDSASSL */ /* diff --git a/cups/http.h b/cups/http.h index bd6e4571d..6ac8e110e 100644 --- a/cups/http.h +++ b/cups/http.h @@ -3,7 +3,7 @@ * * Hyper-Text Transport Protocol definitions for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -88,7 +88,7 @@ extern "C" { #if defined(AF_INET6) && !defined(s6_addr32) # if defined(__sun) # define s6_addr32 _S6_un._S6_u32 -# elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) +# elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)|| defined(__DragonFly__) # define s6_addr32 __u6_addr.__u6_addr32 # elif defined(__osf__) # define s6_addr32 s6_un.sa6_laddr diff --git a/cups/mark.c b/cups/mark.c index 21d41d176..4dbd7555c 100644 --- a/cups/mark.c +++ b/cups/mark.c @@ -77,10 +77,15 @@ cupsMarkOptions( s[255]; /* Temporary string */ const char *val, /* Pointer into value */ *media, /* media option */ + *output_bin, /* output-bin option */ + *output_mode, /* output-mode option */ *page_size, /* PageSize option */ - *ppd_keyword; /* PPD keyword */ + *ppd_keyword, /* PPD keyword */ + *print_quality, /* print-quality option */ + *sides; /* sides option */ cups_option_t *optptr; /* Current option */ ppd_attr_t *attr; /* PPD attribute */ + _pwg_t *pwg; /* PWG mapping data */ /* @@ -93,29 +98,39 @@ cupsMarkOptions( ppd_debug_marked(ppd, "Before..."); /* - * Do special handling for media and PageSize... + * Do special handling for finishings, media, output-bin, output-mode, + * print-color-mode, print-quality, and PageSize... */ - media = cupsGetOption("media", num_options, options); - page_size = cupsGetOption("PageSize", num_options, options); + media = cupsGetOption("media", num_options, options); + output_bin = cupsGetOption("output-bin", num_options, options); + output_mode = cupsGetOption("output-mode", num_options, options); + page_size = cupsGetOption("PageSize", num_options, options); + print_quality = cupsGetOption("print-quality", num_options, options); + sides = cupsGetOption("sides", num_options, options); - if (media) + if ((media || output_bin || output_mode || print_quality || sides) && + !ppd->pwg) { /* * Load PWG mapping data as needed... */ - if (!ppd->pwg) - ppd->pwg = _pwgCreateWithPPD(ppd); + ppd->pwg = _pwgCreateWithPPD(ppd); + } + + pwg = (_pwg_t *)ppd->pwg; + if (media) + { /* - * Loop through the option string, separating it at commas and - * marking each individual option as long as the corresponding - * PPD option (PageSize, InputSlot, etc.) is not also set. + * Loop through the option string, separating it at commas and marking each + * individual option as long as the corresponding PPD option (PageSize, + * InputSlot, etc.) is not also set. * - * For PageSize, we also check for an empty option value since - * some versions of MacOS X use it to specify auto-selection - * of the media based solely on the size. + * For PageSize, we also check for an empty option value since some versions + * of MacOS X use it to specify auto-selection of the media based solely on + * the size. */ for (val = media; *val;) @@ -139,21 +154,114 @@ cupsMarkOptions( { if (!strncasecmp(s, "Custom.", 7) || ppdPageSize(ppd, s)) ppd_mark_option(ppd, "PageSize", s); - else if ((ppd_keyword = _pwgGetPageSize((_pwg_t *)ppd->pwg, NULL, s, - NULL)) != NULL) + else if ((ppd_keyword = _pwgGetPageSize(pwg, NULL, s, NULL)) != NULL) ppd_mark_option(ppd, "PageSize", ppd_keyword); } - if (!cupsGetOption("InputSlot", num_options, options) && - (ppd_keyword = _pwgGetInputSlot((_pwg_t *)ppd->pwg, NULL, s)) != NULL) - ppd_mark_option(ppd, "InputSlot", ppd_keyword); + if (pwg && pwg->source_option && + !cupsGetOption(pwg->source_option, num_options, options) && + (ppd_keyword = _pwgGetInputSlot(pwg, NULL, s)) != NULL) + ppd_mark_option(ppd, pwg->source_option, ppd_keyword); if (!cupsGetOption("MediaType", num_options, options) && - (ppd_keyword = _pwgGetMediaType((_pwg_t *)ppd->pwg, NULL, s)) != NULL) + (ppd_keyword = _pwgGetMediaType(pwg, NULL, s)) != NULL) ppd_mark_option(ppd, "MediaType", ppd_keyword); } } + if (pwg) + { + if (!cupsGetOption("com.apple.print.DocumentTicket.PMSpoolFormat", + num_options, options) && + !cupsGetOption("APPrinterPreset", num_options, options) && + (output_mode || print_quality)) + { + /* + * Map output-mode and print-quality to a preset... + */ + + _pwg_output_mode_t pwg_om; /* output-mode index */ + _pwg_print_quality_t pwg_pq; /* print-quality index */ + cups_option_t *preset;/* Current preset option */ + + if (output_mode && !strcmp(output_mode, "monochrome")) + pwg_om = _PWG_OUTPUT_MODE_MONOCHROME; + else + pwg_om = _PWG_OUTPUT_MODE_COLOR; + + if (print_quality) + { + pwg_pq = atoi(print_quality) - IPP_QUALITY_DRAFT; + if (pwg_pq < _PWG_PRINT_QUALITY_DRAFT) + pwg_pq = _PWG_PRINT_QUALITY_DRAFT; + else if (pwg_pq > _PWG_PRINT_QUALITY_HIGH) + pwg_pq = _PWG_PRINT_QUALITY_HIGH; + } + else + pwg_pq = _PWG_PRINT_QUALITY_NORMAL; + + if (pwg->num_presets[pwg_om][pwg_pq] == 0) + { + /* + * Try to find a preset that works so that we maximize the chances of us + * getting a good print using IPP attributes. + */ + + if (pwg->num_presets[pwg_om][_PWG_PRINT_QUALITY_NORMAL] > 0) + pwg_pq = _PWG_PRINT_QUALITY_NORMAL; + else if (pwg->num_presets[_PWG_OUTPUT_MODE_COLOR][pwg_pq] > 0) + pwg_om = _PWG_OUTPUT_MODE_COLOR; + else + { + pwg_pq = _PWG_PRINT_QUALITY_NORMAL; + pwg_om = _PWG_OUTPUT_MODE_COLOR; + } + } + + if (pwg->num_presets[pwg_om][pwg_pq] > 0) + { + /* + * Copy the preset options as long as the corresponding names are not + * already defined in the IPP request... + */ + + for (i = pwg->num_presets[pwg_om][pwg_pq], + preset = pwg->presets[pwg_om][pwg_pq]; + i > 0; + i --, preset ++) + { + if (!cupsGetOption(preset->name, num_options, options)) + ppd_mark_option(ppd, preset->name, preset->value); + } + } + } + + if (output_bin && !cupsGetOption("OutputBin", num_options, options) && + (ppd_keyword = _pwgGetOutputBin(pwg, output_bin)) != NULL) + { + /* + * Map output-bin to OutputBin... + */ + + ppd_mark_option(ppd, "OutputBin", ppd_keyword); + } + + if (sides && pwg->sides_option && + !cupsGetOption(pwg->sides_option, num_options, options)) + { + /* + * Map sides to duplex option... + */ + + if (!strcmp(sides, "one-sided")) + ppd_mark_option(ppd, pwg->sides_option, pwg->sides_1sided); + else if (!strcmp(sides, "two-sided-long-edge")) + ppd_mark_option(ppd, pwg->sides_option, pwg->sides_2sided_long); + else if (!strcmp(sides, "two-sided-short-edge")) + ppd_mark_option(ppd, pwg->sides_option, pwg->sides_2sided_short); + } + } + /* * Mark other options... */ @@ -162,6 +270,7 @@ cupsMarkOptions( if (!strcasecmp(optptr->name, "media") || !strcasecmp(optptr->name, "output-bin") || !strcasecmp(optptr->name, "output-mode") || + !strcasecmp(optptr->name, "print-quality") || !strcasecmp(optptr->name, "sides")) continue; else if (!strcasecmp(optptr->name, "resolution") || @@ -227,60 +336,6 @@ cupsMarkOptions( ppd_mark_choices(ppd, attr->value); } } - else if (!strcasecmp(optptr->name, "print-quality")) - { - ppd_option_t *output_mode = ppdFindOption(ppd, "OutputMode"); - /* OutputMode option */ - - if (!strcmp(optptr->value, "3")) - { - /* - * Draft quality... - */ - - if (ppdFindChoice(output_mode, "Draft")) - ppd_mark_option(ppd, "OutputMode", "Draft"); - else if (ppdFindChoice(output_mode, "Fast")) - ppd_mark_option(ppd, "OutputMode", "Fast"); - - if ((attr = ppdFindAttr(ppd, "APPrinterPreset", - "DraftGray_with_Paper_Auto-Detect")) != NULL) - ppd_mark_choices(ppd, attr->value); - } - else if (!strcmp(optptr->value, "4")) - { - /* - * Normal quality... - */ - - if (ppdFindChoice(output_mode, "Normal")) - ppd_mark_option(ppd, "OutputMode", "Normal"); - else if (ppdFindChoice(output_mode, "Good")) - ppd_mark_option(ppd, "OutputMode", "Good"); - - if ((attr = ppdFindAttr(ppd, "APPrinterPreset", - "Color_with_Paper_Auto-Detect")) != NULL) - ppd_mark_choices(ppd, attr->value); - else if ((attr = ppdFindAttr(ppd, "APPrinterPreset", - "Gray_with_Paper_Auto-Detect")) != NULL) - ppd_mark_choices(ppd, attr->value); - } - else if (!strcmp(optptr->value, "5")) - { - /* - * High/best/photo quality... - */ - - if (ppdFindChoice(output_mode, "Best")) - ppd_mark_option(ppd, "OutputMode", "Best"); - else if (ppdFindChoice(output_mode, "High")) - ppd_mark_option(ppd, "OutputMode", "High"); - - if ((attr = ppdFindAttr(ppd, "APPrinterPreset", - "Photo_on_Photo_Paper")) != NULL) - ppd_mark_choices(ppd, attr->value); - } - } else if (!strcasecmp(optptr->name, "APPrinterPreset")) { /* diff --git a/cups/ppd.c b/cups/ppd.c index bfcb2ff1c..f1d236251 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -3,7 +3,7 @@ * * PPD file routines for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -41,7 +41,6 @@ * ppd_compare_attrs() - Compare two attributes. * ppd_compare_choices() - Compare two choices... * ppd_compare_coptions() - Compare two custom options. - * ppd_compare_cparams() - Compare two custom parameters. * ppd_compare_options() - Compare two options. * ppd_decode() - Decode a string value... * ppd_free_group() - Free a single UI group. @@ -109,7 +108,6 @@ static int ppd_compare_attrs(ppd_attr_t *a, ppd_attr_t *b); static int ppd_compare_choices(ppd_choice_t *a, ppd_choice_t *b); static int ppd_compare_coptions(ppd_coption_t *a, ppd_coption_t *b); -static int ppd_compare_cparams(ppd_cparam_t *a, ppd_cparam_t *b); static int ppd_compare_options(ppd_option_t *a, ppd_option_t *b); static int ppd_decode(char *string); static void ppd_free_group(ppd_group_t *group); @@ -359,7 +357,8 @@ ppdErrorString(ppd_status_t status) /* I - PPD status */ _("Illegal whitespace character"), _("Bad custom parameter"), _("Missing option keyword"), - _("Bad value string") + _("Bad value string"), + _("Missing CloseGroup") }; @@ -1206,7 +1205,7 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */ } } - if (!name[0]) + if (!name[0] && cg->ppd_conform == PPD_CONFORM_STRICT) { /* * Found "*JobPatchFile: string"... @@ -1936,6 +1935,16 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */ _cupsStrFree(string); } + /* + * Check for a missing CloseGroup... + */ + + if (group && cg->ppd_conform == PPD_CONFORM_STRICT) + { + cg->ppd_status = PPD_MISSING_CLOSE_GROUP; + goto error; + } + ppd_free(line.buffer); /* @@ -2309,18 +2318,6 @@ ppd_compare_coptions(ppd_coption_t *a, /* I - First option */ } -/* - * 'ppd_compare_cparams()' - Compare two custom parameters. - */ - -static int /* O - Result of comparison */ -ppd_compare_cparams(ppd_cparam_t *a, /* I - First parameter */ - ppd_cparam_t *b) /* I - Second parameter */ -{ - return (strcasecmp(a->name, b->name)); -} - - /* * 'ppd_compare_options()' - Compare two options. */ @@ -2476,7 +2473,7 @@ ppd_get_coption(ppd_file_t *ppd, /* I - PPD file */ strlcpy(copt->keyword, name, sizeof(copt->keyword)); - copt->params = cupsArrayNew((cups_array_func_t)ppd_compare_cparams, NULL); + copt->params = cupsArrayNew((cups_array_func_t)NULL, NULL); cupsArrayAdd(ppd->coptions, copt); diff --git a/cups/ppd.h b/cups/ppd.h index 42c08df33..1b00ae455 100644 --- a/cups/ppd.h +++ b/cups/ppd.h @@ -3,7 +3,7 @@ * * PostScript Printer Description definitions for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -118,6 +118,7 @@ typedef enum ppd_status_e /**** Status Codes @since CUPS 1.1.19/Mac OS X 10.3@ PPD_BAD_CUSTOM_PARAM, /* Bad custom parameter */ PPD_MISSING_OPTION_KEYWORD, /* Missing option keyword */ PPD_BAD_VALUE, /* Bad value string */ + PPD_MISSING_CLOSE_GROUP, /* Missing CloseGroup */ PPD_MAX_STATUS /* @private@ */ } ppd_status_t; diff --git a/cups/pwg-ppd.c b/cups/pwg-ppd.c index 1bfd26d9e..777ee07db 100644 --- a/cups/pwg-ppd.c +++ b/cups/pwg-ppd.c @@ -1015,55 +1015,59 @@ _pwgGetPageSize(_pwg_t *pwg, /* I - PWG mapping data */ closest = NULL; dclosest = 999999999; - for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++) + if (!ppd_name || strncasecmp(ppd_name, "Custom.", 7) || + strncasecmp(ppd_name, "custom_", 7)) { - /* - * Adobe uses a size matching algorithm with an epsilon of 5 points, which - * is just about 176/2540ths... - */ - - dwidth = size->width - jobsize.width; - dlength = size->length - jobsize.length; - - if (dwidth <= -176 || dwidth >= 176 || dlength <= -176 || dlength >= 176) - continue; - - if (margins_set) + for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++) { /* - * Use a tighter epsilon of 1 point (35/2540ths) for margins... + * Adobe uses a size matching algorithm with an epsilon of 5 points, which + * is just about 176/2540ths... */ - dleft = size->left - jobsize.left; - dright = size->right - jobsize.right; - dtop = size->top - jobsize.top; - dbottom = size->bottom - jobsize.bottom; + dwidth = size->width - jobsize.width; + dlength = size->length - jobsize.length; + + if (dwidth <= -176 || dwidth >= 176 || dlength <= -176 || dlength >= 176) + continue; - if (dleft <= -35 || dleft >= 35 || dright <= -35 || dright >= 35 || - dtop <= -35 || dtop >= 35 || dbottom <= -35 || dbottom >= 35) + if (margins_set) { - dleft = dleft < 0 ? -dleft : dleft; - dright = dright < 0 ? -dright : dright; - dbottom = dbottom < 0 ? -dbottom : dbottom; - dtop = dtop < 0 ? -dtop : dtop; - dmin = dleft + dright + dbottom + dtop; + /* + * Use a tighter epsilon of 1 point (35/2540ths) for margins... + */ - if (dmin < dclosest) + dleft = size->left - jobsize.left; + dright = size->right - jobsize.right; + dtop = size->top - jobsize.top; + dbottom = size->bottom - jobsize.bottom; + + if (dleft <= -35 || dleft >= 35 || dright <= -35 || dright >= 35 || + dtop <= -35 || dtop >= 35 || dbottom <= -35 || dbottom >= 35) { - dclosest = dmin; - closest = size; - } + dleft = dleft < 0 ? -dleft : dleft; + dright = dright < 0 ? -dright : dright; + dbottom = dbottom < 0 ? -dbottom : dbottom; + dtop = dtop < 0 ? -dtop : dtop; + dmin = dleft + dright + dbottom + dtop; - continue; + if (dmin < dclosest) + { + dclosest = dmin; + closest = size; + } + + continue; + } } - } - if (exact) - *exact = 1; + if (exact) + *exact = 1; - DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\"", size->map.ppd)); + DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\"", size->map.ppd)); - return (size->map.ppd); + return (size->map.ppd); + } } if (closest) diff --git a/cups/request.c b/cups/request.c index df2c0137c..31b316cb3 100644 --- a/cups/request.c +++ b/cups/request.c @@ -638,10 +638,23 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP */ httpClearFields(http); - httpSetLength(http, length); + httpSetExpect(http, expect); httpSetField(http, HTTP_FIELD_CONTENT_TYPE, "application/ipp"); + httpSetLength(http, length); + +#ifdef HAVE_GSSAPI + if (http->authstring && !strncmp(http->authstring, "Negotiate", 9)) + { + /* + * Do not use cached Kerberos credentials since they will look like a + * "replay" attack... + */ + + cupsDoAuthentication(http, "POST", resource); + } + else +#endif /* HAVE_GSSAPI */ httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring); - httpSetExpect(http, expect); DEBUG_printf(("2cupsSendRequest: authstring=\"%s\"", http->authstring)); diff --git a/cups/testi18n.c b/cups/testi18n.c index fa5491970..3188c78f9 100644 --- a/cups/testi18n.c +++ b/cups/testi18n.c @@ -3,7 +3,7 @@ * * Internationalization test for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2011 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -423,6 +423,7 @@ main(int argc, /* I - Argument Count */ puts("PASS"); } +#ifndef __linux fputs("cupsCharsetToUTF8(CUPS_EUC_JP): ", stdout); strcpy(legsrc, legdest); @@ -444,6 +445,7 @@ main(int argc, /* I - Argument Count */ } else puts("PASS"); +#endif /* !__linux */ /* * Test UTF-8 to/from legacy charset (Windows 950)... diff --git a/doc/Makefile b/doc/Makefile index 4978deff0..0e4688474 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,9 +1,9 @@ # # "$Id: Makefile 7941 2008-09-16 00:46:13Z mike $" # -# Documentation makefile for the Common UNIX Printing System (CUPS). +# Documentation makefile for CUPS. # -# Copyright 2007-2009 by Apple Inc. +# Copyright 2007-2011 by Apple Inc. # Copyright 1997-2007 by Easy Software Products. # # These coded instructions, statements, and computer programs are the @@ -40,6 +40,8 @@ HELPIMAGES = \ images/cups-postscript-chain.png \ images/cups-raster-chain.png \ images/raster.png \ + images/raster-organization.png \ + images/sample-image.png \ images/smiley.jpg HELPFILES = \ help/accounting.html \ diff --git a/doc/cups.css b/doc/cups.css index 4d76d6332..815c193c3 100644 --- a/doc/cups.css +++ b/doc/cups.css @@ -117,7 +117,9 @@ TD.unsel { TD.sel A, TD.sel A:hover, TD.unsel A:link:hover, TD.unsel A:visited:hover, TD.unsel A:active, TD.unsel A, TD.unsel A:visited { color: #666666; + display: block; font-weight: normal; + padding: 8px; text-decoration: none; } diff --git a/doc/de/index.html.in b/doc/de/index.html.in index 6ca957e32..a73d77179 100644 --- a/doc/de/index.html.in +++ b/doc/de/index.html.in @@ -101,7 +101,7 @@ HEIGHT="128" ALT="CUPS">   CUPS und das CUPS Logo sind eingetragene Warenzeichen der Apple Inc. -CUPS ist urheberrechtlich geschützt 2007-2010 von Apple Inc, alle Rechte vorbehalten. +CUPS ist urheberrechtlich geschützt 2007-2011 von Apple Inc, alle Rechte vorbehalten. diff --git a/doc/es/index.html.in b/doc/es/index.html.in index da71c5442..5afb0d0c0 100644 --- a/doc/es/index.html.in +++ b/doc/es/index.html.in @@ -101,7 +101,7 @@ HEIGHT="128" ALT="CUPS">   CUPS y el logo de CUPS son marcas registradas de Apple Inc. Los derechos -de copia de CUPS 2007-2010 son de Apple Inc. Todos los derechos reservados. +de copia de CUPS 2007-2011 son de Apple Inc. Todos los derechos reservados. diff --git a/doc/eu/index.html.in b/doc/eu/index.html.in index 0408c3884..42780f9af 100644 --- a/doc/eu/index.html.in +++ b/doc/eu/index.html.in @@ -100,7 +100,7 @@ HEIGHT="128" ALT="CUPS">   CUPS eta CUPSen logotipoa Apple Inc.en marka erregistratuaj dira. -CUPSen copyright-a 2007-2010 Apple Inc. Eskubide guztiak gordeta. +CUPSen copyright-a 2007-2011 Apple Inc. Eskubide guztiak gordeta. diff --git a/doc/help/api-array.html b/doc/help/api-array.html index 2b47b3e13..6c57c13e4 100644 --- a/doc/help/api-array.html +++ b/doc/help/api-array.html @@ -2,9 +2,10 @@ -Array API - - + Array API + + +