⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shell.h

📁 这是一个linux下的Shell.有命令历史和命令提示
💻 H
字号:
/////////////////////////////////////////////////////////////////////

#if !defined(AFX_SHELL_H__39C37421_B80B_47DE_8B98_08EECA27AD07__INCLUDED_)
#define AFX_SHELL_H__39C37421_B80B_47DE_8B98_08EECA27AD07__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//
//
//
#include "CircleQueue.h"
#include "List.cpp"
#include "Process.h"
const int FILENAMESIZE_MAX = 256;
const int READ  = 0;
const int WRITE = 1;

class Shell  
{
public:
	Shell();
        ~Shell();
	void  getinput_stdin(void);
	void  getinput_file(void);
	void  load(int fid);
	bool  getcommand(void);
	
	// anslyse the command.
	// block it.
	
	void  run(void);		
private:
	
	int  command_simple(char** command_block,int num_block,pro_info& pro);				//fill pro
	int  command_lover(char** command_block,int num_block);						//is a lover command?yes run it
	void  command_anslyse(void);									
	void  execv__(pro_info pro);									//execute pro
	void  execv__(char* , List<char>* , char* outputfile);
	void  exit__(void);										// exit lover
	void  fresh(void);										//fresh command
	void  idle(void);										//run if now is idle.	
private:
	void  showPath(void);
	void  setPath(int num, char** pp);
	void  addPath(char* p);
	void  subPath(char* p);
private:
	char*        findFirst(char* s,int type);
	List<char>*  findAll(char* s,int type, bool curFlag);
	char*  findFirstExecFile(char* s);
	List<char>*  findAllExecFile(char* s);
	char*        findfirst(List<char>path,char* p,int type);
	char*        findfirst(char* path,char* p,int type);
	List<char>*  findall(List<char>path,char* p,int type);
	List<char>*  findall(char* path,char* p,int type);
	//
	char*        _findfirst(List<char>path,char* p_subdir,int type);
	char*        _findfirst(char* path, char* p_subdir,int type);
	List<char>*  _findall(List<char> path, char* p_subdir,int type);	
	List<char>*  _findall(char* path,char* p_subdir,List<char>* o,int type);	
	List<char>*  _findall(char* path,char* p_subdir,int type);
private:
	void recoverIOenv(void);
	void _cd(char* p);
	void _pwd(void);								
	void _his(int num);
	void show(void);
private:
	CircleQueue commandbuf;							//the history of command
	List<char> PATH;								//the path of Lover seach from
	List<char> command_file;
	int     num_process_background;
	char    tipchar;								//the Lover tip char.default 
											//normol user is '$'.the root user is '#'
	char*   path_cur;								//current path
	char*   path_userhome;								//the user's home directory
	char*   name_user;								//the user's name
	char    path_cur_last[FILENAMESIZE_MAX + 1];					

	char*   input;									//the user input buffer point
	char*   command;								//command
private:
	static   const char*  spechar;
	static   const char*  helpinfo;		
	struct termios* save;
};

#endif // !defined(AFX_SHELL_H__39C37421_B80B_47DE_8B98_08EECA27AD07__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -