diff options
author | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2006-08-30 16:09:13 +0000 |
---|---|---|
committer | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2006-08-30 16:09:13 +0000 |
commit | d09495fadd23469999a64b1812ffb880bf4372de (patch) | |
tree | a6f43f6010b7194f777264b0b3659a6f244bc6bb /scheduler | |
parent | 8ca02f3c0539293422509d03219786fb6d7db48b (diff) | |
download | cups-d09495fadd23469999a64b1812ffb880bf4372de.tar.gz |
Load cups into easysw/current.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@211 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler')
-rw-r--r-- | scheduler/Dependencies | 157 | ||||
-rw-r--r-- | scheduler/Makefile | 21 | ||||
-rw-r--r-- | scheduler/auth.c | 13 | ||||
-rw-r--r-- | scheduler/client.c | 189 | ||||
-rw-r--r-- | scheduler/client.h | 5 | ||||
-rw-r--r-- | scheduler/conf.c | 65 | ||||
-rw-r--r-- | scheduler/cups-lpd.c | 12 | ||||
-rw-r--r-- | scheduler/cups-polld.c | 97 | ||||
-rw-r--r-- | scheduler/dirsvc.c | 37 | ||||
-rw-r--r-- | scheduler/dirsvc.h | 5 | ||||
-rw-r--r-- | scheduler/ipp.c | 125 | ||||
-rw-r--r-- | scheduler/job.c | 43 | ||||
-rw-r--r-- | scheduler/job.h | 6 | ||||
-rw-r--r-- | scheduler/main.c | 10 | ||||
-rw-r--r-- | scheduler/mime.h | 12 | ||||
-rw-r--r-- | scheduler/policy.c | 8 | ||||
-rw-r--r-- | scheduler/printers.c | 16 | ||||
-rw-r--r-- | scheduler/printers.h | 5 | ||||
-rw-r--r-- | scheduler/statbuf.c | 6 | ||||
-rw-r--r-- | scheduler/subscriptions.c | 16 | ||||
-rw-r--r-- | scheduler/sysman.c | 7 | ||||
-rw-r--r-- | scheduler/testlpd.c | 550 |
22 files changed, 1127 insertions, 278 deletions
diff --git a/scheduler/Dependencies b/scheduler/Dependencies index 7ca0a4300..d54993e2a 100644 --- a/scheduler/Dependencies +++ b/scheduler/Dependencies @@ -4,169 +4,177 @@ auth.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h auth.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h auth.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h auth.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -auth.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -auth.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -auth.o: banners.h dirsvc.h network.h subscriptions.h +auth.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +auth.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +auth.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h banners.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h banners.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h banners.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h banners.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -banners.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -banners.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -banners.o: classes.h job.h conf.h banners.h dirsvc.h network.h +banners.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +banners.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +banners.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h banners.o: subscriptions.h ../cups/dir.h cert.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h cert.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h cert.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h cert.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -cert.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -cert.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -cert.o: banners.h dirsvc.h network.h subscriptions.h +cert.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +cert.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +cert.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h classes.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h classes.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h classes.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h classes.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -classes.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -classes.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -classes.o: classes.h job.h conf.h banners.h dirsvc.h network.h +classes.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +classes.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +classes.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h classes.o: subscriptions.h client.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h client.o: ../cups/ipp-private.h ../cups/ipp.h cupsd.h ../cups/string.h client.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h client.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -client.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -client.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -client.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +client.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +client.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +client.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +client.o: subscriptions.h conf.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h conf.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h conf.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h conf.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -conf.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -conf.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -conf.o: banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h +conf.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +conf.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +conf.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +conf.o: ../cups/dir.h dirsvc.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h dirsvc.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h dirsvc.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h dirsvc.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -dirsvc.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -dirsvc.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -dirsvc.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +dirsvc.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +dirsvc.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +dirsvc.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +dirsvc.o: subscriptions.h env.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h env.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h env.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h env.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -env.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -env.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -env.o: banners.h dirsvc.h network.h subscriptions.h +env.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +env.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +env.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h main.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h main.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h main.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h main.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -main.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -main.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -main.o: banners.h dirsvc.h network.h subscriptions.h +main.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +main.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +main.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h ipp.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h ipp.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h ipp.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h ipp.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -ipp.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -ipp.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -ipp.o: banners.h dirsvc.h network.h subscriptions.h +ipp.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +ipp.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +ipp.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h listen.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h listen.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h listen.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h listen.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -listen.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -listen.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -listen.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +listen.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +listen.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +listen.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +listen.o: subscriptions.h job.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h job.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h job.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h job.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -job.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -job.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -job.o: banners.h dirsvc.h network.h subscriptions.h ../cups/backend.h -job.o: ../cups/dir.h +job.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +job.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +job.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +job.o: ../cups/backend.h ../cups/dir.h log.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h log.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h log.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h log.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -log.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h statbuf.h -log.o: cert.h auth.h client.h policy.h printers.h classes.h job.h conf.h -log.o: banners.h dirsvc.h network.h subscriptions.h -network.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h -network.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h +log.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h ../cups/debug.h +log.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h +log.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +network.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h +network.o: ../cups/ipp-private.h ../cups/ipp.h cupsd.h ../cups/string.h network.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h network.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -network.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -network.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -network.o: classes.h job.h conf.h banners.h dirsvc.h network.h +network.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +network.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +network.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h network.o: subscriptions.h policy.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h policy.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h policy.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h policy.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -policy.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -policy.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -policy.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +policy.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +policy.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +policy.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +policy.o: subscriptions.h printers.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h printers.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h printers.o: ../cups/string.h ../cups/array.h ../cups/cups.h ../cups/ppd.h printers.o: ../cups/array.h ../cups/file.h ../cups/language.h mime.h printers.o: ../cups/ipp.h ../cups/file.h ../cups/http.h ../cups/i18n.h -printers.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h -printers.o: policy.h printers.h classes.h job.h conf.h banners.h dirsvc.h -printers.o: network.h subscriptions.h ../cups/transcode.h +printers.o: ../cups/transcode.h ../cups/debug.h sysman.h statbuf.h cert.h +printers.o: auth.h client.h policy.h printers.h classes.h job.h conf.h +printers.o: banners.h dirsvc.h network.h subscriptions.h ../cups/dir.h process.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h process.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h process.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h process.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -process.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -process.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -process.o: classes.h job.h conf.h banners.h dirsvc.h network.h +process.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +process.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +process.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h process.o: subscriptions.h quotas.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h quotas.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h quotas.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h quotas.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -quotas.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -quotas.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -quotas.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +quotas.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +quotas.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +quotas.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +quotas.o: subscriptions.h server.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h server.o: ../cups/ipp-private.h ../cups/ipp.h cupsd.h ../cups/string.h server.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h server.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -server.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -server.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -server.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +server.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +server.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +server.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +server.o: subscriptions.h statbuf.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h statbuf.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h statbuf.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h statbuf.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -statbuf.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -statbuf.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -statbuf.o: classes.h job.h conf.h banners.h dirsvc.h network.h +statbuf.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +statbuf.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +statbuf.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h statbuf.o: subscriptions.h subscriptions.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h subscriptions.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h subscriptions.o: ../cups/string.h ../cups/array.h ../cups/cups.h subscriptions.o: ../cups/ppd.h ../cups/array.h ../cups/file.h subscriptions.o: ../cups/language.h mime.h ../cups/ipp.h ../cups/file.h -subscriptions.o: ../cups/http.h ../cups/i18n.h ../cups/debug.h sysman.h -subscriptions.o: statbuf.h cert.h auth.h client.h policy.h printers.h -subscriptions.o: classes.h job.h conf.h banners.h dirsvc.h network.h -subscriptions.o: subscriptions.h +subscriptions.o: ../cups/http.h ../cups/i18n.h ../cups/transcode.h +subscriptions.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h +subscriptions.o: policy.h printers.h classes.h job.h conf.h banners.h +subscriptions.o: dirsvc.h network.h subscriptions.h sysman.o: cupsd.h ../cups/http-private.h ../config.h ../cups/http.h sysman.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/string.h sysman.o: ../cups/array.h ../cups/cups.h ../cups/ppd.h ../cups/array.h sysman.o: ../cups/file.h ../cups/language.h mime.h ../cups/ipp.h -sysman.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/debug.h -sysman.o: sysman.h statbuf.h cert.h auth.h client.h policy.h printers.h -sysman.o: classes.h job.h conf.h banners.h dirsvc.h network.h subscriptions.h +sysman.o: ../cups/file.h ../cups/http.h ../cups/i18n.h ../cups/transcode.h +sysman.o: ../cups/debug.h sysman.h statbuf.h cert.h auth.h client.h policy.h +sysman.o: printers.h classes.h job.h conf.h banners.h dirsvc.h network.h +sysman.o: subscriptions.h filter.o: ../cups/debug.h ../cups/string.h ../config.h mime.h ../cups/array.h filter.o: ../cups/ipp.h ../cups/file.h -mime.o: ../cups/dir.h ../cups/string.h ../config.h mime.h ../cups/array.h -mime.o: ../cups/ipp.h ../cups/file.h +mime.o: ../cups/debug.h ../cups/dir.h ../cups/string.h ../config.h mime.h +mime.o: ../cups/array.h ../cups/ipp.h ../cups/file.h type.o: ../cups/string.h ../config.h mime.h ../cups/array.h ../cups/ipp.h type.o: ../cups/file.h ../cups/debug.h cups-deviced.o: util.h ../cups/cups.h ../cups/ipp.h ../cups/http.h @@ -176,7 +184,7 @@ cups-deviced.o: ../config.h ../cups/array.h ../cups/dir.h cups-driverd.o: util.h ../cups/cups.h ../cups/ipp.h ../cups/http.h cups-driverd.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h cups-driverd.o: ../cups/language.h ../cups/file.h ../cups/string.h -cups-driverd.o: ../config.h ../cups/dir.h +cups-driverd.o: ../config.h ../cups/dir.h ../cups/transcode.h cups-lpd.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h cups-lpd.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h ../cups/ppd.h cups-lpd.o: ../cups/array.h ../cups/file.h ../cups/language.h @@ -188,6 +196,9 @@ cups-polld.o: ../cups/language.h ../cups/string.h testdirsvc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h testdirsvc.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h testdirsvc.o: ../cups/string.h ../config.h +testlpd.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h +testlpd.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h +testlpd.o: ../cups/string.h ../config.h testmime.o: ../cups/string.h ../config.h mime.h ../cups/array.h ../cups/ipp.h testmime.o: ../cups/file.h ../cups/dir.h testspeed.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h diff --git a/scheduler/Makefile b/scheduler/Makefile index f269c3849..58d362114 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5736 2006-07-13 19:59:36Z mike $" +# "$Id: Makefile 5868 2006-08-23 19:39:39Z mike $" # # Scheduler Makefile for the Common UNIX Printing System (CUPS). # @@ -59,6 +59,7 @@ OBJS = \ cups-lpd.o \ cups-polld.o \ testdirsvc.o \ + testlpd.o \ testmime.o \ testspeed.o \ util.o @@ -70,6 +71,7 @@ TARGETS = \ cups-polld \ libmime.a \ testdirsvc \ + testlpd \ testmime \ testspeed @@ -251,6 +253,16 @@ testdirsvc: testdirsvc.o # +# Make the test program, "testlpd". +# + +testlpd: testlpd.o ../cups/libcups.a cups-lpd + echo Linking $@... + $(CC) $(LDFLAGS) -o testlpd testlpd.o ../cups/libcups.a \ + $(COMMONLIBS) $(LIBZ) $(SSLLIBS) + + +# # testmime # @@ -264,9 +276,10 @@ testmime: testmime.o libmime.a ../cups/libcups.a # Make the test program, "testspeed". # -testspeed: testspeed.o ../cups/$(LIBCUPS) +testspeed: testspeed.o ../cups/libcups.a echo Linking $@... - $(CC) $(LDFLAGS) -o testspeed testspeed.o $(LIBS) + $(CC) $(LDFLAGS) -o testspeed testspeed.o ../cups/libcups.a \ + $(COMMONLIBS) $(LIBZ) $(SSLLIBS) # @@ -277,5 +290,5 @@ include Dependencies # -# End of "$Id: Makefile 5736 2006-07-13 19:59:36Z mike $". +# End of "$Id: Makefile 5868 2006-08-23 19:39:39Z mike $". # diff --git a/scheduler/auth.c b/scheduler/auth.c index efae9914c..a1a10406b 100644 --- a/scheduler/auth.c +++ b/scheduler/auth.c @@ -1,5 +1,5 @@ /* - * "$Id: auth.c 5643 2006-06-07 20:58:29Z mike $" + * "$Id: auth.c 5840 2006-08-17 14:55:30Z mike $" * * Authorization routines for the Common UNIX Printing System (CUPS). * @@ -89,9 +89,9 @@ static cupsd_authmask_t *add_allow(cupsd_location_t *loc); static cupsd_authmask_t *add_deny(cupsd_location_t *loc); static int compare_locations(cupsd_location_t *a, cupsd_location_t *b); -#if !HAVE_LIBPAM +#if !HAVE_LIBPAM && !defined(HAVE_USERSEC_H) static char *cups_crypt(const char *pw, const char *salt); -#endif /* !HAVE_LIBPAM */ +#endif /* !HAVE_LIBPAM && !HAVE_USERSEC_H */ static char *get_md5_password(const char *username, const char *group, char passwd[33]); #if HAVE_LIBPAM @@ -540,7 +540,6 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ */ char *authmsg; /* Authentication message */ - char *loginmsg; /* Login message */ int reenter; /* ??? */ @@ -1871,7 +1870,7 @@ compare_locations(cupsd_location_t *a, /* I - First location */ } -#if !HAVE_LIBPAM +#if !HAVE_LIBPAM && !defined(HAVE_USERSEC_H) /* * 'cups_crypt()' - Encrypt the password using the DES or MD5 algorithms, * as needed. @@ -1991,7 +1990,7 @@ cups_crypt(const char *pw, /* I - Password string */ return (crypt(pw, salt)); } } -#endif /* !HAVE_LIBPAM */ +#endif /* !HAVE_LIBPAM && !HAVE_USERSEC_H */ /* @@ -2171,5 +2170,5 @@ to64(char *s, /* O - Output string */ /* - * End of "$Id: auth.c 5643 2006-06-07 20:58:29Z mike $". + * End of "$Id: auth.c 5840 2006-08-17 14:55:30Z mike $". */ diff --git a/scheduler/client.c b/scheduler/client.c index c3c236f78..d5d1851a3 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1,5 +1,5 @@ /* - * "$Id: client.c 5739 2006-07-16 15:21:18Z mike $" + * "$Id: client.c 5898 2006-08-28 18:54:10Z mike $" * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -26,6 +26,7 @@ * cupsdAcceptClient() - Accept a new client. * cupsdCloseAllClients() - Close all remote clients immediately. * cupsdCloseClient() - Close a remote client. + * cupsdFlushHeader() - Flush the header fields to the client. * cupsdReadClient() - Read data from a client. * cupsdSendCommand() - Send output from a command via HTTP. * cupsdSendError() - Send an error message via HTTP. @@ -674,6 +675,19 @@ cupsdCloseClient(cupsd_client_t *con) /* I - Client to close */ /* + * 'cupsdFlushHeader()' - Flush the header fields to the client. + */ + +void +cupsdFlushHeader(cupsd_client_t *con) /* I - Client to flush to */ +{ + httpFlushWrite(HTTP(con)); + + con->http.data_encoding = HTTP_ENCODE_LENGTH; +} + + +/* * 'cupsdReadClient()' - Read data from a client. */ @@ -1024,6 +1038,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Upgrade: TLS/1.0,HTTP/1.1\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); encrypt_client(con); #else @@ -1038,6 +1053,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); } else if (!is_path_absolute(con->uri)) { @@ -1065,6 +1081,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Upgrade: TLS/1.0,HTTP/1.1\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); encrypt_client(con); #else @@ -1105,6 +1122,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); } } @@ -1538,6 +1556,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (cupsdCloseClient(con)); + cupsdFlushHeader(con); + cupsdLogRequest(con, HTTP_OK); } else if ((!strncmp(con->uri, "/admin/conf/", 12) && @@ -1601,6 +1621,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (cupsdCloseClient(con)); + cupsdFlushHeader(con); + con->http.state = HTTP_WAITING; break; @@ -2074,6 +2096,8 @@ cupsdSendError(cupsd_client_t *con, /* I - Connection */ else if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); + cupsdFlushHeader(con); + con->http.state = HTTP_WAITING; return (1); @@ -2093,6 +2117,10 @@ cupsdSendHeader(cupsd_client_t *con, /* I - Client to send to */ * Send the HTTP status header... */ + httpFlushWrite(HTTP(con)); + + con->http.data_encoding = HTTP_ENCODE_FIELDS; + if (httpPrintf(HTTP(con), "HTTP/%d.%d %d %s\r\n", con->http.version / 100, con->http.version % 100, code, httpStatus(code)) < 0) return (0); @@ -2106,7 +2134,10 @@ cupsdSendHeader(cupsd_client_t *con, /* I - Client to send to */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); else + { + cupsdFlushHeader(con); return (1); + } } if (httpPrintf(HTTP(con), "Date: %s\r\n", httpGetDateString(time(NULL))) < 0) @@ -2191,7 +2222,7 @@ cupsdUpdateCGI(void) if (!strchr(CGIStatusBuffer->buffer, '\n')) break; - if (ptr == NULL && errno) + if (ptr == NULL && !CGIStatusBuffer->bufused) { /* * Fatal error on pipe - should never happen! @@ -2274,15 +2305,13 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ return (0); } else if (!strncasecmp(buf, "Status:", 7)) - cupsdSendError(con, atoi(buf + 7)); + cupsdSendError(con, (http_status_t)atoi(buf + 7)); else { cupsdSendHeader(con, HTTP_OK, NULL); if (con->http.version == HTTP_1_1) { - con->http.data_encoding = HTTP_ENCODE_CHUNKED; - if (httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n") < 0) return (0); } @@ -2310,7 +2339,14 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ */ if (con->field_col == 0) + { con->got_fields = 1; + + cupsdFlushHeader(con); + + if (con->http.version == HTTP_1_1) + con->http.data_encoding = HTTP_ENCODE_CHUNKED; + } else con->field_col = 0; } @@ -3350,19 +3386,31 @@ static int /* O - 1 on success, 0 on failure */ make_certificate(void) { #if defined(HAVE_LIBSSL) && defined(HAVE_WAITPID) - int pid, /* Process ID of command */ - status; /* Status of command */ - char command[1024], /* Command */ - *argv[11], /* Command-line arguments */ - *envp[MAX_ENV]; /* Environment variables */ + int pid, /* Process ID of command */ + status; /* Status of command */ + char command[1024], /* Command */ + *argv[11], /* Command-line arguments */ + *envp[MAX_ENV + 1], /* Environment variables */ + home[1024], /* HOME environment variable */ + infofile[1024], /* Type-in information for cert */ + seedfile[1024]; /* Random number seed file */ + int envc, /* Number of environment variables */ + bytes; /* Bytes written */ + cups_file_t *fp; /* Seed/info file */ + int infofd; /* Info file descriptor */ /* - * Run the "openssl" command to generate a self-signed certificate - * that is good for 10 years: + * Run the "openssl" command to seed the random number generator and + * generate a self-signed certificate that is good for 10 years: + * + * openssl rand -rand seedfile 1 * * openssl req -new -x509 -keyout ServerKey \ * -out ServerCertificate -days 3650 -nodes + * + * The seeding step is crucial in ensuring that the openssl command + * does not block on systems without sufficient entropy... */ if (!cupsFileFind("openssl", getenv("PATH"), 1, command, sizeof(command))) @@ -3372,6 +3420,108 @@ make_certificate(void) return (0); } + if (access("/dev/urandom", 0)) + { + /* + * If the system doesn't provide /dev/urandom, then any random source + * will probably be blocking-style, so generate some random data to + * use as a seed for the certificate. Note that we have already + * seeded the random number generator in cupsdInitCerts()... + */ + + cupsdLogMessage(CUPSD_LOG_INFO, + "Seeding the random number generator..."); + + snprintf(home, sizeof(home), "HOME=%s", TempDir); + + /* + * Write the seed file... + */ + + if ((fp = cupsTempFile2(seedfile, sizeof(seedfile))) == NULL) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create seed file %s - %s", + seedfile, strerror(errno)); + return (0); + } + + for (bytes = 0; bytes < 262144; bytes ++) + cupsFilePutChar(fp, random()); + + cupsFileClose(fp); + + /* + * Run the openssl command to seed its random number generator... + */ + + argv[0] = "openssl"; + argv[1] = "rand"; + argv[2] = "-rand"; + argv[3] = seedfile; + argv[4] = "1"; + argv[5] = NULL; + + envc = cupsdLoadEnv(envp, MAX_ENV); + envp[envc++] = home; + envp[envc] = NULL; + + if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, 1, &pid)) + { + unlink(seedfile); + return (0); + } + + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + { + status = 1; + break; + } + + cupsdFinishProcess(pid, command, sizeof(command)); + + /* + * Remove the seed file, as it is no longer needed... + */ + + unlink(seedfile); + + if (status) + { + if (WIFEXITED(status)) + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to seed random number generator - " + "the openssl command stopped with status %d!", + WEXITSTATUS(status)); + else + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to seed random number generator - " + "the openssl command crashed on signal %d!", + WTERMSIG(status)); + + return (0); + } + } + + /* + * Create a file with the certificate information fields... + * + * Note: This assumes that the default questions are asked by the openssl + * command... + */ + + if ((fp = cupsTempFile2(infofile, sizeof(infofile))) == NULL) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to create certificate information file %s - %s", + infofile, strerror(errno)); + return (0); + } + + cupsFilePrintf(fp, ".\n.\n.\n%s\n.\n%s\n%s\n", + ServerName, ServerName, ServerAdmin); + cupsFileClose(fp); + cupsdLogMessage(CUPSD_LOG_INFO, "Generating SSL server key and certificate..."); @@ -3390,8 +3540,17 @@ make_certificate(void) cupsdLoadEnv(envp, MAX_ENV); - if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, 1, &pid)) + infofd = open(infofile, O_RDONLY); + + if (!cupsdStartProcess(command, argv, envp, infofd, -1, -1, -1, 1, &pid)) + { + close(infofd); + unlink(infofile); return (0); + } + + close(infofd); + unlink(infofile); while (waitpid(pid, &status, 0) < 0) if (errno != EINTR) @@ -3993,6 +4152,8 @@ write_file(cupsd_client_t *con, /* I - Client connection */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); + cupsdFlushHeader(con); + con->http.data_encoding = HTTP_ENCODE_LENGTH; con->http.data_remaining = filestats->st_size; @@ -4011,5 +4172,5 @@ write_file(cupsd_client_t *con, /* I - Client connection */ /* - * End of "$Id: client.c 5739 2006-07-16 15:21:18Z mike $". + * End of "$Id: client.c 5898 2006-08-28 18:54:10Z mike $". */ diff --git a/scheduler/client.h b/scheduler/client.h index 7a7b70cd7..ef376cda8 100644 --- a/scheduler/client.h +++ b/scheduler/client.h @@ -1,5 +1,5 @@ /* - * "$Id: client.h 5305 2006-03-18 03:05:12Z mike $" + * "$Id: client.h 5889 2006-08-24 21:44:35Z mike $" * * Client definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -104,6 +104,7 @@ extern void cupsdAcceptClient(cupsd_listener_t *lis); extern void cupsdCloseAllClients(void); extern int cupsdCloseClient(cupsd_client_t *con); extern void cupsdDeleteAllListeners(void); +extern void cupsdFlushHeader(cupsd_client_t *con); extern void cupsdPauseListening(void); extern int cupsdProcessIPPRequest(cupsd_client_t *con); extern int cupsdReadClient(cupsd_client_t *con); @@ -121,5 +122,5 @@ extern int cupsdWriteClient(cupsd_client_t *con); /* - * End of "$Id: client.h 5305 2006-03-18 03:05:12Z mike $". + * End of "$Id: client.h 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/conf.c b/scheduler/conf.c index 42acaf083..4d4f1cf85 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1,5 +1,5 @@ /* - * "$Id: conf.c 5736 2006-07-13 19:59:36Z mike $" + * "$Id: conf.c 5905 2006-08-29 20:48:59Z mike $" * * Configuration routines for the Common UNIX Printing System (CUPS). * @@ -636,21 +636,21 @@ cupsdReadConfiguration(void) * writable by the user and group in the cupsd.conf file... */ - check_permissions(CacheDir, NULL, 0775, RunUser, Group, 1, 1); -/* check_permissions(CacheDir, "ppd", 0755, RunUser, Group, 1, 1);*/ - - check_permissions(StateDir, NULL, 0755, RunUser, Group, 1, 1); - check_permissions(StateDir, "certs", RunUser ? 0711 : 0511, User, - SystemGroupIDs[0], 1, 1); - - check_permissions(ServerRoot, NULL, 0755, RunUser, Group, 1, 0); - check_permissions(ServerRoot, "ppd", 0755, RunUser, Group, 1, 1); - check_permissions(ServerRoot, "ssl", 0700, RunUser, Group, 1, 0); - check_permissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, Group, - 0, 0); - check_permissions(ServerRoot, "classes.conf", 0600, RunUser, Group, 0, 0); - check_permissions(ServerRoot, "printers.conf", 0600, RunUser, Group, 0, 0); - check_permissions(ServerRoot, "passwd.md5", 0600, User, Group, 0, 0); + if (check_permissions(CacheDir, NULL, 0775, RunUser, Group, 1, 1) < 0 || + check_permissions(StateDir, NULL, 0755, RunUser, Group, 1, 1) < 0 || + check_permissions(StateDir, "certs", RunUser ? 0711 : 0511, User, + SystemGroupIDs[0], 1, 1) < 0 || + check_permissions(ServerRoot, NULL, 0755, RunUser, Group, 1, 0) < 0 || + check_permissions(ServerRoot, "ppd", 0755, RunUser, Group, 1, 1) < 0 || + check_permissions(ServerRoot, "ssl", 0700, RunUser, Group, 1, 0) < 0 || + check_permissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, + Group, 0, 0) < 0 || + check_permissions(ServerRoot, "classes.conf", 0600, RunUser, Group, + 0, 0) < 0 || + check_permissions(ServerRoot, "printers.conf", 0600, RunUser, Group, + 0, 0) < 0 || + check_permissions(ServerRoot, "passwd.md5", 0600, User, Group, 0, 0) < 0) + return (0); /* * Update TempDir to the default if it hasn't been set already... @@ -677,14 +677,14 @@ cupsdReadConfiguration(void) "TMPDIR (%s) has the wrong permissions!", tmpdir); else cupsdSetString(&TempDir, tmpdir); - - if (!TempDir) - cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...", - RequestRoot); } if (!TempDir) + { + cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...", + RequestRoot); cupsdSetStringf(&TempDir, "%s/tmp", RequestRoot); + } } /* @@ -692,7 +692,8 @@ cupsdReadConfiguration(void) * permissions... */ - check_permissions(RequestRoot, NULL, 0710, RunUser, Group, 1, 1); + if (check_permissions(RequestRoot, NULL, 0710, RunUser, Group, 1, 1) < 0) + return (0); if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)) || access(TempDir, 0)) @@ -702,7 +703,8 @@ cupsdReadConfiguration(void) * is under the spool directory or does not exist... */ - check_permissions(TempDir, NULL, 01770, RunUser, Group, 1, 1); + if (check_permissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0) + return (0); } if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot))) @@ -772,7 +774,7 @@ cupsdReadConfiguration(void) if (MaxActiveJobs > (MaxFDs / 3)) MaxActiveJobs = MaxFDs / 3; - if (Classification && strcasecmp(Classification, "none") == 0) + if (Classification && !strcasecmp(Classification, "none")) cupsdClearString(&Classification); if (Classification) @@ -1112,7 +1114,7 @@ cupsdReadConfiguration(void) * 'check_permissions()' - Fix the mode and ownership of a file or directory. */ -static int /* O - 0 on success, -1 on error */ +static int /* O - 0 on success, -1 on error, 1 on warning */ check_permissions(const char *filename, /* I - File/directory name */ const char *suffix, /* I - Additional file/directory name */ int mode, /* I - Permissions */ @@ -1158,7 +1160,7 @@ check_permissions(const char *filename, /* I - File/directory name */ dir_created = 1; } else - return (-1); + return (create_dir ? -1 : 1); } /* @@ -1190,7 +1192,7 @@ check_permissions(const char *filename, /* I - File/directory name */ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to change ownership of \"%s\" - %s", filename, strerror(errno)); - return (-1); + return (1); } } @@ -1203,7 +1205,7 @@ check_permissions(const char *filename, /* I - File/directory name */ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to change permissions of \"%s\" - %s", filename, strerror(errno)); - return (-1); + return (1); } } @@ -1947,6 +1949,13 @@ parse_protocols(const char *s) /* I - Space-delimited protocols */ /* + * Empty protocol line yields NULL pointer... + */ + + if (!s) + return (0); + + /* * Loop through the value string,... */ @@ -3280,5 +3289,5 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ /* - * End of "$Id: conf.c 5736 2006-07-13 19:59:36Z mike $". + * End of "$Id: conf.c 5905 2006-08-29 20:48:59Z mike $". */ diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index 60b68090f..caa6bef9a 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-lpd.c 5455 2006-04-24 13:49:59Z mike $" + * "$Id: cups-lpd.c 5878 2006-08-24 15:55:42Z mike $" * * Line Printer Daemon interface for the Common UNIX Printing System (CUPS). * @@ -471,7 +471,7 @@ get_printer(http_t *http, /* I - HTTP connection */ request = ippNewRequest(CUPS_GET_PRINTERS); - ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested) / sizeof(requested[0])), NULL, requested); @@ -597,7 +597,7 @@ get_printer(http_t *http, /* I - HTTP connection */ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); - ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested) / sizeof(requested[0])), NULL, requested); @@ -648,7 +648,7 @@ get_printer(http_t *http, /* I - HTTP connection */ if (state) { if ((attr = ippFindAttribute(response, "printer-state", - IPP_TAG_INTEGER)) == NULL) + IPP_TAG_ENUM)) == NULL) syslog(LOG_ERR, "No printer-state attribute found in " "response from server!"); else @@ -1387,7 +1387,7 @@ remove_jobs(const char *dest, /* I - Destination */ return (1); } else - syslog(LOG_INFO, "Job ID %d cancelled", id); + syslog(LOG_INFO, "Job ID %d canceled", id); } httpClose(http); @@ -1716,5 +1716,5 @@ smart_gets(char *s, /* I - Pointer to line buffer */ /* - * End of "$Id: cups-lpd.c 5455 2006-04-24 13:49:59Z mike $". + * End of "$Id: cups-lpd.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/scheduler/cups-polld.c b/scheduler/cups-polld.c index 259361d5b..be6bbb5e6 100644 --- a/scheduler/cups-polld.c +++ b/scheduler/cups-polld.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-polld.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: cups-polld.c 5871 2006-08-23 20:55:33Z mike $" * * Polling daemon for the Common UNIX Printing System (CUPS). * @@ -23,9 +23,11 @@ * * Contents: * - * main() - Open sockets and poll until we are killed... - * dequote() - Remote quotes from a string. - * poll_server() - Poll the server for the given set of printers or classes. + * main() - Open sockets and poll until we are killed... + * dequote() - Remote quotes from a string. + * poll_server() - Poll the server for the given set of printers or + * classes. + * sighup_handler() - Handle 'hangup' signals to restart polling. */ /* @@ -38,6 +40,14 @@ #include <errno.h> #include <cups/language.h> #include <cups/string.h> +#include <signal.h> + + +/* + * Local globals... + */ + +static int restart_polling = 1; /* @@ -47,6 +57,7 @@ static char *dequote(char *d, const char *s, int dlen); static int poll_server(http_t *http, int sock, int port, int interval, const char *prefix); +static void sighup_handler(int sig); /* @@ -65,9 +76,29 @@ main(int argc, /* I - Number of command-line args */ int seconds, /* Seconds left from poll */ remain; /* Total remaining time to sleep */ char prefix[1024]; /* Prefix for log messages */ +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + struct sigaction action; /* Actions for POSIX signals */ +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ /* + * Catch hangup signals for when the network changes... + */ + +#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ + sigset(SIGHUP, sighup_handler); +#elif defined(HAVE_SIGACTION) + memset(&action, 0, sizeof(action)); + + sigemptyset(&action.sa_mask); + sigaddset(&action.sa_mask, SIGHUP); + action.sa_handler = sighup_handler; + sigaction(SIGHUP, &action, NULL); +#else + signal(SIGHUP, sighup_handler); +#endif /* HAVE_SIGSET */ + + /* * Don't buffer log messages... */ @@ -119,38 +150,43 @@ main(int argc, /* I - Number of command-line args */ } /* - * Open a connection to the server... + * Loop forever, asking for available printers and classes... */ - while ((http = httpConnectEncrypt(argv[1], atoi(argv[2]), - cupsEncryption())) == NULL) + for (http = NULL;;) { - fprintf(stderr, "ERROR: %s Unable to connect to %s on port %s: %s\n", - prefix, argv[1], argv[2], - h_errno ? hstrerror(h_errno) : strerror(errno)); - sleep(interval); - } + /* + * Open a connection to the server... + */ - /* - * Loop forever, asking for available printers and classes... - */ + if (restart_polling || !http) + { + restart_polling = 0; + httpClose(http); + + if ((http = httpConnectEncrypt(argv[1], atoi(argv[2]), + cupsEncryption())) == NULL) + { + fprintf(stderr, "ERROR: %s Unable to connect to %s on port %s: %s\n", + prefix, argv[1], argv[2], + h_errno ? hstrerror(h_errno) : strerror(errno)); + } + } - for (;;) - { /* * Get the printers and classes... */ remain = interval; - if ((seconds = poll_server(http, sock, port, interval, prefix)) > 0) + if (http && (seconds = poll_server(http, sock, port, interval, prefix)) > 0) remain -= seconds; /* * Sleep for any remaining time... */ - if (remain > 0) + if (remain > 0 && !restart_polling) sleep(remain); } } @@ -260,6 +296,7 @@ poll_server(http_t *http, /* I - HTTP connection */ * Do the request and get back a response... */ + seconds = time(NULL); response = cupsDoRequest(http, request, "/"); if (cupsLastError() > IPP_OK_CONFLICT) @@ -285,7 +322,6 @@ poll_server(http_t *http, /* I - HTTP connection */ fprintf(stderr, "DEBUG: %s Found %d printers.\n", prefix, max_count); count = 0; - seconds = time(NULL); max_count = max_count / interval + 1; /* @@ -409,7 +445,7 @@ poll_server(http_t *http, /* I - HTTP connection */ sleep(1); } - if (!attr) + if (!attr || restart_polling) break; } @@ -425,5 +461,22 @@ poll_server(http_t *http, /* I - HTTP connection */ /* - * End of "$Id: cups-polld.c 5753 2006-07-18 19:53:24Z mike $". + * 'sighup_handler()' - Handle 'hangup' signals to restart polling. + */ + +static void +sighup_handler(int sig) /* I - Signal number */ +{ + (void)sig; + + restart_polling = 1; + +#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION) + signal(SIGHUP, sighup_handler); +#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */ +} + + +/* + * End of "$Id: cups-polld.c 5871 2006-08-23 20:55:33Z mike $". */ diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index c2e19a970..cb751549b 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.c 5724 2006-07-12 19:42:35Z mike $" + * "$Id: dirsvc.c 5889 2006-08-24 21:44:35Z mike $" * * Directory services routines for the Common UNIX Printing System (CUPS). * @@ -514,6 +514,23 @@ cupsdLoadRemoteCache(void) /* + * 'cupsdRestartPolling()' - Restart polling servers as needed. + */ + +void +cupsdRestartPolling(void) +{ + int i; /* Looping var */ + cupsd_dirsvc_poll_t *pollp; /* Current polling server */ + + + for (i = 0, pollp = Polled; i < NumPolled; i ++, pollp ++) + if (pollp->pid) + kill(pollp->pid, SIGHUP); +} + + +/* * 'cupsdSaveRemoteCache()' - Save the remote printer cache. */ @@ -1468,7 +1485,7 @@ cupsdUpdateCUPSBrowse(void) if (cupsdCheckAuth(address, srcname, len, 1, &(Relays[i].from))) if (sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(Relays[i].to), - sizeof(http_addr_t)) <= 0) + httpAddrLength(&(Relays[i].to))) <= 0) { cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdUpdateCUPSBrowse: sendto failed for relay %d - %s.", @@ -1609,7 +1626,7 @@ cupsdUpdatePolling(void) if (!strchr(PollStatusBuffer->buffer, '\n')) break; - if (ptr == NULL) + if (ptr == NULL && !PollStatusBuffer->bufused) { /* * All polling processes have died; stop polling... @@ -1923,6 +1940,9 @@ process_browse_data( else return; + if (hptr && !*hptr) + *hptr = '.'; /* Resource FQDN */ + if ((p = cupsdFindClass(name)) == NULL && BrowseShortNames) { if ((p = cupsdFindClass(resource + 9)) != NULL) @@ -2026,6 +2046,9 @@ process_browse_data( else return; + if (hptr && !*hptr) + *hptr = '.'; /* Resource FQDN */ + if ((p = cupsdFindPrinter(name)) == NULL && BrowseShortNames) { if ((p = cupsdFindPrinter(resource + 10)) != NULL) @@ -2566,7 +2589,7 @@ send_cups_browse(cupsd_printer_t *p) /* I - Printer to send */ sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(iface->broadcast), - sizeof(struct sockaddr_in)); + httpAddrLength(&(iface->broadcast))); } } else if ((iface = cupsdNetIFFind(b->iface)) != NULL) @@ -2607,7 +2630,7 @@ send_cups_browse(cupsd_printer_t *p) /* I - Printer to send */ sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(iface->broadcast), - sizeof(struct sockaddr_in)); + httpAddrLength(&(iface->broadcast))); } } } @@ -2628,7 +2651,7 @@ send_cups_browse(cupsd_printer_t *p) /* I - Printer to send */ if (sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(b->to), - sizeof(struct sockaddr_in)) <= 0) + httpAddrLength(&(b->to))) <= 0) { /* * Unable to send browse packet, so remove this address from the @@ -3158,5 +3181,5 @@ slp_url_callback( /* - * End of "$Id: dirsvc.c 5724 2006-07-12 19:42:35Z mike $". + * End of "$Id: dirsvc.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/dirsvc.h b/scheduler/dirsvc.h index 171933f93..2e3a05988 100644 --- a/scheduler/dirsvc.h +++ b/scheduler/dirsvc.h @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.h 5305 2006-03-18 03:05:12Z mike $" + * "$Id: dirsvc.h 5833 2006-08-16 20:05:58Z mike $" * * Directory services definitions for the Common UNIX Printing System * (CUPS) scheduler. @@ -164,6 +164,7 @@ VAR char *BrowseLDAPBindDN VALUE(NULL), */ extern void cupsdLoadRemoteCache(void); +extern void cupsdRestartPolling(void); extern void cupsdSaveRemoteCache(void); extern void cupsdSendBrowseDelete(cupsd_printer_t *p); extern void cupsdSendBrowseList(void); @@ -180,5 +181,5 @@ extern void cupsdUpdateSLPBrowse(void); /* - * End of "$Id: dirsvc.h 5305 2006-03-18 03:05:12Z mike $". + * End of "$Id: dirsvc.h 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 28115133d..d32a71505 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c 5736 2006-07-13 19:59:36Z mike $" + * "$Id: ipp.c 5907 2006-08-30 02:18:28Z mike $" * * IPP routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -630,7 +630,7 @@ cupsdProcessIPPRequest( #ifdef CUPSD_USE_CHUNKING /* * Because older versions of CUPS (1.1.17 and older) and some IPP - * clients do not implement chunking properly, we should not use + * clients do not implement chunking properly, we cannot use * chunking by default. This may become the default in future * CUPS releases, or we might add a configuration directive for * it. @@ -638,23 +638,25 @@ cupsdProcessIPPRequest( if (con->http.version == HTTP_1_1) { - con->http.data_encoding = HTTP_ENCODE_CHUNKED; - httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n\r\n"); + cupsdFlushHeader(con); + + con->http.data_encoding = HTTP_ENCODE_CHUNKED; } else #endif /* CUPSD_USE_CHUNKING */ { - con->http.data_encoding = HTTP_ENCODE_LENGTH; - con->http.data_remaining = ippLength(con->response); + size_t length; /* Length of response */ - if (con->http.data_remaining < INT_MAX) - con->http._data_remaining = con->http.data_remaining; - else - con->http._data_remaining = INT_MAX; + + length = ippLength(con->response); httpPrintf(HTTP(con), "Content-Length: " CUPS_LLFMT "\r\n\r\n", - CUPS_LLCAST con->http.data_remaining); + CUPS_LLCAST length); + cupsdFlushHeader(con); + + con->http.data_encoding = HTTP_ENCODE_LENGTH; + con->http.data_remaining = length; } cupsdLogMessage(CUPSD_LOG_DEBUG2, @@ -784,7 +786,6 @@ add_class(cupsd_client_t *con, /* I - Client connection */ cupsd_printer_t *pclass, /* Class */ *member; /* Member printer/class */ cups_ptype_t dtype; /* Destination type */ - const char *dest; /* Printer or class name */ ipp_attribute_t *attr; /* Printer attribute */ int modify; /* Non-zero if we just modified */ char newname[IPP_MAX_NAME]; /* New class name */ @@ -1007,7 +1008,7 @@ add_class(cupsd_client_t *con, /* I - Client connection */ sizeof(method), username, sizeof(username), host, sizeof(host), &port, resource, sizeof(resource)); - if ((dest = cupsdValidateDest(host, resource, &dtype, &member)) == NULL) + if (!cupsdValidateDest(host, resource, &dtype, &member)) { /* * Bad URI... @@ -1467,7 +1468,7 @@ add_job(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", IPP_JOB_STOPPED); - job->state_value = job->state->values[0].integer; + job->state_value = (ipp_jstate_t)job->state->values[0].integer; job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-media-sheets-completed", 0); ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL, @@ -1728,7 +1729,7 @@ add_job_state_reasons( cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job_state_reasons(%p[%d], %d)", con, con->http.fd, job ? job->id : 0); - switch (job ? job->state_value : IPP_JOB_CANCELLED) + switch (job ? job->state_value : IPP_JOB_CANCELED) { case IPP_JOB_PENDING : dest = cupsdFindDest(job->dest); @@ -1763,7 +1764,7 @@ add_job_state_reasons( "job-state-reasons", NULL, "job-stopped"); break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-canceled-by-user"); break; @@ -1961,7 +1962,6 @@ add_job_uuid(cupsd_client_t *con, /* I - Client connection */ cupsd_job_t *job) /* I - Job */ { char uuid[1024]; /* job-uuid string */ - ipp_attribute_t *attr; /* job-uuid attribute */ _cups_md5_state_t md5state; /* MD5 state */ unsigned char md5sum[16]; /* MD5 digest/sum */ @@ -1970,7 +1970,7 @@ add_job_uuid(cupsd_client_t *con, /* I - Client connection */ * First see if the job already has a job-uuid attribute; if so, return... */ - if ((attr = ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI)) != NULL) + if (ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI)) return; /* @@ -2872,7 +2872,7 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ cupsdCancelJobs(NULL, username, purge); cupsdLogMessage(CUPSD_LOG_INFO, "All jobs were %s by \"%s\".", - purge ? "purged" : "cancelled", get_username(con)); + purge ? "purged" : "canceled", get_username(con)); } else { @@ -2893,7 +2893,7 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ cupsdCancelJobs(dest, username, purge); cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".", - dest, purge ? "purged" : "cancelled", get_username(con)); + dest, purge ? "purged" : "canceled", get_username(con)); } con->response->request.status.status_code = IPP_OK; @@ -3043,17 +3043,17 @@ cancel_job(cupsd_client_t *con, /* I - Client connection */ } /* - * See if the job is already completed, cancelled, or aborted; if so, + * See if the job is already completed, canceled, or aborted; if so, * we can't cancel... */ - if (job->state_value >= IPP_JOB_CANCELLED) + if (job->state_value >= IPP_JOB_CANCELED) { switch (job->state_value) { - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : send_ipp_status(con, IPP_NOT_POSSIBLE, - _("Job #%d is already cancelled - can\'t cancel."), + _("Job #%d is already canceled - can\'t cancel."), jobid); break; @@ -3078,12 +3078,12 @@ cancel_job(cupsd_client_t *con, /* I - Client connection */ */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, - "Job cancelled by \"%s\".", username); + "Job canceled by \"%s\".", username); cupsdCancelJob(job, 0); cupsdCheckJobs(); - cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was cancelled by \"%s\".", jobid, + cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was canceled by \"%s\".", jobid, username); con->response->request.status.status_code = IPP_OK; @@ -4382,7 +4382,7 @@ copy_subscription_attrs( */ ippAddString(con->response, IPP_TAG_SUBSCRIPTION, - IPP_TAG_KEYWORD | IPP_TAG_COPY, + (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY), "notify-events", NULL, name); } else @@ -4396,7 +4396,7 @@ copy_subscription_attrs( count ++; attr = ippAddStrings(con->response, IPP_TAG_SUBSCRIPTION, - IPP_TAG_KEYWORD | IPP_TAG_COPY, + (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY), "notify-events", count, NULL, NULL); for (mask = 1, count = 0; mask < CUPSD_EVENT_ALL; mask <<= 1) @@ -4676,7 +4676,6 @@ create_subscription( http_status_t status; /* Policy status */ int i; /* Looping var */ ipp_attribute_t *attr; /* Current attribute */ - const char *dest; /* Destination */ cups_ptype_t dtype; /* Destination type (printer or class) */ char scheme[HTTP_MAX_URI], /* Scheme portion of URI */ @@ -4725,23 +4724,20 @@ create_subscription( if (!strcmp(resource, "/")) { - dest = NULL; dtype = (cups_ptype_t)0; printer = NULL; } else if (!strncmp(resource, "/printers", 9) && strlen(resource) <= 10) { - dest = NULL; dtype = (cups_ptype_t)0; printer = NULL; } else if (!strncmp(resource, "/classes", 8) && strlen(resource) <= 9) { - dest = NULL; dtype = CUPS_PRINTER_CLASS; printer = NULL; } - else if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) + else if (!cupsdValidateDest(host, resource, &dtype, &printer)) { /* * Bad URI... @@ -5734,7 +5730,6 @@ get_printer_attrs(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *uri) /* I - Printer URI */ { http_status_t status; /* Policy status */ - const char *dest; /* Destination */ cups_ptype_t dtype; /* Destination type (printer or class) */ char method[HTTP_MAX_URI], /* Method portion of URI */ @@ -5760,7 +5755,7 @@ get_printer_attrs(cupsd_client_t *con, /* I - Client connection */ sizeof(method), username, sizeof(username), host, sizeof(host), &port, resource, sizeof(resource)); - if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) + if (!cupsdValidateDest(host, resource, &dtype, &printer)) { /* * Bad URI... @@ -6269,6 +6264,9 @@ hold_job(cupsd_client_t *con, /* I - Client connection */ cupsdHoldJob(job); + cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, + "Job held by user."); + if ((newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_KEYWORD)) == NULL) newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME); @@ -6302,6 +6300,9 @@ hold_job(cupsd_client_t *con, /* I - Client connection */ */ cupsdSetJobHoldUntil(job, attr->values[0].string.text); + + cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job, + "Job job-hold-until value changed by user."); } cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was held by \"%s\".", jobid, @@ -6323,8 +6324,7 @@ move_job(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *attr; /* Current attribute */ int jobid; /* Job ID */ cupsd_job_t *job; /* Current job */ - const char *src, /* Source printer/class */ - *dest; /* Destination */ + const char *src; /* Source printer/class */ cups_ptype_t stype, /* Source type (printer or class) */ dtype; /* Destination type (printer or class) */ char method[HTTP_MAX_URI], /* Method portion of URI */ @@ -6359,7 +6359,7 @@ move_job(cupsd_client_t *con, /* I - Client connection */ sizeof(method), username, sizeof(username), host, sizeof(host), &port, resource, sizeof(resource)); - if ((dest = cupsdValidateDest(host, resource, &dtype, &dprinter)) == NULL) + if (!cupsdValidateDest(host, resource, &dtype, &dprinter)) { /* * Bad URI... @@ -7317,6 +7317,9 @@ release_job(cupsd_client_t *con, /* I - Client connection */ attr->value_tag = IPP_TAG_KEYWORD; attr->values[0].string.text = _cupsStrAlloc("no-hold"); + + cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job, + "Job job-hold-until value changed by user."); } /* @@ -7325,6 +7328,9 @@ release_job(cupsd_client_t *con, /* I - Client connection */ cupsdReleaseJob(job); + cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, + "Job released by user."); + cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was released by \"%s\".", jobid, username); @@ -8004,7 +8010,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", jobid); ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", - job ? job->state_value : IPP_JOB_CANCELLED); + job ? job->state_value : IPP_JOB_CANCELED); add_job_state_reasons(con, job); con->response->request.status.status_code = IPP_OK; @@ -8053,14 +8059,12 @@ send_ipp_status(cupsd_client_t *con, /* I - Client connection */ _cupsLangString(con->language, message), ap); va_end(ap); - cupsdLogMessage(status >= IPP_BAD_REQUEST ? CUPSD_LOG_ERROR : CUPSD_LOG_INFO, - "%s %s: %s", + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s %s: %s", ippOpString(con->request->request.op.operation_id), ippErrorString(status), formatted); } else - cupsdLogMessage(status >= IPP_BAD_REQUEST ? CUPSD_LOG_ERROR : CUPSD_LOG_INFO, - "%s %s", + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s %s", ippOpString(con->request->request.op.operation_id), ippErrorString(status)); @@ -8181,6 +8185,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ + int event; /* Events? */ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_job_attrs(%p[%d], %s)", con, @@ -8282,6 +8287,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ cupsdLoadJob(job); + event = 0; + for (attr = con->request->attrs; attr; attr = attr->next) { if (attr->group_tag != IPP_TAG_JOB || !attr->name) @@ -8345,7 +8352,10 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ return; } else if (con->response->request.status.status_code == IPP_OK) + { cupsdSetJobPriority(job, attr->values[0].integer); + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED; + } } else if (!strcmp(attr->name, "job-state")) { @@ -8375,7 +8385,9 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ else if (con->response->request.status.status_code == IPP_OK) { job->state->values[0].integer = attr->values[0].integer; - job->state_value = attr->values[0].integer; + job->state_value = (ipp_jstate_t)attr->values[0].integer; + + event |= CUPSD_EVENT_JOB_STATE; } break; @@ -8389,7 +8401,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ } break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : case IPP_JOB_ABORTED : case IPP_JOB_COMPLETED : if (job->state_value > IPP_JOB_PROCESSING) @@ -8405,7 +8417,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ if (JobHistory) { job->state->values[0].integer = attr->values[0].integer; - job->state_value = attr->values[0].integer; + job->state_value = (ipp_jstate_t)attr->values[0].integer; cupsdSaveJob(job); } } @@ -8450,6 +8462,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ cupsdReleaseJob(job); else cupsdHoldJob(job); + + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE; } } else if (attr->value_tag == IPP_TAG_DELETEATTR) @@ -8470,6 +8484,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ job->attrs->last = job->attrs->prev; _ippFreeAttr(attr2); + + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED; } } else @@ -8479,6 +8495,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ */ copy_attribute(job->attrs, attr, 0); + + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED; } } @@ -8489,6 +8507,19 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ cupsdSaveJob(job); /* + * Send events as needed... + */ + + if (event & CUPSD_EVENT_JOB_STATE) + cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, + job->state_value == IPP_JOB_HELD ? + "Job held by user." : "Job restarted by user."); + + if (event & CUPSD_EVENT_JOB_CONFIG_CHANGED) + cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job, + "Job options changed by user."); + + /* * Start jobs if possible... */ @@ -9200,5 +9231,5 @@ validate_user(cupsd_job_t *job, /* I - Job */ /* - * End of "$Id: ipp.c 5736 2006-07-13 19:59:36Z mike $". + * End of "$Id: ipp.c 5907 2006-08-30 02:18:28Z mike $". */ diff --git a/scheduler/job.c b/scheduler/job.c index 967f9ac67..79370fbba 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,5 +1,5 @@ /* - * "$Id: job.c 5719 2006-07-11 21:04:48Z mike $" + * "$Id: job.c 5889 2006-08-24 21:44:35Z mike $" * * Job management routines for the Common UNIX Printing System (CUPS). * @@ -354,7 +354,7 @@ cupsdCheckJobs(void) */ cupsdLogMessage(CUPSD_LOG_WARN, - "Printer/class %s has gone away; cancelling job %d!", + "Printer/class %s has gone away; canceling job %d!", job->dest, job->id); cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, @@ -690,7 +690,7 @@ cupsdFreeAllJobs(void) cupsdHoldSignals(); - cupsdStopAllJobs(); + cupsdStopAllJobs(1); cupsdSaveAllJobs(); for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); @@ -1494,7 +1494,7 @@ cupsdSetJobPriority( */ void -cupsdStopAllJobs(void) +cupsdStopAllJobs(int force) /* I - 1 = Force all filters to stop */ { cupsd_job_t *job; /* Current job */ @@ -1506,7 +1506,7 @@ cupsdStopAllJobs(void) job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state_value == IPP_JOB_PROCESSING) { - cupsdStopJob(job, 1); + cupsdStopJob(job, force); job->state->values[0].integer = IPP_JOB_PENDING; job->state_value = IPP_JOB_PENDING; } @@ -1728,7 +1728,7 @@ cupsdUpdateJob(cupsd_job_t *job) /* I - Job to check */ break; } - if (ptr == NULL) + if (ptr == NULL && !job->status_buffer->bufused) { /* * See if all of the filters and the backend have returned their @@ -2053,7 +2053,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ } else if (!strcasecmp(line, "State")) { - job->state_value = atoi(value); + job->state_value = (ipp_jstate_t)atoi(value); if (job->state_value < IPP_JOB_PENDING) job->state_value = IPP_JOB_PENDING; @@ -2425,7 +2425,6 @@ start_job(cupsd_job_t *job, /* I - Job ID */ /* PRINTER env variable */ rip_max_cache[255]; /* RIP_MAX_CACHE env variable */ - int remote_job; /* Remote print job? */ static char *options = NULL;/* Full list of options */ static int optlength = 0; /* Length of option buffer */ @@ -2435,7 +2434,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (job->num_files == 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, "Job ID %d has no files! Cancelling it!", + cupsdLogMessage(CUPSD_LOG_ERROR, "Job ID %d has no files! Canceling it!", job->id); cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, @@ -2567,17 +2566,10 @@ start_job(cupsd_job_t *job, /* I - Job ID */ FilterLevel += job->cost; /* - * Determine if we are printing to a remote printer... - */ - - remote_job = printer->raw && job->num_files > 1 && - !strncmp(printer->device_uri, "ipp://", 6); - - /* * Add decompression filters, if any... */ - if (!remote_job && job->compressions[job->current_file]) + if (!printer->raw && job->compressions[job->current_file]) { /* * Add gziptoany filter to the front of the list... @@ -2911,7 +2903,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ * For remote jobs, we send all of the files in the argument list. */ - if (remote_job) + if (printer->remote && job->num_files > 1) argv = calloc(7 + job->num_files, sizeof(char *)); else argv = calloc(8, sizeof(char *)); @@ -2925,7 +2917,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ argv[4] = copies; argv[5] = options; - if (remote_job) + if (printer->remote && job->num_files > 1) { for (i = 0; i < job->num_files; i ++) { @@ -3018,11 +3010,12 @@ start_job(cupsd_job_t *job, /* I - Job ID */ envp[envc ++] = device_uri; envp[envc ++] = printer_name; - if ((filter = (mime_filter_t *)cupsArrayLast(filters)) != NULL) + if (!printer->remote && + (filter = (mime_filter_t *)cupsArrayLast(filters)) != NULL) { snprintf(final_content_type, sizeof(final_content_type), "FINAL_CONTENT_TYPE=%s/%s", - filter->src->super, filter->src->type); + filter->dst->super, filter->dst->type); envp[envc ++] = final_content_type; } @@ -3059,7 +3052,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] envp[%d]=\"DEVICE_URI=%s\"", job->id, i, sani_uri); - if (remote_job) + if (printer->remote) job->current_file = job->num_files; else job->current_file ++; @@ -3355,7 +3348,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ slot, filterfds[slot][0], filterfds[slot][1]); cupsdClosePipe(filterfds[slot]); - if (remote_job) + if (printer->remote && job->num_files > 1) { for (i = 0; i < job->num_files; i ++) free(argv[i + 6]); @@ -3399,7 +3392,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ cupsArrayDelete(filters); - if (remote_job) + if (printer->remote && job->num_files > 1) { for (i = 0; i < job->num_files; i ++) free(argv[i + 6]); @@ -3433,5 +3426,5 @@ unload_job(cupsd_job_t *job) /* I - Job */ /* - * End of "$Id: job.c 5719 2006-07-11 21:04:48Z mike $". + * End of "$Id: job.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/job.h b/scheduler/job.h index 93bb774b2..48148c969 100644 --- a/scheduler/job.h +++ b/scheduler/job.h @@ -1,5 +1,5 @@ /* - * "$Id: job.h 5393 2006-04-14 18:17:18Z mike $" + * "$Id: job.h 5833 2006-08-16 20:05:58Z mike $" * * Print job definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -115,11 +115,11 @@ extern void cupsdSaveAllJobs(void); extern void cupsdSaveJob(cupsd_job_t *job); extern void cupsdSetJobHoldUntil(cupsd_job_t *job, const char *when); extern void cupsdSetJobPriority(cupsd_job_t *job, int priority); -extern void cupsdStopAllJobs(void); +extern void cupsdStopAllJobs(int force); extern void cupsdStopJob(cupsd_job_t *job, int force); extern void cupsdUpdateJob(cupsd_job_t *job); /* - * End of "$Id: job.h 5393 2006-04-14 18:17:18Z mike $". + * End of "$Id: job.h 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/scheduler/main.c b/scheduler/main.c index 2806c26bc..101f178de 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1,5 +1,5 @@ /* - * "$Id: main.c 5634 2006-06-06 17:48:27Z mike $" + * "$Id: main.c 5878 2006-08-24 15:55:42Z mike $" * * Scheduler main loop for the Common UNIX Printing System (CUPS). * @@ -660,7 +660,7 @@ main(int argc, /* I - Number of command-line args */ * inactivity... */ - if (timeout.tv_sec == 86400 && Launchd && LaunchdTimeout && + if (timeout.tv_sec == 86400 && Launchd && LaunchdTimeout && !NumPolled && (!Browsing || !(BrowseLocalProtocols & BROWSE_DNSSD) || cupsArrayCount(Printers) == 0)) { @@ -1628,7 +1628,7 @@ launchd_sync_conf(void) kCFBooleanTrue); if ((Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)) || - cupsArrayCount(ActiveJobs)) + cupsArrayCount(ActiveJobs) || NumPolled) CFDictionaryAddValue(cupsd_dict, CFSTR(LAUNCH_JOBKEY_RUNATLOAD), kCFBooleanTrue); else @@ -1893,7 +1893,7 @@ process_children(void) #endif /* HAVE_WAITPID */ { /* - * Ignore SIGTERM errors - that comes when a job is cancelled... + * Ignore SIGTERM errors - that comes when a job is canceled... */ cupsdFinishProcess(pid, name, sizeof(name)); @@ -2253,5 +2253,5 @@ usage(int status) /* O - Exit status */ /* - * End of "$Id: main.c 5634 2006-06-06 17:48:27Z mike $". + * End of "$Id: main.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/scheduler/mime.h b/scheduler/mime.h index 9c5aa6448..2b44bf121 100644 --- a/scheduler/mime.h +++ b/scheduler/mime.h @@ -1,5 +1,5 @@ /* - * "$Id: mime.h 5487 2006-05-03 19:28:29Z mike $" + * "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $" * * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS). * @@ -34,9 +34,9 @@ * C++ magic... */ -# ifdef _cplusplus +# ifdef __cplusplus extern "C" { -# endif /* _cplusplus */ +# endif /* __cplusplus */ /* @@ -147,11 +147,11 @@ extern mime_filter_t *mimeFirstFilter(mime_t *mime); extern mime_filter_t *mimeNextFilter(mime_t *mime); extern int mimeNumFilters(mime_t *mime); -# ifdef _cplusplus +# ifdef __cplusplus } -# endif /* _cplusplus */ +# endif /* __cplusplus */ #endif /* !_CUPS_MIME_H_ */ /* - * End of "$Id: mime.h 5487 2006-05-03 19:28:29Z mike $". + * End of "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $". */ diff --git a/scheduler/policy.c b/scheduler/policy.c index e869c48ee..606978e3e 100644 --- a/scheduler/policy.c +++ b/scheduler/policy.c @@ -1,5 +1,5 @@ /* - * "$Id: policy.c 5247 2006-03-08 13:43:38Z mike $" + * "$Id: policy.c 5838 2006-08-17 14:41:42Z mike $" * * Policy routines for the Common UNIX Printing System (CUPS). * @@ -195,7 +195,7 @@ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ { cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con); - return (0); + return ((http_status_t)0); } /* @@ -205,7 +205,7 @@ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ if ((po = cupsdFindPolicyOp(p, con->request->request.op.operation_id)) == NULL) { cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!"); - return (0); + return ((http_status_t)0); } con->best = po; @@ -330,5 +330,5 @@ cupsdFindPolicyOp(cupsd_policy_t *p, /* I - Policy */ /* - * End of "$Id: policy.c 5247 2006-03-08 13:43:38Z mike $". + * End of "$Id: policy.c 5838 2006-08-17 14:41:42Z mike $". */ diff --git a/scheduler/printers.c b/scheduler/printers.c index f1cb56352..02e0a219a 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1,5 +1,5 @@ /* - * "$Id: printers.c 5724 2006-07-12 19:42:35Z mike $" + * "$Id: printers.c 5828 2006-08-15 21:21:45Z mike $" * * Printer routines for the Common UNIX Printing System (CUPS). * @@ -1492,7 +1492,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ else snprintf(resource, sizeof(resource), "/printers/%s", p->name); - if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL) + if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL || + auth->type == AUTH_NONE) auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB); if (auth) @@ -1572,7 +1573,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ printer_type = p->type; - p->raw = 0; + p->raw = 0; + p->remote = 0; if (p->type & CUPS_PRINTER_REMOTE) { @@ -1590,7 +1592,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, p->uri); - p->raw = 1; + p->raw = 1; + p->remote = 1; } else { @@ -2030,7 +2033,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ * Print all files directly... */ - p->raw = 1; + p->raw = 1; + p->remote = 1; } else { @@ -3312,5 +3316,5 @@ write_irix_state(cupsd_printer_t *p) /* I - Printer to update */ /* - * End of "$Id: printers.c 5724 2006-07-12 19:42:35Z mike $". + * End of "$Id: printers.c 5828 2006-08-15 21:21:45Z mike $". */ diff --git a/scheduler/printers.h b/scheduler/printers.h index ef8b34709..acbc73800 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -1,5 +1,5 @@ /* - * "$Id: printers.h 5330 2006-03-23 21:07:20Z mike $" + * "$Id: printers.h 5828 2006-08-15 21:21:45Z mike $" * * Printer definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -66,6 +66,7 @@ typedef struct cupsd_printer_s char *device_uri; /* Device URI */ char *port_monitor; /* Port monitor */ int raw; /* Raw queue? */ + int remote; /* Remote queue? */ mime_type_t *filetype; /* Pseudo-filetype for printer */ cups_array_t *filetypes; /* Supported file types */ void *job; /* Current job in queue */ @@ -146,5 +147,5 @@ extern char *cupsdSanitizeURI(const char *uri, char *buffer, /* - * End of "$Id: printers.h 5330 2006-03-23 21:07:20Z mike $". + * End of "$Id: printers.h 5828 2006-08-15 21:21:45Z mike $". */ diff --git a/scheduler/statbuf.c b/scheduler/statbuf.c index eb257d787..b10f63ebc 100644 --- a/scheduler/statbuf.c +++ b/scheduler/statbuf.c @@ -1,5 +1,5 @@ /* - * "$Id: statbuf.c 5447 2006-04-21 20:07:51Z mike $" + * "$Id: statbuf.c 5889 2006-08-24 21:44:35Z mike $" * * Status buffer routines for the Common UNIX Printing System (CUPS) * scheduler. @@ -193,7 +193,7 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ lineptr = NULL; } - if (lineptr == NULL) + if (!lineptr) { /* * End of file... @@ -330,5 +330,5 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ /* - * End of "$Id: statbuf.c 5447 2006-04-21 20:07:51Z mike $". + * End of "$Id: statbuf.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c index f27c48ff4..f3a320594 100644 --- a/scheduler/subscriptions.c +++ b/scheduler/subscriptions.c @@ -1,5 +1,5 @@ /* - * "$Id: subscriptions.c 5716 2006-07-11 17:56:57Z mike $" + * "$Id: subscriptions.c 5878 2006-08-24 15:55:42Z mike $" * * Subscription routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -267,7 +267,7 @@ cupsdAddEvent( "job-stopped"); break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-canceled-by-user"); @@ -1245,13 +1245,12 @@ cupsdStopAllNotifiers(void) void cupsdUpdateNotifierStatus(void) { - char *ptr, /* Pointer to end of line in buffer */ - message[1024]; /* Pointer to message text */ + char message[1024]; /* Pointer to message text */ int loglevel; /* Log level for message */ - while ((ptr = cupsdStatBufUpdate(NotifierStatusBuffer, &loglevel, - message, sizeof(message))) != NULL) + while (cupsdStatBufUpdate(NotifierStatusBuffer, &loglevel, + message, sizeof(message))) if (!strchr(NotifierStatusBuffer->buffer, '\n')) break; } @@ -1506,7 +1505,6 @@ cupsd_start_notifier( { int pid; /* Notifier process ID */ int fds[2]; /* Pipe file descriptors */ - int envc; /* Number of environment variables */ char *argv[4], /* Command-line arguments */ *envp[MAX_ENV], /* Environment variables */ user_data[128], /* Base-64 encoded user data */ @@ -1546,7 +1544,7 @@ cupsd_start_notifier( * Setup the environment... */ - envc = cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0]))); + cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0]))); /* * Create pipes as needed... @@ -1624,5 +1622,5 @@ cupsd_start_notifier( /* - * End of "$Id: subscriptions.c 5716 2006-07-11 17:56:57Z mike $". + * End of "$Id: subscriptions.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/scheduler/sysman.c b/scheduler/sysman.c index f83319853..853ff86c8 100644 --- a/scheduler/sysman.c +++ b/scheduler/sysman.c @@ -1,5 +1,5 @@ /* - * "$Id: sysman.c 5305 2006-03-18 03:05:12Z mike $" + * "$Id: sysman.c 5833 2006-08-16 20:05:58Z mike $" * * System management definitions for the Common UNIX Printing System (CUPS). * @@ -289,7 +289,7 @@ cupsdUpdateSystemMonitor(void) Sleeping = 1; - cupsdStopAllJobs(); + cupsdStopAllJobs(0); cupsdSaveAllJobs(); for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); @@ -350,6 +350,7 @@ cupsdUpdateSystemMonitor(void) p->browse_time = 0; cupsdSendBrowseList(); + cupsdRestartPolling(); } else cupsdLogMessage(CUPSD_LOG_DEBUG, @@ -727,5 +728,5 @@ sysEventTimerNotifier( /* - * End of "$Id: sysman.c 5305 2006-03-18 03:05:12Z mike $". + * End of "$Id: sysman.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/scheduler/testlpd.c b/scheduler/testlpd.c new file mode 100644 index 000000000..a49950391 --- /dev/null +++ b/scheduler/testlpd.c @@ -0,0 +1,550 @@ +/* + * "$Id: testlpd.c 5868 2006-08-23 19:39:39Z mike $" + * + * cups-lpd test program for the Common UNIX Printing System (CUPS). + * + * Copyright 2006 by Easy Software Products, all rights reserved. + * + * These coded instructions, statements, and computer programs are the + * property of Easy Software Products and are protected by Federal + * copyright law. Distribution and use rights are outlined in the file + * "LICENSE.txt" which should have been included with this file. If this + * file is missing or damaged please contact Easy Software Products + * at: + * + * Attn: CUPS Licensing Information + * Easy Software Products + * 44141 Airport View Drive, Suite 204 + * Hollywood, Maryland 20636 USA + * + * Voice: (301) 373-9600 + * EMail: cups-info@cups.org + * WWW: http://www.cups.org + * + * Contents: + * + * main() - Simulate an LPD client. + * do_command() - Send the LPD command and wait for a response. + * print_job() - Submit a file for printing. + * print_waiting() - Print waiting jobs. + * remove_job() - Cancel a print job. + * status_long() - Show the long printer status. + * status_short() - Show the short printer status. + * usage() - Show program usage... + */ + +/* + * Include necessary headers... + */ + +#include <cups/cups.h> +#include <cups/string.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <errno.h> +#include <signal.h> +#include <unistd.h> +#include <fcntl.h> + + +/* + * Local functions... + */ + +static int do_command(int outfd, int infd, const char *command); +static int print_job(int outfd, int infd, char *dest, char **args); +static int print_waiting(int outfd, int infd, char *dest); +static int remove_job(int outfd, int infd, char *dest, char **args); +static int status_long(int outfd, int infd, char *dest, char **args); +static int status_short(int outfd, int infd, char *dest, char **args); +static void usage(void); + + +/* + * 'main()' - Simulate an LPD client. + */ + +int /* O - Exit status */ +main(int argc, /* I - Number of command-line arguments */ + char *argv[]) /* I - Command-line arguments */ +{ + int i; /* Looping var */ + int status; /* Test status */ + char *op, /* Operation to test */ + **opargs, /* Remaining arguments */ + *dest; /* Destination */ + int cupslpd_argc; /* Argument count for cups-lpd */ + char *cupslpd_argv[1000]; /* Arguments for cups-lpd */ + int cupslpd_stdin[2], /* Standard input for cups-lpd */ + cupslpd_stdout[2], /* Standard output for cups-lpd */ + cupslpd_pid; /* Process ID for cups-lpd */ + + + /* + * Collect command-line arguments... + */ + + op = NULL; + opargs = NULL; + dest = NULL; + cupslpd_argc = 1; + cupslpd_argv[0] = (char *)"cups-lpd"; + + for (i = 1; i < argc; i ++) + if (!strncmp(argv[i], "-o", 2)) + { + cupslpd_argv[cupslpd_argc++] = argv[i]; + + if (argv[i][2]) + { + i ++; + + if (i >= argc) + usage(); + + cupslpd_argv[cupslpd_argc++] = argv[i]; + } + } + else if (argv[i][0] == '-') + usage(); + else if (!op) + op = argv[i]; + else if (!dest) + dest = argv[i]; + else + { + opargs = argv + i; + break; + } + + if (!op || + (!strcmp(op, "print-job") && (!dest || !opargs)) || + (!strcmp(op, "remove-job") && (!dest || !opargs)) || + (strcmp(op, "print-job") && strcmp(op, "print-waiting") && + strcmp(op, "remove-job") && strcmp(op, "status-long") && + strcmp(op, "status-short"))) + usage(); + + /* + * Run the cups-lpd program using pipes... + */ + + cupslpd_argv[cupslpd_argc] = NULL; + + pipe(cupslpd_stdin); + pipe(cupslpd_stdout); + + if ((cupslpd_pid = fork()) < 0) + { + /* + * Error! + */ + + perror("testlpd: Unable to fork"); + return (1); + } + else if (cupslpd_pid == 0) + { + /* + * Child goes here... + */ + + close(0); + dup(cupslpd_stdin[0]); + close(cupslpd_stdin[0]); + close(cupslpd_stdin[1]); + + close(1); + dup(cupslpd_stdout[1]); + close(cupslpd_stdout[0]); + close(cupslpd_stdout[1]); + + execv("./cups-lpd", cupslpd_argv); + + perror("testlpd: Unable to exec ./cups-lpd"); + exit(errno); + } + else + { + close(cupslpd_stdin[0]); + close(cupslpd_stdout[1]); + } + + /* + * Do the operation test... + */ + + if (!strcmp(op, "print-job")) + status = print_job(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + else if (!strcmp(op, "print-waiting")) + status = print_waiting(cupslpd_stdin[1], cupslpd_stdout[0], dest); + else if (!strcmp(op, "remove-job")) + status = remove_job(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + else if (!strcmp(op, "status-long")) + status = status_long(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + else if (!strcmp(op, "status-short")) + status = status_short(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + + /* + * Kill the test program... + */ + + close(cupslpd_stdin[1]); + close(cupslpd_stdout[0]); + kill(cupslpd_pid, SIGTERM); + + /* + * Return the test status... + */ + + return (status); +} + + +/* + * 'do_command()' - Send the LPD command and wait for a response. + */ + +static int /* O - Status from cups-lpd */ +do_command(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + const char *command) /* I - Command line to send */ +{ + int len; /* Length of command line */ + char status; /* Status byte */ + + + printf("COMMAND: %02X %s", command[0], command + 1); + + len = strlen(command); + + if (write(outfd, command, len) < len) + { + puts(" Write failed!"); + return (-1); + } + + if (read(infd, &status, 1) < 1) + puts("IN: ERROR"); + else + printf("IN: %d\n", status); + + return (status); +} + + +/* + * 'print_job()' - Submit a file for printing. + */ + +static int /* O - Status from cups-lpd */ +print_job(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + int fd; /* Print file descriptor */ + char command[1024], /* Command buffer */ + control[1024], /* Control file */ + buffer[8192]; /* Print buffer */ + int status; /* Status of command */ + struct stat fileinfo; /* File information */ + char *jobname; /* Job name */ + int sequence; /* Sequence number */ + int bytes; /* Bytes read/written */ + + + /* + * Check the print file... + */ + + if (stat(args[0], &fileinfo)) + { + perror(args[0]); + return (-1); + } + + if ((fd = open(args[0], O_RDONLY)) < 0) + { + perror(args[0]); + return (-1); + } + + /* + * Send the "receive print job" command... + */ + + snprintf(command, sizeof(command), "\002%s\n", dest); + if ((status = do_command(outfd, infd, command)) != 0) + { + close(fd); + return (status); + } + + /* + * Format a control file string that will be used to submit the job... + */ + + if ((jobname = strrchr(args[0], '/')) != NULL) + jobname ++; + else + jobname = args[0]; + + sequence = (int)getpid() % 1000; + + snprintf(control, sizeof(control), + "Hlocalhost\n" + "P%s\n" + "J%s\n" + "ldfA%03.3dlocalhost\n" + "UdfA%03.3dlocalhost\n" + "N%s\n", + cupsUser(), jobname, sequence, sequence, jobname); + + /* + * Send the control file... + */ + + bytes = strlen(control); + + snprintf(command, sizeof(command), "\002%d cfA%03.3dlocalhost\n", + bytes, sequence); + + if ((status = do_command(outfd, infd, command)) != 0) + { + close(fd); + return (status); + } + + bytes ++; + + if (write(outfd, control, bytes) < bytes) + { + printf("CONTROL: Unable to write %d bytes!\n", bytes); + close(fd); + return (-1); + } + + printf("CONTROL: Wrote %d bytes.\n", bytes); + + if (read(infd, command, 1) < 1) + { + puts("IN: ERROR"); + close(fd); + return (-1); + } + else + { + status = command[0]; + + printf("IN: %d\n", status); + } + + /* + * Send the data file... + */ + + snprintf(command, sizeof(command), "\003%d dfA%03.3dlocalhost\n", + (int)fileinfo.st_size, sequence); + + if ((status = do_command(outfd, infd, command)) != 0) + { + close(fd); + return (status); + } + + while ((bytes = read(fd, buffer, sizeof(buffer))) > 0) + { + if (write(outfd, buffer, bytes) < bytes) + { + printf("DATA: Unable to write %d bytes!\n", bytes); + close(fd); + return (-1); + } + } + + write(outfd, "", 1); + + close(fd); + + printf("DATA: Wrote %d bytes.\n", (int)fileinfo.st_size); + + if (read(infd, command, 1) < 1) + { + puts("IN: ERROR"); + close(fd); + return (-1); + } + else + { + status = command[0]; + + printf("IN: %d\n", status); + } + + return (status); +} + + +/* + * 'print_waiting()' - Print waiting jobs. + */ + +static int /* O - Status from cups-lpd */ +print_waiting(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest) /* I - Destination */ +{ + char command[1024]; /* Command buffer */ + + + /* + * Send the "print waiting jobs" command... + */ + + snprintf(command, sizeof(command), "\001%s\n", dest); + + return (do_command(outfd, infd, command)); +} + + +/* + * 'remove_job()' - Cancel a print job. + */ + +static int /* O - Status from cups-lpd */ +remove_job(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + int i; /* Looping var */ + char command[1024]; /* Command buffer */ + + /* + * Send the "remove jobs" command... + */ + + snprintf(command, sizeof(command), "\005%s", dest); + + for (i = 0; args[i]; i ++) + { + strlcat(command, " ", sizeof(command)); + strlcat(command, args[i], sizeof(command)); + } + + strlcat(command, "\n", sizeof(command)); + + return (do_command(outfd, infd, command)); +} + + +/* + * 'status_long()' - Show the long printer status. + */ + +static int /* O - Status from cups-lpd */ +status_long(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + char command[1024], /* Command buffer */ + buffer[8192]; /* Status buffer */ + int bytes; /* Bytes read/written */ + + + /* + * Send the "send short status" command... + */ + + if (args) + snprintf(command, sizeof(command), "\004%s %s\n", dest, args[0]); + else + snprintf(command, sizeof(command), "\004%s\n", dest); + + bytes = strlen(command); + + if (write(outfd, command, bytes) < bytes) + return (-1); + + /* + * Read the status back... + */ + + while ((bytes = read(infd, buffer, sizeof(buffer))) > 0) + { + fwrite(buffer, 1, bytes, stdout); + fflush(stdout); + } + + return (0); +} + + +/* + * 'status_short()' - Show the short printer status. + */ + +static int /* O - Status from cups-lpd */ +status_short(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + char command[1024], /* Command buffer */ + buffer[8192]; /* Status buffer */ + int bytes; /* Bytes read/written */ + + + /* + * Send the "send short status" command... + */ + + if (args) + snprintf(command, sizeof(command), "\003%s %s\n", dest, args[0]); + else + snprintf(command, sizeof(command), "\003%s\n", dest); + + bytes = strlen(command); + + if (write(outfd, command, bytes) < bytes) + return (-1); + + /* + * Read the status back... + */ + + while ((bytes = read(infd, buffer, sizeof(buffer))) > 0) + { + fwrite(buffer, 1, bytes, stdout); + fflush(stdout); + } + + return (0); +} + + +/* + * 'usage()' - Show program usage... + */ + +static void +usage(void) +{ + puts("Usage: testlpd [options] print-job printer user filename [... filename]"); + puts(" testlpd [options] print-waiting [printer or user]"); + puts(" testlpd [options] remove-job printer [user [job-id]]"); + puts(" testlpd [options] status-long [printer or user]"); + puts(" testlpd [options] status-short [printer or user]"); + puts(""); + puts("Options:"); + puts(" -o name=value"); + + exit(0); +} + + +/* + * End of "$Id: testlpd.c 5868 2006-08-23 19:39:39Z mike $". + */ |