]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Added support for job-media-sheets-completed attribute, which is updated
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 2 May 2000 19:29:23 +0000 (19:29 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 2 May 2000 19:29:23 +0000 (19:29 +0000)
as pages are printed for the job.

Added support for the job-billing attribute, which is logged in the page_log
file as needed.

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

scheduler/ipp.c
scheduler/job.c
scheduler/job.h
scheduler/log.c

index 51fbc556b350269b819162b9c1b6e2f16ac40aa0..916d0acb86af3f9b83f4df2dc25d1b4b219bdab2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c,v 1.63 2000/04/29 12:35:57 mike Exp $"
+ * "$Id: ipp.c,v 1.64 2000/05/02 19:29:22 mike Exp $"
  *
  *   IPP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -1672,6 +1672,8 @@ create_job(client_t        *con,  /* I - Client connection */
   ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id);
   job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM,
                              "job-state", IPP_JOB_STOPPED);
+  job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER,
+                              "job-media-sheets-completed", 0);
   ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL,
                printer_uri);
   ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL,
@@ -1689,7 +1691,7 @@ create_job(client_t        *con,  /* I - Client connection */
 
     if (attr == NULL)
     {
-      attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job->sheets",
+      attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-sheets",
                            2, NULL, NULL);
       attr->values[0].string.text = strdup(printer->job_sheets[0]);
       attr->values[1].string.text = strdup(printer->job_sheets[1]);
@@ -3225,6 +3227,8 @@ print_job(client_t        *con,           /* I - Client connection */
   ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id);
   job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM,
                              "job-state", IPP_JOB_PENDING);
+  job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER,
+                              "job-media-sheets-completed", 0);
   ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL,
                printer_uri);
   ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL,
@@ -4764,5 +4768,5 @@ validate_job(client_t        *con,        /* I - Client connection */
 
 
 /*
- * End of "$Id: ipp.c,v 1.63 2000/04/29 12:35:57 mike Exp $".
+ * End of "$Id: ipp.c,v 1.64 2000/05/02 19:29:22 mike Exp $".
  */
index b85200732937e1b77e2d0f84a38a69904b7230c8..ead3bc82ee771bb6b6bd1c7acaedc65b61a65481 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: job.c,v 1.64 2000/04/27 12:24:58 mike Exp $"
+ * "$Id: job.c,v 1.65 2000/05/02 19:29:22 mike Exp $"
  *
  *   Job management routines for the Common UNIX Printing System (CUPS).
  *
@@ -1254,6 +1254,7 @@ void
 UpdateJob(job_t *job)          /* I - Job to check */
 {
   int          bytes;          /* Number of bytes read */
+  int          copies;         /* Number of copies printed */
   char         *lineptr,       /* Pointer to end of line in buffer */
                *message;       /* Pointer to message text */
   int          loglevel;       /* Log level for message */
@@ -1330,9 +1331,15 @@ UpdateJob(job_t *job)            /* I - Job to check */
     if (loglevel == L_PAGE)
     {
      /*
-      * Page message; send the message to the page_log file...
+      * Page message; send the message to the page_log file and update the
+      * job sheet count...
       */
 
+      if (!sscanf(message, "%*d%d", &copies))
+        job->sheets->values[0].integer ++;
+      else
+        job->sheets->values[0].integer += copies;
+
       LogPage(job, message);
     }
     else
@@ -2322,5 +2329,5 @@ start_process(const char *command,        /* I - Full path to command */
 
 
 /*
- * End of "$Id: job.c,v 1.64 2000/04/27 12:24:58 mike Exp $".
+ * End of "$Id: job.c,v 1.65 2000/05/02 19:29:22 mike Exp $".
  */
index 6ebc60b1f4da1055d61217ccc397262c4adc8437..e5a333b21ebf5d6df0c5cbd541e4bb4826f5ff26 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: job.h,v 1.16 2000/05/01 19:50:27 mike Exp $"
+ * "$Id: job.h,v 1.17 2000/05/02 19:29:22 mike Exp $"
  *
  *   Print job definitions for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -32,6 +32,7 @@ typedef struct job_str
   int          id,                     /* Job ID */
                priority;               /* Job priority */
   ipp_attribute_t *state;              /* Job state */
+  ipp_attribute_t *sheets;             /* job-media-sheets-completed */
   char         username[33];           /* Printing user */
   char         dest[IPP_MAX_NAME];     /* Destination printer or class */
   cups_ptype_t dtype;                  /* Destination type (class/remote bits) */
@@ -84,5 +85,5 @@ extern const char *ValidateDest(const char *resource, cups_ptype_t *dtype);
 
 
 /*
- * End of "$Id: job.h,v 1.16 2000/05/01 19:50:27 mike Exp $".
+ * End of "$Id: job.h,v 1.17 2000/05/02 19:29:22 mike Exp $".
  */
index d2ebb838aba2d0bd73780bc92697711c980b96af..b926f19cba6fa66532a42b4f98f4d8216cb80053 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: log.c,v 1.8 2000/03/21 18:35:38 mike Exp $"
+ * "$Id: log.c,v 1.9 2000/05/02 19:29:23 mike Exp $"
  *
  *   Log file routines for the Common UNIX Printing System (CUPS).
  *
@@ -189,8 +189,12 @@ LogPage(job_t       *job,  /* I - Job being printed */
 {
   char         filename[1024], /* Name of error log file */
                backname[1024]; /* Backup filename */
+  ipp_attribute_t *billing;    /* job-billing attribute */
 
 
+
+  billing = ippFindAttribute(job->attrs, "job-billing", IPP_TAG_TEXT);
+
 #ifdef HAVE_VSYSLOG
  /*
   * See if we are logging pages via syslog...
@@ -198,8 +202,8 @@ LogPage(job_t       *job,   /* I - Job being printed */
 
   if (strcmp(PageLog, "syslog") == 0)
   {
-    syslog(LOG_INFO, "PAGE %s %s %d %s", job->printer->name, job->username,
-           job->id, page);
+    syslog(LOG_INFO, "PAGE %s %s %d %s %s", job->printer->name, job->username,
+           job->id, page, billing ? billing->values[0].string.text : "");
 
     return (1);
   }
@@ -256,11 +260,12 @@ LogPage(job_t       *job, /* I - Job being printed */
  /*
   * Print a page log entry of the form:
   *
-  *    printer job-id user [DD/MON/YYYY:HH:MM:SS +TTTT] page num-copies
+  *    printer job-id user [DD/MON/YYYY:HH:MM:SS +TTTT] page num-copies billing
   */
 
-  fprintf(PageFile, "%s %s %d %s %s\n", job->printer->name, job->username,
-          job->id, get_datetime(time(NULL)), page);
+  fprintf(PageFile, "%s %s %d %s %s %s\n", job->printer->name, job->username,
+          job->id, get_datetime(time(NULL)), page,
+         billing ? billing->values[0].string.text : "");
   fflush(PageFile);
 
   return (1);
@@ -432,5 +437,5 @@ get_datetime(time_t t)              /* I - Time value */
 
 
 /*
- * End of "$Id: log.c,v 1.8 2000/03/21 18:35:38 mike Exp $".
+ * End of "$Id: log.c,v 1.9 2000/05/02 19:29:23 mike Exp $".
  */