From d1a8285f818eb7e5c3d6a05709ea21a808490b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 19 Mar 2018 19:55:58 +0100 Subject: New upstream version 5.1.0 --- app/tools/bin2c.c | 126 ------------------------------------------------------ 1 file changed, 126 deletions(-) delete mode 100644 app/tools/bin2c.c (limited to 'app/tools/bin2c.c') diff --git a/app/tools/bin2c.c b/app/tools/bin2c.c deleted file mode 100644 index bb619dc..0000000 --- a/app/tools/bin2c.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -BIN2C V1.0 CODED BY CHRISTIAN PADOVANO ON 17-MAY-1995 -this little utility translates a binary file in a useful C structure -that can be included in a C source. -to contact me write to EMAIL: [[Email Removed]] -*/ - - -#include -#include -#include -#include - -#define BUF_LEN 1024 -#define LINE 12 - -/* Tell u the file size in bytes */ - -long int filesize( FILE *fp ) -{ - long int save_pos, size_of_file; - - save_pos = ftell( fp ); - fseek( fp,0L, SEEK_END ); - size_of_file = ftell( fp ); - fseek( fp, save_pos, SEEK_SET ); - return( size_of_file ); -} - - -/* lower chars --> upper chars */ - -void Upper_chars(char *buffer) -{ - unsigned int c; - - for (c=0; c <= strlen(buffer)-1; c++) - *(buffer+c)=toupper( *( buffer+c) ); -} - - -int main( int argc, char **argv ) -{ - FILE *source,*dest; - char Dummy[BUF_LEN]; - int buffer; - int c; - - if ( (argc < 4) ) - { - - if ( ( argc == 2 ) && ( strcmp(argv[1],"-h")==0 ) ) - { - puts(" - <<< BIN2C V1.0 >>> by Christian Padovano - \n"); - puts("USAGE: bin2C "); - puts("\n = name of the C structure in the destination file name.\n"); - puts(" = without extension '.h' it will be added by program."); - return EXIT_SUCCESS; - } - else - { - puts("Bad arguments !!! You must give me all the parameters !!!!\n" - "Type 'bin2c -h' to read the help !!!! "); - return EXIT_SUCCESS; - } - - } - - if( (source=fopen( argv[1], "rb" )) == NULL ) - { - printf("ERROR : I can't find source file %s\n",argv[1]); - return EXIT_FAILURE; - } - - strcpy(Dummy,argv[2]); - strcat(Dummy,".h"); /* add suffix .h to target name */ - - if( (dest=fopen( Dummy, "wb+" )) == NULL ) - { - printf("ERROR : I can't open destination file %s\n",Dummy); - return EXIT_FAILURE; - } - - - strcpy(Dummy,argv[3]); - Upper_chars(Dummy); /* lower to upper chars */ - strcat(Dummy,"_LEN"); /* add the suffix _LEN to the struct name */ - /* for the #define stantment */ - - - /* It writes the header information */ - fprintf( dest, "\n#define %s %ld\n\n", Dummy, filesize(source) ); - fprintf( dest, "static unsigned char %s[] = {\n ", argv[3] ); - - if( ferror( dest )) - { - printf( "ERROR writing on target file: %s\n",argv[2] ); - return EXIT_FAILURE; - } - - - c = 0; - buffer = fgetc( source ); - - while( buffer != EOF ) - { - fprintf(dest,"0x%02x", buffer); - - buffer = fgetc( source ); - if( !feof(source)) - fputc(',', dest); - - c++; - if(c == LINE ) { - fprintf(dest,"\n "); - c = 0; - } - - } - - fprintf(dest,"\n};\n\n"); - - return EXIT_SUCCESS; -} - - -- cgit v1.2.3