1.1 --- a/core/AdminCache.cpp Sun Aug 19 15:02:20 2007 +0000
1.2 +++ b/core/AdminCache.cpp Sun Aug 19 15:11:49 2007 +0000
1.3 @@ -460,7 +460,9 @@
1.4
1.5 if (name && name[0] != '\0')
1.6 {
1.7 - pUser->nameidx = m_pStrings->AddString(name);
1.8 + int nameidx = m_pStrings->AddString(name);
1.9 + pUser = (AdminUser *)m_pMemory->GetAddress(id);
1.10 + pUser->nameidx = nameidx;
1.11 }
1.12
1.13 return id;
1.14 @@ -507,7 +509,9 @@
1.15 m_LastGroup = id;
1.16 }
1.17
1.18 - pGroup->nameidx = m_pStrings->AddString(group_name);
1.19 + int nameidx = m_pStrings->AddString(group_name);
1.20 + pGroup = (AdminGroup *)m_pMemory->GetAddress(id);
1.21 + pGroup->nameidx = nameidx;
1.22
1.23 sm_trie_insert(m_pGroups, group_name, (void *)id);
1.24
1.25 @@ -585,6 +589,17 @@
1.26 return pGroup->addflags;
1.27 }
1.28
1.29 +const char *AdminCache::GetGroupName(GroupId gid)
1.30 +{
1.31 + AdminGroup *pGroup = (AdminGroup *)m_pMemory->GetAddress(gid);
1.32 + if (!pGroup || pGroup->magic != GRP_MAGIC_SET)
1.33 + {
1.34 + return 0;
1.35 + }
1.36 +
1.37 + return m_pStrings->GetString(pGroup->nameidx);
1.38 +}
1.39 +
1.40 void AdminCache::SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled)
1.41 {
1.42 AdminGroup *pGroup = (AdminGroup *)m_pMemory->GetAddress(id);
1.43 @@ -621,26 +636,27 @@
1.44
1.45 void AdminCache::AddGroupImmunity(GroupId id, GroupId other_id)
1.46 {
1.47 - AdminGroup *pGroup = (AdminGroup *)m_pMemory->GetAddress(id);
1.48 + AdminGroup *pGroup = (AdminGroup *)m_pMemory->GetAddress(other_id);
1.49 if (!pGroup || pGroup->magic != GRP_MAGIC_SET)
1.50 {
1.51 return;
1.52 }
1.53
1.54 - AdminGroup *pOther = (AdminGroup *)m_pMemory->GetAddress(id);
1.55 - if (!pOther || pOther->magic != GRP_MAGIC_SET)
1.56 + pGroup = (AdminGroup *)m_pMemory->GetAddress(id);
1.57 + if (!pGroup || pGroup->magic != GRP_MAGIC_SET)
1.58 {
1.59 return;
1.60 }
1.61
1.62 /* We always need to resize the immunity table */
1.63 int *table, tblidx;
1.64 - if (pOther->immune_table == -1)
1.65 + if (pGroup->immune_table == -1)
1.66 {
1.67 tblidx = m_pMemory->CreateMem(sizeof(int) * 2, (void **)&table);
1.68 + pGroup = (AdminGroup *)m_pMemory->GetAddress(id);
1.69 table[0] = 0;
1.70 } else {
1.71 - int *old_table = (int *)m_pMemory->GetAddress(pOther->immune_table);
1.72 + int *old_table = (int *)m_pMemory->GetAddress(pGroup->immune_table);
1.73 /* Break out if this group is already in the list */
1.74 for (int i=0; i<old_table[0]; i++)
1.75 {
1.76 @@ -651,7 +667,8 @@
1.77 }
1.78 tblidx = m_pMemory->CreateMem(sizeof(int) * (old_table[0] + 2), (void **)&table);
1.79 /* Get the old address again in case of resize */
1.80 - old_table = (int *)m_pMemory->GetAddress(pOther->immune_table);
1.81 + pGroup = (AdminGroup *)m_pMemory->GetAddress(id);
1.82 + old_table = (int *)m_pMemory->GetAddress(pGroup->immune_table);
1.83 table[0] = old_table[0];
1.84 for (unsigned int i=1; i<=(unsigned int)old_table[0]; i++)
1.85 {
1.86 @@ -660,7 +677,7 @@
1.87 }
1.88
1.89 /* Assign */
1.90 - pOther->immune_table = tblidx;
1.91 + pGroup->immune_table = tblidx;
1.92
1.93 /* Add to the array */
1.94 table[0]++;
1.95 @@ -1131,7 +1148,10 @@
1.96 return false;
1.97 }
1.98
1.99 - pUser->auth.identidx = m_pStrings->AddString(ident);
1.100 + int i_ident = m_pStrings->AddString(ident);
1.101 +
1.102 + pUser = (AdminUser *)m_pMemory->GetAddress(id);
1.103 + pUser->auth.identidx = i_ident;
1.104 GetMethodIndex(auth, &pUser->auth.index);
1.105
1.106 return sm_trie_insert(pTable, ident, (void **)id);
1.107 @@ -1354,7 +1374,14 @@
1.108
1.109 int *table = (int *)m_pMemory->GetAddress(pUser->grp_table);
1.110
1.111 - return table[index];
1.112 + GroupId gid = table[index];
1.113 +
1.114 + if (name)
1.115 + {
1.116 + *name = GetGroupName(gid);
1.117 + }
1.118 +
1.119 + return gid;
1.120 }
1.121
1.122 const char *AdminCache::GetAdminPassword(AdminId id)
1.123 @@ -1376,7 +1403,9 @@
1.124 return;
1.125 }
1.126
1.127 - pUser->password = m_pStrings->AddString(password);
1.128 + int i_password = m_pStrings->AddString(password);
1.129 + pUser = (AdminUser *)m_pMemory->GetAddress(id);
1.130 + pUser->password = i_password;
1.131 }
1.132
1.133 unsigned int AdminCache::FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize)