📄 bff.c
字号:
/// @ingroup AMD_BOOTLOADER/// @file bff.c/// @brief The tool is used to combine two files into one.////// @remarks The format should be\n/// bff SourceFile2 SourceFile1 TargetFile [size for SourceFile1]\n/// The default size for SourceFile1 is 512/// @bug /// @version $Version$/// @section history History/// 24-Dec-03 Add size option for combining bootloader for AXD method/////<<<<<Include#include <stdio.h>//>>>>>Include//<<<<<< Private Macro//>>>>>> Private Macro//<<<<<< Private Structure//>>>>>> Private Structure//<<<<<< Global VariableFILE *in1,*in2, *outfile;//>>>>>> Global Variable//<<<<<Private Function Declearation//>>>>>Private Function Declearation//<<<<<Bodyint CombineFirstFile( unsigned int size){ int number; unsigned char rData[size]; number=fread(rData,sizeof(char),size,in2); fwrite(rData, sizeof(char), size, outfile); return number;}///Main functionint main (int argc, char *argv[]){ int i,num; unsigned int readSize = 512; unsigned char bData; if (argc < 4 || argc > 5) { printf("Usage: bff file2 file1 targetfile [size]\n \ Example: bff bootloader.bin flashloader.bin bootfromflash.bin\n"); return 0; } if (!(in1 = fopen(argv[1],"rb"))) { printf("Input file open error !\n"); return 0; } if (!(in2 = fopen(argv[2],"rb"))) { printf("Input file open error !\n"); fclose(in1); return 0; } if (!(outfile = fopen(argv[3],"wb"))) { printf("Output file open error !\n"); fclose(in1); fclose(in2); return 0; } if( argc == 5 ) readSize = atoi(argv[4]); num = CombineFirstFile( readSize ); printf("read %d chars from %s\n",num,argv[2]); if( argc == 4 ) { /* For old use */ bData = 0; for (i=num; i<0x1F8; i++) fwrite(&bData, sizeof(char), 1, outfile); } while( fread(&bData,sizeof(char),1,in1) > 0) fwrite(&bData,sizeof(char),1, outfile); fclose(outfile); fclose(in1); fclose(in2); printf("\nConversion done.\n"); return 0;}//>>>>>Body
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -