diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-07-17 08:37:24 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-07-17 08:37:24 +0200 |
| commit | c73b06b03a3f43256fb1e071553af91fa6d6a825 (patch) | |
| tree | 4068d456343726f616e64ffa37e36a76c920d1b5 /src/simple.c | |
| parent | 0823979013457bc1dfae1087e027e154852b79d5 (diff) | |
| download | use-zlib-c73b06b03a3f43256fb1e071553af91fa6d6a825.tar.gz use-zlib-c73b06b03a3f43256fb1e071553af91fa6d6a825.tar.bz2 use-zlib-c73b06b03a3f43256fb1e071553af91fa6d6a825.zip | |
Fehlerbehandlung in den Beispielprogrammen verbessert
Diffstat (limited to 'src/simple.c')
| -rw-r--r-- | src/simple.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/simple.c b/src/simple.c index da79562..be92977 100644 --- a/src/simple.c +++ b/src/simple.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | static void | 12 | static void |
| 13 | usage(void) | 13 | usage(void) |
| 14 | { | 14 | { |
| 15 | (void) fprintf(stderr, "compress [-d] infile outfile\n"); | 15 | (void) fprintf(stderr, "simple [-d] infile outfile\n"); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | static void | 18 | static void |
| @@ -142,10 +142,19 @@ main(int argc, char *argv[]) | |||
| 142 | 142 | ||
| 143 | if ( argc != 2 ) { | 143 | if ( argc != 2 ) { |
| 144 | usage(); | 144 | usage(); |
| 145 | return EXIT_FAILURE; | ||
| 146 | } | ||
| 147 | |||
| 148 | FILE *in_file = fopen(argv[0], "rb"); | ||
| 149 | if ( in_file == NULL ) { | ||
| 150 | error("fopen() on in_file failed"); | ||
| 145 | } | 151 | } |
| 146 | 152 | ||
| 147 | FILE *in_file = fopen(argv[0], "rb"); | ||
| 148 | FILE *out_file = fopen(argv[1], "wb"); | 153 | FILE *out_file = fopen(argv[1], "wb"); |
| 154 | if ( out_file == NULL ) { | ||
| 155 | (void) fclose(in_file); | ||
| 156 | error("fopen() on out_file failed"); | ||
| 157 | } | ||
| 149 | 158 | ||
| 150 | if ( !decompress ) { | 159 | if ( !decompress ) { |
| 151 | do_compress(in_file, out_file, compress_level); | 160 | do_compress(in_file, out_file, compress_level); |
