typedefstruct { char *name; /* User printable name of the function. */ rl_icpfunc_t *func; /* Function to call to do the job. */ char *doc; /* Documentation for this function. */ } COMMAND;
//这个 rl_rcpfunc_t 是系统自带的函数指针类型,typedef int rl_icpfunc_t (char *);
同时对于 Shell 的状态信息,我们需要定义一个结构体:
1 2 3 4 5 6 7 8 9 10 11 12 13
typedefstructYshell_control_block{
Yshell_job fg_job; /* currently executing foreground job */
double execution_time; /* execution time of last command */
char history_commands_file[128]; /* command history log file */
Yshell_job_list jobs; /* list of currently suspened and runing jobs */