CAtom *Decode( const string &x, unsigned long iStart ) { if( iStart < x.size( ) ) { if( x[iStart] == 'i' ) return DecodeLong( x, iStart ); else if( isdigit( x[iStart] ) ) return DecodeString( x, iStart ); else if( x[iStart] == 'l' ) return DecodeList( x, iStart ); else if( x[iStart] == 'd' ) return DecodeDicti( x, iStart ); string temp = x.substr( iStart ); UTIL_LogPrint( "error decoding - found unexpected character %u, halting decode\n", (unsigned char)x[iStart] ); } else UTIL_LogPrint( "error decoding - out of range\n" ); return NULL; }
void FbGenreFunction::Execute(wxSQLite3FunctionContext& ctx) { if (ctx.GetArgCount() == 1) ctx.SetResult( DecodeList(ctx.GetString(0)) ); }
bool TorrentFile::ParseTorrentFile(unsigned short * buf, int size) { string tempstring; int pos = 1; if(buf[0] != 'd') { tempstring = ""; strcpy(m_url,tempstring.c_str()); return false; } int len = size; if(m_data == NULL) m_data = new unsigned short[len+1]; memcpy(m_data, buf, len); for(int i = 0; i < len; i++) { if(m_data[i] != buf[i]) { m_data[i] = buf[i]; } } m_data[len] = 0; m_size = size; info_start = 0; int info_end = 0; bool havePieces = false; while(true) { tempstring = ParseNext(buf, &pos); // The URL if(tempstring.compare("announce") == 0) { tempstring = DecodeString(buf, &pos); strcpy(m_url,tempstring.c_str()); } else if(tempstring.compare("announce-list") == 0) { AtomList al = DecodeList(buf, &pos); v_announce_list = al.v_elements; } else if(tempstring.compare("info") == 0) { info_start = pos; } // Creation date else if(tempstring.compare("creation date") == 0) { m_creationdate = DecodeInt(buf,&pos); } // Length else if(tempstring.compare("length") == 0) { m_length += DecodeInt(buf,&pos); } // Name else if(tempstring.compare("name") == 0) { tempstring = DecodeString(buf, &pos); strcpy(m_name,tempstring.c_str()); } // Piece Length else if(tempstring.compare("piece length") == 0) { m_piecelength = DecodeInt(buf,&pos); } // Pieces else if(tempstring.compare("pieces") == 0) { v_pieces = DecodePieces(buf, &pos); m_numpieces = (int)v_pieces.size(); havePieces = true; } if(havePieces && (buf[pos] == 'e') || tempstring.compare("break") == 0) { info_end = pos; info_len = info_end-info_start+1; break; } } b_is_valid = true; return true; }