diff --git a/.gitignore b/.gitignore index bad004b..480bd49 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ cups-1.4.4-source.tar.bz2 /cups-1.5.2-source.tar.bz2 /cups-1.5.3-source.tar.bz2 /cups-1.5.4-source.tar.bz2 +/cups-1.6.1-source.tar.bz2 diff --git a/cups-0755.patch b/cups-0755.patch index dcb6255..b0df3a0 100644 --- a/cups-0755.patch +++ b/cups-0755.patch @@ -1,14 +1,14 @@ -diff -up cups-1.5.3/Makedefs.in.0755 cups-1.5.3/Makedefs.in ---- cups-1.5.3/Makedefs.in.0755 2012-05-15 16:51:31.000000000 +0200 -+++ cups-1.5.3/Makedefs.in 2012-05-15 16:52:59.246906315 +0200 -@@ -41,14 +41,14 @@ SHELL = /bin/sh +diff -up cups-1.6b1/Makedefs.in.0755 cups-1.6b1/Makedefs.in +--- cups-1.6b1/Makedefs.in.0755 2012-05-23 01:58:31.000000000 +0200 ++++ cups-1.6b1/Makedefs.in 2012-05-25 16:09:40.545463214 +0200 +@@ -40,14 +40,14 @@ SHELL = /bin/sh # Installation programs... # -INSTALL_BIN = $(LIBTOOL) $(INSTALL) -c -m 555 @INSTALL_STRIP@ +INSTALL_BIN = $(LIBTOOL) $(INSTALL) -c -m 755 @INSTALL_STRIP@ - INSTALL_CONFIG = $(INSTALL) -c -m @CUPS_CONFIG_FILE_PERM@ INSTALL_COMPDATA = $(INSTALL) -c -m 444 @INSTALL_GZIP@ + INSTALL_CONFIG = $(INSTALL) -c -m @CUPS_CONFIG_FILE_PERM@ INSTALL_DATA = $(INSTALL) -c -m 444 INSTALL_DIR = $(INSTALL) -d -INSTALL_LIB = $(LIBTOOL) $(INSTALL) -c -m 555 @INSTALL_STRIP@ @@ -19,15 +19,3 @@ diff -up cups-1.5.3/Makedefs.in.0755 cups-1.5.3/Makedefs.in # # Default user, group, and system groups for the scheduler... -diff -up cups-1.5.3/scheduler/Makefile.0755 cups-1.5.3/scheduler/Makefile ---- cups-1.5.3/scheduler/Makefile.0755 2011-05-12 00:17:34.000000000 +0200 -+++ cups-1.5.3/scheduler/Makefile 2012-05-15 16:51:31.703516547 +0200 -@@ -213,7 +213,7 @@ install-data: - install-exec: - echo Installing programs in $(SBINDIR)... - $(INSTALL_DIR) -m 755 $(SBINDIR) -- $(INSTALL_BIN) -m 500 cupsd $(SBINDIR) -+ $(INSTALL_BIN) -m 755 cupsd $(SBINDIR) - $(INSTALL_BIN) cupsfilter $(SBINDIR) - -if test "x`uname`" = xDarwin; then \ - $(INSTALL_DIR) $(BUILDROOT)/System/Library/Printers/Libraries; \ diff --git a/cups-avahi-1-config.patch b/cups-avahi-1-config.patch deleted file mode 100644 index 516e01f..0000000 --- a/cups-avahi-1-config.patch +++ /dev/null @@ -1,42 +0,0 @@ -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 Avahi for DNS Service Discovery? -+ */ -+ -+#undef HAVE_AVAHI -+ -+ -+/* - * Do we have ? - */ - -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="" - -+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 deleted file mode 100644 index 9fa3677..0000000 --- a/cups-avahi-2-backend.patch +++ /dev/null @@ -1,1118 +0,0 @@ -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: - * -+ * 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 */ - - - /* -@@ -53,7 +71,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 */ -@@ -65,6 +88,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... -@@ -78,6 +115,7 @@ static int job_canceled = 0; - * Local functions... - */ - -+#ifdef HAVE_DNSSD - static void browse_callback(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, -@@ -95,13 +133,6 @@ static void browse_local_callback(DNSSe - const char *replyDomain, - 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) -- __attribute__((nonnull(1,2,3,4))); - static void query_callback(DNSServiceRef sdRef, - DNSServiceFlags flags, - uint32_t interfaceIndex, -@@ -111,10 +142,119 @@ static void query_callback(DNSServiceRe - const void *rdata, uint32_t ttl, - void *context) - __attribute__((nonnull(1,5,9,11))); -+#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) -+ __attribute__((nonnull(1,2,3,4))); - static void sigterm_handler(int sig); - static void unquote(char *dst, const char *src, size_t dstsize) - __attribute__((nonnull(1,2))); - -+#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. -@@ -125,6 +265,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 */ -@@ -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 */ -- 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 */ -@@ -203,6 +349,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"); -@@ -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); -+#endif /* HAVE_DNSSD */ - - /* - * Loop until we are killed... -@@ -270,6 +460,9 @@ main(int argc, /* I - Number of comm - - while (!job_canceled) - { -+ int announce = 0; -+ -+#ifdef HAVE_DNSSD - FD_ZERO(&input); - FD_SET(fd, &input); - -@@ -289,11 +482,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 */ -@@ -307,6 +524,7 @@ main(int argc, /* I - Number of comm - if (device->sent) - sent ++; - -+#ifdef HAVE_DNSSD - if (device->ref) - count ++; - -@@ -338,14 +556,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; -@@ -406,6 +633,7 @@ main(int argc, /* I - Number of comm - } - - -+#ifdef HAVE_DNSSD - /* - * 'browse_callback()' - Browse devices. - */ -@@ -494,6 +722,7 @@ browse_local_callback( - device->fullName); - device->sent = 1; - } -+#endif /* HAVE_DNSSD */ - - - /* -@@ -574,6 +803,41 @@ 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")) -+ return (CUPS_DEVICE_IPP); -+ else if (!strcmp(regtype, "_ipps._tcp") || -+ !strcmp(regtype, "_ipp-tls._tcp")) -+ return (CUPS_DEVICE_IPPS); -+ 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.")) -+ return (CUPS_DEVICE_IPP); -+ else if (!strcmp(regtype, "_ipps._tcp.") || -+ !strcmp(regtype, "_ipp-tls._tcp.")) -+ return (CUPS_DEVICE_IPPS); -+ 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. - */ - -@@ -594,20 +858,7 @@ get_device(cups_array_t *devices, /* I - - */ - - key.name = (char *)serviceName; -- -- if (!strcmp(regtype, "_ipp._tcp.")) -- key.type = CUPS_DEVICE_IPP; -- else if (!strcmp(regtype, "_ipps._tcp.") || -- !strcmp(regtype, "_ipp-tls._tcp.")) -- key.type = CUPS_DEVICE_IPPS; -- 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; -@@ -627,8 +878,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); - } -@@ -648,6 +905,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); - -@@ -655,13 +915,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. - */ -@@ -685,7 +952,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\", " -@@ -719,94 +986,233 @@ query_callback( - if ((ptr = strstr(name, "._")) != NULL) - *ptr = '\0'; - -- if (strstr(fullName, "_ipp._tcp.")) -- dkey.type = CUPS_DEVICE_IPP; -- else if (strstr(fullName, "_ipps._tcp.") || -- strstr(fullName, "_ipp-tls._tcp.")) -- dkey.type = CUPS_DEVICE_IPPS; -- 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); - -- for (device = cupsArrayFind(devices, &dkey); -+ 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); -+ -+ 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 (_cups_strcasecmp(device->name, dkey.name) || -- _cups_strcasecmp(device->domain, dkey.domain)) -+ if (_cups_strcasecmp(device->name, dkey->name) || -+ _cups_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; -- -- datanext = data + datalen; -- -- for (ptr = key; data < datanext && *data != '='; data ++) -- *ptr++ = *data; -- *ptr = '\0'; -+ char *key; -+ char *value; - -- if (data < datanext && *data == '=') -- { -- data ++; -- -- if (data < datanext) -- memcpy(value, data, datanext - data); -- value[datanext - data] = '\0'; -+ if (parse_txt_record_pair (txt)) -+ goto next; - -- fprintf(stderr, "DEBUG2: query_callback: \"%s=%s\".\n", -- key, value); -- } -- else -- { -- fprintf(stderr, "DEBUG2: query_callback: \"%s\" with no value.\n", -- key); -- continue; -- } -- -- if (!_cups_strncasecmp(key, "usb_", 4)) -+ key = txt->key; -+ value = txt->value; -+ if (!strncasecmp(key, "usb_", 4)) - { - /* - * Add USB device ID information... -@@ -861,6 +1267,10 @@ query_callback( - if (device->type == CUPS_DEVICE_PRINTER) - device->sent = 1; - } -+ -+ next: -+ if (next_txt_record (txt) == NULL) -+ break; - } - - if (device->device_id) -@@ -917,11 +1327,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.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. - * http_resolve_cb() - 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. - */ - - /* -@@ -60,6 +64,11 @@ - # include - # endif /* WIN32 */ - #endif /* HAVE_DNSSD */ -+#ifdef HAVE_AVAHI -+# include -+# include -+# include -+#endif /* HAVE_AVAHI */ - - - /* -@@ -127,6 +136,24 @@ static void DNSSD_API http_resolve_cb(DN - 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 -@@ -1434,6 +1461,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 - # ifdef WIN32 - # pragma comment(lib, "dnssd.lib") -@@ -1452,6 +1482,17 @@ _httpResolveURI( - fd_set input_set; /* Input set for select() */ - struct timeval stimeout; /* Timeout value for select() */ - #endif /* HAVE_POLL */ -+#else /* HAVE_AVAHI */ -+ AvahiSimplePoll *simple_poll; -+ AvahiClient *client; -+ int error; -+ struct -+ { -+ AvahiSimplePoll *poll; -+ _http_uribuf_t uribuf; -+ } user_data; -+#endif /* HAVE_DNSSD */ -+ - - if (options & _HTTP_RESOLVE_STDERR) - fprintf(stderr, "DEBUG: Resolving \"%s\"...\n", hostname); -@@ -1488,9 +1529,16 @@ _httpResolveURI( - if (domain) - *domain++ = '\0'; - -+#ifdef HAVE_DNSSD - uribuf.buffer = resolved_uri; - uribuf.bufsize = resolved_size; - uribuf.options = options; -+#else -+ user_data.uribuf.buffer = resolved_uri; -+ user_data.uribuf.bufsize = resolved_size; -+ user_data.uribuf.options = options; -+#endif -+ - resolved_uri[0] = '\0'; - - DEBUG_printf(("6_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", " -@@ -1504,6 +1552,7 @@ _httpResolveURI( - - uri = NULL; - -+#ifdef HAVE_DNSSD - if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError) - { - localref = ref; -@@ -1611,6 +1660,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 (options & _HTTP_RESOLVE_STDERR) - { -@@ -1622,13 +1701,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 ((options & _HTTP_RESOLVE_STDERR) && !uri) - _cupsLangPrintFilter(stderr, "ERROR", _("Unable to find printer.")); -@@ -1916,6 +1995,115 @@ http_resolve_cb( - } - #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 10284 2012-02-15 01:06:12Z mike $". diff --git a/cups-avahi-3-timeouts.patch b/cups-avahi-3-timeouts.patch deleted file mode 100644 index daf852a..0000000 --- a/cups-avahi-3-timeouts.patch +++ /dev/null @@ -1,381 +0,0 @@ -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); - -+#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... -@@ -173,6 +182,11 @@ VAR int Launchd VALUE(0); - /* Running from launchd */ - #endif /* HAVE_LAUNCH_H */ - -+#ifdef HAVE_AVAHI -+VAR cups_array_t *Timeouts; /* Timed callbacks for main loop */ -+#endif /* HAVE_AVAHI */ -+ -+ - - /* - * Prototypes... -@@ -242,6 +256,20 @@ extern void cupsdStopSelect(void); - extern void cupsdStartServer(void); - extern void cupsdStopServer(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); -+ - - /* - * End of "$Id: cupsd.h 9766 2011-05-11 22:17:34Z mike $". -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? */ - #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 -@@ -535,6 +539,14 @@ main(int argc, /* I - Number of comm - - httpInitialize(); - -+#ifdef HAVE_AVAHI -+ /* -+ * Initialize timed callback structures. -+ */ -+ -+ cupsdInitTimeouts(); -+#endif /* HAVE_AVAHI */ -+ - cupsdStartServer(); - - /* -@@ -874,6 +886,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... -@@ -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 */ -+#ifdef HAVE_AVAHI -+ cupsd_timeout_t *tmo; /* Timed callback */ -+ long tmo_delay; /* Seconds before calling it */ -+#endif /* HAVE_AVAHI */ - - - /* -@@ -1829,6 +1855,19 @@ select_timeout(int fds) /* I - Number - } - #endif /* __APPLE__ */ - -+#ifdef HAVE_AVAHI -+ /* -+ * See if there are any scheduled timed callbacks to run. -+ */ -+ -+ if ((tmo = cupsdNextTimeout(&tmo_delay)) != NULL && -+ (now + tmo_delay) < timeout) -+ { -+ timeout = tmo_delay; -+ why = "run a timed callback"; -+ } -+#endif /* HAVE_AVAHI */ -+ - /* - * Check whether we are accepting new connections... - */ -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 \ - subscriptions.o \ -- sysman.o -+ sysman.o \ -+ timeout.o - LIBOBJS = \ - filter.o \ - mime.o \ -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, 2011 Red Hat, Inc. -+ * Authors: -+ * Tim Waugh -+ * -+ * 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: -+ * -+ * 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_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 (addrsdiff); -+ -+ return (p0->enabled ? -1 : 1); -+ } -+ -+ tvdiff = avahi_timeval_compare (&p0->when, &p1->when); -+ if (tvdiff != 0) -+ return (tvdiff); -+ -+ return (addrsdiff); -+} -+ -+ -+/* -+ * '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 deleted file mode 100644 index d7fa5fd..0000000 --- a/cups-avahi-4-poll.patch +++ /dev/null @@ -1,529 +0,0 @@ -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, 2011 Red Hat, Inc. -+ * Authors: -+ * Tim Waugh -+ * -+ * 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: -+ * -+ * 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 -+ * 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); -+ -+ -+/* -+ * '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; -+ int any_watches = 0; -+ -+ for (watch = (AvahiWatch *)cupsArrayFirst(watched_fd->watches); -+ watch; -+ watch = (AvahiWatch *)cupsArrayNext(watched_fd->watches)) -+ { -+ any_watches = 1; -+ 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 (any_watches); -+} -+ -+/* -+ * '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 (NULL, NULL); -+ cupsArrayAdd (cups_poll->watched_fds, watched_fd); -+ } -+ -+ 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); -+} -+ -+ -+/* -+ * '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) -+{ -+ /* -+ * Compare by fd (no two elements have the same fd) -+ */ -+ -+ if (p0->fd == p1->fd) -+ return 0; -+ -+ return (p0->fd < p1->fd ? -1 : 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 (NULL, 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.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, 2011 Red Hat, Inc. -+ * Authors: -+ * Tim Waugh -+ * -+ * 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 -+ -+#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.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 = \ - auth.o \ -+ avahi.o \ - banners.o \ - cert.o \ - classes.o \ diff --git a/cups-avahi-5-services.patch b/cups-avahi-5-services.patch deleted file mode 100644 index 820b3c3..0000000 --- a/cups-avahi-5-services.patch +++ /dev/null @@ -1,1272 +0,0 @@ -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'; - --#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.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 - * -@@ -32,37 +32,40 @@ - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - --#include -+#ifndef _CUPS_AVAHI_H_ -+# define _CUPS_AVAHI_H_ - --#ifdef HAVE_AVAHI --# include --# include --#endif /* HAVE_AVAHI */ -+/* -+ * Include necessary headers... -+ */ - --#ifdef HAVE_AUTHORIZATION_H --# include --#endif /* HAVE_AUTHORIZATION_H */ -+# include - -+# ifdef HAVE_AVAHI -+# include -+# include -+# 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)); - } - --#ifdef HAVE_DNSSD -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - /* - * Check if the hostname is something.local (Bonjour); if so, allow it. - */ -@@ -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); --#endif /* HAVE_DNSSD */ -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - /* - * Check if the hostname is an IP address... -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; - --#ifdef HAVE_DNSSD -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups"); - #endif /* HAVE_DNSSD */ - -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 - * 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. -@@ -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. -+ * avahiPackTxtRecord() - Pack an array of key/value pairs into an -+ * AvahiStringList. - * dnssdRegisterCallback() - DNSServiceRegister callback. - * dnssdRegisterPrinter() - Start sending broadcast information for a - * printer or update the broadcast contents. -@@ -83,6 +85,7 @@ - */ - - #include "cupsd.h" -+#include - #include - - #ifdef HAVE_DNSSD -@@ -97,6 +100,17 @@ - # 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 */ - - - /* -@@ -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 void dnssdDeregisterPrinter(cupsd_printer_t *p); -+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, - DNSServiceFlags flags, - 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 +308,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) */ - } - - -@@ -702,10 +727,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) */ - } - - -@@ -1419,6 +1444,36 @@ ldap_disconnect(LDAP *ld) /* I - LDAP h - #endif /* HAVE_LDAP */ - - -+#ifdef HAVE_AVAHI -+/* -+ * 'cupsdStartAvahiClient()' - Start an Avahi client if needed -+ */ -+ -+void -+cupsdStartAvahiClient(void) -+{ -+ int error = 0; -+ -+ if (!AvahiCupsClient && !AvahiCupsClientConnecting) -+ { -+ if (!AvahiCupsPollHandle) -+ AvahiCupsPollHandle = avahi_cups_poll_new (); -+ -+ if (AvahiCupsPollHandle) -+ { -+ 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 +1597,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... - */ -@@ -1573,6 +1631,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 -@@ -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_AVAHI -+ cupsdStartAvahiClient (); -+#endif /* HAVE_AVAHI */ -+ -+#ifdef HAVE_DNSSD - } -- } - #endif /* HAVE_DNSSD */ -+ } -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - #ifdef HAVE_LIBSLP - if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) -@@ -1834,10 +1899,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) && -@@ -1902,7 +1967,7 @@ cupsdStopPolling(void) - } - - --#ifdef HAVE_DNSSD -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - /* - * 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing... - */ -@@ -1910,8 +1975,14 @@ cupsdStopPolling(void) - void - cupsdUpdateDNSSDName(void) - { -+#ifdef HAVE_DNSSD - DNSServiceErrorType error; /* Error from service creation */ - char webif[1024]; /* Web interface share name */ -+#endif /* HAVE_DNSSD */ -+#ifdef HAVE_AVAHI -+ int ret; /* Error from service creation */ -+ char webif[AVAHI_LABEL_MAX]; /* Web interface share name */ -+#endif /* HAVE_AVAHI */ - # ifdef HAVE_SYSTEMCONFIGURATION - SCDynamicStoreRef sc; /* Context for dynamic store */ - CFDictionaryRef btmm; /* Back-to-My-Mac domains */ -@@ -2042,6 +2113,7 @@ cupsdUpdateDNSSDName(void) - else - strlcpy(webif, "CUPS Web Interface", sizeof(webif)); - -+#ifdef HAVE_DNSSD - if (WebIFRef) - DNSServiceRefDeallocate(WebIFRef); - -@@ -2054,9 +2126,45 @@ 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 */ -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - - #ifdef HAVE_LDAP -@@ -2334,13 +2442,15 @@ dnssdAddAlias(const void *key, /* I - K - "Bad Back to My Mac domain in dynamic store!"); - } - # endif /* HAVE_COREFOUNDATION */ -+#endif /* HAVE_DNSSD */ - - -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - /* - * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info. - */ - --static char * /* O - TXT record */ -+static cupsd_txt_record_t /* O - TXT record */ - dnssdBuildTxtRecord( - int *txt_len, /* O - TXT record length */ - cupsd_printer_t *p, /* I - Printer information */ -@@ -2379,7 +2489,12 @@ dnssdBuildTxtRecord( - keyvalue[i ][0] = "ty"; - keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown"; - -- snprintf(admin_hostname, sizeof(admin_hostname), "%s.local.", DNSSDHostName); -+ snprintf(admin_hostname, sizeof(admin_hostname), -+ "%s.local" -+#ifdef HAVE_DNSSD -+ "." /* terminating dot no good for Avahi */ -+#endif /* HAVE_DNSSD */ -+ , DNSSDHostName); - 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,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)); -+#endif /* HAVE_AVAHI */ - } - - -@@ -2489,6 +2597,10 @@ dnssdDeregisterPrinter( - { - cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name); - -+#ifdef HAVE_DNSSD -+ if (!DNSSDRef) -+ return; -+ - /* - * Closing the socket deregisters the service - */ -@@ -2524,6 +2636,24 @@ 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 -@@ -2533,8 +2663,10 @@ dnssdDeregisterPrinter( - cupsArrayRemove(DNSSDPrinters, p); - cupsdClearString(&p->reg_name); - } -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - -+#ifdef HAVE_DNSSD - /* - * 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the - * TXT record format. -@@ -2644,8 +2776,10 @@ dnssdRegisterCallback( - LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED; - } - } -+#endif /* HAVE_DNSSD */ - - -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - /* - * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer - * or update the broadcast contents. -@@ -2654,20 +2788,40 @@ dnssdRegisterCallback( - static void - dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ - { -+#ifdef HAVE_DNSSD - 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 */ -+ name[1024]; /* Service name */ - int ipp_len, /* IPP TXT record length */ - printer_len, /* LPD TXT record length */ - printer_port; /* LPD port number */ -+#endif /* HAVE_DNSSD */ -+#ifdef HAVE_AVAHI -+ int ret; /* Error code */ -+ AvahiStringList *ipp_txt, /* IPP TXT record */ -+ *printer_txt; /* LPD TXT record */ -+ char name[AVAHI_LABEL_MAX], /* Service name */ -+ fullsubtype[AVAHI_LABEL_MAX]; /* Full subtype */ -+ char *regtype_copy, /* Writeable copy of reg type */ -+ *subtype, /* Current service sub type */ -+ *nextsubtype; /* Next service sub type */ -+#endif /* HAVE_AVAHI */ -+ char *nameptr; /* Pointer into name */ - const char *regtype; /* Registration type */ - - -+#ifdef HAVE_DNSSD -+ if (!DNSSDRef) -+ return; -+ - 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, -+ !p->avahi_group ? "new" : "update"); -+#endif /* HAVE_AVAHI */ - /* - * If per-printer sharing was just disabled make sure we're not - * registered before returning. -@@ -2686,12 +2840,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)); - -@@ -2712,6 +2890,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); - -@@ -2884,6 +3063,209 @@ 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" : DNSSDRegType; -+ -+ 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); -+ -+ /* -+ * Update the service group entry. -+ */ -+ -+ regtype_copy = strdup (regtype); -+ subtype = strchr (regtype_copy, ','); -+ if (subtype) -+ *subtype = '\0'; -+ -+ cupsdLogMessage (CUPSD_LOG_DEBUG, -+ "Updating TXT record for %s (%s)", name, regtype_copy); -+ ret = avahi_entry_group_update_service_txt_strlst (p->avahi_group, -+ AVAHI_IF_UNSPEC, -+ AVAHI_PROTO_UNSPEC, -+ 0, name, -+ regtype_copy, -+ NULL, ipp_txt); -+ free (regtype_copy); -+ -+ 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; -+ } -+ -+ /* -+ * Add each service type (DNSSDRegType may contain several, -+ * separated by commas). -+ */ -+ -+ subtype = regtype_copy = strdup (regtype); -+ while (subtype && *subtype) -+ { -+ nextsubtype = strchr (subtype, ','); -+ if (nextsubtype) -+ *nextsubtype++ = '\0'; -+ -+ if (subtype == regtype_copy) -+ { -+ /* -+ * Main type entry. -+ */ -+ -+ cupsdLogMessage (CUPSD_LOG_DEBUG, -+ "Adding TXT record for %s (%s)", name, regtype_copy); -+ ret = avahi_entry_group_add_service_strlst (p->avahi_group, -+ AVAHI_IF_UNSPEC, -+ AVAHI_PROTO_UNSPEC, -+ 0, name, regtype_copy, -+ NULL, NULL, -+ DNSSDPort, -+ ipp_txt); -+ } -+ else -+ { -+ /* -+ * Sub-type entry. -+ */ -+ -+ snprintf (fullsubtype, sizeof(fullsubtype), -+ "%s._sub.%s", subtype, regtype_copy); -+ cupsdLogMessage (CUPSD_LOG_DEBUG, -+ "Adding TXT record for %s (%s)", name, fullsubtype); -+ ret = avahi_entry_group_add_service_subtype (p->avahi_group, -+ AVAHI_IF_UNSPEC, -+ AVAHI_PROTO_UNSPEC, -+ 0, name, -+ regtype_copy, -+ NULL, fullsubtype); -+ } -+ -+ if (ret < 0) -+ { -+ free (regtype_copy); -+ goto add_failed; -+ } -+ -+ subtype = nextsubtype; -+ } -+ -+ free (regtype_copy); -+ 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 */ - } - - -@@ -2896,6 +3278,10 @@ dnssdStop(void) - { - cupsd_printer_t *p; /* Current printer */ - -+#ifdef HAVE_DNSSD -+ if (!DNSSDRef) -+ return; -+#endif /* HAVE_DNSSD */ - - /* - * De-register the individual printers -@@ -2910,12 +3296,23 @@ dnssdStop(void) - * Shutdown the rest of the service refs... - */ - -+#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; -+#endif /* HAVE_DNSSD */ - - cupsArrayDelete(DNSSDPrinters); - DNSSDPrinters = NULL; - - DNSSDPort = 0; - } -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - -+#ifdef HAVE_DNSSD - /* - * 'dnssdUpdate()' - Handle DNS-SD queries. - */ -@@ -2955,6 +3355,153 @@ 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 - Number of 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. -+ */ -+ 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. -+ */ -+ 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.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_AVAHI -+# include -+#endif /* HAVE_AVAHI */ -+ - /* - * Browse protocols... - */ -@@ -131,19 +135,22 @@ 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 char *DNSSDComputerName VALUE(NULL), - /* Computer/server name */ - *DNSSDHostName VALUE(NULL), - /* Hostname */ - *DNSSDRegType VALUE(NULL); - /* Bonjour registration type */ --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 /* defined(HAVE_DNSSD) || defined(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), -@@ -152,6 +159,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); -+ /* Is AvahiClient object connecting? */ -+VAR AvahiEntryGroup *AvahiWebIFGroup VALUE(NULL); -+ /* Web interface entry group */ -+#endif /* HAVE_AVAHI */ -+ - #ifdef HAVE_LIBSLP - VAR SLPHandle BrowseSLPHandle VALUE(NULL); - /* SLP API handle */ -@@ -195,13 +213,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.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)); - --#ifdef HAVE_DNSSD -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - if (!ra || cupsArrayFind(ra, "printer-dns-sd-name")) - { - if (printer->reg_name) -@@ -6109,7 +6109,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.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 */ -+#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 */ -@@ -672,6 +676,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; -@@ -894,6 +901,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.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); - --#ifdef HAVE_DNSSD -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - cupsdClearString(&p->pdl); --#endif /* HAVE_DNSSD */ -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - cupsArrayDelete(p->filetypes); - -@@ -3787,7 +3787,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 */ -@@ -3843,7 +3843,7 @@ add_printer_formats(cupsd_printer_t *p) - - cupsdSetString(&p->pdl, pdl); - } --#endif /* HAVE_DNSSD */ -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - } - - -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 - #endif /* HAVE_DNSSD */ -+#ifdef HAVE_AVAHI -+# include "avahi.h" -+#endif /* HAVE_AVAHI */ - #include - - -@@ -95,16 +98,23 @@ struct cupsd_printer_s - time_t marker_time; /* Last time marker attributes were updated */ - _ppd_cache_t *pc; /* PPD cache and mapping data */ - --#ifdef HAVE_DNSSD -+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - char *reg_name, /* Name used for service registration */ -- *pdl, /* pdl value for TXT record */ -- *ipp_txt, /* IPP TXT record contents */ -+ *pdl; /* pdl value for TXT record */ -+#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ -+#ifdef HAVE_DNSSD -+ 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 */ - }; - - diff --git a/cups-cups-get-classes.patch b/cups-cups-get-classes.patch index c998852..b0ffe1c 100644 --- a/cups-cups-get-classes.patch +++ b/cups-cups-get-classes.patch @@ -81,7 +81,7 @@ diff -up cups-1.5.0/cups/dest.c.cups-get-classes cups-1.5.0/cups/dest.c + */ + + if (get_classes) -+ num_dests = _cupsGetDests (http, CUPS_GET_CLASSES, name, dests); ++ num_dests = _cupsGetDests (http, CUPS_GET_CLASSES, name, dests, 0, 0); + + /* * Return the count... diff --git a/cups-dnssd-deviceid.patch b/cups-dnssd-deviceid.patch index dedbcb2..b3c2b8e 100644 --- a/cups-dnssd-deviceid.patch +++ b/cups-dnssd-deviceid.patch @@ -1,38 +1,38 @@ -diff -up cups-1.5b1/backend/dnssd.c.dnssd-deviceid cups-1.5b1/backend/dnssd.c ---- cups-1.5b1/backend/dnssd.c.dnssd-deviceid 2011-05-20 05:49:49.000000000 +0200 -+++ cups-1.5b1/backend/dnssd.c 2011-05-24 17:28:18.000000000 +0200 -@@ -817,15 +817,22 @@ query_callback( - if (device->device_id) - free(device->device_id); +diff -up cups-1.6b1/backend/dnssd.c.dnssd-deviceid cups-1.6b1/backend/dnssd.c +--- cups-1.6b1/backend/dnssd.c.dnssd-deviceid 2012-05-21 18:05:58.000000000 +0200 ++++ cups-1.6b1/backend/dnssd.c 2012-05-25 16:27:49.226874427 +0200 +@@ -1181,15 +1181,22 @@ query_callback( + if (device->device_id) + free(device->device_id); -+ if (device_id[0]) -+ { -+ /* Mark this as the real device ID. */ -+ ptr = device_id + strlen(device_id); -+ snprintf(ptr, sizeof(device_id) - (ptr - device_id), "FZY:0;"); -+ } ++ if (device_id[0]) ++ { ++ /* Mark this as the real device ID. */ ++ ptr = device_id + strlen(device_id); ++ snprintf(ptr, sizeof(device_id) - (ptr - device_id), "FZY:0;"); ++ } + - if (!device_id[0] && strcmp(model, "Unknown")) - { - if (make_and_model[0]) -- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;", -+ snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;FZY:1;", - make_and_model, model); - else if (!_cups_strncasecmp(model, "designjet ", 10)) -- snprintf(device_id, sizeof(device_id), "MFG:HP;MDL:%s", model + 10); -+ snprintf(device_id, sizeof(device_id), "MFG:HP;MDL:%s;FZY:1;", model + 10); - else if (!_cups_strncasecmp(model, "stylus ", 7)) -- snprintf(device_id, sizeof(device_id), "MFG:EPSON;MDL:%s", model + 7); -+ snprintf(device_id, sizeof(device_id), "MFG:EPSON;MDL:%s;FZY:1;", model + 7); - else if ((ptr = strchr(model, ' ')) != NULL) - { - /* -@@ -835,7 +842,7 @@ query_callback( - memcpy(make_and_model, model, ptr - model); - make_and_model[ptr - model] = '\0'; + if (!device_id[0] && strcmp(model, "Unknown")) + { + if (make_and_model[0]) +- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;", ++ snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;FZY:1;", + make_and_model, model); + else if (!_cups_strncasecmp(model, "designjet ", 10)) +- snprintf(device_id, sizeof(device_id), "MFG:HP;MDL:%s", model + 10); ++ snprintf(device_id, sizeof(device_id), "MFG:HP;MDL:%s;FZY:1;", model + 10); + else if (!_cups_strncasecmp(model, "stylus ", 7)) +- snprintf(device_id, sizeof(device_id), "MFG:EPSON;MDL:%s", model + 7); ++ snprintf(device_id, sizeof(device_id), "MFG:EPSON;MDL:%s;FZY:1;", model + 7); + else if ((ptr = strchr(model, ' ')) != NULL) + { + /* +@@ -1199,7 +1206,7 @@ query_callback( + memcpy(make_and_model, model, ptr - model); + make_and_model[ptr - model] = '\0'; -- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s", -+ snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;FZY:1;", - make_and_model, ptr + 1); - } - } +- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s", ++ snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;FZY:1;", + make_and_model, ptr + 1); + } + } diff --git a/cups-filter-debug.patch b/cups-filter-debug.patch index 2a42343..96c82da 100644 --- a/cups-filter-debug.patch +++ b/cups-filter-debug.patch @@ -1,14 +1,14 @@ -diff -up cups-1.5b1/scheduler/job.c.filter-debug cups-1.5b1/scheduler/job.c ---- cups-1.5b1/scheduler/job.c.filter-debug 2011-05-24 15:58:07.000000000 +0200 -+++ cups-1.5b1/scheduler/job.c 2011-05-24 15:58:07.000000000 +0200 -@@ -557,10 +557,28 @@ cupsdContinueJob(cupsd_job_t *job) /* I +diff -up cups-1.6b1/scheduler/job.c.filter-debug cups-1.6b1/scheduler/job.c +--- cups-1.6b1/scheduler/job.c.filter-debug 2012-05-25 16:06:01.000000000 +0200 ++++ cups-1.6b1/scheduler/job.c 2012-05-25 16:07:46.309259511 +0200 +@@ -625,10 +625,28 @@ cupsdContinueJob(cupsd_job_t *job) /* I if (!filters) { + mime_filter_t *current; + cupsdLogJob(job, CUPSD_LOG_ERROR, - "Unable to convert file %d to printable format!", + "Unable to convert file %d to printable format.", job->current_file); + cupsdLogJob(job, CUPSD_LOG_ERROR, diff --git a/cups-getpass.patch b/cups-getpass.patch deleted file mode 100644 index 7b089a7..0000000 --- a/cups-getpass.patch +++ /dev/null @@ -1,50 +0,0 @@ -diff -up cups-1.5b1/cups/usersys.c.getpass cups-1.5b1/cups/usersys.c ---- cups-1.5b1/cups/usersys.c.getpass 2011-05-20 05:49:49.000000000 +0200 -+++ cups-1.5b1/cups/usersys.c 2011-05-24 15:41:33.000000000 +0200 -@@ -43,6 +43,8 @@ - #include "cups-private.h" - #include - #include -+#include -+#include - #ifdef WIN32 - # include - #else -@@ -501,13 +503,31 @@ _cupsGetPassword(const char *prompt) /* - * empty password is treated as canceling the authentication request. - */ - -- const char *password = getpass(prompt); -- /* Password string */ -- -- if (!password || !password[0]) -- return (NULL); -- else -+ static char password[100]; -+ struct termios oldtio, newtio; -+ sigset_t oldset, newset; -+ int nread; -+ sigprocmask (SIG_BLOCK, NULL, &newset); -+ sigaddset (&newset, SIGINT); -+ sigaddset (&newset, SIGTSTP); -+ sigprocmask (SIG_BLOCK, &newset, &oldset); -+ tcgetattr (STDIN_FILENO, &oldtio); -+ newtio = oldtio; -+ newtio.c_lflag &= ~ECHO; -+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &newtio); -+ fputs (prompt, stdout); -+ fflush (stdout); -+ nread = read (STDIN_FILENO, password, sizeof (password)); -+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &oldtio); -+ fputc ('\n', stdout); -+ sigprocmask (SIG_SETMASK, &oldset, NULL); -+ if (nread > 0) -+ { -+ password[nread - 1] = '\0'; - return (password); -+ } -+ else -+ return (NULL); - #endif /* WIN32 */ - } - diff --git a/cups-icc.patch b/cups-icc.patch deleted file mode 100644 index db4ae22..0000000 --- a/cups-icc.patch +++ /dev/null @@ -1,1042 +0,0 @@ -From db29c24e3ff75938775aa1f4072e346aeb7f6a9c Mon Sep 17 00:00:00 2001 -From: Richard Hughes -Date: Tue, 1 Mar 2011 16:05:48 +0000 -Subject: [PATCH] Add colord support to CUPS which allows Linux printers to be - color managed - -This functionality is possible because of lots of help from Tim Waugh -- thanks! ---- - scheduler/Makefile | 1 + - scheduler/colord.c | 784 ++++++++++++++++++++++++++++++++++++++++++++++++++ - scheduler/colord.h | 41 +++ - scheduler/ipp.c | 18 +- - scheduler/printers.c | 69 +++++ - scheduler/printers.h | 4 + - 6 files changed, 914 insertions(+), 3 deletions(-) - create mode 100644 scheduler/colord.c - create mode 100644 scheduler/colord.h - -diff --git a/scheduler/Makefile b/scheduler/Makefile -index 3c7da8e..b9c47d3 100644 ---- a/scheduler/Makefile -+++ b/scheduler/Makefile -@@ -27,6 +27,7 @@ CUPSDOBJS = \ - file.o \ - main.o \ - ipp.o \ -+ colord.o \ - listen.o \ - job.o \ - log.o \ -diff --git a/scheduler/colord.c b/scheduler/colord.c -new file mode 100644 -index 0000000..bd06e1c ---- /dev/null -+++ b/scheduler/colord.c -@@ -0,0 +1,784 @@ -+/* -+ * "$Id$" -+ * -+ * colord integration for the CUPS scheduler. -+ * -+ * Copyright 2011 Red Hat, Inc. -+ * -+ * 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: -+ * -+ * colordRegisterPrinter() - Register profiles for a printer. -+ * colordUnregisterPrinter() - Unregister profiles for a printer. -+ * colordStart() - Get a connection to the system bus. -+ * colordStop() - Release any connection to the system bus -+ * so that added profiles and devices are -+ * automatically removed. -+ */ -+ -+/* -+ * Include necessary headers... -+ */ -+ -+#include "cupsd.h" -+ -+#ifdef HAVE_DBUS -+ -+#include -+#include -+ -+/* -+ * Defines used by colord. See the reference docs for further details: -+ * http://colord.hughsie.com/api/ref-dbus.html -+ */ -+#define COLORD_SCOPE_NORMAL "normal" /* System scope */ -+#define COLORD_SCOPE_TEMP "temp" /* Process scope */ -+#define COLORD_SCOPE_DISK "disk" /* Lives forever, as stored in DB */ -+ -+#define COLORD_RELATION_SOFT "soft" /* Mapping is not default */ -+#define COLORD_RELATION_HARD "hard" /* Explicitly mapped profile */ -+ -+#define COLORD_SPACE_RGB "rgb" /* RGB colorspace */ -+#define COLORD_SPACE_CMYK "cmyk" /* CMYK colorspace */ -+#define COLORD_SPACE_GRAY "gray" /* Gray colorspace */ -+#define COLORD_SPACE_UNKNOWN "unknown" /* Unknown colorspace */ -+ -+#define COLORD_MODE_PHYSICAL "physical" /* Actual device */ -+#define COLORD_MODE_VIRTUAL "virtual" /* Virtual device with no hardware */ -+ -+#define COLORD_KIND_PRINTER "printer" /* printing output device */ -+ -+/* the timeout for connecting to colord */ -+#define COLORD_DBUS_TIMEOUT 5000 /* ms */ -+ -+/* This is static */ -+static DBusConnection *con = NULL; -+ -+/* -+ * 'colordStart()' - Get a connection to the system bus. -+ */ -+ -+void -+colordStart(void) -+{ -+ if (con) -+ return; -+ con = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); -+} -+ -+/* -+ * 'colordStop()' - Release any connection to the system bus so that -+ * added profiles and devices are automatically removed. -+ */ -+ -+void -+colordStop(void) -+{ -+ if (con == NULL) -+ return; -+ dbus_connection_unref(con); -+ con = NULL; -+} -+ -+/* -+ * 'message_dict_add_strings()' - add two strings to a dictionary. -+ */ -+ -+static void -+message_dict_add_strings (DBusMessageIter *dict, -+ const char *key, -+ const char *value) -+{ -+ DBusMessageIter entry; -+ dbus_message_iter_open_container(dict, -+ DBUS_TYPE_DICT_ENTRY, -+ NULL, -+ &entry); -+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); -+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &value); -+ dbus_message_iter_close_container(dict, &entry); -+} -+ -+/* -+ * 'colordCreateProfile()' - Create a color profile for a printer. -+ * -+ * Notes: When creating the device, we can create -+ */ -+ -+static void -+colordCreateProfile (cups_array_t *profiles, /* I - Profiles array */ -+ const char *printer_name, /* I - Printer name */ -+ const char *qualifier, /* I - Profile qualifier */ -+ const char *colorspace, /* I - Profile colorspace */ -+ const char **format, /* I - Profile qualifier format */ -+ const char *iccfile, /* I - ICC filename */ -+ const char *scope) /* I - The scope of the profile, e.g. -+ 'normal', 'temp' or 'disk' */ -+{ -+ DBusMessage *message = NULL; /* D-Bus request */ -+ DBusMessage *reply = NULL; /* D-Bus reply */ -+ DBusMessageIter args; /* D-Bus method arguments */ -+ DBusMessageIter dict; /* D-Bus method arguments */ -+ DBusError error; /* D-Bus error */ -+ char *idstr; /* Profile ID string */ -+ size_t idstrlen; /* Profile ID allocated length */ -+ const char *profile_path; /* Device object path */ -+ char format_str[1024]; /* Qualifier format as a string */ -+ -+ /* -+ * Create the profile... -+ */ -+ -+ message = dbus_message_new_method_call("org.freedesktop.ColorManager", -+ "/org/freedesktop/ColorManager", -+ "org.freedesktop.ColorManager", -+ "CreateProfile"); -+ -+ /* create a profile id */ -+ idstrlen = strlen (printer_name) + 1 + strlen (qualifier) + 1; -+ idstr = malloc (idstrlen); -+ if (!idstr) -+ goto out; -+ snprintf (idstr, idstrlen, "%s-%s", printer_name, qualifier); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Using profile id of %s", -+ idstr); -+ -+ dbus_message_iter_init_append(message, &args); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &idstr); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &scope); -+ -+ /* mush the qualifier format into a simple string */ -+ snprintf(format_str, sizeof(format_str), "%s.%s.%s", -+ format[0], -+ format[1], -+ format[2]); -+ -+ /* set initial properties */ -+ dbus_message_iter_open_container(&args, -+ DBUS_TYPE_ARRAY, -+ "{ss}", -+ &dict); -+ message_dict_add_strings(&dict, "Qualifier", qualifier); -+ message_dict_add_strings(&dict, "Format", format_str); -+ message_dict_add_strings(&dict, "Colorspace", colorspace); -+ if (iccfile != NULL) -+ message_dict_add_strings(&dict, "Filename", iccfile); -+ dbus_message_iter_close_container(&args, &dict); -+ -+ /* send syncronous */ -+ dbus_error_init(&error); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling CreateProfile(%s,%s)", -+ idstr, scope); -+ reply = dbus_connection_send_with_reply_and_block(con, -+ message, -+ COLORD_DBUS_TIMEOUT, -+ &error); -+ if (reply == NULL) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "failed to CreateProfile: %s:%s", -+ error.name, error.message); -+ dbus_error_free(&error); -+ goto out; -+ } -+ -+ /* get reply data */ -+ dbus_message_iter_init(reply, &args); -+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "incorrect reply type"); -+ goto out; -+ } -+ dbus_message_iter_get_basic(&args, &profile_path); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "created profile %s", -+ profile_path); -+ cupsArrayAdd(profiles, strdup(profile_path)); -+ -+out: -+ if (message != NULL) -+ dbus_message_unref(message); -+ if (reply != NULL) -+ dbus_message_unref(reply); -+ free (idstr); -+} -+ -+/* -+ * 'colordDeviceAddProfile()' - Assign a profile to a device. -+ */ -+ -+static void -+colordDeviceAddProfile (const char *device_path, /* I - Device object path */ -+ const char *profile_path, /* I - Profile object path */ -+ const char *relation) /* I - Device relation, either 'soft' or 'hard' */ -+{ -+ DBusMessage *message = NULL; /* D-Bus request */ -+ DBusMessage *reply = NULL; /* D-Bus reply */ -+ DBusMessageIter args; /* D-Bus method arguments */ -+ DBusError error; /* D-Bus error */ -+ -+ message = dbus_message_new_method_call("org.freedesktop.ColorManager", -+ device_path, -+ "org.freedesktop.ColorManager.Device", -+ "AddProfile"); -+ -+ /* send profile path as the argument */ -+ dbus_message_iter_init_append(message, &args); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &relation); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &profile_path); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "Calling %s:AddProfile(%s) [%s]", -+ device_path, profile_path, relation); -+ -+ /* send syncronous */ -+ dbus_error_init(&error); -+ reply = dbus_connection_send_with_reply_and_block(con, -+ message, -+ COLORD_DBUS_TIMEOUT, -+ &error); -+ if (reply == NULL) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "failed to AddProfile: %s:%s", -+ error.name, error.message); -+ dbus_error_free(&error); -+ goto out; -+ } -+out: -+ if (message != NULL) -+ dbus_message_unref(message); -+ if (reply != NULL) -+ dbus_message_unref(reply); -+} -+ -+/* -+ * 'colordCreateDevice()' - Create a device and register profiles. -+ */ -+ -+static void -+colordCreateDevice (cupsd_printer_t *p, /* I - Printer */ -+ ppd_file_t *ppd, /* I - PPD file */ -+ cups_array_t *profiles, /* I - Profiles array */ -+ const char *colorspace, /* I - Device colorspace, e.g. 'rgb' */ -+ char **format, /* I - Device qualifier format */ -+ const char *relation, /* I - Profile relation, either 'soft' or 'hard' */ -+ const char *scope) /* I - The scope of the device, e.g. -+ 'normal', 'temp' or 'disk' */ -+{ -+ DBusMessage *message = NULL; /* D-Bus request */ -+ DBusMessage *reply = NULL; /* D-Bus reply */ -+ DBusMessageIter args; /* D-Bus method arguments */ -+ DBusMessageIter dict; /* D-Bus method arguments */ -+ DBusError error; /* D-Bus error */ -+ const char *device_path; /* Device object path */ -+ const char *profile_path; /* Profile path */ -+ char *default_profile_path = NULL; -+ /* Default profile path */ -+ char device_id[1024]; /* Device ID as understood by colord */ -+ char format_str[1024]; /* Qualifier format as a string */ -+ -+ /* -+ * Create the device... -+ */ -+ -+ snprintf(device_id, sizeof(device_id), "cups-%s", p->name); -+ device_path = device_id; -+ -+ message = dbus_message_new_method_call("org.freedesktop.ColorManager", -+ "/org/freedesktop/ColorManager", -+ "org.freedesktop.ColorManager", -+ "CreateDevice"); -+ -+ dbus_message_iter_init_append(message, &args); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_path); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &scope); -+ -+ /* mush the qualifier format into a simple string */ -+ snprintf(format_str, sizeof(format_str), "%s.%s.%s", -+ format[0], -+ format[1], -+ format[2]); -+ -+ /* set initial properties */ -+ dbus_message_iter_open_container(&args, -+ DBUS_TYPE_ARRAY, -+ "{ss}", -+ &dict); -+ message_dict_add_strings(&dict, "Colorspace", colorspace); -+ message_dict_add_strings(&dict, "Mode", COLORD_MODE_PHYSICAL); -+ if (ppd->manufacturer != NULL) -+ message_dict_add_strings(&dict, "Vendor", ppd->manufacturer); -+ if (ppd->modelname != NULL) -+ message_dict_add_strings(&dict, "Model", ppd->modelname); -+ if (p->sanitized_device_uri != NULL) -+ message_dict_add_strings(&dict, "Serial", p->sanitized_device_uri); -+ message_dict_add_strings(&dict, "Format", format_str); -+ message_dict_add_strings(&dict, "Kind", COLORD_KIND_PRINTER); -+ dbus_message_iter_close_container(&args, &dict); -+ -+ /* send syncronous */ -+ dbus_error_init(&error); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling CreateDevice(%s,%s)", -+ device_id, scope); -+ reply = dbus_connection_send_with_reply_and_block(con, -+ message, -+ COLORD_DBUS_TIMEOUT, -+ &error); -+ if (reply == NULL) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "failed to CreateDevice: %s:%s", -+ error.name, error.message); -+ dbus_error_free(&error); -+ goto out; -+ } -+ -+ /* get reply data */ -+ dbus_message_iter_init(reply, &args); -+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "incorrect reply type"); -+ goto out; -+ } -+ dbus_message_iter_get_basic(&args, &device_path); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "created device %s", -+ device_path); -+ -+ /* add profiles */ -+ for (profile_path = cupsArrayFirst(profiles); -+ profile_path; -+ profile_path = cupsArrayNext(profiles)) -+ { -+ colordDeviceAddProfile (device_path, profile_path, relation); -+ } -+ -+out: -+ free(default_profile_path); -+ if (message != NULL) -+ dbus_message_unref(message); -+ if (reply != NULL) -+ dbus_message_unref(reply); -+} -+ -+/* -+ * 'colordFindDeviceById()' - Finds a device -+ */ -+ -+static char * -+colordFindDeviceById (const char *device_id) /* I - Device ID string */ -+{ -+ DBusMessage *message = NULL; /* D-Bus request */ -+ DBusMessage *reply = NULL; /* D-Bus reply */ -+ DBusMessageIter args; /* D-Bus method arguments */ -+ DBusError error; /* D-Bus error */ -+ const char *device_path_tmp; /* Device object path */ -+ char *device_path = NULL; /* Device object path */ -+ -+ message = dbus_message_new_method_call("org.freedesktop.ColorManager", -+ "/org/freedesktop/ColorManager", -+ "org.freedesktop.ColorManager", -+ "FindDeviceById"); -+ -+ dbus_message_iter_init_append(message, &args); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_id); -+ -+ /* send syncronous */ -+ dbus_error_init(&error); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling FindDeviceById(%s)", device_id); -+ reply = dbus_connection_send_with_reply_and_block(con, -+ message, -+ COLORD_DBUS_TIMEOUT, -+ &error); -+ if (reply == NULL) -+ { -+ /* this can happen normally on start-up */ -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "failed to DeleteDevice: %s:%s", -+ error.name, error.message); -+ dbus_error_free(&error); -+ goto out; -+ } -+ -+ /* get reply data */ -+ dbus_message_iter_init(reply, &args); -+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "incorrect reply type"); -+ goto out; -+ } -+ dbus_message_iter_get_basic(&args, &device_path_tmp); -+ if (device_path_tmp != NULL) -+ device_path = strdup (device_path_tmp); -+out: -+ if (message != NULL) -+ dbus_message_unref(message); -+ if (reply != NULL) -+ dbus_message_unref(reply); -+ return device_path; -+} -+ -+/* -+ * 'colordDeleteDevice()' - Delete a device -+ */ -+ -+static void -+colordDeleteDevice (const char *device_id) /* I - Device ID string */ -+{ -+ DBusMessage *message = NULL; /* D-Bus request */ -+ DBusMessage *reply = NULL; /* D-Bus reply */ -+ DBusMessageIter args; /* D-Bus method arguments */ -+ DBusError error; /* D-Bus error */ -+ char *device_path; /* Device object path */ -+ -+ /* -+ * Find the device... -+ */ -+ -+ device_path = colordFindDeviceById (device_id); -+ if (device_path == NULL) -+ { -+ /* this can happen normally on start-up */ -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "failed to find device: %s", -+ device_id); -+ goto out; -+ } -+ -+ /* -+ * Delete the device... -+ */ -+ -+ message = dbus_message_new_method_call("org.freedesktop.ColorManager", -+ "/org/freedesktop/ColorManager", -+ "org.freedesktop.ColorManager", -+ "DeleteDevice"); -+ -+ dbus_message_iter_init_append(message, &args); -+ dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &device_id); -+ -+ /* send syncronous */ -+ dbus_error_init(&error); -+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Calling DeleteDevice(%s)", device_id); -+ reply = dbus_connection_send_with_reply_and_block(con, -+ message, -+ COLORD_DBUS_TIMEOUT, -+ &error); -+ if (reply == NULL) -+ { -+ /* this can happen normally on start-up */ -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "failed to DeleteDevice: %s:%s", -+ error.name, error.message); -+ dbus_error_free(&error); -+ goto out; -+ } -+out: -+ free (device_path); -+ if (message != NULL) -+ dbus_message_unref(message); -+ if (reply != NULL) -+ dbus_message_unref(reply); -+} -+ -+/* -+ * 'colordGetQualifierFormat()' - Get the qualifier format. -+ * -+ * Notes: Returns a value of "ColorSpace.MediaType.Resolution" by default -+ */ -+ -+char ** -+colordGetQualifierFormat(ppd_file_t *ppd) -+{ -+ char **format; /* Qualifier format tuple */ -+ const char *tmp; /* Temporary string */ -+ ppd_attr_t *attr; /* Profile attributes */ -+ -+ /* create 3-tuple */ -+ format = calloc(3, sizeof(char*)); -+ -+ /* get 1st section */ -+ tmp = "cupsICCQualifier1"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ if (attr != NULL) -+ tmp = attr->value; -+ else -+ { -+ tmp = "DefaultColorSpace"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ } -+ if (attr == NULL) -+ { -+ tmp = "DefaultColorModel"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ } -+ if (attr == NULL) -+ { -+ tmp = ""; -+ } -+ if (strncmp(tmp, "Default", 7) == 0) -+ tmp += 7; -+ format[0] = strdup(tmp); -+ -+ /* get 2nd section */ -+ tmp = "cupsICCQualifier2"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ if (attr != NULL) -+ tmp = attr->value; -+ else -+ { -+ tmp = "DefaultMediaType"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ } -+ if (attr == NULL) -+ { -+ tmp = ""; -+ } -+ if (strncmp(tmp, "Default", 7) == 0) -+ tmp += 7; -+ format[1] = strdup(tmp); -+ -+ /* get 3rd section */ -+ tmp = "cupsICCQualifier3"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ if (attr != NULL) -+ tmp = attr->value; -+ else -+ { -+ tmp = "DefaultResolution"; -+ attr = ppdFindAttr(ppd, tmp, NULL); -+ } -+ if (attr == NULL) -+ { -+ tmp = ""; -+ } -+ if (strncmp(tmp, "Default", 7) == 0) -+ tmp += 7; -+ format[2] = strdup(tmp); -+ -+ return format; -+} -+ -+/* -+ * 'colordRegisterPrinter()' - Register profiles for a printer. -+ */ -+ -+void -+colordRegisterPrinter(cupsd_printer_t *p) /* I - printer */ -+{ -+ char ppdfile[1024], /* PPD filename */ -+ iccfile[1024]; /* ICC filename */ -+ ppd_file_t *ppd; /* PPD file */ -+ cups_array_t *profiles; /* Profile paths array */ -+ const char *profile_key; /* Profile keyword */ -+ ppd_attr_t *attr; /* Profile attributes */ -+ const char *device_colorspace; /* Device colorspace */ -+ char **format; /* Qualifier format tuple */ -+ int i; /* Loop counter */ -+ -+ /* -+ * Do nothing for discovered printers as they will have local color -+ * correction -+ */ -+ -+ if (p->type & CUPS_PRINTER_DISCOVERED) -+ return; -+ -+ /* -+ * Ensure we have a DBus connection -+ */ -+ -+ colordStart(); -+ if (con == NULL) -+ return; -+ -+ /* -+ * Try opening the PPD file for this printer... -+ */ -+ -+ snprintf(ppdfile, sizeof(ppdfile), "%s/ppd/%s.ppd", ServerRoot, p->name); -+ if ((ppd = ppdOpenFile(ppdfile)) == NULL) -+ { -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "cannot open %s", -+ ppdfile); -+ return; -+ } -+ -+ /* -+ * Find out the qualifier format -+ */ -+ -+ format = colordGetQualifierFormat(ppd); -+ -+ /* -+ * See if we have any embedded profiles... -+ */ -+ -+ profiles = cupsArrayNew3 (NULL, NULL, NULL, 0, NULL, -+ (cups_afree_func_t) free); -+ profile_key = "cupsICCProfile"; -+ attr = ppdFindAttr(ppd, profile_key, NULL); -+ for (; attr; attr = ppdFindNextAttr(ppd, profile_key, NULL)) -+ if (attr->spec[0] && attr->value && attr->value[0]) -+ { -+ if (attr->value[0] != '/') -+ snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir, -+ attr->value); -+ else -+ strlcpy(iccfile, attr->value, sizeof(iccfile)); -+ -+ if (access(iccfile, 0)) -+ { -+ cupsdLogMessage(CUPSD_LOG_WARN, -+ "no access to %s", -+ iccfile); -+ continue; -+ } -+ -+ colordCreateProfile(profiles, -+ p->name, -+ attr->spec, -+ COLORD_SPACE_UNKNOWN, -+ (const char **)format, -+ iccfile, -+ COLORD_SCOPE_TEMP); -+ } -+ -+ /* -+ * Add the grayscale profile first. We always have a grayscale profile. -+ */ -+ -+ colordCreateProfile(profiles, -+ p->name, -+ "Gray..", -+ COLORD_SPACE_GRAY, -+ (const char **)format, -+ NULL, -+ COLORD_SCOPE_TEMP); -+ -+ /* -+ * Then add the RGB/CMYK/DeviceN color profile... -+ */ -+ -+ device_colorspace = "unknown"; -+ switch (ppd->colorspace) -+ { -+ case PPD_CS_RGB : -+ case PPD_CS_CMY : -+ device_colorspace = COLORD_SPACE_RGB; -+ colordCreateProfile(profiles, -+ p->name, -+ "RGB..", -+ COLORD_SPACE_RGB, -+ (const char **)format, -+ NULL, -+ COLORD_SCOPE_TEMP); -+ break; -+ case PPD_CS_RGBK : -+ case PPD_CS_CMYK : -+ device_colorspace = COLORD_SPACE_CMYK; -+ colordCreateProfile(profiles, -+ p->name, -+ "CMYK..", -+ COLORD_SPACE_CMYK, -+ (const char **)format, -+ NULL, -+ COLORD_SCOPE_TEMP); -+ break; -+ case PPD_CS_GRAY : -+ device_colorspace = COLORD_SPACE_GRAY; -+ break; -+ case PPD_CS_N : -+ colordCreateProfile(profiles, -+ p->name, -+ "DeviceN..", -+ COLORD_SPACE_UNKNOWN, -+ (const char **)format, -+ NULL, -+ COLORD_SCOPE_TEMP); -+ break; -+ } -+ -+ /* -+ * Register the device with colord. -+ */ -+ -+ cupsdLogMessage(CUPSD_LOG_INFO, "Registering ICC color profiles for \"%s\"", -+ p->name); -+ colordCreateDevice (p, -+ ppd, -+ profiles, -+ device_colorspace, -+ format, -+ COLORD_RELATION_SOFT, -+ COLORD_SCOPE_TEMP); -+ -+ /* -+ * Free any memory we used... -+ */ -+ -+ cupsArrayDelete(profiles); -+ for (i=0; i<3; i++) -+ free(format[i]); -+ free(format); -+ -+ ppdClose(ppd); -+} -+ -+/* -+ * 'colordUnregisterPrinter()' - Unregister profiles for a printer. -+ */ -+ -+void -+colordUnregisterPrinter(cupsd_printer_t *p) /* I - printer */ -+{ -+ char device_id[1024]; /* Device ID as understood by colord */ -+ -+ /* -+ * Ensure we have a DBus connection -+ */ -+ -+ colordStart(); -+ if (con == NULL) -+ return; -+ -+ /* -+ * Just delete the device itself, and leave the profiles registered -+ */ -+ -+ snprintf(device_id, sizeof(device_id), "cups-%s", p->name); -+ colordDeleteDevice(device_id); -+} -+ -+#endif /* HAVE_DBUS */ -+ -+/* -+ * End of "$Id$". -+ */ -diff --git a/scheduler/colord.h b/scheduler/colord.h -new file mode 100644 -index 0000000..75bdd3b ---- /dev/null -+++ b/scheduler/colord.h -@@ -0,0 +1,41 @@ -+/* -+ * "$Id$" -+ * -+ * colord integration for the CUPS scheduler. -+ * -+ * Copyright 2011 Red Hat, Inc. -+ * -+ * 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. -+ * -+ */ -+ -+void colordRegisterPrinter(cupsd_printer_t *p); -+void colordUnregisterPrinter(cupsd_printer_t *p); -+void colordStart(void); -+void colordStop(void); -+ -+/* -+ * End of "$Id$". -+ */ -diff --git a/scheduler/ipp.c b/scheduler/ipp.c -index b9903d1..b5af36f 100644 ---- a/scheduler/ipp.c -+++ b/scheduler/ipp.c -@@ -2921,17 +2921,23 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ - - cupsdSetPrinterReasons(printer, "none"); - --#ifdef __APPLE__ - /* - * (Re)register color profiles... - */ - - if (!RunUser) - { -+ cupsdCmsRegisterPrinter(printer); -+#ifdef __APPLE__ -+ /* -+ * FIXME: ideally the ColorSync stuff would be moved to colorsync.c -+ * and the colorsyncRegisterProfiles() would be called from -+ * cupsdCmsRegisterPrinter() in printers.c -+ */ - apple_unregister_profiles(printer); - apple_register_profiles(printer); -- } - #endif /* __APPLE__ */ -+ } - } - - /* -@@ -7028,11 +7034,17 @@ delete_printer(cupsd_client_t *con, /* I - Client connection */ - snprintf(filename, sizeof(filename), "%s/%s.data", CacheDir, printer->name); - unlink(filename); - --#ifdef __APPLE__ - /* - * Unregister color profiles... - */ - -+ cupsdCmsUnregisterPrinter(printer); -+#ifdef __APPLE__ -+ /* -+ * FIXME: ideally the ColorSync stuff would be moved to colorsync.c -+ * and the colorsyncUnregisterPrinter() would be called from -+ * cupsdCmsUnregisterPrinter() in printers.c -+ */ - apple_unregister_profiles(printer); - #endif /* __APPLE__ */ - -diff --git a/scheduler/printers.c b/scheduler/printers.c -index 6920801..e830499 100644 ---- a/scheduler/printers.c -+++ b/scheduler/printers.c -@@ -80,6 +80,9 @@ - # include - #endif /* __APPLE__ */ - -+#ifdef HAVE_DBUS -+# include "colord.h" -+#endif /* HAVE_DBUS */ - - /* - * Local functions... -@@ -712,6 +715,53 @@ cupsdDeleteAllPrinters(void) - } - } - -+/* -+ * 'cupsdCmsRegisterPrinter()' - Registers a printer and profiles with the CMS -+ */ -+ -+void -+cupsdCmsRegisterPrinter(cupsd_printer_t *p) -+{ -+#if defined(HAVE_DBUS) -+ colordRegisterPrinter(p); -+#endif /* defined(HAVE_DBUS) */ -+} -+ -+/* -+ * 'cupsdCmsUnregisterPrinter()' - Unregisters a printer and profiles with the CMS -+ */ -+ -+void -+cupsdCmsUnregisterPrinter(cupsd_printer_t *p) -+{ -+#if defined(HAVE_DBUS) -+ colordUnregisterPrinter(p); -+#endif /* defined(HAVE_DBUS) */ -+} -+ -+/* -+ * 'cupsdCmsStart()' - Starts the CMS -+ */ -+ -+void -+cupsdCmsStart(void) -+{ -+#if defined(HAVE_DBUS) -+ colordStart(); -+#endif /* defined(HAVE_DBUS) */ -+} -+ -+/* -+ * 'cupsdCmsStop()' - Stops the CMS -+ */ -+ -+void -+cupsdCmsStop(void) -+{ -+#if defined(HAVE_DBUS) -+ colordStop(); -+#endif /* defined(HAVE_DBUS) */ -+} - - /* - * 'cupsdDeletePrinter()' - Delete a printer from the system. -@@ -752,6 +802,12 @@ cupsdDeletePrinter( - "Job stopped."); - - /* -+ * Unregister profiles... -+ */ -+ -+ cupsdCmsUnregisterPrinter(p); -+ -+ /* - * If this printer is the next for browsing, point to the next one... - */ - -@@ -1418,6 +1474,12 @@ cupsdRenamePrinter( - } - - /* -+ * Unregister profiles... -+ */ -+ -+ cupsdCmsUnregisterPrinter(p); -+ -+ /* - * Rename the printer... - */ - -@@ -2644,6 +2706,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ - #endif /* __sgi */ - - /* -+ * Re-register profiles... -+ */ -+ -+ cupsdCmsUnregisterPrinter(p); -+ cupsdCmsRegisterPrinter(p); -+ -+ /* - * Let the browse protocols reflect the change - */ - -diff --git a/scheduler/printers.h b/scheduler/printers.h -index 1751578..3820428 100644 ---- a/scheduler/printers.h -+++ b/scheduler/printers.h -@@ -170,6 +170,10 @@ extern const char *cupsdValidateDest(const char *uri, - cups_ptype_t *dtype, - cupsd_printer_t **printer); - extern void cupsdWritePrintcap(void); -+extern void cupsdCmsRegisterPrinter(cupsd_printer_t *p); -+extern void cupsdCmsUnregisterPrinter(cupsd_printer_t *p); -+extern void cupsdCmsStart(void); -+extern void cupsdCmsStop(void); - - - /* --- -1.7.6.2 - diff --git a/cups-lspp.patch b/cups-lspp.patch index dbab270..d81ef06 100644 --- a/cups-lspp.patch +++ b/cups-lspp.patch @@ -1,9 +1,9 @@ -diff -up cups-1.5.2/config.h.in.lspp cups-1.5.2/config.h.in ---- cups-1.5.2/config.h.in.lspp 2012-02-15 13:02:38.423776301 +0000 -+++ cups-1.5.2/config.h.in 2012-02-15 13:02:38.438776307 +0000 -@@ -754,6 +754,12 @@ - - #undef HAVE_XPC +diff -up cups-1.6b1/config.h.in.lspp cups-1.6b1/config.h.in +--- cups-1.6b1/config.h.in.lspp 2012-05-25 17:01:32.000000000 +0200 ++++ cups-1.6b1/config.h.in 2012-05-25 17:03:16.889043298 +0200 +@@ -768,6 +768,13 @@ static __inline int _cups_abs(int i) { r + # endif /* __GNUC__ || __STDC_VERSION__ */ + #endif /* !HAVE_ABS && !abs */ +/* + * Are we trying to meet LSPP requirements? @@ -11,12 +11,13 @@ diff -up cups-1.5.2/config.h.in.lspp cups-1.5.2/config.h.in + +#undef WITH_LSPP + - ++ #endif /* !_CUPS_CONFIG_H_ */ -diff -up cups-1.5.2/config-scripts/cups-lspp.m4.lspp cups-1.5.2/config-scripts/cups-lspp.m4 ---- cups-1.5.2/config-scripts/cups-lspp.m4.lspp 2012-02-15 13:02:38.438776307 +0000 -+++ cups-1.5.2/config-scripts/cups-lspp.m4 2012-02-15 13:02:38.438776307 +0000 + /* +diff -up cups-1.6b1/config-scripts/cups-lspp.m4.lspp cups-1.6b1/config-scripts/cups-lspp.m4 +--- cups-1.6b1/config-scripts/cups-lspp.m4.lspp 2012-05-25 17:01:32.852768495 +0200 ++++ cups-1.6b1/config-scripts/cups-lspp.m4 2012-05-25 17:01:32.853768488 +0200 @@ -0,0 +1,36 @@ +dnl +dnl LSPP code for the Common UNIX Printing System (CUPS). @@ -54,11 +55,11 @@ diff -up cups-1.5.2/config-scripts/cups-lspp.m4.lspp cups-1.5.2/config-scripts/c + ;; + esac +fi -diff -up cups-1.5.2/configure.in.lspp cups-1.5.2/configure.in ---- cups-1.5.2/configure.in.lspp 2012-02-15 13:02:38.424776301 +0000 -+++ cups-1.5.2/configure.in 2012-02-15 13:02:38.439776308 +0000 -@@ -42,6 +42,8 @@ sinclude(config-scripts/cups-defaults.m4 - sinclude(config-scripts/cups-pdf.m4) +diff -up cups-1.6b1/configure.in.lspp cups-1.6b1/configure.in +--- cups-1.6b1/configure.in.lspp 2012-05-25 17:01:32.000000000 +0200 ++++ cups-1.6b1/configure.in 2012-05-25 17:04:03.994714943 +0200 +@@ -37,6 +37,8 @@ sinclude(config-scripts/cups-systemd.m4) + sinclude(config-scripts/cups-defaults.m4) sinclude(config-scripts/cups-scripting.m4) +sinclude(config-scripts/cups-lspp.m4) @@ -66,9 +67,9 @@ diff -up cups-1.5.2/configure.in.lspp cups-1.5.2/configure.in INSTALL_LANGUAGES="" UNINSTALL_LANGUAGES="" LANGFILES="" -diff -up cups-1.5.2/filter/common.c.lspp cups-1.5.2/filter/common.c ---- cups-1.5.2/filter/common.c.lspp 2011-05-20 04:49:49.000000000 +0100 -+++ cups-1.5.2/filter/common.c 2012-02-15 13:02:38.441776309 +0000 +diff -up cups-1.6b1/filter/common.c.lspp cups-1.6b1/filter/common.c +--- cups-1.6b1/filter/common.c.lspp 2011-05-20 05:49:49.000000000 +0200 ++++ cups-1.6b1/filter/common.c 2012-05-25 17:01:32.854768481 +0200 @@ -30,6 +30,12 @@ * Include necessary headers... */ @@ -237,10 +238,10 @@ diff -up cups-1.5.2/filter/common.c.lspp cups-1.5.2/filter/common.c /* -diff -up cups-1.5.2/filter/pstops.c.lspp cups-1.5.2/filter/pstops.c ---- cups-1.5.2/filter/pstops.c.lspp 2011-09-02 19:14:34.000000000 +0100 -+++ cups-1.5.2/filter/pstops.c 2012-02-15 13:02:38.441776310 +0000 -@@ -3259,6 +3259,18 @@ write_label_prolog(pstops_doc_t *doc, /* +diff -up cups-1.6b1/filter/pstops.c.lspp cups-1.6b1/filter/pstops.c +--- cups-1.6b1/filter/pstops.c.lspp 2012-04-23 21:19:19.000000000 +0200 ++++ cups-1.6b1/filter/pstops.c 2012-05-25 17:01:32.855768474 +0200 +@@ -3202,6 +3202,18 @@ write_label_prolog(pstops_doc_t *doc, /* { const char *classification; /* CLASSIFICATION environment variable */ const char *ptr; /* Temporary string pointer */ @@ -259,7 +260,7 @@ diff -up cups-1.5.2/filter/pstops.c.lspp cups-1.5.2/filter/pstops.c /* -@@ -3281,6 +3293,124 @@ write_label_prolog(pstops_doc_t *doc, /* +@@ -3224,6 +3236,124 @@ write_label_prolog(pstops_doc_t *doc, /* return; } @@ -384,7 +385,7 @@ diff -up cups-1.5.2/filter/pstops.c.lspp cups-1.5.2/filter/pstops.c /* * Set the classification + page label string... */ -@@ -3359,7 +3489,10 @@ write_label_prolog(pstops_doc_t *doc, /* +@@ -3302,7 +3432,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"); @@ -395,11 +396,11 @@ diff -up cups-1.5.2/filter/pstops.c.lspp cups-1.5.2/filter/pstops.c /* -diff -up cups-1.5.2/Makedefs.in.lspp cups-1.5.2/Makedefs.in ---- cups-1.5.2/Makedefs.in.lspp 2012-02-15 13:02:38.429776302 +0000 -+++ cups-1.5.2/Makedefs.in 2012-02-15 13:02:38.442776310 +0000 -@@ -159,7 +159,7 @@ LDFLAGS = -L../cgi-bin -L../cups -L../f - LEGACY_BACKENDS = @LEGACY_BACKENDS@ +diff -up cups-1.6b1/Makedefs.in.lspp cups-1.6b1/Makedefs.in +--- cups-1.6b1/Makedefs.in.lspp 2012-05-25 17:01:32.000000000 +0200 ++++ cups-1.6b1/Makedefs.in 2012-05-25 17:07:57.325088484 +0200 +@@ -146,7 +146,7 @@ LDFLAGS = -L../cgi-bin -L../cups -L../f + @LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM) LINKCUPS = @LINKCUPS@ $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(LIBZ) LINKCUPSIMAGE = @LINKCUPSIMAGE@ -LIBS = $(LINKCUPS) $(COMMONLIBS) @@ -407,18 +408,18 @@ diff -up cups-1.5.2/Makedefs.in.lspp cups-1.5.2/Makedefs.in OPTIM = @OPTIM@ OPTIONS = PAMLIBS = @PAMLIBS@ -diff -up cups-1.5.2/scheduler/client.c.lspp cups-1.5.2/scheduler/client.c ---- cups-1.5.2/scheduler/client.c.lspp 2012-02-15 13:02:38.394776287 +0000 -+++ cups-1.5.2/scheduler/client.c 2012-02-15 13:02:38.444776310 +0000 -@@ -45,6 +45,7 @@ - * valid_host() - Is the Host: field valid? - * write_file() - Send a file via HTTP. - * write_pipe() - Flag that data is available on the CGI pipe. -+ * client_pid_to_auid() - Get the audit login uid of the client. +diff -up cups-1.6b1/scheduler/client.c.lspp cups-1.6b1/scheduler/client.c +--- cups-1.6b1/scheduler/client.c.lspp 2012-05-08 00:41:30.000000000 +0200 ++++ cups-1.6b1/scheduler/client.c 2012-05-25 17:13:38.947707163 +0200 +@@ -41,6 +41,7 @@ + * valid_host() - Is the Host: field valid? + * write_file() - Send a file via HTTP. + * write_pipe() - Flag that data is available on the CGI pipe. ++ * client_pid_to_auid() - Get the audit login uid of the client. */ /* -@@ -53,10 +54,17 @@ +@@ -49,10 +50,16 @@ #include "cupsd.h" @@ -432,11 +433,10 @@ diff -up cups-1.5.2/scheduler/client.c.lspp cups-1.5.2/scheduler/client.c +#include +#include +#endif /* WITH_LSPP */ -+ /* - * Local functions... -@@ -354,6 +362,57 @@ cupsdAcceptClient(cupsd_listener_t *lis) + * Local globals... +@@ -371,6 +378,57 @@ cupsdAcceptClient(cupsd_listener_t *lis) } #endif /* HAVE_TCPD_H */ @@ -493,8 +493,8 @@ diff -up cups-1.5.2/scheduler/client.c.lspp cups-1.5.2/scheduler/client.c + #ifdef AF_LOCAL if (con->http.hostaddr->addr.sa_family == AF_LOCAL) - cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s (Domain)", -@@ -714,6 +773,13 @@ cupsdReadClient(cupsd_client_t *con) /* + cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Accepted from %s (Domain)", +@@ -678,6 +736,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 */ @@ -508,7 +508,7 @@ diff -up cups-1.5.2/scheduler/client.c.lspp cups-1.5.2/scheduler/client.c status = HTTP_CONTINUE; -@@ -2140,6 +2206,67 @@ cupsdReadClient(cupsd_client_t *con) /* +@@ -2126,6 +2191,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); @@ -576,9 +576,9 @@ diff -up cups-1.5.2/scheduler/client.c.lspp cups-1.5.2/scheduler/client.c } if (con->http.state != HTTP_POST_SEND) -@@ -4550,6 +4677,50 @@ make_certificate(cupsd_client_t *con) /* - #endif /* HAVE_SSL */ - +@@ -3581,6 +3707,49 @@ is_path_absolute(const char *path) /* I + return (1); + } +#ifdef WITH_LSPP +/* @@ -623,13 +623,12 @@ diff -up cups-1.5.2/scheduler/client.c.lspp cups-1.5.2/scheduler/client.c + return uid; +} +#endif /* WITH_LSPP */ -+ + /* * 'pipe_command()' - Pipe the output of a command to the remote client. - */ -diff -up cups-1.5.2/scheduler/client.h.lspp cups-1.5.2/scheduler/client.h ---- cups-1.5.2/scheduler/client.h.lspp 2012-02-15 13:02:38.430776303 +0000 -+++ cups-1.5.2/scheduler/client.h 2012-02-15 13:02:38.446776310 +0000 +diff -up cups-1.6b1/scheduler/client.h.lspp cups-1.6b1/scheduler/client.h +--- cups-1.6b1/scheduler/client.h.lspp 2012-05-25 17:01:32.847768530 +0200 ++++ cups-1.6b1/scheduler/client.h 2012-05-25 17:14:12.963470050 +0200 @@ -18,6 +18,13 @@ #endif /* HAVE_AUTHORIZATION_H */ @@ -644,7 +643,7 @@ diff -up cups-1.5.2/scheduler/client.h.lspp cups-1.5.2/scheduler/client.h /* * HTTP client structure... */ -@@ -61,6 +68,10 @@ struct cupsd_client_s +@@ -63,6 +70,10 @@ struct cupsd_client_s #ifdef HAVE_AUTHORIZATION_H AuthorizationRef authref; /* Authorization ref */ #endif /* HAVE_AUTHORIZATION_H */ @@ -655,7 +654,7 @@ diff -up cups-1.5.2/scheduler/client.h.lspp cups-1.5.2/scheduler/client.h }; #define HTTP(con) &((con)->http) -@@ -133,6 +144,9 @@ extern void cupsdStartListening(void); +@@ -135,6 +146,9 @@ extern void cupsdStartListening(void); extern void cupsdStopListening(void); extern void cupsdUpdateCGI(void); extern void cupsdWriteClient(cupsd_client_t *con); @@ -663,12 +662,12 @@ diff -up cups-1.5.2/scheduler/client.h.lspp cups-1.5.2/scheduler/client.h +extern uid_t client_pid_to_auid(pid_t clipid); +#endif /* WITH_LSPP */ - - /* -diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c ---- cups-1.5.2/scheduler/conf.c.lspp 2012-02-15 13:02:38.397776287 +0000 -+++ cups-1.5.2/scheduler/conf.c 2012-02-15 13:02:38.448776311 +0000 -@@ -31,6 +31,7 @@ + #ifdef HAVE_SSL + extern int cupsdEndTLS(cupsd_client_t *con); +diff -up cups-1.6b1/scheduler/conf.c.lspp cups-1.6b1/scheduler/conf.c +--- cups-1.6b1/scheduler/conf.c.lspp 2012-05-25 17:01:32.778769011 +0200 ++++ cups-1.6b1/scheduler/conf.c 2012-05-25 17:01:32.860768439 +0200 +@@ -32,6 +32,7 @@ * read_location() - Read a definition. * read_policy() - Read a definition. * set_policy_defaults() - Set default policy values as needed. @@ -676,7 +675,7 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c */ /* -@@ -56,6 +57,9 @@ +@@ -57,6 +58,9 @@ # define INADDR_NONE 0xffffffff #endif /* !INADDR_NONE */ @@ -686,7 +685,7 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c /* * Configuration variable structure... -@@ -173,6 +177,10 @@ static const cupsd_var_t variables[] = +@@ -164,6 +168,10 @@ static const cupsd_var_t variables[] = # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS) { "ServerKey", &ServerKey, CUPSD_VARTYPE_PATHNAME }, # endif /* HAVE_LIBSSL || HAVE_GNUTLS */ @@ -697,7 +696,7 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c #endif /* HAVE_SSL */ { "ServerName", &ServerName, CUPSD_VARTYPE_STRING }, { "ServerRoot", &ServerRoot, CUPSD_VARTYPE_PATHNAME }, -@@ -434,6 +442,9 @@ cupsdReadConfiguration(void) +@@ -537,6 +545,9 @@ cupsdReadConfiguration(void) const char *tmpdir; /* TMPDIR environment variable */ struct stat tmpinfo; /* Temporary directory info */ cupsd_policy_t *p; /* Policy */ @@ -707,7 +706,7 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c /* -@@ -726,6 +737,25 @@ cupsdReadConfiguration(void) +@@ -801,6 +812,25 @@ cupsdReadConfiguration(void) RunUser = getuid(); @@ -733,7 +732,7 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.", RemotePort ? "enabled" : "disabled"); -@@ -1116,7 +1146,19 @@ cupsdReadConfiguration(void) +@@ -1185,7 +1215,19 @@ cupsdReadConfiguration(void) cupsdClearString(&Classification); if (Classification) @@ -753,7 +752,7 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c /* * Check the MaxClients setting, and then allocate memory for it... -@@ -3781,6 +3823,18 @@ read_location(cups_file_t *fp, /* I - C +@@ -3423,6 +3465,18 @@ read_location(cups_file_t *fp, /* I - C return ((FatalErrors & CUPSD_FATAL_CONFIG) ? 0 : linenum); } @@ -772,35 +771,36 @@ diff -up cups-1.5.2/scheduler/conf.c.lspp cups-1.5.2/scheduler/conf.c /* * 'read_policy()' - Read a definition. -diff -up cups-1.5.2/scheduler/conf.h.lspp cups-1.5.2/scheduler/conf.h ---- cups-1.5.2/scheduler/conf.h.lspp 2012-02-15 13:02:38.320776250 +0000 -+++ cups-1.5.2/scheduler/conf.h 2012-02-15 13:02:38.450776313 +0000 -@@ -250,6 +250,12 @@ VAR char *ServerKey VALUE(NULL); - VAR int SSLOptions VALUE(CUPSD_SSL_NONE); +diff -up cups-1.6b1/scheduler/conf.h.lspp cups-1.6b1/scheduler/conf.h +--- cups-1.6b1/scheduler/conf.h.lspp 2012-05-25 17:01:32.000000000 +0200 ++++ cups-1.6b1/scheduler/conf.h 2012-05-25 17:16:20.522580884 +0200 +@@ -247,6 +247,13 @@ VAR int SSLOptions VALUE(CUPSD_SSL_NO /* SSL/TLS options */ #endif /* HAVE_SSL */ + +#ifdef WITH_LSPP +VAR int AuditLog VALUE(-1), + /* File descriptor for audit */ + PerPageLabels VALUE(TRUE); + /* Put the label on each page */ +#endif /* WITH_LSPP */ - ++ #ifdef HAVE_LAUNCHD - VAR int LaunchdTimeout VALUE(DEFAULT_KEEPALIVE); -@@ -261,6 +267,9 @@ VAR char *SystemGroupAuthKey VALUE(NULL - /* System group auth key */ - #endif /* HAVE_AUTHORIZATION_H */ + VAR int LaunchdTimeout VALUE(10); + /* Time after which an idle cupsd will exit */ +@@ -265,6 +272,9 @@ int HaveServerCreds VALUE(0); + gss_cred_id_t ServerCreds; /* Server's GSS credentials */ + #endif /* HAVE_GSSAPI */ +#ifdef WITH_LSPP -+extern int is_lspp_config(void); ++extern int is_lspp_config(void); +#endif /* WITH_LSPP */ /* * Prototypes... -diff -up cups-1.5.2/scheduler/cupsd.h.lspp cups-1.5.2/scheduler/cupsd.h ---- cups-1.5.2/scheduler/cupsd.h.lspp 2012-02-15 13:02:38.383776281 +0000 -+++ cups-1.5.2/scheduler/cupsd.h 2012-02-15 13:02:38.450776313 +0000 +diff -up cups-1.6b1/scheduler/cupsd.h.lspp cups-1.6b1/scheduler/cupsd.h +--- cups-1.6b1/scheduler/cupsd.h.lspp 2012-05-21 19:40:22.000000000 +0200 ++++ cups-1.6b1/scheduler/cupsd.h 2012-05-25 17:01:32.861768432 +0200 @@ -13,6 +13,8 @@ * file is missing or damaged, see the license at "http://www.cups.org/". */ @@ -832,10 +832,10 @@ diff -up cups-1.5.2/scheduler/cupsd.h.lspp cups-1.5.2/scheduler/cupsd.h /* * Some OS's don't have hstrerror(), most notably Solaris... */ -diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c ---- cups-1.5.2/scheduler/ipp.c.lspp 2012-02-15 13:02:38.417776295 +0000 -+++ cups-1.5.2/scheduler/ipp.c 2012-02-15 13:02:38.454776315 +0000 -@@ -41,6 +41,7 @@ +diff -up cups-1.6b1/scheduler/ipp.c.lspp cups-1.6b1/scheduler/ipp.c +--- cups-1.6b1/scheduler/ipp.c.lspp 2012-05-25 17:01:32.810768787 +0200 ++++ cups-1.6b1/scheduler/ipp.c 2012-05-25 17:18:06.620841313 +0200 +@@ -35,6 +35,7 @@ * cancel_all_jobs() - Cancel all or selected print jobs. * cancel_job() - Cancel a print job. * cancel_subscription() - Cancel a subscription. @@ -843,7 +843,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c * check_rss_recipient() - Check that we do not have a duplicate RSS * feed URI. * check_quotas() - Check quotas for a printer and user. -@@ -106,6 +107,9 @@ +@@ -99,6 +100,9 @@ * validate_user() - Validate the user for the request. */ @@ -853,7 +853,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * Include necessary headers... */ -@@ -131,6 +135,14 @@ extern int mbr_check_membership_by_id(uu +@@ -122,6 +126,14 @@ extern int mbr_check_membership_by_id(uu # endif /* HAVE_MEMBERSHIPPRIV_H */ #endif /* __APPLE__ */ @@ -868,7 +868,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * Local functions... -@@ -168,6 +180,9 @@ static void cancel_all_jobs(cupsd_client +@@ -146,6 +158,9 @@ static void cancel_all_jobs(cupsd_client static void cancel_job(cupsd_client_t *con, ipp_attribute_t *uri); static void cancel_subscription(cupsd_client_t *con, int id); static int check_rss_recipient(const char *recipient); @@ -876,9 +876,9 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c +static int check_context(cupsd_client_t *con, cupsd_job_t *job); +#endif /* WITH_LSPP */ static int check_quotas(cupsd_client_t *con, cupsd_printer_t *p); - static ipp_attribute_t *copy_attribute(ipp_t *to, ipp_attribute_t *attr, - int quickcopy); -@@ -1365,6 +1380,21 @@ add_job(cupsd_client_t *con, /* I - Cl + static void close_job(cupsd_client_t *con, ipp_attribute_t *uri); + static void copy_attrs(ipp_t *to, ipp_t *from, cups_array_t *ra, +@@ -1285,6 +1300,21 @@ add_job(cupsd_client_t *con, /* I - Cl ipp_attribute_t *media_col, /* media-col attribute */ *media_margin; /* media-*-margin attribute */ ipp_t *unsup_col; /* media-col in unsupported response */ @@ -900,7 +900,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))", -@@ -1622,6 +1652,106 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1542,6 +1572,106 @@ add_job(cupsd_client_t *con, /* I - Cl ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, "Untitled"); @@ -1007,7 +1007,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c if ((job = cupsdAddJob(priority, printer->name)) == NULL) { send_ipp_status(con, IPP_INTERNAL_ERROR, -@@ -1630,6 +1760,32 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1550,6 +1680,32 @@ add_job(cupsd_client_t *con, /* I - Cl return (NULL); } @@ -1037,10 +1037,10 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c + } +#endif /* WITH_LSPP */ + - job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT | - CUPS_PRINTER_REMOTE); + job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE); job->attrs = con->request; -@@ -1835,6 +1991,29 @@ add_job(cupsd_client_t *con, /* I - Cl + job->dirty = 1; +@@ -1759,6 +1915,29 @@ add_job(cupsd_client_t *con, /* I - Cl attr->values[0].string.text = _cupsStrRetain(printer->job_sheets[0]); attr->values[1].string.text = _cupsStrRetain(printer->job_sheets[1]); } @@ -1070,7 +1070,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c job->job_sheets = attr; -@@ -1865,6 +2044,9 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1789,6 +1968,9 @@ add_job(cupsd_client_t *con, /* I - Cl "job-sheets=\"%s,none\", " "job-originating-user-name=\"%s\"", Classification, job->username); @@ -1080,7 +1080,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c } else if (attr->num_values == 2 && strcmp(attr->values[0].string.text, -@@ -1883,6 +2065,9 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1807,6 +1989,9 @@ add_job(cupsd_client_t *con, /* I - Cl "job-originating-user-name=\"%s\"", attr->values[0].string.text, attr->values[1].string.text, job->username); @@ -1090,7 +1090,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c } else if (strcmp(attr->values[0].string.text, Classification) && strcmp(attr->values[0].string.text, "none") && -@@ -1903,6 +2088,9 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1827,6 +2012,9 @@ add_job(cupsd_client_t *con, /* I - Cl "job-originating-user-name=\"%s\"", attr->values[0].string.text, attr->values[1].string.text, job->username); @@ -1100,7 +1100,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c } } else if (strcmp(attr->values[0].string.text, Classification) && -@@ -1943,8 +2131,52 @@ add_job(cupsd_client_t *con, /* I - Cl +@@ -1867,8 +2055,52 @@ add_job(cupsd_client_t *con, /* I - Cl "job-sheets=\"%s\", " "job-originating-user-name=\"%s\"", Classification, job->username); @@ -1153,7 +1153,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * See if we need to add the starting sheet... -@@ -4709,6 +4941,111 @@ check_rss_recipient( +@@ -3615,6 +3847,111 @@ check_rss_recipient( } @@ -1265,7 +1265,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * 'check_quotas()' - Check quotas for a printer and user. */ -@@ -5349,6 +5686,15 @@ copy_banner(cupsd_client_t *con, /* I - +@@ -4067,6 +4404,15 @@ copy_banner(cupsd_client_t *con, /* I - char attrname[255], /* Name of attribute */ *s; /* Pointer into name */ ipp_attribute_t *attr; /* Attribute */ @@ -1281,7 +1281,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c cupsdLogMessage(CUPSD_LOG_DEBUG2, -@@ -5384,6 +5730,82 @@ copy_banner(cupsd_client_t *con, /* I - +@@ -4102,6 +4448,82 @@ copy_banner(cupsd_client_t *con, /* I - fchmod(cupsFileNumber(out), 0640); fchown(cupsFileNumber(out), RunUser, Group); @@ -1364,7 +1364,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * Try the localized banner file under the subdirectory... -@@ -5478,6 +5900,24 @@ copy_banner(cupsd_client_t *con, /* I - +@@ -4196,6 +4618,24 @@ copy_banner(cupsd_client_t *con, /* I - else s = attrname; @@ -1389,7 +1389,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c if (!strcmp(s, "printer-name")) { cupsFilePuts(out, job->dest); -@@ -7475,6 +7915,22 @@ get_job_attrs(cupsd_client_t *con, /* I +@@ -6273,6 +6713,22 @@ get_job_attrs(cupsd_client_t *con, /* I exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username); @@ -1412,7 +1412,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * Copy attributes... */ -@@ -7828,6 +8284,11 @@ get_jobs(cupsd_client_t *con, /* I - C +@@ -6626,6 +7082,11 @@ get_jobs(cupsd_client_t *con, /* I - C if (username[0] && _cups_strcasecmp(username, job->username)) continue; @@ -1424,7 +1424,7 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c if (count > 0) ippAddSeparator(con->response); -@@ -12287,6 +12748,11 @@ validate_user(cupsd_job_t *job, /* I +@@ -11106,6 +11567,11 @@ validate_user(cupsd_job_t *job, /* I strlcpy(username, get_username(con), userlen); @@ -1436,11 +1436,11 @@ diff -up cups-1.5.2/scheduler/ipp.c.lspp cups-1.5.2/scheduler/ipp.c /* * Check the username against the owner... */ -diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c ---- cups-1.5.2/scheduler/job.c.lspp 2012-02-15 13:02:38.362776272 +0000 -+++ cups-1.5.2/scheduler/job.c 2012-02-15 13:02:38.457776315 +0000 -@@ -64,6 +64,9 @@ - * update_job_attrs() - Update the job-printer-* attributes. +diff -up cups-1.6b1/scheduler/job.c.lspp cups-1.6b1/scheduler/job.c +--- cups-1.6b1/scheduler/job.c.lspp 2012-05-25 17:01:32.824768691 +0200 ++++ cups-1.6b1/scheduler/job.c 2012-05-25 17:22:50.856860012 +0200 +@@ -68,6 +68,9 @@ + * update_job_attrs() - Update the job-printer-* attributes. */ +/* Copyright (C) 2005 Trusted Computer Solutions, Inc. */ @@ -1449,7 +1449,7 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c /* * Include necessary headers... */ -@@ -79,6 +82,14 @@ +@@ -83,6 +86,14 @@ # endif /* HAVE_IOKIT_PWR_MGT_IOPMLIBPRIVATE_H */ #endif /* __APPLE__ */ @@ -1464,7 +1464,7 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c /* * Design Notes for Job Management -@@ -519,6 +530,14 @@ cupsdContinueJob(cupsd_job_t *job) /* I +@@ -580,6 +591,14 @@ cupsdContinueJob(cupsd_job_t *job) /* I /* PRINTER_STATE_REASONS env var */ rip_max_cache[255]; /* RIP_MAX_CACHE env variable */ @@ -1479,7 +1479,7 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c cupsdLogMessage(CUPSD_LOG_DEBUG2, -@@ -1007,6 +1026,67 @@ cupsdContinueJob(cupsd_job_t *job) /* I +@@ -1071,6 +1090,67 @@ cupsdContinueJob(cupsd_job_t *job) /* I } } @@ -1547,8 +1547,8 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c if (Classification && !banner_page) { if ((attr = ippFindAttribute(job->attrs, "job-sheets", -@@ -1728,6 +1808,20 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J - goto error; +@@ -1845,6 +1925,20 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J + ippSetString(job->attrs, &job->reasons, 0, "none"); } +#ifdef WITH_LSPP @@ -1568,9 +1568,9 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/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); -@@ -2116,6 +2210,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J - char filename[1024], /* Job control filename */ - newfile[1024]; /* New job control filename */ +@@ -2235,6 +2329,14 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J + { + char filename[1024]; /* Job control filename */ cups_file_t *fp; /* Job file */ +#ifdef WITH_LSPP + security_context_t spoolcon; /* context of the job control file */ @@ -1583,8 +1583,8 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p", -@@ -2135,6 +2237,76 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J - fchmod(cupsFileNumber(fp), 0600); +@@ -2247,6 +2349,76 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J + fchown(cupsFileNumber(fp), RunUser, Group); +#ifdef WITH_LSPP @@ -1660,7 +1660,7 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c job->attrs->state = IPP_IDLE; if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, -@@ -3525,6 +3697,18 @@ get_options(cupsd_job_t *job, /* I - Jo +@@ -3735,6 +3907,18 @@ get_options(cupsd_job_t *job, /* I - Jo banner_page) continue; @@ -1679,7 +1679,7 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c /* * Otherwise add them to the list... */ -@@ -4159,6 +4343,19 @@ static void +@@ -4457,6 +4641,19 @@ static void start_job(cupsd_job_t *job, /* I - Job ID */ cupsd_printer_t *printer) /* I - Printer to print job */ { @@ -1699,7 +1699,7 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job(job=%p(%d), printer=%p(%s))", job, job->id, printer, printer->name); -@@ -4288,6 +4485,108 @@ start_job(cupsd_job_t *job, /* I - +@@ -4599,6 +4796,108 @@ start_job(cupsd_job_t *job, /* I - fcntl(job->side_pipes[1], F_SETFD, fcntl(job->side_pipes[1], F_GETFD) | FD_CLOEXEC); @@ -1808,9 +1808,9 @@ diff -up cups-1.5.2/scheduler/job.c.lspp cups-1.5.2/scheduler/job.c /* * Now start the first file in the job... */ -diff -up cups-1.5.2/scheduler/job.h.lspp cups-1.5.2/scheduler/job.h ---- cups-1.5.2/scheduler/job.h.lspp 2011-05-18 03:27:11.000000000 +0100 -+++ cups-1.5.2/scheduler/job.h 2012-02-15 13:02:38.459776316 +0000 +diff -up cups-1.6b1/scheduler/job.h.lspp cups-1.6b1/scheduler/job.h +--- cups-1.6b1/scheduler/job.h.lspp 2012-05-23 03:36:50.000000000 +0200 ++++ cups-1.6b1/scheduler/job.h 2012-05-25 17:23:41.802504888 +0200 @@ -13,6 +13,13 @@ * file is missing or damaged, see the license at "http://www.cups.org/". */ @@ -1825,10 +1825,10 @@ diff -up cups-1.5.2/scheduler/job.h.lspp cups-1.5.2/scheduler/job.h /* * Constants... */ -@@ -76,6 +83,10 @@ struct cupsd_job_s /**** Job request * - void *profile; /* Security profile */ - cups_array_t *history; /* Debug log history */ +@@ -82,6 +89,10 @@ struct cupsd_job_s /**** Job request * int progress; /* Printing progress */ + int num_keywords; /* Number of PPD keywords */ + cups_option_t *keywords; /* PPD keywords */ +#ifdef WITH_LSPP + security_context_t scon; /* Security context of job */ + uid_t auid; /* Audit loginuid for this job */ @@ -1836,9 +1836,9 @@ diff -up cups-1.5.2/scheduler/job.h.lspp cups-1.5.2/scheduler/job.h }; typedef struct cupsd_joblog_s /**** Job log message ****/ -diff -up cups-1.5.2/scheduler/main.c.lspp cups-1.5.2/scheduler/main.c ---- cups-1.5.2/scheduler/main.c.lspp 2012-02-15 13:02:38.436776304 +0000 -+++ cups-1.5.2/scheduler/main.c 2012-02-15 13:02:38.461776318 +0000 +diff -up cups-1.6b1/scheduler/main.c.lspp cups-1.6b1/scheduler/main.c +--- cups-1.6b1/scheduler/main.c.lspp 2012-05-25 17:01:32.849768516 +0200 ++++ cups-1.6b1/scheduler/main.c 2012-05-25 17:01:32.868768383 +0200 @@ -38,6 +38,8 @@ * usage() - Show scheduler usage. */ @@ -1858,7 +1858,7 @@ diff -up cups-1.5.2/scheduler/main.c.lspp cups-1.5.2/scheduler/main.c /* * Local functions... -@@ -143,6 +148,9 @@ main(int argc, /* I - Number of comm +@@ -138,6 +143,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 */ @@ -1868,7 +1868,7 @@ diff -up cups-1.5.2/scheduler/main.c.lspp cups-1.5.2/scheduler/main.c #ifdef __sgi cups_file_t *fp; /* Fake lpsched lock file */ struct stat statbuf; /* Needed for checking lpsched FIFO */ -@@ -472,6 +480,25 @@ main(int argc, /* I - Number of comm +@@ -463,6 +471,25 @@ main(int argc, /* I - Number of comm #endif /* DEBUG */ } @@ -1894,7 +1894,7 @@ diff -up cups-1.5.2/scheduler/main.c.lspp cups-1.5.2/scheduler/main.c /* * Set the timezone info... */ -@@ -1246,6 +1273,11 @@ main(int argc, /* I - Number of comm +@@ -1180,6 +1207,11 @@ main(int argc, /* I - Number of comm cupsdStopSelect(); @@ -1906,9 +1906,9 @@ diff -up cups-1.5.2/scheduler/main.c.lspp cups-1.5.2/scheduler/main.c return (!stop_scheduler); } -diff -up cups-1.5.2/scheduler/printers.c.lspp cups-1.5.2/scheduler/printers.c ---- cups-1.5.2/scheduler/printers.c.lspp 2012-02-15 13:02:38.420776300 +0000 -+++ cups-1.5.2/scheduler/printers.c 2012-02-15 13:02:38.463776320 +0000 +diff -up cups-1.6b1/scheduler/printers.c.lspp cups-1.6b1/scheduler/printers.c +--- cups-1.6b1/scheduler/printers.c.lspp 2012-05-25 17:01:32.786768955 +0200 ++++ cups-1.6b1/scheduler/printers.c 2012-05-25 17:24:11.144300359 +0200 @@ -56,6 +56,8 @@ * write_xml_string() - Write a string with XML escaping. */ @@ -1918,19 +1918,18 @@ diff -up cups-1.5.2/scheduler/printers.c.lspp cups-1.5.2/scheduler/printers.c /* * Include necessary headers... */ -@@ -84,6 +86,11 @@ - # include "colord.h" - #endif /* HAVE_DBUS */ +@@ -80,6 +82,10 @@ + # include + #endif /* __APPLE__ */ +#ifdef WITH_LSPP +# include +# include +#endif /* WITH_LSPP */ -+ + /* * Local functions... - */ -@@ -2199,6 +2206,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p) +@@ -2101,6 +2107,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p) "username", "password" }; @@ -1944,7 +1943,7 @@ diff -up cups-1.5.2/scheduler/printers.c.lspp cups-1.5.2/scheduler/printers.c DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name, -@@ -2336,6 +2350,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p) +@@ -2234,6 +2247,45 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p) attr->values[1].string.text = _cupsStrAlloc(Classification ? Classification : p->job_sheets[1]); } @@ -1990,7 +1989,7 @@ diff -up cups-1.5.2/scheduler/printers.c.lspp cups-1.5.2/scheduler/printers.c } p->raw = 0; -@@ -5546,7 +5599,6 @@ write_irix_state(cupsd_printer_t *p) /* +@@ -5320,7 +5372,6 @@ write_irix_state(cupsd_printer_t *p) /* } #endif /* __sgi */ diff --git a/cups-no-gzip-man.patch b/cups-no-gzip-man.patch index 6786c44..cabfcf1 100644 --- a/cups-no-gzip-man.patch +++ b/cups-no-gzip-man.patch @@ -1,10 +1,10 @@ -diff -up cups-1.5b1/config-scripts/cups-manpages.m4.no-gzip-man cups-1.5b1/config-scripts/cups-manpages.m4 ---- cups-1.5b1/config-scripts/cups-manpages.m4.no-gzip-man 2011-05-12 07:21:56.000000000 +0200 -+++ cups-1.5b1/config-scripts/cups-manpages.m4 2011-05-23 17:25:50.000000000 +0200 +diff -up cups-1.6b1/config-scripts/cups-manpages.m4.no-gzip-man cups-1.6b1/config-scripts/cups-manpages.m4 +--- cups-1.6b1/config-scripts/cups-manpages.m4.no-gzip-man 2012-04-23 19:26:57.000000000 +0200 ++++ cups-1.6b1/config-scripts/cups-manpages.m4 2012-05-25 14:57:01.959845267 +0200 @@ -69,10 +69,10 @@ case "$uname" in ;; Linux* | GNU* | Darwin*) - # Linux, GNU Hurd, and Mac OS X + # Linux, GNU Hurd, and OS X - MAN1EXT=1.gz - MAN5EXT=5.gz - MAN7EXT=7.gz diff --git a/cups-res_init.patch b/cups-res_init.patch index 1dc110e..94a81a4 100644 --- a/cups-res_init.patch +++ b/cups-res_init.patch @@ -1,7 +1,7 @@ -diff -up cups-1.5b1/cups/http-addr.c.res_init cups-1.5b1/cups/http-addr.c ---- cups-1.5b1/cups/http-addr.c.res_init 2011-04-16 01:38:13.000000000 +0200 -+++ cups-1.5b1/cups/http-addr.c 2011-05-24 15:56:50.000000000 +0200 -@@ -256,7 +256,8 @@ httpAddrLookup( +diff -up cups-1.6b1/cups/http-addr.c.res_init cups-1.6b1/cups/http-addr.c +--- cups-1.6b1/cups/http-addr.c.res_init 2012-05-17 00:57:03.000000000 +0200 ++++ cups-1.6b1/cups/http-addr.c 2012-05-25 15:51:51.323916352 +0200 +@@ -254,7 +254,8 @@ httpAddrLookup( if (error) { @@ -11,16 +11,16 @@ diff -up cups-1.5b1/cups/http-addr.c.res_init cups-1.5b1/cups/http-addr.c cg->need_res_init = 1; return (httpAddrString(addr, name, namelen)); -diff -up cups-1.5b1/cups/http-addrlist.c.res_init cups-1.5b1/cups/http-addrlist.c ---- cups-1.5b1/cups/http-addrlist.c.res_init 2011-05-20 05:49:49.000000000 +0200 -+++ cups-1.5b1/cups/http-addrlist.c 2011-05-24 15:56:50.000000000 +0200 -@@ -386,7 +386,8 @@ httpAddrGetList(const char *hostname, /* - - freeaddrinfo(results); +diff -up cups-1.6b1/cups/http-addrlist.c.res_init cups-1.6b1/cups/http-addrlist.c +--- cups-1.6b1/cups/http-addrlist.c.res_init 2012-04-23 19:26:57.000000000 +0200 ++++ cups-1.6b1/cups/http-addrlist.c 2012-05-25 16:05:05.930377452 +0200 +@@ -540,7 +540,8 @@ httpAddrGetList(const char *hostname, /* } -- else if (error == EAI_FAIL) -+ else if (error == EAI_FAIL || error == EAI_AGAIN || error == EAI_NODATA || -+ error == EAI_NONAME) - cg->need_res_init = 1; + else + { +- if (error == EAI_FAIL) ++ if (error == EAI_FAIL || error == EAI_AGAIN || error == EAI_NODATA || ++ error == EAI_NONAME) + cg->need_res_init = 1; - #else + _cupsSetError(IPP_INTERNAL_ERROR, gai_strerror(error), 0); diff --git a/cups-serial.patch b/cups-serial.patch deleted file mode 100644 index d17c9cb..0000000 --- a/cups-serial.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -up cups-1.5b1/backend/serial.c.serial cups-1.5b1/backend/serial.c ---- cups-1.5b1/backend/serial.c.serial 2011-05-20 05:49:49.000000000 +0200 -+++ cups-1.5b1/backend/serial.c 2011-05-23 17:34:33.000000000 +0200 -@@ -75,6 +75,7 @@ - #endif /* __APPLE__ */ - - #if defined(__linux) && defined(TIOCGSERIAL) -+# include - # include - # include - #endif /* __linux && TIOCGSERIAL */ diff --git a/cups-snmp-quirks.patch b/cups-snmp-quirks.patch deleted file mode 100644 index 535f6c0..0000000 --- a/cups-snmp-quirks.patch +++ /dev/null @@ -1,115 +0,0 @@ -diff -up cups-1.5.2/backend/snmp-supplies.c.snmp-quirks cups-1.5.2/backend/snmp-supplies.c ---- cups-1.5.2/backend/snmp-supplies.c.snmp-quirks 2011-10-07 23:41:07.000000000 +0200 -+++ cups-1.5.2/backend/snmp-supplies.c 2012-02-06 10:48:47.543906526 +0100 -@@ -47,6 +47,13 @@ - - - /* -+ * Printer quirks... -+ */ -+ -+#define QUIRK_CAPACITY (1<<0) -+ -+ -+/* - * Local structures... - */ - -@@ -66,6 +73,12 @@ typedef struct /**** Printer state ta - const char *keyword; /* IPP printer-state-reasons keyword */ - } backend_state_t; - -+typedef struct /**** Quirk names table ****/ -+{ -+ int bit; /* Quirk bit */ -+ const char *keyword; /* cupsSNMPQuirks keyword */ -+} quirk_name_t; -+ - - /* - * Local globals... -@@ -77,6 +90,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 */ - static int supply_state = -1; -@@ -176,6 +190,15 @@ static const backend_state_t const suppl - { CUPS_TONER_EMPTY, "toner-empty-warning" } - }; - -+static const quirk_name_t const quirk_names[] = -+ { -+ /* -+ * The prtMarkerSuppliesLevel values are -+ * percentages, not levels relative to the -+ * stated capacity. -+ */ -+ { QUIRK_CAPACITY, "capacity" } -+ }; - - /* - * Local functions... -@@ -229,6 +252,9 @@ backendSNMPSupplies( - - for (i = 0, ptr = value; i < num_supplies; i ++, ptr += strlen(ptr)) - { -+ if (quirks & QUIRK_CAPACITY) -+ supplies[i].max_capacity = 100; -+ - if (supplies[i].max_capacity > 0 && supplies[i].level >= 0) - percent = 100 * supplies[i].level / supplies[i].max_capacity; - else -@@ -401,6 +427,7 @@ backend_init_supplies( - http_addr_t *addr) /* I - Printer address */ - { - int i, /* Looping var */ -+ len, /* Quirk name length */ - type; /* Current marker type */ - cups_file_t *cachefile; /* Cache file */ - const char *cachedir; /* CUPS_CACHEDIR value */ -@@ -462,6 +489,7 @@ backend_init_supplies( - current_state = -1; - num_supplies = -1; - charset = -1; -+ quirks = 0; - - memset(supplies, 0, sizeof(supplies)); - -@@ -477,6 +505,34 @@ backend_init_supplies( - return; - } - -+ if (ppd && -+ (ppdattr = ppdFindAttr(ppd, "cupsSNMPQuirks", NULL)) != NULL && -+ ppdattr->value) -+ { -+ ptr = ppdattr->value; -+ while (*ptr != '\0') -+ { -+ /* -+ * Match keyword against quirk_names table. -+ */ -+ -+ for (i = 0; i < sizeof (quirk_names) / sizeof (quirk_names[0]); i++) -+ { -+ len = strlen (quirk_names[i].keyword); -+ if (!strncmp (ptr, quirk_names[i].keyword, len) && -+ (ptr[len] == '\0' || ptr[len] == ' ')) -+ quirks |= quirk_names[i].bit; -+ } -+ -+ /* -+ * Advance to next keyword. -+ */ -+ -+ ptr += strcspn (ptr, " "); -+ ptr += strspn (ptr, " "); -+ } -+ } -+ - ppdClose(ppd); - - /* diff --git a/cups-systemd-socket.patch b/cups-systemd-socket.patch index 234555f..83fabdb 100644 --- a/cups-systemd-socket.patch +++ b/cups-systemd-socket.patch @@ -1,7 +1,7 @@ -diff -up cups-1.5.2/config.h.in.systemd-socket cups-1.5.2/config.h.in ---- cups-1.5.2/config.h.in.systemd-socket 2012-03-16 14:50:57.089449755 +0000 -+++ cups-1.5.2/config.h.in 2012-03-16 14:50:57.146449787 +0000 -@@ -503,6 +503,13 @@ +diff -up cups-1.6b1/config.h.in.systemd-socket cups-1.6b1/config.h.in +--- cups-1.6b1/config.h.in.systemd-socket 2012-05-17 00:57:03.000000000 +0200 ++++ cups-1.6b1/config.h.in 2012-05-28 11:16:35.657250584 +0200 +@@ -506,6 +506,13 @@ /* @@ -15,9 +15,9 @@ diff -up cups-1.5.2/config.h.in.systemd-socket cups-1.5.2/config.h.in * Various scripting languages... */ -diff -up cups-1.5.2/config-scripts/cups-systemd.m4.systemd-socket cups-1.5.2/config-scripts/cups-systemd.m4 ---- cups-1.5.2/config-scripts/cups-systemd.m4.systemd-socket 2012-03-16 14:50:57.146449787 +0000 -+++ cups-1.5.2/config-scripts/cups-systemd.m4 2012-03-16 14:50:57.146449787 +0000 +diff -up cups-1.6b1/config-scripts/cups-systemd.m4.systemd-socket cups-1.6b1/config-scripts/cups-systemd.m4 +--- cups-1.6b1/config-scripts/cups-systemd.m4.systemd-socket 2012-05-28 11:16:35.658250577 +0200 ++++ cups-1.6b1/config-scripts/cups-systemd.m4 2012-05-28 11:16:35.658250577 +0200 @@ -0,0 +1,36 @@ +dnl +dnl "$Id$" @@ -55,18 +55,18 @@ diff -up cups-1.5.2/config-scripts/cups-systemd.m4.systemd-socket cups-1.5.2/con +dnl +dnl "$Id$" +dnl -diff -up cups-1.5.2/configure.in.systemd-socket cups-1.5.2/configure.in ---- cups-1.5.2/configure.in.systemd-socket 2011-08-31 02:36:33.000000000 +0100 -+++ cups-1.5.2/configure.in 2012-03-16 14:50:57.146449787 +0000 -@@ -37,6 +37,7 @@ sinclude(config-scripts/cups-pam.m4) +diff -up cups-1.6b1/configure.in.systemd-socket cups-1.6b1/configure.in +--- cups-1.6b1/configure.in.systemd-socket 2012-04-23 19:26:57.000000000 +0200 ++++ cups-1.6b1/configure.in 2012-05-28 11:16:35.658250577 +0200 +@@ -33,6 +33,7 @@ sinclude(config-scripts/cups-pam.m4) sinclude(config-scripts/cups-largefile.m4) sinclude(config-scripts/cups-dnssd.m4) sinclude(config-scripts/cups-launchd.m4) +sinclude(config-scripts/cups-systemd.m4) sinclude(config-scripts/cups-defaults.m4) - sinclude(config-scripts/cups-pdf.m4) sinclude(config-scripts/cups-scripting.m4) -@@ -71,6 +72,9 @@ AC_OUTPUT(Makedefs + +@@ -66,6 +67,9 @@ AC_OUTPUT(Makedefs conf/snmp.conf cups-config data/testprint @@ -76,10 +76,10 @@ diff -up cups-1.5.2/configure.in.systemd-socket cups-1.5.2/configure.in desktop/cups.desktop doc/help/ref-cupsd-conf.html doc/help/standard.html -diff -up cups-1.5.2/cups/usersys.c.systemd-socket cups-1.5.2/cups/usersys.c ---- cups-1.5.2/cups/usersys.c.systemd-socket 2012-03-16 14:50:57.054449734 +0000 -+++ cups-1.5.2/cups/usersys.c 2012-03-16 14:50:57.148449788 +0000 -@@ -778,7 +778,7 @@ cups_read_client_conf( +diff -up cups-1.6b1/cups/usersys.c.systemd-socket cups-1.6b1/cups/usersys.c +--- cups-1.6b1/cups/usersys.c.systemd-socket 2012-04-23 19:26:57.000000000 +0200 ++++ cups-1.6b1/cups/usersys.c 2012-05-28 11:16:35.659250570 +0200 +@@ -975,7 +975,7 @@ cups_read_client_conf( struct stat sockinfo; /* Domain socket information */ if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) && @@ -88,9 +88,9 @@ diff -up cups-1.5.2/cups/usersys.c.systemd-socket cups-1.5.2/cups/usersys.c cups_server = CUPS_DEFAULT_DOMAINSOCKET; else #endif /* CUPS_DEFAULT_DOMAINSOCKET */ -diff -up cups-1.5.2/data/cups.path.in.systemd-socket cups-1.5.2/data/cups.path.in ---- cups-1.5.2/data/cups.path.in.systemd-socket 2012-03-16 14:50:57.148449788 +0000 -+++ cups-1.5.2/data/cups.path.in 2012-03-16 14:50:57.148449788 +0000 +diff -up cups-1.6b1/data/cups.path.in.systemd-socket cups-1.6b1/data/cups.path.in +--- cups-1.6b1/data/cups.path.in.systemd-socket 2012-05-28 11:16:35.659250570 +0200 ++++ cups-1.6b1/data/cups.path.in 2012-05-28 11:16:35.659250570 +0200 @@ -0,0 +1,8 @@ +[Unit] +Description=CUPS Printer Service Spool @@ -100,9 +100,9 @@ diff -up cups-1.5.2/data/cups.path.in.systemd-socket cups-1.5.2/data/cups.path.i + +[Install] +WantedBy=multi-user.target -diff -up cups-1.5.2/data/cups.service.in.systemd-socket cups-1.5.2/data/cups.service.in ---- cups-1.5.2/data/cups.service.in.systemd-socket 2012-03-16 14:50:57.149449788 +0000 -+++ cups-1.5.2/data/cups.service.in 2012-03-16 14:50:57.149449788 +0000 +diff -up cups-1.6b1/data/cups.service.in.systemd-socket cups-1.6b1/data/cups.service.in +--- cups-1.6b1/data/cups.service.in.systemd-socket 2012-05-28 11:16:35.659250570 +0200 ++++ cups-1.6b1/data/cups.service.in 2012-05-28 11:16:35.659250570 +0200 @@ -0,0 +1,10 @@ +[Unit] +Description=CUPS Printing Service @@ -114,9 +114,9 @@ diff -up cups-1.5.2/data/cups.service.in.systemd-socket cups-1.5.2/data/cups.ser +[Install] +Also=cups.socket cups.path +WantedBy=printer.target -diff -up cups-1.5.2/data/cups.socket.in.systemd-socket cups-1.5.2/data/cups.socket.in ---- cups-1.5.2/data/cups.socket.in.systemd-socket 2012-03-16 14:50:57.150449788 +0000 -+++ cups-1.5.2/data/cups.socket.in 2012-03-16 14:50:57.150449788 +0000 +diff -up cups-1.6b1/data/cups.socket.in.systemd-socket cups-1.6b1/data/cups.socket.in +--- cups-1.6b1/data/cups.socket.in.systemd-socket 2012-05-28 11:16:35.660250563 +0200 ++++ cups-1.6b1/data/cups.socket.in 2012-05-28 11:16:35.660250563 +0200 @@ -0,0 +1,8 @@ +[Unit] +Description=CUPS Printing Service Sockets @@ -126,10 +126,10 @@ diff -up cups-1.5.2/data/cups.socket.in.systemd-socket cups-1.5.2/data/cups.sock + +[Install] +WantedBy=sockets.target -diff -up cups-1.5.2/data/Makefile.systemd-socket cups-1.5.2/data/Makefile ---- cups-1.5.2/data/Makefile.systemd-socket 2011-05-12 06:21:56.000000000 +0100 -+++ cups-1.5.2/data/Makefile 2012-03-16 14:50:57.151449789 +0000 -@@ -112,6 +112,12 @@ install-data: +diff -up cups-1.6b1/data/Makefile.systemd-socket cups-1.6b1/data/Makefile +--- cups-1.6b1/data/Makefile.systemd-socket 2011-08-27 11:23:01.000000000 +0200 ++++ cups-1.6b1/data/Makefile 2012-05-28 11:16:35.660250563 +0200 +@@ -100,6 +100,12 @@ install-data: $(INSTALL_DATA) $$file $(DATADIR)/ppdc; \ done $(INSTALL_DIR) -m 755 $(DATADIR)/profiles @@ -142,8 +142,8 @@ diff -up cups-1.5.2/data/Makefile.systemd-socket cups-1.5.2/data/Makefile # -@@ -159,6 +165,9 @@ uninstall: - -$(RMDIR) $(DATADIR)/charsets +@@ -143,6 +149,9 @@ uninstall: + -$(RMDIR) $(DATADIR)/data -$(RMDIR) $(DATADIR)/banners -$(RMDIR) $(DATADIR) + for file in $(SYSTEMD_UNITS); do \ @@ -152,10 +152,10 @@ diff -up cups-1.5.2/data/Makefile.systemd-socket cups-1.5.2/data/Makefile # -diff -up cups-1.5.2/Makedefs.in.systemd-socket cups-1.5.2/Makedefs.in ---- cups-1.5.2/Makedefs.in.systemd-socket 2012-03-16 14:50:57.081449751 +0000 -+++ cups-1.5.2/Makedefs.in 2012-03-16 14:50:57.152449790 +0000 -@@ -143,6 +143,7 @@ CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ +diff -up cups-1.6b1/Makedefs.in.systemd-socket cups-1.6b1/Makedefs.in +--- cups-1.6b1/Makedefs.in.systemd-socket 2012-05-28 11:16:35.648250647 +0200 ++++ cups-1.6b1/Makedefs.in 2012-05-28 11:16:35.660250563 +0200 +@@ -134,11 +134,13 @@ CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ CXXLIBS = @CXXLIBS@ DBUS_NOTIFIER = @DBUS_NOTIFIER@ DBUS_NOTIFIERLIBS = @DBUS_NOTIFIERLIBS@ @@ -163,15 +163,13 @@ diff -up cups-1.5.2/Makedefs.in.systemd-socket cups-1.5.2/Makedefs.in DNSSD_BACKEND = @DNSSD_BACKEND@ DSOFLAGS = -L../cups @DSOFLAGS@ DSOLIBS = @DSOLIBS@ $(COMMONLIBS) -@@ -151,6 +152,7 @@ FONTS = @FONTS@ - IMGLIBS = @IMGLIBS@ - IMGFILTERS = @IMGFILTERS@ + DNSSDLIBS = @DNSSDLIBS@ LAUNCHDLIBS = @LAUNCHDLIBS@ +SDLIBS = @SDLIBS@ LDFLAGS = -L../cgi-bin -L../cups -L../filter -L../ppdc \ -L../scheduler @LDARCHFLAGS@ \ @LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM) -@@ -267,6 +269,7 @@ PAMFILE = @PAMFILE@ +@@ -229,6 +231,7 @@ PAMFILE = @PAMFILE@ DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@ DBUSDIR = @DBUSDIR@ @@ -179,10 +177,10 @@ diff -up cups-1.5.2/Makedefs.in.systemd-socket cups-1.5.2/Makedefs.in # -diff -up cups-1.5.2/scheduler/client.h.systemd-socket cups-1.5.2/scheduler/client.h ---- cups-1.5.2/scheduler/client.h.systemd-socket 2011-03-25 21:25:38.000000000 +0000 -+++ cups-1.5.2/scheduler/client.h 2012-03-16 14:50:57.153449791 +0000 -@@ -75,6 +75,9 @@ typedef struct +diff -up cups-1.6b1/scheduler/client.h.systemd-socket cups-1.6b1/scheduler/client.h +--- cups-1.6b1/scheduler/client.h.systemd-socket 2012-03-22 21:30:20.000000000 +0100 ++++ cups-1.6b1/scheduler/client.h 2012-05-28 11:16:35.661250556 +0200 +@@ -77,6 +77,9 @@ typedef struct int fd; /* File descriptor for this server */ http_addr_t address; /* Bind address of socket */ http_encryption_t encryption; /* To encrypt or not to encrypt... */ @@ -192,99 +190,9 @@ diff -up cups-1.5.2/scheduler/client.h.systemd-socket cups-1.5.2/scheduler/clien } cupsd_listener_t; -diff -up cups-1.5.2/scheduler/dirsvc.c.systemd-socket cups-1.5.2/scheduler/dirsvc.c ---- cups-1.5.2/scheduler/dirsvc.c.systemd-socket 2012-03-16 14:50:57.112449768 +0000 -+++ cups-1.5.2/scheduler/dirsvc.c 2012-03-16 14:50:57.155449792 +0000 -@@ -1512,7 +1512,7 @@ cupsdStartBrowsing(void) - } - } - -- if (BrowseSocket >= 0) -+ if (BrowseSocket >= 0 && !BrowseSocketIsSystemd) - { - /* - * Bind the socket to browse port... -@@ -1556,13 +1556,17 @@ cupsdStartBrowsing(void) - cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to set broadcast mode - %s.", - strerror(errno)); - -+ if (!BrowseSocketIsSystemd) -+ { - #ifdef WIN32 -- closesocket(BrowseSocket); -+ closesocket(BrowseSocket); - #else -- close(BrowseSocket); -+ close(BrowseSocket); - #endif /* WIN32 */ - -- BrowseSocket = -1; -+ BrowseSocket = -1; -+ } -+ - BrowseLocalProtocols &= ~BROWSE_CUPS; - BrowseRemoteProtocols &= ~BROWSE_CUPS; - -@@ -1885,15 +1889,22 @@ cupsdStopBrowsing(void) - if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS) && - BrowseSocket >= 0) - { -- /* -- * Close the socket and remove it from the input selection set. -- */ -+ if (!BrowseSocketIsSystemd) -+ { -+ /* -+ * Close the socket. -+ */ - - #ifdef WIN32 -- closesocket(BrowseSocket); -+ closesocket(BrowseSocket); - #else -- close(BrowseSocket); -+ close(BrowseSocket); - #endif /* WIN32 */ -+ } -+ -+ /* -+ * Remove it from the input selection set. -+ */ - - cupsdRemoveSelect(BrowseSocket); - BrowseSocket = -1; -@@ -5693,11 +5704,14 @@ update_cups_browse(void) - strerror(errno)); - cupsdLogMessage(CUPSD_LOG_ERROR, "CUPS browsing turned off."); - -+ if (!BrowseSocketIsSystemd) -+ { - #ifdef WIN32 -- closesocket(BrowseSocket); -+ closesocket(BrowseSocket); - #else -- close(BrowseSocket); -+ close(BrowseSocket); - #endif /* WIN32 */ -+ } - - cupsdRemoveSelect(BrowseSocket); - BrowseSocket = -1; -diff -up cups-1.5.2/scheduler/dirsvc.h.systemd-socket cups-1.5.2/scheduler/dirsvc.h ---- cups-1.5.2/scheduler/dirsvc.h.systemd-socket 2012-03-16 14:50:57.113449769 +0000 -+++ cups-1.5.2/scheduler/dirsvc.h 2012-03-16 14:50:57.157449792 +0000 -@@ -100,6 +100,8 @@ VAR int Browsing VALUE(TRUE), - /* Short names for remote printers? */ - BrowseSocket VALUE(-1), - /* Socket for browsing */ -+ BrowseSocketIsSystemd VALUE(0), -+ /* BrowseSocket is systemd-provided? */ - BrowsePort VALUE(IPP_PORT), - /* Port number for broadcasts */ - BrowseInterval VALUE(DEFAULT_INTERVAL), -diff -up cups-1.5.2/scheduler/listen.c.systemd-socket cups-1.5.2/scheduler/listen.c ---- cups-1.5.2/scheduler/listen.c.systemd-socket 2011-04-16 00:38:13.000000000 +0100 -+++ cups-1.5.2/scheduler/listen.c 2012-03-16 14:50:57.158449792 +0000 +diff -up cups-1.6b1/scheduler/listen.c.systemd-socket cups-1.6b1/scheduler/listen.c +--- cups-1.6b1/scheduler/listen.c.systemd-socket 2011-04-16 01:38:13.000000000 +0200 ++++ cups-1.6b1/scheduler/listen.c 2012-05-28 11:16:35.661250556 +0200 @@ -401,7 +401,11 @@ cupsdStopListening(void) lis; lis = (cupsd_listener_t *)cupsArrayNext(Listeners)) @@ -298,9 +206,9 @@ diff -up cups-1.5.2/scheduler/listen.c.systemd-socket cups-1.5.2/scheduler/liste { #ifdef WIN32 closesocket(lis->fd); -diff -up cups-1.5.2/scheduler/main.c.systemd-socket cups-1.5.2/scheduler/main.c ---- cups-1.5.2/scheduler/main.c.systemd-socket 2012-03-16 14:50:57.121449773 +0000 -+++ cups-1.5.2/scheduler/main.c 2012-03-16 14:51:55.409483636 +0000 +diff -up cups-1.6b1/scheduler/main.c.systemd-socket cups-1.6b1/scheduler/main.c +--- cups-1.6b1/scheduler/main.c.systemd-socket 2012-05-28 11:16:35.612250897 +0200 ++++ cups-1.6b1/scheduler/main.c 2012-05-28 12:49:32.698375139 +0200 @@ -26,6 +26,8 @@ * launchd_checkin() - Check-in with launchd and collect the listening * fds. @@ -331,7 +239,7 @@ diff -up cups-1.5.2/scheduler/main.c.systemd-socket cups-1.5.2/scheduler/main.c static void parent_handler(int sig); static void process_children(void); static void sigchld_handler(int sig); -@@ -537,6 +546,13 @@ main(int argc, /* I - Number of comm +@@ -528,6 +537,13 @@ main(int argc, /* I - Number of comm } #endif /* HAVE_LAUNCHD */ @@ -345,7 +253,7 @@ diff -up cups-1.5.2/scheduler/main.c.systemd-socket cups-1.5.2/scheduler/main.c /* * Startup the server... */ -@@ -759,6 +775,15 @@ main(int argc, /* I - Number of comm +@@ -738,6 +754,15 @@ main(int argc, /* I - Number of comm } #endif /* HAVE_LAUNCHD */ @@ -361,7 +269,7 @@ diff -up cups-1.5.2/scheduler/main.c.systemd-socket cups-1.5.2/scheduler/main.c /* * Startup the server... */ -@@ -1584,6 +1609,139 @@ launchd_checkout(void) +@@ -1516,6 +1541,102 @@ launchd_checkout(void) } #endif /* HAVE_LAUNCHD */ @@ -403,43 +311,6 @@ diff -up cups-1.5.2/scheduler/main.c.systemd-socket cups-1.5.2/scheduler/main.c + + if (!r) + { -+ if (Browsing && -+ ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS)) -+ { -+ r = sd_is_socket(fd, AF_UNSPEC, SOCK_DGRAM, 0); -+ if (r < 0) -+ { -+ cupsdLogMessage(CUPSD_LOG_ERROR, -+ "systemd_checkin: Unable to verify socket type - %s", -+ strerror(-r)); -+ continue; -+ } -+ -+ if (r) -+ { -+ /* -+ * This is the browse socket. -+ */ -+ -+ char addrstr[256]; -+ if (getsockname(fd, (struct sockaddr*) &addr, &addrlen)) -+ { -+ cupsdLogMessage(CUPSD_LOG_ERROR, -+ "systemd_checkin: Unable to get local address - %s", -+ strerror(errno)); -+ continue; -+ } -+ -+ httpAddrString (&addr, addrstr, sizeof (addrstr)); -+ BrowseSocket = fd; -+ BrowseSocketIsSystemd = 1; -+ cupsdLogMessage(CUPSD_LOG_DEBUG, -+ "systemd_checkin: Matched browse (port %d) with fd %d:%s...", -+ BrowsePort, fd, addrstr); -+ continue; -+ } -+ -+ } + cupsdLogMessage(CUPSD_LOG_ERROR, + "systemd_checkin: Socket not of the right type"); + continue; @@ -501,10 +372,10 @@ diff -up cups-1.5.2/scheduler/main.c.systemd-socket cups-1.5.2/scheduler/main.c /* * 'parent_handler()' - Catch USR1/CHLD signals... -diff -up cups-1.5.2/scheduler/Makefile.systemd-socket cups-1.5.2/scheduler/Makefile ---- cups-1.5.2/scheduler/Makefile.systemd-socket 2012-03-16 14:50:57.130449778 +0000 -+++ cups-1.5.2/scheduler/Makefile 2012-03-16 14:50:57.160449794 +0000 -@@ -382,7 +382,7 @@ cupsd: $(CUPSDOBJS) $(LIBCUPSMIME) ../cu +diff -up cups-1.6b1/scheduler/Makefile.systemd-socket cups-1.6b1/scheduler/Makefile +--- cups-1.6b1/scheduler/Makefile.systemd-socket 2012-05-21 19:40:22.000000000 +0200 ++++ cups-1.6b1/scheduler/Makefile 2012-05-28 11:16:35.663250542 +0200 +@@ -371,7 +371,7 @@ cupsd: $(CUPSDOBJS) $(LIBCUPSMIME) ../cu $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \ $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \ $(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \ @@ -513,12 +384,12 @@ diff -up cups-1.5.2/scheduler/Makefile.systemd-socket cups-1.5.2/scheduler/Makef cupsd-static: $(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC) echo Linking $@... -@@ -390,7 +390,7 @@ cupsd-static: $(CUPSDOBJS) libcupsmime.a +@@ -379,7 +379,7 @@ cupsd-static: $(CUPSDOBJS) libcupsmime.a $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \ ../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \ $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \ - $(LIBWRAP) -+ $(LIBWRAP) $(SDLIBS) ++ $(LIBWRAP) $(SDLIBS) + tls.o: tls-darwin.c tls-gnutls.c tls-openssl.c - # diff --git a/cups.spec b/cups.spec index fc8178a..1601e45 100644 --- a/cups.spec +++ b/cups.spec @@ -1,5 +1,3 @@ -%global php_extdir %(php-config --extension-dir 2>/dev/null || echo %{_libdir}/php4) - %global use_alternatives 1 %global lspp 1 @@ -11,15 +9,13 @@ Summary: Common Unix Printing System Name: cups -Version: 1.5.4 +Version: 1.6.1 Release: 1%{?dist} License: GPLv2 Group: System Environment/Daemons Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2 # Pixmap for desktop file Source2: cupsprinter.png -# LSPP-required ps->pdf filter -Source4: pstopdf # xinetd config file for cups-lpd service Source5: cups-lpd # Logrotate configuration @@ -28,14 +24,11 @@ Source6: cups.logrotate Source7: ncp.backend # Cron-based tmpwatch for /var/spool/cups/tmp Source8: cups.cron -# Filter and PPD for textonly printing -Source9: textonly.filter -Source10: textonly.ppd Source11: macros.cups Patch1: cups-no-gzip-man.patch Patch2: cups-system-auth.patch Patch3: cups-multilib.patch -Patch4: cups-serial.patch + Patch5: cups-banners.patch Patch6: cups-serverbin-compat.patch Patch7: cups-no-export-ssllibs.patch @@ -44,31 +37,24 @@ Patch9: cups-lpr-help.patch Patch10: cups-peercred.patch Patch11: cups-pid.patch Patch12: cups-eggcups.patch -Patch13: cups-getpass.patch + Patch14: cups-driverd-timeout.patch Patch15: cups-strict-ppd-line-length.patch Patch16: cups-logrotate.patch Patch17: cups-usb-paperout.patch -Patch18: cups-build.patch +#Patch18: cups-build.patch Patch19: cups-res_init.patch Patch20: cups-filter-debug.patch Patch21: cups-uri-compat.patch Patch22: cups-cups-get-classes.patch Patch23: cups-str3382.patch Patch25: cups-0755.patch -Patch26: cups-snmp-quirks.patch + Patch27: cups-hp-deviceid-oid.patch Patch28: cups-dnssd-deviceid.patch Patch29: cups-ricoh-deviceid-oid.patch -Patch30: cups-avahi-1-config.patch -Patch31: cups-avahi-2-backend.patch -Patch32: cups-avahi-3-timeouts.patch -Patch33: cups-avahi-4-poll.patch -Patch34: cups-avahi-5-services.patch - -Patch35: cups-icc.patch -Patch36: cups-systemd-socket.patch +Patch30: cups-systemd-socket.patch Patch100: cups-lspp.patch @@ -76,6 +62,7 @@ Epoch: 1 Url: http://www.cups.org/ Requires: /sbin/chkconfig /sbin/service +Requires: %{name}-filesystem = %{epoch}:%{version}-%{release} Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} %if %use_alternatives Provides: /usr/bin/lpq /usr/bin/lpr /usr/bin/lp /usr/bin/cancel /usr/bin/lprm /usr/bin/lpstat @@ -97,16 +84,12 @@ Conflicts: kdelibs < 6:3.5.2-6 BuildRequires: pam-devel pkgconfig BuildRequires: gnutls-devel libacl-devel BuildRequires: openldap-devel -BuildRequires: make >= 1:3.80 -BuildRequires: php-devel, pcre-devel -BuildRequires: libjpeg-devel -BuildRequires: libpng-devel -BuildRequires: libtiff-devel BuildRequires: libusb1-devel BuildRequires: krb5-devel BuildRequires: avahi-devel -BuildRequires: poppler-utils BuildRequires: systemd-units, systemd-devel +BuildRequires: dbus-devel +BuildRequires: automake # Make sure we get postscriptdriver tags. BuildRequires: python-cups @@ -116,13 +99,7 @@ BuildRequires: libselinux-devel >= 1.23 BuildRequires: audit-libs-devel >= 1.1 %endif -# -fstack-protector-all requires GCC 4.0.1 -BuildRequires: gcc >= 4.0.1 - -BuildRequires: automake - -BuildRequires: dbus-devel >= 0.90 -Requires: dbus >= 0.90 +Requires: dbus # Requires tmpwatch for the cron.daily script (bug #218901). Requires: tmpwatch @@ -136,8 +113,6 @@ Requires(post): systemd-sysv # Requires working PrivateTmp (bug #807672) Requires(pre): systemd >= 37-14 -Requires: poppler-utils - # We ship udev rules which use setfacl. Requires: systemd Requires: acl @@ -161,6 +136,11 @@ Summary: Common Unix Printing System - libraries Group: System Environment/Libraries License: LGPLv2 +%package filesystem +Summary: Common Unix Printing System - directory layout +Group: System Environment/Base +BuildArch: noarch + %package lpd Summary: Common Unix Printing System - lpd emulation Group: System Environment/Daemons @@ -168,47 +148,39 @@ Requires: %{name} = %{epoch}:%{version}-%{release} Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} Requires: xinetd -%package php -Summary: Common Unix Printing System - php module -Group: Development/Languages -Requires: %{name} = %{epoch}:%{version}-%{release} -Requires: %{name}-libs = %{epoch}:%{version}-%{release} -Requires: php(zend-abi) = %{php_zend_api} -Requires: php(api) = %{php_core_api} - %package ipptool Summary: Common Unix Printing System - tool for performing IPP requests Group: System Environment/Daemons -Requires: %{name}-libs = %{epoch}:%{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} %description -The Common UNIX Printing System provides a portable printing layer for -UNIX® operating systems. It has been developed by Easy Software Products -to promote a standard printing solution for all UNIX vendors and users. -CUPS provides the System V and Berkeley command-line interfaces. +The Common UNIX Printing System provides a portable printing layer for +UNIX® operating systems. It has been developed by Easy Software Products +to promote a standard printing solution for all UNIX vendors and users. +CUPS provides the System V and Berkeley command-line interfaces. %description devel -The Common UNIX Printing System provides a portable printing layer for +The Common UNIX Printing System provides a portable printing layer for UNIX® operating systems. This is the development package for creating additional printer drivers, and other CUPS services. %description libs -The Common UNIX Printing System provides a portable printing layer for -UNIX® operating systems. It has been developed by Easy Software Products -to promote a standard printing solution for all UNIX vendors and users. -CUPS provides the System V and Berkeley command-line interfaces. +The Common UNIX Printing System provides a portable printing layer for +UNIX® operating systems. It has been developed by Easy Software Products +to promote a standard printing solution for all UNIX vendors and users. +CUPS provides the System V and Berkeley command-line interfaces. The cups-libs package provides libraries used by applications to use CUPS natively, without needing the lp/lpr commands. -%description lpd -The Common UNIX Printing System provides a portable printing layer for -UNIX® operating systems. This is the package that provides standard -lpd emulation. +%description filesystem +The Common UNIX Printing System provides a portable printing layer for +UNIX® operating systems. This package provides some directories which are +required by other packages that add CUPS drivers (i.e. filters, backends etc.). -%description php +%description lpd The Common UNIX Printing System provides a portable printing layer for -UNIX® operating systems. This is the package that provides a PHP -module. +UNIX® operating systems. This is the package that provides standard +lpd emulation. %description ipptool Sends IPP requests to the specified URI and tests and/or displays the results. @@ -221,8 +193,7 @@ Sends IPP requests to the specified URI and tests and/or displays the results. %patch2 -p1 -b .system-auth # Prevent multilib conflict in cups-config script. %patch3 -p1 -b .multilib -# Fix compilation of serial backend. -%patch4 -p1 -b .serial + # Ignore rpm save/new files in the banners directory. %patch5 -p1 -b .banners # Use compatibility fallback path for ServerBin. @@ -239,8 +210,7 @@ Sends IPP requests to the specified URI and tests and/or displays the results. %patch11 -p1 -b .pid # Fix implementation of com.redhat.PrinterSpooler D-Bus object. %patch12 -p1 -b .eggcups -# More sophisticated implementation of cupsGetPassword than getpass. -%patch13 -p1 -b .getpass + # Increase driverd timeout to 70s to accommodate foomatic (bug #744715). %patch14 -p1 -b .driverd-timeout # Only enforce maximum PPD line length when in strict mode. @@ -250,8 +220,8 @@ Sends IPP requests to the specified URI and tests and/or displays the results. # Support for errno==ENOSPACE-based USB paper-out reporting. %patch17 -p1 -b .usb-paperout # Simplify the DNSSD parts so they can build using the compat library. -%patch18 -p1 -b .build -# Re-initialise the resolver on failure in httpAddrGetList(). +#%%patch18 -p1 -b .build +# Re-initialise the resolver on failure in httpAddrGetList() (bug #567353). %patch19 -p1 -b .res_init # Log extra debugging information if no filters are available. %patch20 -p1 -b .filter-debug @@ -263,8 +233,7 @@ Sends IPP requests to the specified URI and tests and/or displays the results. %patch23 -p1 -b .str3382 # Use mode 0755 for binaries and libraries where appropriate. %patch25 -p1 -b .0755 -# Handle SNMP supply level quirks (bug #581825). -%patch26 -p1 -b .snmp-quirks + # Add an SNMP query for HP's device ID OID (STR #3552). %patch27 -p1 -b .hp-deviceid-oid # Mark DNS-SD Device IDs that have been guessed at with "FZY:1;". @@ -272,27 +241,23 @@ Sends IPP requests to the specified URI and tests and/or displays the results. # Add an SNMP query for Ricoh's device ID OID (STR #3552). %patch29 -p1 -b .ricoh-deviceid-oid -# Avahi support: -# - discovery in the dnssd backend -# - service announcement in the scheduler -%patch30 -p1 -b .avahi-1-config -%patch31 -p1 -b .avahi-2-backend -%patch32 -p1 -b .avahi-3-timeouts -%patch33 -p1 -b .avahi-4-poll -%patch34 -p1 -b .avahi-5-services - -# ICC colord support. -%patch35 -p1 -b .icc - # Add support for systemd socket activation (patch from Lennart # Poettering). -%patch36 -p1 -b .systemd-socket +%patch30 -p1 -b .systemd-socket %if %lspp # LSPP support. %patch100 -p1 -b .lspp %endif +# We want to use the PDF workflow in principle with one exception when the input +# is PostScript and the printer is a native PostScript printer. +# To avoid the PS -> PDF -> PS conversion (costs 66), +# set the cost factor of pstops to 65. +# This forth-and-back conversion sometimes produces PostScript files which are +# too big for the printer's memory resulting in not getting printed. +sed -i -r -e '/\spstops$/ { s/66/65/ }' conf/mime.convs.in + sed -i -e '1iMaxLogSize 0' conf/cupsd.conf.in cp %{SOURCE5} cups-lpd.real @@ -301,15 +266,11 @@ perl -pi -e "s,\@LIBDIR\@,%{_libdir},g" cups-lpd.real # Let's look at the compilation command lines. perl -pi -e "s,^.SILENT:,," Makedefs.in -# Fix locale code for Norwegian (bug #520379). -mv locale/cups_no.po locale/cups_nb.po - f=CREDITS.txt mv "$f" "$f"~ iconv -f MACINTOSH -t UTF-8 "$f"~ > "$f" rm "$f"~ -# Rebuild configure script for --enable-avahi. aclocal -I config-scripts autoconf -I config-scripts @@ -320,10 +281,12 @@ export CFLAGS="$RPM_OPT_FLAGS -fstack-protector-all -DLDAP_DEPRECATED=1" %if %lspp --enable-lspp \ %endif - --with-log-file-perm=0600 --enable-relro \ - --with-pdftops=pdftops \ + --with-cupsd-file-perm=0755 \ + --with-log-file-perm=0600 \ + --enable-relro \ --with-dbusdir=%{_sysconfdir}/dbus-1 \ - --with-php=/usr/bin/php-cgi --enable-avahi \ + --with-php=/usr/bin/php-cgi \ + --enable-avahi \ --enable-threads --enable-gnutls \ localedir=%{_datadir}/locale @@ -333,9 +296,6 @@ make %{?_smp_mflags} %install make BUILDROOT=$RPM_BUILD_ROOT install -# Serial backend needs to run as root (bug #212577). -chmod 700 $RPM_BUILD_ROOT%{cups_serverbin}/backend/serial - rm -rf $RPM_BUILD_ROOT%{_initddir} \ $RPM_BUILD_ROOT%{_sysconfdir}/init.d \ $RPM_BUILD_ROOT%{_sysconfdir}/rc?.d @@ -365,13 +325,6 @@ install -c -m 644 cups-lpd.real $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/cups-lpd install -c -m 644 %{SOURCE6} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/cups install -c -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{cups_serverbin}/backend/ncp install -c -m 755 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/cups -install -c -m 755 %{SOURCE9} $RPM_BUILD_ROOT%{cups_serverbin}/filter/textonly -install -c -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_datadir}/cups/model/textonly.ppd - -# Ship pstopdf for LSPP systems to deal with malicious postscript -%if %lspp -install -c -m 755 %{SOURCE4} $RPM_BUILD_ROOT%{cups_serverbin}/filter -%endif # Ship an rpm macro for where to put driver executables. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm/ @@ -394,13 +347,9 @@ mkdir -p $RPM_BUILD_ROOT%{_datadir}/ppd rm -rf $RPM_BUILD_ROOT%{_mandir}/cat? $RPM_BUILD_ROOT%{_mandir}/*/cat? rm -f $RPM_BUILD_ROOT%{_datadir}/applications/cups.desktop rm -rf $RPM_BUILD_ROOT%{_datadir}/icons - -# Put the php config bit into place -%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/php.d -%{__cat} << __EOF__ > $RPM_BUILD_ROOT%{_sysconfdir}/php.d/%{name}.ini -; Enable %{name} extension module -extension=phpcups.so -__EOF__ +# these are shipped with cups-filters +rm -rf $RPM_BUILD_ROOT%{_datadir}/cups/banners +rm -f $RPM_BUILD_ROOT%{_datadir}/cups/data/testprint # install /usr/lib/tmpfiles.d/cups.conf (bug #656566) mkdir -p ${RPM_BUILD_ROOT}%{_prefix}/lib/tmpfiles.d @@ -430,20 +379,9 @@ s:.*\('%{_datadir}'/\)\([^/_]\+\)\(.*\.po$\):%lang(\2) \1\2\3: /^\([^%].*\)/d ' > %{name}.lang -%check -# Minimal load test of php extension -LD_LIBRARY_PATH=${RPM_BUILD_ROOT}%{_libdir} \ -php --no-php-ini \ - --define extension_dir=${RPM_BUILD_ROOT}%{php_extdir} \ - --define extension=phpcups.so \ - --modules | grep phpcups - %post -if [ $1 -eq 1 ] ; then - # Initial installation - /bin/systemctl enable cups.{service,socket,path} >/dev/null 2>&1 || : -fi +%{systemd_post} %{name}.path %{name}.socket %{name}.service # Remove old-style certs directory; new-style is /var/run # (see bug #194581 for why this is necessary). @@ -472,24 +410,21 @@ exit 0 %postun libs -p /sbin/ldconfig %preun -if [ $1 -eq 0 ] ; then - # Package removal, not upgrade - /bin/systemctl --no-reload disable %{name}.path %{name}.socket %{name}.service >/dev/null 2>&1 || : - /bin/systemctl stop %{name}.path %{name}.socket %{name}.service >/dev/null 2>&1 || : +%{systemd_preun} %{name}.path %{name}.socket %{name}.service + %if %use_alternatives +if [ $1 -eq 0 ] ; then /usr/sbin/alternatives --remove print %{_bindir}/lpr.cups -%endif fi +%endif + exit 0 %postun -/bin/systemctl daemon-reload >/dev/null 2>&1 || : -if [ $1 -ge 1 ]; then - # Package upgrade, not uninstall - /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : -fi +%{systemd_postun_with_restart} %{name}.service exit 0 + %triggerun -- %{name} < 1:1.5.0-22 # This package is allowed to autostart; however, the upgrade trigger # in Fedora 16 final failed to actually do this. Do it now as a @@ -546,26 +481,17 @@ rm -f %{cups_serverbin}/backend/smb %config(noreplace) %{_sysconfdir}/pam.d/cups %config(noreplace) %{_sysconfdir}/logrotate.d/cups %dir %{_datadir}/%{name}/www +%dir %{_datadir}/%{name}/www/ca %dir %{_datadir}/%{name}/www/es -%dir %{_datadir}/%{name}/www/eu %dir %{_datadir}/%{name}/www/ja -%dir %{_datadir}/%{name}/www/pl -%dir %{_datadir}/%{name}/www/ru %{_datadir}/%{name}/www/images %{_datadir}/%{name}/www/*.css %doc %{_datadir}/%{name}/www/index.html %doc %{_datadir}/%{name}/www/help %doc %{_datadir}/%{name}/www/robots.txt -%doc %{_datadir}/%{name}/www/de/index.html +%doc %{_datadir}/%{name}/www/ca/index.html %doc %{_datadir}/%{name}/www/es/index.html -%doc %{_datadir}/%{name}/www/eu/index.html -%doc %{_datadir}/%{name}/www/fr/index.html -%doc %{_datadir}/%{name}/www/hu/index.html -%doc %{_datadir}/%{name}/www/id/index.html -%doc %{_datadir}/%{name}/www/it/index.html %doc %{_datadir}/%{name}/www/ja/index.html -%doc %{_datadir}/%{name}/www/pl/index.html -%doc %{_datadir}/%{name}/www/ru/index.html %{_unitdir}/%{name}.service %{_unitdir}/%{name}.socket %{_unitdir}/%{name}.path @@ -574,54 +500,34 @@ rm -f %{cups_serverbin}/backend/smb %{_bindir}/cancel* %{_bindir}/lp* %{_bindir}/ppd* -%dir %{cups_serverbin} -%{cups_serverbin}/backend +%{cups_serverbin}/backend/* %{cups_serverbin}/cgi-bin %dir %{cups_serverbin}/daemon -%{cups_serverbin}/daemon/cups-polld %{cups_serverbin}/daemon/cups-deviced %{cups_serverbin}/daemon/cups-driverd %{cups_serverbin}/daemon/cups-exec %{cups_serverbin}/notifier -%{cups_serverbin}/filter +%{cups_serverbin}/filter/* %{cups_serverbin}/monitor -%{cups_serverbin}/driver %{_mandir}/man1/cancel* %{_mandir}/man1/cupstest* %{_mandir}/man1/lp* %{_mandir}/man1/ppd* %{_mandir}/man[578]/* %{_sbindir}/* -%dir %{_datadir}/cups -%dir %{_datadir}/cups/banners -%{_datadir}/cups/banners/* -%{_datadir}/cups/charsets -%{_datadir}/cups/data -%{_datadir}/cups/fonts -%{_datadir}/cups/model %dir %{_datadir}/cups/templates %{_datadir}/cups/templates/*.tmpl -%{_datadir}/cups/templates/de/*.tmpl +%{_datadir}/cups/templates/ca/*.tmpl %{_datadir}/cups/templates/es/*.tmpl -%{_datadir}/cups/templates/eu/*.tmpl -%{_datadir}/cups/templates/fr/*.tmpl -%{_datadir}/cups/templates/hu/*.tmpl -%{_datadir}/cups/templates/id/*.tmpl -%{_datadir}/cups/templates/it/*.tmpl %{_datadir}/cups/templates/ja/*.tmpl -%{_datadir}/cups/templates/pl/*.tmpl -%{_datadir}/cups/templates/ru/*.tmpl -%{_datadir}/locale/*/*.po -%{_datadir}/ppd %dir %attr(1770,root,lp) %{_localstatedir}/spool/cups/tmp %dir %attr(0710,root,lp) %{_localstatedir}/spool/cups %dir %attr(0755,lp,sys) %{_localstatedir}/log/cups %{_datadir}/pixmaps/cupsprinter.png %{_sysconfdir}/cron.daily/cups %config(noreplace) %{_sysconfdir}/dbus-1/system.d/cups.conf -%{_datadir}/cups/drv +%{_datadir}/cups/drv/sample.drv %{_datadir}/cups/examples -%dir %{_datadir}/cups/mime %{_datadir}/cups/mime/mime.types %{_datadir}/cups/mime/mime.convs %dir %{_datadir}/cups/ppdc @@ -632,6 +538,20 @@ rm -f %{cups_serverbin}/backend/smb %doc LICENSE.txt %{_libdir}/*.so.* +%files filesystem +%dir %{cups_serverbin} +%dir %{cups_serverbin}/backend +%dir %{cups_serverbin}/driver +%dir %{cups_serverbin}/filter +%dir %{_datadir}/cups +#%%dir %%{_datadir}/cups/banners +#%%dir %%{_datadir}/cups/charsets +%dir %{_datadir}/cups/data +%dir %{_datadir}/cups/drv +%dir %{_datadir}/cups/mime +%dir %{_datadir}/cups/model +%dir %{_datadir}/ppd + %files devel %{_bindir}/cups-config %{_libdir}/*.so @@ -645,10 +565,6 @@ rm -f %{cups_serverbin}/backend/smb %dir %{cups_serverbin}/daemon %{cups_serverbin}/daemon/cups-lpd -%files php -%config(noreplace) %{_sysconfdir}/php.d/%{name}.ini -%{php_extdir}/phpcups.so - %files ipptool %{_bindir}/ipptool %dir %{_datadir}/cups/ipptool @@ -656,6 +572,23 @@ rm -f %{cups_serverbin}/backend/smb %{_mandir}/man1/ipptool.1.gz %changelog +* Wed Aug 08 2012 Jiri Popelka 1:1.6.1-1 +- 1.6.1 + - simplified systemd.patch due to removed CUPS Browsing protocol (STR #3922) + - removed: + textonly filter - moved to cups-filters + pstopdf filter - cups-filters also has pstopdf (different) + PHP module - moved to cups-filters (STR #3932) + serial.patch - moved to cups-filters + getpass.patch - r10140 removed the getpass() use + snmp-quirks.patch - fixed upstream (r10493) + avahi patches - merged upstream (STR #3066) + icc.patch - merged upstream (STR #3808) + - TODO: + - do we need cups-build.patch ? +- added filesystem sub-package (#624695) +- use macroized systemd scriptlets + * Thu Jul 26 2012 Jiri Popelka 1:1.5.4-1 - 1.5.4 diff --git a/pstopdf b/pstopdf deleted file mode 100644 index 83f0221..0000000 --- a/pstopdf +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# -# CUPS filter script for Ghostscript. -# -# Copyright 2001-2002 by Easy Software Products. -# Copyright 2006 by Hewlett-Packard Development Company, L.P. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# Installation directories... -prefix=/usr -exec_prefix=${prefix} -bindir=${exec_prefix}/bin - -# Set the library/font path... -GS_FONTPATH="$CUPS_FONTPATH" -export GS_FONTPATH - -# Options we use with Ghostscript... -gsopts="-dQUIET -dDEBUG -dPARANOIDSAFER -dNOPAUSE -dBATCH " -gsopts="$gsopts -dNOMEDIAATTRS -sDEVICE=pdfwrite -sstdout=%stderr" - -# See if we have a profile=n,n,n,n,n,n,n,n,n,n,n option... -profile="" -for option in $5; do - case $option in - profile=*) - profile="-scupsProfile=`echo $option | awk -F= '{print $2}'`" - ;; - esac -done - -# See if we have a filename on the command-line... -if test -z "$6"; then - ifile="-" -else - ifile="$6" -fi - -# Now run Ghostscript... -$bindir/gs $gsopts -sOUTPUTFILE="%stdout" $profile $ifile - diff --git a/sources b/sources index bb2ced0..a744de6 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -de3006e5cf1ee78a9c6145ce62c4e982 cups-1.5.4-source.tar.bz2 +87ade07e3d1efd03c9c3add949cf9c00 cups-1.6.1-source.tar.bz2 diff --git a/textonly.filter b/textonly.filter deleted file mode 100755 index 445d597..0000000 --- a/textonly.filter +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash -## Copyright (C) 2003-2006 Red Hat, Inc. -## Copyright (C) 2003-2006 Tim Waugh -## Changed on 2007/05/17, Opher Shachar, LADPC Ltd. -## Added support for page-ranges option. -## Added page accounting. - -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License -## as published by the Free Software Foundation; either version 2 -## of the License, or (at your option) any later version. - -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. - -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -if [ $# == 0 ]; then - echo >&2 "ERROR: $0 job-id user title copies options [file]" - exit 1 -fi - -# Extract the papersize -SENDFF=`grep '^\*DefaultSendFF' "$PPD" | cut -d\ -f2` -COPIES=1 -if [ $# -ge 4 ]; then - COPIES="$4" -fi - -if [ $# -lt 6 ]; then - unset TMPFILE - trap -- 'rm -f "$TMPFILE"' EXIT - TMPFILE=$(mktemp ${TMPDIR:-/tmp}/textonly.XXXXXX) - cat > "$TMPFILE" -else - TMPFILE="$6" -fi - -PR=${5#*page-ranges=} -# Do options specify page-ranges? -if [[ "$PR" != "$5" ]]; then - PR=${PR%% *} -else - #unset PR - PR=1-999999 -fi - -if [[ "$PR" ]]; then - TMPFILE2=$(mktemp ${TMPDIR:-/tmp}/textonly2.XXXXXX) - pagenum=0 - EOF= - { - while [[ "$PR" ]]; do - pl=${PR%%,*} ;# take first subrange - PR=${PR#$pl};PR=${PR#,} ;# remove from range list - pu=${pl#*-} ;# extract upper and lower - pl=${pl%-*} ;# pages of subrange - # Allows interpreting 0-5,3-10 as 1-5,6-10 rejects 5-1 or 1- - (( pagenum >= pl )) && pl=$(( pagenum + 1 )) - (( pl > pu )) && continue - - # Loop reading pages until at or over lower page of subrange. - while read -d `echo -ne '\f'` -r; do - (( pagenum++ )) - (( pagenum == pl )) && break - done - # Did we reach lower page of subrange or EOF? - if (( pagenum < pl )); then - [[ ! "$REPLY" ]] && break ;# empty last page - we're done. - (( pagenum++ )) - EOF=y - fi - # Output page and report to page log - if (( pagenum == pl )); then - echo -n "${REPLY}" >>"$TMPFILE2" - # If EOF then page has no final FF - [[ ! "$EOF" ]] && echo -ne '\f' >>"$TMPFILE2" - echo "PAGE: $pagenum $COPIES" >&2 - fi - [[ "$EOF" ]] && break - # Is the current subrange a single page? - (( pagenum == pu )) && continue - while read -d `echo -ne '\f'` -r; do - (( pagenum++ )) - echo -ne "${REPLY}\f" >>"$TMPFILE2" - echo "PAGE: $pagenum $COPIES" >&2 - (( pagenum == pu )) && break - done - # Could be that we reached EOF before page boundry - if (( pagenum < pu )); then - if [[ "$REPLY" ]]; then - (( pagenum++ )) - echo -n "${REPLY}" >>"$TMPFILE2" - echo "PAGE: $pagenum $COPIES" >&2 - fi - break - fi - done - } <"$TMPFILE" -else - TMPFILE2="$TMPFILE" - pc=$(grep -co `echo -ne '\f'` "$TMPFILE2") - pc=$(( pc * $COPIES )) - echo "PAGE: $pc" >&2 -fi - -while [ "$COPIES" -gt 0 ]; do - # Just translate LF->CRLF at the moment, until the PPD has options added. - sed -e 's/$/'`echo -ne '\r'`'/g' "$TMPFILE2" - - if [ "$SENDFF" == "True" ] - then - echo -ne '\f' - fi - - COPIES=$(($COPIES - 1)) -done -# Cleanup -[[ "$TMPFILE" != "$TMPFILE2" ]] && rm -f "$TMPFILE2" -exit 0 diff --git a/textonly.ppd b/textonly.ppd deleted file mode 100644 index 89060bc..0000000 --- a/textonly.ppd +++ /dev/null @@ -1,47 +0,0 @@ -*PPD-Adobe: "4.3" -*% -*% Text-only printer definition -*% -*FormatVersion: "4.3" -*FileVersion: "1.1" -*LanguageVersion: English -*LanguageEncoding: ISOLatin1 -*PCFileName: "TEXTONLY.PPD" -*Manufacturer: "Generic" -*Product: "(Generic)" -*cupsVersion: 1.0 -*cupsManualCopies: True -*cupsModelNumber: 2 -*cupsFilter: "text/plain 0 textonly" -*ModelName: "Generic text-only printer" -*ShortNickName: "Generic text-only printer" -*NickName: "Generic text-only printer" -*PSVersion: "(2017.000) 0" -*LanguageLevel: "2" -*ColorDevice: False -*DefaultColorSpace: Gray -*FileSystem: False -*Throughput: "8" -*LandscapeOrientation: Plus90 -*VariablePaperSize: False -*TTRasterizer: Type42 -*DefaultImageableArea: Letter -*ImageableArea Letter/US Letter: "18 36 594 756" -*DefaultPaperDimension: Letter -*PaperDimension Letter/Letter: "612 792" -*OpenUI *PageSize/Media Size: PickOne -*OrderDependency: 10 AnySetup *PageSize -*DefaultPageSize: Letter -*PageSize Letter/Letter: "<>setpagedevice" -*CloseUI: *PageSize -*OpenUI *PageRegion: PickOne -*OrderDependency: 10 AnySetup *PageRegion -*DefaultPageRegion: Letter -*PageRegion Letter/Letter: "<>setpagedevice" -*CloseUI: *PageRegion - -*OpenUI *SendFF: Boolean -*DefaultSendFF: False -*SendFF True/True: "" -*SendFF False/False: "" -*CloseUI: *SendFF