?? binsrc.c
字號:
#include <stdio.h>
#include <ctype.h>
unsigned char buffer[0x2000];
main(argc,argv)
int argc;
char *argv[];
{
FILE *infile,*outfile;
int tmp = 0;
long size,ltmp;
unsigned char *pc;
if (argc != 4)
{
printf("\nUsage: BINSRC [InFile] [OutFile] [Name]\n");
exit(1);
}
if (!(infile = fopen(argv[1],"rb")))
{ printf("Can't open source file: %s\n",argv[1]); exit(1); }
// Get the file size
fseek( infile, 0, SEEK_END );
size = ftell( infile );
rewind( infile );
printf("Input File : %s\n",argv[1]);
printf("File Size : %ld\n",size);
if (!(outfile = fopen(argv[2],"wb")))
{ printf("Can't open output file: %s\n",argv[2]); exit(1); }
printf("Output File: %s\n",argv[2]);
fprintf( outfile, "#define %s_SIZE %ld\r\n", argv[3], size );
fprintf( outfile, "unsigned char %s[] = {\r\n ", argv[3] );
tmp = 0;
while( size )
{
if( size >= sizeof(buffer) )
ltmp = sizeof(buffer);
else
ltmp = size;
fread(buffer,1,(short)ltmp,infile);
pc = buffer;
size -= ltmp;
while( ltmp-- )
{
if( size || ltmp )
{
fprintf(outfile,"0x%02X, ",*pc++);
if( !(++tmp % 12) )
fprintf(outfile,"\r\n ");
}
else
fprintf(outfile,"0x%02X };\r\n",*pc++);
}
}
fclose(infile);
fclose(outfile);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -