资源简介
os作业分享,可以在mac环境编译运行,虚拟机没调试过
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#define LEN sizeof(struct commandHistory)
#define LEN1 sizeof(struct savePath)
struct commandHistory
{
int iOrder;
char *strDisplay_name;
char *strDirectory;
struct commandHistory *next;
};
struct savePath
{
char *path_name;
struct savePath *next;
};
/* Function prototypes */
char * extractRoute_cd(char * const char * int);
char * extractRoute_path(char * const char * int);
struct commandHistory * create_commandHistroy(int char * char *);
void display_History(struct commandHistory *);
int clear_History(struct commandHistory*);
struct commandHistory * write_History(int char * char * struct commandHistory *);
void display_singleHistory(int int struct commandHistory *);
struct savePath * create_path_head(char *);
void write_Path(int char * struct savePath *);
struct savePath * delete_path(char * struct savePath *);
void display_path(struct savePath *);
int execu_tion(char *);
int main(int argc const char * argv[]) {
char *strCommand_name[6] = { “exit““cd ““pwd““path““history“}; //add a “ “ to each command so that the program can know if the format is wrong
char *strUser_command1; //for saving user‘s input
char strHistory_offset1[10] = “history -c“; //for “strcmp“ to find the offset
char strUser_command[100];
char strNew_directory[100] = {0}; //for saving user‘s file route
char strOffset_empty[8] = {“ “}; //“pwd“ command does not have offset
int iDigit=0; //to record the command‘s number of character
int irecordNumber = 0; //to record which record “history -[num]“ wants to look for
int iNumber = 0; // which command was executed? 0 means “exit “;1 means “cd “....
int iTotal_execution = 0; //to record how many commands were executed.
struct commandHistory * head = NULL; //use a chain to record command history
struct savePath * head_path = NULL;
char *strCommand_extract_cd = NULL;
char *strCommand_extract_history = NULL;
char *strCommand_extract_path = NULL;
char *token=NULL;
int iNumber_path = 0;
char buf[80];
while (1)
{
char str1[100]=“+ “;
char str2[100]=“- “;
char *pathDirectory = NULL;
printf(“\n$“);
strUser_command1 = (char *)malloc(100 *sizeof(char));
fgets(strUser_command1100stdin);
strcpy(strUser_command strUser_command1);
iDigit = ((int)strlen(strUser_command))-1;
//printf(“\n%d---digit“iDigit);
strUser_command[iDigit]=‘\0‘;
free(strUser_command1);
//if (head_path!=NULL)
//{
if(strUser_command[0]==‘/‘||(strUser_command[0]==‘.‘&&strUser_command[1]==‘/‘)) //if the input is a
{
int status;
status = execu_tion(strUser_command);
- 上一篇:Qt实现动态曲线图+文本数据的实时显示
- 下一篇:锅炉课程设计计算用表.xlsm
相关资源
- ACCESS财务报表(带数据).accdb
- The Secret Path 3D 3D魔方迷宫[源码][scra
- LCD显示温度+串口接收温度.rar
- Xpath生成器,自动生成可用的Xpath。
- CSMA/CD等动画演示加源代码
- Img2Lcd(将图片转换为数组的工具)
- 基于c8051f020的AD转换程序及LCD显示程序
- [免费]msp430f149控制PS2键盘并用1602显示
- ICD10 excel
- arm触摸屏与LCD校准程序三点校准法
- vhdl与lcd1602实现的多控制电子钟
- pctolcd2002完美版460701
- ADC0809数字电压表 LCD1602显示 汇编程序
- lcd12684显示程序
- lcd12864的VHDL程序
- CD7110客显测试程序
- LCD12864滚动显示
-
xm
l课件及例题(xm l) - linux简易shell C实现
- 收藏奉献_DOS汉字系统03:WPS 2.0 + 金山
- shell从入门到精通
- ECC和ECDSA算法
- Anti-biofilm Activity of Resveratrol and Ursol
- 偏振深非弹性散射中包容性重味产生
- STM32 电子密码锁设计,LCD12864显示
- STM32 LCD12864并口驱动实验
- 全自动采集getshell工具
- 类似QCD的新领域中的Theta
- 从动态晶格QCD模拟得出迷人的四夸克
- 从晶格QCD计算中提取parton分布函数
评论
共有 条评论