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; }
int CLuaACLDefs::aclCreate ( lua_State* luaVM ) { // acl aclCreate ( string aclName ) SString strACLName; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strACLName ); if ( !argStream.HasErrors () ) { // See that the name doesn't exist already CAccessControlList* pACL = m_pACLManager->GetACL ( strACLName ); if ( !pACL ) { // Create a new ACL with that name pACL = m_pACLManager->AddACL ( strACLName ); CLogger::LogPrintf ( "ACL: %s: ACL '%s' created\n", GetResourceName ( luaVM ), pACL->GetName () ); // Return the created ACL lua_pushacl ( luaVM, pACL ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaACLDefs::aclGet ( lua_State* luaVM ) { // acl aclGet ( string aclName ) SString strACLName; CScriptArgReader argStream ( luaVM ); argStream.ReadString ( strACLName ); if ( !argStream.HasErrors () ) { // See that the name doesn't exist already CAccessControlList* pACL = m_pACLManager->GetACL ( strACLName ); if ( pACL ) { // Return the created ACL lua_pushacl ( luaVM, pACL ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaACLDefs::aclCreate ( lua_State* luaVM ) { // Verify the argument types if ( lua_type ( luaVM, 1 ) == LUA_TSTRING ) { // Grab the arguments const char* szACLName = lua_tostring ( luaVM, 1 ); // See that the name doesn't exist already CAccessControlList* pACL = m_pACLManager->GetACL ( szACLName ); if ( !pACL ) { // Create a new ACL with that name pACL = m_pACLManager->AddACL ( szACLName ); CLogger::LogPrintf ( "ACL: %s: ACL '%s' created\n", GetResourceName ( luaVM ), pACL->GetName () ); // Return the created ACL lua_pushacl ( luaVM, pACL ); return 1; } } else m_pScriptDebugging->LogBadType ( luaVM, "aclCreate" ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaACLDefs::aclGroupListACL ( lua_State* luaVM ) { // Verify the arguents if ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA ) { // Grab and verify the group CAccessControlListGroup* pGroup = lua_toaclgroup ( luaVM, 1 ); if ( pGroup ) { // 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; } } // Return true lua_pushboolean ( luaVM, false ); return 1; }
int CLuaACLDefs::aclList ( lua_State* luaVM ) { // Create a table to return into lua_newtable ( luaVM ); // Loop through ACL stuff unsigned int uiIndex = 0; list <CAccessControlList* > ::const_iterator iter = m_pACLManager->ACL_Begin (); for ( ; iter != m_pACLManager->ACL_End (); iter++ ) { // Push onto the table lua_pushnumber ( luaVM, ++uiIndex ); lua_pushacl ( luaVM, *iter ); lua_settable ( luaVM, -3 ); } // Return true return 1; }
int CLuaACLDefs::aclGet ( lua_State* luaVM ) { // Verify the argument types if ( lua_type ( luaVM, 1 ) == LUA_TSTRING ) { // Grab the arguments const char* szACLName = lua_tostring ( luaVM, 1 ); // See that the name doesn't exist already CAccessControlList* pACL = m_pACLManager->GetACL ( szACLName ); if ( pACL ) { // Return the created ACL lua_pushacl ( luaVM, pACL ); return 1; } } else m_pScriptDebugging->LogBadType ( luaVM, "aclGet" ); lua_pushboolean ( luaVM, false ); return 1; }
void lua_pushuserdata ( lua_State* luaVM, void* pData ) { if ( CElement* pEntity = UserDataCast < CElement > ( ( CElement* ) NULL, pData, NULL ) ) return lua_pushelement ( luaVM, pEntity ); if ( CPlayer* pEntity = UserDataCast < CPlayer > ( ( CPlayer* ) NULL, pData, NULL ) ) return lua_pushelement ( luaVM, pEntity ); else if ( CResource* pResource = UserDataCast < CResource > ( ( CResource* ) NULL, pData, NULL ) ) return lua_pushresource ( luaVM, pResource ); else if ( CXMLNode* pNode = UserDataCast < CXMLNode > ( ( CXMLNode* ) NULL, pData, NULL ) ) return lua_pushxmlnode ( luaVM, pNode ); else if ( CLuaTimer* pTimer = UserDataCast < CLuaTimer > ( ( CLuaTimer* ) NULL, pData, luaVM ) ) return lua_pushtimer ( luaVM, pTimer ); else if ( CLuaVector2D* pVector = UserDataCast < CLuaVector2D > ( (CLuaVector2D*) NULL, pData, luaVM ) ) return lua_pushvector ( luaVM, *pVector ); else if ( CLuaVector3D* pVector = UserDataCast < CLuaVector3D > ( (CLuaVector3D*) NULL, pData, luaVM ) ) return lua_pushvector ( luaVM, *pVector ); else if ( CLuaVector4D* pVector = UserDataCast < CLuaVector4D > ( (CLuaVector4D*) NULL, pData, luaVM ) ) return lua_pushvector ( luaVM, *pVector ); else if ( CLuaMatrix* pMatrix = UserDataCast < CLuaMatrix > ( (CLuaMatrix*) NULL, pData, luaVM ) ) return lua_pushmatrix ( luaVM, *pMatrix ); else if ( CAccount* pAccount = UserDataCast < CAccount > ( (CAccount*) NULL, pData, luaVM ) ) return lua_pushaccount ( luaVM, pAccount ); else if ( CAccessControlList* pACL = UserDataCast < CAccessControlList > ( (CAccessControlList*) NULL, pData, luaVM ) ) return lua_pushacl ( luaVM, pACL ); else if ( CAccessControlListGroup* pACLGroup = UserDataCast < CAccessControlListGroup > ( (CAccessControlListGroup*) NULL, pData, luaVM ) ) return lua_pushaclgroup ( luaVM, pACLGroup ); else if ( CBan* pBan = UserDataCast < CBan > ( (CBan*) NULL, pData, luaVM ) ) return lua_pushban ( luaVM, pBan ); else if ( CTextDisplay* pTextDisplay = UserDataCast < CTextDisplay > ( (CTextDisplay*) NULL, pData, luaVM ) ) return lua_pushtextdisplay ( luaVM, pTextDisplay ); else if ( CTextItem* pTextItem = UserDataCast < CTextItem > ( (CTextItem*) NULL, pData, luaVM ) ) return lua_pushtextitem ( luaVM, pTextItem ); else if ( CDbJobData* pQuery = UserDataCast < CDbJobData > ( (CDbJobData*) NULL, pData, luaVM ) ) return lua_pushquery ( luaVM, pQuery ); lua_pushobject ( luaVM, NULL, pData ); }