Skip to content

Commit

Permalink
Some more cleanup #151
Browse files Browse the repository at this point in the history
  • Loading branch information
double-fault committed Jan 12, 2017
1 parent 5180442 commit 1fa4907
Showing 1 changed file with 76 additions and 80 deletions.
156 changes: 76 additions & 80 deletions bin/boneshell/boneshell.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,101 +54,97 @@ bool executed_internally=false;

void removeSpaces(char* source)
{
char* i = source;
char* j = source;
while(*j != 0)
{
*i = *j++;
if(*i != ' ')
i++;
}
*i = 0;
char* i = source;
char* j = source;
while(*j != 0)
{
*i = *j++;
if(*i != ' ')
i++;
}
*i = 0;
}


void loop_terminal()
{
shell_instance_cnt+=1;
if (shell_instance_cnt != 1)
printk("Shell #%d\n" , shell_instance_cnt);
printk ("%s release %s started at ", VAR_OSNAME, VAR_RELEASE);
rtc_print_date();
while(1)
{
start_shell:;
int FG__ = video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg;
int BG__ = video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg;
if(video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg==0x7 && video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg==0x0)
{
printck(2,0,"%s@boneos:",VAR_USER);
printck(1,0,"%s",VAR_PWD);
printck(0x0,0x7,"");
printck(0x7,0x0," $ ");
}
else
shell_instance_cnt+=1;
if (shell_instance_cnt != 1)
printk("Shell #%d\n" , shell_instance_cnt);
printk ("%s release %s started at ", VAR_OSNAME, VAR_RELEASE);
rtc_print_date();
while(1)
{
printk("%s@boneos:",VAR_USER);
printk("%s",VAR_PWD);
printk(" $ ");
}
video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg = FG__;
video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg = BG__;

start_shell:;
int FG__ = video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg;
int BG__ = video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg;
if(video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg==0x7 && video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg==0x0)
{
printck(2,0,"%s@boneos:",VAR_USER);
printck(1,0,"%s",VAR_PWD);
printck(0x0,0x7,"");
printck(0x7,0x0," $ ");
}
else
{
printk("%s@boneos:",VAR_USER);
printk("%s",VAR_PWD);
printk(" $ ");
}
video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg = FG__;
video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg = BG__;

//continue_read:
scank(true,true, "%s" , cmd_active.value);
scank(true,true, "%s" , cmd_active.value);

if(tab_multiple_opts==true)
{
tab_multiple_opts=false;
goto start_shell;
}
else if(tab_one_opt == true)
{
tab_one_opt = false;
strcpy (cmd_active.value, tab__);
executed_internally = true;
removeSpaces (cmd_active.value);
}
else if (tab_zero_opt == true)
{
key_handler_util_backspace();
tab_zero_opt = false;
scank (true, true, "%s", cmd_active.value + (strlen (cmd_active.value)));
}
if(tab_multiple_opts==true)
{
tab_multiple_opts=false;
goto start_shell;
}
else if(tab_one_opt == true)
{
tab_one_opt = false;
strcpy (cmd_active.value, tab__);
executed_internally = true;
removeSpaces (cmd_active.value);
}
else if (tab_zero_opt == true)
{
key_handler_util_backspace();
tab_zero_opt = false;
scank (true, true, "%s", cmd_active.value + (strlen (cmd_active.value)));
}

if(strcmp(cmd_active.value, "exit")==0)
{
shell_instance_cnt-=1;
printk("Exited shell instance #%d\n",shell_instance_cnt+1);
goto end_shell;
}

//removeSpaces(cmd_active.value);
if(strcmp(cmd_active.value, "exit")==0)
{
shell_instance_cnt-=1;
printk("Exited shell instance #%d\n",shell_instance_cnt+1);
goto end_shell;
}
for(int i=0; cmds[i]; i++)
{
if(termcmp(cmds[i]->name, cmd_active.value)==0)
{
if(executed_internally==true)
{
executed_internally=false;
}
cmds[i]->handler(cmd_active.value);
__found = 1;
}
}

for(int i=0; cmds[i]; i++)
{
if(termcmp(cmds[i]->name, cmd_active.value)==0)
{
if(executed_internally==true)
if(__found == 0 && cmd_active.value [0] != '\0')
{
executed_internally=false;
printk("Invalid Command '%s' \n", cmd_active.value);
printk("Try 'help' for more information.\n");
}
cmds[i]->handler(cmd_active.value);
__found = 1;
}
}

if(__found == 0 && cmd_active.value [0] != '\0')
{
printk("Invalid Command '%s' \n", cmd_active.value);
printk("Try 'help' for more information.\n");
__found = 0;
cmd_active_index++;
}

__found = 0;
cmd_active_index++;
}
end_shell:;
end_shell:;
}
int boneshell_handler(char* cmd)
{
Expand Down

0 comments on commit 1fa4907

Please sign in to comment.