/*
- * "$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
* 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;
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);
* Remove the test file...
*/
- unlink(compression ? "testfile.dat.gz" : "testfile.dat");
+ if (!status)
+ unlink(compression ? "testfile.dat.gz" : "testfile.dat");
/*
* Return the test status...
/*
- * 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 $".
*/