]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testfile.c
Import CUPS v2.0.3
[thirdparty/cups.git] / cups / testfile.c
index 6543e0a2f9e6ee5e016e1b984edc4ce128ba9b46..16e52c3e69b084147a4423771c4316a962fc8cac 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: testfile.c 11558 2014-02-06 18:33:34Z msweet $"
+ * "$Id: testfile.c 12578 2015-03-30 19:07:29Z msweet $"
  *
  * File test program for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -205,14 +205,14 @@ main(int  argc,                           /* I - Number of command-line arguments */
     * Cat the filename on the command-line...
     */
 
-    char       line[1024];             /* Line from file */
+    char       line[8192];             /* Line from file */
 
     if ((fp = cupsFileOpen(argv[1], "r")) == NULL)
     {
       perror(argv[1]);
       status = 1;
     }
-    else
+    else if (argc == 2)
     {
       status = 0;
 
@@ -224,6 +224,21 @@ main(int  argc,                            /* I - Number of command-line arguments */
 
       cupsFileClose(fp);
     }
+    else
+    {
+      status = 0;
+      ssize_t bytes;
+
+      while ((bytes = cupsFileRead(fp, line, sizeof(line))) > 0)
+        printf("%s: %d bytes\n", argv[1], (int)bytes);
+
+      if (cupsFileEOF(fp))
+        printf("%s: EOF\n", argv[1]);
+      else
+        perror(argv[1]);
+
+      cupsFileClose(fp);
+    }
   }
 
   return (status);
@@ -798,7 +813,8 @@ read_write_tests(int compression)   /* I - Use compression? */
   * Remove the test file...
   */
 
-  unlink(compression ? "testfile.dat.gz" : "testfile.dat");
+  if (!status)
+    unlink(compression ? "testfile.dat.gz" : "testfile.dat");
 
  /*
   * Return the test status...
@@ -809,5 +825,5 @@ read_write_tests(int compression)   /* I - Use compression? */
 
 
 /*
- * End of "$Id: testfile.c 11558 2014-02-06 18:33:34Z msweet $".
+ * End of "$Id: testfile.c 12578 2015-03-30 19:07:29Z msweet $".
  */