]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Back-port accounting changes from CUPS 2.3 (Issue #5439)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Fri, 16 Nov 2018 21:05:40 +0000 (16:05 -0500)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Fri, 16 Nov 2018 21:05:40 +0000 (16:05 -0500)
CHANGES.md
doc/help/man-cupsd-logs.html
man/cupsd-logs.man
scheduler/job.c
test/run-stp-tests.sh

index bb76c7db700550c387c90f9e3850365b4087332b..004e801df731475e5c5a77676fd1fcbf570ff51d 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES - 2.2.10 - 2018-11-14
+CHANGES - 2.2.10 - 2018-11-16
 =============================
 
 
@@ -8,6 +8,7 @@ Changes in CUPS v2.2.10
 - The generated PPD files for IPP Everywhere printers did not contain the
   cupsManualCopies keyword (Issue #5433)
 - Kerberos credentials might be truncated (Issue #5435)
+- Incorporated the page accounting changes from CUPS 2.3 (Issue #5439)
 
 
 Changes in CUPS v2.2.9
index 30ee2af66ed27687e1f09c1dd142c252497fd615..e90dd405bf35818c7cabc80e61f3c03f076f2aba 100644 (file)
@@ -142,25 +142,17 @@ The <i>level</i> field contains the type of message:
 <p>The <i>message</i> field contains a free-form textual message.
 Messages from job filters are prefixed with "[Job NNN]" where "NNN" is the job ID.
 <h3><a name="PAGE_LOG_FILE_FORMAT">Page Log File Format</a></h3>
-The <i>page_log</i> file lists each page or group of pages that are sent to a printer.
+The <i>page_log</i> file lists the total number of pages (sheets) that are printed.
 By default, each line contains the following information:
 <pre class="man">
 
-    <i>printer user job-id date-time page-number num-copies job-billing
-      job-originating-host-name job-name media sides</i>
-
-    <i>printer user job-id date-time </i><b>total </b><i>num-impressions job-billing
+    <i>printer user job-id date-time </i><b>total </b><i>num-sheets job-billing
       job-originating-host-name job-name media sides</i>
 
 </pre>
-For example the entries for a two page job called "myjob" might look like:
+For example the entry for a two page job called "myjob" might look like:
 <pre class="man">
 
-    DeskJet root 1 [20/May/1999:19:21:05 +0000] 1 1 acme-123
-      localhost myjob na_letter_8.5x11in one-sided
-    DeskJet root 1 [20/May/1999:19:21:05 +0000] 2 1 acme-123
-      localhost myjob na_letter_8.5x11in one-sided
-
     DeskJet root 1 [20/May/1999:19:21:06 +0000] total 2 acme-123
       localhost myjob na_letter_8.5x11in one-sided
 
@@ -174,9 +166,7 @@ If you send a job to a printer class, this field will contain the name of the pr
 <p>The <i>job-id</i> field contains the job number of the page being printed.
 <p>The <i>date-time</i> field contains the date and time of when the page started printing.
 The format of this field is identical to the data-time field in the <i>access_log</i> file.
-<p>The <i>page-number</i> and <i>num-copies</i> fields contain the page number and number of copies being printed of that page.
-For printers that cannot produce copies on their own, the num-copies field will always be 1.
-<p>Lines containing the keyword "total" have a <i>num-impressions</i> field instead which provides the total number of impressions (sides) that have been printed on for the job.
+<p>The <i>num-sheets</i> field provides the total number of pages (sheets) that have been printed on for the job.
 <p>The <i>job-billing</i> field contains a copy of the job-billing or job-account-id attributes provided with the IPP Create-Job or Print-Job requests or "-" if neither was provided.
 <p>The <i>job-originating-host-name</i> field contains the hostname or IP address of the client that printed the job.
 <p>The <i>job-name</i> field contains a copy of the job-name attribute provided with the IPP Create-Job or Print-Job requests or "-" if none was provided.
@@ -188,7 +178,7 @@ For printers that cannot produce copies on their own, the num-copies field will
 <a href="man-cups-files.conf.html?TOPIC=Man+Pages"><b>cups-files.conf</b>(5),</a>
 CUPS Online Help (<a href="http://localhost:631/help">http://localhost:631/help</a>)
 <h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
-Copyright &copy; 2007-2017 by Apple Inc.
+Copyright &copy; 2007-2018 by Apple Inc.
 
 </body>
 </html>
index d12fab35f165671504f2d03930bf8e002dedf510..8672afa09d323358767eb807d214f8b7c861aebd 100644 (file)
@@ -1,8 +1,8 @@
 .\"
 .\" cupsd-logs man page for CUPS.
 .\"
-.\" Copyright 2007-2014 by Apple Inc.
-.\" Copyright 1997-2006 by Easy Software Products.
+.\" Copyright © 2007-2018 by Apple Inc.
+.\" Copyright © 1997-2006 by Easy Software Products.
 .\"
 .\" These coded instructions, statements, and computer programs are the
 .\" property of Apple Inc. and are protected by Federal copyright
@@ -10,7 +10,7 @@
 .\" which should have been included with this file.  If this file is
 .\" file is missing or damaged, see the license at "http://www.cups.org/".
 .\"
-.TH cupsd-logs 5 "CUPS" "11 June 2014" "Apple Inc."
+.TH cupsd-logs 5 "CUPS" "8 November 2017" "Apple Inc."
 .SH NAME
 cupsd\-logs \- cupsd log files (access_log, error_log, and page_log)
 .SH DESCRIPTION
@@ -176,25 +176,17 @@ The \fIdate-time\fR field contains the date and time of when the page started pr
 The \fImessage\fR field contains a free-form textual message.
 Messages from job filters are prefixed with "[Job NNN]" where "NNN" is the job ID.
 .SS PAGE LOG FILE FORMAT
-The \fIpage_log\fR file lists each page or group of pages that are sent to a printer.
+The \fIpage_log\fR file lists the total number of pages (sheets) that are printed.
 By default, each line contains the following information:
 .nf
 
-    \fIprinter user job-id date-time page-number num-copies job-billing
-      job-originating-host-name job-name media sides\fR
-
-    \fIprinter user job-id date-time \fBtotal \fInum-impressions job-billing
+    \fIprinter user job-id date-time \fBtotal \fInum-sheets job-billing
       job-originating-host-name job-name media sides\fR
 
 .fi
-For example the entries for a two page job called "myjob" might look like:
+For example the entry for a two page job called "myjob" might look like:
 .nf
 
-    DeskJet root 1 [20/May/1999:19:21:05 +0000] 1 1 acme-123
-      localhost myjob na_letter_8.5x11in one-sided
-    DeskJet root 1 [20/May/1999:19:21:05 +0000] 2 1 acme-123
-      localhost myjob na_letter_8.5x11in one-sided
-
     DeskJet root 1 [20/May/1999:19:21:06 +0000] total 2 acme-123
       localhost myjob na_letter_8.5x11in one-sided
 
@@ -213,10 +205,7 @@ The \fIjob-id\fR field contains the job number of the page being printed.
 The \fIdate-time\fR field contains the date and time of when the page started printing.
 The format of this field is identical to the data-time field in the \fIaccess_log\fR file.
 .LP
-The \fIpage-number\fR and \fInum-copies\fR fields contain the page number and number of copies being printed of that page.
-For printers that cannot produce copies on their own, the num-copies field will always be 1.
-.LP
-Lines containing the keyword "total" have a \fInum-impressions\fR field instead which provides the total number of impressions (sides) that have been printed on for the job.
+The \fInum-sheets\fR field provides the total number of pages (sheets) that have been printed on for the job.
 .LP
 The \fIjob-billing\fR field contains a copy of the job-billing or job-account-id attributes provided with the IPP Create-Job or Print-Job requests or "-" if neither was provided.
 .LP
@@ -233,4 +222,4 @@ The \fIsides\fR field contains a copy of the sides attribute provided with the I
 .BR cups-files.conf (5),
 CUPS Online Help (http://localhost:631/help)
 .SH COPYRIGHT
-Copyright \[co] 2007-2017 by Apple Inc.
+Copyright \[co] 2007-2018 by Apple Inc.
index 554e09215da9ee443241fd0b476e4cfc0c21470d..3cbe56aa89f541a04af5aa5a60593772238d6c38 100644 (file)
@@ -1850,6 +1850,8 @@ cupsdLoadJob(cupsd_job_t *job)            /* I - Job */
 
   if (!job->impressions)
     job->impressions = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-impressions-completed", 0);
+  if (!job->sheets)
+    job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-media-sheets-completed", 0);
 
   if (!job->priority)
   {
@@ -3154,6 +3156,13 @@ finalize_job(cupsd_job_t *job,           /* I - Job */
   cupsdStatBufDelete(job->status_buffer);
   job->status_buffer = NULL;
 
+ /*
+  * Log the final impression (page) count...
+  */
+
+  snprintf(buffer, sizeof(buffer), "total %d", ippGetInteger(job->impressions, 0));
+  cupsdLogPage(job, buffer);
+
  /*
   * Process the exit status...
   */
@@ -4993,7 +5002,6 @@ void
 update_job(cupsd_job_t *job)           /* I - Job to check */
 {
   int          i;                      /* Looping var */
-  int          copies;                 /* Number of copies printed */
   char         message[CUPSD_SB_BUFFER_SIZE],
                                        /* Message text */
                *ptr;                   /* Pointer update... */
@@ -5031,6 +5039,10 @@ update_job(cupsd_job_t *job)             /* I - Job to check */
 
     if (loglevel == CUPSD_LOG_PAGE)
     {
+      int      impressions = ippGetInteger(job->impressions, 0);
+                               /* Number of impressions printed */
+      int      delta;          /* Number of impressions added */
+
      /*
       * Page message; send the message to the page_log file and update the
       * job sheet count...
@@ -5038,51 +5050,57 @@ update_job(cupsd_job_t *job)            /* I - Job to check */
 
       cupsdLogJob(job, CUPSD_LOG_DEBUG, "PAGE: %s", message);
 
-      if (job->impressions)
+      if (!_cups_strncasecmp(message, "total ", 6))
       {
-        if (!_cups_strncasecmp(message, "total ", 6))
-       {
-        /*
-         * Got a total count of pages from a backend or filter...
-         */
+       /*
+       * Got a total count of pages from a backend or filter...
+       */
+
+       int total = atoi(message + 6);  /* Total impressions */
 
-         copies = atoi(message + 6);
-         copies -= ippGetInteger(job->impressions, 0); /* Just track the delta */
+       if (total > impressions)
+       {
+         delta       = total - impressions;
+         impressions = total;
        }
-       else if (!sscanf(message, "%*d%d", &copies))
+       else
+         delta = 0;
+      }
+      else
+      {
+       /*
+        * Add the number of copies to the impression count...
+        */
+
+       int copies;                     /* Number of copies */
+
+       if (!sscanf(message, "%*d%d", &copies) || copies <= 0)
          copies = 1;
 
-        ippSetInteger(job->attrs, &job->impressions, 0, ippGetInteger(job->impressions, 0) + copies);
-        job->dirty = 1;
-       cupsdMarkDirty(CUPSD_DIRTY_JOBS);
+        delta = copies;
+       impressions += copies;
       }
 
+      if (job->impressions)
+        ippSetInteger(job->attrs, &job->impressions, 0, impressions);
+
       if (job->sheets)
       {
-        if (!_cups_strncasecmp(message, "total ", 6))
-       {
-        /*
-         * Got a total count of pages from a backend or filter...
-         */
-
-         copies = atoi(message + 6);
-         copies -= ippGetInteger(job->sheets, 0); /* Just track the delta */
-       }
-       else if (!sscanf(message, "%*d%d", &copies))
-         copies = 1;
+       const char *sides = ippGetString(ippFindAttribute(job->attrs, "sides", IPP_TAG_KEYWORD), 0, NULL);
 
-        ippSetInteger(job->attrs, &job->sheets, 0, ippGetInteger(job->sheets, 0) + copies);
-        job->dirty = 1;
-       cupsdMarkDirty(CUPSD_DIRTY_JOBS);
+        if (sides && strcmp(sides, "one-sided"))
+          ippSetInteger(job->attrs, &job->sheets, 0, impressions / 2);
+       else
+          ippSetInteger(job->attrs, &job->sheets, 0, impressions);
 
-       if (job->printer->page_limit)
-         cupsdUpdateQuota(job->printer, job->username, copies, 0);
+       cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "Printed %d page(s).", ippGetInteger(job->sheets, 0));
       }
 
-      cupsdLogPage(job, message);
+      job->dirty = 1;
+      cupsdMarkDirty(CUPSD_DIRTY_JOBS);
 
-      if (job->sheets)
-       cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "Printed %d page(s).", ippGetInteger(job->sheets, 0));
+      if (job->printer->page_limit)
+       cupsdUpdateQuota(job->printer, job->username, delta, 0);
     }
     else if (loglevel == CUPSD_LOG_JOBSTATE)
     {
index 8a263fbf118dbc977e57cfb1d501452d8654a537..fc7e2525ccee1a4f2a6998be82e36f03fbeb657f 100755 (executable)
@@ -886,7 +886,7 @@ fi
 
 # Paged printed on Test3
 count=`$GREP '^Test3 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
-expected=4
+expected=2
 if test $count != $expected; then
        echo "FAIL: Printer 'Test3' produced $count page(s), expected $expected."
        echo "    <p>FAIL: Printer 'Test3' produced $count page(s), expected $expected.</p>" >>$strfile