]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testfile.c
Remove svn:keywords since they cause svn_load_dirs.pl to complain about every file.
[thirdparty/cups.git] / cups / testfile.c
index de50fc5e27f66647d223fa317253cddafad752c3..56f4d5a634c07bdb6484df07f3dd2e8a5b129312 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: testfile.c 4754 2005-10-08 04:01:46Z mike $"
+ * "$Id: testfile.c 177 2006-06-21 00:20:03Z jlovell $"
  *
  *   File test program for the Common UNIX Printing System (CUPS).
  *
@@ -39,7 +39,9 @@
 #include "string.h"
 #include "file.h"
 #include "debug.h"
-#include <zlib.h>
+#ifdef HAVE_LIBZ
+#  include <zlib.h>
+#endif /* HAVE_LIBZ */
 
 
 /*
@@ -57,33 +59,79 @@ int                                 /* O - Exit status */
 main(int  argc,                                /* I - Number of command-line arguments */
      char *argv[])                     /* I - Command-line arguments */
 {
-  int          status;                 /* Exit status */
+  int  status;                         /* Exit status */
+  char filename[1024];                 /* Filename buffer */
 
 
- /*
-  * Do uncompressed file tests...
-  */
+  if (argc == 1)
+  {
+   /*
+    * Do uncompressed file tests...
+    */
 
-  status = read_write_tests(0);
+    status = read_write_tests(0);
 
 #ifdef HAVE_LIBZ
- /*
-  * Do compressed file tests...
-  */
  /*
+    * Do compressed file tests...
+    */
 
-  putchar('\n');
+    putchar('\n');
 
-  status += read_write_tests(1);
+    status += read_write_tests(1);
 #endif /* HAVE_LIBZ */
 
- /*
-  * Summarize the results and return...
-  */
+   /*
+    * Test path functions...
+    */
+
+    fputs("cupsFileFind: ", stdout);
+    if (cupsFileFind("cat", "/bin", 1, filename, sizeof(filename)) &&
+       cupsFileFind("cat", "/bin:/usr/bin", 1, filename, sizeof(filename)))
+      printf("PASS (%s)\n", filename);
+    else
+    {
+      puts("FAIL");
+      status ++;
+    }
 
-  if (!status)
-    puts("\nALL TESTS PASSED!");
+   /*
+    * Summarize the results and return...
+    */
+
+    if (!status)
+      puts("\nALL TESTS PASSED!");
+    else
+      printf("\n%d TEST(S) FAILED!\n", status);
+  }
   else
-    printf("\n%d TEST(S) FAILED!\n", status);
+  {
+   /*
+    * Cat the filename on the command-line...
+    */
+
+    cups_file_t        *fp;                    /* File pointer */
+    char       line[1024];             /* Line from file */
+
+
+    if ((fp = cupsFileOpen(argv[1], "r")) == NULL)
+    {
+      perror(argv[1]);
+      status = 1;
+    }
+    else
+    {
+      status = 0;
+
+      while (cupsFileGets(fp, line, sizeof(line)))
+        puts(line);
+
+      if (!cupsFileEOF(fp))
+        perror(argv[1]);
+
+      cupsFileClose(fp);
+    }
+  }
 
   return (status);
 }
@@ -396,5 +444,5 @@ read_write_tests(int compression)   /* I - Use compression? */
 
 
 /*
- * End of "$Id: testfile.c 4754 2005-10-08 04:01:46Z mike $".
+ * End of "$Id: testfile.c 177 2006-06-21 00:20:03Z jlovell $".
  */