/*
- * "$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.
*/
/*
*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 */
* 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);
*/
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...
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)
{
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;
abort_job = 1;
}
-
-
-/*
- * End of "$Id$".
- */