merge in oc-dr1-release history after reset to db32612b4b2a7469106491b210f07e912feffa33
diff --git a/config.h b/config.h
index ec0f673..ba24f78 100644
--- a/config.h
+++ b/config.h
@@ -17,8 +17,8 @@
 #ifndef _CUPS_CONFIG_H_
 #define _CUPS_CONFIG_H_
 
-#define CUPS_SVERSION "CUPS v2.2.3"
-#define CUPS_MINIMAL "CUPS/2.2.3"
+#define CUPS_SVERSION "CUPS v2.2.1"
+#define CUPS_MINIMAL "CUPS/2.2.1"
 #define CUPS_DEFAULT_PRINTOPERATOR_AUTH "@SYSTEM"
 #define CUPS_DEFAULT_LOG_LEVEL "warn"
 #define CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS "dnssd"
diff --git a/cups/Makefile b/cups/Makefile
index 1df7d85..ba9bbed 100644
--- a/cups/Makefile
+++ b/cups/Makefile
@@ -8,7 +8,7 @@
 # property of Apple Inc. and are protected by Federal copyright
 # law.  Distribution and use rights are outlined in the file "LICENSE.txt"
 # which should have been included with this file.  If this file is
-# missing or damaged, see the license at "http://www.cups.org/".
+# file is missing or damaged, see the license at "http://www.cups.org/".
 #
 # This file is subject to the Apple OS-Developed Software exception.
 #
diff --git a/cups/adminutil.c b/cups/adminutil.c
index adb1f7a..1a6d6a7 100644
--- a/cups/adminutil.c
+++ b/cups/adminutil.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/adminutil.h b/cups/adminutil.h
index 23f7978..cc119fc 100644
--- a/cups/adminutil.h
+++ b/cups/adminutil.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/api-filter.shtml b/cups/api-filter.shtml
index bd90333..1b8f6f3 100644
--- a/cups/api-filter.shtml
+++ b/cups/api-filter.shtml
@@ -94,7 +94,7 @@
 <p>Filters and backends may also receive <code>SIGPIPE</code> when an upstream or downstream filter/backend exits with a non-zero status. Developers should generally ignore <code>SIGPIPE</code> at the beginning of <code>main()</code> with the following function call:</p>
 
 <pre class="example">
-#include &lt;signal.h&gt;
+#include &lt;signal.h&gt;>
 
 ...
 
diff --git a/cups/array-private.h b/cups/array-private.h
index ff083e4..c563e25 100644
--- a/cups/array-private.h
+++ b/cups/array-private.h
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/array.c b/cups/array.c
index dee4f5e..b8bec27 100644
--- a/cups/array.c
+++ b/cups/array.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/array.h b/cups/array.h
index 189c6e1..c747831 100644
--- a/cups/array.h
+++ b/cups/array.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/auth.c b/cups/auth.c
index 8348a2c..f9187ff 100644
--- a/cups/auth.c
+++ b/cups/auth.c
@@ -1,7 +1,7 @@
 /*
  * Authentication functions for CUPS.
  *
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * This file contains Kerberos support code, copyright 2006 by
@@ -11,7 +11,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -386,7 +386,10 @@
 
     if (data.sem)
     {
-      major_status = gss_acquire_cred_ex_f(NULL, GSS_C_NO_NAME, 0, GSS_C_INDEFINITE, GSS_KRB5_MECHANISM, GSS_C_INITIATE, (gss_auth_identity_t)&identity, &data, cups_gss_acquire);
+      major_status = gss_acquire_cred_ex_f(NULL, GSS_C_NO_NAME, 0,
+				           GSS_C_INDEFINITE, GSS_KRB5_MECHANISM,
+					   GSS_C_INITIATE, &identity, &data,
+					   cups_gss_acquire);
 
       if (major_status == GSS_S_COMPLETE)
       {
diff --git a/cups/backchannel.c b/cups/backchannel.c
index e804d45..13a9560 100644
--- a/cups/backchannel.c
+++ b/cups/backchannel.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/backend.c b/cups/backend.c
index f164617..a21ee38 100644
--- a/cups/backend.c
+++ b/cups/backend.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/backend.h b/cups/backend.h
index 274bcd4..709fd6e 100644
--- a/cups/backend.h
+++ b/cups/backend.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/cups-private.h b/cups/cups-private.h
index 264fd01..998aeec 100644
--- a/cups/cups-private.h
+++ b/cups/cups-private.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -124,8 +124,7 @@
 			*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 */
-  char			pwg_name[65],	/* PWG media name for custom size */
-			ppd_name[41];	/* PPD media name for custom size */
+  char			pwg_name[65];	/* PWG media name for custom size */
 
   /* request.c */
   http_t		*http;		/* Current server connection */
diff --git a/cups/cups.h b/cups/cups.h
index 3205dd8..cef5697 100644
--- a/cups/cups.h
+++ b/cups/cups.h
@@ -1,14 +1,14 @@
 /*
  * API definitions for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -47,10 +47,10 @@
  * Constants...
  */
 
-#  define CUPS_VERSION			2.0203
+#  define CUPS_VERSION			2.0201
 #  define CUPS_VERSION_MAJOR		2
 #  define CUPS_VERSION_MINOR		2
-#  define CUPS_VERSION_PATCH		3
+#  define CUPS_VERSION_PATCH		1
 
 #  define CUPS_BC_FD			3
 					/* Back-channel file descriptor for
@@ -233,12 +233,13 @@
   CUPS_PRINTER_COMMANDS = 0x800000,	/* Printer supports maintenance commands
 					 * @since CUPS 1.2/macOS 10.5@ */
   CUPS_PRINTER_DISCOVERED = 0x1000000,	/* Printer was automatically discovered
-					 * and added @private@ */
+					 * and added @private@
+					 * @since Deprecated@ */
   CUPS_PRINTER_SCANNER = 0x2000000,	/* Scanner-only device
 					 * @since CUPS 1.4/macOS 10.6@ */
   CUPS_PRINTER_MFP = 0x4000000,		/* Printer with scanning capabilities
 					 * @since CUPS 1.4/macOS 10.6@ */
-  CUPS_PRINTER_3D = 0x8000000,		/* Printer with 3D capabilities @private@ */
+  CUPS_PRINTER_3D = 0x8000000,		/* Printer with 3D capabilities @since CUPS 2.1@ */
   CUPS_PRINTER_OPTIONS = 0x6fffc	/* ~(CLASS | REMOTE | IMPLICIT |
 					 * DEFAULT | FAX | REJECTING | DELETE |
 					 * NOT_SHARED | AUTHENTICATED |
diff --git a/cups/debug-private.h b/cups/debug-private.h
index 23a0ae1..8d9861c 100644
--- a/cups/debug-private.h
+++ b/cups/debug-private.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/debug.c b/cups/debug.c
index bd244fe..a25e4b1 100644
--- a/cups/debug.c
+++ b/cups/debug.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/dest-job.c b/cups/dest-job.c
index b0d89b6..146887e 100644
--- a/cups/dest-job.c
+++ b/cups/dest-job.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/dest-localization.c b/cups/dest-localization.c
index 6d75a97..6358b6d 100644
--- a/cups/dest-localization.c
+++ b/cups/dest-localization.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/dest-options.c b/cups/dest-options.c
index bf9020b..fc3fd35 100644
--- a/cups/dest-options.c
+++ b/cups/dest-options.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/dest.c b/cups/dest.c
index b06a9ee..cd7529c 100644
--- a/cups/dest.c
+++ b/cups/dest.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/dir.c b/cups/dir.c
index 65b8c4f..074e659 100644
--- a/cups/dir.c
+++ b/cups/dir.c
@@ -10,7 +10,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
diff --git a/cups/dir.h b/cups/dir.h
index d010544..98a6767 100644
--- a/cups/dir.h
+++ b/cups/dir.h
@@ -10,7 +10,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 #ifndef _CUPS_DIR_H_
diff --git a/cups/encode.c b/cups/encode.c
index e60aec0..d26d86d 100644
--- a/cups/encode.c
+++ b/cups/encode.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/file-private.h b/cups/file-private.h
index b8ca431..6ce11cf 100644
--- a/cups/file-private.h
+++ b/cups/file-private.h
@@ -13,7 +13,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/file.c b/cups/file.c
index a027df4..b81bfe8 100644
--- a/cups/file.c
+++ b/cups/file.c
@@ -13,7 +13,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/file.h b/cups/file.h
index 177c2e9..8a4289f 100644
--- a/cups/file.h
+++ b/cups/file.h
@@ -13,7 +13,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/getdevices.c b/cups/getdevices.c
index 0f303ba..13bebd2 100644
--- a/cups/getdevices.c
+++ b/cups/getdevices.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/getputfile.c b/cups/getputfile.c
index ae33bc5..76a3093 100644
--- a/cups/getputfile.c
+++ b/cups/getputfile.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/globals.c b/cups/globals.c
index 8a05c3e..276bbcf 100644
--- a/cups/globals.c
+++ b/cups/globals.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/hash.c b/cups/hash.c
index ede5461..d52807e 100644
--- a/cups/hash.c
+++ b/cups/hash.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/http-addr.c b/cups/http-addr.c
index 12d13a6..dd61d4a 100644
--- a/cups/http-addr.c
+++ b/cups/http-addr.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -872,18 +872,6 @@
   }
 
  /*
-  * Convert the hostname to lowercase as needed...
-  */
-
-  if (s[0] != '/')
-  {
-    char	*ptr;			/* Pointer into string */
-
-    for (ptr = s; *ptr; ptr ++)
-      *ptr = (char)_cups_tolower((int)*ptr);
-  }
-
- /*
   * Return the hostname with as much domain info as we have...
   */
 
diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c
index 723bf02..e9ef53e 100644
--- a/cups/http-addrlist.c
+++ b/cups/http-addrlist.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -312,7 +312,7 @@
 	DEBUG_printf(("pfds[%d].revents=%x\n", i, pfds[i].revents));
 	if (pfds[i].revents && !(pfds[i].revents & (POLLERR | POLLHUP)))
 #  else
-	if (FD_ISSET(fds[i], &input_set) && !FD_ISSET(fds[i], &error_set))
+	if (FD_ISSET(fds[i], &input) && !FD_ISSET(fds[i], &error))
 #  endif /* HAVE_POLL */
 	{
 	  *sock    = fds[i];
@@ -327,7 +327,7 @@
 #  ifdef HAVE_POLL
 	else if (pfds[i].revents & (POLLERR | POLLHUP))
 #  else
-	else if (FD_ISSET(fds[i], &error_set))
+	else if (FD_ISSET(fds[i], &error))
 #  endif /* HAVE_POLL */
         {
          /*
diff --git a/cups/http-private.h b/cups/http-private.h
index ec908a6..ec29707 100644
--- a/cups/http-private.h
+++ b/cups/http-private.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/http-support.c b/cups/http-support.c
index 1ca01b2..21776d7 100644
--- a/cups/http-support.c
+++ b/cups/http-support.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/http.c b/cups/http.c
index 7925513..b3abbe7 100644
--- a/cups/http.c
+++ b/cups/http.c
@@ -11,7 +11,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -3667,9 +3667,6 @@
       return (0);
     }
 
-    if (http->state == HTTP_STATE_POST_RECV || http->state == HTTP_STATE_GET)
-      http->state ++;
-
 #ifdef HAVE_LIBZ
    /*
     * Then start any content encoding...
diff --git a/cups/http.h b/cups/http.h
index ccbf77e..00039ee 100644
--- a/cups/http.h
+++ b/cups/http.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/ipp-private.h b/cups/ipp-private.h
index 4b1947c..0dbd97e 100644
--- a/cups/ipp-private.h
+++ b/cups/ipp-private.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/ipp-support.c b/cups/ipp-support.c
index b49ac0d..fc53573 100644
--- a/cups/ipp-support.c
+++ b/cups/ipp-support.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -429,10 +429,10 @@
 		  "punch-quad-top",	/* Finishings 2.0 */
 		  "punch-quad-right",	/* Finishings 2.0 */
 		  "punch-quad-bottom",	/* Finishings 2.0 */
-		  "punch-multiple-left",/* Finishings 2.1/Canon */
-		  "punch-multiple-top",	/* Finishings 2.1/Canon */
-		  "punch-multiple-right",/* Finishings 2.1/Canon */
-		  "punch-multiple-bottom",/* Finishings 2.1/Canon */
+		  "86",
+		  "87",
+		  "88",
+		  "89",
 		  "fold-accordian",	/* Finishings 2.0 */
 		  "fold-double-gate",	/* Finishings 2.0 */
 		  "fold-gate",		/* Finishings 2.0 */
@@ -443,8 +443,7 @@
 		  "fold-parallel",	/* Finishings 2.0 */
 		  "fold-poster",	/* Finishings 2.0 */
 		  "fold-right-gate",	/* Finishings 2.0 */
-		  "fold-z",		/* Finishings 2.0 */
-                  "fold-engineering-z"	/* Finishings 2.1 */
+		  "fold-z"		/* Finishings 2.0 */
 		},
 		* const ipp_finishings_vendor[] =
 		{
@@ -897,14 +896,12 @@
     "k-octets",
     "k-octets-processed",
     "last-document",
-    "materials-col-actual",		/* IPP 3D */
     "media-actual",
     "media-col-actual",
     "media-input-tray-check-actual",
     "media-sheets",
     "media-sheets-completed",
     "more-info",
-    "multiple-object-handling-actual",	/* IPP 3D */
     "number-up-actual",
     "orientation-requested-actual",
     "output-bin-actual",
@@ -916,17 +913,12 @@
     "pages",
     "pages-completed",
     "pages-completed-current-copy",
-    "platform-temperature-actual",	/* IPP 3D */
     "presentation-direction-number-up-actual",
-    "print-accuracy-actual",		/* IPP 3D */
-    "print-base-actual",		/* IPP 3D */
     "print-color-mode-actual",
     "print-content-optimize-actual",
-    "print-objects-actual",		/* IPP 3D */
     "print-quality-actual",
     "print-rendering-intent-actual",
     "print-scaling-actual",		/* IPP Paid Printing */
-    "print-supports-actual",		/* IPP 3D */
     "printer-resolution-actual",
     "printer-up-time",
     "separator-sheets-actual",
@@ -981,20 +973,6 @@
     "insert-sheet",
     "insert-sheet-default",
     "insert-sheet-supported",
-    "material-amount-units-supported",	/* IPP 3D */
-    "material-diameter-supported",	/* IPP 3D */
-    "material-purpose-supported",	/* IPP 3D */
-    "material-rate-supported",		/* IPP 3D */
-    "material-rate-units-supported",	/* IPP 3D */
-    "material-shell-thickness-supported",/* IPP 3D */
-    "material-temperature-supported",	/* IPP 3D */
-    "material-type-supported",		/* IPP 3D */
-    "materials-col",			/* IPP 3D */
-    "materials-col-database",		/* IPP 3D */
-    "materials-col-default",		/* IPP 3D */
-    "materials-col-ready",		/* IPP 3D */
-    "materials-col-supported",		/* IPP 3D */
-    "max-materials-col-supported",	/* IPP 3D */
     "max-stitching-locations-supported",
     "media",
     "media-back-coating-supported",
@@ -1027,9 +1005,6 @@
     "multiple-document-handling",
     "multiple-document-handling-default",
     "multiple-document-handling-supported",
-    "multiple-object-handling",		/* IPP 3D */
-    "multiple-object-handling-default",	/* IPP 3D */
-    "multiple-object-handling-supported",/* IPP 3D */
     "number-up",
     "number-up-default",
     "number-up-supported",
@@ -1058,27 +1033,15 @@
     "pdl-init-file-name-subdirectory-supported",
     "pdl-init-file-name-supported",
     "pdl-init-file-supported",
-    "platform-temperature",		/* IPP 3D */
-    "platform-temperature-default",	/* IPP 3D */
-    "platform-temperature-supported",	/* IPP 3D */
     "presentation-direction-number-up",
     "presentation-direction-number-up-default",
     "presentation-direction-number-up-supported",
-    "print-accuracy",			/* IPP 3D */
-    "print-accuracy-default",		/* IPP 3D */
-    "print-accuracy-supported",		/* IPP 3D */
-    "print-base",			/* IPP 3D */
-    "print-base-default",		/* IPP 3D */
-    "print-base-supported",		/* IPP 3D */
     "print-color-mode",
     "print-color-mode-default",
     "print-color-mode-supported",
     "print-content-optimize",
     "print-content-optimize-default",
     "print-content-optimize-supported",
-    "print-objects",			/* IPP 3D */
-    "print-objects-default",		/* IPP 3D */
-    "print-objects-supported",		/* IPP 3D */
     "print-quality",
     "print-quality-default",
     "print-quality-supported",
@@ -1088,9 +1051,6 @@
     "print-scaling",			/* IPP Paid Printing */
     "print-scaling-default",		/* IPP Paid Printing */
     "print-scaling-supported",		/* IPP Paid Printing */
-    "print-supports",			/* IPP 3D */
-    "print-supports-default",		/* IPP 3D */
-    "print-supports-supported",		/* IPP 3D */
     "printer-resolution",
     "printer-resolution-default",
     "printer-resolution-supported",
@@ -1205,12 +1165,10 @@
     "job-state-reasons",
     "job-uri",
     "job-uuid",
-    "materials-col-actual",		/* IPP 3D */
     "media-actual",
     "media-col-actual",
     "media-check-input-tray-actual",
     "multiple-document-handling-actual",
-    "multiple-object-handling-actual",	/* IPP 3D */
     "number-of-documents",
     "number-of-intervening-jobs",
     "number-up-actual",
@@ -1222,17 +1180,12 @@
     "page-delivery-actual",
     "page-order-received-actual",
     "page-ranges-actual",
-    "platform-temperature-actual",	/* IPP 3D */
     "presentation-direction-number-up-actual",
-    "print-accuracy-actual",		/* IPP 3D */
-    "print-base-actual",		/* IPP 3D */
     "print-color-mode-actual",
     "print-content-optimize-actual",
-    "print-objects-actual",		/* IPP 3D */
     "print-quality-actual",
     "print-rendering-intent-actual",
     "print-scaling-actual",		/* IPP Paid Printing */
-    "print-supports-actual",		/* IPP 3D */
     "printer-resolution-actual",
     "separator-sheets-actual",
     "sheet-collate-actual",
@@ -1254,7 +1207,6 @@
   };
   static const char * const job_template[] =
   {					/* job-template group */
-    "accuracy-units-supported",		/* IPP 3D */
     "confirmation-sheet-print",		/* IPP FaxOut */
     "confirmation-sheet-print-default",
     "copies",
@@ -1362,20 +1314,6 @@
     "job-sheets-default",
     "job-sheets-supported",
     "logo-uri-schemes-supported",
-    "material-amount-units-supported",	/* IPP 3D */
-    "material-diameter-supported",	/* IPP 3D */
-    "material-purpose-supported",	/* IPP 3D */
-    "material-rate-supported",		/* IPP 3D */
-    "material-rate-units-supported",	/* IPP 3D */
-    "material-shell-thickness-supported",/* IPP 3D */
-    "material-temperature-supported",	/* IPP 3D */
-    "material-type-supported",		/* IPP 3D */
-    "materials-col",			/* IPP 3D */
-    "materials-col-database",		/* IPP 3D */
-    "materials-col-default",		/* IPP 3D */
-    "materials-col-ready",		/* IPP 3D */
-    "materials-col-supported",		/* IPP 3D */
-    "max-materials-col-supported",	/* IPP 3D */
     "max-save-info-supported",
     "max-stitching-locations-supported",
     "media",
@@ -1409,9 +1347,6 @@
     "multiple-document-handling",
     "multiple-document-handling-default",
     "multiple-document-handling-supported",
-    "multiple-object-handling",		/* IPP 3D */
-    "multiple-object-handling-default",	/* IPP 3D */
-    "multiple-object-handling-supported",/* IPP 3D */
     "number-of-retries",		/* IPP FaxOut */
     "number-of-retries-default",
     "number-of-retries-supported",
@@ -1449,27 +1384,15 @@
     "pdl-init-file-name-subdirectory-supported",
     "pdl-init-file-name-supported",
     "pdl-init-file-supported",
-    "platform-temperature",		/* IPP 3D */
-    "platform-temperature-default",	/* IPP 3D */
-    "platform-temperature-supported",	/* IPP 3D */
     "presentation-direction-number-up",
     "presentation-direction-number-up-default",
     "presentation-direction-number-up-supported",
-    "print-accuracy",			/* IPP 3D */
-    "print-accuracy-default",		/* IPP 3D */
-    "print-accuracy-supported",		/* IPP 3D */
-    "print-base",			/* IPP 3D */
-    "print-base-default",		/* IPP 3D */
-    "print-base-supported",		/* IPP 3D */
     "print-color-mode",
     "print-color-mode-default",
     "print-color-mode-supported",
     "print-content-optimize",
     "print-content-optimize-default",
     "print-content-optimize-supported",
-    "print-objects",			/* IPP 3D */
-    "print-objects-default",		/* IPP 3D */
-    "print-objects-supported",		/* IPP 3D */
     "print-quality",
     "print-quality-default",
     "print-quality-supported",
@@ -1479,9 +1402,6 @@
     "print-scaling",			/* IPP Paid Printing */
     "print-scaling-default",		/* IPP Paid Printing */
     "print-scaling-supported",		/* IPP Paid Printing */
-    "print-supports",			/* IPP 3D */
-    "print-supports-default",		/* IPP 3D */
-    "print-supports-supported",		/* IPP 3D */
     "printer-resolution",
     "printer-resolution-default",
     "printer-resolution-supported",
@@ -1612,7 +1532,6 @@
     "pages-per-minute",
     "pages-per-minute-color",
     "pdf-k-octets-supported",		/* CUPS extension */
-    "pdf-features-supported",		/* IPP 3D */
     "pdf-versions-supported",		/* CUPS extension */
     "pdl-override-supported",
     "port-monitor",			/* CUPS extension */
@@ -1640,7 +1559,6 @@
     "printer-get-attributes-supported",
     "printer-icc-profiles",
     "printer-icons",
-    "printer-id",               	/* CUPS extension */
     "printer-info",
     "printer-input-tray",		/* IPP JPS3 */
     "printer-is-accepting-jobs",
@@ -2125,7 +2043,7 @@
   * See if the operation ID is a known value...
   */
 
-  if (op >= IPP_OP_PRINT_JOB && op < (ipp_op_t)(sizeof(ipp_std_ops) / sizeof(ipp_std_ops[0])))
+  if (op >= IPP_OP_PRINT_JOB && op <= IPP_OP_VALIDATE_DOCUMENT)
     return (ipp_std_ops[op]);
   else if (op == IPP_OP_PRIVATE)
     return ("windows-ext");
diff --git a/cups/ipp.c b/cups/ipp.c
index 817c9d5..1964962 100644
--- a/cups/ipp.c
+++ b/cups/ipp.c
@@ -1,14 +1,14 @@
 /*
  * Internet Printing Protocol functions for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -1419,6 +1419,11 @@
     case IPP_TAG_CHARSET :
     case IPP_TAG_KEYWORD :
     case IPP_TAG_LANGUAGE :
+    case IPP_TAG_MIMETYPE :
+    case IPP_TAG_NAME :
+    case IPP_TAG_NAMELANG :
+    case IPP_TAG_TEXT :
+    case IPP_TAG_TEXTLANG :
     case IPP_TAG_URI :
     case IPP_TAG_URISCHEME :
 	for (i = attr->num_values, avalue = attr->values;
@@ -1435,25 +1440,6 @@
 	  }
         }
 
-    case IPP_TAG_MIMETYPE :
-    case IPP_TAG_NAME :
-    case IPP_TAG_NAMELANG :
-    case IPP_TAG_TEXT :
-    case IPP_TAG_TEXTLANG :
-	for (i = attr->num_values, avalue = attr->values;
-	     i > 0;
-	     i --, avalue ++)
-	{
-	  DEBUG_printf(("1ippContainsString: value[%d]=\"%s\"",
-	                attr->num_values - i, avalue->string.text));
-
-	  if (!_cups_strcasecmp(value, avalue->string.text))
-	  {
-	    DEBUG_puts("1ippContainsString: Returning 1 (match)");
-	    return (1);
-	  }
-        }
-
     default :
         break;
   }
@@ -2570,16 +2556,13 @@
              int             element,	/* I - Value number (0-based) */
 	     const char      **language)/* O - Language code (@code NULL@ for don't care) */
 {
-  ipp_tag_t	tag;			/* Value tag */
-
-
  /*
   * Range check input...
   */
 
-  tag = ippGetValueTag(attr);
-
-  if (!attr || element < 0 || element >= attr->num_values || (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG && (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE)))
+  if (!attr || element < 0 || element >= attr->num_values ||
+      (attr->value_tag != IPP_TAG_TEXTLANG && attr->value_tag != IPP_TAG_NAMELANG &&
+       (attr->value_tag < IPP_TAG_TEXT || attr->value_tag > IPP_TAG_MIMETYPE)))
     return (NULL);
 
  /*
diff --git a/cups/ipp.h b/cups/ipp.h
index 54d9d4b..84585a2 100644
--- a/cups/ipp.h
+++ b/cups/ipp.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -150,10 +150,6 @@
   IPP_FINISHINGS_PUNCH_QUAD_TOP,	/* Punch 4 holes top edge */
   IPP_FINISHINGS_PUNCH_QUAD_RIGHT,	/* Punch 4 holes right side */
   IPP_FINISHINGS_PUNCH_QUAD_BOTTOM,	/* Punch 4 holes bottom edge */
-  IPP_FINISHINGS_PUNCH_MULTIPLE_LEFT,	/* Pucnh multiple holes left side */
-  IPP_FINISHINGS_PUNCH_MULTIPLE_TOP,	/* Pucnh multiple holes top edge */
-  IPP_FINISHINGS_PUNCH_MULTIPLE_RIGHT,	/* Pucnh multiple holes right side */
-  IPP_FINISHINGS_PUNCH_MULTIPLE_BOTTOM,	/* Pucnh multiple holes bottom edge */
   IPP_FINISHINGS_FOLD_ACCORDIAN = 90,	/* Accordian-fold the paper vertically into four sections */
   IPP_FINISHINGS_FOLD_DOUBLE_GATE,	/* Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically */
   IPP_FINISHINGS_FOLD_GATE,		/* Fold the top and bottom quarters of the paper towards the midline */
@@ -165,7 +161,6 @@
   IPP_FINISHINGS_FOLD_POSTER,		/* Fold the paper in half horizontally and vertically; sometimes also called a cross fold */
   IPP_FINISHINGS_FOLD_RIGHT_GATE,	/* Fold the bottom quarter of the paper towards the midline */
   IPP_FINISHINGS_FOLD_Z,		/* Fold the paper vertically into three sections, forming a Z */
-  IPP_FINISHINGS_FOLD_ENGINEERING_Z,	/* Fold the paper vertically into two small sections and one larger, forming an elongated Z */
 
   /* CUPS extensions for finishings (pre-standard versions of values above) */
   IPP_FINISHINGS_CUPS_PUNCH_TOP_LEFT = 0x40000046,
diff --git a/cups/langprintf.c b/cups/langprintf.c
index 46b6be5..40a6688 100644
--- a/cups/langprintf.c
+++ b/cups/langprintf.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/language-private.h b/cups/language-private.h
index 49e4b71..a597cd3 100644
--- a/cups/language-private.h
+++ b/cups/language-private.h
@@ -1,14 +1,14 @@
 /*
  * Private localization support for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2010 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -22,9 +22,6 @@
 
 #  include <stdio.h>
 #  include <cups/transcode.h>
-#  ifdef __APPLE__
-#    include <CoreFoundation/CoreFoundation.h>
-#  endif /* __APPLE__ */
 
 #  ifdef __cplusplus
 extern "C" {
@@ -54,8 +51,8 @@
  */
 
 #  ifdef __APPLE__
-extern const char	*_cupsAppleLanguage(const char *locale, char *language, size_t langsize);
-extern const char	*_cupsAppleLocale(CFStringRef languageName, char *locale, size_t localesize);
+extern const char	*_cupsAppleLanguage(const char *locale, char *language,
+			                    size_t langsize);
 #  endif /* __APPLE__ */
 extern void		_cupsCharmapFlush(void);
 extern const char	*_cupsEncodingName(cups_encoding_t encoding);
diff --git a/cups/language.c b/cups/language.c
index f3a3496..f1afecc 100644
--- a/cups/language.c
+++ b/cups/language.c
@@ -1,14 +1,14 @@
 /*
  * I18N/language support for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -118,13 +118,11 @@
 } _apple_language_locale_t;
 
 static const _apple_language_locale_t apple_language_locale[] =
-{					/* Language to locale ID LUT */
-  { "en",         "en_US" },
-  { "nb",         "no" },
-  { "nb_NO",      "no" },
-  { "zh-Hans",    "zh_CN" },
-  { "zh-Hant",    "zh_TW" },
-  { "zh-Hant_CN", "zh_TW" }
+{					/* Locale to language ID LUT */
+  { "en",      "en_US" },
+  { "nb",      "no" },
+  { "zh-Hans", "zh_CN" },
+  { "zh-Hant", "zh_TW" }
 };
 #endif /* __APPLE__ */
 
@@ -241,75 +239,6 @@
 
   return (language);
 }
-
-
-/*
- * '_cupsAppleLocale()' - Get the locale associated with an Apple language ID.
- */
-
-const char *					/* O - Locale */
-_cupsAppleLocale(CFStringRef languageName,	/* I - Apple language ID */
-                 char        *locale,		/* I - Buffer for locale */
-		 size_t      localesize)	/* I - Size of buffer */
-{
-  int		i;			/* Looping var */
-  CFStringRef	localeName;		/* Locale as a CF string */
-
-
-  localeName = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, languageName);
-
-  if (localeName)
-  {
-   /*
-    * Copy the locale name and tweak as needed...
-    */
-
-    if (!CFStringGetCString(localeName, locale, (CFIndex)localesize, kCFStringEncodingASCII))
-      *locale = '\0';
-
-    CFRelease(localeName);
-
-   /*
-    * Map new language identifiers to locales...
-    */
-
-    for (i = 0;
-	 i < (int)(sizeof(apple_language_locale) /
-		   sizeof(apple_language_locale[0]));
-	 i ++)
-    {
-      if (!strcmp(locale, apple_language_locale[i].language))
-      {
-	strlcpy(locale, apple_language_locale[i].locale, localesize);
-	break;
-      }
-    }
-  }
-  else
-  {
-   /*
-    * Just try the Apple language name...
-    */
-
-    if (!CFStringGetCString(languageName, locale, (CFIndex)localesize, kCFStringEncodingASCII))
-      *locale = '\0';
-  }
-
-  if (!*locale)
-    return (NULL);
-
- /*
-  * Convert language subtag into region subtag...
-  */
-
-  if (locale[2] == '-')
-    locale[2] = '_';
-
-  if (!strchr(locale, '.'))
-    strlcat(locale, ".UTF-8", localesize);
-
-  return (locale);
-}
 #endif /* __APPLE__ */
 
 
@@ -1205,11 +1134,13 @@
 static const char *			/* O - Locale string */
 appleLangDefault(void)
 {
+  int			i;		/* Looping var */
   CFBundleRef		bundle;		/* Main bundle (if any) */
   CFArrayRef		bundleList;	/* List of localizations in bundle */
   CFPropertyListRef 	localizationList = NULL;
 					/* List of localization data */
   CFStringRef		languageName;	/* Current name */
+  CFStringRef		localeName;	/* Canonical from of name */
   char			*lang;		/* LANG environment variable */
   _cups_globals_t	*cg = _cupsGlobals();
   					/* Pointer to library globals */
@@ -1294,11 +1225,49 @@
 	if (languageName &&
 	    CFGetTypeID(languageName) == CFStringGetTypeID())
 	{
-	  if (_cupsAppleLocale(languageName, cg->language, sizeof(cg->language)))
+	  localeName = CFLocaleCreateCanonicalLocaleIdentifierFromString(
+			   kCFAllocatorDefault, languageName);
+
+	  if (localeName)
+	  {
+	    CFStringGetCString(localeName, cg->language, sizeof(cg->language),
+			       kCFStringEncodingASCII);
+	    CFRelease(localeName);
+
 	    DEBUG_printf(("3appleLangDefault: cg->language=\"%s\"",
 			  cg->language));
+
+	   /*
+	    * Map new language identifiers to locales...
+	    */
+
+	    for (i = 0;
+		 i < (int)(sizeof(apple_language_locale) /
+		           sizeof(apple_language_locale[0]));
+		 i ++)
+	    {
+	      if (!strcmp(cg->language, apple_language_locale[i].language))
+	      {
+		DEBUG_printf(("3appleLangDefault: mapping \"%s\" to \"%s\"...",
+			      cg->language, apple_language_locale[i].locale));
+		strlcpy(cg->language, apple_language_locale[i].locale,
+			sizeof(cg->language));
+		break;
+	      }
+	    }
+
+	   /*
+	    * Convert language subtag into region subtag...
+	    */
+
+	    if (cg->language[2] == '-')
+	      cg->language[2] = '_';
+
+	    if (!strchr(cg->language, '.'))
+	      strlcat(cg->language, ".UTF-8", sizeof(cg->language));
+	  }
 	  else
-	    DEBUG_puts("3appleLangDefault: Unable to get locale.");
+	    DEBUG_puts("3appleLangDefault: Unable to get localeName.");
 	}
       }
 
@@ -1402,11 +1371,10 @@
       locale = "Japanese";
     else if (!strncmp(locale, "es", 2))
       locale = "Spanish";
-    else if (!strcmp(locale, "zh_HK") || !strncmp(locale, "zh-Hant", 7))
+    else if (!strcmp(locale, "zh_HK"))
     {
      /*
       * <rdar://problem/22130168>
-      * <rdar://problem/27245567>
       *
       * Try zh_TW first, then zh...  Sigh...
       */
diff --git a/cups/language.h b/cups/language.h
index 0a3da77..c378e98 100644
--- a/cups/language.h
+++ b/cups/language.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/libcups2.def b/cups/libcups2.def
index a7be679..51be135 100644
--- a/cups/libcups2.def
+++ b/cups/libcups2.def
@@ -118,6 +118,8 @@
 _ppdOpen
 _ppdOpenFile
 _ppdParseOptions
+_pwgGenerateSize
+_pwgInitSize
 _pwgInputSlotForSource
 _pwgMediaNearSize
 _pwgMediaTable
diff --git a/cups/md5passwd.c b/cups/md5passwd.c
index a9817aa..9714aaa 100644
--- a/cups/md5passwd.c
+++ b/cups/md5passwd.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/notify.c b/cups/notify.c
index b58a136..5f6e7fd 100644
--- a/cups/notify.c
+++ b/cups/notify.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/options.c b/cups/options.c
index aa70992..a3f57cf 100644
--- a/cups/options.c
+++ b/cups/options.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/ppd-attr.c b/cups/ppd-attr.c
index da02637..6324e6e 100644
--- a/cups/ppd-attr.c
+++ b/cups/ppd-attr.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
index e712341..9ce5cfc 100644
--- a/cups/ppd-cache.c
+++ b/cups/ppd-cache.c
@@ -1,13 +1,13 @@
 /*
  * PPD cache implementation for CUPS.
  *
- * Copyright 2010-2017 by Apple Inc.
+ * Copyright 2010-2016 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
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -32,10 +32,10 @@
  * Local functions...
  */
 
-static void	pwg_add_finishing(cups_array_t *finishings, ipp_finishings_t template, const char *name, const char *value);
 static int	pwg_compare_finishings(_pwg_finishings_t *a,
 		                       _pwg_finishings_t *b);
 static void	pwg_free_finishings(_pwg_finishings_t *f);
+static void	pwg_free_material(_pwg_material_t *m);
 static void	pwg_ppdize_name(const char *ipp, char *name, size_t namesize);
 static void	pwg_ppdize_resolution(ipp_attribute_t *attr, int element, int *xres, int *yres, char *name, size_t namesize);
 static void	pwg_unppdize_name(const char *ppd, char *name, size_t namesize,
@@ -49,20 +49,21 @@
  * attributes and values and adds them to the specified IPP request.
  */
 
-int					/* O - New number of copies */
-_cupsConvertOptions(
-    ipp_t           *request,		/* I - IPP request */
-    ppd_file_t      *ppd,		/* I - PPD file */
-    _ppd_cache_t    *pc,		/* I - PPD cache info */
-    ipp_attribute_t *media_col_sup,	/* I - media-col-supported values */
-    ipp_attribute_t *doc_handling_sup,	/* I - multiple-document-handling-supported values */
-    ipp_attribute_t *print_color_mode_sup,
-                                	/* I - Printer supports print-color-mode */
-    const char    *user,		/* I - User info */
-    const char    *format,		/* I - document-format value */
-    int           copies,		/* I - Number of copies */
-    int           num_options,		/* I - Number of options */
-    cups_option_t *options)		/* I - Options */
+int						/* O - New number of copies */
+_cupsConvertOptions(ipp_t           *request,	/* I - IPP request */
+                    ppd_file_t      *ppd,	/* I - PPD file */
+		    _ppd_cache_t    *pc,	/* I - PPD cache info */
+		    ipp_attribute_t *media_col_sup,
+						/* I - media-col-supported values */
+		    ipp_attribute_t *doc_handling_sup,
+						/* I - multiple-document-handling-supported values */
+		    ipp_attribute_t *print_color_mode_sup,
+						/* I - Printer supports print-color-mode */
+		    const char    *user,	/* I - User info */
+		    const char    *format,	/* I - document-format value */
+		    int           copies,	/* I - Number of copies */
+		    int           num_options,	/* I - Number of options */
+		    cups_option_t *options)	/* I - Options */
 {
   int		i;			/* Looping var */
   const char	*keyword,		/* PWG keyword */
@@ -197,42 +198,41 @@
   if ((keyword = cupsGetOption("PageSize", num_options, options)) == NULL)
     keyword = cupsGetOption("media", num_options, options);
 
-  media_source = _ppdCacheGetSource(pc, cupsGetOption("InputSlot", num_options, options));
-  media_type   = _ppdCacheGetType(pc, cupsGetOption("MediaType", num_options, options));
-  size         = _ppdCacheGetSize(pc, keyword);
-
-  if (size || media_source || media_type)
+  if ((size = _ppdCacheGetSize(pc, keyword)) != NULL)
   {
    /*
     * Add a media-col value...
     */
 
+    media_size = ippNew();
+    ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+		  "x-dimension", size->width);
+    ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+		  "y-dimension", size->length);
+
     media_col = ippNew();
+    ippAddCollection(media_col, IPP_TAG_ZERO, "media-size", media_size);
 
-    if (size)
-    {
-      media_size = ippNew();
-      ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER,
-                    "x-dimension", size->width);
-      ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER,
-                    "y-dimension", size->length);
-
-      ippAddCollection(media_col, IPP_TAG_ZERO, "media-size", media_size);
-    }
+    media_source = _ppdCacheGetSource(pc, cupsGetOption("InputSlot",
+							num_options,
+							options));
+    media_type   = _ppdCacheGetType(pc, cupsGetOption("MediaType",
+						      num_options,
+						      options));
 
     for (i = 0; i < media_col_sup->num_values; i ++)
     {
-      if (size && !strcmp(media_col_sup->values[i].string.text, "media-left-margin"))
+      if (!strcmp(media_col_sup->values[i].string.text, "media-left-margin"))
 	ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-left-margin", size->left);
-      else if (size && !strcmp(media_col_sup->values[i].string.text, "media-bottom-margin"))
+      else if (!strcmp(media_col_sup->values[i].string.text, "media-bottom-margin"))
 	ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-bottom-margin", size->bottom);
-      else if (size && !strcmp(media_col_sup->values[i].string.text, "media-right-margin"))
+      else if (!strcmp(media_col_sup->values[i].string.text, "media-right-margin"))
 	ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-right-margin", size->right);
-      else if (size && !strcmp(media_col_sup->values[i].string.text, "media-top-margin"))
+      else if (!strcmp(media_col_sup->values[i].string.text, "media-top-margin"))
 	ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-top-margin", size->top);
-      else if (media_source && !strcmp(media_col_sup->values[i].string.text, "media-source"))
+      else if (!strcmp(media_col_sup->values[i].string.text, "media-source") && media_source)
 	ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, "media-source", NULL, media_source);
-      else if (media_type && !strcmp(media_col_sup->values[i].string.text, "media-type"))
+      else if (!strcmp(media_col_sup->values[i].string.text, "media-type") && media_type)
 	ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, "media-type", NULL, media_type);
     }
 
@@ -503,6 +503,53 @@
       _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Bad PPD cache file."), 1);
       goto create_error;
     }
+    else if (!_cups_strcasecmp(line, "3D"))
+    {
+      pc->cups_3d = _cupsStrAlloc(value);
+    }
+    else if (!_cups_strcasecmp(line, "LayerOrder"))
+    {
+      pc->cups_layer_order = _cupsStrAlloc(value);
+    }
+    else if (!_cups_strcasecmp(line, "Accuracy"))
+    {
+      sscanf(value, "%d%d%d", pc->cups_accuracy + 0, pc->cups_accuracy + 1, pc->cups_accuracy + 2);
+    }
+    else if (!_cups_strcasecmp(line, "Volume"))
+    {
+      sscanf(value, "%d%d%d", pc->cups_volume + 0, pc->cups_volume + 1, pc->cups_volume + 2);
+    }
+    else if (!_cups_strcasecmp(line, "Material"))
+    {
+     /*
+      * Material key "name" name=value ... name=value
+      */
+
+      if ((valueptr = strchr(value, ' ')) != NULL)
+      {
+	_pwg_material_t	*material = (_pwg_material_t *)calloc(1, sizeof(_pwg_material_t));
+
+        *valueptr++ = '\0';
+
+        material->key = _cupsStrAlloc(value);
+
+        if (*valueptr == '\"')
+	{
+	  value = valueptr + 1;
+	  if ((valueptr = strchr(value, '\"')) != NULL)
+	  {
+	    *valueptr++ = '\0';
+	    material->name = _cupsStrAlloc(value);
+	    material->num_props = cupsParseOptions(valueptr, 0, &material->props);
+	  }
+	}
+
+	if (!pc->materials)
+	  pc->materials = cupsArrayNew3(NULL, NULL, NULL, 0, NULL, (cups_afree_func_t)pwg_free_material);
+
+        cupsArrayAdd(pc->materials, material);
+      }
+    }
     else if (!_cups_strcasecmp(line, "Filter"))
     {
       if (!pc->filters)
@@ -1667,10 +1714,6 @@
 
   if ((ppd_attr = ppdFindAttr(ppd, "cupsIPPFinishings", NULL)) != NULL)
   {
-   /*
-    * Have proper vendor mapping of IPP finishings values to PPD options...
-    */
-
     pc->finishings = cupsArrayNew3((cups_array_func_t)pwg_compare_finishings,
                                    NULL, NULL, 0, NULL,
                                    (cups_afree_func_t)pwg_free_finishings);
@@ -1690,114 +1733,6 @@
     while ((ppd_attr = ppdFindNextAttr(ppd, "cupsIPPFinishings",
                                        NULL)) != NULL);
   }
-  else
-  {
-   /*
-    * No IPP mapping data, try to map common/standard PPD keywords...
-    */
-
-    ppd_option_t	*ppd_option;	/* PPD option */
-
-    pc->finishings = cupsArrayNew3((cups_array_func_t)pwg_compare_finishings, NULL, NULL, 0, NULL, (cups_afree_func_t)pwg_free_finishings);
-
-    if ((ppd_option = ppdFindOption(ppd, "StapleLocation")) != NULL)
-    {
-     /*
-      * Add staple finishings...
-      */
-
-      if (ppdFindChoice(ppd_option, "SinglePortrait"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_LEFT, "StapleLocation", "SinglePortrait");
-      if (ppdFindChoice(ppd_option, "UpperLeft")) /* Ricoh extension */
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_LEFT, "StapleLocation", "UpperLeft");
-      if (ppdFindChoice(ppd_option, "UpperRight")) /* Ricoh extension */
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_TOP_RIGHT, "StapleLocation", "UpperRight");
-      if (ppdFindChoice(ppd_option, "SingleLandscape"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, "StapleLocation", "SingleLandscape");
-      if (ppdFindChoice(ppd_option, "DualLandscape"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_STAPLE_DUAL_LEFT, "StapleLocation", "DualLandscape");
-    }
-
-    if ((ppd_option = ppdFindOption(ppd, "RIPunch")) != NULL)
-    {
-     /*
-      * Add (Ricoh) punch finishings...
-      */
-
-      if (ppdFindChoice(ppd_option, "Left2"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_DUAL_LEFT, "RIPunch", "Left2");
-      if (ppdFindChoice(ppd_option, "Left3"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_TRIPLE_LEFT, "RIPunch", "Left3");
-      if (ppdFindChoice(ppd_option, "Left4"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_QUAD_LEFT, "RIPunch", "Left4");
-      if (ppdFindChoice(ppd_option, "Right2"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_DUAL_RIGHT, "RIPunch", "Right2");
-      if (ppdFindChoice(ppd_option, "Right3"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_TRIPLE_RIGHT, "RIPunch", "Right3");
-      if (ppdFindChoice(ppd_option, "Right4"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_QUAD_RIGHT, "RIPunch", "Right4");
-      if (ppdFindChoice(ppd_option, "Upper2"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_DUAL_TOP, "RIPunch", "Upper2");
-      if (ppdFindChoice(ppd_option, "Upper3"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_TRIPLE_TOP, "RIPunch", "Upper3");
-      if (ppdFindChoice(ppd_option, "Upper4"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_PUNCH_QUAD_TOP, "RIPunch", "Upper4");
-    }
-
-    if ((ppd_option = ppdFindOption(ppd, "BindEdge")) != NULL)
-    {
-     /*
-      * Add bind finishings...
-      */
-
-      if (ppdFindChoice(ppd_option, "Left"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_LEFT, "BindEdge", "Left");
-      if (ppdFindChoice(ppd_option, "Right"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_RIGHT, "BindEdge", "Right");
-      if (ppdFindChoice(ppd_option, "Top"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_TOP, "BindEdge", "Top");
-      if (ppdFindChoice(ppd_option, "Bottom"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_BIND_BOTTOM, "BindEdge", "Bottom");
-    }
-
-    if ((ppd_option = ppdFindOption(ppd, "FoldType")) != NULL)
-    {
-     /*
-      * Add (Adobe) fold finishings...
-      */
-
-      if (ppdFindChoice(ppd_option, "ZFold"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_Z, "FoldType", "ZFold");
-      if (ppdFindChoice(ppd_option, "Saddle"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_HALF, "FoldType", "Saddle");
-      if (ppdFindChoice(ppd_option, "DoubleGate"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_DOUBLE_GATE, "FoldType", "DoubleGate");
-      if (ppdFindChoice(ppd_option, "LeftGate"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LEFT_GATE, "FoldType", "LeftGate");
-      if (ppdFindChoice(ppd_option, "RightGate"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_RIGHT_GATE, "FoldType", "RightGate");
-      if (ppdFindChoice(ppd_option, "Letter"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LETTER, "FoldType", "Letter");
-      if (ppdFindChoice(ppd_option, "XFold"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_POSTER, "FoldType", "XFold");
-    }
-
-    if ((ppd_option = ppdFindOption(ppd, "RIFoldType")) != NULL)
-    {
-     /*
-      * Add (Ricoh) fold finishings...
-      */
-
-      if (ppdFindChoice(ppd_option, "OutsideTwoFold"))
-        pwg_add_finishing(pc->finishings, IPP_FINISHINGS_FOLD_LETTER, "RIFoldType", "OutsideTwoFold");
-    }
-
-    if (cupsArrayCount(pc->finishings) == 0)
-    {
-      cupsArrayDelete(pc->finishings);
-      pc->finishings = NULL;
-    }
-  }
 
  /*
   * Max copies...
@@ -1847,6 +1782,42 @@
     cupsArrayAdd(pc->support_files, ppd_attr->value);
 
  /*
+  * 3D stuff...
+  */
+
+  if ((ppd_attr = ppdFindAttr(ppd, "cups3D", NULL)) != NULL)
+    pc->cups_3d = _cupsStrAlloc(ppd_attr->value);
+
+  if ((ppd_attr = ppdFindAttr(ppd, "cupsLayerOrder", NULL)) != NULL)
+    pc->cups_layer_order = _cupsStrAlloc(ppd_attr->value);
+
+  if ((ppd_attr = ppdFindAttr(ppd, "cupsAccuracy", NULL)) != NULL)
+    sscanf(ppd_attr->value, "%d%d%d", pc->cups_accuracy + 0, pc->cups_accuracy + 1, pc->cups_accuracy + 2);
+
+  if ((ppd_attr = ppdFindAttr(ppd, "cupsVolume", NULL)) != NULL)
+    sscanf(ppd_attr->value, "%d%d%d", pc->cups_volume + 0, pc->cups_volume + 1, pc->cups_volume + 2);
+
+  for (ppd_attr = ppdFindAttr(ppd, "cupsMaterial", NULL);
+       ppd_attr;
+       ppd_attr = ppdFindNextAttr(ppd, "cupsMaterial", NULL))
+  {
+   /*
+    * *cupsMaterial key/name: "name=value ... name=value"
+    */
+
+    _pwg_material_t	*material = (_pwg_material_t *)calloc(1, sizeof(_pwg_material_t));
+
+    material->key = _cupsStrAlloc(ppd_attr->name);
+    material->name = _cupsStrAlloc(ppd_attr->text);
+    material->num_props = cupsParseOptions(ppd_attr->value, 0, &material->props);
+
+    if (!pc->materials)
+      pc->materials = cupsArrayNew3(NULL, NULL, NULL, 0, NULL, (cups_afree_func_t)pwg_free_material);
+
+    cupsArrayAdd(pc->materials, material);
+  }
+
+ /*
   * Return the cache data...
   */
 
@@ -1953,6 +1924,11 @@
 
   cupsArrayDelete(pc->support_files);
 
+  _cupsStrFree(pc->cups_3d);
+  _cupsStrFree(pc->cups_layer_order);
+
+  cupsArrayDelete(pc->materials);
+
   free(pc);
 }
 
@@ -2710,6 +2686,7 @@
   cups_option_t		*option;	/* Current option */
   const char		*value;		/* Filter/pre-filter value */
   char			newfile[1024];	/* New filename */
+  _pwg_material_t	*m;		/* Material */
 
 
  /*
@@ -2891,6 +2868,32 @@
     cupsFilePutConf(fp, "SupportFile", value);
 
  /*
+  * 3D stuff...
+  */
+
+  if (pc->cups_3d)
+    cupsFilePutConf(fp, "3D", pc->cups_3d);
+
+  if (pc->cups_layer_order)
+    cupsFilePutConf(fp, "LayerOrder", pc->cups_layer_order);
+
+  if (pc->cups_accuracy[0] || pc->cups_accuracy[0] || pc->cups_accuracy[2])
+    cupsFilePrintf(fp, "Accuracy %d %d %d\n", pc->cups_accuracy[0], pc->cups_accuracy[1], pc->cups_accuracy[2]);
+
+  if (pc->cups_volume[0] || pc->cups_volume[0] || pc->cups_volume[2])
+    cupsFilePrintf(fp, "Volume %d %d %d\n", pc->cups_volume[0], pc->cups_volume[1], pc->cups_volume[2]);
+
+  for (m = (_pwg_material_t *)cupsArrayFirst(pc->materials);
+       m;
+       m = (_pwg_material_t *)cupsArrayNext(pc->materials))
+  {
+    cupsFilePrintf(fp, "Material %s \"%s\"", m->key, m->name);
+    for (i = 0; i < m->num_props; i ++)
+      cupsFilePrintf(fp, " %s=%s", m->props[i].name, m->props[i].value);
+    cupsFilePuts(fp, "\n");
+  }
+
+ /*
   * IPP attributes, if any...
   */
 
@@ -2922,16 +2925,14 @@
  *                         of an IPP printer.
  */
 
-char *					/* O - PPD filename or @code NULL@ on error */
+char *					/* O - PPD filename or NULL on error */
 _ppdCreateFromIPP(char   *buffer,	/* I - Filename buffer */
                   size_t bufsize,	/* I - Size of filename buffer */
 		  ipp_t  *response)	/* I - Get-Printer-Attributes response */
 {
   cups_file_t		*fp;		/* PPD file */
-  cups_array_t		*sizes;		/* Media sizes we've added */
   ipp_attribute_t	*attr,		/* xxx-supported */
 			*defattr,	/* xxx-default */
-                        *quality,	/* print-quality-supported */
 			*x_dim, *y_dim;	/* Media dimensions */
   ipp_t			*media_size;	/* Media size collection */
   char			make[256],	/* Make and model */
@@ -2943,10 +2944,7 @@
 			bottom,		/* Largest bottom margin */
 			left,		/* Largest left margin */
 			right,		/* Largest right margin */
-			top,		/* Largest top margin */
-			is_apple = 0,	/* Does the printer support Apple raster? */
-			is_pdf = 0,	/* Does the printer support PDF? */
-			is_pwg = 0;	/* Does the printer support PWG Raster? */
+			top;		/* Largest top margin */
   pwg_media_t		*pwg;		/* PWG media size */
   int			xres, yres;	/* Resolution values */
   cups_lang_t		*lang = cupsLangDefault();
@@ -2972,7 +2970,6 @@
     { "fold", _("Fold") },
     { "fold-accordian", _("Accordian Fold") },
     { "fold-double-gate", _("Double Gate Fold") },
-    { "fold-engineering-z", _("Engineering Z Fold") },
     { "fold-gate", _("Gate Fold") },
     { "fold-half", _("Half Fold") },
     { "fold-half-z", _("Half Z Fold") },
@@ -3001,10 +2998,6 @@
     { "punch-triple-left", _("3-Hole Punch (Portrait)") },
     { "punch-triple-right", _("3-Hole Punch (Reverse Portrait)") },
     { "punch-triple-top", _("3-Hole Punch (Landscape)") },
-    { "punch-multiple-bottom", _("Multi-Hole Punch (Reverse Landscape)") },
-    { "punch-multiple-left", _("Multi-Hole Punch (Portrait)") },
-    { "punch-multiple-right", _("Multi-Hole Punch (Reverse Portrait)") },
-    { "punch-multiple-top", _("Multi-Hole Punch (Landscape)") },
     { "saddle-stitch", _("Saddle Stitch") },
     { "staple", _("Staple") },
     { "staple-bottom-left", _("Single Staple (Reverse Landscape)") },
@@ -3030,27 +3023,15 @@
   if (buffer)
     *buffer = '\0';
 
-  if (!buffer || bufsize < 1)
-  {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+  if (!buffer || bufsize < 1 || !response)
     return (NULL);
-  }
-
-  if (!response)
-  {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No IPP attributes."), 1);
-    return (NULL);
-  }
 
  /*
   * Open a temporary file for the PPD...
   */
 
   if ((fp = cupsTempFile2(buffer, (int)bufsize)) == NULL)
-  {
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
     return (NULL);
-  }
 
  /*
   * Standard stuff for PPD file...
@@ -3103,31 +3084,20 @@
 
   if ((attr = ippFindAttribute(response, "document-format-supported", IPP_TAG_MIMETYPE)) != NULL)
   {
-    is_apple = ippContainsString(attr, "image/urf");
-    is_pdf   = ippContainsString(attr, "application/pdf");
-    is_pwg   = ippContainsString(attr, "image/pwg-raster");
-
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
       const char *format = ippGetString(attr, i, NULL);
 					/* PDL */
 
-     /*
-      * Write cupsFilter2 lines for supported formats...
-      */
-
       if (!_cups_strcasecmp(format, "application/pdf"))
         cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/pdf 10 -\"\n");
-      else if (!_cups_strcasecmp(format, "image/jpeg") || !_cups_strcasecmp(format, "image/png"))
-        cupsFilePrintf(fp, "*cupsFilter2: \"%s %s 0 -\"\n", format, format);
-      else if (!_cups_strcasecmp(format, "image/pwg-raster") || !_cups_strcasecmp(format, "image/urf"))
-        cupsFilePrintf(fp, "*cupsFilter2: \"%s %s 100 -\"\n", format, format);
+      else if (!_cups_strcasecmp(format, "application/postscript"))
+        cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-postscript application/postscript 10 -\"\n");
+      else if (_cups_strcasecmp(format, "application/octet-stream") && _cups_strcasecmp(format, "application/vnd.hp-pcl") && _cups_strcasecmp(format, "text/plain"))
+        cupsFilePrintf(fp, "*cupsFilter2: \"%s %s 10 -\"\n", format, format);
     }
   }
 
-  if (!is_apple && !is_pdf && !is_pwg)
-    goto bad_ppd;
-
  /*
   * PageSize/PageRegion/ImageableArea/PaperDimension
   */
@@ -3176,54 +3146,35 @@
       x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
       y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
 
-      if (x_dim && y_dim && (pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0))) != NULL)
+      if (x_dim && y_dim)
+      {
+        pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
 	strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
+      }
       else
 	strlcpy(ppdname, "Unknown", sizeof(ppdname));
     }
     else
       strlcpy(ppdname, "Unknown", sizeof(ppdname));
   }
-  else if ((pwg = pwgMediaForPWG(ippGetString(ippFindAttribute(response, "media-default", IPP_TAG_ZERO), 0, NULL))) != NULL)
-    strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
-  else
-    strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  if ((attr = ippFindAttribute(response, "media-size-supported", IPP_TAG_BEGIN_COLLECTION)) == NULL)
-    attr = ippFindAttribute(response, "media-supported", IPP_TAG_ZERO);
-  if (attr)
+  if ((attr = ippFindAttribute(response, "media-size-supported", IPP_TAG_BEGIN_COLLECTION)) != NULL)
   {
     cupsFilePrintf(fp, "*OpenUI *PageSize: PickOne\n"
 		       "*OrderDependency: 10 AnySetup *PageSize\n"
                        "*DefaultPageSize: %s\n", ppdname);
-
-    sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
-
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
-      if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION)
-      {
-	media_size = ippGetCollection(attr, i);
-	x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
-	y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
+      media_size = ippGetCollection(attr, i);
+      x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
+      y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
 
-	pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
-      }
-      else
-        pwg = pwgMediaForPWG(ippGetString(attr, i, NULL));
-
-      if (pwg)
+      if (x_dim && y_dim)
       {
         char	twidth[256],		/* Width string */
 		tlength[256];		/* Length string */
 
-        if (cupsArrayFind(sizes, (void *)pwg->ppd))
-        {
-          cupsFilePrintf(fp, "*%% warning: Duplicate size '%s' reported by printer.\n", pwg->ppd);
-          continue;
-        }
-
-        cupsArrayAdd(sizes, (void *)pwg->ppd);
+        pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
 
         _cupsStrFormatd(twidth, twidth + sizeof(twidth), pwg->width * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tlength, tlength + sizeof(tlength), pwg->length * 72.0 / 2540.0, loc);
@@ -3233,34 +3184,21 @@
     }
     cupsFilePuts(fp, "*CloseUI: *PageSize\n");
 
-    cupsArrayDelete(sizes);
-    sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
-
     cupsFilePrintf(fp, "*OpenUI *PageRegion: PickOne\n"
                        "*OrderDependency: 10 AnySetup *PageRegion\n"
                        "*DefaultPageRegion: %s\n", ppdname);
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
-      if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION)
-      {
-	media_size = ippGetCollection(attr, i);
-	x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
-	y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
+      media_size = ippGetCollection(attr, i);
+      x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
+      y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
 
-	pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
-      }
-      else
-        pwg = pwgMediaForPWG(ippGetString(attr, i, NULL));
-
-      if (pwg)
+      if (x_dim && y_dim)
       {
         char	twidth[256],		/* Width string */
 		tlength[256];		/* Length string */
 
-        if (cupsArrayFind(sizes, (void *)pwg->ppd))
-          continue;
-
-        cupsArrayAdd(sizes, (void *)pwg->ppd);
+        pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
 
         _cupsStrFormatd(twidth, twidth + sizeof(twidth), pwg->width * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tlength, tlength + sizeof(tlength), pwg->length * 72.0 / 2540.0, loc);
@@ -3270,25 +3208,15 @@
     }
     cupsFilePuts(fp, "*CloseUI: *PageRegion\n");
 
-    cupsArrayDelete(sizes);
-    sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
-
     cupsFilePrintf(fp, "*DefaultImageableArea: %s\n"
 		       "*DefaultPaperDimension: %s\n", ppdname, ppdname);
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
-      if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION)
-      {
-	media_size = ippGetCollection(attr, i);
-	x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
-	y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
+      media_size = ippGetCollection(attr, i);
+      x_dim      = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
+      y_dim      = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
 
-	pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
-      }
-      else
-        pwg = pwgMediaForPWG(ippGetString(attr, i, NULL));
-
-      if (pwg)
+      if (x_dim && y_dim)
       {
         char	tleft[256],		/* Left string */
 		tbottom[256],		/* Bottom string */
@@ -3297,10 +3225,7 @@
 		twidth[256],		/* Width string */
 		tlength[256];		/* Length string */
 
-        if (cupsArrayFind(sizes, (void *)pwg->ppd))
-          continue;
-
-        cupsArrayAdd(sizes, (void *)pwg->ppd);
+        pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
 
         _cupsStrFormatd(tleft, tleft + sizeof(tleft), left * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tbottom, tbottom + sizeof(tbottom), bottom * 72.0 / 2540.0, loc);
@@ -3313,22 +3238,18 @@
         cupsFilePrintf(fp, "*PaperDimension %s: \"%s %s\"\n", pwg->ppd, twidth, tlength);
       }
     }
-
-    cupsArrayDelete(sizes);
   }
-  else
-    goto bad_ppd;
 
  /*
   * InputSlot...
   */
 
-  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_ZERO)) != NULL)
+  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_KEYWORD)) != NULL)
     pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
   else
     strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
+  if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_KEYWORD)) != NULL && (count = ippGetCount(attr)) > 1)
   {
     static const char * const sources[][2] =
     {					/* "media-source" strings */
@@ -3405,12 +3326,12 @@
   * MediaType...
   */
 
-  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type", IPP_TAG_ZERO)) != NULL)
+  if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type", IPP_TAG_KEYWORD)) != NULL)
     pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
   else
     strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  if ((attr = ippFindAttribute(response, "media-type-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
+  if ((attr = ippFindAttribute(response, "media-type-supported", IPP_TAG_KEYWORD)) != NULL && (count = ippGetCount(attr)) > 1)
   {
     static const char * const media_types[][2] =
     {					/* "media-type" strings */
@@ -3420,19 +3341,6 @@
       { "cardboard", _("Cardboard") },
       { "cardstock", _("Cardstock") },
       { "cd", _("CD") },
-      { "com.hp.advanced-photo", _("Advanced Photo Paper") }, /* HP */
-      { "com.hp.brochure-glossy", _("Glossy Brochure Paper") }, /* HP */
-      { "com.hp.brochure-matte", _("Matte Brochure Paper") }, /* HP */
-      { "com.hp.cover-matte", _("Matte Cover Paper") }, /* HP */
-      { "com.hp.ecosmart-lite", _("Office Recycled Paper") }, /* HP */
-      { "com.hp.everyday-glossy", _("Everyday Glossy Photo Paper") }, /* HP */
-      { "com.hp.everyday-matte", _("Everyday Matte Paper") }, /* HP */
-      { "com.hp.extra-heavy", _("Extra Heavyweight Paper") }, /* HP */
-      { "com.hp.intermediate", _("Multipurpose Paper") }, /* HP */
-      { "com.hp.mid-weight", _("Mid-Weight Paper") }, /* HP */
-      { "com.hp.premium-inkjet", _("Premium Inkjet Paper") }, /* HP */
-      { "com.hp.premium-photo", _("Premium Photo Glossy Paper") }, /* HP */
-      { "com.hp.premium-presentation-matte", _("Premium Presentation Matte Paper") }, /* HP */
       { "continuous", _("Continuous") },
       { "continuous-long", _("Continuous Long") },
       { "continuous-short", _("Continuous Short") },
@@ -3480,10 +3388,6 @@
       { "gravure-cylinder", _("Gravure Cylinder") },
       { "image-setter-paper", _("Image Setter Paper") },
       { "imaging-cylinder", _("Imaging Cylinder") },
-      { "jp.co.canon_photo-paper-plus-glossy-ii", _("Photo Paper Plus Glossy II") }, /* Canon */
-      { "jp.co.canon_photo-paper-pro-platinum", _("Photo Paper Pro Platinum") }, /* Canon */
-      { "jp.co.canon-photo-paper-plus-glossy-ii", _("Photo Paper Plus Glossy II") }, /* Canon */
-      { "jp.co.canon-photo-paper-pro-platinum", _("Photo Paper Pro Platinum") }, /* Canon */
       { "labels", _("Labels") },
       { "labels-colored", _("Colored Labels") },
       { "labels-glossy", _("Glossy Labels") },
@@ -3507,9 +3411,8 @@
       { "multi-part-form", _("Multi Part Form") },
       { "other", _("Other") },
       { "paper", _("Paper") },
-      { "photo", _("Photo Paper") }, /* HP mis-spelling */
       { "photographic", _("Photo Paper") },
-      { "photographic-archival", _("Archival Photo Paper") },
+      { "photographic-archival", _("Photographic Archival") },
       { "photographic-film", _("Photo Film") },
       { "photographic-glossy", _("Glossy Photo Paper") },
       { "photographic-high-gloss", _("High Gloss Photo Paper") },
@@ -3536,14 +3439,14 @@
       { "single-face", _("Single Face") },
       { "single-wall", _("Single Wall Cardboard") },
       { "sleeve", _("Sleeve") },
-      { "stationery", _("Plain Paper") },
-      { "stationery-archival", _("Archival Paper") },
+      { "stationery", _("Stationery") },
+      { "stationery-archival", _("Stationery Archival") },
       { "stationery-coated", _("Coated Paper") },
-      { "stationery-cotton", _("Cotton Paper") },
+      { "stationery-cotton", _("Stationery Cotton") },
       { "stationery-fine", _("Vellum Paper") },
       { "stationery-heavyweight", _("Heavyweight Paper") },
-      { "stationery-heavyweight-coated", _("Heavyweight Coated Paper") },
-      { "stationery-inkjet", _("Inkjet Paper") },
+      { "stationery-heavyweight-coated", _("Stationery Heavyweight Coated") },
+      { "stationery-inkjet", _("Stationery Inkjet Paper") },
       { "stationery-letterhead", _("Letterhead") },
       { "stationery-lightweight", _("Lightweight Paper") },
       { "stationery-preprinted", _("Preprinted Paper") },
@@ -3559,20 +3462,14 @@
     cupsFilePrintf(fp, "*OpenUI *MediaType: PickOne\n"
                        "*OrderDependency: 10 AnySetup *MediaType\n"
                        "*DefaultMediaType: %s\n", ppdname);
-    for (i = 0; i < count; i ++)
+    for (i = 0; i < (int)(sizeof(media_types) / sizeof(media_types[0])); i ++)
     {
-      const char *keyword = ippGetString(attr, i, NULL);
+      if (!ippContainsString(attr, media_types[i][0]))
+        continue;
 
-      pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
+      pwg_ppdize_name(media_types[i][0], ppdname, sizeof(ppdname));
 
-      for (j = 0; j < (int)(sizeof(media_types) / sizeof(media_types[0])); j ++)
-        if (!strcmp(keyword, media_types[j][0]))
-          break;
-
-      if (j < (int)(sizeof(media_types) / sizeof(media_types[0])))
-        cupsFilePrintf(fp, "*MediaType %s/%s: \"<</MediaType(%s)>>setpagedevice\"\n", ppdname, _cupsLangString(lang, media_types[j][1]), ppdname);
-      else
-        cupsFilePrintf(fp, "*MediaType %s/%s: \"<</MediaType(%s)>>setpagedevice\"\n", ppdname, keyword, ppdname);
+      cupsFilePrintf(fp, "*MediaType %s/%s: \"<</MediaType(%s)>>setpagedevice\"\n", ppdname, _cupsLangString(lang, media_types[i][1]), ppdname);
     }
     cupsFilePuts(fp, "*CloseUI: *MediaType\n");
   }
@@ -3582,9 +3479,7 @@
   */
 
   if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
-    if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) == NULL)
-      if ((attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD)) == NULL)
-        attr = ippFindAttribute(response, "output-mode-supported", IPP_TAG_KEYWORD);
+    attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD);
 
   if (attr)
   {
@@ -3606,7 +3501,7 @@
         if (!default_color)
 	  default_color = "FastGray";
       }
-      else if (!strcmp(keyword, "sgray_8") || !strcmp(keyword, "W8") || !strcmp(keyword, "monochrome") || !strcmp(keyword, "process-monochrome"))
+      else if (!strcmp(keyword, "sgray_8") || !strcmp(keyword, "monochrome") || !strcmp(keyword, "process-monochrome"))
       {
         if (!default_color)
 	  cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
@@ -3617,7 +3512,7 @@
         if (!default_color || !strcmp(default_color, "FastGray"))
 	  default_color = "Gray";
       }
-      else if (!strcmp(keyword, "srgb_8") || !strcmp(keyword, "SRGB24") || !strcmp(keyword, "color"))
+      else if (!strcmp(keyword, "srgb_8") || !strcmp(keyword, "color"))
       {
         if (!default_color)
 	  cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
@@ -3627,17 +3522,6 @@
 
 	default_color = "RGB";
       }
-      else if (!strcmp(keyword, "adobe-rgb_16") || !strcmp(keyword, "ADOBERGB48"))
-      {
-        if (!default_color)
-	  cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
-			     "*OrderDependency: 10 AnySetup *ColorModel\n", _cupsLangString(lang, _("Color Mode")));
-
-        cupsFilePrintf(fp, "*ColorModel AdobeRGB/%s: \"<</cupsColorSpace 20/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n", _cupsLangString(lang, _("Deep Color")));
-
-        if (!default_color)
-	  default_color = "AdobeRGB";
-      }
     }
 
     if (default_color)
@@ -3707,261 +3591,95 @@
   }
 
  /*
-  * Output bin...
-  */
-
-  if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO)) != NULL)
-    pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
-  else
-    strlcpy(ppdname, "Unknown", sizeof(ppdname));
-
-  if ((attr = ippFindAttribute(response, "output-bin-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
-  {
-    static const char * const output_bins[][2] =
-    {					/* "output-bin" strings */
-      { "auto", _("Automatic") },
-      { "bottom", _("Bottom Tray") },
-      { "center", _("Center Tray") },
-      { "face-down", _("Face Down") },
-      { "face-up", _("Face Up") },
-      { "large-capacity", _("Large Capacity Tray") },
-      { "left", _("Left Tray") },
-      { "mailbox-1", _("Mailbox 1") },
-      { "mailbox-2", _("Mailbox 2") },
-      { "mailbox-3", _("Mailbox 3") },
-      { "mailbox-4", _("Mailbox 4") },
-      { "mailbox-5", _("Mailbox 5") },
-      { "mailbox-6", _("Mailbox 6") },
-      { "mailbox-7", _("Mailbox 7") },
-      { "mailbox-8", _("Mailbox 8") },
-      { "mailbox-9", _("Mailbox 9") },
-      { "mailbox-10", _("Mailbox 10") },
-      { "middle", _("Middle") },
-      { "my-mailbox", _("My Mailbox") },
-      { "rear", _("Rear Tray") },
-      { "right", _("Right Tray") },
-      { "side", _("Side Tray") },
-      { "stacker-1", _("Stacker 1") },
-      { "stacker-2", _("Stacker 2") },
-      { "stacker-3", _("Stacker 3") },
-      { "stacker-4", _("Stacker 4") },
-      { "stacker-5", _("Stacker 5") },
-      { "stacker-6", _("Stacker 6") },
-      { "stacker-7", _("Stacker 7") },
-      { "stacker-8", _("Stacker 8") },
-      { "stacker-9", _("Stacker 9") },
-      { "stacker-10", _("Stacker 10") },
-      { "top", _("Top Tray") },
-      { "tray-1", _("Tray 1") },
-      { "tray-2", _("Tray 2") },
-      { "tray-3", _("Tray 3") },
-      { "tray-4", _("Tray 4") },
-      { "tray-5", _("Tray 5") },
-      { "tray-6", _("Tray 6") },
-      { "tray-7", _("Tray 7") },
-      { "tray-8", _("Tray 8") },
-      { "tray-9", _("Tray 9") },
-      { "tray-10", _("Tray 10") }
-    };
-
-    cupsFilePrintf(fp, "*OpenUI *OutputBin: PickOne\n"
-                       "*OrderDependency: 10 AnySetup *OutputBin\n"
-                       "*DefaultOutputBin: %s\n", ppdname);
-    for (i = 0; i < (int)(sizeof(output_bins) / sizeof(output_bins[0])); i ++)
-    {
-      if (!ippContainsString(attr, output_bins[i][0]))
-        continue;
-
-      pwg_ppdize_name(output_bins[i][0], ppdname, sizeof(ppdname));
-
-      cupsFilePrintf(fp, "*OutputBin %s/%s: \"\"\n", ppdname, _cupsLangString(lang, output_bins[i][1]));
-    }
-    cupsFilePuts(fp, "*CloseUI: *OutputBin\n");
-  }
-
- /*
   * Finishing options...
-  *
-  * Eventually need to re-add support for finishings-col-database, however
-  * it is difficult to map arbitrary finishing-template values to PPD options
-  * and have the right constraints apply (e.g. stapling vs. folding vs.
-  * punching, etc.)
   */
 
-  if ((attr = ippFindAttribute(response, "finishings-supported", IPP_TAG_ENUM)) != NULL)
+  if ((attr = ippFindAttribute(response, "finishings-col-database", IPP_TAG_BEGIN_COLLECTION)) != NULL)
   {
+    ipp_t		*col;		/* Collection value */
+    ipp_attribute_t	*template;	/* "finishing-template" member */
     const char		*name;		/* String name */
-    int			value;		/* Enum value */
+    int			value;		/* Enum value, if any */
     cups_array_t	*names;		/* Names we've added */
 
     count = ippGetCount(attr);
     names = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
 
-   /*
-    * Staple/Bind/Stitch
-    */
+    cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickMany\n"
+		       "*OrderDependency: 10 AnySetup *cupsFinishingTemplate\n"
+		       "*DefaultcupsFinishingTemplate: none\n"
+		       "*cupsFinishingTemplate none/%s: \"\"\n"
+		       "*cupsIPPFinishings 3/none: \"*cupsFinishingTemplate none\"\n", _cupsLangString(lang, _("Finishing")), _cupsLangString(lang, _("No Finishing")));
 
     for (i = 0; i < count; i ++)
     {
-      value = ippGetInteger(attr, i);
-      name  = ippEnumString("finishings", value);
+      col      = ippGetCollection(attr, i);
+      template = ippFindAttribute(col, "finishing-template", IPP_TAG_ZERO);
 
-      if (!strncmp(name, "staple-", 7) || !strncmp(name, "bind-", 5) || !strncmp(name, "edge-stitch-", 12) || !strcmp(name, "saddle-stitch"))
-        break;
-    }
+      if ((name = ippGetString(template, 0, NULL)) == NULL || !strcmp(name, "none"))
+        continue;
 
-    if (i < count)
-    {
-      cupsFilePrintf(fp, "*OpenUI *StapleLocation/%s: PickOne\n", _cupsLangString(lang, _("Staple")));
-      cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *StapleLocation\n");
-      cupsFilePuts(fp, "*DefaultStapleLocation: None\n");
-      cupsFilePrintf(fp, "*StapleLocation None/%s: \"\"\n", _cupsLangString(lang, _("None")));
+      if (cupsArrayFind(names, (char *)name))
+        continue;			/* Already did this finishing template */
 
-      for (; i < count; i ++)
+      cupsArrayAdd(names, (char *)name);
+
+      for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
       {
-        value = ippGetInteger(attr, i);
-        name  = ippEnumString("finishings", value);
+        if (!strcmp(finishings[j][0], name))
+	{
+          cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\"\n", name, _cupsLangString(lang, finishings[j][1]));
 
-        if (strncmp(name, "staple-", 7) && strncmp(name, "bind-", 5) && strncmp(name, "edge-stitch-", 12) && strcmp(name, "saddle-stitch"))
-          continue;
+	  value = ippEnumValue("finishings", name);
 
-        if (cupsArrayFind(names, (char *)name))
-          continue;			/* Already did this finishing template */
-
-        cupsArrayAdd(names, (char *)name);
-
-        for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
-        {
-          if (!strcmp(finishings[j][0], name))
-          {
-            cupsFilePrintf(fp, "*StapleLocation %s/%s: \"\"\n", name, _cupsLangString(lang, finishings[j][1]));
-            cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*StapleLocation %s\"\n", value, name, name);
-            break;
-          }
-        }
+	  if (value)
+	    cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*cupsFinishingTemplate %s\"\n", value, name, name);
+          break;
+	}
       }
-
-      cupsFilePuts(fp, "*CloseUI: *StapleLocation\n");
-    }
-
-   /*
-    * Fold
-    */
-
-    for (i = 0; i < count; i ++)
-    {
-      value = ippGetInteger(attr, i);
-      name  = ippEnumString("finishings", value);
-
-      if (!strncmp(name, "fold-", 5))
-        break;
-    }
-
-    if (i < count)
-    {
-      cupsFilePrintf(fp, "*OpenUI *FoldType/%s: PickOne\n", _cupsLangString(lang, _("Fold")));
-      cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *FoldType\n");
-      cupsFilePuts(fp, "*DefaultFoldType: None\n");
-      cupsFilePrintf(fp, "*FoldType None/%s: \"\"\n", _cupsLangString(lang, _("None")));
-
-      for (; i < count; i ++)
-      {
-        value = ippGetInteger(attr, i);
-        name  = ippEnumString("finishings", value);
-
-        if (strncmp(name, "fold-", 5))
-          continue;
-
-        if (cupsArrayFind(names, (char *)name))
-          continue;			/* Already did this finishing template */
-
-        cupsArrayAdd(names, (char *)name);
-
-        for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
-        {
-          if (!strcmp(finishings[j][0], name))
-          {
-            cupsFilePrintf(fp, "*FoldType %s/%s: \"\"\n", name, _cupsLangString(lang, finishings[j][1]));
-            cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*FoldType %s\"\n", value, name, name);
-            break;
-          }
-        }
-      }
-
-      cupsFilePuts(fp, "*CloseUI: *FoldType\n");
-    }
-
-   /*
-    * Punch
-    */
-
-    for (i = 0; i < count; i ++)
-    {
-      value = ippGetInteger(attr, i);
-      name  = ippEnumString("finishings", value);
-
-      if (!strncmp(name, "punch-", 6))
-        break;
-    }
-
-    if (i < count)
-    {
-      cupsFilePrintf(fp, "*OpenUI *PunchMedia/%s: PickOne\n", _cupsLangString(lang, _("Punch")));
-      cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *PunchMedia\n");
-      cupsFilePuts(fp, "*DefaultPunchMedia: None\n");
-      cupsFilePrintf(fp, "*PunchMedia None/%s: \"\"\n", _cupsLangString(lang, _("None")));
-
-      for (i = 0; i < count; i ++)
-      {
-        value = ippGetInteger(attr, i);
-        name  = ippEnumString("finishings", value);
-
-        if (strncmp(name, "punch-", 6))
-          continue;
-
-        if (cupsArrayFind(names, (char *)name))
-          continue;			/* Already did this finishing template */
-
-        cupsArrayAdd(names, (char *)name);
-
-        for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
-        {
-          if (!strcmp(finishings[j][0], name))
-          {
-            cupsFilePrintf(fp, "*PunchMedia %s/%s: \"\"\n", name, _cupsLangString(lang, finishings[j][1]));
-            cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*PunchMedia %s\"\n", value, name, name);
-            break;
-          }
-        }
-      }
-
-      cupsFilePuts(fp, "*CloseUI: *PunchMedia\n");
-    }
-
-   /*
-    * Booklet
-    */
-
-    if (ippContainsInteger(attr, IPP_FINISHINGS_BOOKLET_MAKER))
-    {
-      cupsFilePrintf(fp, "*OpenUI *Booklet/%s: Boolean\n", _cupsLangString(lang, _("Booklet")));
-      cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *Booklet\n");
-      cupsFilePuts(fp, "*DefaultBooklet: False\n");
-      cupsFilePuts(fp, "*Booklet False: \"\"\n");
-      cupsFilePuts(fp, "*Booklet True: \"\"\n");
-      cupsFilePrintf(fp, "*cupsIPPFinishings %d/booklet-maker: \"*Booklet True\"\n", IPP_FINISHINGS_BOOKLET_MAKER);
-      cupsFilePuts(fp, "*CloseUI: *Booklet\n");
     }
 
     cupsArrayDelete(names);
+
+    cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n");
+  }
+  else if ((attr = ippFindAttribute(response, "finishings-supported", IPP_TAG_ENUM)) != NULL && (count = ippGetCount(attr)) > 1 )
+  {
+    const char		*name;		/* String name */
+    int			value;		/* Enum value, if any */
+
+    count = ippGetCount(attr);
+
+    cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickMany\n"
+		       "*OrderDependency: 10 AnySetup *cupsFinishingTemplate\n"
+		       "*DefaultcupsFinishingTemplate: none\n"
+		       "*cupsFinishingTemplate none/%s: \"\"\n"
+		       "*cupsIPPFinishings 3/none: \"*cupsFinishingTemplate none\"\n", _cupsLangString(lang, _("Finishing")), _cupsLangString(lang, _("No Finishing")));
+
+    for (i = 0; i < count; i ++)
+    {
+      if ((value = ippGetInteger(attr, i)) == 3)
+        continue;
+
+      name = ippEnumString("finishings", value);
+      for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
+      {
+        if (!strcmp(finishings[j][0], name))
+	{
+          cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\"\n", name, _cupsLangString(lang, finishings[j][1]));
+	  cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*cupsFinishingTemplate %s\"\n", value, name, name);
+          break;
+	}
+      }
+    }
+
+    cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n");
   }
 
  /*
   * cupsPrintQuality and DefaultResolution...
   */
 
-  quality = ippFindAttribute(response, "print-quality-supported", IPP_TAG_ENUM);
-
   if ((attr = ippFindAttribute(response, "pwg-raster-document-resolution-supported", IPP_TAG_RESOLUTION)) != NULL)
   {
     count = ippGetCount(attr);
@@ -3972,19 +3690,16 @@
     cupsFilePrintf(fp, "*OpenUI *cupsPrintQuality/%s: PickOne\n"
 		       "*OrderDependency: 10 AnySetup *cupsPrintQuality\n"
 		       "*DefaultcupsPrintQuality: Normal\n", _cupsLangString(lang, _("Print Quality")));
-    if (count > 2 || ippContainsInteger(quality, IPP_QUALITY_DRAFT))
+    if (count > 2)
     {
       pwg_ppdize_resolution(attr, 0, &xres, &yres, NULL, 0);
       cupsFilePrintf(fp, "*cupsPrintQuality Draft/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Draft")), xres, yres);
     }
     pwg_ppdize_resolution(attr, count / 2, &xres, &yres, NULL, 0);
     cupsFilePrintf(fp, "*cupsPrintQuality Normal/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Normal")), xres, yres);
-    if (count > 1 || ippContainsInteger(quality, IPP_QUALITY_HIGH))
+    if (count > 1)
     {
-      if (count > 1)
-        pwg_ppdize_resolution(attr, count - 1, &xres, &yres, NULL, 0);
-      else
-        pwg_ppdize_resolution(attr, 0, &xres, &yres, NULL, 0);
+      pwg_ppdize_resolution(attr, count - 1, &xres, &yres, NULL, 0);
       cupsFilePrintf(fp, "*cupsPrintQuality High/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("High")), xres, yres);
     }
 
@@ -4016,7 +3731,7 @@
       * Invalid "urf-supported" value...
       */
 
-      goto bad_ppd;
+      cupsFilePuts(fp, "*DefaultResolution: 300dpi\n");
     }
     else
     {
@@ -4031,40 +3746,19 @@
 			 "*DefaultcupsPrintQuality: Normal\n", _cupsLangString(lang, _("Print Quality")));
       if ((lowdpi & 1) == 0)
 	cupsFilePrintf(fp, "*cupsPrintQuality Draft/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Draft")), lowdpi, lowdpi / 2);
-      else if (ippContainsInteger(quality, IPP_QUALITY_DRAFT))
-	cupsFilePrintf(fp, "*cupsPrintQuality Draft/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Draft")), lowdpi, lowdpi);
       cupsFilePrintf(fp, "*cupsPrintQuality Normal/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Normal")), lowdpi, lowdpi);
-      if (hidpi > lowdpi || ippContainsInteger(quality, IPP_QUALITY_HIGH))
+      if (hidpi > lowdpi)
 	cupsFilePrintf(fp, "*cupsPrintQuality High/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("High")), hidpi, hidpi);
       cupsFilePuts(fp, "*CloseUI: *cupsPrintQuality\n");
     }
   }
-  else if (is_apple || is_pwg)
-    goto bad_ppd;
-  else
+  else if ((attr = ippFindAttribute(response, "printer-resolution-default", IPP_TAG_RESOLUTION)) != NULL)
   {
-    if ((attr = ippFindAttribute(response, "printer-resolution-default", IPP_TAG_RESOLUTION)) != NULL)
-    {
-      pwg_ppdize_resolution(attr, 0, &xres, &yres, ppdname, sizeof(ppdname));
-    }
-    else
-    {
-      xres = yres = 300;
-      strlcpy(ppdname, "300dpi", sizeof(ppdname));
-    }
-
+    pwg_ppdize_resolution(attr, 0, &xres, &yres, ppdname, sizeof(ppdname));
     cupsFilePrintf(fp, "*DefaultResolution: %s\n", ppdname);
-
-    cupsFilePrintf(fp, "*OpenUI *cupsPrintQuality/%s: PickOne\n"
-                       "*OrderDependency: 10 AnySetup *cupsPrintQuality\n"
-                       "*DefaultcupsPrintQuality: Normal\n", _cupsLangString(lang, _("Print Quality")));
-    if (ippContainsInteger(quality, IPP_QUALITY_DRAFT))
-      cupsFilePrintf(fp, "*cupsPrintQuality Draft/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Draft")), xres, yres);
-    cupsFilePrintf(fp, "*cupsPrintQuality Normal/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("Normal")), xres, yres);
-    if (ippContainsInteger(quality, IPP_QUALITY_HIGH))
-      cupsFilePrintf(fp, "*cupsPrintQuality High/%s: \"<</HWResolution[%d %d]>>setpagedevice\"\n", _cupsLangString(lang, _("High")), xres, yres);
-    cupsFilePuts(fp, "*CloseUI: *cupsPrintQuality\n");
   }
+  else
+    cupsFilePuts(fp, "*DefaultResolution: 300dpi\n");
 
  /*
   * Close up and return...
@@ -4073,20 +3767,6 @@
   cupsFileClose(fp);
 
   return (buffer);
-
- /*
-  * If we get here then there was a problem creating the PPD...
-  */
-
-  bad_ppd:
-
-  cupsFileClose(fp);
-  unlink(buffer);
-  *buffer = '\0';
-
-  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Printer does not support required IPP attributes or document formats."), 1);
-
-  return (NULL);
 }
 
 
@@ -4246,34 +3926,10 @@
 
 
 /*
- * 'pwg_add_finishing()' - Add a finishings value.
- */
-
-static void
-pwg_add_finishing(
-    cups_array_t     *finishings,	/* I - Finishings array */
-    ipp_finishings_t template,		/* I - Finishing template */
-    const char       *name,		/* I - PPD option */
-    const char       *value)		/* I - PPD choice */
-{
-  _pwg_finishings_t	*f;		/* New finishings value */
-
-
-  if ((f = (_pwg_finishings_t *)calloc(1, sizeof(_pwg_finishings_t))) != NULL)
-  {
-    f->value       = template;
-    f->num_options = cupsAddOption(name, value, 0, &f->options);
-
-    cupsArrayAdd(finishings, f);
-  }
-}
-
-
-/*
  * 'pwg_compare_finishings()' - Compare two finishings values.
  */
 
-static int				/* O - Result of comparison */
+static int				/* O- Result of comparison */
 pwg_compare_finishings(
     _pwg_finishings_t *a,		/* I - First finishings value */
     _pwg_finishings_t *b)		/* I - Second finishings value */
@@ -4296,6 +3952,22 @@
 
 
 /*
+ * 'pwg_free_material()' - Free a material value.
+ */
+
+static void
+pwg_free_material(_pwg_material_t *m)	/* I - Material value */
+{
+  _cupsStrFree(m->key);
+  _cupsStrFree(m->name);
+
+  cupsFreeOptions(m->num_props, m->props);
+
+  free(m);
+}
+
+
+/*
  * 'pwg_ppdize_name()' - Convert an IPP keyword to a PPD keyword.
  */
 
@@ -4308,17 +3980,11 @@
 	*end;				/* End of name buffer */
 
 
-  if (!ipp)
-  {
-    *name = '\0';
-    return;
-  }
-
   *name = (char)toupper(*ipp++);
 
   for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
   {
-    if (*ipp == '-' && _cups_isalnum(ipp[1]))
+    if (*ipp == '-' && _cups_isalpha(ipp[1]))
     {
       ipp ++;
       *ptr++ = (char)toupper(*ipp++ & 255);
diff --git a/cups/ppd-conflicts.c b/cups/ppd-conflicts.c
index 8f875a5..68e03b4 100644
--- a/cups/ppd-conflicts.c
+++ b/cups/ppd-conflicts.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
diff --git a/cups/ppd-custom.c b/cups/ppd-custom.c
index b7070fa..6e4d3bd 100644
--- a/cups/ppd-custom.c
+++ b/cups/ppd-custom.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
diff --git a/cups/ppd-emit.c b/cups/ppd-emit.c
index 36e5bca..0b4f1c9 100644
--- a/cups/ppd-emit.c
+++ b/cups/ppd-emit.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
diff --git a/cups/ppd-localize.c b/cups/ppd-localize.c
index ed75bf8..db93170 100644
--- a/cups/ppd-localize.c
+++ b/cups/ppd-localize.c
@@ -1,14 +1,14 @@
 /*
  * PPD localization routines for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
@@ -665,7 +665,7 @@
    /*
     * <rdar://problem/22130168>
     *
-    * Multiple locales need special handling...  Sigh...
+    * Hong Kong locale needs special handling...  Sigh...
     */
 
     if (!strcmp(ll_CC, "zh_HK"))
diff --git a/cups/ppd-mark.c b/cups/ppd-mark.c
index 9fdaf0b..08bc993 100644
--- a/cups/ppd-mark.c
+++ b/cups/ppd-mark.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
diff --git a/cups/ppd-page.c b/cups/ppd-page.c
index ccbf052..f18e68d 100644
--- a/cups/ppd-page.c
+++ b/cups/ppd-page.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
diff --git a/cups/ppd-private.h b/cups/ppd-private.h
index b199bbd..83f048e 100644
--- a/cups/ppd-private.h
+++ b/cups/ppd-private.h
@@ -1,14 +1,14 @@
 /*
  * Private PPD definitions for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
@@ -47,7 +47,7 @@
  * Constants...
  */
 
-#  define _PPD_CACHE_VERSION	8	/* Version number in cache file */
+#  define _PPD_CACHE_VERSION	7	/* Version number in cache file */
 
 
 /*
@@ -100,7 +100,7 @@
 {
   _PWG_PRINT_COLOR_MODE_MONOCHROME = 0,	/* print-color-mode=monochrome */
   _PWG_PRINT_COLOR_MODE_COLOR,		/* print-color-mode=color */
-  /* Other values are not supported by CUPS yet. */
+  /* Other proposed values are not supported by CUPS yet. */
   _PWG_PRINT_COLOR_MODE_MAX
 } _pwg_print_color_mode_t;
 
@@ -119,6 +119,14 @@
   cups_option_t		*options;	/* Options to apply */
 } _pwg_finishings_t;
 
+typedef struct _pwg_material_s		/**** PWG material mapping data ****/
+{
+  char		*key,			/* material-key value */
+		*name;			/* material-name value */
+  int		num_props;		/* Number of properties */
+  cups_option_t	*props;			/* Material properties */
+} _pwg_material_t;
+
 struct _ppd_cache_s			/**** PPD cache and PWG conversion data ****/
 {
   int		num_bins;		/* Number of output bins */
@@ -158,6 +166,11 @@
   cups_array_t	*mandatory;		/* cupsMandatory value */
   char		*charge_info_uri;	/* cupsChargeInfoURI value */
   cups_array_t	*support_files;		/* Support files - ICC profiles, etc. */
+  char		*cups_3d,		/* cups3D value */
+		*cups_layer_order;	/* cupsLayerOrder value */
+  int		cups_accuracy[3];	/* cupsAccuracy value - x, y, and z in nanometers */
+  int		cups_volume[3];		/* cupsVolume value - x, y, and z in millimeters */
+  cups_array_t	*materials;		/* cupsMaterial values */
 };
 
 
diff --git a/cups/ppd-util.c b/cups/ppd-util.c
index d0194c8..af5bd20 100644
--- a/cups/ppd-util.c
+++ b/cups/ppd-util.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/ppd.c b/cups/ppd.c
index 5bd839d..44a22c5 100644
--- a/cups/ppd.c
+++ b/cups/ppd.c
@@ -1,14 +1,14 @@
 /*
  * PPD file routines for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
@@ -579,28 +579,12 @@
 
    /*
     * <rdar://problem/22130168>
-    * <rdar://problem/27245567>
     *
     * Need to use a different base language for some locales...
     */
 
     if (!strcmp(lang->language, "zh_HK"))
-    {					/* Traditional Chinese + variants */
-      strlcpy(ll_CC, "zh_TW.", sizeof(ll_CC));
-      strlcpy(ll, "zh_", sizeof(ll));
-    }
-    else if (!strncmp(lang->language, "zh", 2))
-      strlcpy(ll, "zh_", sizeof(ll));	/* Any Chinese variant */
-    else if (!strncmp(lang->language, "jp", 2))
-    {					/* Any Japanese variant */
-      strlcpy(ll_CC, "ja", sizeof(ll_CC));
-      strlcpy(ll, "jp", sizeof(ll));
-    }
-    else if (!strncmp(lang->language, "nb", 2) || !strncmp(lang->language, "no", 2))
-    {					/* Any Norwegian variant */
-      strlcpy(ll_CC, "nb", sizeof(ll_CC));
-      strlcpy(ll, "no", sizeof(ll));
-    }
+      strlcpy(ll, "zh_TW.", sizeof(ll));
     else
       snprintf(ll, sizeof(ll), "%2.2s.", lang->language);
 
diff --git a/cups/ppd.h b/cups/ppd.h
index fb33c08..eb9ab38 100644
--- a/cups/ppd.h
+++ b/cups/ppd.h
@@ -12,7 +12,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * PostScript is a trademark of Adobe Systems, Inc.
  *
diff --git a/cups/pwg-media.c b/cups/pwg-media.c
index 73356fd..6a20687 100644
--- a/cups/pwg-media.c
+++ b/cups/pwg-media.c
@@ -1,13 +1,13 @@
 /*
  * PWG media name API implementation for CUPS.
  *
- * Copyright 2009-2017 by Apple Inc.
+ * Copyright 2009-2016 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
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -37,7 +37,8 @@
 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);
-static int	pwg_scan_measurement(const char *buf, char **bufptr, int numer, int denom);
+static int	pwg_scan_measurement(const char *buf, char **bufptr, int numer,
+		                     int denom);
 
 
 /*
@@ -60,7 +61,7 @@
   _PWG_MEDIA_IN("na_index-5x8_5x8in", NULL, "5x8", 5, 8),
   _PWG_MEDIA_IN("na_number-14_5x11.5in", NULL, "Env14", 5, 11.5),
   _PWG_MEDIA_IN("na_invoice_5.5x8.5in", "invoice", "Statement", 5.5, 8.5),
-  _PWG_MEDIA_IN("na_index-4x6-ext_6x8in", NULL, "6x8", 6, 8),
+  _PWG_MEDIA_IN("na_index-4x6-ext_6x8in", NULL, NULL, 6, 8),
   _PWG_MEDIA_IN("na_6x9_6x9in", "na-6x9-envelope", "6x9", 6, 9),
   _PWG_MEDIA_IN("na_c5_6.5x9.5in", NULL, "6.5x9.5", 6.5, 9.5),
   _PWG_MEDIA_IN("na_7x9_7x9in", "na-7x9-envelope", "7x9", 7, 9),
@@ -85,7 +86,7 @@
   _PWG_MEDIA_IN("na_10x15_10x15in", "na-10x15-envelope", "10x15", 10, 15),
   _PWG_MEDIA_IN("na_11x12_11x12in", NULL, "11x12", 11, 12),
   _PWG_MEDIA_IN("na_edp_11x14in", NULL, "11x14", 11, 14),
-  _PWG_MEDIA_IN("na_fanfold-us_11x14.875in", NULL, "11x14.875", 11, 14.875),
+  _PWG_MEDIA_IN("na_fanfold-us_11x14.875in", NULL, NULL, 11, 14.875),
   _PWG_MEDIA_IN("na_11x15_11x15in", NULL, "11x15", 11, 15),
   _PWG_MEDIA_IN("na_ledger_11x17in", "tabloid", "Tabloid", 11, 17),
   _PWG_MEDIA_IN("na_eur-edp_12x14in", NULL, NULL, 12, 14),
@@ -97,8 +98,8 @@
   _PWG_MEDIA_IN("na_arch-c_18x24in", "arch-c", "ARCHC", 18, 24),
   _PWG_MEDIA_IN("na_d_22x34in", "d", "AnsiD", 22, 34),
   _PWG_MEDIA_IN("na_arch-d_24x36in", "arch-d", "ARCHD", 24, 36),
-  _PWG_MEDIA_IN("asme_f_28x40in", "f", "28x40", 28, 40),
-  _PWG_MEDIA_IN("na_wide-format_30x42in", NULL, "30x42", 30, 42),
+  _PWG_MEDIA_IN("asme_f_28x40in", "f", NULL, 28, 40),
+  _PWG_MEDIA_IN("na_wide-format_30x42in", NULL, NULL, 30, 42),
   _PWG_MEDIA_IN("na_e_34x44in", "e", "AnsiE", 34, 44),
   _PWG_MEDIA_IN("na_arch-e_36x48in", "arch-e", "ARCHE", 36, 48),
   _PWG_MEDIA_IN("na_f_44x68in", NULL, "AnsiF", 44, 68),
@@ -115,35 +116,35 @@
   _PWG_MEDIA_MM("iso_a4-tab_225x297mm", NULL, "A4Tab", 225, 297),
   _PWG_MEDIA_MM("iso_a4-extra_235.5x322.3mm", NULL, "A4Extra", 235.5, 322.3),
   _PWG_MEDIA_MM("iso_a3_297x420mm", "iso-a3", "A3", 297, 420),
-  _PWG_MEDIA_MM("iso_a4x3_297x630mm", "iso-a4x3", "A4x3", 297, 630),
-  _PWG_MEDIA_MM("iso_a4x4_297x841mm", "iso-a4x4", "A4x4", 297, 841),
-  _PWG_MEDIA_MM("iso_a4x5_297x1051mm", "iso-a4x5", "A4x5", 297, 1051),
-  _PWG_MEDIA_MM("iso_a4x6_297x1261mm", "iso-a4x6", "A4x6", 297, 1261),
-  _PWG_MEDIA_MM("iso_a4x7_297x1471mm", "iso-a4x7", "A4x7", 297, 1471),
-  _PWG_MEDIA_MM("iso_a4x8_297x1682mm", "iso-a4x8", "A4x8", 297, 1682),
-  _PWG_MEDIA_MM("iso_a4x9_297x1892mm", "iso-a4x9", "A4x9", 297, 1892),
+  _PWG_MEDIA_MM("iso_a4x3_297x630mm", "iso-a4x3", NULL, 297, 630),
+  _PWG_MEDIA_MM("iso_a4x4_297x841mm", "iso-a4x4", NULL, 297, 841),
+  _PWG_MEDIA_MM("iso_a4x5_297x1051mm", "iso-a4x5", NULL, 297, 1051),
+  _PWG_MEDIA_MM("iso_a4x6_297x1261mm", "iso-a4x6", NULL, 297, 1261),
+  _PWG_MEDIA_MM("iso_a4x7_297x1471mm", "iso-a4x7", NULL, 297, 1471),
+  _PWG_MEDIA_MM("iso_a4x8_297x1682mm", "iso-a4x8", NULL, 297, 1682),
+  _PWG_MEDIA_MM("iso_a4x9_297x1892mm", "iso-a4x9", NULL, 297, 1892),
   _PWG_MEDIA_MM("iso_a3-extra_322x445mm", "iso-a3-extra", "A3Extra", 322, 445),
   _PWG_MEDIA_MM("iso_a2_420x594mm", "iso-a2", "A2", 420, 594),
-  _PWG_MEDIA_MM("iso_a3x3_420x891mm", "iso-a3x3", "A3x3", 420, 891),
-  _PWG_MEDIA_MM("iso_a3x4_420x1189mm", "iso-a3x4", "A3x4", 420, 1189),
-  _PWG_MEDIA_MM("iso_a3x5_420x1486mm", "iso-a3x5", "A3x6", 420, 1486),
-  _PWG_MEDIA_MM("iso_a3x6_420x1783mm", "iso-a3x6", "A3x6", 420, 1783),
-  _PWG_MEDIA_MM("iso_a3x7_420x2080mm", "iso-a3x7", "A3x7", 420, 2080),
+  _PWG_MEDIA_MM("iso_a3x3_420x891mm", "iso-a3x3", NULL, 420, 891),
+  _PWG_MEDIA_MM("iso_a3x4_420x1189mm", "iso-a3x4", NULL, 420, 1189),
+  _PWG_MEDIA_MM("iso_a3x5_420x1486mm", "iso-a3x5", NULL, 420, 1486),
+  _PWG_MEDIA_MM("iso_a3x6_420x1783mm", "iso-a3x6", NULL, 420, 1783),
+  _PWG_MEDIA_MM("iso_a3x7_420x2080mm", "iso-a3x7", NULL, 420, 2080),
   _PWG_MEDIA_MM("iso_a1_594x841mm", "iso-a1", "A1", 594, 841),
-  _PWG_MEDIA_MM("iso_a2x3_594x1261mm", "iso-a2x3", "A2x3", 594, 1261),
-  _PWG_MEDIA_MM("iso_a2x4_594x1682mm", "iso-a2x4", "A2x4", 594, 1682),
-  _PWG_MEDIA_MM("iso_a2x5_594x2102mm", "iso-a2x5", "A2x5", 594, 2102),
+  _PWG_MEDIA_MM("iso_a2x3_594x1261mm", "iso-a2x3", NULL, 594, 1261),
+  _PWG_MEDIA_MM("iso_a2x4_594x1682mm", "iso-a2x4", NULL, 594, 1682),
+  _PWG_MEDIA_MM("iso_a2x5_594x2102mm", "iso-a2x5", NULL, 594, 2102),
   _PWG_MEDIA_MM("iso_a0_841x1189mm", "iso-a0", "A0", 841, 1189),
-  _PWG_MEDIA_MM("iso_a1x3_841x1783mm", "iso-a1x3", "A1x3", 841, 1783),
-  _PWG_MEDIA_MM("iso_a1x4_841x2378mm", "iso-a1x4", "A1x4", 841, 2378),
-  _PWG_MEDIA_MM("iso_2a0_1189x1682mm", NULL, "1189x1682mm", 1189, 1682),
-  _PWG_MEDIA_MM("iso_a0x3_1189x2523mm", NULL, "A0x3", 1189, 2523),
+  _PWG_MEDIA_MM("iso_a1x3_841x1783mm", "iso-a1x3", NULL, 841, 1783),
+  _PWG_MEDIA_MM("iso_a1x4_841x2378mm", "iso-a1x4", NULL, 841, 2378),
+  _PWG_MEDIA_MM("iso_2a0_1189x1682mm", NULL, NULL, 1189, 1682),
+  _PWG_MEDIA_MM("iso_a0x3_1189x2523mm", NULL, NULL, 1189, 2523),
   _PWG_MEDIA_MM("iso_b10_31x44mm", "iso-b10", "ISOB10", 31, 44),
   _PWG_MEDIA_MM("iso_b9_44x62mm", "iso-b9", "ISOB9", 44, 62),
   _PWG_MEDIA_MM("iso_b8_62x88mm", "iso-b8", "ISOB8", 62, 88),
   _PWG_MEDIA_MM("iso_b7_88x125mm", "iso-b7", "ISOB7", 88, 125),
   _PWG_MEDIA_MM("iso_b6_125x176mm", "iso-b6", "ISOB6", 125, 176),
-  _PWG_MEDIA_MM("iso_b6c4_125x324mm", NULL, "125x324mm", 125, 324),
+  _PWG_MEDIA_MM("iso_b6c4_125x324mm", NULL, NULL, 125, 324),
   _PWG_MEDIA_MM("iso_b5_176x250mm", "iso-b5", "ISOB5", 176, 250),
   _PWG_MEDIA_MM("iso_b5-extra_201x276mm", NULL, "ISOB5Extra", 201, 276),
   _PWG_MEDIA_MM("iso_b4_250x353mm", "iso-b4", "ISOB4", 250, 353),
@@ -151,11 +152,11 @@
   _PWG_MEDIA_MM("iso_b2_500x707mm", "iso-b2", "ISOB2", 500, 707),
   _PWG_MEDIA_MM("iso_b1_707x1000mm", "iso-b1", "ISOB1", 707, 1000),
   _PWG_MEDIA_MM("iso_b0_1000x1414mm", "iso-b0", "ISOB0", 1000, 1414),
-  _PWG_MEDIA_MM("iso_c10_28x40mm", "iso-c10", "EnvC10", 28, 40),
-  _PWG_MEDIA_MM("iso_c9_40x57mm", "iso-c9", "EnvC9", 40, 57),
-  _PWG_MEDIA_MM("iso_c8_57x81mm", "iso-c8", "EnvC8", 57, 81),
+  _PWG_MEDIA_MM("iso_c10_28x40mm", "iso-c10", NULL, 28, 40),
+  _PWG_MEDIA_MM("iso_c9_40x57mm", "iso-c9", NULL, 40, 57),
+  _PWG_MEDIA_MM("iso_c8_57x81mm", "iso-c8", NULL, 57, 81),
   _PWG_MEDIA_MM("iso_c7_81x114mm", "iso-c7", "EnvC7", 81, 114),
-  _PWG_MEDIA_MM("iso_c7c6_81x162mm", NULL, "EnvC76", 81, 162),
+  _PWG_MEDIA_MM("iso_c7c6_81x162mm", NULL, NULL, 81, 162),
   _PWG_MEDIA_MM("iso_c6_114x162mm", "iso-c6", "EnvC6", 114, 162),
   _PWG_MEDIA_MM("iso_c6c5_114x229mm", NULL, "EnvC65", 114, 229),
   _PWG_MEDIA_MM("iso_c5_162x229mm", "iso-c5", "EnvC5", 162, 229),
@@ -165,16 +166,16 @@
   _PWG_MEDIA_MM("iso_c1_648x917mm", "iso-c1", "EnvC1", 648, 917),
   _PWG_MEDIA_MM("iso_c0_917x1297mm", "iso-c0", "EnvC0", 917, 1297),
   _PWG_MEDIA_MM("iso_dl_110x220mm", "iso-designated", "EnvDL", 110, 220),
-  _PWG_MEDIA_MM("iso_ra4_215x305mm", "iso-ra4", "RA4", 215, 305),
-  _PWG_MEDIA_MM("iso_sra4_225x320mm", "iso-sra4", "SRA4", 225, 320),
-  _PWG_MEDIA_MM("iso_ra3_305x430mm", "iso-ra3", "RA3", 305, 430),
-  _PWG_MEDIA_MM("iso_sra3_320x450mm", "iso-sra3", "SRA3", 320, 450),
-  _PWG_MEDIA_MM("iso_ra2_430x610mm", "iso-ra2", "RA2", 430, 610),
-  _PWG_MEDIA_MM("iso_sra2_450x640mm", "iso-sra2", "SRA2", 450, 640),
-  _PWG_MEDIA_MM("iso_ra1_610x860mm", "iso-ra1", "RA1", 610, 860),
-  _PWG_MEDIA_MM("iso_sra1_640x900mm", "iso-sra1", "SRA1", 640, 900),
-  _PWG_MEDIA_MM("iso_ra0_860x1220mm", "iso-ra0", "RA0", 860, 1220),
-  _PWG_MEDIA_MM("iso_sra0_900x1280mm", "iso-sra0", "SRA0", 900, 1280),
+  _PWG_MEDIA_MM("iso_ra4_215x305mm", "iso-ra4", NULL, 215, 305),
+  _PWG_MEDIA_MM("iso_sra4_225x320mm", "iso-sra4", NULL, 225, 320),
+  _PWG_MEDIA_MM("iso_ra3_305x430mm", "iso-ra3", NULL, 305, 430),
+  _PWG_MEDIA_MM("iso_sra3_320x450mm", "iso-sra3", NULL, 320, 450),
+  _PWG_MEDIA_MM("iso_ra2_430x610mm", "iso-ra2", NULL, 430, 610),
+  _PWG_MEDIA_MM("iso_sra2_450x640mm", "iso-sra2", NULL, 450, 640),
+  _PWG_MEDIA_MM("iso_ra1_610x860mm", "iso-ra1", NULL, 610, 860),
+  _PWG_MEDIA_MM("iso_sra1_640x900mm", "iso-sra1", NULL, 640, 900),
+  _PWG_MEDIA_MM("iso_ra0_860x1220mm", "iso-ra0", NULL, 860, 1220),
+  _PWG_MEDIA_MM("iso_sra0_900x1280mm", "iso-sra0", NULL, 900, 1280),
 
   /* Japanese Standard Sheet Media Sizes */
   _PWG_MEDIA_MM("jis_b10_32x45mm", "jis-b10", "B10", 32, 45),
@@ -188,7 +189,7 @@
   _PWG_MEDIA_MM("jis_b2_515x728mm", "jis-b2", "B2", 515, 728),
   _PWG_MEDIA_MM("jis_b1_728x1030mm", "jis-b1", "B1", 728, 1030),
   _PWG_MEDIA_MM("jis_b0_1030x1456mm", "jis-b0", "B0", 1030, 1456),
-  _PWG_MEDIA_MM("jis_exec_216x330mm", NULL, "216x330mm", 216, 330),
+  _PWG_MEDIA_MM("jis_exec_216x330mm", NULL, NULL, 216, 330),
   _PWG_MEDIA_MM("jpn_kaku2_240x332mm", NULL, "EnvKaku2", 240, 332),
   _PWG_MEDIA_MM("jpn_kaku3_216x277mm", NULL, "EnvKaku3", 216, 277),
   _PWG_MEDIA_MM("jpn_kaku4_197x267mm", NULL, "EnvKaku4", 197, 267),
@@ -203,7 +204,7 @@
   _PWG_MEDIA_MM("jpn_chou3_120x235mm", NULL, "EnvChou3", 120, 235),
   _PWG_MEDIA_MM("jpn_chou40_90x225mm", NULL, "EnvChou40", 90, 225),
   _PWG_MEDIA_MM("jpn_oufuku_148x200mm", NULL, "DoublePostcardRotated", 148, 200),
-  _PWG_MEDIA_MM("jpn_kahu_240x322.1mm", NULL, "240x322mm", 240, 322.1),
+  _PWG_MEDIA_MM("jpn_kahu_240x322.1mm", NULL, NULL, 240, 322.1),
 
   /* Chinese Standard Sheet Media Sizes */
   _PWG_MEDIA_MM("prc_32k_97x151mm", NULL, "PRC32K", 97, 151),
@@ -214,9 +215,9 @@
   _PWG_MEDIA_MM("prc_6_120x320mm", NULL, NULL, 120, 320),
   _PWG_MEDIA_MM("prc_16k_146x215mm", NULL, "PRC16K", 146, 215),
   _PWG_MEDIA_MM("prc_7_160x230mm", NULL, "EnvPRC7", 160, 230),
-  _PWG_MEDIA_MM("om_juuro-ku-kai_198x275mm", NULL, "198x275mm", 198, 275),
-  _PWG_MEDIA_MM("om_pa-kai_267x389mm", NULL, "267x389mm", 267, 389),
-  _PWG_MEDIA_MM("om_dai-pa-kai_275x395mm", NULL, "275x395mm", 275, 395),
+  _PWG_MEDIA_MM("om_juuro-ku-kai_198x275mm", NULL, NULL, 198, 275),
+  _PWG_MEDIA_MM("om_pa-kai_267x389mm", NULL, NULL, 267, 389),
+  _PWG_MEDIA_MM("om_dai-pa-kai_275x395mm", NULL, NULL, 275, 395),
 
   /* Chinese Standard Sheet Media Inch Sizes */
   _PWG_MEDIA_IN("roc_16k_7.75x10.75in", NULL, "roc16k", 7.75, 10.75),
@@ -226,16 +227,16 @@
   _PWG_MEDIA_IN("oe_photo-l_3.5x5in", NULL, "3.5x5", 3.5, 5),
 
   /* Other Metric Standard Sheet Media Sizes */
-  _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, "100x150mm", 100, 150),
+  _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, "om_small-photo", 100, 150),
   _PWG_MEDIA_MM("om_italian_110x230mm", NULL, "EnvItalian", 110, 230),
-  _PWG_MEDIA_MM("om_large-photo_200x300", NULL, "200x300mm", 200, 300),
+  _PWG_MEDIA_MM("om_large-photo_200x300", NULL, "om_large-photo", 200, 300),
   _PWG_MEDIA_MM("om_folio_210x330mm", "folio", "Folio", 210, 330),
   _PWG_MEDIA_MM("om_folio-sp_215x315mm", NULL, "FolioSP", 215, 315),
   _PWG_MEDIA_MM("om_invite_220x220mm", NULL, "EnvInvite", 220, 220),
-  _PWG_MEDIA_MM("om_small-photo_100x200mm", NULL, "100x200mm", 100, 200),
+  _PWG_MEDIA_MM("om_small-photo_100x200mm", NULL, "om_wide-photo", 100, 200),
 
   /* Disc Sizes */
-  _PWG_MEDIA_MM("disc_standard_40x118mm", NULL, "Disc", 118, 118)
+  _PWG_MEDIA_MM("disc_standard_40x118mm", NULL, NULL, 118, 118)
 };
 
 
@@ -377,6 +378,11 @@
   return (1);
 }
 
+/* For macOS 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_t structure using IPP Job Template
@@ -554,6 +560,10 @@
   return (1);
 }
 
+/* For macOS 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.
@@ -761,8 +771,6 @@
 	*     [oe|om]_WIDTHxHEIGHTuu_WIDTHxHEIGHTuu
 	*/
 
-        char	wstr[32], lstr[32];	/* Width and length as strings */
-
 	size         = &(cg->pwg_media);
 	size->width  = w;
 	size->length = l;
@@ -771,12 +779,6 @@
 	pwgFormatSizeName(cg->pwg_name, sizeof(cg->pwg_name),
 	                  custom ? "custom" : NULL, custom ? ppd + 7 : NULL,
 	                  size->width, size->length, NULL);
-
-        if ((w % 635) == 0 && (l % 635) == 0)
-          snprintf(cg->ppd_name, sizeof(cg->ppd_name), "%sx%s", pwg_format_inches(wstr, sizeof(wstr), w), pwg_format_inches(lstr, sizeof(lstr), l));
-        else
-          snprintf(cg->ppd_name, sizeof(cg->ppd_name), "%sx%smm", pwg_format_millimeters(wstr, sizeof(wstr), w), pwg_format_millimeters(lstr, sizeof(lstr), l));
-        size->ppd = cg->ppd_name;
       }
     }
   }
@@ -867,8 +869,6 @@
 
       if (ptr)
       {
-        char	wstr[32], lstr[32];	/* Width and length strings */
-
         if (!strncmp(pwg, "disc_", 5))
           w = l;			/* Make the media size OUTERxOUTER */
 
@@ -878,12 +878,6 @@
 
         strlcpy(cg->pwg_name, pwg, sizeof(cg->pwg_name));
 	size->pwg = cg->pwg_name;
-
-        if (numer == 100)
-          snprintf(cg->ppd_name, sizeof(cg->ppd_name), "%sx%smm", pwg_format_millimeters(wstr, sizeof(wstr), w), pwg_format_millimeters(lstr, sizeof(lstr), l));
-        else
-          snprintf(cg->ppd_name, sizeof(cg->ppd_name), "%sx%s", pwg_format_inches(wstr, sizeof(wstr), w), pwg_format_inches(lstr, sizeof(lstr), l));
-        size->ppd = cg->ppd_name;
       }
     }
   }
@@ -933,7 +927,6 @@
   int		dw, dl,			/* Difference in width and length */
 		best_dw = 999,		/* Best difference in width and length */
 		best_dl = 999;
-  char		wstr[32], lstr[32];	/* Width and length as strings */
   _cups_globals_t *cg = _cupsGlobals();	/* Global data */
 
 
@@ -986,12 +979,6 @@
   cg->pwg_media.width  = width;
   cg->pwg_media.length = length;
 
-  if ((width % 635) == 0 && (length % 635) == 0)
-    snprintf(cg->ppd_name, sizeof(cg->ppd_name), "%sx%s", pwg_format_inches(wstr, sizeof(wstr), width), pwg_format_inches(lstr, sizeof(lstr), length));
-  else
-    snprintf(cg->ppd_name, sizeof(cg->ppd_name), "%sx%smm", pwg_format_millimeters(wstr, sizeof(wstr), width), pwg_format_millimeters(lstr, sizeof(lstr), length));
-  cg->pwg_media.ppd = cg->ppd_name;
-
   return (&(cg->pwg_media));
 }
 
@@ -1051,8 +1038,8 @@
 
 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 */
+                 size_t bufsize,	/* I - Size of buffer */
+                 int    val)		/* I - Value in hundredths of millimeters */
 {
   int	thousandths,			/* Thousandths of inches */
 	integer,			/* Integer portion */
@@ -1092,8 +1079,8 @@
 
 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 */
+                      size_t bufsize,	/* I - Size of buffer */
+                      int    val)	/* I - Value in hundredths of millimeters */
 {
   int	integer,			/* Integer portion */
 	fraction;			/* Fractional portion */
diff --git a/cups/pwg-private.h b/cups/pwg-private.h
index e771590..25fb667 100644
--- a/cups/pwg-private.h
+++ b/cups/pwg-private.h
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/pwg.h b/cups/pwg.h
index 2269dbe..f663246 100644
--- a/cups/pwg.h
+++ b/cups/pwg.h
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/raster-private.h b/cups/raster-private.h
index 3813581..7656b27 100644
--- a/cups/raster-private.h
+++ b/cups/raster-private.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/raster.h b/cups/raster.h
index 4067b3c..43a9d15 100644
--- a/cups/raster.h
+++ b/cups/raster.h
@@ -10,7 +10,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -52,9 +52,6 @@
 #  define CUPS_RASTER_SYNCv2	0x52615332	/* RaS2 */
 #  define CUPS_RASTER_REVSYNCv2	0x32536152	/* 2SaR */
 
-#  define CUPS_RASTER_SYNCapple	0x554E4952	/* UNIR */
-#  define CUPS_RASTER_REVSYNCapple 0x52494E55	/* RINU */
-
 #  define CUPS_RASTER_SYNC_PWG	CUPS_RASTER_SYNCv2
 
 /*
@@ -79,13 +76,6 @@
 #  define CUPS_RASTER_HAVE_PWGRASTER 1
 
 /*
- * The following definition can be used to determine if Apple Raster is
- * supported (beta).
- */
-
-#  define CUPS_RASTER_HAVE_APPLERASTER 1
-
-/*
  * The following PWG 5102.4 definitions specify indices into the
  * cupsInteger[] array in the raster header.
  */
@@ -212,8 +202,7 @@
   CUPS_RASTER_READ = 0,			/* Open stream for reading */
   CUPS_RASTER_WRITE = 1,		/* Open stream for writing */
   CUPS_RASTER_WRITE_COMPRESSED = 2,	/* Open stream for compressed writing @since CUPS 1.3/macOS 10.5@ */
-  CUPS_RASTER_WRITE_PWG = 3,		/* Open stream for compressed writing in PWG Raster mode @since CUPS 1.5/macOS 10.7@ */
-  CUPS_RASTER_WRITE_APPLE = 4		/* Open stream for compressed writing in AppleRaster mode (beta) @private@ */
+  CUPS_RASTER_WRITE_PWG = 3		/* Open stream for compressed writing in PWG mode @since CUPS 1.5/macOS 10.7@ */
 };
 
 typedef enum cups_mode_e cups_mode_t;	/**** cupsRasterOpen modes ****/
diff --git a/cups/request.c b/cups/request.c
index 39cbe6c..8de44f7 100644
--- a/cups/request.c
+++ b/cups/request.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/sidechannel.c b/cups/sidechannel.c
index a4cd960..8070ea7 100644
--- a/cups/sidechannel.c
+++ b/cups/sidechannel.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/sidechannel.h b/cups/sidechannel.h
index a82408f..3de4542 100644
--- a/cups/sidechannel.h
+++ b/cups/sidechannel.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/snprintf.c b/cups/snprintf.c
index c5d8908..d586ce9 100644
--- a/cups/snprintf.c
+++ b/cups/snprintf.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/string-private.h b/cups/string-private.h
index e8448d1..8b1140b 100644
--- a/cups/string-private.h
+++ b/cups/string-private.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/string.c b/cups/string.c
index 39a787f..23b0439 100644
--- a/cups/string.c
+++ b/cups/string.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/tempfile.c b/cups/tempfile.c
index da705a9..d96ee7d 100644
--- a/cups/tempfile.c
+++ b/cups/tempfile.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testadmin.c b/cups/testadmin.c
index 69b5efb..f15c808 100644
--- a/cups/testadmin.c
+++ b/cups/testadmin.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testarray.c b/cups/testarray.c
index 6164ffc..5ae7315 100644
--- a/cups/testarray.c
+++ b/cups/testarray.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testcache.c b/cups/testcache.c
index e7816a3..9025a0d 100644
--- a/cups/testcache.c
+++ b/cups/testcache.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testconflicts.c b/cups/testconflicts.c
index 973c5a0..d07b088 100644
--- a/cups/testconflicts.c
+++ b/cups/testconflicts.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testcreds.c b/cups/testcreds.c
index bc17a20..8e3c878 100644
--- a/cups/testcreds.c
+++ b/cups/testcreds.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testcups.c b/cups/testcups.c
index aa58766..b6bf78f 100644
--- a/cups/testcups.c
+++ b/cups/testcups.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testdest.c b/cups/testdest.c
index 945e3e1..de6f1da 100644
--- a/cups/testdest.c
+++ b/cups/testdest.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testfile.c b/cups/testfile.c
index b2ec8cd..dae50fa 100644
--- a/cups/testfile.c
+++ b/cups/testfile.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testhttp.c b/cups/testhttp.c
index 376d71f..20c6625 100644
--- a/cups/testhttp.c
+++ b/cups/testhttp.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testi18n.c b/cups/testi18n.c
index beaf236..a88f1e1 100644
--- a/cups/testi18n.c
+++ b/cups/testi18n.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testipp.c b/cups/testipp.c
index 017ee9d..150abe0 100644
--- a/cups/testipp.c
+++ b/cups/testipp.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testlang.c b/cups/testlang.c
index 6aa49ab..6f0691e 100644
--- a/cups/testlang.c
+++ b/cups/testlang.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testoptions.c b/cups/testoptions.c
index f5ce2e2..44a3c71 100644
--- a/cups/testoptions.c
+++ b/cups/testoptions.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testppd.c b/cups/testppd.c
index e1b5156..6d5065c 100644
--- a/cups/testppd.c
+++ b/cups/testppd.c
@@ -1,14 +1,14 @@
 /*
  * PPD test program for CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testpwg.c b/cups/testpwg.c
index d2332c2..05aba45 100644
--- a/cups/testpwg.c
+++ b/cups/testpwg.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/testsnmp.c b/cups/testsnmp.c
index 4026a28..3ab48af 100644
--- a/cups/testsnmp.c
+++ b/cups/testsnmp.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/thread-private.h b/cups/thread-private.h
index ca4ef4c..64897a3 100644
--- a/cups/thread-private.h
+++ b/cups/thread-private.h
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/thread.c b/cups/thread.c
index 77b4442..b389b15 100644
--- a/cups/thread.c
+++ b/cups/thread.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/tls-darwin.c b/cups/tls-darwin.c
index b6e88b0..383a20e 100644
--- a/cups/tls-darwin.c
+++ b/cups/tls-darwin.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -41,8 +41,6 @@
 static char		*tls_common_name = NULL;
 					/* Default common name */
 #ifdef HAVE_SECKEYCHAINOPEN
-static int		tls_cups_keychain = 0;
-					/* Opened the CUPS keychain? */
 static SecKeychainRef	tls_keychain = NULL;
 					/* Server cert keychain */
 #else
@@ -1749,7 +1747,6 @@
   CFMutableDictionaryRef query = NULL;	/* Query qualifiers */
   CFArrayRef		list = NULL;	/* Keychain list */
   SecKeychainRef	syschain = NULL;/* System keychain */
-  SecKeychainStatus	status = 0;	/* Keychain status */
 
 
   DEBUG_printf(("3http_cdsa_copy_server(common_name=\"%s\")", common_name));
@@ -1772,11 +1769,6 @@
 
   _cupsMutexLock(&tls_mutex);
 
-  err = SecKeychainGetStatus(tls_keychain, &status);
-
-  if (err == noErr && !(status & kSecUnlockStateStatus) && tls_cups_keychain)
-    SecKeychainUnlock(tls_keychain, _CUPS_CDSA_PASSLEN, _CUPS_CDSA_PASSWORD, TRUE);
-
   CFDictionaryAddValue(query, kSecClass, kSecClassIdentity);
   CFDictionaryAddValue(query, kSecMatchPolicy, policy);
   CFDictionaryAddValue(query, kSecReturnRef, kCFBooleanTrue);
@@ -1909,15 +1901,9 @@
   */
 
   if (!path)
-  {
     path = http_cdsa_default_path(filename, filesize);
-    tls_cups_keychain = 1;
-  }
   else
-  {
     strlcpy(filename, path, filesize);
-    tls_cups_keychain = 0;
-  }
 
  /*
   * Save the interaction setting and disable while we open the keychain...
@@ -1926,7 +1912,7 @@
   SecKeychainGetUserInteractionAllowed(&interaction);
   SecKeychainSetUserInteractionAllowed(FALSE);
 
-  if (access(path, R_OK) && tls_cups_keychain)
+  if (access(path, R_OK))
   {
    /*
     * Create a new keychain at the given path...
@@ -1945,7 +1931,7 @@
     if (err == noErr)
       err = SecKeychainGetStatus(keychain, &status);
 
-    if (err == noErr && !(status & kSecUnlockStateStatus) && tls_cups_keychain)
+    if (err == noErr && !(status & kSecUnlockStateStatus))
       err = SecKeychainUnlock(keychain, _CUPS_CDSA_PASSLEN, _CUPS_CDSA_PASSWORD, TRUE);
   }
 
diff --git a/cups/tls-gnutls.c b/cups/tls-gnutls.c
index 7193d79..9941e51 100644
--- a/cups/tls-gnutls.c
+++ b/cups/tls-gnutls.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/tls-sspi.c b/cups/tls-sspi.c
index 46f6e79..8d88faf 100644
--- a/cups/tls-sspi.c
+++ b/cups/tls-sspi.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/tls.c b/cups/tls.c
index 36d484c..c1db80d 100644
--- a/cups/tls.c
+++ b/cups/tls.c
@@ -11,7 +11,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/tlscheck.c b/cups/tlscheck.c
index 32cbcca..9197261 100644
--- a/cups/tlscheck.c
+++ b/cups/tlscheck.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/transcode.c b/cups/transcode.c
index 6f73a42..2aa1a8b 100644
--- a/cups/transcode.c
+++ b/cups/transcode.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/transcode.h b/cups/transcode.h
index cd12cb5..20d13db 100644
--- a/cups/transcode.h
+++ b/cups/transcode.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/usersys.c b/cups/usersys.c
index 333d21e..9a23d74 100644
--- a/cups/usersys.c
+++ b/cups/usersys.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/util.c b/cups/util.c
index 5db2fc6..abfb8d4 100644
--- a/cups/util.c
+++ b/cups/util.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/cups/versioning.h b/cups/versioning.h
index 2e92e6b..ed68f82 100644
--- a/cups/versioning.h
+++ b/cups/versioning.h
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/Makefile b/filter/Makefile
index 7da764d..152bc90 100644
--- a/filter/Makefile
+++ b/filter/Makefile
@@ -8,7 +8,7 @@
 # property of Apple Inc. and are protected by Federal copyright
 # law.  Distribution and use rights are outlined in the file "LICENSE.txt"
 # which should have been included with this file.  If this file is
-# missing or damaged, see the license at "http://www.cups.org/".
+# file is missing or damaged, see the license at "http://www.cups.org/".
 #
 # This file is subject to the Apple OS-Developed Software exception.
 #
diff --git a/filter/api-raster.shtml b/filter/api-raster.shtml
index 6d458a2..35996f6 100644
--- a/filter/api-raster.shtml
+++ b/filter/api-raster.shtml
@@ -34,7 +34,7 @@
 file descriptor 0:</p>
 
 <pre class="example">
-#include &lt;cups/raster.h&gt;
+#include &lt;cups/raster.h&gt;>
 
 <a href="#cups_raster_t">cups_raster_t</a> *ras = <a href="#cupsRasterOpen">cupsRasterOpen</a>(0, CUPS_RASTER_READ);
 </pre>
@@ -61,7 +61,7 @@
 function:</p>
 
 <pre class="example">
-#include &lt;cups/raster.h&gt;
+#include &lt;cups/raster.h&gt;>
 
 <a href="#cups_raster_t">cups_raster_t</a> *ras = <a href="#cupsRasterOpen">cupsRasterOpen</a>(0, CUPS_RASTER_READ);
 <a href="#cups_page_header2_t">cups_page_header2_t</a> header;
@@ -84,7 +84,7 @@
 at a time:</p>
 
 <pre class="example">
-#include &lt;cups/raster.h&gt;
+#include &lt;cups/raster.h&gt;>
 
 <a href="#cups_raster_t">cups_raster_t</a> *ras = <a href="#cupsRasterOpen">cupsRasterOpen</a>(0, CUPS_RASTER_READ);
 <a href="#cups_page_header2_t">cups_page_header2_t</a> header;
diff --git a/filter/commandtops.c b/filter/commandtops.c
index 07979e0..65dcd35 100644
--- a/filter/commandtops.c
+++ b/filter/commandtops.c
@@ -7,7 +7,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
diff --git a/filter/common.c b/filter/common.c
index 86b5f8e..bed4a53 100644
--- a/filter/common.c
+++ b/filter/common.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/common.h b/filter/common.h
index e72b27f..0dcb289 100644
--- a/filter/common.h
+++ b/filter/common.h
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/error.c b/filter/error.c
index 3c552cb..dfbb5c9 100644
--- a/filter/error.c
+++ b/filter/error.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/gziptoany.c b/filter/gziptoany.c
index 0eae85e..b3f5dff 100644
--- a/filter/gziptoany.c
+++ b/filter/gziptoany.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/interpret.c b/filter/interpret.c
index 031b1d5..f811d1a 100644
--- a/filter/interpret.c
+++ b/filter/interpret.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/pstops.c b/filter/pstops.c
index 072356e..e9b4438 100644
--- a/filter/pstops.c
+++ b/filter/pstops.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/raster.c b/filter/raster.c
index bacf5ba..dee8eec 100644
--- a/filter/raster.c
+++ b/filter/raster.c
@@ -10,7 +10,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -36,8 +36,7 @@
   cups_raster_iocb_t	iocb;		/* IO callback */
   cups_mode_t		mode;		/* Read/write mode */
   cups_page_header2_t	header;		/* Raster header for current page */
-  unsigned		rowheight,	/* Row height in lines */
-			count,		/* Current row run-length count */
+  unsigned		count,		/* Current row run-length count */
 			remaining,	/* Remaining rows in page image */
 			bpp;		/* Bytes per pixel/color */
   unsigned char		*pixels,	/* Pixels for current row */
@@ -52,7 +51,6 @@
 #ifdef DEBUG
   size_t		iocount;	/* Number of bytes read/written */
 #endif /* DEBUG */
-  unsigned		apple_page_count;/* Apple raster page count */
 };
 
 
@@ -420,9 +418,7 @@
         r->sync != CUPS_RASTER_SYNCv1 &&
         r->sync != CUPS_RASTER_REVSYNCv1 &&
         r->sync != CUPS_RASTER_SYNCv2 &&
-        r->sync != CUPS_RASTER_REVSYNCv2 &&
-        r->sync != CUPS_RASTER_SYNCapple &&
-        r->sync != CUPS_RASTER_REVSYNCapple)
+        r->sync != CUPS_RASTER_REVSYNCv2)
     {
       _cupsRasterAddError("Unknown raster format %08x!\n", r->sync);
       free(r);
@@ -430,33 +426,14 @@
     }
 
     if (r->sync == CUPS_RASTER_SYNCv2 ||
-        r->sync == CUPS_RASTER_REVSYNCv2 ||
-        r->sync == CUPS_RASTER_SYNCapple ||
-        r->sync == CUPS_RASTER_REVSYNCapple)
+        r->sync == CUPS_RASTER_REVSYNCv2)
       r->compressed = 1;
 
     if (r->sync == CUPS_RASTER_REVSYNC ||
         r->sync == CUPS_RASTER_REVSYNCv1 ||
-        r->sync == CUPS_RASTER_REVSYNCv2 ||
-        r->sync == CUPS_RASTER_REVSYNCapple)
+        r->sync == CUPS_RASTER_REVSYNCv2)
       r->swapped = 1;
 
-    if (r->sync == CUPS_RASTER_SYNCapple ||
-        r->sync == CUPS_RASTER_REVSYNCapple)
-    {
-      unsigned char	header[8];	/* File header */
-
-      if (cups_raster_io(r, (unsigned char *)header, sizeof(header)) !=
-	      sizeof(header))
-      {
-	_cupsRasterAddError("Unable to read header from raster stream: %s\n",
-			    strerror(errno));
-	free(r);
-	return (NULL);
-      }
-
-    }
-
     DEBUG_printf(("1cupsRasterOpenIO: r->swapped=%d, r->sync=%08x\n", r->swapped, r->sync));
   }
   else
@@ -482,13 +459,6 @@
           r->sync       = htonl(CUPS_RASTER_SYNC_PWG);
           r->swapped    = r->sync != CUPS_RASTER_SYNC_PWG;
 	  break;
-
-      case CUPS_RASTER_WRITE_APPLE :
-          r->compressed     = 1;
-          r->sync           = htonl(CUPS_RASTER_SYNCapple);
-          r->swapped        = r->sync != CUPS_RASTER_SYNCapple;
-          r->apple_page_count = 0xffffffffU;
-	  break;
     }
 
     if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) < (ssize_t)sizeof(r->sync))
@@ -692,31 +662,7 @@
 	  return (0);
 	}
 
-        if (byte == 128)
-        {
-         /*
-          * Clear to end of line...
-          */
-
-          switch (r->header.cupsColorSpace)
-          {
-            case CUPS_CSPACE_W :
-            case CUPS_CSPACE_RGB :
-            case CUPS_CSPACE_SW :
-            case CUPS_CSPACE_SRGB :
-            case CUPS_CSPACE_RGBW :
-            case CUPS_CSPACE_ADOBERGB :
-                memset(temp, 0xff, (size_t)bytes);
-                break;
-            default :
-                memset(temp, 0x00, (size_t)bytes);
-                break;
-          }
-
-          temp += bytes;
-          bytes = 0;
-        }
-	else if (byte & 128)
+	if (byte & 128)
 	{
 	 /*
 	  * Copy N literal pixels...
@@ -945,60 +891,6 @@
 
     return (cups_raster_io(r, (unsigned char *)&fh, sizeof(fh)) == sizeof(fh));
   }
-  else if (r->mode == CUPS_RASTER_WRITE_APPLE)
-  {
-   /*
-    * Raw raster data is always network byte order with most of the page header
-    * zeroed.
-    */
-
-    unsigned char appleheader[32];	/* Raw page header */
-
-    if (r->apple_page_count == 0xffffffffU)
-    {
-     /*
-      * Write raw page count from raster page header...
-      */
-
-      r->apple_page_count = r->header.cupsInteger[0];
-
-      appleheader[0] = 'A';
-      appleheader[1] = 'S';
-      appleheader[2] = 'T';
-      appleheader[3] = 0;
-      appleheader[4] = (unsigned char)(r->apple_page_count >> 24);
-      appleheader[5] = (unsigned char)(r->apple_page_count >> 16);
-      appleheader[6] = (unsigned char)(r->apple_page_count >> 8);
-      appleheader[7] = (unsigned char)(r->apple_page_count);
-
-      if (cups_raster_io(r, appleheader, 8) != 8)
-        return (0);
-    }
-
-    memset(appleheader, 0, sizeof(appleheader));
-
-    appleheader[0]  = (unsigned char)r->header.cupsBitsPerPixel;
-    appleheader[1]  = r->header.cupsColorSpace == CUPS_CSPACE_SRGB ? 1 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_RGBW ? 2 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_ADOBERGB ? 3 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_W ? 4 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_RGB ? 5 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_CMYK ? 6 : 0;
-    appleheader[12] = (unsigned char)(r->header.cupsWidth >> 24);
-    appleheader[13] = (unsigned char)(r->header.cupsWidth >> 16);
-    appleheader[14] = (unsigned char)(r->header.cupsWidth >> 8);
-    appleheader[15] = (unsigned char)(r->header.cupsWidth);
-    appleheader[16] = (unsigned char)(r->header.cupsHeight >> 24);
-    appleheader[17] = (unsigned char)(r->header.cupsHeight >> 16);
-    appleheader[18] = (unsigned char)(r->header.cupsHeight >> 8);
-    appleheader[19] = (unsigned char)(r->header.cupsHeight);
-    appleheader[20] = (unsigned char)(r->header.HWResolution[0] >> 24);
-    appleheader[21] = (unsigned char)(r->header.HWResolution[0] >> 16);
-    appleheader[22] = (unsigned char)(r->header.HWResolution[0] >> 8);
-    appleheader[23] = (unsigned char)(r->header.HWResolution[0]);
-
-    return (cups_raster_io(r, appleheader, sizeof(appleheader)) == sizeof(appleheader));
-  }
   else
     return (cups_raster_io(r, (unsigned char *)&(r->header), sizeof(r->header))
 		== sizeof(r->header));
@@ -1009,7 +901,7 @@
  * 'cupsRasterWriteHeader2()' - Write a raster page header from a version 2
  *                              page header structure.
  *
- * The page header can be initialized using @link cupsRasterInitPWGHeader@.
+ * The page header can be initialized using @link cupsRasterInterpretPPD@.
  *
  * @since CUPS 1.2/macOS 10.5@
  */
@@ -1032,16 +924,6 @@
   if (!cups_raster_update(r))
     return (0);
 
-  if (r->mode == CUPS_RASTER_WRITE_APPLE)
-  {
-    r->rowheight = h->HWResolution[0] / h->HWResolution[1];
-
-    if (h->HWResolution[0] != (r->rowheight * h->HWResolution[1]))
-      return (0);
-  }
-  else
-    r->rowheight = 1;
-
  /*
   * Write the raster header...
   */
@@ -1103,62 +985,6 @@
 
     return (cups_raster_io(r, (unsigned char *)&fh, sizeof(fh)) == sizeof(fh));
   }
-  else if (r->mode == CUPS_RASTER_WRITE_APPLE)
-  {
-   /*
-    * Raw raster data is always network byte order with most of the page header
-    * zeroed.
-    */
-
-    unsigned char appleheader[32];	/* Raw page header */
-    unsigned height = r->header.cupsHeight * r->rowheight;
-					/* Computed page height */
-
-    if (r->apple_page_count == 0xffffffffU)
-    {
-     /*
-      * Write raw page count from raster page header...
-      */
-
-      r->apple_page_count = r->header.cupsInteger[0];
-
-      appleheader[0] = 'A';
-      appleheader[1] = 'S';
-      appleheader[2] = 'T';
-      appleheader[3] = 0;
-      appleheader[4] = (unsigned char)(r->apple_page_count >> 24);
-      appleheader[5] = (unsigned char)(r->apple_page_count >> 16);
-      appleheader[6] = (unsigned char)(r->apple_page_count >> 8);
-      appleheader[7] = (unsigned char)(r->apple_page_count);
-
-      if (cups_raster_io(r, appleheader, 8) != 8)
-        return (0);
-    }
-
-    memset(appleheader, 0, sizeof(appleheader));
-
-    appleheader[0]  = (unsigned char)r->header.cupsBitsPerPixel;
-    appleheader[1]  = r->header.cupsColorSpace == CUPS_CSPACE_SRGB ? 1 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_RGBW ? 2 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_ADOBERGB ? 3 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_W ? 4 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_RGB ? 5 :
-                        r->header.cupsColorSpace == CUPS_CSPACE_CMYK ? 6 : 0;
-    appleheader[12] = (unsigned char)(r->header.cupsWidth >> 24);
-    appleheader[13] = (unsigned char)(r->header.cupsWidth >> 16);
-    appleheader[14] = (unsigned char)(r->header.cupsWidth >> 8);
-    appleheader[15] = (unsigned char)(r->header.cupsWidth);
-    appleheader[16] = (unsigned char)(height >> 24);
-    appleheader[17] = (unsigned char)(height >> 16);
-    appleheader[18] = (unsigned char)(height >> 8);
-    appleheader[19] = (unsigned char)(height);
-    appleheader[20] = (unsigned char)(r->header.HWResolution[0] >> 24);
-    appleheader[21] = (unsigned char)(r->header.HWResolution[0] >> 16);
-    appleheader[22] = (unsigned char)(r->header.HWResolution[0] >> 8);
-    appleheader[23] = (unsigned char)(r->header.HWResolution[0]);
-
-    return (cups_raster_io(r, appleheader, sizeof(appleheader)) == sizeof(appleheader));
-  }
   else
     return (cups_raster_io(r, (unsigned char *)&(r->header), sizeof(r->header))
 		== sizeof(r->header));
@@ -1290,7 +1116,7 @@
           * Increase the repeat count...
 	  */
 
-	  r->count += r->rowheight;
+	  r->count ++;
 	  r->pcurrent = r->pixels;
 
 	 /*
@@ -1306,7 +1132,7 @@
 	    else
 	      return (len);
 	  }
-	  else if (r->count > (256 - r->rowheight))
+	  else if (r->count == 256)
 	  {
 	    if (cups_raster_write(r, r->pixels) <= 0)
 	      return (0);
@@ -1335,7 +1161,7 @@
         * Increase the repeat count...
 	*/
 
-	r->count += r->rowheight;
+	r->count ++;
 	r->pcurrent = r->pixels;
 
        /*
@@ -1375,118 +1201,53 @@
 
   DEBUG_printf(("4cups_raster_read_header: r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
 
-  memset(&(r->header), 0, sizeof(r->header));
+ /*
+  * Get the length of the raster header...
+  */
+
+  if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1)
+    len = sizeof(cups_page_header_t);
+  else
+    len = sizeof(cups_page_header2_t);
+
+  DEBUG_printf(("4cups_raster_read_header: len=%d", (int)len));
 
  /*
   * Read the header...
   */
 
-  switch (r->sync)
+  memset(&(r->header), 0, sizeof(r->header));
+
+  if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len)
   {
-    default :
-       /*
-	* Get the length of the raster header...
-	*/
+    DEBUG_printf(("4cups_raster_read_header: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
+    return (0);
+  }
 
-	if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1)
-	  len = sizeof(cups_page_header_t);
-	else
-	  len = sizeof(cups_page_header2_t);
+ /*
+  * Swap bytes as needed...
+  */
 
-	DEBUG_printf(("4cups_raster_read_header: len=%d", (int)len));
-
-       /*
-        * Read it...
-        */
-
-	if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len)
-	{
-	  DEBUG_printf(("4cups_raster_read_header: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
-	  return (0);
-	}
-
-       /*
-	* Swap bytes as needed...
-	*/
-
-	if (r->swapped)
-	{
-	  unsigned	*s,		/* Current word */
-			temp;		/* Temporary copy */
+  if (r->swapped)
+  {
+    unsigned	*s,			/* Current word */
+		temp;			/* Temporary copy */
 
 
-	  DEBUG_puts("4cups_raster_read_header: Swapping header bytes.");
+    DEBUG_puts("4cups_raster_read_header: Swapping header bytes.");
 
-	  for (len = 81, s = &(r->header.AdvanceDistance);
-	       len > 0;
-	       len --, s ++)
-	  {
-	    temp = *s;
-	    *s   = ((temp & 0xff) << 24) |
-		   ((temp & 0xff00) << 8) |
-		   ((temp & 0xff0000) >> 8) |
-		   ((temp & 0xff000000) >> 24);
+    for (len = 81, s = &(r->header.AdvanceDistance);
+	 len > 0;
+	 len --, s ++)
+    {
+      temp = *s;
+      *s   = ((temp & 0xff) << 24) |
+             ((temp & 0xff00) << 8) |
+             ((temp & 0xff0000) >> 8) |
+             ((temp & 0xff000000) >> 24);
 
-	    DEBUG_printf(("4cups_raster_read_header: %08x => %08x", temp, *s));
-	  }
-	}
-        break;
-
-    case CUPS_RASTER_SYNCapple :
-    case CUPS_RASTER_REVSYNCapple :
-        {
-          unsigned char	appleheader[32];	/* Raw header */
-          static const unsigned rawcspace[] =
-          {
-            CUPS_CSPACE_SW,
-            CUPS_CSPACE_SRGB,
-            CUPS_CSPACE_RGBW,
-            CUPS_CSPACE_ADOBERGB,
-            CUPS_CSPACE_W,
-            CUPS_CSPACE_RGB,
-            CUPS_CSPACE_CMYK
-          };
-          static const unsigned rawnumcolors[] =
-          {
-            1,
-            3,
-            4,
-            3,
-            1,
-            3,
-            4
-          };
-
-	  if (cups_raster_read(r, appleheader, sizeof(appleheader)) < (ssize_t)sizeof(appleheader))
-	  {
-	    DEBUG_printf(("4cups_raster_read_header: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount));
-	    return (0);
-	  }
-
-	  strlcpy(r->header.MediaClass, "PwgRaster", sizeof(r->header.MediaClass));
-					      /* PwgRaster */
-          r->header.cupsBitsPerPixel = appleheader[0];
-          r->header.cupsColorSpace   = appleheader[1] >= (sizeof(rawcspace) / sizeof(rawcspace[0])) ? CUPS_CSPACE_DEVICE1 : rawcspace[appleheader[1]];
-          r->header.cupsNumColors    = appleheader[1] >= (sizeof(rawnumcolors) / sizeof(rawnumcolors[0])) ? 1 : rawnumcolors[appleheader[1]];
-          r->header.cupsBitsPerColor = r->header.cupsBitsPerPixel / r->header.cupsNumColors;
-          r->header.cupsWidth        = ((((((unsigned)appleheader[12] << 8) | (unsigned)appleheader[13]) << 8) | (unsigned)appleheader[14]) << 8) | (unsigned)appleheader[15];
-          r->header.cupsHeight       = ((((((unsigned)appleheader[16] << 8) | (unsigned)appleheader[17]) << 8) | (unsigned)appleheader[18]) << 8) | (unsigned)appleheader[19];
-          r->header.cupsBytesPerLine = r->header.cupsWidth * r->header.cupsBitsPerPixel / 8;
-          r->header.cupsColorOrder   = CUPS_ORDER_CHUNKED;
-          r->header.HWResolution[0]  = r->header.HWResolution[1] = ((((((unsigned)appleheader[20] << 8) | (unsigned)appleheader[21]) << 8) | (unsigned)appleheader[22]) << 8) | (unsigned)appleheader[23];
-
-          if (r->header.HWResolution[0] > 0)
-          {
-	    r->header.PageSize[0]     = (unsigned)(r->header.cupsWidth * 72 / r->header.HWResolution[0]);
-	    r->header.PageSize[1]     = (unsigned)(r->header.cupsHeight * 72 / r->header.HWResolution[1]);
-	    r->header.cupsPageSize[0] = (float)(r->header.cupsWidth * 72.0 / r->header.HWResolution[0]);
-	    r->header.cupsPageSize[1] = (float)(r->header.cupsHeight * 72.0 / r->header.HWResolution[1]);
-          }
-
-          r->header.cupsInteger[0] = r->apple_page_count;
-          r->header.cupsInteger[7] = 0xffffff;
-        }
-        break;
+      DEBUG_printf(("4cups_raster_read_header: %08x => %08x", temp, *s));
+    }
   }
 
  /*
diff --git a/filter/rasterbench.c b/filter/rasterbench.c
index 8746f31..010fd9d 100644
--- a/filter/rasterbench.c
+++ b/filter/rasterbench.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c
index 4efe669..74dc61c 100644
--- a/filter/rastertoepson.c
+++ b/filter/rastertoepson.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/rastertohp.c b/filter/rastertohp.c
index eb11c8c..2994b80 100644
--- a/filter/rastertohp.c
+++ b/filter/rastertohp.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
diff --git a/filter/rastertolabel.c b/filter/rastertolabel.c
index 4e49181..a082831 100644
--- a/filter/rastertolabel.c
+++ b/filter/rastertolabel.c
@@ -1,14 +1,14 @@
 /*
  * Label printer filter for CUPS.
  *
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 2001-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -438,7 +438,7 @@
  */
 
 void
-EndPage(ppd_file_t          *ppd,	/* I - PPD file */
+EndPage(ppd_file_t *ppd,		/* I - PPD file */
         cups_page_header2_t *header)	/* I - Page header */
 {
   int		val;			/* Option value */
@@ -496,19 +496,6 @@
         puts("^XA");
 
        /*
-        * Rotate 180 degrees so that the top of the label/page is at the
-	* leading edge...
-	*/
-
-	puts("^POI");
-
-       /*
-        * Set print width...
-	*/
-
-        printf("^PW%u\n", header->cupsWidth);
-
-       /*
         * Set print rate...
 	*/
 
@@ -618,8 +605,8 @@
         * End the label and eject...
 	*/
 
-	puts("^XZ");
         puts("^IDR:CUPS.GRF^FS");
+	puts("^XZ");
 
        /*
         * Cut the label as needed...
diff --git a/filter/rastertopwg.c b/filter/rastertopwg.c
index 5413df0..f478ac5 100644
--- a/filter/rastertopwg.c
+++ b/filter/rastertopwg.c
@@ -1,13 +1,13 @@
 /*
  * CUPS raster to PWG raster format filter for CUPS.
  *
- * Copyright 2011, 2014-2017 Apple Inc.
+ * Copyright 2011, 2014-2016 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
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -31,8 +31,6 @@
 main(int  argc,				/* I - Number of command-line args */
      char *argv[])			/* I - Command-line arguments */
 {
-  const char		*final_content_type;
-					/* FINAL_CONTENT_TYPE env var */
   int			fd;		/* Raster file */
   cups_raster_t		*inras,		/* Input raster stream */
 			*outras;	/* Output raster stream */
@@ -50,7 +48,7 @@
 			lineoffset;	/* Offset into line */
   unsigned char		white;		/* White pixel */
   ppd_file_t		*ppd;		/* PPD file */
-  ppd_attr_t		*back;		/* cupsBackSide attribute */
+  ppd_attr_t		*back;		/* cupsBackSize attribute */
   _ppd_cache_t		*cache;		/* PPD cache */
   pwg_size_t		*pwg_size;	/* PWG media size */
   pwg_media_t		*pwg_media;	/* PWG media name */
@@ -75,11 +73,8 @@
   else
     fd = 0;
 
-  if ((final_content_type = getenv("FINAL_CONTENT_TYPE")) == NULL)
-    final_content_type = "image/pwg-raster";
-
   inras  = cupsRasterOpen(fd, CUPS_RASTER_READ);
-  outras = cupsRasterOpen(1, !strcmp(final_content_type, "image/pwg-raster") ? CUPS_RASTER_WRITE_PWG : CUPS_RASTER_WRITE_APPLE);
+  outras = cupsRasterOpen(1, CUPS_RASTER_WRITE_PWG);
 
   ppd   = ppdOpenFile(getenv("PPD"));
   back  = ppdFindAttr(ppd, "cupsBackSide", NULL);
@@ -435,9 +430,6 @@
     if (linesize < inheader.cupsBytesPerLine)
       linesize = inheader.cupsBytesPerLine;
 
-    if ((lineoffset + inheader.cupsBytesPerLine) > linesize)
-      lineoffset = linesize - inheader.cupsBytesPerLine;
-
     line = malloc(linesize);
 
     memset(line, white, linesize);
diff --git a/filter/testraster.c b/filter/testraster.c
index d5d63de..9c3f765 100644
--- a/filter/testraster.c
+++ b/filter/testraster.c
@@ -8,7 +8,7 @@
  * property of Apple Inc. and are protected by Federal copyright
  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
  * which should have been included with this file.  If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
  * This file is subject to the Apple OS-Developed Software exception.
  */
@@ -208,7 +208,6 @@
     errors += do_raster_tests(CUPS_RASTER_WRITE);
     errors += do_raster_tests(CUPS_RASTER_WRITE_COMPRESSED);
     errors += do_raster_tests(CUPS_RASTER_WRITE_PWG);
-    errors += do_raster_tests(CUPS_RASTER_WRITE_APPLE);
   }
   else
   {
@@ -527,9 +526,8 @@
 
   printf("cupsRasterOpen(%s): ",
          mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE" :
-	     mode == CUPS_RASTER_WRITE_COMPRESSED ? "CUPS_RASTER_WRITE_COMPRESSED" :
-	     mode == CUPS_RASTER_WRITE_PWG ? "CUPS_RASTER_WRITE_PWG" :
-				             "CUPS_RASTER_WRITE_APPLE");
+	     mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE_COMPRESSED" :
+	                                 "CUPS_RASTER_WRITE_PWG");
   fflush(stdout);
 
   if ((fp = fopen("test.raster", "wb")) == NULL)
@@ -553,24 +551,18 @@
     header.cupsWidth        = 256;
     header.cupsHeight       = 256;
     header.cupsBytesPerLine = 256;
-    header.HWResolution[0]  = 64;
-    header.HWResolution[1]  = 64;
-    header.PageSize[0]      = 288;
-    header.PageSize[1]      = 288;
-    header.cupsPageSize[0]  = 288.0f;
-    header.cupsPageSize[1]  = 288.0f;
 
     if (page & 1)
     {
-      header.cupsBytesPerLine *= 4;
+      header.cupsBytesPerLine *= 2;
       header.cupsColorSpace = CUPS_CSPACE_CMYK;
       header.cupsColorOrder = CUPS_ORDER_CHUNKED;
       header.cupsNumColors  = 4;
     }
     else
     {
-      header.cupsColorSpace = CUPS_CSPACE_W;
-      header.cupsColorOrder = CUPS_ORDER_CHUNKED;
+      header.cupsColorSpace = CUPS_CSPACE_K;
+      header.cupsColorOrder = CUPS_ORDER_BANDED;
       header.cupsNumColors  = 1;
     }
 
@@ -685,18 +677,8 @@
     expected.cupsWidth        = 256;
     expected.cupsHeight       = 256;
     expected.cupsBytesPerLine = 256;
-    expected.HWResolution[0]  = 64;
-    expected.HWResolution[1]  = 64;
-    expected.PageSize[0]      = 288;
-    expected.PageSize[1]      = 288;
 
-    if (mode != CUPS_RASTER_WRITE_PWG)
-    {
-      expected.cupsPageSize[0] = 288.0f;
-      expected.cupsPageSize[1] = 288.0f;
-    }
-
-    if (mode >= CUPS_RASTER_WRITE_PWG)
+    if (mode == CUPS_RASTER_WRITE_PWG)
     {
       strlcpy(expected.MediaClass, "PwgRaster", sizeof(expected.MediaClass));
       expected.cupsInteger[7] = 0xffffff;
@@ -704,15 +686,15 @@
 
     if (page & 1)
     {
-      expected.cupsBytesPerLine *= 4;
+      expected.cupsBytesPerLine *= 2;
       expected.cupsColorSpace = CUPS_CSPACE_CMYK;
       expected.cupsColorOrder = CUPS_ORDER_CHUNKED;
       expected.cupsNumColors  = 4;
     }
     else
     {
-      expected.cupsColorSpace = CUPS_CSPACE_W;
-      expected.cupsColorOrder = CUPS_ORDER_CHUNKED;
+      expected.cupsColorSpace = CUPS_CSPACE_K;
+      expected.cupsColorOrder = CUPS_ORDER_BANDED;
       expected.cupsNumColors  = 1;
     }
 
diff --git a/libcups_version b/libcups_version
deleted file mode 100644
index 0b1f88b..0000000
--- a/libcups_version
+++ /dev/null
@@ -1 +0,0 @@
-v2.2.3
diff --git a/update_libcups.sh b/update_libcups.sh
index 34592d6..8afbdce 100755
--- a/update_libcups.sh
+++ b/update_libcups.sh
@@ -14,7 +14,7 @@
 echo "== get current rev =="
 cd $TARGET_DIR
 
-CURRENT_REV=$(cat libcups_version)
+CURRENT_REV=$(git tag -l | grep -v "release" | grep -v "b" | grep -v "rc" | sort | tail -n1)
 echo "Current rev is $CURRENT_REV"
 
 echo
@@ -56,15 +56,16 @@
     sed -i -e "s/^\(#.*CUPS_SVERSION\).*/\1 \"CUPS $NEW_REV\"/g" config.h
     sed -i -e "s:^\(#.*CUPS_MINIMAL\).*:\1 \"CUPS/${NEW_REV#v}\":g" config.h
 
+    git add -A
+    git commit -m "Update libcups to $NEW_REV"
+
+    git tag $NEW_REV
+
     echo
     echo ">>> Updated license"
 
     cp LICENSE.txt NOTICE
 
-    echo $NEW_REV > libcups_version
-    git add -A
-    git commit -m "Update libcups to $NEW_REV"
-
     echo
     echo ">>> Updated libcups from $CURRENT_REV to $NEW_REV"
 fi