2 * Copyright (C) ARM Limited 2013-2014. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
11 #include "CapturedXML.h"
13 #include "OlyUtility.h"
14 #include "SessionData.h"
16 char* EventsXML::getXML() {
17 #include "events_xml.h" // defines and initializes char events_xml[] and int events_xml_len
22 // Avoid unused variable warning
25 // Load the provided or default events xml
26 if (gSessionData->mEventsXMLPath) {
27 strncpy(path, gSessionData->mEventsXMLPath, PATH_MAX);
29 util->getApplicationFullPath(path, PATH_MAX);
30 strncat(path, "events.xml", PATH_MAX - strlen(path) - 1);
32 fl = fopen(path, "r");
34 xml = mxmlLoadFile(NULL, fl, MXML_NO_CALLBACK);
37 logg->logMessage("Unable to locate events.xml, using default");
38 xml = mxmlLoadString(NULL, (const char *)events_xml, MXML_NO_CALLBACK);
41 // Add dynamic events from the drivers
42 mxml_node_t *events = mxmlFindElement(xml, xml, "events", NULL, NULL, MXML_DESCEND);
44 logg->logMessage("Unable to find <events> node in the events.xml");
47 for (Driver *driver = Driver::getHead(); driver != NULL; driver = driver->getNext()) {
48 driver->writeEvents(events);
51 char* string = mxmlSaveAllocString(xml, mxmlWhitespaceCB);
57 void EventsXML::write(const char* path) {
61 snprintf(file, PATH_MAX, "%s/events.xml", path);
64 if (util->writeToDisk(file, buf) < 0) {
65 logg->logError(__FILE__, __LINE__, "Error writing %s\nPlease verify the path.", file);