]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/fpga_compress.c
Merge pull request #638 from grauerfuchs/master
[proxmark3-svn] / client / fpga_compress.c
index 2ef883db9369342b9b57f25bec89ce53cf4ca9ee..bd1e8be2d374ce1912ea14dde76ea87ef51e5de0 100644 (file)
 
 static void usage(void)
 {
-       fprintf(stderr, "Usage: fpga_compress <infile1> <infile2> ... <infile_n> <outfile>\n");
-       fprintf(stderr, "          Combine n FPGA bitstream files and compress them into one.\n\n");
-       fprintf(stderr, "       fpga_compress -d <infile> <outfile>");
-       fprintf(stderr, "          Decompress <infile>. Write result to <outfile>");
-       fprintf(stderr, "       fpga_compress -t <infile> <outfile>");
-       fprintf(stderr, "          Compress hardnested table <infile>. Write result to <outfile>");
+       fprintf(stdout, "Usage: fpga_compress <infile1> <infile2> ... <infile_n> <outfile>\n");
+       fprintf(stdout, "          Combine n FPGA bitstream files and compress them into one.\n\n");
+       fprintf(stdout, "       fpga_compress -d <infile> <outfile>");
+       fprintf(stdout, "          Decompress <infile>. Write result to <outfile>");
+       fprintf(stdout, "       fpga_compress -t <infile> <outfile>");
+       fprintf(stdout, "          Compress hardnested table <infile>. Write result to <outfile>");
 }
 
 
@@ -108,7 +108,7 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
 
                for(uint16_t j = 0; j < num_infiles; j++) {
                        for(uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) {
-                               c = fgetc(infile[j]);
+                               c = (uint8_t)fgetc(infile[j]);
                                if (!feof(infile[j])) {
                                        fpga_config[i++] = c;
                                } else if (num_infiles > 1) {
@@ -150,7 +150,7 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
                ret = deflate(&compressed_fpga_stream, Z_FINISH);
        }
        
-       fprintf(stderr, "compressed %u input bytes to %lu output bytes\n", i, compressed_fpga_stream.total_out);
+       fprintf(stdout, "compressed %u input bytes to %lu output bytes\n", i, compressed_fpga_stream.total_out);
 
        if (ret != Z_STREAM_END) {
                fprintf(stderr, "Error in deflate(): %i %s\n", ret, compressed_fpga_stream.msg);
@@ -297,9 +297,9 @@ int main(int argc, char **argv)
                }
                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");
+                       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]);
+                               fprintf(stderr, "Error. Cannot open input file %s", argv[i+(hardnested_mode?2:1)]);
                                return(EXIT_FAILURE);
                        }
                }
Impressum, Datenschutz