]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge changes from CUPS 1.5svn-r9041.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 23 Mar 2010 21:42:49 +0000 (21:42 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 23 Mar 2010 21:42:49 +0000 (21:42 +0000)
(all of the media changes)

git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1987 a1ca3aef-8c08-0410-bb20-df032aa958be

27 files changed:
CHANGES-1.4.txt
CREDITS.txt
cups/Dependencies
cups/Makefile
cups/dest.c
cups/globals.h
cups/mark.c
cups/page.c
cups/ppd.c
cups/ppd.h
cups/pwg-file.c [new file with mode: 0644]
cups/pwg-media.c [new file with mode: 0644]
cups/pwg-ppd.c [new file with mode: 0644]
cups/pwg-private.h [new file with mode: 0644]
cups/pwgmedia.c [deleted file]
cups/pwgmedia.h [deleted file]
cups/test.ppd
cups/testipp.c
cups/testppd.c
cups/testpwg.c [new file with mode: 0644]
scheduler/Dependencies
scheduler/ipp.c
scheduler/printers.c
scheduler/printers.h
systemv/cupstestppd.c
test/get-printer-attributes-2.0.test
test/print-job-media-col.test

index 3bd701b819f2bfe0bb500db433e919f6939a9794..5a7bbb987defc47ddd4b9905dcd3243ad203e480 100644 (file)
@@ -4,6 +4,7 @@ CHANGES-1.4.txt
 CHANGES IN CUPS V1.4.4
 
        - Documentation updates (STR #3453)
+       - Fixed support for media-col and page size variants (STR #3394)
        - The PostScript filter did not support all media selection options for
          the first page (STR #3525)
        - The scheduler did not always remove job control files (STR #3425)
index e37a1fb28cb350b21a159cb7c9dd7665dc9efb9b..a241eef4db1058088c05645984034108a360e457 100644 (file)
@@ -1,4 +1,4 @@
-CREDITS.txt - 2009-07-07
+CREDITS.txt - 2010-03-13
 ------------------------
 
 Few projects are completed by one person, and CUPS is no exception.  We'd
@@ -40,7 +40,7 @@ like to thank the following individuals for their contributions:
     Opher Shachar                  - Hebrew localization.
     Stuart Stevens                 - HP JetDirect IPP information.
     Andrea Suatoni                 - IRIX desktop integration and testing.
-    Teppo Turlianen                - Finnish localization.
+    Teppo Turliainen               - Finnish localization.
     Tim Waugh                      - Lots of patches, testing, and Linux
                                      integration.
     Yugami                         - LDAP browsing support.
index ff0ac495c11be80028cef01f7e98bc46047ab90c..6ccc01b665e86e7f67abcd877b0a747f1dcdd227 100644 (file)
 
 adminutil.o: adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h
 adminutil.o: file.h language.h globals.h string.h ../config.h http-private.h
-adminutil.o: md5.h ipp-private.h i18n.h transcode.h debug.h
+adminutil.o: md5.h ipp-private.h i18n.h transcode.h pwg-private.h
+adminutil.o: ../cups/cups.h debug.h
 array.o: array.h versioning.h string.h ../config.h debug.h
 attr.o: ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h file.h
 attr.o: language.h debug.h string.h ../config.h
 auth.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 auth.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-auth.o: i18n.h transcode.h debug.h
+auth.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 backchannel.o: cups.h ipp.h http.h versioning.h ppd.h array.h file.h
 backchannel.o: language.h
 backend.o: backend.h versioning.h globals.h string.h ../config.h
 backend.o: http-private.h http.h md5.h ipp-private.h ipp.h cups.h ppd.h
-backend.o: array.h file.h language.h i18n.h transcode.h
+backend.o: array.h file.h language.h i18n.h transcode.h pwg-private.h
+backend.o: ../cups/cups.h
 conflicts.o: ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h
 conflicts.o: file.h language.h string.h ../config.h debug.h
 custom.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 custom.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-custom.o: i18n.h transcode.h debug.h
+custom.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 debug.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 debug.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-debug.o: i18n.h transcode.h debug.h
+debug.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 dest.o: debug.h globals.h string.h ../config.h http-private.h http.h
 dest.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h
-dest.o: language.h i18n.h transcode.h pwgmedia.h
+dest.o: language.h i18n.h transcode.h pwg-private.h ../cups/cups.h
 dir.o: dir.h versioning.h string.h ../config.h debug.h
 emit.o: ppd.h array.h versioning.h file.h string.h ../config.h debug.h
 encode.o: cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
 encode.o: ipp-private.h string.h ../config.h debug.h
 file.o: file-private.h http-private.h ../config.h http.h versioning.h md5.h
 file.o: ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h file.h
-file.o: language.h i18n.h transcode.h debug.h
+file.o: language.h i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 getdevices.o: globals.h string.h ../config.h http-private.h http.h
 getdevices.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-getdevices.o: file.h language.h i18n.h transcode.h debug.h
+getdevices.o: file.h language.h i18n.h transcode.h pwg-private.h
+getdevices.o: ../cups/cups.h debug.h
 getifaddrs.o: http-private.h ../config.h http.h versioning.h md5.h
 getifaddrs.o: ipp-private.h ipp.h
 getputfile.o: globals.h string.h ../config.h http-private.h http.h
 getputfile.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-getputfile.o: file.h language.h i18n.h transcode.h debug.h
+getputfile.o: file.h language.h i18n.h transcode.h pwg-private.h
+getputfile.o: ../cups/cups.h debug.h
 globals.o: http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 globals.o: ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-globals.o: i18n.h transcode.h
+globals.o: i18n.h transcode.h pwg-private.h ../cups/cups.h
 http.o: http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 http.o: ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-http.o: i18n.h transcode.h debug.h
+http.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 http-addr.o: http-private.h ../config.h http.h versioning.h md5.h
 http-addr.o: ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h
-http-addr.o: file.h language.h i18n.h transcode.h debug.h
+http-addr.o: file.h language.h i18n.h transcode.h pwg-private.h
+http-addr.o: ../cups/cups.h debug.h
 http-addrlist.o: http-private.h ../config.h http.h versioning.h md5.h
 http-addrlist.o: ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h
-http-addrlist.o: file.h language.h i18n.h transcode.h debug.h
+http-addrlist.o: file.h language.h i18n.h transcode.h pwg-private.h
+http-addrlist.o: ../cups/cups.h debug.h
 http-support.o: debug.h globals.h string.h ../config.h http-private.h http.h
 http-support.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-http-support.o: file.h language.h i18n.h transcode.h
+http-support.o: file.h language.h i18n.h transcode.h pwg-private.h
+http-support.o: ../cups/cups.h
 ipp.o: http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 ipp.o: ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h i18n.h
-ipp.o: transcode.h debug.h
+ipp.o: transcode.h pwg-private.h ../cups/cups.h debug.h
 ipp-support.o: globals.h string.h ../config.h http-private.h http.h
 ipp-support.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-ipp-support.o: file.h language.h i18n.h transcode.h debug.h
+ipp-support.o: file.h language.h i18n.h transcode.h pwg-private.h
+ipp-support.o: ../cups/cups.h debug.h
 langprintf.o: globals.h string.h ../config.h http-private.h http.h
 langprintf.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-langprintf.o: file.h language.h i18n.h transcode.h
+langprintf.o: file.h language.h i18n.h transcode.h pwg-private.h
+langprintf.o: ../cups/cups.h
 language.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 language.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-language.o: i18n.h transcode.h debug.h
+language.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 localize.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 localize.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-localize.o: i18n.h transcode.h ppd-private.h debug.h
+localize.o: i18n.h transcode.h pwg-private.h ../cups/cups.h ppd-private.h
+localize.o: debug.h
 mark.o: cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
-mark.o: string.h ../config.h debug.h pwgmedia.h
+mark.o: string.h ../config.h debug.h pwg-private.h ../cups/cups.h
 md5.o: md5.h string.h ../config.h
 md5passwd.o: http-private.h ../config.h http.h versioning.h md5.h
 md5passwd.o: ipp-private.h ipp.h string.h
 notify.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 notify.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-notify.o: i18n.h transcode.h
+notify.o: i18n.h transcode.h pwg-private.h ../cups/cups.h
 options.o: cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
 options.o: string.h ../config.h debug.h
 page.o: ppd.h array.h versioning.h file.h string.h ../config.h debug.h
 ppd.o: ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h file.h
-ppd.o: language.h globals.h string.h ../config.h http-private.h md5.h
-ppd.o: ipp-private.h i18n.h transcode.h debug.h
-pwgmedia.o: pwgmedia.h globals.h string.h ../config.h http-private.h http.h
-pwgmedia.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-pwgmedia.o: file.h language.h i18n.h transcode.h debug.h
+ppd.o: language.h pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+ppd.o: http-private.h md5.h ipp-private.h i18n.h transcode.h debug.h
+pwg-file.o: pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-file.o: http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-file.o: cups.h ppd.h array.h file.h language.h i18n.h transcode.h debug.h
+pwg-media.o: pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-media.o: http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-media.o: cups.h ppd.h array.h file.h language.h i18n.h transcode.h
+pwg-media.o: debug.h
+pwg-ppd.o: pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-ppd.o: http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-ppd.o: cups.h ppd.h array.h file.h language.h i18n.h transcode.h debug.h
 request.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 request.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-request.o: i18n.h transcode.h debug.h
+request.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 sidechannel.o: sidechannel.h versioning.h string.h ../config.h debug.h
 snmp.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 snmp.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-snmp.o: i18n.h transcode.h debug.h snmp-private.h
+snmp.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
+snmp.o: snmp-private.h
 snprintf.o: string.h ../config.h
 string.o: array.h versioning.h debug.h string.h ../config.h
 tempfile.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 tempfile.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-tempfile.o: i18n.h transcode.h debug.h
+tempfile.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 transcode.o: globals.h string.h ../config.h http-private.h http.h
 transcode.o: versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-transcode.o: file.h language.h i18n.h transcode.h debug.h
+transcode.o: file.h language.h i18n.h transcode.h pwg-private.h
+transcode.o: ../cups/cups.h debug.h
 usersys.o: http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 usersys.o: ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-usersys.o: i18n.h transcode.h debug.h
+usersys.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 util.o: globals.h string.h ../config.h http-private.h http.h versioning.h
 util.o: md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-util.o: i18n.h transcode.h debug.h
+util.o: i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 testadmin.o: adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h
 testadmin.o: file.h language.h string.h ../config.h
 testarray.o: ../cups/string.h ../config.h string.h array.h versioning.h dir.h
@@ -127,119 +146,138 @@ testoptions.o: string.h ../config.h cups.h ipp.h http.h versioning.h ppd.h
 testoptions.o: array.h file.h language.h
 testlang.o: i18n.h transcode.h language.h array.h versioning.h string.h
 testlang.o: ../config.h
-testppd.o: ../cups/string.h ../config.h string.h cups.h ipp.h http.h
-testppd.o: versioning.h ppd.h array.h file.h language.h pwgmedia.h
+testppd.o: ../cups/cups.h ../cups/string.h ../config.h string.h
+testpwg.o: pwg-private.h ../cups/cups.h
 testsnmp.o: string.h ../config.h snmp-private.h http.h versioning.h
 # DO NOT DELETE
 
 adminutil.32.o: adminutil.c  adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h
 adminutil.32.o: adminutil.c  file.h language.h globals.h string.h ../config.h http-private.h
-adminutil.32.o: adminutil.c  md5.h ipp-private.h i18n.h transcode.h debug.h
+adminutil.32.o: adminutil.c  md5.h ipp-private.h i18n.h transcode.h pwg-private.h
+adminutil.32.o: adminutil.c  ../cups/cups.h debug.h
 array.32.o: array.c  array.h versioning.h string.h ../config.h debug.h
 attr.32.o: attr.c  ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h file.h
 attr.32.o: attr.c  language.h debug.h string.h ../config.h
 auth.32.o: auth.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 auth.32.o: auth.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-auth.32.o: auth.c  i18n.h transcode.h debug.h
+auth.32.o: auth.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 backchannel.32.o: backchannel.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h
 backchannel.32.o: backchannel.c  language.h
 backend.32.o: backend.c  backend.h versioning.h globals.h string.h ../config.h
 backend.32.o: backend.c  http-private.h http.h md5.h ipp-private.h ipp.h cups.h ppd.h
-backend.32.o: backend.c  array.h file.h language.h i18n.h transcode.h
+backend.32.o: backend.c  array.h file.h language.h i18n.h transcode.h pwg-private.h
+backend.32.o: backend.c  ../cups/cups.h
 conflicts.32.o: conflicts.c  ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h
 conflicts.32.o: conflicts.c  file.h language.h string.h ../config.h debug.h
 custom.32.o: custom.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 custom.32.o: custom.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-custom.32.o: custom.c  i18n.h transcode.h debug.h
+custom.32.o: custom.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 debug.32.o: debug.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 debug.32.o: debug.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-debug.32.o: debug.c  i18n.h transcode.h debug.h
+debug.32.o: debug.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 dest.32.o: dest.c  debug.h globals.h string.h ../config.h http-private.h http.h
 dest.32.o: dest.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h
-dest.32.o: dest.c  language.h i18n.h transcode.h pwgmedia.h
+dest.32.o: dest.c  language.h i18n.h transcode.h pwg-private.h ../cups/cups.h
 dir.32.o: dir.c  dir.h versioning.h string.h ../config.h debug.h
 emit.32.o: emit.c  ppd.h array.h versioning.h file.h string.h ../config.h debug.h
 encode.32.o: encode.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
 encode.32.o: encode.c  ipp-private.h string.h ../config.h debug.h
 file.32.o: file.c  file-private.h http-private.h ../config.h http.h versioning.h md5.h
 file.32.o: file.c  ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h file.h
-file.32.o: file.c  language.h i18n.h transcode.h debug.h
+file.32.o: file.c  language.h i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 getdevices.32.o: getdevices.c  globals.h string.h ../config.h http-private.h http.h
 getdevices.32.o: getdevices.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-getdevices.32.o: getdevices.c  file.h language.h i18n.h transcode.h debug.h
+getdevices.32.o: getdevices.c  file.h language.h i18n.h transcode.h pwg-private.h
+getdevices.32.o: getdevices.c  ../cups/cups.h debug.h
 getifaddrs.32.o: getifaddrs.c  http-private.h ../config.h http.h versioning.h md5.h
 getifaddrs.32.o: getifaddrs.c  ipp-private.h ipp.h
 getputfile.32.o: getputfile.c  globals.h string.h ../config.h http-private.h http.h
 getputfile.32.o: getputfile.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-getputfile.32.o: getputfile.c  file.h language.h i18n.h transcode.h debug.h
+getputfile.32.o: getputfile.c  file.h language.h i18n.h transcode.h pwg-private.h
+getputfile.32.o: getputfile.c  ../cups/cups.h debug.h
 globals.32.o: globals.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 globals.32.o: globals.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-globals.32.o: globals.c  i18n.h transcode.h
+globals.32.o: globals.c  i18n.h transcode.h pwg-private.h ../cups/cups.h
 http.32.o: http.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 http.32.o: http.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-http.32.o: http.c  i18n.h transcode.h debug.h
+http.32.o: http.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 http-addr.32.o: http-addr.c  http-private.h ../config.h http.h versioning.h md5.h
 http-addr.32.o: http-addr.c  ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h
-http-addr.32.o: http-addr.c  file.h language.h i18n.h transcode.h debug.h
+http-addr.32.o: http-addr.c  file.h language.h i18n.h transcode.h pwg-private.h
+http-addr.32.o: http-addr.c  ../cups/cups.h debug.h
 http-addrlist.32.o: http-addrlist.c  http-private.h ../config.h http.h versioning.h md5.h
 http-addrlist.32.o: http-addrlist.c  ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h
-http-addrlist.32.o: http-addrlist.c  file.h language.h i18n.h transcode.h debug.h
+http-addrlist.32.o: http-addrlist.c  file.h language.h i18n.h transcode.h pwg-private.h
+http-addrlist.32.o: http-addrlist.c  ../cups/cups.h debug.h
 http-support.32.o: http-support.c  debug.h globals.h string.h ../config.h http-private.h http.h
 http-support.32.o: http-support.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-http-support.32.o: http-support.c  file.h language.h i18n.h transcode.h
+http-support.32.o: http-support.c  file.h language.h i18n.h transcode.h pwg-private.h
+http-support.32.o: http-support.c  ../cups/cups.h
 ipp.32.o: ipp.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 ipp.32.o: ipp.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h i18n.h
-ipp.32.o: ipp.c  transcode.h debug.h
+ipp.32.o: ipp.c  transcode.h pwg-private.h ../cups/cups.h debug.h
 ipp-support.32.o: ipp-support.c  globals.h string.h ../config.h http-private.h http.h
 ipp-support.32.o: ipp-support.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-ipp-support.32.o: ipp-support.c  file.h language.h i18n.h transcode.h debug.h
+ipp-support.32.o: ipp-support.c  file.h language.h i18n.h transcode.h pwg-private.h
+ipp-support.32.o: ipp-support.c  ../cups/cups.h debug.h
 langprintf.32.o: langprintf.c  globals.h string.h ../config.h http-private.h http.h
 langprintf.32.o: langprintf.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-langprintf.32.o: langprintf.c  file.h language.h i18n.h transcode.h
+langprintf.32.o: langprintf.c  file.h language.h i18n.h transcode.h pwg-private.h
+langprintf.32.o: langprintf.c  ../cups/cups.h
 language.32.o: language.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 language.32.o: language.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-language.32.o: language.c  i18n.h transcode.h debug.h
+language.32.o: language.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 localize.32.o: localize.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 localize.32.o: localize.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-localize.32.o: localize.c  i18n.h transcode.h ppd-private.h debug.h
+localize.32.o: localize.c  i18n.h transcode.h pwg-private.h ../cups/cups.h ppd-private.h
+localize.32.o: localize.c  debug.h
 mark.32.o: mark.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
-mark.32.o: mark.c  string.h ../config.h debug.h pwgmedia.h
+mark.32.o: mark.c  string.h ../config.h debug.h pwg-private.h ../cups/cups.h
 md5.32.o: md5.c  md5.h string.h ../config.h
 md5passwd.32.o: md5passwd.c  http-private.h ../config.h http.h versioning.h md5.h
 md5passwd.32.o: md5passwd.c  ipp-private.h ipp.h string.h
 notify.32.o: notify.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 notify.32.o: notify.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-notify.32.o: notify.c  i18n.h transcode.h
+notify.32.o: notify.c  i18n.h transcode.h pwg-private.h ../cups/cups.h
 options.32.o: options.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
 options.32.o: options.c  string.h ../config.h debug.h
 page.32.o: page.c  ppd.h array.h versioning.h file.h string.h ../config.h debug.h
 ppd.32.o: ppd.c  ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h file.h
-ppd.32.o: ppd.c  language.h globals.h string.h ../config.h http-private.h md5.h
-ppd.32.o: ppd.c  ipp-private.h i18n.h transcode.h debug.h
-pwgmedia.32.o: pwgmedia.c  pwgmedia.h globals.h string.h ../config.h http-private.h http.h
-pwgmedia.32.o: pwgmedia.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-pwgmedia.32.o: pwgmedia.c  file.h language.h i18n.h transcode.h debug.h
+ppd.32.o: ppd.c  language.h pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+ppd.32.o: ppd.c  http-private.h md5.h ipp-private.h i18n.h transcode.h debug.h
+pwg-file.32.o: pwg-file.c  pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-file.32.o: pwg-file.c  http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-file.32.o: pwg-file.c  cups.h ppd.h array.h file.h language.h i18n.h transcode.h debug.h
+pwg-media.32.o: pwg-media.c  pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-media.32.o: pwg-media.c  http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-media.32.o: pwg-media.c  cups.h ppd.h array.h file.h language.h i18n.h transcode.h
+pwg-media.32.o: pwg-media.c  debug.h
+pwg-ppd.32.o: pwg-ppd.c  pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-ppd.32.o: pwg-ppd.c  http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-ppd.32.o: pwg-ppd.c  cups.h ppd.h array.h file.h language.h i18n.h transcode.h debug.h
 request.32.o: request.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 request.32.o: request.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-request.32.o: request.c  i18n.h transcode.h debug.h
+request.32.o: request.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 sidechannel.32.o: sidechannel.c  sidechannel.h versioning.h string.h ../config.h debug.h
 snmp.32.o: snmp.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 snmp.32.o: snmp.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-snmp.32.o: snmp.c  i18n.h transcode.h debug.h snmp-private.h
+snmp.32.o: snmp.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
+snmp.32.o: snmp.c  snmp-private.h
 snprintf.32.o: snprintf.c  string.h ../config.h
 string.32.o: string.c  array.h versioning.h debug.h string.h ../config.h
 tempfile.32.o: tempfile.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 tempfile.32.o: tempfile.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-tempfile.32.o: tempfile.c  i18n.h transcode.h debug.h
+tempfile.32.o: tempfile.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 transcode.32.o: transcode.c  globals.h string.h ../config.h http-private.h http.h
 transcode.32.o: transcode.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-transcode.32.o: transcode.c  file.h language.h i18n.h transcode.h debug.h
+transcode.32.o: transcode.c  file.h language.h i18n.h transcode.h pwg-private.h
+transcode.32.o: transcode.c  ../cups/cups.h debug.h
 usersys.32.o: usersys.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 usersys.32.o: usersys.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-usersys.32.o: usersys.c  i18n.h transcode.h debug.h
+usersys.32.o: usersys.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 util.32.o: util.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 util.32.o: util.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-util.32.o: util.c  i18n.h transcode.h debug.h
+util.32.o: util.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 testadmin.32.o: testadmin.c  adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h
 testadmin.32.o: testadmin.c  file.h language.h string.h ../config.h
 testarray.32.o: testarray.c  ../cups/string.h ../config.h string.h array.h versioning.h dir.h
@@ -259,119 +297,138 @@ testoptions.32.o: testoptions.c  string.h ../config.h cups.h ipp.h http.h versio
 testoptions.32.o: testoptions.c  array.h file.h language.h
 testlang.32.o: testlang.c  i18n.h transcode.h language.h array.h versioning.h string.h
 testlang.32.o: testlang.c  ../config.h
-testppd.32.o: testppd.c  ../cups/string.h ../config.h string.h cups.h ipp.h http.h
-testppd.32.o: testppd.c  versioning.h ppd.h array.h file.h language.h pwgmedia.h
+testppd.32.o: testppd.c  ../cups/cups.h ../cups/string.h ../config.h string.h
+testpwg.32.o: testpwg.c  pwg-private.h ../cups/cups.h
 testsnmp.32.o: testsnmp.c  string.h ../config.h snmp-private.h http.h versioning.h
 # DO NOT DELETE
 
 adminutil.64.o: adminutil.c  adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h
 adminutil.64.o: adminutil.c  file.h language.h globals.h string.h ../config.h http-private.h
-adminutil.64.o: adminutil.c  md5.h ipp-private.h i18n.h transcode.h debug.h
+adminutil.64.o: adminutil.c  md5.h ipp-private.h i18n.h transcode.h pwg-private.h
+adminutil.64.o: adminutil.c  ../cups/cups.h debug.h
 array.64.o: array.c  array.h versioning.h string.h ../config.h debug.h
 attr.64.o: attr.c  ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h file.h
 attr.64.o: attr.c  language.h debug.h string.h ../config.h
 auth.64.o: auth.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 auth.64.o: auth.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-auth.64.o: auth.c  i18n.h transcode.h debug.h
+auth.64.o: auth.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 backchannel.64.o: backchannel.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h
 backchannel.64.o: backchannel.c  language.h
 backend.64.o: backend.c  backend.h versioning.h globals.h string.h ../config.h
 backend.64.o: backend.c  http-private.h http.h md5.h ipp-private.h ipp.h cups.h ppd.h
-backend.64.o: backend.c  array.h file.h language.h i18n.h transcode.h
+backend.64.o: backend.c  array.h file.h language.h i18n.h transcode.h pwg-private.h
+backend.64.o: backend.c  ../cups/cups.h
 conflicts.64.o: conflicts.c  ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h
 conflicts.64.o: conflicts.c  file.h language.h string.h ../config.h debug.h
 custom.64.o: custom.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 custom.64.o: custom.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-custom.64.o: custom.c  i18n.h transcode.h debug.h
+custom.64.o: custom.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 debug.64.o: debug.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 debug.64.o: debug.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-debug.64.o: debug.c  i18n.h transcode.h debug.h
+debug.64.o: debug.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 dest.64.o: dest.c  debug.h globals.h string.h ../config.h http-private.h http.h
 dest.64.o: dest.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h
-dest.64.o: dest.c  language.h i18n.h transcode.h pwgmedia.h
+dest.64.o: dest.c  language.h i18n.h transcode.h pwg-private.h ../cups/cups.h
 dir.64.o: dir.c  dir.h versioning.h string.h ../config.h debug.h
 emit.64.o: emit.c  ppd.h array.h versioning.h file.h string.h ../config.h debug.h
 encode.64.o: encode.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
 encode.64.o: encode.c  ipp-private.h string.h ../config.h debug.h
 file.64.o: file.c  file-private.h http-private.h ../config.h http.h versioning.h md5.h
 file.64.o: file.c  ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h file.h
-file.64.o: file.c  language.h i18n.h transcode.h debug.h
+file.64.o: file.c  language.h i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 getdevices.64.o: getdevices.c  globals.h string.h ../config.h http-private.h http.h
 getdevices.64.o: getdevices.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-getdevices.64.o: getdevices.c  file.h language.h i18n.h transcode.h debug.h
+getdevices.64.o: getdevices.c  file.h language.h i18n.h transcode.h pwg-private.h
+getdevices.64.o: getdevices.c  ../cups/cups.h debug.h
 getifaddrs.64.o: getifaddrs.c  http-private.h ../config.h http.h versioning.h md5.h
 getifaddrs.64.o: getifaddrs.c  ipp-private.h ipp.h
 getputfile.64.o: getputfile.c  globals.h string.h ../config.h http-private.h http.h
 getputfile.64.o: getputfile.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-getputfile.64.o: getputfile.c  file.h language.h i18n.h transcode.h debug.h
+getputfile.64.o: getputfile.c  file.h language.h i18n.h transcode.h pwg-private.h
+getputfile.64.o: getputfile.c  ../cups/cups.h debug.h
 globals.64.o: globals.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 globals.64.o: globals.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-globals.64.o: globals.c  i18n.h transcode.h
+globals.64.o: globals.c  i18n.h transcode.h pwg-private.h ../cups/cups.h
 http.64.o: http.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 http.64.o: http.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-http.64.o: http.c  i18n.h transcode.h debug.h
+http.64.o: http.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 http-addr.64.o: http-addr.c  http-private.h ../config.h http.h versioning.h md5.h
 http-addr.64.o: http-addr.c  ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h
-http-addr.64.o: http-addr.c  file.h language.h i18n.h transcode.h debug.h
+http-addr.64.o: http-addr.c  file.h language.h i18n.h transcode.h pwg-private.h
+http-addr.64.o: http-addr.c  ../cups/cups.h debug.h
 http-addrlist.64.o: http-addrlist.c  http-private.h ../config.h http.h versioning.h md5.h
 http-addrlist.64.o: http-addrlist.c  ipp-private.h ipp.h globals.h string.h cups.h ppd.h array.h
-http-addrlist.64.o: http-addrlist.c  file.h language.h i18n.h transcode.h debug.h
+http-addrlist.64.o: http-addrlist.c  file.h language.h i18n.h transcode.h pwg-private.h
+http-addrlist.64.o: http-addrlist.c  ../cups/cups.h debug.h
 http-support.64.o: http-support.c  debug.h globals.h string.h ../config.h http-private.h http.h
 http-support.64.o: http-support.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-http-support.64.o: http-support.c  file.h language.h i18n.h transcode.h
+http-support.64.o: http-support.c  file.h language.h i18n.h transcode.h pwg-private.h
+http-support.64.o: http-support.c  ../cups/cups.h
 ipp.64.o: ipp.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 ipp.64.o: ipp.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h i18n.h
-ipp.64.o: ipp.c  transcode.h debug.h
+ipp.64.o: ipp.c  transcode.h pwg-private.h ../cups/cups.h debug.h
 ipp-support.64.o: ipp-support.c  globals.h string.h ../config.h http-private.h http.h
 ipp-support.64.o: ipp-support.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-ipp-support.64.o: ipp-support.c  file.h language.h i18n.h transcode.h debug.h
+ipp-support.64.o: ipp-support.c  file.h language.h i18n.h transcode.h pwg-private.h
+ipp-support.64.o: ipp-support.c  ../cups/cups.h debug.h
 langprintf.64.o: langprintf.c  globals.h string.h ../config.h http-private.h http.h
 langprintf.64.o: langprintf.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-langprintf.64.o: langprintf.c  file.h language.h i18n.h transcode.h
+langprintf.64.o: langprintf.c  file.h language.h i18n.h transcode.h pwg-private.h
+langprintf.64.o: langprintf.c  ../cups/cups.h
 language.64.o: language.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 language.64.o: language.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-language.64.o: language.c  i18n.h transcode.h debug.h
+language.64.o: language.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 localize.64.o: localize.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 localize.64.o: localize.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-localize.64.o: localize.c  i18n.h transcode.h ppd-private.h debug.h
+localize.64.o: localize.c  i18n.h transcode.h pwg-private.h ../cups/cups.h ppd-private.h
+localize.64.o: localize.c  debug.h
 mark.64.o: mark.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
-mark.64.o: mark.c  string.h ../config.h debug.h pwgmedia.h
+mark.64.o: mark.c  string.h ../config.h debug.h pwg-private.h ../cups/cups.h
 md5.64.o: md5.c  md5.h string.h ../config.h
 md5passwd.64.o: md5passwd.c  http-private.h ../config.h http.h versioning.h md5.h
 md5passwd.64.o: md5passwd.c  ipp-private.h ipp.h string.h
 notify.64.o: notify.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 notify.64.o: notify.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-notify.64.o: notify.c  i18n.h transcode.h
+notify.64.o: notify.c  i18n.h transcode.h pwg-private.h ../cups/cups.h
 options.64.o: options.c  cups.h ipp.h http.h versioning.h ppd.h array.h file.h language.h
 options.64.o: options.c  string.h ../config.h debug.h
 page.64.o: page.c  ppd.h array.h versioning.h file.h string.h ../config.h debug.h
 ppd.64.o: ppd.c  ppd-private.h cups.h ipp.h http.h versioning.h ppd.h array.h file.h
-ppd.64.o: ppd.c  language.h globals.h string.h ../config.h http-private.h md5.h
-ppd.64.o: ppd.c  ipp-private.h i18n.h transcode.h debug.h
-pwgmedia.64.o: pwgmedia.c  pwgmedia.h globals.h string.h ../config.h http-private.h http.h
-pwgmedia.64.o: pwgmedia.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-pwgmedia.64.o: pwgmedia.c  file.h language.h i18n.h transcode.h debug.h
+ppd.64.o: ppd.c  language.h pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+ppd.64.o: ppd.c  http-private.h md5.h ipp-private.h i18n.h transcode.h debug.h
+pwg-file.64.o: pwg-file.c  pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-file.64.o: pwg-file.c  http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-file.64.o: pwg-file.c  cups.h ppd.h array.h file.h language.h i18n.h transcode.h debug.h
+pwg-media.64.o: pwg-media.c  pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-media.64.o: pwg-media.c  http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-media.64.o: pwg-media.c  cups.h ppd.h array.h file.h language.h i18n.h transcode.h
+pwg-media.64.o: pwg-media.c  debug.h
+pwg-ppd.64.o: pwg-ppd.c  pwg-private.h ../cups/cups.h globals.h string.h ../config.h
+pwg-ppd.64.o: pwg-ppd.c  http-private.h http.h versioning.h md5.h ipp-private.h ipp.h
+pwg-ppd.64.o: pwg-ppd.c  cups.h ppd.h array.h file.h language.h i18n.h transcode.h debug.h
 request.64.o: request.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 request.64.o: request.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-request.64.o: request.c  i18n.h transcode.h debug.h
+request.64.o: request.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 sidechannel.64.o: sidechannel.c  sidechannel.h versioning.h string.h ../config.h debug.h
 snmp.64.o: snmp.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 snmp.64.o: snmp.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-snmp.64.o: snmp.c  i18n.h transcode.h debug.h snmp-private.h
+snmp.64.o: snmp.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
+snmp.64.o: snmp.c  snmp-private.h
 snprintf.64.o: snprintf.c  string.h ../config.h
 string.64.o: string.c  array.h versioning.h debug.h string.h ../config.h
 tempfile.64.o: tempfile.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 tempfile.64.o: tempfile.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-tempfile.64.o: tempfile.c  i18n.h transcode.h debug.h
+tempfile.64.o: tempfile.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 transcode.64.o: transcode.c  globals.h string.h ../config.h http-private.h http.h
 transcode.64.o: transcode.c  versioning.h md5.h ipp-private.h ipp.h cups.h ppd.h array.h
-transcode.64.o: transcode.c  file.h language.h i18n.h transcode.h debug.h
+transcode.64.o: transcode.c  file.h language.h i18n.h transcode.h pwg-private.h
+transcode.64.o: transcode.c  ../cups/cups.h debug.h
 usersys.64.o: usersys.c  http-private.h ../config.h http.h versioning.h md5.h ipp-private.h
 usersys.64.o: usersys.c  ipp.h globals.h string.h cups.h ppd.h array.h file.h language.h
-usersys.64.o: usersys.c  i18n.h transcode.h debug.h
+usersys.64.o: usersys.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 util.64.o: util.c  globals.h string.h ../config.h http-private.h http.h versioning.h
 util.64.o: util.c  md5.h ipp-private.h ipp.h cups.h ppd.h array.h file.h language.h
-util.64.o: util.c  i18n.h transcode.h debug.h
+util.64.o: util.c  i18n.h transcode.h pwg-private.h ../cups/cups.h debug.h
 testadmin.64.o: testadmin.c  adminutil.h cups.h ipp.h http.h versioning.h ppd.h array.h
 testadmin.64.o: testadmin.c  file.h language.h string.h ../config.h
 testarray.64.o: testarray.c  ../cups/string.h ../config.h string.h array.h versioning.h dir.h
@@ -391,6 +448,6 @@ testoptions.64.o: testoptions.c  string.h ../config.h cups.h ipp.h http.h versio
 testoptions.64.o: testoptions.c  array.h file.h language.h
 testlang.64.o: testlang.c  i18n.h transcode.h language.h array.h versioning.h string.h
 testlang.64.o: testlang.c  ../config.h
-testppd.64.o: testppd.c  ../cups/string.h ../config.h string.h cups.h ipp.h http.h
-testppd.64.o: testppd.c  versioning.h ppd.h array.h file.h language.h pwgmedia.h
+testppd.64.o: testppd.c  ../cups/cups.h ../cups/string.h ../config.h string.h
+testpwg.64.o: testpwg.c  pwg-private.h ../cups/cups.h
 testsnmp.64.o: testsnmp.c  string.h ../config.h snmp-private.h http.h versioning.h
index b7e9a8d8a71e31856f41d0c9bfcf9ed33f7236e0..ef408df24692418fdc28d448c46db0162b55ed68 100644 (file)
@@ -56,7 +56,9 @@ LIBOBJS       =       \
                options.o \
                page.o \
                ppd.o \
-               pwgmedia.o \
+               pwg-file.o \
+               pwg-media.o \
+               pwg-ppd.o \
                request.o \
                sidechannel.o \
                snmp.o \
@@ -83,6 +85,7 @@ OBJS  =       \
                testoptions.o \
                testlang.o \
                testppd.o \
+               testpwg.o \
                testsnmp.o \
                php_cups_wrap.o
 
@@ -130,6 +133,7 @@ UNITTARGETS =       \
                testlang \
                testoptions \
                testppd \
+               testpwg \
                testsnmp
 
 TARGETS        =       \
@@ -505,6 +509,18 @@ testppd:   testppd.o $(LIBCUPSSTATIC) test.ppd test2.ppd
        ./testppd
 
 
+#
+# testpwg (dependency on static CUPS library is intentional)
+#
+
+testpwg:       testpwg.o $(LIBCUPSSTATIC) test.ppd
+       echo Linking $@...
+       $(CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testpwg.o $(LIBCUPSSTATIC) \
+               $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
+       echo Running PWG API tests...
+       ./testpwg test.ppd
+
+
 #
 # testsnmp (dependency on static CUPS library is intentional)
 #
index 52f70765d81a1b6bbbfa80e6533dbed2d8981d5b..3be7130875768cbd2ff27ccb5d97da68cb1377a9 100644 (file)
@@ -53,7 +53,7 @@
 
 #include "debug.h"
 #include "globals.h"
-#include "pwgmedia.h"
+#include "pwg-private.h"
 #include <stdlib.h>
 #include <ctype.h>
 #include <sys/stat.h>
@@ -1095,8 +1095,8 @@ static char *                             /* O - Default paper size */
 appleGetPaperSize(char *name,          /* I - Paper size name buffer */
                   int  namesize)       /* I - Size of buffer */
 {
-  CFStringRef          defaultPaperID; /* Default paper ID */
-  _cups_pwg_media_t    *pwgmedia;      /* PWG media size */
+  CFStringRef  defaultPaperID;         /* Default paper ID */
+  _pwg_media_t *pwgmedia;              /* PWG media size */
 
 
   defaultPaperID = CFPreferencesCopyAppValue(kDefaultPaperIDKey,
@@ -1106,7 +1106,7 @@ appleGetPaperSize(char *name,             /* I - Paper size name buffer */
       !CFStringGetCString(defaultPaperID, name, namesize,
                          kCFStringEncodingUTF8))
     name[0] = '\0';
-  else if ((pwgmedia = _cupsPWGMediaByLegacy(name)) != NULL)
+  else if ((pwgmedia = _pwgMediaForLegacy(name)) != NULL)
     strlcpy(name, pwgmedia->pwg, namesize);
 
   if (defaultPaperID)
index 1e07daac64f854d111ba0081f8e57cae19edac25..0b599987e7d098ce0a72567f03a943dec80baa23 100644 (file)
@@ -26,6 +26,7 @@
 #  include "http-private.h"
 #  include "cups.h"
 #  include "i18n.h"
+#  include "pwg-private.h"
 
 #  ifdef HAVE_PTHREAD_H
 #    include <pthread.h>
@@ -103,9 +104,12 @@ typedef struct _cups_globals_s             /**** CUPS global state data ****/
   int                  ppd_line;       /* Current line number */
   ppd_conform_t                ppd_conform;    /* Level of conformance required */
 
-  /* pwgmedia.c */
-  cups_array_t         *pwg_size_lut,  /* Lookup table for PWG names */
-                       *leg_size_lut;  /* Lookup table for legacy names */
+  /* pwg-media.c */
+  cups_array_t         *leg_size_lut,  /* Lookup table for legacy names */
+                       *ppd_size_lut,  /* Lookup table for PPD names */
+                       *pwg_size_lut;  /* Lookup table for PWG names */
+  _pwg_media_t         pwg_media;      /* PWG media data for custom size */
+  char                 pwg_name[65];   /* PWG media name for custom size */
 
   /* snmp.c */
   char                 snmp_community[255];
index 14349a1f9fb1150388f8472843e86530663827ab..a9b5124e34a7809d4ad4cb8caeac024856ab6814 100644 (file)
@@ -34,8 +34,6 @@
  *   ppd_mark_choices()    - Mark one or more option choices from a string.
  *   ppd_mark_option()     - Quickly mark an option without checking for
  *                           conflicts.
- *   ppd_mark_size()       - Quickly mark a page size without checking for
- *                           conflicts.
  */
 
 /*
@@ -45,7 +43,7 @@
 #include "cups.h"
 #include "string.h"
 #include "debug.h"
-#include "pwgmedia.h"
+#include "pwg-private.h"
 
 
 /*
@@ -61,7 +59,6 @@ static void   ppd_defaults(ppd_file_t *ppd, ppd_group_t *g);
 static void    ppd_mark_choices(ppd_file_t *ppd, const char *s);
 static void    ppd_mark_option(ppd_file_t *ppd, const char *option,
                                const char *choice);
-static void    ppd_mark_size(ppd_file_t *ppd, const char *size);
 
 
 /*
@@ -83,8 +80,8 @@ cupsMarkOptions(
                s[255];                 /* Temporary string */
   const char   *val,                   /* Pointer into value */
                *media,                 /* media option */
-               *media_col,             /* media-col option */
-               *page_size;             /* PageSize option */
+               *page_size,             /* PageSize option */
+               *ppd_keyword;           /* PPD keyword */
   cups_option_t        *optptr;                /* Current option */
   ppd_option_t *option;                /* PPD option */
   ppd_attr_t   *attr;                  /* PPD attribute */
@@ -125,66 +122,21 @@ cupsMarkOptions(
   ppd_debug_marked(ppd, "Before...");
 
  /*
-  * Do special handling for media, media-col, and PageSize...
+  * Do special handling for media and PageSize...
   */
 
   media     = cupsGetOption("media", num_options, options);
-  media_col = cupsGetOption("media-col", num_options, options);
   page_size = cupsGetOption("PageSize", num_options, options);
 
-  if (media_col && (!page_size || !page_size[0]))
+  if (media)
   {
    /*
-    * Pull out the corresponding media size from the media-col value...
+    * Load PWG mapping data as needed...
     */
 
-    int                        num_media_cols, /* Number of media-col values */
-                       num_media_sizes;/* Number of media-size values */
-    cups_option_t      *media_cols,    /* media-col values */
-                       *media_sizes;   /* media-size values */
-
-
-    num_media_cols = cupsParseOptions(media_col, 0, &media_cols);
-
-    if ((val = cupsGetOption("media-size", num_media_cols,
-                            media_cols)) != NULL)
-    {
-     /*
-      * Lookup by dimensions...
-      */
-
-      double           width,          /* Width in points */
-                       length;         /* Length in points */
-      struct lconv     *loc;           /* Locale data */
-      _cups_pwg_media_t        *pwgmedia;      /* PWG media name */
-
-
-      num_media_sizes = cupsParseOptions(val, 0, &media_sizes);
-      loc             = localeconv();
-
-      if ((val = cupsGetOption("media-x-dimension", num_media_sizes,
-                               media_sizes)) != NULL)
-        width = _cupsStrScand(val, NULL, loc) * 72.0 / 2540.0;
-      else
-        width = 0.0;
-
-      if ((val = cupsGetOption("media-y-dimension", num_media_sizes,
-                               media_sizes)) != NULL)
-        length = _cupsStrScand(val, NULL, loc) * 72.0 / 2540.0;
-      else
-        length = 0.0;
-
-      if ((pwgmedia = _cupsPWGMediaBySize(width, length)) != NULL)
-        media = pwgmedia->pwg;
-
-      cupsFreeOptions(num_media_sizes, media_sizes);
-    }
-
-    cupsFreeOptions(num_media_cols, media_cols);
-  }
+    if (!ppd->pwg)
+      ppd->pwg = _pwgCreateWithPPD(ppd);
 
-  if (media)
-  {
    /*
     * Loop through the option string, separating it at commas and
     * marking each individual option as long as the corresponding
@@ -212,27 +164,18 @@ cupsMarkOptions(
       * Mark it...
       */
 
-      if (!page_size || !page_size[0])
-       ppd_mark_size(ppd, s);
-
-      if (cupsGetOption("InputSlot", num_options, options) == NULL)
-       ppd_mark_option(ppd, "InputSlot", s);
-
-      if (cupsGetOption("MediaColor", num_options, options) == NULL)
-       ppd_mark_option(ppd, "MediaColor", s);
-
-      if (cupsGetOption("MediaType", num_options, options) == NULL)
-       ppd_mark_option(ppd, "MediaType", s);
-
-      if (cupsGetOption("EFMediaType", num_options, options) == NULL)
-       ppd_mark_option(ppd, "EFMediaType", s);         /* EFI */
+      if ((!page_size || !page_size[0]) &&
+         (ppd_keyword = _pwgGetPageSize((_pwg_t *)ppd->pwg, NULL, s,
+                                        NULL)) != NULL)
+       ppd_mark_option(ppd, "PageSize", ppd_keyword);
 
-      if (cupsGetOption("EFMediaQualityMode", num_options, options) == NULL)
-       ppd_mark_option(ppd, "EFMediaQualityMode", s);  /* EFI */
+      if (!cupsGetOption("InputSlot", num_options, options) &&
+         (ppd_keyword = _pwgGetInputSlot((_pwg_t *)ppd->pwg, NULL, s)) != NULL)
+       ppd_mark_option(ppd, "InputSlot", ppd_keyword);
 
-      if (!strcasecmp(s, "manual") &&
-         !cupsGetOption("ManualFeed", num_options, options))
-       ppd_mark_option(ppd, "ManualFeed", "True");
+      if (!cupsGetOption("MediaType", num_options, options) &&
+         (ppd_keyword = _pwgGetMediaType((_pwg_t *)ppd->pwg, NULL, s)) != NULL)
+       ppd_mark_option(ppd, "MediaType", ppd_keyword);
     }
   }
 
@@ -241,8 +184,7 @@ cupsMarkOptions(
   */
 
   for (i = num_options, optptr = options; i > 0; i --, optptr ++)
-    if (!strcasecmp(optptr->name, "media") ||
-        !strcasecmp(optptr->name, "media-col"))
+    if (!strcasecmp(optptr->name, "media"))
       continue;
     else if (!strcasecmp(optptr->name, "sides"))
     {
index 71817b6136285ff68371a59e4ac31998706ff697..bf4fd862c62ff879a530c1b52a9839f6155ecdc7 100644 (file)
@@ -44,7 +44,7 @@ ppdPageSize(ppd_file_t *ppd,          /* I - PPD file record */
 {
   int          i;                      /* Looping var */
   ppd_size_t   *size;                  /* Current page size */
-  float                w, l;                   /* Width and length of page */
+  double       w, l;                   /* Width and length of page */
   char         *nameptr;               /* Pointer into name */
   struct lconv *loc;                   /* Locale data */
   ppd_coption_t        *coption;               /* Custom option for page size */
@@ -81,52 +81,54 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       * Variable size; size name can be one of the following:
       *
       *    Custom.WIDTHxLENGTHin    - Size in inches
+      *    Custom.WIDTHxLENGTHft    - Size in feet
       *    Custom.WIDTHxLENGTHcm    - Size in centimeters
       *    Custom.WIDTHxLENGTHmm    - Size in millimeters
+      *    Custom.WIDTHxLENGTHm     - Size in meters
       *    Custom.WIDTHxLENGTH[pt]  - Size in points
       */
 
       loc = localeconv();
-      w   = (float)_cupsStrScand(name + 7, &nameptr, loc);
+      w   = _cupsStrScand(name + 7, &nameptr, loc);
       if (!nameptr || *nameptr != 'x')
         return (NULL);
 
-      l = (float)_cupsStrScand(nameptr + 1, &nameptr, loc);
+      l = _cupsStrScand(nameptr + 1, &nameptr, loc);
       if (!nameptr)
         return (NULL);
 
       if (!strcasecmp(nameptr, "in"))
       {
-        w *= 72.0f;
-       l *= 72.0f;
+        w *= 72.0;
+       l *= 72.0;
       }
       else if (!strcasecmp(nameptr, "ft"))
       {
-        w *= 12.0f * 72.0f;
-       l *= 12.0f * 72.0f;
+        w *= 12.0 * 72.0;
+       l *= 12.0 * 72.0;
       }
       else if (!strcasecmp(nameptr, "mm"))
       {
-        w *= 72.0f / 25.4f;
-        l *= 72.0f / 25.4f;
+        w *= 72.0 / 25.4;
+        l *= 72.0 / 25.4;
       }
       else if (!strcasecmp(nameptr, "cm"))
       {
-        w *= 72.0f / 2.54f;
-        l *= 72.0f / 2.54f;
+        w *= 72.0 / 2.54;
+        l *= 72.0 / 2.54;
       }
       else if (!strcasecmp(nameptr, "m"))
       {
-        w *= 72.0f / 0.0254f;
-        l *= 72.0f / 0.0254f;
+        w *= 72.0 / 0.0254;
+        l *= 72.0 / 0.0254;
       }
 
-      size->width  = w;
-      size->length = l;
+      size->width  = (float)w;
+      size->length = (float)l;
       size->left   = ppd->custom_margins[0];
       size->bottom = ppd->custom_margins[1];
-      size->right  = w - ppd->custom_margins[2];
-      size->top    = l - ppd->custom_margins[3];
+      size->right  = (float)(w - ppd->custom_margins[2]);
+      size->top    = (float)(l - ppd->custom_margins[3]);
 
      /*
       * Update the custom option records for the page size, too...
index 6fe2dc7768ec454c3392e07d32e08095e7478d7d..dbdaaf17aec4dfcbe599cc6b7879a40ce46231b6 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * "$Id: ppd.c 7906 2008-09-03 20:19:43Z mike $"
  *
- *   PPD file routines for the Common UNIX Printing System (CUPS).
+ *   PPD file routines for CUPS.
  *
- *   Copyright 2007-2009 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -60,6 +60,7 @@
  */
 
 #include "ppd-private.h"
+#include "pwg-private.h"
 #include "globals.h"
 #include "debug.h"
 #include <stdlib.h>
@@ -313,6 +314,13 @@ ppdClose(ppd_file_t *ppd)          /* I - PPD file record */
     cupsArrayDelete(ppd->cups_uiconstraints);
   }
 
+ /*
+  * Free any PWG mapping data...
+  */
+
+  if (ppd->pwg)
+    _pwgDestroy((_pwg_t *)ppd->pwg);
+
  /*
   * Free the whole record...
   */
index d0b8ec8f27e79d7029084c591d76e1b242079cf5..dfda690dc476623b1c9ea99fdf12bb427c2a7fd0 100644 (file)
@@ -1,10 +1,9 @@
 /*
  * "$Id: ppd.h 7791 2008-07-24 00:55:30Z mike $"
  *
- *   PostScript Printer Description definitions for the Common UNIX Printing
- *   System (CUPS).
+ *   PostScript Printer Description definitions for CUPS.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -334,6 +333,9 @@ typedef struct ppd_file_s           /**** PPD File ****/
 
   /**** New in CUPS 1.4/Mac OS X 10.6 ****/
   cups_array_t *cups_uiconstraints;    /* cupsUIConstraints @since CUPS 1.4/Mac OS X 10.6@ @private@ */
+
+  /**** New in CUPS 1.5 ****/
+  void         *pwg;                   /* PWG to/from PPD mappings */
 } ppd_file_t;
 
 
diff --git a/cups/pwg-file.c b/cups/pwg-file.c
new file mode 100644 (file)
index 0000000..454edb0
--- /dev/null
@@ -0,0 +1,491 @@
+/*
+ * "$Id$"
+ *
+ *   PWG load/save API implementation for CUPS.
+ *
+ *   Copyright 2010 by Apple Inc.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ *   _pwgCreateWithFile() - Create PWG mapping data from a written file.
+ *   _pwgDestroy()        - Free all memory used for PWG mapping data.
+ *   _pwgWriteFile()      - Write PWG mapping data to a file.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "pwg-private.h"
+#include "globals.h"
+#include "string.h"
+#include "debug.h"
+#include <math.h>
+
+
+/*
+ * '_pwgCreateWithFile()' - Create PWG mapping data from a written file.
+ *
+ * Use the @link _pwgWriteFile@ function to write PWG mapping data to a file.
+ */
+
+_pwg_t *                               /* O - PWG mapping data */
+_pwgCreateWithFile(const char *filename)/* I - File to read */
+{
+  cups_file_t  *fp;                    /* File */
+  _pwg_t       *pwg;                   /* PWG mapping data */
+  _pwg_size_t  *size;                  /* Current size */
+  _pwg_map_t   *map;                   /* Current map */
+  int          linenum,                /* Current line number */
+               num_sizes,              /* Number of sizes in file */
+               num_sources,            /* Number of sources in file */
+               num_types;              /* Number of types in file */
+  char         line[512],              /* Current line */
+               *value,                 /* Pointer to value in line */
+               pwg_keyword[128],       /* PWG keyword */
+               ppd_keyword[PPD_MAX_NAME];
+                                       /* PPD keyword */
+
+
+  DEBUG_printf(("_pwgCreateWithFile(filename=\"%s\")", filename));
+
+ /*
+  * Range check input...
+  */
+
+  if (!filename)
+  {
+    _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+    return (NULL);
+  }
+
+ /*
+  * Open the file...
+  */
+
+  if ((fp = cupsFileOpen(filename, "r")) == NULL)
+  {
+    _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+    return (NULL);
+  }
+
+ /*
+  * Allocate the mapping data structure...
+  */
+
+  if ((pwg = calloc(1, sizeof(_pwg_t))) == NULL)
+  {
+    DEBUG_puts("_pwgCreateWithFile: Unable to allocate pwg_t.");
+    _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+    goto create_error;
+  }
+
+ /*
+  * Read the file...
+  */
+
+  linenum     = 0;
+  num_sizes   = 0;
+  num_sources = 0;
+  num_types   = 0;
+
+  while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
+  {
+    DEBUG_printf(("_pwgCreateWithFile: line=\"%s\", value=\"%s\", linenum=%d",
+                 line, value, linenum));
+
+    if (!value)
+    {
+      DEBUG_printf(("_pwgCreateWithFile: Missing value on line %d.", linenum));
+      _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+      goto create_error;
+    }
+    else if (!strcasecmp(line, "NumSizes"))
+    {
+      if (num_sizes > 0)
+      {
+        DEBUG_puts("_pwgCreateWithFile: NumSizes listed multiple times.");
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if ((num_sizes = atoi(value)) <= 0 || num_sizes > 65536)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad NumSizes value %d on line %d.",
+                     num_sizes, linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if ((pwg->sizes = calloc(num_sizes, sizeof(_pwg_size_t))) == NULL)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Unable to allocate %d sizes.",
+                     num_sizes));
+       _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+       goto create_error;
+      }
+    }
+    else if (!strcasecmp(line, "Size"))
+    {
+      if (pwg->num_sizes >= num_sizes)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Too many Size's on line %d.",
+                     linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      size = pwg->sizes + pwg->num_sizes;
+
+      if (sscanf(value, "%127s%40s%d%d%d%d%d%d", pwg_keyword, ppd_keyword,
+                &(size->width), &(size->length), &(size->left),
+                &(size->bottom), &(size->right), &(size->top)) != 8)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad Size on line %d.", linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      size->map.pwg = _cupsStrAlloc(pwg_keyword);
+      size->map.ppd = _cupsStrAlloc(ppd_keyword);
+
+      pwg->num_sizes ++;
+    }
+    else if (!strcasecmp(line, "CustomSize"))
+    {
+      if (pwg->custom_max_width > 0)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Too many CustomSize's on line %d.",
+                     linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if (sscanf(value, "%d%d%d%d%d%d%d%d", &(pwg->custom_max_width),
+                 &(pwg->custom_max_length), &(pwg->custom_min_width),
+                &(pwg->custom_min_length), &(pwg->custom_size.left),
+                &(pwg->custom_size.bottom), &(pwg->custom_size.right),
+                &(pwg->custom_size.top)) != 8)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad CustomSize on line %d.", linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
+                      pwg->custom_max_width, pwg->custom_max_length);
+      pwg->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
+
+      _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
+                      pwg->custom_min_width, pwg->custom_min_length);
+      pwg->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
+    }
+    else if (!strcasecmp(line, "NumSources"))
+    {
+      if (num_sources > 0)
+      {
+        DEBUG_puts("_pwgCreateWithFile: NumSources listed multiple times.");
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if ((num_sources = atoi(value)) <= 0 || num_sources > 65536)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad NumSources value %d on line %d.",
+                     num_sources, linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if ((pwg->sources = calloc(num_sources, sizeof(_pwg_map_t))) == NULL)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Unable to allocate %d sources.",
+                     num_sources));
+       _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+       goto create_error;
+      }
+    }
+    else if (!strcasecmp(line, "Source"))
+    {
+      if (sscanf(value, "%127s%40s", pwg_keyword, ppd_keyword) != 2)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad Source on line %d.", linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if (pwg->num_sources >= num_sources)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Too many Source's on line %d.",
+                     linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      map      = pwg->sources + pwg->num_sources;
+      map->pwg = _cupsStrAlloc(pwg_keyword);
+      map->ppd = _cupsStrAlloc(ppd_keyword);
+
+      pwg->num_sources ++;
+    }
+    else if (!strcasecmp(line, "NumTypes"))
+    {
+      if (num_types > 0)
+      {
+        DEBUG_puts("_pwgCreateWithFile: NumTypes listed multiple times.");
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if ((num_types = atoi(value)) <= 0 || num_types > 65536)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad NumTypes value %d on line %d.",
+                     num_types, linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if ((pwg->types = calloc(num_types, sizeof(_pwg_map_t))) == NULL)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Unable to allocate %d types.",
+                     num_types));
+       _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+       goto create_error;
+      }
+    }
+    else if (!strcasecmp(line, "Type"))
+    {
+      if (sscanf(value, "%127s%40s", pwg_keyword, ppd_keyword) != 2)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Bad Type on line %d.", linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      if (pwg->num_types >= num_types)
+      {
+        DEBUG_printf(("_pwgCreateWithFile: Too many Type's on line %d.",
+                     linenum));
+       _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+       goto create_error;
+      }
+
+      map      = pwg->types + pwg->num_types;
+      map->pwg = _cupsStrAlloc(pwg_keyword);
+      map->ppd = _cupsStrAlloc(ppd_keyword);
+
+      pwg->num_types ++;
+    }
+    else
+    {
+      DEBUG_printf(("_pwgCreateWithFile: Unknown %s on line %d.", line,
+                   linenum));
+      _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+      goto create_error;
+    }
+  }
+
+  if (pwg->num_sizes < num_sizes)
+  {
+    DEBUG_printf(("_pwgCreateWithFile: Not enough sizes (%d < %d).",
+                  pwg->num_sizes, num_sizes));
+    _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+    goto create_error;
+  }
+
+  if (pwg->num_sources < num_sources)
+  {
+    DEBUG_printf(("_pwgCreateWithFile: Not enough sources (%d < %d).",
+                  pwg->num_sources, num_sources));
+    _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+    goto create_error;
+  }
+
+  if (pwg->num_types < num_types)
+  {
+    DEBUG_printf(("_pwgCreateWithFile: Not enough types (%d < %d).",
+                  pwg->num_types, num_types));
+    _cupsSetError(IPP_INTERNAL_ERROR, _("Bad PWG mapping file."), 1);
+    goto create_error;
+  }
+
+  cupsFileClose(fp);
+
+  return (pwg);
+
+ /*
+  * If we get here the file was bad - free any data and return...
+  */
+
+  create_error:
+
+  cupsFileClose(fp);
+  _pwgDestroy(pwg);
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgDestroy()' - Free all memory used for PWG mapping data.
+ */
+
+void
+_pwgDestroy(_pwg_t *pwg)               /* I - PWG mapping data */
+{
+  int          i;                      /* Looping var */
+  _pwg_map_t   *map;                   /* Current map */
+  _pwg_size_t  *size;                  /* Current size */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!pwg)
+    return;
+
+ /*
+  * Free memory as needed...
+  */
+
+  if (pwg->sizes)
+  {
+    for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
+    {
+      _cupsStrFree(size->map.pwg);
+      _cupsStrFree(size->map.ppd);
+    }
+
+    free(pwg->sizes);
+  }
+
+  if (pwg->sources)
+  {
+    for (i = pwg->num_sources, map = pwg->sources; i > 0; i --, map ++)
+    {
+      _cupsStrFree(map->pwg);
+      _cupsStrFree(map->ppd);
+    }
+
+    free(pwg->sources);
+  }
+
+  if (pwg->types)
+  {
+    for (i = pwg->num_types, map = pwg->types; i > 0; i --, map ++)
+    {
+      _cupsStrFree(map->pwg);
+      _cupsStrFree(map->ppd);
+    }
+
+    free(pwg->types);
+  }
+
+  if (pwg->custom_max_keyword)
+    _cupsStrFree(pwg->custom_max_keyword);
+
+  if (pwg->custom_min_keyword)
+    _cupsStrFree(pwg->custom_min_keyword);
+
+  free(pwg);
+}
+
+
+/*
+ * '_pwgWriteFile()' - Write PWG mapping data to a file.
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+_pwgWriteFile(_pwg_t     *pwg,         /* I - PWG mapping data */
+              const char *filename)    /* I - File to write */
+{
+  int          i;                      /* Looping var */
+  cups_file_t  *fp;                    /* Output file */
+  _pwg_size_t  *size;                  /* Current size */
+  _pwg_map_t   *map;                   /* Current map */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!pwg || !filename)
+  {
+    _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0);
+    return (0);
+  }
+
+ /*
+  * Open the file and write with compression...
+  */
+
+  if ((fp = cupsFileOpen(filename, "w9")) == NULL)
+  {
+    _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno), 0);
+    return (0);
+  }
+
+ /*
+  * Standard header...
+  */
+
+  cupsFilePuts(fp, "#CUPS-PWGPPD\n");
+
+ /*
+  * Media sizes...
+  */
+
+  cupsFilePrintf(fp, "NumSizes %d\n", pwg->num_sizes);
+  for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
+    cupsFilePrintf(fp, "Size %s %s %d %d %d %d %d %d\n", size->map.pwg,
+                  size->map.ppd, size->width, size->length, size->left,
+                  size->bottom, size->right, size->top);
+  if (pwg->custom_max_width > 0)
+    cupsFilePrintf(fp, "CustomSize %d %d %d %d %d %d %d %d\n",
+                   pwg->custom_max_width, pwg->custom_max_length,
+                  pwg->custom_min_width, pwg->custom_min_length,
+                  pwg->custom_size.left, pwg->custom_size.bottom,
+                  pwg->custom_size.right, pwg->custom_size.top);
+
+ /*
+  * Media sources...
+  */
+
+  if (pwg->num_sources > 0)
+  {
+    cupsFilePrintf(fp, "NumSources %d\n", pwg->num_sources);
+    for (i = pwg->num_sources, map = pwg->sources; i > 0; i --, map ++)
+      cupsFilePrintf(fp, "Source %s %s\n", map->pwg, map->ppd);
+  }
+
+ /*
+  * Media types...
+  */
+
+  if (pwg->num_types > 0)
+  {
+    cupsFilePrintf(fp, "NumTypes %d\n", pwg->num_types);
+    for (i = pwg->num_types, map = pwg->types; i > 0; i --, map ++)
+      cupsFilePrintf(fp, "Type %s %s\n", map->pwg, map->ppd);
+  }
+
+ /*
+  * Close and return...
+  */
+
+  return (!cupsFileClose(fp));
+}
+
+
+/*
+ * End of "$Id$".
+ */
diff --git a/cups/pwg-media.c b/cups/pwg-media.c
new file mode 100644 (file)
index 0000000..fbd97f7
--- /dev/null
@@ -0,0 +1,688 @@
+/*
+ * "$Id$"
+ *
+ *   PWG media name API implementation for CUPS.
+ *
+ *   Copyright 2009-2010 by Apple Inc.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ *   _pwgGenerateSize()   - Generate a PWG size keyword.
+ *   _pwgInitSize()       - Initialize a PWG size using IPP job template
+ *                          attributes.
+ *   _pwgMediaForLegacy() - Find a PWG media size by ISO/IPP legacy name.
+ *   _pwgMediaForPPD()    - Find a PWG media size by Adobe PPD name.
+ *   _pwgMediaForPWG()    - Find a PWG media size by 5101.1 self-describing
+ *                          name.
+ *   _pwgMediaForSize()   - Get the PWG media name for a given size.
+ *   pwg_compare_legacy() - Compare two sizes using the legacy names.
+ *   pwg_compare_ppd()    - Compare two sizes using the PPD names.
+ *   pwg_compare_pwg()    - Compare two sizes using the PWG names.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "pwg-private.h"
+#include "globals.h"
+#include "string.h"
+#include "debug.h"
+#include <math.h>
+
+
+/*
+ * Local macros...
+ */
+
+#define _PWG_MEDIA_IN(p,l,a,x,y) {p, l, a, (int)(x * 2540), (int)(y * 2540)}
+#define _PWG_MEDIA_MM(p,l,a,x,y) {p, l, a, (int)(x * 100), (int)(y * 100)}
+
+
+/*
+ * Local functions...
+ */
+
+static int     pwg_compare_legacy(_pwg_media_t *a, _pwg_media_t *b);
+static int     pwg_compare_pwg(_pwg_media_t *a, _pwg_media_t *b);
+static int     pwg_compare_ppd(_pwg_media_t *a, _pwg_media_t *b);
+
+
+/*
+ * Local globals...
+ */
+
+static _pwg_media_t const cups_pwg_media[] =
+{                                      /* Media size lookup table */
+  /* North American Standard Sheet Media Sizes */
+  _PWG_MEDIA_IN("na_index-3x5_3x5in", NULL, NULL, 3, 5),
+  _PWG_MEDIA_IN("na_personal_3.625x6.5in", NULL, "EnvPersonal", 3.625, 6.5),
+  _PWG_MEDIA_IN("na_monarch_3.875x7.5in", "monarch-envelope", "EnvMonarch", 3.875, 7.5),
+  _PWG_MEDIA_IN("na_number-9_3.875x8.875in", "na-number-9-envelope", "Env9", 3.875, 8.875),
+  _PWG_MEDIA_IN("na_index-4x6_4x6in", NULL, NULL, 4, 6),
+  _PWG_MEDIA_IN("na_number-10_4.125x9.5in", "na-number-10-envelope", "Env10", 4.125, 9.5),
+  _PWG_MEDIA_IN("na_a2_4.375x5.75in", NULL, NULL, 4.375, 5.75),
+  _PWG_MEDIA_IN("na_number-11_4.5x10.375in", NULL, "Env11", 4.5, 10.375),
+  _PWG_MEDIA_IN("na_number-12_4.75x11in", NULL, "Env12", 4.75, 11),
+  _PWG_MEDIA_IN("na_5x7_5x7in", NULL, NULL, 5, 7),
+  _PWG_MEDIA_IN("na_index-5x8_5x8in", NULL, NULL, 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, NULL, 6, 8),
+  _PWG_MEDIA_IN("na_6x9_6x9in", "na-6x9-envelope", NULL, 6, 9),
+  _PWG_MEDIA_IN("na_c5_6.5x9.5in", NULL, NULL, 6.5, 9.5),
+  _PWG_MEDIA_IN("na_7x9_7x9in", "na-7x9-envelope", "7x9", 7, 9),
+  _PWG_MEDIA_IN("na_executive_7.25x10.5in", "executive", "Executive", 7.25, 10.5),
+  _PWG_MEDIA_IN("na_govt-letter_8x10in", "na-8x10", "8x10", 8, 10),
+  _PWG_MEDIA_IN("na_govt-legal_8x13in", NULL, NULL, 8, 13),
+  _PWG_MEDIA_IN("na_quarto_8.5x10.83in", "quarto", "Quarto", 8.5, 10.83),
+  _PWG_MEDIA_IN("na_letter_8.5x11in", "na-letter", "Letter", 8.5, 11),
+  _PWG_MEDIA_IN("na_fanfold-eur_8.5x12in", NULL, "FanFoldGerman", 8.5, 12),
+  _PWG_MEDIA_IN("na_letter-plus_8.5x12.69in", NULL, "LetterPlus", 8.5, 12.69),
+  _PWG_MEDIA_IN("na_foolscap_8.5x13in", NULL, "FanFoldGermanLegal", 8.5, 13),
+  _PWG_MEDIA_IN("na_legal_8.5x14in", "na-legal", "Legal", 8.5, 14),
+  _PWG_MEDIA_IN("na_super-a_8.94x14in", NULL, "SuperA", 8.94, 14),
+  _PWG_MEDIA_IN("na_9x11_9x11in", "na-9x11-envelope", "9x11", 9, 11),
+  _PWG_MEDIA_IN("na_arch-a_9x12in", "arch-a", "ARCHA", 9, 12),
+  _PWG_MEDIA_IN("na_letter-extra_9.5x12in", NULL, "LetterExtra", 9.5, 12),
+  _PWG_MEDIA_IN("na_legal-extra_9.5x15in", NULL, "LegalExtra", 9.5, 15),
+  _PWG_MEDIA_IN("na_10x11_10x11in", NULL, "10x11", 10, 11),
+  _PWG_MEDIA_IN("na_10x13_10x13in", "na-10x13-envelope", "10x13", 10, 13),
+  _PWG_MEDIA_IN("na_10x14_10x14in", "na-10x14-envelope", "10x14", 10, 14),
+  _PWG_MEDIA_IN("na_10x15_10x15in", "na-10x15-envelope", NULL, 10, 15),
+  _PWG_MEDIA_IN("na_11x12_11x12in", NULL, NULL, 11, 12),
+  _PWG_MEDIA_IN("na_edp_11x14in", NULL, NULL, 11, 14),
+  _PWG_MEDIA_IN("na_fanfold-us_11x14.875in", NULL, NULL, 11, 14.875),
+  _PWG_MEDIA_IN("na_11x15_11x15in", NULL, NULL, 11, 15),
+  _PWG_MEDIA_IN("na_ledger_11x17in", "tabloid", "Tabloid", 11, 17),
+  _PWG_MEDIA_IN("na_eur-edp_12x14in", NULL, NULL, 12, 14),
+  _PWG_MEDIA_IN("na_arch-b_12x18in", "arch-b", "ARCHB", 12, 18),
+  _PWG_MEDIA_IN("na_12x19_12x19in", NULL, NULL, 12, 19),
+  _PWG_MEDIA_IN("na_b-plus_12x19.17in", NULL, "SuperB", 12, 19.17),
+  _PWG_MEDIA_IN("na_super-b_13x19in", NULL, NULL, 13, 19),
+  _PWG_MEDIA_IN("na_c_17x22in", "c", "AnsiC", 17, 22),
+  _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", 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, NULL, 44, 68),
+
+  /* Chinese Standard Sheet Media Inch Sizes */
+  _PWG_MEDIA_IN("roc_16k_7.75x10.75in", NULL, NULL, 7.75, 10.75),
+  _PWG_MEDIA_IN("roc_8k_10.75x15.5in", NULL, NULL, 10.75, 15.5),
+
+  /* ISO Standard Sheet Media Sizes */
+  _PWG_MEDIA_MM("iso_a10_26x37mm", "iso-a10", "A10", 26, 37),
+  _PWG_MEDIA_MM("iso_a9_37x52mm", "iso-a9", "A9", 37, 52),
+  _PWG_MEDIA_MM("iso_a8_52x74mm", "iso-a8", "A8", 52, 74),
+  _PWG_MEDIA_MM("iso_a7_74x105mm", "iso-a7", "A7", 74, 105),
+  _PWG_MEDIA_MM("iso_a6_105x148mm", "iso-a6", "A6", 105, 148),
+  _PWG_MEDIA_MM("iso_a5_148x210mm", "iso-a5", "A5", 148, 210),
+  _PWG_MEDIA_MM("iso_a5-extra_174x235mm", NULL, "A5Extra", 174, 235),
+  _PWG_MEDIA_MM("iso_a4_210x297mm", "iso-a4", "A4", 210, 297),
+  _PWG_MEDIA_MM("iso_a4-tab_225x297mm", NULL, NULL, 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", 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", 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", 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", 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, 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),
+  _PWG_MEDIA_MM("iso_b3_353x500mm", "iso-b3", "ISOB3", 353, 500),
+  _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", 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, 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),
+  _PWG_MEDIA_MM("iso_c4_229x324mm", "iso-c4", "EnvC4", 229, 324),
+  _PWG_MEDIA_MM("iso_c3_324x458mm", "iso-c3", "EnvC3", 324, 458),
+  _PWG_MEDIA_MM("iso_c2_458x648mm", "iso-c2", "EnvC2", 458, 648),
+  _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_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),
+  _PWG_MEDIA_MM("jis_b9_45x64mm", "jis-b9", "B9", 45, 64),
+  _PWG_MEDIA_MM("jis_b8_64x91mm", "jis-b8", "B8", 64, 91),
+  _PWG_MEDIA_MM("jis_b7_91x128mm", "jis-b7", "B7", 91, 128),
+  _PWG_MEDIA_MM("jis_b6_128x182mm", "jis-b6", "B6", 128, 182),
+  _PWG_MEDIA_MM("jis_b5_182x257mm", "jis-b5", "B5", 182, 257),
+  _PWG_MEDIA_MM("jis_b4_257x364mm", "jis-b4", "B4", 257, 364),
+  _PWG_MEDIA_MM("jis_b3_364x515mm", "jis-b3", "B3", 364, 515),
+  _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, NULL, 216, 330),
+  _PWG_MEDIA_MM("jpn_chou4_90x205mm", NULL, "EnvChou4", 90, 205),
+  _PWG_MEDIA_MM("jpn_hagaki_100x148mm", NULL, "Postcard", 100, 148),
+  _PWG_MEDIA_MM("jpn_you4_105x235mm", NULL, "EnvYou4", 105, 235),
+  _PWG_MEDIA_MM("jpn_chou2_111.1x146mm", NULL, NULL, 111.1, 146),
+  _PWG_MEDIA_MM("jpn_chou3_120x235mm", NULL, "EnvChou3", 120, 235),
+  _PWG_MEDIA_MM("jpn_oufuku_148x200mm", NULL, "DoublePostcardRotated", 148, 200),
+  _PWG_MEDIA_MM("jpn_kahu_240x322.1mm", NULL, NULL, 240, 322.1),
+  _PWG_MEDIA_MM("jpn_kaku2_240x332mm", NULL, "EnvKaku2", 240, 332),
+
+  /* Chinese Standard Sheet Media Sizes */
+  _PWG_MEDIA_MM("prc_32k_97x151mm", NULL, "PRC32K", 97, 151),
+  _PWG_MEDIA_MM("prc_1_102x165mm", NULL, "EnvPRC1", 102, 165),
+  _PWG_MEDIA_MM("prc_2_102x176mm", NULL, "EnvPRC2", 102, 176),
+  _PWG_MEDIA_MM("prc_4_110x208mm", NULL, "EnvPRC4", 110, 208),
+  _PWG_MEDIA_MM("prc_5_110x220mm", NULL, "EnvPRC5", 110, 220),
+  _PWG_MEDIA_MM("prc_8_120x309mm", NULL, "EnvPRC8", 120, 309),
+  _PWG_MEDIA_MM("prc_6_120x320mm", NULL, NULL, 120, 320),
+  _PWG_MEDIA_MM("prc_3_125x176mm", NULL, "EnvPRC3", 125, 176),
+  _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, 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),
+  _PWG_MEDIA_MM("prc_10_324x458mm", NULL, "EnvPRC10", 324, 458),
+
+  /* Other Metric Standard Sheet Media Sizes */
+  _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, NULL, 100, 150),
+  _PWG_MEDIA_MM("om_italian_110x230mm", NULL, "EnvItalian", 110, 230),
+  _PWG_MEDIA_MM("om_postfix_114x229mm", NULL, NULL, 114, 229),
+  _PWG_MEDIA_MM("om_large-photo_200x300", NULL, NULL, 200, 300),
+  _PWG_MEDIA_MM("om_folio_210x330mm", "folio", "Folio", 210, 330),
+  _PWG_MEDIA_MM("om_folio-sp_215x315mm", NULL, NULL, 215, 315),
+  _PWG_MEDIA_MM("om_invite_220x220mm", NULL, "EnvInvite", 220, 220)
+};
+
+
+/*
+ * '_pwgGenerateSize()' - Generate a PWG size keyword.
+ */
+
+void
+_pwgGenerateSize(char       *keyword,  /* I - Keyword buffer */
+                 size_t     keysize,   /* I - Size of keyword buffer */
+                const char *prefix,    /* I - Prefix for PWG size or NULL */
+                const char *name,      /* I - Size name or NULL */
+                int        width,      /* I - Width of page in 2540ths */
+                int        length)     /* I - Length of page in 2540ths */
+{
+  struct lconv *loc;                   /* Locale conversion data */
+  double       uwidth,                 /* Width in inches or millimeters */
+               ulength;                /* Height in inches or millimeters */
+  const char   *units;                 /* Units to report */
+  char         usize[12 + 1 + 12 + 3], /* Unit size: NNNNNNNNNNNNxNNNNNNNNNNNNuu */
+               *uptr;                  /* Pointer into unit size */
+
+
+  loc = localeconv();
+
+  if ((width % 635) == 0 && (length % 635) == 0)
+  {
+   /*
+    * Use inches since the size is a multiple of 1/4 inch.
+    */
+
+    uwidth  = width / 2540.0;
+    ulength = length / 2540.0;
+    units   = "in";
+
+    if (!prefix)
+      prefix = "oe";
+  }
+  else
+  {
+   /*
+    * Use millimeters since the size is not a multiple of 1/4 inch.
+    */
+
+    uwidth  = width * 0.01;
+    ulength = length * 0.01;
+    units   = "mm";
+
+    if (!prefix)
+      prefix = "om";
+  }
+
+  uptr = usize;
+  _cupsStrFormatd(uptr, uptr + 12, uwidth, loc);
+  uptr += strlen(uptr);
+  *uptr++ = 'x';
+  _cupsStrFormatd(uptr, uptr + 12, ulength, loc);
+  uptr += strlen(uptr);
+
+ /*
+  * Safe because usize can hold up to 12 + 1 + 12 + 4 bytes.
+  */
+
+  strcpy(uptr, units);
+
+  if (!name)
+    name = usize;
+
+ /*
+  * Format the name...
+  */
+
+  snprintf(keyword, keysize, "%s_%s_%s", prefix, name, usize);
+}
+
+
+/*
+ * '_pwgInitSize()' - Initialize a PWG size using IPP job template attributes.
+ */
+
+int                                    /* O - 1 if size was initialize, 0 otherwise */
+_pwgInitSize(_pwg_size_t *size,                /* I - Size to initialize */
+             ipp_t       *job,         /* I - Job template attributes */
+            int         *margins_set)  /* O - 1 if margins were set, 0 otherwise */
+{
+  ipp_attribute_t *media,              /* media attribute */
+               *media_bottom_margin,   /* media-bottom-margin member attribute */
+               *media_col,             /* media-col attribute */
+               *media_left_margin,     /* media-left-margin member attribute */
+               *media_right_margin,    /* media-right-margin member attribute */
+               *media_size,            /* media-size member attribute */
+               *media_top_margin,      /* media-top-margin member attribute */
+               *x_dimension,           /* x-dimension member attribute */
+               *y_dimension;           /* y-dimension member attribute */
+  _pwg_media_t *pwg;                   /* PWG media value */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!size || !job || !margins_set)
+    return (0);
+
+ /*
+  * Look for media-col and then media...
+  */
+
+  memset(size, 0, sizeof(_pwg_size_t));
+  *margins_set = 0;
+
+  if ((media_col = ippFindAttribute(job, "media-col",
+                                    IPP_TAG_BEGIN_COLLECTION)) != NULL)
+  {
+   /*
+    * Got media-col, look for media-size member attribute...
+    */
+
+    if ((media_size = ippFindAttribute(media_col->values[0].collection,
+                                            "media-size",
+                                           IPP_TAG_BEGIN_COLLECTION)) != NULL)
+    {
+     /*
+      * Got media-size, look for x-dimension and y-dimension member
+      * attributes...
+      */
+
+      x_dimension = ippFindAttribute(media_size->values[0].collection,
+                                    "x-dimension", IPP_TAG_INTEGER);
+      y_dimension = ippFindAttribute(media_size->values[0].collection,
+                                     "y-dimension", IPP_TAG_INTEGER);
+
+      if (x_dimension && y_dimension)
+      {
+        size->width  = x_dimension->values[0].integer;
+       size->length = y_dimension->values[0].integer;
+      }
+      else if (!x_dimension)
+      {
+       _cupsSetError(IPP_INTERNAL_ERROR,
+                     _("Missing x-dimension in media-size."), 1);
+        return (0);
+      }
+      else if (!y_dimension)
+      {
+       _cupsSetError(IPP_INTERNAL_ERROR,
+                     _("Missing y-dimension in media-size."), 1);
+        return (0);
+      }
+    }
+    else
+    {
+      _cupsSetError(IPP_INTERNAL_ERROR, _("Missing media-size in media-col."),
+                    1);
+      return (0);
+    }
+
+    /* media-*-margin */
+    media_bottom_margin = ippFindAttribute(media_col->values[0].collection,
+                                          "media-bottom-margin",
+                                          IPP_TAG_INTEGER);
+    media_left_margin   = ippFindAttribute(media_col->values[0].collection,
+                                          "media-left-margin",
+                                          IPP_TAG_INTEGER);
+    media_right_margin  = ippFindAttribute(media_col->values[0].collection,
+                                          "media-right-margin",
+                                          IPP_TAG_INTEGER);
+    media_top_margin    = ippFindAttribute(media_col->values[0].collection,
+                                          "media-top-margin",
+                                          IPP_TAG_INTEGER);
+    if (media_bottom_margin && media_left_margin && media_right_margin &&
+        media_top_margin)
+    {
+      *margins_set = 1;
+      size->bottom = media_bottom_margin->values[0].integer;
+      size->left   = media_left_margin->values[0].integer;
+      size->right  = media_right_margin->values[0].integer;
+      size->top    = media_top_margin->values[0].integer;
+    }
+  }
+  else
+  {
+    if ((media = ippFindAttribute(job, "media", IPP_TAG_NAME)) == NULL)
+      media = ippFindAttribute(job, "media", IPP_TAG_KEYWORD);
+
+    if (media)
+    {
+      if ((pwg = _pwgMediaForPWG(media->values[0].string.text)) == NULL)
+       pwg = _pwgMediaForLegacy(media->values[0].string.text);
+
+      if (pwg)
+      {
+        size->width  = pwg->width;
+       size->length = pwg->length;
+      }
+      else
+      {
+        _cupsSetError(IPP_INTERNAL_ERROR, _("Unsupported media value."), 1);
+       return (0);
+      }
+    }
+    else
+    {
+      _cupsSetError(IPP_INTERNAL_ERROR, _("Missing media or media-col."), 1);
+      return (0);
+    }
+  }
+
+  return (1);
+}
+
+
+/*
+ * '_pwgMediaForLegacy()' - Find a PWG media size by ISO/IPP legacy name.
+ */
+
+_pwg_media_t *                         /* O - Matching size or NULL */
+_pwgMediaForLegacy(
+    const char *legacy)                        /* I - Legacy size name */
+{
+  _pwg_media_t key;                    /* Search key */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!legacy)
+    return (NULL);
+
+ /*
+  * Build the lookup table for PWG names as needed...
+  */
+
+  if (!cg->leg_size_lut)
+  {
+    int                        i;              /* Looping var */
+    _pwg_media_t       *size;          /* Current size */
+
+    cg->leg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_legacy,
+                                    NULL);
+
+    for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
+             size = (_pwg_media_t *)cups_pwg_media;
+        i > 0;
+        i --, size ++)
+      if (size->legacy)
+       cupsArrayAdd(cg->leg_size_lut, size);
+  }
+
+ /*
+  * Lookup the name...
+  */
+
+  key.legacy = legacy;
+  return ((_pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key));
+}
+
+
+/*
+ * '_pwgMediaForPPD()' - Find a PWG media size by Adobe PPD name.
+ */
+
+_pwg_media_t *                         /* O - Matching size or NULL */
+_pwgMediaForPPD(const char *ppd)       /* I - PPD size name */
+{
+  _pwg_media_t key;                    /* Search key */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!ppd)
+    return (NULL);
+
+ /*
+  * Build the lookup table for PWG names as needed...
+  */
+
+  if (!cg->ppd_size_lut)
+  {
+    int                        i;              /* Looping var */
+    _pwg_media_t       *size;          /* Current size */
+
+    cg->ppd_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_ppd, NULL);
+
+    for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
+             size = (_pwg_media_t *)cups_pwg_media;
+        i > 0;
+        i --, size ++)
+      if (size->ppd)
+        cupsArrayAdd(cg->ppd_size_lut, size);
+  }
+
+ /*
+  * Lookup the name...
+  */
+
+  key.ppd = ppd;
+  return ((_pwg_media_t *)cupsArrayFind(cg->ppd_size_lut, &key));
+}
+
+
+/*
+ * '_pwgMediaForPWG()' - Find a PWG media size by 5101.1 self-describing name.
+ */
+
+_pwg_media_t *                         /* O - Matching size or NULL */
+_pwgMediaForPWG(const char *pwg)       /* I - PWG size name */
+{
+  _pwg_media_t key;                    /* Search key */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!pwg)
+    return (NULL);
+
+ /*
+  * Build the lookup table for PWG names as needed...
+  */
+
+  if (!cg->pwg_size_lut)
+  {
+    int                        i;              /* Looping var */
+    _pwg_media_t       *size;          /* Current size */
+
+    cg->pwg_size_lut = cupsArrayNew((cups_array_func_t)pwg_compare_pwg, NULL);
+
+    for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
+             size = (_pwg_media_t *)cups_pwg_media;
+        i > 0;
+        i --, size ++)
+      cupsArrayAdd(cg->pwg_size_lut, size);
+  }
+
+ /*
+  * Lookup the name...
+  */
+
+  key.pwg = pwg;
+  return ((_pwg_media_t *)cupsArrayFind(cg->pwg_size_lut, &key));
+}
+
+
+/*
+ * '_pwgMediaForSize()' - Get the PWG media name for a given size.
+ */
+
+_pwg_media_t *                         /* O - PWG media name */
+_pwgMediaForSize(int width,            /* I - Width in 2540ths */
+                int length)            /* I - Length in 2540ths */
+{
+  int          i;                      /* Looping var */
+  _pwg_media_t *media;                 /* Current media */
+  int          dw, dl;                 /* Difference in width and length */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (width <= 0 || length <= 0)
+    return (NULL);
+
+ /*
+  * Look for a standard size...
+  */
+
+  for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
+          media = (_pwg_media_t *)cups_pwg_media;
+       i > 0;
+       i --, media ++)
+  {
+   /*
+    * Adobe uses a size matching algorithm with an epsilon of 5 points, which
+    * is just about 176/2540ths...
+    */
+
+    dw = media->width - width;
+    dl = media->length - length;
+
+    if (dw > -176 && dw < 176 && dl > -176 && dl < 176)
+      return (media);
+  }
+
+ /*
+  * Not a standard size; convert it to a PWG custom name of the form:
+  *
+  *     custom_WIDTHxHEIGHTuu_WIDTHxHEIGHTuu
+  */
+
+  _pwgGenerateSize(cg->pwg_name, sizeof(cg->pwg_name), "custom", NULL, width,
+                   length);
+
+  cg->pwg_media.pwg    = cg->pwg_name;
+  cg->pwg_media.width  = width;
+  cg->pwg_media.length = length;
+
+  return (&(cg->pwg_media));
+}
+
+
+/*
+ * 'pwg_compare_legacy()' - Compare two sizes using the legacy names.
+ */
+
+static int                             /* O - Result of comparison */
+pwg_compare_legacy(_pwg_media_t *a,    /* I - First size */
+                   _pwg_media_t *b)    /* I - Second size */
+{
+  return (strcmp(a->legacy, b->legacy));
+}
+
+
+/*
+ * 'pwg_compare_ppd()' - Compare two sizes using the PPD names.
+ */
+
+static int                             /* O - Result of comparison */
+pwg_compare_ppd(_pwg_media_t *a,       /* I - First size */
+                _pwg_media_t *b)       /* I - Second size */
+{
+  return (strcmp(a->ppd, b->ppd));
+}
+
+
+/*
+ * 'pwg_compare_pwg()' - Compare two sizes using the PWG names.
+ */
+
+static int                             /* O - Result of comparison */
+pwg_compare_pwg(_pwg_media_t *a,       /* I - First size */
+                _pwg_media_t *b)       /* I - Second size */
+{
+  return (strcmp(a->pwg, b->pwg));
+}
+
+
+/*
+ * End of "$Id$".
+ */
diff --git a/cups/pwg-ppd.c b/cups/pwg-ppd.c
new file mode 100644 (file)
index 0000000..319e7c3
--- /dev/null
@@ -0,0 +1,949 @@
+/*
+ * "$Id$"
+ *
+ *   PWG PPD mapping API implementation for CUPS.
+ *
+ *   Copyright 2010 by Apple Inc.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ *   _pwgCreateWithPPD()      - Create PWG mapping data from a PPD file.
+ *   _pwgGetInputSlot()       - Get the PPD InputSlot associated with the job
+ *                              attributes or a keyword string.
+ *   _pwgGetMediaType()       - Get the PPD MediaType associated with the job
+ *                              attributes or a keyword string.
+ *   _pwgGetPageSize()        - Get the PPD PageSize associated with the job
+ *                              attributes or a keyword string.
+ *   _pwgGetSize()            - Get the PWG size associated with a PPD PageSize.
+ *   _pwgGetSource()          - Get the PWG media-source associated with a PPD
+ *                              InputSlot.
+ *   _pwgGetType()            - Get the PWG media-type associated with a PPD
+ *                              MediaType.
+ *   _pwgInputSlotForSource() - Get the InputSlot name for the given PWG source.
+ *   _pwgMediaTypeForType()   - Get the MediaType name for the given PWG type.
+ *   _pwgPageSizeForMedia()   - Get the PageSize name for the given media.
+ *   pwg_ppdize_name()        - Convert an IPP keyword to a PPD keyword.
+ *   pwg_unppdize_name()      - Convert a PPD keyword to a lowercase IPP
+ *                              keyword.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "pwg-private.h"
+#include "globals.h"
+#include "string.h"
+#include "debug.h"
+#include <math.h>
+
+
+/*
+ * Local functions...
+ */
+
+static void    pwg_ppdize_name(const char *ipp, char *name, size_t namesize);
+static void    pwg_unppdize_name(const char *ppd, char *name, size_t namesize);
+
+
+/*
+ * '_pwgCreateWithPPD()' - Create PWG mapping data from a PPD file.
+ */
+
+_pwg_t *                               /* O - PWG mapping data */
+_pwgCreateWithPPD(ppd_file_t *ppd)     /* I - PPD file */
+{
+  int          i, j;                   /* Looping vars */
+  _pwg_t       *pwg;                   /* PWG mapping data */
+  ppd_option_t *input_slot,            /* InputSlot option */
+               *media_type;            /* MediaType option */
+  ppd_choice_t *choice;                /* Current InputSlot/MediaType */
+  _pwg_map_t   *map;                   /* Current source/type map */
+  ppd_size_t   *ppd_size;              /* Current PPD size */
+  _pwg_size_t  *pwg_size;              /* Current PWG size */
+  char         pwg_keyword[3 + PPD_MAX_NAME + 1 + 12 + 1 + 12 + 3],
+                                       /* PWG keyword string */
+               ppd_name[PPD_MAX_NAME]; /* Normalized PPD name */
+  const char   *pwg_name;              /* Standard PWG media name */
+  _pwg_media_t *pwg_media;             /* PWG media data */
+  struct lconv *loc;                   /* Locale conversion data */
+
+
+  DEBUG_printf(("_pwgCreateWithPPD(ppd=%p)", ppd));
+
+ /*
+  * Range check input...
+  */
+
+  if (!ppd)
+    return (NULL);
+
+ /*
+  * Allocate memory...
+  */
+
+  if ((pwg = calloc(1, sizeof(_pwg_t))) == NULL)
+  {
+    DEBUG_puts("_pwgCreateWithPPD: Unable to allocate _pwg_t.");
+    goto create_error;
+  }
+
+ /*
+  * Copy and convert size data...
+  */
+
+  if (ppd->num_sizes == 0)
+  {
+    DEBUG_puts("_pwgCreateWithPPD: No page sizes in PPD.");
+    goto create_error;
+  }
+
+  if ((pwg->sizes = calloc(ppd->num_sizes, sizeof(_pwg_size_t))) == NULL)
+  {
+    DEBUG_printf(("_pwgCreateWithPPD: Unable to allocate %d _pwg_size_t's.",
+                  ppd->num_sizes));
+    goto create_error;
+  }
+
+  loc = localeconv();
+
+  for (i = ppd->num_sizes, pwg_size = pwg->sizes, ppd_size = ppd->sizes;
+       i > 0;
+       i --, ppd_size ++)
+  {
+   /*
+    * Don't copy over custom size...
+    */
+
+    if (!strcasecmp(ppd_size->name, "Custom"))
+      continue;
+
+   /*
+    * Convert the PPD size name to the corresponding PWG keyword name.
+    */
+
+    if ((pwg_media = _pwgMediaForPPD(ppd_size->name)) != NULL)
+    {
+     /*
+      * Standard name, do we have conflicts?
+      */
+
+      for (j = 0; j < pwg->num_sizes; j ++)
+        if (!strcmp(pwg->sizes[j].map.pwg, pwg_media->pwg))
+       {
+         pwg_media = NULL;
+         break;
+       }
+    }
+
+    if (pwg_media)
+    {
+     /*
+      * Standard name and no conflicts, use it!
+      */
+
+      pwg_name = pwg_media->pwg;
+    }
+    else
+    {
+     /*
+      * Not a standard name; convert it to a PWG vendor name of the form:
+      *
+      *     pp_lowerppd_WIDTHxHEIGHTuu
+      */
+
+      pwg_name = pwg_keyword;
+
+      pwg_unppdize_name(ppd_size->name, ppd_name, sizeof(ppd_name));
+      _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), NULL, ppd_name,
+                      _PWG_FROMPTS(ppd_size->width),
+                      _PWG_FROMPTS(ppd_size->length));
+    }
+
+   /*
+    * Save this size...
+    */
+
+    pwg_size->map.ppd = _cupsStrAlloc(ppd_size->name);
+    pwg_size->map.pwg = _cupsStrAlloc(pwg_name);
+    pwg_size->width   = _PWG_FROMPTS(ppd_size->width);
+    pwg_size->length  = _PWG_FROMPTS(ppd_size->length);
+    pwg_size->left    = _PWG_FROMPTS(ppd_size->left);
+    pwg_size->bottom  = _PWG_FROMPTS(ppd_size->bottom);
+    pwg_size->right   = _PWG_FROMPTS(ppd_size->width - ppd_size->right);
+    pwg_size->top     = _PWG_FROMPTS(ppd_size->length - ppd_size->top);
+
+    pwg->num_sizes ++;
+    pwg_size ++;
+  }
+
+  if (ppd->variable_sizes)
+  {
+   /*
+    * Generate custom size data...
+    */
+
+    _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
+                    _PWG_FROMPTS(ppd->custom_max[0]),
+                    _PWG_FROMPTS(ppd->custom_max[1]));
+    pwg->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
+    pwg->custom_max_width   = _PWG_FROMPTS(ppd->custom_max[0]);
+    pwg->custom_max_length  = _PWG_FROMPTS(ppd->custom_max[1]);
+
+    _pwgGenerateSize(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
+                    _PWG_FROMPTS(ppd->custom_min[0]),
+                    _PWG_FROMPTS(ppd->custom_min[1]));
+    pwg->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
+    pwg->custom_min_width   = _PWG_FROMPTS(ppd->custom_min[0]);
+    pwg->custom_min_length  = _PWG_FROMPTS(ppd->custom_min[1]);
+
+    pwg->custom_size.left   = _PWG_FROMPTS(ppd->custom_margins[0]);
+    pwg->custom_size.bottom = _PWG_FROMPTS(ppd->custom_margins[1]);
+    pwg->custom_size.right  = _PWG_FROMPTS(ppd->custom_margins[2]);
+    pwg->custom_size.top    = _PWG_FROMPTS(ppd->custom_margins[3]);
+  }
+
+ /*
+  * Copy and convert InputSlot data...
+  */
+
+  if ((input_slot = ppdFindOption(ppd, "InputSlot")) != NULL)
+  {
+    if ((pwg->sources = calloc(input_slot->num_choices,
+                               sizeof(_pwg_map_t))) == NULL)
+    {
+      DEBUG_printf(("_pwgCreateWithPPD: Unable to allocate %d _pwg_map_t's "
+                    "for InputSlot.", input_slot->num_choices));
+      goto create_error;
+    }
+
+    pwg->num_sources = input_slot->num_choices;
+
+    for (i = input_slot->num_choices, choice = input_slot->choices,
+             map = pwg->sources;
+        i > 0;
+        i --, choice ++, map ++)
+    {
+      if (!strncasecmp(choice->choice, "Auto", 4) ||
+          !strcasecmp(choice->choice, "Default"))
+        pwg_name = "auto";
+      else if (!strcasecmp(choice->choice, "Cassette"))
+        pwg_name = "main-tray";
+      else if (!strncasecmp(choice->choice, "Multipurpose", 12) ||
+               !strcasecmp(choice->choice, "MP") ||
+               !strcasecmp(choice->choice, "MPTray"))
+        pwg_name = "alternate-tray";
+      else if (!strcasecmp(choice->choice, "LargeCapacity"))
+        pwg_name = "large-capacity-tray";
+      else if (!strncasecmp(choice->choice, "Lower", 5))
+        pwg_name = "bottom-tray";
+      else if (!strncasecmp(choice->choice, "Middle", 6))
+        pwg_name = "middle-tray";
+      else if (!strncasecmp(choice->choice, "Upper", 5))
+        pwg_name = "top-tray";
+      else if (!strcasecmp(choice->choice, "Rear"))
+        pwg_name = "rear-feed";
+      else if (!strncasecmp(choice->choice, "Side", 4))
+        pwg_name = "side-feed";
+      else if (!strcasecmp(choice->choice, "Envelope"))
+        pwg_name = "envelope-feed";
+      else if (!strcasecmp(choice->choice, "Manual"))
+        pwg_name = "manual-feed";
+      else if (!strcasecmp(choice->choice, "Roll") ||
+               !strcasecmp(choice->choice, "Roll"))
+        pwg_name = "main-roll";
+      else if (!strcasecmp(choice->choice, "Roll2"))
+        pwg_name = "alternate-roll";
+      else
+      {
+       /*
+        * Convert PPD name to lowercase...
+       */
+
+        pwg_name = pwg_keyword;
+       pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword));
+      }
+
+      map->pwg = _cupsStrAlloc(pwg_name);
+      map->ppd = _cupsStrAlloc(choice->choice);
+    }
+  }
+
+ /*
+  * Copy and convert MediaType data...
+  */
+
+  if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL)
+  {
+    if ((pwg->types = calloc(media_type->num_choices,
+                             sizeof(_pwg_map_t))) == NULL)
+    {
+      DEBUG_printf(("_pwgCreateWithPPD: Unable to allocate %d _pwg_map_t's "
+                    "for MediaType.", input_slot->num_choices));
+      goto create_error;
+    }
+
+    pwg->num_types = media_type->num_choices;
+
+    for (i = media_type->num_choices, choice = media_type->choices,
+             map = pwg->types;
+        i > 0;
+        i --, choice ++, map ++)
+    {
+      if (!strncasecmp(choice->choice, "Auto", 4) ||
+          !strcasecmp(choice->choice, "Any") ||
+          !strcasecmp(choice->choice, "Default"))
+        pwg_name = "auto";
+      else if (!strncasecmp(choice->choice, "Card", 4))
+        pwg_name = "cardstock";
+      else if (!strncasecmp(choice->choice, "Env", 3))
+        pwg_name = "envelope";
+      else if (!strncasecmp(choice->choice, "Gloss", 5))
+        pwg_name = "photographic-glossy";
+      else if (!strcasecmp(choice->choice, "HighGloss"))
+        pwg_name = "photographic-high-gloss";
+      else if (!strcasecmp(choice->choice, "Matte"))
+        pwg_name = "photographic-matte";
+      else if (!strncasecmp(choice->choice, "Plain", 5))
+        pwg_name = "stationery";
+      else if (!strncasecmp(choice->choice, "Coated", 6))
+        pwg_name = "stationery-coated";
+      else if (!strcasecmp(choice->choice, "Inkjet"))
+        pwg_name = "stationery-inkjet";
+      else if (!strcasecmp(choice->choice, "Letterhead"))
+        pwg_name = "stationery-letterhead";
+      else if (!strncasecmp(choice->choice, "Preprint", 8))
+        pwg_name = "stationery-preprinted";
+      else if (!strncasecmp(choice->choice, "Transparen", 10))
+        pwg_name = "transparency";
+      else
+      {
+       /*
+        * Convert PPD name to lowercase...
+       */
+
+        pwg_name = pwg_keyword;
+       pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword));
+      }
+
+      map->pwg = _cupsStrAlloc(pwg_name);
+      map->ppd = _cupsStrAlloc(choice->choice);
+    }
+  }
+
+  return (pwg);
+
+ /*
+  * If we get here we need to destroy the PWG mapping data and return NULL...
+  */
+
+  create_error:
+
+  _cupsSetError(IPP_INTERNAL_ERROR, _("Out of memory."), 1);
+  _pwgDestroy(pwg);
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgGetInputSlot()' - Get the PPD InputSlot associated with the job
+ *                        attributes or a keyword string.
+ */
+
+const char *                           /* O - PPD InputSlot or NULL */
+_pwgGetInputSlot(_pwg_t     *pwg,      /* I - PWG mapping data */
+                 ipp_t      *job,      /* I - Job attributes or NULL */
+                const char *keyword)   /* I - Keyword string or NULL */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!pwg || pwg->num_sources == 0 || (!job && !keyword))
+    return (NULL);
+
+  if (job && !keyword)
+  {
+   /*
+    * Lookup the media-col attribute and any media-source found there...
+    */
+
+    ipp_attribute_t    *media_col,     /* media-col attribute */
+                       *media_source;  /* media-source attribute */
+
+    media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION);
+    if (media_col &&
+        (media_source = ippFindAttribute(media_col->values[0].collection,
+                                         "media-source",
+                                        IPP_TAG_KEYWORD)) != NULL)
+      keyword = media_source->values[0].string.text;
+  }
+
+  if (keyword)
+  {
+    int        i;                              /* Looping var */
+
+    for (i = 0; i < pwg->num_sources; i ++)
+      if (!strcasecmp(keyword, pwg->sources[i].pwg))
+        return (pwg->sources[i].ppd);
+  }
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgGetMediaType()' - Get the PPD MediaType associated with the job
+ *                        attributes or a keyword string.
+ */
+
+const char *                           /* O - PPD MediaType or NULL */
+_pwgGetMediaType(_pwg_t     *pwg,      /* I - PWG mapping data */
+                 ipp_t      *job,      /* I - Job attributes or NULL */
+                const char *keyword)   /* I - Keyword string or NULL */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!pwg || pwg->num_types == 0 || (!job && !keyword))
+    return (NULL);
+
+  if (job && !keyword)
+  {
+   /*
+    * Lookup the media-col attribute and any media-source found there...
+    */
+
+    ipp_attribute_t    *media_col,     /* media-col attribute */
+                       *media_type;    /* media-type attribute */
+
+    media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION);
+    if (media_col)
+    {
+      if ((media_type = ippFindAttribute(media_col->values[0].collection,
+                                         "media-type",
+                                        IPP_TAG_KEYWORD)) == NULL)
+       media_type = ippFindAttribute(media_col->values[0].collection,
+                                     "media-type", IPP_TAG_NAME);
+
+      if (media_type)
+       keyword = media_type->values[0].string.text;
+    }
+  }
+
+  if (keyword)
+  {
+    int        i;                              /* Looping var */
+
+    for (i = 0; i < pwg->num_types; i ++)
+      if (!strcasecmp(keyword, pwg->types[i].pwg))
+        return (pwg->types[i].ppd);
+  }
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgGetPageSize()' - Get the PPD PageSize associated with the job
+ *                       attributes or a keyword string.
+ */
+
+const char *                           /* O - PPD PageSize or NULL */
+_pwgGetPageSize(_pwg_t     *pwg,       /* I - PWG mapping data */
+                ipp_t      *job,       /* I - Job attributes or NULL */
+               const char *keyword,    /* I - Keyword string or NULL */
+               int        *exact)      /* I - 1 if exact match, 0 otherwise */
+{
+  int          i;                      /* Looping var */
+  _pwg_size_t  *size,                  /* Current size */
+               *closest,               /* Closest size */
+               jobsize;                /* Size data from job */
+  int          margins_set,            /* Were the margins set? */
+               dwidth,                 /* Difference in width */
+               dlength,                /* Difference in length */
+               dleft,                  /* Difference in left margins */
+               dright,                 /* Difference in right margins */
+               dbottom,                /* Difference in bottom margins */
+               dtop,                   /* Difference in top margins */
+               dmin,                   /* Minimum difference */
+               dclosest;               /* Closest difference */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!pwg || (!job && !keyword))
+    return (NULL);
+
+  if (exact)
+    *exact = 0;
+
+  if (job && !keyword)
+  {
+   /*
+    * Get the size using media-col or media, with the preference being
+    * media-col.
+    */
+
+    if (!_pwgInitSize(&jobsize, job, &margins_set))
+      return (NULL);
+  }    
+  else
+  {
+   /*
+    * Get the size using a media keyword...
+    */
+
+    _pwg_media_t       *media;         /* Media definition */
+
+
+    if ((media = _pwgMediaForPWG(keyword)) == NULL)
+      if ((media = _pwgMediaForLegacy(keyword)) == NULL)
+        return (NULL);
+
+    jobsize.width  = media->width;
+    jobsize.length = media->length;
+    margins_set    = 0;
+  }
+
+ /*
+  * Now that we have the dimensions and possibly the margins, look at the
+  * available sizes and find the match...
+  */
+
+  closest  = NULL;
+  dclosest = 999999999;
+
+  for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
+  {
+   /*
+    * Adobe uses a size matching algorithm with an epsilon of 5 points, which
+    * is just about 176/2540ths...
+    */
+
+    dwidth  = size->width - jobsize.width;
+    dlength = size->length - jobsize.length;
+
+    if (dwidth <= -176 || dwidth >= 176 || dlength <= -176 || dlength >= 176)
+      continue;
+
+    if (margins_set)
+    {
+     /*
+      * Use a tighter epsilon of 1 point (35/2540ths) for margins...
+      */
+
+      dleft   = size->left - jobsize.left;
+      dright  = size->right - jobsize.right;
+      dtop    = size->top - jobsize.top;
+      dbottom = size->bottom - jobsize.bottom;
+
+      if (dleft <= -35 || dleft >= 35 || dright <= -35 || dright >= 35 ||
+          dtop <= -35 || dtop >= 35 || dbottom <= -35 || dbottom >= 35)
+      {
+        dleft   = dleft < 0 ? -dleft : dleft;
+        dright  = dright < 0 ? -dright : dright;
+        dbottom = dbottom < 0 ? -dbottom : dbottom;
+        dtop    = dtop < 0 ? -dtop : dtop;
+       dmin    = dleft + dright + dbottom + dtop;
+
+        if (dmin < dclosest)
+       {
+         dclosest = dmin;
+         closest  = size;
+       }
+
+       continue;
+      }
+    }
+
+    if (exact)
+      *exact = 1;
+
+    return (size->map.ppd);
+  }
+
+  if (closest)
+    return (closest->map.ppd);
+
+ /*
+  * If we get here we need to check for custom page size support...
+  */
+
+  if (jobsize.width >= pwg->custom_min_width &&
+      jobsize.width <= pwg->custom_max_width &&
+      jobsize.length >= pwg->custom_min_length &&
+      jobsize.length <= pwg->custom_max_length)
+  {
+   /*
+    * In range, format as Custom.WWWWxLLLL (points).
+    */
+
+    snprintf(pwg->custom_ppd_size, sizeof(pwg->custom_ppd_size), "Custom.%dx%d",
+             (int)_PWG_TOPTS(jobsize.width), (int)_PWG_TOPTS(jobsize.length));
+
+    if (margins_set && exact)
+    {
+      dleft   = pwg->custom_size.left - jobsize.left;
+      dright  = pwg->custom_size.right - jobsize.right;
+      dtop    = pwg->custom_size.top - jobsize.top;
+      dbottom = pwg->custom_size.bottom - jobsize.bottom;
+
+      if (dleft > -35 && dleft < 35 && dright > -35 && dright < 35 &&
+          dtop > -35 && dtop < 35 && dbottom > -35 && dbottom < 35)
+       *exact = 1;
+    }
+    else if (exact)
+      *exact = 1;
+
+    return (pwg->custom_ppd_size);
+  }
+
+ /*
+  * No custom page size support or the size is out of range - return NULL.
+  */
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgGetSize()' - Get the PWG size associated with a PPD PageSize.
+ */
+
+_pwg_size_t *                          /* O - PWG size or NULL */
+_pwgGetSize(_pwg_t     *pwg,           /* I - PWG mapping data */
+            const char *page_size)     /* I - PPD PageSize */
+{
+  int          i;
+  _pwg_size_t  *size;                  /* Current size */
+
+
+  if (!strncasecmp(page_size, "Custom.", 7))
+  {
+   /*
+    * Custom size; size name can be one of the following:
+    *
+    *    Custom.WIDTHxLENGTHin    - Size in inches
+    *    Custom.WIDTHxLENGTHft    - Size in feet
+    *    Custom.WIDTHxLENGTHcm    - Size in centimeters
+    *    Custom.WIDTHxLENGTHmm    - Size in millimeters
+    *    Custom.WIDTHxLENGTHm     - Size in meters
+    *    Custom.WIDTHxLENGTH[pt]  - Size in points
+    */
+
+    double             w, l;           /* Width and length of page */
+    char               *ptr;           /* Pointer into PageSize */
+    struct lconv       *loc;           /* Locale data */
+
+    loc = localeconv();
+    w   = (float)_cupsStrScand(page_size + 7, &ptr, loc);
+    if (!ptr || *ptr != 'x')
+      return (NULL);
+
+    l = (float)_cupsStrScand(ptr + 1, &ptr, loc);
+    if (!ptr)
+      return (NULL);
+
+    if (!strcasecmp(ptr, "in"))
+    {
+      w *= 2540.0;
+      l *= 2540.0;
+    }
+    else if (!strcasecmp(ptr, "ft"))
+    {
+      w *= 12.0 * 2540.0;
+      l *= 12.0 * 2540.0;
+    }
+    else if (!strcasecmp(ptr, "mm"))
+    {
+      w *= 100.0;
+      l *= 100.0;
+    }
+    else if (!strcasecmp(ptr, "cm"))
+    {
+      w *= 1000.0;
+      l *= 1000.0;
+    }
+    else if (!strcasecmp(ptr, "m"))
+    {
+      w *= 100000.0;
+      l *= 100000.0;
+    }
+    else
+    {
+      w *= 2540.0 / 72.0;
+      l *= 2540.0 / 72.0;
+    }
+
+    pwg->custom_size.width  = (int)w;
+    pwg->custom_size.length = (int)l;
+
+    return (&(pwg->custom_size));
+  }
+
+ /*
+  * Not a custom size - look it up...
+  */
+
+  for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
+    if (!strcasecmp(page_size, size->map.ppd))
+      return (size);
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgGetSource()' - Get the PWG media-source associated with a PPD InputSlot.
+ */
+
+const char *                           /* O - PWG media-source keyword */
+_pwgGetSource(_pwg_t     *pwg,         /* I - PWG mapping data */
+              const char *input_slot)  /* I - PPD InputSlot */
+{
+  int          i;                      /* Looping var */
+  _pwg_map_t   *source;                /* Current source */
+
+
+  for (i = pwg->num_sources, source = pwg->sources; i > 0; i --, source ++)
+    if (!strcasecmp(input_slot, source->ppd))
+      return (source->pwg);
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgGetType()' - Get the PWG media-type associated with a PPD MediaType.
+ */
+
+const char *                           /* O - PWG media-type keyword */
+_pwgGetType(_pwg_t     *pwg,           /* I - PWG mapping data */
+           const char *media_type)     /* I - PPD MediaType */
+{
+  int          i;                      /* Looping var */
+  _pwg_map_t   *type;                  /* Current type */
+
+
+  for (i = pwg->num_types, type = pwg->types; i > 0; i --, type ++)
+    if (!strcasecmp(media_type, type->ppd))
+      return (type->pwg);
+
+  return (NULL);
+}
+
+
+/*
+ * '_pwgInputSlotForSource()' - Get the InputSlot name for the given PWG source.
+ */
+
+const char *                           /* O - InputSlot name */
+_pwgInputSlotForSource(
+    const char *media_source,          /* I - PWG media-source */
+    char       *name,                  /* I - Name buffer */
+    size_t     namesize)               /* I - Size of name buffer */
+{
+  if (strcasecmp(media_source, "main-tray"))
+    strlcpy(name, "Cassette", namesize);
+  else if (strcasecmp(media_source, "alternate-tray"))
+    strlcpy(name, "Multipurpose", namesize);
+  else if (strcasecmp(media_source, "large-capacity-tray"))
+    strlcpy(name, "LargeCapacity", namesize);
+  else if (strcasecmp(media_source, "bottom-tray"))
+    strlcpy(name, "Lower", namesize);
+  else if (strcasecmp(media_source, "middle-tray"))
+    strlcpy(name, "Middle", namesize);
+  else if (strcasecmp(media_source, "top-tray"))
+    strlcpy(name, "Upper", namesize);
+  else if (strcasecmp(media_source, "rear-feed"))
+    strlcpy(name, "Rear", namesize);
+  else if (strcasecmp(media_source, "side-feed"))
+    strlcpy(name, "Side", namesize);
+  else if (strcasecmp(media_source, "envelope-feed"))
+    strlcpy(name, "Envelope", namesize);
+  else if (strcasecmp(media_source, "main-roll"))
+    strlcpy(name, "Roll", namesize);
+  else if (strcasecmp(media_source, "alternate-roll"))
+    strlcpy(name, "Roll2", namesize);
+  else
+    pwg_ppdize_name(media_source, name, namesize);
+
+  return (name);
+}
+
+
+/*
+ * '_pwgMediaTypeForType()' - Get the MediaType name for the given PWG type.
+ */
+
+const char *                           /* O - MediaType name */
+_pwgMediaTypeForType(
+    const char *media_type,            /* I - PWG media-source */
+    char       *name,                  /* I - Name buffer */
+    size_t     namesize)               /* I - Size of name buffer */
+{
+  if (strcasecmp(media_type, "auto"))
+    strlcpy(name, "Auto", namesize);
+  else if (strcasecmp(media_type, "cardstock"))
+    strlcpy(name, "Cardstock", namesize);
+  else if (strcasecmp(media_type, "envelope"))
+    strlcpy(name, "Envelope", namesize);
+  else if (strcasecmp(media_type, "photographic-glossy"))
+    strlcpy(name, "Glossy", namesize);
+  else if (strcasecmp(media_type, "photographic-high-gloss"))
+    strlcpy(name, "HighGloss", namesize);
+  else if (strcasecmp(media_type, "photographic-matte"))
+    strlcpy(name, "Matte", namesize);
+  else if (strcasecmp(media_type, "stationery"))
+    strlcpy(name, "Plain", namesize);
+  else if (strcasecmp(media_type, "stationery-coated"))
+    strlcpy(name, "Coated", namesize);
+  else if (strcasecmp(media_type, "stationery-inkjet"))
+    strlcpy(name, "Inkjet", namesize);
+  else if (strcasecmp(media_type, "stationery-letterhead"))
+    strlcpy(name, "Letterhead", namesize);
+  else if (strcasecmp(media_type, "stationery-preprinted"))
+    strlcpy(name, "Preprinted", namesize);
+  else if (strcasecmp(media_type, "transparency"))
+    strlcpy(name, "Transparency", namesize);
+  else
+    pwg_ppdize_name(media_type, name, namesize);
+
+  return (name);
+}
+
+
+/*
+ * '_pwgPageSizeForMedia()' - Get the PageSize name for the given media.
+ */
+
+const char *                           /* O - PageSize name */
+_pwgPageSizeForMedia(
+    _pwg_media_t *media,               /* I - Media */
+    char         *name,                        /* I - PageSize name buffer */
+    size_t       namesize)             /* I - Size of name buffer */
+{
+  const char   *sizeptr,               /* Pointer to size in PWG name */
+               *dimptr;                /* Pointer to dimensions in PWG name */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!media || !name || namesize < PPD_MAX_NAME)
+    return (NULL);
+
+ /*
+  * Copy or generate a PageSize name...
+  */
+
+  if (media->ppd)
+  {
+   /*
+    * Use a standard Adobe name...
+    */
+
+    strlcpy(name, media->ppd, namesize);
+  }
+  else if (!media->pwg || !strncmp(media->pwg, "custom_", 7) ||
+           (sizeptr = strchr(media->pwg, '_')) == NULL ||
+          (dimptr = strchr(sizeptr + 1, '_')) == NULL ||
+          (dimptr - sizeptr) > namesize)
+  {
+   /*
+    * Use a name of the form "wNNNhNNN"...
+    */
+
+    snprintf(name, namesize, "w%dh%d", (int)_PWG_TOPTS(media->width),
+             (int)_PWG_TOPTS(media->length));
+  }
+  else
+  {
+   /*
+    * Copy the size name from class_sizename_dimensions...
+    */
+
+    memcpy(name, sizeptr + 1, dimptr - sizeptr - 1);
+    name[dimptr - sizeptr - 1] = '\0';
+  }
+
+  return (name);
+}
+
+
+/*
+ * 'pwg_ppdize_name()' - Convert an IPP keyword to a PPD keyword.
+ */
+
+static void
+pwg_ppdize_name(const char *ipp,       /* I - IPP keyword */
+                char       *name,      /* I - Name buffer */
+               size_t     namesize)    /* I - Size of name buffer */
+{
+  char *ptr,                           /* Pointer into name buffer */
+       *end;                           /* End of name buffer */
+
+
+  *name = toupper(*ipp++);
+
+  for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
+  {
+    if (*ipp == '-' && isalpha(ipp[1] & 255))
+    {
+      ipp ++;
+      *ptr++ = toupper(*ipp++ & 255);
+    }
+    else
+      *ptr++ = *ipp++;
+  }
+
+  *ptr = '\0';
+}
+
+
+/*
+ * 'pwg_unppdize_name()' - Convert a PPD keyword to a lowercase IPP keyword.
+ */
+
+static void
+pwg_unppdize_name(const char *ppd,     /* I - PPD keyword */
+                 char       *name,     /* I - Name buffer */
+                  size_t     namesize) /* I - Size of name buffer */
+{
+  char *ptr,                           /* Pointer into name buffer */
+       *end;                           /* End of name buffer */
+
+
+  for (ptr = name, end = name + namesize - 1; *ppd && ptr < end; ppd ++)
+  {
+    if (isalnum(*ppd & 255) || *ppd == '-' || *ppd == '.')
+      *ptr++ = tolower(*ppd & 255);
+    else if (*ppd == '_')
+      *ptr++ = '-';
+
+    if (!isupper(*ppd & 255) && isalnum(*ppd & 255) &&
+       isupper(ppd[1] & 255) && ptr < end)
+      *ptr++ = '-';
+  }
+
+  *ptr = '\0';
+}
+
+
+/*
+ * End of "$Id$".
+ */
diff --git a/cups/pwg-private.h b/cups/pwg-private.h
new file mode 100644 (file)
index 0000000..05ab28e
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * "$Id$"
+ *
+ *   PWG media API definitions for CUPS.
+ *
+ *   Copyright 2009-2010 by Apple Inc.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ */
+
+#ifndef _CUPS_PWG_PRIVATE_H_
+#  define _CUPS_PWG_PRIVATE_H_
+
+
+/*
+ * Include necessary headers...
+ */
+
+#  include <cups/cups.h>
+
+
+/*
+ * C++ magic...
+ */
+
+#  ifdef __cplusplus
+extern "C" {
+#  endif /* __cplusplus */
+
+
+/*
+ * Macros...
+ */
+
+/* Convert from points to 2540ths */
+#  define _PWG_FROMPTS(n)      (int)((n) * 2540 / 72)
+/* Convert from 2540ths to points */
+#  define _PWG_TOPTS(n)                ((n) * 72.0 / 2540.0)
+
+
+/*
+ * Types and structures...
+ */
+
+typedef struct _pwg_media_s            /**** Common media size data ****/
+{
+  const char   *pwg,                   /* PWG 5101.1 "self describing" name */
+               *legacy,                /* IPP/ISO legacy name */
+               *ppd;                   /* Standard Adobe PPD name */
+  int          width,                  /* Width in 2540ths */
+               length;                 /* Length in 2540ths */
+} _pwg_media_t;
+
+typedef struct _pwg_map_s              /**** Map element - PPD to/from PWG */
+{
+  char         *pwg,                   /* PWG media keyword */
+               *ppd;                   /* PPD option keyword */
+} _pwg_map_t;
+
+typedef struct _pwg_size_s             /**** Size element - PPD to/from PWG */
+{
+  _pwg_map_t   map;                    /* Map element */
+  int          width,                  /* Width in 2540ths */
+               length,                 /* Length in 2540ths */
+               left,                   /* Left margin in 2540ths */
+               bottom,                 /* Bottom margin in 2540ths */
+               right,                  /* Right margin in 2540ths */
+               top;                    /* Top margin in 2540ths */
+} _pwg_size_t;
+
+typedef struct _pwg_s                  /**** PWG-PPD conversion data ****/
+{
+  int          num_sizes;              /* Number of media sizes */
+  _pwg_size_t  *sizes;                 /* Media sizes */
+  int          custom_max_width,       /* Maximum custom width in 2540ths */
+               custom_max_length,      /* Maximum custom length in 2540ths */
+               custom_min_width,       /* Minimum custom width in 2540ths */
+               custom_min_length;      /* Minimum custom length in 2540ths */
+  char         *custom_max_keyword,    /* Maximum custom size PWG keyword */
+               *custom_min_keyword,    /* Minimum custom size PWG keyword */
+               custom_ppd_size[PPD_MAX_NAME];
+                                       /* Custom PPD size name */
+  _pwg_size_t  custom_size;            /* Custom size record */
+  int          num_sources;            /* Number of media sources */
+  _pwg_map_t   *sources;               /* Media sources */
+  int          num_types;              /* Number of media types */
+  _pwg_map_t   *types;                 /* Media types */
+} _pwg_t;
+
+
+/*
+ * Functions...
+ */
+
+extern _pwg_t          *_pwgCreateWithFile(const char *filename);
+extern _pwg_t          *_pwgCreateWithPPD(ppd_file_t *ppd);
+extern void            _pwgDestroy(_pwg_t *pwg);
+extern void            _pwgGenerateSize(char *keyword, size_t keysize,
+                                        const char *prefix,
+                                        const char *ppdname,
+                                        int width, int length);
+extern const char      *_pwgGetInputSlot(_pwg_t *pwg, ipp_t *job,
+                                         const char *keyword);
+extern const char      *_pwgGetMediaType(_pwg_t *pwg, ipp_t *job,
+                                         const char *keyword);
+extern const char      *_pwgGetPageSize(_pwg_t *pwg, ipp_t *job,
+                                        const char *keyword, int *exact);
+extern _pwg_size_t     *_pwgGetSize(_pwg_t *pwg, const char *page_size);
+extern const char      *_pwgGetSource(_pwg_t *pwg, const char *input_slot);
+extern const char      *_pwgGetType(_pwg_t *pwg, const char *media_type);
+extern int             _pwgInitSize(_pwg_size_t *size, ipp_t *job,
+                                    int *margins_set);
+extern const char      *_pwgInputSlotForSource(const char *media_source,
+                                               char *name, size_t namesize);
+extern _pwg_media_t    *_pwgMediaForLegacy(const char *legacy);
+extern _pwg_media_t    *_pwgMediaForPPD(const char *ppd);
+extern _pwg_media_t    *_pwgMediaForPWG(const char *pwg);
+extern _pwg_media_t    *_pwgMediaForSize(int width, int length);
+extern const char      *_pwgMediaTypeForType(const char *media_source,
+                                             char *name, size_t namesize);
+extern const char      *_pwgPageSizeForMedia(_pwg_media_t *media,
+                                             char *name, size_t namesize);
+extern int             _pwgWriteFile(_pwg_t *pwg, const char *filename);
+
+
+#  ifdef __cplusplus
+}
+#  endif /* __cplusplus */
+
+#endif /* !_CUPS_PWG_PRIVATE_H_ */
+
+/*
+ * End of "$Id$".
+ */
diff --git a/cups/pwgmedia.c b/cups/pwgmedia.c
deleted file mode 100644 (file)
index c2d10f0..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * "$Id$"
- *
- *   PWG media name API implementation for the Common UNIX Printing System
- *   (CUPS).
- *
- *   Copyright 2009 by Apple Inc.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   _cupsPWGMediaByLegacy() - Find a PWG media size by ISO/IPP legacy name.
- *   _cupsPWGMediaByName()   - Find a PWG media size by 5101.1 self-describing
- *                             name.
- *   _cupsPWGMediaBySize()   - Find a PWG media size by size in points.
- *   compare_legacy()        - Compare two sizes using the legacy names.
- *   compare_pwg()           - Compare two sizes using the PWG names.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "pwgmedia.h"
-#include "globals.h"
-#include "string.h"
-#include "debug.h"
-#include <math.h>
-
-
-/*
- * Local macros...
- */
-
-#define _CUPS_SIZE_IN(p,l,x,y) {p, l, x * 72.0, y * 72.0}
-#define _CUPS_SIZE_MM(p,l,x,y) {p, l, x / 25.4 * 72.0, y / 25.4 * 72.0}
-
-
-/*
- * Local functions...
- */
-
-static int     compare_legacy(_cups_pwg_media_t *a, _cups_pwg_media_t *b);
-static int     compare_pwg(_cups_pwg_media_t *a, _cups_pwg_media_t *b);
-
-
-/*
- * Local globals...
- */
-
-static _cups_pwg_media_t const cups_pwg_media[] =
-{                                      /* Media size lookup table */
-  /* North American Standard Sheet Media Sizes */
-  _CUPS_SIZE_IN("na_index-3x5_3x5in", NULL, 3, 5),
-  _CUPS_SIZE_IN("na_personal_3.625x6.5in", NULL, 3.625, 6.5),
-  _CUPS_SIZE_IN("na_monarch_3.875x7.5in", "monarch-envelope", 3.875, 7.5),
-  _CUPS_SIZE_IN("na_number-9_3.875x8.875in", "na-number-9-envelope", 3.875, 8.875),
-  _CUPS_SIZE_IN("na_index-4x6_4x6in", NULL, 4, 6),
-  _CUPS_SIZE_IN("na_number-10_4.125x9.5in", "na-number-10-envelope", 4.125, 9.5),
-  _CUPS_SIZE_IN("na_a2_4.375x5.75in", NULL, 4.375, 5.75),
-  _CUPS_SIZE_IN("na_number-11_4.5x10.375in", NULL, 4.5, 10.375),
-  _CUPS_SIZE_IN("na_number-12_4.75x11in", NULL, 4.75, 11),
-  _CUPS_SIZE_IN("na_5x7_5x7in", NULL, 5, 7),
-  _CUPS_SIZE_IN("na_index-5x8_5x8in", NULL, 5, 8),
-  _CUPS_SIZE_IN("na_number-14_5x11.5in", NULL, 5, 11.5),
-  _CUPS_SIZE_IN("na_invoice_5.5x8.5in", "invoice", 5.5, 8.5),
-  _CUPS_SIZE_IN("na_index-4x6-ext_6x8in", NULL, 6, 8),
-  _CUPS_SIZE_IN("na_6x9_6x9in", "na-6x9-envelope", 6, 9),
-  _CUPS_SIZE_IN("na_c5_6.5x9.5in", NULL, 6.5, 9.5),
-  _CUPS_SIZE_IN("na_7x9_7x9in", "na-7x9-envelope", 7, 9),
-  _CUPS_SIZE_IN("na_executive_7.25x10.5in", "executive", 7.25, 10.5),
-  _CUPS_SIZE_IN("na_govt-letter_8x10in", "na-8x10", 8, 10),
-  _CUPS_SIZE_IN("na_govt-legal_8x13in", NULL, 8, 13),
-  _CUPS_SIZE_IN("na_quarto_8.5x10.83in", "quarto", 8.5, 10.83),
-  _CUPS_SIZE_IN("na_letter_8.5x11in", "na-letter", 8.5, 11),
-  _CUPS_SIZE_IN("na_fanfold-eur_8.5x12in", NULL, 8.5, 12),
-  _CUPS_SIZE_IN("na_letter-plus_8.5x12.69in", NULL, 8.5, 12.69),
-  _CUPS_SIZE_IN("na_foolscap_8.5x13in", NULL, 8.5, 13),
-  _CUPS_SIZE_IN("na_legal_8.5x14in", "na-legal", 8.5, 14),
-  _CUPS_SIZE_IN("na_super-a_8.94x14in", NULL, 8.94, 14),
-  _CUPS_SIZE_IN("na_9x11_9x11in", "na-9x11-envelope", 9, 11),
-  _CUPS_SIZE_IN("na_arch-a_9x12in", "arch-a", 9, 12),
-  _CUPS_SIZE_IN("na_letter-extra_9.5x12in", NULL, 9.5, 12),
-  _CUPS_SIZE_IN("na_legal-extra_9.5x15in", NULL, 9.5, 15),
-  _CUPS_SIZE_IN("na_10x11_10x11in", NULL, 10, 11),
-  _CUPS_SIZE_IN("na_10x13_10x13in", "na-10x13-envelope", 10, 13),
-  _CUPS_SIZE_IN("na_10x14_10x14in", "na-10x14-envelope", 10, 14),
-  _CUPS_SIZE_IN("na_10x15_10x15in", "na-10x15-envelope", 10, 15),
-  _CUPS_SIZE_IN("na_11x12_11x12in", NULL, 11, 12),
-  _CUPS_SIZE_IN("na_edp_11x14in", NULL, 11, 14),
-  _CUPS_SIZE_IN("na_fanfold-us_11x14.875in", NULL, 11, 14.875),
-  _CUPS_SIZE_IN("na_11x15_11x15in", NULL, 11, 15),
-  _CUPS_SIZE_IN("na_ledger_11x17in", "tabloid", 11, 17),
-  _CUPS_SIZE_IN("na_eur-edp_12x14in", NULL, 12, 14),
-  _CUPS_SIZE_IN("na_arch-b_12x18in", "arch-b", 12, 18),
-  _CUPS_SIZE_IN("na_12x19_12x19in", NULL, 12, 19),
-  _CUPS_SIZE_IN("na_b-plus_12x19.17in", NULL, 12, 19.17),
-  _CUPS_SIZE_IN("na_super-b_13x19in", NULL, 13, 19),
-  _CUPS_SIZE_IN("na_c_17x22in", "c", 17, 22),
-  _CUPS_SIZE_IN("na_arch-c_18x24in", "arch-c", 18, 24),
-  _CUPS_SIZE_IN("na_d_22x34in", "d", 22, 34),
-  _CUPS_SIZE_IN("na_arch-d_24x36in", "arch-d", 24, 36),
-  _CUPS_SIZE_IN("asme_f_28x40in", "f", 28, 40),
-  _CUPS_SIZE_IN("na_wide-format_30x42in", NULL, 30, 42),
-  _CUPS_SIZE_IN("na_e_34x44in", "e", 34, 44),
-  _CUPS_SIZE_IN("na_arch-e_36x48in", "arch-e", 36, 48),
-  _CUPS_SIZE_IN("na_f_44x68in", NULL, 44, 68),
-
-  /* Chinese Standard Sheet Media Inch Sizes */
-  _CUPS_SIZE_IN("roc_16k_7.75x10.75in", NULL, 7.75, 10.75),
-  _CUPS_SIZE_IN("roc_8k_10.75x15.5in", NULL, 10.75, 15.5),
-
-  /* ISO Standard Sheet Media Sizes */
-  _CUPS_SIZE_MM("iso_a10_26x37mm", "iso-a10", 26, 37),
-  _CUPS_SIZE_MM("iso_a9_37x52mm", "iso-a9", 37, 52),
-  _CUPS_SIZE_MM("iso_a8_52x74mm", "iso-a8", 52, 74),
-  _CUPS_SIZE_MM("iso_a7_74x105mm", "iso-a7", 74, 105),
-  _CUPS_SIZE_MM("iso_a6_105x148mm", "iso-a6", 105, 148),
-  _CUPS_SIZE_MM("iso_a5_148x210mm", "iso-a5", 148, 210),
-  _CUPS_SIZE_MM("iso_a5-extra_174x235mm", NULL, 174, 235),
-  _CUPS_SIZE_MM("iso_a4_210x297mm", "iso-a4", 210, 297),
-  _CUPS_SIZE_MM("iso_a4-tab_225x297mm", NULL, 225, 297),
-  _CUPS_SIZE_MM("iso_a4-extra_235.5x322.3mm", NULL, 235.5, 322.3),
-  _CUPS_SIZE_MM("iso_a3_297x420mm", "iso-a3", 297, 420),
-  _CUPS_SIZE_MM("iso_a4x3_297x630mm", "iso-a4x3", 297, 630),
-  _CUPS_SIZE_MM("iso_a4x4_297x841mm", "iso-a4x4", 297, 841),
-  _CUPS_SIZE_MM("iso_a4x5_297x1051mm", "iso-a4x5", 297, 1051),
-  _CUPS_SIZE_MM("iso_a4x6_297x1261mm", "iso-a4x6", 297, 1261),
-  _CUPS_SIZE_MM("iso_a4x7_297x1471mm", "iso-a4x7", 297, 1471),
-  _CUPS_SIZE_MM("iso_a4x8_297x1682mm", "iso-a4x8", 297, 1682),
-  _CUPS_SIZE_MM("iso_a4x9_297x1892mm", "iso-a4x9", 297, 1892),
-  _CUPS_SIZE_MM("iso_a3-extra_322x445mm", "iso-a3-extra", 322, 445),
-  _CUPS_SIZE_MM("iso_a2_420x594mm", "iso-a2", 420, 594),
-  _CUPS_SIZE_MM("iso_a3x3_420x891mm", "iso-a3x3", 420, 891),
-  _CUPS_SIZE_MM("iso_a3x4_420x1189mm", "iso-a3x4", 420, 1189),
-  _CUPS_SIZE_MM("iso_a3x5_420x1486mm", "iso-a3x5", 420, 1486),
-  _CUPS_SIZE_MM("iso_a3x6_420x1783mm", "iso-a3x6", 420, 1783),
-  _CUPS_SIZE_MM("iso_a3x7_420x2080mm", "iso-a3x7", 420, 2080),
-  _CUPS_SIZE_MM("iso_a1_594x841mm", "iso-a1", 594, 841),
-  _CUPS_SIZE_MM("iso_a2x3_594x1261mm", "iso-a2x3", 594, 1261),
-  _CUPS_SIZE_MM("iso_a2x4_594x1682mm", "iso-a2x4", 594, 1682),
-  _CUPS_SIZE_MM("iso_a2x5_594x2102mm", "iso-a2x5", 594, 2102),
-  _CUPS_SIZE_MM("iso_a0_841x1189mm", "iso-a0", 841, 1189),
-  _CUPS_SIZE_MM("iso_a1x3_841x1783mm", "iso-a1x3", 841, 1783),
-  _CUPS_SIZE_MM("iso_a1x4_841x2378mm", "iso-a1x4", 841, 2378),
-  _CUPS_SIZE_MM("iso_2a0_1189x1682mm", NULL, 1189, 1682),
-  _CUPS_SIZE_MM("iso_a0x3_1189x2523mm", NULL, 1189, 2523),
-  _CUPS_SIZE_MM("iso_b10_31x44mm", "iso-b10", 31, 44),
-  _CUPS_SIZE_MM("iso_b9_44x62mm", "iso-b9", 44, 62),
-  _CUPS_SIZE_MM("iso_b8_62x88mm", "iso-b8", 62, 88),
-  _CUPS_SIZE_MM("iso_b7_88x125mm", "iso-b7", 88, 125),
-  _CUPS_SIZE_MM("iso_b6_125x176mm", "iso-b6", 125, 176),
-  _CUPS_SIZE_MM("iso_b6c4_125x324mm", NULL, 125, 324),
-  _CUPS_SIZE_MM("iso_b5_176x250mm", "iso-b5", 176, 250),
-  _CUPS_SIZE_MM("iso_b5-extra_201x276mm", NULL, 201, 276),
-  _CUPS_SIZE_MM("iso_b4_250x353mm", "iso-b4", 250, 353),
-  _CUPS_SIZE_MM("iso_b3_353x500mm", "iso-b3", 353, 500),
-  _CUPS_SIZE_MM("iso_b2_500x707mm", "iso-b2", 500, 707),
-  _CUPS_SIZE_MM("iso_b1_707x1000mm", "iso-b1", 707, 1000),
-  _CUPS_SIZE_MM("iso_b0_1000x1414mm", "iso-b0", 1000, 1414),
-  _CUPS_SIZE_MM("iso_c10_28x40mm", "iso-c10", 28, 40),
-  _CUPS_SIZE_MM("iso_c9_40x57mm", "iso-c9", 40, 57),
-  _CUPS_SIZE_MM("iso_c8_57x81mm", "iso-c8", 57, 81),
-  _CUPS_SIZE_MM("iso_c7_81x114mm", "iso-c7", 81, 114),
-  _CUPS_SIZE_MM("iso_c7c6_81x162mm", NULL, 81, 162),
-  _CUPS_SIZE_MM("iso_c6_114x162mm", "iso-c6", 114, 162),
-  _CUPS_SIZE_MM("iso_c6c5_114x229mm", NULL, 114, 229),
-  _CUPS_SIZE_MM("iso_c5_162x229mm", "iso-c5", 162, 229),
-  _CUPS_SIZE_MM("iso_c4_229x324mm", "iso-c4", 229, 324),
-  _CUPS_SIZE_MM("iso_c3_324x458mm", "iso-c3", 324, 458),
-  _CUPS_SIZE_MM("iso_c2_458x648mm", "iso-c2", 458, 648),
-  _CUPS_SIZE_MM("iso_c1_648x917mm", "iso-c1", 648, 917),
-  _CUPS_SIZE_MM("iso_c0_917x1297mm", "iso-c0", 917, 1297),
-  _CUPS_SIZE_MM("iso_dl_110x220mm", "iso-designated", 110, 220),
-  _CUPS_SIZE_MM("iso_ra2_430x610mm", "iso-ra2", 430, 610),
-  _CUPS_SIZE_MM("iso_sra2_450x640mm", "iso-sra2", 450, 640),
-  _CUPS_SIZE_MM("iso_ra1_610x860mm", "iso-ra1", 610, 860),
-  _CUPS_SIZE_MM("iso_sra1_640x900mm", "iso-sra1", 640, 900),
-  _CUPS_SIZE_MM("iso_ra0_860x1220mm", "iso-ra0", 860, 1220),
-  _CUPS_SIZE_MM("iso_sra0_900x1280mm", "iso-sra0", 900, 1280),
-
-  /* Japanese Standard Sheet Media Sizes */
-  _CUPS_SIZE_MM("jis_b10_32x45mm", "jis-b10", 32, 45),
-  _CUPS_SIZE_MM("jis_b9_45x64mm", "jis-b9", 45, 64),
-  _CUPS_SIZE_MM("jis_b8_64x91mm", "jis-b8", 64, 91),
-  _CUPS_SIZE_MM("jis_b7_91x128mm", "jis-b7", 91, 128),
-  _CUPS_SIZE_MM("jis_b6_128x182mm", "jis-b6", 128, 182),
-  _CUPS_SIZE_MM("jis_b5_182x257mm", "jis-b5", 182, 257),
-  _CUPS_SIZE_MM("jis_b4_257x364mm", "jis-b4", 257, 364),
-  _CUPS_SIZE_MM("jis_b3_364x515mm", "jis-b3", 364, 515),
-  _CUPS_SIZE_MM("jis_b2_515x728mm", "jis-b2", 515, 728),
-  _CUPS_SIZE_MM("jis_b1_728x1030mm", "jis-b1", 728, 1030),
-  _CUPS_SIZE_MM("jis_b0_1030x1456mm", "jis-b0", 1030, 1456),
-  _CUPS_SIZE_MM("jis_exec_216x330mm", NULL, 216, 330),
-  _CUPS_SIZE_MM("jpn_chou4_90x205mm", NULL, 90, 205),
-  _CUPS_SIZE_MM("jpn_hagaki_100x148mm", NULL, 100, 148),
-  _CUPS_SIZE_MM("jpn_you4_105x235mm", NULL, 105, 235),
-  _CUPS_SIZE_MM("jpn_chou2_111.1x146mm", NULL, 111.1, 146),
-  _CUPS_SIZE_MM("jpn_chou3_120x235mm", NULL, 120, 235),
-  _CUPS_SIZE_MM("jpn_oufuku_148x200mm", NULL, 148, 200),
-  _CUPS_SIZE_MM("jpn_kahu_240x322.1mm", NULL, 240, 322.1),
-  _CUPS_SIZE_MM("jpn_kaku2_240x332mm", NULL, 240, 332),
-
-  /* Chinese Standard Sheet Media Sizes */
-  _CUPS_SIZE_MM("prc_32k_97x151mm", NULL, 97, 151),
-  _CUPS_SIZE_MM("prc_1_102x165mm", NULL, 102, 165),
-  _CUPS_SIZE_MM("prc_2_102x176mm", NULL, 102, 176),
-  _CUPS_SIZE_MM("prc_4_110x208mm", NULL, 110, 208),
-  _CUPS_SIZE_MM("prc_5_110x220mm", NULL, 110, 220),
-  _CUPS_SIZE_MM("prc_8_120x309mm", NULL, 120, 309),
-  _CUPS_SIZE_MM("prc_6_120x320mm", NULL, 120, 320),
-  _CUPS_SIZE_MM("prc_3_125x176mm", NULL, 125, 176),
-  _CUPS_SIZE_MM("prc_16k_146x215mm", NULL, 146, 215),
-  _CUPS_SIZE_MM("prc_7_160x230mm", NULL, 160, 230),
-  _CUPS_SIZE_MM("om_juuro-ku-kai_198x275mm", NULL, 198, 275),
-  _CUPS_SIZE_MM("om_pa-kai_267x389mm", NULL, 267, 389),
-  _CUPS_SIZE_MM("om_dai-pa-kai_275x395mm", NULL, 275, 395),
-  _CUPS_SIZE_MM("prc_10_324x458mm", NULL, 324, 458),
-
-  /* Other Metric Standard Sheet Media Sizes */
-  _CUPS_SIZE_MM("om_small-photo_100x150mm", NULL, 100, 150),
-  _CUPS_SIZE_MM("om_italian_110x230mm", NULL, 110, 230),
-  _CUPS_SIZE_MM("om_postfix_114x229mm", NULL, 114, 229),
-  _CUPS_SIZE_MM("om_large-photo_200x300", NULL, 200, 300),
-  _CUPS_SIZE_MM("om_folio_210x330mm", "folio", 210, 330),
-  _CUPS_SIZE_MM("om_folio-sp_215x315mm", NULL, 215, 315),
-  _CUPS_SIZE_MM("om_invite_220x220mm", NULL, 220, 220)
-};
-
-
-/*
- * '_cupsPWGMediaByLegacy()' - Find a PWG media size by ISO/IPP legacy name.
- */
-
-_cups_pwg_media_t *                    /* O - Matching size or NULL */
-_cupsPWGMediaByLegacy(
-    const char *legacy)                        /* I - Legacy size name */
-{
-  _cups_pwg_media_t    key;            /* Search key */
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Global data */
-
-
- /*
-  * Build the lookup table for PWG names as needed...
-  */
-
-  if (!cg->leg_size_lut)
-  {
-    int                        i;              /* Looping var */
-    _cups_pwg_media_t  *size;          /* Current size */
-
-    cg->leg_size_lut = cupsArrayNew((cups_array_func_t)compare_legacy, NULL);
-
-    for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-             size = (_cups_pwg_media_t *)cups_pwg_media;
-        i > 0;
-        i --, size ++)
-      if (size->legacy)
-       cupsArrayAdd(cg->leg_size_lut, size);
-  }
-
- /*
-  * Lookup the name...
-  */
-
-  key.legacy = legacy;
-  return ((_cups_pwg_media_t *)cupsArrayFind(cg->leg_size_lut, &key));
-}
-
-
-/*
- * '_cupsPWGMediaByName()' - Find a PWG media size by 5101.1 self-describing
- *                           name.
- */
-
-_cups_pwg_media_t *                    /* O - Matching size or NULL */
-_cupsPWGMediaByName(const char *pwg)   /* I - PWG size name */
-{
-  _cups_pwg_media_t    key;            /* Search key */
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Global data */
-
-
- /*
-  * Build the lookup table for PWG names as needed...
-  */
-
-  if (!cg->pwg_size_lut)
-  {
-    int                        i;              /* Looping var */
-    _cups_pwg_media_t  *size;          /* Current size */
-
-    cg->pwg_size_lut = cupsArrayNew((cups_array_func_t)compare_pwg, NULL);
-
-    for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-             size = (_cups_pwg_media_t *)cups_pwg_media;
-        i > 0;
-        i --, size ++)
-      cupsArrayAdd(cg->pwg_size_lut, size);
-  }
-
- /*
-  * Lookup the name...
-  */
-
-  key.pwg = pwg;
-  return ((_cups_pwg_media_t *)cupsArrayFind(cg->pwg_size_lut, &key));
-}
-
-
-/*
- * '_cupsPWGMediaBySize()' - Find a PWG media size by size in points.
- */
-
-_cups_pwg_media_t *                    /* O - Matching size or NULL */
-_cupsPWGMediaBySize(double width,      /* I - Width in points */
-                    double length)     /* I - Length in points */
-{
-  int                  i;              /* Looping var */
-  _cups_pwg_media_t    *size;          /* Current size */
-  double               dw, dl;         /* Difference in width and length */
-
-
-  for (i = (int)(sizeof(cups_pwg_media) / sizeof(cups_pwg_media[0])),
-          size = (_cups_pwg_media_t *)cups_pwg_media;
-       i > 0;
-       i --, size ++)
-  {
-   /*
-    * Adobe uses a size matching algorithm with an epsilon of 5 points...
-    */
-
-    dw = size->width - width;
-    dl = size->length - length;
-
-    if (dw > -5.0 && dw < 5.0 && dl > -5.0 && dl < 5.0)
-      return (size);
-  }
-
-  return (NULL);
-}
-
-
-/*
- * 'compare_legacy()' - Compare two sizes using the legacy names.
- */
-
-static int                             /* O - Result of comparison */
-compare_legacy(_cups_pwg_media_t *a,   /* I - First size */
-               _cups_pwg_media_t *b)   /* I - Second size */
-{
-  return (strcmp(a->legacy, b->legacy));
-}
-
-
-/*
- * 'compare_pwg()' - Compare two sizes using the PWG names.
- */
-
-static int                             /* O - Result of comparison */
-compare_pwg(_cups_pwg_media_t *a,      /* I - First size */
-            _cups_pwg_media_t *b)      /* I - Second size */
-{
-  return (strcmp(a->pwg, b->pwg));
-}
-
-
-/*
- * End of "$Id$".
- */
diff --git a/cups/pwgmedia.h b/cups/pwgmedia.h
deleted file mode 100644 (file)
index a07ca0c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * "$Id$"
- *
- *   PWG media name API definitions for the Common UNIX Printing System (CUPS).
- *
- *   Copyright 2009 by Apple Inc.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- */
-
-#ifndef _CUPS_PWGMEDIA_H_
-#  define _CUPS_PWGMEDIA_H_
-
-
-/*
- * C++ magic...
- */
-
-#  ifdef __cplusplus
-extern "C" {
-#  endif /* __cplusplus */
-
-
-/*
- * Types and structures...
- */
-
-typedef struct _cups_pwg_media_s       /**** Common media size data ****/
-{
-  const char   *pwg,                   /* PWG 5101.1 "self describing" name */
-               *legacy;                /* IPP/ISO legacy name */
-  double       width,                  /* Width in points */
-               length;                 /* Length in points */
-} _cups_pwg_media_t;
-
-
-/*
- * Functions...
- */
-
-extern _cups_pwg_media_t       *_cupsPWGMediaByLegacy(const char *legacy);
-extern _cups_pwg_media_t       *_cupsPWGMediaByName(const char *pwg);
-extern _cups_pwg_media_t       *_cupsPWGMediaBySize(double width,
-                                                    double length);
-
-
-#  ifdef __cplusplus
-}
-#  endif /* __cplusplus */
-
-#endif /* !_CUPS_PWGMEDIA_H_ */
-
-/*
- * End of "$Id$".
- */
index 27a0dd00964a60f78d5fede6965e0626b48a0b43..779d789d90fa52f2c33bd8c15583a96015d67c78 100644 (file)
@@ -2,7 +2,7 @@
 *%
 *% "$Id: test.ppd 7819 2008-08-01 00:27:24Z mike $"
 *%
-*% Test PPD file for the Common UNIX Printing System (CUPS).
+*% Test PPD file for CUPS.
 *%
 *% This file is used to test the CUPS PPD API functions and cannot be
 *% used with any known printers.  Look on the CUPS web site for working PPD
@@ -12,7 +12,7 @@
 *% to create your PPD files - not only will it save you time, it produces
 *% consistently high-quality files.
 *%
-*% Copyright 2007-2009 by Apple Inc.
+*% Copyright 2007-2010 by Apple Inc.
 *% Copyright 2002-2006 by Easy Software Products.
 *% 
 *% These coded instructions, statements, and computer programs are the
@@ -65,6 +65,9 @@
 *PageSize Letter/US Letter:    "PageSize=Letter"
 *fr.PageSize Letter/French US Letter: ""
 *fr_CA.PageSize Letter/French Canadian US Letter: ""
+*PageSize Letter.Fullbleed/US Letter Borderless: "PageSize=Letter.Fullbleed"
+*fr.PageSize Letter.Fullbleed/French US Letter Borderless: ""
+*fr_CA.PageSize Letter.Fullbleed/French Canadian US Letter Borderless: ""
 *PageSize A4/A4:               "PageSize=A4"
 *fr.PageSize A4/French A4: ""
 *fr_CA.PageSize A4/French Canadian A4: ""
 *OrderDependency: 10 AnySetup *PageRegion
 *DefaultPageRegion: Letter
 *PageRegion Letter/US Letter:  "PageRegion=Letter"
+*PageRegion Letter.Fullbleed/US Letter Borderless: "PageRegion=Letter.Fullbleed"
 *PageRegion A4/A4:             "PageRegion=A4"
 *PageRegion Env10/#10 Envelope:        "PageRegion=Env10"
 *CloseUI: *PageRegion
 
 *fr.Translation PageRegion/French Page Region: ""
 *fr.PageRegion Letter/French US Letter: ""
+*fr.PageRegion Letter.Fullbleed/French US Letter Borderless: ""
 *fr.PageRegion A4/French A4: ""
 *fr.PageRegion Env10/French #10 Envelope: ""
 
 *fr_CA.Translation PageRegion/French Canadian Page Region: ""
 *fr_CA.PageRegion Letter/French Canadian US Letter: ""
+*fr_CA.PageRegion Letter.Fullbleed/French Canadian US Letter Borderless: ""
 *fr_CA.PageRegion A4/French Canadian A4: ""
 *fr_CA.PageRegion Env10/French Canadian #10 Envelope: ""
 
 *DefaultImageableArea: Letter 
 *ImageableArea Letter: "18 36 594 756"
+*ImageableArea Letter.Fullbleed:       "0 0 612 792"
 *ImageableArea A4:     "18 36 577 806"
 *ImageableArea Env10:  "18 36 279 648"
 
 *DefaultPaperDimension: Letter
 *PaperDimension Letter:        "612 792"
+*PaperDimension Letter.Fullbleed:      "612 792"
 *PaperDimension A4:    "595 842"
 *PaperDimension Env10: "297 684"
 
 *InputSlot Envelope/Envelope Feed: "InputSlot=Envelope"
 *CloseUI: *InputSlot
 
+*OpenUI *MediaType/Media Type: PickOne
+*OrderDependency: 25 AnySetup *MediaType
+*DefaultMediaType: Plain
+*MediaType Plain/Plain Paper: "MediaType=Plain"
+*MediaType Matte/Matte Photo: "MediaType=Matte"
+*MediaType Glossy/Glossy Photo: "MediaType=Glossy"
+*MediaType Transparency/Transparency Film: "MediaType=Transparency"
+*CloseUI: *MediaType
+
 *OpenUI *Duplex/2-Sided Printing: PickOne
 *OrderDependency: 10 DocumentSetup *Duplex
 *DefaultDuplex: None
index 972c6474dbfcf3f190e257875af4ef667fff38a8..d6247621d53c1e69f399948a82a3e09a786d2f43 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   IPP test program for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2009 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2005 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <cups/file.h>
 #include <cups/string.h>
 #include <errno.h>
 #include "ipp-private.h"
@@ -80,6 +81,32 @@ ipp_uchar_t  collection[] =                  /* Collection buffer */
                  0x00, 0x09,                   /* Name length + name */
                  'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l',
                  0x00, 0x00,                   /* No value */
+                   IPP_TAG_MEMBERNAME,         /* memberAttrName tag */
+                   0x00, 0x00,                 /* No name */
+                   0x00, 0x0a,                 /* Value length + value */
+                   'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
+                   IPP_TAG_BEGIN_COLLECTION,   /* begCollection tag */
+                   0x00, 0x00,                 /* Name length + name */
+                   0x00, 0x00,                 /* No value */
+                     IPP_TAG_MEMBERNAME,       /* memberAttrName tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x0b,               /* Value length + value */
+                     'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
+                     IPP_TAG_INTEGER,          /* integer tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x04,               /* Value length + value */
+                     0x00, 0x00, 0x54, 0x56,
+                     IPP_TAG_MEMBERNAME,       /* memberAttrName tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x0b,               /* Value length + value */
+                     'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
+                     IPP_TAG_INTEGER,          /* integer tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x04,               /* Value length + value */
+                     0x00, 0x00, 0x6d, 0x24,
+                   IPP_TAG_END_COLLECTION,     /* endCollection tag */
+                   0x00, 0x00,                 /* No name */
+                   0x00, 0x00,                 /* No value */
                    IPP_TAG_MEMBERNAME,         /* memberAttrName tag */
                    0x00, 0x00,                 /* No name */
                    0x00, 0x0b,                 /* Value length + value */
@@ -104,6 +131,32 @@ ipp_uchar_t        collection[] =                  /* Collection buffer */
                  IPP_TAG_BEGIN_COLLECTION,     /* begCollection tag */
                  0x00, 0x00,                   /* No name */
                  0x00, 0x00,                   /* No value */
+                   IPP_TAG_MEMBERNAME,         /* memberAttrName tag */
+                   0x00, 0x00,                 /* No name */
+                   0x00, 0x0a,                 /* Value length + value */
+                   'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
+                   IPP_TAG_BEGIN_COLLECTION,   /* begCollection tag */
+                   0x00, 0x00,                 /* Name length + name */
+                   0x00, 0x00,                 /* No value */
+                     IPP_TAG_MEMBERNAME,       /* memberAttrName tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x0b,               /* Value length + value */
+                     'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
+                     IPP_TAG_INTEGER,          /* integer tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x04,               /* Value length + value */
+                     0x00, 0x00, 0x52, 0x08,
+                     IPP_TAG_MEMBERNAME,       /* memberAttrName tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x0b,               /* Value length + value */
+                     'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
+                     IPP_TAG_INTEGER,          /* integer tag */
+                     0x00, 0x00,               /* No name */
+                     0x00, 0x04,               /* Value length + value */
+                     0x00, 0x00, 0x74, 0x04,
+                   IPP_TAG_END_COLLECTION,     /* endCollection tag */
+                   0x00, 0x00,                 /* No name */
+                   0x00, 0x00,                 /* No value */
                    IPP_TAG_MEMBERNAME,         /* memberAttrName tag */
                    0x00, 0x00,                 /* No name */
                    0x00, 0x0b,                 /* Value length + value */
@@ -147,11 +200,15 @@ int                               /* O - Exit status */
 main(int  argc,                        /* I - Number of command-line arguments */
      char *argv[])             /* I - Command-line arguments */
 {
-  ipp_t                *cols[2];       /* Collections */
+  ipp_t                *cols[2],       /* Collections */
+               *size;          /* media-size collection */
   ipp_t                *request;       /* Request */
+  ipp_attribute_t *media_col,  /* media-col attribute */
+               *media_size,    /* media-size attribute */
+               *attr;          /* Other attribute */
   ipp_state_t  state;          /* State */
   int          length;         /* Length of data */
-  int          fd;             /* File descriptor */
+  cups_file_t  *fp;            /* File pointer */
   int          i;              /* Looping var */
   int          status;         /* Status of tests (0 = success, 1 = fail) */
 
@@ -180,14 +237,27 @@ main(int  argc,                   /* I - Number of command-line arguments */
                 "printer-uri", NULL, "ipp://localhost/printers/foo");
 
     cols[0] = ippNew();
-    ippAddString(cols[0], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-color", NULL, "blue");
-    ippAddString(cols[0], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-type", NULL, "plain");
+    size    = ippNew();
+    ippAddInteger(size, IPP_TAG_ZERO, IPP_TAG_INTEGER, "x-dimension", 21590);
+    ippAddInteger(size, IPP_TAG_ZERO, IPP_TAG_INTEGER, "y-dimension", 27940);
+    ippAddCollection(cols[0], IPP_TAG_JOB, "media-size", size);
+    ippAddString(cols[0], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-color", NULL,
+                 "blue");
+    ippAddString(cols[0], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-type", NULL,
+                 "plain");
 
     cols[1] = ippNew();
-    ippAddString(cols[1], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-color", NULL, "plaid");
-    ippAddString(cols[1], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-type", NULL, "glossy");
-
-    ippAddCollections(request, IPP_TAG_JOB, "media-col", 2, (const ipp_t **)cols);
+    size    = ippNew();
+    ippAddInteger(size, IPP_TAG_ZERO, IPP_TAG_INTEGER, "x-dimension", 21000);
+    ippAddInteger(size, IPP_TAG_ZERO, IPP_TAG_INTEGER, "y-dimension", 29700);
+    ippAddCollection(cols[1], IPP_TAG_JOB, "media-size", size);
+    ippAddString(cols[1], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-color", NULL,
+                 "plaid");
+    ippAddString(cols[1], IPP_TAG_JOB, IPP_TAG_KEYWORD, "media-type", NULL,
+                "glossy");
+
+    ippAddCollections(request, IPP_TAG_JOB, "media-col", 2,
+                      (const ipp_t **)cols);
 
     length = ippLength(request);
     if (length != sizeof(collection))
@@ -225,7 +295,11 @@ main(int  argc,                    /* I - Number of command-line arguments */
     }
     else if (memcmp(wbuffer, collection, wused))
     {
-      puts("FAIL - output does not match baseline!");
+      for (i = 0; i < wused; i ++)
+        if (wbuffer[i] != collection[i])
+         break;
+
+      printf("FAIL - output does not match baseline at 0x%04x!\n", i);
       hex_dump("Bytes Written", wbuffer, wused);
       hex_dump("Baseline", collection, sizeof(collection));
       status = 1;
@@ -271,13 +345,148 @@ main(int  argc,                  /* I - Number of command-line arguments */
     else
       puts("PASS");
 
+    fputs("ippFindAttribute(media-col): ", stdout);
+    if ((media_col = ippFindAttribute(request, "media-col",
+                                      IPP_TAG_BEGIN_COLLECTION)) == NULL)
+    {
+      if ((media_col = ippFindAttribute(request, "media-col",
+                                        IPP_TAG_ZERO)) == NULL)
+        puts("FAIL (not found)");
+      else
+        printf("FAIL (wrong type - %s)\n", ippTagString(media_col->value_tag));
+
+      status = 1;
+    }
+    else if (media_col->num_values != 2)
+    {
+      printf("FAIL (wrong count - %d)\n", media_col->num_values);
+      status = 1;
+    }
+    else
+      puts("PASS");
+
+    fputs("ippFindAttribute(media-size 1): ", stdout);
+    if ((media_size = ippFindAttribute(media_col->values[0].collection,
+                                       "media-size",
+                                       IPP_TAG_BEGIN_COLLECTION)) == NULL)
+    {
+      if ((media_size = ippFindAttribute(media_col->values[0].collection,
+                                         "media-col",
+                                         IPP_TAG_ZERO)) == NULL)
+        puts("FAIL (not found)");
+      else
+        printf("FAIL (wrong type - %s)\n", ippTagString(media_size->value_tag));
+
+      status = 1;
+    }
+    else
+    {
+      if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                   "x-dimension", IPP_TAG_INTEGER)) == NULL)
+      {
+       if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                    "x-dimension", IPP_TAG_ZERO)) == NULL)
+         puts("FAIL (missing x-dimension)");
+       else
+         printf("FAIL (wrong type for x-dimension - %s)\n",
+                ippTagString(attr->value_tag));
+
+       status = 1;
+      }
+      else if (attr->values[0].integer != 21590)
+      {
+        printf("FAIL (wrong value for x-dimension - %d)\n",
+              attr->values[0].integer);
+       status = 1;
+      }
+      else if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                        "y-dimension",
+                                       IPP_TAG_INTEGER)) == NULL)
+      {
+       if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                    "y-dimension", IPP_TAG_ZERO)) == NULL)
+         puts("FAIL (missing y-dimension)");
+       else
+         printf("FAIL (wrong type for y-dimension - %s)\n",
+                ippTagString(attr->value_tag));
+
+       status = 1;
+      }
+      else if (attr->values[0].integer != 27940)
+      {
+        printf("FAIL (wrong value for y-dimension - %d)\n",
+              attr->values[0].integer);
+       status = 1;
+      }
+      else
+       puts("PASS");
+    }
+
+    fputs("ippFindAttribute(media-size 2): ", stdout);
+    if ((media_size = ippFindAttribute(media_col->values[1].collection,
+                                       "media-size",
+                                       IPP_TAG_BEGIN_COLLECTION)) == NULL)
+    {
+      if ((media_size = ippFindAttribute(media_col->values[1].collection,
+                                         "media-col",
+                                         IPP_TAG_ZERO)) == NULL)
+        puts("FAIL (not found)");
+      else
+        printf("FAIL (wrong type - %s)\n", ippTagString(media_size->value_tag));
+
+      status = 1;
+    }
+    else
+    {
+      if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                   "x-dimension",
+                                  IPP_TAG_INTEGER)) == NULL)
+      {
+       if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                    "x-dimension", IPP_TAG_ZERO)) == NULL)
+         puts("FAIL (missing x-dimension)");
+       else
+         printf("FAIL (wrong type for x-dimension - %s)\n",
+                ippTagString(attr->value_tag));
+
+       status = 1;
+      }
+      else if (attr->values[0].integer != 21000)
+      {
+        printf("FAIL (wrong value for x-dimension - %d)\n",
+              attr->values[0].integer);
+       status = 1;
+      }
+      else if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                        "y-dimension",
+                                       IPP_TAG_INTEGER)) == NULL)
+      {
+       if ((attr = ippFindAttribute(media_size->values[0].collection,
+                                    "y-dimension", IPP_TAG_ZERO)) == NULL)
+         puts("FAIL (missing y-dimension)");
+       else
+         printf("FAIL (wrong type for y-dimension - %s)\n",
+                ippTagString(attr->value_tag));
+
+       status = 1;
+      }
+      else if (attr->values[0].integer != 29700)
+      {
+        printf("FAIL (wrong value for y-dimension - %d)\n",
+              attr->values[0].integer);
+       status = 1;
+      }
+      else
+       puts("PASS");
+    }
+
     ippDelete(request);
 
    /*
     * Test _ippFindOption() private API...
     */
 
-    fputs("_ippFindOption(\"printer-type\"): ", stdout);
+    fputs("_ippFindOption(printer-type): ", stdout);
     if (_ippFindOption("printer-type"))
       puts("PASS");
     else
@@ -305,7 +514,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
     for (i = 1; i < argc; i ++)
     {
-      if ((fd = open(argv[i], O_RDONLY)) < 0)
+      if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
       {
        printf("Unable to open \"%s\" - %s\n", argv[i], strerror(errno));
        status = 1;
@@ -313,7 +522,8 @@ main(int  argc,                     /* I - Number of command-line arguments */
       }
 
       request = ippNew();
-      while ((state = ippReadFile(fd, request)) == IPP_ATTRIBUTE);
+      while ((state = ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL,
+                                request)) == IPP_ATTRIBUTE);
 
       if (state != IPP_DATA)
       {
@@ -327,7 +537,7 @@ main(int  argc,                     /* I - Number of command-line arguments */
       }
 
       ippDelete(request);
-      close(fd);
+      cupsFileClose(fp);
     }
   }
 
index c9a8ece3839777e59763744b0bb75f5183782771..c63778a7bd5e2163f6e78d4459b6de04d9e86a6a 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PPD test program for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2009 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
  * Include necessary headers...
  */
 
+#include <cups/cups.h>
+#include <cups/string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <cups/string.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include "cups.h"
-#include "pwgmedia.h"
 #ifdef WIN32
 #  include <io.h>
 #else
@@ -58,6 +57,11 @@ static const char    *default_code =
                        "%%EndFeature\n"
                        "} stopped cleartomark\n"
                        "[{\n"
+                       "%%BeginFeature: *MediaType Plain\n"
+                       "MediaType=Plain\n"
+                       "%%EndFeature\n"
+                       "} stopped cleartomark\n"
+                       "[{\n"
                        "%%BeginFeature: *IntOption None\n"
                        "%%EndFeature\n"
                        "} stopped cleartomark\n"
@@ -77,6 +81,11 @@ static const char    *custom_code =
                        "%%EndFeature\n"
                        "} stopped cleartomark\n"
                        "[{\n"
+                       "%%BeginFeature: *MediaType Plain\n"
+                       "MediaType=Plain\n"
+                       "%%EndFeature\n"
+                       "} stopped cleartomark\n"
+                       "[{\n"
                        "%%BeginFeature: *IntOption None\n"
                        "%%EndFeature\n"
                        "} stopped cleartomark\n"
@@ -145,7 +154,6 @@ main(int  argc,                             /* I - Number of command-line arguments */
                maxsize,                /* Maximum size */
                *size;                  /* Current size */
   ppd_attr_t   *attr;                  /* Current attribute */
-  _cups_pwg_media_t *pwgmedia;         /* PWG media size */
 
 
   status = 0;
@@ -437,20 +445,6 @@ main(int  argc,                            /* I - Number of command-line arguments */
     else
       puts("PASS");
 
-    fputs("_cupsPWGMediaBySize(842, 1191): ", stdout);
-    if ((pwgmedia = _cupsPWGMediaBySize(842, 1191)) == NULL)
-    {
-      puts("FAIL (not found)");
-      status ++;
-    }
-    else if (strcmp(pwgmedia->pwg, "iso_a3_297x420mm"))
-    {
-      printf("FAIL (%s)\n", pwgmedia->pwg);
-      status ++;
-    }
-    else
-      puts("PASS");
-
    /*
     * Test localization...
     */
diff --git a/cups/testpwg.c b/cups/testpwg.c
new file mode 100644 (file)
index 0000000..ef2b742
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * "$Id$"
+ *
+ *   PWG test program for CUPS.
+ *
+ *   Copyright 2009-2010 by Apple Inc.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ *   main()     - Main entry.
+ *   test_pwg() - Test the PWG mapping functions.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "pwg-private.h"
+
+
+/*
+ * Local functions...
+ */
+
+static int     test_pwg(_pwg_t *pwg);
+
+
+/*
+ * 'main()' - Main entry.
+ */
+
+int                                    /* O - Exit status */
+main(int  argc,                                /* I - Number of command-line args */
+     char *argv[])                     /* I - Command-line arguments */
+{
+  int          status;                 /* Status of tests (0 = success, 1 = fail) */
+  const char   *ppdfile;               /* PPD filename */
+  ppd_file_t   *ppd;                   /* PPD file */
+  _pwg_t       *pwg;                   /* PWG mapping data */
+  _pwg_media_t *pwgmedia;              /* PWG media size */
+
+
+  status = 0;
+
+  if (argc != 2)
+  {
+    puts("Usage: ./testpwg filename.ppd");
+    return (1);
+  }
+  else
+    ppdfile = argv[1];
+
+  printf("ppdOpenFile(%s): ", ppdfile);
+  if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+  {
+    ppd_status_t err;                  /* Last error in file */
+    int                line;                   /* Line number in file */
+
+
+    err = ppdLastError(&line);
+
+    printf("FAIL (%s on line %d)\n", ppdErrorString(err), line);
+
+    return (1);
+  }
+  else
+    puts("PASS");
+
+  fputs("_pwgCreateWithPPD(ppd): ", stdout);
+  if ((pwg = _pwgCreateWithPPD(ppd)) == NULL)
+  {
+    puts("FAIL");
+    status ++;
+  }
+  else
+  {
+    puts("PASS");
+    status += test_pwg(pwg);
+
+   /*
+    * _pwgDestroy should never fail...
+    */
+
+    fputs("_pwgDestroy(pwg): ", stdout);
+    _pwgDestroy(pwg);
+    puts("PASS");
+  }
+
+  fputs("_pwgMediaForSize(29700, 42000): ", stdout);
+  if ((pwgmedia = _pwgMediaForSize(29700, 42000)) == NULL)
+  {
+    puts("FAIL (not found)");
+    status ++;
+  }
+  else if (strcmp(pwgmedia->pwg, "iso_a3_297x420mm"))
+  {
+    printf("FAIL (%s)\n", pwgmedia->pwg);
+    status ++;
+  }
+  else
+    puts("PASS");
+
+  return (status);
+}
+
+
+/*
+ * 'test_pwg()' - Test the PWG mapping functions.
+ */
+
+static int                             /* O - 1 on failure, 0 on success */
+test_pwg(_pwg_t *pwg)                  /* I - PWG mapping data */
+{
+  int          i,                      /* Looping var */
+               status = 0;             /* Return status */
+  _pwg_t       *pwg2;                  /* Loaded data */
+  _pwg_size_t  *size,                  /* Size from original */
+               *size2;                 /* Size from saved */
+  _pwg_map_t   *map,                   /* Map from original */
+               *map2;                  /* Map from saved */
+
+
+ /*
+  * Verify that we can write and read back the same data...
+  */
+
+  fputs("_pwgWriteFile(test.pwg): ", stdout);
+  if (!_pwgWriteFile(pwg, "test.pwg"))
+  {
+    puts("FAIL");
+    status ++;
+  }
+  else
+    puts("PASS");
+
+  fputs("_pwgCreateWithFile(test.pwg): ", stdout);
+  if ((pwg2 = _pwgCreateWithFile("test.pwg")) == NULL)
+  {
+    puts("FAIL");
+    status ++;
+  }
+  else
+  {
+    if (pwg2->num_sizes != pwg->num_sizes)
+    {
+      if (!status)
+        puts("FAIL");
+
+      printf("    SAVED num_sizes=%d, ORIG num_sizes=%d\n", pwg2->num_sizes,
+             pwg->num_sizes);
+
+      status ++;
+    }
+    else
+    {
+      for (i = pwg->num_sizes, size = pwg->sizes, size2 = pwg2->sizes;
+           i > 0;
+          i --, size ++, size2 ++)
+      {
+        if (strcmp(size2->map.pwg, size->map.pwg) ||
+           strcmp(size2->map.ppd, size->map.ppd) ||
+           size2->width != size->width ||
+           size2->length != size->length ||
+           size2->left != size->left ||
+           size2->bottom != size->bottom ||
+           size2->right != size->right ||
+           size2->top != size->top)
+       {
+         if (!status)
+           puts("FAIL");
+
+         if (strcmp(size->map.pwg, size2->map.pwg))
+           printf("    SAVED size->map.pwg=\"%s\", ORIG "
+                  "size->map.pwg=\"%s\"\n", size2->map.pwg, size->map.pwg);
+
+         if (strcmp(size2->map.ppd, size->map.ppd))
+           printf("    SAVED size->map.ppd=\"%s\", ORIG "
+                  "size->map.ppd=\"%s\"\n", size2->map.ppd, size->map.ppd);
+
+         if (size2->width != size->width)
+           printf("    SAVED size->width=%d, ORIG size->width=%d\n",
+                  size2->width, size->width);
+
+         if (size2->length != size->length)
+           printf("    SAVED size->length=%d, ORIG size->length=%d\n",
+                  size2->length, size->length);
+
+         if (size2->left != size->left)
+           printf("    SAVED size->left=%d, ORIG size->left=%d\n",
+                  size2->left, size->left);
+
+         if (size2->bottom != size->bottom)
+           printf("    SAVED size->bottom=%d, ORIG size->bottom=%d\n",
+                  size2->bottom, size->bottom);
+
+         if (size2->right != size->right)
+           printf("    SAVED size->right=%d, ORIG size->right=%d\n",
+                  size2->right, size->right);
+
+         if (size2->top != size->top)
+           printf("    SAVED size->top=%d, ORIG size->top=%d\n",
+                  size2->top, size->top);
+
+         status ++;
+         break;
+       }
+      }
+
+      for (i = pwg->num_sources, map = pwg->sources, map2 = pwg2->sources;
+           i > 0;
+          i --, map ++, map2 ++)
+      {
+        if (strcmp(map2->pwg, map->pwg) ||
+           strcmp(map2->ppd, map->ppd))
+       {
+         if (!status)
+           puts("FAIL");
+
+         if (strcmp(map->pwg, map2->pwg))
+           printf("    SAVED source->pwg=\"%s\", ORIG source->pwg=\"%s\"\n",
+                  map2->pwg, map->pwg);
+
+         if (strcmp(map2->ppd, map->ppd))
+           printf("    SAVED source->ppd=\"%s\", ORIG source->ppd=\"%s\"\n",
+                  map2->ppd, map->ppd);
+
+         status ++;
+         break;
+       }
+      }
+
+      for (i = pwg->num_types, map = pwg->types, map2 = pwg2->types;
+           i > 0;
+          i --, map ++, map2 ++)
+      {
+        if (strcmp(map2->pwg, map->pwg) ||
+           strcmp(map2->ppd, map->ppd))
+       {
+         if (!status)
+           puts("FAIL");
+
+         if (strcmp(map->pwg, map2->pwg))
+           printf("    SAVED type->pwg=\"%s\", ORIG type->pwg=\"%s\"\n",
+                  map2->pwg, map->pwg);
+
+         if (strcmp(map2->ppd, map->ppd))
+           printf("    SAVED type->ppd=\"%s\", ORIG type->ppd=\"%s\"\n",
+                  map2->ppd, map->ppd);
+
+         status ++;
+         break;
+       }
+      }
+    }
+
+    if (!status)
+      puts("PASS");
+  }
+
+  return (status);
+}
+
+
+/*
+ * End of "$Id$".
+ */
index 1a8e7c325653c30d33e46a3294e1bd72375c3198..381a1ca320047ee23252a24e2ac89d22767b3df7 100644 (file)
@@ -6,104 +6,107 @@ auth.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 auth.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 auth.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 auth.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h auth.h
-auth.o: client.h policy.h printers.h classes.h job.h conf.h banners.h
-auth.o: dirsvc.h network.h subscriptions.h
+auth.o: client.h policy.h printers.h ../cups/pwg-private.h classes.h job.h
+auth.o: conf.h banners.h dirsvc.h network.h subscriptions.h
 banners.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 banners.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 banners.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 banners.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 banners.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 banners.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-banners.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-banners.o: banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
+banners.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h
+banners.o: classes.h job.h conf.h banners.h dirsvc.h network.h
+banners.o: subscriptions.h ../cups/dir.h
 cert.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 cert.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 cert.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 cert.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 cert.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 cert.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h auth.h
-cert.o: client.h policy.h printers.h classes.h job.h conf.h banners.h
-cert.o: dirsvc.h network.h subscriptions.h
+cert.o: client.h policy.h printers.h ../cups/pwg-private.h classes.h job.h
+cert.o: conf.h banners.h dirsvc.h network.h subscriptions.h
 classes.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 classes.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 classes.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 classes.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 classes.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 classes.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-classes.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-classes.o: banners.h dirsvc.h network.h subscriptions.h
+classes.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h
+classes.o: classes.h job.h conf.h banners.h dirsvc.h network.h
+classes.o: subscriptions.h
 client.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 client.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 client.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 client.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 client.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 client.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-client.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-client.o: banners.h dirsvc.h network.h subscriptions.h
+client.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+client.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 conf.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 conf.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 conf.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 conf.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 conf.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 conf.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h auth.h
-conf.o: client.h policy.h printers.h classes.h job.h conf.h banners.h
-conf.o: dirsvc.h network.h subscriptions.h
+conf.o: client.h policy.h printers.h ../cups/pwg-private.h classes.h job.h
+conf.o: conf.h banners.h dirsvc.h network.h subscriptions.h
 dirsvc.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 dirsvc.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 dirsvc.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 dirsvc.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 dirsvc.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 dirsvc.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-dirsvc.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-dirsvc.o: banners.h dirsvc.h network.h subscriptions.h
+dirsvc.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+dirsvc.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 env.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 env.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h
 env.o: ../cups/string.h ../cups/array.h ../cups/cups.h ../cups/ppd.h
 env.o: ../cups/array.h ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h
 env.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h
 env.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h
-env.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
-env.o: subscriptions.h
+env.o: printers.h ../cups/pwg-private.h classes.h job.h conf.h banners.h
+env.o: dirsvc.h network.h subscriptions.h
 main.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 main.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 main.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 main.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 main.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 main.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h auth.h
-main.o: client.h policy.h printers.h classes.h job.h conf.h banners.h
-main.o: dirsvc.h network.h subscriptions.h ../cups/dir.h
+main.o: client.h policy.h printers.h ../cups/pwg-private.h classes.h job.h
+main.o: conf.h banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
 ipp.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 ipp.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h
 ipp.o: ../cups/string.h ../cups/array.h ../cups/cups.h ../cups/ppd.h
 ipp.o: ../cups/array.h ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h
 ipp.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h
 ipp.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h
-ipp.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
-ipp.o: subscriptions.h ../cups/ppd-private.h ../cups/cups.h
+ipp.o: printers.h ../cups/pwg-private.h classes.h job.h conf.h banners.h
+ipp.o: dirsvc.h network.h subscriptions.h ../cups/ppd-private.h
+ipp.o: ../cups/cups.h
 listen.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 listen.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 listen.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 listen.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 listen.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 listen.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-listen.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-listen.o: banners.h dirsvc.h network.h subscriptions.h
+listen.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+listen.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 job.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 job.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h
 job.o: ../cups/string.h ../cups/array.h ../cups/cups.h ../cups/ppd.h
 job.o: ../cups/array.h ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h
 job.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h
 job.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h
-job.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
-job.o: subscriptions.h ../cups/backend.h ../cups/dir.h
+job.o: printers.h ../cups/pwg-private.h classes.h job.h conf.h banners.h
+job.o: dirsvc.h network.h subscriptions.h ../cups/backend.h ../cups/dir.h
 log.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 log.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h
 log.o: ../cups/string.h ../cups/array.h ../cups/cups.h ../cups/ppd.h
 log.o: ../cups/array.h ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h
 log.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h
 log.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h
-log.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h
-log.o: subscriptions.h
+log.o: printers.h ../cups/pwg-private.h classes.h job.h conf.h banners.h
+log.o: dirsvc.h network.h subscriptions.h
 network.o: ../cups/http-private.h ../config.h ../cups/http.h
 network.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 network.o: ../cups/ipp.h cupsd.h ../cups/string.h ../cups/array.h
@@ -111,57 +114,59 @@ network.o: ../cups/cups.h ../cups/ppd.h ../cups/array.h ../cups/file.h
 network.o: ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h
 network.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h
 network.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h
-network.o: classes.h job.h conf.h banners.h dirsvc.h network.h
-network.o: subscriptions.h
+network.o: ../cups/pwg-private.h classes.h job.h conf.h banners.h dirsvc.h
+network.o: network.h subscriptions.h
 policy.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 policy.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 policy.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 policy.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 policy.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 policy.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-policy.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-policy.o: banners.h dirsvc.h network.h subscriptions.h
+policy.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+policy.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 printers.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 printers.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 printers.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 printers.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 printers.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 printers.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-printers.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-printers.o: banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
-printers.o: ../cups/pwgmedia.h
+printers.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h
+printers.o: classes.h job.h conf.h banners.h dirsvc.h network.h
+printers.o: subscriptions.h ../cups/dir.h
 process.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 process.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 process.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 process.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 process.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 process.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-process.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-process.o: banners.h dirsvc.h network.h subscriptions.h
+process.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h
+process.o: classes.h job.h conf.h banners.h dirsvc.h network.h
+process.o: subscriptions.h
 quotas.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 quotas.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 quotas.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 quotas.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 quotas.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 quotas.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-quotas.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-quotas.o: banners.h dirsvc.h network.h subscriptions.h
+quotas.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+quotas.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 removefile.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 removefile.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 removefile.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 removefile.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 removefile.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h
 removefile.o: ../cups/i18n.h ../cups/transcode.h ../cups/debug.h sysman.h
-removefile.o: statbuf.h cert.h auth.h client.h policy.h printers.h classes.h
-removefile.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
+removefile.o: statbuf.h cert.h auth.h client.h policy.h printers.h
+removefile.o: ../cups/pwg-private.h classes.h job.h conf.h banners.h dirsvc.h
+removefile.o: network.h subscriptions.h
 select.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 select.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 select.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 select.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 select.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 select.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-select.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-select.o: banners.h dirsvc.h network.h subscriptions.h
+select.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+select.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 server.o: ../cups/http-private.h ../config.h ../cups/http.h
 server.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 server.o: ../cups/ipp.h cupsd.h ../cups/string.h ../cups/array.h
@@ -169,15 +174,17 @@ server.o: ../cups/cups.h ../cups/ppd.h ../cups/array.h ../cups/file.h
 server.o: ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h
 server.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h
 server.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h
-server.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h
+server.o: ../cups/pwg-private.h classes.h job.h conf.h banners.h dirsvc.h
+server.o: network.h subscriptions.h
 statbuf.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 statbuf.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 statbuf.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 statbuf.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 statbuf.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 statbuf.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-statbuf.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-statbuf.o: banners.h dirsvc.h network.h subscriptions.h
+statbuf.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h
+statbuf.o: classes.h job.h conf.h banners.h dirsvc.h network.h
+statbuf.o: subscriptions.h
 subscriptions.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 subscriptions.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 subscriptions.o: ../cups/ipp.h ../cups/string.h ../cups/array.h
@@ -185,16 +192,16 @@ subscriptions.o: ../cups/cups.h ../cups/ppd.h ../cups/array.h ../cups/file.h
 subscriptions.o: ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h
 subscriptions.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h
 subscriptions.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h
-subscriptions.o: policy.h printers.h classes.h job.h conf.h banners.h
-subscriptions.o: dirsvc.h network.h subscriptions.h
+subscriptions.o: policy.h printers.h ../cups/pwg-private.h classes.h job.h
+subscriptions.o: conf.h banners.h dirsvc.h network.h subscriptions.h
 sysman.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h
 sysman.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 sysman.o: ../cups/ipp.h ../cups/string.h ../cups/array.h ../cups/cups.h
 sysman.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
 sysman.o: mime.h ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h
 sysman.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h
-sysman.o: auth.h client.h policy.h printers.h classes.h job.h conf.h
-sysman.o: banners.h dirsvc.h network.h subscriptions.h
+sysman.o: auth.h client.h policy.h printers.h ../cups/pwg-private.h classes.h
+sysman.o: job.h conf.h banners.h dirsvc.h network.h subscriptions.h
 filter.o: ../cups/debug.h ../cups/string.h ../config.h mime.h ../cups/array.h
 filter.o: ../cups/versioning.h ../cups/ipp.h ../cups/file.h
 mime.o: ../cups/debug.h ../cups/dir.h ../cups/versioning.h ../cups/string.h
@@ -211,7 +218,8 @@ cups-deviced.o: ../config.h ../cups/http.h ../cups/versioning.h ../cups/md5.h
 cups-deviced.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/globals.h
 cups-deviced.o: ../cups/string.h ../cups/cups.h ../cups/i18n.h
 cups-deviced.o: ../cups/transcode.h ../cups/language.h ../cups/array.h
-cups-deviced.o: ../cups/debug.h ../cups/array.h ../cups/dir.h
+cups-deviced.o: ../cups/pwg-private.h ../cups/cups.h ../cups/ppd.h
+cups-deviced.o: ../cups/file.h ../cups/debug.h ../cups/array.h ../cups/dir.h
 cups-lpd.o: ../cups/http-private.h ../config.h ../cups/http.h
 cups-lpd.o: ../cups/versioning.h ../cups/md5.h ../cups/ipp-private.h
 cups-lpd.o: ../cups/ipp.h ../cups/cups.h ../cups/ppd.h ../cups/array.h
@@ -241,11 +249,14 @@ util.o: util.h ../cups/file-private.h ../cups/http-private.h ../config.h
 util.o: ../cups/http.h ../cups/versioning.h ../cups/md5.h
 util.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/globals.h
 util.o: ../cups/string.h ../cups/cups.h ../cups/i18n.h ../cups/transcode.h
-util.o: ../cups/language.h ../cups/array.h ../cups/debug.h
+util.o: ../cups/language.h ../cups/array.h ../cups/pwg-private.h
+util.o: ../cups/cups.h ../cups/ppd.h ../cups/file.h ../cups/debug.h
 cups-driverd.o: util.h ../cups/file-private.h ../cups/http-private.h
 cups-driverd.o: ../config.h ../cups/http.h ../cups/versioning.h ../cups/md5.h
 cups-driverd.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/globals.h
 cups-driverd.o: ../cups/string.h ../cups/cups.h ../cups/i18n.h
 cups-driverd.o: ../cups/transcode.h ../cups/language.h ../cups/array.h
-cups-driverd.o: ../cups/debug.h ../cups/dir.h ../cups/transcode.h
-cups-driverd.o: ../cups/ppd-private.h ../ppdc/ppdc.h ../cups/file.h
+cups-driverd.o: ../cups/pwg-private.h ../cups/cups.h ../cups/ppd.h
+cups-driverd.o: ../cups/file.h ../cups/debug.h ../cups/dir.h
+cups-driverd.o: ../cups/transcode.h ../cups/ppd-private.h ../ppdc/ppdc.h
+cups-driverd.o: ../cups/file.h
index 58a1ab493ed44ef0c3f33b584c9b573a470f9eab..c4604fc61e8e1a82399b497f52760f94e8fea1fa 100644 (file)
@@ -1347,6 +1347,11 @@ add_job(cupsd_client_t  *con,            /* I - Client connection */
   int          kbytes;                 /* Size of print file */
   int          i;                      /* Looping var */
   int          lowerpagerange;         /* Page range bound */
+  const char   *ppd;                   /* PPD keyword for media selection */
+  int          exact;                  /* Did we have an exact match? */
+  ipp_attribute_t *media_col,          /* media-col attribute */
+               *media_margin;          /* media-*-margin attribute */
+  ipp_t                *unsup_col;             /* media-col in unsupported response */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
@@ -1512,6 +1517,62 @@ add_job(cupsd_client_t  *con,            /* I - Client connection */
     }
   }
 
+ /*
+  * Do media selection as needed...
+  */
+
+  if (!ippFindAttribute(con->request, "InputSlot", IPP_TAG_ZERO) &&
+      (ppd = _pwgGetInputSlot(printer->pwg, con->request, NULL)) != NULL)
+    ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "InputSlot", NULL,
+                 ppd);
+
+  if (!ippFindAttribute(con->request, "MediaType", IPP_TAG_ZERO) &&
+      (ppd = _pwgGetMediaType(printer->pwg, con->request, NULL)) != NULL)
+    ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "MediaType", NULL,
+                 ppd);
+
+  if (!ippFindAttribute(con->request, "PageSize", IPP_TAG_ZERO) &&
+      (ppd = _pwgGetPageSize(printer->pwg, con->request, NULL, &exact)) != NULL)
+  {
+    ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "PageSize", NULL,
+                 ppd);
+
+    if (!exact &&
+        (media_col = ippFindAttribute(con->request, "media-col",
+                                     IPP_TAG_BEGIN_COLLECTION)) != NULL)
+    {
+      send_ipp_status(con, IPP_OK_SUBST, _("Unsupported margins."));
+
+      unsup_col = ippNew();
+      ippAddCollection(con->response, IPP_TAG_UNSUPPORTED_GROUP, "media-col",
+                       unsup_col);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-bottom-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-bottom-margin", media_margin->values[0].integer);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-left-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-left-margin", media_margin->values[0].integer);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-right-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-right-margin", media_margin->values[0].integer);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-top-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-top-margin", media_margin->values[0].integer);
+    }
+  }
+
  /*
   * Make sure we aren't over our limit...
   */
@@ -2883,6 +2944,10 @@ add_printer(cupsd_client_t  *con,        /* I - Client connection */
              printer->name);
     unlink(cache_name);
 
+    snprintf(cache_name, sizeof(cache_name), "%s/%s.pwg", CacheDir,
+             printer->name);
+    unlink(cache_name);
+
 #ifdef __APPLE__
    /*
     * (Re)register color profiles...
@@ -4617,8 +4682,9 @@ copy_attribute(
         for (i = 0; i < attr->num_values; i ++)
        {
          toattr->values[i].collection = ippNew();
+         toattr->values[i].collection->request.status.version[0] = 2;
          copy_attrs(toattr->values[i].collection, attr->values[i].collection,
-                    NULL, IPP_TAG_ZERO, 0);
+                    NULL, IPP_TAG_ZERO, quickcopy);
        }
         break;
 
@@ -4683,11 +4749,14 @@ copy_attrs(ipp_t        *to,            /* I - Destination request */
     {
      /*
       * Don't send collection attributes by default to IPP/1.x clients
-      * since many do not support collections...
+      * since many do not support collections.  Also don't send
+      * media-col-database unless specifically requested by the client.
       */
 
       if (fromattr->value_tag == IPP_TAG_BEGIN_COLLECTION &&
-          !ra && to->request.status.version[0] == 1)
+          !ra &&
+         (to->request.status.version[0] == 1 ||
+          !strcmp(fromattr->name, "media-col-database")))
        continue;
 
       copy_attribute(to, fromattr, quickcopy);
@@ -5052,6 +5121,7 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
   int          i;                      /* Looping var */
   char         option[PPD_MAX_NAME],   /* Option name */
                choice[PPD_MAX_NAME];   /* Choice name */
+  ppd_size_t   *size;                  /* Default size */
   int          num_defaults;           /* Number of default options */
   cups_option_t        *defaults;              /* Default options */
   char         cups_protocol[PPD_MAX_LINE];
@@ -5224,19 +5294,19 @@ copy_model(cupsd_client_t *con,         /* I - Client connection */
 
     cupsFileClose(dst);
   }
-  else if (ppdPageSize(ppd, DefaultPaperSize))
+  else if ((size = ppdPageSize(ppd, DefaultPaperSize)) != NULL)
   {
    /*
     * Add the default media sizes...
     */
 
-    num_defaults = cupsAddOption("PageSize", DefaultPaperSize,
+    num_defaults = cupsAddOption("PageSize", size->name,
                                  num_defaults, &defaults);
-    num_defaults = cupsAddOption("PageRegion", DefaultPaperSize,
+    num_defaults = cupsAddOption("PageRegion", size->name,
                                  num_defaults, &defaults);
-    num_defaults = cupsAddOption("PaperDimension", DefaultPaperSize,
+    num_defaults = cupsAddOption("PaperDimension", size->name,
                                  num_defaults, &defaults);
-    num_defaults = cupsAddOption("ImageableArea", DefaultPaperSize,
+    num_defaults = cupsAddOption("ImageableArea", size->name,
                                  num_defaults, &defaults);
   }
 
@@ -6373,6 +6443,9 @@ delete_printer(cupsd_client_t  *con,      /* I - Client connection */
   snprintf(filename, sizeof(filename), "%s/%s.ipp2", CacheDir, printer->name);
   unlink(filename);
 
+  snprintf(filename, sizeof(filename), "%s/%s.pwg", CacheDir, printer->name);
+  unlink(filename);
+
 #ifdef __APPLE__
  /*
   * Unregister color profiles...
index b77885cf2512ed258ab50a5ee909855bafdcacdc..1823e697f47012a20c72e3655ea3cb443ba6e229 100644 (file)
@@ -51,6 +51,7 @@
  *   delete_string_array()      - Delete an array of CUPS strings.
  *   load_ppd()                 - Load a cached PPD file, updating the cache as
  *                                needed.
+ *   new_media_col()            - Create a media-col collection value.
  *   write_irix_config()        - Update the config files used by the IRIX
  *                                desktop tools.
  *   write_irix_state()         - Update the status files used by IRIX printing
@@ -64,7 +65,6 @@
 
 #include "cupsd.h"
 #include <cups/dir.h>
-#include <cups/pwgmedia.h>
 
 
 /*
@@ -80,6 +80,8 @@ static int    compare_printers(void *first, void *second, void *data);
 static void    delete_printer_filters(cupsd_printer_t *p);
 static void    delete_string_array(cups_array_t **a);
 static void    load_ppd(cupsd_printer_t *p);
+static ipp_t   *new_media_col(_pwg_size_t *size, const char *source,
+                              const char *type);
 #ifdef __sgi
 static void    write_irix_config(cupsd_printer_t *p);
 static void    write_irix_state(cupsd_printer_t *p);
@@ -356,9 +358,12 @@ cupsdCreateCommonData(void)
                };
   static const char * const media_col_supported[] =
                {                       /* media-col-supported values */
+                 "media-bottom-margin",
                  "media-color",
-                 "media-key",
+                 "media-left-margin",
+                 "media-right-margin",
                  "media-size",
+                 "media-top-margin",
                  "media-type"
                };
   static const char * const multiple_document_handling[] =
@@ -396,15 +401,37 @@ cupsdCreateCommonData(void)
                  "server-started",
                  "server-stopped"
                };
+  static const char * const job_creation[] =
+               {                       /* job-creation-attributes-supported */
+                 "copies",
+                 "finishings",
+                 "job-hold-until",
+                 "job-name",
+                 "job-priority",
+                 "job-sheets",
+                 "media",
+                 "media-col",
+                 "multiple-document-handling",
+                 "number-up",
+                 "output-bin",
+                 "orientation-requested",
+                 "page-ranges",
+                 "print-quality",
+                 "printer-resolution",
+                 "sides"
+               };
   static const char * const job_settable[] =
                {                       /* job-settable-attributes-supported */
                  "copies",
                  "finishings",
                  "job-hold-until",
+                 "job-name",
                  "job-priority",
                  "media",
+                 "media-col",
                  "multiple-document-handling",
                  "number-up",
+                 "output-bin",
                  "orientation-requested",
                  "page-ranges",
                  "print-quality",
@@ -459,6 +486,12 @@ cupsdCreateCommonData(void)
                 "ipp-versions-supported", sizeof(versions) / sizeof(versions[0]),
                NULL, versions);
 
+  /* job-creation-attributes-supported */
+  ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY,
+                "job-creation-attributes-supported",
+               sizeof(job_creation) / sizeof(job_creation[0]),
+               NULL, job_creation);
+
   /* job-hold-until-supported */
   ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY,
                 "job-hold-until-supported", sizeof(holds) / sizeof(holds[0]),
@@ -3432,6 +3465,7 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */
     cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-priority-default"));
     cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-sheets-default"));
     cupsArrayAdd(CommonDefaults, _cupsStrAlloc("media-default"));
+    cupsArrayAdd(CommonDefaults, _cupsStrAlloc("media-col-default"));
     cupsArrayAdd(CommonDefaults, _cupsStrAlloc("number-up-default"));
     cupsArrayAdd(CommonDefaults,
                  _cupsStrAlloc("orientation-requested-default"));
@@ -3890,35 +3924,39 @@ delete_string_array(cups_array_t **a)   /* I - Array */
 static void
 load_ppd(cupsd_printer_t *p)           /* I - Printer */
 {
-  int          i;                      /* Looping var */
-  cups_file_t  *cache;                 /* Cache file */
-  char         cache_name[1024];       /* Cache filename */
-  struct stat  cache_info;             /* Cache file info */
+  int          i, j, k;                /* Looping vars */
+  cups_file_t  *cache;                 /* IPP cache file */
+  char         cache_name[1024];       /* IPP cache filename */
+  struct stat  cache_info;             /* IPP cache file info */
+  char         pwg_name[1024];         /* PWG cache filename */
+  struct stat  pwg_info;               /* PWG cache file info */
   ppd_file_t   *ppd;                   /* PPD file */
   char         ppd_name[1024];         /* PPD filename */
   struct stat  ppd_info;               /* PPD file info */
   int          num_media;              /* Number of media options */
-  char         custom_in[256],         /* Custom size name in inches */
-               custom_mm[256];         /* Custom size name in millimeters */
-  ppd_size_t   *size;                  /* Current size */
+  ppd_size_t   *size;                  /* Current PPD size */
   ppd_option_t *duplex,                /* Duplex option */
                *output_bin,            /* OutputBin option */
                *output_mode,           /* OutputMode option */
                *resolution;            /* (Set|JCL|)Resolution option */
-  ppd_choice_t *choice;                /* Current PPD choice */
+  ppd_choice_t *choice,                /* Current PPD choice */
+               *input_slot,            /* Current input slot */
+               *media_type;            /* Current media type */
   ppd_attr_t   *ppd_attr;              /* PPD attribute */
   int          xdpi,                   /* Horizontal resolution */
                ydpi;                   /* Vertical resolution */
   const char   *resptr;                /* Pointer into resolution keyword */
-  _cups_pwg_media_t *pwgmedia;         /* Matching PWG size name */
+  _pwg_size_t  *pwgsize;               /* Current PWG size */
+  _pwg_map_t   *pwgsource,             /* Current PWG source */
+               *pwgtype;               /* Current PWG type */
   ipp_attribute_t *attr;               /* Attribute data */
-  ipp_t                *media_col_default,     /* media-col-default collection value */
-               *media_size;            /* media-size collection value */
   ipp_value_t  *val;                   /* Attribute value */
   int          num_finishings,         /* Number of finishings */
                finishings[5];          /* finishings-supported values */
   int          num_qualities,          /* Number of print-quality values */
                qualities[3];           /* print-quality values */
+  int          num_margins,            /* Number of media-*-margin-supported values */
+               margins[16];            /* media-*-margin-supported values */
   static const char * const sides[3] = /* sides-supported values */
                {
                  "one-sided",
@@ -3941,6 +3979,10 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
   if (stat(cache_name, &cache_info))
     cache_info.st_mtime = 0;
 
+  snprintf(pwg_name, sizeof(pwg_name), "%s/%s.pwg", CacheDir, p->name);
+  if (stat(pwg_name, &pwg_info))
+    pwg_info.st_mtime = 0;
+
   snprintf(ppd_name, sizeof(ppd_name), "%s/ppd/%s.ppd", ServerRoot, p->name);
   if (stat(ppd_name, &ppd_info))
     ppd_info.st_mtime = 1;
@@ -3948,7 +3990,13 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
   ippDelete(p->ppd_attrs);
   p->ppd_attrs = ippNew();
 
-  if (cache_info.st_mtime >= ppd_info.st_mtime &&
+  _pwgDestroy(p->pwg);
+  p->pwg = NULL;
+
+  if (pwg_info.st_mtime >= ppd_info.st_mtime)
+    p->pwg = _pwgCreateWithFile(pwg_name);
+
+  if (cache_info.st_mtime >= ppd_info.st_mtime && p->pwg &&
       (cache = cupsFileOpen(cache_name, "r")) != NULL)
   {
    /*
@@ -3973,6 +4021,9 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
 
   cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
 
+  _pwgDestroy(p->pwg);
+  p->pwg = NULL;
+
   cupsdLogMessage(CUPSD_LOG_DEBUG, "load_ppd: Loading %s...", ppd_name);
 
   delete_string_array(&(p->filters));
@@ -3990,6 +4041,8 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
     * Add make/model and other various attributes...
     */
 
+    p->pwg = _pwgCreateWithPPD(ppd);
+
     ppdMarkDefaults(ppd);
 
     if (ppd->color_device)
@@ -4080,112 +4133,292 @@ load_ppd(cupsd_printer_t *p)          /* I - Printer */
     * Add media options from the PPD file...
     */
 
-    if (ppd->num_sizes == 0)
+    if (ppd->num_sizes == 0 || !p->pwg)
     {
       if (!ppdFindAttr(ppd, "APScannerOnly", NULL))
        cupsdLogMessage(CUPSD_LOG_CRIT,
                        "The PPD file for printer %s contains no media "
                        "options and is therefore invalid!", p->name);
 
+      ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                  "media-default", NULL, "unknown");
       ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
                   "media-supported", NULL, "unknown");
     }
     else
     {
-      num_media = ppd->num_sizes;
-      if (ppd->variable_sizes)
-       num_media ++;
+     /*
+      * media-default
+      */
 
-      attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
-                          "media-supported", num_media, NULL, NULL);
-      if (attr != NULL)
+      if ((size = ppdPageSize(ppd, NULL)) != NULL)
+        pwgsize = _pwgGetSize(p->pwg, size->name);
+      else
+        pwgsize = NULL;
+
+      ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                  "media-default", NULL,
+                  pwgsize ? pwgsize->map.pwg : "unknown");
+
+     /*
+      * media-col-default
+      */
+
+      if (pwgsize)
+      {
+       input_slot = ppdFindMarkedChoice(ppd, "InputSlot");
+       media_type = ppdFindMarkedChoice(ppd, "MediaType");
+
+       ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-default",
+                        new_media_col(pwgsize,
+                                      input_slot ?
+                                          _pwgGetSource(p->pwg,
+                                                        input_slot->choice) :
+                                          NULL,
+                                      media_type ?
+                                          _pwgGetType(p->pwg,
+                                                      media_type->choice) :
+                                          NULL));
+      }
+
+     /*
+      * media-supported
+      */
+
+      num_media = p->pwg->num_sizes;
+      if (p->pwg->custom_min_keyword)
+       num_media += 2;
+
+      if ((attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                               "media-supported", num_media, NULL,
+                               NULL)) != NULL)
       {
        val = attr->values;
 
-        for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
+        for (i = p->pwg->num_sizes, pwgsize = p->pwg->sizes;
+            i > 0;
+            i --, pwgsize ++, val ++)
+         val->string.text = _cupsStrRetain(pwgsize->map.pwg);
+
+        if (p->pwg->custom_min_keyword)
+       {
+         val->string.text = _cupsStrRetain(p->pwg->custom_min_keyword);
+         val ++;
+         val->string.text = _cupsStrRetain(p->pwg->custom_max_keyword);
+        }
+      }
+
+     /*
+      * media-source-supported
+      */
+
+      if (p->pwg->num_sources > 0 &&
+          (attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                               "media-source-supported", p->pwg->num_sources,
+                               NULL, NULL)) != NULL)
+      {
+       for (i = p->pwg->num_sources, pwgsource = p->pwg->sources,
+                val = attr->values;
+            i > 0;
+            i --, pwgsource ++, val ++)
+         val->string.text = _cupsStrRetain(pwgsource->pwg);
+      }
+
+     /*
+      * media-type-supported
+      */
+
+      if (p->pwg->num_types > 0 &&
+          (attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                               "media-type-supported", p->pwg->num_types,
+                               NULL, NULL)) != NULL)
+      {
+       for (i = p->pwg->num_types, pwgtype = p->pwg->types,
+                val = attr->values;
+            i > 0;
+            i --, pwgtype ++, val ++)
+         val->string.text = _cupsStrRetain(pwgtype->pwg);
+      }
+
+     /*
+      * media-*-margin-supported
+      */
+
+      for (i = p->pwg->num_sizes, pwgsize = p->pwg->sizes, num_margins = 0;
+          i > 0 && num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+          i --, pwgsize ++)
+      {
+        for (j = 0; j < num_margins; j ++)
+         if (pwgsize->bottom == margins[j])
+           break;
+
+       if (j >= num_margins)
+       {
+         margins[num_margins] = pwgsize->bottom;
+         num_margins ++;
+       }
+      }
+
+      if (num_margins > 0)
+        ippAddIntegers(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                      "media-bottom-margin-supported", num_margins, margins);
+      else
+        ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                     "media-bottom-margin-supported", 0);
+
+      for (i = p->pwg->num_sizes, pwgsize = p->pwg->sizes, num_margins = 0;
+          i > 0 && num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+          i --, pwgsize ++)
+      {
+        for (j = 0; j < num_margins; j ++)
+         if (pwgsize->left == margins[j])
+           break;
+
+       if (j >= num_margins)
        {
-         if (strcasecmp(size->name, "Custom"))
+         margins[num_margins] = pwgsize->left;
+         num_margins ++;
+       }
+      }
+
+      if (num_margins > 0)
+        ippAddIntegers(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                      "media-left-margin-supported", num_margins, margins);
+      else
+        ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                     "media-left-margin-supported", 0);
+
+      for (i = p->pwg->num_sizes, pwgsize = p->pwg->sizes, num_margins = 0;
+          i > 0 && num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+          i --, pwgsize ++)
+      {
+        for (j = 0; j < num_margins; j ++)
+         if (pwgsize->right == margins[j])
+           break;
+
+       if (j >= num_margins)
+       {
+         margins[num_margins] = pwgsize->right;
+         num_margins ++;
+       }
+      }
+
+      if (num_margins > 0)
+        ippAddIntegers(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                      "media-right-margin-supported", num_margins, margins);
+      else
+        ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                     "media-right-margin-supported", 0);
+
+      for (i = p->pwg->num_sizes, pwgsize = p->pwg->sizes, num_margins = 0;
+          i > 0 && num_margins < (int)(sizeof(margins) / sizeof(margins[0]));
+          i --, pwgsize ++)
+      {
+        for (j = 0; j < num_margins; j ++)
+         if (pwgsize->top == margins[j])
+           break;
+
+       if (j >= num_margins)
+       {
+         margins[num_margins] = pwgsize->top;
+         num_margins ++;
+       }
+      }
+
+      if (num_margins > 0)
+        ippAddIntegers(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                      "media-top-margin-supported", num_margins, margins);
+      else
+        ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+                     "media-top-margin-supported", 0);
+
+     /*
+      * media-col-database
+      */
+
+      num_media = p->pwg->num_sizes;
+      if (p->pwg->num_sources)
+      {
+        if (p->pwg->num_types > 0)
+         num_media += p->pwg->num_sizes * p->pwg->num_sources *
+                      p->pwg->num_types;
+       else
+          num_media += p->pwg->num_sizes * p->pwg->num_sources;
+      }
+      else if (p->pwg->num_types)
+        num_media += p->pwg->num_sizes * p->pwg->num_types;
+
+      if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER,
+                                    "media-col-database", num_media,
+                                   NULL)) != NULL)
+      {
+        for (i = p->pwg->num_sizes, pwgsize = p->pwg->sizes, val = attr->values;
+            i > 0;
+            i --, pwgsize ++)
+       {
+        /*
+         * Start by adding the page size without source or type...
+         */
+
+         ppdMarkOption(ppd, "PageSize", pwgsize->map.ppd);
+
+          val->collection = new_media_col(pwgsize, NULL, NULL);
+         val ++;
+
+         /*
+         * Then add the specific, supported combinations of size, source, and
+         * type...
+         */
+
+         if (p->pwg->num_sources > 0)
          {
-           if ((pwgmedia = _cupsPWGMediaBySize(size->width,
-                                               size->length)) != NULL)
-           {
-             val->string.text = _cupsStrAlloc(pwgmedia->pwg);
-           }
-           else
+           for (j = p->pwg->num_sources, pwgsource = p->pwg->sources;
+                j > 0;
+                j --, pwgsource ++)
            {
-             snprintf(custom_in, sizeof(custom_in), "adobe_%s_%gx%gin",
-                      size->name, size->width / 72.0, size->length / 72.0);
-             snprintf(custom_mm, sizeof(custom_mm), "adobe_%s_%gx%gmm",
-                      size->name, size->width * 25.4 / 72.0,
-                      size->length * 25.4 / 72.0);
-              if (strlen(custom_in) < strlen(custom_mm))
-               val->string.text = _cupsStrAlloc(custom_in);
-             else
-               val->string.text = _cupsStrAlloc(custom_mm);
-           }
+             ppdMarkOption(ppd, "InputSlot", pwgsource->ppd);
 
-           if (size->marked)
+             if (p->pwg->num_types > 0)
+             {
+               for (k = p->pwg->num_types, pwgtype = p->pwg->types;
+                    k > 0;
+                    k --, pwgtype ++)
+               {
+                 if (!ppdMarkOption(ppd, "MediaType", pwgtype->ppd))
+                 {
+                   val->collection = new_media_col(pwgsize, pwgsource->pwg,
+                                                   pwgtype->pwg);
+                   val ++;
+                 }
+               }
+             }
+             else if (!ppdConflicts(ppd))
+             {
+               val->collection = new_media_col(pwgsize, pwgsource->pwg, NULL);
+               val ++;
+             }
+           }
+         }
+         else if (p->pwg->num_types > 0)
+         {
+           for (j = p->pwg->num_types, pwgtype = p->pwg->types;
+                j > 0;
+                j --, pwgtype ++)
            {
-            /*
-             * Add media-default...
-             */
-
-             ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
-                          "media-default", NULL, val->string.text);
-
-             /*
-             * Add media-col-default...
-             */
-
-             media_size = ippNew();
-             ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
-                           "x-dimension", (int)(size->width * 2540.0 / 72.0));
-             ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
-                           "y-dimension", (int)(size->length * 2540.0 / 72.0));
-
-             media_col_default = ippNew();
-             ippAddString(media_col_default, IPP_TAG_PRINTER,
-                          IPP_TAG_KEYWORD | IPP_TAG_COPY, "media-color", NULL,
-                          "white");
-             ippAddString(media_col_default, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
-                          "media-key", NULL,val->string.text);
-             ippAddCollection(media_col_default, IPP_TAG_PRINTER, "media-size",
-                              media_size);
-             ippAddString(media_col_default, IPP_TAG_PRINTER,
-                          IPP_TAG_KEYWORD | IPP_TAG_COPY, "media-type", NULL,
-                          "stationary");
-
-              ippAddCollection(p->ppd_attrs, IPP_TAG_PRINTER,
-                              "media-col-default", media_col_default);
+             if (!ppdMarkOption(ppd, "MediaType", pwgtype->ppd))
+             {
+               val->collection = new_media_col(pwgsize, NULL, pwgtype->pwg);
+               val ++;
+             }
            }
-
-            val ++;
          }
        }
 
-        if (ppd->variable_sizes)
-       {
-         snprintf(custom_in, sizeof(custom_in), "custom_min_%gx%gin",
-                  ppd->custom_min[0] / 72.0, ppd->custom_min[1] / 72.0);
-         snprintf(custom_mm, sizeof(custom_mm), "custom_min_%gx%gmm",
-                  ppd->custom_min[0] * 25.4 / 72.0,
-                  ppd->custom_min[1] * 25.4 / 72.0);
-         if (strlen(custom_in) < strlen(custom_mm))
-           val->string.text = _cupsStrAlloc(custom_in);
-         else
-           val->string.text = _cupsStrAlloc(custom_mm);
-         val ++;
+       /*
+        * Update the number of media-col-database values...
+       */
 
-         snprintf(custom_in, sizeof(custom_in), "custom_max_%gx%gin",
-                  ppd->custom_max[0] / 72.0, ppd->custom_max[1] / 72.0);
-         snprintf(custom_mm, sizeof(custom_mm), "custom_max_%gx%gmm",
-                  ppd->custom_max[0] * 25.4 / 72.0,
-                  ppd->custom_max[1] * 25.4 / 72.0);
-         if (strlen(custom_in) < strlen(custom_mm))
-           val->string.text = _cupsStrAlloc(custom_in);
-         else
-           val->string.text = _cupsStrAlloc(custom_mm);
-       }
+       attr->num_values = val - attr->values;
       }
     }
 
@@ -4684,7 +4917,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
   ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM,
                "finishings-default", IPP_FINISHINGS_NONE);
 
-  if (ppd && (cache = cupsFileOpen(cache_name, "w")) != NULL)
+  if (ppd && (cache = cupsFileOpen(cache_name, "w9")) != NULL)
   {
    /*
     * Save cached PPD attributes to disk...
@@ -4704,18 +4937,67 @@ load_ppd(cupsd_printer_t *p)            /* I - Printer */
     }
 
     cupsFileClose(cache);
+
+    _pwgWriteFile(p->pwg, pwg_name);
   }
-  else if (cache_info.st_mtime)
+  else
   {
    /*
-    * Remove cache file...
+    * Remove cache files...
     */
 
-    unlink(cache_name);
+    if (cache_info.st_mtime)
+      unlink(cache_name);
+
+    if (pwg_info.st_mtime)
+      unlink(pwg_name);
   }
 }
 
 
+/*
+ * 'new_media_col()' - Create a media-col collection value.
+ */
+
+static ipp_t *                         /* O - Collection value */
+new_media_col(_pwg_size_t *size,       /* I - media-size/margin values */
+              const char  *source,     /* I - media-source value */
+              const char  *type)       /* I - media-type value */
+{
+  ipp_t        *media_col,                     /* Collection value */
+       *media_size;                    /* media-size value */
+
+
+  media_col = ippNew();
+
+  media_size = ippNew();
+  ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+               "x-dimension", size->width);
+  ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+               "y-dimension", size->length);
+
+  ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size);
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+               "media-bottom-margin", size->bottom);
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+               "media-left-margin", size->left);
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+               "media-right-margin", size->right);
+  ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+               "media-top-margin", size->top);
+
+  if (source)
+    ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source",
+                NULL, source);
+
+  if (type)
+    ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type",
+                NULL, type);
+
+  return (media_col);
+}
+
+
 #ifdef __sgi
 /*
  * 'write_irix_config()' - Update the config files used by the IRIX
index 327909240b32c9b6cf4ad5cb5eabd9ff6007a29e..f594a2492c76f899e7f6ad955540c3e2baa56596 100644 (file)
@@ -16,6 +16,8 @@
 #ifdef HAVE_DNSSD
 #  include <dns_sd.h>
 #endif /* HAVE_DNSSD */
+#include <cups/pwg-private.h>
+
 
 /*
  * Quota data...
@@ -94,6 +96,7 @@ typedef struct cupsd_printer_s
   time_t       marker_time;            /* Last time marker attributes were updated */
   cups_array_t *filters,               /* Filters for queue */
                *pre_filters;           /* Pre-filters for queue */
+  _pwg_t       *pwg;                   /* PWG<->PPD mapping data */
 
 #ifdef HAVE_DNSSD
   char         *reg_name,              /* Name used for service registration */
index c9f64de95acedf40413ec4cdeafec4efa8bb7472..fb5e1e30d50237617d2d83de6b8ec27db411c27a 100644 (file)
@@ -2911,8 +2911,6 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
   ppd_size_t   *size;                  /* Current size */
   int          width,                  /* Custom width */
                length;                 /* Custom length */
-  char         name[PPD_MAX_NAME],     /* Size name without dot suffix */
-               *nameptr;               /* Pointer into name */
   const char   *prefix;                /* WARN/FAIL prefix */
   ppd_option_t *page_size,             /* PageSize option */
                *page_region;           /* PageRegion option */
index 664bd6c53b8f6a8989309663ed2b12942323cea0..c123c3e102161cfba582d70c354990e38b761bab 100644 (file)
@@ -17,6 +17,7 @@
        ATTR charset attributes-charset utf-8
        ATTR language attributes-natural-language en
        ATTR uri printer-uri $uri
+       ATTR keyword requested-attributes printer-defaults,printer-description,media-col-database
 
        # What statuses are OK?
        STATUS successful-ok
index 6c271979b05b22f85eee6bf7d3cb60db37859cbd..373825ab3cabe7dcd6f9963ac90214aa18d35d66 100644 (file)
@@ -22,8 +22,8 @@
        ATTR collection media-col {
                MEMBER collection media-size {
                        # 4x6
-                       MEMBER integer media-x-dimension 10160
-                       MEMBER integer media-y-dimension 15240
+                       MEMBER integer x-dimension 10160
+                       MEMBER integer y-dimension 15240
                }
        }