?? myshell.h
字號:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <dirent.h>
#include <ctype.h>
#define MAX_BUFFER 1024 // 讀取一行命令時最多1024個字符
#define MAX_ARGS 64 // 一行命令中最多64個參數(不包括I/O重定向和后臺運行)
#define NUM 10 // myshell所支持的命令個數
#define MAX_OPEN 10 // 最多打開10個dtdin重定向文件和10個stdout重定向文件(myshell支持多個I/O重定向)
#define MAX_PATH 100 // 文件名或目錄名的最大長度
typedef struct//自定義重定向數據結構
{
char *filename; // 重定向文件名
char opentype[3]; // 重定向文件打開方式 "a" "r" "w" char open[3]; // 重定向文件打開方式 ">>" "<" ">"
} Redirect; //
extern int errno; // system error number
extern char **environ; // environment array
/************************ 輔助函數 *****************************************/
int my_strtok(char *buf,char **args,int *states,Redirect *InPuts,Redirect *OutPuts);//命令行(字符串)解析
int Execute(char *buffer);//命令執行
int my_shell(FILE *inputfile,const Redirect *Outputs,const int *states);//命令入口
int my_spawn(char **args, const Redirect *Inputs,const Redirect *Outputs,int *states);//void my_delay(int n); //延時,保證父子進程的先后順序
void get_fullpath(char *fullpath,const char *shortpath); //獲取文件或目錄的完整路徑
int Error(int errortype,char **args,const Redirect * IOputs,const int *states, char * msg) ;// //錯誤處理
/************************ 命令函數 *******************************/
int my_cd(char **args,const Redirect *Inputs, int *states);// execute command 'cd'
void my_clear(void);// execute command 'clear'
int my_dir(char **args,const Redirect *Inputs, int *states);// execute command 'dir' //const Redirect *Outputs,
int my_echo(char **args,const Redirect *Inputs,int *states);// execute command 'echo' //const Redirect *Outputs,
int list_environ(void);// execute command 'environ'
int show_pwd(void); // execute command 'pwd'
int my_help(char **args,const Redirect *Outputs,int *states);// execute command 'help'
int my_bat(char **args,const Redirect *Inputs,const Redirect *Outputs,int *states); // execute command 'myshell'
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -