- outfile = fopen(argv[argc-1], "wb");
- if (outfile == NULL) {
- fprintf(stderr, "Error. Cannot open output file %s", argv[argc-1]);
- return -1;
+ infiles = calloc(argc-2, sizeof(FILE*));
+ for (uint16_t i = 0; i < argc-2; i++) {
+ infiles[i] = fopen(argv[i+1], "rb");
+ if (infiles[i] == NULL) {
+ fprintf(stderr, "Error. Cannot open input file %s", argv[i+1]);
+ return(EXIT_FAILURE);
+ }
+ }
+ outfile = fopen(argv[argc-1], "wb");
+ if (outfile == NULL) {
+ fprintf(stderr, "Error. Cannot open output file %s", argv[argc-1]);
+ return(EXIT_FAILURE);
+ }
+ return zlib_compress(infiles, argc-2, outfile);