From 019a41cd01fb6ebfacf735675049f07770e4a2e0 Mon Sep 17 00:00:00 2001
From: Jiri Popelka
Date: Fri, 3 Jun 2011 14:43:17 +0200
Subject: [PATCH 1/8] Set the default RIPCache to 128m (STR #3535, bug
#549901).
---
cups-str3535.patch | 48 ++++++++++++++++++++++++++++++++++++++++++++++
cups.spec | 8 +++++++-
2 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 cups-str3535.patch
diff --git a/cups-str3535.patch b/cups-str3535.patch
new file mode 100644
index 0000000..6c77215
--- /dev/null
+++ b/cups-str3535.patch
@@ -0,0 +1,48 @@
+diff -up cups-1.4.6/doc/help/ref-cupsd-conf.html.in.str3535 cups-1.4.6/doc/help/ref-cupsd-conf.html.in
+--- cups-1.4.6/doc/help/ref-cupsd-conf.html.in.str3535 2010-07-14 04:43:27.000000000 +0200
++++ cups-1.4.6/doc/help/ref-cupsd-conf.html.in 2011-06-03 13:53:04.711110536 +0200
+@@ -2646,7 +2646,7 @@ appear inside a Examples
+
+
+-RIPCache 8m
++RIPCache 128m
+ RIPCache 1g
+ RIPCache 2048k
+
+@@ -2657,8 +2657,9 @@ RIPCache 2048k
+ memory cache used by Raster Image Processor ("RIP") filters such
+ as imagetoraster
and pstoraster
. The
+ size can be suffixed with a "k" for kilobytes, "m" for megabytes,
+-or "g" for gigabytes. The default cache size is "8m", or 8
+-megabytes.
++or "g" for gigabytes. The default cache size is "128m", or 128
++megabytes (compare
++CUPS STR 3535
).
+
+
+
+diff -up cups-1.4.6/scheduler/conf.c.str3535 cups-1.4.6/scheduler/conf.c
+--- cups-1.4.6/scheduler/conf.c.str3535 2011-06-03 13:53:04.552112524 +0200
++++ cups-1.4.6/scheduler/conf.c 2011-06-03 13:53:04.712110524 +0200
+@@ -543,7 +543,7 @@ cupsdReadConfiguration(void)
+
+ cupsdClearString(&DefaultPaperSize);
+
+- cupsdSetString(&RIPCache, "8m");
++ cupsdSetString(&RIPCache, "128m");
+
+ cupsdSetString(&TempDir, NULL);
+
+diff -up cups-1.4.6/scheduler/cupsfilter.c.str3535 cups-1.4.6/scheduler/cupsfilter.c
+--- cups-1.4.6/scheduler/cupsfilter.c.str3535 2010-03-31 00:07:33.000000000 +0200
++++ cups-1.4.6/scheduler/cupsfilter.c 2011-06-03 13:53:04.713110512 +0200
+@@ -1218,7 +1218,7 @@ read_cupsd_conf(const char *filename) /*
+ else
+ set_string(&FontPath, CUPS_FONTPATH);
+
+- set_string(&RIPCache, "8m");
++ set_string(&RIPCache, "128m");
+
+ if ((temp = getenv("CUPS_SERVERBIN")) != NULL)
+ set_string(&ServerBin, temp);
diff --git a/cups.spec b/cups.spec
index c9c6f93..e46af38 100644
--- a/cups.spec
+++ b/cups.spec
@@ -13,7 +13,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.4.6
-Release: 17%{?dist}
+Release: 18%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -75,6 +75,7 @@ Patch40: cups-avahi.patch
Patch41: cups-icc.patch
Patch42: cups-usb-parallel.patch
Patch43: cups-job-state-changed.patch
+Patch44: cups-str3535.patch
Patch100: cups-lspp.patch
@@ -295,6 +296,8 @@ module.
%patch42 -p1 -b .usb-parallel
# Fixed dbus notifier support for job-state-changed.
%patch43 -p1 -b .job-state-changed
+# Set the default RIPCache to 128m (STR #3535, bug #549901).
+%patch44 -p1 -b .str3535
%if %lspp
# LSPP support.
@@ -614,6 +617,9 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
+* Fri Jun 03 2011 Jiri Popelka 1:1.4.6-18
+- Set the default RIPCache to 128m (STR #3535, bug #549901).
+
* Wed May 18 2011 Tim Waugh 1:1.4.6-17
- Package parallel port printer device nodes (bug #678804).
From 9463d0b6c995c0a333c0d15718f6c29801b1ff3d Mon Sep 17 00:00:00 2001
From: Tim Waugh
Date: Fri, 3 Jun 2011 14:03:01 +0100
Subject: [PATCH 2/8] Don't crash when unable to connect to D-Bus.
---
cups-icc.patch | 10 +++++++---
cups.spec | 5 ++++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/cups-icc.patch b/cups-icc.patch
index 04a839d..6b829fa 100644
--- a/cups-icc.patch
+++ b/cups-icc.patch
@@ -8,9 +8,9 @@
listen.o \
job.o \
log.o \
---- b/scheduler/colord.c
-+++ cups-1.4.6/scheduler/colord.c 2011-05-24 12:47:19.698093377 +0100
-@@ -0,0 +1,684 @@
+--- cups-1.4.6/scheduler/colord.c 2011-05-24 12:47:19.698093377 +0100
++++ cups-1.4.6/scheduler/colord.c 2011-06-03 14:01:22.780205436 +0100
+@@ -0,0 +1,688 @@
+/*
+ * "$Id$"
+ *
@@ -528,6 +528,8 @@
+ */
+
+ colordStart();
++ if (con == NULL)
++ return;
+
+ /*
+ * Try opening the PPD file for this printer...
@@ -681,6 +683,8 @@
+ */
+
+ colordStart();
++ if (con == NULL)
++ return;
+
+ /*
+ * Just delete the device itself, and leave the profiles registered
diff --git a/cups.spec b/cups.spec
index e46af38..ad37641 100644
--- a/cups.spec
+++ b/cups.spec
@@ -13,7 +13,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.4.6
-Release: 18%{?dist}
+Release: 19%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -617,6 +617,9 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
+* Fri Jun 3 2011 Tim Waugh 1:1.4.6-19
+- Don't crash when unable to connect to D-Bus.
+
* Fri Jun 03 2011 Jiri Popelka 1:1.4.6-18
- Set the default RIPCache to 128m (STR #3535, bug #549901).
From 1cca59f9dc62e1221d76847faf6b3a92927b6197 Mon Sep 17 00:00:00 2001
From: Tim Waugh
Date: Fri, 3 Jun 2011 14:03:18 +0100
Subject: [PATCH 3/8] Fixed some typos in cups-icc.patch.
---
cups-icc.patch | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cups-icc.patch b/cups-icc.patch
index 6b829fa..d723d92 100644
--- a/cups-icc.patch
+++ b/cups-icc.patch
@@ -458,7 +458,7 @@
+ tmp += 7;
+ format[0] = strdup(tmp);
+
-+ /* get 2st section */
++ /* get 2nd section */
+ tmp = "cupsICCQualifier2";
+ attr = ppdFindAttr(ppd, tmp, NULL);
+ if (attr != NULL)
@@ -476,7 +476,7 @@
+ tmp += 7;
+ format[1] = strdup(tmp);
+
-+ /* get 3st section */
++ /* get 3rd section */
+ tmp = "cupsICCQualifier3";
+ attr = ppdFindAttr(ppd, tmp, NULL);
+ if (attr != NULL)
From 28f2e3ad02e02e61b5b3a9aa1c881941c998597b Mon Sep 17 00:00:00 2001
From: Tim Waugh
Date: Fri, 3 Jun 2011 15:52:13 +0100
Subject: [PATCH 4/8] Use correct port number when publishing services through
Avahi (Ubuntu #792309).
---
cups-avahi.patch | 6 +++---
cups.spec | 6 +++++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/cups-avahi.patch b/cups-avahi.patch
index 0626945..031eb84 100644
--- a/cups-avahi.patch
+++ b/cups-avahi.patch
@@ -1929,7 +1929,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
+ "_http._tcp", /* type */
+ NULL, /* domain */
+ NULL, /* host */
-+ htons(DNSSDPort), /* port */
++ DNSSDPort, /* port */
+ "path=/", NULL);
+ if (ret == 0)
+ ret = avahi_entry_group_commit (AvahiWebIFGroup);
@@ -2424,7 +2424,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ 0, name, regtype, NULL, NULL,
-+ htons(DNSSDPort),
++ DNSSDPort,
+ ipp_txt);
+ if (ret < 0)
+ goto add_failed;
@@ -2443,7 +2443,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
+ AVAHI_PROTO_UNSPEC,
+ 0, name,
+ "_printer._tcp", NULL, NULL,
-+ htons(515),
++ 515,
+ printer_txt);
+ if (ret < 0)
+ goto add_failed;
diff --git a/cups.spec b/cups.spec
index ad37641..078f0c2 100644
--- a/cups.spec
+++ b/cups.spec
@@ -13,7 +13,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.4.6
-Release: 19%{?dist}
+Release: 20%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -617,6 +617,10 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
+* Fri Jun 3 2011 Tim Waugh 1:1.4.6-20
+- Use correct port number when publishing services through Avahi
+ (Ubuntu #792309).
+
* Fri Jun 3 2011 Tim Waugh 1:1.4.6-19
- Don't crash when unable to connect to D-Bus.
From e663022e55440121bdd08719211899ca08da570e Mon Sep 17 00:00:00 2001
From: Jiri Popelka
Date: Tue, 28 Jun 2011 11:48:01 +0200
Subject: [PATCH 5/8] 1.4.7.
---
.gitignore | 1 +
cups-autotype-crash.patch | 15 ---
cups-hostnamelookups.patch | 24 -----
cups-job-state-changed.patch | 12 ---
cups-lspp.patch | 186 +++++++++++++++++------------------
cups-serverbin-compat.patch | 68 ++++++-------
cups-snmp-quirks.patch | 38 +++----
cups-str3754.patch | 11 ---
cups.spec | 44 ++++-----
sources | 2 +-
10 files changed, 165 insertions(+), 236 deletions(-)
delete mode 100644 cups-autotype-crash.patch
delete mode 100644 cups-hostnamelookups.patch
delete mode 100644 cups-job-state-changed.patch
delete mode 100644 cups-str3754.patch
diff --git a/.gitignore b/.gitignore
index 7da940e..60f8131 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,3 +45,4 @@ cups-1.4.3-source.tar.bz2
cups-1.4.4-source.tar.bz2
/cups-1.4.5-source.tar.bz2
/cups-1.4.6-source.tar.bz2
+/cups-1.4.7-source.tar.bz2
diff --git a/cups-autotype-crash.patch b/cups-autotype-crash.patch
deleted file mode 100644
index ed6cb15..0000000
--- a/cups-autotype-crash.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -up cups-1.4.4/scheduler/ipp.c.autotype-crash cups-1.4.4/scheduler/ipp.c
---- cups-1.4.4/scheduler/ipp.c.autotype-crash 2010-10-15 15:25:15.093421917 +0100
-+++ cups-1.4.4/scheduler/ipp.c 2010-10-15 15:25:49.645296947 +0100
-@@ -10481,8 +10481,9 @@ send_document(cupsd_client_t *con, /* I
- if (!filetype)
- filetype = mimeType(MimeDatabase, super, type);
-
-- cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
-- filetype->super, filetype->type);
-+ if (filetype)
-+ cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
-+ filetype->super, filetype->type);
- }
- else
- filetype = mimeType(MimeDatabase, super, type);
diff --git a/cups-hostnamelookups.patch b/cups-hostnamelookups.patch
deleted file mode 100644
index 75b6abf..0000000
--- a/cups-hostnamelookups.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -up cups-1.4.4/scheduler/network.c.hostnamelookups cups-1.4.4/scheduler/network.c
---- cups-1.4.4/scheduler/network.c.hostnamelookups 2010-04-09 23:42:09.000000000 +0100
-+++ cups-1.4.4/scheduler/network.c 2010-06-18 11:13:02.331979867 +0100
-@@ -154,11 +154,7 @@ cupsdNetIFUpdate(void)
- * Try looking up the hostname for the address as needed...
- */
-
--#ifdef __APPLE__
- if (HostNameLookups)
--#else
-- if (HostNameLookups || RemotePort)
--#endif /* __APPLE__ */
- httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname,
- sizeof(hostname));
- else
-@@ -166,7 +162,7 @@ cupsdNetIFUpdate(void)
- /*
- * Map the default server address and localhost to the server name
- * and localhost, respectively; for all other addresses, use the
-- * dotted notation...
-+ * numeric address...
- */
-
- if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))
diff --git a/cups-job-state-changed.patch b/cups-job-state-changed.patch
deleted file mode 100644
index 16b5677..0000000
--- a/cups-job-state-changed.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up cups-1.4.6/notifier/dbus.c.job-state-changed cups-1.4.6/notifier/dbus.c
---- cups-1.4.6/notifier/dbus.c.job-state-changed 2011-02-25 12:42:11.084127808 +0000
-+++ cups-1.4.6/notifier/dbus.c 2011-02-25 12:42:31.312811947 +0000
-@@ -332,7 +332,7 @@ main(int argc, /* I - Number of comm
- const char *word2 = event + 4; /* Second word */
-
- params = PARAMS_JOB;
-- if (!strcmp(word2, "state"))
-+ if (!strcmp(word2, "state-changed"))
- signame = "JobState";
- else if (!strcmp(word2, "created"))
- signame = "JobCreated";
diff --git a/cups-lspp.patch b/cups-lspp.patch
index 7f67913..56a171e 100644
--- a/cups-lspp.patch
+++ b/cups-lspp.patch
@@ -1,7 +1,7 @@
-diff -up cups-1.4.5/config.h.in.lspp cups-1.4.5/config.h.in
---- cups-1.4.5/config.h.in.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/config.h.in 2010-12-13 14:51:01.000000000 +0100
-@@ -672,6 +672,12 @@
+diff -up cups-1.4.7/config.h.in.lspp cups-1.4.7/config.h.in
+--- cups-1.4.7/config.h.in.lspp 2011-06-28 11:18:57.127406939 +0200
++++ cups-1.4.7/config.h.in 2011-06-28 11:18:57.170406371 +0200
+@@ -673,6 +673,12 @@
#undef HAVE_SYS_STATVFS_H
#undef HAVE_SYS_VFS_H
@@ -14,9 +14,9 @@ diff -up cups-1.4.5/config.h.in.lspp cups-1.4.5/config.h.in
#endif /* !_CUPS_CONFIG_H_ */
-diff -up cups-1.4.5/config-scripts/cups-lspp.m4.lspp cups-1.4.5/config-scripts/cups-lspp.m4
---- cups-1.4.5/config-scripts/cups-lspp.m4.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/config-scripts/cups-lspp.m4 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/config-scripts/cups-lspp.m4.lspp cups-1.4.7/config-scripts/cups-lspp.m4
+--- cups-1.4.7/config-scripts/cups-lspp.m4.lspp 2011-06-28 11:18:57.170406371 +0200
++++ cups-1.4.7/config-scripts/cups-lspp.m4 2011-06-28 11:18:57.170406371 +0200
@@ -0,0 +1,36 @@
+dnl
+dnl LSPP code for the Common UNIX Printing System (CUPS).
@@ -54,9 +54,9 @@ diff -up cups-1.4.5/config-scripts/cups-lspp.m4.lspp cups-1.4.5/config-scripts/c
+ ;;
+ esac
+fi
-diff -up cups-1.4.5/configure.in.lspp cups-1.4.5/configure.in
---- cups-1.4.5/configure.in.lspp 2010-06-22 23:42:44.000000000 +0200
-+++ cups-1.4.5/configure.in 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/configure.in.lspp cups-1.4.7/configure.in
+--- cups-1.4.7/configure.in.lspp 2010-06-22 23:42:44.000000000 +0200
++++ cups-1.4.7/configure.in 2011-06-28 11:18:57.171406358 +0200
@@ -42,6 +42,8 @@ sinclude(config-scripts/cups-pap.m4)
sinclude(config-scripts/cups-pdf.m4)
sinclude(config-scripts/cups-scripting.m4)
@@ -66,9 +66,9 @@ diff -up cups-1.4.5/configure.in.lspp cups-1.4.5/configure.in
INSTALL_LANGUAGES=""
UNINSTALL_LANGUAGES=""
LANGFILES=""
-diff -up cups-1.4.5/cups/cups.h.lspp cups-1.4.5/cups/cups.h
---- cups-1.4.5/cups/cups.h.lspp 2010-06-22 05:18:27.000000000 +0200
-+++ cups-1.4.5/cups/cups.h 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/cups/cups.h.lspp cups-1.4.7/cups/cups.h
+--- cups-1.4.7/cups/cups.h.lspp 2011-01-06 23:48:42.000000000 +0100
++++ cups-1.4.7/cups/cups.h 2011-06-28 11:18:57.172406345 +0200
@@ -15,6 +15,9 @@
* This file is subject to the Apple OS-Developed Software exception.
*/
@@ -92,9 +92,9 @@ diff -up cups-1.4.5/cups/cups.h.lspp cups-1.4.5/cups/cups.h
/*
* Types and structures...
*/
-diff -up cups-1.4.5/data/Makefile.lspp cups-1.4.5/data/Makefile
---- cups-1.4.5/data/Makefile.lspp 2008-11-12 20:30:57.000000000 +0100
-+++ cups-1.4.5/data/Makefile 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/data/Makefile.lspp cups-1.4.7/data/Makefile
+--- cups-1.4.7/data/Makefile.lspp 2008-11-12 20:30:57.000000000 +0100
++++ cups-1.4.7/data/Makefile 2011-06-28 11:18:57.172406345 +0200
@@ -25,7 +25,10 @@ BANNERS = \
secret \
standard \
@@ -107,9 +107,9 @@ diff -up cups-1.4.5/data/Makefile.lspp cups-1.4.5/data/Makefile
CHARMAPS = \
euc-cn.txt \
-diff -up cups-1.4.5/data/mls.lspp cups-1.4.5/data/mls
---- cups-1.4.5/data/mls.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/data/mls 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/data/mls.lspp cups-1.4.7/data/mls
+--- cups-1.4.7/data/mls.lspp 2011-06-28 11:18:57.173406332 +0200
++++ cups-1.4.7/data/mls 2011-06-28 11:18:57.173406332 +0200
@@ -0,0 +1,261 @@
+%!PS-Adobe-3.0
+%%BoundingBox: 0 0 612 792
@@ -372,9 +372,9 @@ diff -up cups-1.4.5/data/mls.lspp cups-1.4.5/data/mls
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
+%
+%%EOF
-diff -up cups-1.4.5/data/selinux.lspp cups-1.4.5/data/selinux
---- cups-1.4.5/data/selinux.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/data/selinux 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/data/selinux.lspp cups-1.4.7/data/selinux
+--- cups-1.4.7/data/selinux.lspp 2011-06-28 11:18:57.173406332 +0200
++++ cups-1.4.7/data/selinux 2011-06-28 11:18:57.173406332 +0200
@@ -0,0 +1,261 @@
+%!PS-Adobe-3.0
+%%BoundingBox: 0 0 612 792
@@ -637,9 +637,9 @@ diff -up cups-1.4.5/data/selinux.lspp cups-1.4.5/data/selinux
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
+%
+%%EOF
-diff -up cups-1.4.5/data/te.lspp cups-1.4.5/data/te
---- cups-1.4.5/data/te.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/data/te 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/data/te.lspp cups-1.4.7/data/te
+--- cups-1.4.7/data/te.lspp 2011-06-28 11:18:57.174406319 +0200
++++ cups-1.4.7/data/te 2011-06-28 11:18:57.174406319 +0200
@@ -0,0 +1,261 @@
+%!PS-Adobe-3.0
+%%BoundingBox: 0 0 612 792
@@ -902,9 +902,9 @@ diff -up cups-1.4.5/data/te.lspp cups-1.4.5/data/te
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
+%
+%%EOF
-diff -up cups-1.4.5/filter/common.c.lspp cups-1.4.5/filter/common.c
---- cups-1.4.5/filter/common.c.lspp 2007-07-11 23:46:42.000000000 +0200
-+++ cups-1.4.5/filter/common.c 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/filter/common.c.lspp cups-1.4.7/filter/common.c
+--- cups-1.4.7/filter/common.c.lspp 2007-07-11 23:46:42.000000000 +0200
++++ cups-1.4.7/filter/common.c 2011-06-28 11:18:57.175406306 +0200
@@ -30,6 +30,12 @@
* Include necessary headers...
*/
@@ -1073,10 +1073,10 @@ diff -up cups-1.4.5/filter/common.c.lspp cups-1.4.5/filter/common.c
/*
-diff -up cups-1.4.5/filter/pstops.c.lspp cups-1.4.5/filter/pstops.c
---- cups-1.4.5/filter/pstops.c.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/filter/pstops.c 2010-12-13 14:51:01.000000000 +0100
-@@ -3335,6 +3335,18 @@ write_label_prolog(pstops_doc_t *doc, /*
+diff -up cups-1.4.7/filter/pstops.c.lspp cups-1.4.7/filter/pstops.c
+--- cups-1.4.7/filter/pstops.c.lspp 2011-06-28 11:18:57.078407587 +0200
++++ cups-1.4.7/filter/pstops.c 2011-06-28 11:18:57.177406280 +0200
+@@ -3330,6 +3330,18 @@ write_label_prolog(pstops_doc_t *doc, /*
{
const char *classification; /* CLASSIFICATION environment variable */
const char *ptr; /* Temporary string pointer */
@@ -1095,7 +1095,7 @@ diff -up cups-1.4.5/filter/pstops.c.lspp cups-1.4.5/filter/pstops.c
/*
-@@ -3357,6 +3369,124 @@ write_label_prolog(pstops_doc_t *doc, /*
+@@ -3352,6 +3364,124 @@ write_label_prolog(pstops_doc_t *doc, /*
return;
}
@@ -1220,7 +1220,7 @@ diff -up cups-1.4.5/filter/pstops.c.lspp cups-1.4.5/filter/pstops.c
/*
* Set the classification + page label string...
*/
-@@ -3435,7 +3565,10 @@ write_label_prolog(pstops_doc_t *doc, /*
+@@ -3430,7 +3560,10 @@ write_label_prolog(pstops_doc_t *doc, /*
doc_printf(doc, " %.0f moveto ESPpl show\n", top - 14.0);
doc_puts(doc, "pop\n");
doc_puts(doc, "}bind put\n");
@@ -1231,9 +1231,9 @@ diff -up cups-1.4.5/filter/pstops.c.lspp cups-1.4.5/filter/pstops.c
/*
-diff -up cups-1.4.5/Makedefs.in.lspp cups-1.4.5/Makedefs.in
---- cups-1.4.5/Makedefs.in.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/Makedefs.in 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/Makedefs.in.lspp cups-1.4.7/Makedefs.in
+--- cups-1.4.7/Makedefs.in.lspp 2011-06-28 11:18:57.154406582 +0200
++++ cups-1.4.7/Makedefs.in 2011-06-28 11:18:57.178406267 +0200
@@ -146,7 +146,7 @@ LIBCUPSORDER = @LIBCUPSORDER@
LIBCUPSIMAGEORDER = @LIBCUPSIMAGEORDER@
LINKCUPS = @LINKCUPS@ $(SSLLIBS) $(DNSSDLIBS)
@@ -1252,9 +1252,9 @@ diff -up cups-1.4.5/Makedefs.in.lspp cups-1.4.5/Makedefs.in
.SUFFIXES: .1 .1.gz .1m .1m.gz .3 .3.gz .5 .5.gz .7 .7.gz .8 .8.gz .a .c .cxx .h .man .o .32.o .64.o .gz
.c.o:
-diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
---- cups-1.4.5/scheduler/client.c.lspp 2010-10-17 06:13:56.000000000 +0200
-+++ cups-1.4.5/scheduler/client.c 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/scheduler/client.c.lspp cups-1.4.7/scheduler/client.c
+--- cups-1.4.7/scheduler/client.c.lspp 2011-01-22 01:07:22.000000000 +0100
++++ cups-1.4.7/scheduler/client.c 2011-06-28 11:19:51.661681320 +0200
@@ -44,6 +44,7 @@
* valid_host() - Is the Host: field valid?
* write_file() - Send a file via HTTP.
@@ -1270,8 +1270,8 @@ diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
+#define _GNU_SOURCE
#ifdef HAVE_CDSASSL
# include
- # include
-@@ -90,6 +92,12 @@ extern const char *cssmErrorString(int e
+ # ifdef HAVE_SECITEM_H
+@@ -92,6 +94,12 @@ extern const char *cssmErrorString(int e
# include
#endif /* HAVE_TCPD_H */
@@ -1284,7 +1284,7 @@ diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
/*
* Local functions...
-@@ -391,6 +399,57 @@ cupsdAcceptClient(cupsd_listener_t *lis)
+@@ -393,6 +401,57 @@ cupsdAcceptClient(cupsd_listener_t *lis)
}
#endif /* HAVE_TCPD_H */
@@ -1342,7 +1342,7 @@ diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
#ifdef AF_INET6
if (con->http.hostaddr->addr.sa_family == AF_INET6)
cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s:%d (IPv6)",
-@@ -781,6 +840,13 @@ cupsdReadClient(cupsd_client_t *con) /*
+@@ -783,6 +842,13 @@ cupsdReadClient(cupsd_client_t *con) /*
mime_type_t *type; /* MIME type of file */
cupsd_printer_t *p; /* Printer */
static unsigned request_id = 0; /* Request ID for temp files */
@@ -1356,7 +1356,7 @@ diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
status = HTTP_CONTINUE;
-@@ -2135,6 +2201,67 @@ cupsdReadClient(cupsd_client_t *con) /*
+@@ -2137,6 +2203,67 @@ cupsdReadClient(cupsd_client_t *con) /*
fchmod(con->file, 0640);
fchown(con->file, RunUser, Group);
fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
@@ -1424,7 +1424,7 @@ diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
}
if (con->http.state != HTTP_POST_SEND)
-@@ -4641,6 +4768,50 @@ make_certificate(cupsd_client_t *con) /*
+@@ -4647,6 +4774,50 @@ make_certificate(cupsd_client_t *con) /*
#endif /* HAVE_SSL */
@@ -1475,9 +1475,9 @@ diff -up cups-1.4.5/scheduler/client.c.lspp cups-1.4.5/scheduler/client.c
/*
* 'pipe_command()' - Pipe the output of a command to the remote client.
*/
-diff -up cups-1.4.5/scheduler/client.h.lspp cups-1.4.5/scheduler/client.h
---- cups-1.4.5/scheduler/client.h.lspp 2009-05-27 00:01:23.000000000 +0200
-+++ cups-1.4.5/scheduler/client.h 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/scheduler/client.h.lspp cups-1.4.7/scheduler/client.h
+--- cups-1.4.7/scheduler/client.h.lspp 2009-05-27 00:01:23.000000000 +0200
++++ cups-1.4.7/scheduler/client.h 2011-06-28 11:18:57.182406212 +0200
@@ -18,6 +18,13 @@
#endif /* HAVE_AUTHORIZATION_H */
@@ -1513,9 +1513,9 @@ diff -up cups-1.4.5/scheduler/client.h.lspp cups-1.4.5/scheduler/client.h
/*
-diff -up cups-1.4.5/scheduler/conf.c.lspp cups-1.4.5/scheduler/conf.c
---- cups-1.4.5/scheduler/conf.c.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/scheduler/conf.c 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/scheduler/conf.c.lspp cups-1.4.7/scheduler/conf.c
+--- cups-1.4.7/scheduler/conf.c.lspp 2011-06-28 11:18:57.050407956 +0200
++++ cups-1.4.7/scheduler/conf.c 2011-06-28 11:18:57.184406186 +0200
@@ -29,6 +29,7 @@
* read_configuration() - Read a configuration file.
* read_location() - Read a definition.
@@ -1555,7 +1555,7 @@ diff -up cups-1.4.5/scheduler/conf.c.lspp cups-1.4.5/scheduler/conf.c
/*
-@@ -713,6 +724,25 @@ cupsdReadConfiguration(void)
+@@ -719,6 +730,25 @@ cupsdReadConfiguration(void)
RunUser = getuid();
@@ -1581,7 +1581,7 @@ diff -up cups-1.4.5/scheduler/conf.c.lspp cups-1.4.5/scheduler/conf.c
cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
RemotePort ? "enabled" : "disabled");
-@@ -1081,11 +1111,23 @@ cupsdReadConfiguration(void)
+@@ -1087,11 +1117,23 @@ cupsdReadConfiguration(void)
* Update classification setting as needed...
*/
@@ -1606,7 +1606,7 @@ diff -up cups-1.4.5/scheduler/conf.c.lspp cups-1.4.5/scheduler/conf.c
/*
* Check the MaxClients setting, and then allocate memory for it...
-@@ -3657,6 +3699,18 @@ read_location(cups_file_t *fp, /* I - C
+@@ -3663,6 +3705,18 @@ read_location(cups_file_t *fp, /* I - C
return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
}
@@ -1625,9 +1625,9 @@ diff -up cups-1.4.5/scheduler/conf.c.lspp cups-1.4.5/scheduler/conf.c
/*
* 'read_policy()' - Read a definition.
-diff -up cups-1.4.5/scheduler/conf.h.lspp cups-1.4.5/scheduler/conf.h
---- cups-1.4.5/scheduler/conf.h.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/scheduler/conf.h 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/scheduler/conf.h.lspp cups-1.4.7/scheduler/conf.h
+--- cups-1.4.7/scheduler/conf.h.lspp 2011-06-28 11:18:57.050407956 +0200
++++ cups-1.4.7/scheduler/conf.h 2011-06-28 11:18:57.197406011 +0200
@@ -250,6 +250,12 @@ VAR char *ServerKey VALUE(NULL);
VAR int SSLOptions VALUE(CUPSD_SSL_NONE);
/* SSL/TLS options */
@@ -1651,9 +1651,9 @@ diff -up cups-1.4.5/scheduler/conf.h.lspp cups-1.4.5/scheduler/conf.h
/*
* Prototypes...
-diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
---- cups-1.4.5/scheduler/ipp.c.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/scheduler/ipp.c 2010-12-13 15:01:43.000000000 +0100
+diff -up cups-1.4.7/scheduler/ipp.c.lspp cups-1.4.7/scheduler/ipp.c
+--- cups-1.4.7/scheduler/ipp.c.lspp 2011-06-28 11:18:57.091407416 +0200
++++ cups-1.4.7/scheduler/ipp.c 2011-06-28 11:18:57.201405959 +0200
@@ -41,6 +41,7 @@
* cancel_all_jobs() - Cancel all print jobs.
* cancel_job() - Cancel a print job.
@@ -1972,7 +1972,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
/*
* See if we need to add the starting sheet...
-@@ -4289,6 +4521,107 @@ check_rss_recipient(
+@@ -4302,6 +4534,107 @@ check_rss_recipient(
}
@@ -2080,7 +2080,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
/*
* 'check_quotas()' - Check quotas for a printer and user.
*/
-@@ -4843,6 +5176,15 @@ copy_banner(cupsd_client_t *con, /* I -
+@@ -4856,6 +5189,15 @@ copy_banner(cupsd_client_t *con, /* I -
char attrname[255], /* Name of attribute */
*s; /* Pointer into name */
ipp_attribute_t *attr; /* Attribute */
@@ -2096,7 +2096,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
cupsdLogMessage(CUPSD_LOG_DEBUG2,
-@@ -4878,6 +5220,82 @@ copy_banner(cupsd_client_t *con, /* I -
+@@ -4891,6 +5233,82 @@ copy_banner(cupsd_client_t *con, /* I -
fchmod(cupsFileNumber(out), 0640);
fchown(cupsFileNumber(out), RunUser, Group);
@@ -2179,7 +2179,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
/*
* Try the localized banner file under the subdirectory...
-@@ -4972,6 +5390,24 @@ copy_banner(cupsd_client_t *con, /* I -
+@@ -4985,6 +5403,24 @@ copy_banner(cupsd_client_t *con, /* I -
else
s = attrname;
@@ -2204,7 +2204,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
if (!strcmp(s, "printer-name"))
{
cupsFilePuts(out, job->dest);
-@@ -6945,6 +7381,22 @@ get_job_attrs(cupsd_client_t *con, /* I
+@@ -6963,6 +7399,22 @@ get_job_attrs(cupsd_client_t *con, /* I
return;
}
@@ -2227,7 +2227,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
/*
* Copy attributes...
*/
-@@ -7175,6 +7627,11 @@ get_jobs(cupsd_client_t *con, /* I - C
+@@ -7193,6 +7645,11 @@ get_jobs(cupsd_client_t *con, /* I - C
if (username[0] && strcasecmp(username, job->username))
continue;
@@ -2239,7 +2239,7 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
if (count > 0)
ippAddSeparator(con->response);
-@@ -11594,6 +12051,11 @@ validate_user(cupsd_job_t *job, /* I
+@@ -11612,6 +12069,11 @@ validate_user(cupsd_job_t *job, /* I
strlcpy(username, get_username(con), userlen);
@@ -2251,10 +2251,10 @@ diff -up cups-1.4.5/scheduler/ipp.c.lspp cups-1.4.5/scheduler/ipp.c
/*
* Check the username against the owner...
*/
-diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
---- cups-1.4.5/scheduler/job.c.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/scheduler/job.c 2010-12-13 15:02:11.000000000 +0100
-@@ -66,6 +66,9 @@
+diff -up cups-1.4.7/scheduler/job.c.lspp cups-1.4.7/scheduler/job.c
+--- cups-1.4.7/scheduler/job.c.lspp 2011-06-28 11:18:57.114407111 +0200
++++ cups-1.4.7/scheduler/job.c 2011-06-28 11:18:57.205405907 +0200
+@@ -64,6 +64,9 @@
* update_job_attrs() - Update the job-printer-* attributes.
*/
@@ -2264,7 +2264,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
/*
* Include necessary headers...
*/
-@@ -75,6 +78,14 @@
+@@ -73,6 +76,14 @@
#include
#include
@@ -2387,7 +2387,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
}
}
#endif /* __x86_64__ */
-@@ -1626,6 +1706,20 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
+@@ -1634,6 +1714,20 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
goto error;
}
@@ -2408,7 +2408,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed",
IPP_TAG_INTEGER);
job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
-@@ -2013,6 +2107,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
+@@ -2021,6 +2115,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
{
char filename[1024]; /* Job control filename */
cups_file_t *fp; /* Job file */
@@ -2423,7 +2423,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p",
-@@ -2031,6 +2133,76 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
+@@ -2039,6 +2141,76 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
fchmod(cupsFileNumber(fp), 0600);
fchown(cupsFileNumber(fp), RunUser, Group);
@@ -2500,7 +2500,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
job->attrs->state = IPP_IDLE;
if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
-@@ -3332,6 +3504,18 @@ get_options(cupsd_job_t *job, /* I - Jo
+@@ -3353,6 +3525,18 @@ get_options(cupsd_job_t *job, /* I - Jo
banner_page)
continue;
@@ -2519,7 +2519,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
/*
* Otherwise add them to the list...
*/
-@@ -4020,6 +4204,19 @@ static void
+@@ -3989,6 +4173,19 @@ static void
start_job(cupsd_job_t *job, /* I - Job ID */
cupsd_printer_t *printer) /* I - Printer to print job */
{
@@ -2539,7 +2539,7 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job(job=%p(%d), printer=%p(%s))",
job, job->id, printer, printer->name);
-@@ -4142,6 +4339,108 @@ start_job(cupsd_job_t *job, /* I -
+@@ -4111,6 +4308,108 @@ start_job(cupsd_job_t *job, /* I -
fcntl(job->side_pipes[1], F_SETFD,
fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC);
@@ -2648,9 +2648,9 @@ diff -up cups-1.4.5/scheduler/job.c.lspp cups-1.4.5/scheduler/job.c
/*
* Now start the first file in the job...
*/
-diff -up cups-1.4.5/scheduler/job.h.lspp cups-1.4.5/scheduler/job.h
---- cups-1.4.5/scheduler/job.h.lspp 2009-05-12 00:46:01.000000000 +0200
-+++ cups-1.4.5/scheduler/job.h 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/scheduler/job.h.lspp cups-1.4.7/scheduler/job.h
+--- cups-1.4.7/scheduler/job.h.lspp 2009-05-12 00:46:01.000000000 +0200
++++ cups-1.4.7/scheduler/job.h 2011-06-28 11:18:57.206405894 +0200
@@ -13,6 +13,13 @@
* file is missing or damaged, see the license at "http://www.cups.org/".
*/
@@ -2676,9 +2676,9 @@ diff -up cups-1.4.5/scheduler/job.h.lspp cups-1.4.5/scheduler/job.h
};
typedef struct cupsd_joblog_s /**** Job log message ****/
-diff -up cups-1.4.5/scheduler/main.c.lspp cups-1.4.5/scheduler/main.c
---- cups-1.4.5/scheduler/main.c.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/scheduler/main.c 2010-12-13 14:51:01.000000000 +0100
+diff -up cups-1.4.7/scheduler/main.c.lspp cups-1.4.7/scheduler/main.c
+--- cups-1.4.7/scheduler/main.c.lspp 2011-06-28 11:18:57.074407640 +0200
++++ cups-1.4.7/scheduler/main.c 2011-06-28 11:18:57.207405881 +0200
@@ -37,6 +37,8 @@
* usage() - Show scheduler usage.
*/
@@ -2746,10 +2746,10 @@ diff -up cups-1.4.5/scheduler/main.c.lspp cups-1.4.5/scheduler/main.c
return (!stop_scheduler);
}
-diff -up cups-1.4.5/scheduler/printers.c.lspp cups-1.4.5/scheduler/printers.c
---- cups-1.4.5/scheduler/printers.c.lspp 2010-12-13 14:51:01.000000000 +0100
-+++ cups-1.4.5/scheduler/printers.c 2010-12-13 14:51:01.000000000 +0100
-@@ -59,6 +59,8 @@
+diff -up cups-1.4.7/scheduler/printers.c.lspp cups-1.4.7/scheduler/printers.c
+--- cups-1.4.7/scheduler/printers.c.lspp 2011-06-28 11:18:57.061407812 +0200
++++ cups-1.4.7/scheduler/printers.c 2011-06-28 11:18:57.209405855 +0200
+@@ -61,6 +61,8 @@
* write_xml_string() - Write a string with XML escaping.
*/
@@ -2758,7 +2758,7 @@ diff -up cups-1.4.5/scheduler/printers.c.lspp cups-1.4.5/scheduler/printers.c
/*
* Include necessary headers...
*/
-@@ -103,6 +105,10 @@ static void write_irix_state(cupsd_print
+@@ -105,6 +107,10 @@ static void write_irix_state(cupsd_print
#endif /* __sgi */
static void write_xml_string(cups_file_t *fp, const char *s);
@@ -2769,7 +2769,7 @@ diff -up cups-1.4.5/scheduler/printers.c.lspp cups-1.4.5/scheduler/printers.c
/*
* 'cupsdAddPrinter()' - Add a printer to the system.
-@@ -2266,6 +2272,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
+@@ -2270,6 +2276,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
"username",
"password"
};
@@ -2783,7 +2783,7 @@ diff -up cups-1.4.5/scheduler/printers.c.lspp cups-1.4.5/scheduler/printers.c
DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
-@@ -2396,6 +2409,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
+@@ -2400,6 +2413,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
attr->values[1].string.text = _cupsStrAlloc(Classification ?
Classification : p->job_sheets[1]);
}
@@ -2829,7 +2829,7 @@ diff -up cups-1.4.5/scheduler/printers.c.lspp cups-1.4.5/scheduler/printers.c
}
p->raw = 0;
-@@ -5535,7 +5587,6 @@ write_irix_state(cupsd_printer_t *p) /*
+@@ -5585,7 +5637,6 @@ write_irix_state(cupsd_printer_t *p) /*
}
#endif /* __sgi */
diff --git a/cups-serverbin-compat.patch b/cups-serverbin-compat.patch
index 44a7894..5e95509 100644
--- a/cups-serverbin-compat.patch
+++ b/cups-serverbin-compat.patch
@@ -1,6 +1,6 @@
-diff -up cups-1.4.4/scheduler/conf.c.serverbin-compat cups-1.4.4/scheduler/conf.c
---- cups-1.4.4/scheduler/conf.c.serverbin-compat 2010-04-23 19:56:34.000000000 +0100
-+++ cups-1.4.4/scheduler/conf.c 2010-09-15 13:20:41.339960335 +0100
+diff -up cups-1.4.7/scheduler/conf.c.serverbin-compat cups-1.4.7/scheduler/conf.c
+--- cups-1.4.7/scheduler/conf.c.serverbin-compat 2011-01-11 08:05:58.000000000 +0100
++++ cups-1.4.7/scheduler/conf.c 2011-06-28 10:43:24.677053741 +0200
@@ -488,6 +488,9 @@ cupsdReadConfiguration(void)
cupsdClearString(&ServerName);
cupsdClearString(&ServerAdmin);
@@ -11,7 +11,7 @@ diff -up cups-1.4.4/scheduler/conf.c.serverbin-compat cups-1.4.4/scheduler/conf.
cupsdSetString(&RequestRoot, CUPS_REQUESTS);
cupsdSetString(&CacheDir, CUPS_CACHEDIR);
cupsdSetString(&DataDir, CUPS_DATADIR);
-@@ -1318,7 +1321,12 @@ cupsdReadConfiguration(void)
+@@ -1337,7 +1340,12 @@ cupsdReadConfiguration(void)
* Read the MIME type and conversion database...
*/
@@ -24,9 +24,9 @@ diff -up cups-1.4.4/scheduler/conf.c.serverbin-compat cups-1.4.4/scheduler/conf.
snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
MimeDatabase = mimeLoadTypes(NULL, mimedir);
-diff -up cups-1.4.4/scheduler/conf.h.serverbin-compat cups-1.4.4/scheduler/conf.h
---- cups-1.4.4/scheduler/conf.h.serverbin-compat 2010-04-23 19:56:34.000000000 +0100
-+++ cups-1.4.4/scheduler/conf.h 2010-09-15 13:20:41.340959464 +0100
+diff -up cups-1.4.7/scheduler/conf.h.serverbin-compat cups-1.4.7/scheduler/conf.h
+--- cups-1.4.7/scheduler/conf.h.serverbin-compat 2010-04-23 20:56:34.000000000 +0200
++++ cups-1.4.7/scheduler/conf.h 2011-06-28 10:43:24.678053725 +0200
@@ -105,6 +105,10 @@ VAR char *ConfigurationFile VALUE(NULL)
/* Root directory for scheduler */
*ServerBin VALUE(NULL),
@@ -38,27 +38,27 @@ diff -up cups-1.4.4/scheduler/conf.h.serverbin-compat cups-1.4.4/scheduler/conf.
*StateDir VALUE(NULL),
/* Root directory for state data */
*RequestRoot VALUE(NULL),
-diff -up cups-1.4.4/scheduler/env.c.serverbin-compat cups-1.4.4/scheduler/env.c
---- cups-1.4.4/scheduler/env.c.serverbin-compat 2009-06-15 18:13:52.000000000 +0100
-+++ cups-1.4.4/scheduler/env.c 2010-09-15 13:20:41.341959587 +0100
-@@ -87,8 +87,13 @@ cupsdInitEnv(void)
- cupsdSetEnv("LD_LIBRARY_PATH", NULL);
- cupsdSetEnv("LD_PRELOAD", NULL);
- cupsdSetEnv("NLSPATH", NULL);
+diff -up cups-1.4.7/scheduler/env.c.serverbin-compat cups-1.4.7/scheduler/env.c
+--- cups-1.4.7/scheduler/env.c.serverbin-compat 2011-01-11 08:05:58.000000000 +0100
++++ cups-1.4.7/scheduler/env.c 2011-06-28 10:49:25.638319580 +0200
+@@ -218,8 +218,13 @@ cupsdUpdateEnv(void)
+ set_if_undefined("LD_PRELOAD", NULL);
+ set_if_undefined("NLSPATH", NULL);
+ if (find_env("PATH") < 0)
+#ifdef __x86_64__
-+ cupsdSetEnvf("PATH", "%s/filter:%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
-+ ":/bin:/usr/bin", ServerBin, ServerBin_compat);
++ cupsdSetEnvf("PATH", "%s/filter:%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
++ ":/bin:/usr/bin", ServerBin, ServerBin_compat);
+#else /* ! defined(__x86_64__) */
- cupsdSetEnvf("PATH", "%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
- ":/bin:/usr/bin", ServerBin);
+ cupsdSetEnvf("PATH", "%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
+ ":/bin:/usr/bin", ServerBin);
+#endif
- cupsdSetEnv("SERVER_ADMIN", ServerAdmin);
- cupsdSetEnv("SHLIB_PATH", NULL);
- cupsdSetEnv("SOFTWARE", CUPS_MINIMAL);
-diff -up cups-1.4.4/scheduler/ipp.c.serverbin-compat cups-1.4.4/scheduler/ipp.c
---- cups-1.4.4/scheduler/ipp.c.serverbin-compat 2010-04-23 19:56:34.000000000 +0100
-+++ cups-1.4.4/scheduler/ipp.c 2010-09-15 13:20:41.359835378 +0100
-@@ -2615,9 +2615,18 @@ add_printer(cupsd_client_t *con, /* I -
+ set_if_undefined("SERVER_ADMIN", ServerAdmin);
+ set_if_undefined("SHLIB_PATH", NULL);
+ set_if_undefined("SOFTWARE", CUPS_MINIMAL);
+diff -up cups-1.4.7/scheduler/ipp.c.serverbin-compat cups-1.4.7/scheduler/ipp.c
+--- cups-1.4.7/scheduler/ipp.c.serverbin-compat 2011-02-15 00:47:29.000000000 +0100
++++ cups-1.4.7/scheduler/ipp.c 2011-06-28 10:43:24.682053664 +0200
+@@ -2602,9 +2602,18 @@ add_printer(cupsd_client_t *con, /* I -
* Could not find device in list!
*/
@@ -77,9 +77,9 @@ diff -up cups-1.4.4/scheduler/ipp.c.serverbin-compat cups-1.4.4/scheduler/ipp.c
}
}
-diff -up cups-1.4.4/scheduler/job.c.serverbin-compat cups-1.4.4/scheduler/job.c
---- cups-1.4.4/scheduler/job.c.serverbin-compat 2010-03-30 23:07:33.000000000 +0100
-+++ cups-1.4.4/scheduler/job.c 2010-09-15 13:20:41.366836134 +0100
+diff -up cups-1.4.7/scheduler/job.c.serverbin-compat cups-1.4.7/scheduler/job.c
+--- cups-1.4.7/scheduler/job.c.serverbin-compat 2011-04-23 00:38:01.000000000 +0200
++++ cups-1.4.7/scheduler/job.c 2011-06-28 10:43:24.686053600 +0200
@@ -972,8 +972,32 @@ cupsdContinueJob(cupsd_job_t *job) /* I
i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
{
@@ -144,10 +144,10 @@ diff -up cups-1.4.4/scheduler/job.c.serverbin-compat cups-1.4.4/scheduler/job.c
close(job->status_pipes[1]);
job->status_pipes[1] = -1;
-diff -up cups-1.4.4/scheduler/printers.c.serverbin-compat cups-1.4.4/scheduler/printers.c
---- cups-1.4.4/scheduler/printers.c.serverbin-compat 2010-04-23 21:53:38.000000000 +0100
-+++ cups-1.4.4/scheduler/printers.c 2010-09-15 13:21:39.627960657 +0100
-@@ -1059,9 +1059,19 @@ cupsdLoadAllPrinters(void)
+diff -up cups-1.4.7/scheduler/printers.c.serverbin-compat cups-1.4.7/scheduler/printers.c
+--- cups-1.4.7/scheduler/printers.c.serverbin-compat 2011-03-04 20:28:38.000000000 +0100
++++ cups-1.4.7/scheduler/printers.c 2011-06-28 10:43:24.688053568 +0200
+@@ -1118,9 +1118,19 @@ cupsdLoadAllPrinters(void)
* Backend does not exist, stop printer...
*/
@@ -167,7 +167,7 @@ diff -up cups-1.4.4/scheduler/printers.c.serverbin-compat cups-1.4.4/scheduler/p
}
}
-@@ -3603,6 +3613,14 @@ add_printer_filter(
+@@ -3657,6 +3667,14 @@ add_printer_filter(
if (stat(filename, &fileinfo))
{
@@ -182,7 +182,7 @@ diff -up cups-1.4.4/scheduler/printers.c.serverbin-compat cups-1.4.4/scheduler/p
memset(&fileinfo, 0, sizeof(fileinfo));
snprintf(p->state_message, sizeof(p->state_message),
-@@ -3611,6 +3629,9 @@ add_printer_filter(
+@@ -3665,6 +3683,9 @@ add_printer_filter(
cupsdSetPrinterReasons(p, "+cups-missing-filter-warning");
cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
diff --git a/cups-snmp-quirks.patch b/cups-snmp-quirks.patch
index 0308676..d7c82a4 100644
--- a/cups-snmp-quirks.patch
+++ b/cups-snmp-quirks.patch
@@ -1,7 +1,7 @@
-diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-supplies.c
---- cups-1.4.3/backend/snmp-supplies.c.snmp-quirks 2009-11-20 01:27:57.000000000 +0000
-+++ cups-1.4.3/backend/snmp-supplies.c 2010-06-09 16:27:05.515019804 +0100
-@@ -38,6 +38,13 @@
+diff -up cups-1.4.7/backend/snmp-supplies.c.snmp-quirks cups-1.4.7/backend/snmp-supplies.c
+--- cups-1.4.7/backend/snmp-supplies.c.snmp-quirks 2011-03-10 04:50:59.000000000 +0100
++++ cups-1.4.7/backend/snmp-supplies.c 2011-06-28 11:11:57.944155996 +0200
+@@ -49,6 +49,13 @@
/*
@@ -15,7 +15,7 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
* Local structures...
*/
-@@ -57,6 +64,12 @@ typedef struct /**** Printer state ta
+@@ -68,6 +75,12 @@ typedef struct /**** Printer state ta
const char *keyword; /* IPP printer-state-reasons keyword */
} backend_state_t;
@@ -28,16 +28,16 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
/*
* Local globals...
-@@ -68,6 +81,7 @@ static int current_state = -1;
+@@ -79,6 +92,7 @@ static int current_state = -1;
static int charset = -1; /* Character set for supply names */
static int num_supplies = 0;
/* Number of supplies found */
+static int quirks = 0; /* Printer quirks */
static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
/* Supply information */
-
-@@ -153,6 +167,15 @@ static const backend_state_t const print
- { CUPS_TC_outputFull, "output-area-full-warning" }
+ static int supply_state = -1;
+@@ -180,6 +194,15 @@ static const backend_state_t const suppl
+ { CUPS_TONER_EMPTY, "toner-empty-warning" }
};
+static const quirk_name_t const quirk_names[] =
@@ -52,17 +52,17 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
/*
* Local functions...
-@@ -208,6 +231,9 @@ backendSNMPSupplies(
- if (i)
- *ptr++ = ',';
+@@ -233,6 +256,9 @@ backendSNMPSupplies(
+ for (i = 0, ptr = value; i < num_supplies; i ++, ptr += strlen(ptr))
+ {
+ if (quirks & QUIRK_CAPACITY)
-+ supplies[i].max_capacity = 100;
++ supplies[i].max_capacity = 100;
+
- if (supplies[i].max_capacity > 0)
- sprintf(ptr, "%d", 100 * supplies[i].level / supplies[i].max_capacity);
- else
-@@ -305,6 +331,7 @@ backend_init_supplies(
+ percent = 100 * supplies[i].level / supplies[i].max_capacity;
+
+ if (percent <= 10)
+@@ -406,6 +432,7 @@ backend_init_supplies(
http_addr_t *addr) /* I - Printer address */
{
int i, /* Looping var */
@@ -70,7 +70,7 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
type; /* Current marker type */
cups_file_t *cachefile; /* Cache file */
const char *cachedir; /* CUPS_CACHEDIR value */
-@@ -366,6 +393,7 @@ backend_init_supplies(
+@@ -467,6 +494,7 @@ backend_init_supplies(
current_state = -1;
num_supplies = -1;
charset = -1;
@@ -78,7 +78,7 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
memset(supplies, 0, sizeof(supplies));
-@@ -381,6 +409,34 @@ backend_init_supplies(
+@@ -482,6 +510,34 @@ backend_init_supplies(
return;
}
diff --git a/cups-str3754.patch b/cups-str3754.patch
deleted file mode 100644
index 148575a..0000000
--- a/cups-str3754.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -up cups-1.4.5/scheduler/printers.c.printer-timeout cups-1.4.5/scheduler/printers.c
---- cups-1.4.5/scheduler/printers.c.printer-timeout 2010-12-16 14:42:07.048865052 +0000
-+++ cups-1.4.5/scheduler/printers.c 2010-12-16 14:43:05.325684376 +0000
-@@ -785,6 +785,7 @@ cupsdDeletePrinter(
- */
-
- cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update);
-+ p->state = IPP_PRINTER_STOPPED;
-
- if (p->job)
- cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
diff --git a/cups.spec b/cups.spec
index 6c2ee6e..7892344 100644
--- a/cups.spec
+++ b/cups.spec
@@ -7,8 +7,8 @@
Summary: Common Unix Printing System
Name: cups
-Version: 1.4.6
-Release: 7%{?dist}
+Version: 1.4.7
+Release: 1%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -58,16 +58,12 @@ Patch24: cups-avahi.patch
Patch25: cups-str3382.patch
Patch26: cups-force-gnutls.patch
Patch27: cups-serialize-gnutls.patch
-Patch29: cups-0755.patch
-Patch31: cups-hostnamelookups.patch
-Patch33: cups-snmp-quirks.patch
-Patch34: cups-hp-deviceid-oid.patch
-Patch35: cups-dnssd-deviceid.patch
-Patch36: cups-ricoh-deviceid-oid.patch
-Patch37: cups-texttops-rotate-page.patch
-Patch38: cups-autotype-crash.patch
-Patch39: cups-str3754.patch
-Patch40: cups-job-state-changed.patch
+Patch28: cups-0755.patch
+Patch29: cups-snmp-quirks.patch
+Patch30: cups-hp-deviceid-oid.patch
+Patch31: cups-dnssd-deviceid.patch
+Patch32: cups-ricoh-deviceid-oid.patch
+Patch33: cups-texttops-rotate-page.patch
Patch100: cups-lspp.patch
@@ -253,28 +249,19 @@ module.
# locking (bug #607159).
%patch27 -p1 -b .serialize-gnutls
# Use mode 0755 for binaries and libraries where appropriate.
-%patch29 -p1 -b .0755
-# Use numeric addresses for interfaces unless HostNameLookups are
-# turned on (bug #583054).
-%patch31 -p1 -b .hostnamelookups
+%patch28 -p1 -b .0755
# Handle SNMP supply level quirks (bug #581825).
-%patch33 -p1 -b .snmp-quirks
+%patch29 -p1 -b .snmp-quirks
# Add an SNMP query for HP's device ID OID (STR #3552).
-%patch34 -p1 -b .hp-deviceid-oid
+%patch30 -p1 -b .hp-deviceid-oid
# Mark DNS-SD Device IDs that have been guessed at with "FZY:1;".
-%patch35 -p1 -b .dnssd-deviceid
+%patch31 -p1 -b .dnssd-deviceid
# Add an SNMP query for Ricoh's device ID OID (STR #3552).
-%patch36 -p1 -b .ricoh-deviceid-oid
+%patch32 -p1 -b .ricoh-deviceid-oid
# Adjust texttops output to be in natural orientation (STR #3563).
# This fixes page-label orientation when texttops is used in the
# filter chain (bug #572338).
-%patch37 -p1 -b .texttops-rotate-page
-# Don't crash when MIME database could not be loaded (bug #610088).
-%patch38 -p1 -b .autotype-crash
-# Don't crash when job queued for printer that times out (bug #660604).
-%patch39 -p1 -b .str3754
-# Fixed dbus notifier support for job-state-changed.
-%patch40 -p1 -b .job-state-changed
+%patch33 -p1 -b .texttops-rotate-page
%if %lspp
# LSPP support.
@@ -572,6 +559,9 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
+* Tue Jun 28 2011 Jiri Popelka 1:1.4.7-1
+- 1.4.7.
+
* Thu Mar 10 2011 Tim Waugh 1:1.4.6-7
- LSPP: only warn when unable to get printer context.
diff --git a/sources b/sources
index e542076..6da4bc9 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-de8fb5a29c36554925c0c6a6e2c0dae1 cups-1.4.6-source.tar.bz2
+1590033ab4c739b859aeb672fe849089 cups-1.4.7-source.tar.bz2
From 993cfb6a8aee335ed9cd00e917d217f2b184fdb6 Mon Sep 17 00:00:00 2001
From: Jiri Popelka
Date: Tue, 28 Jun 2011 12:12:17 +0200
Subject: [PATCH 6/8] 1.4.7.
---
cups-autotype-crash.patch | 15 --
cups-avahi.patch | 124 +++++++++--------
cups-hostnamelookups.patch | 24 ----
cups-job-state-changed.patch | 12 --
cups-lspp.patch | 263 +++++++++++++++++++----------------
cups-serverbin-compat.patch | 76 +++++-----
cups-snmp-quirks.patch | 38 ++---
cups-str3754.patch | 11 --
cups.spec | 70 +++++-----
9 files changed, 297 insertions(+), 336 deletions(-)
delete mode 100644 cups-autotype-crash.patch
delete mode 100644 cups-hostnamelookups.patch
delete mode 100644 cups-job-state-changed.patch
delete mode 100644 cups-str3754.patch
diff --git a/cups-autotype-crash.patch b/cups-autotype-crash.patch
deleted file mode 100644
index ed6cb15..0000000
--- a/cups-autotype-crash.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -up cups-1.4.4/scheduler/ipp.c.autotype-crash cups-1.4.4/scheduler/ipp.c
---- cups-1.4.4/scheduler/ipp.c.autotype-crash 2010-10-15 15:25:15.093421917 +0100
-+++ cups-1.4.4/scheduler/ipp.c 2010-10-15 15:25:49.645296947 +0100
-@@ -10481,8 +10481,9 @@ send_document(cupsd_client_t *con, /* I
- if (!filetype)
- filetype = mimeType(MimeDatabase, super, type);
-
-- cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
-- filetype->super, filetype->type);
-+ if (filetype)
-+ cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
-+ filetype->super, filetype->type);
- }
- else
- filetype = mimeType(MimeDatabase, super, type);
diff --git a/cups-avahi.patch b/cups-avahi.patch
index 031eb84..072f889 100644
--- a/cups-avahi.patch
+++ b/cups-avahi.patch
@@ -1,6 +1,6 @@
-diff -up cups-1.4.6/backend/dnssd.c.avahi cups-1.4.6/backend/dnssd.c
---- cups-1.4.6/backend/dnssd.c.avahi 2011-01-25 13:26:16.607114570 +0000
-+++ cups-1.4.6/backend/dnssd.c 2011-01-25 13:26:16.633115058 +0000
+diff -up cups-1.4.7/backend/dnssd.c.avahi cups-1.4.7/backend/dnssd.c
+--- cups-1.4.7/backend/dnssd.c.avahi 2011-06-28 11:55:27.024868568 +0200
++++ cups-1.4.7/backend/dnssd.c 2011-06-28 11:55:27.033868442 +0200
@@ -15,14 +15,21 @@
*
* Contents:
@@ -824,10 +824,10 @@ diff -up cups-1.4.6/backend/dnssd.c.avahi cups-1.4.6/backend/dnssd.c
/*
* 'sigterm_handler()' - Handle termination signals...
*/
-diff -up cups-1.4.6/config.h.in.avahi cups-1.4.6/config.h.in
---- cups-1.4.6/config.h.in.avahi 2010-08-13 05:11:46.000000000 +0100
-+++ cups-1.4.6/config.h.in 2011-01-25 13:26:16.635115097 +0000
-@@ -344,6 +344,13 @@
+diff -up cups-1.4.7/config.h.in.avahi cups-1.4.7/config.h.in
+--- cups-1.4.7/config.h.in.avahi 2011-01-10 08:39:37.000000000 +0100
++++ cups-1.4.7/config.h.in 2011-06-28 11:55:27.033868442 +0200
+@@ -345,6 +345,13 @@
/*
@@ -841,9 +841,9 @@ diff -up cups-1.4.6/config.h.in.avahi cups-1.4.6/config.h.in
* Do we have ?
*/
-diff -up cups-1.4.6/config-scripts/cups-dnssd.m4.avahi cups-1.4.6/config-scripts/cups-dnssd.m4
---- cups-1.4.6/config-scripts/cups-dnssd.m4.avahi 2009-08-28 23:54:34.000000000 +0100
-+++ cups-1.4.6/config-scripts/cups-dnssd.m4 2011-01-25 13:26:16.636115116 +0000
+diff -up cups-1.4.7/config-scripts/cups-dnssd.m4.avahi cups-1.4.7/config-scripts/cups-dnssd.m4
+--- cups-1.4.7/config-scripts/cups-dnssd.m4.avahi 2009-08-29 00:54:34.000000000 +0200
++++ cups-1.4.7/config-scripts/cups-dnssd.m4 2011-06-28 11:55:27.034868428 +0200
@@ -27,6 +27,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dn
DNSSDLIBS=""
DNSSD_BACKEND=""
@@ -866,9 +866,9 @@ diff -up cups-1.4.6/config-scripts/cups-dnssd.m4.avahi cups-1.4.6/config-scripts
if test x$enable_dnssd != xno; then
AC_CHECK_HEADER(dns_sd.h, [
case "$uname" in
-diff -up cups-1.4.6/cups/http-support.c.avahi cups-1.4.6/cups/http-support.c
---- cups-1.4.6/cups/http-support.c.avahi 2010-10-01 23:40:38.000000000 +0100
-+++ cups-1.4.6/cups/http-support.c 2011-01-25 13:26:16.638115152 +0000
+diff -up cups-1.4.7/cups/http-support.c.avahi cups-1.4.7/cups/http-support.c
+--- cups-1.4.7/cups/http-support.c.avahi 2010-10-02 00:40:38.000000000 +0200
++++ cups-1.4.7/cups/http-support.c 2011-06-28 11:55:27.035868414 +0200
@@ -41,6 +41,10 @@
* http_copy_decode() - Copy and decode a URI.
* http_copy_encode() - Copy and encode a URI.
@@ -1136,9 +1136,9 @@ diff -up cups-1.4.6/cups/http-support.c.avahi cups-1.4.6/cups/http-support.c
/*
* End of "$Id: http-support.c 9322 2010-10-01 22:40:38Z mike $".
*/
-diff -up cups-1.4.6/scheduler/avahi.c.avahi cups-1.4.6/scheduler/avahi.c
---- cups-1.4.6/scheduler/avahi.c.avahi 2011-01-25 13:26:16.640115190 +0000
-+++ cups-1.4.6/scheduler/avahi.c 2011-01-25 13:26:16.640115190 +0000
+diff -up cups-1.4.7/scheduler/avahi.c.avahi cups-1.4.7/scheduler/avahi.c
+--- cups-1.4.7/scheduler/avahi.c.avahi 2011-06-28 11:55:27.036868400 +0200
++++ cups-1.4.7/scheduler/avahi.c 2011-06-28 11:55:27.036868400 +0200
@@ -0,0 +1,445 @@
+/*
+ * "$Id$"
@@ -1585,9 +1585,9 @@ diff -up cups-1.4.6/scheduler/avahi.c.avahi cups-1.4.6/scheduler/avahi.c
+/*
+ * End of "$Id$".
+ */
-diff -up cups-1.4.6/scheduler/avahi.h.avahi cups-1.4.6/scheduler/avahi.h
---- cups-1.4.6/scheduler/avahi.h.avahi 2011-01-25 13:26:16.640115190 +0000
-+++ cups-1.4.6/scheduler/avahi.h 2011-01-25 13:26:16.641115209 +0000
+diff -up cups-1.4.7/scheduler/avahi.h.avahi cups-1.4.7/scheduler/avahi.h
+--- cups-1.4.7/scheduler/avahi.h.avahi 2011-06-28 11:55:27.037868386 +0200
++++ cups-1.4.7/scheduler/avahi.h 2011-06-28 11:55:27.037868386 +0200
@@ -0,0 +1,49 @@
+/*
+ * "$Id$"
@@ -1638,9 +1638,9 @@ diff -up cups-1.4.6/scheduler/avahi.h.avahi cups-1.4.6/scheduler/avahi.h
+/*
+ * End of "$Id$".
+ */
-diff -up cups-1.4.6/scheduler/cupsd.h.avahi cups-1.4.6/scheduler/cupsd.h
---- cups-1.4.6/scheduler/cupsd.h.avahi 2010-09-21 23:34:57.000000000 +0100
-+++ cups-1.4.6/scheduler/cupsd.h 2011-01-25 13:26:16.641115209 +0000
+diff -up cups-1.4.7/scheduler/cupsd.h.avahi cups-1.4.7/scheduler/cupsd.h
+--- cups-1.4.7/scheduler/cupsd.h.avahi 2011-01-11 08:05:58.000000000 +0100
++++ cups-1.4.7/scheduler/cupsd.h 2011-06-28 11:55:27.037868386 +0200
@@ -147,6 +147,15 @@ extern const char *cups_hstrerror(int);
typedef void (*cupsd_selfunc_t)(void *data);
@@ -1667,7 +1667,7 @@ diff -up cups-1.4.6/scheduler/cupsd.h.avahi cups-1.4.6/scheduler/cupsd.h
-@@ -240,6 +252,18 @@ extern void cupsdRemoveSelect(int fd);
+@@ -241,6 +253,18 @@ extern void cupsdRemoveSelect(int fd);
extern void cupsdStartSelect(void);
extern void cupsdStopSelect(void);
@@ -1686,9 +1686,9 @@ diff -up cups-1.4.6/scheduler/cupsd.h.avahi cups-1.4.6/scheduler/cupsd.h
extern int cupsdRemoveFile(const char *filename);
-diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
---- cups-1.4.6/scheduler/dirsvc.c.avahi 2011-01-25 13:26:16.534113189 +0000
-+++ cups-1.4.6/scheduler/dirsvc.c 2011-01-25 17:39:15.062315327 +0000
+diff -up cups-1.4.7/scheduler/dirsvc.c.avahi cups-1.4.7/scheduler/dirsvc.c
+--- cups-1.4.7/scheduler/dirsvc.c.avahi 2011-06-28 11:55:26.971869301 +0200
++++ cups-1.4.7/scheduler/dirsvc.c 2011-06-28 12:04:15.066420076 +0200
@@ -27,6 +27,7 @@
* ldap_connect() - Start new LDAP connection
* ldap_reconnect() - Reconnect to LDAP Server
@@ -2159,7 +2159,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
/*
* Remove the printer from the array of DNS-SD printers, then clear the
-@@ -2526,133 +2493,46 @@ dnssdDeregisterPrinter(
+@@ -2526,136 +2493,46 @@ dnssdDeregisterPrinter(
/*
@@ -2205,12 +2205,14 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
+ if (!DNSSDRef)
+ return;
+- if (count <= 0)
+- return (NULL);
++ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
++ !p->ipp_ref ? "new" : "update");
+
- for (length = i = 0; i < count; i++)
- length += 1 + strlen(keyvalue[i][0]) +
- (keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0);
-+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
-+ !p->ipp_ref ? "new" : "update");
-+
+#endif /* HAVE_DNSSD */
+#ifdef HAVE_AVAHI
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
@@ -2325,7 +2327,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
*/
if (!p->shared)
-@@ -2694,6 +2574,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
+@@ -2697,6 +2574,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
* Register IPP and (optionally) LPD...
*/
@@ -2333,7 +2335,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
ipp_len = 0; /* anti-compiler-warning-code */
ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0);
-@@ -2860,6 +2741,146 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
+@@ -2863,6 +2741,146 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
if (printer_txt)
free(printer_txt);
}
@@ -2480,7 +2482,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
}
-@@ -2872,6 +2893,10 @@ dnssdStop(void)
+@@ -2875,6 +2893,10 @@ dnssdStop(void)
{
cupsd_printer_t *p; /* Current printer */
@@ -2491,7 +2493,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
/*
* De-register the individual printers
-@@ -2882,6 +2907,7 @@ dnssdStop(void)
+@@ -2885,6 +2907,7 @@ dnssdStop(void)
p = (cupsd_printer_t *)cupsArrayNext(Printers))
dnssdDeregisterPrinter(p);
@@ -2499,7 +2501,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
/*
* Shutdown the rest of the service refs...
*/
-@@ -2902,6 +2928,7 @@ dnssdStop(void)
+@@ -2905,6 +2928,7 @@ dnssdStop(void)
DNSServiceRefDeallocate(DNSSDRef);
DNSSDRef = NULL;
@@ -2507,7 +2509,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
cupsArrayDelete(DNSSDPrinters);
DNSSDPrinters = NULL;
-@@ -2911,6 +2938,272 @@ dnssdStop(void)
+@@ -2914,6 +2938,272 @@ dnssdStop(void)
/*
@@ -2780,7 +2782,7 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
* 'dnssdUpdate()' - Handle DNS-SD queries.
*/
-@@ -2931,6 +3224,146 @@ dnssdUpdate(void)
+@@ -2934,6 +3224,146 @@ dnssdUpdate(void)
#endif /* HAVE_DNSSD */
@@ -2927,9 +2929,9 @@ diff -up cups-1.4.6/scheduler/dirsvc.c.avahi cups-1.4.6/scheduler/dirsvc.c
/*
* 'get_auth_info_required()' - Get the auth-info-required value to advertise.
*/
-diff -up cups-1.4.6/scheduler/dirsvc.h.avahi cups-1.4.6/scheduler/dirsvc.h
---- cups-1.4.6/scheduler/dirsvc.h.avahi 2009-05-14 18:54:37.000000000 +0100
-+++ cups-1.4.6/scheduler/dirsvc.h 2011-01-25 17:39:15.063315332 +0000
+diff -up cups-1.4.7/scheduler/dirsvc.h.avahi cups-1.4.7/scheduler/dirsvc.h
+--- cups-1.4.7/scheduler/dirsvc.h.avahi 2009-05-14 19:54:37.000000000 +0200
++++ cups-1.4.7/scheduler/dirsvc.h 2011-06-28 11:55:27.042868318 +0200
@@ -32,6 +32,10 @@
# endif /* HAVE_LDAP_SSL_H */
#endif /* HAVE_LDAP */
@@ -3002,9 +3004,9 @@ diff -up cups-1.4.6/scheduler/dirsvc.h.avahi cups-1.4.6/scheduler/dirsvc.h
#ifdef HAVE_LDAP
extern void cupsdUpdateLDAPBrowse(void);
#endif /* HAVE_LDAP */
-diff -up cups-1.4.6/scheduler/main.c.avahi cups-1.4.6/scheduler/main.c
---- cups-1.4.6/scheduler/main.c.avahi 2011-01-25 13:26:16.487112302 +0000
-+++ cups-1.4.6/scheduler/main.c 2011-01-25 13:26:16.650115377 +0000
+diff -up cups-1.4.7/scheduler/main.c.avahi cups-1.4.7/scheduler/main.c
+--- cups-1.4.7/scheduler/main.c.avahi 2011-06-28 11:55:26.943869690 +0200
++++ cups-1.4.7/scheduler/main.c 2011-06-28 11:55:27.043868305 +0200
@@ -135,6 +135,10 @@ main(int argc, /* I - Number of comm
cupsd_listener_t *lis; /* Current listener */
time_t current_time, /* Current time */
@@ -3110,9 +3112,9 @@ diff -up cups-1.4.6/scheduler/main.c.avahi cups-1.4.6/scheduler/main.c
/*
* Check whether we are accepting new connections...
*/
-diff -up cups-1.4.6/scheduler/Makefile.avahi cups-1.4.6/scheduler/Makefile
---- cups-1.4.6/scheduler/Makefile.avahi 2011-01-25 13:26:16.591114269 +0000
-+++ cups-1.4.6/scheduler/Makefile 2011-01-25 13:26:16.657115510 +0000
+diff -up cups-1.4.7/scheduler/Makefile.avahi cups-1.4.7/scheduler/Makefile
+--- cups-1.4.7/scheduler/Makefile.avahi 2011-06-28 11:55:27.007868803 +0200
++++ cups-1.4.7/scheduler/Makefile 2011-06-28 11:55:27.044868291 +0200
@@ -17,6 +17,7 @@ include ../Makedefs
CUPSDOBJS = \
@@ -3131,10 +3133,10 @@ diff -up cups-1.4.6/scheduler/Makefile.avahi cups-1.4.6/scheduler/Makefile
LIBOBJS = \
filter.o \
mime.o \
-diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
---- cups-1.4.6/scheduler/printers.c.avahi 2011-01-25 13:26:16.628114966 +0000
-+++ cups-1.4.6/scheduler/printers.c 2011-01-25 13:26:16.659115546 +0000
-@@ -929,10 +929,10 @@ cupsdDeletePrinter(
+diff -up cups-1.4.7/scheduler/printers.c.avahi cups-1.4.7/scheduler/printers.c
+--- cups-1.4.7/scheduler/printers.c.avahi 2011-06-28 11:55:26.928869897 +0200
++++ cups-1.4.7/scheduler/printers.c 2011-06-28 11:55:27.046868263 +0200
+@@ -932,10 +932,10 @@ cupsdDeletePrinter(
cupsdClearString(&p->alert);
cupsdClearString(&p->alert_description);
@@ -3147,7 +3149,7 @@ diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
cupsArrayDelete(p->filetypes);
-@@ -1301,9 +1301,9 @@ cupsdLoadAllPrinters(void)
+@@ -1304,9 +1304,9 @@ cupsdLoadAllPrinters(void)
{
if (value)
{
@@ -3159,7 +3161,7 @@ diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
}
else
cupsdLogMessage(CUPSD_LOG_ERROR,
-@@ -1717,10 +1717,10 @@ cupsdSaveAllPrinters(void)
+@@ -1720,10 +1720,10 @@ cupsdSaveAllPrinters(void)
cupsFilePrintf(fp, "Type %d\n", printer->type);
@@ -3172,7 +3174,7 @@ diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
for (ptr = (char *)cupsArrayFirst(printer->filters);
ptr;
-@@ -3860,7 +3860,7 @@ add_printer_formats(cupsd_printer_t *p)
+@@ -3858,7 +3858,7 @@ add_printer_formats(cupsd_printer_t *p)
attr->values[i].string.text = _cupsStrAlloc(mimetype);
}
@@ -3181,7 +3183,7 @@ diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
{
char pdl[1024]; /* Buffer to build pdl list */
mime_filter_t *filter; /* MIME filter looping var */
-@@ -3914,7 +3914,7 @@ add_printer_formats(cupsd_printer_t *p)
+@@ -3912,7 +3912,7 @@ add_printer_formats(cupsd_printer_t *p)
cupsdSetString(&p->pdl, pdl);
}
@@ -3190,7 +3192,7 @@ diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
}
-@@ -4951,9 +4951,9 @@ load_ppd(cupsd_printer_t *p) /* I - Pri
+@@ -4979,9 +4979,9 @@ load_ppd(cupsd_printer_t *p) /* I - Pri
attr->values[i].string.text = _cupsStrAlloc("bcp");
}
@@ -3202,9 +3204,9 @@ diff -up cups-1.4.6/scheduler/printers.c.avahi cups-1.4.6/scheduler/printers.c
if (ppdFindAttr(ppd, "APRemoteQueueID", NULL))
p->type |= CUPS_PRINTER_REMOTE;
-diff -up cups-1.4.6/scheduler/printers.h.avahi cups-1.4.6/scheduler/printers.h
---- cups-1.4.6/scheduler/printers.h.avahi 2010-03-30 23:07:33.000000000 +0100
-+++ cups-1.4.6/scheduler/printers.h 2011-01-25 13:26:16.665115661 +0000
+diff -up cups-1.4.7/scheduler/printers.h.avahi cups-1.4.7/scheduler/printers.h
+--- cups-1.4.7/scheduler/printers.h.avahi 2010-03-31 00:07:33.000000000 +0200
++++ cups-1.4.7/scheduler/printers.h 2011-06-28 11:55:27.048868235 +0200
@@ -16,6 +16,9 @@
#ifdef HAVE_DNSSD
# include
@@ -3244,9 +3246,9 @@ diff -up cups-1.4.6/scheduler/printers.h.avahi cups-1.4.6/scheduler/printers.h
} cupsd_printer_t;
-diff -up cups-1.4.6/scheduler/timeout.c.avahi cups-1.4.6/scheduler/timeout.c
---- cups-1.4.6/scheduler/timeout.c.avahi 2011-01-25 13:26:16.668115715 +0000
-+++ cups-1.4.6/scheduler/timeout.c 2011-01-25 13:26:16.668115715 +0000
+diff -up cups-1.4.7/scheduler/timeout.c.avahi cups-1.4.7/scheduler/timeout.c
+--- cups-1.4.7/scheduler/timeout.c.avahi 2011-06-28 11:55:27.049868221 +0200
++++ cups-1.4.7/scheduler/timeout.c 2011-06-28 11:55:27.049868221 +0200
@@ -0,0 +1,195 @@
+/*
+ * "$Id$"
diff --git a/cups-hostnamelookups.patch b/cups-hostnamelookups.patch
deleted file mode 100644
index 75b6abf..0000000
--- a/cups-hostnamelookups.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -up cups-1.4.4/scheduler/network.c.hostnamelookups cups-1.4.4/scheduler/network.c
---- cups-1.4.4/scheduler/network.c.hostnamelookups 2010-04-09 23:42:09.000000000 +0100
-+++ cups-1.4.4/scheduler/network.c 2010-06-18 11:13:02.331979867 +0100
-@@ -154,11 +154,7 @@ cupsdNetIFUpdate(void)
- * Try looking up the hostname for the address as needed...
- */
-
--#ifdef __APPLE__
- if (HostNameLookups)
--#else
-- if (HostNameLookups || RemotePort)
--#endif /* __APPLE__ */
- httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname,
- sizeof(hostname));
- else
-@@ -166,7 +162,7 @@ cupsdNetIFUpdate(void)
- /*
- * Map the default server address and localhost to the server name
- * and localhost, respectively; for all other addresses, use the
-- * dotted notation...
-+ * numeric address...
- */
-
- if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))
diff --git a/cups-job-state-changed.patch b/cups-job-state-changed.patch
deleted file mode 100644
index 16b5677..0000000
--- a/cups-job-state-changed.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up cups-1.4.6/notifier/dbus.c.job-state-changed cups-1.4.6/notifier/dbus.c
---- cups-1.4.6/notifier/dbus.c.job-state-changed 2011-02-25 12:42:11.084127808 +0000
-+++ cups-1.4.6/notifier/dbus.c 2011-02-25 12:42:31.312811947 +0000
-@@ -332,7 +332,7 @@ main(int argc, /* I - Number of comm
- const char *word2 = event + 4; /* Second word */
-
- params = PARAMS_JOB;
-- if (!strcmp(word2, "state"))
-+ if (!strcmp(word2, "state-changed"))
- signame = "JobState";
- else if (!strcmp(word2, "created"))
- signame = "JobCreated";
diff --git a/cups-lspp.patch b/cups-lspp.patch
index 5ab87bd..f8a3b22 100644
--- a/cups-lspp.patch
+++ b/cups-lspp.patch
@@ -1,7 +1,7 @@
-diff -urNp cups-1.4.6.old/config.h.in cups-1.4.6/config.h.in
---- cups-1.4.6.old/config.h.in 2011-03-07 13:34:52.585876279 +0000
-+++ cups-1.4.6/config.h.in 2011-03-07 13:35:07.138875913 +0000
-@@ -672,6 +672,12 @@
+diff -up cups-1.4.7/config.h.in.lspp cups-1.4.7/config.h.in
+--- cups-1.4.7/config.h.in.lspp 2011-06-28 12:05:58.524936215 +0200
++++ cups-1.4.7/config.h.in 2011-06-28 12:05:58.566935614 +0200
+@@ -673,6 +673,12 @@
#undef HAVE_SYS_STATVFS_H
#undef HAVE_SYS_VFS_H
@@ -14,9 +14,9 @@ diff -urNp cups-1.4.6.old/config.h.in cups-1.4.6/config.h.in
#endif /* !_CUPS_CONFIG_H_ */
-diff -urNp cups-1.4.6.old/config-scripts/cups-lspp.m4 cups-1.4.6/config-scripts/cups-lspp.m4
---- cups-1.4.6.old/config-scripts/cups-lspp.m4 1970-01-01 01:00:00.000000000 +0100
-+++ cups-1.4.6/config-scripts/cups-lspp.m4 2011-03-07 13:35:07.139875938 +0000
+diff -up cups-1.4.7/config-scripts/cups-lspp.m4.lspp cups-1.4.7/config-scripts/cups-lspp.m4
+--- cups-1.4.7/config-scripts/cups-lspp.m4.lspp 2011-06-28 12:05:58.566935614 +0200
++++ cups-1.4.7/config-scripts/cups-lspp.m4 2011-06-28 12:05:58.566935614 +0200
@@ -0,0 +1,36 @@
+dnl
+dnl LSPP code for the Common UNIX Printing System (CUPS).
@@ -54,9 +54,9 @@ diff -urNp cups-1.4.6.old/config-scripts/cups-lspp.m4 cups-1.4.6/config-scripts/
+ ;;
+ esac
+fi
-diff -urNp cups-1.4.6.old/configure.in cups-1.4.6/configure.in
---- cups-1.4.6.old/configure.in 2011-03-07 13:34:52.521876279 +0000
-+++ cups-1.4.6/configure.in 2011-03-07 13:35:07.139875938 +0000
+diff -up cups-1.4.7/configure.in.lspp cups-1.4.7/configure.in
+--- cups-1.4.7/configure.in.lspp 2010-06-22 23:42:44.000000000 +0200
++++ cups-1.4.7/configure.in 2011-06-28 12:05:58.567935599 +0200
@@ -42,6 +42,8 @@ sinclude(config-scripts/cups-pap.m4)
sinclude(config-scripts/cups-pdf.m4)
sinclude(config-scripts/cups-scripting.m4)
@@ -66,9 +66,9 @@ diff -urNp cups-1.4.6.old/configure.in cups-1.4.6/configure.in
INSTALL_LANGUAGES=""
UNINSTALL_LANGUAGES=""
LANGFILES=""
-diff -urNp cups-1.4.6.old/cups/cups.h cups-1.4.6/cups/cups.h
---- cups-1.4.6.old/cups/cups.h 2011-03-07 13:34:53.042876279 +0000
-+++ cups-1.4.6/cups/cups.h 2011-03-07 13:35:07.140875960 +0000
+diff -up cups-1.4.7/cups/cups.h.lspp cups-1.4.7/cups/cups.h
+--- cups-1.4.7/cups/cups.h.lspp 2011-01-06 23:48:42.000000000 +0100
++++ cups-1.4.7/cups/cups.h 2011-06-28 12:05:58.567935599 +0200
@@ -15,6 +15,9 @@
* This file is subject to the Apple OS-Developed Software exception.
*/
@@ -92,9 +92,9 @@ diff -urNp cups-1.4.6.old/cups/cups.h cups-1.4.6/cups/cups.h
/*
* Types and structures...
*/
-diff -urNp cups-1.4.6.old/data/Makefile cups-1.4.6/data/Makefile
---- cups-1.4.6.old/data/Makefile 2011-03-07 13:34:52.596876279 +0000
-+++ cups-1.4.6/data/Makefile 2011-03-07 13:35:07.140875960 +0000
+diff -up cups-1.4.7/data/Makefile.lspp cups-1.4.7/data/Makefile
+--- cups-1.4.7/data/Makefile.lspp 2008-11-12 20:30:57.000000000 +0100
++++ cups-1.4.7/data/Makefile 2011-06-28 12:05:58.568935584 +0200
@@ -25,7 +25,10 @@ BANNERS = \
secret \
standard \
@@ -107,9 +107,9 @@ diff -urNp cups-1.4.6.old/data/Makefile cups-1.4.6/data/Makefile
CHARMAPS = \
euc-cn.txt \
-diff -urNp cups-1.4.6.old/data/mls cups-1.4.6/data/mls
---- cups-1.4.6.old/data/mls 1970-01-01 01:00:00.000000000 +0100
-+++ cups-1.4.6/data/mls 2011-03-07 13:35:07.141875981 +0000
+diff -up cups-1.4.7/data/mls.lspp cups-1.4.7/data/mls
+--- cups-1.4.7/data/mls.lspp 2011-06-28 12:05:58.569935569 +0200
++++ cups-1.4.7/data/mls 2011-06-28 12:05:58.569935569 +0200
@@ -0,0 +1,261 @@
+%!PS-Adobe-3.0
+%%BoundingBox: 0 0 612 792
@@ -372,9 +372,9 @@ diff -urNp cups-1.4.6.old/data/mls cups-1.4.6/data/mls
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
+%
+%%EOF
-diff -urNp cups-1.4.6.old/data/selinux cups-1.4.6/data/selinux
---- cups-1.4.6.old/data/selinux 1970-01-01 01:00:00.000000000 +0100
-+++ cups-1.4.6/data/selinux 2011-03-07 13:35:07.141875981 +0000
+diff -up cups-1.4.7/data/selinux.lspp cups-1.4.7/data/selinux
+--- cups-1.4.7/data/selinux.lspp 2011-06-28 12:05:58.576935469 +0200
++++ cups-1.4.7/data/selinux 2011-06-28 12:05:58.576935469 +0200
@@ -0,0 +1,261 @@
+%!PS-Adobe-3.0
+%%BoundingBox: 0 0 612 792
@@ -637,9 +637,9 @@ diff -urNp cups-1.4.6.old/data/selinux cups-1.4.6/data/selinux
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
+%
+%%EOF
-diff -urNp cups-1.4.6.old/data/te cups-1.4.6/data/te
---- cups-1.4.6.old/data/te 1970-01-01 01:00:00.000000000 +0100
-+++ cups-1.4.6/data/te 2011-03-07 13:35:07.142875996 +0000
+diff -up cups-1.4.7/data/te.lspp cups-1.4.7/data/te
+--- cups-1.4.7/data/te.lspp 2011-06-28 12:05:58.576935469 +0200
++++ cups-1.4.7/data/te 2011-06-28 12:05:58.576935469 +0200
@@ -0,0 +1,261 @@
+%!PS-Adobe-3.0
+%%BoundingBox: 0 0 612 792
@@ -902,9 +902,9 @@ diff -urNp cups-1.4.6.old/data/te cups-1.4.6/data/te
+% End of "$Id: mls_template,v 1.1 2005/06/27 18:44:46 colmo Exp $".
+%
+%%EOF
-diff -urNp cups-1.4.6.old/filter/common.c cups-1.4.6/filter/common.c
---- cups-1.4.6.old/filter/common.c 2011-03-07 13:34:53.361876279 +0000
-+++ cups-1.4.6/filter/common.c 2011-03-07 13:35:07.143876025 +0000
+diff -up cups-1.4.7/filter/common.c.lspp cups-1.4.7/filter/common.c
+--- cups-1.4.7/filter/common.c.lspp 2007-07-11 23:46:42.000000000 +0200
++++ cups-1.4.7/filter/common.c 2011-06-28 12:05:58.580935412 +0200
@@ -30,6 +30,12 @@
* Include necessary headers...
*/
@@ -957,7 +957,7 @@ diff -urNp cups-1.4.6.old/filter/common.c cups-1.4.6/filter/common.c
+ {
+ lines = 1 + (int)(label_len / max_width);
+ line_len = (int)(label_len / lines);
-+ wrapped_label = malloc(sizeof(*wrapped_label) * lines);
++ wrapped_label = malloc(sizeof(wrapped_label) * lines);
+ label_index = i = n = 0;
+ while (classification[label_index])
+ {
@@ -989,7 +989,7 @@ diff -urNp cups-1.4.6.old/filter/common.c cups-1.4.6/filter/common.c
+ else
+ {
+ lines = 1;
-+ wrapped_label = malloc(sizeof(*wrapped_label));
++ wrapped_label = malloc(sizeof(wrapped_label));
+ wrapped_label[0] = (char*)classification;
+ }
+
@@ -1073,10 +1073,10 @@ diff -urNp cups-1.4.6.old/filter/common.c cups-1.4.6/filter/common.c
/*
-diff -urNp cups-1.4.6.old/filter/pstops.c cups-1.4.6/filter/pstops.c
---- cups-1.4.6.old/filter/pstops.c 2011-03-07 13:34:53.372876279 +0000
-+++ cups-1.4.6/filter/pstops.c 2011-03-07 13:35:07.144876057 +0000
-@@ -3326,6 +3326,18 @@ write_label_prolog(pstops_doc_t *doc, /*
+diff -up cups-1.4.7/filter/pstops.c.lspp cups-1.4.7/filter/pstops.c
+--- cups-1.4.7/filter/pstops.c.lspp 2011-06-28 12:05:58.442937394 +0200
++++ cups-1.4.7/filter/pstops.c 2011-06-28 12:05:58.582935382 +0200
+@@ -3330,6 +3330,18 @@ write_label_prolog(pstops_doc_t *doc, /*
{
const char *classification; /* CLASSIFICATION environment variable */
const char *ptr; /* Temporary string pointer */
@@ -1095,7 +1095,7 @@ diff -urNp cups-1.4.6.old/filter/pstops.c cups-1.4.6/filter/pstops.c
/*
-@@ -3348,6 +3360,124 @@ write_label_prolog(pstops_doc_t *doc, /*
+@@ -3352,6 +3364,124 @@ write_label_prolog(pstops_doc_t *doc, /*
return;
}
@@ -1115,7 +1115,7 @@ diff -urNp cups-1.4.6.old/filter/pstops.c cups-1.4.6/filter/pstops.c
+ {
+ lines = 1 + (int)(label_len / max_width);
+ line_len = (int)(label_len / lines);
-+ wrapped_label = malloc(sizeof(*wrapped_label) * lines);
++ wrapped_label = malloc(sizeof(wrapped_label) * lines);
+ label_index = i = n = 0;
+ while (classification[label_index])
+ {
@@ -1147,7 +1147,7 @@ diff -urNp cups-1.4.6.old/filter/pstops.c cups-1.4.6/filter/pstops.c
+ else
+ {
+ lines = 1;
-+ wrapped_label = malloc(sizeof(*wrapped_label));
++ wrapped_label = malloc(sizeof(wrapped_label));
+ wrapped_label[0] = (char*)classification;
+ }
+
@@ -1220,7 +1220,7 @@ diff -urNp cups-1.4.6.old/filter/pstops.c cups-1.4.6/filter/pstops.c
/*
* Set the classification + page label string...
*/
-@@ -3426,7 +3556,10 @@ write_label_prolog(pstops_doc_t *doc, /*
+@@ -3430,7 +3560,10 @@ write_label_prolog(pstops_doc_t *doc, /*
doc_printf(doc, " %.0f moveto ESPpl show\n", top - 14.0);
doc_puts(doc, "pop\n");
doc_puts(doc, "}bind put\n");
@@ -1231,9 +1231,9 @@ diff -urNp cups-1.4.6.old/filter/pstops.c cups-1.4.6/filter/pstops.c
/*
-diff -urNp cups-1.4.6.old/Makedefs.in cups-1.4.6/Makedefs.in
---- cups-1.4.6.old/Makedefs.in 2011-03-07 13:34:53.424876279 +0000
-+++ cups-1.4.6/Makedefs.in 2011-03-07 13:35:07.145876086 +0000
+diff -up cups-1.4.7/Makedefs.in.lspp cups-1.4.7/Makedefs.in
+--- cups-1.4.7/Makedefs.in.lspp 2011-06-28 12:05:58.507936462 +0200
++++ cups-1.4.7/Makedefs.in 2011-06-28 12:05:58.583935367 +0200
@@ -146,7 +146,7 @@ LIBCUPSORDER = @LIBCUPSORDER@
LIBCUPSIMAGEORDER = @LIBCUPSIMAGEORDER@
LINKCUPS = @LINKCUPS@ $(SSLLIBS) $(DNSSDLIBS)
@@ -1243,9 +1243,18 @@ diff -urNp cups-1.4.6.old/Makedefs.in cups-1.4.6/Makedefs.in
OPTIM = @OPTIM@
OPTIONS =
PAMLIBS = @PAMLIBS@
-diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
---- cups-1.4.6.old/scheduler/client.c 2011-03-07 13:34:53.733876279 +0000
-+++ cups-1.4.6/scheduler/client.c 2011-03-07 13:35:07.150876188 +0000
+@@ -258,7 +258,7 @@ DBUSDIR = @DBUSDIR@
+ # Rules...
+ #
+
+-.SILENT:
++
+ .SUFFIXES: .1 .1.gz .1m .1m.gz .3 .3.gz .5 .5.gz .7 .7.gz .8 .8.gz .a .c .cxx .h .man .o .32.o .64.o .gz
+
+ .c.o:
+diff -up cups-1.4.7/scheduler/client.c.lspp cups-1.4.7/scheduler/client.c
+--- cups-1.4.7/scheduler/client.c.lspp 2011-01-22 01:07:22.000000000 +0100
++++ cups-1.4.7/scheduler/client.c 2011-06-28 12:05:58.585935339 +0200
@@ -44,6 +44,7 @@
* valid_host() - Is the Host: field valid?
* write_file() - Send a file via HTTP.
@@ -1261,8 +1270,8 @@ diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
+#define _GNU_SOURCE
#ifdef HAVE_CDSASSL
# include
- # include
-@@ -90,6 +92,12 @@ extern const char *cssmErrorString(int e
+ # ifdef HAVE_SECITEM_H
+@@ -92,6 +94,12 @@ extern const char *cssmErrorString(int e
# include
#endif /* HAVE_TCPD_H */
@@ -1275,7 +1284,7 @@ diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
/*
* Local functions...
-@@ -391,6 +399,57 @@ cupsdAcceptClient(cupsd_listener_t *lis)
+@@ -393,6 +401,57 @@ cupsdAcceptClient(cupsd_listener_t *lis)
}
#endif /* HAVE_TCPD_H */
@@ -1333,7 +1342,7 @@ diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
#ifdef AF_INET6
if (con->http.hostaddr->addr.sa_family == AF_INET6)
cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s:%d (IPv6)",
-@@ -781,6 +840,13 @@ cupsdReadClient(cupsd_client_t *con) /*
+@@ -783,6 +842,13 @@ cupsdReadClient(cupsd_client_t *con) /*
mime_type_t *type; /* MIME type of file */
cupsd_printer_t *p; /* Printer */
static unsigned request_id = 0; /* Request ID for temp files */
@@ -1347,7 +1356,7 @@ diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
status = HTTP_CONTINUE;
-@@ -2135,6 +2201,67 @@ cupsdReadClient(cupsd_client_t *con) /*
+@@ -2137,6 +2203,67 @@ cupsdReadClient(cupsd_client_t *con) /*
fchmod(con->file, 0640);
fchown(con->file, RunUser, Group);
fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
@@ -1415,7 +1424,7 @@ diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
}
if (con->http.state != HTTP_POST_SEND)
-@@ -4641,6 +4768,50 @@ make_certificate(cupsd_client_t *con) /*
+@@ -4647,6 +4774,50 @@ make_certificate(cupsd_client_t *con) /*
#endif /* HAVE_SSL */
@@ -1466,9 +1475,9 @@ diff -urNp cups-1.4.6.old/scheduler/client.c cups-1.4.6/scheduler/client.c
/*
* 'pipe_command()' - Pipe the output of a command to the remote client.
*/
-diff -urNp cups-1.4.6.old/scheduler/client.h cups-1.4.6/scheduler/client.h
---- cups-1.4.6.old/scheduler/client.h 2011-03-07 13:34:53.708876279 +0000
-+++ cups-1.4.6/scheduler/client.h 2011-03-07 13:35:07.155876256 +0000
+diff -up cups-1.4.7/scheduler/client.h.lspp cups-1.4.7/scheduler/client.h
+--- cups-1.4.7/scheduler/client.h.lspp 2009-05-27 00:01:23.000000000 +0200
++++ cups-1.4.7/scheduler/client.h 2011-06-28 12:05:58.586935325 +0200
@@ -18,6 +18,13 @@
#endif /* HAVE_AUTHORIZATION_H */
@@ -1504,9 +1513,9 @@ diff -urNp cups-1.4.6.old/scheduler/client.h cups-1.4.6/scheduler/client.h
/*
-diff -urNp cups-1.4.6.old/scheduler/conf.c cups-1.4.6/scheduler/conf.c
---- cups-1.4.6.old/scheduler/conf.c 2011-03-07 13:34:53.540876279 +0000
-+++ cups-1.4.6/scheduler/conf.c 2011-03-07 13:35:07.157876274 +0000
+diff -up cups-1.4.7/scheduler/conf.c.lspp cups-1.4.7/scheduler/conf.c
+--- cups-1.4.7/scheduler/conf.c.lspp 2011-06-28 12:05:58.560935698 +0200
++++ cups-1.4.7/scheduler/conf.c 2011-06-28 12:05:58.588935297 +0200
@@ -29,6 +29,7 @@
* read_configuration() - Read a configuration file.
* read_location() - Read a definition.
@@ -1546,7 +1555,7 @@ diff -urNp cups-1.4.6.old/scheduler/conf.c cups-1.4.6/scheduler/conf.c
/*
-@@ -713,6 +724,25 @@ cupsdReadConfiguration(void)
+@@ -719,6 +730,25 @@ cupsdReadConfiguration(void)
RunUser = getuid();
@@ -1572,7 +1581,7 @@ diff -urNp cups-1.4.6.old/scheduler/conf.c cups-1.4.6/scheduler/conf.c
cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
RemotePort ? "enabled" : "disabled");
-@@ -1081,11 +1111,23 @@ cupsdReadConfiguration(void)
+@@ -1087,11 +1117,23 @@ cupsdReadConfiguration(void)
* Update classification setting as needed...
*/
@@ -1597,7 +1606,7 @@ diff -urNp cups-1.4.6.old/scheduler/conf.c cups-1.4.6/scheduler/conf.c
/*
* Check the MaxClients setting, and then allocate memory for it...
-@@ -3657,6 +3699,18 @@ read_location(cups_file_t *fp, /* I - C
+@@ -3663,6 +3705,18 @@ read_location(cups_file_t *fp, /* I - C
return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum);
}
@@ -1616,9 +1625,9 @@ diff -urNp cups-1.4.6.old/scheduler/conf.c cups-1.4.6/scheduler/conf.c
/*
* 'read_policy()' - Read a definition.
-diff -urNp cups-1.4.6.old/scheduler/conf.h cups-1.4.6/scheduler/conf.h
---- cups-1.4.6.old/scheduler/conf.h 2011-03-07 13:34:53.561876277 +0000
-+++ cups-1.4.6/scheduler/conf.h 2011-03-07 13:35:07.158876277 +0000
+diff -up cups-1.4.7/scheduler/conf.h.lspp cups-1.4.7/scheduler/conf.h
+--- cups-1.4.7/scheduler/conf.h.lspp 2011-06-28 12:05:58.411937841 +0200
++++ cups-1.4.7/scheduler/conf.h 2011-06-28 12:05:58.589935283 +0200
@@ -250,6 +250,12 @@ VAR char *ServerKey VALUE(NULL);
VAR int SSLOptions VALUE(CUPSD_SSL_NONE);
/* SSL/TLS options */
@@ -1642,9 +1651,9 @@ diff -urNp cups-1.4.6.old/scheduler/conf.h cups-1.4.6/scheduler/conf.h
/*
* Prototypes...
-diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
---- cups-1.4.6.old/scheduler/ipp.c 2011-03-07 13:34:53.720876279 +0000
-+++ cups-1.4.6/scheduler/ipp.c 2011-03-07 13:35:07.167876275 +0000
+diff -up cups-1.4.7/scheduler/ipp.c.lspp cups-1.4.7/scheduler/ipp.c
+--- cups-1.4.7/scheduler/ipp.c.lspp 2011-06-28 12:05:58.547935884 +0200
++++ cups-1.4.7/scheduler/ipp.c 2011-06-28 12:05:58.593935224 +0200
@@ -41,6 +41,7 @@
* cancel_all_jobs() - Cancel all print jobs.
* cancel_job() - Cancel a print job.
@@ -1963,7 +1972,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
/*
* See if we need to add the starting sheet...
-@@ -4295,6 +4527,111 @@ check_rss_recipient(
+@@ -4308,6 +4540,107 @@ check_rss_recipient(
}
@@ -2022,11 +2031,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
+ cupsdLogMessage(CUPSD_LOG_ERROR, "check_context: unable to convert %s to SELinux sid", con->scon);
+ return -1;
+ }
-+ if (avc_context_to_sid(job->scon, &jobsid) != 0)
-+ {
-+ cupsdLogMessage(CUPSD_LOG_ERROR, "check_context: unable to convert %s to SELinux sid", job->scon);
-+ return -1;
-+ }
++ avc_context_to_sid(job->scon, &jobsid);
+ avc_entry_ref_init(&avcref);
+ tclass = SECCLASS_FILE;
+ avr = FILE__READ;
@@ -2075,7 +2080,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
/*
* 'check_quotas()' - Check quotas for a printer and user.
*/
-@@ -4849,6 +5182,15 @@ copy_banner(cupsd_client_t *con, /* I -
+@@ -4862,6 +5195,15 @@ copy_banner(cupsd_client_t *con, /* I -
char attrname[255], /* Name of attribute */
*s; /* Pointer into name */
ipp_attribute_t *attr; /* Attribute */
@@ -2091,7 +2096,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
cupsdLogMessage(CUPSD_LOG_DEBUG2,
-@@ -4884,6 +5226,82 @@ copy_banner(cupsd_client_t *con, /* I -
+@@ -4897,6 +5239,82 @@ copy_banner(cupsd_client_t *con, /* I -
fchmod(cupsFileNumber(out), 0640);
fchown(cupsFileNumber(out), RunUser, Group);
@@ -2174,7 +2179,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
/*
* Try the localized banner file under the subdirectory...
-@@ -4978,6 +5396,24 @@ copy_banner(cupsd_client_t *con, /* I -
+@@ -4991,6 +5409,24 @@ copy_banner(cupsd_client_t *con, /* I -
else
s = attrname;
@@ -2199,7 +2204,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
if (!strcmp(s, "printer-name"))
{
cupsFilePuts(out, job->dest);
-@@ -6957,6 +7393,22 @@ get_job_attrs(cupsd_client_t *con, /* I
+@@ -6975,6 +7411,22 @@ get_job_attrs(cupsd_client_t *con, /* I
return;
}
@@ -2222,7 +2227,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
/*
* Copy attributes...
*/
-@@ -7187,6 +7639,11 @@ get_jobs(cupsd_client_t *con, /* I - C
+@@ -7205,6 +7657,11 @@ get_jobs(cupsd_client_t *con, /* I - C
if (username[0] && strcasecmp(username, job->username))
continue;
@@ -2234,7 +2239,7 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
if (count > 0)
ippAddSeparator(con->response);
-@@ -11606,6 +12063,11 @@ validate_user(cupsd_job_t *job, /* I
+@@ -11624,6 +12081,11 @@ validate_user(cupsd_job_t *job, /* I
strlcpy(username, get_username(con), userlen);
@@ -2246,10 +2251,10 @@ diff -urNp cups-1.4.6.old/scheduler/ipp.c cups-1.4.6/scheduler/ipp.c
/*
* Check the username against the owner...
*/
-diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
---- cups-1.4.6.old/scheduler/job.c 2011-03-07 13:34:53.553876279 +0000
-+++ cups-1.4.6/scheduler/job.c 2011-03-07 13:35:07.175876275 +0000
-@@ -66,6 +66,9 @@
+diff -up cups-1.4.7/scheduler/job.c.lspp cups-1.4.7/scheduler/job.c
+--- cups-1.4.7/scheduler/job.c.lspp 2011-06-28 12:05:58.476936905 +0200
++++ cups-1.4.7/scheduler/job.c 2011-06-28 12:05:58.596935180 +0200
+@@ -64,6 +64,9 @@
* update_job_attrs() - Update the job-printer-* attributes.
*/
@@ -2259,7 +2264,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
/*
* Include necessary headers...
*/
-@@ -75,6 +78,14 @@
+@@ -73,6 +76,14 @@
#include
#include
@@ -2274,7 +2279,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
/*
* Design Notes for Job Management
-@@ -508,6 +519,14 @@ cupsdContinueJob(cupsd_job_t *job) /* I
+@@ -505,6 +516,14 @@ cupsdContinueJob(cupsd_job_t *job) /* I
/* PRINTER env variable */
rip_max_cache[255];
/* RIP_MAX_CACHE env variable */
@@ -2289,7 +2294,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
cupsdLogMessage(CUPSD_LOG_DEBUG2,
-@@ -932,6 +951,67 @@ cupsdContinueJob(cupsd_job_t *job) /* I
+@@ -929,6 +948,67 @@ cupsdContinueJob(cupsd_job_t *job) /* I
}
}
@@ -2357,7 +2362,32 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
if (Classification && !banner_page)
{
if ((attr = ippFindAttribute(job->attrs, "job-sheets",
-@@ -1629,6 +1709,20 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
+@@ -1165,13 +1245,13 @@ cupsdContinueJob(cupsd_job_t *job) /* I
+ if (access(command, F_OK))
+ {
+ snprintf(command, sizeof(command), "%s/backend/%s", ServerBin_compat,
+- method);
++ scheme);
+ if (!access(command, F_OK))
+ {
+ /* Not in the correct directory, but we found it in the compat
+ * directory. Issue a warning. */
+ cupsdLogMessage(CUPSD_LOG_INFO,
+- "Backend '%s' not in %s/backend!", method,
++ "Backend '%s' not in %s/backend!", scheme,
+ ServerBin);
+ }
+ else
+@@ -1179,7 +1259,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I
+ /* Not in the compat directory either; make any error
+ messages use the correct directory name then. */
+ snprintf(command, sizeof(command), "%s/backend/%s", ServerBin,
+- method);
++ scheme);
+ }
+ }
+ #endif /* __x86_64__ */
+@@ -1634,6 +1714,20 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
goto error;
}
@@ -2378,7 +2408,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed",
IPP_TAG_INTEGER);
job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
-@@ -2016,6 +2110,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
+@@ -2021,6 +2115,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
{
char filename[1024]; /* Job control filename */
cups_file_t *fp; /* Job file */
@@ -2393,7 +2423,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p",
-@@ -2034,6 +2136,76 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
+@@ -2039,6 +2141,76 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
fchmod(cupsFileNumber(fp), 0600);
fchown(cupsFileNumber(fp), RunUser, Group);
@@ -2470,7 +2500,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
job->attrs->state = IPP_IDLE;
if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
-@@ -3341,6 +3513,18 @@ get_options(cupsd_job_t *job, /* I - Jo
+@@ -3353,6 +3525,18 @@ get_options(cupsd_job_t *job, /* I - Jo
banner_page)
continue;
@@ -2489,7 +2519,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
/*
* Otherwise add them to the list...
*/
-@@ -4029,6 +4213,19 @@ static void
+@@ -3989,6 +4173,19 @@ static void
start_job(cupsd_job_t *job, /* I - Job ID */
cupsd_printer_t *printer) /* I - Printer to print job */
{
@@ -2509,7 +2539,7 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job(job=%p(%d), printer=%p(%s))",
job, job->id, printer, printer->name);
-@@ -4151,6 +4348,108 @@ start_job(cupsd_job_t *job, /* I -
+@@ -4111,6 +4308,108 @@ start_job(cupsd_job_t *job, /* I -
fcntl(job->side_pipes[1], F_SETFD,
fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC);
@@ -2618,9 +2648,9 @@ diff -urNp cups-1.4.6.old/scheduler/job.c cups-1.4.6/scheduler/job.c
/*
* Now start the first file in the job...
*/
-diff -urNp cups-1.4.6.old/scheduler/job.h cups-1.4.6/scheduler/job.h
---- cups-1.4.6.old/scheduler/job.h 2011-03-07 13:34:53.530876279 +0000
-+++ cups-1.4.6/scheduler/job.h 2011-03-07 13:35:07.177876275 +0000
+diff -up cups-1.4.7/scheduler/job.h.lspp cups-1.4.7/scheduler/job.h
+--- cups-1.4.7/scheduler/job.h.lspp 2009-05-12 00:46:01.000000000 +0200
++++ cups-1.4.7/scheduler/job.h 2011-06-28 12:05:58.605935048 +0200
@@ -13,6 +13,13 @@
* file is missing or damaged, see the license at "http://www.cups.org/".
*/
@@ -2646,9 +2676,9 @@ diff -urNp cups-1.4.6.old/scheduler/job.h cups-1.4.6/scheduler/job.h
};
typedef struct cupsd_joblog_s /**** Job log message ****/
-diff -urNp cups-1.4.6.old/scheduler/main.c cups-1.4.6/scheduler/main.c
---- cups-1.4.6.old/scheduler/main.c 2011-03-07 13:34:53.671876279 +0000
-+++ cups-1.4.6/scheduler/main.c 2011-03-07 13:35:07.179876275 +0000
+diff -up cups-1.4.7/scheduler/main.c.lspp cups-1.4.7/scheduler/main.c
+--- cups-1.4.7/scheduler/main.c.lspp 2011-06-28 12:05:58.533936087 +0200
++++ cups-1.4.7/scheduler/main.c 2011-06-28 12:06:45.061266687 +0200
@@ -37,6 +37,8 @@
* usage() - Show scheduler usage.
*/
@@ -2668,16 +2698,16 @@ diff -urNp cups-1.4.6.old/scheduler/main.c cups-1.4.6/scheduler/main.c
/*
* Local functions...
-@@ -149,6 +154,9 @@ main(int argc, /* I - Number of comm
- #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
- struct sigaction action; /* Actions for POSIX signals */
- #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+@@ -170,6 +175,9 @@ main(int argc, /* I - Number of comm
+ long tmo_delay; /* Time before it must be called */
+ #endif /* HAVE_AVAHI */
+
+#if WITH_LSPP
+ auditfail_t failmode; /* Action for audit_open failure */
+#endif /* WITH_LSPP */
- #ifdef __sgi
- cups_file_t *fp; /* Fake lpsched lock file */
- struct stat statbuf; /* Needed for checking lpsched FIFO */
+
+ #ifdef HAVE_GETEUID
+ /*
@@ -478,6 +486,25 @@ main(int argc, /* I - Number of comm
#endif /* DEBUG */
}
@@ -2716,10 +2746,10 @@ diff -urNp cups-1.4.6.old/scheduler/main.c cups-1.4.6/scheduler/main.c
return (!stop_scheduler);
}
-diff -urNp cups-1.4.6.old/scheduler/printers.c cups-1.4.6/scheduler/printers.c
---- cups-1.4.6.old/scheduler/printers.c 2011-03-07 13:34:53.708876279 +0000
-+++ cups-1.4.6/scheduler/printers.c 2011-03-07 13:35:07.182876275 +0000
-@@ -59,6 +59,8 @@
+diff -up cups-1.4.7/scheduler/printers.c.lspp cups-1.4.7/scheduler/printers.c
+--- cups-1.4.7/scheduler/printers.c.lspp 2011-06-28 12:05:58.551935828 +0200
++++ cups-1.4.7/scheduler/printers.c 2011-06-28 12:05:58.608935007 +0200
+@@ -61,6 +61,8 @@
* write_xml_string() - Write a string with XML escaping.
*/
@@ -2728,19 +2758,18 @@ diff -urNp cups-1.4.6.old/scheduler/printers.c cups-1.4.6/scheduler/printers.c
/*
* Include necessary headers...
*/
-@@ -81,6 +83,11 @@
- # include
- #endif /* HAVE_SYS_VFS_H */
+@@ -108,6 +110,10 @@ static void write_irix_state(cupsd_print
+ #endif /* __sgi */
+ static void write_xml_string(cups_file_t *fp, const char *s);
+#ifdef WITH_LSPP
+# include
+# include
+#endif /* WITH_LSPP */
-+
- #ifdef HAVE_DBUS
- # include "colord.h"
- #endif /* HAVE_DBUS */
-@@ -2329,6 +2336,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
+
+ /*
+ * 'cupsdAddPrinter()' - Add a printer to the system.
+@@ -2332,6 +2338,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
"username",
"password"
};
@@ -2754,7 +2783,7 @@ diff -urNp cups-1.4.6.old/scheduler/printers.c cups-1.4.6/scheduler/printers.c
DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
-@@ -2459,6 +2473,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
+@@ -2462,6 +2475,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)
attr->values[1].string.text = _cupsStrAlloc(Classification ?
Classification : p->job_sheets[1]);
}
@@ -2800,7 +2829,7 @@ diff -urNp cups-1.4.6.old/scheduler/printers.c cups-1.4.6/scheduler/printers.c
}
p->raw = 0;
-@@ -5605,7 +5658,6 @@ write_irix_state(cupsd_printer_t *p) /*
+@@ -5654,7 +5706,6 @@ write_irix_state(cupsd_printer_t *p) /*
}
#endif /* __sgi */
diff --git a/cups-serverbin-compat.patch b/cups-serverbin-compat.patch
index bf1bc99..5e95509 100644
--- a/cups-serverbin-compat.patch
+++ b/cups-serverbin-compat.patch
@@ -1,6 +1,6 @@
-diff -up cups-1.4.6/scheduler/conf.c.serverbin-compat cups-1.4.6/scheduler/conf.c
---- cups-1.4.6/scheduler/conf.c.serverbin-compat 2010-08-31 05:18:38.000000000 +0100
-+++ cups-1.4.6/scheduler/conf.c 2011-01-12 16:28:47.233270999 +0000
+diff -up cups-1.4.7/scheduler/conf.c.serverbin-compat cups-1.4.7/scheduler/conf.c
+--- cups-1.4.7/scheduler/conf.c.serverbin-compat 2011-01-11 08:05:58.000000000 +0100
++++ cups-1.4.7/scheduler/conf.c 2011-06-28 10:43:24.677053741 +0200
@@ -488,6 +488,9 @@ cupsdReadConfiguration(void)
cupsdClearString(&ServerName);
cupsdClearString(&ServerAdmin);
@@ -11,7 +11,7 @@ diff -up cups-1.4.6/scheduler/conf.c.serverbin-compat cups-1.4.6/scheduler/conf.
cupsdSetString(&RequestRoot, CUPS_REQUESTS);
cupsdSetString(&CacheDir, CUPS_CACHEDIR);
cupsdSetString(&DataDir, CUPS_DATADIR);
-@@ -1331,7 +1334,12 @@ cupsdReadConfiguration(void)
+@@ -1337,7 +1340,12 @@ cupsdReadConfiguration(void)
* Read the MIME type and conversion database...
*/
@@ -24,9 +24,9 @@ diff -up cups-1.4.6/scheduler/conf.c.serverbin-compat cups-1.4.6/scheduler/conf.
snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
MimeDatabase = mimeLoadTypes(NULL, mimedir);
-diff -up cups-1.4.6/scheduler/conf.h.serverbin-compat cups-1.4.6/scheduler/conf.h
---- cups-1.4.6/scheduler/conf.h.serverbin-compat 2010-04-23 19:56:34.000000000 +0100
-+++ cups-1.4.6/scheduler/conf.h 2011-01-12 16:28:47.233270999 +0000
+diff -up cups-1.4.7/scheduler/conf.h.serverbin-compat cups-1.4.7/scheduler/conf.h
+--- cups-1.4.7/scheduler/conf.h.serverbin-compat 2010-04-23 20:56:34.000000000 +0200
++++ cups-1.4.7/scheduler/conf.h 2011-06-28 10:43:24.678053725 +0200
@@ -105,6 +105,10 @@ VAR char *ConfigurationFile VALUE(NULL)
/* Root directory for scheduler */
*ServerBin VALUE(NULL),
@@ -38,26 +38,26 @@ diff -up cups-1.4.6/scheduler/conf.h.serverbin-compat cups-1.4.6/scheduler/conf.
*StateDir VALUE(NULL),
/* Root directory for state data */
*RequestRoot VALUE(NULL),
-diff -up cups-1.4.6/scheduler/env.c.serverbin-compat cups-1.4.6/scheduler/env.c
---- cups-1.4.6/scheduler/env.c.serverbin-compat 2009-06-15 18:13:52.000000000 +0100
-+++ cups-1.4.6/scheduler/env.c 2011-01-12 16:28:47.234270949 +0000
-@@ -87,8 +87,13 @@ cupsdInitEnv(void)
- cupsdSetEnv("LD_LIBRARY_PATH", NULL);
- cupsdSetEnv("LD_PRELOAD", NULL);
- cupsdSetEnv("NLSPATH", NULL);
+diff -up cups-1.4.7/scheduler/env.c.serverbin-compat cups-1.4.7/scheduler/env.c
+--- cups-1.4.7/scheduler/env.c.serverbin-compat 2011-01-11 08:05:58.000000000 +0100
++++ cups-1.4.7/scheduler/env.c 2011-06-28 10:49:25.638319580 +0200
+@@ -218,8 +218,13 @@ cupsdUpdateEnv(void)
+ set_if_undefined("LD_PRELOAD", NULL);
+ set_if_undefined("NLSPATH", NULL);
+ if (find_env("PATH") < 0)
+#ifdef __x86_64__
-+ cupsdSetEnvf("PATH", "%s/filter:%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
-+ ":/bin:/usr/bin", ServerBin, ServerBin_compat);
++ cupsdSetEnvf("PATH", "%s/filter:%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
++ ":/bin:/usr/bin", ServerBin, ServerBin_compat);
+#else /* ! defined(__x86_64__) */
- cupsdSetEnvf("PATH", "%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
- ":/bin:/usr/bin", ServerBin);
+ cupsdSetEnvf("PATH", "%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
+ ":/bin:/usr/bin", ServerBin);
+#endif
- cupsdSetEnv("SERVER_ADMIN", ServerAdmin);
- cupsdSetEnv("SHLIB_PATH", NULL);
- cupsdSetEnv("SOFTWARE", CUPS_MINIMAL);
-diff -up cups-1.4.6/scheduler/ipp.c.serverbin-compat cups-1.4.6/scheduler/ipp.c
---- cups-1.4.6/scheduler/ipp.c.serverbin-compat 2010-10-06 21:07:44.000000000 +0100
-+++ cups-1.4.6/scheduler/ipp.c 2011-01-12 16:28:47.246270349 +0000
+ set_if_undefined("SERVER_ADMIN", ServerAdmin);
+ set_if_undefined("SHLIB_PATH", NULL);
+ set_if_undefined("SOFTWARE", CUPS_MINIMAL);
+diff -up cups-1.4.7/scheduler/ipp.c.serverbin-compat cups-1.4.7/scheduler/ipp.c
+--- cups-1.4.7/scheduler/ipp.c.serverbin-compat 2011-02-15 00:47:29.000000000 +0100
++++ cups-1.4.7/scheduler/ipp.c 2011-06-28 10:43:24.682053664 +0200
@@ -2602,9 +2602,18 @@ add_printer(cupsd_client_t *con, /* I -
* Could not find device in list!
*/
@@ -77,10 +77,10 @@ diff -up cups-1.4.6/scheduler/ipp.c.serverbin-compat cups-1.4.6/scheduler/ipp.c
}
}
-diff -up cups-1.4.6/scheduler/job.c.serverbin-compat cups-1.4.6/scheduler/job.c
---- cups-1.4.6/scheduler/job.c.serverbin-compat 2010-11-30 22:35:02.000000000 +0000
-+++ cups-1.4.6/scheduler/job.c 2011-01-12 16:31:43.515443755 +0000
-@@ -975,8 +975,32 @@ cupsdContinueJob(cupsd_job_t *job) /* I
+diff -up cups-1.4.7/scheduler/job.c.serverbin-compat cups-1.4.7/scheduler/job.c
+--- cups-1.4.7/scheduler/job.c.serverbin-compat 2011-04-23 00:38:01.000000000 +0200
++++ cups-1.4.7/scheduler/job.c 2011-06-28 10:43:24.686053600 +0200
+@@ -972,8 +972,32 @@ cupsdContinueJob(cupsd_job_t *job) /* I
i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
{
if (filter->filter[0] != '/')
@@ -115,7 +115,7 @@ diff -up cups-1.4.6/scheduler/job.c.serverbin-compat cups-1.4.6/scheduler/job.c
else
strlcpy(command, filter->filter, sizeof(command));
-@@ -1122,6 +1146,28 @@ cupsdContinueJob(cupsd_job_t *job) /* I
+@@ -1119,6 +1143,28 @@ cupsdContinueJob(cupsd_job_t *job) /* I
cupsdClosePipe(job->print_pipes);
cupsdClosePipe(job->back_pipes);
cupsdClosePipe(job->side_pipes);
@@ -123,13 +123,13 @@ diff -up cups-1.4.6/scheduler/job.c.serverbin-compat cups-1.4.6/scheduler/job.c
+ if (access(command, F_OK))
+ {
+ snprintf(command, sizeof(command), "%s/backend/%s", ServerBin_compat,
-+ scheme);
++ method);
+ if (!access(command, F_OK))
+ {
+ /* Not in the correct directory, but we found it in the compat
+ * directory. Issue a warning. */
+ cupsdLogMessage(CUPSD_LOG_INFO,
-+ "Backend '%s' not in %s/backend!", scheme,
++ "Backend '%s' not in %s/backend!", method,
+ ServerBin);
+ }
+ else
@@ -137,17 +137,17 @@ diff -up cups-1.4.6/scheduler/job.c.serverbin-compat cups-1.4.6/scheduler/job.c
+ /* Not in the compat directory either; make any error
+ messages use the correct directory name then. */
+ snprintf(command, sizeof(command), "%s/backend/%s", ServerBin,
-+ scheme);
++ method);
+ }
+ }
+#endif /* __x86_64__ */
close(job->status_pipes[1]);
job->status_pipes[1] = -1;
-diff -up cups-1.4.6/scheduler/printers.c.serverbin-compat cups-1.4.6/scheduler/printers.c
---- cups-1.4.6/scheduler/printers.c.serverbin-compat 2010-09-22 19:35:07.000000000 +0100
-+++ cups-1.4.6/scheduler/printers.c 2011-01-12 16:28:47.261269599 +0000
-@@ -1114,9 +1114,19 @@ cupsdLoadAllPrinters(void)
+diff -up cups-1.4.7/scheduler/printers.c.serverbin-compat cups-1.4.7/scheduler/printers.c
+--- cups-1.4.7/scheduler/printers.c.serverbin-compat 2011-03-04 20:28:38.000000000 +0100
++++ cups-1.4.7/scheduler/printers.c 2011-06-28 10:43:24.688053568 +0200
+@@ -1118,9 +1118,19 @@ cupsdLoadAllPrinters(void)
* Backend does not exist, stop printer...
*/
@@ -167,7 +167,7 @@ diff -up cups-1.4.6/scheduler/printers.c.serverbin-compat cups-1.4.6/scheduler/p
}
}
-@@ -3658,6 +3668,14 @@ add_printer_filter(
+@@ -3657,6 +3667,14 @@ add_printer_filter(
if (stat(filename, &fileinfo))
{
@@ -182,7 +182,7 @@ diff -up cups-1.4.6/scheduler/printers.c.serverbin-compat cups-1.4.6/scheduler/p
memset(&fileinfo, 0, sizeof(fileinfo));
snprintf(p->state_message, sizeof(p->state_message),
-@@ -3666,6 +3684,9 @@ add_printer_filter(
+@@ -3665,6 +3683,9 @@ add_printer_filter(
cupsdSetPrinterReasons(p, "+cups-missing-filter-warning");
cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
diff --git a/cups-snmp-quirks.patch b/cups-snmp-quirks.patch
index 0308676..d7c82a4 100644
--- a/cups-snmp-quirks.patch
+++ b/cups-snmp-quirks.patch
@@ -1,7 +1,7 @@
-diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-supplies.c
---- cups-1.4.3/backend/snmp-supplies.c.snmp-quirks 2009-11-20 01:27:57.000000000 +0000
-+++ cups-1.4.3/backend/snmp-supplies.c 2010-06-09 16:27:05.515019804 +0100
-@@ -38,6 +38,13 @@
+diff -up cups-1.4.7/backend/snmp-supplies.c.snmp-quirks cups-1.4.7/backend/snmp-supplies.c
+--- cups-1.4.7/backend/snmp-supplies.c.snmp-quirks 2011-03-10 04:50:59.000000000 +0100
++++ cups-1.4.7/backend/snmp-supplies.c 2011-06-28 11:11:57.944155996 +0200
+@@ -49,6 +49,13 @@
/*
@@ -15,7 +15,7 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
* Local structures...
*/
-@@ -57,6 +64,12 @@ typedef struct /**** Printer state ta
+@@ -68,6 +75,12 @@ typedef struct /**** Printer state ta
const char *keyword; /* IPP printer-state-reasons keyword */
} backend_state_t;
@@ -28,16 +28,16 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
/*
* Local globals...
-@@ -68,6 +81,7 @@ static int current_state = -1;
+@@ -79,6 +92,7 @@ static int current_state = -1;
static int charset = -1; /* Character set for supply names */
static int num_supplies = 0;
/* Number of supplies found */
+static int quirks = 0; /* Printer quirks */
static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
/* Supply information */
-
-@@ -153,6 +167,15 @@ static const backend_state_t const print
- { CUPS_TC_outputFull, "output-area-full-warning" }
+ static int supply_state = -1;
+@@ -180,6 +194,15 @@ static const backend_state_t const suppl
+ { CUPS_TONER_EMPTY, "toner-empty-warning" }
};
+static const quirk_name_t const quirk_names[] =
@@ -52,17 +52,17 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
/*
* Local functions...
-@@ -208,6 +231,9 @@ backendSNMPSupplies(
- if (i)
- *ptr++ = ',';
+@@ -233,6 +256,9 @@ backendSNMPSupplies(
+ for (i = 0, ptr = value; i < num_supplies; i ++, ptr += strlen(ptr))
+ {
+ if (quirks & QUIRK_CAPACITY)
-+ supplies[i].max_capacity = 100;
++ supplies[i].max_capacity = 100;
+
- if (supplies[i].max_capacity > 0)
- sprintf(ptr, "%d", 100 * supplies[i].level / supplies[i].max_capacity);
- else
-@@ -305,6 +331,7 @@ backend_init_supplies(
+ percent = 100 * supplies[i].level / supplies[i].max_capacity;
+
+ if (percent <= 10)
+@@ -406,6 +432,7 @@ backend_init_supplies(
http_addr_t *addr) /* I - Printer address */
{
int i, /* Looping var */
@@ -70,7 +70,7 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
type; /* Current marker type */
cups_file_t *cachefile; /* Cache file */
const char *cachedir; /* CUPS_CACHEDIR value */
-@@ -366,6 +393,7 @@ backend_init_supplies(
+@@ -467,6 +494,7 @@ backend_init_supplies(
current_state = -1;
num_supplies = -1;
charset = -1;
@@ -78,7 +78,7 @@ diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-
memset(supplies, 0, sizeof(supplies));
-@@ -381,6 +409,34 @@ backend_init_supplies(
+@@ -482,6 +510,34 @@ backend_init_supplies(
return;
}
diff --git a/cups-str3754.patch b/cups-str3754.patch
deleted file mode 100644
index 148575a..0000000
--- a/cups-str3754.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -up cups-1.4.5/scheduler/printers.c.printer-timeout cups-1.4.5/scheduler/printers.c
---- cups-1.4.5/scheduler/printers.c.printer-timeout 2010-12-16 14:42:07.048865052 +0000
-+++ cups-1.4.5/scheduler/printers.c 2010-12-16 14:43:05.325684376 +0000
-@@ -785,6 +785,7 @@ cupsdDeletePrinter(
- */
-
- cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update);
-+ p->state = IPP_PRINTER_STOPPED;
-
- if (p->job)
- cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
diff --git a/cups.spec b/cups.spec
index 078f0c2..4ce6d57 100644
--- a/cups.spec
+++ b/cups.spec
@@ -12,8 +12,8 @@
Summary: Common Unix Printing System
Name: cups
-Version: 1.4.6
-Release: 20%{?dist}
+Version: 1.4.7
+Release: 1%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -59,23 +59,20 @@ Patch20: cups-res_init.patch
Patch21: cups-filter-debug.patch
Patch22: cups-uri-compat.patch
Patch23: cups-cups-get-classes.patch
-Patch25: cups-str3382.patch
-Patch26: cups-force-gnutls.patch
-Patch27: cups-serialize-gnutls.patch
-Patch29: cups-0755.patch
-Patch31: cups-hostnamelookups.patch
-Patch33: cups-snmp-quirks.patch
-Patch34: cups-hp-deviceid-oid.patch
-Patch35: cups-dnssd-deviceid.patch
-Patch36: cups-ricoh-deviceid-oid.patch
-Patch37: cups-texttops-rotate-page.patch
-Patch38: cups-autotype-crash.patch
-Patch39: cups-str3754.patch
+Patch24: cups-str3382.patch
+Patch25: cups-force-gnutls.patch
+Patch26: cups-serialize-gnutls.patch
+Patch27: cups-0755.patch
+Patch28: cups-snmp-quirks.patch
+Patch29: cups-hp-deviceid-oid.patch
+Patch30: cups-dnssd-deviceid.patch
+Patch31: cups-ricoh-deviceid-oid.patch
+Patch32: cups-texttops-rotate-page.patch
+Patch33: cups-usb-parallel.patch
+Patch34: cups-str3535.patch
+
Patch40: cups-avahi.patch
Patch41: cups-icc.patch
-Patch42: cups-usb-parallel.patch
-Patch43: cups-job-state-changed.patch
-Patch44: cups-str3535.patch
Patch100: cups-lspp.patch
@@ -261,43 +258,35 @@ module.
# Fix support for older CUPS servers in cupsGetDests.
%patch23 -p1 -b .cups-get-classes
# Fix temporary filename creation.
-%patch25 -p1 -b .str3382
+%patch24 -p1 -b .str3382
# Force the use of gnutls despite thread-safety concerns (bug #607159).
-%patch26 -p1 -b .force-gnutls
+%patch25 -p1 -b .force-gnutls
# Perform locking for gnutls and avoid libgcrypt's broken
# locking (bug #607159).
-%patch27 -p1 -b .serialize-gnutls
+%patch26 -p1 -b .serialize-gnutls
# Use mode 0755 for binaries and libraries where appropriate.
-%patch29 -p1 -b .0755
-# Use numeric addresses for interfaces unless HostNameLookups are
-# turned on (bug #583054).
-%patch31 -p1 -b .hostnamelookups
+%patch27 -p1 -b .0755
# Handle SNMP supply level quirks (bug #581825).
-%patch33 -p1 -b .snmp-quirks
+%patch28 -p1 -b .snmp-quirks
# Add an SNMP query for HP's device ID OID (STR #3552).
-%patch34 -p1 -b .hp-deviceid-oid
+%patch29 -p1 -b .hp-deviceid-oid
# Mark DNS-SD Device IDs that have been guessed at with "FZY:1;".
-%patch35 -p1 -b .dnssd-deviceid
+%patch30 -p1 -b .dnssd-deviceid
# Add an SNMP query for Ricoh's device ID OID (STR #3552).
-%patch36 -p1 -b .ricoh-deviceid-oid
+%patch31 -p1 -b .ricoh-deviceid-oid
# Adjust texttops output to be in natural orientation (STR #3563).
# This fixes page-label orientation when texttops is used in the
# filter chain (bug #572338).
-%patch37 -p1 -b .texttops-rotate-page
-# Don't crash when MIME database could not be loaded (bug #610088).
-%patch38 -p1 -b .autotype-crash
-# Don't crash when job queued for printer that times out (bug #660604).
-%patch39 -p1 -b .str3754
+%patch32 -p1 -b .texttops-rotate-page
+# Till's patch to fix USB-Parallel adapter cable problem (bug #624564).
+%patch33 -p1 -b .usb-parallel
+# Set the default RIPCache to 128m (STR #3535, bug #549901).
+%patch34 -p1 -b .str3535
+
# Avahi support in the dnssd backend.
%patch40 -p1 -b .avahi
# ICC colord support.
%patch41 -p1 -b .icc
-# Till's patch to fix USB-Parallel adapter cable problem (bug #624564).
-%patch42 -p1 -b .usb-parallel
-# Fixed dbus notifier support for job-state-changed.
-%patch43 -p1 -b .job-state-changed
-# Set the default RIPCache to 128m (STR #3535, bug #549901).
-%patch44 -p1 -b .str3535
%if %lspp
# LSPP support.
@@ -617,6 +606,9 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
+* Tue Jun 28 2011 Jiri Popelka 1:1.4.7-1
+- 1.4.7.
+
* Fri Jun 3 2011 Tim Waugh 1:1.4.6-20
- Use correct port number when publishing services through Avahi
(Ubuntu #792309).
From 1a668d884ab47fe6ede2d6b798ba3c4893465097 Mon Sep 17 00:00:00 2001
From: Jiri Popelka
Date: Tue, 28 Jun 2011 13:30:13 +0200
Subject: [PATCH 7/8] added to sources
---
.gitignore | 1 +
sources | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 7da940e..60f8131 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,3 +45,4 @@ cups-1.4.3-source.tar.bz2
cups-1.4.4-source.tar.bz2
/cups-1.4.5-source.tar.bz2
/cups-1.4.6-source.tar.bz2
+/cups-1.4.7-source.tar.bz2
diff --git a/sources b/sources
index e542076..6da4bc9 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-de8fb5a29c36554925c0c6a6e2c0dae1 cups-1.4.6-source.tar.bz2
+1590033ab4c739b859aeb672fe849089 cups-1.4.7-source.tar.bz2
From e6c38fe3de6f270ea82af2830838138e80d209d8 Mon Sep 17 00:00:00 2001
From: Tim Waugh
Date: Tue, 28 Jun 2011 12:57:58 +0100
Subject: [PATCH 8/8] Updated avahi patches.
---
cups-avahi-1-config.patch | 42 +
cups-avahi-2-backend.patch | 1096 +++++++++++
cups-avahi-3-timeouts.patch | 337 ++++
cups-avahi-4-poll.patch | 513 ++++++
cups-avahi-5-services.patch | 1606 ++++++++++++++++
cups-avahi.patch | 3447 -----------------------------------
cups.spec | 27 +-
7 files changed, 3615 insertions(+), 3453 deletions(-)
create mode 100644 cups-avahi-1-config.patch
create mode 100644 cups-avahi-2-backend.patch
create mode 100644 cups-avahi-3-timeouts.patch
create mode 100644 cups-avahi-4-poll.patch
create mode 100644 cups-avahi-5-services.patch
delete mode 100644 cups-avahi.patch
diff --git a/cups-avahi-1-config.patch b/cups-avahi-1-config.patch
new file mode 100644
index 0000000..5d91f2a
--- /dev/null
+++ b/cups-avahi-1-config.patch
@@ -0,0 +1,42 @@
+diff -up cups-1.4.7/config.h.in.avahi-1-config cups-1.4.7/config.h.in
+--- cups-1.4.7/config.h.in.avahi-1-config 2011-01-10 07:39:37.000000000 +0000
++++ cups-1.4.7/config.h.in 2011-06-28 12:53:16.860630055 +0100
+@@ -345,6 +345,13 @@
+
+
+ /*
++ * Do we have Avahi for DNS Service Discovery?
++ */
++
++#undef HAVE_AVAHI
++
++
++/*
+ * Do we have ?
+ */
+
+diff -up cups-1.4.7/config-scripts/cups-dnssd.m4.avahi-1-config cups-1.4.7/config-scripts/cups-dnssd.m4
+--- cups-1.4.7/config-scripts/cups-dnssd.m4.avahi-1-config 2009-08-28 23:54:34.000000000 +0100
++++ cups-1.4.7/config-scripts/cups-dnssd.m4 2011-06-28 12:53:16.860630055 +0100
+@@ -27,6 +27,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dn
+ DNSSDLIBS=""
+ DNSSD_BACKEND=""
+
++AC_ARG_ENABLE(avahi, [ --enable-avahi turn on DNS Service Discovery support, default=no],
++ [if test x$enable_avahi = xyes; then
++ AC_MSG_CHECKING(for Avahi)
++ if $PKGCONFIG --exists avahi-client; then
++ AC_MSG_RESULT(yes)
++ CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`"
++ DNSSDLIBS="`$PKGCONFIG --libs avahi-client`"
++ DNSSD_BACKEND="dnssd"
++ AC_DEFINE(HAVE_AVAHI)
++ enable_dnssd=no
++ else
++ AC_MSG_RESULT(no)
++ fi
++ fi])
++
+ if test x$enable_dnssd != xno; then
+ AC_CHECK_HEADER(dns_sd.h, [
+ case "$uname" in
diff --git a/cups-avahi-2-backend.patch b/cups-avahi-2-backend.patch
new file mode 100644
index 0000000..b3ab389
--- /dev/null
+++ b/cups-avahi-2-backend.patch
@@ -0,0 +1,1096 @@
+diff -up cups-1.4.7/backend/dnssd.c.avahi-2-backend cups-1.4.7/backend/dnssd.c
+--- cups-1.4.7/backend/dnssd.c.avahi-2-backend 2011-06-28 12:51:40.491366359 +0100
++++ cups-1.4.7/backend/dnssd.c 2011-06-28 12:53:39.969213688 +0100
+@@ -15,14 +15,21 @@
+ *
+ * Contents:
+ *
++ * next_txt_record() - Get next TXT record from a cups_txt_records_t.
++ * parse_txt_record_pair() - Read key/value pair in cups_txt_records_t.
+ * main() - Browse for printers.
+ * browse_callback() - Browse devices.
+ * browse_local_callback() - Browse local devices.
+ * compare_devices() - Compare two devices.
+ * exec_backend() - Execute the backend that corresponds to the
+ * resolved service name.
++ * device_type() - Get DNS-SD type enumeration from string.
+ * get_device() - Create or update a device.
+ * query_callback() - Process query data.
++ * avahi_client_callback() - Avahi client callback function.
++ * avahi_query_callback() - Avahi query callback function.
++ * avahi_browse_callback() - Avahi browse callback function.
++ * find_device() - Find a device from its name and domain.
+ * sigterm_handler() - Handle termination signals...
+ * unquote() - Unquote a name string.
+ */
+@@ -33,7 +40,18 @@
+
+ #include "backend-private.h"
+ #include
+-#include
++#ifdef HAVE_DNSSD
++# include
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++# include
++# include
++# include
++# include
++# include
++# include
++#define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX
++#endif /* HAVE_AVAHI */
+
+
+ /*
+@@ -52,7 +70,12 @@ typedef enum
+
+ typedef struct
+ {
++#ifdef HAVE_DNSSD
+ DNSServiceRef ref; /* Service reference for resolve */
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ int resolved; /* Did we resolve the device? */
++#endif /* HAVE_AVAHI */
+ char *name, /* Service name */
+ *domain, /* Domain name */
+ *fullName, /* Full name */
+@@ -64,6 +87,20 @@ typedef struct
+ sent; /* Did we list the device? */
+ } cups_device_t;
+
++typedef struct
++{
++ char key[256];
++ char value[256];
++
++#ifdef HAVE_DNSSD
++ const uint8_t *data;
++ const uint8_t *datanext;
++ const uint8_t *dataend;
++#else /* HAVE_AVAHI */
++ AvahiStringList *txt;
++#endif /* HAVE_DNSSD */
++} cups_txt_records_t;
++
+
+ /*
+ * Local globals...
+@@ -77,6 +114,7 @@ static int job_canceled = 0;
+ * Local functions...
+ */
+
++#ifdef HAVE_DNSSD
+ static void browse_callback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+@@ -92,12 +130,6 @@ static void browse_local_callback(DNSSe
+ const char *regtype,
+ const char *replyDomain,
+ void *context);
+-static int compare_devices(cups_device_t *a, cups_device_t *b);
+-static void exec_backend(char **argv);
+-static cups_device_t *get_device(cups_array_t *devices,
+- const char *serviceName,
+- const char *regtype,
+- const char *replyDomain);
+ static void query_callback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+@@ -106,9 +138,118 @@ static void query_callback(DNSServiceRe
+ uint16_t rrclass, uint16_t rdlen,
+ const void *rdata, uint32_t ttl,
+ void *context);
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++static void avahi_client_callback (AvahiClient *client,
++ AvahiClientState state,
++ void *context);
++static void avahi_browse_callback (AvahiServiceBrowser *browser,
++ AvahiIfIndex interface,
++ AvahiProtocol protocol,
++ AvahiBrowserEvent event,
++ const char *serviceName,
++ const char *regtype,
++ const char *replyDomain,
++ AvahiLookupResultFlags flags,
++ void *context);
++#endif /* HAVE_AVAHI */
++
++static cups_device_t * find_device (cups_array_t *devices,
++ cups_txt_records_t *txt,
++ cups_device_t *dkey);
++static int compare_devices(cups_device_t *a, cups_device_t *b);
++static void exec_backend(char **argv);
++static cups_device_t *get_device(cups_array_t *devices,
++ const char *serviceName,
++ const char *regtype,
++ const char *replyDomain);
+ static void sigterm_handler(int sig);
+ static void unquote(char *dst, const char *src, size_t dstsize);
+
++#ifdef HAVE_AVAHI
++static AvahiSimplePoll *simple_poll = NULL;
++static int avahi_got_callback;
++#endif /* HAVE_AVAHI */
++
++
++/*
++ * 'next_txt_record()' - Get next TXT record from a cups_txt_records_t.
++ */
++
++static cups_txt_records_t *
++next_txt_record (cups_txt_records_t *txt)
++{
++#ifdef HAVE_DNSSD
++ txt->data = txt->datanext;
++#else /* HAVE_AVAHI */
++ txt->txt = avahi_string_list_get_next (txt->txt);
++ if (txt->txt == NULL)
++ return NULL;
++#endif /* HAVE_DNSSD */
++
++ return txt;
++}
++
++
++/*
++ * 'parse_txt_record_pair()' - Read key/value pair in cups_txt_records_t.
++ */
++
++static int
++parse_txt_record_pair (cups_txt_records_t *txt)
++{
++#ifdef HAVE_DNSSD
++ uint8_t datalen;
++ uint8_t *data = txt->data;
++ char *ptr;
++
++ /*
++ * Read a key/value pair starting with an 8-bit length. Since the
++ * length is 8 bits and the size of the key/value buffers is 256, we
++ * don't need to check for overflow...
++ */
++
++ datalen = *data++;
++ if (!datalen || (data + datalen) >= txt->dataend)
++ return NULL;
++ txt->datanext = data + datalen;
++
++ for (ptr = txt->key; data < txt->datanext && *data != '='; data ++)
++ *ptr++ = *data;
++ *ptr = '\0';
++
++ if (data < txt->datanext && *data == '=')
++ {
++ data++;
++
++ if (data < datanext)
++ memcpy (txt->value, data, txt->datanext - data);
++ value[txt->datanext - data] = '\0';
++ }
++ else
++ return 1;
++#else /* HAVE_AVAHI */
++ char *key, *value;
++ size_t len;
++ avahi_string_list_get_pair (txt->txt, &key, &value, &len);
++ if (len > sizeof (txt->value) - 1)
++ len = sizeof (txt->value) - 1;
++
++ memcpy (txt->value, value, len);
++ txt->value[len] = '\0';
++ len = strlen (key);
++ if (len > sizeof (txt->key) - 1)
++ len = sizeof (txt->key) - 1;
++
++ memcpy (txt->key, key, len);
++ txt->key[len] = '\0';
++ avahi_free (key);
++ avahi_free (value);
++#endif /* HAVE_AVAHI */
++
++ return 0;
++}
++
+
+ /*
+ * 'main()' - Browse for printers.
+@@ -119,6 +260,13 @@ main(int argc, /* I - Number of comm
+ char *argv[]) /* I - Command-line arguments */
+ {
+ const char *name; /* Backend name */
++ cups_array_t *devices; /* Device array */
++ cups_device_t *device; /* Current device */
++ char uriName[1024]; /* Unquoted fullName for URI */
++#ifdef HAVE_DNSSD
++ int fd; /* Main file descriptor */
++ fd_set input; /* Input set for select() */
++ struct timeval timeout; /* Timeout for select() */
+ DNSServiceRef main_ref, /* Main service reference */
+ fax_ipp_ref, /* IPP fax service reference */
+ ipp_ref, /* IPP service reference */
+@@ -130,12 +278,11 @@ main(int argc, /* I - Number of comm
+ pdl_datastream_ref, /* AppSocket service reference */
+ printer_ref, /* LPD service reference */
+ riousbprint_ref; /* Remote IO service reference */
+- int fd; /* Main file descriptor */
+- fd_set input; /* Input set for select() */
+- struct timeval timeout; /* Timeout for select() */
+- cups_array_t *devices; /* Device array */
+- cups_device_t *device; /* Current device */
+- char uriName[1024]; /* Unquoted fullName for URI */
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ AvahiClient *client;
++ int error;
++#endif /* HAVE_AVAHI */
+ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action; /* Actions for POSIX signals */
+ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+@@ -194,6 +341,49 @@ main(int argc, /* I - Number of comm
+ * Browse for different kinds of printers...
+ */
+
++#ifdef HAVE_AVAHI
++ if ((simple_poll = avahi_simple_poll_new ()) == NULL)
++ {
++ perror ("ERROR: Unable to create avahi simple poll object");
++ return (1);
++ }
++
++ client = avahi_client_new (avahi_simple_poll_get (simple_poll),
++ 0, avahi_client_callback, NULL, &error);
++ if (!client)
++ {
++ perror ("DEBUG: Unable to create avahi client");
++ return (0);
++ }
++
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_fax-ipp._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_ipp._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_ipp-tls._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_pdl-datastream._tcp",
++ NULL, 0,
++ avahi_browse_callback,
++ devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_printer._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_riousbprint._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++#endif /* HAVE_AVAHI */
++#ifdef HAVE_DNSSD
+ if (DNSServiceCreateConnection(&main_ref) != kDNSServiceErr_NoError)
+ {
+ perror("ERROR: Unable to create service connection");
+@@ -245,6 +435,7 @@ main(int argc, /* I - Number of comm
+ riousbprint_ref = main_ref;
+ DNSServiceBrowse(&riousbprint_ref, kDNSServiceFlagsShareConnection, 0,
+ "_riousbprint._tcp", NULL, browse_callback, devices);
++#endif /* HAVE_DNSSD */
+
+ /*
+ * Loop until we are killed...
+@@ -252,6 +443,9 @@ main(int argc, /* I - Number of comm
+
+ while (!job_canceled)
+ {
++ int announce = 0;
++
++#ifdef HAVE_DNSSD
+ FD_ZERO(&input);
+ FD_SET(fd, &input);
+
+@@ -271,11 +465,35 @@ main(int argc, /* I - Number of comm
+ }
+ else
+ {
++ announce = 1;
++ }
++#else /* HAVE_AVAHI */
++ int r;
++ avahi_got_callback = 0;
++ r = avahi_simple_poll_iterate (simple_poll, 1);
++ if (r != 0 && r != EINTR)
++ {
++ /*
++ * We've been told to exit the loop. Perhaps the connection to
++ * avahi failed.
++ */
++
++ break;
++ }
++
++ if (avahi_got_callback)
++ announce = 1;
++#endif /* HAVE_DNSSD */
++
++ if (announce)
++ {
+ /*
+ * Announce any devices we've found...
+ */
+
++#ifdef HAVE_DNSSD
+ DNSServiceErrorType status; /* DNS query status */
++#endif /* HAVE_DNSSD */
+ cups_device_t *best; /* Best matching device */
+ char device_uri[1024]; /* Device URI */
+ int count; /* Number of queries */
+@@ -285,6 +503,7 @@ main(int argc, /* I - Number of comm
+ best = NULL, count = 0;
+ device;
+ device = (cups_device_t *)cupsArrayNext(devices))
++#ifdef HAVE_DNSSD
+ if (!device->ref && !device->sent)
+ {
+ /*
+@@ -313,14 +532,23 @@ main(int argc, /* I - Number of comm
+ count ++;
+ }
+ }
+- else if (!device->sent)
++ else
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ if (!device->resolved)
++ continue;
++ else
++#endif /* HAVE_AVAHI */
++ if (!device->sent)
+ {
++#ifdef HAVE_DNSSD
+ /*
+ * Got the TXT records, now report the device...
+ */
+
+ DNSServiceRefDeallocate(device->ref);
+ device->ref = 0;
++#endif /* HAVE_DNSSD */
+
+ if (!best)
+ best = device;
+@@ -368,6 +596,7 @@ main(int argc, /* I - Number of comm
+ }
+
+
++#ifdef HAVE_DNSSD
+ /*
+ * 'browse_callback()' - Browse devices.
+ */
+@@ -456,6 +685,7 @@ browse_local_callback(
+ device->fullName);
+ device->sent = 1;
+ }
++#endif /* HAVE_DNSSD */
+
+
+ /*
+@@ -530,6 +760,37 @@ exec_backend(char **argv) /* I - Comman
+
+
+ /*
++ * 'device_type()' - Get DNS-SD type enumeration from string.
++ */
++
++static int
++device_type (const char *regtype)
++{
++#ifdef HAVE_AVAHI
++ if (!strcmp(regtype, "_ipp._tcp") ||
++ !strcmp(regtype, "_ipp-tls._tcp"))
++ return (CUPS_DEVICE_IPP);
++ else if (!strcmp(regtype, "_fax-ipp._tcp"))
++ return (CUPS_DEVICE_FAX_IPP);
++ else if (!strcmp(regtype, "_printer._tcp"))
++ return (CUPS_DEVICE_PDL_DATASTREAM);
++#else
++ if (!strcmp(regtype, "_ipp._tcp.") ||
++ !strcmp(regtype, "_ipp-tls._tcp."))
++ return (CUPS_DEVICE_IPP);
++ else if (!strcmp(regtype, "_fax-ipp._tcp."))
++ return (CUPS_DEVICE_FAX_IPP);
++ else if (!strcmp(regtype, "_printer._tcp."))
++ return (CUPS_DEVICE_PRINTER);
++ else if (!strcmp(regtype, "_pdl-datastream._tcp."))
++ return (CUPS_DEVICE_PDL_DATASTREAM);
++#endif /* HAVE_AVAHI */
++
++ return (CUPS_DEVICE_RIOUSBPRINT);
++}
++
++
++/*
+ * 'get_device()' - Create or update a device.
+ */
+
+@@ -550,18 +811,7 @@ get_device(cups_array_t *devices, /* I -
+ */
+
+ key.name = (char *)serviceName;
+-
+- if (!strcmp(regtype, "_ipp._tcp.") ||
+- !strcmp(regtype, "_ipp-tls._tcp."))
+- key.type = CUPS_DEVICE_IPP;
+- else if (!strcmp(regtype, "_fax-ipp._tcp."))
+- key.type = CUPS_DEVICE_FAX_IPP;
+- else if (!strcmp(regtype, "_printer._tcp."))
+- key.type = CUPS_DEVICE_PRINTER;
+- else if (!strcmp(regtype, "_pdl-datastream._tcp."))
+- key.type = CUPS_DEVICE_PDL_DATASTREAM;
+- else
+- key.type = CUPS_DEVICE_RIOUSBPRINT;
++ key.type = device_type (regtype);
+
+ for (device = cupsArrayFind(devices, &key);
+ device;
+@@ -581,8 +831,14 @@ get_device(cups_array_t *devices, /* I -
+ free(device->domain);
+ device->domain = strdup(replyDomain);
+
++#ifdef HAVE_DNSSD
+ DNSServiceConstructFullName(fullName, device->name, regtype,
+ replyDomain);
++#else /* HAVE_AVAHI */
++ avahi_service_name_join (fullName, kDNSServiceMaxDomainName,
++ serviceName, regtype, replyDomain);
++#endif /* HAVE_DNSSD */
++
+ free(device->fullName);
+ device->fullName = strdup(fullName);
+ }
+@@ -602,6 +858,9 @@ get_device(cups_array_t *devices, /* I -
+ device->domain = strdup(replyDomain);
+ device->type = key.type;
+ device->priority = 50;
++#ifdef HAVE_AVAHI
++ device->resolved = 0;
++#endif /* HAVE_AVAHI */
+
+ cupsArrayAdd(devices, device);
+
+@@ -609,13 +868,20 @@ get_device(cups_array_t *devices, /* I -
+ * Set the "full name" of this service, which is used for queries...
+ */
+
++#ifdef HAVE_DNSSD
+ DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain);
++#else /* HAVE_AVAHI */
++ avahi_service_name_join (fullName, kDNSServiceMaxDomainName,
++ serviceName, regtype, replyDomain);
++#endif /* HAVE_DNSSD */
++
+ device->fullName = strdup(fullName);
+
+ return (device);
+ }
+
+
++#ifdef HAVE_DNSSD
+ /*
+ * 'query_callback()' - Process query data.
+ */
+@@ -639,7 +905,7 @@ query_callback(
+ *ptr; /* Pointer into string */
+ cups_device_t dkey, /* Search key */
+ *device; /* Device */
+-
++ cups_txt_records_t txt;
+
+ fprintf(stderr, "DEBUG2: query_callback(sdRef=%p, flags=%x, "
+ "interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
+@@ -673,84 +939,232 @@ query_callback(
+ if ((ptr = strstr(name, "._")) != NULL)
+ *ptr = '\0';
+
+- if (strstr(fullName, "_ipp._tcp.") ||
+- strstr(fullName, "_ipp-tls._tcp."))
+- dkey.type = CUPS_DEVICE_IPP;
+- else if (strstr(fullName, "_fax-ipp._tcp."))
+- dkey.type = CUPS_DEVICE_FAX_IPP;
+- else if (strstr(fullName, "_printer._tcp."))
+- dkey.type = CUPS_DEVICE_PRINTER;
+- else if (strstr(fullName, "_pdl-datastream._tcp."))
+- dkey.type = CUPS_DEVICE_PDL_DATASTREAM;
++ dkey.type = device_type (fullName);
++
++ txt.data = rdata;
++ txt.dataend = rdata + rdlen;
++ device = find_device ((cups_array_t *) context, &txt, &dkey);
++ if (!device)
++ fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
++}
++#endif /* HAVE_DNSSD */
++
++
++#ifdef HAVE_AVAHI
++/*
++ * 'avahi_client_callback()' - Avahi client callback function.
++ */
++
++static void
++avahi_client_callback(AvahiClient *client,
++ AvahiClientState state,
++ void *context)
++{
++ /*
++ * If the connection drops, quit.
++ */
++
++ if (state == AVAHI_CLIENT_FAILURE)
++ {
++ fprintf (stderr, "ERROR: Avahi connection failed\n");
++ avahi_simple_poll_quit (simple_poll);
++ }
++}
++
++
++/*
++ * 'avahi_query_callback()' - Avahi query callback function.
++ */
++
++static void
++avahi_query_callback(AvahiServiceResolver *resolver,
++ AvahiIfIndex interface,
++ AvahiProtocol protocol,
++ AvahiResolverEvent event,
++ const char *name,
++ const char *type,
++ const char *domain,
++ const char *host_name,
++ const AvahiAddress *address,
++ uint16_t port,
++ AvahiStringList *txt,
++ AvahiLookupResultFlags flags,
++ void *context)
++{
++ AvahiClient *client;
++ cups_device_t key,
++ *device;
++ char uqname[1024],
++ *ptr;
++ cups_txt_records_t txtr;
++
++ client = avahi_service_resolver_get_client (resolver);
++ if (event != AVAHI_RESOLVER_FOUND)
++ {
++ if (event == AVAHI_RESOLVER_FAILURE)
++ {
++ fprintf (stderr, "ERROR: %s\n",
++ avahi_strerror (avahi_client_errno (client)));
++ }
++
++ avahi_service_resolver_free (resolver);
++ return;
++ }
++
++ /*
++ * Set search key for device.
++ */
++
++ key.name = uqname;
++ unquote (uqname, name, sizeof (uqname));
++ if ((ptr = strstr(name, "._")) != NULL)
++ *ptr = '\0';
++
++ key.domain = (char *) domain;
++ key.type = device_type (type);
++
++ /*
++ * Find the device and the the TXT information.
++ */
++
++ txtr.txt = txt;
++ device = find_device ((cups_array_t *) context, &txtr, &key);
++ if (device)
++ {
++ /*
++ * Let the main loop know to announce the device.
++ */
++
++ device->resolved = 1;
++ avahi_got_callback = 1;
++ }
+ else
+- dkey.type = CUPS_DEVICE_RIOUSBPRINT;
++ fprintf (stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", name);
++
++ avahi_service_resolver_free (resolver);
++}
++
++
++/*
++ * 'avahi_browse_callback()' - Avahi browse callback function.
++ */
++
++static void
++avahi_browse_callback(AvahiServiceBrowser *browser,
++ AvahiIfIndex interface,
++ AvahiProtocol protocol,
++ AvahiBrowserEvent event,
++ const char *name,
++ const char *type,
++ const char *domain,
++ AvahiLookupResultFlags flags,
++ void *context)
++{
++ AvahiClient *client = avahi_service_browser_get_client (browser);
+
+- for (device = cupsArrayFind(devices, &dkey);
++ switch (event)
++ {
++ case AVAHI_BROWSER_FAILURE:
++ fprintf (stderr, "ERROR: %s\n",
++ avahi_strerror (avahi_client_errno (client)));
++ avahi_simple_poll_quit (simple_poll);
++ return;
++
++ case AVAHI_BROWSER_NEW:
++ /*
++ * This object is new on the network.
++ */
++
++ if (flags & AVAHI_LOOKUP_RESULT_LOCAL)
++ {
++ /*
++ * This comes from the local machine so ignore it.
++ */
++
++ fprintf (stderr, "DEBUG: ignoring local service %s\n", name);
++ }
++ else
++ {
++ /*
++ * Create a device entry for it if it doesn't yet exist.
++ */
++
++ get_device ((cups_array_t *)context, name, type, domain);
++
++ /*
++ * Now look for a TXT entry.
++ */
++
++ if (avahi_service_resolver_new (client, interface, protocol,
++ name, type, domain,
++ AVAHI_PROTO_UNSPEC, 0,
++ avahi_query_callback, context) == NULL)
++ {
++ fprintf (stderr, "ERROR: failed to resolve service %s: %s\n",
++ name, avahi_strerror (avahi_client_errno (client)));
++ }
++ }
++
++ break;
++
++ case AVAHI_BROWSER_REMOVE:
++ case AVAHI_BROWSER_ALL_FOR_NOW:
++ case AVAHI_BROWSER_CACHE_EXHAUSTED:
++ break;
++ }
++}
++#endif /* HAVE_AVAHI */
++
++
++/*
++ * 'find_device()' - Find a device from its name and domain.
++ */
++
++static cups_device_t *
++find_device (cups_array_t *devices,
++ cups_txt_records_t *txt,
++ cups_device_t *dkey)
++{
++ cups_device_t *device;
++ char *ptr;
++
++ for (device = cupsArrayFind(devices, dkey);
+ device;
+ device = cupsArrayNext(devices))
+ {
+- if (strcasecmp(device->name, dkey.name) ||
+- strcasecmp(device->domain, dkey.domain))
++ if (strcasecmp(device->name, dkey->name) ||
++ strcasecmp(device->domain, dkey->domain))
+ {
+ device = NULL;
+ break;
+ }
+- else if (device->type == dkey.type)
++ else if (device->type == dkey->type)
+ {
+ /*
+ * Found it, pull out the priority and make and model from the TXT
+ * record and save it...
+ */
+
+- const uint8_t *data, /* Pointer into data */
+- *datanext, /* Next key/value pair */
+- *dataend; /* End of entire TXT record */
+- uint8_t datalen; /* Length of current key/value pair */
+- char key[256], /* Key string */
+- value[256], /* Value string */
+- make_and_model[512],
++ char make_and_model[512],
+ /* Manufacturer and model */
+ model[256], /* Model */
+- device_id[2048];/* 1284 device ID */
+-
++ device_id[2048]; /* 1284 device ID */
+
+ device_id[0] = '\0';
+ make_and_model[0] = '\0';
+
+ strcpy(model, "Unknown");
+
+- for (data = rdata, dataend = data + rdlen;
+- data < dataend;
+- data = datanext)
++ for (;;)
+ {
+- /*
+- * Read a key/value pair starting with an 8-bit length. Since the
+- * length is 8 bits and the size of the key/value buffers is 256, we
+- * don't need to check for overflow...
+- */
+-
+- datalen = *data++;
+-
+- if (!datalen || (data + datalen) >= dataend)
+- break;
++ char *key;
++ char *value;
+
+- datanext = data + datalen;
+-
+- for (ptr = key; data < datanext && *data != '='; data ++)
+- *ptr++ = *data;
+- *ptr = '\0';
+-
+- if (data < datanext && *data == '=')
+- {
+- data ++;
+-
+- if (data < datanext)
+- memcpy(value, data, datanext - data);
+- value[datanext - data] = '\0';
+- }
+- else
+- continue;
++ if (parse_txt_record_pair (txt))
++ goto next;
+
++ key = txt->key;
++ value = txt->value;
+ if (!strncasecmp(key, "usb_", 4))
+ {
+ /*
+@@ -805,6 +1219,10 @@ query_callback(
+ if (device->type == CUPS_DEVICE_PRINTER)
+ device->sent = 1;
+ }
++
++ next:
++ if (next_txt_record (txt) == NULL)
++ break;
+ }
+
+ if (device->device_id)
+@@ -861,11 +1279,9 @@ query_callback(
+ }
+ }
+
+- if (!device)
+- fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
++ return device;
+ }
+
+-
+ /*
+ * 'sigterm_handler()' - Handle termination signals...
+ */
+diff -up cups-1.4.7/cups/http-support.c.avahi-2-backend cups-1.4.7/cups/http-support.c
+--- cups-1.4.7/cups/http-support.c.avahi-2-backend 2010-10-01 23:40:38.000000000 +0100
++++ cups-1.4.7/cups/http-support.c 2011-06-28 12:53:39.971213652 +0100
+@@ -41,6 +41,10 @@
+ * http_copy_decode() - Copy and decode a URI.
+ * http_copy_encode() - Copy and encode a URI.
+ * resolve_callback() - Build a device URI for the given service name.
++ * avahi_resolve_uri_client_cb()
++ * - Avahi client callback for resolving URI.
++ * avahi_resolve_uri_resolver_cb()
++ * - Avahi resolver callback for resolving URI.
+ */
+
+ /*
+@@ -55,6 +59,11 @@
+ # include
+ # include
+ #endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++# include
++# include
++# include
++#endif /* HAVE_AVAHI */
+
+
+ /*
+@@ -121,6 +130,24 @@ static void resolve_callback(DNSService
+ void *context);
+ #endif /* HAVE_DNSSD */
+
++#ifdef HAVE_AVAHI
++static void avahi_resolve_uri_client_cb(AvahiClient *client,
++ AvahiClientState state,
++ void *simple_poll);
++static void avahi_resolve_uri_resolver_cb(AvahiServiceResolver *resolver,
++ AvahiIfIndex interface,
++ AvahiProtocol protocol,
++ AvahiResolverEvent event,
++ const char *name,
++ const char *type,
++ const char *domain,
++ const char *host_name,
++ const AvahiAddress *address,
++ uint16_t port,
++ AvahiStringList *txt,
++ AvahiLookupResultFlags flags,
++ void *context);
++#endif /* HAVE_AVAHI */
+
+ /*
+ * 'httpAssembleURI()' - Assemble a uniform resource identifier from its
+@@ -1351,6 +1378,9 @@ _httpResolveURI(
+
+ if (strstr(hostname, "._tcp"))
+ {
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++ char *regtype, /* Pointer to type in hostname */
++ *domain; /* Pointer to domain in hostname */
+ #ifdef HAVE_DNSSD
+ DNSServiceRef ref, /* DNS-SD master service reference */
+ domainref, /* DNS-SD service reference for domain */
+@@ -1361,6 +1391,16 @@ _httpResolveURI(
+ *domain; /* Pointer to domain in hostname */
+ _http_uribuf_t uribuf; /* URI buffer */
+ struct pollfd polldata; /* Polling data */
++#else /* HAVE_AVAHI */
++ AvahiSimplePoll *simple_poll;
++ AvahiClient *client;
++ int error;
++ struct
++ {
++ AvahiSimplePoll *poll;
++ _http_uribuf_t uribuf;
++ } user_data;
++#endif /* HAVE_DNSSD */
+
+
+ if (logit)
+@@ -1398,8 +1438,13 @@ _httpResolveURI(
+ if (domain)
+ *domain++ = '\0';
+
++#ifdef HAVE_DNSSD
+ uribuf.buffer = resolved_uri;
+ uribuf.bufsize = resolved_size;
++#else
++ user_data.uribuf.buffer = resolved_uri;
++ user_data.uribuf.bufsize = resolved_size;
++#endif
+
+ resolved_uri[0] = '\0';
+
+@@ -1414,6 +1459,7 @@ _httpResolveURI(
+
+ uri = NULL;
+
++#ifdef HAVE_DNSSD
+ if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
+ {
+ localref = ref;
+@@ -1500,6 +1546,36 @@ _httpResolveURI(
+
+ DNSServiceRefDeallocate(ref);
+ }
++#else /* HAVE_AVAHI */
++ if ((simple_poll = avahi_simple_poll_new ()) != NULL)
++ {
++ if ((client = avahi_client_new (avahi_simple_poll_get (simple_poll),
++ 0, avahi_resolve_uri_client_cb,
++ &simple_poll, &error)) != NULL)
++ {
++ user_data.poll = simple_poll;
++ if (avahi_service_resolver_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC, hostname,
++ regtype, domain, AVAHI_PROTO_UNSPEC, 0,
++ avahi_resolve_uri_resolver_cb,
++ &user_data) != NULL)
++ {
++ avahi_simple_poll_loop (simple_poll);
++
++ /*
++ * Collect the result.
++ */
++
++ if (resolved_uri[0])
++ uri = resolved_uri;
++ }
++
++ avahi_client_free (client);
++ }
++
++ avahi_simple_poll_free (simple_poll);
++ }
++#endif /* HAVE_DNSSD */
+
+ if (logit)
+ {
+@@ -1511,13 +1587,13 @@ _httpResolveURI(
+ fputs("STATE: -connecting-to-device,offline-report\n", stderr);
+ }
+
+-#else
++#else /* HAVE_DNSSD || HAVE_AVAHI */
+ /*
+ * No DNS-SD support...
+ */
+
+ uri = NULL;
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+
+ if (logit && !uri)
+ _cupsLangPuts(stderr, _("Unable to find printer!\n"));
+@@ -1723,6 +1799,116 @@ resolve_callback(
+ #endif /* HAVE_DNSSD */
+
+
++#ifdef HAVE_AVAHI
++/*
++ * 'avahi_resolve_uri_client_cb()' - Avahi client callback for resolving URI.
++ */
++
++static void
++avahi_resolve_uri_client_cb (AvahiClient *client,
++ AvahiClientState state,
++ void *simple_poll)
++{
++ DEBUG_printf(("avahi_resolve_uri_client_callback(client=%p, state=%d, "
++ "simple_poll=%p)\n", client, state, simple_poll));
++
++ /*
++ * If the connection drops, quit.
++ */
++
++ if (state == AVAHI_CLIENT_FAILURE)
++ avahi_simple_poll_quit (simple_poll);
++}
++
++
++/*
++ * 'avahi_resolve_uri_resolver_cb()' - Avahi resolver callback for resolving
++ * URI.
++ */
++
++static void
++avahi_resolve_uri_resolver_cb (AvahiServiceResolver *resolver,
++ AvahiIfIndex interface,
++ AvahiProtocol protocol,
++ AvahiResolverEvent event,
++ const char *name,
++ const char *type,
++ const char *domain,
++ const char *host_name,
++ const AvahiAddress *address,
++ uint16_t port,
++ AvahiStringList *txt,
++ AvahiLookupResultFlags flags,
++ void *context)
++{
++ const char *scheme; /* URI scheme */
++ char rp[256]; /* Remote printer */
++ AvahiStringList *pair;
++ char *value;
++ size_t valueLen = 0;
++ char addr[AVAHI_ADDRESS_STR_MAX];
++ struct
++ {
++ AvahiSimplePoll *poll;
++ _http_uribuf_t uribuf;
++ } *poll_uribuf = context;
++
++ DEBUG_printf(("avahi_resolve_uri_resolver_callback(resolver=%p, "
++ "interface=%d, protocol=%d, event=%d, name=\"%s\", "
++ "type=\"%s\", domain=\"%s\", host_name=\"%s\", address=%p, "
++ "port=%d, txt=%p, flags=%d, context=%p)\n",
++ resolver, interface, protocol, event, name, type, domain,
++ host_name, address, port, txt, flags, context));
++
++ if (event != AVAHI_RESOLVER_FOUND)
++ {
++ avahi_service_resolver_free (resolver);
++ avahi_simple_poll_quit (poll_uribuf->poll);
++ return;
++ }
++
++ /*
++ * Figure out the scheme from the full name...
++ */
++
++ if (strstr(type, "_ipp."))
++ scheme = "ipp";
++ else if (strstr(type, "_printer."))
++ scheme = "lpd";
++ else if (strstr(type, "_pdl-datastream."))
++ scheme = "socket";
++ else
++ scheme = "riousbprint";
++
++ /*
++ * Extract the "remote printer key from the TXT record...
++ */
++
++ if ((pair = avahi_string_list_find (txt, "rp")) != NULL)
++ {
++ avahi_string_list_get_pair (pair, NULL, &value, &valueLen);
++ rp[0] = '/';
++ memcpy (rp + 1, value, valueLen);
++ rp[valueLen + 1] = '\0';
++ }
++ else
++ rp[0] = '\0';
++
++ /*
++ * Assemble the final device URI...
++ */
++
++ avahi_address_snprint (addr, AVAHI_ADDRESS_STR_MAX, address);
++ httpAssembleURI(HTTP_URI_CODING_ALL, poll_uribuf->uribuf.buffer,
++ poll_uribuf->uribuf.bufsize, scheme, NULL,
++ addr, port, rp);
++ DEBUG_printf(("avahi_resolve_uri_resolver_callback: Resolved URI is \"%s\"\n",
++ poll_uribuf->uribuf.buffer));
++ avahi_simple_poll_quit (poll_uribuf->poll);
++}
++#endif /* HAVE_AVAHI */
++
++
+ /*
+ * End of "$Id: http-support.c 9322 2010-10-01 22:40:38Z mike $".
+ */
diff --git a/cups-avahi-3-timeouts.patch b/cups-avahi-3-timeouts.patch
new file mode 100644
index 0000000..6397be0
--- /dev/null
+++ b/cups-avahi-3-timeouts.patch
@@ -0,0 +1,337 @@
+diff -up cups-1.4.7/scheduler/cupsd.h.avahi-3-timeouts cups-1.4.7/scheduler/cupsd.h
+--- cups-1.4.7/scheduler/cupsd.h.avahi-3-timeouts 2011-01-11 07:05:58.000000000 +0000
++++ cups-1.4.7/scheduler/cupsd.h 2011-06-28 12:54:06.906728322 +0100
+@@ -147,6 +147,15 @@ extern const char *cups_hstrerror(int);
+
+ typedef void (*cupsd_selfunc_t)(void *data);
+
++#ifdef HAVE_AVAHI
++/*
++ * Timeout callback function type...
++ */
++
++typedef struct _cupsd_timeout_s cupsd_timeout_t;
++typedef void (*cupsd_timeoutfunc_t)(cupsd_timeout_t *timeout, void *data);
++#endif /* HAVE_AVAHI */
++
+
+ /*
+ * Globals...
+@@ -188,6 +197,9 @@ VAR PSQUpdateQuotaProcPtr PSQUpdateQuota
+ /* Apple PrintService quota function */
+ #endif /* __APPLE__ && HAVE_DLFCN_H */
+
++#ifdef HAVE_AVAHI
++VAR cups_array_t *Timeouts; /* Timed callbacks for main loop */
++#endif /* HAVE_AVAHI */
+
+
+
+@@ -241,6 +253,18 @@ extern void cupsdRemoveSelect(int fd);
+ extern void cupsdStartSelect(void);
+ extern void cupsdStopSelect(void);
+
++#ifdef HAVE_AVAHI
++extern void cupsdInitTimeouts(void);
++extern cupsd_timeout_t *cupsdAddTimeout (const struct timeval *tv,
++ cupsd_timeoutfunc_t cb,
++ void *data);
++extern cupsd_timeout_t *cupsdNextTimeout (long *delay);
++extern void cupsdRunTimeout (cupsd_timeout_t *timeout);
++extern void cupsdUpdateTimeout (cupsd_timeout_t *timeout,
++ const struct timeval *tv);
++extern void cupsdRemoveTimeout (cupsd_timeout_t *timeout);
++#endif /* HAVE_AVAHI */
++
+ extern int cupsdRemoveFile(const char *filename);
+
+
+diff -up cups-1.4.7/scheduler/main.c.avahi-3-timeouts cups-1.4.7/scheduler/main.c
+--- cups-1.4.7/scheduler/main.c.avahi-3-timeouts 2011-06-28 12:51:40.307369673 +0100
++++ cups-1.4.7/scheduler/main.c 2011-06-28 12:54:06.909728268 +0100
+@@ -161,6 +161,10 @@ main(int argc, /* I - Number of comm
+ int launchd_idle_exit;
+ /* Idle exit on select timeout? */
+ #endif /* HAVE_LAUNCHD */
++#ifdef HAVE_AVAHI
++ cupsd_timeout_t *tmo; /* Next scheduled timed callback */
++ long tmo_delay; /* Time before it must be called */
++#endif /* HAVE_AVAHI */
+
+
+ #ifdef HAVE_GETEUID
+@@ -561,6 +565,14 @@ main(int argc, /* I - Number of comm
+
+ httpInitialize();
+
++#ifdef HAVE_AVAHI
++ /*
++ * Initialize timed callback structures.
++ */
++
++ cupsdInitTimeouts();
++#endif /* HAVE_AVAHI */
++
+ cupsdStartServer();
+
+ /*
+@@ -900,6 +912,16 @@ main(int argc, /* I - Number of comm
+ }
+ #endif /* __APPLE__ */
+
++#ifdef HAVE_AVAHI
++ /*
++ * If a timed callback is due, run it.
++ */
++
++ tmo = cupsdNextTimeout (&tmo_delay);
++ if (tmo && tmo_delay == 0)
++ cupsdRunTimeout (tmo);
++#endif /* HAVE_AVAHI */
++
+ #ifndef __APPLE__
+ /*
+ * Update the network interfaces once a minute...
+@@ -1925,6 +1947,10 @@ select_timeout(int fds) /* I - Number
+ cupsd_job_t *job; /* Job information */
+ cupsd_subscription_t *sub; /* Subscription information */
+ const char *why; /* Debugging aid */
++#ifdef HAVE_AVAHI
++ cupsd_timeout_t *tmo; /* Timed callback */
++ long tmo_delay; /* Seconds before calling it */
++#endif /* HAVE_AVAHI */
+
+
+ /*
+@@ -1967,6 +1993,19 @@ select_timeout(int fds) /* I - Number
+ }
+ #endif /* __APPLE__ */
+
++#ifdef HAVE_AVAHI
++ /*
++ * See if there are any scheduled timed callbacks to run.
++ */
++
++ tmo = cupsdNextTimeout (&tmo_delay);
++ if (tmo)
++ {
++ timeout = tmo_delay;
++ why = "run a timed callback";
++ }
++#endif /* HAVE_AVAHI */
++
+ /*
+ * Check whether we are accepting new connections...
+ */
+diff -up cups-1.4.7/scheduler/Makefile.avahi-3-timeouts cups-1.4.7/scheduler/Makefile
+--- cups-1.4.7/scheduler/Makefile.avahi-3-timeouts 2011-06-28 12:51:40.475366647 +0100
++++ cups-1.4.7/scheduler/Makefile 2011-06-28 12:54:06.906728322 +0100
+@@ -39,7 +39,8 @@ CUPSDOBJS = \
+ server.o \
+ statbuf.o \
+ subscriptions.o \
+- sysman.o
++ sysman.o \
++ timeout.o
+ LIBOBJS = \
+ filter.o \
+ mime.o \
+diff -up cups-1.4.7/scheduler/timeout.c.avahi-3-timeouts cups-1.4.7/scheduler/timeout.c
+--- cups-1.4.7/scheduler/timeout.c.avahi-3-timeouts 2011-06-28 12:54:06.910728250 +0100
++++ cups-1.4.7/scheduler/timeout.c 2011-06-28 12:54:06.910728250 +0100
+@@ -0,0 +1,195 @@
++/*
++ * "$Id$"
++ *
++ * Timeout functions for the Common UNIX Printing System (CUPS).
++ *
++ * Copyright (C) 2010 Red Hat, Inc.
++ * Authors:
++ * Tim Waugh
++ *
++ * Distribution and use rights are outlined in the file "LICENSE.txt"
++ * which should have been included with this file. If this file is
++ * file is missing or damaged, see the license at "http://www.cups.org/".
++ *
++ * Contents:
++ *
++ * cupsdInitTimeouts() - Initialise timeout structure.
++ * cupsdAddTimeout() - Add a timed callback.
++ * cupsdNextTimeout() - Find the next enabled timed callback.
++ * cupsdUpdateTimeout() - Adjust the time of a timed callback or disable it.
++ * cupsdRemoveTimeout() - Discard a timed callback.
++ * compare_timeouts() - Compare timed callbacks for array sorting.
++ */
++
++#include
++
++#ifdef HAVE_AVAHI /* Applies to entire file... */
++
++/*
++ * Include necessary headers...
++ */
++
++#include "cupsd.h"
++
++#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
++# include
++#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
++
++#ifdef HAVE_AVAHI
++# include
++#endif /* HAVE_AVAHI */
++
++
++struct _cupsd_timeout_s
++{
++ struct timeval when;
++ int enabled;
++ cupsd_timeoutfunc_t callback;
++ void *data;
++};
++
++/*
++ * Local functions...
++ */
++
++/*
++ * 'compare_timeouts()' - Compare timed callbacks for array sorting.
++ */
++
++static int
++compare_timeouts (cupsd_timeout_t *p0, cupsd_timeout_t *p1)
++{
++ if (!p0->enabled || !p1->enabled)
++ {
++ if (!p0->enabled && !p1->enabled)
++ return (0);
++
++ return (p0->enabled ? -1 : 1);
++ }
++
++ return (avahi_timeval_compare (&p0->when, &p1->when));
++}
++
++
++/*
++ * 'cupsdInitTimeouts()' - Initialise timeout structures.
++ */
++
++void
++cupsdInitTimeouts(void)
++{
++ Timeouts = cupsArrayNew ((cups_array_func_t)compare_timeouts, NULL);
++}
++
++
++/*
++ * 'cupsdAddTimeout()' - Add a timed callback.
++ */
++
++cupsd_timeout_t * /* O - Timeout handle */
++cupsdAddTimeout(const struct timeval *tv, /* I - Absolute time */
++ cupsd_timeoutfunc_t cb, /* I - Callback function */
++ void *data) /* I - User data */
++{
++ cupsd_timeout_t *timeout;
++
++ timeout = malloc (sizeof(cupsd_timeout_t));
++ if (timeout != NULL)
++ {
++ timeout->enabled = (tv != NULL);
++ if (tv)
++ {
++ timeout->when.tv_sec = tv->tv_sec;
++ timeout->when.tv_usec = tv->tv_usec;
++ }
++
++ timeout->callback = cb;
++ timeout->data = data;
++ cupsArrayAdd (Timeouts, timeout);
++ }
++
++ return timeout;
++}
++
++
++/*
++ * 'cupsdNextTimeout()' - Find the next enabled timed callback.
++ */
++
++cupsd_timeout_t * /* O - Next enabled timeout or NULL */
++cupsdNextTimeout(long *delay) /* O - Seconds before scheduled */
++{
++ cupsd_timeout_t *first = cupsArrayFirst (Timeouts);
++ struct timeval curtime;
++
++ if (first && !first->enabled)
++ first = NULL;
++
++ if (first && delay)
++ {
++ gettimeofday (&curtime, NULL);
++ if (avahi_timeval_compare (&curtime, &first->when) > 0)
++ {
++ *delay = 0;
++ } else {
++ *delay = 1 + first->when.tv_sec - curtime.tv_sec;
++ if (first->when.tv_usec < curtime.tv_usec)
++ (*delay)--;
++ }
++ }
++
++ return (first);
++}
++
++
++/*
++ * 'cupsdRunTimeout()' - Run a timed callback.
++ */
++
++void
++cupsdRunTimeout(cupsd_timeout_t *timeout) /* I - Timeout */
++{
++ if (!timeout)
++ return;
++ timeout->enabled = 0;
++ if (!timeout->callback)
++ return;
++ timeout->callback (timeout, timeout->data);
++}
++
++/*
++ * 'cupsdUpdateTimeout()' - Adjust the time of a timed callback or disable it.
++ */
++
++void
++cupsdUpdateTimeout(cupsd_timeout_t *timeout, /* I - Timeout */
++ const struct timeval *tv) /* I - Absolute time or NULL */
++{
++ cupsArrayRemove (Timeouts, timeout);
++ timeout->enabled = (tv != NULL);
++ if (tv)
++ {
++ timeout->when.tv_sec = tv->tv_sec;
++ timeout->when.tv_usec = tv->tv_usec;
++ }
++ cupsArrayAdd (Timeouts, timeout);
++}
++
++
++/*
++ * 'cupsdRemoveTimeout()' - Discard a timed callback.
++ */
++
++void
++cupsdRemoveTimeout(cupsd_timeout_t *timeout) /* I - Timeout */
++{
++ cupsArrayRemove (Timeouts, timeout);
++ free (timeout);
++}
++
++
++#endif /* HAVE_AVAHI ... from top of file */
++
++/*
++ * End of "$Id$".
++ */
diff --git a/cups-avahi-4-poll.patch b/cups-avahi-4-poll.patch
new file mode 100644
index 0000000..d53ec69
--- /dev/null
+++ b/cups-avahi-4-poll.patch
@@ -0,0 +1,513 @@
+diff -up cups-1.4.7/scheduler/avahi.c.avahi-4-poll cups-1.4.7/scheduler/avahi.c
+--- cups-1.4.7/scheduler/avahi.c.avahi-4-poll 2011-06-28 12:54:34.651228409 +0100
++++ cups-1.4.7/scheduler/avahi.c 2011-06-28 12:54:34.652228391 +0100
+@@ -0,0 +1,445 @@
++/*
++ * "$Id$"
++ *
++ * Avahi poll implementation for the CUPS scheduler.
++ *
++ * Copyright (C) 2010 Red Hat, Inc.
++ * Authors:
++ * Tim Waugh
++ *
++ * Distribution and use rights are outlined in the file "LICENSE.txt"
++ * "LICENSE" which should have been included with this file. If this
++ * file is missing or damaged, see the license at "http://www.cups.org/".
++ *
++ * Contents:
++ *
++ * watch_read_cb - Read callback for file descriptor
++ * watch_write_cb - Write callback for file descriptor
++ * watched_fd_add_select() - Call cupsdAddSelect() as needed
++ * watch_new() - Create a new file descriptor watch
++ * watch_free() - Free a file descriptor watch
++ * watch_update() - Update watched events for a file descriptor
++ * watch_get_events() - Get events that happened for a file descriptor
++ * timeout_cb() - Run a timed Avahi callback
++ * timeout_new() - Set a wakeup time
++ * timeout_update() - Update the expiration time for a timeout
++ * timeout_free() - Free a timeout
++ * compare_watched_fds() - Compare watched file descriptors for array sorting
++ * compare_timeouts() - Compare timeouts for array sorting
++ * avahi_cups_poll_new() - Create a new Avahi main loop object for CUPS
++ * avahi_cups_poll_free() - Free an Avahi main loop object for CUPS
++ * avahi_cups_poll_get() - Get the abstract poll API structure
++ */
++
++#include
++
++#ifdef HAVE_AVAHI /* Applies to entire file... */
++
++/*
++ * Include necessary headers...
++ */
++
++#include "cupsd.h"
++
++#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
++# include
++#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
++
++#ifdef HAVE_AVAHI
++# include
++#endif /* HAVE_AVAHI */
++
++
++typedef struct
++{
++ AvahiCupsPoll *cups_poll;
++
++ int fd;
++ AvahiWatchEvent occurred;
++ cups_array_t *watches;
++} cupsd_watched_fd_t;
++
++struct AvahiWatch
++{
++ cupsd_watched_fd_t *watched_fd;
++
++ AvahiWatchEvent events;
++ AvahiWatchCallback callback;
++ void *userdata;
++};
++
++struct AvahiTimeout
++{
++ AvahiCupsPoll *cups_poll;
++ AvahiTimeoutCallback callback;
++ void *userdata;
++ cupsd_timeout_t *cupsd_timeout;
++};
++
++/*
++ * Local functions...
++ */
++
++static AvahiWatch * watch_new(const AvahiPoll *api,
++ int fd,
++ AvahiWatchEvent events,
++ AvahiWatchCallback callback,
++ void *userdata);
++static void watch_free(AvahiWatch *watch);
++static void watch_update(AvahiWatch *watch,
++ AvahiWatchEvent events);
++static AvahiWatchEvent watch_get_events(AvahiWatch *watch);
++static int compare_watches(AvahiWatch *p0,
++ AvahiWatch *p1);
++
++
++/*
++ * 'watch_read_cb' - Read callback for file descriptor
++ */
++
++static void
++watch_read_cb (void *userdata)
++{
++ AvahiWatch *watch;
++ cupsd_watched_fd_t *watched_fd = userdata;
++ watched_fd->occurred |= AVAHI_WATCH_IN;
++ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
++ watch;
++ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
++ if (watch->events & watched_fd->occurred) {
++ (watch->callback) (watch, watched_fd->fd,
++ AVAHI_WATCH_IN, watch->userdata);
++ watched_fd->occurred &= ~AVAHI_WATCH_IN;
++ break;
++ }
++ }
++}
++
++
++/*
++ * 'watch_write_cb' - Write callback for file descriptor
++ */
++
++static void
++watch_write_cb (void *userdata)
++{
++ AvahiWatch *watch;
++ cupsd_watched_fd_t *watched_fd = userdata;
++ watched_fd->occurred |= AVAHI_WATCH_OUT;
++ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
++ watch;
++ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
++ if (watch->events & watched_fd->occurred) {
++ (watch->callback) (watch, watched_fd->fd,
++ AVAHI_WATCH_OUT, watch->userdata);
++ watched_fd->occurred &= ~AVAHI_WATCH_OUT;
++ break;
++ }
++ }
++}
++
++
++/*
++ * 'watched_fd_add_select' - Call cupsdAddSelect() as needed
++ */
++
++static int /* O - Watches? */
++watched_fd_add_select (cupsd_watched_fd_t *watched_fd)
++{
++ AvahiWatch *watch;
++ cupsd_selfunc_t read_cb = NULL, write_cb = NULL;
++
++ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
++ watch;
++ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
++ if (watch->events & (AVAHI_WATCH_IN |
++ AVAHI_WATCH_ERR |
++ AVAHI_WATCH_HUP)) {
++ read_cb = (cupsd_selfunc_t)watch_read_cb;
++ if (write_cb != NULL)
++ break;
++ }
++
++ if (watch->events & AVAHI_WATCH_OUT) {
++ write_cb = (cupsd_selfunc_t)watch_write_cb;
++ if (read_cb != NULL)
++ break;
++ }
++ }
++
++ if (read_cb || write_cb)
++ cupsdAddSelect (watched_fd->fd, read_cb, write_cb, watched_fd);
++ else
++ cupsdRemoveSelect (watched_fd->fd);
++
++ return (read_cb || write_cb);
++}
++
++/*
++ * 'watch_new' - Create a new file descriptor watch
++ */
++
++static AvahiWatch *
++watch_new (const AvahiPoll *api,
++ int fd,
++ AvahiWatchEvent events,
++ AvahiWatchCallback callback,
++ void *userdata)
++{
++ cupsd_watched_fd_t key, *watched_fd;
++ AvahiCupsPoll *cups_poll = api->userdata;
++ AvahiWatch *watch = malloc(sizeof(AvahiWatch));
++ if (watch == NULL)
++ return (NULL);
++
++ watch->events = events;
++ watch->callback = callback;
++ watch->userdata = userdata;
++
++ key.fd = fd;
++ watched_fd = cupsArrayFind (cups_poll->watched_fds, &key);
++ if (watched_fd == NULL) {
++ watched_fd = malloc(sizeof(cupsd_watched_fd_t));
++ if (watched_fd == NULL) {
++ free (watch);
++ return (NULL);
++ }
++
++ watched_fd->fd = fd;
++ watched_fd->occurred = 0;
++ watched_fd->cups_poll = cups_poll;
++ watched_fd->watches = cupsArrayNew ((cups_array_func_t)compare_watches,
++ NULL);
++ }
++
++ watch->watched_fd = watched_fd;
++ cupsArrayAdd(watched_fd->watches, watch);
++ watched_fd_add_select (watched_fd);
++ return (watch);
++}
++
++
++/*
++ * 'watch_free' - Free a file descriptor watch
++ */
++
++static void
++watch_free (AvahiWatch *watch)
++{
++ cupsd_watched_fd_t *watched_fd = watch->watched_fd;
++ AvahiCupsPoll *cups_poll = watched_fd->cups_poll;
++
++ cupsArrayRemove (watched_fd->watches, watch);
++ free (watch);
++
++ if (!watched_fd_add_select (watched_fd)) {
++ /* No more watches */
++ cupsArrayRemove (cups_poll->watched_fds, watched_fd);
++ free (watched_fd);
++ }
++}
++
++
++/*
++ * 'watch_update' - Update watched events for a file descriptor
++ */
++
++static void
++watch_update (AvahiWatch *watch,
++ AvahiWatchEvent events)
++{
++ watch->events = events;
++ watched_fd_add_select (watch->watched_fd);
++}
++
++
++/*
++ * 'watch_get_events' - Get events that happened for a file descriptor
++ */
++
++static AvahiWatchEvent
++watch_get_events (AvahiWatch *watch)
++{
++ return (watch->watched_fd->occurred);
++}
++
++
++/*
++ * 'compare_watches' - Compare watches for array sorting
++ */
++
++static int
++compare_watches (AvahiWatch *p0,
++ AvahiWatch *p1)
++{
++ if (p0->watched_fd->fd < p1->watched_fd->fd)
++ return (-1);
++
++ return ((p0->watched_fd->fd == p1->watched_fd->fd) ? 0 : 1);
++}
++
++
++/*
++ * 'timeout_cb()' - Run a timed Avahi callback
++ */
++
++static void
++timeout_cb (cupsd_timeout_t *cupsd_timeout, void *userdata)
++{
++ AvahiTimeout *timeout = userdata;
++ (timeout->callback) (timeout, timeout->userdata);
++}
++
++
++/*
++ * 'timeout_new' - Set a wakeup time
++ */
++
++static AvahiTimeout *
++timeout_new (const AvahiPoll *api,
++ const struct timeval *tv,
++ AvahiTimeoutCallback callback,
++ void *userdata)
++{
++ AvahiTimeout *timeout;
++ AvahiCupsPoll *cups_poll = api->userdata;
++
++ timeout = malloc(sizeof(AvahiTimeout));
++ if (timeout == NULL)
++ return (NULL);
++
++ timeout->cups_poll = cups_poll;
++ timeout->callback = callback;
++ timeout->userdata = userdata;
++ timeout->cupsd_timeout = cupsdAddTimeout (tv,
++ (cupsd_timeoutfunc_t)timeout_cb,
++ timeout);
++ cupsArrayAdd (cups_poll->timeouts, timeout);
++ return (timeout);
++}
++
++
++/*
++ * 'timeout_update' - Update the expiration time for a timeout
++ */
++
++static void
++timeout_update (AvahiTimeout *timeout,
++ const struct timeval *tv)
++{
++ cupsdUpdateTimeout (timeout->cupsd_timeout, tv);
++}
++
++
++/*
++ * ' timeout_free' - Free a timeout
++ */
++
++static void
++timeout_free (AvahiTimeout *timeout)
++{
++ cupsArrayRemove (timeout->cups_poll->timeouts, timeout);
++ cupsdRemoveTimeout (timeout->cupsd_timeout);
++ free (timeout);
++}
++
++
++/*
++ * 'compare_watched_fds' - Compare watched file descriptors for array sorting
++ */
++static int
++compare_watched_fds(cupsd_watched_fd_t *p0,
++ cupsd_watched_fd_t *p1)
++{
++ if (p0->fd != p1->fd)
++ return (p0->fd < p1->fd ? -1 : 1);
++
++ if (p0 == p1)
++ return (0);
++
++ return (p0 < p1 ? -1 : 1);
++}
++
++
++/*
++ * 'compare_timeouts' - Compare timeouts for array sorting
++ */
++static int
++compare_timeouts(AvahiTimeout *p0,
++ AvahiTimeout *p1)
++{
++ /*
++ * Just compare pointers to make it a stable sort.
++ */
++
++ if (p0->cupsd_timeout < p1->cupsd_timeout)
++ return (-1);
++ return ((p0->cupsd_timeout == p1->cupsd_timeout) ? 0 : 1);
++}
++
++
++/*
++ * 'avahi_cups_poll_new' - Create a new Avahi main loop object for CUPS
++ */
++
++AvahiCupsPoll *
++avahi_cups_poll_new (void)
++{
++ AvahiCupsPoll *cups_poll = malloc(sizeof(AvahiCupsPoll));
++ if (cups_poll == NULL)
++ return (NULL);
++
++ cups_poll->watched_fds = cupsArrayNew ((cups_array_func_t)compare_watched_fds,
++ NULL);
++ cups_poll->timeouts = cupsArrayNew ((cups_array_func_t)compare_timeouts,
++ NULL);
++
++ cups_poll->api.userdata = cups_poll;
++ cups_poll->api.watch_new = watch_new;
++ cups_poll->api.watch_free = watch_free;
++ cups_poll->api.watch_update = watch_update;
++ cups_poll->api.watch_get_events = watch_get_events;
++
++ cups_poll->api.timeout_new = timeout_new;
++ cups_poll->api.timeout_update = timeout_update;
++ cups_poll->api.timeout_free = timeout_free;
++
++ return (cups_poll);
++}
++
++
++/*
++ * 'avahi_cups_poll_free' - Free an Avahi main loop object for CUPS
++ */
++void
++avahi_cups_poll_free (AvahiCupsPoll *cups_poll)
++{
++ cupsd_watched_fd_t *watched_fd;
++
++ for (watched_fd = (cupsd_watched_fd_t*)cupsArrayFirst(cups_poll->watched_fds);
++ watched_fd;
++ watched_fd = (cupsd_watched_fd_t*)cupsArrayNext(cups_poll->watched_fds)){
++ cupsArrayClear (watched_fd->watches);
++ }
++
++ cupsArrayClear (cups_poll->watched_fds);
++ cupsArrayClear (cups_poll->timeouts);
++}
++
++
++/*
++ * 'avahi_cups_poll_get' - Get the abstract poll API structure
++ */
++
++const AvahiPoll *
++avahi_cups_poll_get (AvahiCupsPoll *cups_poll)
++{
++ return (&cups_poll->api);
++}
++
++
++#endif /* HAVE_AVAHI ... from top of file */
++
++/*
++ * End of "$Id$".
++ */
+diff -up cups-1.4.7/scheduler/avahi.h.avahi-4-poll cups-1.4.7/scheduler/avahi.h
+--- cups-1.4.7/scheduler/avahi.h.avahi-4-poll 2011-06-28 12:54:34.658228283 +0100
++++ cups-1.4.7/scheduler/avahi.h 2011-06-28 12:54:34.658228283 +0100
+@@ -0,0 +1,49 @@
++/*
++ * "$Id$"
++ *
++ * Avahi poll implementation for the CUPS scheduler.
++ *
++ * Copyright (C) 2010 Red Hat, Inc.
++ * Authors:
++ * Tim Waugh
++ *
++ * Distribution and use rights are outlined in the file "LICENSE.txt"
++ * which should have been included with this file. If this file is
++ * file is missing or damaged, see the license at "http://www.cups.org/".
++ */
++
++#include
++
++#ifdef HAVE_AVAHI
++# include
++# include
++#endif /* HAVE_AVAHI */
++
++#ifdef HAVE_AUTHORIZATION_H
++# include
++#endif /* HAVE_AUTHORIZATION_H */
++
++
++#ifdef HAVE_AVAHI
++typedef struct
++{
++ AvahiPoll api;
++ cups_array_t *watched_fds;
++ cups_array_t *timeouts;
++} AvahiCupsPoll;
++#endif /* HAVE_AVAHI */
++
++/*
++ * Prototypes...
++ */
++
++#ifdef HAVE_AVAHI
++extern AvahiCupsPoll * avahi_cups_poll_new(void);
++extern void avahi_cups_poll_free(AvahiCupsPoll *cups_poll);
++extern const AvahiPoll *avahi_cups_poll_get(AvahiCupsPoll *cups_poll);
++#endif /* HAVE_AVAHI */
++
++
++/*
++ * End of "$Id$".
++ */
+diff -up cups-1.4.7/scheduler/Makefile.avahi-4-poll cups-1.4.7/scheduler/Makefile
+--- cups-1.4.7/scheduler/Makefile.avahi-4-poll 2011-06-28 12:54:06.906728322 +0100
++++ cups-1.4.7/scheduler/Makefile 2011-06-28 12:54:34.651228409 +0100
+@@ -17,6 +17,7 @@ include ../Makedefs
+
+ CUPSDOBJS = \
+ auth.o \
++ avahi.o \
+ banners.o \
+ cert.o \
+ classes.o \
diff --git a/cups-avahi-5-services.patch b/cups-avahi-5-services.patch
new file mode 100644
index 0000000..4a80f8c
--- /dev/null
+++ b/cups-avahi-5-services.patch
@@ -0,0 +1,1606 @@
+diff -up cups-1.4.7/cgi-bin/admin.c.avahi-5-services cups-1.4.7/cgi-bin/admin.c
+--- cups-1.4.7/cgi-bin/admin.c.avahi-5-services 2011-03-04 19:28:38.000000000 +0000
++++ cups-1.4.7/cgi-bin/admin.c 2011-06-28 12:54:55.450853624 +0100
+@@ -1643,7 +1643,7 @@ do_config_server(http_t *http) /* I - H
+ else
+ local_protocols[0] = '\0';
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ if (cgiGetVariable("BROWSE_LOCAL_DNSSD"))
+ {
+ if (local_protocols[0])
+@@ -1651,7 +1651,7 @@ do_config_server(http_t *http) /* I - H
+ else
+ strcat(local_protocols, "dnssd");
+ }
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ #ifdef HAVE_LDAP
+ if (cgiGetVariable("BROWSE_LOCAL_LDAP"))
+@@ -2718,9 +2718,9 @@ do_menu(http_t *http) /* I - HTTP conn
+ #endif /* HAVE_GSSAPI */
+ cgiSetVariable("KERBEROS", "");
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ cgiSetVariable("HAVE_DNSSD", "1");
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ #ifdef HAVE_LDAP
+ cgiSetVariable("HAVE_LDAP", "1");
+diff -up cups-1.4.7/scheduler/client.c.avahi-5-services cups-1.4.7/scheduler/client.c
+--- cups-1.4.7/scheduler/client.c.avahi-5-services 2011-01-22 00:07:22.000000000 +0000
++++ cups-1.4.7/scheduler/client.c 2011-06-28 12:54:55.454853552 +0100
+@@ -5095,7 +5095,7 @@ valid_host(cupsd_client_t *con) /* I -
+ !strncmp(host, "[::1]:", 6));
+ }
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ /*
+ * Check if the hostname is something.local (Bonjour); if so, allow it.
+ */
+@@ -5104,7 +5104,7 @@ valid_host(cupsd_client_t *con) /* I -
+ (!strcasecmp(end, ".local") || !strncasecmp(end, ".local:", 7) ||
+ !strcasecmp(end, ".local.") || !strncasecmp(end, ".local.:", 8)))
+ return (1);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ /*
+ * Check if the hostname is an IP address...
+diff -up cups-1.4.7/scheduler/dirsvc.c.avahi-5-services cups-1.4.7/scheduler/dirsvc.c
+--- cups-1.4.7/scheduler/dirsvc.c.avahi-5-services 2011-06-28 12:51:40.386368251 +0100
++++ cups-1.4.7/scheduler/dirsvc.c 2011-06-28 12:54:55.462853408 +0100
+@@ -27,6 +27,7 @@
+ * ldap_connect() - Start new LDAP connection
+ * ldap_reconnect() - Reconnect to LDAP Server
+ * ldap_disconnect() - Disconnect from LDAP Server
++ * cupsdStartAvahiClient() - Start an Avahi client if needed
+ * cupsdStartBrowsing() - Start sending and receiving broadcast
+ * information.
+ * cupsdStartPolling() - Start polling servers as needed.
+@@ -83,6 +84,7 @@
+ */
+
+ #include "cupsd.h"
++#include
+ #include
+
+ #ifdef HAVE_DNSSD
+@@ -97,8 +99,18 @@
+ # endif /* HAVE_SYSTEMCONFIGURATION */
+ # endif /* __APPLE__ */
+ #endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++# include
++#endif /* HAVE_AVAHI */
+
+
++#ifdef HAVE_DNSSD
++typedef char *cupsd_txt_record_t;
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++typedef AvahiStringList *cupsd_txt_record_t;
++#endif /* HAVE_AVAHI */
++
+ /*
+ * Local functions...
+ */
+@@ -159,15 +171,20 @@ static void update_polling(void);
+ static void update_smb(int onoff);
+
+
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++static cupsd_txt_record_t dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p,
++ int for_lpd);
++static void dnssdDeregisterPrinter(cupsd_printer_t *p);
++static int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b);
++static void dnssdRegisterPrinter(cupsd_printer_t *p);
++static void dnssdStop(void);
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
++
+ #ifdef HAVE_DNSSD
+ # ifdef HAVE_COREFOUNDATION
+ static void dnssdAddAlias(const void *key, const void *value,
+ void *context);
+ # endif /* HAVE_COREFOUNDATION */
+-static char *dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p,
+- int for_lpd);
+-static int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b);
+-static void dnssdDeregisterPrinter(cupsd_printer_t *p);
+ static char *dnssdPackTxtRecord(int *txt_len, char *keyvalue[][2],
+ int count);
+ static void dnssdRegisterCallback(DNSServiceRef sdRef,
+@@ -175,11 +192,20 @@ static void dnssdRegisterCallback(DNSSer
+ DNSServiceErrorType errorCode,
+ const char *name, const char *regtype,
+ const char *domain, void *context);
+-static void dnssdRegisterPrinter(cupsd_printer_t *p);
+-static void dnssdStop(void);
+ static void dnssdUpdate(void);
+ #endif /* HAVE_DNSSD */
+
++#ifdef HAVE_AVAHI
++static AvahiStringList *avahiPackTxtRecord(char *keyvalue[][2],
++ int count);
++static void avahi_entry_group_cb (AvahiEntryGroup *group,
++ AvahiEntryGroupState state,
++ void *userdata);
++static void avahi_client_cb (AvahiClient *client,
++ AvahiClientState state,
++ void *userdata);
++#endif /* HAVE_AVAHI */
++
+ #ifdef HAVE_LDAP
+ static const char * const ldap_attrs[] =/* CUPS LDAP attributes */
+ {
+@@ -283,10 +309,10 @@ cupsdDeregisterPrinter(
+ ldap_dereg_printer(p);
+ #endif /* HAVE_LDAP */
+
+-#ifdef HAVE_DNSSD
+- if (removeit && (BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++ if (removeit && (BrowseLocalProtocols & BROWSE_DNSSD))
+ dnssdDeregisterPrinter(p);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+ }
+
+
+@@ -694,10 +720,10 @@ cupsdRegisterPrinter(cupsd_printer_t *p)
+ slpRegisterPrinter(p); */
+ #endif /* HAVE_LIBSLP */
+
+-#ifdef HAVE_DNSSD
+- if ((BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++ if ((BrowseLocalProtocols & BROWSE_DNSSD))
+ dnssdRegisterPrinter(p);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+ }
+
+
+@@ -1411,6 +1437,23 @@ ldap_disconnect(LDAP *ld) /* I - LDAP h
+ }
+ #endif /* HAVE_LDAP */
+
++#ifdef HAVE_AVAHI
++/*
++ * 'cupsdStartAvahiClient()' - Start an Avahi client if needed
++ */
++
++void
++cupsdStartAvahiClient(void) {
++ if (!AvahiCupsClient && !AvahiCupsClientConnecting)
++ {
++ if (!AvahiCupsPollHandle)
++ AvahiCupsPollHandle = avahi_cups_poll_new ();
++ if (AvahiCupsPollHandle)
++ avahi_client_new (avahi_cups_poll_get (AvahiCupsPollHandle),
++ AVAHI_CLIENT_NO_FAIL, avahi_client_cb, NULL, NULL);
++ }
++}
++#endif /* HAVE_AVAHI */
+
+ /*
+ * 'cupsdStartBrowsing()' - Start sending and receiving broadcast information.
+@@ -1535,13 +1578,16 @@ cupsdStartBrowsing(void)
+ else
+ BrowseSocket = -1;
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD)
+ {
++#ifdef HAVE_DNSSD
+ DNSServiceErrorType error; /* Error from service creation */
++#endif /* HAVE_DNSSD */
+ cupsd_listener_t *lis; /* Current listening socket */
+
+
++#ifdef HAVE_DNSSD
+ /*
+ * First create a "master" connection for all registrations...
+ */
+@@ -1566,6 +1612,7 @@ cupsdStartBrowsing(void)
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+
+ cupsdAddSelect(fd, (cupsd_selfunc_t)dnssdUpdate, NULL, NULL);
++#endif /* HAVE_DNSSD */
+
+ /*
+ * Then get the port we use for registrations. If we are not listening
+@@ -1607,9 +1654,16 @@ cupsdStartBrowsing(void)
+ */
+
+ cupsdUpdateDNSSDName();
++#ifdef HAVE_DNSSD
+ }
+- }
+ #endif /* HAVE_DNSSD */
++ }
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
++
++#ifdef HAVE_AVAHI
++ if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD)
++ cupsdStartAvahiClient();
++#endif /* HAVE_AVAHI */
+
+ #ifdef HAVE_LIBSLP
+ if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP)
+@@ -1835,10 +1889,10 @@ cupsdStopBrowsing(void)
+ BrowseSocket = -1;
+ }
+
+-#ifdef HAVE_DNSSD
+- if ((BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++ if ((BrowseLocalProtocols & BROWSE_DNSSD))
+ dnssdStop();
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ #ifdef HAVE_LIBSLP
+ if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) &&
+@@ -1903,7 +1957,7 @@ cupsdStopPolling(void)
+ }
+
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ /*
+ * 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing...
+ */
+@@ -1911,7 +1965,12 @@ cupsdStopPolling(void)
+ void
+ cupsdUpdateDNSSDName(void)
+ {
++#ifdef HAVE_DNSSD
+ DNSServiceErrorType error; /* Error from service creation */
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ int ret; /* Error from service creation */
++#endif /* HAVE_AVAHI */
+ char webif[1024]; /* Web interface share name */
+ #ifdef HAVE_COREFOUNDATION_H
+ SCDynamicStoreRef sc; /* Context for dynamic store */
+@@ -2043,6 +2102,7 @@ cupsdUpdateDNSSDName(void)
+ else
+ strlcpy(webif, "CUPS Web Interface", sizeof(webif));
+
++#ifdef HAVE_DNSSD
+ if (WebIFRef)
+ DNSServiceRefDeallocate(WebIFRef);
+
+@@ -2055,6 +2115,42 @@ cupsdUpdateDNSSDName(void)
+ NULL)) != kDNSServiceErr_NoError)
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "DNS-SD web interface registration failed: %d", error);
++#endif /* HAVE_DNSSD */
++
++#ifdef HAVE_AVAHI
++ if (!AvahiCupsClient)
++ /*
++ * Client not yet running.
++ */
++ return;
++
++ if (AvahiWebIFGroup)
++ avahi_entry_group_reset (AvahiWebIFGroup);
++ else
++ AvahiWebIFGroup = avahi_entry_group_new (AvahiCupsClient,
++ avahi_entry_group_cb,
++ NULL);
++
++ if (AvahiWebIFGroup)
++ {
++ ret = avahi_entry_group_add_service (AvahiWebIFGroup,
++ AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ 0, /* flags */
++ webif, /* name */
++ "_http._tcp", /* type */
++ NULL, /* domain */
++ NULL, /* host */
++ DNSSDPort, /* port */
++ "path=/", NULL);
++ if (ret == 0)
++ ret = avahi_entry_group_commit (AvahiWebIFGroup);
++
++ if (ret != 0)
++ cupsdLogMessage (CUPSD_LOG_ERROR,
++ "Avahi web interface registration failed: %d", ret);
++ }
++#endif /* HAVE_AVAHI */
+ }
+ }
+ #endif /* HAVE_DNSSD */
+@@ -2300,162 +2396,7 @@ dequote(char *d, /* I - Destinat
+ }
+
+
+-#ifdef HAVE_DNSSD
+-# ifdef HAVE_COREFOUNDATION
+-/*
+- * 'dnssdAddAlias()' - Add a DNS-SD alias name.
+- */
+-
+-static void
+-dnssdAddAlias(const void *key, /* I - Key */
+- const void *value, /* I - Value (domain) */
+- void *context) /* I - Unused */
+-{
+- char valueStr[1024], /* Domain string */
+- hostname[1024]; /* Complete hostname */
+-
+-
+- (void)context;
+-
+- if (CFGetTypeID((CFStringRef)value) == CFStringGetTypeID() &&
+- CFStringGetCString((CFStringRef)value, valueStr, sizeof(valueStr),
+- kCFStringEncodingUTF8))
+- {
+- snprintf(hostname, sizeof(hostname), "%s.%s", DNSSDHostName, valueStr);
+- if (!DNSSDAlias)
+- DNSSDAlias = cupsArrayNew(NULL, NULL);
+-
+- cupsdAddAlias(DNSSDAlias, hostname);
+- cupsdLogMessage(CUPSD_LOG_DEBUG, "Added Back to My Mac ServerAlias %s",
+- hostname);
+- }
+- else
+- cupsdLogMessage(CUPSD_LOG_ERROR,
+- "Bad Back to My Mac domain in dynamic store!");
+-}
+-# endif /* HAVE_COREFOUNDATION */
+-
+-
+-/*
+- * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info.
+- */
+-
+-static char * /* O - TXT record */
+-dnssdBuildTxtRecord(
+- int *txt_len, /* O - TXT record length */
+- cupsd_printer_t *p, /* I - Printer information */
+- int for_lpd) /* I - 1 = LPD, 0 = IPP */
+-{
+- int i; /* Looping var */
+- char adminurl_str[256], /* URL for th admin page */
+- type_str[32], /* Type to string buffer */
+- state_str[32], /* State to string buffer */
+- rp_str[1024], /* Queue name string buffer */
+- air_str[1024], /* auth-info-required string buffer */
+- *keyvalue[32][2]; /* Table of key/value pairs */
+-
+-
+- /*
+- * Load up the key value pairs...
+- */
+-
+- i = 0;
+-
+- keyvalue[i ][0] = "txtvers";
+- keyvalue[i++][1] = "1";
+-
+- keyvalue[i ][0] = "qtotal";
+- keyvalue[i++][1] = "1";
+-
+- keyvalue[i ][0] = "rp";
+- keyvalue[i++][1] = rp_str;
+- if (for_lpd)
+- strlcpy(rp_str, p->name, sizeof(rp_str));
+- else
+- snprintf(rp_str, sizeof(rp_str), "%s/%s",
+- (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers", p->name);
+-
+- keyvalue[i ][0] = "ty";
+- keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown";
+-
+- httpAssembleURIf(HTTP_URI_CODING_ALL, adminurl_str, sizeof(adminurl_str),
+- "http", NULL, DNSSDHostName, DNSSDPort, "/%s/%s",
+- (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
+- p->name);
+- keyvalue[i ][0] = "adminurl";
+- keyvalue[i++][1] = adminurl_str;
+-
+- keyvalue[i ][0] = "note";
+- keyvalue[i++][1] = p->location ? p->location : "";
+-
+- keyvalue[i ][0] = "priority";
+- keyvalue[i++][1] = for_lpd ? "100" : "0";
+-
+- keyvalue[i ][0] = "product";
+- keyvalue[i++][1] = p->product ? p->product : "Unknown";
+-
+- snprintf(type_str, sizeof(type_str), "0x%X", p->type | CUPS_PRINTER_REMOTE);
+- snprintf(state_str, sizeof(state_str), "%d", p->state);
+-
+- keyvalue[i ][0] = "printer-state";
+- keyvalue[i++][1] = state_str;
+-
+- keyvalue[i ][0] = "printer-type";
+- keyvalue[i++][1] = type_str;
+-
+- keyvalue[i ][0] = "Transparent";
+- keyvalue[i++][1] = "T";
+-
+- keyvalue[i ][0] = "Binary";
+- keyvalue[i++][1] = "T";
+-
+- keyvalue[i ][0] = "Fax";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_FAX) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Color";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLOR) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Duplex";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_DUPLEX) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Staple";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_STAPLE) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Copies";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_COPIES) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Collate";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLLATE) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Punch";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_PUNCH) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Bind";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_BIND) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Sort";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_SORT) ? "T" : "F";
+-
+- keyvalue[i ][0] = "Scan";
+- keyvalue[i++][1] = (p->type & CUPS_PRINTER_MFP) ? "T" : "F";
+-
+- keyvalue[i ][0] = "pdl";
+- keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
+-
+- if (get_auth_info_required(p, air_str, sizeof(air_str)))
+- {
+- keyvalue[i ][0] = "air";
+- keyvalue[i++][1] = air_str;
+- }
+-
+- /*
+- * Then pack them into a proper txt record...
+- */
+-
+- return (dnssdPackTxtRecord(txt_len, keyvalue, i));
+-}
+-
+-
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ /*
+ * 'dnssdComparePrinters()' - Compare the registered names of two printers.
+ */
+@@ -2464,7 +2405,16 @@ static int /* O - Result of compariso
+ dnssdComparePrinters(cupsd_printer_t *a,/* I - First printer */
+ cupsd_printer_t *b)/* I - Second printer */
+ {
+- return (strcasecmp(a->reg_name, b->reg_name));
++ if (!a->reg_name)
++ if (!b->reg_name)
++ return 0;
++ else
++ return -1;
++ else
++ if (!b->reg_name)
++ return 1;
++ else
++ return (strcasecmp(a->reg_name, b->reg_name));
+ }
+
+
+@@ -2479,6 +2429,10 @@ dnssdDeregisterPrinter(
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name);
+
++#ifdef HAVE_DNSSD
++ if (!DNSSDRef)
++ return;
++
+ /*
+ * Closing the socket deregisters the service
+ */
+@@ -2514,6 +2468,23 @@ dnssdDeregisterPrinter(
+ free(p->printer_txt);
+ p->printer_txt = NULL;
+ }
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ if (p->avahi_group)
++ {
++ avahi_entry_group_reset (p->avahi_group);
++ avahi_entry_group_free (p->avahi_group);
++ p->avahi_group = NULL;
++
++ if (p->ipp_txt)
++ avahi_string_list_free (p->ipp_txt);
++
++ if (p->printer_txt)
++ avahi_string_list_free (p->printer_txt);
++
++ p->ipp_txt = p->printer_txt = NULL;
++ }
++#endif /* HAVE_AVAHI */
+
+ /*
+ * Remove the printer from the array of DNS-SD printers, then clear the
+@@ -2526,136 +2497,47 @@ dnssdDeregisterPrinter(
+
+
+ /*
+- * 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the
+- * TXT record format.
++ * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer
++ * or update the broadcast contents.
+ */
+
+-static char * /* O - TXT record */
+-dnssdPackTxtRecord(int *txt_len, /* O - TXT record length */
+- char *keyvalue[][2], /* I - Table of key value pairs */
+- int count) /* I - Items in table */
++static void
++dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
+ {
+- int i; /* Looping var */
+- int length; /* Length of TXT record */
+- int length2; /* Length of value */
+- char *txtRecord; /* TXT record buffer */
+- char *cursor; /* Looping pointer */
++#ifdef HAVE_DNSSD
++ DNSServiceErrorType se; /* dnssd errors */
++ char *ipp_txt, /* IPP TXT record buffer */
++ *printer_txt; /* LPD TXT record buffer */
++ int ipp_len, /* IPP TXT record length */
++ printer_len; /* LPD TXT record length */
++ char name[1024]; /* Service name */
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ int ret; /* Error code */
++ AvahiStringList *ipp_txt, /* IPP TXT record list */
++ *printer_txt; /* LPD TXT record buffer */
++ char name[AVAHI_LABEL_MAX]; /* Service name */
++#endif /* HAVE_AVAHI */
++ const char *regtype; /* Registration type */
++ char *nameptr; /* Pointer into name */
+
+
+- /*
+- * Calculate the buffer size
+- */
++#ifdef HAVE_DNSSD
++ if (!DNSSDRef)
++ return;
+
+- if (count <= 0)
+- return (NULL);
++ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
++ !p->ipp_ref ? "new" : "update");
+
+- for (length = i = 0; i < count; i++)
+- length += 1 + strlen(keyvalue[i][0]) +
+- (keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0);
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
++ !p->avahi_group ? "new" : "update");
++#endif /* HAVE_AVAHI */
+
+ /*
+- * Allocate and fill it
+- */
+-
+- txtRecord = malloc(length);
+- if (txtRecord)
+- {
+- *txt_len = length;
+-
+- for (cursor = txtRecord, i = 0; i < count; i++)
+- {
+- /*
+- * Drop in the p-string style length byte followed by the data
+- */
+-
+- length = strlen(keyvalue[i][0]);
+- length2 = keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0;
+-
+- *cursor++ = (unsigned char)(length + length2);
+-
+- memcpy(cursor, keyvalue[i][0], length);
+- cursor += length;
+-
+- if (length2)
+- {
+- length2 --;
+- *cursor++ = '=';
+- memcpy(cursor, keyvalue[i][1], length2);
+- cursor += length2;
+- }
+- }
+- }
+-
+- return (txtRecord);
+-}
+-
+-
+-/*
+- * 'dnssdRegisterCallback()' - DNSServiceRegister callback.
+- */
+-
+-static void
+-dnssdRegisterCallback(
+- DNSServiceRef sdRef, /* I - DNS Service reference */
+- DNSServiceFlags flags, /* I - Reserved for future use */
+- DNSServiceErrorType errorCode, /* I - Error code */
+- const char *name, /* I - Service name */
+- const char *regtype, /* I - Service type */
+- const char *domain, /* I - Domain. ".local" for now */
+- void *context) /* I - User-defined context */
+-{
+- cupsd_printer_t *p = (cupsd_printer_t *)context;
+- /* Current printer */
+-
+-
+- cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterCallback(%s, %s) for %s (%s)",
+- name, regtype, p ? p->name : "Web Interface",
+- p ? (p->reg_name ? p->reg_name : "(null)") : "NA");
+-
+- if (errorCode)
+- {
+- cupsdLogMessage(CUPSD_LOG_ERROR,
+- "DNSServiceRegister failed with error %d", (int)errorCode);
+- return;
+- }
+- else if (p && (!p->reg_name || strcasecmp(name, p->reg_name)))
+- {
+- cupsdLogMessage(CUPSD_LOG_INFO, "Using service name \"%s\" for \"%s\"",
+- name, p->name);
+-
+- cupsArrayRemove(DNSSDPrinters, p);
+- cupsdSetString(&p->reg_name, name);
+- cupsArrayAdd(DNSSDPrinters, p);
+-
+- LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED;
+- }
+-}
+-
+-
+-/*
+- * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer
+- * or update the broadcast contents.
+- */
+-
+-static void
+-dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
+-{
+- DNSServiceErrorType se; /* dnssd errors */
+- char *ipp_txt, /* IPP TXT record buffer */
+- *printer_txt, /* LPD TXT record buffer */
+- name[1024], /* Service name */
+- *nameptr; /* Pointer into name */
+- int ipp_len, /* IPP TXT record length */
+- printer_len; /* LPD TXT record length */
+- const char *regtype; /* Registration type */
+-
+-
+- cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
+- !p->ipp_ref ? "new" : "update");
+-
+- /*
+- * If per-printer sharing was just disabled make sure we're not
+- * registered before returning.
++ * If per-printer sharing was just disabled make sure we're not
++ * registered before returning.
+ */
+
+ if (!p->shared)
+@@ -2671,12 +2553,36 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
+ if (p->info && strlen(p->info) > 0)
+ {
+ if (DNSSDComputerName)
+- snprintf(name, sizeof(name), "%s @ %s", p->info, DNSSDComputerName);
++ {
++ /*
++ * Make sure there is room for at least 15 characters of
++ * DNSSDComputerName.
++ */
++
++ assert(sizeof(name) >= 15 + 4);
++ nameptr = name + strlcpy(name, p->info,
++ sizeof(name) - 4 -
++ strnlen(DNSSDComputerName, 15));
++ nameptr += strlcpy(nameptr, " @ ", sizeof(name) - (nameptr - name));
++ strlcpy(nameptr, DNSSDComputerName, sizeof(name) - (nameptr - name));
++ }
+ else
+ strlcpy(name, p->info, sizeof(name));
+ }
+ else if (DNSSDComputerName)
+- snprintf(name, sizeof(name), "%s @ %s", p->name, DNSSDComputerName);
++ {
++ /*
++ * Make sure there is room for at least 15 characters of
++ * DNSSDComputerName.
++ */
++
++ assert(sizeof(name) >= 15 + 4);
++ nameptr = name + strlcpy(name, p->info,
++ sizeof(name) - 4 -
++ strnlen(DNSSDComputerName, 15));
++ nameptr += strlcpy(nameptr, " @ ", sizeof(name) - (nameptr - name));
++ strlcpy(nameptr, DNSSDComputerName, sizeof(name) - (nameptr - name));
++ }
+ else
+ strlcpy(name, p->name, sizeof(name));
+
+@@ -2697,6 +2603,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
+ * Register IPP and (optionally) LPD...
+ */
+
++#ifdef HAVE_DNSSD
+ ipp_len = 0; /* anti-compiler-warning-code */
+ ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0);
+
+@@ -2863,6 +2770,149 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
+ if (printer_txt)
+ free(printer_txt);
+ }
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ if (!AvahiCupsClient)
++ /*
++ * Client not running yet. The client callback will call us again later.
++ */
++ return;
++
++ ipp_txt = dnssdBuildTxtRecord(NULL, p, 0);
++ printer_txt = dnssdBuildTxtRecord(NULL, p, 1);
++ regtype = (p->type & CUPS_PRINTER_FAX) ? "_fax-ipp._tcp" : "_ipp._tcp";
++
++ if (p->avahi_group && p->ipp_txt && ipp_txt &&
++ !avahi_string_list_equal (p->ipp_txt, ipp_txt))
++ {
++ /*
++ * Update the existing registration...
++ */
++
++ avahi_string_list_free (p->ipp_txt);
++
++ if (p->printer_txt)
++ avahi_string_list_free (p->printer_txt);
++
++ ret = avahi_entry_group_update_service_txt_strlst (p->avahi_group,
++ AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ 0, name, regtype, NULL,
++ ipp_txt);
++ if (ret < 0)
++ goto update_failed;
++
++ p->ipp_txt = ipp_txt;
++ ipp_txt = NULL;
++
++ if (BrowseLocalProtocols & BROWSE_LPD)
++ {
++ ret = avahi_entry_group_update_service_txt_strlst (p->avahi_group,
++ AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ 0, name,
++ "_printer._tcp", NULL,
++ printer_txt);
++
++ if (ret < 0)
++ goto update_failed;
++
++ p->printer_txt = printer_txt;
++ printer_txt = NULL;
++ }
++
++ ret = avahi_entry_group_commit (p->avahi_group);
++ if (ret < 0)
++ {
++ update_failed:
++ cupsdLogMessage (CUPSD_LOG_ERROR,
++ "Failed to update TXT record for %s: %d",
++ name, ret);
++ avahi_entry_group_reset (p->avahi_group);
++ avahi_entry_group_free (p->avahi_group);
++ p->avahi_group = NULL;
++ ipp_txt = p->ipp_txt;
++ p->ipp_txt = NULL;
++ }
++ }
++
++ if (!p->avahi_group)
++ {
++ /*
++ * Initial registration. Use the _fax subtype for fax queues...
++ */
++
++ p->avahi_group = avahi_entry_group_new (AvahiCupsClient,
++ avahi_entry_group_cb,
++ p);
++
++ cupsdLogMessage(CUPSD_LOG_DEBUG,
++ "Registering Avahi printer %s with name \"%s\" and "
++ "type \"%s\"", p->name, name, regtype);
++
++ if (!p->avahi_group)
++ {
++ ret = 0;
++ goto add_failed;
++ }
++
++ ret = avahi_entry_group_add_service_strlst (p->avahi_group,
++ AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ 0, name, regtype, NULL, NULL,
++ DNSSDPort,
++ ipp_txt);
++ if (ret < 0)
++ goto add_failed;
++
++ p->ipp_txt = ipp_txt;
++ ipp_txt = NULL;
++
++ if (BrowseLocalProtocols & BROWSE_LPD)
++ {
++ cupsdLogMessage(CUPSD_LOG_DEBUG,
++ "Registering Avahi printer %s with name \"%s\" and "
++ "type \"_printer._tcp\"", p->name, name);
++
++ ret = avahi_entry_group_add_service_strlst (p->avahi_group,
++ AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ 0, name,
++ "_printer._tcp", NULL, NULL,
++ 515,
++ printer_txt);
++ if (ret < 0)
++ goto add_failed;
++
++ p->printer_txt = printer_txt;
++ printer_txt = NULL;
++ }
++
++ ret = avahi_entry_group_commit (p->avahi_group);
++
++ if (ret < 0)
++ {
++ add_failed:
++ cupsdLogMessage (CUPSD_LOG_ERROR,
++ "Failed to add Avahi entry for %s: %d",
++ name, ret);
++ if (p->avahi_group)
++ {
++ avahi_entry_group_reset (p->avahi_group);
++ avahi_entry_group_free (p->avahi_group);
++ p->avahi_group = NULL;
++ }
++ ipp_txt = p->ipp_txt;
++ p->ipp_txt = NULL;
++ }
++ }
++
++ if (ipp_txt)
++ avahi_string_list_free (ipp_txt);
++
++ if (printer_txt)
++ avahi_string_list_free (printer_txt);
++#endif /* HAVE_AVAHI */
+ }
+
+
+@@ -2875,6 +2925,10 @@ dnssdStop(void)
+ {
+ cupsd_printer_t *p; /* Current printer */
+
++#ifdef HAVE_DNSSD
++ if (!DNSSDRef)
++ return;
++#endif /* HAVE_DNSSD */
+
+ /*
+ * De-register the individual printers
+@@ -2885,6 +2939,7 @@ dnssdStop(void)
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ dnssdDeregisterPrinter(p);
+
++#ifdef HAVE_DNSSD
+ /*
+ * Shutdown the rest of the service refs...
+ */
+@@ -2905,6 +2960,7 @@ dnssdStop(void)
+
+ DNSServiceRefDeallocate(DNSSDRef);
+ DNSSDRef = NULL;
++#endif /* HAVE_DNSSD */
+
+ cupsArrayDelete(DNSSDPrinters);
+ DNSSDPrinters = NULL;
+@@ -2914,6 +2970,275 @@ dnssdStop(void)
+
+
+ /*
++ * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info.
++ */
++
++static cupsd_txt_record_t /* O - TXT record */
++dnssdBuildTxtRecord(
++ int *txt_len, /* O - TXT record length */
++ cupsd_printer_t *p, /* I - Printer information */
++ int for_lpd) /* I - 1 = LPD, 0 = IPP */
++{
++ int i; /* Looping var */
++ char adminurl_str[256], /* URL for th admin page */
++ type_str[32], /* Type to string buffer */
++ state_str[32], /* State to string buffer */
++ rp_str[1024], /* Queue name string buffer */
++ air_str[1024], /* auth-info-required string buffer */
++ *keyvalue[32][2]; /* Table of key/value pairs */
++
++
++ /*
++ * Load up the key value pairs...
++ */
++
++ i = 0;
++
++ keyvalue[i ][0] = "txtvers";
++ keyvalue[i++][1] = "1";
++
++ keyvalue[i ][0] = "qtotal";
++ keyvalue[i++][1] = "1";
++
++ keyvalue[i ][0] = "rp";
++ keyvalue[i++][1] = rp_str;
++ if (for_lpd)
++ strlcpy(rp_str, p->name, sizeof(rp_str));
++ else
++ snprintf(rp_str, sizeof(rp_str), "%s/%s",
++ (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers", p->name);
++
++ keyvalue[i ][0] = "ty";
++ keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown";
++
++ httpAssembleURIf(HTTP_URI_CODING_ALL, adminurl_str, sizeof(adminurl_str),
++ "http", NULL, DNSSDHostName, DNSSDPort, "/%s/%s",
++ (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
++ p->name);
++ keyvalue[i ][0] = "adminurl";
++ keyvalue[i++][1] = adminurl_str;
++
++ keyvalue[i ][0] = "note";
++ keyvalue[i++][1] = p->location ? p->location : "";
++
++ keyvalue[i ][0] = "priority";
++ keyvalue[i++][1] = for_lpd ? "100" : "0";
++
++ keyvalue[i ][0] = "product";
++ keyvalue[i++][1] = p->product ? p->product : "Unknown";
++
++ snprintf(type_str, sizeof(type_str), "0x%X", p->type | CUPS_PRINTER_REMOTE);
++ snprintf(state_str, sizeof(state_str), "%d", p->state);
++
++ keyvalue[i ][0] = "printer-state";
++ keyvalue[i++][1] = state_str;
++
++ keyvalue[i ][0] = "printer-type";
++ keyvalue[i++][1] = type_str;
++
++ keyvalue[i ][0] = "Transparent";
++ keyvalue[i++][1] = "T";
++
++ keyvalue[i ][0] = "Binary";
++ keyvalue[i++][1] = "T";
++
++ keyvalue[i ][0] = "Fax";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_FAX) ? "T" : "F";
++
++ keyvalue[i ][0] = "Color";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLOR) ? "T" : "F";
++
++ keyvalue[i ][0] = "Duplex";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_DUPLEX) ? "T" : "F";
++
++ keyvalue[i ][0] = "Staple";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_STAPLE) ? "T" : "F";
++
++ keyvalue[i ][0] = "Copies";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_COPIES) ? "T" : "F";
++
++ keyvalue[i ][0] = "Collate";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLLATE) ? "T" : "F";
++
++ keyvalue[i ][0] = "Punch";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_PUNCH) ? "T" : "F";
++
++ keyvalue[i ][0] = "Bind";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_BIND) ? "T" : "F";
++
++ keyvalue[i ][0] = "Sort";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_SORT) ? "T" : "F";
++
++ keyvalue[i ][0] = "Scan";
++ keyvalue[i++][1] = (p->type & CUPS_PRINTER_MFP) ? "T" : "F";
++
++ keyvalue[i ][0] = "pdl";
++ keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
++
++ if (get_auth_info_required(p, air_str, sizeof(air_str)))
++ {
++ keyvalue[i ][0] = "air";
++ keyvalue[i++][1] = air_str;
++ }
++
++ /*
++ * Then pack them into a proper txt record...
++ */
++
++#ifdef HAVE_DNSSD
++ return (dnssdPackTxtRecord(txt_len, keyvalue, i));
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ return (avahiPackTxtRecord(keyvalue, i));
++#endif /* HAVE_AVAHI */
++}
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
++
++
++#ifdef HAVE_DNSSD
++# ifdef HAVE_COREFOUNDATION
++/*
++ * 'dnssdAddAlias()' - Add a DNS-SD alias name.
++ */
++
++static void
++dnssdAddAlias(const void *key, /* I - Key */
++ const void *value, /* I - Value (domain) */
++ void *context) /* I - Unused */
++{
++ char valueStr[1024], /* Domain string */
++ hostname[1024]; /* Complete hostname */
++
++
++ (void)context;
++
++ if (CFGetTypeID((CFStringRef)value) == CFStringGetTypeID() &&
++ CFStringGetCString((CFStringRef)value, valueStr, sizeof(valueStr),
++ kCFStringEncodingUTF8))
++ {
++ snprintf(hostname, sizeof(hostname), "%s.%s", DNSSDHostName, valueStr);
++ if (!DNSSDAlias)
++ DNSSDAlias = cupsArrayNew(NULL, NULL);
++
++ cupsdAddAlias(DNSSDAlias, hostname);
++ cupsdLogMessage(CUPSD_LOG_DEBUG, "Added Back to My Mac ServerAlias %s",
++ hostname);
++ }
++ else
++ cupsdLogMessage(CUPSD_LOG_ERROR,
++ "Bad Back to My Mac domain in dynamic store!");
++}
++# endif /* HAVE_COREFOUNDATION */
++
++
++/*
++ * 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the
++ * TXT record format.
++ */
++
++static char * /* O - TXT record */
++dnssdPackTxtRecord(int *txt_len, /* O - TXT record length */
++ char *keyvalue[][2], /* I - Table of key value pairs */
++ int count) /* I - Items in table */
++{
++ int i; /* Looping var */
++ int length; /* Length of TXT record */
++ int length2; /* Length of value */
++ char *txtRecord; /* TXT record buffer */
++ char *cursor; /* Looping pointer */
++
++
++ /*
++ * Calculate the buffer size
++ */
++
++ if (count <= 0)
++ return (NULL);
++
++ for (length = i = 0; i < count; i++)
++ length += 1 + strlen(keyvalue[i][0]) +
++ (keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0);
++
++ /*
++ * Allocate and fill it
++ */
++
++ txtRecord = malloc(length);
++ if (txtRecord)
++ {
++ *txt_len = length;
++
++ for (cursor = txtRecord, i = 0; i < count; i++)
++ {
++ /*
++ * Drop in the p-string style length byte followed by the data
++ */
++
++ length = strlen(keyvalue[i][0]);
++ length2 = keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0;
++
++ *cursor++ = (unsigned char)(length + length2);
++
++ memcpy(cursor, keyvalue[i][0], length);
++ cursor += length;
++
++ if (length2)
++ {
++ length2 --;
++ *cursor++ = '=';
++ memcpy(cursor, keyvalue[i][1], length2);
++ cursor += length2;
++ }
++ }
++ }
++
++ return (txtRecord);
++}
++
++
++/*
++ * 'dnssdRegisterCallback()' - DNSServiceRegister callback.
++ */
++
++static void
++dnssdRegisterCallback(
++ DNSServiceRef sdRef, /* I - DNS Service reference */
++ DNSServiceFlags flags, /* I - Reserved for future use */
++ DNSServiceErrorType errorCode, /* I - Error code */
++ const char *name, /* I - Service name */
++ const char *regtype, /* I - Service type */
++ const char *domain, /* I - Domain. ".local" for now */
++ void *context) /* I - User-defined context */
++{
++ cupsd_printer_t *p = (cupsd_printer_t *)context;
++ /* Current printer */
++
++
++ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterCallback(%s, %s) for %s (%s)",
++ name, regtype, p ? p->name : "Web Interface",
++ p ? (p->reg_name ? p->reg_name : "(null)") : "NA");
++
++ if (errorCode)
++ {
++ cupsdLogMessage(CUPSD_LOG_ERROR,
++ "DNSServiceRegister failed with error %d", (int)errorCode);
++ return;
++ }
++ else if (p && (!p->reg_name || strcasecmp(name, p->reg_name)))
++ {
++ cupsdLogMessage(CUPSD_LOG_INFO, "Using service name \"%s\" for \"%s\"",
++ name, p->name);
++
++ cupsArrayRemove(DNSSDPrinters, p);
++ cupsdSetString(&p->reg_name, name);
++ cupsArrayAdd(DNSSDPrinters, p);
++
++ LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED;
++ }
++}
++
++
++/*
+ * 'dnssdUpdate()' - Handle DNS-SD queries.
+ */
+
+@@ -2934,6 +3259,146 @@ dnssdUpdate(void)
+ #endif /* HAVE_DNSSD */
+
+
++#ifdef HAVE_AVAHI
++/*
++ * 'avahiPackTxtRecord()' - Pack an array of key/value pairs into an
++ * AvahiStringList.
++ */
++
++static AvahiStringList * /* O - new string list */
++avahiPackTxtRecord(char *keyvalue[][2], /* I - Table of key value pairs */
++ int count) /* I - Items in table */
++{
++ AvahiStringList *strlst = NULL;
++ char **elements;
++ size_t len;
++ int i = 0;
++
++ elements = malloc ((1 + count) * sizeof (char *));
++ if (!elements)
++ goto cleanup;
++
++ for (i = 0; i < count; i++)
++ {
++ len = (1 + strlen (keyvalue[i][0]) +
++ (keyvalue[i][1] ? 1 + strlen (keyvalue[i][1]) : 1));
++ elements[i] = malloc (len * sizeof (char));
++ if (!elements[i])
++ goto cleanup;
++
++ snprintf (elements[i], len, "%s=%s", keyvalue[i][0], keyvalue[i][1]);
++ }
++
++ strlst = avahi_string_list_new_from_array ((const char **) elements, count);
++
++cleanup:
++ while (--i >= 0)
++ free (elements[i]);
++
++ free (elements);
++ return (strlst);
++}
++
++
++/*
++ * 'avahi_entry_group_cb()' - Avahi entry group callback function.
++ */
++static void
++avahi_entry_group_cb (AvahiEntryGroup *group,
++ AvahiEntryGroupState state,
++ void *userdata)
++{
++ char *name;
++
++ if (userdata)
++ name = ((cupsd_printer_t *) userdata)->reg_name;
++ else
++ name = "CUPS web interface";
++
++ switch (state)
++ {
++ case AVAHI_ENTRY_GROUP_UNCOMMITED:
++ case AVAHI_ENTRY_GROUP_REGISTERING:
++ break;
++
++ case AVAHI_ENTRY_GROUP_ESTABLISHED:
++ cupsdLogMessage (CUPSD_LOG_DEBUG,
++ "Avahi entry group established for %s", name);
++ break;
++
++ default:
++ cupsdLogMessage (CUPSD_LOG_DEBUG,
++ "Avahi entry group %s has state %d",
++ name, state);
++ break;
++ }
++}
++
++/*
++ * 'avahi_client_cb()' - Avahi client callback function.
++ */
++static void
++avahi_client_cb (AvahiClient *client,
++ AvahiClientState state,
++ void *userdata)
++{
++ cupsd_printer_t *printer;
++ switch (state)
++ {
++ case AVAHI_CLIENT_S_RUNNING:
++ /*
++ * Avahi client started successfully.
++ */
++ AvahiCupsClient = client;
++ AvahiCupsClientConnecting = 0;
++ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client started");
++
++ cupsdUpdateDNSSDName ();
++
++ for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers);
++ printer;
++ printer = (cupsd_printer_t *)cupsArrayNext(Printers))
++ if (Browsing && (BrowseLocalProtocols & BROWSE_DNSSD) &&
++ (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT |
++ CUPS_PRINTER_SCANNER))) && printer->shared)
++ dnssdRegisterPrinter (printer);
++
++ break;
++
++ case AVAHI_CLIENT_CONNECTING:
++ /*
++ * No Avahi daemon, client is waiting.
++ */
++ AvahiCupsClientConnecting = 1;
++ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client connecting");
++ break;
++
++ case AVAHI_CLIENT_FAILURE:
++ /*
++ * Avahi client failed, close it to allow a clean restart.
++ */
++ cupsdLogMessage (CUPSD_LOG_ERROR,
++ "Avahi client failed, "
++ "closing client to allow a clean restart");
++
++ for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers);
++ printer;
++ printer = (cupsd_printer_t *)cupsArrayNext(Printers))
++ dnssdDeregisterPrinter (printer);
++
++ avahi_client_free(client);
++ AvahiCupsClientConnecting = 0;
++ AvahiCupsClient = NULL;
++
++ break;
++
++ default:
++ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client state: %d", state);
++ }
++}
++#endif /* HAVE_AVAHI */
++
++
+ /*
+ * 'get_auth_info_required()' - Get the auth-info-required value to advertise.
+ */
+diff -up cups-1.4.7/scheduler/dirsvc.h.avahi-5-services cups-1.4.7/scheduler/dirsvc.h
+--- cups-1.4.7/scheduler/dirsvc.h.avahi-5-services 2009-05-14 18:54:37.000000000 +0100
++++ cups-1.4.7/scheduler/dirsvc.h 2011-06-28 12:54:55.464853372 +0100
+@@ -32,6 +32,10 @@
+ # endif /* HAVE_LDAP_SSL_H */
+ #endif /* HAVE_LDAP */
+
++#ifdef HAVE_AVAHI
++# include
++#endif /* HAVE_AVAHI */
++
+ /*
+ * Browse protocols...
+ */
+@@ -132,17 +136,20 @@ VAR int PollPipe VALUE(0);
+ VAR cupsd_statbuf_t *PollStatusBuffer VALUE(NULL);
+ /* Status buffer for pollers */
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++VAR int DNSSDPort VALUE(0);
++ /* Port number to register */
+ VAR char *DNSSDComputerName VALUE(NULL),
+ /* Computer/server name */
+ *DNSSDHostName VALUE(NULL);
+ /* Hostname */
+-VAR cups_array_t *DNSSDAlias VALUE(NULL);
+- /* List of dynamic ServerAlias's */
+-VAR int DNSSDPort VALUE(0);
+- /* Port number to register */
+ VAR cups_array_t *DNSSDPrinters VALUE(NULL);
+ /* Printers we have registered */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
++
++#ifdef HAVE_DNSSD
++VAR cups_array_t *DNSSDAlias VALUE(NULL);
++ /* List of dynamic ServerAlias's */
+ VAR DNSServiceRef DNSSDRef VALUE(NULL),
+ /* Master DNS-SD service reference */
+ WebIFRef VALUE(NULL),
+@@ -151,6 +158,17 @@ VAR DNSServiceRef DNSSDRef VALUE(NULL),
+ /* Remote printer browse reference */
+ #endif /* HAVE_DNSSD */
+
++#ifdef HAVE_AVAHI
++VAR AvahiCupsPoll *AvahiCupsPollHandle VALUE(NULL);
++ /* AvahiCupsPoll object */
++VAR AvahiClient *AvahiCupsClient VALUE(NULL);
++ /* AvahiClient object */
++VAR int AvahiCupsClientConnecting VALUE(0);
++ /* AvahiClient object (waiting) */
++VAR AvahiEntryGroup *AvahiWebIFGroup VALUE(NULL);
++ /* Web interface entry group */
++#endif /* HAVE_AVAHI */
++
+ #ifdef HAVE_LIBSLP
+ VAR SLPHandle BrowseSLPHandle VALUE(NULL);
+ /* SLP API handle */
+@@ -194,13 +212,14 @@ extern void cupsdRegisterPrinter(cupsd_p
+ extern void cupsdRestartPolling(void);
+ extern void cupsdSaveRemoteCache(void);
+ extern void cupsdSendBrowseList(void);
++extern void cupsdStartAvahiClient(void);
+ extern void cupsdStartBrowsing(void);
+ extern void cupsdStartPolling(void);
+ extern void cupsdStopBrowsing(void);
+ extern void cupsdStopPolling(void);
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ extern void cupsdUpdateDNSSDName(void);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+ #ifdef HAVE_LDAP
+ extern void cupsdUpdateLDAPBrowse(void);
+ #endif /* HAVE_LDAP */
+diff -up cups-1.4.7/scheduler/ipp.c.avahi-5-services cups-1.4.7/scheduler/ipp.c
+--- cups-1.4.7/scheduler/ipp.c.avahi-5-services 2011-06-28 12:51:40.354368827 +0100
++++ cups-1.4.7/scheduler/ipp.c 2011-06-28 12:54:55.474853192 +0100
+@@ -5597,7 +5597,7 @@ copy_printer_attrs(
+ ippAddDate(con->response, IPP_TAG_PRINTER, "printer-current-time",
+ ippTimeToDate(curtime));
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ if (!ra || cupsArrayFind(ra, "printer-dns-sd-name"))
+ {
+ if (printer->reg_name)
+@@ -5607,7 +5607,7 @@ copy_printer_attrs(
+ ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE,
+ "printer-dns-sd-name", 0);
+ }
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ if (!ra || cupsArrayFind(ra, "printer-error-policy"))
+ ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME,
+diff -up cups-1.4.7/scheduler/main.c.avahi-5-services cups-1.4.7/scheduler/main.c
+--- cups-1.4.7/scheduler/main.c.avahi-5-services 2011-06-28 12:54:06.909728268 +0100
++++ cups-1.4.7/scheduler/main.c 2011-06-28 12:54:55.476853156 +0100
+@@ -135,6 +135,10 @@ main(int argc, /* I - Number of comm
+ cupsd_listener_t *lis; /* Current listener */
+ time_t current_time, /* Current time */
+ activity, /* Client activity timer */
++#ifdef HAVE_AVAHI
++ avahi_client_time, /* Time for next Avahi client
++ check */
++#endif /* HAVE_AVAHI */
+ browse_time, /* Next browse send time */
+ senddoc_time, /* Send-Document time */
+ expire_time, /* Subscription expire time */
+@@ -698,6 +702,9 @@ main(int argc, /* I - Number of comm
+ */
+
+ current_time = time(NULL);
++#ifdef HAVE_AVAHI
++ avahi_client_time = current_time;
++#endif /* HAVE_AVAHI */
+ browse_time = current_time;
+ event_time = current_time;
+ expire_time = current_time;
+@@ -920,6 +927,16 @@ main(int argc, /* I - Number of comm
+ tmo = cupsdNextTimeout (&tmo_delay);
+ if (tmo && tmo_delay == 0)
+ cupsdRunTimeout (tmo);
++
++ /*
++ * Try to restart the Avahi client every 10 seconds if needed...
++ */
++
++ if ((current_time - avahi_client_time) >= 10)
++ {
++ avahi_client_time = current_time;
++ cupsdStartAvahiClient();
++ }
+ #endif /* HAVE_AVAHI */
+
+ #ifndef __APPLE__
+diff -up cups-1.4.7/scheduler/printers.c.avahi-5-services cups-1.4.7/scheduler/printers.c
+--- cups-1.4.7/scheduler/printers.c.avahi-5-services 2011-06-28 12:51:40.272370305 +0100
++++ cups-1.4.7/scheduler/printers.c 2011-06-28 12:54:55.483853030 +0100
+@@ -932,10 +932,10 @@ cupsdDeletePrinter(
+ cupsdClearString(&p->alert);
+ cupsdClearString(&p->alert_description);
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ cupsdClearString(&p->product);
+ cupsdClearString(&p->pdl);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ cupsArrayDelete(p->filetypes);
+
+@@ -1304,9 +1304,9 @@ cupsdLoadAllPrinters(void)
+ {
+ if (value)
+ {
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ p->product = _cupsStrAlloc(value);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+ }
+ else
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+@@ -1720,10 +1720,10 @@ cupsdSaveAllPrinters(void)
+
+ cupsFilePrintf(fp, "Type %d\n", printer->type);
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ if (printer->product)
+ cupsFilePutConf(fp, "Product", printer->product);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ for (ptr = (char *)cupsArrayFirst(printer->filters);
+ ptr;
+@@ -3858,7 +3858,7 @@ add_printer_formats(cupsd_printer_t *p)
+ attr->values[i].string.text = _cupsStrAlloc(mimetype);
+ }
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ {
+ char pdl[1024]; /* Buffer to build pdl list */
+ mime_filter_t *filter; /* MIME filter looping var */
+@@ -3912,7 +3912,7 @@ add_printer_formats(cupsd_printer_t *p)
+
+ cupsdSetString(&p->pdl, pdl);
+ }
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+ }
+
+
+@@ -4979,9 +4979,9 @@ load_ppd(cupsd_printer_t *p) /* I - Pri
+ attr->values[i].string.text = _cupsStrAlloc("bcp");
+ }
+
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+ cupsdSetString(&p->product, ppd->product);
+-#endif /* HAVE_DNSSD */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+
+ if (ppdFindAttr(ppd, "APRemoteQueueID", NULL))
+ p->type |= CUPS_PRINTER_REMOTE;
+diff -up cups-1.4.7/scheduler/printers.h.avahi-5-services cups-1.4.7/scheduler/printers.h
+--- cups-1.4.7/scheduler/printers.h.avahi-5-services 2010-03-30 23:07:33.000000000 +0100
++++ cups-1.4.7/scheduler/printers.h 2011-06-28 12:54:55.484853012 +0100
+@@ -16,6 +16,9 @@
+ #ifdef HAVE_DNSSD
+ # include
+ #endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++# include "avahi.h"
++#endif /* HAVE_AVAHI */
+ #include
+
+
+@@ -99,17 +102,24 @@ typedef struct cupsd_printer_s
+ char *recoverable; /* com.apple.print.recoverable-message */
+ _pwg_t *pwg; /* PWG<->PPD mapping data */
+
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
++ char *reg_name; /* Name used for service registration */
++ char *product, /* PPD Product string */
++ *pdl; /* pdl value for TXT record */
++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
+ #ifdef HAVE_DNSSD
+- char *reg_name, /* Name used for service registration */
+- *product, /* PPD Product string */
+- *pdl, /* pdl value for TXT record */
+- *ipp_txt, /* IPP TXT record contents */
++ char *ipp_txt, /* IPP TXT record contents */
+ *printer_txt; /* LPD TXT record contents */
+ int ipp_len, /* IPP TXT record length */
+ printer_len; /* LPD TXT record length */
+ DNSServiceRef ipp_ref, /* Reference for _ipp._tcp,_cups */
+ printer_ref; /* Reference for _printer._tcp */
+ #endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ AvahiStringList *ipp_txt, /* IPP TXT record */
++ *printer_txt; /* LPD TXT record */
++ AvahiEntryGroup *avahi_group; /* Avahi entry group */
++#endif /* HAVE_AVAHI */
+ } cupsd_printer_t;
+
+
diff --git a/cups-avahi.patch b/cups-avahi.patch
deleted file mode 100644
index 072f889..0000000
--- a/cups-avahi.patch
+++ /dev/null
@@ -1,3447 +0,0 @@
-diff -up cups-1.4.7/backend/dnssd.c.avahi cups-1.4.7/backend/dnssd.c
---- cups-1.4.7/backend/dnssd.c.avahi 2011-06-28 11:55:27.024868568 +0200
-+++ cups-1.4.7/backend/dnssd.c 2011-06-28 11:55:27.033868442 +0200
-@@ -15,14 +15,21 @@
- *
- * Contents:
- *
-+ * next_txt_record() - Get next TXT record from a cups_txt_records_t.
-+ * parse_txt_record_pair() - Read key/value pair in cups_txt_records_t.
- * main() - Browse for printers.
- * browse_callback() - Browse devices.
- * browse_local_callback() - Browse local devices.
- * compare_devices() - Compare two devices.
- * exec_backend() - Execute the backend that corresponds to the
- * resolved service name.
-+ * device_type() - Get DNS-SD type enumeration from string.
- * get_device() - Create or update a device.
- * query_callback() - Process query data.
-+ * avahi_client_callback() - Avahi client callback function.
-+ * avahi_query_callback() - Avahi query callback function.
-+ * avahi_browse_callback() - Avahi browse callback function.
-+ * find_device() - Find a device from its name and domain.
- * sigterm_handler() - Handle termination signals...
- * unquote() - Unquote a name string.
- */
-@@ -33,7 +40,18 @@
-
- #include "backend-private.h"
- #include
--#include
-+#ifdef HAVE_DNSSD
-+# include
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+# include
-+# include
-+# include
-+# include
-+# include
-+# include
-+#define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX
-+#endif /* HAVE_AVAHI */
-
-
- /*
-@@ -52,7 +70,12 @@ typedef enum
-
- typedef struct
- {
-+#ifdef HAVE_DNSSD
- DNSServiceRef ref; /* Service reference for resolve */
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ int resolved; /* Did we resolve the device? */
-+#endif /* HAVE_AVAHI */
- char *name, /* Service name */
- *domain, /* Domain name */
- *fullName, /* Full name */
-@@ -64,6 +87,20 @@ typedef struct
- sent; /* Did we list the device? */
- } cups_device_t;
-
-+typedef struct
-+{
-+ char key[256];
-+ char value[256];
-+
-+#ifdef HAVE_DNSSD
-+ const uint8_t *data;
-+ const uint8_t *datanext;
-+ const uint8_t *dataend;
-+#else /* HAVE_AVAHI */
-+ AvahiStringList *txt;
-+#endif /* HAVE_DNSSD */
-+} cups_txt_records_t;
-+
-
- /*
- * Local globals...
-@@ -77,6 +114,7 @@ static int job_canceled = 0;
- * Local functions...
- */
-
-+#ifdef HAVE_DNSSD
- static void browse_callback(DNSServiceRef sdRef,
- DNSServiceFlags flags,
- uint32_t interfaceIndex,
-@@ -92,12 +130,6 @@ static void browse_local_callback(DNSSe
- const char *regtype,
- const char *replyDomain,
- void *context);
--static int compare_devices(cups_device_t *a, cups_device_t *b);
--static void exec_backend(char **argv);
--static cups_device_t *get_device(cups_array_t *devices,
-- const char *serviceName,
-- const char *regtype,
-- const char *replyDomain);
- static void query_callback(DNSServiceRef sdRef,
- DNSServiceFlags flags,
- uint32_t interfaceIndex,
-@@ -106,9 +138,118 @@ static void query_callback(DNSServiceRe
- uint16_t rrclass, uint16_t rdlen,
- const void *rdata, uint32_t ttl,
- void *context);
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+static void avahi_client_callback (AvahiClient *client,
-+ AvahiClientState state,
-+ void *context);
-+static void avahi_browse_callback (AvahiServiceBrowser *browser,
-+ AvahiIfIndex interface,
-+ AvahiProtocol protocol,
-+ AvahiBrowserEvent event,
-+ const char *serviceName,
-+ const char *regtype,
-+ const char *replyDomain,
-+ AvahiLookupResultFlags flags,
-+ void *context);
-+#endif /* HAVE_AVAHI */
-+
-+static cups_device_t * find_device (cups_array_t *devices,
-+ cups_txt_records_t *txt,
-+ cups_device_t *dkey);
-+static int compare_devices(cups_device_t *a, cups_device_t *b);
-+static void exec_backend(char **argv);
-+static cups_device_t *get_device(cups_array_t *devices,
-+ const char *serviceName,
-+ const char *regtype,
-+ const char *replyDomain);
- static void sigterm_handler(int sig);
- static void unquote(char *dst, const char *src, size_t dstsize);
-
-+#ifdef HAVE_AVAHI
-+static AvahiSimplePoll *simple_poll = NULL;
-+static int avahi_got_callback;
-+#endif /* HAVE_AVAHI */
-+
-+
-+/*
-+ * 'next_txt_record()' - Get next TXT record from a cups_txt_records_t.
-+ */
-+
-+static cups_txt_records_t *
-+next_txt_record (cups_txt_records_t *txt)
-+{
-+#ifdef HAVE_DNSSD
-+ txt->data = txt->datanext;
-+#else /* HAVE_AVAHI */
-+ txt->txt = avahi_string_list_get_next (txt->txt);
-+ if (txt->txt == NULL)
-+ return NULL;
-+#endif /* HAVE_DNSSD */
-+
-+ return txt;
-+}
-+
-+
-+/*
-+ * 'parse_txt_record_pair()' - Read key/value pair in cups_txt_records_t.
-+ */
-+
-+static int
-+parse_txt_record_pair (cups_txt_records_t *txt)
-+{
-+#ifdef HAVE_DNSSD
-+ uint8_t datalen;
-+ uint8_t *data = txt->data;
-+ char *ptr;
-+
-+ /*
-+ * Read a key/value pair starting with an 8-bit length. Since the
-+ * length is 8 bits and the size of the key/value buffers is 256, we
-+ * don't need to check for overflow...
-+ */
-+
-+ datalen = *data++;
-+ if (!datalen || (data + datalen) >= txt->dataend)
-+ return NULL;
-+ txt->datanext = data + datalen;
-+
-+ for (ptr = txt->key; data < txt->datanext && *data != '='; data ++)
-+ *ptr++ = *data;
-+ *ptr = '\0';
-+
-+ if (data < txt->datanext && *data == '=')
-+ {
-+ data++;
-+
-+ if (data < datanext)
-+ memcpy (txt->value, data, txt->datanext - data);
-+ value[txt->datanext - data] = '\0';
-+ }
-+ else
-+ return 1;
-+#else /* HAVE_AVAHI */
-+ char *key, *value;
-+ size_t len;
-+ avahi_string_list_get_pair (txt->txt, &key, &value, &len);
-+ if (len > sizeof (txt->value) - 1)
-+ len = sizeof (txt->value) - 1;
-+
-+ memcpy (txt->value, value, len);
-+ txt->value[len] = '\0';
-+ len = strlen (key);
-+ if (len > sizeof (txt->key) - 1)
-+ len = sizeof (txt->key) - 1;
-+
-+ memcpy (txt->key, key, len);
-+ txt->key[len] = '\0';
-+ avahi_free (key);
-+ avahi_free (value);
-+#endif /* HAVE_AVAHI */
-+
-+ return 0;
-+}
-+
-
- /*
- * 'main()' - Browse for printers.
-@@ -119,6 +260,13 @@ main(int argc, /* I - Number of comm
- char *argv[]) /* I - Command-line arguments */
- {
- const char *name; /* Backend name */
-+ cups_array_t *devices; /* Device array */
-+ cups_device_t *device; /* Current device */
-+ char uriName[1024]; /* Unquoted fullName for URI */
-+#ifdef HAVE_DNSSD
-+ int fd; /* Main file descriptor */
-+ fd_set input; /* Input set for select() */
-+ struct timeval timeout; /* Timeout for select() */
- DNSServiceRef main_ref, /* Main service reference */
- fax_ipp_ref, /* IPP fax service reference */
- ipp_ref, /* IPP service reference */
-@@ -130,12 +278,11 @@ main(int argc, /* I - Number of comm
- pdl_datastream_ref, /* AppSocket service reference */
- printer_ref, /* LPD service reference */
- riousbprint_ref; /* Remote IO service reference */
-- int fd; /* Main file descriptor */
-- fd_set input; /* Input set for select() */
-- struct timeval timeout; /* Timeout for select() */
-- cups_array_t *devices; /* Device array */
-- cups_device_t *device; /* Current device */
-- char uriName[1024]; /* Unquoted fullName for URI */
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ AvahiClient *client;
-+ int error;
-+#endif /* HAVE_AVAHI */
- #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
- struct sigaction action; /* Actions for POSIX signals */
- #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-@@ -194,6 +341,49 @@ main(int argc, /* I - Number of comm
- * Browse for different kinds of printers...
- */
-
-+#ifdef HAVE_AVAHI
-+ if ((simple_poll = avahi_simple_poll_new ()) == NULL)
-+ {
-+ perror ("ERROR: Unable to create avahi simple poll object");
-+ return (1);
-+ }
-+
-+ client = avahi_client_new (avahi_simple_poll_get (simple_poll),
-+ 0, avahi_client_callback, NULL, &error);
-+ if (!client)
-+ {
-+ perror ("DEBUG: Unable to create avahi client");
-+ return (0);
-+ }
-+
-+ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ "_fax-ipp._tcp", NULL, 0,
-+ avahi_browse_callback, devices);
-+ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ "_ipp._tcp", NULL, 0,
-+ avahi_browse_callback, devices);
-+ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ "_ipp-tls._tcp", NULL, 0,
-+ avahi_browse_callback, devices);
-+ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ "_pdl-datastream._tcp",
-+ NULL, 0,
-+ avahi_browse_callback,
-+ devices);
-+ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ "_printer._tcp", NULL, 0,
-+ avahi_browse_callback, devices);
-+ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ "_riousbprint._tcp", NULL, 0,
-+ avahi_browse_callback, devices);
-+#endif /* HAVE_AVAHI */
-+#ifdef HAVE_DNSSD
- if (DNSServiceCreateConnection(&main_ref) != kDNSServiceErr_NoError)
- {
- perror("ERROR: Unable to create service connection");
-@@ -245,6 +435,7 @@ main(int argc, /* I - Number of comm
- riousbprint_ref = main_ref;
- DNSServiceBrowse(&riousbprint_ref, kDNSServiceFlagsShareConnection, 0,
- "_riousbprint._tcp", NULL, browse_callback, devices);
-+#endif /* HAVE_DNSSD */
-
- /*
- * Loop until we are killed...
-@@ -252,6 +443,9 @@ main(int argc, /* I - Number of comm
-
- while (!job_canceled)
- {
-+ int announce = 0;
-+
-+#ifdef HAVE_DNSSD
- FD_ZERO(&input);
- FD_SET(fd, &input);
-
-@@ -271,11 +465,35 @@ main(int argc, /* I - Number of comm
- }
- else
- {
-+ announce = 1;
-+ }
-+#else /* HAVE_AVAHI */
-+ int r;
-+ avahi_got_callback = 0;
-+ r = avahi_simple_poll_iterate (simple_poll, 1);
-+ if (r != 0 && r != EINTR)
-+ {
-+ /*
-+ * We've been told to exit the loop. Perhaps the connection to
-+ * avahi failed.
-+ */
-+
-+ break;
-+ }
-+
-+ if (avahi_got_callback)
-+ announce = 1;
-+#endif /* HAVE_DNSSD */
-+
-+ if (announce)
-+ {
- /*
- * Announce any devices we've found...
- */
-
-+#ifdef HAVE_DNSSD
- DNSServiceErrorType status; /* DNS query status */
-+#endif /* HAVE_DNSSD */
- cups_device_t *best; /* Best matching device */
- char device_uri[1024]; /* Device URI */
- int count; /* Number of queries */
-@@ -285,6 +503,7 @@ main(int argc, /* I - Number of comm
- best = NULL, count = 0;
- device;
- device = (cups_device_t *)cupsArrayNext(devices))
-+#ifdef HAVE_DNSSD
- if (!device->ref && !device->sent)
- {
- /*
-@@ -313,14 +532,23 @@ main(int argc, /* I - Number of comm
- count ++;
- }
- }
-- else if (!device->sent)
-+ else
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ if (!device->resolved)
-+ continue;
-+ else
-+#endif /* HAVE_AVAHI */
-+ if (!device->sent)
- {
-+#ifdef HAVE_DNSSD
- /*
- * Got the TXT records, now report the device...
- */
-
- DNSServiceRefDeallocate(device->ref);
- device->ref = 0;
-+#endif /* HAVE_DNSSD */
-
- if (!best)
- best = device;
-@@ -368,6 +596,7 @@ main(int argc, /* I - Number of comm
- }
-
-
-+#ifdef HAVE_DNSSD
- /*
- * 'browse_callback()' - Browse devices.
- */
-@@ -456,6 +685,7 @@ browse_local_callback(
- device->fullName);
- device->sent = 1;
- }
-+#endif /* HAVE_DNSSD */
-
-
- /*
-@@ -530,6 +760,37 @@ exec_backend(char **argv) /* I - Comman
-
-
- /*
-+ * 'device_type()' - Get DNS-SD type enumeration from string.
-+ */
-+
-+static int
-+device_type (const char *regtype)
-+{
-+#ifdef HAVE_AVAHI
-+ if (!strcmp(regtype, "_ipp._tcp") ||
-+ !strcmp(regtype, "_ipp-tls._tcp"))
-+ return (CUPS_DEVICE_IPP);
-+ else if (!strcmp(regtype, "_fax-ipp._tcp"))
-+ return (CUPS_DEVICE_FAX_IPP);
-+ else if (!strcmp(regtype, "_printer._tcp"))
-+ return (CUPS_DEVICE_PDL_DATASTREAM);
-+#else
-+ if (!strcmp(regtype, "_ipp._tcp.") ||
-+ !strcmp(regtype, "_ipp-tls._tcp."))
-+ return (CUPS_DEVICE_IPP);
-+ else if (!strcmp(regtype, "_fax-ipp._tcp."))
-+ return (CUPS_DEVICE_FAX_IPP);
-+ else if (!strcmp(regtype, "_printer._tcp."))
-+ return (CUPS_DEVICE_PRINTER);
-+ else if (!strcmp(regtype, "_pdl-datastream._tcp."))
-+ return (CUPS_DEVICE_PDL_DATASTREAM);
-+#endif /* HAVE_AVAHI */
-+
-+ return (CUPS_DEVICE_RIOUSBPRINT);
-+}
-+
-+
-+/*
- * 'get_device()' - Create or update a device.
- */
-
-@@ -550,18 +811,7 @@ get_device(cups_array_t *devices, /* I -
- */
-
- key.name = (char *)serviceName;
--
-- if (!strcmp(regtype, "_ipp._tcp.") ||
-- !strcmp(regtype, "_ipp-tls._tcp."))
-- key.type = CUPS_DEVICE_IPP;
-- else if (!strcmp(regtype, "_fax-ipp._tcp."))
-- key.type = CUPS_DEVICE_FAX_IPP;
-- else if (!strcmp(regtype, "_printer._tcp."))
-- key.type = CUPS_DEVICE_PRINTER;
-- else if (!strcmp(regtype, "_pdl-datastream._tcp."))
-- key.type = CUPS_DEVICE_PDL_DATASTREAM;
-- else
-- key.type = CUPS_DEVICE_RIOUSBPRINT;
-+ key.type = device_type (regtype);
-
- for (device = cupsArrayFind(devices, &key);
- device;
-@@ -581,8 +831,14 @@ get_device(cups_array_t *devices, /* I -
- free(device->domain);
- device->domain = strdup(replyDomain);
-
-+#ifdef HAVE_DNSSD
- DNSServiceConstructFullName(fullName, device->name, regtype,
- replyDomain);
-+#else /* HAVE_AVAHI */
-+ avahi_service_name_join (fullName, kDNSServiceMaxDomainName,
-+ serviceName, regtype, replyDomain);
-+#endif /* HAVE_DNSSD */
-+
- free(device->fullName);
- device->fullName = strdup(fullName);
- }
-@@ -602,6 +858,9 @@ get_device(cups_array_t *devices, /* I -
- device->domain = strdup(replyDomain);
- device->type = key.type;
- device->priority = 50;
-+#ifdef HAVE_AVAHI
-+ device->resolved = 0;
-+#endif /* HAVE_AVAHI */
-
- cupsArrayAdd(devices, device);
-
-@@ -609,13 +868,20 @@ get_device(cups_array_t *devices, /* I -
- * Set the "full name" of this service, which is used for queries...
- */
-
-+#ifdef HAVE_DNSSD
- DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain);
-+#else /* HAVE_AVAHI */
-+ avahi_service_name_join (fullName, kDNSServiceMaxDomainName,
-+ serviceName, regtype, replyDomain);
-+#endif /* HAVE_DNSSD */
-+
- device->fullName = strdup(fullName);
-
- return (device);
- }
-
-
-+#ifdef HAVE_DNSSD
- /*
- * 'query_callback()' - Process query data.
- */
-@@ -639,7 +905,7 @@ query_callback(
- *ptr; /* Pointer into string */
- cups_device_t dkey, /* Search key */
- *device; /* Device */
--
-+ cups_txt_records_t txt;
-
- fprintf(stderr, "DEBUG2: query_callback(sdRef=%p, flags=%x, "
- "interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
-@@ -673,84 +939,232 @@ query_callback(
- if ((ptr = strstr(name, "._")) != NULL)
- *ptr = '\0';
-
-- if (strstr(fullName, "_ipp._tcp.") ||
-- strstr(fullName, "_ipp-tls._tcp."))
-- dkey.type = CUPS_DEVICE_IPP;
-- else if (strstr(fullName, "_fax-ipp._tcp."))
-- dkey.type = CUPS_DEVICE_FAX_IPP;
-- else if (strstr(fullName, "_printer._tcp."))
-- dkey.type = CUPS_DEVICE_PRINTER;
-- else if (strstr(fullName, "_pdl-datastream._tcp."))
-- dkey.type = CUPS_DEVICE_PDL_DATASTREAM;
-+ dkey.type = device_type (fullName);
-+
-+ txt.data = rdata;
-+ txt.dataend = rdata + rdlen;
-+ device = find_device ((cups_array_t *) context, &txt, &dkey);
-+ if (!device)
-+ fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
-+}
-+#endif /* HAVE_DNSSD */
-+
-+
-+#ifdef HAVE_AVAHI
-+/*
-+ * 'avahi_client_callback()' - Avahi client callback function.
-+ */
-+
-+static void
-+avahi_client_callback(AvahiClient *client,
-+ AvahiClientState state,
-+ void *context)
-+{
-+ /*
-+ * If the connection drops, quit.
-+ */
-+
-+ if (state == AVAHI_CLIENT_FAILURE)
-+ {
-+ fprintf (stderr, "ERROR: Avahi connection failed\n");
-+ avahi_simple_poll_quit (simple_poll);
-+ }
-+}
-+
-+
-+/*
-+ * 'avahi_query_callback()' - Avahi query callback function.
-+ */
-+
-+static void
-+avahi_query_callback(AvahiServiceResolver *resolver,
-+ AvahiIfIndex interface,
-+ AvahiProtocol protocol,
-+ AvahiResolverEvent event,
-+ const char *name,
-+ const char *type,
-+ const char *domain,
-+ const char *host_name,
-+ const AvahiAddress *address,
-+ uint16_t port,
-+ AvahiStringList *txt,
-+ AvahiLookupResultFlags flags,
-+ void *context)
-+{
-+ AvahiClient *client;
-+ cups_device_t key,
-+ *device;
-+ char uqname[1024],
-+ *ptr;
-+ cups_txt_records_t txtr;
-+
-+ client = avahi_service_resolver_get_client (resolver);
-+ if (event != AVAHI_RESOLVER_FOUND)
-+ {
-+ if (event == AVAHI_RESOLVER_FAILURE)
-+ {
-+ fprintf (stderr, "ERROR: %s\n",
-+ avahi_strerror (avahi_client_errno (client)));
-+ }
-+
-+ avahi_service_resolver_free (resolver);
-+ return;
-+ }
-+
-+ /*
-+ * Set search key for device.
-+ */
-+
-+ key.name = uqname;
-+ unquote (uqname, name, sizeof (uqname));
-+ if ((ptr = strstr(name, "._")) != NULL)
-+ *ptr = '\0';
-+
-+ key.domain = (char *) domain;
-+ key.type = device_type (type);
-+
-+ /*
-+ * Find the device and the the TXT information.
-+ */
-+
-+ txtr.txt = txt;
-+ device = find_device ((cups_array_t *) context, &txtr, &key);
-+ if (device)
-+ {
-+ /*
-+ * Let the main loop know to announce the device.
-+ */
-+
-+ device->resolved = 1;
-+ avahi_got_callback = 1;
-+ }
- else
-- dkey.type = CUPS_DEVICE_RIOUSBPRINT;
-+ fprintf (stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", name);
-+
-+ avahi_service_resolver_free (resolver);
-+}
-+
-+
-+/*
-+ * 'avahi_browse_callback()' - Avahi browse callback function.
-+ */
-+
-+static void
-+avahi_browse_callback(AvahiServiceBrowser *browser,
-+ AvahiIfIndex interface,
-+ AvahiProtocol protocol,
-+ AvahiBrowserEvent event,
-+ const char *name,
-+ const char *type,
-+ const char *domain,
-+ AvahiLookupResultFlags flags,
-+ void *context)
-+{
-+ AvahiClient *client = avahi_service_browser_get_client (browser);
-
-- for (device = cupsArrayFind(devices, &dkey);
-+ switch (event)
-+ {
-+ case AVAHI_BROWSER_FAILURE:
-+ fprintf (stderr, "ERROR: %s\n",
-+ avahi_strerror (avahi_client_errno (client)));
-+ avahi_simple_poll_quit (simple_poll);
-+ return;
-+
-+ case AVAHI_BROWSER_NEW:
-+ /*
-+ * This object is new on the network.
-+ */
-+
-+ if (flags & AVAHI_LOOKUP_RESULT_LOCAL)
-+ {
-+ /*
-+ * This comes from the local machine so ignore it.
-+ */
-+
-+ fprintf (stderr, "DEBUG: ignoring local service %s\n", name);
-+ }
-+ else
-+ {
-+ /*
-+ * Create a device entry for it if it doesn't yet exist.
-+ */
-+
-+ get_device ((cups_array_t *)context, name, type, domain);
-+
-+ /*
-+ * Now look for a TXT entry.
-+ */
-+
-+ if (avahi_service_resolver_new (client, interface, protocol,
-+ name, type, domain,
-+ AVAHI_PROTO_UNSPEC, 0,
-+ avahi_query_callback, context) == NULL)
-+ {
-+ fprintf (stderr, "ERROR: failed to resolve service %s: %s\n",
-+ name, avahi_strerror (avahi_client_errno (client)));
-+ }
-+ }
-+
-+ break;
-+
-+ case AVAHI_BROWSER_REMOVE:
-+ case AVAHI_BROWSER_ALL_FOR_NOW:
-+ case AVAHI_BROWSER_CACHE_EXHAUSTED:
-+ break;
-+ }
-+}
-+#endif /* HAVE_AVAHI */
-+
-+
-+/*
-+ * 'find_device()' - Find a device from its name and domain.
-+ */
-+
-+static cups_device_t *
-+find_device (cups_array_t *devices,
-+ cups_txt_records_t *txt,
-+ cups_device_t *dkey)
-+{
-+ cups_device_t *device;
-+ char *ptr;
-+
-+ for (device = cupsArrayFind(devices, dkey);
- device;
- device = cupsArrayNext(devices))
- {
-- if (strcasecmp(device->name, dkey.name) ||
-- strcasecmp(device->domain, dkey.domain))
-+ if (strcasecmp(device->name, dkey->name) ||
-+ strcasecmp(device->domain, dkey->domain))
- {
- device = NULL;
- break;
- }
-- else if (device->type == dkey.type)
-+ else if (device->type == dkey->type)
- {
- /*
- * Found it, pull out the priority and make and model from the TXT
- * record and save it...
- */
-
-- const uint8_t *data, /* Pointer into data */
-- *datanext, /* Next key/value pair */
-- *dataend; /* End of entire TXT record */
-- uint8_t datalen; /* Length of current key/value pair */
-- char key[256], /* Key string */
-- value[256], /* Value string */
-- make_and_model[512],
-+ char make_and_model[512],
- /* Manufacturer and model */
- model[256], /* Model */
-- device_id[2048];/* 1284 device ID */
--
-+ device_id[2048]; /* 1284 device ID */
-
- device_id[0] = '\0';
- make_and_model[0] = '\0';
-
- strcpy(model, "Unknown");
-
-- for (data = rdata, dataend = data + rdlen;
-- data < dataend;
-- data = datanext)
-+ for (;;)
- {
-- /*
-- * Read a key/value pair starting with an 8-bit length. Since the
-- * length is 8 bits and the size of the key/value buffers is 256, we
-- * don't need to check for overflow...
-- */
--
-- datalen = *data++;
--
-- if (!datalen || (data + datalen) >= dataend)
-- break;
-+ char *key;
-+ char *value;
-
-- datanext = data + datalen;
--
-- for (ptr = key; data < datanext && *data != '='; data ++)
-- *ptr++ = *data;
-- *ptr = '\0';
--
-- if (data < datanext && *data == '=')
-- {
-- data ++;
--
-- if (data < datanext)
-- memcpy(value, data, datanext - data);
-- value[datanext - data] = '\0';
-- }
-- else
-- continue;
-+ if (parse_txt_record_pair (txt))
-+ goto next;
-
-+ key = txt->key;
-+ value = txt->value;
- if (!strncasecmp(key, "usb_", 4))
- {
- /*
-@@ -805,6 +1219,10 @@ query_callback(
- if (device->type == CUPS_DEVICE_PRINTER)
- device->sent = 1;
- }
-+
-+ next:
-+ if (next_txt_record (txt) == NULL)
-+ break;
- }
-
- if (device->device_id)
-@@ -861,11 +1279,9 @@ query_callback(
- }
- }
-
-- if (!device)
-- fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
-+ return device;
- }
-
--
- /*
- * 'sigterm_handler()' - Handle termination signals...
- */
-diff -up cups-1.4.7/config.h.in.avahi cups-1.4.7/config.h.in
---- cups-1.4.7/config.h.in.avahi 2011-01-10 08:39:37.000000000 +0100
-+++ cups-1.4.7/config.h.in 2011-06-28 11:55:27.033868442 +0200
-@@ -345,6 +345,13 @@
-
-
- /*
-+ * Do we have Avahi for DNS Service Discovery?
-+ */
-+
-+#undef HAVE_AVAHI
-+
-+
-+/*
- * Do we have ?
- */
-
-diff -up cups-1.4.7/config-scripts/cups-dnssd.m4.avahi cups-1.4.7/config-scripts/cups-dnssd.m4
---- cups-1.4.7/config-scripts/cups-dnssd.m4.avahi 2009-08-29 00:54:34.000000000 +0200
-+++ cups-1.4.7/config-scripts/cups-dnssd.m4 2011-06-28 11:55:27.034868428 +0200
-@@ -27,6 +27,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dn
- DNSSDLIBS=""
- DNSSD_BACKEND=""
-
-+AC_ARG_ENABLE(avahi, [ --enable-avahi turn on DNS Service Discovery support, default=no],
-+ [if test x$enable_avahi = xyes; then
-+ AC_MSG_CHECKING(for Avahi)
-+ if $PKGCONFIG --exists avahi-client; then
-+ AC_MSG_RESULT(yes)
-+ CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`"
-+ DNSSDLIBS="`$PKGCONFIG --libs avahi-client`"
-+ DNSSD_BACKEND="dnssd"
-+ AC_DEFINE(HAVE_AVAHI)
-+ enable_dnssd=no
-+ else
-+ AC_MSG_RESULT(no)
-+ fi
-+ fi])
-+
- if test x$enable_dnssd != xno; then
- AC_CHECK_HEADER(dns_sd.h, [
- case "$uname" in
-diff -up cups-1.4.7/cups/http-support.c.avahi cups-1.4.7/cups/http-support.c
---- cups-1.4.7/cups/http-support.c.avahi 2010-10-02 00:40:38.000000000 +0200
-+++ cups-1.4.7/cups/http-support.c 2011-06-28 11:55:27.035868414 +0200
-@@ -41,6 +41,10 @@
- * http_copy_decode() - Copy and decode a URI.
- * http_copy_encode() - Copy and encode a URI.
- * resolve_callback() - Build a device URI for the given service name.
-+ * avahi_resolve_uri_client_cb()
-+ * - Avahi client callback for resolving URI.
-+ * avahi_resolve_uri_resolver_cb()
-+ * - Avahi resolver callback for resolving URI.
- */
-
- /*
-@@ -55,6 +59,11 @@
- # include
- # include
- #endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+# include
-+# include
-+# include
-+#endif /* HAVE_AVAHI */
-
-
- /*
-@@ -121,6 +130,24 @@ static void resolve_callback(DNSService
- void *context);
- #endif /* HAVE_DNSSD */
-
-+#ifdef HAVE_AVAHI
-+static void avahi_resolve_uri_client_cb(AvahiClient *client,
-+ AvahiClientState state,
-+ void *simple_poll);
-+static void avahi_resolve_uri_resolver_cb(AvahiServiceResolver *resolver,
-+ AvahiIfIndex interface,
-+ AvahiProtocol protocol,
-+ AvahiResolverEvent event,
-+ const char *name,
-+ const char *type,
-+ const char *domain,
-+ const char *host_name,
-+ const AvahiAddress *address,
-+ uint16_t port,
-+ AvahiStringList *txt,
-+ AvahiLookupResultFlags flags,
-+ void *context);
-+#endif /* HAVE_AVAHI */
-
- /*
- * 'httpAssembleURI()' - Assemble a uniform resource identifier from its
-@@ -1351,6 +1378,9 @@ _httpResolveURI(
-
- if (strstr(hostname, "._tcp"))
- {
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+ char *regtype, /* Pointer to type in hostname */
-+ *domain; /* Pointer to domain in hostname */
- #ifdef HAVE_DNSSD
- DNSServiceRef ref, /* DNS-SD master service reference */
- domainref, /* DNS-SD service reference for domain */
-@@ -1361,6 +1391,16 @@ _httpResolveURI(
- *domain; /* Pointer to domain in hostname */
- _http_uribuf_t uribuf; /* URI buffer */
- struct pollfd polldata; /* Polling data */
-+#else /* HAVE_AVAHI */
-+ AvahiSimplePoll *simple_poll;
-+ AvahiClient *client;
-+ int error;
-+ struct
-+ {
-+ AvahiSimplePoll *poll;
-+ _http_uribuf_t uribuf;
-+ } user_data;
-+#endif /* HAVE_DNSSD */
-
-
- if (logit)
-@@ -1398,8 +1438,13 @@ _httpResolveURI(
- if (domain)
- *domain++ = '\0';
-
-+#ifdef HAVE_DNSSD
- uribuf.buffer = resolved_uri;
- uribuf.bufsize = resolved_size;
-+#else
-+ user_data.uribuf.buffer = resolved_uri;
-+ user_data.uribuf.bufsize = resolved_size;
-+#endif
-
- resolved_uri[0] = '\0';
-
-@@ -1414,6 +1459,7 @@ _httpResolveURI(
-
- uri = NULL;
-
-+#ifdef HAVE_DNSSD
- if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
- {
- localref = ref;
-@@ -1500,6 +1546,36 @@ _httpResolveURI(
-
- DNSServiceRefDeallocate(ref);
- }
-+#else /* HAVE_AVAHI */
-+ if ((simple_poll = avahi_simple_poll_new ()) != NULL)
-+ {
-+ if ((client = avahi_client_new (avahi_simple_poll_get (simple_poll),
-+ 0, avahi_resolve_uri_client_cb,
-+ &simple_poll, &error)) != NULL)
-+ {
-+ user_data.poll = simple_poll;
-+ if (avahi_service_resolver_new (client, AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC, hostname,
-+ regtype, domain, AVAHI_PROTO_UNSPEC, 0,
-+ avahi_resolve_uri_resolver_cb,
-+ &user_data) != NULL)
-+ {
-+ avahi_simple_poll_loop (simple_poll);
-+
-+ /*
-+ * Collect the result.
-+ */
-+
-+ if (resolved_uri[0])
-+ uri = resolved_uri;
-+ }
-+
-+ avahi_client_free (client);
-+ }
-+
-+ avahi_simple_poll_free (simple_poll);
-+ }
-+#endif /* HAVE_DNSSD */
-
- if (logit)
- {
-@@ -1511,13 +1587,13 @@ _httpResolveURI(
- fputs("STATE: -connecting-to-device,offline-report\n", stderr);
- }
-
--#else
-+#else /* HAVE_DNSSD || HAVE_AVAHI */
- /*
- * No DNS-SD support...
- */
-
- uri = NULL;
--#endif /* HAVE_DNSSD */
-+#endif /* HAVE_DNSSD || HAVE_AVAHI */
-
- if (logit && !uri)
- _cupsLangPuts(stderr, _("Unable to find printer!\n"));
-@@ -1723,6 +1799,116 @@ resolve_callback(
- #endif /* HAVE_DNSSD */
-
-
-+#ifdef HAVE_AVAHI
-+/*
-+ * 'avahi_resolve_uri_client_cb()' - Avahi client callback for resolving URI.
-+ */
-+
-+static void
-+avahi_resolve_uri_client_cb (AvahiClient *client,
-+ AvahiClientState state,
-+ void *simple_poll)
-+{
-+ DEBUG_printf(("avahi_resolve_uri_client_callback(client=%p, state=%d, "
-+ "simple_poll=%p)\n", client, state, simple_poll));
-+
-+ /*
-+ * If the connection drops, quit.
-+ */
-+
-+ if (state == AVAHI_CLIENT_FAILURE)
-+ avahi_simple_poll_quit (simple_poll);
-+}
-+
-+
-+/*
-+ * 'avahi_resolve_uri_resolver_cb()' - Avahi resolver callback for resolving
-+ * URI.
-+ */
-+
-+static void
-+avahi_resolve_uri_resolver_cb (AvahiServiceResolver *resolver,
-+ AvahiIfIndex interface,
-+ AvahiProtocol protocol,
-+ AvahiResolverEvent event,
-+ const char *name,
-+ const char *type,
-+ const char *domain,
-+ const char *host_name,
-+ const AvahiAddress *address,
-+ uint16_t port,
-+ AvahiStringList *txt,
-+ AvahiLookupResultFlags flags,
-+ void *context)
-+{
-+ const char *scheme; /* URI scheme */
-+ char rp[256]; /* Remote printer */
-+ AvahiStringList *pair;
-+ char *value;
-+ size_t valueLen = 0;
-+ char addr[AVAHI_ADDRESS_STR_MAX];
-+ struct
-+ {
-+ AvahiSimplePoll *poll;
-+ _http_uribuf_t uribuf;
-+ } *poll_uribuf = context;
-+
-+ DEBUG_printf(("avahi_resolve_uri_resolver_callback(resolver=%p, "
-+ "interface=%d, protocol=%d, event=%d, name=\"%s\", "
-+ "type=\"%s\", domain=\"%s\", host_name=\"%s\", address=%p, "
-+ "port=%d, txt=%p, flags=%d, context=%p)\n",
-+ resolver, interface, protocol, event, name, type, domain,
-+ host_name, address, port, txt, flags, context));
-+
-+ if (event != AVAHI_RESOLVER_FOUND)
-+ {
-+ avahi_service_resolver_free (resolver);
-+ avahi_simple_poll_quit (poll_uribuf->poll);
-+ return;
-+ }
-+
-+ /*
-+ * Figure out the scheme from the full name...
-+ */
-+
-+ if (strstr(type, "_ipp."))
-+ scheme = "ipp";
-+ else if (strstr(type, "_printer."))
-+ scheme = "lpd";
-+ else if (strstr(type, "_pdl-datastream."))
-+ scheme = "socket";
-+ else
-+ scheme = "riousbprint";
-+
-+ /*
-+ * Extract the "remote printer key from the TXT record...
-+ */
-+
-+ if ((pair = avahi_string_list_find (txt, "rp")) != NULL)
-+ {
-+ avahi_string_list_get_pair (pair, NULL, &value, &valueLen);
-+ rp[0] = '/';
-+ memcpy (rp + 1, value, valueLen);
-+ rp[valueLen + 1] = '\0';
-+ }
-+ else
-+ rp[0] = '\0';
-+
-+ /*
-+ * Assemble the final device URI...
-+ */
-+
-+ avahi_address_snprint (addr, AVAHI_ADDRESS_STR_MAX, address);
-+ httpAssembleURI(HTTP_URI_CODING_ALL, poll_uribuf->uribuf.buffer,
-+ poll_uribuf->uribuf.bufsize, scheme, NULL,
-+ addr, port, rp);
-+ DEBUG_printf(("avahi_resolve_uri_resolver_callback: Resolved URI is \"%s\"\n",
-+ poll_uribuf->uribuf.buffer));
-+ avahi_simple_poll_quit (poll_uribuf->poll);
-+}
-+#endif /* HAVE_AVAHI */
-+
-+
- /*
- * End of "$Id: http-support.c 9322 2010-10-01 22:40:38Z mike $".
- */
-diff -up cups-1.4.7/scheduler/avahi.c.avahi cups-1.4.7/scheduler/avahi.c
---- cups-1.4.7/scheduler/avahi.c.avahi 2011-06-28 11:55:27.036868400 +0200
-+++ cups-1.4.7/scheduler/avahi.c 2011-06-28 11:55:27.036868400 +0200
-@@ -0,0 +1,445 @@
-+/*
-+ * "$Id$"
-+ *
-+ * Avahi poll implementation for the CUPS scheduler.
-+ *
-+ * Copyright (C) 2010 Red Hat, Inc.
-+ * Authors:
-+ * Tim Waugh
-+ *
-+ * Distribution and use rights are outlined in the file "LICENSE.txt"
-+ * "LICENSE" which should have been included with this file. If this
-+ * file is missing or damaged, see the license at "http://www.cups.org/".
-+ *
-+ * Contents:
-+ *
-+ * watch_read_cb - Read callback for file descriptor
-+ * watch_write_cb - Write callback for file descriptor
-+ * watched_fd_add_select() - Call cupsdAddSelect() as needed
-+ * watch_new() - Create a new file descriptor watch
-+ * watch_free() - Free a file descriptor watch
-+ * watch_update() - Update watched events for a file descriptor
-+ * watch_get_events() - Get events that happened for a file descriptor
-+ * timeout_cb() - Run a timed Avahi callback
-+ * timeout_new() - Set a wakeup time
-+ * timeout_update() - Update the expiration time for a timeout
-+ * timeout_free() - Free a timeout
-+ * compare_watched_fds() - Compare watched file descriptors for array sorting
-+ * compare_timeouts() - Compare timeouts for array sorting
-+ * avahi_cups_poll_new() - Create a new Avahi main loop object for CUPS
-+ * avahi_cups_poll_free() - Free an Avahi main loop object for CUPS
-+ * avahi_cups_poll_get() - Get the abstract poll API structure
-+ */
-+
-+#include
-+
-+#ifdef HAVE_AVAHI /* Applies to entire file... */
-+
-+/*
-+ * Include necessary headers...
-+ */
-+
-+#include "cupsd.h"
-+
-+#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
-+# include
-+#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
-+
-+#ifdef HAVE_AVAHI
-+# include
-+#endif /* HAVE_AVAHI */
-+
-+
-+typedef struct
-+{
-+ AvahiCupsPoll *cups_poll;
-+
-+ int fd;
-+ AvahiWatchEvent occurred;
-+ cups_array_t *watches;
-+} cupsd_watched_fd_t;
-+
-+struct AvahiWatch
-+{
-+ cupsd_watched_fd_t *watched_fd;
-+
-+ AvahiWatchEvent events;
-+ AvahiWatchCallback callback;
-+ void *userdata;
-+};
-+
-+struct AvahiTimeout
-+{
-+ AvahiCupsPoll *cups_poll;
-+ AvahiTimeoutCallback callback;
-+ void *userdata;
-+ cupsd_timeout_t *cupsd_timeout;
-+};
-+
-+/*
-+ * Local functions...
-+ */
-+
-+static AvahiWatch * watch_new(const AvahiPoll *api,
-+ int fd,
-+ AvahiWatchEvent events,
-+ AvahiWatchCallback callback,
-+ void *userdata);
-+static void watch_free(AvahiWatch *watch);
-+static void watch_update(AvahiWatch *watch,
-+ AvahiWatchEvent events);
-+static AvahiWatchEvent watch_get_events(AvahiWatch *watch);
-+static int compare_watches(AvahiWatch *p0,
-+ AvahiWatch *p1);
-+
-+
-+/*
-+ * 'watch_read_cb' - Read callback for file descriptor
-+ */
-+
-+static void
-+watch_read_cb (void *userdata)
-+{
-+ AvahiWatch *watch;
-+ cupsd_watched_fd_t *watched_fd = userdata;
-+ watched_fd->occurred |= AVAHI_WATCH_IN;
-+ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
-+ watch;
-+ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
-+ if (watch->events & watched_fd->occurred) {
-+ (watch->callback) (watch, watched_fd->fd,
-+ AVAHI_WATCH_IN, watch->userdata);
-+ watched_fd->occurred &= ~AVAHI_WATCH_IN;
-+ break;
-+ }
-+ }
-+}
-+
-+
-+/*
-+ * 'watch_write_cb' - Write callback for file descriptor
-+ */
-+
-+static void
-+watch_write_cb (void *userdata)
-+{
-+ AvahiWatch *watch;
-+ cupsd_watched_fd_t *watched_fd = userdata;
-+ watched_fd->occurred |= AVAHI_WATCH_OUT;
-+ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
-+ watch;
-+ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
-+ if (watch->events & watched_fd->occurred) {
-+ (watch->callback) (watch, watched_fd->fd,
-+ AVAHI_WATCH_OUT, watch->userdata);
-+ watched_fd->occurred &= ~AVAHI_WATCH_OUT;
-+ break;
-+ }
-+ }
-+}
-+
-+
-+/*
-+ * 'watched_fd_add_select' - Call cupsdAddSelect() as needed
-+ */
-+
-+static int /* O - Watches? */
-+watched_fd_add_select (cupsd_watched_fd_t *watched_fd)
-+{
-+ AvahiWatch *watch;
-+ cupsd_selfunc_t read_cb = NULL, write_cb = NULL;
-+
-+ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
-+ watch;
-+ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
-+ if (watch->events & (AVAHI_WATCH_IN |
-+ AVAHI_WATCH_ERR |
-+ AVAHI_WATCH_HUP)) {
-+ read_cb = (cupsd_selfunc_t)watch_read_cb;
-+ if (write_cb != NULL)
-+ break;
-+ }
-+
-+ if (watch->events & AVAHI_WATCH_OUT) {
-+ write_cb = (cupsd_selfunc_t)watch_write_cb;
-+ if (read_cb != NULL)
-+ break;
-+ }
-+ }
-+
-+ if (read_cb || write_cb)
-+ cupsdAddSelect (watched_fd->fd, read_cb, write_cb, watched_fd);
-+ else
-+ cupsdRemoveSelect (watched_fd->fd);
-+
-+ return (read_cb || write_cb);
-+}
-+
-+/*
-+ * 'watch_new' - Create a new file descriptor watch
-+ */
-+
-+static AvahiWatch *
-+watch_new (const AvahiPoll *api,
-+ int fd,
-+ AvahiWatchEvent events,
-+ AvahiWatchCallback callback,
-+ void *userdata)
-+{
-+ cupsd_watched_fd_t key, *watched_fd;
-+ AvahiCupsPoll *cups_poll = api->userdata;
-+ AvahiWatch *watch = malloc(sizeof(AvahiWatch));
-+ if (watch == NULL)
-+ return (NULL);
-+
-+ watch->events = events;
-+ watch->callback = callback;
-+ watch->userdata = userdata;
-+
-+ key.fd = fd;
-+ watched_fd = cupsArrayFind (cups_poll->watched_fds, &key);
-+ if (watched_fd == NULL) {
-+ watched_fd = malloc(sizeof(cupsd_watched_fd_t));
-+ if (watched_fd == NULL) {
-+ free (watch);
-+ return (NULL);
-+ }
-+
-+ watched_fd->fd = fd;
-+ watched_fd->occurred = 0;
-+ watched_fd->cups_poll = cups_poll;
-+ watched_fd->watches = cupsArrayNew ((cups_array_func_t)compare_watches,
-+ NULL);
-+ }
-+
-+ watch->watched_fd = watched_fd;
-+ cupsArrayAdd(watched_fd->watches, watch);
-+ watched_fd_add_select (watched_fd);
-+ return (watch);
-+}
-+
-+
-+/*
-+ * 'watch_free' - Free a file descriptor watch
-+ */
-+
-+static void
-+watch_free (AvahiWatch *watch)
-+{
-+ cupsd_watched_fd_t *watched_fd = watch->watched_fd;
-+ AvahiCupsPoll *cups_poll = watched_fd->cups_poll;
-+
-+ cupsArrayRemove (watched_fd->watches, watch);
-+ free (watch);
-+
-+ if (!watched_fd_add_select (watched_fd)) {
-+ /* No more watches */
-+ cupsArrayRemove (cups_poll->watched_fds, watched_fd);
-+ free (watched_fd);
-+ }
-+}
-+
-+
-+/*
-+ * 'watch_update' - Update watched events for a file descriptor
-+ */
-+
-+static void
-+watch_update (AvahiWatch *watch,
-+ AvahiWatchEvent events)
-+{
-+ watch->events = events;
-+ watched_fd_add_select (watch->watched_fd);
-+}
-+
-+
-+/*
-+ * 'watch_get_events' - Get events that happened for a file descriptor
-+ */
-+
-+static AvahiWatchEvent
-+watch_get_events (AvahiWatch *watch)
-+{
-+ return (watch->watched_fd->occurred);
-+}
-+
-+
-+/*
-+ * 'compare_watches' - Compare watches for array sorting
-+ */
-+
-+static int
-+compare_watches (AvahiWatch *p0,
-+ AvahiWatch *p1)
-+{
-+ if (p0->watched_fd->fd < p1->watched_fd->fd)
-+ return (-1);
-+
-+ return ((p0->watched_fd->fd == p1->watched_fd->fd) ? 0 : 1);
-+}
-+
-+
-+/*
-+ * 'timeout_cb()' - Run a timed Avahi callback
-+ */
-+
-+static void
-+timeout_cb (cupsd_timeout_t *cupsd_timeout, void *userdata)
-+{
-+ AvahiTimeout *timeout = userdata;
-+ (timeout->callback) (timeout, timeout->userdata);
-+}
-+
-+
-+/*
-+ * 'timeout_new' - Set a wakeup time
-+ */
-+
-+static AvahiTimeout *
-+timeout_new (const AvahiPoll *api,
-+ const struct timeval *tv,
-+ AvahiTimeoutCallback callback,
-+ void *userdata)
-+{
-+ AvahiTimeout *timeout;
-+ AvahiCupsPoll *cups_poll = api->userdata;
-+
-+ timeout = malloc(sizeof(AvahiTimeout));
-+ if (timeout == NULL)
-+ return (NULL);
-+
-+ timeout->cups_poll = cups_poll;
-+ timeout->callback = callback;
-+ timeout->userdata = userdata;
-+ timeout->cupsd_timeout = cupsdAddTimeout (tv,
-+ (cupsd_timeoutfunc_t)timeout_cb,
-+ timeout);
-+ cupsArrayAdd (cups_poll->timeouts, timeout);
-+ return (timeout);
-+}
-+
-+
-+/*
-+ * 'timeout_update' - Update the expiration time for a timeout
-+ */
-+
-+static void
-+timeout_update (AvahiTimeout *timeout,
-+ const struct timeval *tv)
-+{
-+ cupsdUpdateTimeout (timeout->cupsd_timeout, tv);
-+}
-+
-+
-+/*
-+ * ' timeout_free' - Free a timeout
-+ */
-+
-+static void
-+timeout_free (AvahiTimeout *timeout)
-+{
-+ cupsArrayRemove (timeout->cups_poll->timeouts, timeout);
-+ cupsdRemoveTimeout (timeout->cupsd_timeout);
-+ free (timeout);
-+}
-+
-+
-+/*
-+ * 'compare_watched_fds' - Compare watched file descriptors for array sorting
-+ */
-+static int
-+compare_watched_fds(cupsd_watched_fd_t *p0,
-+ cupsd_watched_fd_t *p1)
-+{
-+ if (p0->fd != p1->fd)
-+ return (p0->fd < p1->fd ? -1 : 1);
-+
-+ if (p0 == p1)
-+ return (0);
-+
-+ return (p0 < p1 ? -1 : 1);
-+}
-+
-+
-+/*
-+ * 'compare_timeouts' - Compare timeouts for array sorting
-+ */
-+static int
-+compare_timeouts(AvahiTimeout *p0,
-+ AvahiTimeout *p1)
-+{
-+ /*
-+ * Just compare pointers to make it a stable sort.
-+ */
-+
-+ if (p0->cupsd_timeout < p1->cupsd_timeout)
-+ return (-1);
-+ return ((p0->cupsd_timeout == p1->cupsd_timeout) ? 0 : 1);
-+}
-+
-+
-+/*
-+ * 'avahi_cups_poll_new' - Create a new Avahi main loop object for CUPS
-+ */
-+
-+AvahiCupsPoll *
-+avahi_cups_poll_new (void)
-+{
-+ AvahiCupsPoll *cups_poll = malloc(sizeof(AvahiCupsPoll));
-+ if (cups_poll == NULL)
-+ return (NULL);
-+
-+ cups_poll->watched_fds = cupsArrayNew ((cups_array_func_t)compare_watched_fds,
-+ NULL);
-+ cups_poll->timeouts = cupsArrayNew ((cups_array_func_t)compare_timeouts,
-+ NULL);
-+
-+ cups_poll->api.userdata = cups_poll;
-+ cups_poll->api.watch_new = watch_new;
-+ cups_poll->api.watch_free = watch_free;
-+ cups_poll->api.watch_update = watch_update;
-+ cups_poll->api.watch_get_events = watch_get_events;
-+
-+ cups_poll->api.timeout_new = timeout_new;
-+ cups_poll->api.timeout_update = timeout_update;
-+ cups_poll->api.timeout_free = timeout_free;
-+
-+ return (cups_poll);
-+}
-+
-+
-+/*
-+ * 'avahi_cups_poll_free' - Free an Avahi main loop object for CUPS
-+ */
-+void
-+avahi_cups_poll_free (AvahiCupsPoll *cups_poll)
-+{
-+ cupsd_watched_fd_t *watched_fd;
-+
-+ for (watched_fd = (cupsd_watched_fd_t*)cupsArrayFirst(cups_poll->watched_fds);
-+ watched_fd;
-+ watched_fd = (cupsd_watched_fd_t*)cupsArrayNext(cups_poll->watched_fds)){
-+ cupsArrayClear (watched_fd->watches);
-+ }
-+
-+ cupsArrayClear (cups_poll->watched_fds);
-+ cupsArrayClear (cups_poll->timeouts);
-+}
-+
-+
-+/*
-+ * 'avahi_cups_poll_get' - Get the abstract poll API structure
-+ */
-+
-+const AvahiPoll *
-+avahi_cups_poll_get (AvahiCupsPoll *cups_poll)
-+{
-+ return (&cups_poll->api);
-+}
-+
-+
-+#endif /* HAVE_AVAHI ... from top of file */
-+
-+/*
-+ * End of "$Id$".
-+ */
-diff -up cups-1.4.7/scheduler/avahi.h.avahi cups-1.4.7/scheduler/avahi.h
---- cups-1.4.7/scheduler/avahi.h.avahi 2011-06-28 11:55:27.037868386 +0200
-+++ cups-1.4.7/scheduler/avahi.h 2011-06-28 11:55:27.037868386 +0200
-@@ -0,0 +1,49 @@
-+/*
-+ * "$Id$"
-+ *
-+ * Avahi poll implementation for the CUPS scheduler.
-+ *
-+ * Copyright (C) 2010 Red Hat, Inc.
-+ * Authors:
-+ * Tim Waugh
-+ *
-+ * Distribution and use rights are outlined in the file "LICENSE.txt"
-+ * which should have been included with this file. If this file is
-+ * file is missing or damaged, see the license at "http://www.cups.org/".
-+ */
-+
-+#include
-+
-+#ifdef HAVE_AVAHI
-+# include
-+# include
-+#endif /* HAVE_AVAHI */
-+
-+#ifdef HAVE_AUTHORIZATION_H
-+# include
-+#endif /* HAVE_AUTHORIZATION_H */
-+
-+
-+#ifdef HAVE_AVAHI
-+typedef struct
-+{
-+ AvahiPoll api;
-+ cups_array_t *watched_fds;
-+ cups_array_t *timeouts;
-+} AvahiCupsPoll;
-+#endif /* HAVE_AVAHI */
-+
-+/*
-+ * Prototypes...
-+ */
-+
-+#ifdef HAVE_AVAHI
-+extern AvahiCupsPoll * avahi_cups_poll_new(void);
-+extern void avahi_cups_poll_free(AvahiCupsPoll *cups_poll);
-+extern const AvahiPoll *avahi_cups_poll_get(AvahiCupsPoll *cups_poll);
-+#endif /* HAVE_AVAHI */
-+
-+
-+/*
-+ * End of "$Id$".
-+ */
-diff -up cups-1.4.7/scheduler/cupsd.h.avahi cups-1.4.7/scheduler/cupsd.h
---- cups-1.4.7/scheduler/cupsd.h.avahi 2011-01-11 08:05:58.000000000 +0100
-+++ cups-1.4.7/scheduler/cupsd.h 2011-06-28 11:55:27.037868386 +0200
-@@ -147,6 +147,15 @@ extern const char *cups_hstrerror(int);
-
- typedef void (*cupsd_selfunc_t)(void *data);
-
-+#ifdef HAVE_AVAHI
-+/*
-+ * Timeout callback function type...
-+ */
-+
-+typedef struct _cupsd_timeout_s cupsd_timeout_t;
-+typedef void (*cupsd_timeoutfunc_t)(cupsd_timeout_t *timeout, void *data);
-+#endif /* HAVE_AVAHI */
-+
-
- /*
- * Globals...
-@@ -188,6 +197,9 @@ VAR PSQUpdateQuotaProcPtr PSQUpdateQuota
- /* Apple PrintService quota function */
- #endif /* __APPLE__ && HAVE_DLFCN_H */
-
-+#ifdef HAVE_AVAHI
-+VAR cups_array_t *Timeouts; /* Timed callbacks for main loop */
-+#endif /* HAVE_AVAHI */
-
-
-
-@@ -241,6 +253,18 @@ extern void cupsdRemoveSelect(int fd);
- extern void cupsdStartSelect(void);
- extern void cupsdStopSelect(void);
-
-+#ifdef HAVE_AVAHI
-+extern void cupsdInitTimeouts(void);
-+extern cupsd_timeout_t *cupsdAddTimeout (const struct timeval *tv,
-+ cupsd_timeoutfunc_t cb,
-+ void *data);
-+extern cupsd_timeout_t *cupsdNextTimeout (long *delay);
-+extern void cupsdRunTimeout (cupsd_timeout_t *timeout);
-+extern void cupsdUpdateTimeout (cupsd_timeout_t *timeout,
-+ const struct timeval *tv);
-+extern void cupsdRemoveTimeout (cupsd_timeout_t *timeout);
-+#endif /* HAVE_AVAHI */
-+
- extern int cupsdRemoveFile(const char *filename);
-
-
-diff -up cups-1.4.7/scheduler/dirsvc.c.avahi cups-1.4.7/scheduler/dirsvc.c
---- cups-1.4.7/scheduler/dirsvc.c.avahi 2011-06-28 11:55:26.971869301 +0200
-+++ cups-1.4.7/scheduler/dirsvc.c 2011-06-28 12:04:15.066420076 +0200
-@@ -27,6 +27,7 @@
- * ldap_connect() - Start new LDAP connection
- * ldap_reconnect() - Reconnect to LDAP Server
- * ldap_disconnect() - Disconnect from LDAP Server
-+ * cupsdStartAvahiClient() - Start an Avahi client if needed
- * cupsdStartBrowsing() - Start sending and receiving broadcast
- * information.
- * cupsdStartPolling() - Start polling servers as needed.
-@@ -99,6 +100,13 @@
- #endif /* HAVE_DNSSD */
-
-
-+#ifdef HAVE_DNSSD
-+typedef char *cupsd_txt_record_t;
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+typedef AvahiStringList *cupsd_txt_record_t;
-+#endif /* HAVE_AVAHI */
-+
- /*
- * Local functions...
- */
-@@ -159,15 +167,20 @@ static void update_polling(void);
- static void update_smb(int onoff);
-
-
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+static cupsd_txt_record_t dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p,
-+ int for_lpd);
-+static void dnssdDeregisterPrinter(cupsd_printer_t *p);
-+static int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b);
-+static void dnssdRegisterPrinter(cupsd_printer_t *p);
-+static void dnssdStop(void);
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-+
- #ifdef HAVE_DNSSD
- # ifdef HAVE_COREFOUNDATION
- static void dnssdAddAlias(const void *key, const void *value,
- void *context);
- # endif /* HAVE_COREFOUNDATION */
--static char *dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p,
-- int for_lpd);
--static int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b);
--static void dnssdDeregisterPrinter(cupsd_printer_t *p);
- static char *dnssdPackTxtRecord(int *txt_len, char *keyvalue[][2],
- int count);
- static void dnssdRegisterCallback(DNSServiceRef sdRef,
-@@ -175,11 +188,20 @@ static void dnssdRegisterCallback(DNSSer
- DNSServiceErrorType errorCode,
- const char *name, const char *regtype,
- const char *domain, void *context);
--static void dnssdRegisterPrinter(cupsd_printer_t *p);
--static void dnssdStop(void);
- static void dnssdUpdate(void);
- #endif /* HAVE_DNSSD */
-
-+#ifdef HAVE_AVAHI
-+static AvahiStringList *avahiPackTxtRecord(char *keyvalue[][2],
-+ int count);
-+static void avahi_entry_group_cb (AvahiEntryGroup *group,
-+ AvahiEntryGroupState state,
-+ void *userdata);
-+static void avahi_client_cb (AvahiClient *client,
-+ AvahiClientState state,
-+ void *userdata);
-+#endif /* HAVE_AVAHI */
-+
- #ifdef HAVE_LDAP
- static const char * const ldap_attrs[] =/* CUPS LDAP attributes */
- {
-@@ -283,10 +305,10 @@ cupsdDeregisterPrinter(
- ldap_dereg_printer(p);
- #endif /* HAVE_LDAP */
-
--#ifdef HAVE_DNSSD
-- if (removeit && (BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+ if (removeit && (BrowseLocalProtocols & BROWSE_DNSSD))
- dnssdDeregisterPrinter(p);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
- }
-
-
-@@ -694,10 +716,10 @@ cupsdRegisterPrinter(cupsd_printer_t *p)
- slpRegisterPrinter(p); */
- #endif /* HAVE_LIBSLP */
-
--#ifdef HAVE_DNSSD
-- if ((BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+ if ((BrowseLocalProtocols & BROWSE_DNSSD))
- dnssdRegisterPrinter(p);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
- }
-
-
-@@ -1411,6 +1433,23 @@ ldap_disconnect(LDAP *ld) /* I - LDAP h
- }
- #endif /* HAVE_LDAP */
-
-+#ifdef HAVE_AVAHI
-+/*
-+ * 'cupsdStartAvahiClient()' - Start an Avahi client if needed
-+ */
-+
-+void
-+cupsdStartAvahiClient(void) {
-+ if (!AvahiCupsClient && !AvahiCupsClientConnecting)
-+ {
-+ if (!AvahiCupsPollHandle)
-+ AvahiCupsPollHandle = avahi_cups_poll_new ();
-+ if (AvahiCupsPollHandle)
-+ avahi_client_new (avahi_cups_poll_get (AvahiCupsPollHandle),
-+ AVAHI_CLIENT_NO_FAIL, avahi_client_cb, NULL, NULL);
-+ }
-+}
-+#endif /* HAVE_AVAHI */
-
- /*
- * 'cupsdStartBrowsing()' - Start sending and receiving broadcast information.
-@@ -1535,13 +1574,16 @@ cupsdStartBrowsing(void)
- else
- BrowseSocket = -1;
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD)
- {
-+#ifdef HAVE_DNSSD
- DNSServiceErrorType error; /* Error from service creation */
-+#endif /* HAVE_DNSSD */
- cupsd_listener_t *lis; /* Current listening socket */
-
-
-+#ifdef HAVE_DNSSD
- /*
- * First create a "master" connection for all registrations...
- */
-@@ -1566,6 +1608,7 @@ cupsdStartBrowsing(void)
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
-
- cupsdAddSelect(fd, (cupsd_selfunc_t)dnssdUpdate, NULL, NULL);
-+#endif /* HAVE_DNSSD */
-
- /*
- * Then get the port we use for registrations. If we are not listening
-@@ -1607,9 +1650,16 @@ cupsdStartBrowsing(void)
- */
-
- cupsdUpdateDNSSDName();
-+#ifdef HAVE_DNSSD
- }
-- }
- #endif /* HAVE_DNSSD */
-+ }
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-+
-+#ifdef HAVE_AVAHI
-+ if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD)
-+ cupsdStartAvahiClient();
-+#endif /* HAVE_AVAHI */
-
- #ifdef HAVE_LIBSLP
- if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP)
-@@ -1835,10 +1885,10 @@ cupsdStopBrowsing(void)
- BrowseSocket = -1;
- }
-
--#ifdef HAVE_DNSSD
-- if ((BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+ if ((BrowseLocalProtocols & BROWSE_DNSSD))
- dnssdStop();
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-
- #ifdef HAVE_LIBSLP
- if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) &&
-@@ -1903,7 +1953,7 @@ cupsdStopPolling(void)
- }
-
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- /*
- * 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing...
- */
-@@ -1911,7 +1961,12 @@ cupsdStopPolling(void)
- void
- cupsdUpdateDNSSDName(void)
- {
-+#ifdef HAVE_DNSSD
- DNSServiceErrorType error; /* Error from service creation */
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ int ret; /* Error from service creation */
-+#endif /* HAVE_AVAHI */
- char webif[1024]; /* Web interface share name */
- #ifdef HAVE_COREFOUNDATION_H
- SCDynamicStoreRef sc; /* Context for dynamic store */
-@@ -2043,6 +2098,7 @@ cupsdUpdateDNSSDName(void)
- else
- strlcpy(webif, "CUPS Web Interface", sizeof(webif));
-
-+#ifdef HAVE_DNSSD
- if (WebIFRef)
- DNSServiceRefDeallocate(WebIFRef);
-
-@@ -2055,6 +2111,42 @@ cupsdUpdateDNSSDName(void)
- NULL)) != kDNSServiceErr_NoError)
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "DNS-SD web interface registration failed: %d", error);
-+#endif /* HAVE_DNSSD */
-+
-+#ifdef HAVE_AVAHI
-+ if (!AvahiCupsClient)
-+ /*
-+ * Client not yet running.
-+ */
-+ return;
-+
-+ if (AvahiWebIFGroup)
-+ avahi_entry_group_reset (AvahiWebIFGroup);
-+ else
-+ AvahiWebIFGroup = avahi_entry_group_new (AvahiCupsClient,
-+ avahi_entry_group_cb,
-+ NULL);
-+
-+ if (AvahiWebIFGroup)
-+ {
-+ ret = avahi_entry_group_add_service (AvahiWebIFGroup,
-+ AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ 0, /* flags */
-+ webif, /* name */
-+ "_http._tcp", /* type */
-+ NULL, /* domain */
-+ NULL, /* host */
-+ DNSSDPort, /* port */
-+ "path=/", NULL);
-+ if (ret == 0)
-+ ret = avahi_entry_group_commit (AvahiWebIFGroup);
-+
-+ if (ret != 0)
-+ cupsdLogMessage (CUPSD_LOG_ERROR,
-+ "Avahi web interface registration failed: %d", ret);
-+ }
-+#endif /* HAVE_AVAHI */
- }
- }
- #endif /* HAVE_DNSSD */
-@@ -2300,162 +2392,7 @@ dequote(char *d, /* I - Destinat
- }
-
-
--#ifdef HAVE_DNSSD
--# ifdef HAVE_COREFOUNDATION
--/*
-- * 'dnssdAddAlias()' - Add a DNS-SD alias name.
-- */
--
--static void
--dnssdAddAlias(const void *key, /* I - Key */
-- const void *value, /* I - Value (domain) */
-- void *context) /* I - Unused */
--{
-- char valueStr[1024], /* Domain string */
-- hostname[1024]; /* Complete hostname */
--
--
-- (void)context;
--
-- if (CFGetTypeID((CFStringRef)value) == CFStringGetTypeID() &&
-- CFStringGetCString((CFStringRef)value, valueStr, sizeof(valueStr),
-- kCFStringEncodingUTF8))
-- {
-- snprintf(hostname, sizeof(hostname), "%s.%s", DNSSDHostName, valueStr);
-- if (!DNSSDAlias)
-- DNSSDAlias = cupsArrayNew(NULL, NULL);
--
-- cupsdAddAlias(DNSSDAlias, hostname);
-- cupsdLogMessage(CUPSD_LOG_DEBUG, "Added Back to My Mac ServerAlias %s",
-- hostname);
-- }
-- else
-- cupsdLogMessage(CUPSD_LOG_ERROR,
-- "Bad Back to My Mac domain in dynamic store!");
--}
--# endif /* HAVE_COREFOUNDATION */
--
--
--/*
-- * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info.
-- */
--
--static char * /* O - TXT record */
--dnssdBuildTxtRecord(
-- int *txt_len, /* O - TXT record length */
-- cupsd_printer_t *p, /* I - Printer information */
-- int for_lpd) /* I - 1 = LPD, 0 = IPP */
--{
-- int i; /* Looping var */
-- char adminurl_str[256], /* URL for th admin page */
-- type_str[32], /* Type to string buffer */
-- state_str[32], /* State to string buffer */
-- rp_str[1024], /* Queue name string buffer */
-- air_str[1024], /* auth-info-required string buffer */
-- *keyvalue[32][2]; /* Table of key/value pairs */
--
--
-- /*
-- * Load up the key value pairs...
-- */
--
-- i = 0;
--
-- keyvalue[i ][0] = "txtvers";
-- keyvalue[i++][1] = "1";
--
-- keyvalue[i ][0] = "qtotal";
-- keyvalue[i++][1] = "1";
--
-- keyvalue[i ][0] = "rp";
-- keyvalue[i++][1] = rp_str;
-- if (for_lpd)
-- strlcpy(rp_str, p->name, sizeof(rp_str));
-- else
-- snprintf(rp_str, sizeof(rp_str), "%s/%s",
-- (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers", p->name);
--
-- keyvalue[i ][0] = "ty";
-- keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown";
--
-- httpAssembleURIf(HTTP_URI_CODING_ALL, adminurl_str, sizeof(adminurl_str),
-- "http", NULL, DNSSDHostName, DNSSDPort, "/%s/%s",
-- (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
-- p->name);
-- keyvalue[i ][0] = "adminurl";
-- keyvalue[i++][1] = adminurl_str;
--
-- keyvalue[i ][0] = "note";
-- keyvalue[i++][1] = p->location ? p->location : "";
--
-- keyvalue[i ][0] = "priority";
-- keyvalue[i++][1] = for_lpd ? "100" : "0";
--
-- keyvalue[i ][0] = "product";
-- keyvalue[i++][1] = p->product ? p->product : "Unknown";
--
-- snprintf(type_str, sizeof(type_str), "0x%X", p->type | CUPS_PRINTER_REMOTE);
-- snprintf(state_str, sizeof(state_str), "%d", p->state);
--
-- keyvalue[i ][0] = "printer-state";
-- keyvalue[i++][1] = state_str;
--
-- keyvalue[i ][0] = "printer-type";
-- keyvalue[i++][1] = type_str;
--
-- keyvalue[i ][0] = "Transparent";
-- keyvalue[i++][1] = "T";
--
-- keyvalue[i ][0] = "Binary";
-- keyvalue[i++][1] = "T";
--
-- keyvalue[i ][0] = "Fax";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_FAX) ? "T" : "F";
--
-- keyvalue[i ][0] = "Color";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLOR) ? "T" : "F";
--
-- keyvalue[i ][0] = "Duplex";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_DUPLEX) ? "T" : "F";
--
-- keyvalue[i ][0] = "Staple";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_STAPLE) ? "T" : "F";
--
-- keyvalue[i ][0] = "Copies";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_COPIES) ? "T" : "F";
--
-- keyvalue[i ][0] = "Collate";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLLATE) ? "T" : "F";
--
-- keyvalue[i ][0] = "Punch";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_PUNCH) ? "T" : "F";
--
-- keyvalue[i ][0] = "Bind";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_BIND) ? "T" : "F";
--
-- keyvalue[i ][0] = "Sort";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_SORT) ? "T" : "F";
--
-- keyvalue[i ][0] = "Scan";
-- keyvalue[i++][1] = (p->type & CUPS_PRINTER_MFP) ? "T" : "F";
--
-- keyvalue[i ][0] = "pdl";
-- keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
--
-- if (get_auth_info_required(p, air_str, sizeof(air_str)))
-- {
-- keyvalue[i ][0] = "air";
-- keyvalue[i++][1] = air_str;
-- }
--
-- /*
-- * Then pack them into a proper txt record...
-- */
--
-- return (dnssdPackTxtRecord(txt_len, keyvalue, i));
--}
--
--
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- /*
- * 'dnssdComparePrinters()' - Compare the registered names of two printers.
- */
-@@ -2464,7 +2401,16 @@ static int /* O - Result of compariso
- dnssdComparePrinters(cupsd_printer_t *a,/* I - First printer */
- cupsd_printer_t *b)/* I - Second printer */
- {
-- return (strcasecmp(a->reg_name, b->reg_name));
-+ if (!a->reg_name)
-+ if (!b->reg_name)
-+ return 0;
-+ else
-+ return -1;
-+ else
-+ if (!b->reg_name)
-+ return 1;
-+ else
-+ return (strcasecmp(a->reg_name, b->reg_name));
- }
-
-
-@@ -2479,6 +2425,10 @@ dnssdDeregisterPrinter(
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name);
-
-+#ifdef HAVE_DNSSD
-+ if (!DNSSDRef)
-+ return;
-+
- /*
- * Closing the socket deregisters the service
- */
-@@ -2514,6 +2464,23 @@ dnssdDeregisterPrinter(
- free(p->printer_txt);
- p->printer_txt = NULL;
- }
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ if (p->avahi_group)
-+ {
-+ avahi_entry_group_reset (p->avahi_group);
-+ avahi_entry_group_free (p->avahi_group);
-+ p->avahi_group = NULL;
-+
-+ if (p->ipp_txt)
-+ avahi_string_list_free (p->ipp_txt);
-+
-+ if (p->printer_txt)
-+ avahi_string_list_free (p->printer_txt);
-+
-+ p->ipp_txt = p->printer_txt = NULL;
-+ }
-+#endif /* HAVE_AVAHI */
-
- /*
- * Remove the printer from the array of DNS-SD printers, then clear the
-@@ -2526,136 +2493,46 @@ dnssdDeregisterPrinter(
-
-
- /*
-- * 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the
-- * TXT record format.
-+ * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer
-+ * or update the broadcast contents.
- */
-
--static char * /* O - TXT record */
--dnssdPackTxtRecord(int *txt_len, /* O - TXT record length */
-- char *keyvalue[][2], /* I - Table of key value pairs */
-- int count) /* I - Items in table */
-+static void
-+dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
- {
-- int i; /* Looping var */
-- int length; /* Length of TXT record */
-- int length2; /* Length of value */
-- char *txtRecord; /* TXT record buffer */
-- char *cursor; /* Looping pointer */
-+#ifdef HAVE_DNSSD
-+ DNSServiceErrorType se; /* dnssd errors */
-+ char *ipp_txt, /* IPP TXT record buffer */
-+ *printer_txt, /* LPD TXT record buffer */
-+ *nameptr; /* Pointer into name */
-+ int ipp_len, /* IPP TXT record length */
-+ printer_len; /* LPD TXT record length */
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ int ret; /* Error code */
-+ AvahiStringList *ipp_txt, /* IPP TXT record list */
-+ *printer_txt; /* LPD TXT record buffer */
-+#endif /* HAVE_AVAHI */
-+ char name[1024]; /* Service name */
-+ const char *regtype; /* Registration type */
-
-
-- /*
-- * Calculate the buffer size
-- */
-+#ifdef HAVE_DNSSD
-+ if (!DNSSDRef)
-+ return;
-
-- if (count <= 0)
-- return (NULL);
-+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
-+ !p->ipp_ref ? "new" : "update");
-
-- for (length = i = 0; i < count; i++)
-- length += 1 + strlen(keyvalue[i][0]) +
-- (keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0);
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
-+ !p->avahi_group ? "new" : "update");
-+#endif /* HAVE_AVAHI */
-
- /*
-- * Allocate and fill it
-- */
--
-- txtRecord = malloc(length);
-- if (txtRecord)
-- {
-- *txt_len = length;
--
-- for (cursor = txtRecord, i = 0; i < count; i++)
-- {
-- /*
-- * Drop in the p-string style length byte followed by the data
-- */
--
-- length = strlen(keyvalue[i][0]);
-- length2 = keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0;
--
-- *cursor++ = (unsigned char)(length + length2);
--
-- memcpy(cursor, keyvalue[i][0], length);
-- cursor += length;
--
-- if (length2)
-- {
-- length2 --;
-- *cursor++ = '=';
-- memcpy(cursor, keyvalue[i][1], length2);
-- cursor += length2;
-- }
-- }
-- }
--
-- return (txtRecord);
--}
--
--
--/*
-- * 'dnssdRegisterCallback()' - DNSServiceRegister callback.
-- */
--
--static void
--dnssdRegisterCallback(
-- DNSServiceRef sdRef, /* I - DNS Service reference */
-- DNSServiceFlags flags, /* I - Reserved for future use */
-- DNSServiceErrorType errorCode, /* I - Error code */
-- const char *name, /* I - Service name */
-- const char *regtype, /* I - Service type */
-- const char *domain, /* I - Domain. ".local" for now */
-- void *context) /* I - User-defined context */
--{
-- cupsd_printer_t *p = (cupsd_printer_t *)context;
-- /* Current printer */
--
--
-- cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterCallback(%s, %s) for %s (%s)",
-- name, regtype, p ? p->name : "Web Interface",
-- p ? (p->reg_name ? p->reg_name : "(null)") : "NA");
--
-- if (errorCode)
-- {
-- cupsdLogMessage(CUPSD_LOG_ERROR,
-- "DNSServiceRegister failed with error %d", (int)errorCode);
-- return;
-- }
-- else if (p && (!p->reg_name || strcasecmp(name, p->reg_name)))
-- {
-- cupsdLogMessage(CUPSD_LOG_INFO, "Using service name \"%s\" for \"%s\"",
-- name, p->name);
--
-- cupsArrayRemove(DNSSDPrinters, p);
-- cupsdSetString(&p->reg_name, name);
-- cupsArrayAdd(DNSSDPrinters, p);
--
-- LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED;
-- }
--}
--
--
--/*
-- * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer
-- * or update the broadcast contents.
-- */
--
--static void
--dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
--{
-- DNSServiceErrorType se; /* dnssd errors */
-- char *ipp_txt, /* IPP TXT record buffer */
-- *printer_txt, /* LPD TXT record buffer */
-- name[1024], /* Service name */
-- *nameptr; /* Pointer into name */
-- int ipp_len, /* IPP TXT record length */
-- printer_len; /* LPD TXT record length */
-- const char *regtype; /* Registration type */
--
--
-- cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterPrinter(%s) %s", p->name,
-- !p->ipp_ref ? "new" : "update");
--
-- /*
-- * If per-printer sharing was just disabled make sure we're not
-- * registered before returning.
-+ * If per-printer sharing was just disabled make sure we're not
-+ * registered before returning.
- */
-
- if (!p->shared)
-@@ -2697,6 +2574,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
- * Register IPP and (optionally) LPD...
- */
-
-+#ifdef HAVE_DNSSD
- ipp_len = 0; /* anti-compiler-warning-code */
- ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0);
-
-@@ -2863,6 +2741,146 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
- if (printer_txt)
- free(printer_txt);
- }
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ if (!AvahiCupsClient)
-+ /*
-+ * Client not running yet. The client callback will call us again later.
-+ */
-+ return;
-+
-+ ipp_txt = dnssdBuildTxtRecord(NULL, p, 0);
-+ printer_txt = dnssdBuildTxtRecord(NULL, p, 1);
-+ regtype = (p->type & CUPS_PRINTER_FAX) ? "_fax-ipp._tcp" : "_ipp._tcp";
-+
-+ if (p->avahi_group && p->ipp_txt && ipp_txt &&
-+ !avahi_string_list_equal (p->ipp_txt, ipp_txt))
-+ {
-+ /*
-+ * Update the existing registration...
-+ */
-+
-+ avahi_string_list_free (p->ipp_txt);
-+
-+ if (p->printer_txt)
-+ avahi_string_list_free (p->printer_txt);
-+
-+ ret = avahi_entry_group_update_service_txt_strlst (p->avahi_group,
-+ AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ 0, name, regtype, NULL,
-+ ipp_txt);
-+ if (ret < 0)
-+ goto update_failed;
-+
-+ p->ipp_txt = ipp_txt;
-+ ipp_txt = NULL;
-+
-+ if (BrowseLocalProtocols & BROWSE_LPD)
-+ {
-+ ret = avahi_entry_group_update_service_txt_strlst (p->avahi_group,
-+ AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ 0, name,
-+ "_printer._tcp", NULL,
-+ printer_txt);
-+
-+ if (ret < 0)
-+ goto update_failed;
-+
-+ p->printer_txt = printer_txt;
-+ printer_txt = NULL;
-+ }
-+
-+ ret = avahi_entry_group_commit (p->avahi_group);
-+ if (ret < 0)
-+ {
-+ update_failed:
-+ cupsdLogMessage (CUPSD_LOG_ERROR,
-+ "Failed to update TXT record for %s: %d",
-+ name, ret);
-+ avahi_entry_group_reset (p->avahi_group);
-+ avahi_entry_group_free (p->avahi_group);
-+ p->avahi_group = NULL;
-+ ipp_txt = p->ipp_txt;
-+ p->ipp_txt = NULL;
-+ }
-+ }
-+
-+ if (!p->avahi_group)
-+ {
-+ /*
-+ * Initial registration. Use the _fax subtype for fax queues...
-+ */
-+
-+ p->avahi_group = avahi_entry_group_new (AvahiCupsClient,
-+ avahi_entry_group_cb,
-+ p);
-+
-+ cupsdLogMessage(CUPSD_LOG_DEBUG,
-+ "Registering Avahi printer %s with name \"%s\" and "
-+ "type \"%s\"", p->name, name, regtype);
-+
-+ if (!p->avahi_group)
-+ goto add_failed;
-+
-+ ret = avahi_entry_group_add_service_strlst (p->avahi_group,
-+ AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ 0, name, regtype, NULL, NULL,
-+ DNSSDPort,
-+ ipp_txt);
-+ if (ret < 0)
-+ goto add_failed;
-+
-+ p->ipp_txt = ipp_txt;
-+ ipp_txt = NULL;
-+
-+ if (BrowseLocalProtocols & BROWSE_LPD)
-+ {
-+ cupsdLogMessage(CUPSD_LOG_DEBUG,
-+ "Registering Avahi printer %s with name \"%s\" and "
-+ "type \"_printer._tcp\"", p->name, name);
-+
-+ ret = avahi_entry_group_add_service_strlst (p->avahi_group,
-+ AVAHI_IF_UNSPEC,
-+ AVAHI_PROTO_UNSPEC,
-+ 0, name,
-+ "_printer._tcp", NULL, NULL,
-+ 515,
-+ printer_txt);
-+ if (ret < 0)
-+ goto add_failed;
-+
-+ p->printer_txt = printer_txt;
-+ printer_txt = NULL;
-+ }
-+
-+ ret = avahi_entry_group_commit (p->avahi_group);
-+
-+ if (ret < 0)
-+ {
-+ add_failed:
-+ cupsdLogMessage (CUPSD_LOG_ERROR,
-+ "Failed to add Avahi entry for %s: %d",
-+ name, ret);
-+ if (p->avahi_group)
-+ {
-+ avahi_entry_group_reset (p->avahi_group);
-+ avahi_entry_group_free (p->avahi_group);
-+ p->avahi_group = NULL;
-+ }
-+ ipp_txt = p->ipp_txt;
-+ p->ipp_txt = NULL;
-+ }
-+ }
-+
-+ if (ipp_txt)
-+ avahi_string_list_free (ipp_txt);
-+
-+ if (printer_txt)
-+ avahi_string_list_free (printer_txt);
-+#endif /* HAVE_AVAHI */
- }
-
-
-@@ -2875,6 +2893,10 @@ dnssdStop(void)
- {
- cupsd_printer_t *p; /* Current printer */
-
-+#ifdef HAVE_DNSSD
-+ if (!DNSSDRef)
-+ return;
-+#endif /* HAVE_DNSSD */
-
- /*
- * De-register the individual printers
-@@ -2885,6 +2907,7 @@ dnssdStop(void)
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- dnssdDeregisterPrinter(p);
-
-+#ifdef HAVE_DNSSD
- /*
- * Shutdown the rest of the service refs...
- */
-@@ -2905,6 +2928,7 @@ dnssdStop(void)
-
- DNSServiceRefDeallocate(DNSSDRef);
- DNSSDRef = NULL;
-+#endif /* HAVE_DNSSD */
-
- cupsArrayDelete(DNSSDPrinters);
- DNSSDPrinters = NULL;
-@@ -2914,6 +2938,272 @@ dnssdStop(void)
-
-
- /*
-+ * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info.
-+ */
-+
-+static cupsd_txt_record_t /* O - TXT record */
-+dnssdBuildTxtRecord(
-+ int *txt_len, /* O - TXT record length */
-+ cupsd_printer_t *p, /* I - Printer information */
-+ int for_lpd) /* I - 1 = LPD, 0 = IPP */
-+{
-+ int i; /* Looping var */
-+ char adminurl_str[256], /* URL for th admin page */
-+ type_str[32], /* Type to string buffer */
-+ state_str[32], /* State to string buffer */
-+ rp_str[1024], /* Queue name string buffer */
-+ air_str[1024], /* auth-info-required string buffer */
-+ *keyvalue[32][2]; /* Table of key/value pairs */
-+
-+
-+ /*
-+ * Load up the key value pairs...
-+ */
-+
-+ i = 0;
-+
-+ keyvalue[i ][0] = "txtvers";
-+ keyvalue[i++][1] = "1";
-+
-+ keyvalue[i ][0] = "qtotal";
-+ keyvalue[i++][1] = "1";
-+
-+ keyvalue[i ][0] = "rp";
-+ keyvalue[i++][1] = rp_str;
-+ if (for_lpd)
-+ strlcpy(rp_str, p->name, sizeof(rp_str));
-+ else
-+ snprintf(rp_str, sizeof(rp_str), "%s/%s",
-+ (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers", p->name);
-+
-+ keyvalue[i ][0] = "ty";
-+ keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown";
-+
-+ httpAssembleURIf(HTTP_URI_CODING_ALL, adminurl_str, sizeof(adminurl_str),
-+ "http", NULL, DNSSDHostName, DNSSDPort, "/%s/%s",
-+ (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
-+ p->name);
-+ keyvalue[i ][0] = "adminurl";
-+ keyvalue[i++][1] = adminurl_str;
-+
-+ keyvalue[i ][0] = "note";
-+ keyvalue[i++][1] = p->location ? p->location : "";
-+
-+ keyvalue[i ][0] = "priority";
-+ keyvalue[i++][1] = for_lpd ? "100" : "0";
-+
-+ keyvalue[i ][0] = "product";
-+ keyvalue[i++][1] = p->product ? p->product : "Unknown";
-+
-+ snprintf(type_str, sizeof(type_str), "0x%X", p->type | CUPS_PRINTER_REMOTE);
-+ snprintf(state_str, sizeof(state_str), "%d", p->state);
-+
-+ keyvalue[i ][0] = "printer-state";
-+ keyvalue[i++][1] = state_str;
-+
-+ keyvalue[i ][0] = "printer-type";
-+ keyvalue[i++][1] = type_str;
-+
-+ keyvalue[i ][0] = "Transparent";
-+ keyvalue[i++][1] = "T";
-+
-+ keyvalue[i ][0] = "Binary";
-+ keyvalue[i++][1] = "T";
-+
-+ keyvalue[i ][0] = "Fax";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_FAX) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Color";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLOR) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Duplex";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_DUPLEX) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Staple";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_STAPLE) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Copies";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_COPIES) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Collate";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_COLLATE) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Punch";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_PUNCH) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Bind";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_BIND) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Sort";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_SORT) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "Scan";
-+ keyvalue[i++][1] = (p->type & CUPS_PRINTER_MFP) ? "T" : "F";
-+
-+ keyvalue[i ][0] = "pdl";
-+ keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
-+
-+ if (get_auth_info_required(p, air_str, sizeof(air_str)))
-+ {
-+ keyvalue[i ][0] = "air";
-+ keyvalue[i++][1] = air_str;
-+ }
-+
-+ /*
-+ * Then pack them into a proper txt record...
-+ */
-+
-+#ifdef HAVE_DNSSD
-+ return (dnssdPackTxtRecord(txt_len, keyvalue, i));
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ return (avahiPackTxtRecord(keyvalue, i));
-+#endif /* HAVE_AVAHI */
-+}
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-+
-+
-+#ifdef HAVE_DNSSD
-+# ifdef HAVE_COREFOUNDATION
-+/*
-+ * 'dnssdAddAlias()' - Add a DNS-SD alias name.
-+ */
-+
-+static void
-+dnssdAddAlias(const void *key, /* I - Key */
-+ const void *value, /* I - Value (domain) */
-+ void *context) /* I - Unused */
-+{
-+ char valueStr[1024], /* Domain string */
-+ hostname[1024]; /* Complete hostname */
-+
-+
-+ (void)context;
-+
-+ if (CFGetTypeID((CFStringRef)value) == CFStringGetTypeID() &&
-+ CFStringGetCString((CFStringRef)value, valueStr, sizeof(valueStr),
-+ kCFStringEncodingUTF8))
-+ {
-+ snprintf(hostname, sizeof(hostname), "%s.%s", DNSSDHostName, valueStr);
-+ if (!DNSSDAlias)
-+ DNSSDAlias = cupsArrayNew(NULL, NULL);
-+
-+ cupsdAddAlias(DNSSDAlias, hostname);
-+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Added Back to My Mac ServerAlias %s",
-+ hostname);
-+ }
-+ else
-+ cupsdLogMessage(CUPSD_LOG_ERROR,
-+ "Bad Back to My Mac domain in dynamic store!");
-+}
-+# endif /* HAVE_COREFOUNDATION */
-+
-+
-+/*
-+ * 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the
-+ * TXT record format.
-+ */
-+
-+static char * /* O - TXT record */
-+dnssdPackTxtRecord(int *txt_len, /* O - TXT record length */
-+ char *keyvalue[][2], /* I - Table of key value pairs */
-+ int count) /* I - Items in table */
-+{
-+ int i; /* Looping var */
-+ int length; /* Length of TXT record */
-+ int length2; /* Length of value */
-+ char *txtRecord; /* TXT record buffer */
-+ char *cursor; /* Looping pointer */
-+
-+
-+ /*
-+ * Calculate the buffer size
-+ */
-+
-+ for (length = i = 0; i < count; i++)
-+ length += 1 + strlen(keyvalue[i][0]) +
-+ (keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0);
-+
-+ /*
-+ * Allocate and fill it
-+ */
-+
-+ txtRecord = malloc(length);
-+ if (txtRecord)
-+ {
-+ *txt_len = length;
-+
-+ for (cursor = txtRecord, i = 0; i < count; i++)
-+ {
-+ /*
-+ * Drop in the p-string style length byte followed by the data
-+ */
-+
-+ length = strlen(keyvalue[i][0]);
-+ length2 = keyvalue[i][1] ? 1 + strlen(keyvalue[i][1]) : 0;
-+
-+ *cursor++ = (unsigned char)(length + length2);
-+
-+ memcpy(cursor, keyvalue[i][0], length);
-+ cursor += length;
-+
-+ if (length2)
-+ {
-+ length2 --;
-+ *cursor++ = '=';
-+ memcpy(cursor, keyvalue[i][1], length2);
-+ cursor += length2;
-+ }
-+ }
-+ }
-+
-+ return (txtRecord);
-+}
-+
-+
-+/*
-+ * 'dnssdRegisterCallback()' - DNSServiceRegister callback.
-+ */
-+
-+static void
-+dnssdRegisterCallback(
-+ DNSServiceRef sdRef, /* I - DNS Service reference */
-+ DNSServiceFlags flags, /* I - Reserved for future use */
-+ DNSServiceErrorType errorCode, /* I - Error code */
-+ const char *name, /* I - Service name */
-+ const char *regtype, /* I - Service type */
-+ const char *domain, /* I - Domain. ".local" for now */
-+ void *context) /* I - User-defined context */
-+{
-+ cupsd_printer_t *p = (cupsd_printer_t *)context;
-+ /* Current printer */
-+
-+
-+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdRegisterCallback(%s, %s) for %s (%s)",
-+ name, regtype, p ? p->name : "Web Interface",
-+ p ? (p->reg_name ? p->reg_name : "(null)") : "NA");
-+
-+ if (errorCode)
-+ {
-+ cupsdLogMessage(CUPSD_LOG_ERROR,
-+ "DNSServiceRegister failed with error %d", (int)errorCode);
-+ return;
-+ }
-+ else if (p && (!p->reg_name || strcasecmp(name, p->reg_name)))
-+ {
-+ cupsdLogMessage(CUPSD_LOG_INFO, "Using service name \"%s\" for \"%s\"",
-+ name, p->name);
-+
-+ cupsArrayRemove(DNSSDPrinters, p);
-+ cupsdSetString(&p->reg_name, name);
-+ cupsArrayAdd(DNSSDPrinters, p);
-+
-+ LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED;
-+ }
-+}
-+
-+
-+/*
- * 'dnssdUpdate()' - Handle DNS-SD queries.
- */
-
-@@ -2934,6 +3224,146 @@ dnssdUpdate(void)
- #endif /* HAVE_DNSSD */
-
-
-+#ifdef HAVE_AVAHI
-+/*
-+ * 'avahiPackTxtRecord()' - Pack an array of key/value pairs into an
-+ * AvahiStringList.
-+ */
-+
-+static AvahiStringList * /* O - new string list */
-+avahiPackTxtRecord(char *keyvalue[][2], /* I - Table of key value pairs */
-+ int count) /* I - Items in table */
-+{
-+ AvahiStringList *strlst = NULL;
-+ char **elements;
-+ size_t len;
-+ int i = 0;
-+
-+ elements = malloc ((1 + count) * sizeof (char *));
-+ if (!elements)
-+ goto cleanup;
-+
-+ for (i = 0; i < count; i++)
-+ {
-+ len = (1 + strlen (keyvalue[i][0]) +
-+ (keyvalue[i][1] ? 1 + strlen (keyvalue[i][1]) : 1));
-+ elements[i] = malloc (len * sizeof (char));
-+ if (!elements[i])
-+ goto cleanup;
-+
-+ snprintf (elements[i], len, "%s=%s", keyvalue[i][0], keyvalue[i][1]);
-+ }
-+
-+ strlst = avahi_string_list_new_from_array ((const char **) elements, count);
-+
-+cleanup:
-+ while (--i >= 0)
-+ free (elements[i]);
-+
-+ free (elements);
-+ return (strlst);
-+}
-+
-+
-+/*
-+ * 'avahi_entry_group_cb()' - Avahi entry group callback function.
-+ */
-+static void
-+avahi_entry_group_cb (AvahiEntryGroup *group,
-+ AvahiEntryGroupState state,
-+ void *userdata)
-+{
-+ char *name;
-+
-+ if (userdata)
-+ name = ((cupsd_printer_t *) userdata)->reg_name;
-+ else
-+ name = "CUPS web interface";
-+
-+ switch (state)
-+ {
-+ case AVAHI_ENTRY_GROUP_UNCOMMITED:
-+ case AVAHI_ENTRY_GROUP_REGISTERING:
-+ break;
-+
-+ case AVAHI_ENTRY_GROUP_ESTABLISHED:
-+ cupsdLogMessage (CUPSD_LOG_DEBUG,
-+ "Avahi entry group established for %s", name);
-+ break;
-+
-+ default:
-+ cupsdLogMessage (CUPSD_LOG_DEBUG,
-+ "Avahi entry group %s has state %d",
-+ name, state);
-+ break;
-+ }
-+}
-+
-+/*
-+ * 'avahi_client_cb()' - Avahi client callback function.
-+ */
-+static void
-+avahi_client_cb (AvahiClient *client,
-+ AvahiClientState state,
-+ void *userdata)
-+{
-+ cupsd_printer_t *printer;
-+ switch (state)
-+ {
-+ case AVAHI_CLIENT_S_RUNNING:
-+ /*
-+ * Avahi client started successfully.
-+ */
-+ AvahiCupsClient = client;
-+ AvahiCupsClientConnecting = 0;
-+ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client started");
-+
-+ cupsdUpdateDNSSDName ();
-+
-+ for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers);
-+ printer;
-+ printer = (cupsd_printer_t *)cupsArrayNext(Printers))
-+ if (Browsing && (BrowseLocalProtocols & BROWSE_DNSSD) &&
-+ (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT |
-+ CUPS_PRINTER_SCANNER))) && printer->shared)
-+ dnssdRegisterPrinter (printer);
-+
-+ break;
-+
-+ case AVAHI_CLIENT_CONNECTING:
-+ /*
-+ * No Avahi daemon, client is waiting.
-+ */
-+ AvahiCupsClientConnecting = 1;
-+ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client connecting");
-+ break;
-+
-+ case AVAHI_CLIENT_FAILURE:
-+ /*
-+ * Avahi client failed, close it to allow a clean restart.
-+ */
-+ cupsdLogMessage (CUPSD_LOG_ERROR,
-+ "Avahi client failed, "
-+ "closing client to allow a clean restart");
-+
-+ for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers);
-+ printer;
-+ printer = (cupsd_printer_t *)cupsArrayNext(Printers))
-+ dnssdDeregisterPrinter (printer);
-+
-+ avahi_client_free(client);
-+ AvahiCupsClientConnecting = 0;
-+ AvahiCupsClient = NULL;
-+
-+ break;
-+
-+ default:
-+ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client state: %d", state);
-+ }
-+}
-+#endif /* HAVE_AVAHI */
-+
-+
- /*
- * 'get_auth_info_required()' - Get the auth-info-required value to advertise.
- */
-diff -up cups-1.4.7/scheduler/dirsvc.h.avahi cups-1.4.7/scheduler/dirsvc.h
---- cups-1.4.7/scheduler/dirsvc.h.avahi 2009-05-14 19:54:37.000000000 +0200
-+++ cups-1.4.7/scheduler/dirsvc.h 2011-06-28 11:55:27.042868318 +0200
-@@ -32,6 +32,10 @@
- # endif /* HAVE_LDAP_SSL_H */
- #endif /* HAVE_LDAP */
-
-+#ifdef HAVE_AVAHI
-+# include
-+#endif /* HAVE_AVAHI */
-+
- /*
- * Browse protocols...
- */
-@@ -132,17 +136,20 @@ VAR int PollPipe VALUE(0);
- VAR cupsd_statbuf_t *PollStatusBuffer VALUE(NULL);
- /* Status buffer for pollers */
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+VAR int DNSSDPort VALUE(0);
-+ /* Port number to register */
- VAR char *DNSSDComputerName VALUE(NULL),
- /* Computer/server name */
- *DNSSDHostName VALUE(NULL);
- /* Hostname */
--VAR cups_array_t *DNSSDAlias VALUE(NULL);
-- /* List of dynamic ServerAlias's */
--VAR int DNSSDPort VALUE(0);
-- /* Port number to register */
- VAR cups_array_t *DNSSDPrinters VALUE(NULL);
- /* Printers we have registered */
-+#endif /* HAVE_DNSSD || HAVE_AVAHI */
-+
-+#ifdef HAVE_DNSSD
-+VAR cups_array_t *DNSSDAlias VALUE(NULL);
-+ /* List of dynamic ServerAlias's */
- VAR DNSServiceRef DNSSDRef VALUE(NULL),
- /* Master DNS-SD service reference */
- WebIFRef VALUE(NULL),
-@@ -151,6 +158,17 @@ VAR DNSServiceRef DNSSDRef VALUE(NULL),
- /* Remote printer browse reference */
- #endif /* HAVE_DNSSD */
-
-+#ifdef HAVE_AVAHI
-+VAR AvahiCupsPoll *AvahiCupsPollHandle VALUE(NULL);
-+ /* AvahiCupsPoll object */
-+VAR AvahiClient *AvahiCupsClient VALUE(NULL);
-+ /* AvahiClient object */
-+VAR int AvahiCupsClientConnecting VALUE(0);
-+ /* AvahiClient object (waiting) */
-+VAR AvahiEntryGroup *AvahiWebIFGroup VALUE(NULL);
-+ /* Web interface entry group */
-+#endif /* HAVE_AVAHI */
-+
- #ifdef HAVE_LIBSLP
- VAR SLPHandle BrowseSLPHandle VALUE(NULL);
- /* SLP API handle */
-@@ -194,13 +212,14 @@ extern void cupsdRegisterPrinter(cupsd_p
- extern void cupsdRestartPolling(void);
- extern void cupsdSaveRemoteCache(void);
- extern void cupsdSendBrowseList(void);
-+extern void cupsdStartAvahiClient(void);
- extern void cupsdStartBrowsing(void);
- extern void cupsdStartPolling(void);
- extern void cupsdStopBrowsing(void);
- extern void cupsdStopPolling(void);
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- extern void cupsdUpdateDNSSDName(void);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
- #ifdef HAVE_LDAP
- extern void cupsdUpdateLDAPBrowse(void);
- #endif /* HAVE_LDAP */
-diff -up cups-1.4.7/scheduler/main.c.avahi cups-1.4.7/scheduler/main.c
---- cups-1.4.7/scheduler/main.c.avahi 2011-06-28 11:55:26.943869690 +0200
-+++ cups-1.4.7/scheduler/main.c 2011-06-28 11:55:27.043868305 +0200
-@@ -135,6 +135,10 @@ main(int argc, /* I - Number of comm
- cupsd_listener_t *lis; /* Current listener */
- time_t current_time, /* Current time */
- activity, /* Client activity timer */
-+#ifdef HAVE_AVAHI
-+ avahi_client_time, /* Time for next Avahi client
-+ check */
-+#endif /* HAVE_AVAHI */
- browse_time, /* Next browse send time */
- senddoc_time, /* Send-Document time */
- expire_time, /* Subscription expire time */
-@@ -161,6 +165,10 @@ main(int argc, /* I - Number of comm
- int launchd_idle_exit;
- /* Idle exit on select timeout? */
- #endif /* HAVE_LAUNCHD */
-+#ifdef HAVE_AVAHI
-+ cupsd_timeout_t *tmo; /* Next scheduled timed callback */
-+ long tmo_delay; /* Time before it must be called */
-+#endif /* HAVE_AVAHI */
-
-
- #ifdef HAVE_GETEUID
-@@ -561,6 +569,14 @@ main(int argc, /* I - Number of comm
-
- httpInitialize();
-
-+#ifdef HAVE_AVAHI
-+ /*
-+ * Initialize timed callback structures.
-+ */
-+
-+ cupsdInitTimeouts();
-+#endif /* HAVE_AVAHI */
-+
- cupsdStartServer();
-
- /*
-@@ -686,6 +702,9 @@ main(int argc, /* I - Number of comm
- */
-
- current_time = time(NULL);
-+#ifdef HAVE_AVAHI
-+ avahi_client_time = current_time;
-+#endif /* HAVE_AVAHI */
- browse_time = current_time;
- event_time = current_time;
- expire_time = current_time;
-@@ -900,6 +919,26 @@ main(int argc, /* I - Number of comm
- }
- #endif /* __APPLE__ */
-
-+#ifdef HAVE_AVAHI
-+ /*
-+ * If a timed callback is due, run it.
-+ */
-+
-+ tmo = cupsdNextTimeout (&tmo_delay);
-+ if (tmo && tmo_delay == 0)
-+ cupsdRunTimeout (tmo);
-+
-+ /*
-+ * Try to restart the Avahi client every 10 seconds if needed...
-+ */
-+
-+ if ((current_time - avahi_client_time) >= 10)
-+ {
-+ avahi_client_time = current_time;
-+ cupsdStartAvahiClient();
-+ }
-+#endif /* HAVE_AVAHI */
-+
- #ifndef __APPLE__
- /*
- * Update the network interfaces once a minute...
-@@ -1925,6 +1964,10 @@ select_timeout(int fds) /* I - Number
- cupsd_job_t *job; /* Job information */
- cupsd_subscription_t *sub; /* Subscription information */
- const char *why; /* Debugging aid */
-+#ifdef HAVE_AVAHI
-+ cupsd_timeout_t *tmo; /* Timed callback */
-+ long tmo_delay; /* Seconds before calling it */
-+#endif /* HAVE_AVAHI */
-
-
- /*
-@@ -1967,6 +2010,19 @@ select_timeout(int fds) /* I - Number
- }
- #endif /* __APPLE__ */
-
-+#ifdef HAVE_AVAHI
-+ /*
-+ * See if there are any scheduled timed callbacks to run.
-+ */
-+
-+ tmo = cupsdNextTimeout (&tmo_delay);
-+ if (tmo)
-+ {
-+ timeout = tmo_delay;
-+ why = "run a timed callback";
-+ }
-+#endif /* HAVE_AVAHI */
-+
- /*
- * Check whether we are accepting new connections...
- */
-diff -up cups-1.4.7/scheduler/Makefile.avahi cups-1.4.7/scheduler/Makefile
---- cups-1.4.7/scheduler/Makefile.avahi 2011-06-28 11:55:27.007868803 +0200
-+++ cups-1.4.7/scheduler/Makefile 2011-06-28 11:55:27.044868291 +0200
-@@ -17,6 +17,7 @@ include ../Makedefs
-
- CUPSDOBJS = \
- auth.o \
-+ avahi.o \
- banners.o \
- cert.o \
- classes.o \
-@@ -39,7 +40,8 @@ CUPSDOBJS = \
- server.o \
- statbuf.o \
- subscriptions.o \
-- sysman.o
-+ sysman.o \
-+ timeout.o
- LIBOBJS = \
- filter.o \
- mime.o \
-diff -up cups-1.4.7/scheduler/printers.c.avahi cups-1.4.7/scheduler/printers.c
---- cups-1.4.7/scheduler/printers.c.avahi 2011-06-28 11:55:26.928869897 +0200
-+++ cups-1.4.7/scheduler/printers.c 2011-06-28 11:55:27.046868263 +0200
-@@ -932,10 +932,10 @@ cupsdDeletePrinter(
- cupsdClearString(&p->alert);
- cupsdClearString(&p->alert_description);
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- cupsdClearString(&p->product);
- cupsdClearString(&p->pdl);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-
- cupsArrayDelete(p->filetypes);
-
-@@ -1304,9 +1304,9 @@ cupsdLoadAllPrinters(void)
- {
- if (value)
- {
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- p->product = _cupsStrAlloc(value);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
- }
- else
- cupsdLogMessage(CUPSD_LOG_ERROR,
-@@ -1720,10 +1720,10 @@ cupsdSaveAllPrinters(void)
-
- cupsFilePrintf(fp, "Type %d\n", printer->type);
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- if (printer->product)
- cupsFilePutConf(fp, "Product", printer->product);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-
- for (ptr = (char *)cupsArrayFirst(printer->filters);
- ptr;
-@@ -3858,7 +3858,7 @@ add_printer_formats(cupsd_printer_t *p)
- attr->values[i].string.text = _cupsStrAlloc(mimetype);
- }
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- {
- char pdl[1024]; /* Buffer to build pdl list */
- mime_filter_t *filter; /* MIME filter looping var */
-@@ -3912,7 +3912,7 @@ add_printer_formats(cupsd_printer_t *p)
-
- cupsdSetString(&p->pdl, pdl);
- }
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
- }
-
-
-@@ -4979,9 +4979,9 @@ load_ppd(cupsd_printer_t *p) /* I - Pri
- attr->values[i].string.text = _cupsStrAlloc("bcp");
- }
-
--#ifdef HAVE_DNSSD
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
- cupsdSetString(&p->product, ppd->product);
--#endif /* HAVE_DNSSD */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
-
- if (ppdFindAttr(ppd, "APRemoteQueueID", NULL))
- p->type |= CUPS_PRINTER_REMOTE;
-diff -up cups-1.4.7/scheduler/printers.h.avahi cups-1.4.7/scheduler/printers.h
---- cups-1.4.7/scheduler/printers.h.avahi 2010-03-31 00:07:33.000000000 +0200
-+++ cups-1.4.7/scheduler/printers.h 2011-06-28 11:55:27.048868235 +0200
-@@ -16,6 +16,9 @@
- #ifdef HAVE_DNSSD
- # include
- #endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+# include "avahi.h"
-+#endif /* HAVE_AVAHI */
- #include
-
-
-@@ -99,17 +102,24 @@ typedef struct cupsd_printer_s
- char *recoverable; /* com.apple.print.recoverable-message */
- _pwg_t *pwg; /* PWG<->PPD mapping data */
-
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+ char *reg_name; /* Name used for service registration */
-+ char *product, /* PPD Product string */
-+ *pdl; /* pdl value for TXT record */
-+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */
- #ifdef HAVE_DNSSD
-- char *reg_name, /* Name used for service registration */
-- *product, /* PPD Product string */
-- *pdl, /* pdl value for TXT record */
-- *ipp_txt, /* IPP TXT record contents */
-+ char *ipp_txt, /* IPP TXT record contents */
- *printer_txt; /* LPD TXT record contents */
- int ipp_len, /* IPP TXT record length */
- printer_len; /* LPD TXT record length */
- DNSServiceRef ipp_ref, /* Reference for _ipp._tcp,_cups */
- printer_ref; /* Reference for _printer._tcp */
- #endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+ AvahiStringList *ipp_txt, /* IPP TXT record */
-+ *printer_txt; /* LPD TXT record */
-+ AvahiEntryGroup *avahi_group; /* Avahi entry group */
-+#endif /* HAVE_AVAHI */
- } cupsd_printer_t;
-
-
-diff -up cups-1.4.7/scheduler/timeout.c.avahi cups-1.4.7/scheduler/timeout.c
---- cups-1.4.7/scheduler/timeout.c.avahi 2011-06-28 11:55:27.049868221 +0200
-+++ cups-1.4.7/scheduler/timeout.c 2011-06-28 11:55:27.049868221 +0200
-@@ -0,0 +1,195 @@
-+/*
-+ * "$Id$"
-+ *
-+ * Timeout functions for the Common UNIX Printing System (CUPS).
-+ *
-+ * Copyright (C) 2010 Red Hat, Inc.
-+ * Authors:
-+ * Tim Waugh
-+ *
-+ * Distribution and use rights are outlined in the file "LICENSE.txt"
-+ * which should have been included with this file. If this file is
-+ * file is missing or damaged, see the license at "http://www.cups.org/".
-+ *
-+ * Contents:
-+ *
-+ * cupsdInitTimeouts() - Initialise timeout structure.
-+ * cupsdAddTimeout() - Add a timed callback.
-+ * cupsdNextTimeout() - Find the next enabled timed callback.
-+ * cupsdUpdateTimeout() - Adjust the time of a timed callback or disable it.
-+ * cupsdRemoveTimeout() - Discard a timed callback.
-+ * compare_timeouts() - Compare timed callbacks for array sorting.
-+ */
-+
-+#include
-+
-+#ifdef HAVE_AVAHI /* Applies to entire file... */
-+
-+/*
-+ * Include necessary headers...
-+ */
-+
-+#include "cupsd.h"
-+
-+#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
-+# include
-+#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
-+
-+#ifdef HAVE_AVAHI
-+# include
-+#endif /* HAVE_AVAHI */
-+
-+
-+struct _cupsd_timeout_s
-+{
-+ struct timeval when;
-+ int enabled;
-+ cupsd_timeoutfunc_t callback;
-+ void *data;
-+};
-+
-+/*
-+ * Local functions...
-+ */
-+
-+/*
-+ * 'compare_timeouts()' - Compare timed callbacks for array sorting.
-+ */
-+
-+static int
-+compare_timeouts (cupsd_timeout_t *p0, cupsd_timeout_t *p1)
-+{
-+ if (!p0->enabled || !p1->enabled)
-+ {
-+ if (!p0->enabled && !p1->enabled)
-+ return (0);
-+
-+ return (p0->enabled ? -1 : 1);
-+ }
-+
-+ return (avahi_timeval_compare (&p0->when, &p1->when));
-+}
-+
-+
-+/*
-+ * 'cupsdInitTimeouts()' - Initialise timeout structures.
-+ */
-+
-+void
-+cupsdInitTimeouts(void)
-+{
-+ Timeouts = cupsArrayNew ((cups_array_func_t)compare_timeouts, NULL);
-+}
-+
-+
-+/*
-+ * 'cupsdAddTimeout()' - Add a timed callback.
-+ */
-+
-+cupsd_timeout_t * /* O - Timeout handle */
-+cupsdAddTimeout(const struct timeval *tv, /* I - Absolute time */
-+ cupsd_timeoutfunc_t cb, /* I - Callback function */
-+ void *data) /* I - User data */
-+{
-+ cupsd_timeout_t *timeout;
-+
-+ timeout = malloc (sizeof(cupsd_timeout_t));
-+ if (timeout != NULL)
-+ {
-+ timeout->enabled = (tv != NULL);
-+ if (tv)
-+ {
-+ timeout->when.tv_sec = tv->tv_sec;
-+ timeout->when.tv_usec = tv->tv_usec;
-+ }
-+
-+ timeout->callback = cb;
-+ timeout->data = data;
-+ cupsArrayAdd (Timeouts, timeout);
-+ }
-+
-+ return timeout;
-+}
-+
-+
-+/*
-+ * 'cupsdNextTimeout()' - Find the next enabled timed callback.
-+ */
-+
-+cupsd_timeout_t * /* O - Next enabled timeout or NULL */
-+cupsdNextTimeout(long *delay) /* O - Seconds before scheduled */
-+{
-+ cupsd_timeout_t *first = cupsArrayFirst (Timeouts);
-+ struct timeval curtime;
-+
-+ if (first && !first->enabled)
-+ first = NULL;
-+
-+ if (first && delay)
-+ {
-+ gettimeofday (&curtime, NULL);
-+ if (avahi_timeval_compare (&curtime, &first->when) > 0)
-+ {
-+ *delay = 0;
-+ } else {
-+ *delay = 1 + first->when.tv_sec - curtime.tv_sec;
-+ if (first->when.tv_usec < curtime.tv_usec)
-+ (*delay)--;
-+ }
-+ }
-+
-+ return (first);
-+}
-+
-+
-+/*
-+ * 'cupsdRunTimeout()' - Run a timed callback.
-+ */
-+
-+void
-+cupsdRunTimeout(cupsd_timeout_t *timeout) /* I - Timeout */
-+{
-+ if (!timeout)
-+ return;
-+ timeout->enabled = 0;
-+ if (!timeout->callback)
-+ return;
-+ timeout->callback (timeout, timeout->data);
-+}
-+
-+/*
-+ * 'cupsdUpdateTimeout()' - Adjust the time of a timed callback or disable it.
-+ */
-+
-+void
-+cupsdUpdateTimeout(cupsd_timeout_t *timeout, /* I - Timeout */
-+ const struct timeval *tv) /* I - Absolute time or NULL */
-+{
-+ cupsArrayRemove (Timeouts, timeout);
-+ timeout->enabled = (tv != NULL);
-+ if (tv)
-+ {
-+ timeout->when.tv_sec = tv->tv_sec;
-+ timeout->when.tv_usec = tv->tv_usec;
-+ }
-+ cupsArrayAdd (Timeouts, timeout);
-+}
-+
-+
-+/*
-+ * 'cupsdRemoveTimeout()' - Discard a timed callback.
-+ */
-+
-+void
-+cupsdRemoveTimeout(cupsd_timeout_t *timeout) /* I - Timeout */
-+{
-+ cupsArrayRemove (Timeouts, timeout);
-+ free (timeout);
-+}
-+
-+
-+#endif /* HAVE_AVAHI ... from top of file */
-+
-+/*
-+ * End of "$Id$".
-+ */
diff --git a/cups.spec b/cups.spec
index 4ce6d57..55c280e 100644
--- a/cups.spec
+++ b/cups.spec
@@ -13,7 +13,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.4.7
-Release: 1%{?dist}
+Release: 2%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -71,8 +71,13 @@ Patch32: cups-texttops-rotate-page.patch
Patch33: cups-usb-parallel.patch
Patch34: cups-str3535.patch
-Patch40: cups-avahi.patch
-Patch41: cups-icc.patch
+Patch40: cups-avahi-1-config.patch
+Patch41: cups-avahi-2-backend.patch
+Patch42: cups-avahi-3-timeouts.patch
+Patch43: cups-avahi-4-poll.patch
+Patch44: cups-avahi-5-services.patch
+
+Patch45: cups-icc.patch
Patch100: cups-lspp.patch
@@ -283,10 +288,17 @@ module.
# Set the default RIPCache to 128m (STR #3535, bug #549901).
%patch34 -p1 -b .str3535
-# Avahi support in the dnssd backend.
-%patch40 -p1 -b .avahi
+# Avahi support:
+# - discovery in the dnssd backend
+# - service announcement in the scheduler
+%patch40 -p1 -b .avahi-1-config
+%patch41 -p1 -b .avahi-2-backend
+%patch42 -p1 -b .avahi-3-timeouts
+%patch43 -p1 -b .avahi-4-poll
+%patch44 -p1 -b .avahi-5-services
+
# ICC colord support.
-%patch41 -p1 -b .icc
+%patch45 -p1 -b .icc
%if %lspp
# LSPP support.
@@ -606,6 +618,9 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
+* Tue Jun 28 2011 Tim Waugh 1:1.4.7-2
+- Updated avahi patches.
+
* Tue Jun 28 2011 Jiri Popelka 1:1.4.7-1
- 1.4.7.