]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/lpd.c
Fix lpadmin error reporting for IPP Everywhere printers (Issue #5370)
[thirdparty/cups.git] / backend / lpd.c
index d8ef9343b2bf36bd4adef5637acbc12b7c24abb8..0fbe38c443811d5304634f86b2cbf06f2628983f 100644 (file)
@@ -1,18 +1,11 @@
 /*
- * "$Id$"
- *
  * Line Printer Daemon backend for CUPS.
  *
- * 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
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file.  If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Copyright © 2007-2016 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
  *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
 /*
@@ -113,7 +106,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 */
@@ -413,23 +405,11 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Find the printer...
   */
 
-  snprintf(portname, sizeof(portname), "%d", port);
-
-  fputs("STATE: +connecting-to-device\n", stderr);
-  fprintf(stderr, "DEBUG: Looking up \"%s\"...\n", hostname);
+  addrlist = backendLookup(hostname, port, NULL);
 
-  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);
@@ -594,7 +574,7 @@ cups_rresvport(int *port,           /* IO - Port number to bind to */
   */
 
   memset(&addr, 0, sizeof(addr));
-  addr.addr.sa_family = family;
+  addr.addr.sa_family = (sa_family_t)family;
 
  /*
   * Try to bind the socket to a reserved port...
@@ -882,8 +862,7 @@ lpd_queue(const char      *hostname,        /* I - Host to connect to */
 
       fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(error));
 
-      if (error == ECONNREFUSED || error == EHOSTDOWN ||
-          error == EHOSTUNREACH)
+      if (errno == ECONNREFUSED || errno == EHOSTDOWN || errno == EHOSTUNREACH || errno == ETIMEDOUT || errno == ENOTCONN)
       {
         if (contimeout && (time(NULL) - start_time) > contimeout)
        {
@@ -901,13 +880,13 @@ lpd_queue(const char      *hostname,      /* I - Host to connect to */
              break;
 
          case EHOSTUNREACH :
+         default :
              _cupsLangPrintFilter(stderr, "WARNING",
                                   _("The printer is unreachable at "
                                     "this time."));
              break;
 
          case ECONNREFUSED :
-         default :
              _cupsLangPrintFilter(stderr, "WARNING",
                                   _("The printer is in use."));
              break;
@@ -1313,8 +1292,3 @@ sigterm_handler(int sig)          /* I - Signal */
 
   abort_job = 1;
 }
-
-
-/*
- * End of "$Id$".
- */