]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testfile.c
Merge changes from CUPS 1.5svn-r8950.
[thirdparty/cups.git] / cups / testfile.c
index 2140765c971d1392d9f749830b858e3f9cff4a33..c3643448224fec313a8d40254d5992ff65572550 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: testfile.c 6962 2007-09-17 20:35:47Z mike $"
+ * "$Id: testfile.c 7720 2008-07-11 22:46:21Z mike $"
  *
  *   File test program for the Common UNIX Printing System (CUPS).
  *
 #ifdef HAVE_LIBZ
 #  include <zlib.h>
 #endif /* HAVE_LIBZ */
-#include <unistd.h>
+#ifdef WIN32
+#  include <io.h>
+#else
+#  include <unistd.h>
+#endif /* WIN32 */
 #include <fcntl.h>
 
 
@@ -60,8 +64,10 @@ main(int  argc,                              /* I - Number of command-line arguments */
   int          status;                 /* Exit status */
   char         filename[1024];         /* Filename buffer */
   cups_file_t  *fp;                    /* File pointer */
+#ifndef WIN32
   int          fds[2];                 /* Open file descriptors */
   cups_file_t  *fdfile;                /* File opened with cupsFileOpenFd() */
+#endif /* !WIN32 */
   int          count;                  /* Number of lines in file */
 
 
@@ -87,8 +93,9 @@ main(int  argc,                               /* I - Number of command-line arguments */
     * Do uncompressed random I/O tests...
     */
 
-    status = random_tests();
+    status += random_tests();
 
+#ifndef WIN32
    /*
     * Test fdopen and close without reading...
     */
@@ -122,6 +129,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
       puts("PASS");
     }
+#endif /* !WIN32 */
 
    /*
     * Count lines in euc-jp.txt, rewind, then count again.
@@ -367,9 +375,9 @@ random_tests(void)
     fputs("cupsFileSeek(), cupsFileRead(): ", stdout);
 
     for (num_records = (pass + 1) * 256, count = (pass + 1) * 256,
-             record = rand() % num_records;
+             record = CUPS_RAND() % num_records;
          count > 0;
-        count --, record = (record + (rand() & 31) - 16 + num_records) %
+        count --, record = (record + (CUPS_RAND() & 31) - 16 + num_records) %
                            num_records)
     {
      /*
@@ -463,14 +471,10 @@ read_write_tests(int compression) /* I - Use compression? */
   * Initialize the write buffer with random data...
   */
 
-#ifdef WIN32
-  srand((unsigned)time(NULL));
-#else
-  srand(time(NULL));
-#endif /* WIN32 */
+  CUPS_SRAND(time(NULL));
 
   for (i = 0; i < (int)sizeof(writebuf); i ++)
-    writebuf[i] = rand();
+    writebuf[i] = CUPS_RAND();
 
  /*
   * cupsFileOpen(write)
@@ -752,7 +756,7 @@ read_write_tests(int compression)   /* I - Use compression? */
 
     fputs("cupsFileGetChar(partial line): ", stdout);
 
-    for (i = 0; i < strlen(partial_line); i ++)
+    for (i = 0; i < (int)strlen(partial_line); i ++)
       if ((byte = cupsFileGetChar(fp)) < 0)
         break;
       else if (byte != partial_line[i])
@@ -815,5 +819,5 @@ read_write_tests(int compression)   /* I - Use compression? */
 
 
 /*
- * End of "$Id: testfile.c 6962 2007-09-17 20:35:47Z mike $".
+ * End of "$Id: testfile.c 7720 2008-07-11 22:46:21Z mike $".
  */