MCPcopy Create free account
hub / github.com/amule-project/amule / LoadStaticServers

Method LoadStaticServers

src/ServerList.cpp:455–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453
454
455void CServerList::LoadStaticServers()
456{
457 if ( !CPath::FileExists(m_staticServersConfig) ) {
458 return;
459 }
460
461 wxFileInputStream stream(m_staticServersConfig);
462 wxTextInputStream f(stream);
463
464 while ( !stream.Eof() ) {
465 wxString line = f.ReadLine();
466
467 // Skip comments
468 if (line.IsEmpty() || line.GetChar(0) == '#' || line.GetChar(0) == '/') {
469 continue;
470 }
471
472 wxStringTokenizer tokens( line, "," );
473
474 if ( tokens.CountTokens() != 3 ) {
475 continue;
476 }
477
478
479 // format is host:port,priority,Name
480 wxString addy = tokens.GetNextToken().Strip( wxString::both );
481 wxString prio = tokens.GetNextToken().Strip( wxString::both );
482 wxString name = tokens.GetNextToken().Strip( wxString::both );
483
484 wxString host = addy.BeforeFirst( ':' );
485 wxString port = addy.AfterFirst( ':' );
486
487
488 int priority = StrToLong( prio );
489 if (priority < SRV_PR_MIN || priority > SRV_PR_MAX) {
490 priority = SRV_PR_NORMAL;
491 }
492
493
494 // We need a valid name for the list
495 if ( name.IsEmpty() ) {
496 name = addy;
497 }
498
499
500 // create server object and add it to the list
501 CServer* server = new CServer( StrToLong( port ), host );
502
503 server->SetListName( name );
504 server->SetIsStaticMember( true );
505 server->SetPreference( priority );
506
507
508 // Try to add the server to the list
509 if ( !theApp->AddServer( server ) ) {
510 delete server;
511 CServer* existing = GetServerByAddress( host, StrToULong( port ) );
512 if ( existing) {

Callers

nothing calls this directly

Calls 8

StrToLongFunction · 0.85
StrToULongFunction · 0.85
SetListNameMethod · 0.80
SetIsStaticMemberMethod · 0.80
SetPreferenceMethod · 0.80
EofMethod · 0.45
IsEmptyMethod · 0.45
AddServerMethod · 0.45

Tested by

no test coverage detected