// ProjectName: Simple RBAC with role mutex Demo
// Author: Vistb
// Time: September 7th, 2009
// Environment: MS Windows7 RTM 32bit build 7600, MSVS2008 with SP1
#include "DefinitionAndInclude.h"
int main()
{
char commandBuffer[commandBufferSize];
// Output welcome info
printf("Simple RBAC with role mutex Demo\n");
printf("Tip: Type help command for help information.\n");
// Main procedure
while(true)
{
memset(commandBuffer,0,commandBufferSize);
fflush(stdin);
putchar('>');
// Get user command
fgets(commandBuffer,commandBufferSize,stdin);
for (int i=0;i<commandBufferSize;++i)
{
if (commandBuffer[i]=='\n')
{
commandBuffer[i]=0;
}
}
/* Analyze the command */
if (strcmp(commandBuffer,"help")==0) // Try if the command is help
{
HelpMainModule();
continue;
}
else if (strcmp(commandBuffer,"cls")==0) // Try if the command is cls
{
ClsMainModule();
continue;
}
else if (strcmp(commandBuffer,"query")==0) // Try if the command is query
{
QueryMainModule();
continue;
}
else if (CheckIsSaveOrLoadCommand(commandBuffer)) // Try if the command is save/load data
{
SaveAndLoadMainModule(commandBuffer);
continue;
}
else if (CheckIsRoleManageCommand(commandBuffer)) // Try if the command is role management
{
RoleManageMainModule(commandBuffer);
continue;
}
else if (CheckIsUserManageCommand(commandBuffer)) // Try if the command is user management
{
UserManageMainModule(commandBuffer);
continue;
}
else if (CheckIsUserRoleManageCommand(commandBuffer)) // Try if the command is user role management
{
UserRoleManageMainModule(commandBuffer);
continue;
}
else if (CheckIsRoleAccessManageCommand(commandBuffer)) // Try if the command is role access management
{
RoleAccessManageMainModule(commandBuffer);
continue;
}
else if (CheckIsRoleMutexManageCommand(commandBuffer)) // Try if the command is role mutex management
{
RoleMutexManageMainModule(commandBuffer);
continue;
}
else if (CheckIsAccessTestCommand(commandBuffer)) // Try if the command is access test
{
AccessTestMainModule(commandBuffer);
continue;
}
else
{
printf("Unknown command!\n");
}
}
return 0;
}
- 1
- 2
前往页