void CDlgConnectionSpeedInfo::UpdateStats(void) { UINT64 u = _TumMgr.getConnectionBandwidth (true); if (u == UINT64_MAX) { SetDlgItemText (IDC__DOWNSPEEDVAL, LS (L_UNKNOWN)); } else { CString str = BytesToString (u); str += _T ("/"); str += LS (L_S); str += _T (" ("); str += getMBitsText (u); str += _T (")"); SetDlgItemText (IDC__DOWNSPEEDVAL, str); } u = _TumMgr.getConnectionBandwidth (false); if (u == UINT64_MAX) { SetDlgItemText (IDC__UPSPEEDVAL, LS (L_UNKNOWN)); } else { CString str = BytesToString (u); str += _T ("/"); str += LS (L_S); SetDlgItemText (IDC__UPSPEEDVAL, str); } }
void CBtDld_Files::AddFiles(fs::ListTree <vmsBtDownloadManager::vmsFile>* pTree, CColumnTreeCtrl *pTreeCtrl, HTREEITEM hRoot) { for (int i = 0; i < pTree->GetLeafCount (); i++) { vmsBtDownloadManager::vmsFile &file = pTree->GetLeaf (i)->GetData (); if (file.nIndex == -1) { HTREEITEM hItem = pTreeCtrl->GetTreeCtrl ().InsertItem (TVIF_TEXT | TVIF_PARAM, file.strName, 0, 0, 0, 0, (DWORD_PTR)NULL, hRoot, TVI_LAST); pTreeCtrl->SetItemText (hItem, 1, BytesToString (file.nFileSize)); AddFiles (pTree->GetLeaf (i), pTreeCtrl, hItem); pTreeCtrl->GetTreeCtrl ().SetCheck (hItem, vmsTreeCtrlHelper::isAtLeast1ChildChecked (&pTreeCtrl->GetTreeCtrl (), hItem)); } else { _inc_filesTreeData *pTD = new _inc_filesTreeData; m_vToDelete.push_back (pTD); pTD->nFileIndex = file.nIndex; pTD->nFilePriority = file.iPriority; HTREEITEM hItem = pTreeCtrl->GetTreeCtrl ().InsertItem (TVIF_TEXT | TVIF_PARAM, file.strName, 0, 0, 0, 0, (DWORD_PTR)pTD, hRoot, TVI_LAST); pTreeCtrl->SetItemText (hItem, 1, BytesToString (file.nFileSize)); pTreeCtrl->GetTreeCtrl ().SetCheck (hItem, file.iPriority != 0); } } }
void CDownloads_Bittorrent_Peers::UpdatePeersDetails() { if (m_vPeers.size () == 0) return; if ((size_t)GetItemCount () != m_vPeers.size ()) return; for (size_t i = 0; i < m_vPeers.size (); i++) { _inc_peer &peer = m_vPeers [i]; CString str; str.Format ("%s, %s/%s", BytesToString (peer.uBytesDownloaded), BytesToString (peer.uDownloadSpeed), LS (L_S)); SetItemText (i, 2, str); str.Format ("%s, %s/%s", BytesToString (peer.uBytesUploaded), BytesToString (peer.uUploadSpeed), LS (L_S)); SetItemText (i, 3, str); } }
StatusBar::StatusBar(QWidget* parent) : KStatusBar(parent), speed(0),up_speed(0),down_speed(0), transfer(0),up_transfer(0),down_transfer(0), dht_status(0),dht_peers(0),dht_tasks(0),dht_on(false) { QString s = i18n("Speed down: %1 / up: %2",BytesPerSecToString((double)down_speed),BytesPerSecToString((double)up_speed)); QString t = i18n("Transferred down: %1 / up: %2",BytesToString(down_transfer),BytesToString(up_transfer)); dht_status = new QLabel(i18n("DHT: off"),this); dht_status->setFrameShape(QFrame::Box); dht_status->setFrameShadow(QFrame::Sunken); addPermanentWidget(dht_status); speed = new QLabel(s,this); speed->setFrameShape(QFrame::Box); speed->setFrameShadow(QFrame::Sunken); addPermanentWidget(speed); transfer = new QLabel(t,this); transfer->setFrameShape(QFrame::Box); transfer->setFrameShadow(QFrame::Sunken); addPermanentWidget(transfer); addPermanentWidget(new KStatusBarOfflineIndicator(this)); }
void CDownloads_Bittorrent_Files::AddFiles(fs::ListTree <vmsBtDownloadManager::vmsFile>* pTree, CColumnTreeCtrl *pTreeCtrl, HTREEITEM hRoot) { for (int i = 0; i < pTree->GetLeafCount (); i++) { vmsBtDownloadManager::vmsFile &file = pTree->GetLeaf (i)->GetData (); if (file.nIndex == -1) { HTREEITEM hItem = pTreeCtrl->GetTreeCtrl ().InsertItem (TVIF_TEXT | TVIF_PARAM | TVIF_STATE, file.strName, 0, 0, TVIS_EXPANDED, TVIS_EXPANDED, -1, hRoot, TVI_LAST); pTreeCtrl->SetItemText (hItem, 1, BytesToString (file.nFileSize)); AddFiles (pTree->GetLeaf (i), pTreeCtrl, hItem); } else { HTREEITEM hItem = pTreeCtrl->GetTreeCtrl ().InsertItem (TVIF_TEXT | TVIF_PARAM | TVIF_PARAM, file.strName, 0, 0, 0, 0, file.nIndex, hRoot, TVI_LAST); pTreeCtrl->SetItemText (hItem, 1, BytesToString (file.nFileSize)); CString str; str.Format ("%d%%", m_dld->pMgr->GetBtDownloadMgr ()->get_FilePercentDone (file.nIndex)); pTreeCtrl->SetItemText (hItem, 2, str); if (file.iPriority == 0) pTreeCtrl->SetItemText (hItem, 3, LS (L_PRIORITY_SKIP)); else if (file.iPriority == 1) pTreeCtrl->SetItemText (hItem, 3, LS (L_PRIORITY_NORMAL)); else pTreeCtrl->SetItemText (hItem, 3, LS (L_PRIORITY_HIGH)); } } }
void StatusBar::updateTransfer(bt::Uint64 up,bt::Uint64 down) { if (up == up_transfer && down == down_transfer) return; up_transfer = up; down_transfer = down; QString t = i18n("Transferred down: %1 / up: %2",BytesToString(down_transfer),BytesToString(up_transfer)); transfer->setText(t); }
void ResourcesForm::refreshNetworkViews() { if (mNetworkInfo == NULL) { return; } QString receivingRate = QString::fromStdString(BytesToString(mNetworkInfo->getReceivingRate())); receivingRate += "/s"; QString sendingRate = QString::fromStdString(BytesToString(mNetworkInfo->getSendingRate())); sendingRate += "/s"; ui->labReceivingRate->setText(receivingRate); ui->labSendingRate->setText(sendingRate); refreshNetTableView(); }
static void cfg_OldToNew(const CFGSTRUCT *cfgst) { int x=0; while(cfgst[x].ptr) { //structure contains another embedded structure. recurse. if(!cfgst[x].name) { cfg_OldToNew((CFGSTRUCT*)cfgst[x].ptr); x++; continue; } if(cfgst[x].len) { //binary data cfgmap[cfgst[x].name] = BytesToString(cfgst[x].ptr,cfgst[x].len); } else { //string data if(*(char**)cfgst[x].ptr) cfgmap[cfgst[x].name] = *(char**)cfgst[x].ptr; else cfgmap[cfgst[x].name] = ""; } x++; } }
void TorrentListGenerator::get(HttpClientHandler* hdlr, const QHttpRequestHeader& hdr) { Q_UNUSED(hdr); HttpResponseHeader rhdr(200); server->setDefaultResponseHeaders(rhdr,"text/xml",true); QByteArray output_data; QXmlStreamWriter out(&output_data); out.setAutoFormatting(true); out.writeStartDocument(); out.writeStartElement("torrents"); kt::QueueManager* qman = core->getQueueManager(); kt::QueueManager::iterator i = qman->begin(); while (i != qman->end()) { bt::TorrentInterface* ti = *i; const bt::TorrentStats & s = ti->getStats(); out.writeStartElement("torrent"); writeElement(out,"name",ti->getDisplayName()); writeElement(out,"info_hash",ti->getInfoHash().toString()); writeElement(out,"status",s.statusToString()); writeElement(out,"bytes_downloaded",BytesToString(s.bytes_downloaded)); writeElement(out,"bytes_uploaded",BytesToString(s.bytes_uploaded)); writeElement(out,"total_bytes",BytesToString(s.total_bytes)); writeElement(out,"total_bytes_to_download",BytesToString(s.total_bytes_to_download)); writeElement(out,"download_rate",BytesPerSecToString(s.download_rate)); writeElement(out,"upload_rate",BytesPerSecToString(s.upload_rate)); writeElement(out,"num_peers",QString::number(s.num_peers)); writeElement(out,"seeders",QString::number(s.seeders_connected_to)); writeElement(out,"seeders_total",QString::number(s.seeders_total)); writeElement(out,"leechers",QString::number(s.leechers_connected_to)); writeElement(out,"leechers_total",QString::number(s.leechers_total)); writeElement(out,"running",s.running ? "1" : "0"); writeElement(out,"percentage",QString::number(Percentage(s),'f',2)); writeElement(out,"num_files",QString::number(ti->getNumFiles())); out.writeEndElement(); i++; } out.writeEndElement(); out.writeEndDocument(); hdlr->send(rhdr,output_data); }
void GlobalDataGenerator::get(HttpClientHandler* hdlr, const QHttpRequestHeader& hdr) { Q_UNUSED(hdr); HttpResponseHeader rhdr(200); server->setDefaultResponseHeaders(rhdr, "text/xml", true); CurrentStats s = core->getStats(); QByteArray output_data; QXmlStreamWriter out(&output_data); out.setAutoFormatting(true); out.writeStartDocument(); out.writeStartElement("global_data"); writeElement(out, "transferred_down", BytesToString(s.bytes_downloaded)); writeElement(out, "transferred_up", BytesToString(s.bytes_uploaded)); writeElement(out, "speed_down", BytesPerSecToString(s.download_speed)); writeElement(out, "speed_up", BytesPerSecToString(s.upload_speed)); writeElement(out, "dht", Settings::dhtSupport() ? "1" : "0"); writeElement(out, "encryption", Settings::useEncryption() ? "1" : "0"); out.writeEndElement(); out.writeEndDocument(); hdlr->send(rhdr, output_data); }
//--------------------------------------------------------------------------- void __fastcall TfrmHeartMonitor::DoDescriptorRead (System::TObject* const Sender, TBluetoothGattDescriptor* const ADescriptor, TBluetoothGattStatus AGattStatus) { if (AGattStatus != TBluetoothGattStatus::Success) { Memo1->Lines->Add("Error reading Characteristc " + ADescriptor->UUIDName + ": " + StrToInt(static_cast<int>(AGattStatus))); } else { String LSValue = BytesToString(ADescriptor->GetValue()); Memo1->Lines->Add(ADescriptor->UUIDName + " Value: " + LSValue); } }
void ResourcesForm::refreshNetTableView() { QStringList cellList; cellList << tr("下载") << QString::fromStdString(BytesToString(mNetworkInfo->getReceivedBytes())) << QString::number(mNetworkInfo->getReceivedPackets()) << QString::number(mNetworkInfo->getReceivedErrors()) << QString::fromStdString(FloatToPercent(mNetworkInfo->getReceivedErrorRate())) << QString::number(mNetworkInfo->getReceivedDrop()) << QString::fromStdString(FloatToPercent(mNetworkInfo->getReceivedDropRate())); TableViewHelper::setTableItem(mNetItemModel, cellList, 0); cellList.clear(); cellList << tr("上传") << QString::fromStdString(BytesToString(mNetworkInfo->getSentBytes())) << QString::number(mNetworkInfo->getSentPackets()) << QString::number(mNetworkInfo->getSentErrors()) << QString::fromStdString(FloatToPercent(mNetworkInfo->getSentErrorRate())) << QString::number(mNetworkInfo->getSentDrop()) << QString::fromStdString(FloatToPercent(mNetworkInfo->getSentDropRate())); TableViewHelper::setTableItem(mNetItemModel, cellList, 1); }
//--------------------------------------------------------------------------- void __fastcall TfrmHeartMonitor::DoCharacteristicRead(System::TObject* const Sender, TBluetoothGattCharacteristic* const ACharacteristic, TBluetoothGattStatus AGattStatus) { if(AGattStatus != TBluetoothGattStatus::Success) { Memo1->Lines->Add("Error reading Characteristic " + ACharacteristic->UUIDName + ": " + IntToStr(static_cast<int>(AGattStatus))); } else { String LSValue = BytesToString(ACharacteristic->Value); Memo1->Lines->Add(ACharacteristic->UUIDName + " Value: " + LSValue); ManageCharacteristicData(ACharacteristic); } }
void ResourcesForm::refreshMemoryViews() { if (mMemoryInfo == NULL) { return; } ui->psbMemory->setValue(mMemoryInfo->getRAMUsage() * 1000); ui->psbSwap->setValue(mMemoryInfo->getSwapUsage() * 1000); unsigned long totalRAM = mMemoryInfo->getTotalRAM(); unsigned long usedRAM = totalRAM - mMemoryInfo->getFreeRAM(); unsigned long totalSwap = mMemoryInfo->getTotalSwap(); unsigned long usedSwap = totalSwap - mMemoryInfo->getFreeSwap(); QString strTotalRAM = QString::fromStdString(BytesToString(totalRAM)); QString strUsedRAM = QString::fromStdString(BytesToString(usedRAM)); QString strTotalSwap = QString::fromStdString(BytesToString(totalSwap)); QString strUsedSwap = QString::fromStdString(BytesToString(usedSwap)); QString strPageSize = QString::fromStdString(BytesToString(mMemoryInfo->getPageSize())); ui->labMemory->setText(strUsedRAM + tr("/") + strTotalRAM); ui->labSwap->setText(strUsedSwap + tr("/") + strTotalSwap); ui->labPageSize->setText(strPageSize); }
void ChunkDownloadView::changeTC(TorrentInterface* tc) { curr_tc = tc; if (!curr_tc) { setEnabled(false); } else { setEnabled(true); const TorrentStats& s = curr_tc.data()->getStats(); m_total_chunks->setText(QString::number(s.total_chunks)); m_size_chunks->setText(BytesToString(s.chunk_size)); } model->changeTC(tc); }
void Downloader::pieceReceived(const Piece & p) { if (cman.completed()) return; ChunkDownload* cd = downloading_chunks.find(p.getIndex()); if (!cd) { unnecessary_data += p.getLength(); Out(SYS_DIO|LOG_DEBUG) << "Unnecessary piece (chunk already finished), total unnecessary data : " << BytesToString(unnecessary_data) << endl; return; } bool ok = false; if (cd->pieceReceived(p,ok)) { if (tmon) tmon->downloadRemoved(cd); if (ok) bytes_downloaded += p.getLength(); if (!finished(cd)) { // if the chunk fails don't count the bytes downloaded if (cd->getChunk()->getSize() > bytes_downloaded) bytes_downloaded = 0; else bytes_downloaded -= cd->getChunk()->getSize(); downloading_chunks.erase(p.getIndex()); } else { downloading_chunks.erase(p.getIndex()); foreach (WebSeed* ws,webseeds) { if (ws->inCurrentRange(p.getIndex())) ws->chunkDownloaded(p.getIndex()); } } } else { if (ok)
void CDlg_Options_Downloads_Network::FillConnectionSpeedCombo () { m_wndConnectionSpeed.ResetContent (); UINT64 uCurrentValue = m_uConnectionSpeedChoosenValue == UINT64_MAX ? _TumMgr.getConnectionBandwidthSpecifiedByUser (true) : m_uConnectionSpeedChoosenValue; int iSelection = -1; for (size_t i = 0; i < m_vConnectionSpeeds.size (); i++) { UINT64 uVal = m_vConnectionSpeeds [i]; m_wndConnectionSpeed.AddString (BytesToString (uVal) + _T ("/") + LS (L_S)); if (uVal == uCurrentValue) iSelection = (int)i; } m_wndConnectionSpeed.AddString (LS (L_DETERMINE_AUTOMATICALLY)); m_wndConnectionSpeed.AddString (LS (L_CHOOSE__GOESDLG)); m_wndConnectionSpeed.SetCurSel (iSelection != -1 ? iSelection : m_vConnectionSpeeds.size ()); }
int main( int argc, char *argv[] ) { int rlines; char **in = ReadFile("./input/is1c7.txt",200,&rlines); char *ms = MergeStrings( in, rlines, '\0'); byte_t *data; int nb = B64StringToBytes( &data, ms ); int i; for( i = 0; i < rlines; i++ ) free(in[i]); free(in); printf("ms:%s\n",ms); free(ms); if( nb%16 ) { printf("WRONG SIZE\n"); return -1; } printf("nb:%d\n",nb); const byte_t key[16] = {'Y','E','L','L','O','W',' ','S', 'U','B','M','A','R','I','N','E'}; AESDecryptECB( data, key, nb, 16 ); /*for( i = 0; i < nb; i+=16 ) { DecryptDataAES( data+i, key, 4 ); }*/ printf("i:%d\n",i); char *str; BytesToString( &str, data, nb ); printf("%s\n",str); return 0; }
BOOL CDlgExportHistory::ExportHistory(LPCSTR pszFile, fs::list <fsDLHistoryRecord*> &vpHist, BOOL bAppend) { HANDLE hFile = CreateFile (pszFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return FALSE; CString str; if (bAppend && GetLastError () == ERROR_ALREADY_EXISTS) { DWORD dwSize = GetFileSize (hFile, NULL); if (dwSize > 10000) { SetFilePointer (hFile, dwSize - 10000, NULL, FILE_BEGIN); dwSize = 10000; } DWORD dw; LPSTR psz = new char [dwSize+1]; ReadFile (hFile, psz, dwSize, &dw, NULL); psz [dwSize] = 0; int nLen = lstrlen (psz); if (nLen != (int) dwSize) { CloseHandle (hFile); return FALSE; } LPSTR psz2 = psz + nLen - 7; while (psz2 != psz) { if (_memicmp (psz2, "</body>", 7) == 0) { *psz2 = 0; break; } *psz2--; } if (psz2 == psz) { CloseHandle (hFile); return FALSE; } SetFilePointer (hFile, (psz2 - psz) - nLen, NULL, FILE_END); SetEndOfFile (hFile); delete [] psz; } else { SetEndOfFile (hFile); str = "<html>\n"; str += "<style type=\"text/css\">\n"; str += "<!--\n"; str += "H3 { font-size: 19px; font-family: Tahoma; color: #cc0000;}\n"; str += "TR { font-size: 12px; font-family: Tahoma; color: #000033}\n"; str += "TD { font-size: 12px; font-family: Tahoma; color: #000033}\n"; str += "A,A:visited,A:active { text-decoration: none; }\n"; str += "A:hover { text-decoration: underline; }\n"; str += "-->\n"; str += "</style>\n"; str += "<body>\n"; str += "<h3>"; str += LS (L_FDMHIST); str += "</h3>\n"; } for (int i = 0; i < vpHist.size (); i++) { fsDLHistoryRecord* rec = vpHist [i]; str += "<table width=\"75%\" border=\"1\">\n"; str += "<tr><td width=\"180\">"; str += LS (L_URLOFDOWNLOAD); str += ":</td>"; str += "<td><a href=\""; str += rec->strURL; str += "\"> "; str += rec->strURL; str += "</a></td></tr>\n"; if (rec->dateDownloaded.dwHighDateTime) { str += "<tr><td>"; str += LS (L_DLDEDTOFILE); str += ":</td><td>"; str += rec->strSavedTo; str += "</td></tr>\n"; str += "<tr><td>"; str += LS (L_SIZEOFFILE); str += ":</td><td>"; str += BytesToString (rec->uFileSize); str += "</td></tr>\n"; str += "<tr><td>"; str += LS (L_DLDWASCOMPLETED); str += ":</td><td>"; str += TimeToStr (rec->dateDownloaded); str += "</td></tr>\n"; } else { str += "<tr><td>"; str += LS (L_DLDWASDELETED); str += ":</td><td>"; str += TimeToStr (rec->dateRecordAdded); str += "</td></tr>\n"; } if (rec->strComment != "") { CString str2 = rec->strComment; str2.Replace ("\n", "<br>"); str += "<tr><td>"; str += LS (L_DESC); str += ":</td><td>"; str += str2; str += "</td></tr>\n"; } str += "</table><br>\n"; } str += "</body></html>"; DWORD dw; WriteFile (hFile, str, str.GetLength (), &dw, NULL); CloseHandle (hFile); return TRUE; }
/** * \internal * \brief Write meta data on a single line json record */ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const File *ff) { MemBuffer *buffer = (MemBuffer *)aft->buffer; json_t *js = CreateJSONHeader((Packet *)p, 0, "file"); //TODO const if (unlikely(js == NULL)) return; /* reset */ MemBufferReset(buffer); json_t *hjs = json_object(); if (unlikely(hjs == NULL)) { json_decref(js); return; } json_object_set_new(hjs, "url", LogFileMetaGetUri(p, ff)); json_object_set_new(hjs, "hostname", LogFileMetaGetHost(p, ff)); json_object_set_new(hjs, "http_refer", LogFileMetaGetReferer(p, ff)); json_object_set_new(hjs, "http_user_agent", LogFileMetaGetUserAgent(p, ff)); json_object_set_new(js, "http", hjs); json_t *fjs = json_object(); if (unlikely(fjs == NULL)) { json_decref(hjs); json_decref(js); return; } char *s = BytesToString(ff->name, ff->name_len); json_object_set_new(fjs, "filename", json_string(s)); if (s != NULL) SCFree(s); if (ff->magic) json_object_set_new(fjs, "magic", json_string((char *)ff->magic)); else json_object_set_new(fjs, "magic", json_string("unknown")); switch (ff->state) { case FILE_STATE_CLOSED: json_object_set_new(fjs, "state", json_string("CLOSED")); #ifdef HAVE_NSS if (ff->flags & FILE_MD5) { size_t x; int i; char *s = SCMalloc(256); if (likely(s != NULL)) { for (i = 0, x = 0; x < sizeof(ff->md5); x++) { i += snprintf(&s[i], 255-i, "%02x", ff->md5[x]); } json_object_set_new(fjs, "md5", json_string(s)); SCFree(s); } } #endif break; case FILE_STATE_TRUNCATED: json_object_set_new(fjs, "state", json_string("TRUNCATED")); break; case FILE_STATE_ERROR: json_object_set_new(fjs, "state", json_string("ERROR")); break; default: json_object_set_new(fjs, "state", json_string("UNKNOWN")); break; } json_object_set_new(fjs, "stored", (ff->flags & FILE_STORED) ? json_true() : json_false()); json_object_set_new(fjs, "size", json_integer(ff->size)); json_object_set_new(js, "file", fjs); OutputJSONBuffer(js, aft->filelog_ctx->file_ctx, buffer); json_object_del(js, "file"); json_object_del(js, "http"); json_object_clear(js); json_decref(js); }
/** * \internal * \brief Write meta data on a single line json record */ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const File *ff) { json_t *js = CreateJSONHeader((Packet *)p, 0, "fileinfo"); //TODO const json_t *hjs = NULL; if (unlikely(js == NULL)) return; /* reset */ MemBufferReset(aft->buffer); switch (p->flow->alproto) { case ALPROTO_HTTP: hjs = JsonHttpAddMetadata(p->flow, ff->txid); if (hjs) json_object_set_new(js, "http", hjs); break; case ALPROTO_SMTP: hjs = JsonSMTPAddMetadata(p->flow, ff->txid); if (hjs) json_object_set_new(js, "smtp", hjs); hjs = JsonEmailAddMetadata(p->flow, ff->txid); if (hjs) json_object_set_new(js, "email", hjs); break; } json_object_set_new(js, "app_proto", json_string(AppProtoToString(p->flow->alproto))); json_t *fjs = json_object(); if (unlikely(fjs == NULL)) { json_decref(js); return; } char *s = BytesToString(ff->name, ff->name_len); json_object_set_new(fjs, "filename", json_string(s)); if (s != NULL) SCFree(s); if (ff->magic) json_object_set_new(fjs, "magic", json_string((char *)ff->magic)); switch (ff->state) { case FILE_STATE_CLOSED: json_object_set_new(fjs, "state", json_string("CLOSED")); #ifdef HAVE_NSS if (ff->flags & FILE_MD5) { size_t x; int i; char s[256]; for (i = 0, x = 0; x < sizeof(ff->md5); x++) { i += snprintf(&s[i], 255-i, "%02x", ff->md5[x]); } json_object_set_new(fjs, "md5", json_string(s)); } #endif break; case FILE_STATE_TRUNCATED: json_object_set_new(fjs, "state", json_string("TRUNCATED")); break; case FILE_STATE_ERROR: json_object_set_new(fjs, "state", json_string("ERROR")); break; default: json_object_set_new(fjs, "state", json_string("UNKNOWN")); break; } json_object_set_new(fjs, "stored", (ff->flags & FILE_STORED) ? json_true() : json_false()); if (ff->flags & FILE_STORED) { json_object_set_new(fjs, "file_id", json_integer(ff->file_id)); } json_object_set_new(fjs, "size", json_integer(ff->size)); json_object_set_new(fjs, "tx_id", json_integer(ff->txid)); /* originally just 'file', but due to bug 1127 naming it fileinfo */ json_object_set_new(js, "fileinfo", fjs); OutputJSONBuffer(js, aft->filelog_ctx->file_ctx, &aft->buffer); json_object_del(js, "fileinfo"); switch (p->flow->alproto) { case ALPROTO_HTTP: json_object_del(js, "http"); break; case ALPROTO_SMTP: json_object_del(js, "smtp"); json_object_del(js, "email"); break; } json_object_clear(js); json_decref(js); }
BOOL CDlgCreateFlvDownloads::OnInitDialog() { assert (!m_initialized); m_changing_dlg_state = true; CDialog::OnInitDialog(); if (m_selected.size () != m_vDlds.size ()) m_selected.resize (m_vDlds.size (), true); m_selectedByUserItself.resize (m_selected.size ()); if (m_pUiWindow) m_pUiWindow->setWindow (m_hWnd); SetDlgItemText (IDC_WPURL, m_strWebPageUrl); CRect rc; m_wndFlvList.GetClientRect (&rc); m_wndFlvList.InsertColumn (0, LS (L_TITLE), LVCFMT_LEFT); m_wndFlvList.InsertColumn (1, LS (L_SIZE), LVCFMT_LEFT); if (!m_ui_customizations.no_url_column) m_wndFlvList.InsertColumn (2, _T("URL"), LVCFMT_LEFT); int nMaxW0 = 0; int nMaxW1 = 0; for (size_t i = 0; i < m_vDlds.size (); i++) { const auto& dl = m_vDlds [i]; m_urlToIndex [dl.strUrl] = i; if (!dl.strLinkedAudioUrl.IsEmpty ()) { m_urlVideoToAudio [dl.strUrl] = dl.strLinkedAudioUrl; m_urlAudioToVideo.insert (std::make_pair (dl.strLinkedAudioUrl, dl.strUrl)); } m_wndFlvList.InsertItem (i, m_vDlds [i].strTitle); int nW0 = m_wndFlvList.GetStringWidth (m_vDlds [i].strTitle); CString strSize; if (m_vDlds [i].uSize != _UI64_MAX) strSize = BytesToString (m_vDlds [i].uSize, true); int nW1 = m_wndFlvList.GetStringWidth (strSize); m_wndFlvList.SetItemText (i, 1, strSize); if (!m_ui_customizations.no_url_column) m_wndFlvList.SetItemText (i, 2, m_vDlds [i].strUrl); nMaxW0 = max (nMaxW0, nW0); nMaxW1 = max (nMaxW1, nW1); } auto vscroll_payload = GetSystemMetrics (SM_CXVSCROLL) + 3; if (!m_ui_customizations.no_url_column) { int n = rc.Width () / 3; if (n > nMaxW0) n = nMaxW0; m_wndFlvList.SetColumnWidth (0, n+20); m_wndFlvList.SetColumnWidth (1, nMaxW1+20); m_wndFlvList.SetColumnWidth (2, rc.Width () - n-20 - nMaxW1-20 - vscroll_payload); } else { nMaxW0 += 20; nMaxW1 += 20; int n = nMaxW0; if (rc.Width () < (nMaxW0 + nMaxW1 + 20 + vscroll_payload)) n = rc.Width () - nMaxW1 - 20 - vscroll_payload; m_wndFlvList.SetColumnWidth (0, n + 20); m_wndFlvList.SetColumnWidth (1, nMaxW1); } m_wndFlvList.SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_CHECKBOXES); for (size_t i = 0; i < m_vDlds.size (); i++) ListView_SetItemState (m_wndFlvList, i, UINT((int(m_selected [i]) + 1) << 12), LVIS_STATEIMAGEMASK); CComboBox *pDirs = (CComboBox*) GetDlgItem (IDC_OUTFOLDER); for (size_t i = 0; i < (size_t)_LastFlashVideoDstFolders.GetRecordCount (); i++) pDirs->AddString (_LastFlashVideoDstFolders.GetRecord (i)); if (_LastFlashVideoDstFolders.GetRecordCount ()) { pDirs->SetCurSel (0); } else { vmsDownloadsGroupSmartPtr pGrp = _DldsGrps.FindGroupByExt (_T("flv")); if (pGrp == NULL) pGrp = _DldsGrps.FindGroupByExt (_T("mp4")); if (pGrp == NULL) pGrp = _DldsGrps.FindGroupByExt (_T("avi")); if (pGrp == NULL) pGrp = _DldsGrps.FindGroup (GRP_OTHER_ID); ASSERT (pGrp != NULL); if (pGrp != NULL) pDirs->SetWindowText (pGrp->strOutFolder); } if (_App.FVDownloads_AutoConvertVideo () && _AppMgr.IsMediaFeaturesInstalled ()) { CheckDlgButton (IDC_USE_AUTO_CONVERT, BST_CHECKED); UpdateEnabled (); } vmsMediaConvertMgr::GetDefaultSettings (m_convertSettings); ApplyLanguage (); if (m_bReqTopMostDialog) { mfcSetForegroundWindow (this); mfcSetTopmostWindow (this); } m_changing_dlg_state = false; m_initialized = true; return TRUE; }
//--------------------------------------------------------------------------- void __fastcall TForm5::UDPServer1UDPRead(TIdUDPListenerThread *AThread, const TIdBytes AData, TIdSocketHandle *ABinding) { LMessages->Items->Add(BytesToString(AData)); }
int main() { int success; //HexToValue TEST success = 1; if( HexToValue( 'd' ) != HexToValue( 'D' ) ) success = 0; if( HexToValue( 'Z' ) != 255 ) success = 0; if( HexToValue( 'b' ) != 11 ) success = 0; if( HexToValue( '4' ) != 4 ) success = 0; evaluate("HEXTOVALUE",success); //EOT //HEXTOBYTE success = 1; if( HexToByte( '1', '2' ) != 0x12 ) success = 0; if( HexToByte( 'a', 'B' ) != 0xAB ) success = 0; if( HexToByte( '3', '4' ) != 0x34 ) success = 0; if( HexToByte( '1', '2' ) != 0x12 ) success = 0; evaluate("HEXTOBYTE",success); //EOT //B64ToValue success = 1; if( B64ToValue( 'a' ) != 26 ) success = 0; if( B64ToValue( 'B' ) != 1 ) success = 0; if( B64ToValue( '+' ) != 62 ) success = 0; if( B64ToValue( 'Z' ) != 25 ) success = 0; evaluate("B64ToVal",success); //EOT //ValueToHex success = 1; if( ValueToHex(3) != '3' ) success = 0; if( ValueToHex(11) != 'B' ) success = 0; if( ValueToHex(18) != -1 ) success = 0; evaluate("ValueToHex",success); //EOT //ValueToB64 success = 1; if( ValueToB64(3) != 'D' ) success = 0; if( ValueToB64(42) != 'q' ) success = 0; if( ValueToB64(55) != '3' ) success = 0; if( ValueToB64(62) != '+' ) success = 0; if( ValueToB64(63) != '/' ) success = 0; if( ValueToB64(66) != -1 ) success = 0; evaluate("ValueToB64",success); //B64ToBytes success = 1; byte_t *b = malloc(3); if( ( B64ToBytes( b, "TWlL" ) != 0) ) success = 0; if( b[0] != 0x4D || b[1] != 0x69 || b[2] != 0x4B ) success = 0; if( ( B64ToBytes( b, "Z29z" ) != 0) ) success = 0; if( b[0] != 0x67 || b[1] != 0x6F || b[2] != 0x73 ) success = 0; if( ( B64ToBytes( b, "YQ==" ) != 0) ) success = 0; if( b[0] != 0x61 || b[1] != 0x00 || b[2] != 0x00 ) success = 0; if( ( B64ToBytes( b, "YWM=" ) != 0) ) success = 0; if( b[0] != 0x61 || b[1] != 0x63 || b[2] != 0x00 ) success = 0; evaluate("B64ToBytes",success); //EOT //ByteToHex success = 1; char b2h[3]; b2h[2] = '\0'; ByteToHex( b2h ,0xAF ); if( b2h[0] != 'A' || b2h[1] != 'F' ) success = 0; ByteToHex( b2h ,0x02 ); if( b2h[0] != '0' || b2h[1] != '2' ) success = 0; evaluate("ByteToHex",success); //EOT //BytesToB64 char b2b[4]; BytesToB64( b2b, (unsigned char *)"gat", 3); if( b2b[0] != 'Z' || b2b[1] != '2' || b2b[2] != 'F' || b2b[3] != '0' ) success = 0; BytesToB64( b2b, (unsigned char *)"pa", 2); if( b2b[0] != 'c' || b2b[1] != 'G' || b2b[2] != 'E' || b2b[3] != '=' ) success = 0; BytesToB64( b2b, (unsigned char *)"g", 1); if( b2b[0] != 'Z' || b2b[1] != 'w' || b2b[2] != '=' || b2b[3] != '=' ) success = 0; evaluate("BytesToB64",success); //EOT //HexStringToBytes success = 1; byte_t *dest; int temp = HexStringToBytes( &dest, LOREMHEX ); char * str; BytesToString( &str, dest, (size_t)temp ); if( strcmp( str, LOREM ) ) success = 0; free(dest); free(str); evaluate("HexStringToBytes",success); //EOT //B64StringToBytes success = 1; temp = B64StringToBytes( &dest, LOREMB64 ); BytesToString( &str, dest, (size_t)temp ); if( strcmp( str, LOREM ) ) success = 0; free(dest); free(str); evaluate("B64StringToBytes",success); //EOT //BytesToHexString success = 1; dest = (byte_t *) LOREM; BytesToHexString( &str, dest, strlen( LOREM ) ); if( strcmp( LOREMHEX, str ) ) success = 0; evaluate("BytesToHexString",success); //BytesToB64String success = 1; BytesToB64String( &str, (byte_t *)LOREM, strlen(LOREM) ); if( strcmp( LOREMB64, str ) ) success = 0; evaluate("B64StringToBytes",success); free(str); BytesToB64String( &str, (byte_t *)"A", 1 ); if( strcmp( str, "QQ==" ) ) success = 0; free(str); BytesToB64String( &str, (byte_t *)"AB", 2 ); if( strcmp( str, "QUI=" ) ) success = 0; free(str); BytesToB64String( &str,(byte_t *)"ABC", 3 ); if( strcmp( str, "QUJD" ) ) success = 0; free(str); evaluate("B64StringToBytes",success); //eot return 0; }