//< ZECERY COS v1.0>
//Running on C++17

#include<iostream>
#include<string>
using namespace std;

const int MAXULIST	=1024;

string clist[]={//命令表 
"help","mkdir","rmdir","mkfile","rmfile"//4
};

namespace basic{
	void clear(){
		#ifdef __WIN32
		system("cls");
		#else
		system("clear");
		#endif
	}
}

namespace user{
	struct userinfo{
		string name;
		int id;
		char per;	//权限
		//V:访客
		//U:普通用户
		//A:管理员
		//R:超级管理员 
		string passwd;
		void loadpasswd(string k){
			passwd=k;
		}
		
		bool trypasswd(string k){
			if(k==passwd)return 1;
			return 0;
		}
	}ulist[MAXULIST]={{"root",1,'R',"zecery"}};
	
	int nwuser;
	bool islogin;
	
	void login(){
		bool run=1;
		while(run){
			basic::clear();
			cout<<"Please log in.\n";
			string username;
			int cho=-1;
			while(cho==-1){
				cout<<"Username:";
				cin>>username;
				for(int i=0;i<MAXULIST;i++){
					if(ulist[i].name==username){
						cho=i;
						break;
					}
				}
				if(cho==-1){
					cout<<"User "<<username<<" not found. Please try again.\n";
				}
			}
			string passwd="";
			int tried=0;
			while(!ulist[cho].trypasswd(passwd)){
				if(tried)cout<<"Password Wrong.";
				if(tried<3)cout<<" Please try again.\n";
				
				cout<<"Password:";
				cin>>passwd;
				tried++;
			}
			if(ulist[cho].trypasswd(passwd)){
				run=0;
			}
		}
		nwuser=cho;
	}
}

namespace console{
	char status;	//现在的读写模式 
	//1.命令模式
	//2.全页模式
	
	void printInfo(){
		
	}
	
	void readCommand(int&x,string&other){
		string k;
		getline(cin,k);
		other="";
		string cmd="";
		bool iscmd=1;
		for(int i=0;i<(int)k.size();i++){
			if(iscmd&&k[i]==' ')iscmd=0;
			if(iscmd){
				cmd+=k[i];
			}else{
				other+=k[i];
			}
		}
		return;
	}
}