Kolja Strohm 3 лет назад
Родитель
Сommit
6eaaed142e

+ 9 - 8
AppServer Linux/AppServer Linux.vcxproj

@@ -37,10 +37,9 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <TargetName>AppServer</TargetName>
-    <TargetExt>
-    </TargetExt>
+    <TargetExt>.exe</TargetExt>
     <RemoteProjectDir>$(RemoteRootDir)/Server/AppServer/release</RemoteProjectDir>
-    <IncludePath>..\..\..\Allgemein\Framework;../../../Framework/release;..\..\..\Allgemein\Network\Network;../../../Network/release;..\..\..\Allgemein\sql\sql;../../../sql/release;..\AppServer;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\..\Allgemein\Framework;../../../../Framework/release;..\..\..\Allgemein\Network\Network;../../../../Network/release/Network;..\..\..\Allgemein\sql\sql;../../../../sql/release/sql;..\AppServer;$(IncludePath)</IncludePath>
     <LibraryPath>
     </LibraryPath>
     <OutDir>$(RemoteRootDir)/Server/AppServer/release/</OutDir>
@@ -49,9 +48,9 @@
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <TargetName>AppServer</TargetName>
-    <TargetExt />
+    <TargetExt>.exe</TargetExt>
     <RemoteProjectDir>$(RemoteRootDir)/Server/AppServer/debug</RemoteProjectDir>
-    <IncludePath>..\..\..\Allgemein\Framework;..\..\..\Allgemein\Network\Network;../../../Network/debug;..\..\..\Allgemein\sql\sql;../../../sql/debug;..\AppServer;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\..\Allgemein\Framework;..\..\..\Allgemein\Network\Network;../../../../Network/debug/Network;..\..\..\Allgemein\sql\sql;../../../../sql/debug/sql;..\AppServer;$(IncludePath)</IncludePath>
     <LibraryPath>
     </LibraryPath>
     <OutDir>$(RemoteRootDir)/Server/AppServer/debug/</OutDir>
@@ -69,10 +68,11 @@
   </ItemGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <Link>
-      <LibraryDependencies>dbgFramework;dbgNetwork;dbgSQL;pq;pthread</LibraryDependencies>
+      <LibraryDependencies>dbgFramework;dbgNetwork;dbgSQL;pq;pthread;ssl</LibraryDependencies>
       <SharedLibrarySearchPath>%(SharedLibrarySearchPath)</SharedLibrarySearchPath>
-      <AdditionalLibraryDirectories>$(RemoteRootDir)/Framework/debug;$(RemoteRootDir)/Network/debug;$(RemoteRootDir)/sql/debug;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(RemoteRootDir)/Framework/debug;$(RemoteRootDir)/Network/debug;$(RemoteRootDir)/sql/debug;/usr/lib/;/usr/local/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
+      <OutputFile>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</OutputFile>
     </Link>
     <ClCompile />
     <ClCompile>
@@ -81,9 +81,10 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <Link>
-      <LibraryDependencies>Framework;Network;SQL;pq;pthread</LibraryDependencies>
+      <LibraryDependencies>Framework;Network;SQL;pq;pthread;ssl</LibraryDependencies>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/Framework/release;$(RemoteRootDir)/Network/release;$(RemoteRootDir)/sql/release;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
+      <OutputFile>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</OutputFile>
     </Link>
     <ClCompile>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>

BIN
AppServer Linux/AppServer.exe


+ 77 - 77
AppServer/AppServer.cpp

@@ -16,7 +16,7 @@ AppServer::AppServer( InitDatei *zDat )
     clients = 0;
     empfangen = 0;
     gesendet = 0;
-    dat = zDat->getThis();
+    dat = dynamic_cast<InitDatei *>( zDat->getThis() );
     server = new Server();
     aServer = new SSLServer();
     aServer->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
@@ -58,13 +58,13 @@ void AppServer::runn()
         if( end && klient )
         {
             klient->trenne();
-            klient = klient->release();
+            klient = (SSLSKlient *)klient->release();
             Sleep( 1000 );
             return;
         }
         if( !klient )
             continue;
-        AppSAKlient * clHandle = new AppSAKlient( klient, (AppServer *)getThis() );
+        AppSAKlient *clHandle = new AppSAKlient( klient, dynamic_cast<AppServer *>( getThis() ) );
         clHandle->start();
     }
 }
@@ -78,7 +78,7 @@ void AppServer::thread()
         if( !klient )
             continue;
         Framework::getThreadRegister()->cleanUpClosedThreads();
-        AppSKlient * clHandle = new AppSKlient( klient, (AppServer *)getThis() );
+        AppSKlient *clHandle = new AppSKlient( klient, dynamic_cast<AppServer *>( getThis() ) );
         clHandle->start();
         clients++;
     }
@@ -168,7 +168,7 @@ bool AppServer::hatClients() const
 
 // Inhalt der AppSKlient Klasse aus AppServer.h
 // Konstruktor 
-AppSAKlient::AppSAKlient( SSLSKlient * klient, AppServer * appS )
+AppSAKlient::AppSAKlient( SSLSKlient *klient, AppServer *appS )
     : Thread()
 {
     this->klient = klient;
@@ -206,13 +206,13 @@ void AppSAKlient::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 )
@@ -289,7 +289,7 @@ void AppSAKlient::thread()
                     }
                     else
                         ok = 1;
-                    if( ok &&appS->hatClients() )
+                    if( ok && appS->hatClients() )
                     {
                         errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
                         break;
@@ -365,7 +365,7 @@ void AppSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fe
 
 // Inhalt der AppSKlient Klasse aus AppServer.h
 // Konstruktor 
-AppSKlient::AppSKlient( SKlient * klient, AppServer * appS )
+AppSKlient::AppSKlient( SKlient *klient, AppServer *appS )
     : Thread()
 {
     std::cout << "New Client aktuell:" << appS->getClients() << "\n";
@@ -428,12 +428,12 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     unsigned char l = 0;
-                    klient->getNachrichtEncrypted( (char *)& l, 1 );
+                    klient->getNachrichtEncrypted( (char *)&l, 1 );
                     char *name = new char[ l + 1 ];
                     name[ (int)l ] = 0;
                     if( l )
                         klient->getNachrichtEncrypted( name, l );
-                    klient->getNachrichtEncrypted( (char *)& l, 1 );
+                    klient->getNachrichtEncrypted( (char *)&l, 1 );
                     char *passwort = new char[ l + 1 ];
                     passwort[ (int)l ] = 0;
                     if( l )
@@ -445,7 +445,7 @@ void AppSKlient::thread()
                         klient->sendeEncrypted( "\1", 1 );
                     else
                         klient->sende( "\0", 1 );
-                    if( accountId &&appS->zDB()->istNeu( accountId ) )
+                    if( accountId && appS->zDB()->istNeu( accountId ) )
                         klient->sendeEncrypted( "\1", 1 );
                     else if( accountId )
                         klient->sendeEncrypted( "\0", 1 );
@@ -456,15 +456,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int num = 0;
-                    klient->getNachrichtEncrypted( (char *)& num, 4 );
+                    klient->getNachrichtEncrypted( (char *)&num, 4 );
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *namen = new RCArray< Text >();
                     num = appS->zDB()->getWeltBloeckeScore( num, score, namen );
-                    klient->sendeEncrypted( (char *)& num, 4 );
+                    klient->sendeEncrypted( (char *)&num, 4 );
                     for( int i = 0; i < num; i++ )
                     {
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char l = (char)namen->z( i )->getLength();
                         klient->sendeEncrypted( &l, 1 );
                         klient->sendeEncrypted( namen->z( i )->getText(), l );
@@ -478,15 +478,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int num = 0;
-                    klient->getNachrichtEncrypted( (char *)& num, 4 );
+                    klient->getNachrichtEncrypted( (char *)&num, 4 );
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *namen = new RCArray< Text >();
                     num = appS->zDB()->getWeltMauerScore( num, score, namen );
-                    klient->sendeEncrypted( (char *)& num, 4 );
+                    klient->sendeEncrypted( (char *)&num, 4 );
                     for( int i = 0; i < num; i++ )
                     {
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char l = (char)namen->z( i )->getLength();
                         klient->sendeEncrypted( &l, 1 );
                         klient->sendeEncrypted( namen->z( i )->getText(), l );
@@ -500,15 +500,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int num = 0;
-                    klient->getNachrichtEncrypted( (char *)& num, 4 );
+                    klient->getNachrichtEncrypted( (char *)&num, 4 );
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *namen = new RCArray< Text >();
                     num = appS->zDB()->getWeltFarbenScore( num, score, namen );
-                    klient->sendeEncrypted( (char *)& num, 4 );
+                    klient->sendeEncrypted( (char *)&num, 4 );
                     for( int i = 0; i < num; i++ )
                     {
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char l = (char)namen->z( i )->getLength();
                         klient->sendeEncrypted( &l, 1 );
                         klient->sendeEncrypted( namen->z( i )->getText(), l );
@@ -522,15 +522,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int num = 0;
-                    klient->getNachrichtEncrypted( (char *)& num, 4 );
+                    klient->getNachrichtEncrypted( (char *)&num, 4 );
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *namen = new RCArray< Text >();
                     num = appS->zDB()->getWeltFangenScore( num, score, namen );
-                    klient->sendeEncrypted( (char *)& num, 4 );
+                    klient->sendeEncrypted( (char *)&num, 4 );
                     for( int i = 0; i < num; i++ )
                     {
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char l = (char)namen->z( i )->getLength();
                         klient->sendeEncrypted( &l, 1 );
                         klient->sendeEncrypted( namen->z( i )->getText(), l );
@@ -544,15 +544,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int num = 0;
-                    klient->getNachrichtEncrypted( (char *)& num, 4 );
+                    klient->getNachrichtEncrypted( (char *)&num, 4 );
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *namen = new RCArray< Text >();
                     num = appS->zDB()->getWeltRennenScore( num, score, namen );
-                    klient->sendeEncrypted( (char *)& num, 4 );
+                    klient->sendeEncrypted( (char *)&num, 4 );
                     for( int i = 0; i < num; i++ )
                     {
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char l = (char)namen->z( i )->getLength();
                         klient->sendeEncrypted( &l, 1 );
                         klient->sendeEncrypted( namen->z( i )->getText(), l );
@@ -566,15 +566,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int num = 0;
-                    klient->getNachrichtEncrypted( (char *)& num, 4 );
+                    klient->getNachrichtEncrypted( (char *)&num, 4 );
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *namen = new RCArray< Text >();
                     num = appS->zDB()->getWeltGesamtScore( num, score, namen );
-                    klient->sendeEncrypted( (char *)& num, 4 );
+                    klient->sendeEncrypted( (char *)&num, 4 );
                     for( int i = 0; i < num; i++ )
                     {
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char l = (char)namen->z( i )->getLength();
                         klient->sendeEncrypted( &l, 1 );
                         klient->sendeEncrypted( namen->z( i )->getText(), l );
@@ -594,7 +594,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = appS->zDB()->getBloeckeScore( accountId );
-                    klient->sendeEncrypted( (char *)& score, 4 );
+                    klient->sendeEncrypted( (char *)&score, 4 );
                     break;
                 }
             case 9: // Frage nach Mauer Score
@@ -608,7 +608,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = appS->zDB()->getMauerScore( accountId );
-                    klient->sendeEncrypted( (char *)& score, 4 );
+                    klient->sendeEncrypted( (char *)&score, 4 );
                     break;
                 }
             case 10: // Frage nach Farben Score
@@ -622,7 +622,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = appS->zDB()->getFarbenScore( accountId );
-                    klient->sendeEncrypted( (char *)& score, 4 );
+                    klient->sendeEncrypted( (char *)&score, 4 );
                     break;
                 }
             case 11: // Frage nach Fangen Score
@@ -636,7 +636,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = appS->zDB()->getFangenScore( accountId );
-                    klient->sendeEncrypted( (char *)& score, 4 );
+                    klient->sendeEncrypted( (char *)&score, 4 );
                     break;
                 }
             case 12: // Frage nach Rennen Score
@@ -650,7 +650,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = appS->zDB()->getRennenScore( accountId );
-                    klient->sendeEncrypted( (char *)& score, 4 );
+                    klient->sendeEncrypted( (char *)&score, 4 );
                     break;
                 }
             case 13: // Frage nach Gesamt Score
@@ -664,7 +664,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = appS->zDB()->getGesamtScore( accountId );
-                    klient->sendeEncrypted( (char *)& score, 4 );
+                    klient->sendeEncrypted( (char *)&score, 4 );
                     break;
                 }
             case 14: // Frage nach Mauer Zeit
@@ -678,9 +678,9 @@ void AppSKlient::thread()
                         break;
                     }
                     int level = 0;
-                    klient->getNachrichtEncrypted( (char *)& level, 4 );
+                    klient->getNachrichtEncrypted( (char *)&level, 4 );
                     int sek = appS->zDB()->getMauerZeit( accountId, level );
-                    klient->sendeEncrypted( (char *)& sek, 4 );
+                    klient->sendeEncrypted( (char *)&sek, 4 );
                     break;
                 }
             case 15: // Set Blöcke Score
@@ -694,7 +694,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = 0;
-                    klient->getNachrichtEncrypted( (char *)& score, 4 );
+                    klient->getNachrichtEncrypted( (char *)&score, 4 );
                     appS->zDB()->setBloeckeScore( accountId, score );
                     klient->sendeEncrypted( "\1", 1 );
                     break;
@@ -710,7 +710,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = 0;
-                    klient->getNachrichtEncrypted( (char *)& score, 4 );
+                    klient->getNachrichtEncrypted( (char *)&score, 4 );
                     appS->zDB()->setFarbenScore( accountId, score );
                     klient->sendeEncrypted( "\1", 1 );
                     break;
@@ -726,7 +726,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = 0;
-                    klient->getNachrichtEncrypted( (char *)& score, 4 );
+                    klient->getNachrichtEncrypted( (char *)&score, 4 );
                     appS->zDB()->setFangenScore( accountId, score );
                     klient->sendeEncrypted( "\1", 1 );
                     break;
@@ -742,7 +742,7 @@ void AppSKlient::thread()
                         break;
                     }
                     int score = 0;
-                    klient->getNachrichtEncrypted( (char *)& score, 4 );
+                    klient->getNachrichtEncrypted( (char *)&score, 4 );
                     appS->zDB()->setRennenScore( accountId, score );
                     klient->sendeEncrypted( "\1", 1 );
                     break;
@@ -758,9 +758,9 @@ void AppSKlient::thread()
                         break;
                     }
                     int level = 0;
-                    klient->getNachrichtEncrypted( (char *)& level, 4 );
+                    klient->getNachrichtEncrypted( (char *)&level, 4 );
                     int zeit = 0;
-                    klient->getNachrichtEncrypted( (char *)& zeit, 4 );
+                    klient->getNachrichtEncrypted( (char *)&zeit, 4 );
                     appS->zDB()->setMauerZeit( accountId, level, zeit );
                     klient->sendeEncrypted( "\1", 1 );
                     break;
@@ -784,7 +784,7 @@ void AppSKlient::thread()
                     acc_mail[ len[ 3 ] ] = 0;
                     klient->getNachrichtEncrypted( acc_mail, len[ 3 ] );
                     unsigned short acc_geb_jahr = 0;
-                    klient->getNachrichtEncrypted( (char *)& acc_geb_jahr, 2 );
+                    klient->getNachrichtEncrypted( (char *)&acc_geb_jahr, 2 );
                     char acc_geb_monat = 0;
                     klient->getNachrichtEncrypted( &acc_geb_monat, 1 );
                     char acc_geb_tag = 0;
@@ -821,15 +821,15 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int level = 0;
-                    klient->getNachrichtEncrypted( (char *)& level, 4 );
+                    klient->getNachrichtEncrypted( (char *)&level, 4 );
                     int sek = 0;
-                    klient->getNachrichtEncrypted( (char *)& sek, 4 );
+                    klient->getNachrichtEncrypted( (char *)&sek, 4 );
                     if( accountId )
                         appS->zDB()->markballsFinish( level, sek, accountId, 0, 0, 0, 0 );
                     else
                     {
                         unsigned char l = 0;
-                        klient->getNachrichtEncrypted( (char *)& l, 1 );
+                        klient->getNachrichtEncrypted( (char *)&l, 1 );
                         char *device = new char[ l + 1 ];
                         device[ (int)l ] = 0;
                         klient->getNachrichtEncrypted( device, l );
@@ -847,13 +847,13 @@ void AppSKlient::thread()
                     Array< int > *score = new Array< int >();
                     RCArray< Text > *name = new RCArray< Text >();
                     int anz = appS->zDB()->getMarkballsScore( level, score, name, 0 );
-                    klient->sendeEncrypted( (char *)& anz, 4 );
+                    klient->sendeEncrypted( (char *)&anz, 4 );
                     for( int i = 0; i < anz; i++ )
                     {
                         int l = level->get( i );
-                        klient->sendeEncrypted( (char *)& l, 4 );
+                        klient->sendeEncrypted( (char *)&l, 4 );
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                         char nl = (char)name->z( i )->getLength();
                         klient->sendeEncrypted( &nl, 1 );
                         if( nl )
@@ -869,17 +869,17 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     unsigned char l = 0;
-                    klient->getNachrichtEncrypted( (char *)& l, 1 );
+                    klient->getNachrichtEncrypted( (char *)&l, 1 );
                     char *name = new char[ l + 1 ];
                     name[ (int)l ] = 0;
                     if( l )
                         klient->getNachrichtEncrypted( name, l );
-                    klient->getNachrichtEncrypted( (char *)& l, 1 );
+                    klient->getNachrichtEncrypted( (char *)&l, 1 );
                     char *passwort = new char[ l + 1 ];
                     passwort[ (int)l ] = 0;
                     if( l )
                         klient->getNachrichtEncrypted( passwort, l );
-                    klient->getNachrichtEncrypted( (char *)& l, 1 );
+                    klient->getNachrichtEncrypted( (char *)&l, 1 );
                     char *device = new char[ l + 1 ];
                     device[ (int)l ] = 0;
                     if( l )
@@ -902,23 +902,23 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int level = 0;
-                    klient->getNachrichtEncrypted( (char *)& level, 4 );
+                    klient->getNachrichtEncrypted( (char *)&level, 4 );
                     int sek = 0;
-                    klient->getNachrichtEncrypted( (char *)& sek, 4 );
+                    klient->getNachrichtEncrypted( (char *)&sek, 4 );
                     int diff = 0;
-                    klient->getNachrichtEncrypted( (char *)& diff, 4 );
+                    klient->getNachrichtEncrypted( (char *)&diff, 4 );
                     int gId = 0;
-                    klient->getNachrichtEncrypted( (char *)& gId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&gId, 4 );
                     if( accountId )
                     {
                         int kupfer = 0;
-                        klient->getNachrichtEncrypted( (char *)& kupfer, 4 );
+                        klient->getNachrichtEncrypted( (char *)&kupfer, 4 );
                         appS->zDB()->markballsFinish( level, sek, accountId, 0, diff, kupfer, gId );
                     }
                     else
                     {
                         unsigned char l = 0;
-                        klient->getNachrichtEncrypted( (char *)& l, 1 );
+                        klient->getNachrichtEncrypted( (char *)&l, 1 );
                         char *device = new char[ l + 1 ];
                         device[ (int)l ] = 0;
                         klient->getNachrichtEncrypted( device, l );
@@ -933,17 +933,17 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int diff = 0;
-                    klient->getNachrichtEncrypted( (char *)& diff, 4 );
+                    klient->getNachrichtEncrypted( (char *)&diff, 4 );
                     Array< int > *level = new Array< int >();
                     Array< int > *score = new Array< int >();
                     int anz = appS->zDB()->getMarkballsScore( level, score, diff );
-                    klient->sendeEncrypted( (char *)& anz, 4 );
+                    klient->sendeEncrypted( (char *)&anz, 4 );
                     for( int i = 0; i < anz; i++ )
                     {
                         int l = level->get( i );
-                        klient->sendeEncrypted( (char *)& l, 4 );
+                        klient->sendeEncrypted( (char *)&l, 4 );
                         int s = score->get( i );
-                        klient->sendeEncrypted( (char *)& s, 4 );
+                        klient->sendeEncrypted( (char *)&s, 4 );
                     }
                     level->release();
                     score->release();
@@ -961,20 +961,20 @@ void AppSKlient::thread()
                     else
                     {
                         unsigned char l = 0;
-                        klient->getNachrichtEncrypted( (char *)& l, 1 );
+                        klient->getNachrichtEncrypted( (char *)&l, 1 );
                         char *device = new char[ l + 1 ];
                         device[ (int)l ] = 0;
                         klient->getNachrichtEncrypted( device, l );
                         anz = appS->zDB()->getGegenstaende( 0, device, gId, diff );
                         delete[] device;
                     }
-                    klient->sendeEncrypted( (char *)& anz, 4 );
+                    klient->sendeEncrypted( (char *)&anz, 4 );
                     for( int i = 0; i < anz; i++ )
                     {
                         int g = gId->get( i );
-                        klient->sendeEncrypted( (char *)& g, 4 );
+                        klient->sendeEncrypted( (char *)&g, 4 );
                         int d = diff->get( i );
-                        klient->sendeEncrypted( (char *)& d, 4 );
+                        klient->sendeEncrypted( (char *)&d, 4 );
                     }
                     gId->release();
                     diff->release();
@@ -989,7 +989,7 @@ void AppSKlient::thread()
                     {
                         klient->sendeEncrypted( "\1", 1 );
                         int ret = appS->zDB()->getKupfer( accountId );
-                        klient->sendeEncrypted( (char *)& ret, 4 );
+                        klient->sendeEncrypted( (char *)&ret, 4 );
                     }
                     break;
                 }
@@ -1004,18 +1004,18 @@ void AppSKlient::thread()
                     else
                     {
                         unsigned char l = 0;
-                        klient->getNachrichtEncrypted( (char *)& l, 1 );
+                        klient->getNachrichtEncrypted( (char *)&l, 1 );
                         char *device = new char[ l + 1 ];
                         device[ (int)l ] = 0;
                         klient->getNachrichtEncrypted( device, l );
                         anz = appS->zDB()->getMarkballsFortschritt( 0, device, fortschritt );
                         delete[] device;
                     }
-                    klient->sendeEncrypted( (char *)& anz, 4 );
+                    klient->sendeEncrypted( (char *)&anz, 4 );
                     for( int i = 0; i < anz; i++ )
                     {
                         int f = fortschritt->get( i );
-                        klient->sendeEncrypted( (char *)& f, 4 );
+                        klient->sendeEncrypted( (char *)&f, 4 );
                     }
                     fortschritt->release();
                     break;
@@ -1024,17 +1024,17 @@ void AppSKlient::thread()
             {
                 klient->sendeEncrypted( "\1", 1 );
                 unsigned char l = 0;
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *name = new char[ l + 1 ];
                 name[ (int)l ] = 0;
                 if( l )
                     klient->getNachrichtEncrypted( name, l );
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *passwort = new char[ l + 1 ];
                 passwort[ (int)l ] = 0;
                 if( l )
                     klient->getNachrichtEncrypted( passwort, l );
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *device = new char[ l + 1 ];
                 device[ (int)l ] = 0;
                 if( l )
@@ -1055,7 +1055,7 @@ void AppSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int kupfer = 0;
-                    klient->getNachrichtEncrypted( (char *)& kupfer, 4 );
+                    klient->getNachrichtEncrypted( (char *)&kupfer, 4 );
                     appS->zDB()->addKupfer( accountId, kupfer );
                 }
                 else
@@ -1112,7 +1112,7 @@ void AppSKlient::errorZuKlient( const char *nachricht ) const // sendet eine Feh
 
 // Inhalt der AppSKTimeOut Klasse aus AppServer.h
 // Konstruktor
-AppSKTimeOut::AppSKTimeOut( AppSKlient * zK )
+AppSKTimeOut::AppSKTimeOut( AppSKlient *zK )
 {
     zKlient = zK;
     zm = new ZeitMesser();

+ 14 - 29
AppServer/Datenbank.cpp

@@ -9,6 +9,7 @@
 // Inhalt der AppSDatenbank Klasse aus Datenbank.h
 // Konstruktor
 AppSDatenbank::AppSDatenbank( InitDatei *zDat )
+    : ReferenceCounter()
 {
     datenbank = new Datenbank( zDat->zWert( "DBBenutzer" )->getText(), zDat->zWert( "DBPasswort" )->getText(),
                                zDat->zWert( "DBName" )->getText(), zDat->zWert( "DBIP" )->getText(),
@@ -22,7 +23,6 @@ AppSDatenbank::AppSDatenbank( InitDatei *zDat )
         exit( 1 );
     }
     InitializeCriticalSection( &ths );
-    ref = 1;
     Text befehl = "SELECT port, admin_port FROM server WHERE id = ";
     befehl += zDat->zWert( "ServerId" )->getText();
     lock();
@@ -60,11 +60,11 @@ int AppSDatenbank::istAdministrator( const char *name, const char *passwort )
     Text *befehl = new Text( "SELECT id FROM benutzer WHERE name = '" );
     Text n( name );
     n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
+    befehl->append( (char *)n );
     befehl->append( "' AND passwort = md5('" );
     Text p( passwort );
     p.ersetzen( "'", "''" );
-    befehl->append( (char*)p );
+    befehl->append( (char *)p );
     befehl->append( "')" );
     lock();
     datenbank->befehl( befehl->getText() );
@@ -545,11 +545,11 @@ int AppSDatenbank::pruefNeuAccount( const char *name, const char *eMail )
     Text *befehl = new Text( "SELECT account_neu_alt_check( '" );
     Text n( name );
     n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
+    befehl->append( (char *)n );
     befehl->append( "', '" );
     Text m( eMail );
     m.ersetzen( "'", "''" );
-    befehl->append( (char*)m );
+    befehl->append( (char *)m );
     befehl->append( "' )" );
     lock();
     datenbank->befehl( befehl->getText() );
@@ -565,9 +565,9 @@ int AppSDatenbank::pruefNeuAccount( const char *name, const char *eMail )
     {
         res.destroy();
         befehl->setText( "SELECT account.id FROM account, account_neu WHERE account.name = '" );
-        befehl->append( (char*)n );
+        befehl->append( (char *)n );
         befehl->append( "' OR account_neu.name = '" );
-        befehl->append( (char*)n );
+        befehl->append( (char *)n );
         befehl->append( "'" );
         lock();
         datenbank->befehl( befehl->getText() );
@@ -593,30 +593,30 @@ bool AppSDatenbank::neuAccount( const char *name, const char *pass, const char *
     Text *befehl = new Text( "INSERT INTO account_neu( name, passwort, geheimnis, e_mail, geb_datum ) VALUES ( '" );
     Text n( name );
     n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
+    befehl->append( (char *)n );
     befehl->append( "', md5('" );
     Text p( pass );
     p.ersetzen( "'", "''" );
-    befehl->append( (char*)p );
+    befehl->append( (char *)p );
     befehl->append( "'), '" );
     Text g( geheim );
     g.ersetzen( "'", "''" );
-    befehl->append( (char*)g );
+    befehl->append( (char *)g );
     befehl->append( "', '" );
     Text m( eMail );
     m.ersetzen( "'", "''" );
-    befehl->append( (char*)m );
+    befehl->append( (char *)m );
     befehl->append( "', '" );
     Text d( gebDatum );
     d.ersetzen( "'", "''" );
-    befehl->append( (char*)d );
+    befehl->append( (char *)d );
     befehl->append( "' )" );
     lock();
     if( datenbank->befehl( befehl->getText() ) )
     {
         unlock();
         befehl->setText( "SELECT schluessel, id FROM account_neu WHERE name = '" );
-        befehl->append( (char*)n );
+        befehl->append( (char *)n );
         befehl->append( "'" );
         lock();
         datenbank->befehl( befehl->getText() );
@@ -626,7 +626,7 @@ bool AppSDatenbank::neuAccount( const char *name, const char *pass, const char *
         {
             // e_mail senden
             pid_t pid;
-            char *pargs[] = { zIni->zWert( "PHP" )->getText(), zIni->zWert( "AccountActivationMail" )->getText(), (char*)name, (char*)geheim, (char*)gebDatum, res.values[ 0 ].getText(), (char*)eMail, res.values[ 1 ].getText(), (char*)0 };
+            char *pargs[] = { zIni->zWert( "PHP" )->getText(), zIni->zWert( "AccountActivationMail" )->getText(), (char *)name, (char *)geheim, (char *)gebDatum, res.values[ 0 ].getText(), (char *)eMail, res.values[ 1 ].getText(), (char *)0 };
             posix_spawn( &pid, zIni->zWert( "PHP" )->getText(), 0, 0, pargs, 0 );
         }
         res.destroy();
@@ -938,19 +938,4 @@ bool AppSDatenbank::getFreeAds( int account )
     bool ret = r.values[ 0 ].istGleich( "t" );
     r.destroy();
     return ret;
-}
-
-// Reference Counting
-AppSDatenbank *AppSDatenbank::getThis()
-{
-    ref++;
-    return this;
-}
-
-AppSDatenbank *AppSDatenbank::release()
-{
-    ref--;
-    if( !ref )
-        delete this;
-    return 0;
 }

+ 2 - 5
AppServer/Datenbank.h

@@ -4,6 +4,7 @@
 #include <sql.h>
 #include <Text.h>
 #include <InitDatei.h>
+#include <ReferenceCounter.h>
 
 using namespace Framework;
 using namespace sql;
@@ -14,12 +15,11 @@ namespace Admin_Recht
     const int AppSBeenden = 58;
 }
 
-class AppSDatenbank
+class AppSDatenbank : public virtual ReferenceCounter
 {
 private:
     Datenbank *datenbank;
     CRITICAL_SECTION ths;
-    int ref;
 
 public:
     // Konstruktor
@@ -65,9 +65,6 @@ public:
     int getMarkballsFortschritt( int accountId, char *device, Array< int > *f );
     void addKupfer( int account, int kupfer );
     bool getFreeAds( int account );
-    // Reference Counting
-    AppSDatenbank *getThis();
-    AppSDatenbank *release();
 };
 
 #endif

+ 44 - 44
AppServer/main.cpp

@@ -9,56 +9,56 @@
 
 int main()
 {
-	struct rlimit core_limits;
-	core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
-	setrlimit(RLIMIT_CORE, &core_limits);
+    struct rlimit core_limits;
+    core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
+    setrlimit( RLIMIT_CORE, &core_limits );
 
-	Framework::initFramework();
+    Framework::initFramework();
     //if( chdir( "/test/app" ) == -1 )
     //    return -1;
-	Zeit *z = getZeit();
-	Text *pfad = new Text( "../log/app/" );
-	pfad->append( z->getZeit( "y-m-d h-i-s.log" ) );
-	z->release();
-	DateiPfadErstellen( pfad->getThis() );
-	std::ofstream file;
-	file.open( pfad->getText() );
-	std::streambuf* sbuf = std::cout.rdbuf();
-	std::cout.rdbuf( file.rdbuf() );
-	pfad->release();
+    Zeit *z = getZeit();
+    Text *pfad = new Text( "../log/app/" );
+    pfad->append( z->getZeit( "y-m-d h-i-s.log" ) );
+    z->release();
+    DateiPfadErstellen( dynamic_cast<Text *>( pfad->getThis() ) );
+    std::ofstream file;
+    file.open( pfad->getText() );
+    std::streambuf *sbuf = std::cout.rdbuf();
+    std::cout.rdbuf( file.rdbuf() );
+    pfad->release();
 
-	std::cout << "AppS: Startet...\n";
-	std::cout << "AppS: Lese init Datei ../data/apsInit.ini ...\n";
+    std::cout << "AppS: Startet...\n";
+    std::cout << "AppS: Lese init Datei ../data/apsInit.ini ...\n";
 
-	InitDatei *dat = new InitDatei( "../data/apsInit.ini" );
-	if( !dat->laden() )
-	{
-		std::cout << "AppS: error: Datei konnte nicht gelesen werden. Das Programm wird geschlossen.\n";
-		dat->release();
-		exit( 1 );
-	}
-	const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "PHP", "AccountActivationMail", "Aktiv", "SSLCert", "SSLKey", "SSLPasswort" };
-	for( const char *w : wichtig )
-	{
-		if( !dat->wertExistiert( w ) )
-		{
-			std::cout << "AppS: error: Der Wert '" << w << "' wurde nicht gefunden. Das Programm wird geschlossen.\n";
-			dat->release();
-			exit( 1 );
-		}
-	}
+    InitDatei *dat = new InitDatei( "../data/apsInit.ini" );
+    if( !dat->laden() )
+    {
+        std::cout << "AppS: error: Datei konnte nicht gelesen werden. Das Programm wird geschlossen.\n";
+        dat->release();
+        exit( 1 );
+    }
+    const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "PHP", "AccountActivationMail", "Aktiv", "SSLCert", "SSLKey", "SSLPasswort" };
+    for( const char *w : wichtig )
+    {
+        if( !dat->wertExistiert( w ) )
+        {
+            std::cout << "AppS: error: Der Wert '" << w << "' wurde nicht gefunden. Das Programm wird geschlossen.\n";
+            dat->release();
+            exit( 1 );
+        }
+    }
 
-	AppServer *appServer = new AppServer( dat );
+    AppServer *appServer = new AppServer( dat );
 
-	std::cout << "AppS: Der Admin Server läuft. Startforgang beendet.\n";
-	appServer->runn();
+    std::cout << "AppS: Der Admin Server läuft. Startforgang beendet.\n";
+    appServer->runn();
 
-	appServer->ende();
-	appServer->release();
-	dat->release();
-	std::cout << "AppS: Der Server ist heruntergefahren.\n";
-	file.close();
-	std::cout.rdbuf( sbuf );
-	Framework::releaseFramework();
-	return 0;
+    appServer->ende();
+    appServer->release();
+    dat->release();
+    std::cout << "AppS: Der Server ist heruntergefahren.\n";
+    file.close();
+    std::cout.rdbuf( sbuf );
+    Framework::releaseFramework();
+    return 0;
 }