summaryrefslogtreecommitdiff
path: root/src/stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stream.c')
-rw-r--r--src/stream.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/stream.c b/src/stream.c
index 286f41a..c6d2d35 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -15,7 +15,14 @@ enum { BUFFER_SIZE = 8192 };
15static void 15static void
16usage(void) 16usage(void)
17{ 17{
18 (void) fprintf(stderr, "compress [-d] infile outfile\n"); 18 (void) fprintf(stderr, "stream [-d] infile outfile\n");
19}
20
21static void
22error(const char *msg)
23{
24 perror(msg);
25 exit(EXIT_FAILURE);
19} 26}
20 27
21static void 28static void
@@ -162,10 +169,19 @@ main(int argc, char *argv[])
162 169
163 if ( argc != 2 ) { 170 if ( argc != 2 ) {
164 usage(); 171 usage();
172 return EXIT_FAILURE;
173 }
174
175 FILE *in_file = fopen(argv[0], "rb");
176 if ( in_file == NULL ) {
177 error("fopen() on in_file failed");
165 } 178 }
166 179
167 FILE *in_file = fopen(argv[0], "rb");
168 FILE *out_file = fopen(argv[1], "wb"); 180 FILE *out_file = fopen(argv[1], "wb");
181 if ( out_file == NULL ) {
182 (void) fclose(in_file);
183 error("fopen() on out_file failed");
184 }
169 185
170 if ( !decompress ) { 186 if ( !decompress ) {
171 int error = do_compress(in_file, out_file, compress_level); 187 int error = do_compress(in_file, out_file, compress_level);