X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=sample%2Fzread.c;fp=sample%2Fzread.c;h=8492dc9c8ee75ae43acec483b15a4e558518badc;hb=c7e61475680fa226bd9b8bdd469cd66914e630f5;hp=3163d42a55892578a86e76b0172587c0f17b3728;hpb=800deb09b422a73c1212233a93839a223ff59678;p=debian%2Fgzip diff --git a/sample/zread.c b/sample/zread.c index 3163d42..8492dc9 100644 --- a/sample/zread.c +++ b/sample/zread.c @@ -1,4 +1,6 @@ +#include #include +#include /* Trivial example of reading a gzip'ed file or gzip'ed standard input * using stdio functions fread(), getc(), etc... fseek() is not supported. @@ -19,7 +21,7 @@ int main(argc, argv) if (argc < 1 || argc > 2) { fprintf(stderr, "usage: %s [file[.gz]]\n", argv[0]); - exit(1); + exit(EXIT_FAILURE); } strcpy(cmd, "gzip -dc "); /* use "gzip -c" for zwrite */ if (argc == 2) { @@ -28,13 +30,13 @@ int main(argc, argv) infile = popen(cmd, "r"); /* use "w" for zwrite */ if (infile == NULL) { fprintf(stderr, "%s: popen('%s', 'r') failed\n", argv[0], cmd); - exit(1); + exit(EXIT_FAILURE); } /* Read one byte using getc: */ n = getc(infile); if (n == EOF) { pclose(infile); - exit(0); + exit(EXIT_SUCCESS); } putchar(n); @@ -46,8 +48,8 @@ int main(argc, argv) } if (pclose(infile) != 0) { fprintf(stderr, "%s: pclose failed\n", argv[0]); - exit(1); + exit(EXIT_FAILURE); } - exit(0); + exit(EXIT_SUCCESS); return 0; /* just to make compiler happy */ }