/*
- * "$Id: lpd.c 6910 2007-09-04 20:34:29Z mike $"
+ * "$Id: lpd.c 7740 2008-07-14 23:58:05Z mike $"
*
* Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
*
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
+ const char *device_uri; /* Device URI */
char method[255], /* Method in URI */
hostname[1024], /* Hostname */
username[255], /* Username info */
if (argc == 1)
{
- puts("network lpd \"Unknown\" \"LPD/LPR Host or Printer\"");
+ printf("network lpd \"Unknown\" \"%s\"\n",
+ _cupsLangString(cupsLangDefault(), _("LPD/LPR Host or Printer")));
return (CUPS_BACKEND_OK);
}
else if (argc < 6 || argc > 7)
* Extract the hostname and printer name from the URI...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, backendResolveURI(argv),
+ if ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
+ return (CUPS_BACKEND_FAILED);
+
+ httpSeparateURI(HTTP_URI_CODING_ALL, device_uri,
method, sizeof(method), username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
unlink(tmpfilename);
return (CUPS_BACKEND_FAILED);
}
-
- filename = tmpfilename;
}
else if (argc == 6)
{
http_addrlist_t *addrlist, /* Address list */
*addr; /* Socket address */
int snmp_fd, /* SNMP socket */
- start_count, /* Page count via SNMP at start */
- page_count; /* Page count via SNMP */
+ have_supplies; /* Printer supports supply levels? */
int copy; /* Copies written */
time_t start_time; /* Time of first connect */
int recoverable; /* Recoverable error shown? */
*/
fputs("STATE: +connecting-to-device\n", stderr);
- _cupsLangPrintf(stderr,
- _("INFO: Attempting to connect to host %s for printer %s\n"),
- hostname, printer);
+ fprintf(stderr, "DEBUG: Connecting to %s:%d for printer %s\n",
+ hostname, port, printer);
+ _cupsLangPuts(stderr, _("INFO: Connecting to printer...\n"));
for (lport = reserve == RESERVE_RFC1179 ? 732 : 1024, addr = addrlist,
delay = 5;;
}
fputs("STATE: -connecting-to-device\n", stderr);
- _cupsLangPrintf(stderr, _("INFO: Connected to %s...\n"), hostname);
+ _cupsLangPuts(stderr, _("INFO: Connected to printer...\n"));
#ifdef AF_INET6
if (addr->addr.addr.sa_family == AF_INET6)
*/
if ((snmp_fd = _cupsSNMPOpen(addr->addr.addr.sa_family)) >= 0)
- if (backendSNMPSupplies(snmp_fd, &(addr->addr), &start_count, NULL))
- {
- /*
- * No, close it...
- */
-
- _cupsSNMPClose(snmp_fd);
- snmp_fd = -1;
- }
+ have_supplies = !backendSNMPSupplies(snmp_fd, &(addr->addr), NULL, NULL);
+ else
+ have_supplies = 0;
/*
* Check for side-channel requests...
}
/*
- * Collect the final page count as needed...
+ * Collect the final supply levels as needed...
*/
- if (snmp_fd >= 0)
- {
- int printer_state; /* State of printer */
-
-
- while (!backendSNMPSupplies(snmp_fd, &(addr->addr), &page_count,
- &printer_state) &&
- printer_state != CUPS_TC_idle)
- sleep(3);
-
- if (page_count > start_count)
- fprintf(stderr, "PAGE: total %d\n", page_count - start_count);
- }
+ if (have_supplies)
+ backendSNMPSupplies(snmp_fd, &(addr->addr), NULL, NULL);
/*
* Close the socket connection and input file...
/*
- * End of "$Id: lpd.c 6910 2007-09-04 20:34:29Z mike $".
+ * End of "$Id: lpd.c 7740 2008-07-14 23:58:05Z mike $".
*/