- outfile = fopen(argv[argc-1], "wb");
- if (outfile == NULL) {
- fprintf(stderr, "Error. Cannot open output file %s", argv[argc-1]);
- return -1;
+ bool hardnested_mode = false;
+ int num_input_files = 0;
+ if (!strcmp(argv[1], "-t")) { // hardnested table
+ if (argc != 4) {
+ usage();
+ return(EXIT_FAILURE);
+ }
+ hardnested_mode = true;
+ num_input_files = 1;
+ } else {
+ num_input_files = argc-2;
+ }
+ infiles = calloc(num_input_files, sizeof(FILE*));
+ for (uint16_t i = 0; i < num_input_files; i++) {
+ infiles[i] = fopen(argv[i+(hardnested_mode?2:1)], "rb");
+ if (infiles[i] == NULL) {
+ fprintf(stderr, "Error. Cannot open input file %s", argv[i+(hardnested_mode?2: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, num_input_files, outfile, hardnested_mode);