From 6961465fb290ecc4f99b4e3a8225d594782d15f5 Mon Sep 17 00:00:00 2001 From: msweet Date: Tue, 9 Apr 2013 20:10:23 +0000 Subject: [PATCH] Merge changes from CUPS 1.7b1-r10947. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@4274 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.6.txt | 23 +- CHANGES.txt | 17 +- INSTALL.txt | 24 +- README.txt | 2 +- backend/ipp.c | 53 ++- backend/usb-darwin.c | 34 +- backend/usb-libusb.c | 2 +- config-scripts/cups-common.m4 | 17 +- config-scripts/cups-directories.m4 | 23 +- config.h.in | 1 + cups/Makefile | 13 +- cups/auth.c | 25 +- cups/cups-private.h | 8 +- cups/cups.h | 26 +- cups/dest-job.c | 6 + cups/dest-options.c | 628 ++++++++++++++++++++++++--- cups/dest.c | 4 +- cups/http-addr.c | 2 +- cups/http-addrlist.c | 4 +- cups/http-support.c | 7 + cups/http.c | 83 ++-- cups/ipp-support.c | 41 +- cups/ipp.c | 153 ++++++- cups/ipp.h | 24 +- cups/ppd-cache.c | 142 +++--- cups/ppd-private.h | 16 +- cups/pwg-media.c | 458 ++++++++++++------- cups/pwg-private.h | 67 +-- cups/pwg.h | 94 ++++ cups/request.c | 3 +- cups/testhttp.c | 4 + cups/testpwg.c | 40 +- cups/usersys.c | 31 +- doc/help/api-cups.html | 440 ++++++++++++++++++- doc/help/api-httpipp.html | 117 ++++- doc/help/whatsnew.html | 28 +- locale/cups.pot | 436 ++++++++++--------- locale/cups.strings | 2 + locale/cups_ca.po | 8 +- locale/cups_es.po | 8 +- locale/cups_fr.po | 8 +- locale/cups_ja.po | 8 +- locale/cups_ru.po | 8 +- scheduler/Makefile | 8 + scheduler/auth.c | 27 +- scheduler/client.c | 72 ++- scheduler/conf.c | 6 +- scheduler/cups-exec.c | 2 +- scheduler/cupsfilter.c | 45 +- scheduler/ipp.c | 21 +- scheduler/job.c | 112 +++-- scheduler/printers.c | 22 +- systemv/cupstestppd.c | 10 +- test/Makefile | 3 +- test/ipptool.c | 4 + test/validate-job.test | 23 + xcode/CUPS.xcodeproj/project.pbxproj | 3 + 57 files changed, 2635 insertions(+), 861 deletions(-) create mode 100644 cups/pwg.h create mode 100644 test/validate-job.test diff --git a/CHANGES-1.6.txt b/CHANGES-1.6.txt index f0794e2b6..6d94e5e03 100644 --- a/CHANGES-1.6.txt +++ b/CHANGES-1.6.txt @@ -1,6 +1,24 @@ CHANGES-1.6.txt --------------- +CHANGES IN CUPS V1.6.3 + + - The configure script now prefers Clang over GCC. + - Fixed a compile problem on AIX (STR #4307) + - The Russian web interface templates were broken (STR #4310) + - The scheduler no longer tries to do Kerberos authentication over the + loopback interface. + - The IPP backend could fail to pause a job for authentication + (STR #4298) + - Fixed a regression on the handling of auth keys on OS X if the + cups-files.conf was not present or did not contain a SystemAuthKey + value. + - The scheduler incorrectly did a reverse lookup of the server address + when HostNameLookups was turned off (STR #4302) + - The scheduler incorrectly computed the final content type value when + null filters were present. + + CHANGES IN CUPS V1.6.2 - Documentation fixes (STR #4229, STR #4239, STR #4234, STR #4248, @@ -12,6 +30,9 @@ CHANGES IN CUPS V1.6.2 - Added a French localization (STR #4247) - Added a Russian localization (STR #4228, STR #4285) - Updated the Catalan localization (STR #4202) + - Local certificate authentication did not guard against an empty + certification file (STR #4293) + - The scheduler did not reject device URIs with spaces. - Added USB quirk rule for Epson Stylus Photo 750 (STR #4286) - The IPP backend could crash if the printer disconnects early (STR #4284) @@ -47,7 +68,7 @@ CHANGES IN CUPS V1.6.2 - The scheduler incorrectly advertised auth-info-required for local queues needing local authentication (STR #4205) - CUPS 1.6 clients using the ServerName directive in client.conf did not - work with CUPS 1.3.x or older servers (STR #4231) + work with CUPS 1.3.x or older servers (STR #4231, STR #4291) - The SNMP backend now tries to work around broken printers that use a newline to separate key/value pairs. - The IPP backend did not send a cancel request to printers when a job diff --git a/CHANGES.txt b/CHANGES.txt index 40b67344c..f85fc21ce 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,24 @@ -CHANGES.txt - 1.7b1 - 2013-01-30 +CHANGES.txt - 1.7b1 - 2013-04-09 -------------------------------- CHANGES IN CUPS V1.7b1 + - The configure script now supports a --with-rundir option to change + the transient run-time state directory from the default to other + locations like /run/cups (STR #4306) + - The scheduler now supports PPD lookups for classes (STR #4296) + - The cupsfilter program did not set the FINAL_CONTENT_TYPE + environment variable for filters. - Added a new "-x" option to the cancel command (STR #4103) + - Made the PWG media handling APIs public (STR #4267) + - Implemented ready media support for the cupsGetDestMediaXxx APIs + (STR #4289) + - Added new cupsFindDestDefault, cupsFindDestReady, and + cupsFindDestSupported APIs (STR #4289) + - Added new cupsGetDestMediaByIndex, cupsGetDestMediaCount, and + cupsGetDestMediaDefault APIs (STR #4289) + - Added new ippGet/SetOctetString APIs for getting and setting an + octetString value (STR #4289) - Added new ippCreateRequestedArray API for generating a array of attributes from the requested-attributes attribute. - The ipptool utility now supports compression, conditional tests based diff --git a/INSTALL.txt b/INSTALL.txt index e5081eace..1295bbc29 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -1,4 +1,4 @@ -INSTALL - CUPS v1.7b1 - 2013-01-11 +INSTALL - CUPS v1.7b1 - 2013-04-09 ---------------------------------- This file describes how to compile and install CUPS from source code. For more @@ -29,18 +29,16 @@ BEFORE YOU BEGIN Compaq, HP, SGI, and Sun. BSD users should use GNU make (gmake) since BSD make does not support "include". - Besides these tools you'll want the JPEG, PNG, TIFF, and ZLIB libraries for - image support, the CDSA, GNU TLS, or OpenSSL libraries for encryption - support, the OpenLDAP and OpenSLP libraries for directory services support, - and either MIT (1.6.3 or higher) or Heimdal Kerberos for Kerberos support. - CUPS will compile and run without these, however you'll miss out on many of - the features provided by CUPS. - - Also, please note that CUPS does not include the Ghostscript-based - PostScript filter needed by non-PostScript printers. You *must* download - GPL Ghostscript separately from the CUPS web site if you want to print - PostScript files to non-PostScript printers on operating systems other than - OS X. + Besides these tools you'll want ZLIB library for compression support, the + CDSA, GNU TLS, or OpenSSL libraries for encryption support, and either MIT + (1.6.3 or higher) or Heimdal Kerberos for Kerberos support. CUPS will + compile and run without these, however you'll miss out on many of the + features provided by CUPS. + + Also, please note that CUPS does not include print filters to support PDF + or raster printing. You *must* download GPL Ghostscript and/or the Open + Printing CUPS filters package separately to print on operating systems + other than OS X. COMPILING THE SUBVERSION REPOSITORY CODE diff --git a/README.txt b/README.txt index 824d286f4..4792fe5ad 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -README - CUPS v1.7b1 - 2013-01-11 +README - CUPS v1.7b1 - 2013-04-09 --------------------------------- ************************************************ diff --git a/backend/ipp.c b/backend/ipp.c index c9f7305b9..85029a69b 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -115,8 +115,6 @@ static char username[256] = "", /* Username for device URI */ *password = NULL; /* Password for device URI */ -static int password_tries = 0; - /* Password tries */ static const char * const pattrs[] = /* Printer attributes we want */ { #ifdef HAVE_LIBZ @@ -185,7 +183,7 @@ static ipp_t *new_request(ipp_op_t op, int version, const char *uri, int print_color_mode); static const char *password_cb(const char *prompt, http_t *http, const char *method, const char *resource, - void *user_data); + int *user_data); static const char *quote_string(const char *s, char *q, size_t qsize); static void report_attr(ipp_attribute_t *attr); static void report_printer_state(ipp_t *ipp); @@ -223,6 +221,7 @@ main(int argc, /* I - Number of command-line args */ *name, /* Name of option */ *value, /* Value of option */ sep; /* Separator character */ + int password_tries = 0; /* Password tries */ http_addrlist_t *addrlist; /* Address of printer */ int snmp_enabled = 1; /* Is SNMP enabled? */ int snmp_fd, /* SNMP socket */ @@ -635,7 +634,7 @@ main(int argc, /* I - Number of command-line args */ * Set the authentication info, if any... */ - cupsSetPasswordCB2(password_cb, NULL); + cupsSetPasswordCB2((cups_password_cb2_t)password_cb, &password_tries); if (username[0]) { @@ -1603,6 +1602,7 @@ main(int argc, /* I - Number of command-line args */ } else if (ipp_status == IPP_STATUS_ERROR_JOB_CANCELED || ipp_status == IPP_STATUS_ERROR_NOT_AUTHORIZED || + ipp_status == IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES || ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_INFO_NEEDED || ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_CLOSED || ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_LIMIT_REACHED || @@ -1887,6 +1887,9 @@ main(int argc, /* I - Number of command-line args */ check_printer_state(http, uri, resource, argv[2], version); + if (cupsLastError() <= IPP_OK_CONFLICT) + password_tries = 0; + /* * Build an IPP_GET_JOB_ATTRIBUTES request... */ @@ -2037,6 +2040,9 @@ main(int argc, /* I - Number of command-line args */ check_printer_state(http, uri, resource, argv[2], version); + if (cupsLastError() <= IPP_OK_CONFLICT) + password_tries = 0; + /* * Collect the final page count as needed... */ @@ -2096,17 +2102,19 @@ main(int argc, /* I - Number of command-line args */ fputs("JOBSTATE: account-authorization-failed\n", stderr); if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN || - ipp_status == IPP_AUTHENTICATION_CANCELED || - ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_INFO_NEEDED || - ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_CLOSED || - ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_LIMIT_REACHED || - ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED) + ipp_status == IPP_AUTHENTICATION_CANCELED) return (CUPS_BACKEND_AUTH_REQUIRED); + else if (ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_LIMIT_REACHED || + ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_INFO_NEEDED || + ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_CLOSED || + ipp_status == IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED) + return (CUPS_BACKEND_HOLD); else if (ipp_status == IPP_INTERNAL_ERROR) return (CUPS_BACKEND_STOP); else if (ipp_status == IPP_CONFLICT) return (CUPS_BACKEND_FAILED); else if (ipp_status == IPP_REQUEST_VALUE || + ipp_status == IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES || ipp_status == IPP_DOCUMENT_FORMAT || job_canceled < 0) { if (ipp_status == IPP_REQUEST_VALUE) @@ -2114,6 +2122,9 @@ main(int argc, /* I - Number of command-line args */ else if (ipp_status == IPP_DOCUMENT_FORMAT) _cupsLangPrintFilter(stderr, "ERROR", _("Printer cannot print supplied content.")); + else if (ipp_status == IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES) + _cupsLangPrintFilter(stderr, "ERROR", + _("Printer cannot print with supplied options.")); else _cupsLangPrintFilter(stderr, "ERROR", _("Print job canceled at printer.")); @@ -2218,9 +2229,6 @@ check_printer_state( fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n", ippErrorString(cupsLastError()), cupsLastErrorString()); - if (cupsLastError() <= IPP_OK_CONFLICT) - password_tries = 0; - /* * Return the printer-state value... */ @@ -2248,6 +2256,7 @@ monitor_printer( const char *job_name; /* Job name */ ipp_jstate_t job_state; /* Job state */ const char *job_user; /* Job originating user name */ + int password_tries = 0; /* Password tries */ /* @@ -2259,7 +2268,8 @@ monitor_printer( httpSetTimeout(http, 30.0, timeout_cb, NULL); if (username[0]) cupsSetUser(username); - cupsSetPasswordCB2(password_cb, NULL); + + cupsSetPasswordCB2((cups_password_cb2_t)password_cb, &password_tries); /* * Loop until the job is canceled, aborted, or completed. @@ -2285,6 +2295,8 @@ monitor_printer( monitor->resource, monitor->user, monitor->version); + if (cupsLastError() <= IPP_OK_CONFLICT) + password_tries = 0; /* * Check the status of the job itself... @@ -2595,7 +2607,7 @@ new_request( ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-account-id", NULL, keyword); - if (pc->account_id && + if (pc->accounting_user_id && (keyword = cupsGetOption("job-accounting-user-id", num_options, options)) != NULL) ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, @@ -2927,18 +2939,19 @@ password_cb(const char *prompt, /* I - Prompt (not used) */ http_t *http, /* I - Connection */ const char *method, /* I - Request method (not used) */ const char *resource, /* I - Resource path (not used) */ - void *user_data) /* I - User data (not used) */ + int *password_tries) /* I - Password tries */ { char def_username[HTTP_MAX_VALUE]; /* Default username */ - fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\"), password=%p, " - "password_tries=%d\n", prompt, password, password_tries); + fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\", http=%p, method=\"%s\", " + "resource=\"%s\", password_tries=%p(%d)), password=%p\n", + prompt, http, method, resource, password_tries, *password_tries, + password); (void)prompt; (void)method; (void)resource; - (void)user_data; /* * Remember that we need to authenticate... @@ -2956,9 +2969,9 @@ password_cb(const char *prompt, /* I - Prompt (not used) */ quote_string(def_username, quoted, sizeof(quoted))); } - if (password && *password && password_tries < 3) + if (password && *password && *password_tries < 3) { - password_tries ++; + (*password_tries) ++; return (password); } diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c index 509bb89f0..2b423c2a4 100644 --- a/backend/usb-darwin.c +++ b/backend/usb-darwin.c @@ -1603,11 +1603,12 @@ static kern_return_t registry_close(void) static OSStatus copy_deviceid(classdriver_t **classdriver, CFStringRef *deviceID) { - CFStringRef devID = NULL, - - deviceMake = NULL, - deviceModel = NULL, - deviceSerial = NULL; + CFStringRef devID = NULL; + CFStringRef deviceMake = NULL; + CFStringRef deviceModel = NULL; + CFStringRef deviceSerial = NULL; + + *deviceID = NULL; OSStatus err = (*classdriver)->GetDeviceID(classdriver, &devID, DEFAULT_TIMEOUT); @@ -1653,12 +1654,10 @@ static OSStatus copy_deviceid(classdriver_t **classdriver, if (deviceSerial == NULL && desc.iSerialNumber != 0) { - CFStringRef data = NULL; - err = (*classdriver)->GetString(classdriver, desc.iSerialNumber, kUSBLanguageEnglish, DEFAULT_TIMEOUT, &data); - if (data != NULL) + err = (*classdriver)->GetString(classdriver, desc.iSerialNumber, kUSBLanguageEnglish, DEFAULT_TIMEOUT, &deviceSerial); + if (deviceSerial != NULL) { - CFStringAppendFormat(newDevID, NULL, CFSTR("SERN:%@;"), data); - CFRelease(data); + CFStringAppendFormat(newDevID, NULL, CFSTR("SERN:%@;"), deviceSerial); } } @@ -1675,6 +1674,21 @@ static OSStatus copy_deviceid(classdriver_t **classdriver, { *deviceID = devID; } + + if (*deviceID == NULL) + return err; + + /* Remove special characters from the serial number */ + CFRange range = (deviceSerial != NULL ? CFStringFind(deviceSerial, CFSTR("+"), 0) : CFRangeMake(0, 0)); + if (range.length == 1) { + range = CFStringFind(*deviceID, deviceSerial, 0); + + CFMutableStringRef deviceIDString = CFStringCreateMutableCopy(NULL, 0, *deviceID); + CFStringFindAndReplace(deviceIDString, CFSTR("+"), CFSTR(""), range, 0); + CFRelease(*deviceID); + *deviceID = deviceIDString; + } + release_deviceinfo(&deviceMake, &deviceModel, &deviceSerial); return err; diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index 44e71e7b7..4c71e6586 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -122,7 +122,7 @@ struct quirk_printer_struct { #define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */ #define USBLP_QUIRK_BAD_CLASS 0x4 /* descriptor uses vendor-specific Class or SubClass */ -#define USBLP_QUICK_BLACKLIST 0x8 /* these printers do not conform to the USB print spec */ +#define USBLP_QUIRK_BLACKLIST 0x8 /* these printers do not conform to the USB print spec */ #define USBLP_QUIRK_RESET 0x4000 /* After printing do a reset for clean-up */ #define USBLP_QUIRK_NO_REATTACH 0x8000 /* After printing we cannot re-attach diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index fbc5de72a..6a30e4809 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -20,11 +20,11 @@ dnl Set the name of the config header file... AC_CONFIG_HEADER(config.h) dnl Version number information... -CUPS_VERSION="1.7svn" +CUPS_VERSION="1.7b1" CUPS_REVISION="" -if test -z "$CUPS_REVISION" -a -d .svn; then - CUPS_REVISION="-r`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[[a-zA-Z]]*//g'`" -fi +#if test -z "$CUPS_REVISION" -a -d .svn; then +# CUPS_REVISION="-r`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[[a-zA-Z]]*//g'`" +#fi CUPS_BUILD="cups-$CUPS_VERSION" AC_ARG_WITH(cups_build, [ --with-cups-build set "cups-config --build" string ], @@ -44,9 +44,9 @@ LDFLAGS="${LDFLAGS:=}" dnl Checks for programs... AC_PROG_AWK -AC_PROG_CC +AC_PROG_CC(clang cc gcc) AC_PROG_CPP -AC_PROG_CXX +AC_PROG_CXX(clang++ c++ g++) AC_PROG_RANLIB AC_PATH_PROG(AR,ar) AC_PATH_PROG(CHMOD,chmod) @@ -338,6 +338,7 @@ AC_SUBST(DBUS_NOTIFIERLIBS) dnl Extra platform-specific libraries... CUPS_DEFAULT_PRINTOPERATOR_AUTH="@SYSTEM" +CUPS_DEFAULT_SYSTEM_AUTHKEY="" CUPS_SYSTEM_AUTHKEY="" INSTALLXPC="" @@ -385,10 +386,13 @@ case $uname in if test "x$default_adminkey" != xdefault; then CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey" + CUPS_DEFAULT_SYSTEM_AUTHKEY="$default_adminkey" elif grep -q system.print.operator /etc/authorization; then CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin" + CUPS_DEFAULT_SYSTEM_AUTHKEY="system.print.admin" else CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences" + CUPS_DEFAULT_SYSTEM_AUTHKEY="system.preferences" fi if test "x$default_operkey" != xdefault; then @@ -426,6 +430,7 @@ esac AC_SUBST(CUPS_DEFAULT_PRINTOPERATOR_AUTH) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTOPERATOR_AUTH, "$CUPS_DEFAULT_PRINTOPERATOR_AUTH") +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_SYSTEM_AUTHKEY, "$CUPS_DEFAULT_SYSTEM_AUTHKEY") AC_SUBST(CUPS_SYSTEM_AUTHKEY) AC_SUBST(INSTALLXPC) diff --git a/config-scripts/cups-directories.m4 b/config-scripts/cups-directories.m4 index e6ab4e97b..eec3dec02 100644 --- a/config-scripts/cups-directories.m4 +++ b/config-scripts/cups-directories.m4 @@ -3,7 +3,7 @@ dnl "$Id: cups-directories.m4 7799 2008-07-25 20:06:08Z mike $" dnl dnl Directory stuff for CUPS. dnl -dnl Copyright 2007-2012 by Apple Inc. +dnl Copyright 2007-2013 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 @@ -412,16 +412,17 @@ AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$sysconfdir/cups") AC_SUBST(CUPS_SERVERROOT) # Transient run-time state -case "$uname" in - Darwin*) - # Darwin (OS X) - CUPS_STATEDIR="$CUPS_SERVERROOT" - ;; - *) - # All others - CUPS_STATEDIR="$localstatedir/run/cups" - ;; -esac +AC_ARG_WITH(rundir, [ --with-rundir set transient run-time state directory],CUPS_STATEDIR="$withval",[ + case "$uname" in + Darwin*) + # Darwin (OS X) + CUPS_STATEDIR="$CUPS_SERVERROOT" + ;; + *) + # All others + CUPS_STATEDIR="$localstatedir/run/cups" + ;; + esac]) AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$CUPS_STATEDIR") AC_SUBST(CUPS_STATEDIR) diff --git a/config.h.in b/config.h.in index f8dbf4199..3aa648210 100644 --- a/config.h.in +++ b/config.h.in @@ -32,6 +32,7 @@ #define CUPS_DEFAULT_GROUP "sys" #define CUPS_DEFAULT_SYSTEM_GROUPS "sys root system" #define CUPS_DEFAULT_PRINTOPERATOR_AUTH "@SYSTEM" +#define CUPS_DEFAULT_SYSTEM_AUTHKEY "system.print.admin" /* diff --git a/cups/Makefile b/cups/Makefile index 063e194a5..f1c3a336f 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -113,6 +113,7 @@ HEADERS = \ ipp.h \ language.h \ ppd.h \ + pwg.h \ raster.h \ sidechannel.h \ transcode.h \ @@ -200,6 +201,14 @@ depend: $(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies +# +# Run oclint to check code coverage... +# + +oclint: + oclint -o=oclint.html -html $(LIBOBJS:.o=.c) -- $(ALL_CFLAGS) + + # # Install all targets... # @@ -527,8 +536,8 @@ apihelp: --css ../doc/cups-printable.css \ --header api-cups.header --intro api-cups.shtml \ api-cups.xml \ - cups.h adminutil.c dest*.c language.c notify.c \ - options.c tempfile.c usersys.c \ + cups.h pwg.h adminutil.c dest*.c language.c notify.c \ + options.c pwg-media.c tempfile.c usersys.c \ util.c >../doc/help/api-cups.html mxmldoc --tokens help/api-cups.html api-cups.xml >../doc/help/api-cups.tokens $(RM) api-cups.xml diff --git a/cups/auth.c b/cups/auth.c index bcbfef250..b0d2d1dd1 100644 --- a/cups/auth.c +++ b/cups/auth.c @@ -667,8 +667,7 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */ int pid; /* Current process ID */ FILE *fp; /* Certificate file */ char trc[16], /* Try Root Certificate parameter */ - filename[1024], /* Certificate filename */ - certificate[33];/* Certificate string */ + filename[1024]; /* Certificate filename */ _cups_globals_t *cg = _cupsGlobals(); /* Global data */ # if defined(HAVE_AUTHORIZATION_H) OSStatus status; /* Status */ @@ -862,19 +861,25 @@ cups_local_auth(http_t *http) /* I - HTTP connection to server */ * Read the certificate from the file... */ - fgets(certificate, sizeof(certificate), fp); + char certificate[33], /* Certificate string */ + *certptr; /* Pointer to certificate string */ + + certptr = fgets(certificate, sizeof(certificate), fp); fclose(fp); - /* - * Set the authorization string and return... - */ + if (certptr) + { + /* + * Set the authorization string and return... + */ - httpSetAuthString(http, "Local", certificate); + httpSetAuthString(http, "Local", certificate); - DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"", - http->authstring)); + DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"", + http->authstring)); - return (0); + return (0); + } } return (1); diff --git a/cups/cups-private.h b/cups/cups-private.h index bf96201f7..6d68be444 100644 --- a/cups/cups-private.h +++ b/cups/cups-private.h @@ -131,7 +131,7 @@ typedef struct _cups_globals_s /**** CUPS global state data ****/ cups_array_t *leg_size_lut, /* Lookup table for legacy names */ *ppd_size_lut, /* Lookup table for PPD names */ *pwg_size_lut; /* Lookup table for PWG names */ - _pwg_media_t pwg_media; /* PWG media data for custom size */ + pwg_media_t pwg_media; /* PWG media data for custom size */ char pwg_name[65]; /* PWG media name for custom size */ /* request.c */ @@ -207,6 +207,7 @@ typedef struct _cups_dconstres_s /* Constraint/resolver */ struct _cups_dinfo_s /* Destination capability and status * information */ { + int version; /* IPP version */ const char *uri; /* Printer URI */ char *resource; /* Resource path */ ipp_t *attrs; /* Printer attributes */ @@ -218,6 +219,11 @@ struct _cups_dinfo_s /* Destination capability and status cups_array_t *media_db; /* Media database */ _cups_media_db_t min_size, /* Minimum size */ max_size; /* Maximum size */ + unsigned cached_flags; /* Flags used for cached media */ + cups_array_t *cached_db; /* Cache of media from last index/default */ + time_t ready_time; /* When xxx-ready attributes were last queried */ + ipp_t *ready_attrs; /* xxx-ready attributes */ + cups_array_t *ready_db; /* media[-col]-ready media database */ }; diff --git a/cups/cups.h b/cups/cups.h index 5254c28c7..fd1ced1f5 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -3,7 +3,7 @@ * * API definitions for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -37,6 +37,7 @@ typedef off_t ssize_t; /* @private@ */ # include "file.h" # include "ipp.h" # include "language.h" +# include "pwg.h" /* @@ -591,6 +592,29 @@ extern http_status_t cupsStartDestDocument(http_t *http, cups_dest_t *dest, int last_document) _CUPS_API_1_6; /* New in CUPS 1.7 */ +extern ipp_attribute_t *cupsFindDestDefault(http_t *http, cups_dest_t *dest, + cups_dinfo_t *dinfo, + const char *option) _CUPS_API_1_7; +extern ipp_attribute_t *cupsFindDestReady(http_t *http, cups_dest_t *dest, + cups_dinfo_t *dinfo, + const char *option) _CUPS_API_1_7; +extern ipp_attribute_t *cupsFindDestSupported(http_t *http, cups_dest_t *dest, + cups_dinfo_t *dinfo, + const char *option) + _CUPS_API_1_7; +extern int cupsGetDestMediaByIndex(http_t *http, cups_dest_t *dest, + cups_dinfo_t *dinfo, int n, + unsigned flags, + cups_size_t *size) + _CUPS_API_1_7; +extern int cupsGetDestMediaCount(http_t *http, cups_dest_t *dest, + cups_dinfo_t *dinfo, + unsigned flags) _CUPS_API_1_7; +extern int cupsGetDestMediaDefault(http_t *http, cups_dest_t *dest, + cups_dinfo_t *dinfo, + unsigned flags, + cups_size_t *size) + _CUPS_API_1_7; extern void cupsSetUserAgent(const char *user_agent) _CUPS_API_1_7; extern const char *cupsUserAgent(void) _CUPS_API_1_7; diff --git a/cups/dest-job.c b/cups/dest-job.c index 9131b3ca4..85009faec 100644 --- a/cups/dest-job.c +++ b/cups/dest-job.c @@ -112,6 +112,8 @@ cupsCloseDestJob( return (IPP_STATUS_ERROR_INTERNAL); } + ippSetVersion(request, info->version / 10, info->version % 10); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, info->uri); ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", @@ -189,6 +191,8 @@ cupsCreateDestJob( return (IPP_STATUS_ERROR_INTERNAL); } + ippSetVersion(request, info->version / 10, info->version % 10); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, info->uri); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", @@ -327,6 +331,8 @@ cupsStartDestDocument( return (HTTP_STATUS_ERROR); } + ippSetVersion(request, info->version / 10, info->version % 10); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, info->uri); ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id); diff --git a/cups/dest-options.c b/cups/dest-options.c index 873d2e2cd..5201302a8 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -21,14 +21,26 @@ * option/value pair. * cupsCopyDestInfo() - Get the supported values/capabilities for the * destination. + * cupsFindDestDefault() - Find the default value(s) for the given + * option. + * cupsFindDestReady() - Find the default value(s) for the given + * option. + * cupsFindDestSupported() - Find the default value(s) for the given + * option. * cupsFreeDestInfo() - Free destination information obtained using * @link cupsCopyDestInfo@. + * cupsGetDestMediaByIndex() - Get a media name, dimension, and margins for a + * specific size. * cupsGetDestMediaByName() - Get media names, dimensions, and margins. * cupsGetDestMediaBySize() - Get media names, dimensions, and margins. + * cupsGetDestMediaCount() - Get the number of sizes supported by a + * destination. + * cupsGetDestMediaDefault() - Get the default size for a destination. * cups_add_dconstres() - Add a constraint or resolver to an array. * cups_compare_dconstres() - Compare to resolver entries. * cups_compare_media_db() - Compare two media entries. * cups_copy_media_db() - Copy a media entry. + * cups_create_cached() - Create the media selection cache. * cups_create_constraints() - Create the constraints and resolvers arrays. * cups_create_defaults() - Create the -default option array. * cups_create_media_db() - Create the media database. @@ -37,6 +49,7 @@ * cups_is_close_media_db() - Compare two media entries to see if they are * close to the same size. * cups_test_constraints() - Test constraints. + * cups_update_ready() - Update xxx-ready attributes for the printer. */ /* @@ -46,6 +59,13 @@ #include "cups-private.h" +/* + * Local constants... + */ + +#define _CUPS_MEDIA_READY_TTL 30 /* Life of xxx-ready values */ + + /* * Local functions... */ @@ -56,12 +76,15 @@ static int cups_compare_dconstres(_cups_dconstres_t *a, static int cups_compare_media_db(_cups_media_db_t *a, _cups_media_db_t *b); static _cups_media_db_t *cups_copy_media_db(_cups_media_db_t *mdb); +static void cups_create_cached(http_t *http, cups_dinfo_t *dinfo, + unsigned flags); static void cups_create_constraints(cups_dinfo_t *dinfo); static void cups_create_defaults(cups_dinfo_t *dinfo); -static void cups_create_media_db(cups_dinfo_t *dinfo); +static void cups_create_media_db(cups_dinfo_t *dinfo, + unsigned flags); static void cups_free_media_db(_cups_media_db_t *mdb); -static int cups_get_media_db(cups_dinfo_t *dinfo, - _pwg_media_t *pwg, unsigned flags, +static int cups_get_media_db(http_t *http, cups_dinfo_t *dinfo, + pwg_media_t *pwg, unsigned flags, cups_size_t *size); static int cups_is_close_media_db(_cups_media_db_t *a, _cups_media_db_t *b); @@ -72,6 +95,7 @@ static cups_array_t *cups_test_constraints(cups_dinfo_t *dinfo, cups_option_t *options, int *num_conflicts, cups_option_t **conflicts); +static void cups_update_ready(http_t *http, cups_dinfo_t *dinfo); /* @@ -133,7 +157,7 @@ cupsCheckDestSupported( * Check range of custom media sizes... */ - _pwg_media_t *pwg; /* Current PWG media size info */ + pwg_media_t *pwg; /* Current PWG media size info */ int min_width, /* Minimum width */ min_length, /* Minimum length */ max_width, /* Maximum width */ @@ -151,13 +175,13 @@ cupsCheckDestSupported( i --, attrval ++) { if (!strncmp(attrval->string.text, "custom_min_", 11) && - (pwg = _pwgMediaForPWG(attrval->string.text)) != NULL) + (pwg = pwgMediaForPWG(attrval->string.text)) != NULL) { min_width = pwg->width; min_length = pwg->length; } else if (!strncmp(attrval->string.text, "custom_max_", 11) && - (pwg = _pwgMediaForPWG(attrval->string.text)) != NULL) + (pwg = pwgMediaForPWG(attrval->string.text)) != NULL) { max_width = pwg->width; max_length = pwg->length; @@ -169,7 +193,7 @@ cupsCheckDestSupported( */ if (min_width < INT_MAX && max_width > 0 && - (pwg = _pwgMediaForPWG(value)) != NULL && + (pwg = pwgMediaForPWG(value)) != NULL && pwg->width >= min_width && pwg->width <= max_width && pwg->length >= min_length && pwg->length <= max_length) return (1); @@ -623,8 +647,8 @@ cupsCopyDestInfo( request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", - NULL, cupsUser()); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + "requesting-user-name", NULL, cupsUser()); ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested_attrs) / sizeof(requested_attrs[0])), @@ -671,6 +695,7 @@ cupsCopyDestInfo( return (NULL); } + dinfo->version = version; dinfo->uri = uri; dinfo->resource = _cupsStrAlloc(resource); dinfo->attrs = response; @@ -679,6 +704,129 @@ cupsCopyDestInfo( } +/* + * 'cupsFindDestDefault()' - Find the default value(s) for the given option. + * + * The returned value is an IPP attribute. Use the @code ippGetBoolean@, + * @code ippGetCollection@, @code ippGetCount@, @code ippGetDate@, + * @code ippGetInteger@, @code ippGetOctetString@, @code ippGetRange@, + * @code ippGetResolution@, @code ippGetString@, and @code ippGetValueTag@ + * functions to inspect the default value(s) as needed. + * + * @since CUPS 1.7@ + */ + +ipp_attribute_t * /* O - Default attribute or @code NULL@ for none */ +cupsFindDestDefault( + http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + const char *option) /* I - Option/attribute name */ +{ + char name[IPP_MAX_NAME]; /* Attribute name */ + + + /* + * Range check input... + */ + + if (!http || !dest || !dinfo || !option) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (NULL); + } + + /* + * Find and return the attribute... + */ + + snprintf(name, sizeof(name), "%s-default", option); + return (ippFindAttribute(dinfo->attrs, name, IPP_TAG_ZERO)); +} + +/* + * 'cupsFindDestReady()' - Find the default value(s) for the given option. + * + * The returned value is an IPP attribute. Use the @code ippGetBoolean@, + * @code ippGetCollection@, @code ippGetCount@, @code ippGetDate@, + * @code ippGetInteger@, @code ippGetOctetString@, @code ippGetRange@, + * @code ippGetResolution@, @code ippGetString@, and @code ippGetValueTag@ + * functions to inspect the default value(s) as needed. + * + * @since CUPS 1.7@ + */ + +ipp_attribute_t * /* O - Default attribute or @code NULL@ for none */ +cupsFindDestReady( + http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + const char *option) /* I - Option/attribute name */ +{ + char name[IPP_MAX_NAME]; /* Attribute name */ + + + /* + * Range check input... + */ + + if (!http || !dest || !dinfo || !option) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (NULL); + } + + /* + * Find and return the attribute... + */ + + cups_update_ready(http, dinfo); + + snprintf(name, sizeof(name), "%s-ready", option); + return (ippFindAttribute(dinfo->ready_attrs, name, IPP_TAG_ZERO)); +} + +/* + * 'cupsFindDestSupported()' - Find the default value(s) for the given option. + * + * The returned value is an IPP attribute. Use the @code ippGetBoolean@, + * @code ippGetCollection@, @code ippGetCount@, @code ippGetDate@, + * @code ippGetInteger@, @code ippGetOctetString@, @code ippGetRange@, + * @code ippGetResolution@, @code ippGetString@, and @code ippGetValueTag@ + * functions to inspect the default value(s) as needed. + * + * @since CUPS 1.7@ + */ + +ipp_attribute_t * /* O - Default attribute or @code NULL@ for none */ +cupsFindDestSupported( + http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + const char *option) /* I - Option/attribute name */ +{ + char name[IPP_MAX_NAME]; /* Attribute name */ + + + /* + * Range check input... + */ + + if (!http || !dest || !dinfo || !option) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (NULL); + } + + /* + * Find and return the attribute... + */ + + snprintf(name, sizeof(name), "%s-supported", option); + return (ippFindAttribute(dinfo->attrs, name, IPP_TAG_ZERO)); +} + + /* * 'cupsFreeDestInfo()' - Free destination information obtained using * @link cupsCopyDestInfo@. @@ -707,12 +855,79 @@ cupsFreeDestInfo(cups_dinfo_t *dinfo) /* I - Destination information */ cupsArrayDelete(dinfo->media_db); + cupsArrayDelete(dinfo->cached_db); + + ippDelete(dinfo->ready_attrs); + cupsArrayDelete(dinfo->ready_db); + ippDelete(dinfo->attrs); free(dinfo); } +/* + * 'cupsGetDestMediaByIndex()' - Get a media name, dimension, and margins for a + * specific size. + * + * The @code flags@ parameter determines which set of media are indexed. For + * example, passing @code CUPS_MEDIA_FLAGS_BORDERLESS@ will get the Nth + * borderless size supported by the printer. + * + * @since CUPS 1.7@ + */ + +int /* O - 1 on success, 0 on failure */ +cupsGetDestMediaByIndex( + http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + int n, /* I - Media size number (0-based) */ + unsigned flags, /* I - Media flags */ + cups_size_t *size) /* O - Media size information */ +{ + cups_size_t *nsize; /* Size for N */ + + + /* + * Range check input... + */ + + if (size) + memset(size, 0, sizeof(cups_size_t)); + + if (!http || !dest || !dinfo || n < 0 || !size) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (0); + } + + /* + * Load media list as needed... + */ + + if (flags & CUPS_MEDIA_FLAGS_READY) + cups_update_ready(http, dinfo); + + if (!dinfo->cached_db || dinfo->cached_flags != flags) + cups_create_cached(http, dinfo, flags); + + /* + * Copy the size over and return... + */ + + if ((nsize = (cups_size_t *)cupsArrayIndex(dinfo->cached_db, n)) == NULL) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (0); + } + + memcpy(size, nsize, sizeof(cups_size_t)); + + return (1); +} + + /* * 'cupsGetDestMediaByName()' - Get media names, dimensions, and margins. * @@ -742,7 +957,7 @@ cupsGetDestMediaByName( unsigned flags, /* I - Media matching flags */ cups_size_t *size) /* O - Media size information */ { - _pwg_media_t *pwg; /* PWG media info */ + pwg_media_t *pwg; /* PWG media info */ /* @@ -762,8 +977,8 @@ cupsGetDestMediaByName( * Lookup the media size name... */ - if ((pwg = _pwgMediaForPWG(media)) == NULL) - if ((pwg = _pwgMediaForLegacy(media)) == NULL) + if ((pwg = pwgMediaForPWG(media)) == NULL) + if ((pwg = pwgMediaForLegacy(media)) == NULL) { DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", media)); _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown media size name."), 1); @@ -774,7 +989,7 @@ cupsGetDestMediaByName( * Lookup the size... */ - return (cups_get_media_db(dinfo, pwg, flags, size)); + return (cups_get_media_db(http, dinfo, pwg, flags, size)); } @@ -810,7 +1025,7 @@ cupsGetDestMediaBySize( unsigned flags, /* I - Media matching flags */ cups_size_t *size) /* O - Media size information */ { - _pwg_media_t *pwg; /* PWG media info */ + pwg_media_t *pwg; /* PWG media info */ /* @@ -830,7 +1045,7 @@ cupsGetDestMediaBySize( * Lookup the media size name... */ - if ((pwg = _pwgMediaForSize(width, length)) == NULL) + if ((pwg = pwgMediaForSize(width, length)) == NULL) { DEBUG_printf(("1cupsGetDestMediaBySize: Invalid size %dx%d.", width, length)); @@ -842,7 +1057,116 @@ cupsGetDestMediaBySize( * Lookup the size... */ - return (cups_get_media_db(dinfo, pwg, flags, size)); + return (cups_get_media_db(http, dinfo, pwg, flags, size)); +} + + +/* + * 'cupsGetDestMediaCount()' - Get the number of sizes supported by a + * destination. + * + * The @code flags@ parameter determines the set of media sizes that are + * counted. For example, passing @code CUPS_MEDIA_FLAGS_BORDERLESS@ will return + * the number of borderless sizes. + * + * @since CUPS 1.7@ + */ + +int /* O - Number of sizes */ +cupsGetDestMediaCount( + http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + unsigned flags) /* I - Media flags */ +{ + /* + * Range check input... + */ + + if (!http || !dest || !dinfo) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (0); + } + + /* + * Load media list as needed... + */ + + if (flags & CUPS_MEDIA_FLAGS_READY) + cups_update_ready(http, dinfo); + + if (!dinfo->cached_db || dinfo->cached_flags != flags) + cups_create_cached(http, dinfo, flags); + + return (cupsArrayCount(dinfo->cached_db)); +} + + +/* + * 'cupsGetDestMediaDefault()' - Get the default size for a destination. + * + * The @code flags@ parameter determines which default size is returned. For + * example, passing @code CUPS_MEDIA_FLAGS_BORDERLESS@ will return the default + * borderless size, typically US Letter or A4, but sometimes 4x6 photo media. + * + * @since CUPS 1.7@ + */ + +int /* O - 1 on success, 0 on failure */ +cupsGetDestMediaDefault( + http_t *http, /* I - Connection to destination */ + cups_dest_t *dest, /* I - Destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + unsigned flags, /* I - Media flags */ + cups_size_t *size) /* O - Media size information */ +{ + const char *media; /* Default media size */ + + + /* + * Range check input... + */ + + if (size) + memset(size, 0, sizeof(cups_size_t)); + + if (!http || !dest || !dinfo || !size) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); + return (0); + } + + /* + * Get the default media size, if any... + */ + + if ((media = cupsGetOption("media", dest->num_options, + dest->options)) == NULL) + media = "na_letter_8.5x11in"; + + if (cupsGetDestMediaByName(http, dest, dinfo, media, flags, size)) + return (1); + + if (strcmp(media, "na_letter_8.5x11in") && + cupsGetDestMediaByName(http, dest, dinfo, "iso_a4_210x297mm", flags, + size)) + return (1); + + if (strcmp(media, "iso_a4_210x297mm") && + cupsGetDestMediaByName(http, dest, dinfo, "na_letter_8.5x11in", flags, + size)) + return (1); + + if ((flags & CUPS_MEDIA_FLAGS_BORDERLESS) && + cupsGetDestMediaByName(http, dest, dinfo, "na_index_4x6in", flags, size)) + return (1); + + /* + * Fall back to the first matching media size... + */ + + return (cupsGetDestMediaByIndex(http, dest, dinfo, flags, 0, size)); } @@ -943,6 +1267,66 @@ cups_copy_media_db( } +/* + * 'cups_create_cached()' - Create the media selection cache. + */ + +static void +cups_create_cached(http_t *http, /* I - Connection to destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + unsigned flags) /* I - Media selection flags */ +{ + cups_array_t *db; /* Media database array to use */ + _cups_media_db_t *mdb, /* Media database entry */ + *first; /* First entry this size */ + + + if (dinfo->cached_db) + cupsArrayDelete(dinfo->cached_db); + + dinfo->cached_db = cupsArrayNew(NULL, NULL); + dinfo->cached_flags = flags; + + if (flags & CUPS_MEDIA_FLAGS_READY) + { + cups_update_ready(http, dinfo); + db = dinfo->ready_db; + } + else + { + if (!dinfo->media_db) + cups_create_media_db(dinfo, CUPS_MEDIA_FLAGS_DEFAULT); + + db = dinfo->media_db; + } + + for (mdb = (_cups_media_db_t *)cupsArrayFirst(db), first = mdb; + mdb; + mdb = (_cups_media_db_t *)cupsArrayNext(db)) + { + if (flags & CUPS_MEDIA_FLAGS_BORDERLESS) + { + if (!mdb->left && !mdb->right && !mdb->top && !mdb->bottom) + cupsArrayAdd(dinfo->cached_db, mdb); + } + else if (flags & CUPS_MEDIA_FLAGS_DUPLEX) + { + if (first->width != mdb->width || first->length != mdb->length) + { + cupsArrayAdd(dinfo->cached_db, first); + first = mdb; + } + else if (mdb->left >= first->left && mdb->right >= first->right && + mdb->top >= first->top && mdb->bottom >= first->bottom) + first = mdb; + } + } + + if (flags & CUPS_MEDIA_FLAGS_DUPLEX) + cupsArrayAdd(dinfo->cached_db, first); +} + + /* * 'cups_create_constraints()' - Create the constraints and resolvers arrays. */ @@ -1036,7 +1420,8 @@ cups_create_defaults( static void cups_create_media_db( - cups_dinfo_t *dinfo) /* I - Destination information */ + cups_dinfo_t *dinfo, /* I - Destination information */ + unsigned flags) /* I - Media flags */ { int i; /* Looping var */ _ipp_value_t *val; /* Current value */ @@ -1044,21 +1429,40 @@ cups_create_media_db( *media_attr, /* media-xxx */ *x_dimension, /* x-dimension */ *y_dimension; /* y-dimension */ - _pwg_media_t *pwg; /* PWG media info */ + pwg_media_t *pwg; /* PWG media info */ + cups_array_t *db; /* New media database array */ _cups_media_db_t mdb; /* Media entry */ - dinfo->media_db = cupsArrayNew3((cups_array_func_t)cups_compare_media_db, - NULL, NULL, 0, - (cups_acopy_func_t)cups_copy_media_db, - (cups_afree_func_t)cups_free_media_db); - dinfo->min_size.width = INT_MAX; - dinfo->min_size.length = INT_MAX; - dinfo->max_size.width = 0; - dinfo->max_size.length = 0; + db = cupsArrayNew3((cups_array_func_t)cups_compare_media_db, + NULL, NULL, 0, + (cups_acopy_func_t)cups_copy_media_db, + (cups_afree_func_t)cups_free_media_db); - if ((media_col_db = ippFindAttribute(dinfo->attrs, "media-col-database", - IPP_TAG_BEGIN_COLLECTION)) != NULL) + if (flags == CUPS_MEDIA_FLAGS_READY) + { + dinfo->ready_db = db; + + media_col_db = ippFindAttribute(dinfo->ready_attrs, "media-col-ready", + IPP_TAG_BEGIN_COLLECTION); + media_attr = ippFindAttribute(dinfo->ready_attrs, "media-ready", + IPP_TAG_ZERO); + } + else + { + dinfo->media_db = db; + dinfo->min_size.width = INT_MAX; + dinfo->min_size.length = INT_MAX; + dinfo->max_size.width = 0; + dinfo->max_size.length = 0; + + media_col_db = ippFindAttribute(dinfo->attrs, "media-col-database", + IPP_TAG_BEGIN_COLLECTION); + media_attr = ippFindAttribute(dinfo->attrs, "media-supported", + IPP_TAG_ZERO); + } + + if (media_col_db) { _ipp_value_t *custom = NULL; /* Custom size range value */ @@ -1075,15 +1479,32 @@ cups_create_media_db( /* media-size collection value */ if ((x_dimension = ippFindAttribute(media_size, "x-dimension", - IPP_TAG_INTEGER)) != NULL && + IPP_TAG_INTEGER)) != NULL && (y_dimension = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER)) != NULL) { + /* + * Fixed size... + */ + mdb.width = x_dimension->values[0].integer; mdb.length = y_dimension->values[0].integer; } - else if ((x_dimension = ippFindAttribute(media_size, "x-dimension", - IPP_TAG_RANGE)) != NULL && + else if ((x_dimension = ippFindAttribute(media_size, "x-dimension", + IPP_TAG_INTEGER)) != NULL && + (y_dimension = ippFindAttribute(media_size, "y-dimension", + IPP_TAG_RANGE)) != NULL) + { + /* + * Roll limits... + */ + + mdb.width = x_dimension->values[0].integer; + mdb.length = y_dimension->values[0].range.upper; + } + else if (flags != CUPS_MEDIA_FLAGS_READY && + (x_dimension = ippFindAttribute(media_size, "x-dimension", + IPP_TAG_RANGE)) != NULL && (y_dimension = ippFindAttribute(media_size, "y-dimension", IPP_TAG_RANGE)) != NULL) { @@ -1107,7 +1528,6 @@ cups_create_media_db( dinfo->max_size.right = 635; /* Default 1/4" side margins */ dinfo->max_size.top = dinfo->max_size.bottom = 1270; /* Default 1/2" top/bottom margins */ - continue; } } @@ -1167,7 +1587,7 @@ cups_create_media_db( IPP_TAG_INTEGER)) != NULL) mdb.top = media_attr->values[0].integer; - cupsArrayAdd(dinfo->media_db, &mdb); + cupsArrayAdd(db, &mdb); } if (custom) @@ -1205,8 +1625,7 @@ cups_create_media_db( } } } - else if ((media_attr = ippFindAttribute(dinfo->attrs, "media-supported", - IPP_TAG_ZERO)) != NULL && + else if (media_attr && (media_attr->value_tag == IPP_TAG_NAME || media_attr->value_tag == IPP_TAG_NAMELANG || media_attr->value_tag == IPP_TAG_KEYWORD)) @@ -1222,8 +1641,8 @@ cups_create_media_db( i > 0; i --, val ++) { - if ((pwg = _pwgMediaForPWG(val->string.text)) == NULL) - if ((pwg = _pwgMediaForLegacy(val->string.text)) == NULL) + if ((pwg = pwgMediaForPWG(val->string.text)) == NULL) + if ((pwg = pwgMediaForLegacy(val->string.text)) == NULL) { DEBUG_printf(("3cups_create_media_db: Ignoring unknown size '%s'.", val->string.text)); @@ -1233,12 +1652,14 @@ cups_create_media_db( mdb.width = pwg->width; mdb.length = pwg->length; - if (!strncmp(val->string.text, "custom_min_", 11)) + if (flags != CUPS_MEDIA_FLAGS_READY && + !strncmp(val->string.text, "custom_min_", 11)) { mdb.size_name = NULL; dinfo->min_size = mdb; } - else if (!strncmp(val->string.text, "custom_max_", 11)) + else if (flags != CUPS_MEDIA_FLAGS_READY && + !strncmp(val->string.text, "custom_max_", 11)) { mdb.size_name = NULL; dinfo->max_size = mdb; @@ -1247,7 +1668,7 @@ cups_create_media_db( { mdb.size_name = val->string.text; - cupsArrayAdd(dinfo->media_db, &mdb); + cupsArrayAdd(db, &mdb); } } } @@ -1284,11 +1705,13 @@ cups_free_media_db( */ static int /* O - 1 on match, 0 on failure */ -cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ - _pwg_media_t *pwg, /* I - PWG media info */ +cups_get_media_db(http_t *http, /* I - Connection to destination */ + cups_dinfo_t *dinfo, /* I - Destination information */ + pwg_media_t *pwg, /* I - PWG media info */ unsigned flags, /* I - Media matching flags */ - cups_size_t *size) /* O - Media size/margin/name info */ + cups_size_t *size) /* O - Media size/margin/name info */ { + cups_array_t *db; /* Which media database to query */ _cups_media_db_t *mdb, /* Current media database entry */ *best = NULL, /* Best matching entry */ key; /* Search key */ @@ -1298,8 +1721,18 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ * Create the media database as needed... */ - if (!dinfo->media_db) - cups_create_media_db(dinfo); + if (flags & CUPS_MEDIA_FLAGS_READY) + { + cups_update_ready(http, dinfo); + db = dinfo->ready_db; + } + else + { + if (!dinfo->media_db) + cups_create_media_db(dinfo, CUPS_MEDIA_FLAGS_DEFAULT); + + db = dinfo->media_db; + } /* * Find a match... @@ -1309,7 +1742,7 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ key.width = pwg->width; key.length = pwg->length; - if ((mdb = cupsArrayFind(dinfo->media_db, &key)) != NULL) + if ((mdb = cupsArrayFind(db, &key)) != NULL) { /* * Found an exact match, let's figure out the best margins for the flags @@ -1327,9 +1760,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ if (best->left != 0 || best->right != 0 || best->top != 0 || best->bottom != 0) { - for (mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayNext(db); mdb && !cups_compare_media_db(mdb, &key); - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) { if (mdb->left <= best->left && mdb->right <= best->right && mdb->top <= best->top && mdb->bottom <= best->bottom) @@ -1357,9 +1790,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ * Look for the largest margins... */ - for (mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayNext(db); mdb && !cups_compare_media_db(mdb, &key); - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) { if (mdb->left >= best->left && mdb->right >= best->right && mdb->top >= best->top && mdb->bottom >= best->bottom) @@ -1372,9 +1805,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ * Look for the smallest non-zero margins... */ - for (mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayNext(db); mdb && !cups_compare_media_db(mdb, &key); - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) { if (((mdb->left > 0 && mdb->left <= best->left) || best->left == 0) && ((mdb->right > 0 && mdb->right <= best->right) || @@ -1434,9 +1867,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ * Find a close size... */ - for (mdb = (_cups_media_db_t *)cupsArrayFirst(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) if (cups_is_close_media_db(mdb, &key)) break; @@ -1454,9 +1887,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ if (best->left != 0 || best->right != 0 || best->top != 0 || best->bottom != 0) { - for (mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayNext(db); mdb && cups_is_close_media_db(mdb, &key); - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) { if (mdb->left <= best->left && mdb->right <= best->right && mdb->top <= best->top && mdb->bottom <= best->bottom) @@ -1475,9 +1908,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ * Look for the largest margins... */ - for (mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayNext(db); mdb && cups_is_close_media_db(mdb, &key); - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) { if (mdb->left >= best->left && mdb->right >= best->right && mdb->top >= best->top && mdb->bottom >= best->bottom) @@ -1490,9 +1923,9 @@ cups_get_media_db(cups_dinfo_t *dinfo, /* I - Destination information */ * Look for the smallest non-zero margins... */ - for (mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db); + for (mdb = (_cups_media_db_t *)cupsArrayNext(db); mdb && cups_is_close_media_db(mdb, &key); - mdb = (_cups_media_db_t *)cupsArrayNext(dinfo->media_db)) + mdb = (_cups_media_db_t *)cupsArrayNext(db)) { if (((mdb->left > 0 && mdb->left <= best->left) || best->left == 0) && ((mdb->right > 0 && mdb->right <= best->right) || @@ -1758,6 +2191,81 @@ cups_test_constraints( } +/* + * 'cups_update_ready()' - Update xxx-ready attributes for the printer. + */ + +static void +cups_update_ready(http_t *http, /* I - Connection to destination */ + cups_dinfo_t *dinfo) /* I - Destination information */ +{ + ipp_t *request; /* Get-Printer-Attributes request */ + static const char * const pattrs[] = /* Printer attributes we want */ + { + "finishings-col-ready", + "finishings-ready", + "job-finishings-col-ready", + "job-finishings-ready", + "media-col-ready", + "media-ready" + }; + + + /* + * Don't update more than once every 30 seconds... + */ + + if ((time(NULL) - dinfo->ready_time) < _CUPS_MEDIA_READY_TTL) + return; + + /* + * Free any previous results... + */ + + if (dinfo->cached_flags & CUPS_MEDIA_FLAGS_READY) + { + cupsArrayDelete(dinfo->cached_db); + dinfo->cached_db = NULL; + dinfo->cached_flags = CUPS_MEDIA_FLAGS_DEFAULT; + } + + ippDelete(dinfo->ready_attrs); + dinfo->ready_attrs = NULL; + + cupsArrayDelete(dinfo->ready_db); + dinfo->ready_db = NULL; + + /* + * Query the xxx-ready values... + */ + + request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); + ippSetVersion(request, dinfo->version / 10, dinfo->version % 10); + + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, + dinfo->uri); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", + NULL, cupsUser()); + ippAddStrings(request, IPP_TAG_OPERATION, + IPP_TAG_KEYWORD | IPP_TAG_CUPS_CONST, "requested-attributes", + (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs); + + dinfo->ready_attrs = cupsDoRequest(http, request, dinfo->resource); + + /* + * Update the ready media database... + */ + + cups_create_media_db(dinfo, CUPS_MEDIA_FLAGS_READY); + + /* + * Update last lookup time and return... + */ + + dinfo->ready_time = time(NULL); +} + + /* * End of "$Id$". */ diff --git a/cups/dest.c b/cups/dest.c index 03ee73c4c..7736baa4c 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -2458,7 +2458,7 @@ appleGetPaperSize(char *name, /* I - Paper size name buffer */ int namesize) /* I - Size of buffer */ { CFStringRef defaultPaperID; /* Default paper ID */ - _pwg_media_t *pwgmedia; /* PWG media size */ + pwg_media_t *pwgmedia; /* PWG media size */ defaultPaperID = _cupsAppleCopyDefaultPaperID(); @@ -2467,7 +2467,7 @@ appleGetPaperSize(char *name, /* I - Paper size name buffer */ !CFStringGetCString(defaultPaperID, name, namesize, kCFStringEncodingUTF8)) name[0] = '\0'; - else if ((pwgmedia = _pwgMediaForLegacy(name)) != NULL) + else if ((pwgmedia = pwgMediaForLegacy(name)) != NULL) strlcpy(name, pwgmedia->pwg, namesize); if (defaultPaperID) diff --git a/cups/http-addr.c b/cups/http-addr.c index 77e3fc116..64ac1b713 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -3,7 +3,7 @@ * * HTTP address routines for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index 6d859b658..97923ae6f 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -34,7 +34,7 @@ # include #endif /* HAVE_POLL */ #ifndef WIN32 -# include +# include #endif /* WIN32 */ @@ -59,7 +59,7 @@ httpAddrConnect( * 'httpAddrConnect2()' - Connect to any of the addresses in the list with a * timeout and optional cancel. * - * @since CUPS 1.6/OS X 10.8@ + * @since CUPS 1.7@ */ http_addrlist_t * /* O - Connected address or NULL on failure */ diff --git a/cups/http-support.c b/cups/http-support.c index 64c181028..4c7cbc9a4 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -474,6 +474,8 @@ httpAssembleURIf( * number. The result is formatted as a UUID URN as defined in RFC 4122. * * The buffer needs to be at least 46 bytes in size. + * + * @since CUPS 1.7@ */ char * /* I - UUID string */ @@ -1869,6 +1871,11 @@ http_copy_decode(char *dst, /* O - Destination buffer */ return (NULL); } } + else if ((*src & 255) <= 0x20 || (*src & 255) >= 0x7f) + { + *ptr = '\0'; + return (NULL); + } else *ptr++ = *src; } diff --git a/cups/http.c b/cups/http.c index 8ea4d93c3..919e73adf 100644 --- a/cups/http.c +++ b/cups/http.c @@ -47,11 +47,11 @@ * _httpFreeCredentials() - Free internal credentials. * httpFreeCredentials() - Free an array of credentials. * httpGet() - Send a GET request to the server. - * httpGetContentEncoding() - Get a common content encoding, if any, - * between the client and server. * httpGetAuthString() - Get the current authorization string. * httpGetBlocking() - Get the blocking/non-block state of a * connection. + * httpGetContentEncoding() - Get a common content encoding, if any, + * between the client and server. * httpGetCookie() - Get any cookie data from the response. * httpGetExpect() - Get the value of the Expect header, if any. * httpGetFd() - Get the file descriptor associated with a @@ -1043,6 +1043,40 @@ httpGet(http_t *http, /* I - Connection to server */ } +/* + * 'httpGetAuthString()' - Get the current authorization string. + * + * The authorization string is set by cupsDoAuthentication() and + * httpSetAuthString(). Use httpGetAuthString() to retrieve the + * string to use with httpSetField() for the HTTP_FIELD_AUTHORIZATION + * value. + * + * @since CUPS 1.3/OS X 10.5@ + */ + +char * /* O - Authorization string */ +httpGetAuthString(http_t *http) /* I - Connection to server */ +{ + if (http) + return (http->authstring); + else + return (NULL); +} + + +/* + * 'httpGetBlocking()' - Get the blocking/non-block state of a connection. + * + * @since CUPS 1.2/OS X 10.5@ + */ + +int /* O - 1 if blocking, 0 if non-blocking */ +httpGetBlocking(http_t *http) /* I - Connection to server */ +{ + return (http ? http->blocking : 0); +} + + /* * 'httpGetContentEncoding()' - Get a common content encoding, if any, between * the client and server. @@ -1131,40 +1165,6 @@ httpGetContentEncoding(http_t *http) /* I - Connection to client/server */ } -/* - * 'httpGetAuthString()' - Get the current authorization string. - * - * The authorization string is set by cupsDoAuthentication() and - * httpSetAuthString(). Use httpGetAuthString() to retrieve the - * string to use with httpSetField() for the HTTP_FIELD_AUTHORIZATION - * value. - * - * @since CUPS 1.3/OS X 10.5@ - */ - -char * /* O - Authorization string */ -httpGetAuthString(http_t *http) /* I - Connection to server */ -{ - if (http) - return (http->authstring); - else - return (NULL); -} - - -/* - * 'httpGetBlocking()' - Get the blocking/non-block state of a connection. - * - * @since CUPS 1.2/OS X 10.5@ - */ - -int /* O - 1 if blocking, 0 if non-blocking */ -httpGetBlocking(http_t *http) /* I - Connection to server */ -{ - return (http ? http->blocking : 0); -} - - /* * 'httpGetCookie()' - Get any cookie data from the response. * @@ -2358,6 +2358,9 @@ httpRead2(http_t *http, /* I - Connection to server */ if (http->state == HTTP_STATE_POST_RECV) http->state ++; + else if (http->state == HTTP_STATE_GET_SEND || + http->state == HTTP_STATE_POST_SEND) + http->state = HTTP_STATE_WAITING; else http->state = HTTP_STATE_STATUS; @@ -2898,8 +2901,8 @@ httpSetCookie(http_t *http, /* I - Connection */ /* * 'httpSetDefaultField()' - Set the default value of an HTTP header. * - * Currently only HTTP_FIELD_ACCEPT_ENCODING, HTTP_FIELD_SERVER, and - * HTTP_FIELD_USER_AGENT can be set. + * Currently only @code HTTP_FIELD_ACCEPT_ENCODING@, @code HTTP_FIELD_SERVER@, + * and @code HTTP_FIELD_USER_AGENT@ can be set. * * @since CUPS 1.7@ */ @@ -4602,7 +4605,7 @@ http_read(http_t *http, /* I - Connection to server */ CUPS_LLCAST bytes)); #ifdef DEBUG if (bytes > 0) - http_debug_hex("http_read", http->buffer, (int)bytes); + http_debug_hex("http_read", buffer, (int)bytes); #endif /* DEBUG */ if (bytes < 0) @@ -5293,7 +5296,7 @@ http_setup_ssl(http_t *http) /* I - Connection to server */ http->error = EIO; http->status = HTTP_STATUS_ERROR; - _cupsSetError(IPP_PKI_ERROR, gnutls_strerror(status), 0); + _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, gnutls_strerror(status), 0); gnutls_deinit(http->tls); gnutls_certificate_free_credentials(*credentials); diff --git a/cups/ipp-support.c b/cups/ipp-support.c index 265d33c5a..6c7aadeda 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -489,13 +489,29 @@ static const char * const ipp_document_states[] = "punch-dual-bottom", "punch-triple-left", "punch-triple-top", - /* 0x40000050 - 0x40000055 */ + /* 0x40000050 - 0x4000005F */ "punch-triple-right", "punch-triple-bottom", "punch-quad-left", "punch-quad-top", "punch-quad-right", "punch-quad-bottom", + "0x40000056", + "0x40000057", + "0x40000058", + "0x40000059", + "fold-accordian", + "fold-double-gate", + "fold-gate", + "fold-half", + "fold-half-z", + "fold-left-gate", + /* 0x40000060 - 0x40000064 */ + "fold-letter", + "fold-parallel", + "fold-poster", + "fold-right-gate", + "fold-z" }, * const ipp_job_collation_types[] = { /* job-collation-type enums */ @@ -863,6 +879,7 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "print-content-optimize-actual", "print-quality-actual", "print-rendering-intent-actual", + "print-scaling-actual", /* IPP Paid Printing */ "printer-resolution-actual", "printer-up-time", "separator-sheets-actual", @@ -955,6 +972,9 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "orientation-requested", "orientation-requested-default", "orientation-requested-supported", + "output-mode", /* CUPS extension */ + "output-mode-default", /* CUPS extension */ + "output-mode-supported", /* CUPS extension */ "overrides", "overrides-supported", "page-delivery", @@ -989,6 +1009,9 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "print-rendering-intent", "print-rendering-intent-default", "print-rendering-intent-supported", + "print-scaling", /* IPP Paid Printing */ + "print-scaling-default", /* IPP Paid Printing */ + "print-scaling-supported", /* IPP Paid Printing */ "printer-resolution", "printer-resolution-default", "printer-resolution-supported", @@ -1123,6 +1146,7 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "print-content-optimize-actual", "print-quality-actual", "print-rendering-intent-actual", + "print-scaling-actual", /* IPP Paid Printing */ "printer-resolution-actual", "separator-sheets-actual", "sheet-collate-actual", @@ -1299,6 +1323,9 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "output-device", "output-device-default", "output-device-supported", + "output-mode", /* CUPS extension */ + "output-mode-default", /* CUPS extension */ + "output-mode-supported", /* CUPS extension */ "overrides", "overrides-supported", "page-delivery", @@ -1333,6 +1360,9 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "print-rendering-intent", "print-rendering-intent-default", "print-rendering-intent-supported", + "print-scaling", /* IPP Paid Printing */ + "print-scaling-default", /* IPP Paid Printing */ + "print-scaling-supported", /* IPP Paid Printing */ "printer-resolution", "printer-resolution-default", "printer-resolution-supported", @@ -1488,6 +1518,8 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "printer-icons", "printer-info", "printer-is-accepting-jobs", + "printer-is-shared", /* CUPS extension */ + "printer-kind", /* IPP Paid Printing */ "printer-location", "printer-make-and-model", "printer-mandatory-job-attributes", @@ -1497,6 +1529,7 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "printer-more-info", "printer-more-info-manufacturer", "printer-name", + "printer-native-formats", "printer-organization", "printer-organizational-unit", "printer-settable-attributes-supported", @@ -1523,6 +1556,7 @@ ippCreateRequestedArray(ipp_t *request) /* I - IPP request */ "requesting-user-name-denied", /* CUPS extension */ "requesting-user-uri-supported", "subordinate-printers-supported", + "urf-supported", /* CUPS extension */ "uri-authentication-supported", "uri-security-supported", "user-defined-value-supported", @@ -1714,7 +1748,10 @@ ippEnumString(const char *attrname, /* I - Attribute name */ !strcmp(attrname, "finishings-actual") || !strcmp(attrname, "finishings-default") || !strcmp(attrname, "finishings-ready") || - !strcmp(attrname, "finishings-supported")) + !strcmp(attrname, "finishings-supported") || + !strcmp(attrname, "job-finishings") || + !strcmp(attrname, "job-finishings-default") || + !strcmp(attrname, "job-finishings-supported")) { if (enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_finishings) / diff --git a/cups/ipp.c b/cups/ipp.c index 68665ebc5..8c1ace0f1 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -57,6 +57,7 @@ * ippGetGroupTag() - Get the group associated with an attribute. * ippGetInteger() - Get the integer/enum value for an attribute. * ippGetName() - Get the attribute name. + * ippGetOctetString() - Get an octetString value from an IPP attribute. * ippGetOperation() - Get the operation ID in an IPP message. * ippGetRange() - Get a rangeOfInteger value from an attribute. * ippGetRequestId() - Get the request ID from an IPP message. @@ -84,6 +85,7 @@ * ippSetGroupTag() - Set the group tag of an attribute. * ippSetInteger() - Set an integer or enum value in an attribute. * ippSetName() - Set the name of an attribute. + * ippSetOctetString() - Set an octetString value in an IPP attribute. * ippSetOperation() - Set the operation ID in an IPP request message. * ippSetRange() - Set a rangeOfInteger value in an attribute. * ippSetRequestId() - Set the request ID in an IPP message. @@ -2382,6 +2384,45 @@ ippGetName(ipp_attribute_t *attr) /* I - IPP attribute */ } +/* + * 'ippGetOctetString()' - Get an octetString value from an IPP attribute. + * + * The @code element@ parameter specifies which value to get from 0 to + * @link ippGetCount(attr)@ - 1. + * + * @since CUPS 1.7@ + */ + +void * /* O - Pointer to octetString data */ +ippGetOctetString( + ipp_attribute_t *attr, /* I - IPP attribute */ + int element, /* I - Value number (0-based) */ + int *datalen) /* O - Length of octetString data */ +{ + /* + * Range check input... + */ + + if (!attr || attr->value_tag != IPP_TAG_STRING || + element < 0 || element >= attr->num_values) + { + if (datalen) + *datalen = 0; + + return (NULL); + } + + /* + * Return the values... + */ + + if (datalen) + *datalen = attr->values[element].unknown.length; + + return (attr->values[element].unknown.data); +} + + /* * 'ippGetOperation()' - Get the operation ID in an IPP message. * @@ -3712,7 +3753,7 @@ ippReadIO(void *src, /* I - Data source */ */ int /* O - 1 on success, 0 on failure */ -ippSetBoolean(ipp_t *ipp, /* IO - IPP message */ +ippSetBoolean(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ int boolvalue)/* I - Boolean value */ @@ -3755,7 +3796,7 @@ ippSetBoolean(ipp_t *ipp, /* IO - IPP message */ int /* O - 1 on success, 0 on failure */ ippSetCollection( - ipp_t *ipp, /* IO - IPP message */ + ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ ipp_t *colvalue) /* I - Collection value */ @@ -3803,7 +3844,7 @@ ippSetCollection( */ int /* O - 1 on success, 0 on failure */ -ippSetDate(ipp_t *ipp, /* IO - IPP message */ +ippSetDate(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ const ipp_uchar_t *datevalue)/* I - Date value */ @@ -3849,7 +3890,7 @@ ippSetDate(ipp_t *ipp, /* IO - IPP message */ int /* O - 1 on success, 0 on failure */ ippSetGroupTag( - ipp_t *ipp, /* IO - IPP message */ + ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - Attribute */ ipp_tag_t group_tag) /* I - Group tag */ { @@ -3887,7 +3928,7 @@ ippSetGroupTag( */ int /* O - 1 on success, 0 on failure */ -ippSetInteger(ipp_t *ipp, /* IO - IPP message */ +ippSetInteger(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ int intvalue) /* I - Integer/enum value */ @@ -3927,7 +3968,7 @@ ippSetInteger(ipp_t *ipp, /* IO - IPP message */ */ int /* O - 1 on success, 0 on failure */ -ippSetName(ipp_t *ipp, /* IO - IPP message */ +ippSetName(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ const char *name) /* I - Attribute name */ { @@ -3957,6 +3998,94 @@ ippSetName(ipp_t *ipp, /* IO - IPP message */ } +/* + * 'ippSetOctetString()' - Set an octetString value in an IPP attribute. + * + * The @code ipp@ parameter refers to an IPP message previously created using + * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions. + * + * The @code attr@ parameter may be modified as a result of setting the value. + * + * The @code element@ parameter specifies which value to set from 0 to + * @link ippGetCount(attr)@. + * + * @since CUPS 1.7@ + */ + +int /* O - 1 on success, 0 on failure */ +ippSetOctetString( + ipp_t *ipp, /* I - IPP message */ + ipp_attribute_t **attr, /* IO - IPP attribute */ + int element, /* I - Value number (0-based) */ + const void *data, /* I - Pointer to octetString data */ + int datalen) /* I - Length of octetString data */ +{ + _ipp_value_t *value; /* Current value */ + + + /* + * Range check input... + */ + + if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_STRING || + element < 0 || element > (*attr)->num_values || + datalen < 0 || datalen > IPP_MAX_LENGTH) + return (0); + + /* + * Set the value and return... + */ + + if ((value = ipp_set_value(ipp, attr, element)) != NULL) + { + if ((int)((*attr)->value_tag) & IPP_TAG_CUPS_CONST) + { + /* + * Just copy the pointer... + */ + + value->unknown.data = (void *)data; + value->unknown.length = datalen; + } + else + { + /* + * Copy the data... + */ + + if (value->unknown.data) + { + /* + * Free previous data... + */ + + free(value->unknown.data); + + value->unknown.data = NULL; + value->unknown.length = 0; + } + + if (datalen > 0) + { + void *temp; /* Temporary data pointer */ + + if ((temp = malloc(datalen)) != NULL) + { + memcpy(temp, data, datalen); + + value->unknown.data = temp; + value->unknown.length = datalen; + } + else + return (0); + } + } + } + + return (value != NULL); +} + + /* * 'ippSetOperation()' - Set the operation ID in an IPP request message. * @@ -4002,7 +4131,7 @@ ippSetOperation(ipp_t *ipp, /* I - IPP request message */ */ int /* O - 1 on success, 0 on failure */ -ippSetRange(ipp_t *ipp, /* IO - IPP message */ +ippSetRange(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ int lowervalue, /* I - Lower bound for range */ @@ -4083,7 +4212,7 @@ ippSetRequestId(ipp_t *ipp, /* I - IPP message */ int /* O - 1 on success, 0 on failure */ ippSetResolution( - ipp_t *ipp, /* IO - IPP message */ + ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ ipp_res_t unitsvalue, /* I - Resolution units */ @@ -4190,7 +4319,7 @@ ippSetStatusCode(ipp_t *ipp, /* I - IPP response or event message */ */ int /* O - 1 on success, 0 on failure */ -ippSetString(ipp_t *ipp, /* IO - IPP message */ +ippSetString(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ const char *strvalue) /* I - String value */ @@ -4257,7 +4386,7 @@ ippSetString(ipp_t *ipp, /* IO - IPP message */ */ int /* O - 1 on success, 0 on failure */ -ippSetStringf(ipp_t *ipp, /* IO - IPP message */ +ippSetStringf(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ const char *format, /* I - Printf-style format string */ @@ -4295,7 +4424,7 @@ ippSetStringf(ipp_t *ipp, /* IO - IPP message */ */ int /* O - 1 on success, 0 on failure */ -ippSetStringfv(ipp_t *ipp, /* IO - IPP message */ +ippSetStringfv(ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ int element, /* I - Value number (0-based) */ const char *format, /* I - Printf-style format string */ @@ -4448,7 +4577,7 @@ ippSetStringfv(ipp_t *ipp, /* IO - IPP message */ int /* O - 1 on success, 0 on failure */ ippSetValueTag( - ipp_t *ipp, /* IO - IPP message */ + ipp_t *ipp, /* I - IPP message */ ipp_attribute_t **attr, /* IO - IPP attribute */ ipp_tag_t value_tag) /* I - Value tag */ { diff --git a/cups/ipp.h b/cups/ipp.h index 3e343a2fd..5360ff1a7 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -102,7 +102,7 @@ typedef enum ipp_finishings_e /**** Finishings ****/ IPP_FINISHINGS_TRIM, /* Trim (any type) */ IPP_FINISHINGS_BALE, /* Bale (any type) */ IPP_FINISHINGS_BOOKLET_MAKER, /* Fold to make booklet */ - IPP_FINISHINGS_JOB_OFFSET, /* Offset for binding (any type) */ + IPP_FINISHINGS_JOG_OFFSET, /* Offset for binding (any type) */ IPP_FINISHINGS_STAPLE_TOP_LEFT = 20, /* Staple top left corner */ IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, /* Staple bottom left corner */ IPP_FINISHINGS_STAPLE_TOP_RIGHT, /* Staple top right corner */ @@ -144,9 +144,24 @@ typedef enum ipp_finishings_e /**** Finishings ****/ IPP_FINISHINGS_CUPS_PUNCH_QUAD_LEFT, /* Punch 4 holes left side */ IPP_FINISHINGS_CUPS_PUNCH_QUAD_TOP, /* Punch 4 holes top edge */ IPP_FINISHINGS_CUPS_PUNCH_QUAD_RIGHT, /* Punch 4 holes right side */ - IPP_FINISHINGS_CUPS_PUNCH_QUAD_BOTTOM /* Punch 4 holes bottom edge */ + IPP_FINISHINGS_CUPS_PUNCH_QUAD_BOTTOM,/* Punch 4 holes bottom edge */ + + IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN = 0x4000005A, + /* Accordian-fold the paper vertically into four sections */ + IPP_FINISHINGS_CUPS_FOLD_DOUBLE_GATE, /* Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically */ + IPP_FINISHINGS_CUPS_FOLD_GATE, /* Fold the top and bottom quarters of the paper towards the midline */ + IPP_FINISHINGS_CUPS_FOLD_HALF, /* Fold the paper in half vertically */ + IPP_FINISHINGS_CUPS_FOLD_HALF_Z, /* Fold the paper in half horizontally, then Z-fold the paper vertically */ + IPP_FINISHINGS_CUPS_FOLD_LEFT_GATE, /* Fold the top quarter of the paper towards the midline */ + IPP_FINISHINGS_CUPS_FOLD_LETTER, /* Fold the paper into three sections vertically; sometimes also known as a C fold*/ + IPP_FINISHINGS_CUPS_FOLD_PARALLEL, /* Fold the paper in half vertically two times, yielding four sections */ + IPP_FINISHINGS_CUPS_FOLD_POSTER, /* Fold the paper in half horizontally and vertically; sometimes also called a cross fold */ + IPP_FINISHINGS_CUPS_FOLD_RIGHT_GATE, /* Fold the bottom quarter of the paper towards the midline */ + IPP_FINISHINGS_CUPS_FOLD_Z /* Fold the paper vertically into three sections, forming a Z */ } ipp_finishings_t; # ifndef _CUPS_NO_DEPRECATED +# define IPP_FINISHINGS_JOB_OFFSET IPP_FINISHINGS_JOG_OFFSET + /* Long-time misspelling... */ typedef enum ipp_finishings_e ipp_finish_t; # endif /* !_CUPS_NO_DEPRECATED */ @@ -921,7 +936,12 @@ extern int ippContainsInteger(ipp_attribute_t *attr, int value) extern int ippContainsString(ipp_attribute_t *attr, const char *value) _CUPS_API_1_7; extern cups_array_t *ippCreateRequestedArray(ipp_t *request) _CUPS_API_1_7; +extern void *ippGetOctetString(ipp_attribute_t *attr, int element, + int *datalen) _CUPS_API_1_7; extern ipp_t *ippNewResponse(ipp_t *request) _CUPS_API_1_7; +extern int ippSetOctetString(ipp_t *ipp, ipp_attribute_t **attr, + int element, const void *data, + int datalen) _CUPS_API_1_7; extern int ippSetStringf(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *format, ...) _CUPS_API_1_7; diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index c1febfa9d..ceae66df9 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -88,8 +88,8 @@ _ppdCacheCreateWithFile( { cups_file_t *fp; /* File */ _ppd_cache_t *pc; /* PWG mapping data */ - _pwg_size_t *size; /* Current size */ - _pwg_map_t *map; /* Current map */ + pwg_size_t *size; /* Current size */ + pwg_map_t *map; /* Current map */ _pwg_finishings_t *finishings; /* Current finishings option */ int linenum, /* Current line number */ num_bins, /* Number of bins in file */ @@ -290,7 +290,7 @@ _ppdCacheCreateWithFile( goto create_error; } - if ((pc->bins = calloc(num_bins, sizeof(_pwg_map_t))) == NULL) + if ((pc->bins = calloc(num_bins, sizeof(pwg_map_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d bins.", num_sizes)); @@ -340,7 +340,7 @@ _ppdCacheCreateWithFile( if (num_sizes > 0) { - if ((pc->sizes = calloc(num_sizes, sizeof(_pwg_size_t))) == NULL) + if ((pc->sizes = calloc(num_sizes, sizeof(pwg_size_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sizes.", num_sizes)); @@ -398,12 +398,12 @@ _ppdCacheCreateWithFile( goto create_error; } - _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "max", - pc->custom_max_width, pc->custom_max_length); + pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max", + pc->custom_max_width, pc->custom_max_length, NULL); pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword); - _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "min", - pc->custom_min_width, pc->custom_min_length); + pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min", + pc->custom_min_width, pc->custom_min_length, NULL); pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword); } else if (!_cups_strcasecmp(line, "SourceOption")) @@ -428,7 +428,7 @@ _ppdCacheCreateWithFile( goto create_error; } - if ((pc->sources = calloc(num_sources, sizeof(_pwg_map_t))) == NULL) + if ((pc->sources = calloc(num_sources, sizeof(pwg_map_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sources.", num_sources)); @@ -477,7 +477,7 @@ _ppdCacheCreateWithFile( goto create_error; } - if ((pc->types = calloc(num_types, sizeof(_pwg_map_t))) == NULL) + if ((pc->types = calloc(num_types, sizeof(pwg_map_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d types.", num_types)); @@ -654,24 +654,24 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ *color_model, /* ColorModel option */ *duplex; /* Duplex option */ ppd_choice_t *choice; /* Current InputSlot/MediaType */ - _pwg_map_t *map; /* Current source/type map */ + pwg_map_t *map; /* Current source/type map */ ppd_attr_t *ppd_attr; /* Current PPD preset attribute */ int num_options; /* Number of preset options and props */ cups_option_t *options; /* Preset options and properties */ ppd_size_t *ppd_size; /* Current PPD size */ - _pwg_size_t *pwg_size; /* Current PWG size */ + pwg_size_t *pwg_size; /* Current PWG size */ char pwg_keyword[3 + PPD_MAX_NAME + 1 + 12 + 1 + 12 + 3], /* PWG keyword string */ ppd_name[PPD_MAX_NAME]; /* Normalized PPD name */ const char *pwg_name; /* Standard PWG media name */ - _pwg_media_t *pwg_media; /* PWG media data */ + pwg_media_t *pwg_media; /* PWG media data */ _pwg_print_color_mode_t pwg_print_color_mode; /* print-color-mode index */ _pwg_print_quality_t pwg_print_quality; /* print-quality index */ int similar; /* Are the old and new size similar? */ - _pwg_size_t *old_size; /* Current old size */ + pwg_size_t *old_size; /* Current old size */ int old_imageable, /* Old imageable length in 2540ths */ old_borderless, /* Old borderless state */ old_known_pwg; /* Old PWG name is well-known */ @@ -684,7 +684,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ new_imageable, /* New imageable length in 2540ths */ new_borderless, /* New borderless state */ new_known_pwg; /* New PWG name is well-known */ - _pwg_size_t *new_size; /* New size to add, if any */ + pwg_size_t *new_size; /* New size to add, if any */ const char *filter; /* Current filter */ _pwg_finishings_t *finishings; /* Current finishings value */ @@ -714,10 +714,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ if (ppd->num_sizes > 0) { - if ((pc->sizes = calloc(ppd->num_sizes, sizeof(_pwg_size_t))) == NULL) + if ((pc->sizes = calloc(ppd->num_sizes, sizeof(pwg_size_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d " - "_pwg_size_t's.", ppd->num_sizes)); + "pwg_size_t's.", ppd->num_sizes)); goto create_error; } @@ -736,7 +736,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ * Convert the PPD size name to the corresponding PWG keyword name. */ - if ((pwg_media = _pwgMediaForPPD(ppd_size->name)) != NULL) + if ((pwg_media = pwgMediaForPPD(ppd_size->name)) != NULL) { /* * Standard name, do we have conflicts? @@ -771,9 +771,9 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ new_known_pwg = 0; pwg_unppdize_name(ppd_size->name, ppd_name, sizeof(ppd_name), "_."); - _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name, - _PWG_FROMPTS(ppd_size->width), - _PWG_FROMPTS(ppd_size->length)); + pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name, + PWG_FROM_POINTS(ppd_size->width), + PWG_FROM_POINTS(ppd_size->length), NULL); } /* @@ -782,16 +782,16 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ * dimensions that are <= 0... */ - if ((pwg_media = _pwgMediaForSize(_PWG_FROMPTS(ppd_size->width), - _PWG_FROMPTS(ppd_size->length))) == NULL) + if ((pwg_media = pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width), + PWG_FROM_POINTS(ppd_size->length))) == NULL) continue; new_width = pwg_media->width; new_length = pwg_media->length; - new_left = _PWG_FROMPTS(ppd_size->left); - new_bottom = _PWG_FROMPTS(ppd_size->bottom); - new_right = _PWG_FROMPTS(ppd_size->width - ppd_size->right); - new_top = _PWG_FROMPTS(ppd_size->length - ppd_size->top); + new_left = PWG_FROM_POINTS(ppd_size->left); + new_bottom = PWG_FROM_POINTS(ppd_size->bottom); + new_right = PWG_FROM_POINTS(ppd_size->width - ppd_size->right); + new_top = PWG_FROM_POINTS(ppd_size->length - ppd_size->top); new_imageable = new_length - new_top - new_bottom; new_borderless = new_bottom == 0 && new_top == 0 && new_left == 0 && new_right == 0; @@ -860,24 +860,24 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ * Generate custom size data... */ - _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "max", - _PWG_FROMPTS(ppd->custom_max[0]), - _PWG_FROMPTS(ppd->custom_max[1])); + pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max", + PWG_FROM_POINTS(ppd->custom_max[0]), + PWG_FROM_POINTS(ppd->custom_max[1]), NULL); pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword); - pc->custom_max_width = _PWG_FROMPTS(ppd->custom_max[0]); - pc->custom_max_length = _PWG_FROMPTS(ppd->custom_max[1]); + pc->custom_max_width = PWG_FROM_POINTS(ppd->custom_max[0]); + pc->custom_max_length = PWG_FROM_POINTS(ppd->custom_max[1]); - _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "min", - _PWG_FROMPTS(ppd->custom_min[0]), - _PWG_FROMPTS(ppd->custom_min[1])); + pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min", + PWG_FROM_POINTS(ppd->custom_min[0]), + PWG_FROM_POINTS(ppd->custom_min[1]), NULL); pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword); - pc->custom_min_width = _PWG_FROMPTS(ppd->custom_min[0]); - pc->custom_min_length = _PWG_FROMPTS(ppd->custom_min[1]); + pc->custom_min_width = PWG_FROM_POINTS(ppd->custom_min[0]); + pc->custom_min_length = PWG_FROM_POINTS(ppd->custom_min[1]); - pc->custom_size.left = _PWG_FROMPTS(ppd->custom_margins[0]); - pc->custom_size.bottom = _PWG_FROMPTS(ppd->custom_margins[1]); - pc->custom_size.right = _PWG_FROMPTS(ppd->custom_margins[2]); - pc->custom_size.top = _PWG_FROMPTS(ppd->custom_margins[3]); + pc->custom_size.left = PWG_FROM_POINTS(ppd->custom_margins[0]); + pc->custom_size.bottom = PWG_FROM_POINTS(ppd->custom_margins[1]); + pc->custom_size.right = PWG_FROM_POINTS(ppd->custom_margins[2]); + pc->custom_size.top = PWG_FROM_POINTS(ppd->custom_margins[3]); } /* @@ -892,10 +892,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ pc->source_option = _cupsStrAlloc(input_slot->keyword); if ((pc->sources = calloc(input_slot->num_choices, - sizeof(_pwg_map_t))) == NULL) + sizeof(pwg_map_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d " - "_pwg_map_t's for InputSlot.", input_slot->num_choices)); + "pwg_map_t's for InputSlot.", input_slot->num_choices)); goto create_error; } @@ -954,10 +954,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL) { if ((pc->types = calloc(media_type->num_choices, - sizeof(_pwg_map_t))) == NULL) + sizeof(pwg_map_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d " - "_pwg_map_t's for MediaType.", media_type->num_choices)); + "pwg_map_t's for MediaType.", media_type->num_choices)); goto create_error; } @@ -1019,10 +1019,10 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL) { if ((pc->bins = calloc(output_bin->num_choices, - sizeof(_pwg_map_t))) == NULL) + sizeof(pwg_map_t))) == NULL) { DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d " - "_pwg_map_t's for OutputBin.", output_bin->num_choices)); + "pwg_map_t's for OutputBin.", output_bin->num_choices)); goto create_error; } @@ -1456,8 +1456,8 @@ void _ppdCacheDestroy(_ppd_cache_t *pc) /* I - PPD cache and mapping data */ { int i; /* Looping var */ - _pwg_map_t *map; /* Current map */ - _pwg_size_t *size; /* Current size */ + pwg_map_t *map; /* Current map */ + pwg_size_t *size; /* Current size */ /* @@ -1720,7 +1720,7 @@ _ppdCacheGetInputSlot( ipp_attribute_t *media_col, /* media-col attribute */ *media_source; /* media-source attribute */ - _pwg_size_t size; /* Dimensional size */ + pwg_size_t size; /* Dimensional size */ int margins_set; /* Were the margins set? */ media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION); @@ -1735,7 +1735,7 @@ _ppdCacheGetInputSlot( keyword = ippGetString(media_source, 0, NULL); } - else if (_pwgInitSize(&size, job, &margins_set)) + else if (pwgInitSize(&size, job, &margins_set)) { /* * For media <= 5x7, look for a photo tray... @@ -1859,7 +1859,7 @@ _ppdCacheGetPageSize( int *exact) /* O - 1 if exact match, 0 otherwise */ { int i; /* Looping var */ - _pwg_size_t *size, /* Current size */ + pwg_size_t *size, /* Current size */ *closest, /* Closest size */ jobsize; /* Size data from job */ int margins_set, /* Were the margins set? */ @@ -1947,7 +1947,7 @@ _ppdCacheGetPageSize( * media-col. */ - if (!_pwgInitSize(&jobsize, job, &margins_set)) + if (!pwgInitSize(&jobsize, job, &margins_set)) return (NULL); } else @@ -1956,12 +1956,12 @@ _ppdCacheGetPageSize( * Get the size using a media keyword... */ - _pwg_media_t *media; /* Media definition */ + pwg_media_t *media; /* Media definition */ - if ((media = _pwgMediaForPWG(keyword)) == NULL) - if ((media = _pwgMediaForLegacy(keyword)) == NULL) - if ((media = _pwgMediaForPPD(keyword)) == NULL) + if ((media = pwgMediaForPWG(keyword)) == NULL) + if ((media = pwgMediaForLegacy(keyword)) == NULL) + if ((media = pwgMediaForPPD(keyword)) == NULL) return (NULL); jobsize.width = media->width; @@ -2054,7 +2054,7 @@ _ppdCacheGetPageSize( */ snprintf(pc->custom_ppd_size, sizeof(pc->custom_ppd_size), "Custom.%dx%d", - (int)_PWG_TOPTS(jobsize.width), (int)_PWG_TOPTS(jobsize.length)); + (int)PWG_TO_POINTS(jobsize.width), (int)PWG_TO_POINTS(jobsize.length)); if (margins_set && exact) { @@ -2090,14 +2090,14 @@ _ppdCacheGetPageSize( * '_ppdCacheGetSize()' - Get the PWG size associated with a PPD PageSize. */ -_pwg_size_t * /* O - PWG size or NULL */ +pwg_size_t * /* O - PWG size or NULL */ _ppdCacheGetSize( _ppd_cache_t *pc, /* I - PPD cache and mapping data */ const char *page_size) /* I - PPD PageSize */ { int i; /* Looping var */ - _pwg_media_t *media; /* Media */ - _pwg_size_t *size; /* Current size */ + pwg_media_t *media; /* Media */ + pwg_size_t *size; /* Current size */ /* @@ -2183,9 +2183,9 @@ _ppdCacheGetSize( * Look up standard sizes... */ - if ((media = _pwgMediaForPPD(page_size)) == NULL) - if ((media = _pwgMediaForLegacy(page_size)) == NULL) - media = _pwgMediaForPWG(page_size); + if ((media = pwgMediaForPPD(page_size)) == NULL) + if ((media = pwgMediaForLegacy(page_size)) == NULL) + media = pwgMediaForPWG(page_size); if (media) { @@ -2210,7 +2210,7 @@ _ppdCacheGetSource( const char *input_slot) /* I - PPD InputSlot */ { int i; /* Looping var */ - _pwg_map_t *source; /* Current source */ + pwg_map_t *source; /* Current source */ /* @@ -2239,7 +2239,7 @@ _ppdCacheGetType( const char *media_type) /* I - PPD MediaType */ { int i; /* Looping var */ - _pwg_map_t *type; /* Current type */ + pwg_map_t *type; /* Current type */ /* @@ -2269,8 +2269,8 @@ _ppdCacheWriteFile( { int i, j, k; /* Looping vars */ cups_file_t *fp; /* Output file */ - _pwg_size_t *size; /* Current size */ - _pwg_map_t *map; /* Current map */ + pwg_size_t *size; /* Current size */ + pwg_map_t *map; /* Current map */ _pwg_finishings_t *f; /* Current finishing option */ cups_option_t *option; /* Current option */ const char *value; /* Filter/pre-filter value */ @@ -2584,7 +2584,7 @@ _pwgMediaTypeForType( const char * /* O - PageSize name */ _pwgPageSizeForMedia( - _pwg_media_t *media, /* I - Media */ + pwg_media_t *media, /* I - Media */ char *name, /* I - PageSize name buffer */ size_t namesize) /* I - Size of name buffer */ { @@ -2620,8 +2620,8 @@ _pwgPageSizeForMedia( * Use a name of the form "wNNNhNNN"... */ - snprintf(name, namesize, "w%dh%d", (int)_PWG_TOPTS(media->width), - (int)_PWG_TOPTS(media->length)); + snprintf(name, namesize, "w%dh%d", (int)PWG_TO_POINTS(media->width), + (int)PWG_TO_POINTS(media->length)); } else { diff --git a/cups/ppd-private.h b/cups/ppd-private.h index 28016d632..c6c25325b 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -3,7 +3,7 @@ * * Private PPD definitions for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -112,9 +112,9 @@ typedef struct _pwg_finishings_s /**** PWG finishings mapping data ****/ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/ { int num_bins; /* Number of output bins */ - _pwg_map_t *bins; /* Output bins */ + pwg_map_t *bins; /* Output bins */ int num_sizes; /* Number of media sizes */ - _pwg_size_t *sizes; /* Media sizes */ + pwg_size_t *sizes; /* Media sizes */ int custom_max_width, /* Maximum custom width in 2540ths */ custom_max_length, /* Maximum custom length in 2540ths */ custom_min_width, /* Minimum custom width in 2540ths */ @@ -122,12 +122,12 @@ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/ char *custom_max_keyword, /* Maximum custom size PWG keyword */ *custom_min_keyword, /* Minimum custom size PWG keyword */ custom_ppd_size[41]; /* Custom PPD size name */ - _pwg_size_t custom_size; /* Custom size record */ + pwg_size_t custom_size; /* Custom size record */ char *source_option; /* PPD option for media source */ int num_sources; /* Number of media sources */ - _pwg_map_t *sources; /* Media sources */ + pwg_map_t *sources; /* Media sources */ int num_types; /* Number of media types */ - _pwg_map_t *types; /* Media types */ + pwg_map_t *types; /* Media types */ int num_presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX]; /* Number of print-color-mode/print-quality options */ cups_option_t *presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX]; @@ -179,7 +179,7 @@ extern const char *_ppdCacheGetOutputBin(_ppd_cache_t *pc, const char *keyword); extern const char *_ppdCacheGetPageSize(_ppd_cache_t *pc, ipp_t *job, const char *keyword, int *exact); -extern _pwg_size_t *_ppdCacheGetSize(_ppd_cache_t *pc, +extern pwg_size_t *_ppdCacheGetSize(_ppd_cache_t *pc, const char *page_size); extern const char *_ppdCacheGetSource(_ppd_cache_t *pc, const char *input_slot); @@ -207,7 +207,7 @@ extern const char *_pwgInputSlotForSource(const char *media_source, char *name, size_t namesize); extern const char *_pwgMediaTypeForType(const char *media_type, char *name, size_t namesize); -extern const char *_pwgPageSizeForMedia(_pwg_media_t *media, +extern const char *_pwgPageSizeForMedia(pwg_media_t *media, char *name, size_t namesize); diff --git a/cups/pwg-media.c b/cups/pwg-media.c index 1c2940bf8..cd392ef98 100644 --- a/cups/pwg-media.c +++ b/cups/pwg-media.c @@ -3,7 +3,7 @@ * * PWG media name API implementation for CUPS. * - * Copyright 2009-2012 by Apple Inc. + * Copyright 2009-2013 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -15,19 +15,20 @@ * * Contents: * - * _pwgFormatInches() - Convert and format PWG units as inches. - * _pwgFormatMillimeters() - Convert and format PWG units as millimeters. - * _pwgGenerateSize() - Generate a PWG size keyword. - * _pwgInitSize() - Initialize a PWG size using IPP job template - * attributes. - * _pwgMediaForLegacy() - Find a PWG media size by ISO/IPP legacy name. - * _pwgMediaForPPD() - Find a PWG media size by Adobe PPD name. - * _pwgMediaForPWG() - Find a PWG media size by 5101.1 self-describing - * name. - * _pwgMediaForSize() - Get the PWG media name for a given size. - * pwg_compare_legacy() - Compare two sizes using the legacy names. - * pwg_compare_ppd() - Compare two sizes using the PPD names. - * pwg_compare_pwg() - Compare two sizes using the PWG names. + * pwgFormatSizeName() - Generate a PWG self-describing media size name. + * pwgInitSize() - Initialize a pwg_size_t structure using IPP Job + * Template attributes. + * pwgMediaForLegacy() - Find a PWG media size by ISO/IPP legacy name. + * pwgMediaForPPD() - Find a PWG media size by Adobe PPD name. + * pwgMediaForPWG() - Find a PWG media size by 5101.1 self-describing + * name. + * pwgMediaForSize() - Get the PWG media size for the given + * dimensions. + * pwg_compare_legacy() - Compare two sizes using the legacy names. + * pwg_compare_ppd() - Compare two sizes using the PPD names. + * pwg_compare_pwg() - Compare two sizes using the PWG names. + * pwg_format_inches() - Convert and format PWG units as inches. + * pwg_format_millimeters() - Convert and format PWG units as millimeters. */ /* @@ -50,16 +51,18 @@ * Local functions... */ -static int pwg_compare_legacy(_pwg_media_t *a, _pwg_media_t *b); -static int pwg_compare_pwg(_pwg_media_t *a, _pwg_media_t *b); -static int pwg_compare_ppd(_pwg_media_t *a, _pwg_media_t *b); +static int pwg_compare_legacy(pwg_media_t *a, pwg_media_t *b); +static int pwg_compare_pwg(pwg_media_t *a, pwg_media_t *b); +static int pwg_compare_ppd(pwg_media_t *a, pwg_media_t *b); +static char *pwg_format_inches(char *buf, size_t bufsize, int val); +static char *pwg_format_millimeters(char *buf, size_t bufsize, int val); /* * Local globals... */ -static _pwg_media_t const cups_pwg_media[] = +static pwg_media_t const cups_pwg_media[] = { /* Media size lookup table */ /* North American Standard Sheet Media Sizes */ _PWG_MEDIA_IN("na_index-3x5_3x5in", NULL, "3x5", 3, 5), @@ -255,126 +258,122 @@ static _pwg_media_t const cups_pwg_media[] = /* - * '_pwgFormatInches()' - Convert and format PWG units as inches. + * 'pwgFormatSizeName()' - Generate a PWG self-describing media size name. + * + * This function generates a PWG self-describing media size name of the form + * "prefix_name_WIDTHxLENGTHunits". The prefix is typically "custom" or "roll" + * for user-supplied sizes but can also be "disc", "iso", "jis", "jpn", "na", + * "oe", "om", "prc", or "roc". A value of @code NULL@ automatically chooses + * "oe" or "om" depending on the units. + * + * The size name may only contain lowercase letters, numbers, "-", and ".". If + * @code NULL@ is passed, the size name will contain the formatted dimensions. + * + * The width and length are specified in hundredths of millimeters, equivalent + * to 1/100000th of a meter or 1/2540th of an inch. The width, length, and + * units used for the generated size name are calculated automatically if the + * units string is @code NULL@, otherwise inches ("in") or millimeters ("mm") + * are used. + * + * @since CUPS 1.7@ */ -char * /* O - String */ -_pwgFormatInches(char *buf, /* I - Buffer */ - size_t bufsize, /* I - Size of buffer */ - int val) /* I - Value in hundredths of millimeters */ +int /* O - 1 on success, 0 on failure */ +pwgFormatSizeName(char *keyword, /* I - Keyword buffer */ + size_t keysize, /* I - Size of keyword buffer */ + const char *prefix, /* I - Prefix for PWG size or @code NULL@ for automatic */ + const char *name, /* I - Size name or @code NULL@ */ + int width, /* I - Width of page in 2540ths */ + int length, /* I - Length of page in 2540ths */ + const char *units) /* I - Units - "in", "mm", or @code NULL@ for automatic */ { - int thousandths, /* Thousandths of inches */ - integer, /* Integer portion */ - fraction; /* Fractional portion */ + char usize[12 + 1 + 12 + 3], /* Unit size: NNNNNNNNNNNNxNNNNNNNNNNNNuu */ + *uptr; /* Pointer into unit size */ + char *(*format)(char *, size_t, int); + /* Formatting function */ /* - * Convert hundredths of millimeters to thousandths of inches and round to - * the nearest thousandth. + * Range check input... */ - thousandths = (val * 1000 + 1270) / 2540; - integer = thousandths / 1000; - fraction = thousandths % 1000; + DEBUG_printf(("pwgFormatSize(keyword=%p, keysize=" CUPS_LLFMT + ", prefix=\"%s\", name=\"%s\", width=%d, length=%d, " + "units=\"%s\")", keyword, CUPS_LLCAST keysize, prefix, name, + width, length, units)); - /* - * Format as a pair of integers (avoids locale stuff), avoiding trailing - * zeros... - */ + if (keyword) + *keyword = '\0'; - if (fraction == 0) - snprintf(buf, bufsize, "%d", integer); - else if (fraction % 10) - snprintf(buf, bufsize, "%d.%03d", integer, fraction); - else if (fraction % 100) - snprintf(buf, bufsize, "%d.%02d", integer, fraction / 10); - else - snprintf(buf, bufsize, "%d.%01d", integer, fraction / 100); - - return (buf); -} - - -/* - * '_pwgFormatMillimeters()' - Convert and format PWG units as millimeters. - */ - -char * /* O - String */ -_pwgFormatMillimeters(char *buf, /* I - Buffer */ - size_t bufsize, /* I - Size of buffer */ - int val) /* I - Value in hundredths of millimeters */ -{ - int integer, /* Integer portion */ - fraction; /* Fractional portion */ - - - /* - * Convert hundredths of millimeters to integer and fractional portions. - */ + if (!keyword || keysize < 32 || width < 0 || length < 0 || + (units && strcmp(units, "in") && strcmp(units, "mm"))) + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid media name arguments."), + 1); + return (0); + } - integer = val / 100; - fraction = val % 100; + if (name) + { + /* + * Validate name... + */ - /* - * Format as a pair of integers (avoids locale stuff), avoiding trailing - * zeros... - */ + const char *nameptr; /* Pointer into name */ - if (fraction == 0) - snprintf(buf, bufsize, "%d", integer); - else if (fraction % 10) - snprintf(buf, bufsize, "%d.%02d", integer, fraction); + for (nameptr = name; *nameptr; nameptr ++) + if (!(*nameptr >= 'a' && *nameptr <= 'z') && + !(*nameptr >= '0' && *nameptr <= '9') && + *nameptr != '.' && *nameptr != '-') + { + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, + _("Invalid media name arguments."), 1); + return (0); + } + } else - snprintf(buf, bufsize, "%d.%01d", integer, fraction / 10); - - return (buf); -} + name = usize; -/* - * '_pwgGenerateSize()' - Generate a PWG size keyword. - */ + if (!units) + { + if ((width % 635) == 0 && (length % 635) == 0) + { + /* + * Use inches since the size is a multiple of 1/4 inch. + */ -void -_pwgGenerateSize(char *keyword, /* I - Keyword buffer */ - size_t keysize, /* I - Size of keyword buffer */ - const char *prefix, /* I - Prefix for PWG size or NULL */ - const char *name, /* I - Size name or NULL */ - int width, /* I - Width of page in 2540ths */ - int length) /* I - Length of page in 2540ths */ -{ - const char *units; /* Units to report */ - char usize[12 + 1 + 12 + 3], /* Unit size: NNNNNNNNNNNNxNNNNNNNNNNNNuu */ - *uptr; /* Pointer into unit size */ - char *(*format)(char *, size_t, int); - /* Formatting function */ + units = "in"; + } + else + { + /* + * Use millimeters since the size is not a multiple of 1/4 inch. + */ + units = "mm"; + } + } - if ((width % 635) == 0 && (length % 635) == 0) + if (!strcmp(units, "in")) { - /* - * Use inches since the size is a multiple of 1/4 inch. - */ - - units = "in"; - format = _pwgFormatInches; + format = pwg_format_inches; if (!prefix) prefix = "oe"; } else { - /* - * Use millimeters since the size is not a multiple of 1/4 inch. - */ - - units = "mm"; - format = _pwgFormatMillimeters; + format = pwg_format_millimeters; if (!prefix) prefix = "om"; } + /* + * Format the size string... + */ + uptr = usize; (*format)(uptr, sizeof(usize) - (uptr - usize), width); uptr += strlen(uptr); @@ -388,25 +387,40 @@ _pwgGenerateSize(char *keyword, /* I - Keyword buffer */ memcpy(uptr, units, 3); - if (!name) - name = usize; - /* * Format the name... */ snprintf(keyword, keysize, "%s_%s_%s", prefix, name, usize); + + return (1); } +/* For OS X 10.8 and earlier... */ +void _pwgGenerateSize(char *keyword, size_t keysize, const char *prefix, + const char *name, int width, int length) +{ pwgFormatSizeName(keyword, keysize, prefix, name, width, length, NULL); } + /* - * '_pwgInitSize()' - Initialize a PWG size using IPP job template attributes. + * 'pwgInitSize()' - Initialize a pwg_size_t structure using IPP Job Template + * attributes. + * + * This function initializes a pwg_size_t structure from an IPP "media" or + * "media-col" attribute in the specified IPP message. 0 is returned if neither + * attribute is found in the message or the values are not valid. + * + * The "margins_set" variable is initialized to 1 if any "media-xxx-margin" + * member attribute was specified in the "media-col" Job Template attribute, + * otherwise it is initialized to 0. + * + * @since CUPS 1.7@ */ -int /* O - 1 if size was initialize, 0 otherwise */ -_pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ - ipp_t *job, /* I - Job template attributes */ - int *margins_set) /* O - 1 if margins were set, 0 otherwise */ +int /* O - 1 if size was initialized, 0 otherwise */ +pwgInitSize(pwg_size_t *size, /* I - Size to initialize */ + ipp_t *job, /* I - Job template attributes */ + int *margins_set) /* O - 1 if margins were set, 0 otherwise */ { ipp_attribute_t *media, /* media attribute */ *media_bottom_margin, /* media-bottom-margin member attribute */ @@ -417,7 +431,7 @@ _pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ *media_top_margin, /* media-top-margin member attribute */ *x_dimension, /* x-dimension member attribute */ *y_dimension; /* y-dimension member attribute */ - _pwg_media_t *pwg; /* PWG media value */ + pwg_media_t *pwg; /* PWG media value */ /* @@ -431,7 +445,7 @@ _pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ * Look for media-col and then media... */ - memset(size, 0, sizeof(_pwg_size_t)); + memset(size, 0, sizeof(pwg_size_t)); *margins_set = 0; if ((media_col = ippFindAttribute(job, "media-col", @@ -515,13 +529,13 @@ _pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ const char *name = media->values[0].string.text; /* Name string */ - if ((pwg = _pwgMediaForPWG(name)) == NULL) + if ((pwg = pwgMediaForPWG(name)) == NULL) { /* * Not a PWG name, try a legacy name... */ - if ((pwg = _pwgMediaForLegacy(name)) == NULL) + if ((pwg = pwgMediaForLegacy(name)) == NULL) { /* * Not a legacy name, try a PPD name... @@ -529,7 +543,7 @@ _pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ const char *suffix; /* Suffix on media string */ - pwg = _pwgMediaForPPD(name); + pwg = pwgMediaForPPD(name); if (pwg && (suffix = name + strlen(name) - 10 /* .FullBleed */) > name && !_cups_strcasecmp(suffix, ".FullBleed")) @@ -564,16 +578,24 @@ _pwgInitSize(_pwg_size_t *size, /* I - Size to initialize */ return (1); } +/* For OS X 10.8 and earlier */ +int _pwgInitSize(pwg_size_t *size, ipp_t *job, int *margins_set) +{ return (pwgInitSize(size, job, margins_set)); } + /* - * '_pwgMediaForLegacy()' - Find a PWG media size by ISO/IPP legacy name. + * 'pwgMediaForLegacy()' - Find a PWG media size by ISO/IPP legacy name. + * + * The "name" argument specifies the legacy ISO media size name, for example + * "iso-a4" or "na-letter". + * + * @since CUPS 1.7@ */ -_pwg_media_t * /* O - Matching size or NULL */ -_pwgMediaForLegacy( - const char *legacy) /* I - Legacy size name */ +pwg_media_t * /* O - Matching size or NULL */ +pwgMediaForLegacy(const char *legacy) /* I - Legacy size name */ { - _pwg_media_t key; /* Search key */ + pwg_media_t key; /* Search key */ _cups_globals_t *cg = _cupsGlobals(); /* Global data */ @@ -591,13 +613,13 @@ _pwgMediaForLegacy( if (!cg->leg_size_lut) { int i; /* Looping var */ - _pwg_media_t *size; /* Current size */ + pwg_media_t *size; /* Current size */ cg->leg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_legacy, NULL); for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])), - size = (_pwg_media_t *)cups_pwg_media; + size = (pwg_media_t *)cups_pwg_media; i > 0; i --, size ++) if (size->legacy) @@ -609,18 +631,33 @@ _pwgMediaForLegacy( */ key.legacy = legacy; - return ((_pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key)); + return ((pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key)); } +/* For OS X 10.8 and earlier */ +pwg_media_t *_pwgMediaForLegacy(const char *legacy) +{ return (pwgMediaForLegacy(legacy)); } + /* - * '_pwgMediaForPPD()' - Find a PWG media size by Adobe PPD name. + * 'pwgMediaForPPD()' - Find a PWG media size by Adobe PPD name. + * + * The "ppd" argument specifies an Adobe page size name as defined in Table B.1 + * of the Adobe PostScript Printer Description File Format Specification Version + * 4.3. + * + * If the name is non-standard, the returned PWG media size is stored in + * thread-local storage and is overwritten by each call to the function in the + * thread. Custom names can be of the form "Custom.WIDTHxLENGTH[units]" or + * "WIDTHxLENGTH[units]". + * + * @since CUPS 1.7@ */ -_pwg_media_t * /* O - Matching size or NULL */ -_pwgMediaForPPD(const char *ppd) /* I - PPD size name */ +pwg_media_t * /* O - Matching size or NULL */ +pwgMediaForPPD(const char *ppd) /* I - PPD size name */ { - _pwg_media_t key, /* Search key */ + pwg_media_t key, /* Search key */ *size; /* Matching size */ _cups_globals_t *cg = _cupsGlobals(); /* Global data */ @@ -643,7 +680,7 @@ _pwgMediaForPPD(const char *ppd) /* I - PPD size name */ cg->ppd_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_ppd, NULL); for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])), - size = (_pwg_media_t *)cups_pwg_media; + size = (pwg_media_t *)cups_pwg_media; i > 0; i --, size ++) if (size->ppd) @@ -655,7 +692,7 @@ _pwgMediaForPPD(const char *ppd) /* I - PPD size name */ */ key.ppd = ppd; - if ((size = (_pwg_media_t *)cupsArrayFind(cg->ppd_size_lut, &key)) == NULL) + if ((size = (pwg_media_t *)cupsArrayFind(cg->ppd_size_lut, &key)) == NULL) { /* * See if the name is of the form: @@ -737,9 +774,9 @@ _pwgMediaForPPD(const char *ppd) /* I - PPD size name */ size->length = (int)(l * factor); size->pwg = cg->pwg_name; - _pwgGenerateSize(cg->pwg_name, sizeof(cg->pwg_name), - custom ? "custom" : NULL, custom ? ppd + 7 : NULL, - size->width, size->length); + pwgFormatSizeName(cg->pwg_name, sizeof(cg->pwg_name), + custom ? "custom" : NULL, custom ? ppd + 7 : NULL, + size->width, size->length, NULL); } } } @@ -747,16 +784,29 @@ _pwgMediaForPPD(const char *ppd) /* I - PPD size name */ return (size); } +/* For OS X 10.8 and earlier */ +pwg_media_t *_pwgMediaForPPD(const char *ppd) +{ return (pwgMediaForPPD(ppd)); } + /* - * '_pwgMediaForPWG()' - Find a PWG media size by 5101.1 self-describing name. + * 'pwgMediaForPWG()' - Find a PWG media size by 5101.1 self-describing name. + * + * The "pwg" argument specifies a self-describing media size name of the form + * "prefix_name_WIDTHxLENGTHunits" as defined in PWG 5101.1. + * + * If the name is non-standard, the returned PWG media size is stored in + * thread-local storage and is overwritten by each call to the function in the + * thread. + * + * @since CUPS 1.7@ */ -_pwg_media_t * /* O - Matching size or NULL */ -_pwgMediaForPWG(const char *pwg) /* I - PWG size name */ +pwg_media_t * /* O - Matching size or NULL */ +pwgMediaForPWG(const char *pwg) /* I - PWG size name */ { char *ptr; /* Pointer into name */ - _pwg_media_t key, /* Search key */ + pwg_media_t key, /* Search key */ *size; /* Matching size */ _cups_globals_t *cg = _cupsGlobals(); /* Global data */ @@ -779,7 +829,7 @@ _pwgMediaForPWG(const char *pwg) /* I - PWG size name */ cg->pwg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_pwg, NULL); for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])), - size = (_pwg_media_t *)cups_pwg_media; + size = (pwg_media_t *)cups_pwg_media; i > 0; i --, size ++) cupsArrayAdd(cg->pwg_size_lut, size); @@ -790,7 +840,7 @@ _pwgMediaForPWG(const char *pwg) /* I - PWG size name */ */ key.pwg = pwg; - if ((size = (_pwg_media_t *)cupsArrayFind(cg->pwg_size_lut, &key)) == NULL && + if ((size = (pwg_media_t *)cupsArrayFind(cg->pwg_size_lut, &key)) == NULL && (ptr = (char *)strchr(pwg, '_')) != NULL && (ptr = (char *)strchr(ptr + 1, '_')) != NULL) { @@ -836,17 +886,30 @@ _pwgMediaForPWG(const char *pwg) /* I - PWG size name */ return (size); } +/* For OS X 10.8 and earlier */ +pwg_media_t *_pwgMediaForPWG(const char *pwg) +{ return (pwgMediaForPWG(pwg)); } + /* - * '_pwgMediaForSize()' - Get the PWG media name for a given size. + * 'pwgMediaForSize()' - Get the PWG media size for the given dimensions. + * + * The "width" and "length" are in hundredths of millimeters, equivalent to + * 1/100000th of a meter or 1/2540th of an inch. + * + * If the dimensions are non-standard, the returned PWG media size is stored in + * thread-local storage and is overwritten by each call to the function in the + * thread. + * + * @since CUPS 1.7@ */ -_pwg_media_t * /* O - PWG media name */ -_pwgMediaForSize(int width, /* I - Width in 2540ths */ - int length) /* I - Length in 2540ths */ +pwg_media_t * /* O - PWG media name */ +pwgMediaForSize(int width, /* I - Width in hundredths of millimeters */ + int length) /* I - Length in hundredths of millimeters */ { int i; /* Looping var */ - _pwg_media_t *media, /* Current media */ + pwg_media_t *media, /* Current media */ *best_media = NULL; /* Best match */ int dw, dl, /* Difference in width and length */ best_dw = 999, /* Best difference in width and length */ @@ -866,7 +929,7 @@ _pwgMediaForSize(int width, /* I - Width in 2540ths */ */ for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])), - media = (_pwg_media_t *)cups_pwg_media; + media = (pwg_media_t *)cups_pwg_media; i > 0; i --, media ++) { @@ -900,8 +963,8 @@ _pwgMediaForSize(int width, /* I - Width in 2540ths */ * custom_WIDTHxHEIGHTuu_WIDTHxHEIGHTuu */ - _pwgGenerateSize(cg->pwg_name, sizeof(cg->pwg_name), "custom", NULL, width, - length); + pwgFormatSizeName(cg->pwg_name, sizeof(cg->pwg_name), "custom", NULL, width, + length, NULL); cg->pwg_media.pwg = cg->pwg_name; cg->pwg_media.width = width; @@ -910,14 +973,18 @@ _pwgMediaForSize(int width, /* I - Width in 2540ths */ return (&(cg->pwg_media)); } +/* For OS X 10.8 and earlier */ +pwg_media_t *_pwgMediaForSize(int width, int length) +{ return (pwgMediaForSize(width, length)); } + /* * 'pwg_compare_legacy()' - Compare two sizes using the legacy names. */ static int /* O - Result of comparison */ -pwg_compare_legacy(_pwg_media_t *a, /* I - First size */ - _pwg_media_t *b) /* I - Second size */ +pwg_compare_legacy(pwg_media_t *a, /* I - First size */ + pwg_media_t *b) /* I - Second size */ { return (strcmp(a->legacy, b->legacy)); } @@ -928,8 +995,8 @@ pwg_compare_legacy(_pwg_media_t *a, /* I - First size */ */ static int /* O - Result of comparison */ -pwg_compare_ppd(_pwg_media_t *a, /* I - First size */ - _pwg_media_t *b) /* I - Second size */ +pwg_compare_ppd(pwg_media_t *a, /* I - First size */ + pwg_media_t *b) /* I - Second size */ { return (strcmp(a->ppd, b->ppd)); } @@ -940,13 +1007,90 @@ pwg_compare_ppd(_pwg_media_t *a, /* I - First size */ */ static int /* O - Result of comparison */ -pwg_compare_pwg(_pwg_media_t *a, /* I - First size */ - _pwg_media_t *b) /* I - Second size */ +pwg_compare_pwg(pwg_media_t *a, /* I - First size */ + pwg_media_t *b) /* I - Second size */ { return (strcmp(a->pwg, b->pwg)); } +/* + * 'pwg_format_inches()' - Convert and format PWG units as inches. + */ + +static char * /* O - String */ +pwg_format_inches(char *buf, /* I - Buffer */ + size_t bufsize, /* I - Size of buffer */ + int val) /* I - Value in hundredths of millimeters */ +{ + int thousandths, /* Thousandths of inches */ + integer, /* Integer portion */ + fraction; /* Fractional portion */ + + + /* + * Convert hundredths of millimeters to thousandths of inches and round to + * the nearest thousandth. + */ + + thousandths = (val * 1000 + 1270) / 2540; + integer = thousandths / 1000; + fraction = thousandths % 1000; + + /* + * Format as a pair of integers (avoids locale stuff), avoiding trailing + * zeros... + */ + + if (fraction == 0) + snprintf(buf, bufsize, "%d", integer); + else if (fraction % 10) + snprintf(buf, bufsize, "%d.%03d", integer, fraction); + else if (fraction % 100) + snprintf(buf, bufsize, "%d.%02d", integer, fraction / 10); + else + snprintf(buf, bufsize, "%d.%01d", integer, fraction / 100); + + return (buf); +} + + +/* + * 'pwg_format_millimeters()' - Convert and format PWG units as millimeters. + */ + +static char * /* O - String */ +pwg_format_millimeters(char *buf, /* I - Buffer */ + size_t bufsize, /* I - Size of buffer */ + int val) /* I - Value in hundredths of millimeters */ +{ + int integer, /* Integer portion */ + fraction; /* Fractional portion */ + + + /* + * Convert hundredths of millimeters to integer and fractional portions. + */ + + integer = val / 100; + fraction = val % 100; + + /* + * Format as a pair of integers (avoids locale stuff), avoiding trailing + * zeros... + */ + + if (fraction == 0) + snprintf(buf, bufsize, "%d", integer); + else if (fraction % 10) + snprintf(buf, bufsize, "%d.%02d", integer, fraction); + else + snprintf(buf, bufsize, "%d.%01d", integer, fraction / 10); + + return (buf); +} + + /* * End of "$Id$". */ diff --git a/cups/pwg-private.h b/cups/pwg-private.h index 33361c1c0..ad097bf53 100644 --- a/cups/pwg-private.h +++ b/cups/pwg-private.h @@ -3,7 +3,7 @@ * * Private PWG media API definitions for CUPS. * - * Copyright 2009-2012 by Apple Inc. + * Copyright 2009-2013 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -35,63 +35,36 @@ extern "C" { /* - * Macros... + * Deprecated stuff for prior users of the private PWG media API... */ -/* Convert from points to 2540ths */ -# define _PWG_FROMPTS(n) (int)(((n) * 2540 + 36) / 72) -/* Convert from 2540ths to points */ -# define _PWG_TOPTS(n) ((n) * 72.0 / 2540.0) - - -/* - * Types and structures... - */ - -typedef struct _pwg_map_s /**** Map element - PPD to/from PWG */ -{ - char *pwg, /* PWG media keyword */ - *ppd; /* PPD option keyword */ -} _pwg_map_t; - -typedef struct _pwg_media_s /**** Common media size data ****/ -{ - const char *pwg, /* PWG 5101.1 "self describing" name */ - *legacy, /* IPP/ISO legacy name */ - *ppd; /* Standard Adobe PPD name */ - int width, /* Width in 2540ths */ - length; /* Length in 2540ths */ -} _pwg_media_t; - -typedef struct _pwg_size_s /**** Size element - PPD to/from PWG */ -{ - _pwg_map_t map; /* Map element */ - int width, /* Width in 2540ths */ - length, /* Length in 2540ths */ - left, /* Left margin in 2540ths */ - bottom, /* Bottom margin in 2540ths */ - right, /* Right margin in 2540ths */ - top; /* Top margin in 2540ths */ -} _pwg_size_t; +# ifndef _CUPS_NO_DEPRECATED +typedef struct pwg_map_s _pwg_map_t; +typedef struct pwg_media_s _pwg_media_t; +typedef struct pwg_size_s _pwg_size_t; +# endif /* _CUPS_NO_DEPRECATED */ /* * Functions... */ -extern char *_pwgFormatInches(char *buf, size_t bufsize, int val); -extern char *_pwgFormatMillimeters(char *buf, size_t bufsize, - int val); extern void _pwgGenerateSize(char *keyword, size_t keysize, const char *prefix, const char *name, - int width, int length); -extern int _pwgInitSize(_pwg_size_t *size, ipp_t *job, - int *margins_set); -extern _pwg_media_t *_pwgMediaForLegacy(const char *legacy); -extern _pwg_media_t *_pwgMediaForPPD(const char *ppd); -extern _pwg_media_t *_pwgMediaForPWG(const char *pwg); -extern _pwg_media_t *_pwgMediaForSize(int width, int length); + int width, int length) + _CUPS_INTERNAL_MSG("Use pwgFormatSizeName instead."); +extern int _pwgInitSize(pwg_size_t *size, ipp_t *job, + int *margins_set) + _CUPS_INTERNAL_MSG("Use pwgInitSize instead."); +extern pwg_media_t *_pwgMediaForLegacy(const char *legacy) + _CUPS_INTERNAL_MSG("Use pwgMediaForLegacy instead."); +extern pwg_media_t *_pwgMediaForPPD(const char *ppd) + _CUPS_INTERNAL_MSG("Use pwgMediaForPPD instead."); +extern pwg_media_t *_pwgMediaForPWG(const char *pwg) + _CUPS_INTERNAL_MSG("Use pwgMediaForPWG instead."); +extern pwg_media_t *_pwgMediaForSize(int width, int length) + _CUPS_INTERNAL_MSG("Use pwgMediaForSize instead."); # ifdef __cplusplus } diff --git a/cups/pwg.h b/cups/pwg.h new file mode 100644 index 000000000..505778e15 --- /dev/null +++ b/cups/pwg.h @@ -0,0 +1,94 @@ +/* + * "$Id$" + * + * PWG media API definitions for CUPS. + * + * Copyright 2009-2013 by Apple Inc. + * + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". + * + * This file is subject to the Apple OS-Developed Software exception. + */ + +#ifndef _CUPS_PWG_H_ +# define _CUPS_PWG_H_ + + +/* + * C++ magic... + */ + +# ifdef __cplusplus +extern "C" { +# endif /* __cplusplus */ + + +/* + * Macros... + */ + +/* Convert from points to hundredths of millimeters */ +# define PWG_FROM_POINTS(n) (int)(((n) * 2540 + 36) / 72) +/* Convert from hundredths of millimeters to points */ +# define PWG_TO_POINTS(n) ((n) * 72.0 / 2540.0) + + +/* + * Types and structures... + */ + +typedef struct pwg_map_s /**** Map element - PPD to/from PWG */ +{ + char *pwg, /* PWG media keyword */ + *ppd; /* PPD option keyword */ +} pwg_map_t; + +typedef struct pwg_media_s /**** Common media size data ****/ +{ + const char *pwg, /* PWG 5101.1 "self describing" name */ + *legacy, /* IPP/ISO legacy name */ + *ppd; /* Standard Adobe PPD name */ + int width, /* Width in 2540ths */ + length; /* Length in 2540ths */ +} pwg_media_t; + +typedef struct pwg_size_s /**** Size element - PPD to/from PWG */ +{ + pwg_map_t map; /* Map element */ + int width, /* Width in 2540ths */ + length, /* Length in 2540ths */ + left, /* Left margin in 2540ths */ + bottom, /* Bottom margin in 2540ths */ + right, /* Right margin in 2540ths */ + top; /* Top margin in 2540ths */ +} pwg_size_t; + + +/* + * Functions... + */ + +extern int pwgFormatSizeName(char *keyword, size_t keysize, + const char *prefix, const char *name, + int width, int length, + const char *units) _CUPS_API_1_7; +extern int pwgInitSize(pwg_size_t *size, ipp_t *job, + int *margins_set) _CUPS_API_1_7; +extern pwg_media_t *pwgMediaForLegacy(const char *legacy) _CUPS_API_1_7; +extern pwg_media_t *pwgMediaForPPD(const char *ppd) _CUPS_API_1_7; +extern pwg_media_t *pwgMediaForPWG(const char *pwg) _CUPS_API_1_7; +extern pwg_media_t *pwgMediaForSize(int width, int length) _CUPS_API_1_7; + +# ifdef __cplusplus +} +# endif /* __cplusplus */ + +#endif /* !_CUPS_PWG_H_ */ + +/* + * End of "$Id$". + */ diff --git a/cups/request.c b/cups/request.c index f5f2638d0..5b0559dc7 100644 --- a/cups/request.c +++ b/cups/request.c @@ -358,7 +358,8 @@ cupsGetResponse(http_t *http, /* I - Connection to server or @code CUPS_HTTP if (!http) http = _cupsConnect(); - if (!http || (http->state != HTTP_STATE_POST_RECV && http->state != HTTP_STATE_POST_SEND)) + if (!http || (http->state != HTTP_STATE_POST_RECV && + http->state != HTTP_STATE_POST_SEND)) return (NULL); /* diff --git a/cups/testhttp.c b/cups/testhttp.c index c4bd08e9b..e6823abd1 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -131,6 +131,8 @@ static uri_test_t uri_tests[] = /* URI test data */ "http", "", "", "", 80, 0 }, { HTTP_URI_STATUS_BAD_HOSTNAME, "http://serve%7/index.html", "http", "", "", "", 80, 0 }, + { HTTP_URI_STATUS_BAD_HOSTNAME, "http://server with spaces/index.html", + "http", "", "", "", 80, 0 }, /* Bad port number */ { HTTP_URI_STATUS_BAD_PORT, "http://127.0.0.1:9999a/index.html", @@ -138,6 +140,8 @@ static uri_test_t uri_tests[] = /* URI test data */ /* Bad resource */ { HTTP_URI_STATUS_BAD_RESOURCE, "http://server/index.html%", + "http", "", "server", "", 80, 0 }, + { HTTP_URI_STATUS_BAD_RESOURCE, "http://server/index with spaces.html", "http", "", "server", "", 80, 0 } }; static const char * const base64_tests[][2] = diff --git a/cups/testpwg.c b/cups/testpwg.c index a352f9ffc..b3d5cead5 100644 --- a/cups/testpwg.c +++ b/cups/testpwg.c @@ -3,7 +3,7 @@ * * PWG test program for CUPS. * - * Copyright 2009-2012 by Apple Inc. + * Copyright 2009-2013 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -49,7 +49,7 @@ main(int argc, /* I - Number of command-line args */ const char *ppdfile; /* PPD filename */ ppd_file_t *ppd; /* PPD file */ _ppd_cache_t *pc; /* PPD cache and PWG mapping data */ - _pwg_media_t *pwgmedia; /* PWG media size */ + pwg_media_t *pwgmedia; /* PWG media size */ status = 0; @@ -151,8 +151,8 @@ main(int argc, /* I - Number of command-line args */ puts("PASS"); } - fputs("_pwgMediaForPWG(\"iso_a4_210x297mm\"): ", stdout); - if ((pwgmedia = _pwgMediaForPWG("iso_a4_210x297mm")) == NULL) + fputs("pwgMediaForPWG(\"iso_a4_210x297mm\"): ", stdout); + if ((pwgmedia = pwgMediaForPWG("iso_a4_210x297mm")) == NULL) { puts("FAIL (not found)"); status ++; @@ -170,8 +170,8 @@ main(int argc, /* I - Number of command-line args */ else puts("PASS"); - fputs("_pwgMediaForLegacy(\"na-letter\"): ", stdout); - if ((pwgmedia = _pwgMediaForLegacy("na-letter")) == NULL) + fputs("pwgMediaForLegacy(\"na-letter\"): ", stdout); + if ((pwgmedia = pwgMediaForLegacy("na-letter")) == NULL) { puts("FAIL (not found)"); status ++; @@ -189,8 +189,8 @@ main(int argc, /* I - Number of command-line args */ else puts("PASS"); - fputs("_pwgMediaForPPD(\"4x6\"): ", stdout); - if ((pwgmedia = _pwgMediaForPPD("4x6")) == NULL) + fputs("pwgMediaForPPD(\"4x6\"): ", stdout); + if ((pwgmedia = pwgMediaForPPD("4x6")) == NULL) { puts("FAIL (not found)"); status ++; @@ -208,8 +208,8 @@ main(int argc, /* I - Number of command-line args */ else puts("PASS"); - fputs("_pwgMediaForPPD(\"10x15cm\"): ", stdout); - if ((pwgmedia = _pwgMediaForPPD("10x15cm")) == NULL) + fputs("pwgMediaForPPD(\"10x15cm\"): ", stdout); + if ((pwgmedia = pwgMediaForPPD("10x15cm")) == NULL) { puts("FAIL (not found)"); status ++; @@ -227,8 +227,8 @@ main(int argc, /* I - Number of command-line args */ else puts("PASS"); - fputs("_pwgMediaForPPD(\"Custom.10x15cm\"): ", stdout); - if ((pwgmedia = _pwgMediaForPPD("Custom.10x15cm")) == NULL) + fputs("pwgMediaForPPD(\"Custom.10x15cm\"): ", stdout); + if ((pwgmedia = pwgMediaForPPD("Custom.10x15cm")) == NULL) { puts("FAIL (not found)"); status ++; @@ -246,8 +246,8 @@ main(int argc, /* I - Number of command-line args */ else puts("PASS"); - fputs("_pwgMediaForSize(29700, 42000): ", stdout); - if ((pwgmedia = _pwgMediaForSize(29700, 42000)) == NULL) + fputs("pwgMediaForSize(29700, 42000): ", stdout); + if ((pwgmedia = pwgMediaForSize(29700, 42000)) == NULL) { puts("FAIL (not found)"); status ++; @@ -260,8 +260,8 @@ main(int argc, /* I - Number of command-line args */ else puts("PASS"); - fputs("_pwgMediaForSize(9842, 19050): ", stdout); - if ((pwgmedia = _pwgMediaForSize(9842, 19050)) == NULL) + fputs("pwgMediaForSize(9842, 19050): ", stdout); + if ((pwgmedia = pwgMediaForSize(9842, 19050)) == NULL) { puts("FAIL (not found)"); status ++; @@ -274,8 +274,8 @@ main(int argc, /* I - Number of command-line args */ else printf("PASS (%s)\n", pwgmedia->pwg); - fputs("_pwgMediaForSize(9800, 19000): ", stdout); - if ((pwgmedia = _pwgMediaForSize(9800, 19000)) == NULL) + fputs("pwgMediaForSize(9800, 19000): ", stdout); + if ((pwgmedia = pwgMediaForSize(9800, 19000)) == NULL) { puts("FAIL (not found)"); status ++; @@ -361,9 +361,9 @@ test_ppd_cache(_ppd_cache_t *pc, /* I - PWG mapping data */ int i, /* Looping var */ status = 0; /* Return status */ _ppd_cache_t *pc2; /* Loaded data */ - _pwg_size_t *size, /* Size from original */ + pwg_size_t *size, /* Size from original */ *size2; /* Size from saved */ - _pwg_map_t *map, /* Map from original */ + pwg_map_t *map, /* Map from original */ *map2; /* Map from saved */ diff --git a/cups/usersys.c b/cups/usersys.c index 244dbe772..e9f215ec0 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -1031,36 +1031,7 @@ cups_read_client_conf( } if ((!cg->server[0] || !cg->ipp_port) && cups_server) - { - if (!cg->server[0]) - { - /* - * Copy server name... - */ - - strlcpy(cg->server, cups_server, sizeof(cg->server)); - - if (cg->server[0] != '/' && (value = strrchr(cg->server, ':')) != NULL && - !strchr(value, ']') && isdigit(value[1] & 255)) - *value++ = '\0'; - else - value = NULL; - - if (cg->server[0] == '/') - strlcpy(cg->servername, "localhost", sizeof(cg->servername)); - else - strlcpy(cg->servername, cg->server, sizeof(cg->servername)); - } - else if (cups_server[0] != '/' && - (value = strrchr(cups_server, ':')) != NULL && - !strchr(value, ']') && isdigit(value[1] & 255)) - value ++; - else - value = NULL; - - if (!cg->ipp_port && value) - cg->ipp_port = atoi(value); - } + cupsSetServer(cups_server); if (!cg->server[0]) { diff --git a/doc/help/api-cups.html b/doc/help/api-cups.html index 12f18e83b..0ce2a199c 100644 --- a/doc/help/api-cups.html +++ b/doc/help/api-cups.html @@ -415,6 +415,9 @@ destination.">cupsCopyDestInfo
  • cupsEncryption
  • cupsEnumDests
  • cupsEnumDestsBlock
  • +
  • cupsFindDestDefault
  • +
  • cupsFindDestReady
  • +
  • cupsFindDestSupported
  • cupsFinishDestDocument
  • cupsFinishDocument
  • cupsFreeDestInfo
  • cupsGetDefault
  • cupsGetDefault2
  • cupsGetDest
  • +
  • cupsGetDestMediaByIndex
  • cupsGetDestMediaByName
  • cupsGetDestMediaBySize
  • +
  • cupsGetDestMediaCount
  • +
  • cupsGetDestMediaDefault
  • cupsGetDests
  • cupsGetDests2
  • cupsGetJobs
  • @@ -486,6 +494,13 @@ connections.">cupsSetCredentials
  • cupsTempFile2
  • cupsUser
  • cupsUserAgent
  • +
  • pwgFormatSizeName
  • +
  • pwgInitSize
  • +
  • pwgMediaForLegacy
  • +
  • pwgMediaForPPD
  • +
  • pwgMediaForPWG
  • +
  • pwgMediaForSize
  • Data Types
  • Structures
  • Variables
    • Cancel a job on a destination.

      The "job_id" is the number returned by cupsCreateDestJob.

      -Returns IPP_OK on success and IPP_NOT_AUTHORIZED or IPP_FORBIDDEN on +Returns IPP_STATUS_OK on success and IPP_NOT_AUTHORIZED or IPP_FORBIDDEN on failure.

      @@ -1254,7 +1275,7 @@ ipp_status_t cupsCloseDestJob (

      IPP status code

      Discussion

      Use when the last call to cupsStartDocument passed 0 for "last_document". -"job_id" is the job ID returned by cupsCreateDestJob. Returns IPP_OK +"job_id" is the job ID returned by cupsCreateDestJob. Returns IPP_STATUS_OK on success.

      @@ -1475,7 +1496,7 @@ ipp_status_t cupsCreateDestJob (

      Return Value

      IPP status code

      Discussion

      -

      Returns IPP_OK or IPP_OK_SUBST on success, saving the job ID +

      Returns IPP_STATUS_OK or IPP_STATUS_OK_SUBST on success, saving the job ID in the variable pointed to by "job_id".

      @@ -1522,7 +1543,7 @@ http_encryption_t cupsEncryption (void);

      The default encryption setting comes from the CUPS_ENCRYPTION environment variable, then the ~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not set, the default is -HTTP_ENCRYPT_IF_REQUESTED.
      +HTTP_ENCRYPTION_IF_REQUESTED.

      Note: The current encryption setting is tracked separately for each thread in a program. Multi-threaded programs that override the setting via the @@ -1607,6 +1628,96 @@ continue enumeration or 0 to stop.
      Enumeration happens on the current thread and does not return until all destinations have been enumerated or the block returns 0. +

      +

       CUPS 1.7 cupsFindDestDefault

      +

      Find the default value(s) for the given option.

      +

      +ipp_attribute_t *cupsFindDestDefault (
      +    http_t *http,
      +    cups_dest_t *dest,
      +    cups_dinfo_t *dinfo,
      +    const char *option
      +);

      +

      Parameters

      +
      +
      http
      +
      Connection to destination
      +
      dest
      +
      Destination
      +
      dinfo
      +
      Destination information
      +
      option
      +
      Option/attribute name
      +
      +

      Return Value

      +

      Default attribute or NULL for none

      +

      Discussion

      +

      The returned value is an IPP attribute. Use the ippGetBoolean, +ippGetCollection, ippGetCount, ippGetDate, +ippGetInteger, ippGetOctetString, ippGetRange, +ippGetResolution, ippGetString, and ippGetValueTag +functions to inspect the default value(s) as needed. + +

      +

       CUPS 1.7 cupsFindDestReady

      +

      Find the default value(s) for the given option.

      +

      +ipp_attribute_t *cupsFindDestReady (
      +    http_t *http,
      +    cups_dest_t *dest,
      +    cups_dinfo_t *dinfo,
      +    const char *option
      +);

      +

      Parameters

      +
      +
      http
      +
      Connection to destination
      +
      dest
      +
      Destination
      +
      dinfo
      +
      Destination information
      +
      option
      +
      Option/attribute name
      +
      +

      Return Value

      +

      Default attribute or NULL for none

      +

      Discussion

      +

      The returned value is an IPP attribute. Use the ippGetBoolean, +ippGetCollection, ippGetCount, ippGetDate, +ippGetInteger, ippGetOctetString, ippGetRange, +ippGetResolution, ippGetString, and ippGetValueTag +functions to inspect the default value(s) as needed. + +

      +

       CUPS 1.7 cupsFindDestSupported

      +

      Find the default value(s) for the given option.

      +

      +ipp_attribute_t *cupsFindDestSupported (
      +    http_t *http,
      +    cups_dest_t *dest,
      +    cups_dinfo_t *dinfo,
      +    const char *option
      +);

      +

      Parameters

      +
      +
      http
      +
      Connection to destination
      +
      dest
      +
      Destination
      +
      dinfo
      +
      Destination information
      +
      option
      +
      Option/attribute name
      +
      +

      Return Value

      +

      Default attribute or NULL for none

      +

      Discussion

      +

      The returned value is an IPP attribute. Use the ippGetBoolean, +ippGetCollection, ippGetCount, ippGetDate, +ippGetInteger, ippGetOctetString, ippGetRange, +ippGetResolution, ippGetString, and ippGetValueTag +functions to inspect the default value(s) as needed. +

       CUPS 1.6/OS X 10.8 cupsFinishDestDocument

      Finish the current document.

      @@ -1628,7 +1739,7 @@ ipp_status_t cupsFinishDestDocument (

      Return Value

      Status of document submission

      Discussion

      -

      Returns IPP_OK or IPP_OK_SUBST on success. +

      Returns IPP_STATUS_OK or IPP_STATUS_OK_SUBST on success.

       CUPS 1.4/OS X 10.6 cupsFinishDocument

      @@ -1782,6 +1893,41 @@ not support the lpoptions-defined default printer.

      Discussion

      Use the cupsGetDests or cupsGetDests2 functions to get a list of supported destinations for the current user.

      +

       CUPS 1.7 cupsGetDestMediaByIndex

      +

      Get a media name, dimension, and margins for a +specific size.

      +

      +int cupsGetDestMediaByIndex (
      +    http_t *http,
      +    cups_dest_t *dest,
      +    cups_dinfo_t *dinfo,
      +    int n,
      +    unsigned flags,
      +    cups_size_t *size
      +);

      +

      Parameters

      +
      +
      http
      +
      Connection to destination
      +
      dest
      +
      Destination
      +
      dinfo
      +
      Destination information
      +
      n
      +
      Media size number (0-based)
      +
      flags
      +
      Media flags
      +
      size
      +
      Media size information
      +
      +

      Return Value

      +

      1 on success, 0 on failure

      +

      Discussion

      +

      The flags parameter determines which set of media are indexed. For +example, passing CUPS_MEDIA_FLAGS_BORDERLESS will get the Nth +borderless size supported by the printer. + +

       CUPS 1.6/OS X 10.8 cupsGetDestMediaByName

      Get media names, dimensions, and margins.

      @@ -1874,6 +2020,66 @@ The matching result (if any) is returned in the "cups_size_t" structur
      Returns 1 when there is a match and 0 if there is not a match. +

      +

       CUPS 1.7 cupsGetDestMediaCount

      +

      Get the number of sizes supported by a +destination.

      +

      +int cupsGetDestMediaCount (
      +    http_t *http,
      +    cups_dest_t *dest,
      +    cups_dinfo_t *dinfo,
      +    unsigned flags
      +);

      +

      Parameters

      +
      +
      http
      +
      Connection to destination
      +
      dest
      +
      Destination
      +
      dinfo
      +
      Destination information
      +
      flags
      +
      Media flags
      +
      +

      Return Value

      +

      Number of sizes

      +

      Discussion

      +

      The flags parameter determines the set of media sizes that are +counted. For example, passing CUPS_MEDIA_FLAGS_BORDERLESS will return +the number of borderless sizes. + +

      +

       CUPS 1.7 cupsGetDestMediaDefault

      +

      Get the default size for a destination.

      +

      +int cupsGetDestMediaDefault (
      +    http_t *http,
      +    cups_dest_t *dest,
      +    cups_dinfo_t *dinfo,
      +    unsigned flags,
      +    cups_size_t *size
      +);

      +

      Parameters

      +
      +
      http
      +
      Connection to destination
      +
      dest
      +
      Destination
      +
      dinfo
      +
      Destination information
      +
      flags
      +
      Media flags
      +
      size
      +
      Media size information
      +
      +

      Return Value

      +

      1 on success, 0 on failure

      +

      Discussion

      +

      The flags parameter determines which default size is returned. For +example, passing CUPS_MEDIA_FLAGS_BORDERLESS will return the default +borderless size, typically US Letter or A4, but sometimes 4x6 photo media. +

      cupsGetDests

      Get the list of destinations from the default server.

      @@ -2123,8 +2329,8 @@ the empty string, a new temporary file is created, otherwise the existing file will be overwritten as needed. The caller "owns" the file that is created and must unlink the returned filename.

      -On success, HTTP_OK is returned for a new PPD file and -HTTP_NOT_MODIFIED if the existing PPD file is up-to-date. Any other +On success, HTTP_STATUS_OK is returned for a new PPD file and +HTTP_STATUS_NOT_MODIFIED if the existing PPD file is up-to-date. Any other status is an error.

      For classes, cupsGetPPD3 returns the PPD file for the first printer @@ -2703,7 +2909,7 @@ void cupsSetEncryption (

      The default encryption setting comes from the CUPS_ENCRYPTION environment variable, then the ~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not set, the default is -HTTP_ENCRYPT_IF_REQUESTED.
      +HTTP_ENCRYPTION_IF_REQUESTED.

      Note: The current encryption setting is tracked separately for each thread in a program. Multi-threaded programs that override the setting need to do @@ -2992,6 +3198,173 @@ name to be used.

      const char *cupsUserAgent (void);

      Return Value

      User-Agent string

      +

       CUPS 1.7 pwgFormatSizeName

      +

      Generate a PWG self-describing media size name.

      +

      +int pwgFormatSizeName (
      +    char *keyword,
      +    size_t keysize,
      +    const char *prefix,
      +    const char *name,
      +    int width,
      +    int length,
      +    const char *units
      +);

      +

      Parameters

      +
      +
      keyword
      +
      Keyword buffer
      +
      keysize
      +
      Size of keyword buffer
      +
      prefix
      +
      Prefix for PWG size or NULL for automatic
      +
      name
      +
      Size name or NULL
      +
      width
      +
      Width of page in 2540ths
      +
      length
      +
      Length of page in 2540ths
      +
      units
      +
      Units - "in", "mm", or NULL for automatic
      +
      +

      Return Value

      +

      1 on success, 0 on failure

      +

      Discussion

      +

      This function generates a PWG self-describing media size name of the form +"prefix_name_WIDTHxLENGTHunits". The prefix is typically "custom" or "roll" +for user-supplied sizes but can also be "disc", "iso", "jis", "jpn", "na", +"oe", "om", "prc", or "roc". A value of NULL automatically chooses +"oe" or "om" depending on the units.
      +
      +The size name may only contain lowercase letters, numbers, "-", and ".". If +NULL is passed, the size name will contain the formatted dimensions.
      +
      +The width and length are specified in hundredths of millimeters, equivalent +to 1/100000th of a meter or 1/2540th of an inch. The width, length, and +units used for the generated size name are calculated automatically if the +units string is NULL, otherwise inches ("in") or millimeters ("mm") +are used. + +

      +

       CUPS 1.7 pwgInitSize

      +

      Initialize a pwg_size_t structure using IPP Job Template +attributes.

      +

      +int pwgInitSize (
      +    pwg_size_t *size,
      +    ipp_t *job,
      +    int *margins_set
      +);

      +

      Parameters

      +
      +
      size
      +
      Size to initialize
      +
      job
      +
      Job template attributes
      +
      margins_set
      +
      1 if margins were set, 0 otherwise
      +
      +

      Return Value

      +

      1 if size was initialized, 0 otherwise

      +

      Discussion

      +

      This function initializes a pwg_size_t structure from an IPP "media" or +"media-col" attribute in the specified IPP message. 0 is returned if neither +attribute is found in the message or the values are not valid.
      +
      +The "margins_set" variable is initialized to 1 if any "media-xxx-margin" +member attribute was specified in the "media-col" Job Template attribute, +otherwise it is initialized to 0. + +

      +

       CUPS 1.7 pwgMediaForLegacy

      +

      Find a PWG media size by ISO/IPP legacy name.

      +

      +pwg_media_t *pwgMediaForLegacy (
      +    const char *legacy
      +);

      +

      Parameters

      +
      +
      legacy
      +
      Legacy size name
      +
      +

      Return Value

      +

      Matching size or NULL

      +

      Discussion

      +

      The "name" argument specifies the legacy ISO media size name, for example +"iso-a4" or "na-letter". + +

      +

       CUPS 1.7 pwgMediaForPPD

      +

      Find a PWG media size by Adobe PPD name.

      +

      +pwg_media_t *pwgMediaForPPD (
      +    const char *ppd
      +);

      +

      Parameters

      +
      +
      ppd
      +
      PPD size name
      +
      +

      Return Value

      +

      Matching size or NULL

      +

      Discussion

      +

      The "ppd" argument specifies an Adobe page size name as defined in Table B.1 +of the Adobe PostScript Printer Description File Format Specification Version +4.3.
      +
      +If the name is non-standard, the returned PWG media size is stored in +thread-local storage and is overwritten by each call to the function in the +thread. Custom names can be of the form "Custom.WIDTHxLENGTH[units]" or +"WIDTHxLENGTH[units]". + +

      +

       CUPS 1.7 pwgMediaForPWG

      +

      Find a PWG media size by 5101.1 self-describing name.

      +

      +pwg_media_t *pwgMediaForPWG (
      +    const char *pwg
      +);

      +

      Parameters

      +
      +
      pwg
      +
      PWG size name
      +
      +

      Return Value

      +

      Matching size or NULL

      +

      Discussion

      +

      The "pwg" argument specifies a self-describing media size name of the form +"prefix_name_WIDTHxLENGTHunits" as defined in PWG 5101.1.
      +
      +If the name is non-standard, the returned PWG media size is stored in +thread-local storage and is overwritten by each call to the function in the +thread. + +

      +

       CUPS 1.7 pwgMediaForSize

      +

      Get the PWG media size for the given dimensions.

      +

      +pwg_media_t *pwgMediaForSize (
      +    int width,
      +    int length
      +);

      +

      Parameters

      +
      +
      width
      +
      Width in hundredths of millimeters
      +
      length
      +
      Length in hundredths of millimeters
      +
      +

      Return Value

      +

      PWG media name

      +

      Discussion

      +

      The "width" and "length" are in hundredths of millimeters, equivalent to +1/100000th of a meter or 1/2540th of an inch.
      +
      +If the dimensions are non-standard, the returned PWG media size is stored in +thread-local storage and is overwritten by each call to the function in the +thread. + +

      Data Types

       CUPS 1.5/OS X 10.7 cups_client_cert_cb_t

      Client credentials callback @@ -3065,6 +3438,21 @@ typedef int (*cups_server_cert_cb_t)(http_t *http, void *tls, cups_array_t *cert

      typedef struct cups_size_s cups_size_t;

      +

      pwg_map_t

      +

      Map element - PPD to/from PWG

      +

      +typedef struct pwg_map_s pwg_map_t; +

      +

      pwg_media_t

      +

      Common media size data

      +

      +typedef struct pwg_media_s pwg_media_t; +

      +

      pwg_size_t

      +

      Size element - PPD to/from PWG

      +

      +typedef struct pwg_size_s pwg_size_t; +

      Structures

      cups_dest_s

      Destination

      @@ -3169,6 +3557,42 @@ millimeters
      val
      Return value
      +

      pwg_map_s

      +

      Map element - PPD to/from PWG

      +

      struct pwg_map_s {
      +    char *pwg, *ppd;
      +};

      +

      Members

      +
      +
      ppd
      +
      PPD option keyword
      +
      +

      pwg_media_s

      +

      Common media size data

      +

      struct pwg_media_s {
      +    int width, length;
      +    const char *pwg, *legacy, *ppd;
      +};

      +

      Members

      +
      +
      length
      +
      Length in 2540ths
      +
      ppd
      +
      Standard Adobe PPD name
      +
      +

      pwg_size_s

      +

      Size element - PPD to/from PWG

      +

      struct pwg_size_s {
      +    pwg_map_t map;
      +    int width, length, left, bottom, right, top;
      +};

      +

      Members

      +
      +
      map
      +
      Map element
      +
      top
      +
      Top margin in 2540ths
      +

      Variables

      CF_RETURNS_RETAINED

      Get the Apple language identifier associated with a diff --git a/doc/help/api-httpipp.html b/doc/help/api-httpipp.html index 0e50514c8..d6736d9dd 100644 --- a/doc/help/api-httpipp.html +++ b/doc/help/api-httpipp.html @@ -552,6 +552,7 @@ in seconds.">ippDateToTime

    • ippGetGroupTag
    • ippGetInteger
    • ippGetName
    • +
    • ippGetOctetString
    • ippGetOperation
    • ippGetRange
    • ippGetRequestId
    • @@ -578,6 +579,7 @@ in seconds.">ippDateToTime
    • ippSetGroupTag
    • ippSetInteger
    • ippSetName
    • +
    • ippSetOctetString
    • ippSetOperation
    • ippSetPort
    • ippSetRange
    • @@ -1011,7 +1013,7 @@ int cupsDoAuthentication (

      Return Value

      0 on success, -1 on error

      Discussion

      -

      This function should be called in response to a HTTP_UNAUTHORIZED +

      This function should be called in response to a HTTP_STATUS_UNAUTHORIZED status, prior to resubmitting your request.

      @@ -1203,7 +1205,7 @@ http_status_t cupsGetFd (

      Return Value

      HTTP status

      Discussion

      -

      This function returns HTTP_OK when the file is successfully retrieved. +

      This function returns HTTP_STATUS_OK when the file is successfully retrieved.

       CUPS 1.1.20/OS X 10.4 cupsGetFile

      @@ -1226,7 +1228,7 @@ http_status_t cupsGetFile (

      Return Value

      HTTP status

      Discussion

      -

      This function returns HTTP_OK when the file is successfully retrieved. +

      This function returns HTTP_STATUS_OK when the file is successfully retrieved.

       CUPS 1.4/OS X 10.6 cupsGetResponse

      @@ -1286,7 +1288,7 @@ http_status_t cupsPutFd (

      Return Value

      HTTP status

      Discussion

      -

      This function returns HTTP_CREATED when the file is stored +

      This function returns HTTP_STATUS_CREATED when the file is stored successfully.

      @@ -1368,7 +1370,7 @@ and cupsReadResponseData to rea response. Only one request can be sent/queued at a time per http_t connection.

      -Returns the initial HTTP status code, which will be HTTP_CONTINUE +Returns the initial HTTP status code, which will be HTTP_STATUS_CONTINUE on a successful send of the request.

      Note: Unlike cupsDoFileRequest, cupsDoIORequest, and @@ -1393,7 +1395,7 @@ http_status_t cupsWriteRequestData (
      Number of bytes to write

      Return Value

      -

      HTTP_CONTINUE if OK or HTTP status on error

      +

      HTTP_STATUS_CONTINUE if OK or HTTP status on error

      Discussion

      This function is used after cupsSendRequest to provide a PPD and after cupsStartDocument to provide a document file. @@ -1651,7 +1653,7 @@ this function in place of traditional string functions whenever you need to create a URI string.

      -

      httpAssembleUUID

      +

       CUPS 1.7 httpAssembleUUID

      Assemble a name-based UUID URN conforming to RFC 4122.

      char *httpAssembleUUID (
      @@ -1684,7 +1686,9 @@ char *httpAssembleUUID (
      name, port number, random data, and optionally an object name and/or object number. The result is formatted as a UUID URN as defined in RFC 4122.

      -The buffer needs to be at least 46 bytes in size.

      +The buffer needs to be at least 46 bytes in size. + +

      httpBlocking

      Set blocking/non-blocking behavior on a connection.

      @@ -2813,8 +2817,8 @@ void httpSetDefaultField (

      Value

      Discussion

      -

      Currently only HTTP_FIELD_ACCEPT_ENCODING, HTTP_FIELD_SERVER, and -HTTP_FIELD_USER_AGENT can be set. +

      Currently only HTTP_FIELD_ACCEPT_ENCODING, HTTP_FIELD_SERVER, +and HTTP_FIELD_USER_AGENT can be set.

       CUPS 1.2/OS X 10.5 httpSetExpect

      @@ -2830,7 +2834,7 @@ void httpSetExpect (
      Connection to server
      expect
      HTTP status to expect -(HTTP_CONTINUE)
      +(HTTP_STATUS_CONTINUE)

      Discussion

      Currently only HTTP_STATUS_CONTINUE is supported for the "expect" @@ -4176,6 +4180,30 @@ const char *ippGetName (

      Return Value

      Attribute name or NULL for separators

      +

       CUPS 1.7 ippGetOctetString

      +

      Get an octetString value from an IPP attribute.

      +

      +void *ippGetOctetString (
      +    ipp_attribute_t *attr,
      +    int element,
      +    int *datalen
      +);

      +

      Parameters

      +
      +
      attr
      +
      IPP attribute
      +
      element
      +
      Value number (0-based)
      +
      datalen
      +
      Length of octetString data
      +
      +

      Return Value

      +

      Pointer to octetString data

      +

      Discussion

      +

      The element parameter specifies which value to get from 0 to +ippGetCount(attr) - 1. + +

       CUPS 1.6/OS X 10.8 ippGetOperation

      Get the operation ID in an IPP message.

      @@ -4678,6 +4706,41 @@ the ippNew, ip
      The attr parameter may be modified as a result of setting the value. +

      +

       CUPS 1.7 ippSetOctetString

      +

      Set an octetString value in an IPP attribute.

      +

      +int ippSetOctetString (
      +    ipp_t *ipp,
      +    ipp_attribute_t **attr,
      +    int element,
      +    const void *data,
      +    int datalen
      +);

      +

      Parameters

      +
      +
      ipp
      +
      IPP message
      +
      attr
      +
      IPP attribute
      +
      element
      +
      Value number (0-based)
      +
      data
      +
      Pointer to octetString data
      +
      datalen
      +
      Length of octetString data
      +
      +

      Return Value

      +

      1 on success, 0 on failure

      +

      Discussion

      +

      The ipp parameter refers to an IPP message previously created using +the ippNew, ippNewRequest, or ippNewResponse functions.
      +
      +The attr parameter may be modified as a result of setting the value.
      +
      +The element parameter specifies which value to set from 0 to +ippGetCount(attr). +

       CUPS 1.6/OS X 10.8 ippSetOperation

      Set the operation ID in an IPP request message.

      @@ -5538,10 +5601,6 @@ are server-oriented...

      HTTP status codes

      Constants

      -
      CUPS_STATUS_AUTHORIZATION_CANCELED  CUPS 1.4 
      -
      User canceled authorization
      -
      CUPS_STATUS_PKI_ERROR  CUPS 1.5/OS X 10.7 
      -
      Error negotiating a secure connection
      HTTP_STATUS_ACCEPTED
      DELETE command was successful
      HTTP_STATUS_BAD_GATEWAY
      @@ -5554,6 +5613,10 @@ are server-oriented...

      Everything OK, keep going...
      HTTP_STATUS_CREATED
      PUT command was successful
      +
      HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED  CUPS 1.4 
      +
      User canceled authorization
      +
      HTTP_STATUS_CUPS_PKI_ERROR  CUPS 1.5/OS X 10.7 
      +
      Error negotiating a secure connection
      HTTP_STATUS_ERROR
      An error response from httpXxxx()
      HTTP_STATUS_EXPECTATION_FAILED
      @@ -5721,6 +5784,28 @@ are server-oriented...

      Fold to make booklet
      IPP_FINISHINGS_COVER
      Add cover
      +
      IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN
      +
      Accordian-fold the paper vertically into four sections
      +
      IPP_FINISHINGS_CUPS_FOLD_DOUBLE_GATE
      +
      Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically
      +
      IPP_FINISHINGS_CUPS_FOLD_GATE
      +
      Fold the top and bottom quarters of the paper towards the midline
      +
      IPP_FINISHINGS_CUPS_FOLD_HALF
      +
      Fold the paper in half vertically
      +
      IPP_FINISHINGS_CUPS_FOLD_HALF_Z
      +
      Fold the paper in half horizontally, then Z-fold the paper vertically
      +
      IPP_FINISHINGS_CUPS_FOLD_LEFT_GATE
      +
      Fold the top quarter of the paper towards the midline
      +
      IPP_FINISHINGS_CUPS_FOLD_LETTER
      +
      Fold the paper into three sections vertically; sometimes also known as a C fold
      +
      IPP_FINISHINGS_CUPS_FOLD_PARALLEL
      +
      Fold the paper in half vertically two times, yielding four sections
      +
      IPP_FINISHINGS_CUPS_FOLD_POSTER
      +
      Fold the paper in half horizontally and vertically; sometimes also called a cross fold
      +
      IPP_FINISHINGS_CUPS_FOLD_RIGHT_GATE
      +
      Fold the bottom quarter of the paper towards the midline
      +
      IPP_FINISHINGS_CUPS_FOLD_Z
      +
      Fold the paper vertically into three sections, forming a Z
      IPP_FINISHINGS_CUPS_PUNCH_BOTTOM_LEFT
      Punch 1 hole bottom left
      IPP_FINISHINGS_CUPS_PUNCH_BOTTOM_RIGHT
      @@ -5765,7 +5850,7 @@ are server-oriented...

      Stitch along top edge
      IPP_FINISHINGS_FOLD
      Fold (any type)
      -
      IPP_FINISHINGS_JOB_OFFSET
      +
      IPP_FINISHINGS_JOG_OFFSET
      Offset for binding (any type)
      IPP_FINISHINGS_NONE
      No finishing
      diff --git a/doc/help/whatsnew.html b/doc/help/whatsnew.html index 73ae2ab39..2bfc86fda 100644 --- a/doc/help/whatsnew.html +++ b/doc/help/whatsnew.html @@ -8,33 +8,13 @@

      What's New in CUPS 1.7

      -

      CUPS 1.7 provides many changes and new features to CUPS 1.6.x. This page provides a high-level outline of these changes. If you have never used CUPS before, read the "Overview of CUPS" document instead.

      +

      This page provides a high-level outline of these changes. If you have never used CUPS before, read the "Overview of CUPS" document instead.

      -

      General

      +

      CUPS 1.7 is primarily a "polish" release. Users will appreciate improved support for paid, PIN, and release printing, as well as expanded support for printers conforming to the IPP Everywhere specification. Full support for this functionality depends on additional software from your operating system vendor.

      -
        +

        When supported by the printer or the remote server, CUPS now compresses print data sent over the network to greatly improve print speed and reduce bandwidth usage. This happens automatically when printing through IPP and is available as an option when using the ipptool utility.

        -
      1. What; Description.
      2. - -
      - - -

      Scheduler

      - -
        - -
      1. What; Description.
      2. - -
      - - -

      CUPS API

      - -
        - -
      1. What; Description.
      2. - -
      +

      Developers can now enumerate supported sizes and option values, as well as query a printer to discovery which media is loaded, making it possible to easily build customized user interfaces without the use of printer drivers or PPD files.

      diff --git a/locale/cups.pot b/locale/cups.pot index 452aa3601..62c857d76 100644 --- a/locale/cups.pot +++ b/locale/cups.pot @@ -30,7 +30,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: http://www.cups.org/str.php\n" -"POT-Creation-Date: 2013-03-08 13:23-0500\n" +"POT-Creation-Date: 2013-03-20 15:42-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1289,172 +1289,172 @@ msgstr "" msgid " PASS" msgstr "" -#: cups/ipp.c:5114 +#: cups/ipp.c:5243 #, c-format msgid "\"%s\": Bad URI value \"%s\" - %s (RFC 2911 section 4.1.5)." msgstr "" -#: cups/ipp.c:5125 +#: cups/ipp.c:5254 #, c-format msgid "\"%s\": Bad URI value \"%s\" - bad length %d (RFC 2911 section 4.1.5)." msgstr "" -#: cups/ipp.c:4745 +#: cups/ipp.c:4874 #, c-format msgid "\"%s\": Bad attribute name - bad length %d (RFC 2911 section 4.1.3)." msgstr "" -#: cups/ipp.c:4737 +#: cups/ipp.c:4866 #, c-format msgid "\"%s\": Bad attribute name - invalid character (RFC 2911 section 4.1.3)." msgstr "" -#: cups/ipp.c:4763 +#: cups/ipp.c:4892 #, c-format msgid "\"%s\": Bad boolen value %d (RFC 2911 section 4.1.11)." msgstr "" -#: cups/ipp.c:5177 +#: cups/ipp.c:5306 #, c-format msgid "\"%s\": Bad charset value \"%s\" - bad characters (RFC 2911 section 4.1.7)." msgstr "" -#: cups/ipp.c:5186 +#: cups/ipp.c:5315 #, c-format msgid "\"%s\": Bad charset value \"%s\" - bad length %d (RFC 2911 section 4.1.7)." msgstr "" -#: cups/ipp.c:4863 +#: cups/ipp.c:4992 #, c-format msgid "\"%s\": Bad dateTime UTC hours %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4871 +#: cups/ipp.c:5000 #, c-format msgid "\"%s\": Bad dateTime UTC minutes %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4855 +#: cups/ipp.c:4984 #, c-format msgid "\"%s\": Bad dateTime UTC sign '%c' (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4815 +#: cups/ipp.c:4944 #, c-format msgid "\"%s\": Bad dateTime day %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4847 +#: cups/ipp.c:4976 #, c-format msgid "\"%s\": Bad dateTime deciseconds %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4823 +#: cups/ipp.c:4952 #, c-format msgid "\"%s\": Bad dateTime hours %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4831 +#: cups/ipp.c:4960 #, c-format msgid "\"%s\": Bad dateTime minutes %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4807 +#: cups/ipp.c:4936 #, c-format msgid "\"%s\": Bad dateTime month %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4839 +#: cups/ipp.c:4968 #, c-format msgid "\"%s\": Bad dateTime seconds %u (RFC 2911 section 4.1.14)." msgstr "" -#: cups/ipp.c:4777 +#: cups/ipp.c:4906 #, c-format msgid "\"%s\": Bad enum value %d - out of range (RFC 2911 section 4.1.4)." msgstr "" -#: cups/ipp.c:5092 +#: cups/ipp.c:5221 #, c-format msgid "\"%s\": Bad keyword value \"%s\" - bad length %d (RFC 2911 section 4.1.3)." msgstr "" -#: cups/ipp.c:5083 +#: cups/ipp.c:5212 #, c-format msgid "\"%s\": Bad keyword value \"%s\" - invalid character (RFC 2911 section 4.1.3)." msgstr "" -#: cups/ipp.c:5286 +#: cups/ipp.c:5415 #, c-format msgid "\"%s\": Bad mimeMediaType value \"%s\" - bad characters (RFC 2911 section 4.1.9)." msgstr "" -#: cups/ipp.c:5296 +#: cups/ipp.c:5425 #, c-format msgid "\"%s\": Bad mimeMediaType value \"%s\" - bad length %d (RFC 2911 section 4.1.9)." msgstr "" -#: cups/ipp.c:5054 +#: cups/ipp.c:5183 #, c-format msgid "\"%s\": Bad name value \"%s\" - bad UTF-8 sequence (RFC 2911 section 4.1.2)." msgstr "" -#: cups/ipp.c:5063 +#: cups/ipp.c:5192 #, c-format msgid "\"%s\": Bad name value \"%s\" - bad length %d (RFC 2911 section 4.1.2)." msgstr "" -#: cups/ipp.c:5232 +#: cups/ipp.c:5361 #, c-format msgid "\"%s\": Bad naturalLanguage value \"%s\" - bad characters (RFC 2911 section 4.1.8)." msgstr "" -#: cups/ipp.c:5242 +#: cups/ipp.c:5371 #, c-format msgid "\"%s\": Bad naturalLanguage value \"%s\" - bad length %d (RFC 2911 section 4.1.8)." msgstr "" -#: cups/ipp.c:4791 +#: cups/ipp.c:4920 #, c-format msgid "\"%s\": Bad octetString value - bad length %d (RFC 2911 section 4.1.10)." msgstr "" -#: cups/ipp.c:4934 +#: cups/ipp.c:5063 #, c-format msgid "\"%s\": Bad rangeOfInteger value %d-%d - lower greater than upper (RFC 2911 section 4.1.13)." msgstr "" -#: cups/ipp.c:4915 +#: cups/ipp.c:5044 #, c-format msgid "\"%s\": Bad resolution value %dx%d%s - bad units value (RFC 2911 section 4.1.15)." msgstr "" -#: cups/ipp.c:4884 +#: cups/ipp.c:5013 #, c-format msgid "\"%s\": Bad resolution value %dx%d%s - cross feed resolution must be positive (RFC 2911 section 4.1.15)." msgstr "" -#: cups/ipp.c:4899 +#: cups/ipp.c:5028 #, c-format msgid "\"%s\": Bad resolution value %dx%d%s - feed resolution must be positive (RFC 2911 section 4.1.15)." msgstr "" -#: cups/ipp.c:4996 +#: cups/ipp.c:5125 #, c-format msgid "\"%s\": Bad text value \"%s\" - bad UTF-8 sequence (RFC 2911 section 4.1.1)." msgstr "" -#: cups/ipp.c:5005 +#: cups/ipp.c:5134 #, c-format msgid "\"%s\": Bad text value \"%s\" - bad length %d (RFC 2911 section 4.1.1)." msgstr "" -#: cups/ipp.c:5148 +#: cups/ipp.c:5277 #, c-format msgid "\"%s\": Bad uriScheme value \"%s\" - bad characters (RFC 2911 section 4.1.6)." msgstr "" -#: cups/ipp.c:5157 +#: cups/ipp.c:5286 #, c-format msgid "\"%s\": Bad uriScheme value \"%s\" - bad length %d (RFC 2911 section 4.1.6)." msgstr "" @@ -1474,7 +1474,7 @@ msgstr "" msgid "%s accepting requests since %s" msgstr "" -#: scheduler/ipp.c:9907 +#: scheduler/ipp.c:9924 #, c-format msgid "%s cannot be changed." msgstr "" @@ -2796,7 +2796,7 @@ msgstr "" msgid "Accept Jobs" msgstr "" -#: cups/http-support.c:1296 +#: cups/http-support.c:1298 msgid "Accepted" msgstr "" @@ -2891,7 +2891,7 @@ msgstr "" msgid "B9" msgstr "" -#: scheduler/ipp.c:10833 +#: scheduler/ipp.c:10850 #, c-format msgid "Bad 'document-format' value \"%s\"." msgstr "" @@ -2925,7 +2925,7 @@ msgstr "" msgid "Bad PPD cache file." msgstr "" -#: cups/http-support.c:1311 +#: cups/http-support.c:1313 msgid "Bad Request" msgstr "" @@ -2946,22 +2946,22 @@ msgstr "" msgid "Bad custom parameter" msgstr "" -#: cups/http-support.c:1463 scheduler/ipp.c:2427 +#: cups/http-support.c:1465 scheduler/ipp.c:2446 #, c-format msgid "Bad device-uri \"%s\"." msgstr "" -#: scheduler/ipp.c:2468 +#: scheduler/ipp.c:2485 #, c-format msgid "Bad device-uri scheme \"%s\"." msgstr "" -#: scheduler/ipp.c:8085 scheduler/ipp.c:8101 scheduler/ipp.c:9316 +#: scheduler/ipp.c:8102 scheduler/ipp.c:8118 scheduler/ipp.c:9333 #, c-format msgid "Bad document-format \"%s\"." msgstr "" -#: scheduler/ipp.c:9332 +#: scheduler/ipp.c:9349 #, c-format msgid "Bad document-format-default \"%s\"." msgstr "" @@ -2979,7 +2979,7 @@ msgstr "" msgid "Bad job-name value: Wrong type or count." msgstr "" -#: scheduler/ipp.c:9922 +#: scheduler/ipp.c:9939 msgid "Bad job-priority value." msgstr "" @@ -2992,24 +2992,24 @@ msgstr "" msgid "Bad job-sheets value type." msgstr "" -#: scheduler/ipp.c:9952 +#: scheduler/ipp.c:9969 msgid "Bad job-state value." msgstr "" -#: scheduler/ipp.c:3051 scheduler/ipp.c:3511 scheduler/ipp.c:5950 -#: scheduler/ipp.c:6097 scheduler/ipp.c:7519 scheduler/ipp.c:7788 -#: scheduler/ipp.c:8637 scheduler/ipp.c:8863 scheduler/ipp.c:9212 -#: scheduler/ipp.c:9815 +#: scheduler/ipp.c:3068 scheduler/ipp.c:3528 scheduler/ipp.c:5967 +#: scheduler/ipp.c:6114 scheduler/ipp.c:7536 scheduler/ipp.c:7805 +#: scheduler/ipp.c:8654 scheduler/ipp.c:8880 scheduler/ipp.c:9229 +#: scheduler/ipp.c:9832 #, c-format msgid "Bad job-uri \"%s\"." msgstr "" -#: scheduler/ipp.c:2126 scheduler/ipp.c:5494 +#: scheduler/ipp.c:2126 scheduler/ipp.c:5511 #, c-format msgid "Bad notify-pull-method \"%s\"." msgstr "" -#: scheduler/ipp.c:2090 scheduler/ipp.c:5458 +#: scheduler/ipp.c:2090 scheduler/ipp.c:5475 #, c-format msgid "Bad notify-recipient-uri \"%s\"." msgstr "" @@ -3029,7 +3029,7 @@ msgstr "" msgid "Bad page-ranges values %d-%d." msgstr "" -#: scheduler/ipp.c:2511 +#: scheduler/ipp.c:2528 #, c-format msgid "Bad port-monitor \"%s\"." msgstr "" @@ -3038,7 +3038,7 @@ msgstr "" msgid "Bad printer URI." msgstr "" -#: scheduler/ipp.c:2572 +#: scheduler/ipp.c:2589 #, c-format msgid "Bad printer-state value %d." msgstr "" @@ -3069,7 +3069,7 @@ msgstr "" msgid "Bond Paper" msgstr "" -#: backend/usb-darwin.c:1880 +#: backend/usb-darwin.c:1894 #, c-format msgid "Boolean expected for waiteof option \"%s\"." msgstr "" @@ -3090,11 +3090,11 @@ msgstr "" msgid "Cancel RSS Subscription" msgstr "" -#: backend/ipp.c:2144 +#: backend/ipp.c:2150 msgid "Canceling print job." msgstr "" -#: scheduler/ipp.c:2552 +#: scheduler/ipp.c:2569 msgid "Cannot share a remote Kerberized printer." msgstr "" @@ -3107,7 +3107,7 @@ msgstr "" msgid "Change Settings" msgstr "" -#: scheduler/ipp.c:2138 scheduler/ipp.c:5506 +#: scheduler/ipp.c:2138 scheduler/ipp.c:5523 #, c-format msgid "Character set \"%s\" not supported." msgstr "" @@ -3120,7 +3120,7 @@ msgstr "" msgid "Clean Print Heads" msgstr "" -#: scheduler/ipp.c:3963 +#: scheduler/ipp.c:3980 msgid "Close-Job doesn't support the job-uri attribute." msgstr "" @@ -3151,7 +3151,7 @@ msgstr "" msgid "Connecting to printer." msgstr "" -#: cups/http-support.c:1284 +#: cups/http-support.c:1286 msgid "Continue" msgstr "" @@ -3167,7 +3167,7 @@ msgstr "" msgid "Copying print data." msgstr "" -#: cups/http-support.c:1293 +#: cups/http-support.c:1295 msgid "Created" msgstr "" @@ -3264,7 +3264,7 @@ msgstr "" msgid "Disabled" msgstr "" -#: scheduler/ipp.c:5999 +#: scheduler/ipp.c:6016 #, c-format msgid "Document #%d does not exist in job #%d." msgstr "" @@ -3593,7 +3593,7 @@ msgstr "" msgid "Executive" msgstr "" -#: cups/http-support.c:1339 +#: cups/http-support.c:1341 msgid "Expectation Failed" msgstr "" @@ -3652,7 +3652,7 @@ msgstr "" msgid "File Folder " msgstr "" -#: scheduler/ipp.c:2447 +#: scheduler/ipp.c:2464 #, c-format msgid "File device URIs have been disabled. To enable, see the FileDevice directive in \"%s/cups-files.conf\"." msgstr "" @@ -3667,7 +3667,7 @@ msgstr "" msgid "Folio" msgstr "" -#: cups/http-support.c:1318 +#: cups/http-support.c:1320 msgid "Forbidden" msgstr "" @@ -3687,10 +3687,10 @@ msgstr "" msgid "Glossy Paper" msgstr "" -#: scheduler/ipp.c:3029 scheduler/ipp.c:3437 scheduler/ipp.c:3975 -#: scheduler/ipp.c:5928 scheduler/ipp.c:6075 scheduler/ipp.c:7496 -#: scheduler/ipp.c:8615 scheduler/ipp.c:8841 scheduler/ipp.c:9190 -#: scheduler/ipp.c:9793 +#: scheduler/ipp.c:3046 scheduler/ipp.c:3454 scheduler/ipp.c:3992 +#: scheduler/ipp.c:5945 scheduler/ipp.c:6092 scheduler/ipp.c:7513 +#: scheduler/ipp.c:8632 scheduler/ipp.c:8858 scheduler/ipp.c:9207 +#: scheduler/ipp.c:9810 msgid "Got a printer-uri attribute but no job-id." msgstr "" @@ -3710,95 +3710,95 @@ msgstr "" msgid "Help file not in index." msgstr "" -#: cups/ipp.c:3157 cups/ipp.c:3184 cups/ipp.c:3207 +#: cups/ipp.c:3198 cups/ipp.c:3225 cups/ipp.c:3248 msgid "IPP 1setOf attribute with incompatible value tags." msgstr "" -#: cups/ipp.c:3120 +#: cups/ipp.c:3161 msgid "IPP attribute has no name." msgstr "" -#: cups/ipp.c:6885 +#: cups/ipp.c:7014 msgid "IPP attribute is not a member of the message." msgstr "" -#: cups/ipp.c:3569 +#: cups/ipp.c:3610 msgid "IPP begCollection value not 0 bytes." msgstr "" -#: cups/ipp.c:3350 +#: cups/ipp.c:3391 msgid "IPP boolean value not 1 byte." msgstr "" -#: cups/ipp.c:3411 +#: cups/ipp.c:3452 msgid "IPP date value not 11 bytes." msgstr "" -#: cups/ipp.c:3590 +#: cups/ipp.c:3631 msgid "IPP endCollection value not 0 bytes." msgstr "" -#: cups/ipp.c:3325 +#: cups/ipp.c:3366 msgid "IPP enum value not 4 bytes." msgstr "" -#: cups/ipp.c:3049 +#: cups/ipp.c:3090 msgid "IPP extension tag larger than 0x7FFFFFFF." msgstr "" -#: cups/ipp.c:3322 +#: cups/ipp.c:3363 msgid "IPP integer value not 4 bytes." msgstr "" -#: cups/ipp.c:3522 +#: cups/ipp.c:3563 msgid "IPP language length overflows value." msgstr "" -#: cups/ipp.c:3531 +#: cups/ipp.c:3572 msgid "IPP language length too large." msgstr "" -#: cups/ipp.c:3234 +#: cups/ipp.c:3275 msgid "IPP member name is not empty." msgstr "" -#: cups/ipp.c:3616 +#: cups/ipp.c:3657 msgid "IPP memberName value is empty." msgstr "" -#: cups/ipp.c:3608 +#: cups/ipp.c:3649 msgid "IPP memberName with no attribute." msgstr "" -#: cups/ipp.c:3103 +#: cups/ipp.c:3144 msgid "IPP name larger than 32767 bytes." msgstr "" -#: cups/ipp.c:3488 +#: cups/ipp.c:3529 msgid "IPP nameWithLanguage value less than minimum 4 bytes." msgstr "" -#: cups/ipp.c:3646 +#: cups/ipp.c:3687 msgid "IPP octetString length too large." msgstr "" -#: cups/ipp.c:3456 +#: cups/ipp.c:3497 msgid "IPP rangeOfInteger value not 8 bytes." msgstr "" -#: cups/ipp.c:3429 +#: cups/ipp.c:3470 msgid "IPP resolution value not 9 bytes." msgstr "" -#: cups/ipp.c:3549 +#: cups/ipp.c:3590 msgid "IPP string length overflows value." msgstr "" -#: cups/ipp.c:3484 +#: cups/ipp.c:3525 msgid "IPP textWithLanguage value less than minimum 4 bytes." msgstr "" -#: cups/ipp.c:3308 +#: cups/ipp.c:3349 msgid "IPP value larger than 32767 bytes." msgstr "" @@ -3842,7 +3842,7 @@ msgstr "" msgid "Intellitech" msgstr "" -#: cups/http-support.c:1345 +#: cups/http-support.c:1347 msgid "Internal Server Error" msgstr "" @@ -3862,7 +3862,11 @@ msgstr "" msgid "Internet Printing Protocol" msgstr "" -#: cups/dest-options.c:837 +#: cups/pwg-media.c:311 cups/pwg-media.c:330 +msgid "Invalid media name arguments." +msgstr "" + +#: cups/dest-options.c:1052 msgid "Invalid media size." msgstr "" @@ -3931,52 +3935,52 @@ msgstr "" msgid "JIS B9" msgstr "" -#: scheduler/ipp.c:8913 +#: scheduler/ipp.c:8930 #, c-format msgid "Job #%d cannot be restarted - no files." msgstr "" -#: scheduler/ipp.c:3069 scheduler/ipp.c:3303 scheduler/ipp.c:3362 -#: scheduler/ipp.c:3539 scheduler/ipp.c:3985 scheduler/ipp.c:5592 -#: scheduler/ipp.c:5968 scheduler/ipp.c:6115 scheduler/ipp.c:6404 -#: scheduler/ipp.c:7343 scheduler/ipp.c:7365 scheduler/ipp.c:7537 -#: scheduler/ipp.c:7762 scheduler/ipp.c:7805 scheduler/ipp.c:8655 -#: scheduler/ipp.c:8881 scheduler/ipp.c:9230 scheduler/ipp.c:9833 +#: scheduler/ipp.c:3086 scheduler/ipp.c:3320 scheduler/ipp.c:3379 +#: scheduler/ipp.c:3556 scheduler/ipp.c:4002 scheduler/ipp.c:5609 +#: scheduler/ipp.c:5985 scheduler/ipp.c:6132 scheduler/ipp.c:6421 +#: scheduler/ipp.c:7360 scheduler/ipp.c:7382 scheduler/ipp.c:7554 +#: scheduler/ipp.c:7779 scheduler/ipp.c:7822 scheduler/ipp.c:8672 +#: scheduler/ipp.c:8898 scheduler/ipp.c:9247 scheduler/ipp.c:9850 #, c-format msgid "Job #%d does not exist." msgstr "" -#: scheduler/ipp.c:3571 +#: scheduler/ipp.c:3588 #, c-format msgid "Job #%d is already aborted - can't cancel." msgstr "" -#: scheduler/ipp.c:3565 +#: scheduler/ipp.c:3582 #, c-format msgid "Job #%d is already canceled - can't cancel." msgstr "" -#: scheduler/ipp.c:3577 +#: scheduler/ipp.c:3594 #, c-format msgid "Job #%d is already completed - can't cancel." msgstr "" -#: scheduler/ipp.c:7563 scheduler/ipp.c:7847 scheduler/ipp.c:9848 +#: scheduler/ipp.c:7580 scheduler/ipp.c:7864 scheduler/ipp.c:9865 #, c-format msgid "Job #%d is finished and cannot be altered." msgstr "" -#: scheduler/ipp.c:8895 +#: scheduler/ipp.c:8912 #, c-format msgid "Job #%d is not complete." msgstr "" -#: scheduler/ipp.c:3084 +#: scheduler/ipp.c:3101 #, c-format msgid "Job #%d is not held for authentication." msgstr "" -#: scheduler/ipp.c:8669 +#: scheduler/ipp.c:8686 #, c-format msgid "Job #%d is not held." msgstr "" @@ -3997,7 +4001,7 @@ msgstr "" msgid "Job Stopped" msgstr "" -#: scheduler/ipp.c:9930 +#: scheduler/ipp.c:9947 msgid "Job is completed and cannot be changed." msgstr "" @@ -4005,11 +4009,11 @@ msgstr "" msgid "Job operation failed" msgstr "" -#: scheduler/ipp.c:9966 scheduler/ipp.c:9985 scheduler/ipp.c:9996 +#: scheduler/ipp.c:9983 scheduler/ipp.c:10002 scheduler/ipp.c:10013 msgid "Job state cannot be changed." msgstr "" -#: scheduler/ipp.c:8761 +#: scheduler/ipp.c:8778 msgid "Job subscriptions cannot be renewed." msgstr "" @@ -4029,7 +4033,7 @@ msgstr "" msgid "Label Top" msgstr "" -#: scheduler/ipp.c:2147 scheduler/ipp.c:5515 +#: scheduler/ipp.c:2147 scheduler/ipp.c:5532 #, c-format msgid "Language \"%s\" not supported." msgstr "" @@ -4066,7 +4070,7 @@ msgstr "" msgid "Long-Edge (Portrait)" msgstr "" -#: cups/http-support.c:1577 +#: cups/http-support.c:1579 msgid "Looking for printer." msgstr "" @@ -4110,7 +4114,7 @@ msgstr "" msgid "Missing asterisk in column 1" msgstr "" -#: scheduler/ipp.c:5991 +#: scheduler/ipp.c:6008 msgid "Missing document-number attribute." msgstr "" @@ -4125,19 +4129,19 @@ msgstr "" msgid "Missing form variable" msgstr "" -#: scheduler/ipp.c:9284 +#: scheduler/ipp.c:9301 msgid "Missing last-document attribute in request." msgstr "" -#: cups/pwg-media.c:559 +#: cups/pwg-media.c:573 msgid "Missing media or media-col." msgstr "" -#: cups/pwg-media.c:478 +#: cups/pwg-media.c:492 msgid "Missing media-size in media-col." msgstr "" -#: scheduler/ipp.c:6534 +#: scheduler/ipp.c:6551 msgid "Missing notify-subscription-ids attribute." msgstr "" @@ -4145,7 +4149,7 @@ msgstr "" msgid "Missing option keyword" msgstr "" -#: scheduler/ipp.c:3210 scheduler/ipp.c:3235 +#: scheduler/ipp.c:3227 scheduler/ipp.c:3252 msgid "Missing requesting-user-name attribute." msgstr "" @@ -4162,11 +4166,11 @@ msgstr "" msgid "Missing value string" msgstr "" -#: cups/pwg-media.c:466 +#: cups/pwg-media.c:480 msgid "Missing x-dimension in media-size." msgstr "" -#: cups/pwg-media.c:472 +#: cups/pwg-media.c:486 msgid "Missing y-dimension in media-size." msgstr "" @@ -4195,7 +4199,7 @@ msgstr "" msgid "Move Job" msgstr "" -#: cups/http-support.c:1302 +#: cups/http-support.c:1304 msgid "Moved Permanently" msgstr "" @@ -4227,7 +4231,7 @@ msgstr "" msgid "No" msgstr "" -#: cups/http-support.c:1299 +#: cups/http-support.c:1301 msgid "No Content" msgstr "" @@ -4247,7 +4251,7 @@ msgstr "" msgid "No active connection" msgstr "" -#: scheduler/ipp.c:3488 +#: scheduler/ipp.c:3505 #, c-format msgid "No active jobs on %s." msgstr "" @@ -4256,7 +4260,7 @@ msgstr "" msgid "No attributes in request." msgstr "" -#: scheduler/ipp.c:3111 +#: scheduler/ipp.c:3128 msgid "No authentication information provided." msgstr "" @@ -4264,11 +4268,11 @@ msgstr "" msgid "No community name" msgstr "" -#: scheduler/ipp.c:5791 +#: scheduler/ipp.c:5808 msgid "No default printer." msgstr "" -#: cgi-bin/ipp-var.c:436 scheduler/ipp.c:7109 +#: cgi-bin/ipp-var.c:436 scheduler/ipp.c:7126 msgid "No destinations added." msgstr "" @@ -4284,7 +4288,7 @@ msgstr "" msgid "No error-status" msgstr "" -#: scheduler/ipp.c:8051 scheduler/ipp.c:9298 +#: scheduler/ipp.c:8068 scheduler/ipp.c:9315 msgid "No file in print request." msgstr "" @@ -4313,7 +4317,7 @@ msgstr "" msgid "No printer-uri found for class" msgstr "" -#: scheduler/ipp.c:6194 +#: scheduler/ipp.c:6211 msgid "No printer-uri in request." msgstr "" @@ -4321,11 +4325,11 @@ msgstr "" msgid "No request-id" msgstr "" -#: scheduler/ipp.c:5400 +#: scheduler/ipp.c:5417 msgid "No subscription attributes in request." msgstr "" -#: scheduler/ipp.c:7436 +#: scheduler/ipp.c:7453 msgid "No subscriptions found." msgstr "" @@ -4349,11 +4353,11 @@ msgstr "" msgid "Normal" msgstr "" -#: cups/http-support.c:1321 +#: cups/http-support.c:1323 msgid "Not Found" msgstr "" -#: cups/http-support.c:1333 +#: cups/http-support.c:1335 msgid "Not Implemented" msgstr "" @@ -4361,15 +4365,15 @@ msgstr "" msgid "Not Installed" msgstr "" -#: cups/http-support.c:1308 +#: cups/http-support.c:1310 msgid "Not Modified" msgstr "" -#: cups/http-support.c:1336 +#: cups/http-support.c:1338 msgid "Not Supported" msgstr "" -#: scheduler/ipp.c:1577 scheduler/ipp.c:10529 +#: scheduler/ipp.c:1577 scheduler/ipp.c:10546 msgid "Not allowed to print." msgstr "" @@ -4381,7 +4385,7 @@ msgstr "" msgid "Note: this program only validates the DSC comments, not the PostScript itself." msgstr "" -#: cups/http-support.c:1290 cups/ppd.c:338 +#: cups/http-support.c:1292 cups/ppd.c:338 msgid "OK" msgstr "" @@ -4616,15 +4620,15 @@ msgstr "" msgid "Print file sent." msgstr "" -#: backend/ipp.c:2118 +#: backend/ipp.c:2124 msgid "Print job canceled at printer." msgstr "" -#: backend/ipp.c:2113 +#: backend/ipp.c:2116 msgid "Print job too large." msgstr "" -#: backend/ipp.c:1618 +#: backend/ipp.c:1619 msgid "Print job was not accepted." msgstr "" @@ -4652,10 +4656,14 @@ msgstr "" msgid "Printer Settings" msgstr "" -#: backend/ipp.c:2116 +#: backend/ipp.c:2119 msgid "Printer cannot print supplied content." msgstr "" +#: backend/ipp.c:2122 +msgid "Printer cannot print with supplied options." +msgstr "" + #: cups/notify.c:126 msgid "Printer:" msgstr "" @@ -4678,7 +4686,7 @@ msgstr "" msgid "Quarto" msgstr "" -#: scheduler/ipp.c:1572 scheduler/ipp.c:10524 +#: scheduler/ipp.c:1572 scheduler/ipp.c:10541 msgid "Quota limit reached." msgstr "" @@ -4709,7 +4717,7 @@ msgstr "" msgid "Reprint After Error" msgstr "" -#: cups/http-support.c:1324 +#: cups/http-support.c:1326 msgid "Request Entity Too Large" msgstr "" @@ -4742,15 +4750,15 @@ msgstr "" msgid "SEQUENCE uses indefinite length" msgstr "" -#: cups/http-support.c:1348 +#: cups/http-support.c:1350 msgid "SSL/TLS Negotiation Error" msgstr "" -#: cups/http-support.c:1305 +#: cups/http-support.c:1307 msgid "See Other" msgstr "" -#: backend/usb-darwin.c:573 backend/usb-libusb.c:441 +#: backend/usb-darwin.c:573 backend/usb-libusb.c:443 msgid "Sending data to printer." msgstr "" @@ -4770,7 +4778,7 @@ msgstr "" msgid "Server Stopped" msgstr "" -#: cups/http-support.c:1342 +#: cups/http-support.c:1344 msgid "Service Unavailable" msgstr "" @@ -4839,8 +4847,8 @@ msgstr "" msgid "Stylus Photo Series" msgstr "" -#: scheduler/ipp.c:3634 scheduler/ipp.c:6550 scheduler/ipp.c:7249 -#: scheduler/ipp.c:8749 +#: scheduler/ipp.c:3651 scheduler/ipp.c:6567 scheduler/ipp.c:7266 +#: scheduler/ipp.c:8766 #, c-format msgid "Subscription #%d does not exist." msgstr "" @@ -4857,7 +4865,7 @@ msgstr "" msgid "Super B/A3" msgstr "" -#: cups/http-support.c:1287 +#: cups/http-support.c:1289 msgid "Switching Protocols" msgstr "" @@ -4890,8 +4898,8 @@ msgstr "" msgid "The \"%s\" attribute is required for print jobs." msgstr "" -#: scheduler/ipp.c:6265 scheduler/ipp.c:6343 scheduler/ipp.c:6359 -#: scheduler/ipp.c:6377 +#: scheduler/ipp.c:6282 scheduler/ipp.c:6360 scheduler/ipp.c:6376 +#: scheduler/ipp.c:6394 #, c-format msgid "The %s attribute cannot be provided with job-ids." msgstr "" @@ -4901,17 +4909,17 @@ msgstr "" msgid "The '%s' Job Description attribute cannot be supplied in a job creation request." msgstr "" -#: scheduler/ipp.c:5207 +#: scheduler/ipp.c:5224 #, c-format msgid "The '%s' operation attribute cannot be supplied in a Create-Job request." msgstr "" -#: scheduler/ipp.c:6780 +#: scheduler/ipp.c:6797 #, c-format msgid "The PPD file \"%s\" could not be found." msgstr "" -#: scheduler/ipp.c:6767 +#: scheduler/ipp.c:6784 #, c-format msgid "The PPD file \"%s\" could not be opened: %s" msgstr "" @@ -4945,7 +4953,7 @@ msgstr "" msgid "The notify-lease-duration attribute cannot be used with job subscriptions." msgstr "" -#: scheduler/ipp.c:2157 scheduler/ipp.c:5525 +#: scheduler/ipp.c:2157 scheduler/ipp.c:5542 #, c-format msgid "The notify-user-data value is too large (%d > 63 octets)." msgstr "" @@ -5049,14 +5057,14 @@ msgstr "" msgid "The printer name may only contain up to 127 printable characters and may not contain spaces, slashes (/), or the pound sign (#)." msgstr "" -#: scheduler/ipp.c:875 scheduler/ipp.c:1135 scheduler/ipp.c:3275 -#: scheduler/ipp.c:3454 scheduler/ipp.c:5190 scheduler/ipp.c:5359 -#: scheduler/ipp.c:5673 scheduler/ipp.c:6231 scheduler/ipp.c:6985 -#: scheduler/ipp.c:7041 scheduler/ipp.c:7355 scheduler/ipp.c:7621 -#: scheduler/ipp.c:7710 scheduler/ipp.c:7743 scheduler/ipp.c:8066 -#: scheduler/ipp.c:8459 scheduler/ipp.c:8541 scheduler/ipp.c:9702 -#: scheduler/ipp.c:10156 scheduler/ipp.c:10487 scheduler/ipp.c:10569 -#: scheduler/ipp.c:10943 +#: scheduler/ipp.c:875 scheduler/ipp.c:1135 scheduler/ipp.c:3292 +#: scheduler/ipp.c:3471 scheduler/ipp.c:5207 scheduler/ipp.c:5376 +#: scheduler/ipp.c:5690 scheduler/ipp.c:6248 scheduler/ipp.c:7002 +#: scheduler/ipp.c:7058 scheduler/ipp.c:7372 scheduler/ipp.c:7638 +#: scheduler/ipp.c:7727 scheduler/ipp.c:7760 scheduler/ipp.c:8083 +#: scheduler/ipp.c:8476 scheduler/ipp.c:8558 scheduler/ipp.c:9719 +#: scheduler/ipp.c:10173 scheduler/ipp.c:10504 scheduler/ipp.c:10586 +#: scheduler/ipp.c:10960 msgid "The printer or class does not exist." msgstr "" @@ -5089,7 +5097,7 @@ msgstr "" msgid "The printer-uri \"%s\" contains invalid characters." msgstr "" -#: scheduler/ipp.c:3252 +#: scheduler/ipp.c:3269 msgid "The printer-uri attribute is required." msgstr "" @@ -5109,12 +5117,12 @@ msgstr "" msgid "The web interface is currently disabled. Run \"cupsctl WebInterface=yes\" to enable it." msgstr "" -#: scheduler/ipp.c:6326 +#: scheduler/ipp.c:6343 #, c-format msgid "The which-jobs value \"%s\" is not supported." msgstr "" -#: scheduler/ipp.c:5603 +#: scheduler/ipp.c:5620 msgid "There are too many subscriptions." msgstr "" @@ -5123,7 +5131,7 @@ msgid "There is a paper jam." msgstr "" #: backend/usb-darwin.c:412 backend/usb-darwin.c:471 backend/usb-darwin.c:535 -#: backend/usb-darwin.c:556 backend/usb-libusb.c:366 backend/usb-libusb.c:420 +#: backend/usb-darwin.c:556 backend/usb-libusb.c:368 backend/usb-libusb.c:422 msgid "There was an unrecoverable USB error." msgstr "" @@ -5140,7 +5148,7 @@ msgstr "" msgid "Too many job-sheets values (%d > 2)." msgstr "" -#: scheduler/ipp.c:2606 +#: scheduler/ipp.c:2623 #, c-format msgid "Too many printer-state-reasons values (%d > %d)." msgstr "" @@ -5169,7 +5177,7 @@ msgstr "" msgid "Tray 4" msgstr "" -#: cups/http-support.c:1327 +#: cups/http-support.c:1329 msgid "URI Too Long" msgstr "" @@ -5221,7 +5229,7 @@ msgstr "" msgid "Unable to add class" msgstr "" -#: backend/ipp.c:1773 +#: backend/ipp.c:1774 msgid "Unable to add document to print job." msgstr "" @@ -5250,7 +5258,7 @@ msgstr "" msgid "Unable to cancel RSS subscription" msgstr "" -#: backend/ipp.c:2165 +#: backend/ipp.c:2171 msgid "Unable to cancel print job." msgstr "" @@ -5266,12 +5274,12 @@ msgstr "" msgid "Unable to change server settings" msgstr "" -#: cups/ipp.c:5276 +#: cups/ipp.c:5405 #, c-format msgid "Unable to compile mimeMediaType regular expression: %s." msgstr "" -#: cups/ipp.c:5222 +#: cups/ipp.c:5351 #, c-format msgid "Unable to compile naturalLanguage regular expression: %s." msgstr "" @@ -5304,12 +5312,12 @@ msgstr "" msgid "Unable to copy CUPS printer driver files (%d)." msgstr "" -#: scheduler/ipp.c:2726 +#: scheduler/ipp.c:2743 #, c-format msgid "Unable to copy PPD file - %s" msgstr "" -#: scheduler/ipp.c:2781 +#: scheduler/ipp.c:2798 msgid "Unable to copy PPD file." msgstr "" @@ -5323,7 +5331,7 @@ msgstr "" msgid "Unable to copy Windows 9x printer driver files (%d)." msgstr "" -#: scheduler/ipp.c:2703 +#: scheduler/ipp.c:2720 #, c-format msgid "Unable to copy interface script - %s" msgstr "" @@ -5352,35 +5360,35 @@ msgstr "" msgid "Unable to edit cupsd.conf files larger than 1MB" msgstr "" -#: cups/http.c:5473 +#: cups/http.c:5478 msgid "Unable to establish a secure connection to host (certificate chain invalid)." msgstr "" -#: cups/http.c:5463 +#: cups/http.c:5468 msgid "Unable to establish a secure connection to host (certificate not yet valid)." msgstr "" -#: cups/http.c:5458 +#: cups/http.c:5463 msgid "Unable to establish a secure connection to host (expired certificate)." msgstr "" -#: cups/http.c:5468 +#: cups/http.c:5473 msgid "Unable to establish a secure connection to host (host name mismatch)." msgstr "" -#: cups/http.c:5478 +#: cups/http.c:5483 msgid "Unable to establish a secure connection to host (peer dropped connection before responding)." msgstr "" -#: cups/http.c:5453 +#: cups/http.c:5458 msgid "Unable to establish a secure connection to host (self-signed certificate)." msgstr "" -#: cups/http.c:5448 +#: cups/http.c:5453 msgid "Unable to establish a secure connection to host (untrusted certificate)." msgstr "" -#: cups/http.c:5249 cups/http.c:5505 cups/http.c:5538 cups/http.c:5555 +#: cups/http.c:5254 cups/http.c:5510 cups/http.c:5543 cups/http.c:5560 msgid "Unable to establish a secure connection to host." msgstr "" @@ -5388,11 +5396,11 @@ msgstr "" msgid "Unable to find destination for job" msgstr "" -#: cups/http-support.c:1767 +#: cups/http-support.c:1769 msgid "Unable to find printer." msgstr "" -#: backend/ipp.c:3387 +#: backend/ipp.c:3393 msgid "Unable to get backend exit status." msgstr "" @@ -5476,7 +5484,7 @@ msgstr "" msgid "Unable to open device file" msgstr "" -#: scheduler/ipp.c:6012 +#: scheduler/ipp.c:6029 #, c-format msgid "Unable to open document #%d in job #%d." msgstr "" @@ -5485,7 +5493,7 @@ msgstr "" msgid "Unable to open help file." msgstr "" -#: backend/ipp.c:393 backend/ipp.c:1520 backend/ipp.c:1728 backend/lpd.c:505 +#: backend/ipp.c:393 backend/ipp.c:1520 backend/ipp.c:1729 backend/lpd.c:505 #: backend/socket.c:155 backend/usb.c:237 filter/gziptoany.c:71 #: filter/pstops.c:300 msgid "Unable to open print file" @@ -5501,7 +5509,7 @@ msgid "Unable to print test page" msgstr "" #: backend/runloop.c:96 backend/runloop.c:325 backend/usb-darwin.c:643 -#: backend/usb-darwin.c:687 backend/usb-libusb.c:511 backend/usb-libusb.c:546 +#: backend/usb-darwin.c:687 backend/usb-libusb.c:513 backend/usb-libusb.c:548 msgid "Unable to read print data." msgstr "" @@ -5522,7 +5530,7 @@ msgstr "" msgid "Unable to send command to printer driver" msgstr "" -#: backend/usb-darwin.c:765 backend/usb-libusb.c:622 +#: backend/usb-darwin.c:765 backend/usb-libusb.c:624 msgid "Unable to send data to printer." msgstr "" @@ -5539,7 +5547,7 @@ msgstr "" msgid "Unable to set server default" msgstr "" -#: backend/ipp.c:3246 backend/ipp.c:3323 backend/ipp.c:3331 +#: backend/ipp.c:3252 backend/ipp.c:3329 backend/ipp.c:3337 msgid "Unable to start backend process." msgstr "" @@ -5547,7 +5555,7 @@ msgstr "" msgid "Unable to upload cupsd.conf file" msgstr "" -#: backend/usb-darwin.c:2019 backend/usb-darwin.c:2043 +#: backend/usb-darwin.c:2033 backend/usb-darwin.c:2057 msgid "Unable to use legacy USB class driver." msgstr "" @@ -5560,7 +5568,7 @@ msgstr "" msgid "Unable to write uncompressed print data: %s" msgstr "" -#: cups/http-support.c:1315 +#: cups/http-support.c:1317 msgid "Unauthorized" msgstr "" @@ -5568,7 +5576,7 @@ msgstr "" msgid "Units" msgstr "" -#: cups/http-support.c:1355 cups/ppd.c:366 +#: cups/http-support.c:1357 cups/ppd.c:366 msgid "Unknown" msgstr "" @@ -5592,7 +5600,7 @@ msgstr "" msgid "Unknown format character: \"%c\"." msgstr "" -#: cups/dest-options.c:769 +#: cups/dest-options.c:984 msgid "Unknown media size name." msgstr "" @@ -5611,12 +5619,12 @@ msgstr "" msgid "Unknown print mode: \"%s\"." msgstr "" -#: scheduler/ipp.c:10358 +#: scheduler/ipp.c:10375 #, c-format msgid "Unknown printer-error-policy \"%s\"." msgstr "" -#: scheduler/ipp.c:10341 +#: scheduler/ipp.c:10358 #, c-format msgid "Unknown printer-op-policy \"%s\"." msgstr "" @@ -5630,17 +5638,17 @@ msgstr "" msgid "Unknown version option value: \"%s\"." msgstr "" -#: scheduler/ipp.c:10814 +#: scheduler/ipp.c:10831 #, c-format msgid "Unsupported 'compression' value \"%s\"." msgstr "" -#: scheduler/ipp.c:10844 +#: scheduler/ipp.c:10861 #, c-format msgid "Unsupported 'document-format' value \"%s\"." msgstr "" -#: scheduler/ipp.c:10919 +#: scheduler/ipp.c:10936 msgid "Unsupported 'job-name' value." msgstr "" @@ -5649,17 +5657,17 @@ msgstr "" msgid "Unsupported character set \"%s\"." msgstr "" -#: scheduler/ipp.c:8032 scheduler/ipp.c:9263 +#: scheduler/ipp.c:8049 scheduler/ipp.c:9280 #, c-format msgid "Unsupported compression \"%s\"." msgstr "" -#: scheduler/ipp.c:8166 scheduler/ipp.c:9413 +#: scheduler/ipp.c:8183 scheduler/ipp.c:9430 #, c-format msgid "Unsupported document-format \"%s\"." msgstr "" -#: scheduler/ipp.c:9396 +#: scheduler/ipp.c:9413 #, c-format msgid "Unsupported document-format \"%s/%s\"." msgstr "" @@ -5673,7 +5681,7 @@ msgstr "" msgid "Unsupported margins." msgstr "" -#: cups/pwg-media.c:553 +#: cups/pwg-media.c:567 msgid "Unsupported media value." msgstr "" @@ -5700,7 +5708,7 @@ msgstr "" msgid "Unsupported value type" msgstr "" -#: cups/http-support.c:1330 +#: cups/http-support.c:1332 msgid "Upgrade Required" msgstr "" @@ -5815,11 +5823,11 @@ msgstr "" msgid "Version uses indefinite length" msgstr "" -#: backend/ipp.c:1874 +#: backend/ipp.c:1875 msgid "Waiting for job to complete." msgstr "" -#: backend/usb-darwin.c:490 backend/usb-libusb.c:318 +#: backend/usb-darwin.c:490 backend/usb-libusb.c:320 msgid "Waiting for printer to become available." msgstr "" @@ -5831,7 +5839,7 @@ msgstr "" msgid "Warning, no Windows 2000 printer drivers are installed." msgstr "" -#: cups/http-support.c:1351 +#: cups/http-support.c:1353 msgid "Web Interface is Disabled" msgstr "" @@ -5868,11 +5876,11 @@ msgstr "" msgid "completed" msgstr "" -#: scheduler/ipp.c:5884 +#: scheduler/ipp.c:5901 msgid "cups-deviced failed to execute." msgstr "" -#: scheduler/ipp.c:6703 scheduler/ipp.c:6952 +#: scheduler/ipp.c:6720 scheduler/ipp.c:6969 msgid "cups-driverd failed to execute." msgstr "" @@ -6046,7 +6054,7 @@ msgstr "" msgid "ipptool: Unknown option \"-%c\"." msgstr "" -#: scheduler/ipp.c:7699 +#: scheduler/ipp.c:7716 msgid "job-printer-uri attribute missing." msgstr "" @@ -6352,16 +6360,16 @@ msgstr "" msgid "no system default destination" msgstr "" -#: scheduler/ipp.c:5574 +#: scheduler/ipp.c:5591 msgid "notify-events not specified." msgstr "" -#: scheduler/ipp.c:2111 scheduler/ipp.c:5479 +#: scheduler/ipp.c:2111 scheduler/ipp.c:5496 #, c-format msgid "notify-recipient-uri URI \"%s\" is already used." msgstr "" -#: scheduler/ipp.c:2101 scheduler/ipp.c:5469 +#: scheduler/ipp.c:2101 scheduler/ipp.c:5486 #, c-format msgid "notify-recipient-uri URI \"%s\" uses unknown scheme." msgstr "" diff --git a/locale/cups.strings b/locale/cups.strings index 53508f5ad..e125be903 100644 --- a/locale/cups.strings +++ b/locale/cups.strings @@ -838,6 +838,7 @@ "Internet Postage 2-Part" = "Internet Postage 2-Part"; "Internet Postage 3-Part" = "Internet Postage 3-Part"; "Internet Printing Protocol" = "Internet Printing Protocol"; +"Invalid media name arguments." = "Invalid media name arguments."; "Invalid media size." = "Invalid media size."; "Invalid printer command \"%s\"." = "Invalid printer command \"%s\"."; "JCL" = "JCL"; @@ -1027,6 +1028,7 @@ "Printer Paused" = "Printer Paused"; "Printer Settings" = "Printer Settings"; "Printer cannot print supplied content." = "Printer cannot print supplied content."; +"Printer cannot print with supplied options." = "Printer cannot print with supplied options."; "Printer:" = "Printer:"; "Printers" = "Printers"; "Printing page %d, %d%% complete." = "Printing page %d, %d%% complete."; diff --git a/locale/cups_ca.po b/locale/cups_ca.po index 350a535a9..be78334cf 100644 --- a/locale/cups_ca.po +++ b/locale/cups_ca.po @@ -32,7 +32,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.4.6\n" "Report-Msgid-Bugs-To: http://www.cups.org/str.php\n" -"POT-Creation-Date: 2013-03-08 13:23-0500\n" +"POT-Creation-Date: 2013-03-20 15:42-0400\n" "PO-Revision-Date: 2012-09-29 11:21+0200\n" "Last-Translator: Àngel Mompó \n" "Language-Team: Catalan \n" @@ -3178,6 +3178,9 @@ msgstr "Franqueig per Internet en 3 parts" msgid "Internet Printing Protocol" msgstr "Protocol d'impressió per Internet" +msgid "Invalid media name arguments." +msgstr "" + msgid "Invalid media size." msgstr "Mida del suport no vàlida." @@ -3782,6 +3785,9 @@ msgstr "Configuració de la impressora" msgid "Printer cannot print supplied content." msgstr "La impressora no pot imprimir el contingut subministrat." +msgid "Printer cannot print with supplied options." +msgstr "" + msgid "Printer:" msgstr "Impressora:" diff --git a/locale/cups_es.po b/locale/cups_es.po index 1a8c18ba7..7e9161c27 100644 --- a/locale/cups_es.po +++ b/locale/cups_es.po @@ -16,7 +16,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: http://www.cups.org/str.php\n" -"POT-Creation-Date: 2013-03-08 13:23-0500\n" +"POT-Creation-Date: 2013-03-20 15:42-0400\n" "PO-Revision-Date: 2012-07-01 20:21+0100\n" "Last-Translator: Juan Pablo González Riopedre \n" "Language-Team: Spanish\n" @@ -3165,6 +3165,9 @@ msgstr "Correo por Internet Parte-3" msgid "Internet Printing Protocol" msgstr "Protocolo de Impresión de Internet IPP" +msgid "Invalid media name arguments." +msgstr "" + msgid "Invalid media size." msgstr "Tamaño del papel no válido" @@ -3770,6 +3773,9 @@ msgstr "Configuración de la impresora" msgid "Printer cannot print supplied content." msgstr "La impresora no puede imprimir el contenido suministrado." +msgid "Printer cannot print with supplied options." +msgstr "" + msgid "Printer:" msgstr "Impresora:" diff --git a/locale/cups_fr.po b/locale/cups_fr.po index 7b6666ea8..3887b3279 100644 --- a/locale/cups_fr.po +++ b/locale/cups_fr.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: http://www.cups.org/str.php\n" -"POT-Creation-Date: 2013-03-08 13:23-0500\n" +"POT-Creation-Date: 2013-03-20 15:42-0400\n" "PO-Revision-Date: 2012-12-12 11:12+0100\n" "Last-Translator: denis meramdjougoma \n" "Language-Team: LANGUAGE \n" @@ -2969,6 +2969,9 @@ msgstr "Affranchissement Internet en 3 parties" msgid "Internet Printing Protocol" msgstr "Internet Printing Protocol" +msgid "Invalid media name arguments." +msgstr "" + msgid "Invalid media size." msgstr "" @@ -3565,6 +3568,9 @@ msgstr "Réglages de l’imprimante" msgid "Printer cannot print supplied content." msgstr "" +msgid "Printer cannot print with supplied options." +msgstr "" + msgid "Printer:" msgstr "Imprimante :" diff --git a/locale/cups_ja.po b/locale/cups_ja.po index 55eecb18c..ab16be3e7 100644 --- a/locale/cups_ja.po +++ b/locale/cups_ja.po @@ -28,7 +28,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: http://www.cups.org/str.php\n" -"POT-Creation-Date: 2013-03-08 13:23-0500\n" +"POT-Creation-Date: 2013-03-20 15:42-0400\n" "PO-Revision-Date: 2012-06-13 01:20+0900\n" "Last-Translator: OPFC TRANSCUPS \n" "Language-Team: OPFC TRANSCUPS \n" @@ -3162,6 +3162,9 @@ msgstr "Internet Postage 3-Part" msgid "Internet Printing Protocol" msgstr "インターネット印刷プロトコル" +msgid "Invalid media name arguments." +msgstr "" + msgid "Invalid media size." msgstr "無効なメディアサイズです。" @@ -3765,6 +3768,9 @@ msgstr "プリンター設定" msgid "Printer cannot print supplied content." msgstr "プリンターは受信した内容を印刷できませんでした。" +msgid "Printer cannot print with supplied options." +msgstr "" + msgid "Printer:" msgstr "プリンター:" diff --git a/locale/cups_ru.po b/locale/cups_ru.po index 022aee704..53ae955c4 100644 --- a/locale/cups_ru.po +++ b/locale/cups_ru.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.4\n" "Report-Msgid-Bugs-To: http://www.cups.org/str.php\n" -"POT-Creation-Date: 2013-03-08 13:23-0500\n" +"POT-Creation-Date: 2013-03-20 15:42-0400\n" "PO-Revision-Date: 2009-02-16 12:00-0800\n" "Last-Translator: Apple Inc.\n" "Language-Team: Apple Inc.\n" @@ -2945,6 +2945,9 @@ msgstr "Наклейки Internet Postage 3-Part" msgid "Internet Printing Protocol" msgstr "Протокол интернет-печати" +msgid "Invalid media name arguments." +msgstr "" + msgid "Invalid media size." msgstr "" @@ -3541,6 +3544,9 @@ msgstr "Параметры принтера" msgid "Printer cannot print supplied content." msgstr "" +msgid "Printer cannot print with supplied options." +msgstr "" + msgid "Printer:" msgstr "Принтер:" diff --git a/scheduler/Makefile b/scheduler/Makefile index 19e16069d..b03d347cb 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -126,6 +126,14 @@ depend: $(CXX) -MM $(ALL_CXXFLAGS) $(CXXOBJS:.o=.cxx) >>Dependencies +# +# Run oclint to check code coverage... +# + +oclint: + oclint -o=oclint.html -html $(CUPSDOBJS:.o=.c) $(LIBOBJS:.o=.c) -- $(ALL_CFLAGS) + + # # Install all targets... # diff --git a/scheduler/auth.c b/scheduler/auth.c index c8e89b9ce..292a7f29c 100644 --- a/scheduler/auth.c +++ b/scheduler/auth.c @@ -513,18 +513,37 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ socklen_t peersize; /* Size of peer credentials */ #ifdef HAVE_AUTHORIZATION_H const char *name; /* Authorizing name */ + int no_peer = 0; /* Don't allow peer credentials? */ + + /* + * See if we should allow peer credentials... + */ for (name = (char *)cupsArrayFirst(con->best->names); name; name = (char *)cupsArrayNext(con->best->names)) + { if (!_cups_strncasecmp(name, "@AUTHKEY(", 9) || !_cups_strcasecmp(name, "@SYSTEM")) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Client %d] PeerCred authentication not allowed for " - "resource.", con->http.fd); - return; + /* Normally don't want peer credentials if we need an auth key... */ + no_peer = 1; } + else if (!_cups_strcasecmp(name, "@OWNER")) + { + /* but if @OWNER is present then we allow it... */ + no_peer = 0; + break; + } + } + + if (no_peer) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "[Client %d] PeerCred authentication not allowed for " + "resource per AUTHKEY policy.", con->http.fd); + return; + } #endif /* HAVE_AUTHORIZATION_H */ if ((pwd = getpwnam(authorization + 9)) == NULL) diff --git a/scheduler/client.c b/scheduler/client.c index 24d077bbd..6cd00fc34 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -436,7 +436,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */ { if (httpAddrLocalhost(&temp)) strlcpy(con->servername, "localhost", sizeof(con->servername)); - else if (HostNameLookups || RemotePort) + else if (HostNameLookups) httpAddrLookup(&temp, con->servername, sizeof(con->servername)); else httpAddrString(&temp, con->servername, sizeof(con->servername)); @@ -1302,7 +1302,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ { case HTTP_STATE_GET_SEND : if ((!strncmp(con->uri, "/ppd/", 5) || - !strncmp(con->uri, "/printers/", 10)) && + !strncmp(con->uri, "/printers/", 10) || + !strncmp(con->uri, "/classes/", 9)) && !strcmp(con->uri + strlen(con->uri) - 4, ".ppd")) { /* @@ -1314,8 +1315,36 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ if (!strncmp(con->uri, "/ppd/", 5)) p = cupsdFindPrinter(con->uri + 5); - else + else if (!strncmp(con->uri, "/printers/", 10)) p = cupsdFindPrinter(con->uri + 10); + else + { + p = cupsdFindClass(con->uri + 9); + + if (p) + { + int i; /* Looping var */ + + for (i = 0; i < p->num_printers; i ++) + { + if (!(p->printers[i]->type & CUPS_PRINTER_CLASS)) + { + char ppdname[1024];/* PPD filename */ + + snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd", + ServerRoot, p->printers[i]->name); + if (!access(ppdname, 0)) + { + p = p->printers[i]; + break; + } + } + } + + if (i >= p->num_printers) + p = NULL; + } + } if (p) { @@ -1349,7 +1378,33 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ else if (!strncmp(con->uri, "/printers/", 10)) p = cupsdFindPrinter(con->uri + 10); else - p = cupsdFindClass(con->uri + 9); + { + p = cupsdFindClass(con->uri + 9); + + if (p) + { + int i; /* Looping var */ + + for (i = 0; i < p->num_printers; i ++) + { + if (!(p->printers[i]->type & CUPS_PRINTER_CLASS)) + { + char ppdname[1024];/* PPD filename */ + + snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd", + ServerRoot, p->printers[i]->name); + if (!access(ppdname, 0)) + { + p = p->printers[i]; + break; + } + } + } + + if (i >= p->num_printers) + p = NULL; + } + } if (p) snprintf(con->uri, sizeof(con->uri), "/icons/%s.png", p->name); @@ -2128,6 +2183,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ return; } + if (data_ready(con)) + continue; break; } else @@ -2619,7 +2676,14 @@ cupsdSendHeader( con->http.hostname); #ifdef HAVE_GSSAPI else if (auth_type == CUPSD_AUTH_NEGOTIATE) + { +# ifdef AF_LOCAL + if (_httpAddrFamily(con->http.hostaddr) == AF_LOCAL) + strlcpy(auth_str, "Basic realm=\"CUPS\"", sizeof(auth_str)); + else +# endif /* AF_LOCAL */ strlcpy(auth_str, "Negotiate", sizeof(auth_str)); + } #endif /* HAVE_GSSAPI */ if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE && diff --git a/scheduler/conf.c b/scheduler/conf.c index 5492eb5d7..28cfbd24c 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -704,7 +704,7 @@ cupsdReadConfiguration(void) AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS; ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM; FatalErrors = parse_fatal_errors(CUPS_DEFAULT_FATAL_ERRORS); - default_auth_type = CUPSD_AUTH_BASIC; + default_auth_type = CUPSD_AUTH_BASIC; #ifdef HAVE_SSL DefaultEncryption = HTTP_ENCRYPT_REQUIRED; SSLOptions = CUPSD_SSL_NONE; @@ -766,7 +766,7 @@ cupsdReadConfiguration(void) cupsdClearString(&DefaultPolicy); #ifdef HAVE_AUTHORIZATION_H - cupsdClearString(&SystemGroupAuthKey); + cupsdSetString(&SystemGroupAuthKey, CUPS_DEFAULT_SYSTEM_AUTHKEY); #endif /* HAVE_AUTHORIZATION_H */ MaxSubscriptions = 100; @@ -3349,7 +3349,7 @@ read_cupsd_conf(cups_file_t *fp) /* I - File to read from */ !_cups_strcasecmp(line, "TempDir") || !_cups_strcasecmp(line, "User")) { - cupsdLogMessage(CUPSD_LOG_WARN, + cupsdLogMessage(CUPSD_LOG_INFO, "Please move \"%s%s%s\" on line %d of %s to the %s file; " "this will become an error in a future release.", line, value ? " " : "", value ? value : "", linenum, diff --git a/scheduler/cups-exec.c b/scheduler/cups-exec.c index cc7056768..1541a785f 100644 --- a/scheduler/cups-exec.c +++ b/scheduler/cups-exec.c @@ -31,6 +31,7 @@ # ifndef SANDBOX_NAMED_EXTERNAL # define SANDBOX_NAMED_EXTERNAL 0x0003 # endif /* !SANDBOX_NAMED_EXTERNAL */ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif /* HAVE_SANDBOX_H */ @@ -60,7 +61,6 @@ main(int argc, /* I - Number of command-line args */ } #ifdef HAVE_SANDBOX_H -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" /* * Run in a separate security profile... */ diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c index c4806f569..84eefde5f 100644 --- a/scheduler/cupsfilter.c +++ b/scheduler/cupsfilter.c @@ -917,7 +917,7 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ { int i; /* Looping var */ const char *argv[8], /* Command-line arguments */ - *envp[16], /* Environment variables */ + *envp[17], /* Environment variables */ *temp; /* Temporary string */ char *optstr, /* Filter options */ content_type[1024], /* CONTENT_TYPE */ @@ -925,6 +925,8 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ cups_fontpath[1024], /* CUPS_FONTPATH */ cups_serverbin[1024], /* CUPS_SERVERBIN */ cups_serverroot[1024], /* CUPS_SERVERROOT */ + final_content_type[1024] = "", + /* FINAL_CONTENT_TYPE */ lang[1024], /* LANG */ path[1024], /* PATH */ ppd[1024], /* PPD */ @@ -947,6 +949,39 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ cups_dest_t *dest; /* Destination information */ + /* + * Figure out the final content type... + */ + + for (filter = (mime_filter_t *)cupsArrayLast(filters); + filter && filter->dst; + filter = (mime_filter_t *)cupsArrayPrev(filters)) + if (strcmp(filter->dst->super, "printer")) + break; + + if (filter && filter->dst) + { + const char *ptr; /* Pointer in type name */ + + if ((ptr = strchr(filter->dst->type, '/')) != NULL) + snprintf(final_content_type, sizeof(final_content_type), + "FINAL_CONTENT_TYPE=%s", ptr + 1); + else + snprintf(final_content_type, sizeof(final_content_type), + "FINAL_CONTENT_TYPE=%s/%s", filter->dst->super, + filter->dst->type); + } + + /* + * Remove NULL ("-") filters... + */ + + for (filter = (mime_filter_t *)cupsArrayFirst(filters); + filter; + filter = (mime_filter_t *)cupsArrayNext(filters)) + if (!strcmp(filter->filter, "-")) + cupsArrayRemove(filters, filter); + /* * Setup the filter environment and command-line... */ @@ -1041,7 +1076,13 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ envp[12] = rip_max_cache; envp[13] = userenv; envp[14] = "CHARSET=utf-8"; - envp[15] = NULL; + if (final_content_type[0]) + { + envp[15] = final_content_type; + envp[16] = NULL; + } + else + envp[15] = NULL; for (i = 0; argv[i]; i ++) fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]); diff --git a/scheduler/ipp.c b/scheduler/ipp.c index febd66dfe..4cd065d96 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -2411,6 +2411,21 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ http_uri_status_t uri_status; /* URI separation status */ char old_device_uri[1024]; /* Old device URI */ + static const char * const uri_status_strings[] = + { + "URI too large.", + "Bad arguments to function.", + "Bad resource path.", + "Bad port number.", + "Bad hostname/address.", + "Bad username/password.", + "Bad URI scheme.", + "Bad URI.", + "OK", + "Missing URI scheme.", + "Unknown URI scheme", + "Missing resource path." + }; need_restart_job = 1; @@ -2422,12 +2437,14 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ host, sizeof(host), &port, resource, sizeof(resource)); + cupsdLogMessage(CUPSD_LOG_DEBUG, + "%s device-uri: %s", printer->name, + uri_status_strings[uri_status - HTTP_URI_STATUS_OVERFLOW]); + if (uri_status < HTTP_URI_OK) { send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"."), attr->values[0].string.text); - cupsdLogMessage(CUPSD_LOG_DEBUG, - "add_printer: httpSeparateURI returned %d", uri_status); return; } diff --git a/scheduler/job.c b/scheduler/job.c index c325d0680..a2ef65f71 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -560,7 +560,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ /* CONTENT_TYPE env variable */ device_uri[1024], /* DEVICE_URI env variable */ - final_content_type[1024], + final_content_type[1024] = "", /* FINAL_CONTENT_TYPE env variable */ lang[255], /* LANG env variable */ #ifdef __APPLE__ @@ -598,7 +598,6 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ memset(job->filters, 0, sizeof(job->filters)); - if (job->printer->raw) { /* @@ -636,6 +635,44 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ goto abort_job; } + /* + * Figure out the final content type... + */ + + cupsdLogJob(job, CUPSD_LOG_DEBUG, "%d filters for job:", + cupsArrayCount(filters)); + for (filter = (mime_filter_t *)cupsArrayFirst(filters); + filter; + filter = (mime_filter_t *)cupsArrayNext(filters)) + cupsdLogJob(job, CUPSD_LOG_DEBUG, "%s (%s/%s to %s/%s, cost %d)", + filter->filter, + filter->src ? filter->src->super : "???", + filter->src ? filter->src->type : "???", + filter->dst ? filter->dst->super : "???", + filter->dst ? filter->dst->type : "???", + filter->cost); + + if (!job->printer->remote) + { + for (filter = (mime_filter_t *)cupsArrayLast(filters); + filter && filter->dst; + filter = (mime_filter_t *)cupsArrayPrev(filters)) + if (strcmp(filter->dst->super, "printer") || + strcmp(filter->dst->type, job->printer->name)) + break; + + if (filter && filter->dst) + { + if ((ptr = strchr(filter->dst->type, '/')) != NULL) + snprintf(final_content_type, sizeof(final_content_type), + "FINAL_CONTENT_TYPE=%s", ptr + 1); + else + snprintf(final_content_type, sizeof(final_content_type), + "FINAL_CONTENT_TYPE=%s/%s", filter->dst->super, + filter->dst->type); + } + } + /* * Remove NULL ("-") filters... */ @@ -1034,25 +1071,8 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */ envp[envc ++] = banner_page ? "CUPS_FILETYPE=job-sheet" : "CUPS_FILETYPE=document"; - if (!job->printer->remote && !job->printer->raw) - { - filter = (mime_filter_t *)cupsArrayLast(filters); - - if (job->printer->port_monitor) - filter = (mime_filter_t *)cupsArrayPrev(filters); - - if (filter && filter->dst) - { - if ((ptr = strchr(filter->dst->type, '/')) != NULL) - snprintf(final_content_type, sizeof(final_content_type), - "FINAL_CONTENT_TYPE=%s", ptr + 1); - else - snprintf(final_content_type, sizeof(final_content_type), - "FINAL_CONTENT_TYPE=%s/%s", filter->dst->super, - filter->dst->type); - envp[envc ++] = final_content_type; - } - } + if (final_content_type[0]) + envp[envc ++] = final_content_type; if (Classification && !banner_page) { @@ -3040,8 +3060,9 @@ finalize_job(cupsd_job_t *job, /* I - Job */ job_state = IPP_JOB_COMPLETED; message = "Job completed."; - ippSetString(job->attrs, &job->reasons, 0, - "job-completed-successfully"); + if (!job->status) + ippSetString(job->attrs, &job->reasons, 0, + "job-completed-successfully"); break; case IPP_JOB_STOPPED : @@ -3227,13 +3248,48 @@ finalize_job(cupsd_job_t *job, /* I - Job */ * Hold the job... */ - cupsdSetJobHoldUntil(job, "indefinite", 1); - ippSetString(job->attrs, &job->reasons, 0, - "job-hold-until-specified"); + const char *reason = ippGetString(job->reasons, 0, NULL); - job_state = IPP_JOB_HELD; - message = "Job held indefinitely due to backend errors; please " + cupsdLogJob(job, CUPSD_LOG_DEBUG, "job-state-reasons=\"%s\"", + reason); + + if (!reason || strncmp(reason, "account-", 8)) + { + cupsdSetJobHoldUntil(job, "indefinite", 1); + + ippSetString(job->attrs, &job->reasons, 0, + "job-hold-until-specified"); + message = "Job held indefinitely due to backend errors; please " "consult the error_log file for details."; + } + else if (!strcmp(reason, "account-info-needed")) + { + cupsdSetJobHoldUntil(job, "indefinite", 0); + + message = "Job held indefinitely - account information is " + "required."; + } + else if (!strcmp(reason, "account-closed")) + { + cupsdSetJobHoldUntil(job, "indefinite", 0); + + message = "Job held indefinitely - account has been closed."; + } + else if (!strcmp(reason, "account-limit-reached")) + { + cupsdSetJobHoldUntil(job, "indefinite", 0); + + message = "Job held indefinitely - account limit has been " + "reached."; + } + else + { + cupsdSetJobHoldUntil(job, "indefinite", 0); + + message = "Job held indefinitely - account authorization failed."; + } + + job_state = IPP_JOB_HELD; } break; diff --git a/scheduler/printers.c b/scheduler/printers.c index 3baa45ca2..17ad5116e 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -2128,7 +2128,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ for (i = 0, name = (char *)cupsArrayFirst(p->users); name; i ++, name = (char *)cupsArrayNext(p->users)) - attr->values[i].string.text = _cupsStrRetain(name); + attr->values[i].string.text = _cupsStrAlloc(name); } ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, @@ -2195,7 +2195,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ for (i = 0; i < p->num_printers; i ++) { if (attr != NULL) - attr->values[i].string.text = _cupsStrRetain(p->printers[i]->name); + attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name); p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type; } @@ -2295,7 +2295,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ { for (i = 0; i < oldattr->num_values; i ++) attr->values[i].string.text = - _cupsStrRetain(oldattr->values[i].string.text); + _cupsStrAlloc(oldattr->values[i].string.text); } } @@ -2349,7 +2349,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ { for (i = 0; i < oldattr->num_values; i ++) attr->values[i].string.text = - _cupsStrRetain(oldattr->values[i].string.text); + _cupsStrAlloc(oldattr->values[i].string.text); } } @@ -2362,7 +2362,7 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ { for (i = 0; i < oldattr->num_values; i ++) attr->values[i].string.text = - _cupsStrRetain(oldattr->values[i].string.text); + _cupsStrAlloc(oldattr->values[i].string.text); } } @@ -3935,13 +3935,13 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ for (i = p->pc->num_sizes, pwgsize = p->pc->sizes; i > 0; i --, pwgsize ++, val ++) - val->string.text = _cupsStrRetain(pwgsize->map.pwg); + val->string.text = _cupsStrAlloc(pwgsize->map.pwg); if (p->pc->custom_min_keyword) { - val->string.text = _cupsStrRetain(p->pc->custom_min_keyword); + val->string.text = _cupsStrAlloc(p->pc->custom_min_keyword); val ++; - val->string.text = _cupsStrRetain(p->pc->custom_max_keyword); + val->string.text = _cupsStrAlloc(p->pc->custom_max_keyword); } } @@ -3993,7 +3993,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ val = attr->values; i > 0; i --, pwgsource ++, val ++) - val->string.text = _cupsStrRetain(pwgsource->pwg); + val->string.text = _cupsStrAlloc(pwgsource->pwg); } /* @@ -4009,7 +4009,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ val = attr->values; i > 0; i --, pwgtype ++, val ++) - val->string.text = _cupsStrRetain(pwgtype->pwg); + val->string.text = _cupsStrAlloc(pwgtype->pwg); } /* @@ -4295,7 +4295,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ mandatory = (char *)cupsArrayFirst(p->pc->mandatory); mandatory; val ++, mandatory = (char *)cupsArrayNext(p->pc->mandatory)) - val->string.text = _cupsStrRetain(mandatory); + val->string.text = _cupsStrAlloc(mandatory); } /* diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 9a17f3e72..9973417c1 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -3,7 +3,7 @@ * * PPD test program for CUPS. * - * Copyright 2007-2012 by Apple Inc. + * Copyright 2007-2013 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -3210,11 +3210,11 @@ check_sizes(ppd_file_t *ppd, /* I - PPD file */ { is_ok = 1; width_2540ths = (size->length > size->width) ? - _PWG_FROMPTS(size->width) : - _PWG_FROMPTS(size->length); + PWG_FROM_POINTS(size->width) : + PWG_FROM_POINTS(size->length); length_2540ths = (size->length > size->width) ? - _PWG_FROMPTS(size->length) : - _PWG_FROMPTS(size->width); + PWG_FROM_POINTS(size->length) : + PWG_FROM_POINTS(size->width); pwg_media = _pwgMediaForSize(width_2540ths, length_2540ths); if (pwg_media && diff --git a/test/Makefile b/test/Makefile index 2cec84c34..66b535378 100644 --- a/test/Makefile +++ b/test/Makefile @@ -49,7 +49,8 @@ TESTFILES = \ ipp-everywhere.test \ print-job.test \ print-job-deflate.test \ - print-job-gzip.test + print-job-gzip.test \ + validate-job.test OBJS = \ ippserver.o \ ipptool.o \ diff --git a/test/ipptool.c b/test/ipptool.c index 99f3b5236..166336cd2 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -2474,6 +2474,10 @@ do_tests(_cups_vars_t *vars, /* I - Variables */ else if (status != HTTP_OK) { httpFlush(http); + + if (status == HTTP_STATUS_UNAUTHORIZED) + continue; + break; } } diff --git a/test/validate-job.test b/test/validate-job.test new file mode 100644 index 000000000..c4140ea03 --- /dev/null +++ b/test/validate-job.test @@ -0,0 +1,23 @@ +# Validate a test page using Validate-Job +{ + # The name of the test... + NAME "Validate file/ticket using Validate-Job" + + # The operation to use + OPERATION Validate-Job + + # Attributes, starting in the operation group... + GROUP operation-attributes-tag + ATTR charset attributes-charset utf-8 + ATTR language attributes-natural-language en + ATTR uri printer-uri $uri + ATTR name requesting-user-name $user + ATTR mimeMediaType document-format $filetype + + GROUP job-attributes-tag + ATTR integer copies 1 + + # What statuses are OK? + STATUS successful-ok + STATUS successful-ok-ignored-or-substituted-attributes +} diff --git a/xcode/CUPS.xcodeproj/project.pbxproj b/xcode/CUPS.xcodeproj/project.pbxproj index 4f8a2419b..18990f2be 100644 --- a/xcode/CUPS.xcodeproj/project.pbxproj +++ b/xcode/CUPS.xcodeproj/project.pbxproj @@ -1967,7 +1967,10 @@ 273BF6B81333B4A90022CAAB /* tests */, 72220EAF1333047D00FCA411 /* Products */, ); + indentWidth = 2; sourceTree = ""; + tabWidth = 8; + wrapsLines = 0; }; 72F75A681336FA42004BB496 /* libcupsimage */ = { isa = PBXGroup; -- 2.39.2