-diff -up cups-1.5.0/config.h.in.avahi-1-config cups-1.5.0/config.h.in
---- cups-1.5.0/config.h.in.avahi-1-config 2011-06-16 21:12:16.000000000 +0100
-+++ cups-1.5.0/config.h.in 2011-08-05 15:04:09.535759988 +0100
+diff -up cups-1.5.2/config.h.in.avahi-1-config cups-1.5.2/config.h.in
+--- cups-1.5.2/config.h.in.avahi-1-config 2011-06-16 21:12:16.000000000 +0100
++++ cups-1.5.2/config.h.in 2012-03-14 15:04:51.365347165 +0000
@@ -390,6 +390,13 @@
* Do we have <sys/ioctl.h>?
*/
-diff -up cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config cups-1.5.0/config-scripts/cups-dnssd.m4
---- cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config 2011-05-12 06:21:56.000000000 +0100
-+++ cups-1.5.0/config-scripts/cups-dnssd.m4 2011-08-05 15:04:09.525760307 +0100
+diff -up cups-1.5.2/config-scripts/cups-dnssd.m4.avahi-1-config cups-1.5.2/config-scripts/cups-dnssd.m4
+--- cups-1.5.2/config-scripts/cups-dnssd.m4.avahi-1-config 2011-05-12 06:21:56.000000000 +0100
++++ cups-1.5.2/config-scripts/cups-dnssd.m4 2012-03-14 15:04:51.365347165 +0000
@@ -23,6 +23,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dn
DNSSDLIBS=""
DNSSD_BACKEND=""
-diff -up cups-1.5.0/backend/dnssd.c.avahi-2-backend cups-1.5.0/backend/dnssd.c
---- cups-1.5.0/backend/dnssd.c.avahi-2-backend 2011-08-05 15:04:46.182591844 +0100
-+++ cups-1.5.0/backend/dnssd.c 2011-08-05 15:05:13.868710181 +0100
+diff -up cups-1.5.3/backend/dnssd.c.avahi-2-backend cups-1.5.3/backend/dnssd.c
+--- cups-1.5.3/backend/dnssd.c.avahi-2-backend 2012-05-15 16:53:18.164774446 +0200
++++ cups-1.5.3/backend/dnssd.c 2012-05-15 17:09:07.684155704 +0200
@@ -15,14 +15,21 @@
*
* Contents:
static void browse_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
-@@ -93,12 +131,6 @@ static void browse_local_callback(DNSSe
- const char *regtype,
+@@ -95,13 +133,6 @@ static void browse_local_callback(DNSSe
const char *replyDomain,
- void *context);
+ void *context)
+ __attribute__((nonnull(1,5,6,7,8)));
-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);
+- const char *replyDomain)
+- __attribute__((nonnull(1,2,3,4)));
static void query_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
-@@ -107,9 +139,118 @@ static void query_callback(DNSServiceRe
- uint16_t rrclass, uint16_t rdlen,
+@@ -111,10 +142,119 @@ static void query_callback(DNSServiceRe
const void *rdata, uint32_t ttl,
- void *context);
+ void *context)
+ __attribute__((nonnull(1,5,9,11)));
+#endif /* HAVE_DNSSD */
+#ifdef HAVE_AVAHI
+static void avahi_client_callback (AvahiClient *client,
+ 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 cups_device_t *get_device(cups_array_t *devices,
+ const char *serviceName,
+ const char *regtype,
-+ const char *replyDomain);
++ const char *replyDomain)
++ __attribute__((nonnull(1,2,3,4)));
static void sigterm_handler(int sig);
- static void unquote(char *dst, const char *src, size_t dstsize);
+ static void unquote(char *dst, const char *src, size_t dstsize)
+ __attribute__((nonnull(1,2)));
+#ifdef HAVE_AVAHI
+static AvahiSimplePoll *simple_poll = NULL;
/*
* 'main()' - Browse for printers.
-@@ -120,6 +261,13 @@ main(int argc, /* I - Number of comm
+@@ -125,6 +265,13 @@ main(int argc, /* I - Number of comm
char *argv[]) /* I - Command-line arguments */
{
const char *name; /* Backend name */
DNSServiceRef main_ref, /* Main service reference */
fax_ipp_ref, /* IPP fax service reference */
ipp_ref, /* IPP service reference */
-@@ -133,12 +281,11 @@ main(int argc, /* I - Number of comm
+@@ -138,12 +285,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 */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-@@ -198,6 +345,49 @@ main(int argc, /* I - Number of comm
+@@ -203,6 +349,49 @@ main(int argc, /* I - Number of comm
* Browse for different kinds of printers...
*/
if (DNSServiceCreateConnection(&main_ref) != kDNSServiceErr_NoError)
{
perror("ERROR: Unable to create service connection");
-@@ -258,6 +448,7 @@ main(int argc, /* I - Number of comm
+@@ -263,6 +452,7 @@ main(int argc, /* I - Number of comm
riousbprint_ref = main_ref;
DNSServiceBrowse(&riousbprint_ref, kDNSServiceFlagsShareConnection, 0,
"_riousbprint._tcp", NULL, browse_callback, devices);
/*
* Loop until we are killed...
-@@ -265,6 +456,9 @@ main(int argc, /* I - Number of comm
+@@ -270,6 +460,9 @@ main(int argc, /* I - Number of comm
while (!job_canceled)
{
FD_ZERO(&input);
FD_SET(fd, &input);
-@@ -284,11 +478,35 @@ main(int argc, /* I - Number of comm
+@@ -289,11 +482,35 @@ main(int argc, /* I - Number of comm
}
else
{
cups_device_t *best; /* Best matching device */
char device_uri[1024]; /* Device URI */
int count; /* Number of queries */
-@@ -302,6 +520,7 @@ main(int argc, /* I - Number of comm
+@@ -307,6 +524,7 @@ main(int argc, /* I - Number of comm
if (device->sent)
sent ++;
if (device->ref)
count ++;
-@@ -333,14 +552,23 @@ main(int argc, /* I - Number of comm
+@@ -338,14 +556,23 @@ main(int argc, /* I - Number of comm
count ++;
}
}
if (!best)
best = device;
-@@ -401,6 +629,7 @@ main(int argc, /* I - Number of comm
+@@ -406,6 +633,7 @@ main(int argc, /* I - Number of comm
}
/*
* 'browse_callback()' - Browse devices.
*/
-@@ -489,6 +718,7 @@ browse_local_callback(
+@@ -494,6 +722,7 @@ browse_local_callback(
device->fullName);
device->sent = 1;
}
/*
-@@ -569,6 +799,41 @@ exec_backend(char **argv) /* I - Comman
+@@ -574,6 +803,41 @@ exec_backend(char **argv) /* I - Comman
/*
* 'get_device()' - Create or update a device.
*/
-@@ -589,20 +854,7 @@ get_device(cups_array_t *devices, /* I -
+@@ -594,20 +858,7 @@ get_device(cups_array_t *devices, /* I -
*/
key.name = (char *)serviceName;
for (device = cupsArrayFind(devices, &key);
device;
-@@ -622,8 +874,14 @@ get_device(cups_array_t *devices, /* I -
+@@ -627,8 +878,14 @@ get_device(cups_array_t *devices, /* I -
free(device->domain);
device->domain = strdup(replyDomain);
free(device->fullName);
device->fullName = strdup(fullName);
}
-@@ -643,6 +901,9 @@ get_device(cups_array_t *devices, /* I -
+@@ -648,6 +905,9 @@ get_device(cups_array_t *devices, /* I -
device->domain = strdup(replyDomain);
device->type = key.type;
device->priority = 50;
cupsArrayAdd(devices, device);
-@@ -650,13 +911,20 @@ get_device(cups_array_t *devices, /* I -
+@@ -655,13 +915,20 @@ get_device(cups_array_t *devices, /* I -
* Set the "full name" of this service, which is used for queries...
*/
/*
* 'query_callback()' - Process query data.
*/
-@@ -680,7 +948,7 @@ query_callback(
+@@ -685,7 +952,7 @@ query_callback(
*ptr; /* Pointer into string */
cups_device_t dkey, /* Search key */
*device; /* Device */
fprintf(stderr, "DEBUG2: query_callback(sdRef=%p, flags=%x, "
"interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
-@@ -714,94 +982,233 @@ query_callback(
+@@ -719,94 +986,233 @@ query_callback(
if ((ptr = strstr(name, "._")) != NULL)
*ptr = '\0';
else
- dkey.type = CUPS_DEVICE_RIOUSBPRINT;
+ fprintf (stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", name);
-+
+
+- for (device = cupsArrayFind(devices, &dkey);
+ avahi_service_resolver_free (resolver);
+}
+
+}
+#endif /* HAVE_AVAHI */
+
-
-- for (device = cupsArrayFind(devices, &dkey);
++
+/*
+ * 'find_device()' - Find a device from its name and domain.
+ */
{
/*
* Add USB device ID information...
-@@ -856,6 +1263,10 @@ query_callback(
+@@ -861,6 +1267,10 @@ query_callback(
if (device->type == CUPS_DEVICE_PRINTER)
device->sent = 1;
}
}
if (device->device_id)
-@@ -912,11 +1323,9 @@ query_callback(
+@@ -917,11 +1327,9 @@ query_callback(
}
}
/*
* 'sigterm_handler()' - Handle termination signals...
*/
-diff -up cups-1.5.0/cups/http-support.c.avahi-2-backend cups-1.5.0/cups/http-support.c
---- cups-1.5.0/cups/http-support.c.avahi-2-backend 2011-06-10 23:06:26.000000000 +0100
-+++ cups-1.5.0/cups/http-support.c 2011-08-05 15:05:13.870710117 +0100
+diff -up cups-1.5.3/cups/http-support.c.avahi-2-backend cups-1.5.3/cups/http-support.c
+--- cups-1.5.3/cups/http-support.c.avahi-2-backend 2012-02-15 02:06:12.000000000 +0100
++++ cups-1.5.3/cups/http-support.c 2012-05-15 17:04:51.045944634 +0200
@@ -43,6 +43,10 @@
* http_copy_decode() - Copy and decode a URI.
* http_copy_encode() - Copy and encode a URI.
/*
* 'httpAssembleURI()' - Assemble a uniform resource identifier from its
-@@ -1431,6 +1458,9 @@ _httpResolveURI(
+@@ -1434,6 +1461,9 @@ _httpResolveURI(
if (strstr(hostname, "._tcp"))
{
#ifdef HAVE_DNSSD
# ifdef WIN32
# pragma comment(lib, "dnssd.lib")
-@@ -1449,6 +1479,17 @@ _httpResolveURI(
+@@ -1452,6 +1482,17 @@ _httpResolveURI(
fd_set input_set; /* Input set for select() */
struct timeval stimeout; /* Timeout value for select() */
#endif /* HAVE_POLL */
if (options & _HTTP_RESOLVE_STDERR)
fprintf(stderr, "DEBUG: Resolving \"%s\"...\n", hostname);
-@@ -1485,9 +1526,16 @@ _httpResolveURI(
+@@ -1488,9 +1529,16 @@ _httpResolveURI(
if (domain)
*domain++ = '\0';
resolved_uri[0] = '\0';
DEBUG_printf(("6_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
-@@ -1501,6 +1549,7 @@ _httpResolveURI(
+@@ -1504,6 +1552,7 @@ _httpResolveURI(
uri = NULL;
if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
{
localref = ref;
-@@ -1608,6 +1657,36 @@ _httpResolveURI(
+@@ -1611,6 +1660,36 @@ _httpResolveURI(
DNSServiceRefDeallocate(ref);
}
if (options & _HTTP_RESOLVE_STDERR)
{
-@@ -1619,13 +1698,13 @@ _httpResolveURI(
+@@ -1622,13 +1701,13 @@ _httpResolveURI(
fputs("STATE: -connecting-to-device,offline-report\n", stderr);
}
if ((options & _HTTP_RESOLVE_STDERR) && !uri)
_cupsLangPrintFilter(stderr, "ERROR", _("Unable to find printer."));
-@@ -1895,6 +1974,116 @@ http_resolve_cb(
+@@ -1916,6 +1995,115 @@ http_resolve_cb(
+ }
#endif /* HAVE_DNSSD */
-
+#ifdef HAVE_AVAHI
+/*
+ * 'avahi_resolve_uri_client_cb()' - Avahi client callback for resolving URI.
+}
+#endif /* HAVE_AVAHI */
+
-+
+
/*
* End of "$Id$".
- */
-diff -up cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts cups-1.5.0/scheduler/cupsd.h
---- cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts 2011-05-11 23:17:34.000000000 +0100
-+++ cups-1.5.0/scheduler/cupsd.h 2011-08-05 15:06:13.570811440 +0100
+diff -up cups-1.5.2/scheduler/cupsd.h.avahi-3-timeouts cups-1.5.2/scheduler/cupsd.h
+--- cups-1.5.2/scheduler/cupsd.h.avahi-3-timeouts 2011-05-11 23:17:34.000000000 +0100
++++ cups-1.5.2/scheduler/cupsd.h 2012-03-14 15:06:36.509476983 +0000
@@ -140,6 +140,15 @@ extern const char *cups_hstrerror(int);
typedef void (*cupsd_selfunc_t)(void *data);
/*
* End of "$Id$".
-diff -up cups-1.5.0/scheduler/main.c.avahi-3-timeouts cups-1.5.0/scheduler/main.c
---- cups-1.5.0/scheduler/main.c.avahi-3-timeouts 2011-08-05 15:05:45.590700888 +0100
-+++ cups-1.5.0/scheduler/main.c 2011-08-05 15:06:13.572811372 +0100
+diff -up cups-1.5.2/scheduler/main.c.avahi-3-timeouts cups-1.5.2/scheduler/main.c
+--- cups-1.5.2/scheduler/main.c.avahi-3-timeouts 2012-03-14 15:04:17.655305548 +0000
++++ cups-1.5.2/scheduler/main.c 2012-03-14 15:06:36.511476986 +0000
@@ -146,6 +146,10 @@ main(int argc, /* I - Number of comm
int launchd_idle_exit;
/* Idle exit on select timeout? */
#ifndef __APPLE__
/*
* Update the network interfaces once a minute...
-@@ -1787,6 +1809,10 @@ select_timeout(int fds) /* I - Number
+@@ -1787,6 +1809,10 @@ select_timeout(int fds) /* I - Number
cupsd_job_t *job; /* Job information */
cupsd_subscription_t *sub; /* Subscription information */
const char *why; /* Debugging aid */
/*
-@@ -1829,6 +1855,19 @@ select_timeout(int fds) /* I - Number
+@@ -1829,6 +1855,19 @@ select_timeout(int fds) /* I - Number
}
#endif /* __APPLE__ */
+ * See if there are any scheduled timed callbacks to run.
+ */
+
-+ tmo = cupsdNextTimeout (&tmo_delay);
-+ if (tmo)
++ if ((tmo = cupsdNextTimeout(&tmo_delay)) != NULL &&
++ (now + tmo_delay) < timeout)
+ {
+ timeout = tmo_delay;
+ why = "run a timed callback";
/*
* Check whether we are accepting new connections...
*/
-diff -up cups-1.5.0/scheduler/Makefile.avahi-3-timeouts cups-1.5.0/scheduler/Makefile
---- cups-1.5.0/scheduler/Makefile.avahi-3-timeouts 2011-08-05 15:05:45.673698248 +0100
-+++ cups-1.5.0/scheduler/Makefile 2011-08-05 15:06:13.569811476 +0100
+diff -up cups-1.5.2/scheduler/Makefile.avahi-3-timeouts cups-1.5.2/scheduler/Makefile
+--- cups-1.5.2/scheduler/Makefile.avahi-3-timeouts 2012-03-14 15:04:17.685305586 +0000
++++ cups-1.5.2/scheduler/Makefile 2012-03-14 15:06:36.508476980 +0000
@@ -39,7 +39,8 @@ CUPSDOBJS = \
server.o \
statbuf.o \
LIBOBJS = \
filter.o \
mime.o \
-diff -up cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts cups-1.5.0/scheduler/timeout.c
---- cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts 2011-08-05 15:06:13.573811341 +0100
-+++ cups-1.5.0/scheduler/timeout.c 2011-08-05 15:06:13.573811341 +0100
-@@ -0,0 +1,195 @@
+diff -up cups-1.5.2/scheduler/timeout.c.avahi-3-timeouts cups-1.5.2/scheduler/timeout.c
+--- cups-1.5.2/scheduler/timeout.c.avahi-3-timeouts 2012-03-14 15:06:36.552477037 +0000
++++ cups-1.5.2/scheduler/timeout.c 2012-03-14 15:06:36.552477037 +0000
+@@ -0,0 +1,235 @@
+/*
+ * "$Id$"
+ *
+ * Timeout functions for the Common UNIX Printing System (CUPS).
+ *
-+ * Copyright (C) 2010 Red Hat, Inc.
++ * Copyright (C) 2010, 2011 Red Hat, Inc.
+ * Authors:
+ * Tim Waugh <twaugh@redhat.com>
+ *
-+ * 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/".
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ *
++ * Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
++ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
++ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
++ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
++ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
++ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contents:
+ *
+ */
+
+static int
++compare_addrs (void *p0, void *p1)
++{
++ if (p0 == p1)
++ return (0);
++ if (p0 < p1)
++ return (-1);
++ return (1);
++}
++
++static int
+compare_timeouts (cupsd_timeout_t *p0, cupsd_timeout_t *p1)
+{
++ int addrsdiff = compare_addrs (p0, p1);
++ int tvdiff;
++
++ if (addrsdiff == 0)
++ return (0);
++
+ if (!p0->enabled || !p1->enabled)
+ {
+ if (!p0->enabled && !p1->enabled)
-+ return (0);
++ return (addrsdiff);
+
+ return (p0->enabled ? -1 : 1);
+ }
+
-+ return (avahi_timeval_compare (&p0->when, &p1->when));
++ tvdiff = avahi_timeval_compare (&p0->when, &p1->when);
++ if (tvdiff != 0)
++ return (tvdiff);
++
++ return (addrsdiff);
+}
+
+
-diff -up cups-1.5.0/scheduler/avahi.c.avahi-4-poll cups-1.5.0/scheduler/avahi.c
---- cups-1.5.0/scheduler/avahi.c.avahi-4-poll 2011-08-05 15:07:09.570033486 +0100
-+++ cups-1.5.0/scheduler/avahi.c 2011-08-05 15:07:09.570033486 +0100
-@@ -0,0 +1,445 @@
+diff -up cups-1.5.2/scheduler/avahi.c.avahi-4-poll cups-1.5.2/scheduler/avahi.c
+--- cups-1.5.2/scheduler/avahi.c.avahi-4-poll 2012-03-14 15:07:29.477542381 +0000
++++ cups-1.5.2/scheduler/avahi.c 2012-03-14 15:07:29.477542381 +0000
+@@ -0,0 +1,441 @@
+/*
+ * "$Id$"
+ *
+ * Avahi poll implementation for the CUPS scheduler.
+ *
-+ * Copyright (C) 2010 Red Hat, Inc.
++ * Copyright (C) 2010, 2011 Red Hat, Inc.
+ * Authors:
+ * Tim Waugh <twaugh@redhat.com>
+ *
-+ * 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/".
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ *
++ * Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
++ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
++ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
++ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
++ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
++ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contents:
+ *
+ * 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
+static void watch_update(AvahiWatch *watch,
+ AvahiWatchEvent events);
+static AvahiWatchEvent watch_get_events(AvahiWatch *watch);
-+static int compare_watches(AvahiWatch *p0,
-+ AvahiWatch *p1);
+
+
+/*
+ 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 = (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;
+ 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 = (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;
+{
+ AvahiWatch *watch;
+ cupsd_selfunc_t read_cb = NULL, write_cb = NULL;
++ int any_watches = 0;
+
+ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches);
+ watch;
-+ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) {
++ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches))
++ {
++ any_watches = 1;
+ if (watch->events & (AVAHI_WATCH_IN |
+ AVAHI_WATCH_ERR |
-+ AVAHI_WATCH_HUP)) {
++ AVAHI_WATCH_HUP))
++ {
+ read_cb = (cupsd_selfunc_t)watch_read_cb;
+ if (write_cb != NULL)
+ break;
+ }
+
-+ if (watch->events & AVAHI_WATCH_OUT) {
++ if (watch->events & AVAHI_WATCH_OUT)
++ {
+ write_cb = (cupsd_selfunc_t)watch_write_cb;
+ if (read_cb != NULL)
+ break;
+ else
+ cupsdRemoveSelect (watched_fd->fd);
+
-+ return (read_cb || write_cb);
++ return (any_watches);
+}
+
+/*
+
+ key.fd = fd;
+ watched_fd = cupsArrayFind (cups_poll->watched_fds, &key);
-+ if (watched_fd == NULL) {
++ if (watched_fd == NULL)
++ {
+ watched_fd = malloc(sizeof(cupsd_watched_fd_t));
-+ if (watched_fd == NULL) {
++ 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);
++ watched_fd->watches = cupsArrayNew (NULL, NULL);
++ cupsArrayAdd (cups_poll->watched_fds, watched_fd);
+ }
+
+ watch->watched_fd = watched_fd;
+ cupsArrayRemove (watched_fd->watches, watch);
+ free (watch);
+
-+ if (!watched_fd_add_select (watched_fd)) {
++ if (!watched_fd_add_select (watched_fd))
++ {
+ /* No more watches */
+ cupsArrayRemove (cups_poll->watched_fds, watched_fd);
+ free (watched_fd);
+
+
+/*
-+ * '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
+ */
+
+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);
++ /*
++ * Compare by fd (no two elements have the same fd)
++ */
+
-+ if (p0 == p1)
-+ return (0);
++ if (p0->fd == p1->fd)
++ 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);
++ return (p0->fd < p1->fd ? -1 : 1);
+}
+
+
+
+ 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->timeouts = cupsArrayNew (NULL, NULL);
+
+ cups_poll->api.userdata = cups_poll;
+ cups_poll->api.watch_new = watch_new;
+
+ 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)){
++ watched_fd = (cupsd_watched_fd_t*)cupsArrayNext(cups_poll->watched_fds))
+ cupsArrayClear (watched_fd->watches);
-+ }
+
+ cupsArrayClear (cups_poll->watched_fds);
+ cupsArrayClear (cups_poll->timeouts);
+/*
+ * End of "$Id$".
+ */
-diff -up cups-1.5.0/scheduler/avahi.h.avahi-4-poll cups-1.5.0/scheduler/avahi.h
---- cups-1.5.0/scheduler/avahi.h.avahi-4-poll 2011-08-05 15:07:09.594032723 +0100
-+++ cups-1.5.0/scheduler/avahi.h 2011-08-05 15:07:09.595032692 +0100
-@@ -0,0 +1,49 @@
+diff -up cups-1.5.2/scheduler/avahi.h.avahi-4-poll cups-1.5.2/scheduler/avahi.h
+--- cups-1.5.2/scheduler/avahi.h.avahi-4-poll 2012-03-14 15:07:29.477542381 +0000
++++ cups-1.5.2/scheduler/avahi.h 2012-03-14 15:07:29.477542381 +0000
+@@ -0,0 +1,69 @@
+/*
+ * "$Id$"
+ *
+ * Avahi poll implementation for the CUPS scheduler.
+ *
-+ * Copyright (C) 2010 Red Hat, Inc.
++ * Copyright (C) 2010, 2011 Red Hat, Inc.
+ * Authors:
+ * Tim Waugh <twaugh@redhat.com>
+ *
-+ * 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/".
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ *
++ * Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
++ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
++ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
++ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
++ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
++ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+/*
+ * End of "$Id$".
+ */
-diff -up cups-1.5.0/scheduler/Makefile.avahi-4-poll cups-1.5.0/scheduler/Makefile
---- cups-1.5.0/scheduler/Makefile.avahi-4-poll 2011-08-05 15:06:48.548700563 +0100
-+++ cups-1.5.0/scheduler/Makefile 2011-08-05 15:07:09.570033486 +0100
+diff -up cups-1.5.2/scheduler/Makefile.avahi-4-poll cups-1.5.2/scheduler/Makefile
+--- cups-1.5.2/scheduler/Makefile.avahi-4-poll 2012-03-14 15:06:36.508476980 +0000
++++ cups-1.5.2/scheduler/Makefile 2012-03-14 15:07:29.476542380 +0000
@@ -17,6 +17,7 @@ include ../Makedefs
CUPSDOBJS = \
-diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c
-index 99b8e7b..2688eff 100644
---- a/cgi-bin/admin.c
-+++ b/cgi-bin/admin.c
-@@ -1643,7 +1643,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
+diff -up cups-1.5.2/cgi-bin/admin.c.avahi-5-services cups-1.5.2/cgi-bin/admin.c
+--- cups-1.5.2/cgi-bin/admin.c.avahi-5-services 2011-08-17 22:01:53.000000000 +0100
++++ cups-1.5.2/cgi-bin/admin.c 2012-03-14 15:08:25.701611799 +0000
+@@ -1643,7 +1643,7 @@ do_config_server(http_t *http) /* I - H
else
local_protocols[0] = '\0';
if (cgiGetVariable("BROWSE_LOCAL_DNSSD"))
{
if (local_protocols[0])
-@@ -1651,7 +1651,7 @@ do_config_server(http_t *http) /* I - HTTP connection */
+@@ -1651,7 +1651,7 @@ do_config_server(http_t *http) /* I - H
else
strcat(local_protocols, "dnssd");
}
#ifdef HAVE_LDAP
if (cgiGetVariable("BROWSE_LOCAL_LDAP"))
-@@ -2718,9 +2718,9 @@ do_menu(http_t *http) /* I - HTTP connection */
+@@ -2718,9 +2718,9 @@ do_menu(http_t *http) /* I - HTTP conn
#endif /* HAVE_GSSAPI */
cgiSetVariable("KERBEROS", "");
#ifdef HAVE_LDAP
cgiSetVariable("HAVE_LDAP", "1");
-diff --git a/scheduler/client.c b/scheduler/client.c
-index e4c9b01..984dcc5 100644
---- a/scheduler/client.c
-+++ b/scheduler/client.c
-@@ -4987,7 +4987,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
+diff -up cups-1.5.2/scheduler/avahi.h.avahi-5-services cups-1.5.2/scheduler/avahi.h
+--- cups-1.5.2/scheduler/avahi.h.avahi-5-services 2012-03-14 15:07:29.477542381 +0000
++++ cups-1.5.2/scheduler/avahi.h 2012-03-14 15:08:25.701611799 +0000
+@@ -3,7 +3,7 @@
+ *
+ * Avahi poll implementation for the CUPS scheduler.
+ *
+- * Copyright (C) 2010, 2011 Red Hat, Inc.
++ * Copyright (C) 2010, 2011, 2012 Red Hat, Inc.
+ * Authors:
+ * Tim Waugh <twaugh@redhat.com>
+ *
+@@ -32,37 +32,40 @@
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+-#include <config.h>
++#ifndef _CUPS_AVAHI_H_
++# define _CUPS_AVAHI_H_
+
+-#ifdef HAVE_AVAHI
+-# include <avahi-client/client.h>
+-# include <avahi-client/publish.h>
+-#endif /* HAVE_AVAHI */
++/*
++ * Include necessary headers...
++ */
+
+-#ifdef HAVE_AUTHORIZATION_H
+-# include <Security/Authorization.h>
+-#endif /* HAVE_AUTHORIZATION_H */
++# include <config.h>
+
++# ifdef HAVE_AVAHI
++# include <avahi-client/client.h>
++# include <avahi-client/publish.h>
++# endif /* HAVE_AVAHI */
+
+-#ifdef HAVE_AVAHI
++# ifdef HAVE_AVAHI
+ typedef struct
+ {
+ AvahiPoll api;
+ cups_array_t *watched_fds;
+ cups_array_t *timeouts;
+ } AvahiCupsPoll;
+-#endif /* HAVE_AVAHI */
++# endif /* HAVE_AVAHI */
+
+ /*
+ * Prototypes...
+ */
+
+-#ifdef HAVE_AVAHI
++# 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 */
++# endif /* HAVE_AVAHI */
+
++#endif /* !_CUPS_AVAHI_H_ */
+
+ /*
+ * End of "$Id$".
+diff -up cups-1.5.2/scheduler/client.c.avahi-5-services cups-1.5.2/scheduler/client.c
+--- cups-1.5.2/scheduler/client.c.avahi-5-services 2012-01-13 23:00:22.000000000 +0000
++++ cups-1.5.2/scheduler/client.c 2012-03-14 15:08:25.703611797 +0000
+@@ -4989,7 +4989,7 @@ valid_host(cupsd_client_t *con) /* I -
!strncmp(host, "[::1]:", 6));
}
/*
* Check if the hostname is something.local (Bonjour); if so, allow it.
*/
-@@ -4996,7 +4996,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
+@@ -4998,7 +4998,7 @@ valid_host(cupsd_client_t *con) /* I -
(!_cups_strcasecmp(end, ".local") || !_cups_strncasecmp(end, ".local:", 7) ||
!_cups_strcasecmp(end, ".local.") || !_cups_strncasecmp(end, ".local.:", 8)))
return (1);
/*
* Check if the hostname is an IP address...
-diff --git a/scheduler/conf.c b/scheduler/conf.c
-index badc630..c1edd39 100644
---- a/scheduler/conf.c
-+++ b/scheduler/conf.c
-@@ -648,7 +648,7 @@ cupsdReadConfiguration(void)
+diff -up cups-1.5.2/scheduler/conf.c.avahi-5-services cups-1.5.2/scheduler/conf.c
+--- cups-1.5.2/scheduler/conf.c.avahi-5-services 2012-03-14 15:04:17.636305526 +0000
++++ cups-1.5.2/scheduler/conf.c 2012-03-14 15:08:25.706611803 +0000
+@@ -652,7 +652,7 @@ cupsdReadConfiguration(void)
Browsing = CUPS_DEFAULT_BROWSING;
DefaultShared = CUPS_DEFAULT_DEFAULT_SHARED;
cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups");
#endif /* HAVE_DNSSD */
-diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c
-index eb3c862..48dcef9 100644
---- a/scheduler/dirsvc.c
-+++ b/scheduler/dirsvc.c
+diff -up cups-1.5.2/scheduler/dirsvc.c.avahi-5-services cups-1.5.2/scheduler/dirsvc.c
+--- cups-1.5.2/scheduler/dirsvc.c.avahi-5-services 2012-03-14 15:04:17.674305572 +0000
++++ cups-1.5.2/scheduler/dirsvc.c 2012-03-14 15:08:25.709611806 +0000
@@ -27,6 +27,7 @@
* ldap_connect() - Start new LDAP connection
* ldap_reconnect() - Reconnect to LDAP Server
* cupsdStartBrowsing() - Start sending and receiving broadcast
* information.
* cupsdStartPolling() - Start polling servers as needed.
-@@ -45,6 +46,8 @@
+@@ -40,11 +41,12 @@
+ * dequote() - Remote quotes from a string.
+ * dnssdAddAlias() - Add a DNS-SD alias name.
+ * dnssdBuildTxtRecord() - Build a TXT record from printer info.
+- * dnssdComparePrinters() - Compare the registered names of two printers.
+ * dnssdDeregisterPrinter() - Stop sending broadcast information for a
* printer.
* dnssdPackTxtRecord() - Pack an array of key/value pairs into the TXT
* record format.
* dnssdRegisterCallback() - DNSServiceRegister callback.
* dnssdRegisterPrinter() - Start sending broadcast information for a
* printer or update the broadcast contents.
-@@ -83,6 +86,7 @@
+@@ -83,6 +85,7 @@
*/
#include "cupsd.h"
#include <grp.h>
#ifdef HAVE_DNSSD
-@@ -97,6 +101,17 @@
+@@ -97,6 +100,17 @@
# endif /* HAVE_SYSTEMCONFIGURATION */
# endif /* __APPLE__ */
#endif /* HAVE_DNSSD */
/*
-@@ -159,27 +174,39 @@ static void update_polling(void);
+@@ -159,27 +173,38 @@ 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 int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b);
+static void dnssdDeregisterPrinter(cupsd_printer_t *p);
+static void dnssdRegisterPrinter(cupsd_printer_t *p);
+static void dnssdStop(void);
#ifdef HAVE_LDAP
static const char * const ldap_attrs[] =/* CUPS LDAP attributes */
{
-@@ -283,10 +310,10 @@ cupsdDeregisterPrinter(
+@@ -283,10 +308,10 @@ cupsdDeregisterPrinter(
ldap_dereg_printer(p);
#endif /* HAVE_LDAP */
}
-@@ -702,10 +729,10 @@ cupsdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
+@@ -702,10 +727,10 @@ cupsdRegisterPrinter(cupsd_printer_t *p)
slpRegisterPrinter(p); */
#endif /* HAVE_LIBSLP */
}
-@@ -1419,6 +1446,27 @@ ldap_disconnect(LDAP *ld) /* I - LDAP handle */
+@@ -1419,6 +1444,36 @@ ldap_disconnect(LDAP *ld) /* I - LDAP h
#endif /* HAVE_LDAP */
+void
+cupsdStartAvahiClient(void)
+{
++ int error = 0;
++
+ 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);
++ {
++ if (avahi_client_new (avahi_cups_poll_get (AvahiCupsPollHandle),
++ AVAHI_CLIENT_NO_FAIL,
++ avahi_client_cb, NULL,
++ &error) != NULL)
++ AvahiCupsClientConnecting = 1;
++ else
++ cupsdLogMessage (CUPSD_LOG_WARN, "Avahi client failed: %d", error);
++ }
+ }
+}
+#endif /* HAVE_AVAHI */
/*
* 'cupsdStartBrowsing()' - Start sending and receiving broadcast information.
*/
-@@ -1542,13 +1590,16 @@ cupsdStartBrowsing(void)
+@@ -1542,13 +1597,16 @@ cupsdStartBrowsing(void)
else
BrowseSocket = -1;
/*
* First create a "master" connection for all registrations...
*/
-@@ -1573,6 +1624,7 @@ cupsdStartBrowsing(void)
+@@ -1573,6 +1631,7 @@ cupsdStartBrowsing(void)
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
cupsdAddSelect(fd, (cupsd_selfunc_t)dnssdUpdate, NULL, NULL);
/*
* Then get the port we use for registrations. If we are not listening
-@@ -1606,9 +1658,16 @@ cupsdStartBrowsing(void)
+@@ -1598,17 +1657,23 @@ cupsdStartBrowsing(void)
+ */
+
+ if (BrowseRemoteProtocols & BROWSE_DNSSD)
+- DNSSDPrinters = cupsArrayNew((cups_array_func_t)dnssdComparePrinters,
+- NULL);
++ DNSSDPrinters = cupsArrayNew(NULL, NULL);
+
+ /*
+ * Set the computer name and register the web interface...
*/
cupsdUpdateDNSSDName();
#ifdef HAVE_LIBSLP
if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP)
-@@ -1834,10 +1893,10 @@ cupsdStopBrowsing(void)
+@@ -1834,10 +1899,10 @@ cupsdStopBrowsing(void)
BrowseSocket = -1;
}
#ifdef HAVE_LIBSLP
if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) &&
-@@ -1902,7 +1961,7 @@ cupsdStopPolling(void)
+@@ -1902,7 +1967,7 @@ cupsdStopPolling(void)
}
/*
* 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing...
*/
-@@ -1910,8 +1969,14 @@ cupsdStopPolling(void)
+@@ -1910,8 +1975,14 @@ cupsdStopPolling(void)
void
cupsdUpdateDNSSDName(void)
{
# ifdef HAVE_SYSTEMCONFIGURATION
SCDynamicStoreRef sc; /* Context for dynamic store */
CFDictionaryRef btmm; /* Back-to-My-Mac domains */
-@@ -2042,6 +2107,7 @@ cupsdUpdateDNSSDName(void)
+@@ -2042,6 +2113,7 @@ cupsdUpdateDNSSDName(void)
else
strlcpy(webif, "CUPS Web Interface", sizeof(webif));
if (WebIFRef)
DNSServiceRefDeallocate(WebIFRef);
-@@ -2054,9 +2120,45 @@ cupsdUpdateDNSSDName(void)
+@@ -2054,9 +2126,45 @@ cupsdUpdateDNSSDName(void)
NULL)) != kDNSServiceErr_NoError)
cupsdLogMessage(CUPSD_LOG_ERROR,
"DNS-SD web interface registration failed: %d", error);
#ifdef HAVE_LDAP
-@@ -2334,13 +2436,15 @@ dnssdAddAlias(const void *key, /* I - Key */
+@@ -2334,13 +2442,15 @@ dnssdAddAlias(const void *key, /* I - K
"Bad Back to My Mac domain in dynamic store!");
}
# endif /* HAVE_COREFOUNDATION */
dnssdBuildTxtRecord(
int *txt_len, /* O - TXT record length */
cupsd_printer_t *p, /* I - Printer information */
-@@ -2379,7 +2483,12 @@ dnssdBuildTxtRecord(
+@@ -2379,7 +2489,12 @@ dnssdBuildTxtRecord(
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, admin_hostname, DNSSDPort, "/%s/%s",
(p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers",
-@@ -2462,7 +2571,12 @@ dnssdBuildTxtRecord(
+@@ -2462,19 +2577,12 @@ dnssdBuildTxtRecord(
* Then pack them into a proper txt record...
*/
+#ifdef HAVE_DNSSD
return (dnssdPackTxtRecord(txt_len, keyvalue, i));
+-}
+-
+-
+-/*
+- * 'dnssdComparePrinters()' - Compare the registered names of two printers.
+- */
+-
+-static int /* O - Result of comparison */
+-dnssdComparePrinters(cupsd_printer_t *a,/* I - First printer */
+- cupsd_printer_t *b)/* I - Second printer */
+-{
+- return (_cups_strcasecmp(a->reg_name, b->reg_name));
+#endif /* HAVE_DNSSD */
+#ifdef HAVE_AVAHI
+ return (avahiPackTxtRecord(keyvalue, i));
}
-@@ -2474,7 +2588,16 @@ static int /* O - Result of comparison */
- dnssdComparePrinters(cupsd_printer_t *a,/* I - First printer */
- cupsd_printer_t *b)/* I - Second printer */
- {
-- return (_cups_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 (_cups_strcasecmp(a->reg_name, b->reg_name));
- }
-
-
-@@ -2489,6 +2612,10 @@ dnssdDeregisterPrinter(
+@@ -2489,6 +2597,10 @@ dnssdDeregisterPrinter(
{
cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name);
/*
* Closing the socket deregisters the service
*/
-@@ -2524,6 +2651,24 @@ dnssdDeregisterPrinter(
+@@ -2524,6 +2636,24 @@ dnssdDeregisterPrinter(
free(p->printer_txt);
p->printer_txt = NULL;
}
/*
* Remove the printer from the array of DNS-SD printers, then clear the
-@@ -2533,8 +2678,10 @@ dnssdDeregisterPrinter(
+@@ -2533,8 +2663,10 @@ dnssdDeregisterPrinter(
cupsArrayRemove(DNSSDPrinters, p);
cupsdClearString(&p->reg_name);
}
/*
* 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the
* TXT record format.
-@@ -2644,8 +2791,10 @@ dnssdRegisterCallback(
+@@ -2644,8 +2776,10 @@ dnssdRegisterCallback(
LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED;
}
}
/*
* 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer
* or update the broadcast contents.
-@@ -2654,20 +2803,40 @@ dnssdRegisterCallback(
+@@ -2654,20 +2788,40 @@ dnssdRegisterCallback(
static void
dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
{
/*
* If per-printer sharing was just disabled make sure we're not
* registered before returning.
-@@ -2686,12 +2855,36 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
+@@ -2686,12 +2840,36 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
if (p->info && strlen(p->info) > 0)
{
if (DNSSDComputerName)
else
strlcpy(name, p->name, sizeof(name));
-@@ -2712,6 +2905,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
+@@ -2712,6 +2890,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
* Register IPP and (optionally) LPD...
*/
ipp_len = 0; /* anti-compiler-warning-code */
ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0);
-@@ -2884,6 +3078,209 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
+@@ -2884,6 +3063,209 @@ dnssdRegisterPrinter(cupsd_printer_t *p)
if (printer_txt)
free(printer_txt);
}
-@@ -2896,6 +3293,10 @@ dnssdStop(void)
+@@ -2896,6 +3278,10 @@ dnssdStop(void)
{
cupsd_printer_t *p; /* Current printer */
/*
* De-register the individual printers
-@@ -2906,6 +3307,7 @@ dnssdStop(void)
- p = (cupsd_printer_t *)cupsArrayNext(Printers))
- dnssdDeregisterPrinter(p);
-
-+#ifdef HAVE_DNSSD
- /*
+@@ -2910,12 +3296,23 @@ dnssdStop(void)
* Shutdown the rest of the service refs...
*/
-@@ -2926,14 +3328,17 @@ dnssdStop(void)
+
++#ifdef HAVE_DNSSD
+ if (WebIFRef)
+ {
+ DNSServiceRefDeallocate(WebIFRef);
+ WebIFRef = NULL;
+ }
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ if (AvahiWebIFGroup)
++ {
++ avahi_entry_group_reset (AvahiWebIFGroup);
++ avahi_entry_group_free (AvahiWebIFGroup);
++ AvahiWebIFGroup = NULL;
++ }
++#endif /* HAVE_AVAHI */
+
++#ifdef HAVE_DNSSD
+ if (RemoteRef)
+ {
+ DNSServiceRefDeallocate(RemoteRef);
+@@ -2926,14 +3323,17 @@ dnssdStop(void)
DNSServiceRefDeallocate(DNSSDRef);
DNSSDRef = NULL;
/*
* 'dnssdUpdate()' - Handle DNS-SD queries.
*/
-@@ -2955,6 +3360,147 @@ dnssdUpdate(void)
+@@ -2955,6 +3355,153 @@ dnssdUpdate(void)
#endif /* HAVE_DNSSD */
+ /*
+ * No Avahi daemon, client is waiting.
+ */
-+ AvahiCupsClientConnecting = 1;
+ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client connecting");
+ break;
+
++ case AVAHI_CLIENT_S_REGISTERING:
++ /*
++ * Not yet registered.
++ */
++ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client registering");
++ break;
++
+ case AVAHI_CLIENT_FAILURE:
+ /*
+ * Avahi client failed, close it to allow a clean restart.
/*
* 'get_auth_info_required()' - Get the auth-info-required value to advertise.
*/
-diff --git a/scheduler/dirsvc.h b/scheduler/dirsvc.h
-index 99079bd..d53a179 100644
---- a/scheduler/dirsvc.h
-+++ b/scheduler/dirsvc.h
+diff -up cups-1.5.2/scheduler/dirsvc.h.avahi-5-services cups-1.5.2/scheduler/dirsvc.h
+--- cups-1.5.2/scheduler/dirsvc.h.avahi-5-services 2011-03-21 02:12:14.000000000 +0000
++++ cups-1.5.2/scheduler/dirsvc.h 2012-03-14 15:08:25.711611808 +0000
@@ -31,6 +31,10 @@
# endif /* HAVE_LDAP_SSL_H */
#endif /* HAVE_LDAP */
#ifdef HAVE_LIBSLP
VAR SLPHandle BrowseSLPHandle VALUE(NULL);
/* SLP API handle */
-@@ -195,13 +213,14 @@ extern void cupsdRegisterPrinter(cupsd_printer_t *p);
+@@ -195,13 +213,14 @@ extern void cupsdRegisterPrinter(cupsd_p
extern void cupsdRestartPolling(void);
extern void cupsdSaveRemoteCache(void);
extern void cupsdSendBrowseList(void);
#ifdef HAVE_LDAP
extern void cupsdUpdateLDAPBrowse(void);
#endif /* HAVE_LDAP */
-diff --git a/scheduler/ipp.c b/scheduler/ipp.c
-index a048baa..9a3ab11 100644
---- a/scheduler/ipp.c
-+++ b/scheduler/ipp.c
-@@ -6087,7 +6087,7 @@ copy_printer_attrs(
+diff -up cups-1.5.2/scheduler/ipp.c.avahi-5-services cups-1.5.2/scheduler/ipp.c
+--- cups-1.5.2/scheduler/ipp.c.avahi-5-services 2012-03-14 15:04:17.665305560 +0000
++++ cups-1.5.2/scheduler/ipp.c 2012-03-14 15:08:25.715611813 +0000
+@@ -6099,7 +6099,7 @@ copy_printer_attrs(
ippAddDate(con->response, IPP_TAG_PRINTER, "printer-current-time",
ippTimeToDate(curtime));
if (!ra || cupsArrayFind(ra, "printer-dns-sd-name"))
{
if (printer->reg_name)
-@@ -6097,7 +6097,7 @@ copy_printer_attrs(
+@@ -6109,7 +6109,7 @@ copy_printer_attrs(
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE,
"printer-dns-sd-name", 0);
}
if (!ra || cupsArrayFind(ra, "printer-error-policy"))
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME,
-diff --git a/scheduler/main.c b/scheduler/main.c
-index 1e60572..6c210e6 100644
---- a/scheduler/main.c
-+++ b/scheduler/main.c
-@@ -120,6 +120,10 @@ main(int argc, /* I - Number of command-line args */
+diff -up cups-1.5.2/scheduler/main.c.avahi-5-services cups-1.5.2/scheduler/main.c
+--- cups-1.5.2/scheduler/main.c.avahi-5-services 2012-03-14 15:06:36.511476986 +0000
++++ cups-1.5.2/scheduler/main.c 2012-03-14 15:08:25.718611817 +0000
+@@ -120,6 +120,10 @@ main(int argc, /* I - Number of comm
cupsd_listener_t *lis; /* Current listener */
time_t current_time, /* Current time */
activity, /* Client activity timer */
browse_time, /* Next browse send time */
senddoc_time, /* Send-Document time */
expire_time, /* Subscription expire time */
-@@ -662,6 +666,9 @@ main(int argc, /* I - Number of command-line args */
+@@ -672,6 +676,9 @@ main(int argc, /* I - Number of comm
*/
current_time = time(NULL);
browse_time = current_time;
event_time = current_time;
expire_time = current_time;
-@@ -884,6 +891,16 @@ main(int argc, /* I - Number of command-line args */
+@@ -894,6 +901,16 @@ main(int argc, /* I - Number of comm
tmo = cupsdNextTimeout (&tmo_delay);
if (tmo && tmo_delay == 0)
cupsdRunTimeout (tmo);
#endif /* HAVE_AVAHI */
#ifndef __APPLE__
-diff --git a/scheduler/printers.c b/scheduler/printers.c
-index 4686c4c..fac7bbc 100644
---- a/scheduler/printers.c
-+++ b/scheduler/printers.c
+diff -up cups-1.5.2/scheduler/printers.c.avahi-5-services cups-1.5.2/scheduler/printers.c
+--- cups-1.5.2/scheduler/printers.c.avahi-5-services 2012-03-14 15:04:17.646305537 +0000
++++ cups-1.5.2/scheduler/printers.c 2012-03-14 15:08:25.720611819 +0000
@@ -883,9 +883,9 @@ cupsdDeletePrinter(
cupsdClearString(&p->alert);
cupsdClearString(&p->alert_description);
cupsArrayDelete(p->filetypes);
-@@ -3765,7 +3765,7 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */
+@@ -3787,7 +3787,7 @@ add_printer_formats(cupsd_printer_t *p)
attr->values[i].string.text = _cupsStrAlloc(mimetype);
}
{
char pdl[1024]; /* Buffer to build pdl list */
mime_filter_t *filter; /* MIME filter looping var */
-@@ -3821,7 +3821,7 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */
+@@ -3843,7 +3843,7 @@ add_printer_formats(cupsd_printer_t *p)
cupsdSetString(&p->pdl, pdl);
}
}
-diff --git a/scheduler/printers.h b/scheduler/printers.h
-index 1751578..fb04651 100644
---- a/scheduler/printers.h
-+++ b/scheduler/printers.h
+diff -up cups-1.5.2/scheduler/printers.h.avahi-5-services cups-1.5.2/scheduler/printers.h
+--- cups-1.5.2/scheduler/printers.h.avahi-5-services 2011-03-18 18:42:46.000000000 +0000
++++ cups-1.5.2/scheduler/printers.h 2012-03-14 15:08:25.721611820 +0000
@@ -16,6 +16,9 @@
#ifdef HAVE_DNSSD
# include <dns_sd.h>
+++ /dev/null
-Index: cups/language.c
-===================================================================
---- cups/language.c (revision 10320)
-+++ cups/language.c (revision 10321)
-@@ -3,7 +3,7 @@
- *
- * I18N/language support for CUPS.
- *
-- * Copyright 2007-2011 by Apple Inc.
-+ * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
-@@ -979,8 +979,23 @@
- */
-
- if (m)
-- cupsArrayAdd(a, m);
-+ {
-+ if (m->str[0])
-+ {
-+ cupsArrayAdd(a, m);
-+ }
-+ else
-+ {
-+ /*
-+ * Translation is empty, don't add it... (STR #4033)
-+ */
-
-+ free(m->id);
-+ free(m->str);
-+ free(m);
-+ }
-+ }
-+
- /*
- * Create a new message with the given msgid string...
- */
-@@ -1057,8 +1072,23 @@
- */
-
- if (m)
-- cupsArrayAdd(a, m);
-+ {
-+ if (m->str[0])
-+ {
-+ cupsArrayAdd(a, m);
-+ }
-+ else
-+ {
-+ /*
-+ * Translation is empty, don't add it... (STR #4033)
-+ */
-
-+ free(m->id);
-+ free(m->str);
-+ free(m);
-+ }
-+ }
-+
- /*
- * Close the message catalog file and return the new array...
- */
Summary(pl.UTF-8): Ogólny system druku dla Uniksa
Summary(pt_BR.UTF-8): Sistema Unix de Impressão
Name: cups
-Version: 1.5.2
-Release: 7
+Version: 1.5.3
+Release: 1
Epoch: 1
License: LGPL v2 (libraries), GPL v2 (the rest) + openssl exception
Group: Applications/Printing
Source0: http://ftp.easysw.com/pub/cups/%{version}/%{name}-%{version}-source.tar.bz2
-# Source0-md5: 9471d2a7c920cfbb17133c32d2e6866f
+# Source0-md5: e1ad15257aa6f162414ea3beae0c5df8
Source1: %{name}.init
Source2: %{name}.pamd
Source3: %{name}.logrotate
Patch13: %{name}-systemd-socket.patch
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=638521
Patch14: ipp-revert-1.4.patch
-Patch15: %{name}-locale.patch
# avahi patches from fedora
Patch100: %{name}-avahi-1-config.patch
Patch101: %{name}-avahi-2-backend.patch
#%patch11 -p1
%patch12 -p1
%patch13 -p1
-%patch14 -p1
-%patch15 -p0
+# 1.5.3 shows it may have a chance of working without this
+#%patch14 -p1
%if %{with avahi}
%patch100 -p1