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

📄 shell.c

📁 Jazmyn is a 32-bit, protected mode, multitasking OS which runs on i386 & above CPU`s. Its complete
💻 C
字号:
#include <sys\types.h>
#include <null.h>
#include <utils.h>
#include <stdio.h>
#include <string.h>
#include <jazmyn.h>

int main(int argc,char **argv,char **env)
{
        char drive = env[1][5];

        char init[4] = {drive,':','\\','\0'};
        char path[255]={'\0'};
        char end[]={">"};

        char prompt[255];

        int exit_status;
        int pid;

        printf("\n\nJazmyn Shell Version 0.1\n");
        printf("Type 'help' to get the list of commands\n");
        char buf[40];
        char argbuf[40];
        while(1)
        {
                strcpy(prompt,init);
                strcat(prompt,path);
                strcat(prompt,end);

                printf(prompt);

                if(read(0,buf,40))
                {
                        if(strcmp(buf,"help") == 0)
                        {
                                printf("\nThe following commands are recognized:\n\n");
                                printf("            help        - Displays this help\n");
                                printf("            ver         - Displays OS version\n");
                                printf("            date        - Displays current date\n");
                                printf("            time        - Displays current time\n");
                                printf("            ps          - Displays process status\n");
                                printf("            cls         - Clears the screen\n");
                                printf("            dir         - Displays dir listing\n");
                                printf("            exit        - Reboots the system\n\n");
                        }

                        else if(strcmp(buf,"ver") == 0)
                        {
                                printf("\nJazmyn [Version 0.1]\n\n");
                        }
                        else if(strcmp(buf,"date") == 0)
                        {
                                date();
                        }
                        else if(strcmp(buf,"time") == 0)
                        {
                                time();
                        }
                        else if(strcmp(buf,"ps") == 0)
                        {
                                ps();
                        }
                        else if(strcmp(buf,"exit") == 0)
                        {
                                exit();
                        }
                        else if(strcmp(buf,"cls") == 0)
                        {
                                cls();
                        }
                        else if(strcmp(buf,"dir") == 0)
                        {
                                pid = fork();
                                if(pid == 0)
                                {
                                        execve("dir.com",NULL,NULL);
                                }
                                wait(&exit_status);
                        }
                        else if(strncmp(buf,"cd",2) == 0)
                        {
                                strcpy(argbuf,(char*)&buf[3]);
                                if(!chdir(argbuf))
                                {
                                        strcpy(path,argbuf);
                                }
                        }
                        else
                        {
                                printf("\nBad Command\n\n");
                        }
                }
        }
        return 0;
}
        

⌨️ 快捷键说明

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