本文整理汇总了C++中IRP::writeHex方法的典型用法代码示例。如果您正苦于以下问题:C++ IRP::writeHex方法的具体用法?C++ IRP::writeHex怎么用?C++ IRP::writeHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRP
的用法示例。
在下文中一共展示了IRP::writeHex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
if (argc<2)
{
usage:
printf("Usage MakeHex IrpFile {OutFile}\n");
return -1;
}
IRP Irp;
char* arg1=*(++argv);
if (arg1[0]=='-' && arg1[2]==0)
{
char s = toupper(arg1[1]);
if (s=='H')
Irp.m_numberFormat = 1;
else if (s=='B')
Irp.m_numberFormat = 2;
else
goto usage;
arg1 = *(++argv);
if (--argc == 1)
goto usage;
}
if (argc>3)
goto usage;
FILE *InFile = fopen(arg1, "r");
if (!InFile)
{
printf("Unable to open \"%s\"\n", arg1);
return -1;
}
if (! Irp.readIrpFile(InFile) )
{
printf("IRP file \"%s\" not processed\n");
return -1;
}
char *OutName;
if (argc==3)
{
OutName = argv[1];
}
else
{
char *tmp = strrchr(arg1, '.');
if (!tmp)
{
tmp = arg1 + strlen(arg1);
}
int len = tmp - arg1;
OutName = new char [len+5];
memcpy(OutName, arg1, len);
strcpy(OutName+len, ".hex");
}
FILE *OutFile = fopen(OutName, "w");
if (!OutFile)
{
printf("Unable to create \"%s\"\n", OutName);
return -1;
}
Irp.writeHex(OutFile);
fclose(OutFile);
return 0;
}