Esempio n. 1
0
/*======================================================================*
                               TestA
 *======================================================================*/
void TestA()
{
	int fd;
	int i, n;

	char tty_name[] = "/dev_tty0";

	char rdbuf[128];


	int fd_stdin  = open(tty_name, O_RDWR);
	assert(fd_stdin  == 0);
	int fd_stdout = open(tty_name, O_RDWR);
	assert(fd_stdout == 1);

//	char filename[MAX_FILENAME_LEN+1] = "zsp01";
	const char bufw[80] = {0};
//	const int rd_bytes = 3;
//	char bufr[rd_bytes];

	clear();
	long int ii = 9999;

printf("                                                                           \n");while(ii-->0);ii=9999;
printf("    ##      D##                     ###           .##                      \n");
printf("    ##      D##                     W##           :##                      \n");
printf("    ##      G##                     ###           .##                      \n");
printf("    ##      G##                     ###           .##                      \n");
printf("    ##      G##                     ###           .##                      \n");
printf("    ##      G##                     ###           .##                      \n");
printf("    ##      D##      L###K          ###           .##           ##W# .     \n");
printf("    ##      G##    j#######i        ###           .##        .########     \n");
printf("    ###########    ##t  .W##        W##           .##        ###   W##D    \n");
printf("    ###########   ##D     ###       W##           .##       D##      ##    \n");
printf("    ##      G##  .##      ###       W##           .##       ##E      ##.   \n");
printf("    ##      G##  .###########       W##           .##       ##       ##E   \n");
printf("    ##      D##  :##                W##           .##       ##       ##E   \n");
printf("    ##      G##  .##                W##           .##       ##       ##G   \n");
printf("    ##      G##   ##.     f##       W##           .##       ##K      ##    \n");
printf("    ##      G##   ###.    ###       W##           .##       i#W     ;##    \n");
printf("    ##      G##    ###,  ###.       W##           .##        #### .###:    \n");
printf("    ##      D##     #######:        W##           :##         #######:     \n");
printf("                      K##           . .             .           i##  .     \n\n");
	startAnimate();
	
	clear();
	disp_color_str(" \n\n                   ==================================\n",5);
	disp_color_str("                                 Kernel on Orange's \n\n",3);
	disp_color_str("                                     Welcome !\n",4);
	disp_color_str("                        ====================================",5);

	

	while (1) {           
		printf("\n\n\n\n\n\n command:");


		int r = read(fd_stdin, rdbuf, 70);
		rdbuf[r] = 0;
		//show();
        if (strcmp(rdbuf, "process") == 0)
        {
			ProcessManage();
        }
		else if (strcmp(rdbuf, "filemng") == 0)
		{
			printf("File Manager is already running on CONSOLE-1 ! \n");

			continue;

		}else if (strcmp(rdbuf, "help") == 0)
		{
			help();
		}
		else if (strcmp(rdbuf, "timer") == 0)
		{

			timer(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "game") == 0){
			clear();
			game(fd_stdin, fd_stdout);
		}
		
		else if (strcmp(rdbuf, "clear") == 0)
		{
			clear();
			printf("                        ==================================\n");
			
			printf("                                 Kernel on Orange's \n\n");
			printf("                                     Welcome !\n");
			printf("                        ==================================\n");
		}
		

		else
			printf("Command not found, please check!\n");
	}
}
Esempio n. 2
0
/*======================================================================*
                               TestA
 *======================================================================*/
void TestA()
{
	int fd;
	int i, n;

	char filename[MAX_FILENAME_LEN+1] = "blah";
	const char bufw[] = "abcde";
	const int rd_bytes = 3;
	char bufr[rd_bytes];

	assert(rd_bytes <= strlen(bufw));

	/* create */
	fd = open(filename, O_CREAT | O_RDWR);
	assert(fd != -1);
	printl("File created: %s (fd %d)\n", filename, fd);

	/* write */
	n = write(fd, bufw, strlen(bufw));
	assert(n == strlen(bufw));

	/* close */
	close(fd);

	/* open */
	fd = open(filename, O_RDWR);
	assert(fd != -1);
	printl("File opened. fd: %d\n", fd);

	/* read */
	n = read(fd, bufr, rd_bytes);
	assert(n == rd_bytes);
	bufr[n] = 0;
	printl("%d bytes read: %s\n", n, bufr);

	/* close */
	close(fd);

	char * filenames[] = {"/foo", "/bar", "/baz"};

	/* create files */
	for (i = 0; i < sizeof(filenames) / sizeof(filenames[0]); i++) {
		fd = open(filenames[i], O_CREAT | O_RDWR);
		assert(fd != -1);
		printl("File created: %s (fd %d)\n", filenames[i], fd);
		close(fd);
	}

	char * rfilenames[] = {"/bar", "/foo", "/baz", "/dev_tty0"};

	/* remove files */
	for (i = 0; i < sizeof(rfilenames) / sizeof(rfilenames[0]); i++) {
		if (unlink(rfilenames[i]) == 0)
			printl("File removed: %s\n", rfilenames[i]);
		else
			printl("Failed to remove file: %s\n", rfilenames[i]);
	}
	
	TestD();

	
	

	char tty_name[] = "/dev_tty0";

	char rdbuf[128];


	int fd_stdin  = open(tty_name, O_RDWR);
	assert(fd_stdin  == 0);
	int fd_stdout = open(tty_name, O_RDWR);
	assert(fd_stdout == 1);

//	char filename[MAX_FILENAME_LEN+1] = "zsp01";
	const char bufwns[80] = {0};
//	const int rd_bytes = 3;
//	char bufr[rd_bytes];
	
	clear();
	welcome();
	
	while (1) {
		printl("hunix->");
		int r = read(fd_stdin, rdbuf, 70);
		rdbuf[r] = 0;
		//show();
		if (strcmp(rdbuf, "process") == 0)
		{
			ProcessManage();
		}
		else if(strcmp(rdbuf, "TextBook") == 0)
		{
			TextBook(fd_stdin, fd_stdout);
		}
		else if (strcmp(rdbuf, "filemng") == 0)
		{
			printf("File Manager is already running on CONSOLE-1 ! \n");
			continue;

		}else if (strcmp(rdbuf, "help") == 0)
		{
			help();
		}
		else if (strcmp(rdbuf, "NewFile") == 0)
		{

			NewFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "RemoveFile") == 0)
		{
			RemoveFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "WriteFile") == 0)
		{
			WriteFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "ReadFile") == 0)
		{
			ReadFile(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "Chess") == 0)
		{
			chess(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "Add") == 0)
		{
			Add(fd_stdin, fd_stdout);
		}
		else if(strcmp(rdbuf, "welcome") == 0)
		{
			welcome();
		}
		else if(strcmp(rdbuf, "number") == 0)
		{
			number(fd_stdin, fd_stdout);
		}
		else if (strcmp(rdbuf, "clear") == 0)
		{
			clear();
			
		}
		else
			printf("Command not found, please check!\n");
	}
	

	spin("TestA");
}