# DO NOT DELETE THIS LINE -- make depend depends on it.
-betest.o: betest.c ../cups/string.h ../config.h
-ipp.o: ipp.c ../cups/http-private.h ../config.h ../cups/http.h \
- ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/backend.h \
- ../cups/cups.h ../cups/ppd.h ../cups/array.h ../cups/file.h \
- ../cups/language.h ../cups/language.h ../cups/i18n.h \
- ../cups/transcode.h ../cups/string.h
-lpd.o: lpd.c ../cups/backend.h ../cups/http-private.h ../config.h \
- ../cups/http.h ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h \
- ../cups/cups.h ../cups/ppd.h ../cups/array.h ../cups/file.h \
- ../cups/language.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h
-pap.o: pap.c ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
- ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h \
- ../cups/backend.h
-parallel.o: parallel.c backend-private.h ../cups/backend.h \
- ../cups/sidechannel.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
- ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h \
- ../cups/debug.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h \
- ../config.h
-scsi.o: scsi.c ../cups/backend.h ../cups/cups.h ../cups/ipp.h \
- ../cups/http.h ../cups/ppd.h ../cups/array.h ../cups/file.h \
- ../cups/language.h ../cups/string.h ../config.h scsi-linux.c \
- ../cups/i18n.h ../cups/transcode.h
-serial.o: serial.c backend-private.h ../cups/backend.h \
- ../cups/sidechannel.h ../cups/cups.h ../cups/ipp.h ../cups/http.h \
- ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h \
- ../cups/debug.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h \
- ../config.h
-snmp.o: snmp.c ../cups/http-private.h ../config.h ../cups/http.h \
- ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h backend-private.h \
- ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h ../cups/ppd.h \
- ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h \
- ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../cups/array.h \
- ../cups/file.h
-socket.o: socket.c ../cups/http-private.h ../config.h ../cups/http.h \
- ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h backend-private.h \
- ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h ../cups/ppd.h \
- ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h \
- ../cups/i18n.h ../cups/transcode.h ../cups/string.h
-test1284.o: test1284.c ../cups/string.h ../config.h ieee1284.c \
- backend-private.h ../cups/backend.h ../cups/sidechannel.h \
- ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h \
- ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h \
- ../cups/i18n.h ../cups/transcode.h
-usb.o: usb.c ../cups/backend.h ../cups/cups.h ../cups/ipp.h \
- ../cups/http.h ../cups/ppd.h ../cups/array.h ../cups/file.h \
- ../cups/language.h ../cups/string.h ../config.h usb-unix.c ieee1284.c \
- backend-private.h ../cups/sidechannel.h ../cups/debug.h ../cups/i18n.h \
- ../cups/transcode.h
+
+betest.o: ../cups/string.h ../config.h
+ipp.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
+ipp.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/backend.h ../cups/cups.h
+ipp.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+ipp.o: ../cups/language.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h
+lpd.o: ../cups/backend.h ../cups/http-private.h ../config.h ../cups/http.h
+lpd.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h
+lpd.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+lpd.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h
+pap.o: ../config.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+pap.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/backend.h
+parallel.o: backend-private.h ../cups/backend.h ../cups/sidechannel.h
+parallel.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+parallel.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
+parallel.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../config.h
+scsi.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
+scsi.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+scsi.o: ../cups/string.h ../config.h
+serial.o: backend-private.h ../cups/backend.h ../cups/sidechannel.h
+serial.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+serial.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
+serial.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../config.h
+snmp.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
+snmp.o: ../cups/ipp-private.h ../cups/ipp.h backend-private.h
+snmp.o: ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h ../cups/ppd.h
+snmp.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
+snmp.o: ../cups/i18n.h ../cups/transcode.h ../cups/string.h ../cups/array.h
+snmp.o: ../cups/file.h
+socket.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
+socket.o: ../cups/ipp-private.h ../cups/ipp.h backend-private.h
+socket.o: ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h
+socket.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+socket.o: ../cups/debug.h ../cups/i18n.h ../cups/transcode.h ../cups/string.h
+test1284.o: ../cups/string.h ../config.h ieee1284.c backend-private.h
+test1284.o: ../cups/backend.h ../cups/sidechannel.h ../cups/cups.h
+test1284.o: ../cups/ipp.h ../cups/http.h ../cups/ppd.h ../cups/array.h
+test1284.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/i18n.h
+test1284.o: ../cups/transcode.h
+usb.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
+usb.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+usb.o: ../cups/string.h ../config.h
ipp_t *request, /* IPP request */
*response, /* IPP response */
*supported; /* get-printer-attributes response */
+ time_t start_time; /* Time of first connect */
+ int recoverable; /* Recoverable error shown? */
+ int contimeout; /* Connection timeout */
+ int delay; /* Delay for retries... */
int compression, /* Do compression of the job data? */
waitjob, /* Wait for job complete? */
waitprinter; /* Wait for printer ready? */
}
else if (argc < 6)
{
- _cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options "
- "[file ... fileN]\n"),
- argv[0]);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_STOP);
}
hostname, sizeof(hostname), &port,
resource, sizeof(resource)) < HTTP_URI_OK)
{
- _cupsLangPuts(stderr,
- _("ERROR: Missing device URI on command-line and no "
- "DEVICE_URI environment variable!\n"));
+ fputs(_("ERROR: Missing device URI on command-line and no "
+ "DEVICE_URI environment variable!\n"), stderr);
return (CUPS_BACKEND_STOP);
}
version = 1;
waitjob = 1;
waitprinter = 1;
+ contimeout = 7 * 24 * 60 * 60;
if ((optptr = strchr(resource, '?')) != NULL)
{
cupsSetEncryption(HTTP_ENCRYPT_IF_REQUESTED);
else
{
- _cupsLangPrintf(stderr,
+ fprintf(stderr,
_("ERROR: Unknown encryption option value \"%s\"!\n"),
value);
}
version = 1;
else
{
- _cupsLangPrintf(stderr,
+ fprintf(stderr,
_("ERROR: Unknown version option value \"%s\"!\n"),
value);
}
!strcasecmp(value, "gzip");
}
#endif /* HAVE_LIBZ */
+ else if (!strcasecmp(name, "contimeout"))
+ {
+ /*
+ * Set the connection timeout...
+ */
+
+ if (atoi(value) > 0)
+ contimeout = atoi(value);
+ }
else
{
/*
* Unknown option...
*/
- _cupsLangPrintf(stderr,
- _("ERROR: Unknown option \"%s\" with value \"%s\"!\n"),
- name, value);
+ fprintf(stderr, _("ERROR: Unknown option \"%s\" with value \"%s\"!\n"),
+ name, value);
}
}
}
#endif /* HAVE_LIBZ */
}
- _cupsLangPrintf(stderr, _("DEBUG: %d files to send in job...\n"), num_files);
+ fprintf(stderr, _("DEBUG: %d files to send in job...\n"), num_files);
/*
* Set the authentication info, if any...
* Try connecting to the remote server...
*/
+ delay = 5;
+ recoverable = 0;
+ start_time = time(NULL);
+
fputs("STATE: +connecting-to-device\n", stderr);
do
{
- _cupsLangPrintf(stderr, _("INFO: Connecting to %s on port %d...\n"),
+ fprintf(stderr, _("INFO: Connecting to %s on port %d...\n"),
hostname, port);
if ((http = httpConnectEncrypt(hostname, port, cupsEncryption())) == NULL)
* available printer in the class.
*/
- _cupsLangPrintf(stderr,
- _("INFO: Unable to connect to %s, queuing on next "
- "printer in class...\n"),
- hostname);
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
if (argc == 6 || strcmp(filename, argv[6]))
unlink(filename);
if (errno == ECONNREFUSED || errno == EHOSTDOWN ||
errno == EHOSTUNREACH)
{
- _cupsLangPrintf(stderr,
- _("INFO: Network host \'%s\' is busy; will retry "
- "in 30 seconds...\n"),
- hostname);
- sleep(30);
+ if (contimeout && (time(NULL) - start_time) > contimeout)
+ {
+ fputs(_("ERROR: Printer not responding!\n"), stderr);
+ return (CUPS_BACKEND_FAILED);
+ }
+
+ recoverable = 1;
+
+ fprintf(stderr,
+ _("WARNING: recoverable: Network host \'%s\' is busy; will "
+ "retry in %d seconds...\n"),
+ hostname, delay);
+
+ sleep(delay);
+
+ if (delay < 30)
+ delay += 5;
}
else if (h_errno)
{
- _cupsLangPrintf(stderr, _("INFO: Unable to lookup host \'%s\' - %s\n"),
- hostname, hstrerror(h_errno));
- sleep(30);
+ fprintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"),
+ hostname);
+ return (CUPS_BACKEND_STOP);
}
else
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to connect to IPP host: %s\n"),
- strerror(errno));
+ recoverable = 1;
+
+ fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(errno));
+ fputs(_("ERROR: recoverable: Unable to connect to printer; will "
+ "retry in 30 seconds...\n"), stderr);
sleep(30);
}
}
fputs("STATE: -connecting-to-device\n", stderr);
- _cupsLangPrintf(stderr, _("INFO: Connected to %s...\n"), hostname);
+ fprintf(stderr, _("INFO: Connected to %s...\n"), hostname);
#ifdef AF_INET6
if (http->hostaddr->addr.sa_family == AF_INET6)
- _cupsLangPrintf(stderr, _("DEBUG: Connected to [%s]:%d (IPv6)...\n"),
- httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
- ntohs(http->hostaddr->ipv6.sin6_port));
+ fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",
+ httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
+ ntohs(http->hostaddr->ipv6.sin6_port));
else
#endif /* AF_INET6 */
if (http->hostaddr->addr.sa_family == AF_INET)
- _cupsLangPrintf(stderr, _("DEBUG: Connected to %s:%d (IPv4)...\n"),
- httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
- ntohs(http->hostaddr->ipv4.sin_port));
+ fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
+ httpAddrString(http->hostaddr, addrname, sizeof(addrname)),
+ ntohs(http->hostaddr->ipv4.sin_port));
/*
* Build a URI for the printer and fill the standard IPP attributes for
* Do the request...
*/
- _cupsLangPuts(stderr, _("DEBUG: Getting supported attributes...\n"));
+ fputs(_("DEBUG: Getting supported attributes...\n"), stderr);
if ((supported = cupsDoRequest(http, request, resource)) == NULL)
ipp_status = cupsLastError();
if (ipp_status == IPP_PRINTER_BUSY ||
ipp_status == IPP_SERVICE_UNAVAILABLE)
{
- _cupsLangPuts(stderr,
- _("INFO: Printer busy; will retry in 10 seconds...\n"));
+ if (contimeout && (time(NULL) - start_time) > contimeout)
+ {
+ fputs(_("ERROR: Printer not responding!\n"), stderr);
+ return (CUPS_BACKEND_FAILED);
+ }
+
+ recoverable = 1;
+
+ fprintf(stderr,
+ _("WARNING: recoverable: Network host \'%s\' is busy; will "
+ "retry in %d seconds...\n"),
+ hostname, delay);
+
report_printer_state(supported);
- sleep(10);
+
+ sleep(delay);
+
+ if (delay < 30)
+ delay += 5;
}
else if ((ipp_status == IPP_BAD_REQUEST ||
ipp_status == IPP_VERSION_NOT_SUPPORTED) && version == 1)
* Switch to IPP/1.0...
*/
- _cupsLangPuts(stderr,
- _("INFO: Printer does not support IPP/1.1, trying "
- "IPP/1.0...\n"));
+ fputs(_("INFO: Printer does not support IPP/1.1, trying IPP/1.0...\n"),
+ stderr);
version = 0;
httpReconnect(http);
}
else if (ipp_status == IPP_NOT_FOUND)
{
- _cupsLangPuts(stderr,
- _("ERROR: Destination printer does not exist!\n"));
+ fputs(_("ERROR: Destination printer does not exist!\n"), stderr);
if (supported)
ippDelete(supported);
}
else
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to get printer status (%s)!\n"),
- ippErrorString(ipp_status));
+ fprintf(stderr, _("ERROR: Unable to get printer status (%s)!\n"),
+ cupsLastErrorString());
sleep(10);
}
* available printer in the class.
*/
- _cupsLangPrintf(stderr,
- _("INFO: Unable to queue job on %s, queuing on next "
- "printer in class...\n"),
- hostname);
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
ippDelete(supported);
httpClose(http);
}
}
+ if (recoverable)
+ {
+ /*
+ * If we've shown a recoverable error make sure the printer proxies
+ * have a chance to see the recovered message. Not pretty but
+ * necessary for now...
+ */
+
+ fputs("INFO: recovered: \n", stderr);
+ sleep(5);
+ }
+
/*
* See if the printer supports multiple copies...
*/
if (ipp_status == IPP_SERVICE_UNAVAILABLE ||
ipp_status == IPP_PRINTER_BUSY)
{
- _cupsLangPuts(stderr,
- _("INFO: Printer is busy; retrying print job...\n"));
+ fputs(_("INFO: Printer busy; will retry in 10 seconds...\n"), stderr);
sleep(10);
}
else if ((ipp_status == IPP_BAD_REQUEST ||
* Switch to IPP/1.0...
*/
- _cupsLangPuts(stderr,
- _("INFO: Printer does not support IPP/1.1, trying "
- "IPP/1.0...\n"));
+ fputs(_("INFO: Printer does not support IPP/1.1, trying IPP/1.0...\n"),
+ stderr);
version = 0;
httpReconnect(http);
}
else
- _cupsLangPrintf(stderr, _("ERROR: Print file was not accepted (%s)!\n"),
- cupsLastErrorString());
+ fprintf(stderr, _("ERROR: Print file was not accepted (%s)!\n"),
+ cupsLastErrorString());
}
else if ((job_id_attr = ippFindAttribute(response, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- _cupsLangPuts(stderr,
- _("NOTICE: Print file accepted - job ID unknown.\n"));
+ fputs(_("NOTICE: Print file accepted - job ID unknown.\n"), stderr);
job_id = 0;
}
else
{
job_id = job_id_attr->values[0].integer;
- _cupsLangPrintf(stderr, _("NOTICE: Print file accepted - job ID %d.\n"),
- job_id);
+ fprintf(stderr, _("NOTICE: Print file accepted - job ID %d.\n"), job_id);
}
ippDelete(response);
{
ipp_status = cupsLastError();
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to add file %d to job: %s\n"),
- job_id, cupsLastErrorString());
+ fprintf(stderr, _("ERROR: Unable to add file %d to job: %s\n"),
+ job_id, cupsLastErrorString());
break;
}
}
if (!job_id || !waitjob)
continue;
- _cupsLangPuts(stderr, _("INFO: Waiting for job to complete...\n"));
+ fputs(_("INFO: Waiting for job to complete...\n"), stderr);
for (; !job_cancelled;)
{
{
ippDelete(response);
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to get job %d attributes (%s)!\n"),
- job_id, ippErrorString(ipp_status));
+ fprintf(stderr, _("ERROR: Unable to get job %d attributes (%s)!\n"),
+ job_id, cupsLastErrorString());
break;
}
}
ipp_t *request; /* Cancel-Job request */
- _cupsLangPuts(stderr, _("INFO: Cancelling print job...\n"));
+ fputs(_("INFO: Cancelling print job...\n"), stderr);
request = ippNewRequest(IPP_CANCEL_JOB);
request->request.op.version[1] = version;
ippDelete(cupsDoRequest(http, request, resource));
if (cupsLastError() > IPP_OK_CONFLICT)
- _cupsLangPrintf(stderr, _("ERROR: Unable to cancel job %d: %s\n"), id,
- cupsLastErrorString());
+ fprintf(stderr, _("ERROR: Unable to cancel job %d: %s\n"), id,
+ cupsLastErrorString());
}
{
if ((fd = cupsTempFd(filename, sizeof(filename))) < 0)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to create temporary compressed "
- "print file: %s\n"), strerror(errno));
+ fprintf(stderr,
+ _("ERROR: Unable to create temporary compressed print file: %s\n"),
+ strerror(errno));
exit(CUPS_BACKEND_FAILED);
}
if ((out = cupsFileOpenFd(fd, "w9")) == NULL)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open temporary compressed "
- "print file: %s\n"), strerror(errno));
+ fprintf(stderr,
+ _("ERROR: Unable to open temporary compressed print file: %s\n"),
+ strerror(errno));
exit(CUPS_BACKEND_FAILED);
}
if ((in = cupsFileOpen(files[i], "r")) == NULL)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open print file \"%s\": %s\n"),
- files[i], strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open print file \"%s\": %s\n"),
+ files[i], strerror(errno));
cupsFileClose(out);
exit(CUPS_BACKEND_FAILED);
}
while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0)
if (cupsFileWrite(out, buffer, bytes) < bytes)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to write " CUPS_LLFMT
- " bytes to \"%s\": %s\n"),
- CUPS_LLCAST bytes, filename, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to write %d bytes to \"%s\": %s\n"),
+ (int)bytes, filename, strerror(errno));
cupsFileClose(in);
cupsFileClose(out);
exit(CUPS_BACKEND_FAILED);
files[i] = strdup(filename);
if (!stat(filename, &outinfo))
- _cupsLangPrintf(stderr,
- _("DEBUG: File %d compressed to %.1f%% of original size, "
- CUPS_LLFMT " bytes...\n"),
- i + 1, 100.0 * outinfo.st_size / total,
- CUPS_LLCAST outinfo.st_size);
+ fprintf(stderr,
+ "DEBUG: File %d compressed to %.1f%% of original size, "
+ CUPS_LLFMT " bytes...\n",
+ i + 1, 100.0 * outinfo.st_size / total,
+ CUPS_LLCAST outinfo.st_size);
}
}
#endif /* HAVE_LIBZ */
printer = getenv("PRINTER");
if (!printer)
{
- _cupsLangPuts(stderr,
- _("ERROR: PRINTER environment variable not defined!\n"));
+ fputs(_("ERROR: PRINTER environment variable not defined!\n"), stderr);
return (-1);
}
if ((ppdfile = cupsGetPPD(printer)) == NULL)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to get PPD file for printer \"%s\" - "
- "%s.\n"),
- printer, cupsLastErrorString());
+ fprintf(stderr,
+ _("ERROR: Unable to get PPD file for printer \"%s\" - %s.\n"),
+ printer, cupsLastErrorString());
}
else
{
if ((fd = cupsTempFd(pstmpname, sizeof(pstmpname))) < 0)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to create temporary file - %s.\n"),
- strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to create temporary file - %s.\n"),
+ strerror(errno));
if (ppdfile)
unlink(ppdfile);
return (-1);
execlp("pictwpstops", printer, argv[1], argv[2], argv[3], argv[4], argv[5],
filename, NULL);
- perror("ERROR: Unable to exec pictwpstops");
+ fprintf(stderr, _("ERROR: Unable to exec pictwpstops: %s\n"),
+ strerror(errno));
return (errno);
}
* Error!
*/
- perror("ERROR: Unable to fork pictwpstops");
+ fprintf(stderr, _("ERROR: Unable to fork pictwpstops: %s\n"),
+ strerror(errno));
unlink(filename);
if (ppdfile)
unlink(ppdfile);
if (wait(&status) < 0)
{
- perror("ERROR: Unable to wait for pictwpstops");
+ fprintf(stderr, _("ERROR: Unable to wait for pictwpstops: %s\n"),
+ strerror(errno));
close(fd);
unlink(filename);
if (ppdfile)
if (status)
{
if (status >= 256)
- _cupsLangPrintf(stderr, ("ERROR: pictwpstops exited with status %d!\n"),
+ fprintf(stderr, _("ERROR: pictwpstops exited with status %d!\n"),
status / 256);
else
- _cupsLangPrintf(stderr, _("ERROR: pictwpstops exited on signal %d!\n"),
+ fprintf(stderr, _("ERROR: pictwpstops exited on signal %d!\n"),
status);
unlink(filename);
}
else if (argc < 6 || argc > 7)
{
- _cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options [file]\n"),
- argv[0]);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_FAILED);
}
contimeout = 7 * 24 * 60 * 60;
#ifdef __APPLE__
- /* We want to pass utf-8 characters, not re-map them (3071945) */
+ /*
+ * We want to pass utf-8 characters, not re-map them (3071945)
+ */
+
sanitize_title = 0;
- /* Get the default timeout from a system preference... */
+ /*
+ * Get the default timeout from a system preference...
+ */
+
{
CFPropertyListRef pvalue; /* Preference value */
SInt32 toval; /* Timeout value */
if (strchr("cdfglnoprtv", value[0]))
format = value[0];
else
- _cupsLangPrintf(stderr,
- _("ERROR: Unknown format character \"%c\"\n"),
- value[0]);
+ fprintf(stderr, _("ERROR: Unknown format character \"%c\"\n"),
+ value[0]);
}
else if (!strcasecmp(name, "mode") && value[0])
{
else if (!strcasecmp(value, "stream"))
order = MODE_STREAM;
else
- _cupsLangPrintf(stderr, _("ERROR: Unknown print mode \"%s\"\n"),
- value);
+ fprintf(stderr, _("ERROR: Unknown print mode \"%s\"\n"), value);
}
else if (!strcasecmp(name, "order") && value[0])
{
else if (!strcasecmp(value, "data,control"))
order = ORDER_DATA_CONTROL;
else
- _cupsLangPrintf(stderr, _("ERROR: Unknown file order \"%s\"\n"),
- value);
+ fprintf(stderr, _("ERROR: Unknown file order \"%s\"\n"), value);
}
else if (!strcasecmp(name, "reserve"))
{
else if (!strcasecmp(name, "contimeout"))
{
/*
- * Set the timeout...
+ * Set the connection timeout...
*/
if (atoi(value) > 0)
if (fd == -1)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to open print file %s: %s\n"),
- filename, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open print file %s: %s\n"),
+ filename, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
}
* Read back the status from the command and return it...
*/
- fprintf(stderr, "DEBUG: Reading command status...\n");
+ fputs("DEBUG: Reading command status...\n", stderr);
alarm(timeout);
if (recv(fd, &status, 1, 0) < 1)
{
- _cupsLangPrintf(stderr,
- _("WARNING: Remote host did not respond with command "
- "status byte after %d seconds!\n"), timeout);
+ fprintf(stderr,
+ _("WARNING: Remote host did not respond with command status "
+ "byte after %d seconds!\n"), timeout);
status = errno;
}
*cptr; /* Pointer into control file string */
char status; /* Status byte from command */
char portname[255]; /* Port name */
+ int delay; /* Delay for retries... */
char addrname[256]; /* Address name */
http_addrlist_t *addrlist, /* Address list */
*addr; /* Socket address */
int copy; /* Copies written */
time_t start_time; /* Time of first connect */
-#ifdef __APPLE__
int recoverable; /* Recoverable error shown? */
-#endif /* __APPLE__ */
size_t nbytes; /* Number of bytes written */
off_t tbytes; /* Total bytes written */
char buffer[32768]; /* Output buffer */
if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"),
- hostname);
+ fprintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"), hostname);
return (CUPS_BACKEND_STOP);
}
/*
- * Remember when we starting trying to connect to the printer...
+ * Remember when we started trying to connect to the printer...
*/
-#ifdef __APPLE__
recoverable = 0;
-#endif /* __APPLE__ */
start_time = time(NULL);
/*
*/
fputs("STATE: +connecting-to-device\n", stderr);
- _cupsLangPrintf(stderr,
- _("INFO: Attempting to connect to host %s for printer "
- "%s\n"),
- hostname, printer);
+ fprintf(stderr,
+ _("INFO: Attempting to connect to host %s for printer %s\n"),
+ hostname, printer);
- for (lport = reserve == RESERVE_RFC1179 ? 732 : 1024, addr = addrlist;;
+ for (lport = reserve == RESERVE_RFC1179 ? 732 : 1024, addr = addrlist,
+ delay = 5;;
addr = addr->next)
{
/*
* available printer in the class.
*/
- _cupsLangPrintf(stderr,
- _("INFO: Unable to connect to %s, queuing on next "
- "printer in class...\n"),
- hostname);
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
httpAddrFreeList(addrlist);
{
if (contimeout && (time(NULL) - start_time) > contimeout)
{
- _cupsLangPuts(stderr, _("ERROR: Printer not responding!\n"));
+ fputs(_("ERROR: Printer not responding!\n"), stderr);
return (CUPS_BACKEND_FAILED);
}
-#ifdef __APPLE__
recoverable = 1;
- _cupsLangPrintf(stderr,
- _("WARNING: recoverable: "
- "Network host \'%s\' is busy, down, or "
- "unreachable; will retry in 30 seconds...\n"),
- hostname);
-#else
- _cupsLangPrintf(stderr,
- _("WARNING: "
- "Network host \'%s\' is busy, down, or "
- "unreachable; will retry in 30 seconds...\n"),
- hostname);
-#endif /* __APPLE__ */
- sleep(30);
+
+ fprintf(stderr,
+ _("WARNING: recoverable: Network host \'%s\' is busy; will "
+ "retry in %d seconds...\n"),
+ hostname, delay);
+
+ sleep(delay);
+
+ if (delay < 30)
+ delay += 5;
}
else if (error == EADDRINUSE)
{
}
else
{
-#ifdef __APPLE__
recoverable = 1;
- perror("ERROR: recoverable: "
- "Unable to connect to printer; will retry in 30 seconds...");
-#else
- perror("ERROR: "
- "Unable to connect to printer; will retry in 30 seconds...");
-#endif /* __APPLE__ */
- sleep(30);
+
+ fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(errno));
+ fputs(_("ERROR: recoverable: Unable to connect to printer; will "
+ "retry in 30 seconds...\n"), stderr);
+ sleep(30);
}
}
-#ifdef __APPLE__
if (recoverable)
{
/*
fputs("INFO: recovered: \n", stderr);
sleep(5);
}
-#endif /* __APPLE__ */
fputs("STATE: -connecting-to-device\n", stderr);
- _cupsLangPrintf(stderr, _("INFO: Connected to %s...\n"), hostname);
+ fprintf(stderr, _("INFO: Connected to %s...\n"), hostname);
#ifdef AF_INET6
if (addr->addr.addr.sa_family == AF_INET6)
if (print_fd)
{
+ /*
+ * Use the size from the print file...
+ */
+
if (fstat(print_fd, &filestats))
{
httpAddrFreeList(addrlist);
filestats.st_size *= manual_copies;
}
else
+ {
+ /*
+ * Use a "very large value" for the size so that the printer will
+ * keep printing until we close the connection...
+ */
+
#ifdef _LARGEFILE_SOURCE
filestats.st_size = (size_t)(999999999999.0);
#else
filestats.st_size = 2147483647;
#endif /* _LARGEFILE_SOURCE */
+ }
/*
* Send a job header to the printer, specifying no banner page and
return (CUPS_BACKEND_FAILED);
}
- fprintf(stderr, "INFO: Sending control file (%u bytes)\n",
+ fprintf(stderr, _("INFO: Sending control file (%u bytes)\n"),
(unsigned)strlen(control));
if (lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
if (read(fd, &status, 1) < 1)
{
- _cupsLangPrintf(stderr,
- _("WARNING: Remote host did not respond with control "
- "status byte after %d seconds!\n"), timeout);
+ fprintf(stderr,
+ _("WARNING: Remote host did not respond with control "
+ "status byte after %d seconds!\n"), timeout);
status = errno;
}
}
if (status != 0)
- _cupsLangPrintf(stderr,
- _("ERROR: Remote host did not accept control file "
- "(%d)\n"),
- status);
+ fprintf(stderr,
+ _("ERROR: Remote host did not accept control file (%d)\n"),
+ status);
else
- _cupsLangPuts(stderr, _("INFO: Control file sent successfully\n"));
+ fputs(_("INFO: Control file sent successfully\n"), stderr);
}
else
status = 0;
return (CUPS_BACKEND_FAILED);
}
- _cupsLangPrintf(stderr,
- _("INFO: Sending data file (" CUPS_LLFMT " bytes)\n"),
- CUPS_LLCAST filestats.st_size);
+ fprintf(stderr,
+#ifdef HAVE_LONG_LONG
+ _("INFO: Sending data file (%lld bytes)\n"),
+#else
+ _("INFO: Sending data file (%ld bytes)\n"),
+#endif /* HAVE_LONG_LONG */
+ CUPS_LLCAST filestats.st_size);
tbytes = 0;
for (copy = 0; copy < manual_copies; copy ++)
while ((nbytes = read(print_fd, buffer, sizeof(buffer))) > 0)
{
- _cupsLangPrintf(stderr,
- _("INFO: Spooling LPR job, %.0f%% complete...\n"),
- 100.0 * tbytes / filestats.st_size);
+ fprintf(stderr, _("INFO: Spooling LPR job, %.0f%% complete...\n"),
+ 100.0 * tbytes / filestats.st_size);
if (lpd_write(fd, buffer, nbytes) < nbytes)
{
if (recv(fd, &status, 1, 0) < 1)
{
- _cupsLangPrintf(stderr,
- _("WARNING: Remote host did not respond with data "
- "status byte after %d seconds!\n"), timeout);
+ fprintf(stderr,
+ _("WARNING: Remote host did not respond with data "
+ "status byte after %d seconds!\n"), timeout);
status = 0;
}
status = 0;
if (status != 0)
- _cupsLangPrintf(stderr,
- _("ERROR: Remote host did not accept data file (%d)\n"),
- status);
+ fprintf(stderr, _("ERROR: Remote host did not accept data file (%d)\n"),
+ status);
else
- _cupsLangPuts(stderr, _("INFO: Data file sent successfully\n"));
+ fputs(_("INFO: Data file sent successfully\n"), stderr);
}
if (status == 0 && order == ORDER_DATA_CONTROL)
return (CUPS_BACKEND_FAILED);
}
- _cupsLangPrintf(stderr, _("INFO: Sending control file (%lu bytes)\n"),
- (unsigned long)strlen(control));
+ fprintf(stderr, _("INFO: Sending control file (%lu bytes)\n"),
+ (unsigned long)strlen(control));
if (lpd_write(fd, control, strlen(control) + 1) < (strlen(control) + 1))
{
if (read(fd, &status, 1) < 1)
{
- _cupsLangPrintf(stderr,
- _("WARNING: Remote host did not respond with control "
- "status byte after %d seconds!\n"), timeout);
+ fprintf(stderr,
+ _("WARNING: Remote host did not respond with control "
+ "status byte after %d seconds!\n"), timeout);
status = errno;
}
}
if (status != 0)
- _cupsLangPrintf(stderr,
- _("ERROR: Remote host did not accept control file "
- "(%d)\n"),
- status);
+ fprintf(stderr,
+ _("ERROR: Remote host did not accept control file (%d)\n"),
+ status);
else
- _cupsLangPuts(stderr, _("INFO: Control file sent successfully\n"));
+ fputs(_("INFO: Control file sent successfully\n"), stderr);
}
/*
}
else if (argc < 6 || argc > 7)
{
- _cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options [file]\n"),
- argv[0]);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_FAILED);
}
* available printer in the class.
*/
- _cupsLangPuts(stderr,
- _("INFO: Unable to open parallel port, queuing on "
- "next printer in class...\n"));
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
if (errno == EBUSY)
{
- _cupsLangPuts(stderr,
- _("INFO: Parallel port busy; will retry in 30 "
- "seconds...\n"));
+ fputs(_("INFO: Printer busy; will retry in 30 seconds...\n"), stderr);
sleep(30);
}
else if (errno == ENXIO || errno == EIO || errno == ENOENT)
{
- _cupsLangPuts(stderr,
- _("INFO: Printer not connected; will retry in 30 "
- "seconds...\n"));
+ fputs(_("INFO: Printer not connected; will retry in 30 seconds...\n"),
+ stderr);
sleep(30);
}
else
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open parallel port device file "
- "\"%s\": %s\n"),
- resource, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open device file \"%s\": %s\n"),
+ resource, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
}
tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb);
if (print_fd != 0 && tbytes >= 0)
- _cupsLangPrintf(stderr,
- _("INFO: Sent print file, " CUPS_LLFMT " bytes...\n"),
- CUPS_LLCAST tbytes);
+ fprintf(stderr,
+#ifdef HAVE_LONG_LONG
+ _("INFO: Sent print file, %lld bytes...\n"),
+#else
+ _("INFO: Sent print file, %ld bytes...\n"),
+#endif /* HAVE_LONG_LONG */
+ CUPS_LLCAST tbytes);
}
/*
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
{
- _cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
+ fputs(_("WARNING: Failed to read side-channel request!\n"), stderr);
return;
}
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
- fprintf(stderr, "DEBUG: backendRunLoop(print_fd=%d, device_fd=%d, use_bc=%d)\n",
+ fprintf(stderr,
+ "DEBUG: backendRunLoop(print_fd=%d, device_fd=%d, use_bc=%d)\n",
print_fd, device_fd, use_bc);
/*
if (errno == ENXIO && !offline)
{
fputs("STATE: +offline-error\n", stderr);
- _cupsLangPuts(stderr, _("INFO: Printer is currently off-line.\n"));
+ fputs(_("INFO: Printer is currently off-line.\n"), stderr);
offline = 1;
}
{
if ((bc_bytes = read(device_fd, bc_buffer, sizeof(bc_buffer))) > 0)
{
- _cupsLangPrintf(stderr,
- _("DEBUG: Received " CUPS_LLFMT " bytes of "
- "back-channel data!\n"),
- CUPS_LLCAST bc_bytes);
+ fprintf(stderr,
+ "DEBUG: Received " CUPS_LLFMT " bytes of back-channel data!\n",
+ CUPS_LLCAST bc_bytes);
cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);
}
}
print_ptr = print_buffer;
- _cupsLangPrintf(stderr, _("DEBUG: Read %d bytes of print data...\n"),
- (int)print_bytes);
+ fprintf(stderr, "DEBUG: Read %d bytes of print data...\n",
+ (int)print_bytes);
}
/*
{
if (!paperout)
{
- _cupsLangPuts(stderr, _("ERROR: Out of paper!\n"));
fputs("STATE: +media-empty-error\n", stderr);
+ fputs(_("ERROR: Out of paper!\n"), stderr);
paperout = 1;
}
}
if (!offline)
{
fputs("STATE: +offline-error\n", stderr);
- _cupsLangPuts(stderr, _("INFO: Printer is currently off-line.\n"));
+ fputs(_("INFO: Printer is currently off-line.\n"), stderr);
offline = 1;
}
}
else if (errno != EAGAIN && errno != EINTR && errno != ENOTTY)
{
- perror("ERROR: Unable to write print data");
+ fprintf(stderr, _("ERROR: Unable to write print data: %s\n"),
+ strerror(errno));
return (-1);
}
}
if (offline)
{
fputs("STATE: -offline-error\n", stderr);
- _cupsLangPuts(stderr, _("INFO: Printer is now on-line.\n"));
+ fputs(_("INFO: Printer is now on-line.\n"), stderr);
offline = 0;
}
- _cupsLangPrintf(stderr, _("DEBUG: Wrote %d bytes of print data...\n"),
- (int)bytes);
+ fprintf(stderr, "DEBUG: Wrote %d bytes of print data...\n", (int)bytes);
print_bytes -= bytes;
print_ptr += bytes;
if (strncmp(resource, "/dev/scsi/", 10) != 0)
{
- _cupsLangPrintf(stderr, _("ERROR: Bad SCSI device file \"%s\"!\n"),
- resource);
+ fprintf(stderr, _("ERROR: Bad SCSI device file \"%s\"!\n"), resource);
return (CUPS_BACKEND_STOP);
}
* available printer in the class.
*/
- _cupsLangPuts(stderr,
- _("INFO: Unable to open SCSI device, queuing on next "
- "printer in class...\n"),
- stderr);
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
if (errno != EAGAIN && errno != EBUSY)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open SCSI device \"%s\" - %s\n"),
- resource, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open device file \"%s\": %s\n"),
+ uri, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
else
{
- _cupsLangPrintf(stderr,
- _("INFO: SCSI device \"%s\" busy; retrying...\n"),
- resource);
+ fputs(_("INFO: Printer busy; will retry in 30 seconds...\n"), stderr);
sleep(30);
}
}
if (ioctl(scsi_fd, DS_ENTER, &scsi_req) < 0 ||
scsi_req.ds_status != 0)
{
- _cupsLangPrintf(stderr,
- _("WARNING: SCSI command timed out (%d); "
- "retrying...\n"),
- scsi_req.ds_status);
+ fprintf(stderr,
+ _("WARNING: SCSI command timed out (%d); retrying...\n"),
+ scsi_req.ds_status);
sleep(try + 1);
}
else
if (try >= 10)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to send print data (%d)\n"),
- scsi_req.ds_status);
+ fprintf(stderr, _("ERROR: Unable to send print data (%d)\n"),
+ scsi_req.ds_status);
close(scsi_fd);
return (CUPS_BACKEND_FAILED);
}
if (strncmp(resource, "/dev/sg", 7) != 0)
{
- _cupsLangPrintf(stderr, _("ERROR: Bad SCSI device file \"%s\"!\n"),
- resource);
+ fprintf(stderr, _("ERROR: Bad SCSI device file \"%s\"!\n"), resource);
return (CUPS_BACKEND_STOP);
}
if (errno != EAGAIN && errno != EBUSY)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open SCSI device \"%s\" - %s\n"),
- resource, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open device file \"%s\": %s\n"),
+ resource, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
else
{
- _cupsLangPrintf(stderr,
- _("INFO: SCSI device \"%s\" busy; retrying...\n"),
- resource);
+ fputs(_("INFO: Printer busy; will retry in 30 seconds...\n"), stderr);
sleep(30);
}
}
if (ioctl(scsi_fd, SG_IO, &scsi_req) < 0 ||
scsi_req.status != 0)
{
- _cupsLangPrintf(stderr,
- _("WARNING: SCSI command timed out (%d); "
- "retrying...\n"),
- scsi_req.status);
+ fprintf(stderr,
+ _("WARNING: SCSI command timed out (%d); retrying...\n"),
+ scsi_req.status);
sleep(try + 1);
}
else
if (try >= 10)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to send print data (%d)\n"),
- scsi_req.status);
+ fprintf(stderr, _("ERROR: Unable to send print data (%d)\n"),
+ scsi_req.status);
close(scsi_fd);
return (CUPS_BACKEND_FAILED);
}
}
else if (argc < 6 || argc > 7)
{
- _cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options [file]\n"),
- argv[0]);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_FAILED);
}
}
else if (argc < 6 || argc > 7)
{
- _cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options [file]\n"),
- argv[0]);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_FAILED);
}
* available printer in the class.
*/
- _cupsLangPuts(stderr,
- _("INFO: Unable to open serial port, queuing on next "
- "printer in class...\n"));
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
if (errno == EBUSY)
{
- _cupsLangPuts(stderr,
- _("INFO: Serial port busy; will retry in 30 "
- "seconds...\n"));
+ fputs(_("INFO: Printer busy; will retry in 30 seconds...\n"), stderr);
sleep(30);
}
else
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open serial port device file "
- "\"%s\": %s\n"),
- resource, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open device file \"%s\": %s\n"),
+ resource, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
}
break;
# endif /* B230400 */
default :
- _cupsLangPrintf(stderr, _("WARNING: Unsupported baud rate %s!\n"),
- value);
+ fprintf(stderr, _("WARNING: Unsupported baud rate %s!\n"),
+ value);
break;
}
#endif /* B19200 == 19200 */
{
if ((bc_bytes = read(device_fd, bc_buffer, sizeof(bc_buffer))) > 0)
{
- _cupsLangPrintf(stderr,
- _("DEBUG: Received " CUPS_LLFMT " bytes of "
- "back-channel data!\n"),
- CUPS_LLCAST bc_bytes);
+ fprintf(stderr,
+ "DEBUG: Received " CUPS_LLFMT " bytes of back-channel data!\n",
+ CUPS_LLCAST bc_bytes);
cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);
}
}
* Wait for DSR to go high...
*/
- _cupsLangPuts(stderr,
- _("DEBUG: DSR is low; waiting for device...\n"));
+ fputs("DEBUG: DSR is low; waiting for device...\n", stderr);
do
{
}
while (!(status & TIOCM_DSR));
- _cupsLangPuts(stderr,
- _("DEBUG: DSR is high; writing to device...\n"));
+ fputs("DEBUG: DSR is high; writing to device...\n", stderr);
}
}
}
else
{
- _cupsLangPrintf(stderr, _("DEBUG: Wrote %d bytes...\n"), (int)bytes);
+ fprintf(stderr, "DEBUG: Wrote %d bytes...\n", (int)bytes);
print_bytes -= bytes;
print_ptr += bytes;
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
{
- _cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
+ fputs(_("WARNING: Failed to read side-channel request!\n"), stderr);
return;
}
*
* SNMP discovery backend for the Common UNIX Printing System (CUPS).
*
- * Copyright 2006 by Easy Software Products, all rights reserved.
+ * Copyright 2006-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
if (argc > 2)
{
- _cupsLangPuts(stderr, _("Usage: snmp [host-or-ip-address]\n"));
+ fputs(_("Usage: snmp [host-or-ip-address]\n"), stderr);
return (1);
}
case ASN1_BOOLEAN :
integer = asn1_get_integer(&buffer, bufend, value_length);
- _cupsLangPrintf(stderr, "DEBUG: %*sBOOLEAN %d bytes %d\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sBOOLEAN %d bytes %d\n", indent, "",
value_length, integer);
break;
case ASN1_INTEGER :
integer = asn1_get_integer(&buffer, bufend, value_length);
- _cupsLangPrintf(stderr, "DEBUG: %*sINTEGER %d bytes %d\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sINTEGER %d bytes %d\n", indent, "",
value_length, integer);
break;
case ASN1_OCTET_STRING :
- _cupsLangPrintf(stderr, "DEBUG: %*sOCTET STRING %d bytes \"%s\"\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sOCTET STRING %d bytes \"%s\"\n", indent, "",
value_length, asn1_get_string(&buffer, bufend,
value_length, string,
sizeof(string)));
break;
case ASN1_NULL_VALUE :
- _cupsLangPrintf(stderr, "DEBUG: %*sNULL VALUE %d bytes\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sNULL VALUE %d bytes\n", indent, "",
value_length);
buffer += value_length;
case ASN1_OID :
asn1_get_oid(&buffer, bufend, value_length, oid, SNMP_MAX_OID);
- _cupsLangPrintf(stderr, "DEBUG: %*sOID %d bytes ", indent, "",
+ fprintf(stderr, "DEBUG: %*sOID %d bytes ", indent, "",
value_length);
for (i = 0; oid[i]; i ++)
- _cupsLangPrintf(stderr, ".%d", oid[i]);
+ fprintf(stderr, ".%d", oid[i]);
putc('\n', stderr);
break;
case ASN1_SEQUENCE :
- _cupsLangPrintf(stderr, "DEBUG: %*sSEQUENCE %d bytes\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sSEQUENCE %d bytes\n", indent, "",
value_length);
asn1_debug(buffer, value_length, indent + 4);
break;
case ASN1_GET_REQUEST :
- _cupsLangPrintf(stderr, "DEBUG: %*sGet-Request-PDU %d bytes\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sGet-Request-PDU %d bytes\n", indent, "",
value_length);
asn1_debug(buffer, value_length, indent + 4);
break;
case ASN1_GET_RESPONSE :
- _cupsLangPrintf(stderr, "DEBUG: %*sGet-Response-PDU %d bytes\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sGet-Response-PDU %d bytes\n", indent, "",
value_length);
asn1_debug(buffer, value_length, indent + 4);
break;
default :
- _cupsLangPrintf(stderr, "DEBUG: %*sUNKNOWN(%x) %d bytes\n", indent, "",
+ fprintf(stderr, "DEBUG: %*sUNKNOWN(%x) %d bytes\n", indent, "",
value_type, value_length);
buffer += value_length;
for (col = 0; len > 0; col ++, buffer ++, len --)
{
if ((col & 15) == 0)
- _cupsLangPrintf(stderr, "DEBUG: %04X ", col);
+ fprintf(stderr, "DEBUG: %04X ", col);
- _cupsLangPrintf(stderr, " %02X", *buffer);
+ fprintf(stderr, " %02X", *buffer);
if ((col & 15) == 15)
putc('\n', stderr);
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
- _cupsLangPrintf(stderr, "ERROR: Unable to create SNMP socket - %s\n",
+ fprintf(stderr, "ERROR: Unable to create SNMP socket - %s\n",
strerror(errno));
return (-1);
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val)))
{
- _cupsLangPrintf(stderr, "ERROR: Unable to set broadcast mode - %s\n",
+ fprintf(stderr, "ERROR: Unable to set broadcast mode - %s\n",
strerror(errno));
close(fd);
if (!supported)
{
- _cupsLangPrintf(stderr, "ERROR: Missing printer-uri-supported from %s!\n",
+ fprintf(stderr, "ERROR: Missing printer-uri-supported from %s!\n",
device->addrname);
httpClose(http);
while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
{
if (!value)
- _cupsLangPrintf(stderr, "ERROR: Missing value on line %d of %s!\n", linenum,
+ fprintf(stderr, "ERROR: Missing value on line %d of %s!\n", linenum,
filename);
else if (!strcasecmp(line, "Address"))
{
else if (!strcasecmp(line, "MaxRunTime"))
MaxRunTime = atoi(value);
else
- _cupsLangPrintf(stderr, "ERROR: Unknown directive %s on line %d of %s!\n",
+ fprintf(stderr, "ERROR: Unknown directive %s on line %d of %s!\n",
line, linenum, filename);
}
if ((bytes = recvfrom(fd, buffer, sizeof(buffer), 0, (void *)&addr,
&addrlen)) < 0)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to read data from socket: %s\n"),
- strerror(errno));
+ fprintf(stderr, "ERROR: Unable to read data from socket: %s\n",
+ strerror(errno));
return;
}
if (asn1_decode_snmp(buffer, bytes, &packet))
{
- _cupsLangPrintf(stderr, _("ERROR: Bad SNMP packet from %s: %s\n"),
- addrname, packet.error);
+ fprintf(stderr, "ERROR: Bad SNMP packet from %s: %s\n",
+ addrname, packet.error);
asn1_debug(buffer, bytes, 0);
hex_debug(buffer, bytes);
if (!addrs)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to scan \"%s\"!\n"), address);
+ fprintf(stderr, "ERROR: Unable to scan \"%s\"!\n", address);
continue;
}
if (bytes < 0)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to send SNMP query: %s\n"),
- packet.error);
+ fprintf(stderr, "ERROR: Unable to send SNMP query: %s\n",
+ packet.error);
return;
}
addr->ipv4.sin_port = htons(SNMP_PORT);
if (sendto(fd, buffer, bytes, 0, (void *)addr, sizeof(addr->ipv4)) < bytes)
- _cupsLangPrintf(stderr, _("ERROR: Unable to send %d bytes to %s: %s\n"),
- bytes, addrname, strerror(errno));
+ fprintf(stderr, "ERROR: Unable to send %d bytes to %s: %s\n",
+ bytes, addrname, strerror(errno));
}
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
- _cupsLangPrintf(stderr, _("ERROR: Unable to create socket: %s\n"),
- strerror(errno));
+ fprintf(stderr, "ERROR: Unable to create socket: %s\n",
+ strerror(errno));
return (-1);
}
*ptr; /* Pointer into name or value */
int print_fd; /* Print file */
int copies; /* Number of copies to print */
+ time_t start_time; /* Time of first connect */
+ int recoverable; /* Recoverable error shown? */
+ int contimeout; /* Connection timeout */
int waiteof; /* Wait for end-of-file? */
int port; /* Port number */
char portname[255]; /* Port name */
}
else if (argc < 6 || argc > 7)
{
- _cupsLangPrintf(stderr,
- _("Usage: %s job-id user title copies options [file]\n"),
- argv[0]);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_FAILED);
}
* Get options, if any...
*/
- waiteof = 1;
+ waiteof = 1;
+ contimeout = 7 * 24 * 60 * 60;
if ((options = strchr(resource, '?')) != NULL)
{
waiteof = !value[0] || !strcasecmp(value, "on") ||
!strcasecmp(value, "yes") || !strcasecmp(value, "true");
}
+ else if (!strcasecmp(name, "contimeout"))
+ {
+ /*
+ * Set the connection timeout...
+ */
+
+ if (atoi(value) > 0)
+ contimeout = atoi(value);
+ }
}
}
* Then try to connect to the remote host...
*/
+ recoverable = 0;
+ start_time = time(NULL);
+
sprintf(portname, "%d", port);
if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to locate printer \'%s\'!\n"), hostname);
+ fprintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"), hostname);
return (CUPS_BACKEND_STOP);
}
- _cupsLangPrintf(stderr,
- _("INFO: Attempting to connect to host %s on port %d\n"),
- hostname, port);
+ fprintf(stderr, _("INFO: Attempting to connect to host %s on port %d\n"),
+ hostname, port);
fputs("STATE: +connecting-to-device\n", stderr);
* available printer in the class.
*/
- _cupsLangPrintf(stderr,
- _("INFO: Unable to connect to \"%s\", queuing on "
- "next printer in class...\n"),
- hostname);
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
if (error == ECONNREFUSED || error == EHOSTDOWN ||
error == EHOSTUNREACH)
{
- _cupsLangPrintf(stderr,
- _("INFO: Network host \'%s\' is busy; will retry "
- "in %d seconds...\n"),
- hostname, delay);
+ if (contimeout && (time(NULL) - start_time) > contimeout)
+ {
+ fputs(_("ERROR: Printer not responding!\n"), stderr);
+ return (CUPS_BACKEND_FAILED);
+ }
+
+ recoverable = 1;
+
+ fprintf(stderr,
+ _("WARNING: recoverable: Network host \'%s\' is busy; will "
+ "retry in %d seconds...\n"),
+ hostname, delay);
+
sleep(delay);
if (delay < 30)
}
else
{
- perror("ERROR: Unable to connect to printer (retrying in 30 seconds)");
+ recoverable = 1;
+
+ fprintf(stderr, "DEBUG: Connection error: %s\n", strerror(errno));
+ fputs(_("ERROR: recoverable: Unable to connect to printer; will "
+ "retry in 30 seconds...\n"), stderr);
sleep(30);
}
}
break;
}
+ if (recoverable)
+ {
+ /*
+ * If we've shown a recoverable error make sure the printer proxies
+ * have a chance to see the recovered message. Not pretty but
+ * necessary for now...
+ */
+
+ fputs("INFO: recovered: \n", stderr);
+ sleep(5);
+ }
+
fputs("STATE: -connecting-to-device\n", stderr);
- _cupsLangPrintf(stderr, _("INFO: Connected to %s...\n"), hostname);
+ fprintf(stderr, _("INFO: Connected to %s...\n"), hostname);
#ifdef AF_INET6
if (addr->addr.addr.sa_family == AF_INET6)
- _cupsLangPrintf(stderr, _("DEBUG: Connected to [%s]:%d (IPv6)...\n"),
- httpAddrString(&addr->addr, addrname, sizeof(addrname)),
- ntohs(addr->addr.ipv6.sin6_port));
+ fprintf(stderr, "DEBUG: Connected to [%s]:%d (IPv6)...\n",
+ httpAddrString(&addr->addr, addrname, sizeof(addrname)),
+ ntohs(addr->addr.ipv6.sin6_port));
else
#endif /* AF_INET6 */
if (addr->addr.addr.sa_family == AF_INET)
- _cupsLangPrintf(stderr, _("DEBUG: Connected to %s:%d (IPv4)...\n"),
- httpAddrString(&addr->addr, addrname, sizeof(addrname)),
- ntohs(addr->addr.ipv4.sin_port));
+ fprintf(stderr, "DEBUG: Connected to %s:%d (IPv4)...\n",
+ httpAddrString(&addr->addr, addrname, sizeof(addrname)),
+ ntohs(addr->addr.ipv4.sin_port));
/*
* Print everything...
tbytes = backendRunLoop(print_fd, device_fd, 1, side_cb);
if (print_fd != 0 && tbytes >= 0)
- _cupsLangPrintf(stderr,
- _("INFO: Sent print file, " CUPS_LLFMT " bytes...\n"),
- CUPS_LLCAST tbytes);
+ fprintf(stderr,
+#ifdef HAVE_LONG_LONG
+ _("INFO: Sent print file, %lld bytes...\n"),
+#else
+ _("INFO: Sent print file, %ld bytes...\n"),
+#endif /* HAVE_LONG_LONG */
+ CUPS_LLCAST tbytes);
}
if (waiteof)
* Shutdown the socket and wait for the other end to finish...
*/
- _cupsLangPuts(stderr,
- _("INFO: Print file sent, waiting for printer to "
- "finish...\n"));
+ fputs(_("INFO: Print file sent, waiting for printer to finish...\n"),
+ stderr);
shutdown(device_fd, 1);
if ((bc_bytes = read(device_fd, resource, sizeof(resource))) > 0)
{
- _cupsLangPrintf(stderr,
- _("DEBUG: Received %d bytes of back-channel data!\n"),
- (int)bc_bytes);
+ fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n",
+ (int)bc_bytes);
cupsBackChannelWrite(resource, bc_bytes, 1.0);
}
else
close(print_fd);
if (tbytes >= 0)
- _cupsLangPuts(stderr, _("INFO: Ready to print.\n"));
+ fputs(_("INFO: Ready to print.\n"), stderr);
return (tbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
}
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
{
- _cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
+ fputs(_("WARNING: Failed to read side-channel request!\n"), stderr);
return;
}
*
* Contents:
*
+ * main() - Test the device-ID functions.
*/
/*
printer_data.printerDriver = 0x0;
}
- fprintf(stderr, "INFO: Looking for '%s %s'\n", hostname, resource);
+ fprintf(stderr, "DEBUG: Looking for '%s %s'\n", hostname, resource);
iterate_printers(find_device_callback, &printer_data);
- fprintf(stderr, "INFO: Opening Connection\n");
+ fputs("DEBUG: Opening connection\n", stderr);
driverBundlePath = NULL;
status = registry_open(&printer_data, &driverBundlePath);
if (driverBundlePath == NULL || !CFStringGetCString(driverBundlePath, buffer, sizeof(buffer), kCFStringEncodingUTF8))
strlcpy(buffer, "USB class driver", sizeof(buffer));
- fprintf(stderr, "STATE: +apple-missing-usbclassdriver-error\n" \
- "FATAL: Could not load %s\n", buffer);
+ fputs("STATE: +apple-missing-usbclassdriver-error\n", stderr);
+ fprintf(stderr, _("FATAL: Could not load %s\n"), buffer);
if (driverBundlePath)
CFRelease(driverBundlePath);
sleep( PRINTER_POLLING_INTERVAL );
countdown -= PRINTER_POLLING_INTERVAL;
if ( countdown <= 0 ) {
- fprintf(stderr, "INFO: Printer busy (status:0x%08x)\n", (int)status);
+ fprintf(stderr, _("INFO: Printer busy (status:0x%08x)\n"), (int)status);
countdown = SUBSEQUENT_LOG_INTERVAL; /* subsequent log entries, every 15 seconds */
}
}
thread_created = 1;
if (thread_created == 0)
- fprintf(stderr, "WARNING: Couldn't create read channel\n");
+ fputs(_("WARNING: Couldn't create read channel\n"), stderr);
if (pthread_cond_init(&printer_data.reqWaitCompCond, NULL) == 0)
reqWaitCompCondPtr = &printer_data.reqWaitCompCond;
reqWait_create = 1;
if (reqWait_create == 0)
- fprintf(stderr, "WARNING: Couldn't create sidechannel thread!\n");
+ fputs(_("WARNING: Couldn't create sidechannel thread!\n"), stderr);
if (pthread_mutex_init(&printer_data.waitCloseMutex, NULL) == 0)
waitCloseMutexPtr = &printer_data.waitCloseMutex;
ssize_t nbytes; /* Number of bytes read */
off_t tbytes = 0; /* Total number of bytes written */
- fprintf(stderr, "INFO: Sending data\n");
+ fputs(_("INFO: Sending data\n"), stderr);
if (STDIN_FILENO != fd) {
fputs("PAGE: 1 1", stderr);
status = (*(printer_data.printerDriver))->WritePipe( printer_data.printerDriver, (UInt8*)bufptr, &wbytes, 0 /* nbytes > wbytes? 0: feof(fp) */ );
if (wbytes < 0 || noErr != status) {
OSStatus err = (*(printer_data.printerDriver))->Abort(printer_data.printerDriver);
- fprintf(stderr, "ERROR: %ld: Unable to send print file to printer (canceled:%ld)\n", status, err);
+ fprintf(stderr, _("ERROR: %ld: Unable to send print file to printer (canceled:%ld)\n"), status, err);
break;
}
}
if (fd != 0 && status == noErr)
- fprintf(stderr, "DEBUG: Sending print file, %qd bytes...\n", (off_t)tbytes);
+ fprintf(stderr, _("DEBUG: Sending print file, %lld bytes...\n"), (off_t)tbytes);
}
}
if (!keepLooking && userData->statusTimer != NULL) {
fputs("STATE: -offline-error\n", stderr);
- fputs("INFO: Printer is now on-line.\n", stderr);
+ fputs(_("INFO: Printer is now on-line.\n"), stderr);
CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), userData->statusTimer, kCFRunLoopDefaultMode);
CFRelease(userData->statusTimer);
userData->statusTimer = NULL;
static void statusTimerCallback (CFRunLoopTimerRef timer, void *info)
{
fputs("STATE: +offline-error\n", stderr);
- fputs("INFO: Printer is currently off-line.\n", stderr);
+ fputs(_("INFO: Printer is currently off-line.\n"), stderr);
}
#pragma mark -
#ifdef DEBUG
char bundlestr[1024];
CFStringGetCString(bundle, bundlestr, sizeof(bundlestr), kCFStringEncodingUTF8);
- fprintf(stderr, "DEBUG:load_classdriver(%s) (kr:0x%08x)\n", bundlestr, (int)kr);
+ fprintf(stderr, "DEBUG: load_classdriver(%s) (kr:0x%08x)\n", bundlestr, (int)kr);
#endif /* DEBUG */
return kr;
*waitEOF = false;
}
else {
- fprintf(stderr, "WARNING: Boolean expected for waiteof option \"%s\"\n", value);
+ fprintf(stderr, _("WARNING: Boolean expected for waiteof option \"%s\"\n"), value);
}
}
else if (strcasecmp(optionName, "serial") == 0) {
CFRelease(lang[0]);
CFRelease(langArray);
} else {
- fprintf(stderr, "DEBUG: usb: LANG environment variable missing.\n");
+ fputs("DEBUG: usb: LANG environment variable missing.\n", stderr);
}
}
}
}
else {
- fprintf(stderr, "DEBUG: usb child running i386 again\n");
+ fputs("DEBUG: usb child running i386 again\n", stderr);
exitstatus = ENOENT;
}
* available printer in the class.
*/
- _cupsLangPuts(stderr,
- _("INFO: Unable to open USB device, queuing on next "
- "printer in class...\n"));
+ fputs(_("INFO: Unable to contact printer, queuing on next "
+ "printer in class...\n"), stderr);
/*
* Sleep 5 seconds to keep the job from requeuing too rapidly...
if (errno == EBUSY)
{
- _cupsLangPuts(stderr,
- _("INFO: USB port busy; will retry in 30 seconds...\n"));
- sleep(30);
+ fputs(_("INFO: Printer busy; will retry in 10 seconds...\n"), stderr);
+ sleep(10);
}
else if (errno == ENXIO || errno == EIO || errno == ENOENT ||
errno == ENODEV)
{
- _cupsLangPuts(stderr,
- _("INFO: Printer not connected; will retry in 30 "
- "seconds...\n"));
+ fputs(_("INFO: Printer not connected; will retry in 30 seconds...\n"),
+ stderr);
sleep(30);
}
else
{
- _cupsLangPrintf(stderr,
- _("ERROR: Unable to open USB device \"%s\": %s\n"),
- uri, strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open device file \"%s\": %s\n"),
+ resource, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
}
tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb);
if (print_fd != 0 && tbytes >= 0)
- _cupsLangPrintf(stderr,
- _("INFO: Sent print file, " CUPS_LLFMT " bytes...\n"),
- CUPS_LLCAST tbytes);
+ fprintf(stderr,
+#ifdef HAVE_LONG_LONG
+ _("INFO: Sent print file, %lld bytes...\n"),
+#else
+ _("INFO: Sent print file, %ld bytes...\n"),
+#endif /* HAVE_LONG_LONG */
+ CUPS_LLCAST tbytes);
}
/*
* Yes, return this file descriptor...
*/
- _cupsLangPrintf(stderr,
- _("DEBUG: Printer using device file \"%s\"...\n"),
- device);
+ fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",
+ device);
return (fd);
}
if (busy)
{
- _cupsLangPuts(stderr,
- _("INFO: USB printer is busy; will retry in 5 "
- "seconds...\n"));
+ fputs(_("INFO: Printer is busy; will retry in 5 seconds...\n"),
+ stderr);
sleep(5);
}
}
if (busy)
{
- _cupsLangPuts(stderr,
- _("INFO: USB printer is busy; will retry in 5 "
- "seconds...\n"));
+ fputs(_("INFO: Printer is busy; will retry in 5 seconds...\n"),
+ stderr);
sleep(5);
}
}
if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
{
- _cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
+ fputs(_("WARNING: Failed to read side-channel request!\n"), stderr);
return;
}
*
* USB port backend for the Common UNIX Printing System (CUPS).
*
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
}
else if (argc < 6 || argc > 7)
{
- _cupsLangPuts(stderr,
- _("Usage: usb job-id user title copies options [file]\n"));
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (CUPS_BACKEND_FAILED);
}
hostname, sizeof(hostname), &port,
resource, sizeof(resource)) < HTTP_URI_OK)
{
- _cupsLangPuts(stderr,
- _("ERROR: No device URI found in argv[0] or in DEVICE_URI "
- "environment variable!\n"));
+ fputs(_("ERROR: No device URI found in argv[0] or in DEVICE_URI "
+ "environment variable!\n"), stderr);
return (1);
}
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
{
- _cupsLangPrintf(stderr, _("ERROR: unable to open print file %s - %s\n"),
- argv[6], strerror(errno));
+ fprintf(stderr, _("ERROR: Unable to open print file %s - %s\n"),
+ argv[6], strerror(errno));
return (CUPS_BACKEND_FAILED);
}