]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - monitor/tbcp.c
Fix source file header text duplication text duplication.
[thirdparty/cups.git] / monitor / tbcp.c
index 4170d493b6ba0516125fb8df063a59b7a014f487..b708ec48f543a27caeb9302bed5ca4d7b2fd5534 100644 (file)
@@ -1,24 +1,16 @@
 /*
- * "$Id: tbcp.c 6800 2007-08-16 18:28:44Z mike $"
+ * TBCP port monitor for CUPS.
  *
- *   TBCP port monitor for CUPS.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1993-2006 by Easy Software Products.
  *
- *   Copyright 2007-2010 by Apple Inc.
- *   Copyright 1993-2006 by Easy Software Products.
+ * 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
+ * missing or damaged, see the license at "http://www.cups.org/".
  *
- *   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/".
- *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   main()    - Main entry...
- *   psgets()  - Get a line from a file.
- *   pswrite() - Write data from a file.
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
@@ -34,7 +26,7 @@
  */
 
 static char            *psgets(char *buf, size_t *bytes, FILE *fp);
-static size_t          pswrite(const char *buf, size_t bytes, FILE *fp);
+static ssize_t         pswrite(const char *buf, size_t bytes);
 
 
 /*
@@ -93,11 +85,8 @@ main(int  argc,                              /* I - Number of command-line args */
     */
 
     linelen = sizeof(line);
-    if (psgets(line, &linelen, fp) == NULL)
-    {
-      fputs("ERROR: Empty print file!\n", stderr);
-      return (1);
-    }
+    if (!psgets(line, &linelen, fp))
+      break;
 
    /*
     * Handle leading PJL fun...
@@ -138,7 +127,7 @@ main(int  argc,                             /* I - Number of command-line args */
     * Loop until we see end-of-file...
     */
 
-    while (pswrite(line, linelen, stdout) > 0)
+    while (pswrite(line, linelen) > 0)
     {
       linelen = sizeof(line);
       if (psgets(line, &linelen, fp) == NULL)
@@ -176,7 +165,7 @@ psgets(char   *buf,                 /* I  - Buffer to read into */
   bufptr = buf;
   ch     = EOF;
 
-  while ((bufptr - buf) < len)
+  while ((size_t)(bufptr - buf) < len)
   {
     if ((ch = getc(fp)) == EOF)
       break;
@@ -201,7 +190,7 @@ psgets(char   *buf,                 /* I  - Buffer to read into */
     else if (ch == '\n')
       break;
     else
-      *bufptr++ = ch;
+      *bufptr++ = (char)ch;
   }
 
  /*
@@ -210,8 +199,8 @@ psgets(char   *buf,                 /* I  - Buffer to read into */
 
   if (ch == '\n' || ch == '\r')
   {
-    if ((bufptr - buf) < len)
-      *bufptr++ = ch;
+    if ((size_t)(bufptr - buf) < len)
+      *bufptr++ = (char)ch;
     else
       ungetc(ch, fp);
   }
@@ -221,7 +210,7 @@ psgets(char   *buf,                 /* I  - Buffer to read into */
   */
 
   *bufptr = '\0';
-  *bytes  = bufptr - buf;
+  *bytes  = (size_t)(bufptr - buf);
 
   if (ch == EOF && bufptr == buf)
     return (NULL);
@@ -234,10 +223,9 @@ psgets(char   *buf,                        /* I  - Buffer to read into */
  * 'pswrite()' - Write data from a file.
  */
 
-static size_t                          /* O - Number of bytes written */
+static ssize_t                         /* O - Number of bytes written */
 pswrite(const char *buf,               /* I - Buffer to write */
-        size_t     bytes,              /* I - Bytes to write */
-       FILE       *fp)                 /* I - File to write to */
+        size_t     bytes)              /* I - Bytes to write */
 {
   size_t       count;                  /* Remaining bytes */
 
@@ -276,10 +264,5 @@ pswrite(const char *buf,           /* I - Buffer to write */
          break;
     }
 
-  return (bytes);
+  return ((ssize_t)bytes);
 }
-
-
-/*
- * End of "$Id: tbcp.c 6800 2007-08-16 18:28:44Z mike $".
- */