void Config::load () { if (!QUIET) Log::out() << "Loading: " << CONFIG_FILE; std::ifstream ifsConfig (CONFIG_FILE.c_str (), std::ios::in); if (!ifsConfig) { Log::out() << "Failed to open '" << CONFIG_FILE << "'."; } else { std::string strConfigFile; strConfigFile.assign ((std::istreambuf_iterator<char> (ifsConfig)), std::istreambuf_iterator<char> ()); if (ifsConfig.bad ()) { Log::out() << "Failed to read '" << CONFIG_FILE << "'."; } else { Section secConfig = ParseSection (strConfigFile, true); std::string strTemp; // XXX Leak Section::mapped_type* smtTmp; smtTmp = SectionEntries (secConfig, SECTION_VALIDATORS); if (smtTmp) { validators = *smtTmp; // SectionEntriesPrint(&validators, SECTION_VALIDATORS); } smtTmp = SectionEntries (secConfig, SECTION_CLUSTER_NODES); if (smtTmp) { CLUSTER_NODES = *smtTmp; // SectionEntriesPrint(&CLUSTER_NODES, SECTION_CLUSTER_NODES); } smtTmp = SectionEntries (secConfig, SECTION_IPS); if (smtTmp) { IPS = *smtTmp; // SectionEntriesPrint(&IPS, SECTION_IPS); } smtTmp = SectionEntries (secConfig, SECTION_SNTP); if (smtTmp) { SNTP_SERVERS = *smtTmp; } smtTmp = SectionEntries (secConfig, SECTION_RPC_STARTUP); if (smtTmp) { RPC_STARTUP = Json::arrayValue; BOOST_FOREACH (const std::string & strJson, *smtTmp) { Json::Reader jrReader; Json::Value jvCommand; if (!jrReader.parse (strJson, jvCommand)) throw std::runtime_error (boost::str (boost::format ("Couldn't parse [" SECTION_RPC_STARTUP "] command: %s") % strJson)); RPC_STARTUP.append (jvCommand); } } if (SectionSingleB (secConfig, SECTION_DATABASE_PATH, DATABASE_PATH)) DATA_DIR = DATABASE_PATH; (void) SectionSingleB (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE); (void) SectionSingleB (secConfig, SECTION_PEER_IP, PEER_IP); if (SectionSingleB (secConfig, SECTION_PEER_PRIVATE, strTemp)) PEER_PRIVATE = lexicalCastThrow <bool> (strTemp); smtTmp = SectionEntries (secConfig, SECTION_RPC_ADMIN_ALLOW); if (smtTmp) { RPC_ADMIN_ALLOW = *smtTmp; } (void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_PASSWORD, RPC_ADMIN_PASSWORD); (void) SectionSingleB (secConfig, SECTION_RPC_ADMIN_USER, RPC_ADMIN_USER); (void) SectionSingleB (secConfig, SECTION_RPC_IP, m_rpcIP); (void) SectionSingleB (secConfig, SECTION_RPC_PASSWORD, RPC_PASSWORD); (void) SectionSingleB (secConfig, SECTION_RPC_USER, RPC_USER); //--------------------------------------- // // VFALCO BEGIN CLEAN // nodeDatabase = parseKeyValueSection ( secConfig, ConfigSection::nodeDatabase ()); ephemeralNodeDatabase = parseKeyValueSection ( secConfig, ConfigSection::tempNodeDatabase ()); importNodeDatabase = parseKeyValueSection ( secConfig, ConfigSection::importNodeDatabase ()); if (SectionSingleB (secConfig, SECTION_PEER_PORT, strTemp)) peerListeningPort = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_PEER_PROXY_PORT, strTemp)) { peerPROXYListeningPort = lexicalCastThrow <int> (strTemp); if (peerPROXYListeningPort != 0 && peerPROXYListeningPort == peerListeningPort) FatalError ("Peer and proxy listening ports can't be the same.", __FILE__, __LINE__); } else { peerPROXYListeningPort = 0; } // // VFALCO END CLEAN // //--------------------------------------- if (SectionSingleB (secConfig, SECTION_RPC_PORT, strTemp)) m_rpcPort = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, "ledger_creator" , strTemp)) LEDGER_CREATOR = lexicalCastThrow <bool> (strTemp); if (SectionSingleB (secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp)) RPC_ALLOW_REMOTE = lexicalCastThrow <bool> (strTemp); if (SectionSingleB (secConfig, SECTION_NODE_SIZE, strTemp)) { if (strTemp == "tiny") NODE_SIZE = 0; else if (strTemp == "small") NODE_SIZE = 1; else if (strTemp == "medium") NODE_SIZE = 2; else if (strTemp == "large") NODE_SIZE = 3; else if (strTemp == "huge") NODE_SIZE = 4; else { NODE_SIZE = lexicalCastThrow <int> (strTemp); if (NODE_SIZE < 0) NODE_SIZE = 0; else if (NODE_SIZE > 4) NODE_SIZE = 4; } } if (SectionSingleB (secConfig, SECTION_ELB_SUPPORT, strTemp)) ELB_SUPPORT = lexicalCastThrow <bool> (strTemp); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_IP, WEBSOCKET_IP); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PORT, strTemp)) WEBSOCKET_PORT = lexicalCastThrow <int> (strTemp); (void) SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_IP, WEBSOCKET_PUBLIC_IP); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_PORT, strTemp)) WEBSOCKET_PUBLIC_PORT = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_SECURE, strTemp)) WEBSOCKET_SECURE = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PUBLIC_SECURE, strTemp)) WEBSOCKET_PUBLIC_SECURE = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp)) WEBSOCKET_PING_FREQ = lexicalCastThrow <int> (strTemp); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CERT, WEBSOCKET_SSL_CERT); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_CHAIN, WEBSOCKET_SSL_CHAIN); SectionSingleB (secConfig, SECTION_WEBSOCKET_SSL_KEY, WEBSOCKET_SSL_KEY); if (SectionSingleB (secConfig, SECTION_RPC_SECURE, strTemp)) RPC_SECURE = lexicalCastThrow <int> (strTemp); SectionSingleB (secConfig, SECTION_RPC_SSL_CERT, RPC_SSL_CERT); SectionSingleB (secConfig, SECTION_RPC_SSL_CHAIN, RPC_SSL_CHAIN); SectionSingleB (secConfig, SECTION_RPC_SSL_KEY, RPC_SSL_KEY); SectionSingleB (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE); SectionSingleB (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR); if (SectionSingleB (secConfig, SECTION_SSL_VERIFY, strTemp)) SSL_VERIFY = lexicalCastThrow <bool> (strTemp); if (SectionSingleB (secConfig, SECTION_VALIDATION_SEED, strTemp)) { VALIDATION_SEED.setSeedGeneric (strTemp); if (VALIDATION_SEED.isValid ()) { VALIDATION_PUB = RippleAddress::createNodePublic (VALIDATION_SEED); VALIDATION_PRIV = RippleAddress::createNodePrivate (VALIDATION_SEED); } } if (SectionSingleB (secConfig, SECTION_NODE_SEED, strTemp)) { NODE_SEED.setSeedGeneric (strTemp); if (NODE_SEED.isValid ()) { NODE_PUB = RippleAddress::createNodePublic (NODE_SEED); NODE_PRIV = RippleAddress::createNodePrivate (NODE_SEED); } } (void) SectionSingleB (secConfig, SECTION_PEER_SSL_CIPHER_LIST, PEER_SSL_CIPHER_LIST); if (SectionSingleB (secConfig, SECTION_PEER_SCAN_INTERVAL_MIN, strTemp)) // Minimum for min is 60 seconds. PEER_SCAN_INTERVAL_MIN = std::max (60, lexicalCastThrow <int> (strTemp)); if (SectionSingleB (secConfig, SECTION_PEER_START_MAX, strTemp)) PEER_START_MAX = std::max (1, lexicalCastThrow <int> (strTemp)); if (SectionSingleB (secConfig, SECTION_PEER_CONNECT_LOW_WATER, strTemp)) PEER_CONNECT_LOW_WATER = std::max (1, lexicalCastThrow <int> (strTemp)); if (SectionSingleB (secConfig, SECTION_NETWORK_QUORUM, strTemp)) NETWORK_QUORUM = std::max (0, lexicalCastThrow <int> (strTemp)); if (SectionSingleB (secConfig, SECTION_VALIDATION_QUORUM, strTemp)) VALIDATION_QUORUM = std::max (0, lexicalCastThrow <int> (strTemp)); if (SectionSingleB (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) FEE_ACCOUNT_RESERVE = lexicalCastThrow <uint64> (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) FEE_OWNER_RESERVE = lexicalCastThrow <uint64> (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp)) FEE_NICKNAME_CREATE = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_OFFER, strTemp)) FEE_OFFER = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_DEFAULT, strTemp)) FEE_DEFAULT = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_FEE_OPERATION, strTemp)) FEE_CONTRACT_OPERATION = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_LEDGER_HISTORY, strTemp)) { boost::to_lower (strTemp); if (strTemp == "none") LEDGER_HISTORY = 0; else if (strTemp == "full") LEDGER_HISTORY = 1000000000u; else LEDGER_HISTORY = lexicalCastThrow <uint32> (strTemp); } if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_OLD, strTemp)) PATH_SEARCH_OLD = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_PATH_SEARCH, strTemp)) PATH_SEARCH = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_FAST, strTemp)) PATH_SEARCH_FAST = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_PATH_SEARCH_MAX, strTemp)) PATH_SEARCH_MAX = lexicalCastThrow <int> (strTemp); if (SectionSingleB (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp)) ACCOUNT_PROBE_MAX = lexicalCastThrow <int> (strTemp); (void) SectionSingleB (secConfig, SECTION_SMS_FROM, SMS_FROM); (void) SectionSingleB (secConfig, SECTION_SMS_KEY, SMS_KEY); (void) SectionSingleB (secConfig, SECTION_SMS_SECRET, SMS_SECRET); (void) SectionSingleB (secConfig, SECTION_SMS_TO, SMS_TO); (void) SectionSingleB (secConfig, SECTION_SMS_URL, SMS_URL); if (SectionSingleB (secConfig, SECTION_VALIDATORS_FILE, strTemp)) { VALIDATORS_FILE = strTemp; } if (SectionSingleB (secConfig, SECTION_DEBUG_LOGFILE, strTemp)) DEBUG_LOGFILE = strTemp; } } }
bool SDP::ParseSDP(SDP &sdp, string &raw) { //FINEST("%s", STR(raw)); //1. Reset sdp.Reset(); //2. Prepare the sections sdp[SDP_SESSION].IsArray(false); sdp[SDP_MEDIATRACKS].IsArray(true); //3. Split the raw content into lines replace(raw, "\r\n", "\n"); vector<string> lines; split(raw, "\n", lines); //4. Detect the media tracks indexes vector<uint32_t> trackIndexes; for (uint32_t i = 0; i < lines.size(); i++) { trim(lines[i]); if (lines[i].find("m=") == 0) { ADD_VECTOR_END(trackIndexes, i); } } if (trackIndexes.size() == 0) { FATAL("No tracks found"); return false; } //5. Parse the header if (!ParseSection(sdp[SDP_SESSION], lines, 0, trackIndexes[0])) { FATAL("Unable to parse header"); return false; } //6. Parse the media sections Variant media; for (uint32_t i = 0; i < trackIndexes.size() - 1; i++) { media.Reset(); media.IsArray(false); if (!ParseSection(media, lines, trackIndexes[i], trackIndexes[i + 1] - trackIndexes[i])) { FATAL("Unable to parse header"); return false; } sdp[SDP_MEDIATRACKS].PushToArray(media); } //7. Parse the last media section media.Reset(); media.IsArray(false); if (!ParseSection(media, lines, trackIndexes[(uint32_t) trackIndexes.size() - 1], (uint32_t) trackIndexes.size() - trackIndexes[(uint32_t) trackIndexes.size() - 1])) { FATAL("Unable to parse header"); return false; } sdp[SDP_MEDIATRACKS].PushToArray(media); return true; }
bool cGuiSkin::LoadListSkin(){ listSections[0] = ParseSection("APGUI_SKIN_LIST_TOP"); listSections[1] = ParseSection("APGUI_SKIN_LIST_LEFT"); listSections[2] = ParseSection("APGUI_SKIN_LIST_DOWN"); listSections[3] = ParseSection("APGUI_SKIN_LIST_RIGHT"); listSections[4] = ParseSection("APGUI_SKIN_LIST_MIDDLE"); ParseColor("APGUI_SKIN_INPUT_TEXT_COLOR", &listSections[5], &listSections[6], &listSections[7]); return listSections[0] != 0 && listSections[1] != 0 && listSections[2] != 0 && listSections[3] != 0 && listSections[4] != 0; }
CfgSection* ConfigParser::ParseConfiguration(std::string configuration) { rapidxml::xml_document<> *xDoc = new rapidxml::xml_document<>(); char * configData = xDoc->allocate_string(configuration.c_str()); xDoc->parse<0>(configData); rapidxml::xml_node<> *configNode = xDoc->first_node("config"); bool stopProcessing = false; CfgSection* cfg = new CfgSection(); CfgSection * firstSection = cfg; rapidxml::xml_node<> *xSection = configNode->first_node("section"); while(! stopProcessing) { if(xSection) { ParseSection(xSection, cfg); cfg->Next = new CfgSection(); cfg = cfg->Next; xSection = xSection->next_sibling("section"); } else stopProcessing = true; } delete xDoc; return firstSection; }
bool cGuiSkin::LoadVerSkiderSkin(){ verSliderSections[0] = ParseSection("APGUI_SKIN_VERSLIDER_BACKGROUND"); verSliderSections[1] = ParseSection("APGUI_SKIN_VERSLIDER_BACKGROUND_TOP"); verSliderSections[2] = ParseSection("APGUI_SKIN_VERSLIDER_BACKGROUND_BOT"); verSliderSections[3] = ParseSection("APGUI_SKIN_VERSLIDER_BIG_DISABLED"); verSliderSections[4] = ParseSection("APGUI_SKIN_VERSLIDER_BIG_NORMAL"); verSliderSections[5] = ParseSection("APGUI_SKIN_VERSLIDER_BIG_OVER"); verSliderSections[6] = ParseSection("APGUI_SKIN_VERSLIDER_BIG_DOWN"); return verSliderSections[0] != 0 && verSliderSections[1] != 0 && verSliderSections[2] != 0 && verSliderSections[3] != 0 && verSliderSections[4] != 0 && verSliderSections[5] != 0 && verSliderSections[6] != 0; }
bool cGuiSkin::LoadHorSliderSkin(){ horSliderSections[0] = ParseSection("APGUI_SKIN_HORSLIDER_BACKGROUND"); horSliderSections[1] = ParseSection("APGUI_SKIN_HORSLIDER_BACKGROUND_LEFT"); horSliderSections[2] = ParseSection("APGUI_SKIN_HORSLIDER_BACKGROUND_RIGHT"); horSliderSections[3] = ParseSection("APGUI_SKIN_HORSLIDER_BIG_DISABLED"); horSliderSections[4] = ParseSection("APGUI_SKIN_HORSLIDER_BIG_NORMAL"); horSliderSections[5] = ParseSection("APGUI_SKIN_HORSLIDER_BIG_OVER"); horSliderSections[6] = ParseSection("APGUI_SKIN_HORSLIDER_BIG_DOWN"); return horSliderSections[0] != 0 && horSliderSections[1] != 0 && horSliderSections[2] != 0 && horSliderSections[3] != 0 && horSliderSections[4] != 0 && horSliderSections[5] != 0 && horSliderSections[6] != 0; }
bool cGuiSkin::LoadRadioSkin(){ radioSections[0] = ParseSection("APGUI_SKIN_RADIO_DISABLED_NC"); radioSections[1] = ParseSection("APGUI_SKIN_RADIO_DISABLED_CH"); radioSections[2] = ParseSection("APGUI_SKIN_RADIO_NORMAL_NC"); radioSections[3] = ParseSection("APGUI_SKIN_RADIO_NORMAL_CH"); radioSections[4] = ParseSection("APGUI_SKIN_RADIO_OVER_NC"); radioSections[5] = ParseSection("APGUI_SKIN_RADIO_OVER_CH"); radioSections[6] = ParseSection("APGUI_SKIN_RADIO_DOWN_NC"); radioSections[7] = ParseSection("APGUI_SKIN_RADIO_DOWN_CH"); ParseColor("APGUI_SKIN_RADIO_TEXT_COLOR", &radioSections[8], &radioSections[9], &radioSections[10]); return radioSections[0] != 0 && radioSections[1] != 0 && radioSections[2] != 0 && radioSections[3] != 0 && radioSections[4] != 0 && radioSections[5] != 0 && radioSections[6] != 0 && radioSections[7] != 0; }
bool cGuiSkin::LoadCheckBoxSkin(){ checkBoxSections[0] = ParseSection("APGUI_SKIN_CHBOX_DISABLED_NC"); checkBoxSections[1] = ParseSection("APGUI_SKIN_CHBOX_DISABLED_CH"); checkBoxSections[2] = ParseSection("APGUI_SKIN_CHBOX_NORMAL_NC"); checkBoxSections[3] = ParseSection("APGUI_SKIN_CHBOX_NORMAL_CH"); checkBoxSections[4] = ParseSection("APGUI_SKIN_CHBOX_OVER_NC"); checkBoxSections[5] = ParseSection("APGUI_SKIN_CHBOX_OVER_CH"); checkBoxSections[6] = ParseSection("APGUI_SKIN_CHBOX_DOWN_NC"); checkBoxSections[7] = ParseSection("APGUI_SKIN_CHBOX_DOWN_CH"); ParseColor("APGUI_SKIN_CHBOX_LABEL_COLOR", &checkBoxSections[8], &checkBoxSections[9], &checkBoxSections[10]); return checkBoxSections[0] != 0 && checkBoxSections[1] != 0 && checkBoxSections[2] != 0 && checkBoxSections[3] != 0 && checkBoxSections[4] != 0 && checkBoxSections[5] != 0 && checkBoxSections[6] != 0 && checkBoxSections[7] != 0; }
void CSunParser::Parse(char* buf, int size) { string thissection; SSection* section = NULL; char* endptr = buf + size; while (buf<=endptr) { if (buf[0] == '/' && buf[1] == '/') { // comment while ((buf != endptr) && *buf!='\n' && *buf!='\r') { buf++; } } else if (buf[0] == '/' && buf[1] == '*') { //comment while ((buf != endptr) && buf[0] != '*' || buf[1] != '/') { buf++; } } else if (*buf == '[') { // sectionname thissection = ""; while (*(++buf) != ']') { thissection += *buf; } } else if (*buf == '{') { // section buf++; section = new SSection; transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int)) tolower); map<string, SSection*>::iterator ui = sections.find(thissection); if (ui != sections.end()) { DeleteSection(&ui->second->sections); delete ui->second; } sections[thissection] = section; buf = ParseSection(buf, endptr - buf, section); } // We can possible hit endptr from somewhere that increases, so don't go past it if (buf <= endptr) buf++; } }
bool cGuiSkin::LoadContainerSkin(){ containerSections[0] = ParseSection("APGUI_SKIN_CONTAINER_BACKGROUND"); containerSections[1] = ParseSection("APGUI_SKIN_CONTAINER_TITLEBAR"); containerSections[2] = ParseSection("APGUI_SKIN_CONTAINER_CLTITLEBAR"); containerSections[3] = ParseSection("APGUI_SKIN_CONTAINER_CLOSE_DIS"); containerSections[4] = ParseSection("APGUI_SKIN_CONTAINER_CLOSE_NORM"); containerSections[5] = ParseSection("APGUI_SKIN_CONTAINER_CLOSE_OVER"); containerSections[6] = ParseSection("APGUI_SKIN_CONTAINER_CLOSE_DOWN"); ParseColor("APGUI_SKIN_CHBOX_LABEL_COLOR", &containerSections[7], &containerSections[8], &containerSections[9]); return containerSections[0] != 0 && containerSections[1] != 0 && containerSections[2] != 0 && containerSections[3] != 0 && containerSections[4] != 0 && containerSections[5] != 0 && containerSections[6] != 0; }
void MythUIAnimation::ParseElement(const QDomElement &element, MythUIType* parent) { QString t = element.attribute("trigger", "AboutToShow"); Trigger trigger = AboutToShow; if ("AboutToHide" == t) trigger = AboutToHide; for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) { QDomElement section = child.toElement(); if (section.isNull()) continue; if (section.tagName() == "section") ParseSection(section, parent, trigger); } }
void* GetSectionInfo(BYTE* hMod, char *name, DWORD dwChamp) { PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hMod; PIMAGE_NT_HEADERS pPE; PIMAGE_SECTION_HEADER pSections; int nbSection, i; pPE = (PIMAGE_NT_HEADERS)(pDosHeader->e_lfanew + (BYTE *)pDosHeader); nbSection = pPE->FileHeader.NumberOfSections; for (i = 0; i < nbSection; i++) { pSections = (PIMAGE_SECTION_HEADER)((BYTE *)pPE + sizeof(IMAGE_NT_HEADERS) + sizeof(IMAGE_SECTION_HEADER) * i); if (!strcmp(pSections->Name, name)) return ParseSection(pSections, dwChamp); } return 0; }
HSETTINGS OpenSettingsFromData(const char *data) { unsigned int length = 0; if (!data || (length = strlen(data)) <= 0) { return NULL; } HSETTINGS settings = NULL; if (!(settings = CreateSettings())) { return NULL; } struct IParse parse; if (!InitSettingsParser(&parse, data, length)) { return NULL; } while (ParseSection(&parse, settings)); return (settings); }
bool cGuiSkin::LoadInputSkin(){ inputSections[0] = ParseSection("APGUI_SKIN_INPUT_DISABLED"); inputSections[1] = ParseSection("APGUI_SKIN_INPUT_DISABLED_LEFT"); inputSections[2] = ParseSection("APGUI_SKIN_INPUT_DISABLED_RIGHT"); inputSections[3] = ParseSection("APGUI_SKIN_INPUT_NORMAL"); inputSections[4] = ParseSection("APGUI_SKIN_INPUT_NORMAL_LEFT"); inputSections[5] = ParseSection("APGUI_SKIN_INPUT_NORMAL_RIGHT"); inputSections[6] = ParseSection("APGUI_SKIN_INPUT_OVER_NONSELECTE"); inputSections[7] = ParseSection("APGUI_SKIN_INPUT_OVER_NONSELECTE_LEFT"); inputSections[8] = ParseSection("APGUI_SKIN_INPUT_OVER_NONSELECTE_RIGHT"); inputSections[9] = ParseSection("APGUI_SKIN_INPUT_OVER_SELECTED"); inputSections[10] = ParseSection("APGUI_SKIN_INPUT_OVER_SELECTED_LEFT"); inputSections[11] = ParseSection("APGUI_SKIN_INPUT_OVER_SELECTED_RIGHT"); inputSections[12] = ParseSection("APGUI_SKIN_INPUT_SELECTED"); inputSections[13] = ParseSection("APGUI_SKIN_INPUT_SELECTED_LEFT"); inputSections[14] = ParseSection("APGUI_SKIN_INPUT_SELECTED_RIGHT"); ParseColor("APGUI_SKIN_INPUT_TEXT_COLOR", &inputSections[15], &inputSections[16], &inputSections[17]); return inputSections[0] != 0 && inputSections[1] != 0 && inputSections[2] != 0 && inputSections[3] != 0 && inputSections[4] != 0 && inputSections[5] != 0 && inputSections[6] != 0 && inputSections[7] != 0 && inputSections[8] != 0 && inputSections[9] != 0 && inputSections[10] != 0 && inputSections[11] != 0 && inputSections[11] != 0 && inputSections[12] != 0 && inputSections[13] != 0 && inputSections[14] != 0; }
char* CSunParser::ParseSection(char* buf, int size, SSection* section) { string thissection; char* endptr = buf + size; while (buf <= endptr) { if (buf[0] == '/' && buf[1] == '/') { // comment while (*buf != '\n' && *buf != '\r') { buf++; } } else if (buf[0] == '/' && buf[1] == '*') { // comment while (buf[0] != '*' || buf[1] != '/') { buf++; } } else if (*buf == '[') { // sectionname thissection = ""; while (*(++buf) != ']') { thissection += *buf; } } else if (*buf == '{') { // section buf++; SSection* newsection = new SSection; transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int)) tolower); map<string, SSection*>::iterator ui = section->sections.find(thissection); if (ui != section->sections.end()) { DeleteSection(&ui->second->sections); delete ui->second; } section->sections[thissection] = newsection; buf = ParseSection(buf, endptr - buf, newsection); } else if (*buf == '}') { // endsection // buf++; return buf; } else if (*buf >= '0' && *buf <= 'z') { string name; string value; while (*buf != '=') { name += *buf; buf++; } buf++; while (*buf != ';') { value += *buf; buf++; } transform(name.begin(), name.end(), name.begin(), (int (*)(int)) tolower); section->values[name] = value; } buf++; } return buf; }
char *CSunParser::ParseSection(char *buf, int size, SSection *section) { ////L("CSunParser::ParseSection(buf, " << size << ", " << section << ")" << endl); string thissection; // int se = 0; //for section start/end errorchecking char *endptr = buf+size; while(buf<=endptr) { if(buf[0]=='/' && buf[1]=='/') //comment { while(*buf!='\n' && *buf!='\r') { buf++; } } else if(buf[0]=='/' && buf[1]=='*') //comment { while(buf[0]!='*' || buf[1]!='/') { buf++; } } else if(*buf == '[') //sectionname { thissection = ""; while(*(++buf)!=']') { thissection += *buf; } } else if(*buf == '{') //section { buf++; SSection *newsection = new SSection; transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int))tolower); map<string, SSection*>::iterator ui=section->sections.find(thissection); if(ui!=section->sections.end()){ // MessageBox(0,"Overwrote earlier section in sunparser",thissection.c_str(),0); ////L("Sun Parsing Error: Overwrote earlier section in sunparser: " << thissection << endl); DeleteSection(&ui->second->sections); delete ui->second; } section->sections[thissection] = newsection; buf = ParseSection(buf, endptr-buf, newsection); } else if(*buf == '}') //endsection { //buf++; return buf; } else if(*buf >= '0' && *buf <= 'z') { string name; string value; while(*buf != '=') { name += *buf; buf++; } buf++; while(*buf != ';') { value += *buf; buf++; } transform(name.begin(), name.end(), name.begin(), (int (*)(int))tolower); ////L("Attempting " << name << " = " << value << endl); section->values[name] = value; ////L(name << " = " << value << endl); } buf++; } return buf; }
void CSunParser::Parse(char *buf, int size) { ////L("CSunParser::Parse(buf, " << size << ")" << endl); string thissection; SSection *section = NULL; //vector<map<string,SSection*>*> sectionlist; //sectionlist.push_back(§ions); // int se = 0; //for section start/end errorchecking char *endptr = buf+size; while(buf<=endptr) { if(buf[0]=='/' && buf[1]=='/') //comment { while((buf != endptr) && *buf!='\n' && *buf!='\r') { buf++; } } else if(buf[0]=='/' && buf[1]=='*') //comment { while((buf != endptr) && buf[0]!='*' || buf[1]!='/') { buf++; } } else if(*buf == '[') //sectionname { thissection = ""; while(*(++buf)!=']') { thissection += *buf; } } else if(*buf == '{') //section { buf++; section = new SSection; transform(thissection.begin(), thissection.end(), thissection.begin(), (int (*)(int))tolower); map<string, SSection*>::iterator ui=sections.find(thissection); if(ui!=sections.end()){ // MessageBox(0,"Overwrote earlier section in sunparser",thissection.c_str(),0); ////L("Sun Parsing Error: Overwrote earlier section in sunparser: " << thissection << endl); DeleteSection(&ui->second->sections); delete ui->second; } sections[thissection] = section; buf = ParseSection(buf, endptr-buf, section); } // We can possible hit endptr from somewhere that increases, so don't go past it if (buf <= endptr) buf++; } ////L("Finished Parsing" << endl); }
bool cGuiSkin::LoadButtonSkin(){ buttonSections[0] = ParseSection("APGUI_SKIN_BUTTON_DISABLED"); buttonSections[1] = ParseSection("APGUI_SKIN_BUTTON_DISABLED_LEFT"); buttonSections[2] = ParseSection("APGUI_SKIN_BUTTON_DISABLED_RIGHT"); buttonSections[3] = ParseSection("APGUI_SKIN_BUTTON_NORMAL"); buttonSections[4] = ParseSection("APGUI_SKIN_BUTTON_NORMAL_LEFT"); buttonSections[5] = ParseSection("APGUI_SKIN_BUTTON_NORMAL_RIGHT"); buttonSections[6] = ParseSection("APGUI_SKIN_BUTTON_OVER"); buttonSections[7] = ParseSection("APGUI_SKIN_BUTTON_OVER_LEFT"); buttonSections[8] = ParseSection("APGUI_SKIN_BUTTON_OVER_RIGHT"); buttonSections[9] = ParseSection("APGUI_SKIN_BUTTON_DOWN"); buttonSections[10] = ParseSection("APGUI_SKIN_BUTTON_DOWN_LEFT"); buttonSections[11] = ParseSection("APGUI_SKIN_BUTTON_DOWN_RIGHT"); ParseColor("APGUI_SKIN_BUTTON_TEXT_COLOR", &buttonSections[12], &buttonSections[13], &buttonSections[14]); return containerSections[0] != 0 && containerSections[1] != 0 && containerSections[2] != 0 && containerSections[3] != 0 && containerSections[4] != 0 && containerSections[5] != 0 && containerSections[6] != 0 && containerSections[7] != 0 && containerSections[8] != 0 && containerSections[9] != 0 && containerSections[10] != 0 && containerSections[11] != 0; }
bool cGuiSkin::LoadComboBoxSkin(){ comboBoxSections[0] = ParseSection("APGUI_SKIN_COMBOBOX_DISABLED"); comboBoxSections[1] = ParseSection("APGUI_SKIN_COMBOBOX_DISABLED_LEFT"); comboBoxSections[2] = ParseSection("APGUI_SKIN_COMBOBOX_DISABLED_RIGHT"); comboBoxSections[3] = ParseSection("APGUI_SKIN_COMBOBOX_ARROW_DISABLED"); comboBoxSections[4] = ParseSection("APGUI_SKIN_COMBOBOX_NORMAL"); comboBoxSections[5] = ParseSection("APGUI_SKIN_COMBOBOX_NORMAL_LEFT"); comboBoxSections[6] = ParseSection("APGUI_SKIN_COMBOBOX_NORMAL_RIGHT"); comboBoxSections[7] = ParseSection("APGUI_SKIN_COMBOBOX_ARROW_NORMAL"); comboBoxSections[8] = ParseSection("APGUI_SKIN_COMBOBOX_OVER"); comboBoxSections[9] = ParseSection("APGUI_SKIN_COMBOBOX_OVER_LEFT"); comboBoxSections[10] = ParseSection("APGUI_SKIN_COMBOBOX_OVER_RIGHT"); comboBoxSections[11] = ParseSection("APGUI_SKIN_COMBOBOX_ARROW_OVER"); comboBoxSections[12] = ParseSection("APGUI_SKIN_COMBOBOX_ARROW_DOWN"); comboBoxSections[13] = ParseSection("APGUI_SKIN_COMBOBOX_EXTENDED"); comboBoxSections[14] = ParseSection("APGUI_SKIN_COMBOBOX_EXTENDED_BOTTOM"); comboBoxSections[15] = ParseSection("APGUI_SKIN_COMBOBOX_ITEM_OVER"); ParseColor("APGUI_SKIN_COMBOBOX_TEXT_COLOR", &comboBoxSections[16], &comboBoxSections[17], &comboBoxSections[18]); return comboBoxSections[0] != 0 && comboBoxSections[1] != 0 && comboBoxSections[2] != 0 && comboBoxSections[3] != 0 && comboBoxSections[4] != 0 && comboBoxSections[5] != 0 && comboBoxSections[6] != 0 && comboBoxSections[7] != 0 && comboBoxSections[8] != 0 && comboBoxSections[9] != 0 && comboBoxSections[10] != 0 && comboBoxSections[11] != 0 && comboBoxSections[11] != 0 && comboBoxSections[12] != 0 && comboBoxSections[13] != 0 && comboBoxSections[14] != 0 && comboBoxSections[15]; }