|
@@ -34,13 +34,12 @@ KartenServer::KartenServer( InitDatei *zIni )
|
|
|
nichtPausiert = 0;
|
|
|
updateKarte = 0;
|
|
|
InitializeCriticalSection( &cs );
|
|
|
- ref = 1;
|
|
|
if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
|
{
|
|
|
serverStarten();
|
|
|
serverFortsetzen();
|
|
|
}
|
|
|
- updater = new Updater( getThis() );
|
|
|
+ updater = new Updater( (KartenServer *)getThis() );
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
@@ -75,7 +74,7 @@ void KartenServer::runn()
|
|
|
}
|
|
|
if( !klient )
|
|
|
continue;
|
|
|
- KSAKlient *clHandle = new KSAKlient( klient, getThis() );
|
|
|
+ KSAKlient * clHandle = new KSAKlient( klient, (KartenServer *)getThis() );
|
|
|
clHandle->start();
|
|
|
}
|
|
|
}
|
|
@@ -88,8 +87,8 @@ void KartenServer::thread()
|
|
|
klient = server->getKlient();
|
|
|
if( !klient )
|
|
|
continue;
|
|
|
- Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
- KSKlient *clHandle = new KSKlient( klient, getThis() );
|
|
|
+ Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
+ KSKlient * clHandle = new KSKlient( klient, (KartenServer *)getThis() );
|
|
|
EnterCriticalSection( &cs );
|
|
|
klients->set( clHandle, klientAnzahl );
|
|
|
klientAnzahl++;
|
|
@@ -114,7 +113,7 @@ void KartenServer::close()
|
|
|
ende();
|
|
|
run = 0;
|
|
|
end = 1;
|
|
|
- Klient *klient = new Klient();
|
|
|
+ Klient * klient = new Klient();
|
|
|
klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
|
Sleep( 500 );
|
|
|
aServer->trenne();
|
|
@@ -227,7 +226,7 @@ bool KartenServer::absturzKlient( int klientId )
|
|
|
return gefunden;
|
|
|
}
|
|
|
|
|
|
-bool KartenServer::removeKlient( KSKlient *zKlient )
|
|
|
+bool KartenServer::removeKlient( KSKlient * zKlient )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
EnterCriticalSection( &cs );
|
|
@@ -306,25 +305,10 @@ bool KartenServer::wirdKarteGeupdatet( int id ) const
|
|
|
return id == updateKarte;
|
|
|
}
|
|
|
|
|
|
-// Reference Counting
|
|
|
-KartenServer *KartenServer::getThis()
|
|
|
-{
|
|
|
- ref++;
|
|
|
- return this;
|
|
|
-}
|
|
|
-
|
|
|
-KartenServer *KartenServer::release()
|
|
|
-{
|
|
|
- ref--;
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
// Inhalt der KSAKlient Klasse aus KartenServer.h
|
|
|
// Konstruktor
|
|
|
-KSAKlient::KSAKlient( SSLSKlient *klient, KartenServer *ks )
|
|
|
+KSAKlient::KSAKlient( SSLSKlient * klient, KartenServer * ks )
|
|
|
: Thread()
|
|
|
{
|
|
|
this->klient = klient;
|
|
@@ -362,13 +346,13 @@ void KSAKlient::thread()
|
|
|
{
|
|
|
klient->sende( "\1", 1 );
|
|
|
unsigned char nLen = 0;
|
|
|
- klient->getNachricht( (char*)&nLen, 1 );
|
|
|
+ klient->getNachricht( (char *)& nLen, 1 );
|
|
|
char *n = new char[ nLen + 1 ];
|
|
|
n[ (int)nLen ] = 0;
|
|
|
if( nLen )
|
|
|
klient->getNachricht( n, nLen );
|
|
|
unsigned char pLen = 0;
|
|
|
- klient->getNachricht( (char*)&pLen, 1 );
|
|
|
+ klient->getNachricht( (char *)& pLen, 1 );
|
|
|
char *p = new char[ pLen + 1 ];
|
|
|
p[ (int)pLen ] = 0;
|
|
|
if( pLen )
|
|
@@ -464,7 +448,7 @@ void KSAKlient::thread()
|
|
|
}
|
|
|
else
|
|
|
ok = 1;
|
|
|
- if( ok && ks->hatClients() )
|
|
|
+ if( ok &&ks->hatClients() )
|
|
|
{
|
|
|
errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
|
break;
|
|
@@ -560,7 +544,7 @@ void KSAKlient::thread()
|
|
|
{
|
|
|
klient->sende( "\1", 1 );
|
|
|
int maxK = 0;
|
|
|
- klient->getNachricht( (char*)&maxK, 4 );
|
|
|
+ klient->getNachricht( (char *)& maxK, 4 );
|
|
|
if( ks->zDB()->adminHatRecht( adminId, Admin_Recht::KSMKChange ) )
|
|
|
{
|
|
|
if( ks->setMaxKarten( maxK ) )
|
|
@@ -582,8 +566,8 @@ void KSAKlient::thread()
|
|
|
{
|
|
|
klient->sende( "\1", 1 );
|
|
|
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 );
|
|
|
else
|
|
|
klient->sende( "\0", 1 );
|
|
@@ -615,16 +599,15 @@ void KSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehl
|
|
|
|
|
|
// Inhalt der KSKlient aus KartenServer.h
|
|
|
// Konstruktor
|
|
|
-KSKlient::KSKlient( SKlient *klient, KartenServer *ks )
|
|
|
+KSKlient::KSKlient( SKlient * klient, KartenServer * ks )
|
|
|
: Thread()
|
|
|
{
|
|
|
this->klient = klient;
|
|
|
unsigned char key[ 20 ] = { 24, 15, 53, 87, 38, 73, 154, 38, 246, 90, 39, 133, 11, 199, 22, 80, 26, 132, 95, 54 };
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
klientNummer = 0;
|
|
|
this->ks = ks;
|
|
|
- ref = 1;
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
@@ -635,7 +618,7 @@ KSKlient::~KSKlient()
|
|
|
}
|
|
|
|
|
|
// 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;
|
|
|
d.setDatei( pf );
|
|
@@ -684,7 +667,7 @@ void KSKlient::thread()
|
|
|
switch( c )
|
|
|
{
|
|
|
case 1: // Klient identifikation
|
|
|
- klient->getNachrichtEncrypted( (char*)&klientNummer, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
|
|
|
if( !ks->zDB()->proveKlient( klientNummer, ks->getId() ) )
|
|
|
{
|
|
|
klientNummer = 0;
|
|
@@ -715,8 +698,8 @@ void KSKlient::thread()
|
|
|
if( 1 )
|
|
|
{
|
|
|
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 );
|
|
|
else
|
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
@@ -759,7 +742,7 @@ void KSKlient::thread()
|
|
|
{
|
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
|
int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
|
{
|
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -779,13 +762,13 @@ void KSKlient::thread()
|
|
|
RCArray< Text > *dList = new RCArray< Text >();
|
|
|
suchDateien( pfad, dList, pfad );
|
|
|
int anz = dList->getEintragAnzahl();
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
for( int i = 0; i < anz; i++ )
|
|
|
{
|
|
|
Text pf = dList->z( i )->getText();
|
|
|
unsigned char len = (unsigned char)pf.getLength();
|
|
|
Text dp = pf.getText();
|
|
|
- dp.insert( 0, (char*)pfad );
|
|
|
+ dp.insert( 0, (char *)pfad );
|
|
|
Datei d;
|
|
|
d.setDatei( dp );
|
|
|
if( !len || !d.open( Datei::Style::lesen ) )
|
|
@@ -793,10 +776,10 @@ void KSKlient::thread()
|
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
|
continue;
|
|
|
}
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
klient->sendeEncrypted( pf, len );
|
|
|
__int64 size = d.getSize();
|
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
char *buffer = new char[ 2048 ];
|
|
|
while( size )
|
|
|
{
|
|
@@ -821,7 +804,7 @@ void KSKlient::thread()
|
|
|
{
|
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
|
int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
|
{
|
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -841,21 +824,21 @@ void KSKlient::thread()
|
|
|
RCArray< Text > *dList = new RCArray< Text >();
|
|
|
suchDateien( pfad, dList, pfad );
|
|
|
int anz = dList->getEintragAnzahl();
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
for( int i = 0; i < anz; i++ )
|
|
|
{
|
|
|
Text pf = dList->z( i )->getText();
|
|
|
unsigned char len = (unsigned char)pf.getLength();
|
|
|
Text dp = pf.getText();
|
|
|
- dp.insert( 0, (char*)pfad );
|
|
|
+ dp.insert( 0, (char *)pfad );
|
|
|
Datei d;
|
|
|
d.setDatei( dp );
|
|
|
if( !len || !d.open( Datei::Style::lesen ) )
|
|
|
continue;
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
klient->sendeEncrypted( pf, len );
|
|
|
__int64 size = d.getSize();
|
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
char *buffer = new char[ 2048 ];
|
|
|
while( size )
|
|
|
{
|
|
@@ -880,7 +863,7 @@ void KSKlient::thread()
|
|
|
{
|
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
|
int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
|
{
|
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -903,7 +886,7 @@ void KSKlient::thread()
|
|
|
else
|
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
|
__int64 size = d.getSize();
|
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
char *buffer = new char[ 2048 ];
|
|
|
while( size )
|
|
|
{
|
|
@@ -926,7 +909,7 @@ void KSKlient::thread()
|
|
|
{
|
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
|
int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
|
{
|
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -949,7 +932,7 @@ void KSKlient::thread()
|
|
|
else
|
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
|
__int64 size = d.getSize();
|
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
char *buffer = new char[ 2048 ];
|
|
|
while( size )
|
|
|
{
|
|
@@ -972,7 +955,7 @@ void KSKlient::thread()
|
|
|
{
|
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
|
int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
|
{
|
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -995,7 +978,7 @@ void KSKlient::thread()
|
|
|
else
|
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
|
__int64 size = d.getSize();
|
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
char *buffer = new char[ 2048 ];
|
|
|
while( size )
|
|
|
{
|
|
@@ -1018,7 +1001,7 @@ void KSKlient::thread()
|
|
|
{
|
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
|
int id = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
if( !ks->zDB()->proveKarte( id, ks->getId() ) )
|
|
|
{
|
|
|
errorZuKlient( "Die Karte wurde nicht gefunden." );
|
|
@@ -1041,7 +1024,7 @@ void KSKlient::thread()
|
|
|
else
|
|
|
errorZuKlient( "Fehler beim lesen der Datei." );
|
|
|
__int64 size = d.getSize();
|
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
|
char *buffer = new char[ 2048 ];
|
|
|
while( size )
|
|
|
{
|
|
@@ -1081,19 +1064,4 @@ void KSKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehle
|
|
|
int KSKlient::getKlientNummer() const // gibt die KlientId zurück
|
|
|
{
|
|
|
return klientNummer;
|
|
|
-}
|
|
|
-
|
|
|
-// Reference Counting
|
|
|
-KSKlient *KSKlient::getThis()
|
|
|
-{
|
|
|
- ref++;
|
|
|
- return this;
|
|
|
-}
|
|
|
-
|
|
|
-KSKlient *KSKlient::release()
|
|
|
-{
|
|
|
- ref--;
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
- return 0;
|
|
|
}
|