]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Update MIME unit test:
authorMichael R Sweet <msweet@msweet.org>
Fri, 17 Oct 2025 17:30:00 +0000 (13:30 -0400)
committerMichael R Sweet <msweet@msweet.org>
Fri, 17 Oct 2025 17:30:00 +0000 (13:30 -0400)
- Use test-internal.h header.
- Add support for finding list of source formats for a given dest
  format, like cupsd does, and include timing information.
- Migrate to C99 comments.
- Modernize CUPS array API usage.

scheduler/Dependencies
scheduler/mime.c
scheduler/testmime.c

index 0550619bccb8e83eaa0fa5ab7876eb75bc469d36..09eecfcb905a75cb6681114f26beb6bd16319c11 100644 (file)
@@ -21,14 +21,13 @@ auth.o: auth.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 banners.o: banners.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -52,14 +51,13 @@ banners.o: banners.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h ../cups/dir.h
 cert.o: cert.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -83,14 +81,13 @@ cert.o: cert.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 classes.o: classes.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -114,14 +111,13 @@ classes.o: classes.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 client.o: client.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -145,14 +141,13 @@ client.o: client.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 colorman.o: colorman.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -176,14 +171,13 @@ colorman.o: colorman.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 conf.o: conf.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -207,14 +201,13 @@ conf.o: conf.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 dirsvc.o: dirsvc.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -238,14 +231,13 @@ dirsvc.o: dirsvc.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 env.o: env.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -269,14 +261,13 @@ env.o: env.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 file.o: file.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -300,14 +291,13 @@ file.o: file.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h ../cups/dir.h
 main.o: main.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -331,14 +321,13 @@ main.o: main.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 ipp.o: ipp.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -362,14 +351,13 @@ ipp.o: ipp.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 listen.o: listen.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -393,14 +381,13 @@ listen.o: listen.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 job.o: job.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -424,15 +411,13 @@ job.o: job.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h ../cups/backend.h \
-  ../cups/dir.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h ../cups/backend.h ../cups/dir.h
 log.o: log.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   ../config.h ../cups/base.h ../cups/debug-internal.h \
   ../cups/debug-private.h ../cups/ipp-private.h ../cups/cups.h \
@@ -456,14 +441,13 @@ log.o: log.c cupsd.h ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 network.o: network.c ../cups/http-private.h ../config.h \
   ../cups/language.h ../cups/array.h ../cups/base.h ../cups/http.h \
   ../cups/ipp-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
@@ -485,16 +469,14 @@ network.o: network.c ../cups/http-private.h ../config.h \
   \
   \
   \
-  \
-  \
-  \
-  cupsd.h ../cups/cups-private.h ../cups/string-private.h \
-  ../cups/debug-internal.h ../cups/debug-private.h \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h \
+  cupsd.h ../cups/cups-private.h \
+  ../cups/string-private.h ../cups/debug-internal.h \
+  ../cups/debug-private.h ../cups/language-private.h ../cups/transcode.h \
+  ../cups/pwg-private.h ../cups/thread.h ../cups/file-private.h \
+  ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h ../cups/dnssd.h \
+  mime.h sysman.h statbuf.h cert.h auth.h ../cups/oauth.h ../cups/jwt.h \
+  ../cups/json.h client.h policy.h printers.h classes.h job.h colorman.h \
+  conf.h banners.h dirsvc.h network.h subscriptions.h \
   ../cups/getifaddrs-internal.h
 policy.o: policy.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
@@ -519,14 +501,13 @@ policy.o: policy.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 printers.o: printers.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -550,14 +531,13 @@ printers.o: printers.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h ../cups/dir.h
 process.o: process.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -581,14 +561,13 @@ process.o: process.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 quotas.o: quotas.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -612,14 +591,13 @@ quotas.o: quotas.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 select.o: select.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -643,14 +621,13 @@ select.o: select.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 server.o: server.c ../cups/http-private.h ../config.h ../cups/language.h \
   ../cups/array.h ../cups/base.h ../cups/http.h ../cups/ipp-private.h \
   ../cups/cups.h ../cups/file.h ../cups/ipp.h ../cups/pwg.h \
@@ -672,16 +649,14 @@ server.o: server.c ../cups/http-private.h ../config.h ../cups/language.h \
   \
   \
   \
-  \
-  \
-  \
-  cupsd.h ../cups/cups-private.h ../cups/string-private.h \
-  ../cups/debug-internal.h ../cups/debug-private.h \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  cupsd.h ../cups/cups-private.h \
+  ../cups/string-private.h ../cups/debug-internal.h \
+  ../cups/debug-private.h ../cups/language-private.h ../cups/transcode.h \
+  ../cups/pwg-private.h ../cups/thread.h ../cups/file-private.h \
+  ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h ../cups/dnssd.h \
+  mime.h sysman.h statbuf.h cert.h auth.h ../cups/oauth.h ../cups/jwt.h \
+  ../cups/json.h client.h policy.h printers.h classes.h job.h colorman.h \
+  conf.h banners.h dirsvc.h network.h subscriptions.h
 statbuf.o: statbuf.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -705,14 +680,13 @@ statbuf.o: statbuf.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 subscriptions.o: subscriptions.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -736,14 +710,13 @@ subscriptions.o: subscriptions.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 sysman.o: sysman.c cupsd.h ../cups/cups-private.h \
   ../cups/string-private.h ../config.h ../cups/base.h \
   ../cups/debug-internal.h ../cups/debug-private.h ../cups/ipp-private.h \
@@ -767,14 +740,13 @@ sysman.o: sysman.c cupsd.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h sysman.h statbuf.h cert.h auth.h \
-  client.h policy.h printers.h classes.h job.h colorman.h conf.h \
-  banners.h dirsvc.h network.h subscriptions.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h ../cups/dnssd.h mime.h sysman.h statbuf.h cert.h \
+  auth.h ../cups/oauth.h ../cups/jwt.h ../cups/json.h client.h policy.h \
+  printers.h classes.h job.h colorman.h conf.h banners.h dirsvc.h \
+  network.h subscriptions.h
 filter.o: filter.c ../cups/cups.h ../cups/file.h ../cups/base.h \
   ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
   ../cups/pwg.h ../cups/string-private.h ../config.h mime.h \
@@ -809,12 +781,10 @@ cupsfilter.o: cupsfilter.c ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/file-private.h ../cups/ppd-private.h \
-  ../cups/ppd.h ../cups/raster.h mime.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/file-private.h ../cups/ppd-private.h ../cups/ppd.h \
+  ../cups/raster.h mime.h
 cups-deviced.o: cups-deviced.c util.h ../cups/file-private.h \
   ../cups/cups-private.h ../cups/string-private.h ../config.h \
   ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
@@ -838,11 +808,9 @@ cups-deviced.o: cups-deviced.c util.h ../cups/file-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/dir.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/dir.h
 cups-exec.o: cups-exec.c ../cups/string-private.h ../config.h \
   ../cups/base.h ../cups/file.h
 cups-lpd.o: cups-lpd.c ../cups/cups-private.h ../cups/string-private.h \
@@ -868,16 +836,13 @@ cups-lpd.o: cups-lpd.c ../cups/cups-private.h ../cups/string-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h
 testlpd.o: testlpd.c ../cups/cups.h ../cups/file.h ../cups/base.h \
   ../cups/ipp.h ../cups/http.h ../cups/array.h ../cups/language.h \
   ../cups/pwg.h ../cups/string-private.h ../config.h
-testmime.o: testmime.c ../cups/string-private.h ../config.h \
-  ../cups/base.h ../cups/dir.h ../cups/debug-private.h \
+testmime.o: testmime.c ../cups/test-internal.h ../cups/string-private.h \
+  ../config.h ../cups/base.h ../cups/dir.h ../cups/debug-private.h \
   ../cups/ppd-private.h ../cups/cups.h ../cups/file.h ../cups/ipp.h \
   ../cups/http.h ../cups/array.h ../cups/language.h ../cups/pwg.h \
   ../cups/ppd.h ../cups/raster.h ../cups/pwg-private.h mime.h \
@@ -913,11 +878,8 @@ util.o: util.c util.h ../cups/file-private.h ../cups/cups-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h
 cups-driverd.o: cups-driverd.cxx util.h ../cups/file-private.h \
   ../cups/cups-private.h ../cups/string-private.h ../config.h \
   ../cups/base.h ../cups/debug-internal.h ../cups/debug-private.h \
@@ -941,9 +903,7 @@ cups-driverd.o: cups-driverd.cxx util.h ../cups/file-private.h \
   \
   \
   \
-  \
-  \
-  \
-  ../cups/language-private.h ../cups/transcode.h ../cups/pwg-private.h \
-  ../cups/thread.h ../cups/dir.h ../cups/ppd-private.h ../cups/ppd.h \
-  ../cups/raster.h ../ppdc/ppdc.h
+  ../cups/language-private.h \
+  ../cups/transcode.h ../cups/pwg-private.h ../cups/thread.h \
+  ../cups/dir.h ../cups/ppd-private.h ../cups/ppd.h ../cups/raster.h \
+  ../ppdc/ppdc.h
index 84faf7d196bfeca883a55e35f67f2aceae7fc3d9..4ecafed4fb5fe0ea2939d1b77affbf6625cffe62 100644 (file)
@@ -1,16 +1,13 @@
-/*
- * MIME database file routines for CUPS.
- *
- * Copyright Â©Â 2020-2024 by OpenPrinting.
- * Copyright 2007-2014 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// MIME database file routines for CUPS.
+//
+// Copyright Â©Â 2020-2025 by OpenPrinting.
+// Copyright Â©Â 2007-2014 by Apple Inc.
+// Copyright Â©Â 1997-2006 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include <cups/cups.h>
 #include <cups/string-private.h>
 #include "mime-private.h"
 
 
-/*
- * Debug macros that used to be private API...
- */
+//
+// Debug macros that used to be private API...
+//
 
 #define DEBUG_puts(x)
 #define DEBUG_printf(...)
 
 
-/*
- * Local types...
- */
+//
+// Local types...
+//
 
-typedef struct _mime_fcache_s          /**** Filter cache structure ****/
+typedef struct _mime_fcache_s          // Filter cache structure
 {
-  char *name,                          /* Filter name */
-       *path;                          /* Full path to filter if available */
+  char *name,                          // Filter name
+       *path;                          // Full path to filter if available
 } _mime_fcache_t;
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
-static const char *mime_add_fcache(cups_array_t *filtercache, const char *name,
-                                  const char *filterpath);
+static const char *mime_add_fcache(cups_array_t *filtercache, const char *name, const char *filterpath);
 static int     mime_compare_fcache(_mime_fcache_t *a, _mime_fcache_t *b, void *data);
 static void    mime_delete_fcache(cups_array_t *filtercache);
 static void    mime_delete_rules(mime_magic_t *rules);
-static void    mime_load_convs(mime_t *mime, const char *filename,
-                               const char *filterpath,
-                               cups_array_t *filtercache);
+static void    mime_load_convs(mime_t *mime, const char *filename, const char *filterpath, cups_array_t *filtercache);
 static void    mime_load_types(mime_t *mime, const char *filename);
 
 
-/*
- * 'mimeDelete()' - Delete (free) a MIME database.
- */
+//
+// 'mimeDelete()' - Delete (free) a MIME database.
+//
 
 void
-mimeDelete(mime_t *mime)               /* I - MIME database */
+mimeDelete(mime_t *mime)               // I - MIME database
 {
-  mime_type_t  *type;                  /* Current type */
-  mime_filter_t        *filter;                /* Current filter */
+  mime_type_t  *type;                  // Current type
+  mime_filter_t        *filter;                // Current filter
 
 
   DEBUG_printf("mimeDelete(mime=%p)", mime);
@@ -68,28 +62,15 @@ mimeDelete(mime_t *mime)            /* I - MIME database */
   if (!mime)
     return;
 
- /*
-  * Loop through filters and free them...
-  */
-
-  for (filter = (mime_filter_t *)cupsArrayFirst(mime->filters);
-       filter;
-       filter = (mime_filter_t *)cupsArrayNext(mime->filters))
+  // Loop through filters and free them...
+  for (filter = (mime_filter_t *)cupsArrayGetFirst(mime->filters); filter; filter = (mime_filter_t *)cupsArrayGetNext(mime->filters))
     mimeDeleteFilter(mime, filter);
 
- /*
-  * Loop through the file types and delete any rules...
-  */
-
-  for (type = (mime_type_t *)cupsArrayFirst(mime->types);
-       type;
-       type = (mime_type_t *)cupsArrayNext(mime->types))
+  // Loop through the file types and delete any rules...
+  for (type = (mime_type_t *)cupsArrayGetFirst(mime->types); type; type = (mime_type_t *)cupsArrayGetNext(mime->types))
     mimeDeleteType(mime, type);
 
- /*
-  * Free the types and filters arrays, and then the MIME database structure.
-  */
-
+  // Free the types and filters arrays, and then the MIME database structure.
   cupsArrayDelete(mime->types);
   cupsArrayDelete(mime->filters);
   cupsArrayDelete(mime->srcs);
@@ -97,22 +78,15 @@ mimeDelete(mime_t *mime)            /* I - MIME database */
 }
 
 
-/*
- * 'mimeDeleteFilter()' - Delete a filter from the MIME database.
- */
+//
+// 'mimeDeleteFilter()' - Delete a filter from the MIME database.
+//
 
 void
-mimeDeleteFilter(mime_t        *mime,  /* I - MIME database */
-                mime_filter_t *filter) /* I - Filter */
+mimeDeleteFilter(mime_t        *mime,  // I - MIME database
+                mime_filter_t *filter) // I - Filter
 {
-  DEBUG_printf(("mimeDeleteFilter(mime=%p, filter=%p(%s/%s->%s/%s, cost=%d, "
-                "maxsize=" CUPS_LLFMT "))", mime, filter,
-               filter ? filter->src->super : "???",
-               filter ? filter->src->type : "???",
-               filter ? filter->dst->super : "???",
-               filter ? filter->dst->super : "???",
-               filter ? filter->cost : -1,
-               filter ? CUPS_LLCAST filter->maxsize : CUPS_LLCAST -1));
+  DEBUG_printf("mimeDeleteFilter(mime=%p, filter=%p(%s/%s->%s/%s, cost=%d, maxsize=" CUPS_LLFMT "))", mime, filter, filter ? filter->src->super : "???", filter ? filter->src->type : "???", filter ? filter->dst->super : "???", filter ? filter->dst->super : "???", filter ? filter->cost : -1, filter ? CUPS_LLCAST filter->maxsize : CUPS_LLCAST -1);
 
   if (!mime || !filter)
     return;
@@ -120,16 +94,12 @@ mimeDeleteFilter(mime_t        *mime,      /* I - MIME database */
 #ifdef DEBUG
   if (!cupsArrayFind(mime->filters, filter))
     DEBUG_puts("1mimeDeleteFilter: Filter not in MIME database.");
-#endif /* DEBUG */
+#endif // DEBUG
 
   cupsArrayRemove(mime->filters, filter);
   free(filter);
 
- /*
-  * Deleting a filter invalidates the source lookup cache used by
-  * mimeFilter()...
-  */
-
+  // Deleting a filter invalidates the source lookup cache used by mimeFilter()...
   if (mime->srcs)
   {
     DEBUG_puts("1mimeDeleteFilter: Deleting source lookup cache.");
@@ -139,13 +109,13 @@ mimeDeleteFilter(mime_t        *mime,     /* I - MIME database */
 }
 
 
-/*
- * 'mimeDeleteType()' - Delete a type from the MIME database.
- */
+//
+// 'mimeDeleteType()' - Delete a type from the MIME database.
+//
 
 void
-mimeDeleteType(mime_t      *mime,      /* I - MIME database */
-              mime_type_t *mt)         /* I - Type */
+mimeDeleteType(mime_t      *mime,      // I - MIME database
+              mime_type_t *mt)         // I - Type
 {
   DEBUG_printf("mimeDeleteType(mime=%p, mt=%p(%s/%s))", mime, mt, mt ? mt->super : "???", mt ? mt->type : "???");
 
@@ -155,7 +125,7 @@ mimeDeleteType(mime_t      *mime,   /* I - MIME database */
 #ifdef DEBUG
   if (!cupsArrayFind(mime->types, mt))
     DEBUG_puts("1mimeDeleteFilter: Type not in MIME database.");
-#endif /* DEBUG */
+#endif // DEBUG
 
   cupsArrayRemove(mime->types, mt);
 
@@ -164,17 +134,17 @@ mimeDeleteType(mime_t      *mime, /* I - MIME database */
 }
 
 
-/*
- * '_mimeError()' - Show an error message.
- */
+//
+// '_mimeError()' - Show an error message.
+//
 
 void
-_mimeError(mime_t     *mime,           /* I - MIME database */
-           const char *message,                /* I - Printf-style message string */
-          ...)                         /* I - Additional arguments as needed */
+_mimeError(mime_t     *mime,           // I - MIME database
+           const char *message,                // I - Printf-style message string
+          ...)                         // I - Additional arguments as needed
 {
-  va_list      ap;                     /* Argument pointer */
-  char         buffer[8192];           /* Message buffer */
+  va_list      ap;                     // Argument pointer
+  char         buffer[8192];           // Message buffer
 
 
   if (mime->error_cb)
@@ -188,12 +158,12 @@ _mimeError(mime_t     *mime,              /* I - MIME database */
 }
 
 
-/*
- * 'mimeFirstFilter()' - Get the first filter in the MIME database.
- */
+//
+// 'mimeFirstFilter()' - Get the first filter in the MIME database.
+//
 
-mime_filter_t *                                /* O - Filter or NULL */
-mimeFirstFilter(mime_t *mime)          /* I - MIME database */
+mime_filter_t *                                // O - Filter or NULL
+mimeFirstFilter(mime_t *mime)          // I - MIME database
 {
   DEBUG_printf("6mimeFirstFilter(mime=%p)", mime);
 
@@ -204,8 +174,8 @@ mimeFirstFilter(mime_t *mime)               /* I - MIME database */
   }
   else
   {
-    mime_filter_t *first = (mime_filter_t *)cupsArrayFirst(mime->filters);
-                                       /* First filter */
+    mime_filter_t *first = (mime_filter_t *)cupsArrayGetFirst(mime->filters);
+                                       // First filter
 
     DEBUG_printf("7mimeFirstFilter: Returning %p.", first);
     return (first);
@@ -213,12 +183,12 @@ mimeFirstFilter(mime_t *mime)             /* I - MIME database */
 }
 
 
-/*
- * 'mimeFirstType()' - Get the first type in the MIME database.
- */
+//
+// 'mimeFirstType()' - Get the first type in the MIME database.
+//
 
-mime_type_t *                          /* O - Type or NULL */
-mimeFirstType(mime_t *mime)            /* I - MIME database */
+mime_type_t *                          // O - Type or NULL
+mimeFirstType(mime_t *mime)            // I - MIME database
 {
   DEBUG_printf("6mimeFirstType(mime=%p)", mime);
 
@@ -229,8 +199,8 @@ mimeFirstType(mime_t *mime)         /* I - MIME database */
   }
   else
   {
-    mime_type_t *first = (mime_type_t *)cupsArrayFirst(mime->types);
-                                       /* First type */
+    mime_type_t *first = (mime_type_t *)cupsArrayGetFirst(mime->types);
+                                       // First type
 
     DEBUG_printf("7mimeFirstType: Returning %p.", first);
     return (first);
@@ -238,21 +208,20 @@ mimeFirstType(mime_t *mime)               /* I - MIME database */
 }
 
 
-/*
- * 'mimeLoad()' - Create a new MIME database from disk.
- *
- * This function uses @link mimeLoadFilters@ and @link mimeLoadTypes@ to
- * create a MIME database from a single directory.
- */
+//
+// 'mimeLoad()' - Create a new MIME database from disk.
+//
+// This function uses @link mimeLoadFilters@ and @link mimeLoadTypes@ to
+// create a MIME database from a single directory.
+//
 
-mime_t *                               /* O - New MIME database */
-mimeLoad(const char *pathname,         /* I - Directory to load */
-         const char *filterpath)       /* I - Directory to load */
+mime_t *                               // O - New MIME database
+mimeLoad(const char *pathname,         // I - Directory to load
+         const char *filterpath)       // I - Directory to load
 {
-  mime_t *mime;                                /* New MIME database */
+  mime_t *mime;                                // New MIME database
 
-  DEBUG_printf(("mimeLoad(pathname=\"%s\", filterpath=\"%s\")", pathname,
-                filterpath));
+  DEBUG_printf("mimeLoad(pathname=\"%s\", filterpath=\"%s\")", pathname, filterpath);
 
   mime = mimeLoadFilters(mimeLoadTypes(NULL, pathname), pathname, filterpath);
   DEBUG_printf("1mimeLoad: Returning %p.", mime);
@@ -261,64 +230,49 @@ mimeLoad(const char *pathname,            /* I - Directory to load */
 }
 
 
-/*
- * 'mimeLoadFilters()' - Load filter definitions from disk.
- *
- * This function loads all of the .convs files from the specified directory.
- * Use @link mimeLoadTypes@ to load all types before you load the filters.
- */
+//
+// 'mimeLoadFilters()' - Load filter definitions from disk.
+//
+// This function loads all of the .convs files from the specified directory.
+// Use @link mimeLoadTypes@ to load all types before you load the filters.
+//
 
-mime_t *                               /* O - MIME database */
-mimeLoadFilters(mime_t     *mime,      /* I - MIME database */
-                const char *pathname,  /* I - Directory to load from */
-                const char *filterpath)        /* I - Default filter program directory */
+mime_t *                               // O - MIME database
+mimeLoadFilters(mime_t     *mime,      // I - MIME database
+                const char *pathname,  // I - Directory to load from
+                const char *filterpath)        // I - Default filter program directory
 {
-  cups_dir_t   *dir;                   /* Directory */
-  cups_dentry_t        *dent;                  /* Directory entry */
-  char         filename[1024];         /* Full filename of .convs file */
-  cups_array_t *filtercache;           /* Filter cache */
-
+  cups_dir_t   *dir;                   // Directory
+  cups_dentry_t        *dent;                  // Directory entry
+  char         filename[1024];         // Full filename of .convs file
+  cups_array_t *filtercache;           // Filter cache
 
-  DEBUG_printf(("mimeLoadFilters(mime=%p, pathname=\"%s\", filterpath=\"%s\")",
-               mime, pathname, filterpath));
 
- /*
-  * Range check input...
-  */
+  DEBUG_printf("mimeLoadFilters(mime=%p, pathname=\"%s\", filterpath=\"%s\")", mime, pathname, filterpath);
 
+  // Range check input...
   if (!mime || !pathname || !filterpath)
   {
     DEBUG_puts("1mimeLoadFilters: Bad arguments.");
     return (mime);
   }
 
- /*
-  * Then open the directory specified by pathname...
-  */
-
+  // Then open the directory specified by pathname...
   if ((dir = cupsDirOpen(pathname)) == NULL)
   {
-    DEBUG_printf(("1mimeLoadFilters: Unable to open \"%s\": %s", pathname,
-                  strerror(errno)));
+    DEBUG_printf("1mimeLoadFilters: Unable to open \"%s\": %s", pathname, strerror(errno));
     _mimeError(mime, "Unable to open \"%s\": %s", pathname, strerror(errno));
     return (mime);
   }
 
- /*
-  * Read all the .convs files...
-  */
-
+  // Read all the .convs files...
   filtercache = cupsArrayNew((cups_array_func_t)mime_compare_fcache, NULL);
 
   while ((dent = cupsDirRead(dir)) != NULL)
   {
-    if (strlen(dent->filename) > 6 &&
-        !strcmp(dent->filename + strlen(dent->filename) - 6, ".convs"))
+    if (strlen(dent->filename) > 6 && !strcmp(dent->filename + strlen(dent->filename) - 6, ".convs"))
     {
-     /*
-      * Load a mime.convs file...
-      */
-
+      // Load a mime.convs file...
       snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
       DEBUG_printf("1mimeLoadFilters: Loading \"%s\".", filename);
       mime_load_convs(mime, filename, filterpath, filtercache);
@@ -333,41 +287,34 @@ mimeLoadFilters(mime_t     *mime, /* I - MIME database */
 }
 
 
-/*
- * 'mimeLoadTypes()' - Load type definitions from disk.
- *
- * This function loads all of the .types files from the specified directory.
- * Use @link mimeLoadFilters@ to load all filters after you load the types.
- */
+//
+// 'mimeLoadTypes()' - Load type definitions from disk.
+//
+// This function loads all of the .types files from the specified directory.
+// Use @link mimeLoadFilters@ to load all filters after you load the types.
+//
 
-mime_t *                               /* O - MIME database */
-mimeLoadTypes(mime_t     *mime,                /* I - MIME database or @code NULL@ to create a new one */
-              const char *pathname)    /* I - Directory to load from */
+mime_t *                               // O - MIME database
+mimeLoadTypes(mime_t     *mime,                // I - MIME database or @code NULL@ to create a new one
+              const char *pathname)    // I - Directory to load from
 {
-  cups_dir_t   *dir;                   /* Directory */
-  cups_dentry_t        *dent;                  /* Directory entry */
-  char         filename[1024];         /* Full filename of .types file */
+  cups_dir_t   *dir;                   // Directory
+  cups_dentry_t        *dent;                  // Directory entry
+  char         filename[1024];         // Full filename of .types file
 
 
   DEBUG_printf("mimeLoadTypes(mime=%p, pathname=\"%s\")", mime, pathname);
 
- /*
-  * First open the directory specified by pathname...
-  */
-
+  // First open the directory specified by pathname...
   if ((dir = cupsDirOpen(pathname)) == NULL)
   {
-    DEBUG_printf(("1mimeLoadTypes: Unable to open \"%s\": %s", pathname,
-                  strerror(errno)));
+    DEBUG_printf("1mimeLoadTypes: Unable to open \"%s\": %s", pathname, strerror(errno));
     DEBUG_printf("1mimeLoadTypes: Returning %p.", mime);
     _mimeError(mime, "Unable to open \"%s\": %s", pathname, strerror(errno));
     return (mime);
   }
 
- /*
-  * If "mime" is NULL, make a new, empty database...
-  */
-
+  // If "mime" is NULL, make a new, empty database...
   if (!mime)
     mime = mimeNew();
 
@@ -378,19 +325,12 @@ mimeLoadTypes(mime_t     *mime,           /* I - MIME database or @code NULL@ to create a
     return (NULL);
   }
 
- /*
-  * Read all the .types files...
-  */
-
+  // Read all the .types files...
   while ((dent = cupsDirRead(dir)) != NULL)
   {
-    if (strlen(dent->filename) > 6 &&
-        !strcmp(dent->filename + strlen(dent->filename) - 6, ".types"))
+    if (strlen(dent->filename) > 6 && !strcmp(dent->filename + strlen(dent->filename) - 6, ".types"))
     {
-     /*
-      * Load a mime.types file...
-      */
-
+      // Load a mime.types file...
       snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
       DEBUG_printf("1mimeLoadTypes: Loading \"%s\".", filename);
       mime_load_types(mime, filename);
@@ -405,23 +345,23 @@ mimeLoadTypes(mime_t     *mime,           /* I - MIME database or @code NULL@ to create a
 }
 
 
-/*
- * 'mimeNew()' - Create a new, empty MIME database.
- */
+//
+// 'mimeNew()' - Create a new, empty MIME database.
+//
 
-mime_t *                               /* O - MIME database */
+mime_t *                               // O - MIME database
 mimeNew(void)
 {
   return ((mime_t *)calloc(1, sizeof(mime_t)));
 }
 
 
-/*
- * 'mimeNextFilter()' - Get the next filter in the MIME database.
- */
+//
+// 'mimeNextFilter()' - Get the next filter in the MIME database.
+//
 
-mime_filter_t *                                /* O - Filter or NULL */
-mimeNextFilter(mime_t *mime)           /* I - MIME database */
+mime_filter_t *                                // O - Filter or NULL
+mimeNextFilter(mime_t *mime)           // I - MIME database
 {
   DEBUG_printf("6mimeNextFilter(mime=%p)", mime);
 
@@ -432,8 +372,8 @@ mimeNextFilter(mime_t *mime)                /* I - MIME database */
   }
   else
   {
-    mime_filter_t *next = (mime_filter_t *)cupsArrayNext(mime->filters);
-                                       /* Next filter */
+    mime_filter_t *next = (mime_filter_t *)cupsArrayGetNext(mime->filters);
+                                       // Next filter
 
     DEBUG_printf("7mimeNextFilter: Returning %p.", next);
     return (next);
@@ -441,12 +381,12 @@ mimeNextFilter(mime_t *mime)              /* I - MIME database */
 }
 
 
-/*
- * 'mimeNextType()' - Get the next type in the MIME database.
- */
+//
+// 'mimeNextType()' - Get the next type in the MIME database.
+//
 
-mime_type_t *                          /* O - Type or NULL */
-mimeNextType(mime_t *mime)             /* I - MIME database */
+mime_type_t *                          // O - Type or NULL
+mimeNextType(mime_t *mime)             // I - MIME database
 {
   DEBUG_printf("6mimeNextType(mime=%p)", mime);
 
@@ -457,8 +397,8 @@ mimeNextType(mime_t *mime)          /* I - MIME database */
   }
   else
   {
-    mime_type_t *next = (mime_type_t *)cupsArrayNext(mime->types);
-                                       /* Next type */
+    mime_type_t *next = (mime_type_t *)cupsArrayGetNext(mime->types);
+                                       // Next type
 
     DEBUG_printf("7mimeNextType: Returning %p.", next);
     return (next);
@@ -466,12 +406,12 @@ mimeNextType(mime_t *mime)                /* I - MIME database */
 }
 
 
-/*
- * 'mimeNumFilters()' - Get the number of filters in a MIME database.
- */
+//
+// 'mimeNumFilters()' - Get the number of filters in a MIME database.
+//
 
 int
-mimeNumFilters(mime_t *mime)           /* I - MIME database */
+mimeNumFilters(mime_t *mime)           // I - MIME database
 {
   DEBUG_printf("mimeNumFilters(mime=%p)", mime);
 
@@ -482,19 +422,18 @@ mimeNumFilters(mime_t *mime)              /* I - MIME database */
   }
   else
   {
-    DEBUG_printf(("1mimeNumFilters: Returning %d.",
-                  cupsArrayCount(mime->filters)));
-    return (cupsArrayCount(mime->filters));
+    DEBUG_printf("1mimeNumFilters: Returning %d.", (int)cupsArrayGetCount(mime->filters));
+    return ((int)cupsArrayGetCount(mime->filters));
   }
 }
 
 
-/*
- * 'mimeNumTypes()' - Get the number of types in a MIME database.
- */
+//
+// 'mimeNumTypes()' - Get the number of types in a MIME database.
+//
 
 int
-mimeNumTypes(mime_t *mime)             /* I - MIME database */
+mimeNumTypes(mime_t *mime)             // I - MIME database
 {
   DEBUG_printf("mimeNumTypes(mime=%p)", mime);
 
@@ -505,22 +444,21 @@ mimeNumTypes(mime_t *mime)                /* I - MIME database */
   }
   else
   {
-    DEBUG_printf(("1mimeNumTypes: Returning %d.",
-                  cupsArrayCount(mime->types)));
-    return (cupsArrayCount(mime->types));
+    DEBUG_printf("1mimeNumTypes: Returning %d.", (int)cupsArrayGetCount(mime->types));
+    return ((int)cupsArrayGetCount(mime->types));
   }
 }
 
 
-/*
- * 'mimeSetErrorCallback()' - Set the callback for error messages.
- */
+//
+// 'mimeSetErrorCallback()' - Set the callback for error messages.
+//
 
 void
 mimeSetErrorCallback(
-    mime_t          *mime,             /* I - MIME database */
-    mime_error_cb_t cb,                        /* I - Callback function */
-    void            *ctx)              /* I - Context pointer for callback */
+    mime_t          *mime,             // I - MIME database
+    mime_error_cb_t cb,                        // I - Callback function
+    void            *ctx)              // I - Context pointer for callback
 {
   if (mime)
   {
@@ -530,23 +468,22 @@ mimeSetErrorCallback(
 }
 
 
-/*
- * 'mime_add_fcache()' - Add a filter to the filter cache.
- */
+//
+// 'mime_add_fcache()' - Add a filter to the filter cache.
+//
 
-static const char *                    /* O - Full path to filter or NULL */
+static const char *                    // O - Full path to filter or NULL
 mime_add_fcache(
-    cups_array_t *filtercache,         /* I - Filter cache */
-    const char   *name,                        /* I - Filter name */
-    const char   *filterpath)          /* I - Filter path */
+    cups_array_t *filtercache,         // I - Filter cache
+    const char   *name,                        // I - Filter name
+    const char   *filterpath)          // I - Filter path
 {
-  _mime_fcache_t       key,            /* Search key */
-                       *temp;          /* New filter cache */
-  char                 path[1024];     /* Full path to filter */
+  _mime_fcache_t       key,            // Search key
+                       *temp;          // New filter cache
+  char                 path[1024];     // Full path to filter
 
 
-  DEBUG_printf(("2mime_add_fcache(filtercache=%p, name=\"%s\", "
-                "filterpath=\"%s\")", filtercache, name, filterpath));
+  DEBUG_printf("2mime_add_fcache(filtercache=%p, name=\"%s\", filterpath=\"%s\")", filtercache, name, filterpath);
 
   key.name = (char *)name;
   if ((temp = (_mime_fcache_t *)cupsArrayFind(filtercache, &key)) != NULL)
@@ -573,42 +510,37 @@ mime_add_fcache(
 }
 
 
-/*
- * 'mime_compare_fcache()' - Compare two filter cache entries.
- */
+//
+// 'mime_compare_fcache()' - Compare two filter cache entries.
+//
 
-static int                             /* O - Result of comparison */
-mime_compare_fcache(_mime_fcache_t *a, /* I - First entry */
-                    _mime_fcache_t *b, /* I - Second entry */
-                    void *data)        /* Unused */
+static int                             // O - Result of comparison
+mime_compare_fcache(_mime_fcache_t *a, // I - First entry
+                    _mime_fcache_t *b, // I - Second entry
+                    void *data)        // Unused
 {
   (void)data;
   return (strcmp(a->name, b->name));
 }
 
 
-/*
- * 'mime_delete_fcache()' - Free all memory used by the filter cache.
- */
+//
+// 'mime_delete_fcache()' - Free all memory used by the filter cache.
+//
 
 static void
 mime_delete_fcache(
-    cups_array_t *filtercache)         /* I - Filter cache */
+    cups_array_t *filtercache)         // I - Filter cache
 {
-  _mime_fcache_t       *current;       /* Current cache entry */
+  _mime_fcache_t       *current;       // Current cache entry
 
 
   DEBUG_printf("2mime_delete_fcache(filtercache=%p)", filtercache);
 
-  for (current = (_mime_fcache_t *)cupsArrayFirst(filtercache);
-       current;
-       current = (_mime_fcache_t *)cupsArrayNext(filtercache))
+  for (current = (_mime_fcache_t *)cupsArrayGetFirst(filtercache); current; current = (_mime_fcache_t *)cupsArrayGetNext(filtercache))
   {
     free(current->name);
-
-    if (current->path)
-      free(current->path);
-
+    free(current->path);
     free(current);
   }
 
@@ -616,22 +548,19 @@ mime_delete_fcache(
 }
 
 
-/*
- * 'mime_delete_rules()' - Free all memory for the given rule tree.
- */
+//
+// 'mime_delete_rules()' - Free all memory for the given rule tree.
+//
 
 static void
-mime_delete_rules(mime_magic_t *rules) /* I - Rules to free */
+mime_delete_rules(mime_magic_t *rules) // I - Rules to free
 {
-  mime_magic_t *next;                  /* Next rule to free */
+  mime_magic_t *next;                  // Next rule to free
 
 
   DEBUG_printf("2mime_delete_rules(rules=%p)", rules);
 
- /*
-  * Free the rules list, descending recursively to free any child rules.
-  */
-
+  // Free the rules list, descending recursively to free any child rules.
   while (rules != NULL)
   {
     next = rules->next;
@@ -648,71 +577,52 @@ mime_delete_rules(mime_magic_t *rules)    /* I - Rules to free */
 }
 
 
-/*
- * 'mime_load_convs()' - Load a xyz.convs file.
- */
+//
+// 'mime_load_convs()' - Load a xyz.convs file.
+//
 
 static void
 mime_load_convs(
-    mime_t       *mime,                        /* I - MIME database */
-    const char   *filename,            /* I - Convs file to load */
-    const char   *filterpath,          /* I - Path for filters */
-    cups_array_t *filtercache)         /* I - Filter program cache */
+    mime_t       *mime,                        // I - MIME database
+    const char   *filename,            // I - Convs file to load
+    const char   *filterpath,          // I - Path for filters
+    cups_array_t *filtercache)         // I - Filter program cache
 {
-  cups_file_t  *fp;                    /* Convs file */
-  char         line[1024],             /* Input line from file */
-               *lineptr,               /* Current position in line */
-               super[MIME_MAX_SUPER],  /* Super-type name */
-               type[MIME_MAX_TYPE],    /* Type name */
-               *temp,                  /* Temporary pointer */
-               *filter;                /* Filter program */
-  mime_type_t  *temptype,              /* MIME type looping var */
-               *dsttype;               /* Destination MIME type */
-  int          cost;                   /* Cost of filter */
+  cups_file_t  *fp;                    // Convs file
+  char         line[1024],             // Input line from file
+               *lineptr,               // Current position in line
+               super[MIME_MAX_SUPER],  // Super-type name
+               type[MIME_MAX_TYPE],    // Type name
+               *temp,                  // Temporary pointer
+               *filter;                // Filter program
+  mime_type_t  *temptype,              // MIME type looping var
+               *dsttype;               // Destination MIME type
+  int          cost;                   // Cost of filter
 
 
-  DEBUG_printf(("2mime_load_convs(mime=%p, filename=\"%s\", filterpath=\"%s\", "
-                "filtercache=%p)", mime, filename, filterpath, filtercache));
-
- /*
-  * First try to open the file...
-  */
+  DEBUG_printf("2mime_load_convs(mime=%p, filename=\"%s\", filterpath=\"%s\", filtercache=%p)", mime, filename, filterpath, filtercache);
 
+  // First try to open the file...
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("3mime_load_convs: Unable to open \"%s\": %s", filename,
-                  strerror(errno)));
+    DEBUG_printf("3mime_load_convs: Unable to open \"%s\": %s", filename, strerror(errno));
     _mimeError(mime, "Unable to open \"%s\": %s", filename, strerror(errno));
     return;
   }
 
- /*
-  * Then read each line from the file, skipping any comments in the file...
-  */
-
+  // Then read each line from the file, skipping any comments in the file...
   while (cupsFileGets(fp, line, sizeof(line)) != NULL)
   {
-   /*
-    * Skip blank lines and lines starting with a #...
-    */
-
+    // Skip blank lines and lines starting with a #...
     if (!line[0] || line[0] == '#')
       continue;
 
-   /*
-    * Strip trailing whitespace...
-    */
-
-    for (lineptr = line + strlen(line) - 1;
-         lineptr >= line && isspace(*lineptr & 255);
-        lineptr --)
+    // Strip trailing whitespace...
+    for (lineptr = line + strlen(line) - 1; lineptr >= line && isspace(*lineptr & 255); lineptr --)
       *lineptr = '\0';
 
-   /*
-    * Extract the destination super-type and type names from the middle of
-    * the line.
-    */
-
+    // Extract the destination super-type and type names from the middle of
+    // the line.
     lineptr = line;
     while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\0')
       lineptr ++;
@@ -722,8 +632,7 @@ mime_load_convs(
 
     temp = super;
 
-    while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' &&
-           (temp - super + 1) < MIME_MAX_SUPER)
+    while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' && (temp - super + 1) < MIME_MAX_SUPER)
       *temp++ = (char)tolower(*lineptr++ & 255);
 
     *temp = '\0';
@@ -734,8 +643,7 @@ mime_load_convs(
     lineptr ++;
     temp = type;
 
-    while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' &&
-           *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
+    while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' && *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
       *temp++ = (char)tolower(*lineptr++ & 255);
 
     *temp = '\0';
@@ -745,15 +653,11 @@ mime_load_convs(
 
     if ((dsttype = mimeType(mime, super, type)) == NULL)
     {
-      DEBUG_printf(("3mime_load_convs: Destination type %s/%s not found.",
-                    super, type));
+      DEBUG_printf("3mime_load_convs: Destination type %s/%s not found.", super, type);
       continue;
     }
 
-   /*
-    * Then get the cost and filter program...
-    */
-
+    // Then get the cost and filter program...
     while (*lineptr == ' ' || *lineptr == '\t')
       lineptr ++;
 
@@ -774,29 +678,21 @@ mime_load_convs(
 
     if (strcmp(filter, "-"))
     {
-     /*
-      * Verify that the filter exists and is executable...
-      */
-
+      // Verify that the filter exists and is executable...
       if (!mime_add_fcache(filtercache, filter, filterpath))
       {
-        DEBUG_printf(("mime_load_convs: Filter %s not found in %s.", filter,
-                     filterpath));
+        DEBUG_printf("mime_load_convs: Filter %s not found in %s.", filter, filterpath);
         _mimeError(mime, "Filter \"%s\" not found.", filter);
         continue;
       }
     }
 
-   /*
-    * Finally, get the source super-type and type names from the beginning of
-    * the line.  We do it here so we can support wildcards...
-    */
-
+    // Finally, get the source super-type and type names from the beginning of
+    // the line.  We do it here so we can support wildcards...
     lineptr = line;
     temp    = super;
 
-    while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' &&
-           (temp - super + 1) < MIME_MAX_SUPER)
+    while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' && (temp - super + 1) < MIME_MAX_SUPER)
       *temp++ = (char)tolower(*lineptr++ & 255);
 
     *temp = '\0';
@@ -807,88 +703,67 @@ mime_load_convs(
     lineptr ++;
     temp = type;
 
-    while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' &&
-           *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
+    while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' && *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
       *temp++ = (char)tolower(*lineptr++ & 255);
 
     *temp = '\0';
 
     if (!strcmp(super, "*") && !strcmp(type, "*"))
     {
-     /*
-      * Force * / * to be "application/octet-stream"...
-      */
-
+      // Force * / * to be "application/octet-stream"...
       cupsCopyString(super, "application", sizeof(super));
       cupsCopyString(type, "octet-stream", sizeof(type));
     }
 
-   /*
-    * Add the filter to the MIME database, supporting wildcards as needed...
-    */
-
-    for (temptype = (mime_type_t *)cupsArrayFirst(mime->types);
-         temptype;
-        temptype = (mime_type_t *)cupsArrayNext(mime->types))
-      if ((super[0] == '*' || !strcmp(temptype->super, super)) &&
-          (type[0] == '*' || !strcmp(temptype->type, type)))
+    // Add the filter to the MIME database, supporting wildcards as needed...
+    for (temptype = (mime_type_t *)cupsArrayGetFirst(mime->types); temptype; temptype = (mime_type_t *)cupsArrayGetNext(mime->types))
+    {
+      if ((super[0] == '*' || !strcmp(temptype->super, super)) && (type[0] == '*' || !strcmp(temptype->type, type)))
        mimeAddFilter(mime, temptype, dsttype, cost, filter);
+    }
   }
 
   cupsFileClose(fp);
 }
 
 
-/*
- * 'mime_load_types()' - Load a xyz.types file.
- */
+//
+// 'mime_load_types()' - Load a xyz.types file.
+//
 
 static void
-mime_load_types(mime_t     *mime,      /* I - MIME database */
-                const char *filename)  /* I - Types file to load */
+mime_load_types(mime_t     *mime,      // I - MIME database
+                const char *filename)  // I - Types file to load
 {
-  cups_file_t  *fp;                    /* Types file */
-  size_t       linelen;                /* Length of line */
-  char         line[32768],            /* Input line from file */
-               *lineptr,               /* Current position in line */
-               super[MIME_MAX_SUPER],  /* Super-type name */
-               type[MIME_MAX_TYPE],    /* Type name */
-               *temp;                  /* Temporary pointer */
-  mime_type_t  *typeptr;               /* New MIME type */
+  cups_file_t  *fp;                    // Types file
+  size_t       linelen;                // Length of line
+  char         line[32768],            // Input line from file
+               *lineptr,               // Current position in line
+               super[MIME_MAX_SUPER],  // Super-type name
+               type[MIME_MAX_TYPE],    // Type name
+               *temp;                  // Temporary pointer
+  mime_type_t  *typeptr;               // New MIME type
 
 
   DEBUG_printf("2mime_load_types(mime=%p, filename=\"%s\")", mime, filename);
 
- /*
-  * First try to open the file...
-  */
-
+  // First try to open the file...
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("3mime_load_types: Unable to open \"%s\": %s", filename,
-                  strerror(errno)));
+    DEBUG_printf("3mime_load_types: Unable to open \"%s\": %s", filename, strerror(errno));
     _mimeError(mime, "Unable to open \"%s\": %s", filename, strerror(errno));
     return;
   }
 
- /*
-  * Then read each line from the file, skipping any comments in the file...
-  */
-
+  // Then read each line from the file, skipping any comments in the file...
   while (cupsFileGets(fp, line, sizeof(line)) != NULL)
   {
-   /*
-    * Skip blank lines and lines starting with a #...
-    */
-
+    // Skip blank lines and lines starting with a #...
     if (!line[0] || line[0] == '#')
       continue;
 
-   /*
-    * While the last character in the line is a backslash, continue on to the
-    * next line (and the next, etc.)
-    */
-
+    // While the last character in the line is a backslash, continue on to the
+    // next line (and the next, etc.)
     linelen = strlen(line);
 
     while (line[linelen - 1] == '\\')
@@ -901,15 +776,11 @@ mime_load_types(mime_t     *mime, /* I - MIME database */
         linelen += strlen(line + linelen);
     }
 
-   /*
-    * Extract the super-type and type names from the beginning of the line.
-    */
-
+    // Extract the super-type and type names from the beginning of the line.
     lineptr = line;
     temp    = super;
 
-    while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' &&
-           (temp - super + 1) < MIME_MAX_SUPER)
+    while (*lineptr != '/' && *lineptr != '\n' && *lineptr != '\0' && (temp - super + 1) < MIME_MAX_SUPER)
       *temp++ = (char)tolower(*lineptr++ & 255);
 
     *temp = '\0';
@@ -920,16 +791,12 @@ mime_load_types(mime_t     *mime, /* I - MIME database */
     lineptr ++;
     temp = type;
 
-    while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' &&
-           *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
+    while (*lineptr != ' ' && *lineptr != '\t' && *lineptr != '\n' && *lineptr != '\0' && (temp - type + 1) < MIME_MAX_TYPE)
       *temp++ = (char)tolower(*lineptr++ & 255);
 
     *temp = '\0';
 
-   /*
-    * Add the type and rules to the MIME database...
-    */
-
+    // Add the type and rules to the MIME database...
     typeptr = mimeAddType(mime, super, type);
     mimeAddTypeRule(typeptr, lineptr);
   }
index 179a90aaee22666d287eb60a5f29b575fe1d7679..b53968bbd22c0cef3b6e35e01560ab0f51ede890 100644 (file)
@@ -1,17 +1,15 @@
-/*
- * MIME test program for CUPS.
- *
- * Copyright Â©Â 2020-2024 by OpenPrinting.
- * Copyright 2007-2014 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
- */
-
-/*
- * Include necessary headers...
- */
-
+//
+// MIME test program for CUPS.
+//
+// Copyright Â©Â 2020-2025 by OpenPrinting.
+// Copyright Â©Â 2007-2014 by Apple Inc.
+// Copyright Â©Â 1997-2006 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
+
+#include <cups/test-internal.h>
 #include <cups/string-private.h>
 #include <cups/dir.h>
 #include <cups/debug-private.h>
 #include "mime.h"
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
-static void    add_ppd_filter(mime_t *mime, mime_type_t *filtertype,
-                              const char *filter);
+static bool    add_ppd_filter(mime_t *mime, mime_type_t *filtertype, const char *filter);
 static void    add_ppd_filters(mime_t *mime, ppd_file_t *ppd);
+static void    get_file_types(mime_t *mime, mime_type_t *dst);
 static void    print_rules(mime_magic_t *rules);
+static void    test_filter(mime_t *mime, mime_type_t *src, size_t srcsize, mime_type_t *dst);
 static void    type_dir(mime_t *mime, const char *dirname);
+static mime_type_t *type_file(mime_t *mime, const char *filename);
 
 
-/*
- * 'main()' - Main entry for the test program.
- */
+//
+// 'main()' - Main entry for the test program.
+//
 
-int                                    /* O - Exit status */
-main(int  argc,                                /* I - Number of command-line args */
-     char *argv[])                     /* I - Command-line arguments */
+int                                    // O - Exit status
+main(int  argc,                                // I - Number of command-line args
+     char *argv[])                     // I - Command-line arguments
 {
-  int          i;                      /* Looping vars */
-  const char   *filter_path;           /* Filter path */
-  char         super[MIME_MAX_SUPER],  /* Super-type name */
-               type[MIME_MAX_TYPE];    /* Type name */
-  int          compression;            /* Compression of file */
-  int          cost;                   /* Cost of filters */
-  mime_t       *mime;                  /* MIME database */
-  mime_type_t  *src,                   /* Source type */
-               *dst;                   /* Destination type */
-  struct stat  srcinfo;                /* Source information */
-  ppd_file_t   *ppd;                   /* PPD file */
-  cups_array_t *filters;               /* Filters for the file */
-  mime_filter_t        *filter;                /* Current filter */
+  int          i;                      // Looping vars
+  const char   *filter_path;           // Filter path
+  char         super[MIME_MAX_SUPER],  // Super-type name
+               type[MIME_MAX_TYPE];    // Type name
+  mime_t       *mime;                  // MIME database
+  mime_type_t  *src,                   // Source type
+               *dst = NULL;            // Destination type
+  struct stat  srcinfo;                // Source information
+  ppd_file_t   *ppd;                   // PPD file
+  mime_filter_t        *filter;                // Current filter
 
 
   mime        = NULL;
   src         = NULL;
   dst         = NULL;
   ppd         = NULL;
-  filter_path = "../filter:" CUPS_SERVERBIN "/filter";
+  filter_path = "../filter:/usr/lib/cups/filter:/usr/libexec/cups/filter:/usr/local/lib/cups/filter:/usr/local/libexec/cups/filter";
 
   srcinfo.st_size = 0;
 
   for (i = 1; i < argc; i ++)
+  {
     if (!strcmp(argv[i], "-d"))
     {
       i ++;
 
       if (i < argc)
       {
+        testBegin("mimeLoad(\"%s\", \"%s\")", argv[i], filter_path);
         mime = mimeLoad(argv[i], filter_path);
+        testEnd(mime != NULL);
 
        if (ppd)
          add_ppd_filters(mime, ppd);
@@ -87,173 +87,158 @@ main(int  argc,                           /* I - Number of command-line args */
 
       if (i < argc)
       {
+        testBegin("ppdOpenFile(\"%s\")", argv[i]);
         ppd = ppdOpenFile(argv[i]);
+        testEnd(ppd != NULL);
 
        if (mime)
          add_ppd_filters(mime, ppd);
       }
     }
-    else if (!src)
+    else if (!src && !access(argv[i], 0))
     {
       if (!mime)
+      {
+        testBegin("mimeLoad(\"../conf\", \"%s\")", filter_path);
        mime = mimeLoad("../conf", filter_path);
+       testEnd(mime != NULL);
+      }
 
       if (ppd)
         add_ppd_filters(mime, ppd);
 
-      src = mimeFileType(mime, argv[i], NULL, &compression);
-      stat(argv[i], &srcinfo);
-
-      if (src)
-       printf("%s: %s/%s%s\n", argv[i], src->super, src->type,
-              compression ? " (gzipped)" : "");
-      else if ((src = mimeType(mime, "application", "octet-stream")) != NULL)
-       printf("%s: application/octet-stream\n", argv[i]);
+      if (stat(argv[i], &srcinfo))
+      {
+        perror(argv[i]);
+        continue;
+      }
+      else if (S_ISDIR(srcinfo.st_mode))
+      {
+        type_dir(mime, argv[i]);
+      }
+      else if (S_ISREG(srcinfo.st_mode))
+      {
+        src = type_file(mime, argv[i]);
+      }
       else
       {
-       printf("%s: unknown\n", argv[i]);
-       if (mime)
-         mimeDelete(mime);
-       return (1);
+        fprintf(stderr, "%s: Not a file or directory.\n", argv[i]);
+        continue;
       }
     }
     else
     {
       sscanf(argv[i], "%15[^/]/%255s", super, type);
+      testBegin("mimeType(\"%s/%s\")", super, type);
       dst = mimeType(mime, super, type);
+      testEnd(dst != NULL);
 
-      filters = mimeFilter2(mime, src, (size_t)srcinfo.st_size, dst, &cost);
-
-      if (!filters)
-      {
-       printf("No filters to convert from %s/%s to %s.\n", src->super,
-              src->type, argv[i]);
-      }
-      else
-      {
-        int first = 1;                 /* First filter shown? */
-
-        printf("Filter cost = %d\n", cost);
-
-        for (filter = (mime_filter_t *)cupsArrayFirst(filters);
-            filter;
-            filter = (mime_filter_t *)cupsArrayNext(filters))
-       {
-         if (!strcmp(filter->filter, "-"))
-           continue;
-
-          if (first)
-         {
-           first = 0;
-           fputs(filter->filter, stdout);
-         }
-         else
-           printf(" | %s", filter->filter);
-       }
-
-        putchar('\n');
-
-        cupsArrayDelete(filters);
-      }
+      if (src && dst)
+        test_filter(mime, src, (size_t)srcinfo.st_size, dst);
+      else if (dst)
+        get_file_types(mime, dst);
     }
+  }
 
   if (!mime)
   {
+    testBegin("mimeLoad(\"../conf\", \"%s\")", filter_path);
     mime = mimeLoad("../conf", filter_path);
+    testEnd(mime != NULL);
+
     if (ppd)
       add_ppd_filters(mime, ppd);
   }
 
-  if (!src)
+  if (ppd)
+  {
+    if ((dst = mimeType(mime, "printer", "test")) != NULL)
+      get_file_types(mime, dst);
+  }
+  else if (!src && !dst)
   {
-    puts("MIME database types:");
+    testMessage("MIME database types:");
     for (src = mimeFirstType(mime); src; src = mimeNextType(mime))
     {
-      printf("\t%s/%s (%d):\n", src->super, src->type, src->priority);
+      testMessage("\t%s/%s (%d):", src->super, src->type, src->priority);
       print_rules(src->rules);
-      puts("");
     }
 
-    puts("");
-
-    puts("MIME database filters:");
+    testMessage("MIME database filters:");
     for (filter = mimeFirstFilter(mime); filter; filter = mimeNextFilter(mime))
-      printf("\t%s/%s to %s/%s: %s (%d)\n",
-             filter->src->super, filter->src->type,
-            filter->dst->super, filter->dst->type,
-            filter->filter, filter->cost);
+      testMessage("\t%s/%s to %s/%s: %s (%d)", filter->src->super, filter->src->type, filter->dst->super, filter->dst->type, filter->filter, filter->cost);
 
     type_dir(mime, "../doc");
+
+    if ((dst = mimeType(mime, "application", "vnd.cups-postscript")) != NULL)
+      get_file_types(mime, dst);
+
+    if ((dst = mimeType(mime, "image", "pwg-raster")) != NULL)
+      get_file_types(mime, dst);
   }
 
-  return (0);
+  mimeDelete(mime);
+
+  return (testsPassed ? 0 : 1);
 }
 
 
-/*
- * 'add_printer_filter()' - Add a printer filter from a PPD.
- */
+//
+// 'add_printer_filter()' - Add a printer filter from a PPD.
+//
 
-static void
-add_ppd_filter(mime_t      *mime,      /* I - MIME database */
-               mime_type_t *filtertype,        /* I - Filter or prefilter MIME type */
-              const char  *filter)     /* I - Filter to add */
+static bool                            // O - `true` on success, `false` on error
+add_ppd_filter(mime_t      *mime,      // I - MIME database
+               mime_type_t *filtertype,        // I - Filter or prefilter MIME type
+              const char  *filter)     // I - Filter to add
 {
-  char         super[MIME_MAX_SUPER],  /* Super-type for filter */
-               type[MIME_MAX_TYPE],    /* Type for filter */
-               dsuper[MIME_MAX_SUPER], /* Destination super-type for filter */
-               dtype[MIME_MAX_TYPE],   /* Destination type for filter */
+  char         super[MIME_MAX_SUPER],  // Super-type for filter
+               type[MIME_MAX_TYPE],    // Type for filter
+               dsuper[MIME_MAX_SUPER], // Destination super-type for filter
+               dtype[MIME_MAX_TYPE],   // Destination type for filter
                dest[MIME_MAX_SUPER + MIME_MAX_TYPE + 2],
-                                       /* Destination super/type */
-               program[1024];          /* Program/filter name */
-  int          cost;                   /* Cost of filter */
-  size_t       maxsize = 0;            /* Maximum supported file size */
-  mime_type_t  *temptype,              /* MIME type looping var */
-               *desttype;              /* Destination MIME type */
-  mime_filter_t        *filterptr;             /* MIME filter */
-
-
- /*
-  * Parse the filter string; it should be in one of the following formats:
-  *
-  *     source/type cost program
-  *     source/type cost maxsize(nnnn) program
-  *     source/type dest/type cost program
-  *     source/type dest/type cost maxsize(nnnn) program
-  */
-
-  if (sscanf(filter, "%15[^/]/%255s%*[ \t]%15[^/]/%255s%d%*[ \t]%1023[^\n]",
-             super, type, dsuper, dtype, &cost, program) == 6)
+                                       // Destination super/type
+               program[1024];          // Program/filter name
+  int          cost;                   // Cost of filter
+  size_t       maxsize = 0;            // Maximum supported file size
+  mime_type_t  *temptype,              // MIME type looping var
+               *desttype;              // Destination MIME type
+  mime_filter_t        *filterptr;             // MIME filter
+
+
+  // Parse the filter string; it should be in one of the following formats:
+  //
+  //   source/type cost program
+  //   source/type cost maxsize(nnnn) program
+  //   source/type dest/type cost program
+  //   source/type dest/type cost maxsize(nnnn) program
+  if (sscanf(filter, "%15[^/]/%255s%*[ \t]%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type, dsuper, dtype, &cost, program) == 6)
   {
     snprintf(dest, sizeof(dest), "test/%s/%s", dsuper, dtype);
 
     if ((desttype = mimeType(mime, "printer", dest)) == NULL)
       desttype = mimeAddType(mime, "printer", dest);
   }
+  else if (sscanf(filter, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type, &cost, program) == 4)
+  {
+    desttype = filtertype;
+  }
   else
   {
-    if (sscanf(filter, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type, &cost,
-               program) == 4)
-    {
-      desttype = filtertype;
-    }
-    else
-    {
-      printf("testmime: Invalid filter string \"%s\".\n", filter);
-      return;
-    }
+    testEndMessage(false, "Invalid filter string \"%s\"", filter);
+    return (false);
   }
 
   if (!strncmp(program, "maxsize(", 8))
   {
-    char       *ptr;                   /* Pointer into maxsize(nnnn) program */
+    char       *ptr;                   // Pointer into maxsize(nnnn) program
 
     maxsize = (size_t)strtoll(program + 8, &ptr, 10);
 
     if (*ptr != ')')
     {
-      printf("testmime: Invalid filter string \"%s\".\n", filter);
-      return;
+      testEndMessage(false, "Invalid filter string \"%s\"", filter);
+      return (false);
     }
 
     ptr ++;
@@ -263,16 +248,10 @@ add_ppd_filter(mime_t      *mime, /* I - MIME database */
     _cups_strcpy(program, ptr);
   }
 
- /*
-  * Add the filter to the MIME database, supporting wildcards as needed...
-  */
-
-  for (temptype = mimeFirstType(mime);
-       temptype;
-       temptype = mimeNextType(mime))
-    if (((super[0] == '*' && _cups_strcasecmp(temptype->super, "printer")) ||
-         !_cups_strcasecmp(temptype->super, super)) &&
-        (type[0] == '*' || !_cups_strcasecmp(temptype->type, type)))
+  // Add the filter to the MIME database, supporting wildcards as needed...
+  for (temptype = mimeFirstType(mime); temptype; temptype = mimeNextType(mime))
+  {
+    if (((super[0] == '*' && _cups_strcasecmp(temptype->super, "printer")) || !_cups_strcasecmp(temptype->super, super)) && (type[0] == '*' || !_cups_strcasecmp(temptype->type, type)))
     {
       if (desttype != filtertype)
       {
@@ -282,68 +261,119 @@ add_ppd_filter(mime_t      *mime,        /* I - MIME database */
           mimeAddFilter(mime, desttype, filtertype, 0, "-");
       }
       else
+      {
         filterptr = mimeAddFilter(mime, temptype, filtertype, cost, program);
+      }
 
       if (filterptr)
        filterptr->maxsize = maxsize;
     }
+  }
+
+  return (true);
 }
 
 
-/*
- * 'add_ppd_filters()' - Add all filters from a PPD.
- */
+//
+// 'add_ppd_filters()' - Add all filters from a PPD.
+//
 
 static void
-add_ppd_filters(mime_t     *mime,      /* I - MIME database */
-                ppd_file_t *ppd)       /* I - PPD file */
+add_ppd_filters(mime_t     *mime,      // I - MIME database
+                ppd_file_t *ppd)       // I - PPD file
 {
-  _ppd_cache_t *pc;                    /* Cache data for PPD */
-  const char   *value;                 /* Filter definition value */
-  mime_type_t  *filter,                /* Filter type */
-               *prefilter;             /* Pre-filter type */
+  bool         result = true;          // Result of adding filters
+  _ppd_cache_t *pc;                    // Cache data for PPD
+  const char   *value;                 // Filter definition value
+  mime_type_t  *filter,                // Filter type
+               *prefilter;             // Pre-filter type
 
 
   pc = _ppdCacheCreateWithPPD(NULL, ppd);
   if (!pc)
     return;
 
+  testBegin("mimeAddType(\"printer/test\")");
   filter = mimeAddType(mime, "printer", "test");
+  testEnd(filter != NULL);
 
+  testBegin("Add PPD Filters");
   if (pc->filters)
   {
-    for (value = (const char *)cupsArrayFirst(pc->filters);
-         value;
-         value = (const char *)cupsArrayNext(pc->filters))
-      add_ppd_filter(mime, filter, value);
+    for (value = (const char *)cupsArrayFirst(pc->filters); value; value = (const char *)cupsArrayNext(pc->filters))
+      result &= add_ppd_filter(mime, filter, value);
   }
   else
   {
-    add_ppd_filter(mime, filter, "application/vnd.cups-raw 0 -");
-    add_ppd_filter(mime, filter, "application/vnd.cups-postscript 0 -");
+    result &= add_ppd_filter(mime, filter, "application/vnd.cups-raw 0 -");
+    result &= add_ppd_filter(mime, filter, "application/vnd.cups-postscript 0 -");
   }
 
   if (pc->prefilters)
   {
     prefilter = mimeAddType(mime, "prefilter", "test");
 
-    for (value = (const char *)cupsArrayFirst(pc->prefilters);
-         value;
-         value = (const char *)cupsArrayNext(pc->prefilters))
-      add_ppd_filter(mime, prefilter, value);
+    for (value = (const char *)cupsArrayFirst(pc->prefilters); value; value = (const char *)cupsArrayNext(pc->prefilters))
+      result &= add_ppd_filter(mime, prefilter, value);
   }
+
+  if (result)
+    testEnd(true);
 }
 
 
-/*
- * 'print_rules()' - Print the rules for a file type...
- */
+//
+// 'get_file_types()' - Get the list of source types for a given destination type.
+//
 
 static void
-print_rules(mime_magic_t *rules)       /* I - Rules to print */
+get_file_types(mime_t      *mime,      // I - MIME database
+               mime_type_t *dst)       // I - Destination MIME media type
 {
-  int  i;                              /* Looping var */
-  static char  indent[255] = "\t";     /* Indentation for rules */
+  cups_array_t *types;                 // Array of supported types
+  mime_type_t  *type;                  // Current type
+  cups_array_t *filters;               // Filters
+  double       start, end;             // Start and end time
+
+
+  // Scan source types...
+  types = cupsArrayNew(NULL, NULL);
+
+  testBegin("Get Source Types to %s/%s", dst->super, dst->type);
+  start = cupsGetClock();
+  for (type = mimeFirstType(mime); type; type = mimeNextType(mime))
+  {
+    if (!_cups_strcasecmp(type->super, "printer"))
+      continue;
+
+    if ((filters = mimeFilter(mime, type, dst, NULL)) != NULL)
+    {
+      cupsArrayAdd(types, type);
+      cupsArrayDelete(filters);
+    }
+  }
+  end = cupsGetClock();
+
+  testEndMessage(cupsArrayGetCount(types) > 0, "%d types, %.6f seconds", (int)cupsArrayGetCount(types), end - start);
+
+  for (type = (mime_type_t *)cupsArrayGetFirst(types); type; type = (mime_type_t *)cupsArrayGetNext(types))
+    testMessage("\t%s/%s", type->super, type->type);
+
+  cupsArrayDelete(types);
+}
+
+
+//
+// 'print_rules()' - Print the rules for a file type...
+//
+
+static void
+print_rules(mime_magic_t *rules)       // I - Rules to print
+{
+  int  i;                              // Looping var
+  char line[1024],                     // Output line
+       *lineptr;                       // Pointer into line
+  static char  indent[255] = "\t\t";   // Indentation for rules
 
 
   if (rules == NULL)
@@ -351,53 +381,72 @@ print_rules(mime_magic_t *rules)  /* I - Rules to print */
 
   while (rules != NULL)
   {
-    printf("%s[%p] ", indent, (void *)rules);
-
-    if (rules->invert)
-      printf("NOT ");
+    snprintf(line, sizeof(line), "%s[%p] %s", indent, (void *)rules, rules->invert ? "NOT " : "");
+    lineptr = line + strlen(line);
 
     switch (rules->op)
     {
       case MIME_MAGIC_MATCH :
-          printf("match(%s)", rules->value.matchv);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "match(%s)", rules->value.matchv);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_LOCALE :
-          printf("locale(%s)", rules->value.localev);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "locale(%s)", rules->value.localev);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_ASCII :
-          printf("ascii(%d,%d)", rules->offset, rules->length);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "ascii(%d,%d)", rules->offset, rules->length);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_PRINTABLE :
-          printf("printable(%d,%d)", rules->offset, rules->length);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "printable(%d,%d)", rules->offset, rules->length);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_STRING :
-          printf("string(%d,", rules->offset);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "string(%d,", rules->offset);
+          lineptr += strlen(lineptr);
          for (i = 0; i < rules->length; i ++)
-           if (rules->value.stringv[i] < ' ' ||
-               rules->value.stringv[i] > 126)
-             printf("<%02X>", rules->value.stringv[i]);
-           else
-             putchar(rules->value.stringv[i]);
-          putchar(')');
+         {
+           if (rules->value.stringv[i] < ' ' || rules->value.stringv[i] > 126)
+           {
+             snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "<%02X>", rules->value.stringv[i]);
+             lineptr += strlen(lineptr);
+           }
+           else if (lineptr < (line + sizeof(line) - 1))
+             *lineptr++ = rules->value.stringv[i];
+         }
+         if (lineptr < (line + sizeof(line) - 1))
+           *lineptr++ = ')';
+         *lineptr = '\0';
          break;
       case MIME_MAGIC_CHAR :
-          printf("char(%d,%d)", rules->offset, rules->value.charv);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "char(%d,%d)", rules->offset, rules->value.charv);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_SHORT :
-          printf("short(%d,%d)", rules->offset, rules->value.shortv);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "short(%d,%d)", rules->offset, rules->value.shortv);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_INT :
-          printf("int(%d,%d)", rules->offset, rules->value.intv);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "int(%d,%d)", rules->offset, rules->value.intv);
+          lineptr += strlen(lineptr);
          break;
       case MIME_MAGIC_CONTAINS :
-          printf("contains(%d,%d,", rules->offset, rules->region);
+          snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "contains(%d,%d,", rules->offset, rules->region);
+          lineptr += strlen(lineptr);
          for (i = 0; i < rules->length; i ++)
-           if (rules->value.stringv[i] < ' ' ||
-               rules->value.stringv[i] > 126)
-             printf("<%02X>", rules->value.stringv[i]);
-           else
-             putchar(rules->value.stringv[i]);
-          putchar(')');
+         {
+           if (rules->value.stringv[i] < ' ' || rules->value.stringv[i] > 126)
+           {
+             snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), "<%02X>", rules->value.stringv[i]);
+             lineptr += strlen(lineptr);
+           }
+           else if (lineptr < (line + sizeof(line) - 1))
+             *lineptr++ = rules->value.stringv[i];
+         }
+         if (lineptr < (line + sizeof(line) - 1))
+           *lineptr++ = ')';
+         *lineptr = '\0';
          break;
       default :
          break;
@@ -406,48 +455,87 @@ print_rules(mime_magic_t *rules)  /* I - Rules to print */
     if (rules->child != NULL)
     {
       if (rules->op == MIME_MAGIC_OR)
-       puts("OR (");
+       testMessage("%sOR (", line);
       else
-       puts("AND (");
+       testMessage("%sAND (", line);
 
       cupsConcatString(indent, "\t", sizeof(indent));
       print_rules(rules->child);
       indent[strlen(indent) - 1] = '\0';
-      printf("%s)\n", indent);
+      testMessage("%s)", indent);
     }
     else
-      putchar('\n');
+    {
+      testMessage("%s", line);
+    }
 
     rules = rules->next;
   }
 }
 
 
-/*
- * 'type_dir()' - Show the MIME types for a given directory.
- */
+//
+// 'test_filter()' - Test filtering.
+//
 
 static void
-type_dir(mime_t     *mime,             /* I - MIME database */
-         const char *dirname)          /* I - Directory */
+test_filter(mime_t      *mime,         // I - MIME database
+            mime_type_t *src,          // I - Source MIME media type
+            size_t      srcsize,       // I - Size of source
+            mime_type_t *dst)          // I - Destination MIME media type
 {
-  cups_dir_t   *dir;                   /* Directory */
-  cups_dentry_t        *dent;                  /* Directory entry */
-  char         filename[1024];         /* File to type */
-  mime_type_t  *filetype;              /* File type */
-  int          compression;            /* Compressed file? */
-  mime_type_t  *pstype;                /* application/vnd.cups-postscript */
-  cups_array_t *filters;               /* Filters to pstype */
-  mime_filter_t        *filter;                /* Current filter */
-  int          cost;                   /* Filter cost */
+  cups_array_t *filters;               // Filters
+  int          cost;                   // Cost
+
+
+  testBegin("mimeFilter2(src=\"%s/%s\", %ld, dst=\"%s/%s\")", src->super, src->type, (long)srcsize, dst->super, dst->type);
+  if ((filters = mimeFilter2(mime, src, srcsize, dst, &cost)) != NULL)
+  {
+    mime_filter_t *filter;             // Current filter
+    char       line[1024],             // Output line
+               *lineptr;               // Pointer into line
+
+    for (filter = (mime_filter_t *)cupsArrayGetFirst(filters), lineptr = line; filter; filter = (mime_filter_t *)cupsArrayGetNext(filters))
+    {
+      if (!strcmp(filter->filter, "-"))
+       continue;
+
+      if (lineptr == line)
+       cupsCopyString(line, filter->filter, sizeof(line));
+      else
+       snprintf(lineptr, sizeof(line) - (size_t)(lineptr - line), " | %s", filter->filter);
+
+      lineptr += strlen(lineptr);
+    }
+
+    testEndMessage(true, "%d filters, cost %d, %s", (int)cupsArrayGetCount(filters), cost, line);
+
+    cupsArrayDelete(filters);
+  }
+  else
+  {
+    testEndMessage(false, "no filters found");
+  }
+}
+
+
+//
+// 'type_dir()' - Show the MIME types for a given directory.
+//
+
+static void
+type_dir(mime_t     *mime,             // I - MIME database
+         const char *dirname)          // I - Directory
+{
+  cups_dir_t   *dir;                   // Directory
+  cups_dentry_t        *dent;                  // Directory entry
+  char         filename[1024];         // File to type
 
 
   dir = cupsDirOpen(dirname);
   if (!dir)
     return;
 
-  pstype = mimeType(mime, "application", "vnd.cups-postscript");
-
   while ((dent = cupsDirRead(dir)) != NULL)
   {
     if (dent->filename[0] == '.')
@@ -457,41 +545,35 @@ type_dir(mime_t     *mime,                /* I - MIME database */
 
     if (S_ISDIR(dent->fileinfo.st_mode))
       type_dir(mime, filename);
+    else if (S_ISREG(dent->fileinfo.st_mode))
+      type_file(mime, filename);
+  }
 
-    if (!S_ISREG(dent->fileinfo.st_mode))
-      continue;
-
-    filetype = mimeFileType(mime, filename, NULL, &compression);
-
-    if (filetype)
-    {
-      printf("%s: %s/%s%s\n", filename, filetype->super, filetype->type,
-             compression ? " (compressed)" : "");
+  cupsDirClose(dir);
+}
 
-      filters = mimeFilter(mime, filetype, pstype, &cost);
 
-      if (!filters)
-       puts("    No filters to convert application/vnd.cups-postscript.");
-      else
-      {
-        printf("    Filter cost = %d\n", cost);
+//
+// 'type_file()' - Determine the MIME media type of a file.
+//
 
-        filter = (mime_filter_t *)cupsArrayFirst(filters);
-       printf("    %s", filter->filter);
+static mime_type_t *                   // O - MIME media type
+type_file(mime_t     *mime,            // I - MIME database
+          const char *filename)                // I - Filename
+{
+  mime_type_t  *src;                   // MIME type
+  int          compression;            // Is the file gzipped?
 
-       for (filter = (mime_filter_t *)cupsArrayNext(filters);
-            filter;
-            filter = (mime_filter_t *)cupsArrayNext(filters))
-         printf(" | %s", filter->filter);
 
-        putchar('\n');
+  testBegin("mimeFileType(\"%s\")", filename);
+  src = mimeFileType(mime, filename, NULL, &compression);
 
-        cupsArrayDelete(filters);
-      }
-    }
-    else
-      printf("%s: unknown%s\n", filename, compression ? " (compressed)" : "");
-  }
+  if (src)
+    testEndMessage(true, "%s/%s%s", src->super, src->type, compression ? " (gzipped)" : "");
+  else if ((src = mimeType(mime, "application", "octet-stream")) != NULL)
+    testEndMessage(true, "application/octet-stream");
+  else
+    testEndMessage(false, "unknown");
 
-  cupsDirClose(dir);
+  return (src);
 }