|
@@ -16,7 +16,7 @@ KartenServer::KartenServer( InitDatei *zIni )
|
|
empfangen = 0;
|
|
empfangen = 0;
|
|
gesendet = 0;
|
|
gesendet = 0;
|
|
fehler = new Text();
|
|
fehler = new Text();
|
|
- ini = zIni->getThis();
|
|
|
|
|
|
+ ini = dynamic_cast<InitDatei *>( zIni->getThis() );
|
|
id = *zIni->zWert( "ServerId" );
|
|
id = *zIni->zWert( "ServerId" );
|
|
server = new Server();
|
|
server = new Server();
|
|
aServer = new SSLServer();
|
|
aServer = new SSLServer();
|
|
@@ -39,7 +39,7 @@ KartenServer::KartenServer( InitDatei *zIni )
|
|
serverStarten();
|
|
serverStarten();
|
|
serverFortsetzen();
|
|
serverFortsetzen();
|
|
}
|
|
}
|
|
- updater = new Updater( (KartenServer *)getThis() );
|
|
|
|
|
|
+ updater = new Updater( dynamic_cast<KartenServer *>( getThis() ) );
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
@@ -68,13 +68,13 @@ void KartenServer::runn()
|
|
if( end && klient )
|
|
if( end && klient )
|
|
{
|
|
{
|
|
klient->trenne();
|
|
klient->trenne();
|
|
- klient = klient->release();
|
|
|
|
|
|
+ klient = (SSLSKlient *)klient->release();
|
|
Sleep( 1000 );
|
|
Sleep( 1000 );
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if( !klient )
|
|
if( !klient )
|
|
continue;
|
|
continue;
|
|
- KSAKlient * clHandle = new KSAKlient( klient, (KartenServer *)getThis() );
|
|
|
|
|
|
+ KSAKlient *clHandle = new KSAKlient( klient, dynamic_cast<KartenServer *>( getThis() ) );
|
|
clHandle->start();
|
|
clHandle->start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -88,7 +88,7 @@ void KartenServer::thread()
|
|
if( !klient )
|
|
if( !klient )
|
|
continue;
|
|
continue;
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
- KSKlient * clHandle = new KSKlient( klient, (KartenServer *)getThis() );
|
|
|
|
|
|
+ KSKlient *clHandle = new KSKlient( klient, dynamic_cast<KartenServer *>( getThis() ) );
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
klients->set( clHandle, klientAnzahl );
|
|
klients->set( clHandle, klientAnzahl );
|
|
klientAnzahl++;
|
|
klientAnzahl++;
|
|
@@ -107,13 +107,13 @@ void KartenServer::close()
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
for( int i = 0; i < klientAnzahl; i++ )
|
|
klients->z( i )->absturz();
|
|
klients->z( i )->absturz();
|
|
- klients = klients->release();
|
|
|
|
|
|
+ klients = ( RCArray < KSKlient > * )klients->release();
|
|
klientAnzahl = 0;
|
|
klientAnzahl = 0;
|
|
LeaveCriticalSection( &cs );
|
|
LeaveCriticalSection( &cs );
|
|
ende();
|
|
ende();
|
|
run = 0;
|
|
run = 0;
|
|
end = 1;
|
|
end = 1;
|
|
- Klient * klient = new Klient();
|
|
|
|
|
|
+ Klient *klient = new Klient();
|
|
klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
Sleep( 500 );
|
|
Sleep( 500 );
|
|
aServer->trenne();
|
|
aServer->trenne();
|
|
@@ -226,7 +226,7 @@ bool KartenServer::absturzKlient( int klientId )
|
|
return gefunden;
|
|
return gefunden;
|
|
}
|
|
}
|
|
|
|
|
|
-bool KartenServer::removeKlient( KSKlient * zKlient )
|
|
|
|
|
|
+bool KartenServer::removeKlient( KSKlient *zKlient )
|
|
{
|
|
{
|
|
bool gefunden = 0;
|
|
bool gefunden = 0;
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
@@ -308,7 +308,7 @@ bool KartenServer::wirdKarteGeupdatet( int id ) const
|
|
|
|
|
|
// Inhalt der KSAKlient Klasse aus KartenServer.h
|
|
// Inhalt der KSAKlient Klasse aus KartenServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-KSAKlient::KSAKlient( SSLSKlient * klient, KartenServer * ks )
|
|
|
|
|
|
+KSAKlient::KSAKlient( SSLSKlient *klient, KartenServer *ks )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
@@ -346,13 +346,13 @@ void KSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
unsigned char nLen = 0;
|
|
unsigned char nLen = 0;
|
|
- klient->getNachricht( (char *)& nLen, 1 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)&nLen, 1 );
|
|
char *n = new char[ nLen + 1 ];
|
|
char *n = new char[ nLen + 1 ];
|
|
n[ (int)nLen ] = 0;
|
|
n[ (int)nLen ] = 0;
|
|
if( nLen )
|
|
if( nLen )
|
|
klient->getNachricht( n, nLen );
|
|
klient->getNachricht( n, nLen );
|
|
unsigned char pLen = 0;
|
|
unsigned char pLen = 0;
|
|
- klient->getNachricht( (char *)& pLen, 1 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)&pLen, 1 );
|
|
char *p = new char[ pLen + 1 ];
|
|
char *p = new char[ pLen + 1 ];
|
|
p[ (int)pLen ] = 0;
|
|
p[ (int)pLen ] = 0;
|
|
if( pLen )
|
|
if( pLen )
|
|
@@ -448,7 +448,7 @@ void KSAKlient::thread()
|
|
}
|
|
}
|
|
else
|
|
else
|
|
ok = 1;
|
|
ok = 1;
|
|
- if( ok &&ks->hatClients() )
|
|
|
|
|
|
+ if( ok && ks->hatClients() )
|
|
{
|
|
{
|
|
errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
break;
|
|
break;
|
|
@@ -544,7 +544,7 @@ void KSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
int maxK = 0;
|
|
int maxK = 0;
|
|
- klient->getNachricht( (char *)& maxK, 4 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)&maxK, 4 );
|
|
if( ks->zDB()->adminHatRecht( adminId, Admin_Recht::KSMKChange ) )
|
|
if( ks->zDB()->adminHatRecht( adminId, Admin_Recht::KSMKChange ) )
|
|
{
|
|
{
|
|
if( ks->setMaxKarten( maxK ) )
|
|
if( ks->setMaxKarten( maxK ) )
|
|
@@ -566,8 +566,8 @@ void KSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
int klientId = 0;
|
|
int klientId = 0;
|
|
- klient->getNachricht( (char *)& klientId, 4 );
|
|
|
|
- if( klientId &&ks->absturzKlient( klientId ) )
|
|
|
|
|
|
+ klient->getNachricht( (char *)&klientId, 4 );
|
|
|
|
+ if( klientId && ks->absturzKlient( klientId ) )
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
klient->sende( "\0", 1 );
|
|
klient->sende( "\0", 1 );
|
|
@@ -599,7 +599,7 @@ void KSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehl
|
|
|
|
|
|
// Inhalt der KSKlient aus KartenServer.h
|
|
// Inhalt der KSKlient aus KartenServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-KSKlient::KSKlient( SKlient * klient, KartenServer * ks )
|
|
|
|
|
|
+KSKlient::KSKlient( SKlient *klient, KartenServer *ks )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
@@ -618,7 +618,7 @@ KSKlient::~KSKlient()
|
|
}
|
|
}
|
|
|
|
|
|
// privat
|
|
// privat
|
|
-void KSKlient::suchDateien( const char *pf, RCArray< Text > * zDL, const char *rem )
|
|
|
|
|
|
+void KSKlient::suchDateien( const char *pf, RCArray< Text > *zDL, const char *rem )
|
|
{
|
|
{
|
|
Datei d;
|
|
Datei d;
|
|
d.setDatei( pf );
|
|
d.setDatei( pf );
|
|
@@ -667,7 +667,7 @@ void KSKlient::thread()
|
|
switch( c )
|
|
switch( c )
|
|
{
|
|
{
|
|
case 1: // Klient identifikation
|
|
case 1: // Klient identifikation
|
|
- klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&klientNummer, 4 );
|
|
if( !ks->zDB()->proveKlient( klientNummer, ks->getId() ) )
|
|
if( !ks->zDB()->proveKlient( klientNummer, ks->getId() ) )
|
|
{
|
|
{
|
|
klientNummer = 0;
|
|
klientNummer = 0;
|
|
@@ -698,8 +698,8 @@ void KSKlient::thread()
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
int klientId = 0;
|
|
int klientId = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& klientId, 4 );
|
|
|
|
- if( klientId &&ks->absturzKlient( klientId ) )
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&klientId, 4 );
|
|
|
|
+ if( klientId && ks->absturzKlient( klientId ) )
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
else
|
|
else
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
@@ -742,7 +742,7 @@ void KSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&id, 4 );
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -762,7 +762,7 @@ void KSKlient::thread()
|
|
RCArray< Text > *dList = new RCArray< Text >();
|
|
RCArray< Text > *dList = new RCArray< Text >();
|
|
suchDateien( pfad, dList, pfad );
|
|
suchDateien( pfad, dList, pfad );
|
|
int anz = dList->getEintragAnzahl();
|
|
int anz = dList->getEintragAnzahl();
|
|
- klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&anz, 4 );
|
|
for( int i = 0; i < anz; i++ )
|
|
for( int i = 0; i < anz; i++ )
|
|
{
|
|
{
|
|
Text pf = dList->z( i )->getText();
|
|
Text pf = dList->z( i )->getText();
|
|
@@ -776,10 +776,10 @@ void KSKlient::thread()
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&len, 1 );
|
|
klient->sendeEncrypted( pf, len );
|
|
klient->sendeEncrypted( pf, len );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&size, 8 );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
{
|
|
{
|
|
@@ -804,7 +804,7 @@ void KSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&id, 4 );
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -824,7 +824,7 @@ void KSKlient::thread()
|
|
RCArray< Text > *dList = new RCArray< Text >();
|
|
RCArray< Text > *dList = new RCArray< Text >();
|
|
suchDateien( pfad, dList, pfad );
|
|
suchDateien( pfad, dList, pfad );
|
|
int anz = dList->getEintragAnzahl();
|
|
int anz = dList->getEintragAnzahl();
|
|
- klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&anz, 4 );
|
|
for( int i = 0; i < anz; i++ )
|
|
for( int i = 0; i < anz; i++ )
|
|
{
|
|
{
|
|
Text pf = dList->z( i )->getText();
|
|
Text pf = dList->z( i )->getText();
|
|
@@ -835,10 +835,10 @@ void KSKlient::thread()
|
|
d.setDatei( dp );
|
|
d.setDatei( dp );
|
|
if( !len || !d.open( Datei::Style::lesen ) )
|
|
if( !len || !d.open( Datei::Style::lesen ) )
|
|
continue;
|
|
continue;
|
|
- klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&len, 1 );
|
|
klient->sendeEncrypted( pf, len );
|
|
klient->sendeEncrypted( pf, len );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&size, 8 );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
{
|
|
{
|
|
@@ -863,7 +863,7 @@ void KSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&id, 4 );
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -886,7 +886,7 @@ void KSKlient::thread()
|
|
else
|
|
else
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&size, 8 );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
{
|
|
{
|
|
@@ -909,7 +909,7 @@ void KSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&id, 4 );
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -932,7 +932,7 @@ void KSKlient::thread()
|
|
else
|
|
else
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&size, 8 );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
{
|
|
{
|
|
@@ -955,7 +955,7 @@ void KSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&id, 4 );
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -978,7 +978,7 @@ void KSKlient::thread()
|
|
else
|
|
else
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&size, 8 );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
{
|
|
{
|
|
@@ -1001,7 +1001,7 @@ void KSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)&id, 4 );
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -1024,7 +1024,7 @@ void KSKlient::thread()
|
|
else
|
|
else
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)&size, 8 );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
{
|
|
{
|