-
-
Notifications
You must be signed in to change notification settings - Fork 26
XML2C
Dirk Hoffmann edited this page Dec 6, 2020
·
1 revision
Amiga BootBlock Reader is a tool for scanning the boot blocks of Amiga floppy disks. It tries to recognize the boot block by matching portions of the raw data with a database. All database records are stored in an XML file called brainfile.xml
.
An easy way to convert the XML file into another format is to utilize the Mini-XML library by Michael R Sweet. Here is some example code showing how the library can be used for this purpose:
#include "mxml.h"
int main(int argc, char *argv[])
{
FILE *fp;
mxml_node_t *tree;
fp = fopen("brainfile.xml", "r");
tree = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK);
fclose(fp);
// Crawl through all Bootblock nodes
mxml_node_t *node, *subnode;
for (node = mxmlFindElement(tree, tree, "Bootblock", NULL, NULL, MXML_DESCEND);
node != NULL;
node = mxmlFindElement(node, tree, "Bootblock", NULL, NULL, MXML_DESCEND)) {
// Skip all entries that are no viruses
subnode = mxmlFindElement(node, tree, "Class", NULL, NULL, MXML_DESCEND);
if (strcmp(mxmlGetOpaque(subnode), "v") != 0) continue;
// Extract name
subnode = mxmlFindElement(node, tree, "Name", NULL, NULL, MXML_DESCEND);
const char *name = mxmlGetOpaque(subnode);
// Extract marker
subnode = mxmlFindElement(node, tree, "Recog", NULL, NULL, MXML_DESCEND);
const char *recog = mxmlGetOpaque(subnode);
printf("VIRUS(\"%s\",\n", name);
printf(" %s),\n", recog);
}
return 0;
}