本文整理汇总了C++中CAccessControlListGroup类的典型用法代码示例。如果您正苦于以下问题:C++ CAccessControlListGroup类的具体用法?C++ CAccessControlListGroup怎么用?C++ CAccessControlListGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAccessControlListGroup类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aclGroupListACL
int CLuaACLDefs::aclGroupListACL ( lua_State* luaVM )
{
// table aclGroupListACL ( aclgroup theGroup )
CAccessControlListGroup* pGroup;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pGroup );
if ( !argStream.HasErrors () )
{
// Create a table to return into
lua_newtable ( luaVM );
// Loop through ACL stuff
unsigned int uiIndex = 0;
list <CAccessControlList* > ::const_iterator iter = pGroup->IterBeginACL ();
for ( ; iter != pGroup->IterEndACL (); ++iter )
{
// Push onto the table
lua_pushnumber ( luaVM, ++uiIndex );
lua_pushacl ( luaVM, *iter );
lua_settable ( luaVM, -3 );
}
// Return the table
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
// Return true
lua_pushboolean ( luaVM, false );
return 1;
}
示例2: argStream
int CLuaACLDefs::aclGroupListObjects ( lua_State* luaVM )
{
// table aclGroupListObjects ( aclgroup theGroup )
CAccessControlListGroup* pGroup;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pGroup );
if ( !argStream.HasErrors () )
{
// Create a table to return into
lua_newtable ( luaVM );
// Loop through ACL stuff
char szBuffer [255];
unsigned int uiIndex = 0;
list <CAccessControlListGroupObject* > ::const_iterator iter = pGroup->IterBeginObjects ();
for ( ; iter != pGroup->IterEndObjects (); ++iter )
{
// Put the base type depending on the type
switch ( (*iter)->GetObjectType () )
{
case CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE:
strcpy ( szBuffer, "resource." );
break;
case CAccessControlListGroupObject::OBJECT_TYPE_USER:
strcpy ( szBuffer, "user." );
break;
};
// Append the object name
strncat ( szBuffer, (*iter)->GetObjectName (), 254 );
// Push its name onto the table
lua_pushnumber ( luaVM, ++uiIndex );
lua_pushstring ( luaVM, szBuffer );
lua_settable ( luaVM, -3 );
}
// Return the table
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: aclGroupGetName
int CLuaACLDefs::aclGroupGetName ( lua_State* luaVM )
{
// string aclGroupGetName ( aclGroup )
CAccessControlListGroup* pGroup;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pGroup );
if ( !argStream.HasErrors () )
{
// Return its name
lua_pushstring ( luaVM, pGroup->GetGroupName () );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例4: aclGroupRemoveACL
int CLuaACLDefs::aclGroupRemoveACL ( lua_State* luaVM )
{
// bool aclGroupRemoveACL ( aclgroup theGroup, acl theACL )
CAccessControlListGroup* pGroup; CAccessControlList* pACL;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pGroup );
argStream.ReadUserData ( pACL );
if ( !argStream.HasErrors () )
{
// Add the ACL to the group
pGroup->RemoveACL ( pACL );
CLogger::LogPrintf ( "ACL: %s: ACL '%s' removed from group '%s'\n", GetResourceName ( luaVM ), pACL->GetName (), pGroup->GetGroupName () );
// Return success
lua_pushboolean ( luaVM, true );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例5: aclDestroyGroup
int CLuaACLDefs::aclDestroyGroup ( lua_State* luaVM )
{
// bool aclDestroyGroup ( aclgroup aclGroup )
CAccessControlListGroup* pGroup;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pGroup );
if ( !argStream.HasErrors () )
{
// Delete it
CLogger::LogPrintf ( "ACL: %s: Group '%s' deleted\n", GetResourceName ( luaVM ), pGroup->GetGroupName () );
m_pACLManager->DeleteGroup ( pGroup );
// Return success
lua_pushboolean ( luaVM, true );
return 1;
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}
示例6: GetFileName
//.........这里部分代码省略.........
strcmp ( strAccess.c_str (), "1" ) == 0 )
{
bAccess = true;
}
// Grab the name of the 'right' name
const char *szRightName = pNameAttribute->GetValue ().c_str ();
// Create the rights control list
CAccessControlListRight* pRight = NULL;
if ( StringBeginsWith ( szRightName, "command." ) )
{
pRight = pACL->AddRight ( &szRightName[8], CAccessControlListRight::RIGHT_TYPE_COMMAND, bAccess );
}
else if ( StringBeginsWith ( szRightName, "function." ) )
{
pRight = pACL->AddRight ( &szRightName[9], CAccessControlListRight::RIGHT_TYPE_FUNCTION, bAccess );
}
else if ( StringBeginsWith ( szRightName, "resource." ) )
{
pRight = pACL->AddRight ( &szRightName[9], CAccessControlListRight::RIGHT_TYPE_RESOURCE, bAccess );
}
else if ( StringBeginsWith ( szRightName, "general." ) )
{
pRight = pACL->AddRight ( &szRightName[8], CAccessControlListRight::RIGHT_TYPE_GENERAL, bAccess );
}
else continue;
// Set all the extra attributes
for ( uint i = 0 ; i < pSubSubNode->GetAttributes ().Count () ; i++ )
{
CXMLAttribute* pAttribute = pSubSubNode->GetAttributes ().Get ( i );
pRight->SetAttributeValue ( pAttribute->GetName (), pAttribute->GetValue () );
}
}
}
}
}
}
}
// Load the groups
pSubNode = NULL;
uiSubNodesCount = m_pRootNode->GetSubNodeCount ();
for ( unsigned int i = 0 ; i < uiSubNodesCount ; i++ )
{
pSubNode = m_pRootNode->GetSubNode ( i );
if ( !pSubNode ) continue;
if ( pSubNode->GetTagName ().compare ( "group" ) == 0 )
{
CXMLAttribute* pAttribute = pSubNode->GetAttributes ().Find ( "name" );
if ( pAttribute )
{
CAccessControlListGroup* pGroup = AddGroup ( pAttribute->GetValue ().c_str () );
CXMLNode* pSubSubNode = NULL;
unsigned int uiSubSubNodesCount = pSubNode->GetSubNodeCount ();
for ( unsigned int j = 0 ; j < uiSubSubNodesCount ; j++ )
{
pSubSubNode = pSubNode->GetSubNode ( j );
if ( !pSubSubNode ) continue;
if ( pSubSubNode->GetTagName ().compare ( "object" ) == 0 )
{
CXMLAttribute* pSubAttribute = pSubSubNode->GetAttributes ().Find ( "name" );
if ( pSubAttribute )
{
const char *szAccountName = pSubAttribute->GetValue ().c_str ();
if ( StringBeginsWith ( szAccountName, "user." ) )
{
pGroup->AddObject ( &szAccountName[5], CAccessControlListGroupObject::OBJECT_TYPE_USER );
}
else if ( StringBeginsWith ( szAccountName, "resource." ) )
{
pGroup->AddObject ( &szAccountName[9], CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE );
}
}
}
else if ( pSubSubNode->GetTagName ().compare ( "acl" ) == 0 )
{
CXMLAttribute* pSubAttribute = pSubSubNode->GetAttributes ().Find ( "name" );
if ( pSubAttribute )
{
CAccessControlList* pACL = GetACL ( pSubAttribute->GetValue ().c_str () );
if ( pACL )
{
pGroup->AddACL ( pACL );
}
}
}
}
}
}
}
m_bNeedsSave = false;
return true;
}
示例7: GetAutoGroupName
///////////////////////////////////////////////////////////////
//
// CResource::RefreshAutoPermissions
//
// Update group and acl used aclrequest items
//
///////////////////////////////////////////////////////////////
bool CResource::RefreshAutoPermissions ( CXMLNode* pNodeAclRequest )
{
// Ensure group and acl exist
CAccessControlListGroup* pAutoGroup = g_pGame->GetACLManager()->AddGroup ( GetAutoGroupName () );
pAutoGroup->AddACL ( GetAutoAcl () );
pAutoGroup->AddObject ( GetName ().c_str (), CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE );
// Track unused right names
std::vector < CAclRightName > unusedRightNameMap;
std::vector < SAclRequest > unusedRequestList;
GetAclRequests ( unusedRequestList );
for ( uint i = 0 ; i < unusedRequestList.size () ; i++ )
unusedRightNameMap.push_back ( unusedRequestList[i].rightName );
// Track any pending requests
bool bHasPending = false;
for ( uint uiIndex = 0 ; true ; uiIndex++ )
{
CXMLNode* pNodeRight = pNodeAclRequest->FindSubNode ( "right", uiIndex );
if ( !pNodeRight )
break;
// Find existing
SAclRequest request ( CAclRightName ( pNodeRight->GetAttributeValue ( "name" ) ) );
if ( !FindAclRequest ( request ) )
{
// Add new request
request.bAccess = false;
request.bPending = true;
request.strWho = "";
request.strDate = "";
// Validate request
if ( !request.rightName.IsValid () || !StringToBool ( pNodeRight->GetAttributeValue ( "access" ) ) )
{
CLogger::ErrorPrintf ( "Invalid aclrequest line in %s (%s)\n", GetName ().c_str (), *request.rightName.GetFullName () );
return false;
}
CommitAclRequest ( request );
}
// This right is used
ListRemove ( unusedRightNameMap, request.rightName );
// Update flag
bHasPending |= request.bPending;
}
// Remove rights not requested
for ( std::vector < CAclRightName >::iterator iter = unusedRightNameMap.begin () ; iter != unusedRightNameMap.end () ; ++iter )
GetAutoAcl ()->RemoveRight ( iter->GetName (), iter->GetType () );
// If any rights are pending, print message
if ( bHasPending )
{
CLogger::LogPrintf ( "Resource '%s' requests some acl rights. Use the command 'aclrequest list %s'\n", GetName ().c_str (), GetName ().c_str () );
}
return bHasPending;
}