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; }
int CLuaACLDefs::aclGroupListObjects ( 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 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; } } // Return true lua_pushboolean ( luaVM, false ); return 1; }