cups-lpd: compatibility with PLP

H. Blischke h.blischke at srz-berlin.de
Thu Mar 26 08:49:58 PDT 2009


> Patrick Powll's PLP (Public Line Printer) behaves, even if configured to use "Berkeley protocol", slightly different from what RFC 1179, as pointed out in the following syslog snippet:
>
>
> Mar  6 21:21:29 obelix cups-lpd[20107]: connect from clienthost
> Mar  6 21:21:29 obelix cups-lpd[20107]: Connection from clienthost
> Mar  6 21:21:29 obelix cups-lpd[20107]: Receive print job for printername
> Mar  6 21:21:29 obelix cups-lpd[20107]: Receive print job for printername
> Mar  6 21:21:29 obelix cups-lpd[20107]: [03] 254631 dfA589clienthost
> Mar  6 21:21:29 obelix cups-lpd[20107]: [02] 137 cfZ589clienthost
> Mar  6 21:21:29 obelix cups-lpd[20107]: [00] (* final EOD *)
> Mar  6 21:21:29 obelix cups-lpd[20107]: Control file:
> Mar  6 21:21:29 obelix cups-lpd[20107]:         D1236370629
> Mar  6 21:21:29 obelix cups-lpd[20107]:         Hclienthost
> Mar  6 21:21:29 obelix cups-lpd[20107]:         Proot
> Mar  6 21:21:29 obelix cups-lpd[20107]:         N/tmp/temp.manu
> Mar  6 21:21:29 obelix cups-lpd[20107]:         J/tmp/temp.manu
> Mar  6 21:21:29 obelix cups-lpd[20107]:         CZ
> Mar  6 21:21:29 obelix cups-lpd[20107]:         fdfA589clienthost
> Mar  6 21:21:29 obelix cups-lpd[20107]:         UdfA589clienthost
> Mar  6 21:21:30 obelix cups-lpd[20107]: Print file - job ID = 275915
> Mar  6 21:21:30 obelix cups-lpd[20107]: Closing connection
>
> The whole bunch of data and control files is followd by a single zero byte as a final EOF indicator.
>
> The attached patch account for this and additionally implents a "-d" command line switch to force diagnostic output to syslog.
>
>
>

--- orig.cups-lpd.c     Wed Aug  8 23:09:31 2007
+++ cups-lpd.c  Tue Dec 18 15:48:41 2007
@@ -1,5 +1,6 @@
 /*
  * "$Id: cups-lpd.c 6781 2007-08-08 21:09:31Z mike $"
+ * "$Id: cups-lpd.c 6781 2007-12-18 15:49_15Z /Bl  $"
  *
  *   Line Printer Daemon interface for the Common UNIX Printing System (CUPS).
  *
@@ -97,6 +98,10 @@
                           int longstatus);
 static char    *smart_gets(char *s, int len, FILE *fp);

+/*
+ * Globals
+ */
+static int debug = 0;                  /* Default: no additional debug messages */

 /*
  * 'main()' - Process an incoming LPD request...
@@ -163,6 +168,10 @@
             }
            break;

+       case 'd' : /* /Bl's debug switch */
+           debug = 1;
+           break;
+
         case 'n' : /* Don't do hostname lookups */
            hostlookups = 0;
            break;
@@ -942,8 +951,16 @@
   {
     if (strlen(line) < 2)
     {
-      status = 1;
-      break;
+      if (line[0] == 0x00)  /* Additional EOD byte for the (list of) data file(s) (PLP or SINIX spool hacked by /Bl) */
+      {
+        if (debug) syslog(LOG_DEBUG, "[00] (* final EOD *)");
+        continue;
+      }
+      else
+      {
+        status = 1;
+        break;
+      }
     }

     command = line[0];
@@ -968,6 +985,7 @@
            status = 1;
            break;
          }
+         if (debug) syslog(LOG_DEBUG, "[02] %s %s", count, name);

           if (control[0])
          {
@@ -1026,6 +1044,7 @@
          }

          strlcpy(data[num_data], name, sizeof(data[0]));
+          if (debug) syslog(LOG_DEBUG, "[03] %s %s", count, name);

           if ((fd = cupsTempFd(temp[num_data], sizeof(temp[0]))) < 0)
          {
@@ -1129,6 +1148,7 @@
       user[0]  = '\0';
       doccount = 0;

+      if (debug) syslog(LOG_DEBUG, "Control file:");
       while (smart_gets(line, sizeof(line), fp) != NULL)
       {
        /*
@@ -1135,6 +1155,7 @@
         * Process control lines...
        */

+        if (debug) syslog(LOG_DEBUG, "\t%s", line);
        switch (line[0])
        {
          case 'J' : /* Job name */






More information about the cups-devel mailing list