buf[4096], /* Buffer */
*ptr, /* Pointer into buffer */
*end; /* End of buffer data */
- off_t pos; /* File position for start of buffer */
+ off_t pos, /* Position in file */
+ bufpos; /* File position for start of buffer */
#ifdef HAVE_LIBZ
z_stream stream; /* (De)compression stream */
if (!fp || fp->mode != 'w')
{
- DEBUG_puts(" Attempt to flush a read-only file...");
+ DEBUG_puts("cupsFileFlush: Attempt to flush a read-only file...");
return (-1);
}
bytes = (ssize_t)(fp->ptr - fp->buf);
- DEBUG_printf((" Flushing %ld bytes...\n", (long)bytes));
+ DEBUG_printf(("cupsFileFlush: Flushing " CUPS_LLFMT " bytes...\n",
+ CUPS_LLCAST bytes));
if (bytes > 0)
{
* Range check input...
*/
+ DEBUG_printf(("cupsFileGetChar(fp=%p)\n", fp));
+
if (!fp || (fp->mode != 'r' && fp->mode != 's'))
{
DEBUG_puts("cupsFileGetChar: Bad arguments!");
DEBUG_printf(("cupsFileGetChar: Returning %d...\n", *(fp->ptr) & 255));
+ fp->pos ++;
+
+ DEBUG_printf(("cupsFileGetChar: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (*(fp->ptr)++ & 255);
}
* Range check input...
*/
+ DEBUG_printf(("cupsFileGetConf(fp=%p, buf=%p, buflen=" CUPS_LLFMT
+ ", value=%p, linenum=%p)\n", fp, buf, CUPS_LLCAST buflen,
+ value, linenum));
+
if (!fp || (fp->mode != 'r' && fp->mode != 's') ||
!buf || buflen < 2 || !value)
{
* Range check input...
*/
+ DEBUG_printf(("cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")\n",
+ fp, buf, CUPS_LLCAST buflen));
+
if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 3)
return (0);
break;
*ptr++ = ch = *(fp->ptr)++;
+ fp->pos ++;
if (ch == '\r')
{
break;
if (*(fp->ptr) == '\n')
+ {
*ptr++ = *(fp->ptr)++;
+ fp->pos ++;
+ }
break;
}
*ptr = '\0';
+ DEBUG_printf(("cupsFileGetLine: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (ptr - buf);
}
* Range check input...
*/
+ DEBUG_printf(("cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")\n", fp, buf,
+ CUPS_LLCAST buflen));
+
if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2)
return (NULL);
}
ch = *(fp->ptr)++;
+ fp->pos ++;
if (ch == '\r')
{
break;
if (*(fp->ptr) == '\n')
- fp->ptr ++;
+ {
+ fp->ptr ++;
+ fp->pos ++;
+ }
break;
}
*ptr = '\0';
+ DEBUG_printf(("cupsFileGets: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (buf);
}
* existing file, "a" to append to an existing file or create a new file,
* or "s" to open a socket connection.
*
- * When opening for writing ("w") or appending ("a"), an optional number from
- * 1 to 9 can be supplied which enables Flate compression of the file.
+ * When opening for writing ("w"), an optional number from 1 to 9 can be
+ * supplied which enables Flate compression of the file. Compression is
+ * not supported for the "a" (append) mode.
*
* When opening a socket connection, the filename is a string of the form
* "address:port" or "hostname:port". The socket will make an IPv4 or IPv6
*/
if (!filename || !mode ||
- (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's'))
+ (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's') ||
+ (*mode == 'a' && isdigit(mode[1] & 255)))
return (NULL);
/*
/*
* 'cupsFileOpenFd()' - Open a CUPS file using a file descriptor.
*
- * The "mode" parameter can be "r" to read, "a" or "w" to write, or "s"
- * to treat the file descriptor as a bidirectional socket connection.
+ * The "mode" parameter can be "r" to read, "w" to write, "a" to append,
+ * or "s" to treat the file descriptor as a bidirectional socket connection.
*
- * When opening for writing ("w") or appending ("a"), an optional number from
- * 1 to 9 can be supplied which enables Flate compression of the file.
+ * When opening for writing ("w"), an optional number from 1 to 9 can be
+ * supplied which enables Flate compression of the file. Compression is
+ * not supported for the "a" (append) mode.
*
* @since CUPS 1.2@
*/
*/
if (fd < 0 || !mode ||
- (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's'))
+ (*mode != 'r' && *mode != 'w' && *mode != 'a' && *mode != 's') ||
+ (*mode == 'a' && isdigit(mode[1] & 255)))
return (NULL);
/*
switch (*mode)
{
- case 'w' :
case 'a' :
+ fp->pos = lseek(fd, 0, SEEK_END);
+
+ case 'w' :
fp->mode = 'w';
fp->ptr = fp->buf;
fp->end = fp->buf + sizeof(fp->buf);
return (-1);
if (fp->mode == 's')
- return (cups_write(fp, buf, bytes));
+ {
+ if (cups_write(fp, buf, bytes) < 0)
+ return (-1);
+
+ fp->pos += bytes;
+
+ DEBUG_printf(("cupsFilePrintf: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
+ return (bytes);
+ }
if ((fp->ptr + bytes) > fp->end)
if (cupsFileFlush(fp))
fp->pos += bytes;
+ DEBUG_printf(("cupsFilePrintf: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
if (bytes > sizeof(fp->buf))
{
#ifdef HAVE_LIBZ
fp->pos ++;
+ DEBUG_printf(("cupsFilePutChar: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (0);
}
fp->pos += bytes;
+ DEBUG_printf(("cupsFilePuts: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (bytes);
}
fp->pos += bytes;
+ DEBUG_printf(("cupsFilePuts: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
if (bytes > sizeof(fp->buf))
{
#ifdef HAVE_LIBZ
ssize_t count; /* Bytes read */
- DEBUG_printf(("cupsFileRead(fp=%p, buf=%p, bytes=%ld)\n", fp, buf,
- (long)bytes));
+ DEBUG_printf(("cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf,
+ CUPS_LLCAST bytes));
/*
* Range check input...
if (fp->ptr >= fp->end)
if (cups_fill(fp) <= 0)
{
- DEBUG_printf((" cups_fill() returned -1, total=%d\n", (int)total));
+ DEBUG_printf(("cupsFileRead: cups_fill() returned -1, total=" CUPS_LLFMT "\n",
+ CUPS_LLCAST total));
if (total > 0)
return ((ssize_t)total);
memcpy(buf, fp->ptr, count);
fp->ptr += count;
+ fp->pos += count;
+
+ DEBUG_printf(("cupsFileRead: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
/*
* Update the counts for the last read...
* Return the total number of bytes read...
*/
- DEBUG_printf((" total=%d\n", (int)total));
+ DEBUG_printf(("cupsFileRead: total=%d\n", (int)total));
return ((ssize_t)total);
}
* Range check input...
*/
+ DEBUG_printf(("cupsFileRewind(fp=%p)\n", fp));
+ DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
if (!fp || fp->mode != 'r')
return (-1);
* Handle special cases...
*/
- if (fp->pos == 0)
+ if (fp->bufpos == 0)
{
/*
* No seeking necessary...
*/
+ fp->pos = 0;
+
if (fp->ptr)
{
fp->ptr = fp->buf;
fp->eof = 0;
}
+ DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (0);
}
lseek(fp->fd, 0, SEEK_SET);
- fp->pos = 0;
- fp->ptr = NULL;
- fp->end = NULL;
- fp->eof = 0;
+ fp->bufpos = 0;
+ fp->pos = 0;
+ fp->ptr = NULL;
+ fp->end = NULL;
+ fp->eof = 0;
+
+ DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
return (0);
}
ssize_t bytes; /* Number bytes in buffer */
- DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")\n", fp, pos));
- DEBUG_printf((" fp->pos=" CUPS_LLFMT "\n", fp->pos));
- DEBUG_printf((" fp->ptr=%p, fp->end=%p\n", fp->ptr, fp->end));
+ DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")\n", fp,
+ CUPS_LLCAST pos));
+ DEBUG_printf(("cupsFileSeek: fp->pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+ DEBUG_printf(("cupsFileSeek: fp->ptr=%p, fp->end=%p\n", fp->ptr, fp->end));
/*
* Range check input...
if (pos == 0)
return (cupsFileRewind(fp));
- if (fp->pos == pos)
+ if (fp->ptr)
{
- /*
- * No seeking necessary...
- */
+ bytes = (ssize_t)(fp->end - fp->buf);
- if (fp->ptr)
+ if (pos >= fp->bufpos && pos < (fp->bufpos + bytes))
{
- fp->ptr = fp->buf;
+ /*
+ * No seeking necessary...
+ */
+
+ fp->pos = pos;
+ fp->ptr = fp->buf + pos - fp->bufpos;
fp->eof = 0;
- }
- return (pos);
+ return (pos);
+ }
}
#ifdef HAVE_LIBZ
#endif /* HAVE_LIBZ */
/*
- * Figure out the number of bytes in the current buffer, and then
- * see if we are outside of it...
+ * Seek forwards or backwards...
*/
- if (fp->ptr)
- bytes = (ssize_t)(fp->end - fp->buf);
- else
- bytes = 0;
-
fp->eof = 0;
- DEBUG_printf((" bytes=" CUPS_LLFMT "\n", CUPS_LLCAST bytes));
+ DEBUG_printf(("cupsFileSeek: bytes=" CUPS_LLFMT "\n", CUPS_LLCAST bytes));
- if (pos < fp->pos)
+ if (pos < fp->bufpos)
{
/*
* Need to seek backwards...
*/
- DEBUG_puts(" SEEK BACKWARDS");
+ DEBUG_puts("cupsFileSeek: SEEK BACKWARDS");
#ifdef HAVE_LIBZ
if (fp->compressed)
inflateEnd(&fp->stream);
lseek(fp->fd, 0, SEEK_SET);
- fp->pos = 0;
- fp->ptr = NULL;
- fp->end = NULL;
+ fp->bufpos = 0;
+ fp->pos = 0;
+ fp->ptr = NULL;
+ fp->end = NULL;
while ((bytes = cups_fill(fp)) > 0)
- if (pos >= fp->pos && pos < (fp->pos + bytes))
+ if (pos >= fp->bufpos && pos < (fp->bufpos + bytes))
break;
if (bytes <= 0)
return (-1);
- fp->ptr = fp->buf + pos - fp->pos;
+ fp->ptr = fp->buf + pos - fp->bufpos;
+ fp->pos = pos;
}
else
#endif /* HAVE_LIBZ */
{
- fp->pos = lseek(fp->fd, pos, SEEK_SET);
- fp->ptr = NULL;
- fp->end = NULL;
+ fp->bufpos = lseek(fp->fd, pos, SEEK_SET);
+ fp->pos = fp->bufpos;
+ fp->ptr = NULL;
+ fp->end = NULL;
- DEBUG_printf((" lseek() returned %ld...\n", (long)fp->pos));
+ DEBUG_printf(("cupsFileSeek: lseek() returned " CUPS_LLFMT "...\n",
+ CUPS_LLCAST fp->pos));
}
}
- else if (pos >= (fp->pos + bytes))
+ else
{
/*
* Need to seek forwards...
*/
- DEBUG_puts(" SEEK FORWARDS");
+ DEBUG_puts("cupsFileSeek: SEEK FORWARDS");
#ifdef HAVE_LIBZ
if (fp->compressed)
{
while ((bytes = cups_fill(fp)) > 0)
{
- if (pos >= fp->pos && pos < (fp->pos + bytes))
+ if (pos >= fp->bufpos && pos < (fp->bufpos + bytes))
break;
}
if (bytes <= 0)
return (-1);
- fp->ptr = fp->buf + pos - fp->pos;
+ fp->ptr = fp->buf + pos - fp->bufpos;
+ fp->pos = pos;
}
else
#endif /* HAVE_LIBZ */
{
- fp->pos = lseek(fp->fd, pos, SEEK_SET);
- fp->ptr = NULL;
- fp->end = NULL;
+ fp->bufpos = lseek(fp->fd, pos, SEEK_SET);
+ fp->pos = fp->bufpos;
+ fp->ptr = NULL;
+ fp->end = NULL;
- DEBUG_printf((" lseek() returned " CUPS_LLFMT "...\n", fp->pos));
+ DEBUG_printf(("cupsFileSeek: lseek() returned " CUPS_LLFMT "...\n",
+ CUPS_LLCAST fp->pos));
}
}
- else
- {
- /*
- * Just reposition the current pointer, since we have the right
- * range...
- */
- DEBUG_puts(" SEEK INSIDE BUFFER");
-
- fp->ptr = fp->buf + pos - fp->pos;
- }
+ DEBUG_printf(("cupsFileSeek: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
return (fp->pos);
}
off_t /* O - File position */
cupsFileTell(cups_file_t *fp) /* I - CUPS file */
{
+ DEBUG_printf(("cupsFileTell(fp=%p)\n", fp));
+ DEBUG_printf(("cupsFileTell: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return (fp ? fp->pos : 0);
}
* Range check...
*/
+ DEBUG_printf(("cupsFileUnlock(fp=%p)\n", fp));
+
if (!fp || fp->mode == 's')
return (-1);
* Range check input...
*/
+ DEBUG_printf(("cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n",
+ fp, buf, CUPS_LLCAST bytes));
+
if (!fp || !buf || bytes < 0 || (fp->mode != 'w' && fp->mode != 's'))
return (-1);
fp->pos += (off_t)bytes;
+ DEBUG_printf(("cupsFileWrite: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
return ((ssize_t)bytes);
}
fp->pos += (off_t)bytes;
+ DEBUG_printf(("cupsFileWrite: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+
if (bytes > sizeof(fp->buf))
{
#ifdef HAVE_LIBZ
const char *buf, /* I - Buffer */
size_t bytes) /* I - Number bytes */
{
- DEBUG_printf(("cups_compress(fp=%p, buf=%p, bytes=%ld)\n", fp, buf,
- (long)bytes));
+ DEBUG_printf(("cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT "\n", fp, buf,
+ CUPS_LLCAST bytes));
/*
* Update the CRC...
* Flush the current buffer...
*/
- DEBUG_printf((" avail_in=%d, avail_out=%d\n", fp->stream.avail_in,
- fp->stream.avail_out));
+ DEBUG_printf(("cups_compress: avail_in=%d, avail_out=%d\n",
+ fp->stream.avail_in, fp->stream.avail_out));
if (fp->stream.avail_out < (int)(sizeof(fp->cbuf) / 8))
{
DEBUG_printf(("cups_fill(fp=%p)\n", fp));
- DEBUG_printf((" fp->ptr=%p, fp->end=%p, fp->buf=%p, "
- "fp->pos=" CUPS_LLFMT ", fp->eof=%d\n",
- fp->ptr, fp->end, fp->buf, fp->pos, fp->eof));
-
- /*
- * Update the "pos" element as needed...
- */
+ DEBUG_printf(("cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, "
+ "fp->bufpos=" CUPS_LLFMT ", fp->eof=%d\n",
+ fp->ptr, fp->end, fp->buf, CUPS_LLCAST fp->bufpos, fp->eof));
if (fp->ptr && fp->end)
- fp->pos += (off_t)(fp->end - fp->buf);
+ fp->bufpos += fp->end - fp->ptr;
#ifdef HAVE_LIBZ
- DEBUG_printf((" fp->compressed=%d\n", fp->compressed));
+ DEBUG_printf(("cups_fill: fp->compressed=%d\n", fp->compressed));
while (!fp->ptr || fp->compressed)
{
* Can't read from file!
*/
- DEBUG_printf((" cups_read() returned " CUPS_LLFMT "!\n",
+ DEBUG_printf(("cups_fill: cups_read() returned " CUPS_LLFMT "!\n",
CUPS_LLCAST bytes));
return (-1);
ssize_t total; /* Total bytes read */
+ DEBUG_printf(("cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf,
+ CUPS_LLCAST bytes));
+
/*
* Loop until we read at least 0 bytes...
*/
total = read(fp->fd, buf, bytes);
#endif /* WIN32 */
+ DEBUG_printf(("cups_read: total=" CUPS_LLFMT "\n", CUPS_LLCAST total));
+
if (total >= 0)
break;
ssize_t count; /* Count this time */
- DEBUG_printf(("cups_write(fp=%p, buf=%p, bytes=%ld)\n", fp, buf,
- (long)bytes));
+ DEBUG_printf(("cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf,
+ CUPS_LLCAST bytes));
/*
* Loop until all bytes are written...
count = write(fp->fd, buf, bytes);
#endif /* WIN32 */
+ DEBUG_printf(("cups_write: count=" CUPS_LLFMT "\n", CUPS_LLCAST count));
+
if (count < 0)
{
/*
return (-1);
}
- DEBUG_printf((" count=%ld\n", (long)count));
-
/*
* Update the counts for the last write call...
*/
* Local functions...
*/
+static int random_tests(void);
static int read_write_tests(int compression);
status += read_write_tests(1);
#endif /* HAVE_LIBZ */
+ /*
+ * Do uncompressed random I/O tests...
+ */
+
+ status = random_tests();
+
/*
* Test fdopen and close without reading...
*/
pipe(fds);
close(fds[1]);
- fputs("cupsFileOpenFd(fd, \"r\"): ", stdout);
+ fputs("\ncupsFileOpenFd(fd, \"r\"): ", stdout);
fflush(stdout);
if ((fdfile = cupsFileOpenFd(fds[0], "r")) == NULL)
* Test path functions...
*/
- fputs("cupsFileFind: ", stdout);
+ fputs("\ncupsFileFind: ", stdout);
#ifdef WIN32
if (cupsFileFind("notepad.exe", "C:/WINDOWS", 1, filename, sizeof(filename)) &&
cupsFileFind("notepad.exe", "C:/WINDOWS;C:/WINDOWS/SYSTEM32", 1, filename, sizeof(filename)))
}
+/*
+ * 'random_tests()' - Do random access tests.
+ */
+
+static int /* O - Status */
+random_tests(void)
+{
+ int status, /* Status of tests */
+ pass, /* Current pass */
+ count, /* Number of records read */
+ record, /* Current record */
+ num_records; /* Number of records */
+ ssize_t pos, /* Position in file */
+ expected; /* Expected position in file */
+ cups_file_t *fp; /* File */
+ char buffer[512]; /* Data buffer */
+
+
+ /*
+ * Run 4 passes, each time appending to a data file and then reopening the
+ * file for reading to validate random records in the file.
+ */
+
+ for (status = 0, pass = 0; pass < 4; pass ++)
+ {
+ /*
+ * cupsFileOpen(append)
+ */
+
+ printf("\ncupsFileOpen(append %d): ", pass);
+
+ if ((fp = cupsFileOpen("testfile.dat", "a")) == NULL)
+ {
+ printf("FAIL (%s)\n", strerror(errno));
+ status ++;
+ break;
+ }
+ else
+ puts("PASS");
+
+ /*
+ * cupsFileTell()
+ */
+
+ expected = 256 * sizeof(buffer) * pass;
+
+ fputs("cupsFileTell(): ", stdout);
+ if ((pos = cupsFileTell(fp)) != expected)
+ {
+ printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n",
+ CUPS_LLCAST pos, CUPS_LLCAST expected);
+ status ++;
+ break;
+ }
+ else
+ puts("PASS");
+
+ /*
+ * cupsFileWrite()
+ */
+
+ fputs("cupsFileWrite(256 512-byte records): ", stdout);
+ for (record = 0; record < 256; record ++)
+ {
+ memset(buffer, record, sizeof(buffer));
+ if (cupsFileWrite(fp, buffer, sizeof(buffer)) < sizeof(buffer))
+ break;
+ }
+
+ if (record < 256)
+ {
+ printf("FAIL (%d: %s)\n", record, strerror(errno));
+ status ++;
+ break;
+ }
+ else
+ puts("PASS");
+
+ /*
+ * cupsFileTell()
+ */
+
+ expected += 256 * sizeof(buffer);
+
+ fputs("cupsFileTell(): ", stdout);
+ if ((pos = cupsFileTell(fp)) != expected)
+ {
+ printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n",
+ CUPS_LLCAST pos, CUPS_LLCAST expected);
+ status ++;
+ break;
+ }
+ else
+ puts("PASS");
+
+ cupsFileClose(fp);
+
+ /*
+ * cupsFileOpen(read)
+ */
+
+ printf("\ncupsFileOpen(read %d): ", pass);
+
+ if ((fp = cupsFileOpen("testfile.dat", "r")) == NULL)
+ {
+ printf("FAIL (%s)\n", strerror(errno));
+ status ++;
+ break;
+ }
+ else
+ puts("PASS");
+
+ /*
+ * cupsFileSeek, cupsFileRead
+ */
+
+ fputs("cupsFileSeek(), cupsFileRead(): ", stdout);
+
+ for (num_records = (pass + 1) * 256, count = (pass + 1) * 256,
+ record = rand() % num_records;
+ count > 0;
+ count --, record = (record + (rand() & 31) - 16 + num_records) %
+ num_records)
+ {
+ /*
+ * The last record is always the first...
+ */
+
+ if (count == 1)
+ record = 0;
+
+ /*
+ * Try reading the data for the specified record, and validate the
+ * contents...
+ */
+
+ expected = sizeof(buffer) * record;
+
+ if ((pos = cupsFileSeek(fp, expected)) != expected)
+ {
+ printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n",
+ CUPS_LLCAST pos, CUPS_LLCAST expected);
+ status ++;
+ break;
+ }
+ else
+ {
+ if (cupsFileRead(fp, buffer, sizeof(buffer)) != sizeof(buffer))
+ {
+ printf("FAIL (%s)\n", strerror(errno));
+ status ++;
+ break;
+ }
+ else if ((buffer[0] & 255) != (record & 255) ||
+ memcmp(buffer, buffer + 1, sizeof(buffer) - 1))
+ {
+ printf("FAIL (Bad Data - %d instead of %d)\n", buffer[0] & 255,
+ record & 255);
+ status ++;
+ break;
+ }
+ }
+ }
+
+ if (count == 0)
+ puts("PASS");
+
+ cupsFileClose(fp);
+ }
+
+ /*
+ * Remove the test file...
+ */
+
+ unlink("testfile.dat");
+
+ /*
+ * Return the test status...
+ */
+
+ return (status);
+}
+
+
/*
* 'read_write_tests()' - Perform read/write tests.
*/
read_write_tests(int compression) /* I - Use compression? */
{
int i; /* Looping var */
- cups_file_t *fp; /* First file */
+ cups_file_t *fp; /* File */
int status; /* Exit status */
char line[1024], /* Line from file */
*value; /* Directive value from line */
status ++;
}
+ /*
+ * Remove the test file...
+ */
+
+ unlink(compression ? "testfile.dat.gz" : "testfile.dat");
+
/*
* Return the test status...
*/