]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/statbuf.c
Block cups-files.conf directives (Issue #5530)
[thirdparty/cups.git] / scheduler / statbuf.c
index c4959cfbefe4ce386cfb3a38f945f6fae7bb81f4..db9d98d41d5c1b6fe43d58a8afc9a6e74463bcc8 100644 (file)
@@ -1,23 +1,10 @@
 /*
- * "$Id: statbuf.c 7674 2008-06-18 23:18:32Z mike $"
+ * Status buffer routines for the CUPS scheduler.
  *
- *   Status buffer routines for the Common UNIX Printing System (CUPS)
- *   scheduler.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
- *   Copyright 2007-2008 by Apple Inc.
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   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/".
- *
- * Contents:
- *
- *   cupsdStatBufDelete() - Destroy a status buffer.
- *   cupsdStatBufNew()    - Create a new status buffer.
- *   cupsdStatBufUpdate() - Update the status buffer.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -57,7 +44,7 @@ cupsdStatBufDelete(cupsd_statbuf_t *sb)       /* I - Status buffer */
  */
 
 cupsd_statbuf_t        *                       /* O - New status buffer */
-cupsdStatBufNew(int fd,                        /* I - File descriptor of pipe */
+cupsdStatBufNew(int        fd,         /* I - File descriptor of pipe */
                 const char *prefix,    /* I - Printf-style prefix string */
                ...)                    /* I - Additional args as needed */
 {
@@ -118,13 +105,11 @@ cupsdStatBufNew(int fd,                   /* I - File descriptor of pipe */
  */
 
 char *                                 /* O - Line from buffer, "", or NULL */
-cupsdStatBufUpdate(cupsd_statbuf_t *sb,        /* I - Status buffer */
-                   int             *loglevel,
-                                       /* O - Log level */ 
-                   char            *line,
-                                       /* I - Line buffer */
-                   int             linelen)
-                                       /* I - Size of line buffer */
+cupsdStatBufUpdate(
+    cupsd_statbuf_t *sb,               /* I - Status buffer */
+    int             *loglevel,         /* O - Log level */
+    char            *line,             /* I - Line buffer */
+    int             linelen)           /* I - Size of line buffer */
 {
   int          bytes;                  /* Number of bytes read */
   char         *lineptr,               /* Pointer to end of line in buffer */
@@ -141,8 +126,7 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb,     /* I - Status buffer */
     * No, read more data...
     */
 
-    if ((bytes = read(sb->fd, sb->buffer + sb->bufused,
-                      CUPSD_SB_BUFFER_SIZE - sb->bufused - 1)) > 0)
+    if ((bytes = read(sb->fd, sb->buffer + sb->bufused, (size_t)(CUPSD_SB_BUFFER_SIZE - sb->bufused - 1))) > 0)
     {
       sb->bufused += bytes;
       sb->buffer[sb->bufused] = '\0';
@@ -261,6 +245,11 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb,    /* I - Status buffer */
     *loglevel = CUPSD_LOG_STATE;
     message   = sb->buffer + 6;
   }
+  else if (!strncmp(sb->buffer, "JOBSTATE:", 9))
+  {
+    *loglevel = CUPSD_LOG_JOBSTATE;
+    message   = sb->buffer + 9;
+  }
   else if (!strncmp(sb->buffer, "ATTR:", 5))
   {
     *loglevel = CUPSD_LOG_ATTR;
@@ -291,7 +280,7 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb,     /* I - Status buffer */
   if (sb->prefix[0])
   {
     if (*loglevel > CUPSD_LOG_NONE &&
-       (*loglevel != CUPSD_LOG_INFO || LogLevel == CUPSD_LOG_DEBUG2))
+       (*loglevel != CUPSD_LOG_INFO || LogLevel >= CUPSD_LOG_DEBUG))
     {
      /*
       * General status message; send it to the error_log file...
@@ -302,7 +291,7 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb,     /* I - Status buffer */
       else
        cupsdLogMessage(*loglevel, "%s %s", sb->prefix, message);
     }
-    else if (*loglevel < CUPSD_LOG_NONE && LogLevel == CUPSD_LOG_DEBUG2)
+    else if (*loglevel < CUPSD_LOG_NONE && LogLevel >= CUPSD_LOG_DEBUG)
       cupsdLogMessage(CUPSD_LOG_DEBUG2, "%s %s", sb->prefix, sb->buffer);
   }
 
@@ -310,7 +299,7 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb,     /* I - Status buffer */
   * Copy the message to the line buffer...
   */
 
-  strlcpy(line, message, linelen);
+  strlcpy(line, message, (size_t)linelen);
 
  /*
   * Copy over the buffer data we've used up...
@@ -326,8 +315,3 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb,     /* I - Status buffer */
 
   return (line);
 }
-
-
-/*
- * End of "$Id: statbuf.c 7674 2008-06-18 23:18:32Z mike $".
- */