]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
More localization stuff + cleanup to only use fputs and fprintf since we
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 27 Mar 2007 16:00:56 +0000 (16:00 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 27 Mar 2007 16:00:56 +0000 (16:00 +0000)
want UTF-8 out of the backends, not the default locale charset...

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@6403 7a7537e8-13f0-0310-91df-b6672ffda945

15 files changed:
backend/Dependencies
backend/ipp.c
backend/lpd.c
backend/parallel.c
backend/runloop.c
backend/scsi-irix.c
backend/scsi-linux.c
backend/scsi.c
backend/serial.c
backend/snmp.c
backend/socket.c
backend/test1284.c
backend/usb-darwin.c
backend/usb-unix.c
backend/usb.c

index 60621e0733a8d053c16ceb7a748fb8a105138034..245181dc87e63943c7159fc2c612ce544731c77a 100644 (file)
@@ -1,49 +1,43 @@
 # 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
index 2f0b15bc58126b1ca0604496d2919be91720ecaa..92588433f83b6a1636d16ec5333246b4465b1354 100644 (file)
@@ -122,6 +122,10 @@ main(int  argc,                            /* I - Number of command-line args */
   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? */
@@ -201,10 +205,8 @@ main(int  argc,                            /* I - Number of command-line args */
   }
   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);
   }
 
@@ -228,9 +230,8 @@ main(int  argc,                             /* I - Number of command-line args */
                      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);
   }
 
@@ -247,6 +248,7 @@ main(int  argc,                             /* I - Number of command-line args */
   version     = 1;
   waitjob     = 1;
   waitprinter = 1;
+  contimeout  = 7 * 24 * 60 * 60;
 
   if ((optptr = strchr(resource, '?')) != NULL)
   {
@@ -331,7 +333,7 @@ main(int  argc,                             /* I - Number of command-line args */
          cupsSetEncryption(HTTP_ENCRYPT_IF_REQUESTED);
        else
        {
-         _cupsLangPrintf(stderr,
+         fprintf(stderr,
                          _("ERROR: Unknown encryption option value \"%s\"!\n"),
                          value);
         }
@@ -344,7 +346,7 @@ main(int  argc,                             /* I - Number of command-line args */
          version = 1;
        else
        {
-         _cupsLangPrintf(stderr,
+         fprintf(stderr,
                          _("ERROR: Unknown version option value \"%s\"!\n"),
                          value);
        }
@@ -358,15 +360,23 @@ main(int  argc,                           /* I - Number of command-line args */
                      !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);
       }
     }
   }
@@ -437,7 +447,7 @@ main(int  argc,                             /* I - Number of command-line args */
 #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...
@@ -519,11 +529,15 @@ main(int  argc,                           /* I - Number of command-line args */
   * 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)
@@ -540,10 +554,8 @@ main(int  argc,                            /* I - Number of command-line args */
        * 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);
@@ -560,22 +572,37 @@ main(int  argc,                           /* I - Number of command-line args */
       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);
       }
 
@@ -594,19 +621,19 @@ main(int  argc,                           /* I - Number of command-line args */
   }
 
   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
@@ -646,7 +673,7 @@ main(int  argc,                             /* I - Number of command-line args */
     * 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();
@@ -658,10 +685,25 @@ main(int  argc,                           /* I - Number of command-line args */
       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)
@@ -670,16 +712,14 @@ main(int  argc,                           /* I - Number of command-line args */
        * 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);
@@ -688,9 +728,8 @@ main(int  argc,                             /* I - Number of command-line args */
       }
       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);
       }
 
@@ -752,10 +791,8 @@ main(int  argc,                            /* I - Number of command-line args */
       * 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);
@@ -773,6 +810,18 @@ main(int  argc,                            /* I - Number of command-line args */
     }
   }
 
+  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...
   */
@@ -943,8 +992,7 @@ main(int  argc,                             /* I - Number of command-line args */
       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 ||
@@ -954,28 +1002,25 @@ main(int  argc,                          /* I - Number of command-line args */
        * 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);
@@ -1013,9 +1058,8 @@ main(int  argc,                           /* I - Number of command-line args */
        {
          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;
        }
       }
@@ -1039,7 +1083,7 @@ main(int  argc,                           /* I - Number of command-line args */
     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;)
     {
@@ -1093,9 +1137,8 @@ main(int  argc,                           /* I - Number of command-line args */
        {
          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;
        }
       }
@@ -1204,7 +1247,7 @@ cancel_job(http_t     *http,              /* I - HTTP connection */
   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;
@@ -1224,8 +1267,8 @@ cancel_job(http_t     *http,              /* I - HTTP connection */
   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());
 }
 
 
@@ -1299,25 +1342,24 @@ compress_files(int  num_files,          /* I - Number of files */
   {
     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);
     }
@@ -1326,10 +1368,8 @@ compress_files(int  num_files,           /* I - Number of files */
     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);
@@ -1343,11 +1383,11 @@ compress_files(int  num_files,          /* I - Number of files */
     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 */
@@ -1530,17 +1570,15 @@ run_pictwps_filter(char       **argv,   /* I - Command-line arguments */
   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
   {
@@ -1554,8 +1592,8 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
 
   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);
@@ -1611,7 +1649,8 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
 
     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);
   }
 
@@ -1623,7 +1662,8 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
     * Error!
     */
 
-    perror("ERROR: Unable to fork pictwpstops");
+    fprintf(stderr, _("ERROR: Unable to fork pictwpstops: %s\n"),
+            strerror(errno));
     unlink(filename);
     if (ppdfile)
       unlink(ppdfile);
@@ -1636,7 +1676,8 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
 
   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)
@@ -1652,10 +1693,10 @@ run_pictwps_filter(char       **argv,   /* I - Command-line arguments */
   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);
index 358688b22f14d752a00daf40482a1f5aa04ad3eb..29b2de545450df985899c6802faae627a1276c79 100644 (file)
@@ -195,9 +195,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   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);
   }
 
@@ -233,10 +232,16 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   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 */
@@ -326,9 +331,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
         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])
       {
@@ -341,8 +345,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
        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])
       {
@@ -355,8 +358,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
        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"))
       {
@@ -403,7 +405,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       else if (!strcasecmp(name, "contimeout"))
       {
        /*
-        * Set the timeout...
+        * Set the connection timeout...
        */
 
        if (atoi(value) > 0)
@@ -464,8 +466,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
     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);
     }
   }
@@ -586,15 +588,15 @@ lpd_command(int  fd,              /* I - Socket connection to LPD host */
   * 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;
   }
 
@@ -636,14 +638,13 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
                        *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 */
@@ -676,18 +677,15 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
 
   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);
 
  /*
@@ -701,12 +699,12 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
     */
 
     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)
     {
      /*
@@ -802,10 +800,8 @@ lpd_queue(const char *hostname,            /* I - Host to connect to */
        * 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);
 
@@ -823,25 +819,21 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
       {
         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)
       {
@@ -853,19 +845,15 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
       }
       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)
     {
      /*
@@ -877,10 +865,9 @@ lpd_queue(const char *hostname,            /* I - Host to connect to */
       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)
@@ -900,6 +887,10 @@ lpd_queue(const char *hostname,            /* I - Host to connect to */
 
     if (print_fd)
     {
+     /*
+      * Use the size from the print file...
+      */
+
       if (fstat(print_fd, &filestats))
       {
        httpAddrFreeList(addrlist);
@@ -912,11 +903,18 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
       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
@@ -975,7 +973,7 @@ lpd_queue(const char *hostname,             /* I - Host to connect to */
         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))
@@ -989,9 +987,9 @@ lpd_queue(const char *hostname,             /* I - Host to connect to */
 
         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;
        }
 
@@ -999,12 +997,11 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
       }
 
       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;
@@ -1025,9 +1022,13 @@ lpd_queue(const char *hostname,          /* I - Host to connect to */
         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 ++)
@@ -1036,9 +1037,8 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
 
        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)
          {
@@ -1072,9 +1072,9 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
 
           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;
           }
 
@@ -1085,11 +1085,10 @@ lpd_queue(const char *hostname,         /* I - Host to connect to */
         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)
@@ -1103,8 +1102,8 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
         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))
       {
@@ -1117,9 +1116,9 @@ lpd_queue(const char *hostname,           /* I - Host to connect to */
 
         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;
        }
 
@@ -1127,12 +1126,11 @@ lpd_queue(const char *hostname,         /* I - Host to connect to */
       }
 
       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);
     }
 
    /*
index 048069ba865015f2cda59d7ad9bc6a5cad621c90..597b4a014cf7c1ac8c6be01c2215204a401a8a85 100644 (file)
@@ -131,9 +131,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   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);
   }
 
@@ -223,9 +222,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
        * 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...
@@ -238,24 +236,19 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
 
       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);
       }
     }
@@ -295,9 +288,13 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
     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);
   }
 
  /*
@@ -625,7 +622,7 @@ side_cb(int print_fd,                       /* I - Print file */
 
   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;
   }
 
index d06efe6e8c5d91204304e308d8e66c1a4f037c00..21c9192bb0c60e917e1d8df1eba7c076980cfb5c 100644 (file)
@@ -68,7 +68,8 @@ backendRunLoop(
 #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);
 
  /*
@@ -132,7 +133,7 @@ backendRunLoop(
        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;
        }
 
@@ -156,10 +157,9 @@ backendRunLoop(
     {
       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);
       }
     }
@@ -196,8 +196,8 @@ backendRunLoop(
 
       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);
     }
 
    /*
@@ -217,8 +217,8 @@ backendRunLoop(
        {
          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;
          }
         }
@@ -227,13 +227,14 @@ backendRunLoop(
          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);
        }
       }
@@ -248,12 +249,11 @@ backendRunLoop(
        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;
index ae64446f13e825f9aaf2f1c90d6ea0f1d0085cde..12f72c0d8d611de84b19c4a68ac5e0b4ff5ce13e 100644 (file)
@@ -95,8 +95,7 @@ print_device(const char *resource,    /* I - SCSI device */
 
   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);
   }
 
@@ -119,10 +118,8 @@ print_device(const char *resource, /* I - SCSI device */
        * 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...
@@ -135,16 +132,13 @@ print_device(const char *resource,        /* I - SCSI device */
 
       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);
       }
     }
@@ -206,10 +200,9 @@ print_device(const char *resource, /* I - SCSI device */
        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
@@ -217,8 +210,8 @@ print_device(const char *resource,  /* I - SCSI device */
 
       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);
       }
index b27e298618578a5db1c9cd9403ada5e38795b546..f996ed55525cc250684df97e00619e5fa3ccf00a 100644 (file)
@@ -109,8 +109,7 @@ print_device(const char *resource,  /* I - SCSI device */
 
   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);
   }
 
@@ -148,16 +147,13 @@ print_device(const char *resource,        /* I - SCSI device */
 
       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);
       }
     }
@@ -223,10 +219,9 @@ print_device(const char *resource, /* I - SCSI device */
        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
@@ -234,8 +229,8 @@ print_device(const char *resource,  /* I - SCSI device */
 
       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);
       }
index 32115bf0a6184eba20da424199add083f746a2ed..f13560203a07100347f1eb37d5d72d2f77249335 100644 (file)
@@ -150,9 +150,8 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
   }
   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);
   }
 
index 114a4384bc041abc5fe8690c4552cab0e538d192..05286c8034ba228c285663e48bdf84fb414f871e 100644 (file)
@@ -170,9 +170,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   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);
   }
 
@@ -244,9 +243,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
        * 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...
@@ -259,17 +257,13 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
 
       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);
       }
     }
@@ -385,8 +379,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
              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 */
@@ -590,10 +584,9 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
       {
        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);
        }
       }
@@ -661,8 +654,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
              * 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
              {
@@ -677,8 +669,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
              }
              while (!(status & TIOCM_DSR));
 
-             _cupsLangPuts(stderr,
-                           _("DEBUG: DSR is high; writing to device...\n"));
+             fputs("DEBUG: DSR is high; writing to device...\n", stderr);
             }
        }
 
@@ -704,7 +695,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
        }
        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;
@@ -1265,7 +1256,7 @@ side_cb(int print_fd,                     /* I - Print file */
 
   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;
   }
 
index 7375b2042d05f25ba5a45cd96540e5f51fb900a1..38026c8f4231b7c4915ddc8d9c8e05427ccc34b2 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   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
@@ -312,7 +312,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
   if (argc > 2)
   {
-    _cupsLangPuts(stderr, _("Usage: snmp [host-or-ip-address]\n"));
+    fputs(_("Usage: snmp [host-or-ip-address]\n"), stderr);
     return (1);
   }
 
@@ -627,26 +627,26 @@ asn1_debug(unsigned char *buffer, /* I - Buffer */
       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;
@@ -655,15 +655,15 @@ asn1_debug(unsigned char *buffer, /* I - Buffer */
       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);
 
@@ -671,7 +671,7 @@ asn1_debug(unsigned char *buffer,   /* I - Buffer */
           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);
 
@@ -679,7 +679,7 @@ asn1_debug(unsigned char *buffer,   /* I - Buffer */
           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);
 
@@ -687,7 +687,7 @@ asn1_debug(unsigned char *buffer,   /* I - Buffer */
           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;
@@ -1619,9 +1619,9 @@ hex_debug(unsigned char *buffer,  /* I - Buffer */
   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);
@@ -1665,7 +1665,7 @@ open_snmp_socket(void)
 
   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);
@@ -1679,7 +1679,7 @@ open_snmp_socket(void)
 
   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);
@@ -1835,7 +1835,7 @@ probe_device(snmp_cache_t *device)        /* I - Device */
 
         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);
@@ -2000,7 +2000,7 @@ read_snmp_conf(const char *address)       /* I - Single address to probe */
     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"))
       {
@@ -2019,7 +2019,7 @@ read_snmp_conf(const char *address)       /* I - Single address to probe */
       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);
     }
 
@@ -2070,8 +2070,8 @@ read_snmp_response(int fd)                /* I - SNMP socket file descriptor */
   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;
   }
 
@@ -2089,8 +2089,8 @@ read_snmp_response(int fd)                /* I - SNMP socket file descriptor */
 
   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);
@@ -2262,7 +2262,7 @@ scan_devices(int fd)                      /* I - SNMP socket */
 
     if (!addrs)
     {
-      _cupsLangPrintf(stderr, _("ERROR: Unable to scan \"%s\"!\n"), address);
+      fprintf(stderr, "ERROR: Unable to scan \"%s\"!\n", address);
       continue;
     }
 
@@ -2365,8 +2365,8 @@ send_snmp_query(
 
   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;
   }
 
@@ -2384,8 +2384,8 @@ send_snmp_query(
   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));
 }
 
 
@@ -2407,8 +2407,8 @@ try_connect(http_addr_t *addr,            /* I - Socket address */
 
   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);
   }
 
index 78af4a0fa47ea32a165da556a3f8343335f2ead7..cce35ce1c56cd3ed9d092d310446a98193056500 100644 (file)
@@ -80,6 +80,9 @@ main(int  argc,                               /* I - Number of command-line arguments (6 or 7) */
                *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 */
@@ -129,9 +132,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   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);
   }
 
@@ -176,7 +178,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   * Get options, if any...
   */
 
-  waiteof = 1;
+  waiteof    = 1;
+  contimeout = 7 * 24 * 60 * 60;
 
   if ((options = strchr(resource, '?')) != NULL)
   {
@@ -234,6 +237,15 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
         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);
+      }
     }
   }
 
@@ -241,18 +253,19 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * 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);
 
@@ -272,10 +285,8 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
        * 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...
@@ -289,10 +300,19 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
       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)
@@ -300,7 +320,11 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
       }
       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);
       }
     }
@@ -308,20 +332,32 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
       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...
@@ -342,9 +378,13 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
     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)
@@ -353,9 +393,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
     * 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);
 
@@ -380,9 +419,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
        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
@@ -409,7 +447,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
     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);
 }
@@ -434,7 +472,7 @@ side_cb(int print_fd,                       /* I - Print file */
 
   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;
   }
 
index 4d77cc68fd1a9fef34ae0a2973fc8fcf37d26b43..1e6f14490cae5712a1a0b010e1b5bd7cf97a9e9f 100644 (file)
@@ -26,6 +26,7 @@
  *
  * Contents:
  *
+ *   main() - Test the device-ID functions.
  */
 
 /*
index f63111a2eee75a427c92843c69dcbfacd998899d..cabb2068336521ff299c925a78df6421c765ef4a 100644 (file)
@@ -309,10 +309,10 @@ print_device(const char *uri,             /* I - Device URI */
       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);
@@ -335,8 +335,8 @@ print_device(const char *uri,               /* I - Device URI */
       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);
@@ -351,7 +351,7 @@ print_device(const char *uri,               /* I - Device URI */
       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 */
       }
     }
@@ -393,7 +393,7 @@ print_device(const char *uri,               /* I - Device URI */
       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;
@@ -408,7 +408,7 @@ print_device(const char *uri,               /* I - Device URI */
       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;
@@ -431,7 +431,7 @@ print_device(const char *uri,               /* I - Device URI */
     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);
@@ -456,7 +456,7 @@ print_device(const char *uri,               /* I - Device URI */
        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;
        }
 
@@ -465,7 +465,7 @@ print_device(const char *uri,               /* I - Device URI */
       }
 
       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);
     }
   }
 
@@ -692,7 +692,7 @@ static Boolean find_device_callback(void *refcon, io_service_t obj)
   
   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;
@@ -704,7 +704,7 @@ static Boolean find_device_callback(void *refcon, io_service_t obj)
 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 -
@@ -871,7 +871,7 @@ static kern_return_t load_classdriver(CFStringRef driverPath, printer_interface_
 #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;
@@ -1223,7 +1223,7 @@ static void parse_options(const char *options, char *serial, UInt32 *location, B
        *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) {
@@ -1268,7 +1268,7 @@ static void setup_cfLanguage(void)
     CFRelease(lang[0]);
     CFRelease(langArray);
   } else {
-    fprintf(stderr, "DEBUG: usb: LANG environment variable missing.\n");
+    fputs("DEBUG: usb: LANG environment variable missing.\n", stderr);
   }
 }
 
@@ -1370,7 +1370,7 @@ static void run_ppc_backend(int argc, char *argv[], int fd)
     }
   }
   else {
-    fprintf(stderr, "DEBUG: usb child running i386 again\n");
+    fputs("DEBUG: usb child running i386 again\n", stderr);
     exitstatus = ENOENT;
   }
 
index b206e741a4e79d23848069aae16164f1a4ff60af..f24fa2d640cb20c18434f984301f702f048c142f 100644 (file)
@@ -103,9 +103,8 @@ print_device(const char *uri,               /* I - Device URI */
        * 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...
@@ -118,23 +117,20 @@ print_device(const char *uri,             /* I - Device URI */
 
       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);
       }
     }
@@ -174,9 +170,13 @@ print_device(const char *uri,              /* I - Device URI */
     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);
   }
 
  /*
@@ -388,9 +388,8 @@ open_device(const char *uri,                /* I - Device URI */
          * 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);
        }
@@ -410,9 +409,8 @@ open_device(const char *uri,                /* I - Device URI */
 
       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);
       }
     }
@@ -504,9 +502,8 @@ open_device(const char *uri,                /* I - Device URI */
 
       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);
       }
     }
@@ -558,7 +555,7 @@ side_cb(int print_fd,                       /* I - Print file */
 
   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;
   }
 
index d919d4d1ed81cff859250a7bb60fc442834bc8f6..d84611884663b573fb4747c139ebd0d29f51ed74 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   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
@@ -192,8 +192,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   }
   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);
   }
 
@@ -208,9 +208,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
                      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);
   }
 
@@ -246,8 +245,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
     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);
     }