]> git.stg.codes - stg.git/commitdiff
Initializing constructor added for IA_USER
authorMaxim Mamontov <faust.madf@gmail.com>
Tue, 13 Sep 2011 14:19:38 +0000 (17:19 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Tue, 13 Sep 2011 14:19:38 +0000 (17:19 +0300)
projects/stargazer/plugins/authorization/inetaccess/inetaccess.h

index 5b2808803596ce8239e718718a2e559f5643cd91..e55733c10814cf407223198bad4360a47ed5a7e6 100644 (file)
@@ -126,15 +126,14 @@ struct IA_USER {
           protoVer(0),
           password("NO PASSWORD")
     {
           protoVer(0),
           password("NO PASSWORD")
     {
-        // +++ Preparing CTX +++
-        unsigned char keyL[PASSWD_LEN];
-        memset(keyL, 0, PASSWD_LEN);
-        strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
-        Blowfish_Init(&ctx, keyL, PASSWD_LEN);
-        // --- Preparing CTX ---
-        #ifdef IA_DEBUG
-        aliveSent = false;
-        #endif
+    unsigned char keyL[PASSWD_LEN];
+    memset(keyL, 0, PASSWD_LEN);
+    strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
+    Blowfish_Init(&ctx, keyL, PASSWD_LEN);
+
+    #ifdef IA_DEBUG
+    aliveSent = false;
+    #endif
     };
 
     IA_USER(const IA_USER & u)
     };
 
     IA_USER(const IA_USER & u)
@@ -148,12 +147,37 @@ struct IA_USER {
           protoVer(u.protoVer),
           password(u.password)
     {
           protoVer(u.protoVer),
           password(u.password)
     {
-        #ifdef IA_DEBUG
-        aliveSent  = u.aliveSent;
-        #endif
-        memcpy(&ctx, &u.ctx, sizeof(BLOWFISH_CTX));
+    #ifdef IA_DEBUG
+    aliveSent  = u.aliveSent;
+    #endif
+    memcpy(&ctx, &u.ctx, sizeof(BLOWFISH_CTX));
     };
 
     };
 
+    IA_USER(const std::string & l,
+            CONST_USER_PTR u,
+            uint16_t p,
+            int ver)
+        : login(l),
+          user(u),
+          phase(),
+          lastSendAlive(0),
+          rnd(random()),
+          port(p),
+          ctx(),
+          messagesToSend(),
+          protoVer(ver),
+          password(user->GetProperty().password.Get())
+    {
+    unsigned char keyL[PASSWD_LEN];
+    memset(keyL, 0, PASSWD_LEN);
+    strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
+    Blowfish_Init(&ctx, keyL, PASSWD_LEN);
+
+    #ifdef IA_DEBUG
+    aliveSent = false;
+    #endif
+    }
+
     std::string     login;
     CONST_USER_PTR  user;
     IA_PHASE        phase;
     std::string     login;
     CONST_USER_PTR  user;
     IA_PHASE        phase;