From ed6e65a66f3bcf84dff4ff4e680096b7e40076d5 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Thu, 24 May 2012 17:15:43 +0200 Subject: Revert "Merge remote-tracking branch 'armlt/previous-armlt-gator' into stable-linux-ux500-3.3" This reverts commit a394b8c66756934bf0bc526da1b888e524313fb4, reversing changes made to a416f0c1e67d56752c38d8db621be99b3cf12bb8. --- drivers/gator/daemon/XMLReader.cpp | 164 ------------------------------------- 1 file changed, 164 deletions(-) delete mode 100644 drivers/gator/daemon/XMLReader.cpp (limited to 'drivers/gator/daemon/XMLReader.cpp') diff --git a/drivers/gator/daemon/XMLReader.cpp b/drivers/gator/daemon/XMLReader.cpp deleted file mode 100644 index 77c76e29d73..00000000000 --- a/drivers/gator/daemon/XMLReader.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Copyright (C) ARM Limited 2010-2012. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include "XMLReader.h" -extern void handleException(); - -XMLReader::XMLReader(const char* xmlstring) { - mPtr = (char*)xmlstring; - mNoMore = false; - mFirstTime = true; -} - -XMLReader::~XMLReader() { -} - -char* XMLReader::nextTag() { - static char tag[128]; // arbitrarily set max tag size to 127 characters + nul - - // Check if past the end of the root tag - if (mNoMore) return NULL; - - // Find start character - mPtr = strchr(mPtr, '<'); - - if (mPtr == NULL) return mPtr; - - // Skip tag if it begins with '); - if (end == NULL) - return 0; - - // Check if tag has no attributes - char* tagend = strchr(mPtr, '>'); - if (tagend < end) end = tagend; - - // Check the tag name length - unsigned int length = (int)end - (int)mPtr; - if (length > sizeof(tag) - 1) { - // tag name too long, skip it - return nextTag(); - } - - // Return the tag name - strncpy(tag, mPtr, length); - tag[length] = 0; - - // Mark the root tag - if (mFirstTime) { - mEndXML[0] = '/'; - strcpy(&mEndXML[1], tag); - mFirstTime = false; - } else if (strcmp(tag, mEndXML) == 0) { - // End of root tag found - mNoMore = true; - } - - return tag; -} - -void XMLReader::getAttribute(const char* name, char* value, int maxSize, const char* defValue) { - char searchString[128]; - - // Set up default - strncpy(value, defValue, maxSize - 1); - value[maxSize - 1] = 0; - - // Determine search string by ending the name with =" - if (strlen(name) > sizeof(searchString) - 3) return; - strcpy(searchString, name); - strcat(searchString, "=\""); - - // Find the beginning of the attribute's search string - char* begin = strstr(mPtr, searchString); - if (begin == NULL) return; - - // Find the beginning of the attribute's value - begin += strlen(searchString); - - // Find the end of the current tag to make sure the attribute exists within the tag - char* endtag = strchr(mPtr, '>'); - if (endtag < begin) return; - - // Find the end of the attribute's value - char* end = strchr(begin, '"'); - if (end == NULL) return; - - // Determine length - int length = (int)end - (int)begin; - if (length > maxSize - 1) return; - - strncpy(value, begin, length); - value[length] = 0; -} - -int XMLReader::getAttributeAsInteger(const char* name, int defValue) { - char value[32]; - getAttribute(name, value, sizeof(value), ""); - if (value[0] == 0) return defValue; - if (value[0] == '0' && value[1] == 'x') { - return (int) strtoul(&value[2], (char**)NULL, 16); - } - return strtol(value, NULL, 10); -} - -bool XMLReader::getAttributeAsBoolean(const char* name, bool defValue) { - char value[32]; - getAttribute(name, value, sizeof(value), ""); - if (value[0] == 0) return defValue; - - // Convert to lowercase - int i = 0; - while (value[i]) { - value[i] = tolower(value[i]); - i++; - } - - if (strcmp(value, "true") == 0 || strcmp(value, "yes") == 0 || strcmp(value, "1") == 0 || strcmp(value, "on") == 0) return true; - else if (strcmp(value, "false") == 0 || strcmp(value, "no") == 0 || strcmp(value, "0") == 0 || strcmp(value, "off") == 0) return false; - else return defValue; -} - -int XMLReader::getAttributeLength(const char* name) { - char searchString[128]; // arbitrarily large amount - - // Determine search string by ending the name with =" - if (strlen(name) > sizeof(searchString) - 3) return 0; - strcpy(searchString, name); - strcat(searchString, "=\""); - - // Find the beginning of the attribute's search string - char* begin = strstr(mPtr, searchString); - if (begin == NULL) return 0; - - // Find the beginning of the attribute's value - begin += strlen(searchString); - - // Find the end of the current tag to make sure the attribute exists within the tag - char* endtag = strchr(mPtr, '>'); - if (endtag < begin) return 0; - - // Find the end of the attribute's value - char* end = strchr(begin, '"'); - if (end == NULL) return 0; - - // Determine length - return (int)end - (int)begin; -} -- cgit v1.2.3