Exemplo n.º 1
0
void shell_main(){
	t_printf("\n[CX] Kernel Debug Shell, forced into due to Kernel fail or Load info said so.\n");
	t_printf("Type \"help\" to get started\n\n");	
	while(running){
		// print the prompt
		t_printf("debug %s $ ", current_args);
		char* c = waitforstring();
		if(strEql(c, "pkaddr")){
			print_kernel_addrs();		
		}else if(strEql(c, "help")){
			print_debug_help();
		}
	}
}
Exemplo n.º 2
0
void kmain(){
	isr_install();	
	clearScreen();
	while(1){		
		print("Echinopsis> ");
		string ch = readStr();
		if(strEql(ch,"kuria")){
			clearScreen();
			continue;
		}
		else if(strEql(ch,"")){
			//enter
		}
		else{
			print("\n");
			print(ch);
			print(": command not found");
		}
		print("\n");
	}
	return;
}
Exemplo n.º 3
0
void launchShell() {
    initialize_calc();

    //allocate some memory for command string buffer. 1kB should be enough for now
    const int bufSize = 128;
    char bufStr[bufSize];//Store sanitized user command (no arguments)
    char rawCommand[bufSize];//Gets user raw command from command line
    char arguments[bufSize/2][bufSize/2];//Store command arguments
    int fs = 1;//First space (first word means actual command)
    int ay = -1;//Y location for arguments
    int ax = 0;//X location for argumetns

    //prepare variable
    for(int i = 0; i < bufSize; ++i){
	bufStr[i] = 0;
    }
    for(int y = 0; y < bufSize; ++y){
	for(int x = 0; x < bufSize; ++x){
		arguments[y][x] = 0;
    	}
    }

    #define TIP print("\nTip: If enter key does not work, it might mean that the input is too long",0x0F);
    #define HELP print("\nWorking Commands in Q OS: \nwriter\nclear\nexecute\nhi\nskip (the no action)\nfiles\ncat\nreboot\ncalc", 0x0F);
    #define BIGHELP kbHelp(); TIP; HELP;
    #define SYSTEMMAN system(arguments);
    #define SAYHI print("\nHello!", 0x3F);
    #define CATFILE print("\nFile Name>  ", 0x0F); readStr(bufStr, bufSize); ASSERT(strlength(bufStr) < MAX_FNAME_LEN); cat(finddir_fs(fs_root, bufStr));
    #define SWITCHDIR print("\nThe specified directory was not found ", 0x0F);
    #define CALCULATE calc(arguments);
    #define BIGCLEAR clearScreen(); printIntro();
    #define MKDIR print("\nThis Command is Reserved for when we have a FAT32 or better FileSystem...", 0x3F);
    #define RMFILE print("\nThis Command is Reserved for when we have a FAT32 or better FileSystem...", 0x3F);
    #define SKIP skip(rawCommand);
    #define FILEMAN files(arguments);
    #define WRITE writer(arguments);
    #define ME me(rawCommand);
    #define CMDNOTFOUND print("\n", 0x0F); print(bufStr, 0x0F); print(": Command Not Found ", 0x0F);

    while (true) {
        print("\nQ-Kernel>  ", 0x08);
        typingCmd = true;
        newCmd = true;
        readStr(rawCommand, bufSize);
        typingCmd = false;

    	for(int i = 0; i < bufSize; ++i){
    	    bufStr[i] = 0;
    	}
    	for(int y = 0; y < bufSize; ++y){
                for(int x = 0; x < bufSize; ++x){
    		arguments[y][x] = 0;
    	    }
    	}
    	fs = 1;
        ay = -1;
        ax = 0;
        if(MULTI_ARG_DEBUG == true) {
            //Sanitize raw input. Move first word to bufStr and move the rest of the word to arguments
            for(int i = 0; i < bufSize; ++i) {
                if(rawCommand[i] != 0 || rawCommand[i] != 10) {
                    if(fs == 1)
                        bufStr[i] = rawCommand[i];
                    else if(fs == 0)
                        arguments[ay][ax] = rawCommand[i];

                    if(i < bufSize && rawCommand[i+1] == 32) {
          		        fs = 0;
          		        ay++;
          		    }
    	        }
                else break;
    	    }
        } else {
            //Sanitize raw input. Move first word to bufStr and move the rest of the word to arguments
            for(int i = 0; i < bufSize; ++i) {
                if(rawCommand[i] != 0 || rawCommand[i] != 10) {
                    if(fs == 1)
                        bufStr[i] = rawCommand[i];
                    if(i < bufSize && rawCommand[i+1] == 32) {
                        fs = 0;
                        ay++;
                        ax = 0;
                    } else if(fs == 0) {
                        arguments[ay][ax] = rawCommand[i];
                        ax++;
                    }
                } else break;
            }
        }

        if (strEql(strTrim(bufStr), ""))        {   HELP;             }
        else if(strEql(bufStr, "help"))         {   BIGHELP;          }
        else if(strEql(bufStr, "system"))       {   SYSTEMMAN;        }
        else if(strEql(bufStr, "skip"))         {   SKIP;             }
        else if(strEql(bufStr, "hi"))           {   SAYHI;            }
        else if(strEql(bufStr, "files"))        {   FILEMAN;          }
        else if(strEql(bufStr, "cat"))          {   CATFILE;          }
        else if(strEql(bufStr,"execute"))       {   execute();        }
        else if(strEql(bufStr,"switch"))        {   SWITCHDIR;        }
        else if(strEql(bufStr,"writer"))        {   WRITE;            }
        else if(strEql(bufStr, "calc"))         {   CALCULATE;        }
        else if(strEql(bufStr, "clear"))        {   clearScreen();    }
        else if(strEql(bufStr, "clear -i"))     {   BIGCLEAR;         }
        else if(strEql(bufStr, "newdir"))       {   MKDIR;            }
        else if(strEql(bufStr, "erase"))        {   RMFILE;           }
	else if(strEql(bufStr, "me"))           {   ME;               }
        else                                    {   CMDNOTFOUND;      }

        newline();
    }
}
Exemplo n.º 4
0
void launchShell() {
    //allocate some memory for command string buffer. 1kB should be enough for now
    const int bufSize = 128;
    char bufStr[bufSize];

    

   
    while (true)
    {
        print("\nQ-Kernel>  ", 0x08);
        typingCmd = true;
        newCmd = true;
        readStr(bufStr, bufSize);
        typingCmd = false;

        if (strEql(strTrim(bufStr), ""))
        {
            print(COMMAND_HELP, 0x0F);
        }
        else if(strEql(bufStr, "help"))
        {
            kbHelp();
            println(PRO_TIP, 0x0F);
            print(COMMAND_HELP, 0x0F);
        }
        else if(strEql(bufStr, "reboot"))
        {
            //reboots the computer
            reboot();
        }
        else if(strEql(bufStr, "skip"))
        {
            // It literally does nothing... (Useful at callback) 
        }
        else if(strEql(bufStr, "hi"))
        {
            print("\nHello!", 0x3F);
        }
        else if(strEql(bufStr, "files"))
        {
            newline();
            listTree();
        }
        else if(strEql(bufStr, "cat"))
        {
            print("\nFile Name>  ", 0x0F);
            readStr(bufStr, bufSize);
            ASSERT(strlength(bufStr) < MAX_FNAME_LEN);
            catFile(finddir_fs(fs_root, bufStr));
        }
        else if(strEql(bufStr,"execute"))
        {
            execute();
        }
        else if(strEql(bufStr,"switch"))
        {
            	print("\nThe specified directory was not found ", 0x0F);
        }
	else if(strEql(bufStr,"writer")) { writer(); }
	else if(strEql(bufStr, "writer -h")) { writerHelp(); }
	
	else if(strEql(bufStr, "calc")){ calc(); }
        else if(strEql(bufStr, "calc -h")){ calcHelp(); }

        else if(strEql(bufStr, "clear"))
        {
           	 clearScreen();
           	 cursorX = 0;
           	 cursorY = 0;
           	 updateCursor();
        }
        else if(strEql(bufStr, "clear -i"))
        {
            	clearScreen();
            	printIntro();
        }
        else if(strEql(bufStr, "newdir"))
        {
            	print("\nReserved", 0x0F);
        }
        else if(strEql(bufStr, "erase"))
        {
            	print("\nReserved", 0x0F);
        }
        else
        {
            	print("\nCommand Not Found ", 0x0F);
        }
        newline();
    }
}
Exemplo n.º 5
0
kmain()
{
  clearScreen();
  print("================================================================================\n",0x0F);
  print("                             Welcome to Q OS\n\n",0x0F);
  print("================================================================================\n",0x0F);

  while (1)
  {
    print("\nQ-Kernel>  ",0x0F);

    string ch = readStr();
    if(strEql(ch,"help "))
    {
      print("\nShowing Help for Q OS ",0x0F);
    }
    else if(strEql(ch,"do"))
    {
      print("\n>  ",0x0F);
      string tmp = readStr();
      if(strEql(tmp,"repeat"))
      {
	print("\nrepeat>  ",0x0F);
	string tmp = readStr();
	nano = 1;
	while(1)
	  {
	  printch('\n',0x0F);
	  print(tmp,0x0F);
	}
      }
      if(strEql(tmp,"execute"))
      {
	print("\n",0x0F);
      }
      else
      {
	print("The 'do' command does not support the command you entered or it does not exist ",0x0F);
      }
    }
    else if(strEql(ch,"ls"))
    {
      print("\nNo Files Found on Disk ",0x0F);
    }
    else if(strEql(ch,"cd"))
    {
      print("\nThe specified directory was not found ",0x0F);
    }
    else if(strEql(ch,"nano"))
    {
      nano = 1;
      clearScreen();
      print("                        Q-OS Nano Text Editor Version 0.1                        ",0xF0);
      print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",0x0F);
      print("                         Built for Q-OS by Raph Hennessy                        ",0xF0);
      
      cursorX = 0;
      cursorY = 1;
      updateCursor();
      string nanoOutput = readStr();
    }
    else if(strEql(ch,"clear"))
    {
      clearScreen();
    }
    else if(strEql(ch,"sudo"))
    {
      print("\n",0x0F);
    }
    else if(strEql(ch,"exit"))
    {
      print("\n",0x0F);
    }
    else if(strEql(ch,"run"))
    {
      print("\n",0x0F);
    }
    else
    {
      print("\nCommand Not Found ",0x0F);
    }
    print("\n",0x0F);
  }
}
Exemplo n.º 6
0
void me(string args) {
    if (strEql(splitArg(args, 1), "setup") || !hasSetup)
    {
        if (strEql(splitArg(args, 2), "skip") && !hasSetup)
        {
            hasSetup = true;
            print("\nYou have skipped the Me setup process, some answers may be strange :D",0x06);
        }
        else if (!hasSetup)
        {
            print("\nWelcome to Me.",0x03);
            print("\nMe is the worlds first truly rubbish personal assistant.",0x03);
            print("\nTo use me, simply ask it a question.",0x03);
            print("\nFor example, type 'me what is the time?'",0x03);
            print("\nTo start using Me, please enter some basic information below when prompted.",0x03);
            newline();

            newline();
            print("What is your name: ",0x0B);
            readStr(name,128);

            while (!birthYearValid)
            {
                newline();
                print("What year were you born in: ",0x0B);
                readStr(birthYear,5);
                birthYearInt = stoi(birthYear);

                // need to make this always the current year + 1
                if (birthYearInt < 2016 && birthYearInt > 1900)
                {
                    birthYearValid = true;
                    print(" Good",0x02);
                }

                if (!birthYearValid)
                {
                    print(" Invalid",0x0C);
                }
            }


            while (!birthDateValid)
            {
                newline();
                print("What day of the month were you born in: ",0x0B);
                readStr(birthDate,3);
                birthDateInt = stoi(birthDate);

                if (birthDateInt < 32)
                {
                    birthDateValid = true;
                    print(" Good",0x02);
                }

                if (!birthDateValid)
                {
                    print(" Invalid",0x0C);
                }
            }

            while (!birthMonthValid)
            {
                newline();
                print("What month were you born in: ",0x0B);
                readStr(birthMonth,128);
                birthMonth = toUpper(birthMonth);

                for(uint32 tmp = 0; tmp < arrLength(months); tmp++)
                {
                    if (strEql(months[tmp],birthMonth))
                    {
                        birthMonthValid = true;
                        print(" Good",0x02);
                    }
                }

                if (!birthMonthValid)
                {
                    print(" Invalid",0x0C);
                }
            }

            while (!continentValid)
            {

                newline();
                print("What continent do you live in: ",0x0B);
                readStr(continent,128);
                continent = toUpper(continent);

                for(uint32 tmp = 0; tmp < arrLength(continents); tmp++)
                {
                    if (strEql(continents[tmp],continent))
                    {
                        continentValid = true;
                        print(" Good",0x02);
                    }
                }

                if (!continentValid)
                {
                    print(" Invalid",0x0C);
                }
            }


            while (!countryValid)
            {
                newline();
                print("What country do you live in: ",0x0B);
                readStr(country,128);
                country = toUpper(country);

                for(uint32 tmp = 0; tmp < arrLength(countries); tmp++)
                {
                    if (strEql(countries[tmp],country))
                    {
                        countryValid = true;
                        print(" Good",0x02);
                    }
                }

                if (!countryValid)
                {
                    print(" Invalid",0x0C);
                }
            }

            while (!stateValid)
            {
                newline();
                print("What state/province do you currently live in: ",0x0B);
                readStr(state,128);
                state = toUpper(state);

                for(uint8 tmp = 0; tmp < arrLength(states); tmp++)
                {
                    if(strEql(states[tmp],country))
                    {
                        stateValid = true;
                        print(" Good",0x02);
                    }
                }

                if (!stateValid)
                {
                    print(" Invalid",0x0C);
                }
            }

            newline();
            print("What city do you live in: ",0x0B);
            readStr(city,128);

            while (!zipValid)
            {
                newline();
                print("What is the zip/post code in your area: ",0x0B);
                readStr(zip,17);

                if (strEql(country,"CANADA"))
                {
                    print(" Good Enough",0x02);
                    zipValid = true;
                }
                else
                {
                    zipInt = stoi(zip);
                    if (zipInt < 9999999999999999 && zipInt > 0)
                    {
                        zipValid = true;
                        print(" Good",0x02);
                    }

                    if (!zipValid)
                    {
                        print(" Invalid",0x0C);
                    }
                }
            }

            newline();
            hasSetup = "true";
            print("Me is now ready to use!",0x03);

            newline();
            print("When Me dosen't know information, it can ask you for help.",0x03);
        }
        else
        {
            print("\nYou have already completed the setup process for Me!",0x05);
        }
    }
    else
    {
        bool over = false;
        int tmp = 0;
        while (!over)
        {
            tmp++;

            if (strEql(splitArg(args, tmp),""))
            {
                over = true;
            }
            else
            {
                newline();
                printint(tmp,0x0A);
                print(" : ",0x0B);
                print(curWord,0x0A);
                print(" : ",0x0B);
                printfloat(sort(splitArg(args, tmp)),0x09);

            }
        }
    }
}