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

📄 shell.c

📁 阿基米德操作系统的源代码
💻 C
字号:

//////////////////////////////////////////////////////////////////////////
#include "general.h"
#include "s_isdirreg.h"
#include "the_syscalls.h"

#include "shell_head.h"
//////////////////////////////////////////////////////////////////////////

void do_shell(void){
	////////////////////////////////////////////
	char * temp_pChar;
	char * temp_pChar0;
	char * temp_pChar1;
	int	   temp_index;
	int	   temp_length;
	
	int	   temp_Ret;
	int	   i,j;

	shell_driver = 2;

	the_screen_call11(0x07);
	the_screen_call09(0);

	the_screen_call18(hello_msg0);
	the_screen_call18(hello_msg1);
	the_screen_call18(hello_msg2);
	the_screen_call18(hello_msg3);

	the_screen_call18(path_buf);

	while(1)
	{
		command_ret = the_keybd_call02(command_buf,250);
		check_cmdline();
		if (command_params){
			temp_pChar				= command_buf + command_index + 1;
			temp_index				= command_index;
			command_index			= command_buf[command_index];
			command_params--;
			command_buf[temp_index] = 0;

			temp_length = 0;
			temp_pChar0 = temp_pChar;
			temp_index	= temp_index + 1;

			if (command_params == 0)
				while (*temp_pChar0 != 0)
				{
					if (((*temp_pChar0) >= 0x61) && ((*temp_pChar0) <= 0x7a))
						*temp_pChar0 = *temp_pChar0 - 0x20;
						
					temp_length++;
					temp_pChar0++;
				}
			else
				while ((temp_index < command_index) && (*temp_pChar0 != 0))
				{
					if (((*temp_pChar0) >= 0x61) && ((*temp_pChar0) <= 0x7a))
						*temp_pChar0 = *temp_pChar0 - 0x20;
						
					temp_length++;
					temp_pChar0++;
					temp_index++;
				}

			i = 0;
			if (temp_length > 10)
				i = NR_COMMAND;
			while (i < NR_COMMAND)
			{
				if ((temp_length < 10) && (command_table[i][temp_length]))
				{
					i++;
					continue;
				}
				temp_pChar0 = temp_pChar;
				temp_pChar1 = command_table[i];
				j = 0;
				while (j < temp_length)
				{
					if (*temp_pChar0++ != *temp_pChar1++)
						break;
					j++;
				}
				if (j == temp_length)
					break;
				i++;
			}
			if (i < NR_COMMAND)
				Cmd_Func_table[i]();
			else
			{
				if ((command_params == 0) && (temp_length == 2) && ((*(temp_pChar + 1)) == ':') &&
					((*temp_pChar) >= 'A') && ((*temp_pChar) <= 'Z') && ((*temp_pChar) != 'B'))
				{
					i = j = *temp_pChar - 'A';
					
					if (j != shell_driver)
					{
						temp_Ret = the_file_chdriver(i, path0_buf, 256);
						if (temp_Ret < 0)
						{
							the_screen_call18("\n\r    C: bad parameters!");
							temp_Ret = the_file_getpath(path0_buf, 256, NULL);
						}
						else
							shell_driver = j;

						for (i = 0; i < temp_Ret + 3; i++)
							path_buf[i] = path0_buf[i];
						pathbuf_length = temp_Ret;
					}
				}
				else
				{
					temp_Ret = the_exec_execve(command_buf0);
					if (temp_Ret < 0)
						the_screen_call18("\n\rBad command!");
					
					temp_Ret = the_file_getpath(path0_buf, 256, &shell_driver);	
					for (i = 0; i < temp_Ret + 3; i++)
						path_buf[i] = path0_buf[i];
					pathbuf_length = temp_Ret;
				}
			}

		}

		//////////////////////////////////////////////////
		the_screen_call18(path_buf);
		the_file_sync();
		//////////////////////////////////////////////////
	}

	return;}
///////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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