CScraperUrl::CScraperUrl(const std::string& strUrl) { relevance = 0; ParseString(strUrl); }
bool CScraperUrl::Parse() { std::string strToParse = m_xml; m_xml.clear(); return ParseString(strToParse); }
ComboList DataFieldFloat::CreateComboList(const TCHAR *reference_string) const { const fixed reference = reference_string != nullptr ? ParseString(reference_string) : mValue; ComboList combo_list; const fixed epsilon = mStep / 1000; const fixed fine_step = mStep / 10; /* how many items before and after the current value? */ unsigned surrounding_items = ComboList::MAX_SIZE / 2 - 2; if (mFine) surrounding_items -= 20; /* the value aligned to mStep */ fixed corrected_value = int((reference - mMin) / mStep) * mStep + mMin; fixed first = corrected_value - surrounding_items * mStep; if (first > mMin + epsilon) /* there are values before "first" - give the user a choice */ combo_list.Append(ComboList::Item::PREVIOUS_PAGE, _T("<<More Items>>")); else if (first < mMin - epsilon) first = int(mMin / mStep) * mStep; fixed last = std::min(first + surrounding_items * mStep * 2, mMax); bool found_current = false; fixed step = mStep; bool inFineSteps = false; for (fixed i = first; i <= last + epsilon; i += step) { // Skip over the items which fall below the beginning of the valid range. // e.g. first may be 0.0 for values with valid range 0.1 - 10.0 and step 1.0 // rather than duplicate all the fine_step setup above simply ignore the few // values here. Needed for nice sequence e.g. 1.0 2.0 ... instead of 1.1 2.1 ... if (i < mMin - epsilon) continue; if (mFine) { // show up to 9 items above and below current value with extended precision if (i - epsilon > reference + mStep - fine_step) { if (inFineSteps) { inFineSteps = false; step = mStep; i = int((i + mStep - fine_step) / mStep) * mStep; if (i > mMax) i = mMax; } } else if (i + epsilon >= reference - mStep + fine_step) { if (!inFineSteps) { inFineSteps = true; step = fine_step; i = std::max(mMin, reference - mStep + fine_step); } } } if (!found_current && reference <= i + epsilon) { combo_list.current_index = combo_list.size(); if (reference < i - epsilon) /* the current value is not listed - insert it here */ AppendComboValue(combo_list, reference); found_current = true; } AppendComboValue(combo_list, i); } if (reference > last + epsilon) { /* the current value out of range - append it here */ last = reference; combo_list.current_index = combo_list.size(); AppendComboValue(combo_list, reference); } if (last < mMax - epsilon) /* there are values after "last" - give the user a choice */ combo_list.Append(ComboList::Item::NEXT_PAGE, _T("<<More Items>>")); return combo_list; }
void DataFieldFloat::SetAsString(const TCHAR *Value) { SetAsFloat(ParseString(Value)); }
void dng_iptc::Parse (const void *blockData, uint32 blockSize, uint64 offsetInOriginalFile) { dng_stream stream (blockData, blockSize, offsetInOriginalFile); stream.SetBigEndian (); // Make a first pass though the data, trying to figure out the // character set. CharSet charSet = kCharSetUnknown; bool isValidUTF8 = true; bool hasEncodingMarker = false; uint64 firstOffset = stream.Position (); uint64 nextOffset = firstOffset; while (nextOffset + 5 < stream.Length ()) { stream.SetReadPosition (nextOffset); uint8 firstByte = stream.Get_uint8 (); if (firstByte != 0x1C) break; uint8 record = stream.Get_uint8 (); uint8 dataSet = stream.Get_uint8 (); uint32 dataSize = stream.Get_uint16 (); nextOffset = stream.Position () + dataSize; if (record == 1) { switch (dataSet) { case 90: { hasEncodingMarker = true; if (dataSize == 3) { uint32 byte1 = stream.Get_uint8 (); uint32 byte2 = stream.Get_uint8 (); uint32 byte3 = stream.Get_uint8 (); if (byte1 == 27 /* Escape */ && byte2 == 0x25 && byte3 == 0x47) { charSet = kCharSetUTF8; } } break; } default: break; } } else if (record == 2) { dng_memory_data buffer (dataSize + 1); char *s = buffer.Buffer_char (); stream.Get (s, dataSize); s [dataSize] = 0; isValidUTF8 = isValidUTF8 && dng_string::IsUTF8 (s); } } // If we don't have an encoding marker, and the data is valid // UTF-8, then assume that it is UTF-8 (rather than system encoding). if (!hasEncodingMarker && isValidUTF8) { charSet = kCharSetUTF8; } // Make a second pass though the data, actually reading the data. nextOffset = firstOffset; while (nextOffset + 5 < stream.Length ()) { stream.SetReadPosition (nextOffset); uint8 firstByte = stream.Get_uint8 (); if (firstByte != 0x1C) break; uint8 record = stream.Get_uint8 (); uint8 dataSet = stream.Get_uint8 (); uint32 dataSize = stream.Get_uint16 (); nextOffset = stream.Position () + dataSize; if (record == 2) { stream.SetReadPosition (stream.Position () - 2); switch ((DataSet) dataSet) { case kObjectNameSet: { ParseString (stream, fTitle, charSet); break; } case kUrgencySet: { int32 size = stream.Get_uint16 (); if (size == 1) { char c = stream.Get_int8 (); if (c >= '0' && c <= '9') { fUrgency = c - '0'; } } break; } case kCategorySet: { ParseString (stream, fCategory, charSet); break; } case kSupplementalCategoriesSet: { dng_string category; ParseString (stream, category, charSet); if (category.NotEmpty ()) { fSupplementalCategories.Append (category); } break; } case kKeywordsSet: { dng_string keyword; ParseString (stream, keyword, charSet); if (keyword.NotEmpty ()) { fKeywords.Append (keyword); } break; } case kSpecialInstructionsSet: { ParseString (stream, fInstructions, charSet); break; } case kDateCreatedSet: { uint32 length = stream.Get_uint16 (); if (length == 8) { char date [9]; stream.Get (date, 8); date [8] = 0; fDateTimeCreated.Decode_IPTC_Date (date); } break; } case kTimeCreatedSet: { uint32 length = stream.Get_uint16 (); if (length >= 4 && length <= 11) { char time [12]; stream.Get (time, length); time [length] = 0; fDateTimeCreated.Decode_IPTC_Time (time); } break; } case kDigitalCreationDateSet: { uint32 length = stream.Get_uint16 (); if (length == 8) { char date [9]; stream.Get (date, 8); date [8] = 0; fDigitalCreationDateTime.Decode_IPTC_Date (date); } break; } case kDigitalCreationTimeSet: { uint32 length = stream.Get_uint16 (); if (length >= 4 && length <= 11) { char time [12]; stream.Get (time, length); time [length] = 0; fDigitalCreationDateTime.Decode_IPTC_Time (time); } break; } case kBylineSet: { dng_string author; ParseString (stream, author, charSet); if (author.NotEmpty ()) { fAuthors.Append (author); } break; } case kBylineTitleSet: { ParseString (stream, fAuthorsPosition, charSet); break; } case kCitySet: { ParseString (stream, fCity, charSet); break; } case kProvinceStateSet: { ParseString (stream, fState, charSet); break; } case kCountryNameSet: { ParseString (stream, fCountry, charSet); break; } case kCountryCodeSet: { ParseString (stream, fCountryCode, charSet); break; } case kSublocationSet: { ParseString (stream, fLocation, charSet); break; } case kOriginalTransmissionReferenceSet: { ParseString (stream, fTransmissionReference, charSet); break; } case kHeadlineSet: { ParseString (stream, fHeadline, charSet); break; } case kCreditSet: { ParseString (stream, fCredit, charSet); break; } case kSourceSet: { ParseString (stream, fSource, charSet); break; } case kCopyrightNoticeSet: { ParseString (stream, fCopyrightNotice, charSet); break; } case kCaptionSet: { ParseString (stream, fDescription, charSet); break; } case kCaptionWriterSet: { ParseString (stream, fDescriptionWriter, charSet); break; } // All other IPTC records are not part of the IPTC core // and/or are not kept in sync with XMP tags, so we ignore // them. default: break; } } } }
bool wxKeyTextCtrl::FromString(const wxString &s, int &mod, int &key) { return ParseString(s.c_str(), s.size(), mod, key); }
//-------------------------------------------------------------------------------------------------- static void ProcessChar ( Parser_t* parserPtr, char c ) //-------------------------------------------------------------------------------------------------- { switch (parserPtr->next) { case EXPECT_OBJECT_OR_ARRAY: // Throw away whitespace characters until '{' or '[' is found. if (c == '{') { PushContext(parserPtr, LE_JSON_CONTEXT_OBJECT, GetEventHandler(parserPtr)); parserPtr->next = EXPECT_MEMBER_OR_OBJECT_END; Report(parserPtr, LE_JSON_OBJECT_START); } else if (c == '[') { PushContext(parserPtr, LE_JSON_CONTEXT_ARRAY, GetEventHandler(parserPtr)); parserPtr->next = EXPECT_VALUE_OR_ARRAY_END; Report(parserPtr, LE_JSON_ARRAY_START); } else if (!isspace(c)) { Error(parserPtr, LE_JSON_SYNTAX_ERROR, "Document must start with '{' or '['."); } return; case EXPECT_MEMBER_OR_OBJECT_END: // Throw away whitespace until a '"' or '}' is found. if (c == '}') // Object end found. { Report(parserPtr, LE_JSON_OBJECT_END); PopContext(parserPtr); } else if (c == '"') // Start of member name (string) found. { PushContext(parserPtr, LE_JSON_CONTEXT_MEMBER, GetEventHandler(parserPtr)); parserPtr->next = EXPECT_STRING; } else if (!isspace(c)) { Error(parserPtr, LE_JSON_SYNTAX_ERROR, "Expected end of object (}) or beginning of object member name (\")."); } return; case EXPECT_COLON: // Throw away whitespace until a ':' is found. if (c == ':') { parserPtr->next = EXPECT_VALUE; } else if (!isspace(c)) { Error(parserPtr, LE_JSON_SYNTAX_ERROR, "Expected ':' after object member name."); } return; case EXPECT_VALUE: ParseValue(parserPtr, c); return; case EXPECT_COMMA_OR_OBJECT_END: // Throw away whitespace until a ',' or '}' is found. if (c == '}') // Object end found. { Report(parserPtr, LE_JSON_OBJECT_END); PopContext(parserPtr); } else if (c == ',') // Comma separator found. { parserPtr->next = EXPECT_MEMBER; } else if (!isspace(c)) { Error(parserPtr, LE_JSON_SYNTAX_ERROR, "Expected end of object (}) or beginning of object member name (\")."); } return; case EXPECT_MEMBER: // Throw away whitespace until a '"' is found. if (c == '"') // Start of member name (string) found. { PushContext(parserPtr, LE_JSON_CONTEXT_MEMBER, GetEventHandler(parserPtr)); parserPtr->next = EXPECT_STRING; } else if (!isspace(c)) { Error(parserPtr, LE_JSON_SYNTAX_ERROR, "Expected beginning of object member name (\")."); } return; case EXPECT_VALUE_OR_ARRAY_END: if (c == ']') { Report(parserPtr, LE_JSON_ARRAY_END); PopContext(parserPtr); } else { ParseValue(parserPtr, c); } return; case EXPECT_COMMA_OR_ARRAY_END: // Throw away whitespace until a ',' or ']' is found. if (c == ']') // Array end found. { Report(parserPtr, LE_JSON_ARRAY_END); PopContext(parserPtr); } else if (c == ',') // Comma separator found. { parserPtr->next = EXPECT_VALUE; } else if (!isspace(c)) { Error(parserPtr, LE_JSON_SYNTAX_ERROR, "Expected end of array (]) or a comma separator (,)."); } return; case EXPECT_STRING: ParseString(parserPtr, c); return; case EXPECT_NUMBER: if ((c == '.') || isdigit(c)) { AddToBuffer(parserPtr, c); } else { ProcessNumber(parserPtr); ProcessChar(parserPtr, c); } return; case EXPECT_TRUE: ParseConstant(parserPtr, c, "true"); if (strcmp(parserPtr->buffer, "true") == 0) { Report(parserPtr, LE_JSON_TRUE); PopContext(parserPtr); } return; case EXPECT_FALSE: ParseConstant(parserPtr, c, "false"); if (strcmp(parserPtr->buffer, "false") == 0) { Report(parserPtr, LE_JSON_FALSE); PopContext(parserPtr); } return; case EXPECT_NULL: ParseConstant(parserPtr, c, "null"); if (strcmp(parserPtr->buffer, "null") == 0) { Report(parserPtr, LE_JSON_NULL); PopContext(parserPtr); } return; case EXPECT_NOTHING: ///< Parsing stopped. return; } LE_FATAL("Internal error: Invalid JSON parser expectation %d.", parserPtr->next); }
void C_DoCommand (const char *cmd) { size_t argc, argsize; char **argv; char *args, *arg, *realargs; const char *data; DConsoleCommand *com; int check = -1; data = ParseString (cmd); if (!data) return; // Check if this is an action if (*com_token == '+') { check = GetActionBit (MakeKey (com_token + 1)); //if (Actions[check] < 255) // Actions[check]++; Actions[check] = 1; } else if (*com_token == '-') { check = GetActionBit (MakeKey (com_token + 1)); //if (Actions[check]) // Actions[check]--; Actions[check] = 0; if (check == ACTION_MLOOK && lookspring) { AddCommandString ("centerview"); } } // Check if this is a normal command if (check == -1) { argc = 1; argsize = strlen (com_token) + 1; realargs = new char[strlen (data) + 1]; strcpy (realargs, data); while ( (data = ParseString (data)) ) { argc++; argsize += strlen (com_token) + 1; } args = new char[argsize]; argv = new char *[argc]; arg = args; data = cmd; argsize = 0; while ( (data = ParseString (data)) ) { strcpy (arg, com_token); argv[argsize] = arg; arg += strlen (arg); *arg++ = 0; argsize++; } // Checking for matching commands follows this search order: // 1. Check the Commands map // 2. Check the CVars list command_map_t::iterator c = Commands().find(argv[0]); if (c != Commands().end()) { com = c->second; if(!safemode || strcmp(argv[0], "if")==0 || strcmp(argv[0], "exec")==0) { com->argc = argc; com->argv = argv; com->args = realargs; com->m_Instigator = consoleplayer().mo; com->Run (); } else { Printf (PRINT_HIGH, "Not a cvar command \"%s\"\n", argv[0]); } } else { // Check for any CVars that match the command cvar_t *var, *dummy; if ( (var = cvar_t::FindCVar (argv[0], &dummy)) ) { if (argc >= 2) { c = Commands().find("set"); if(c != Commands().end()) { com = c->second; com->argc = argc + 1; com->argv = argv - 1; // Hack com->m_Instigator = consoleplayer().mo; com->Run (); } else Printf (PRINT_HIGH, "set command not found\n"); } // [Russell] - Don't make the user feel inadequate, tell // them its either enabled, disabled or its other value else if (var->cstring()[0] == '1' && !(var->m_Flags & CVAR_NOENABLEDISABLE)) Printf (PRINT_HIGH, "\"%s\" is enabled.\n", var->name()); else if (var->cstring()[0] == '0' && !(var->m_Flags & CVAR_NOENABLEDISABLE)) Printf (PRINT_HIGH, "\"%s\" is disabled.\n", var->name()); else Printf (PRINT_HIGH, "\"%s\" is \"%s\"\n", var->name(), var->cstring()); } else { // We don't know how to handle this command Printf (PRINT_HIGH, "Unknown command \"%s\"\n", argv[0]); } } delete[] argv; delete[] args; delete[] realargs; } }
int GmshRemote() { GmshClient *client = Msg::GetGmshClient(); int rank = Msg::GetCommRank(); int nbDaemon = Msg::GetCommSize(); if(!client && rank == 0) return 0; if(client && nbDaemon < 2) computeAndSendVertexArrays(client); else if(client && nbDaemon >= 2 && rank == 0) gatherAndSendVertexArrays(client, false); while(1){ // on the node with MPI rank 0, communicate through a socket if (rank == 0) { // stop if we have no communications for 5 minutes int ret = client->Select(300, 0); if(!ret){ client->Info("Timout: stopping remote Gmsh..."); break; } else if(ret < 0){ client->Error("Error on select: stopping remote Gmsh..."); break; } int type, length, swap; if(!client->ReceiveHeader(&type, &length, &swap)){ client->Error("Did not receive message header: stopping remote Gmsh..."); break; } char *msg = new char[length + 1]; if(!client->ReceiveString(length, msg)){ client->Error("Did not receive message body: stopping remote Gmsh..."); delete [] msg; break; } if(type == GmshSocket::GMSH_STOP){ client->Info("Stopping remote Gmsh..."); delete [] msg; break; } else if(type == GmshSocket::GMSH_VERTEX_ARRAY){ ParseString(msg); #if !defined(HAVE_MPI) computeAndSendVertexArrays(client); #else int mpi_msg = MPI_GMSH_PARSE_STRING; MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD); gatherAndSendVertexArrays(client, swap); #endif } else if(type == GmshSocket::GMSH_MERGE_FILE){ MergeFile(msg); #if !defined(HAVE_MPI) computeAndSendVertexArrays(client); #else int mpi_msg = MPI_GMSH_MERGE_FILE; MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD); gatherAndSendVertexArrays(client, swap); #endif } else if(type == GmshSocket::GMSH_PARSE_STRING){ ParseString(msg); #if defined(HAVE_MPI) int mpi_msg = MPI_GMSH_PARSE_STRING; MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD); #endif } else if(type == GmshSocket::GMSH_SPEED_TEST){ client->Info("Sending huge array"); std::string huge(500000000, 'a'); client->SpeedTest(huge.c_str()); } else{ client->Error("Ignoring unknown message"); } delete [] msg; } else { // if we're not on the master node (rank != 0) wait for him... #if defined(HAVE_MPI) int mpi_msg; MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD); if (mpi_msg == MPI_GMSH_COMPUTE_VIEW) computeAndSendVertexArrays(); else if(mpi_msg == MPI_GMSH_SHUTDOWN) Msg::Exit(0); else if(mpi_msg == MPI_GMSH_PARSE_STRING){ int length; MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD); char msg[length]; MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD); ParseString(msg); } else if (mpi_msg == MPI_GMSH_MERGE_FILE){ int length; MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD); char msg[length]; MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD); MergeFile(msg); } #endif } } #if defined(HAVE_MPI) int mpi_msg = MPI_GMSH_SHUTDOWN; MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD); #endif return 0; }
/* ** Parses and executes the given command. ** */ void CommandHandler::ExecuteCommand(const WCHAR* command, MeterWindow* skin, bool multi) { if (command[0] == L'!') // Bang { ++command; // Skip "!" if (_wcsnicmp(L"Execute", command, 7) == 0) { command += 7; command = wcschr(command, L'['); if (!command) return; } else { if (_wcsnicmp(command, L"Rainmeter", 9) == 0) { // Skip "Rainmeter" for backwards compatibility command += 9; } std::wstring bang; std::vector<std::wstring> args; // Find the first space const WCHAR* pos = wcschr(command, L' '); if (pos) { bang.assign(command, 0, pos - command); args = ParseString(pos + 1, skin ? &skin->GetParser() : nullptr); } else { bang = command; } ExecuteBang(bang.c_str(), args, skin); return; } } if (multi && command[0] == L'[') // Multi-bang { std::wstring bangs = command; std::wstring::size_type start = std::wstring::npos; int count = 0; for (size_t i = 0, isize = bangs.size(); i < isize; ++i) { if (bangs[i] == L'[') { if (count == 0) { start = i; } ++count; } else if (bangs[i] == L']') { --count; if (count == 0 && start != std::wstring::npos) { // Change ] to nullptr bangs[i] = L'\0'; // Skip whitespace start = bangs.find_first_not_of(L" \t\r\n", start + 1, 4); ExecuteCommand(bangs.c_str() + start, skin, false); } } else if (bangs[i] == L'"' && isize > (i + 2) && bangs[i + 1] == L'"' && bangs[i + 2] == L'"') { i += 3; std::wstring::size_type pos = bangs.find(L"\"\"\"", i); if (pos != std::wstring::npos) { i = pos + 2; // Skip "", loop will skip last " } } } } else { // Check for built-ins if (_wcsnicmp(L"PLAY", command, 4) == 0) { if (command[4] == L' ' || // PLAY _wcsnicmp(L"LOOP ", &command[4], 5) == 0) // PLAYLOOP { command += 4; // Skip PLAY DWORD flags = SND_FILENAME | SND_ASYNC; if (command[0] != L' ') { flags |= SND_LOOP | SND_NODEFAULT; command += 4; // Skip LOOP } ++command; // Skip the space if (command[0] != L'\0') { std::wstring sound = command; // Strip the quotes std::wstring::size_type len = sound.length(); if (len >= 2 && sound[0] == L'"' && sound[len - 1] == L'"') { len -= 2; sound.assign(sound, 1, len); } if (skin) { skin->GetParser().ReplaceMeasures(sound); skin->MakePathAbsolute(sound); } PlaySound(sound.c_str(), nullptr, flags); } return; } else if (_wcsnicmp(L"STOP", &command[4], 4) == 0) // PLAYSTOP { PlaySound(nullptr, nullptr, SND_PURGE); return; } } // Run command std::wstring tmpSz = command; if (skin) { skin->GetParser().ReplaceMeasures(tmpSz); } RunCommand(tmpSz); } }
//------------------------------------------------------------------------------ Tokeniser::tokentype Tokeniser::GetNextToken () { tokentype TokenType = EMPTY; while ((TokenType == EMPTY) && !in.bad() && !atEOF) { curChar = GetNextChar (); //std::cout << curChar << " GetNextChar" << std::endl; if (IsWhiteSpace (curChar)) { // skip white space } else { if (IsPunctuation (curChar)) { // std::cout << curChar << " IsPunctuation" << std::endl; // classify punctuation token switch (curChar) { case '[': ParseComment (); break; case '\'': if (ParseString ()) TokenType = STRING; else TokenType = BAD; break; case '(': TokenType = LPAR; break; case ')': TokenType = RPAR; break; case '{': TokenType = LPAR; break; case '}': TokenType = RPAR; break; case '!': TokenType = BANG; break; case '#': TokenType = HASH; break; case '=': TokenType = EQUALS; break; case ';': TokenType = SEMICOLON; break; case ',': TokenType = COMMA; break; case '*': TokenType = ASTERIX; break; case ':': TokenType = COLON; break; case '-': TokenType = MINUS; break; case '"': TokenType = DOUBLEQUOTE; break; case '/': TokenType = BACKSLASH; break; default: TokenType = OTHER; break; } } else { // It's either a number, or a string if (isdigit (curChar)) { TokenType = ParseNumber(); /* if (ParseNumber ()) TokenType = NUMBER; else TokenType = BAD; */ } else { if (ParseToken ()) TokenType = STRING; else TokenType = BAD; } } } } if ((TokenType != STRING) && (TokenType != NUMBER)) { token = ""; token += curChar; } return TokenType; }
bool idListWindow::ParseInternalVar( const char* _name, idTokenParser* src ) { if( idStr::Icmp( _name, "horizontal" ) == 0 ) { horizontal = src->ParseBool(); return true; } if( idStr::Icmp( _name, "listname" ) == 0 ) { ParseString( src, listName ); return true; } if( idStr::Icmp( _name, "tabstops" ) == 0 ) { ParseString( src, tabStopStr ); return true; } if( idStr::Icmp( _name, "tabaligns" ) == 0 ) { ParseString( src, tabAlignStr ); return true; } if( idStr::Icmp( _name, "multipleSel" ) == 0 ) { multipleSel = src->ParseBool(); return true; } if( idStr::Icmp( _name, "tabvaligns" ) == 0 ) { ParseString( src, tabVAlignStr ); return true; } if( idStr::Icmp( _name, "tabTypes" ) == 0 ) { ParseString( src, tabTypeStr ); return true; } if( idStr::Icmp( _name, "tabIconSizes" ) == 0 ) { ParseString( src, tabIconSizeStr ); return true; } if( idStr::Icmp( _name, "tabIconVOffset" ) == 0 ) { ParseString( src, tabIconVOffsetStr ); return true; } idStr strName = _name; if( idStr::Icmp( strName.Left( 4 ), "mtr_" ) == 0 ) { idStr matName; const idMaterial* mat; ParseString( src, matName ); mat = declManager->FindMaterial( matName ); if( mat != NULL && !mat->TestMaterialFlag( MF_DEFAULTED ) ) { mat->SetSort( SS_GUI ); } iconMaterials.Set( _name, mat ); return true; } return idWindow::ParseInternalVar( _name, src ); }
CGnuDownloadShell* CGnuTransfers::LoadDownloadHosts(CString FilePath) { // Check if file already loaded for(int i = 0; i < m_DownloadList.size(); i++) if( m_DownloadList[i]->m_BackupPath.CompareNoCase(FilePath) == 0 ) return NULL; CStdioFile BackupFile; CString NextLine; CString Backup; if (BackupFile.Open(FilePath, CFile::modeRead)) { while (BackupFile.ReadString(NextLine)) Backup += NextLine + "\n"; BackupFile.Abort(); } if(Backup.IsEmpty() || Backup.Find("[Download]") == -1) return NULL; int CurrentPos = Backup.Find("[Download]"); CGnuDownloadShell* Download = new CGnuDownloadShell(this); Download->m_ShellStatus = (CGnuDownloadShell::Status) atoi(GetBackupString("Status", CurrentPos, Backup)); Download->m_Name = GetBackupString("Name", CurrentPos, Backup); Download->m_FileLength = _atoi64(GetBackupString("FileLength", CurrentPos, Backup)); Download->m_PartSize = atoi(GetBackupString("PartSize", CurrentPos, Backup)); Download->m_OverrideName = GetBackupString("OverrideName", CurrentPos, Backup); Download->m_OverridePath = GetBackupString("OverridePath", CurrentPos, Backup); Download->m_PartialPath = GetBackupString("PartialPath", CurrentPos, Backup); Download->m_BackupPath = FilePath; Download->m_Sha1Hash = GetBackupString("Sha1Hash", CurrentPos, Backup); Download->m_Search = GetBackupString("Search", CurrentPos, Backup); Download->m_AvgSpeed = atoi(GetBackupString("AvgSpeed", CurrentPos, Backup)); Download->m_HashComputed = atoi(GetBackupString("HashComputed", CurrentPos, Backup)); Download->m_HashVerified = atoi(GetBackupString("HashVerified", CurrentPos, Backup)); Download->m_FileMoved = atoi(GetBackupString("FileMoved", CurrentPos, Backup)); Download->m_ReasonDead = GetBackupString("ReasonDead", CurrentPos, Backup); Download->m_MetaXml = GetBackupString("Meta", CurrentPos, Backup); Download->m_UseProxy = atoi(GetBackupString("UseProxy", CurrentPos, Backup)); Download->m_DefaultProxy = GetBackupString("DefaultProxy", CurrentPos, Backup); Download->m_TigerHash = GetBackupString("TigerHash", CurrentPos, Backup); Download->m_TreeSize = atoi(GetBackupString("TreeSize", CurrentPos, Backup)); Download->m_TreeRes = atoi(GetBackupString("TreeRes", CurrentPos, Backup)); if(Download->m_TreeSize) { Download->m_TigerTree = new byte[Download->m_TreeSize]; memset(Download->m_TigerTree, 0, Download->m_TreeSize); } if(Download->m_TigerTree) { CString Value = GetBackupString("TigerTree", CurrentPos, Backup); int buffPos = 0; int dotPos = Value.Find("."); while(dotPos != -1 && buffPos < Download->m_TreeSize) { DecodeBase32( Value.Mid(dotPos - 39, 39), 39, Download->m_TigerTree + buffPos, Download->m_TreeSize - buffPos ); buffPos += 24; dotPos = Value.Find(".", dotPos + 1); } } Download->Init(Download->m_Name, Download->m_FileLength, HASH_SHA1, Download->m_Sha1Hash); // Load Host info if( !Download->m_FileMoved ) for(int i = 0; ; i++) { CurrentPos = Backup.Find("[Host " + NumtoStr(i) + "]"); if(CurrentPos == -1) break; CurrentPos += 5; // Host in header and value conflict FileSource nResult; nResult.Name = GetBackupString("Name", CurrentPos, Backup); nResult.NameLower = nResult.Name; nResult.NameLower.MakeLower(); nResult.Sha1Hash = GetBackupString("Sha1Hash", CurrentPos, Backup); //nResult.BitprintHash = GetBackupString("BitprintHash", CurrentPos, Backup); nResult.FileIndex = atoi(GetBackupString("FileIndex", CurrentPos, Backup)); nResult.Size = _atoi64(GetBackupString("Size", CurrentPos, Backup)); nResult.Address.Host = StrtoIP(GetBackupString("Host", CurrentPos, Backup)); nResult.Address.Port = atoi(GetBackupString("Port", CurrentPos, Backup)); nResult.Network = atoi(GetBackupString("Network", CurrentPos, Backup)); nResult.HostStr = GetBackupString("HostStr", CurrentPos, Backup); nResult.Path = GetBackupString("Path", CurrentPos, Backup); nResult.Speed = atoi(GetBackupString("Speed", CurrentPos, Backup)); nResult.Vendor = GetBackupString("Vendor", CurrentPos, Backup); nResult.Firewall = atoi(GetBackupString("Firewall", CurrentPos, Backup)) != 0; nResult.OpenSlots = atoi(GetBackupString("OpenSlots", CurrentPos, Backup)) != 0; nResult.Busy = atoi(GetBackupString("Busy", CurrentPos, Backup)) != 0; nResult.Stable = atoi(GetBackupString("Stable", CurrentPos, Backup)) != 0; nResult.ActualSpeed = atoi(GetBackupString("ActualSpeed", CurrentPos, Backup)) != 0; nResult.SupportF2F = atoi(GetBackupString("SupportF2F", CurrentPos, Backup)) != 0; DecodeBase16(GetBackupString("PushID", CurrentPos, Backup), 32, (byte*) &nResult.PushID, 16); CString Nodes = GetBackupString("Direct", CurrentPos, Backup); while(!Nodes.IsEmpty()) nResult.DirectHubs.push_back( StrtoIPv4(ParseString(Nodes, ',')) ); nResult.GnuRouteID = 0; nResult.Distance = 7; //nResult.Icon = m_pCore->GetIconIndex(nResult.Name); Download->AddHost(nResult); } //Download->m_DoReQuery = true; // Add Download to list m_DownloadAccess.Lock(); m_DownloadList.push_back(Download); m_DownloadAccess.Unlock(); TransferLoadMeta(); if(Download->m_ShellStatus == CGnuDownloadShell::eActive) Download->Start(); return Download; }