]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add address logging to network backends (<rdar://problem/29268474>)
authorMichael R Sweet <michaelrsweet@gmail.com>
Tue, 15 Nov 2016 17:12:05 +0000 (12:12 -0500)
committerMichael R Sweet <michaelrsweet@gmail.com>
Tue, 15 Nov 2016 17:12:05 +0000 (12:12 -0500)
CHANGES.txt
backend/backend-private.h
backend/ipp.c
backend/lpd.c
backend/network.c
backend/socket.c
xcode/CUPS.xcodeproj/project.pbxproj

index 6594d47a2411c6e75801eb584acf5b56ddba1ffe..00dcd85b6783b72780ccff502e135ad6f1c42cb4 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES.txt - 2.2.2 - 2016-11-08
+CHANGES.txt - 2.2.2 - 2016-11-15
 --------------------------------
 
 CHANGES IN CUPS V2.2.2
@@ -15,6 +15,8 @@ CHANGES IN CUPS V2.2.2
           (<rdar://problem/28332470>)
        - The ippContainsString function now uses case-insensitive comparisons
          for mimeMediaType, name, and text values in conformance with RFC 2911.
+       - The network backends now log the addresses that were found for a
+         printer (<rdar://problem/29268474>)
         - Updated documentation (PR #4896)
         - Updated localizations (PR #4894, PR #4895, PR #4904, PR #4908)
 
index 04bf5167405d4f5918ec2cac1e3f6b0771957d73..64fbe411cb42f462610b7b89ee1f79f66b872e1f 100644 (file)
@@ -312,6 +312,7 @@ extern int          backendGetDeviceID(int fd, char *device_id,
 extern int             backendGetMakeModel(const char *device_id,
                                            char *make_model,
                                            size_t make_model_size);
+extern http_addrlist_t *backendLookup(const char *hostname, int port, int *cancel);
 extern int             backendNetworkSideCB(int print_fd, int device_fd,
                                             int snmp_fd, http_addr_t *addr,
                                             int use_bc);
index 180418664e247c517683b20ba5e2fa2874484cfa..a338577f9dc20de788a658b7fb902cf9444f9524 100644 (file)
@@ -223,7 +223,6 @@ main(int  argc,                             /* I - Number of command-line args */
                *compatfile = NULL;     /* Compatibility filename */
   off_t                compatsize = 0;         /* Size of compatibility file */
   int          port;                   /* Port number (not used) */
-  char         portname[255];          /* Port name */
   char         uri[HTTP_MAX_URI];      /* Updated URI without user/pass */
   char         print_job_name[1024];   /* Update job-name for Print-Job */
   http_status_t        http_status;            /* Status of HTTP request */
@@ -664,26 +663,7 @@ main(int  argc,                            /* I - Number of command-line args */
 
   start_time = time(NULL);
 
-  sprintf(portname, "%d", port);
-
-  update_reasons(NULL, "+connecting-to-device");
-  fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);
-
-  while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
-  {
-    _cupsLangPrintFilter(stderr, "INFO",
-                         _("Unable to locate printer \"%s\"."), hostname);
-    sleep(10);
-
-    if (getenv("CLASS") != NULL)
-    {
-      update_reasons(NULL, "-connecting-to-device");
-      return (CUPS_BACKEND_STOP);
-    }
-
-    if (job_canceled)
-      return (CUPS_BACKEND_OK);
-  }
+  addrlist = backendLookup(hostname, port, &job_canceled);
 
   http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, cupsEncryption(), 1,
                       0, NULL);
index 2b811076b6e81ebded4d1c9f78b2de4ba2ae2195..835f9eaeeeeb82fc4efc38d775544c6e61bd0cd2 100644 (file)
@@ -111,7 +111,6 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
                *filename,              /* File to print */
                title[256];             /* Title string */
   int          port;                   /* Port number */
-  char         portname[256];          /* Port name (string) */
   http_addrlist_t *addrlist;           /* List of addresses for printer */
   int          snmp_enabled = 1;       /* Is SNMP enabled? */
   int          snmp_fd;                /* SNMP socket */
@@ -411,23 +410,11 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Find the printer...
   */
 
-  snprintf(portname, sizeof(portname), "%d", port);
+  addrlist = backendLookup(hostname, port, NULL);
 
-  fputs("STATE: +connecting-to-device\n", stderr);
-  fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);
-
-  while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
-  {
-    _cupsLangPrintFilter(stderr, "INFO",
-                        _("Unable to locate printer \"%s\"."), hostname);
-    sleep(10);
-
-    if (getenv("CLASS") != NULL)
-    {
-      fputs("STATE: -connecting-to-device\n", stderr);
-      exit(CUPS_BACKEND_FAILED);
-    }
-  }
+ /*
+  * See if the printer supports SNMP...
+  */
 
   if (snmp_enabled)
     snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);
index 8beced8d27b7b001d8a86b61deef3e02ddacec11..d2c64a128832b9bb64bb9da1faf25197859303b3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Common backend network APIs for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 2006-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -26,7 +26,6 @@
  * 'backendCheckSideChannel()' - Check the side-channel for pending requests.
  */
 
-
 void
 backendCheckSideChannel(
     int         snmp_fd,               /* I - SNMP socket */
@@ -46,6 +45,65 @@ backendCheckSideChannel(
 }
 
 
+/*
+ * 'backendLookup()' - Lookup the given host and log addresses.
+ */
+
+http_addrlist_t        *                       /* O - List of addresses or NULL */
+backendLookup(const char *hostname,    /* I - Hostname */
+              int        port,         /* I - Port number */
+             int        *cancel)       /* I - Variable to watch for job cancel */
+{
+  char                 portname[32],   /* Port number as string */
+                       addrname[256];  /* Address as string */
+  http_addrlist_t      *addrlist,      /* List of addresses */
+                       *current;       /* Current address */
+
+
+ /*
+  * Lookup the address for the named host...
+  */
+
+  snprintf(portname, sizeof(portname), "%d", port);
+
+  fputs("STATE: +connecting-to-device\n", stderr);
+  fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);
+
+  while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
+  {
+    _cupsLangPrintFilter(stderr, "INFO", _("Unable to locate printer \"%s\"."), hostname);
+    sleep(10);
+
+    if (getenv("CLASS") != NULL)
+    {
+      fputs("STATE: -connecting-to-device\n", stderr);
+      exit(CUPS_BACKEND_STOP);
+    }
+
+    if (cancel && *cancel)
+    {
+      fputs("STATE: -connecting-to-device\n", stderr);
+      exit(CUPS_BACKEND_OK);
+    }
+  }
+
+  fputs("STATE: -connecting-to-device\n", stderr);
+
+ /*
+  * Log the addresses we got...
+  */
+
+  for (current = addrlist; current; current = current->next)
+    fprintf(stderr, "DEBUG: %s=%s\n", hostname, httpAddrString(&current->addr, addrname, sizeof(addrname)));
+
+ /*
+  * Return...
+  */
+
+  return (addrlist);
+}
+
+
 /*
  * 'backendNetworkSideCB()' - Handle common network side-channel commands.
  */
index e5158239470dae89fe271129cc947eb56fb7406e..7fc0880f16fa8b3d25bd1be2d96ae0c1c1d5a05b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * AppSocket backend for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -69,7 +69,6 @@ main(int  argc,                               /* I - Number of command-line arguments (6 or 7) */
   int          contimeout;             /* Connection timeout */
   int          waiteof;                /* Wait for end-of-file? */
   int          port;                   /* Port number */
-  char         portname[255];          /* Port name */
   int          delay;                  /* Delay for retries... */
   int          device_fd;              /* AppSocket */
   int          error;                  /* Error code (if any) */
@@ -264,23 +263,7 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
 
   start_time = time(NULL);
 
-  sprintf(portname, "%d", port);
-
-  fputs("STATE: +connecting-to-device\n", stderr);
-  fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);
-
-  while ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
-  {
-    _cupsLangPrintFilter(stderr, "INFO",
-                         _("Unable to locate printer \"%s\"."), hostname);
-    sleep(10);
-
-    if (getenv("CLASS") != NULL)
-    {
-      fputs("STATE: -connecting-to-device\n", stderr);
-      return (CUPS_BACKEND_STOP);
-    }
-  }
+  addrlist = backendLookup(hostname, port, NULL);
 
  /*
   * See if the printer supports SNMP...
index dcff0d52c65e96af3fd7d1735827ba7cd8b2dc71..3a673f20dd31c42291e2d89ba83a85f37a378f75 100644 (file)
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                COMBINE_HIDPI_IMAGES = YES;
+                               DYLIB_COMPATIBILITY_VERSION = 2.0.0;
+                               DYLIB_CURRENT_VERSION = 2.12.0;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                COMBINE_HIDPI_IMAGES = YES;
+                               DYLIB_COMPATIBILITY_VERSION = 2.0.0;
+                               DYLIB_CURRENT_VERSION = 2.12.0;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;