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
- cups_dest_s
@@ -515,6 +533,9 @@ information ">cups_dinfo_t
cups_option_s
cups_size_s
pollfd
+ pwg_map_s
+ pwg_media_s
+ pwg_size_s
Variables
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.
+
+
+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.
+
+
+
+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.
+
+
+
+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.
+
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.
@@ -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.
+
+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.
+
+
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.
+
+
+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.
+
+
+
+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.
+
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
+
+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.
+
+
+
+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.
+
+
+
+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".
+
+
+
+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]".
+
+
+
+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.
+
+
+
+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.
+
+
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;
+
+Map element - PPD to/from PWG
+
+typedef struct pwg_map_s pwg_map_t;
+
+
+Common media size data
+
+typedef struct pwg_media_s pwg_media_t;
+
+
+Size element - PPD to/from PWG
+
+typedef struct pwg_size_s pwg_size_t;
+
Destination
@@ -3169,6 +3557,42 @@ millimeters
val
Return value
+
+Map element - PPD to/from PWG
+struct pwg_map_s {
+ char *pwg, *ppd;
+};
+Members
+
+- ppd
+- PPD option keyword
+
+
+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
+
+
+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
+
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.
@@ -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.
@@ -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.
-
+
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.
+
+
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.
@@ -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
+
+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.
+
+
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.
+
+
+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)
.
+
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.
-
+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.
- - What; Description.
-
-
-
-
-
-
-
-
- - What; Description.
-
-
-
-
-
-
-
-
- - What; Description.
-
-
+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.