|
|
@ -21,6 +21,8 @@
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (argc<2)
|
|
|
|
if (argc<2)
|
|
|
@ -29,23 +31,36 @@ int main(int argc, char* argv[])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char sDir[256];
|
|
|
|
|
|
|
|
char sPath[256];
|
|
|
|
|
|
|
|
char sName[256];
|
|
|
|
|
|
|
|
char sExt[256];
|
|
|
|
|
|
|
|
_splitpath (argv[1], sDir, sPath, sName, sExt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char sOutput[256];
|
|
|
|
char sOutput[256];
|
|
|
|
if (argc>2)
|
|
|
|
char *cExt = strrchr(argv[1], '.');
|
|
|
|
strcpy (sOutput, argv[2]);
|
|
|
|
char *cName = max(strrchr(argv[1], '/'), strrchr(argv[1], '\\')) + 1;
|
|
|
|
|
|
|
|
char sName[256];
|
|
|
|
|
|
|
|
strcpy(sName, cName);
|
|
|
|
|
|
|
|
if (cExt > cName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sName[cExt - cName] = '\x00';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
strcpy(sOutput, argv[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_makepath (sOutput, sDir, sPath, sName, ".cpp");
|
|
|
|
strcpy(sOutput, argv[1]);
|
|
|
|
|
|
|
|
if (cExt <= cName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cExt = sOutput + strlen(sOutput);
|
|
|
|
|
|
|
|
cExt[0] = '.';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cExt[1] = 'c';
|
|
|
|
|
|
|
|
cExt[2] = '\x00';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FILE *pIn=fopen( argv[1], "rb");
|
|
|
|
FILE *pIn=fopen( argv[1], "rb");
|
|
|
|
if (pIn==NULL)
|
|
|
|
if (pIn==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
printf ("Can't open %s.", argv[1]);
|
|
|
|
printf ("Can't open %s.", argv[1]);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *pOut=fopen( sOutput, "w");
|
|
|
|
FILE *pOut=fopen( sOutput, "w");
|
|
|
@ -61,7 +76,7 @@ int main(int argc, char* argv[])
|
|
|
|
"\n"
|
|
|
|
"\n"
|
|
|
|
"extern const unsigned char %s[];\n"
|
|
|
|
"extern const unsigned char %s[];\n"
|
|
|
|
"extern const unsigned int %sSize;\n\n"
|
|
|
|
"extern const unsigned int %sSize;\n\n"
|
|
|
|
"static const unsigned char %s[] =\n"
|
|
|
|
"const unsigned char %s[] =\n"
|
|
|
|
"{\n", argv[1], sName, sName, sName);
|
|
|
|
"{\n", argv[1], sName, sName, sName);
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int size=0;
|
|
|
|
unsigned int size=0;
|
|
|
@ -83,7 +98,7 @@ int main(int argc, char* argv[])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf (pOut, "};\n\n");
|
|
|
|
fprintf (pOut, "};\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
fprintf (pOut, "static const unsigned int %sSize = %d;\n\n", sName, size);
|
|
|
|
fprintf (pOut, "const unsigned int %sSize = %d;\n\n", sName, size);
|
|
|
|
|
|
|
|
|
|
|
|
fclose (pOut);
|
|
|
|
fclose (pOut);
|
|
|
|
fclose (pIn);
|
|
|
|
fclose (pIn);
|
|
|
|