xml2env
is a tool to convert the resource data for the ENV library written in XML format to the source file format in C.
% perl init2env.pl RESOURCE_FILE
[-o OUTPUT_FILE]
The resource data written in the INIT format specified by RESOURCE_FILE
is changed to the C source file format and is output with the name RESOURCE_FILE.result.c
.
However, it is necessary to put in the absolute path of files you want to change in RESOURCE_FILE
.
With the -o
option, the output file name can be changed from RESOURCE_FILE.result.c
to OUTPUT_FILE
.
Note: If in an environment where XML::Parser cannot be used, it is necessary to include the latest version of perl and the expat library in the cygwin setup.
Description example of the resource data for the ENV library in XML format.
XML formatted resource data before being changed.
<envlist>
<resource name="environment1">
<class name="myClass11">
<string name="str1">mario</string>
<hexbinary name="bin1">12345678</hexbinary>
</class>
</resource>
<resource name="environment2">
<class name="myClass21">
<string name="str1">mario</string>
<hexbinary name="bin1">abcd123</hexbinary>
<hexbinary name="bin2" src="../test/test.txt"/>
</class>
<class name="myClass22">
<s32 name="data1">-500</s32>
<u16 name="data2">0x8000</u16>
</class>
</resource>
</envlist>
C Source File formatted Resource Data after being changed.
ENVResource myResource1[] = {
"myClass11.str1", ENV_STRING( "mario" ),
"myClass11.bin1", ENV_BINARY( "\x31\x32\x33\x34\x35\x36\x37\x38" ),
ENV_RESOUCE_END
};
ENVResource myResource2[] = {
"myClass21.str1", ENV_STRING( "mario" ),
"myClass21.bin1", ENV_BINARY( "file contents" ),
"myClass21.bin2", ENV_BINARY( "test.txt file contents" ),
"myClass22.data1", ENV_S32( -500 ),
"myClass22.data2", ENV_U16( 0x8000 ),
ENV_RESOUCE_END
};
ENVResource* resourceArray[]={ myResource1, myResource2, NULL };
When the resource type is BINARY, it is possible to make the file contents into element data automatically by surrounding the reletive file path within the src attribute inside the element with ""
.
Resource data can be used as is by compiling the generated C source file and the program using ENV together.
$NitroSDK/tools/bin/xml2env.pl
10/20/2005 Initial version.