diff --git a/bin/clear/clear.c b/bin/clear/clear.c index c83ebe0..890f326 100644 --- a/bin/clear/clear.c +++ b/bin/clear/clear.c @@ -15,11 +15,12 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + ** Ashish Ahuja + **/ #include #include @@ -32,7 +33,7 @@ #include #include -struct cmd_opt_t* cmd_clear_opts[] = +struct cmd_opt_t* cmd_clear_opts[] = { &cmd_clear_opt_color, 0 @@ -46,12 +47,11 @@ int cmd_clear_handler(char* cmd) video_drivers[VGA_VIDEO_DRIVER_INDEX]->clear(); return STATUS_OK; } - - main_clear_opt_handler(cmd); - return STATUS_OK; + + return main_clear_opt_handler(cmd); } -struct cmd_t cmd_clear = +struct cmd_t cmd_clear = { .name = "clear", .usage = "clear [--help] [-color ] [-color --def] [-color <--help>] ", @@ -65,9 +65,9 @@ struct cmd_t cmd_clear = "\tcolor with the -color command and providing it\n " "\ta Foreground as well as a Background Color \n" "MORE HELP : \n " - "\t[clear -color --help] for help on -color option\n", + "\t[clear -color --help] for help on -color option\n", .cmd_opts = cmd_clear_opts, - .handler = &cmd_clear_handler, + .handler = &cmd_clear_handler, .invalid_use_msg = "Invalid use of clear command.\n" "Type in clear --help for more help.\n", .privilege = USER diff --git a/bin/clear/opts/color.c b/bin/clear/opts/color.c index 33f61cb..377c727 100644 --- a/bin/clear/opts/color.c +++ b/bin/clear/opts/color.c @@ -15,11 +15,12 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: - ** Amanuel Bogale : start - **/ + ** Amanuel Bogale : start + ** Ashish Ahuja + **/ #include #include @@ -32,27 +33,24 @@ #include #include - - - int cmd_clear_color_handler(char* cmd) { size_t num_opts = get_opt_count(cmd); str_t opts[num_opts]; get_opt(cmd,opts); - + int _FG = strtoi((char*)opts[2].str, 0, 16); int _BG = strtoi((char*)opts[3].str, 0, 16); - + video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg = _FG; video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg = _BG; - + video_drivers[VGA_VIDEO_DRIVER_INDEX]->clear(); - + return STATUS_OK; } -struct cmd_opt_t cmd_clear_opt_color = +struct cmd_opt_t cmd_clear_opt_color = { .help = "clear(1) \t\t\t\t BoneOS Terminal Manual \n" "NAME : \n " @@ -74,7 +72,7 @@ struct cmd_opt_t cmd_clear_opt_color = "\t\t 5 = Purple\t D = Light Purple\n " "\t\t 6 = Yellow\t E = Light Yellow\n " "\t\t 7 = White \t F = Bright White\n " - "\t\t--def : Clears to default (BG : 0x7 , FG : 0x0)\n ", + "\t\t--def : Clears to default (BG : 0x7 , FG : 0x0)\n ", .cmd_opt_name = "-color" , .handler = &cmd_clear_color_handler, .invalid_use_msg = "Invalid Use of -color option. Use command clear -color --help for instructions\n" diff --git a/bin/clear/opts/main_clear.c b/bin/clear/opts/main_clear.c index ee44eb8..e40f2d2 100644 --- a/bin/clear/opts/main_clear.c +++ b/bin/clear/opts/main_clear.c @@ -15,12 +15,13 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ - + ** Ashish Ahuja + **/ + #include #include #include @@ -34,44 +35,41 @@ int main_clear_opt_handler(char *cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); - - if(strcmp(opts[1].str, "-color")==0) - { - if(strcmp(opts[2].str, "--help")==0) - { - printk(cmd_clear_opt_color.help); - } - else if(strcmp(opts[2].str, "--def")==0) - { - video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg = 0x7; - video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg = 0x0; - video_drivers[VGA_VIDEO_DRIVER_INDEX]->clear(); - } - else if(opts[2].str[0] == '\0' || opts[3].str[0] == '\0') - { - printk(cmd_clear_opt_color.invalid_use_msg); - } - else - { - cmd_clear_opt_color.handler(cmd); - } - } - else if(strcmp(opts[1].str, "--help")==0) - { - printk(cmd_clear.help); - } - else - { - printk(cmd_clear.invalid_use_msg); - } - return STATUS_OK; -} - - - - + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd,opts); + if(strcmp(opts[1].str, "-color")==0) + { + if(strcmp(opts[2].str, "--help")==0) + { + printk(cmd_clear_opt_color.help); + } + else if(strcmp(opts[2].str, "--def")==0) + { + video_drivers[VGA_VIDEO_DRIVER_INDEX]->fg = 0x7; + video_drivers[VGA_VIDEO_DRIVER_INDEX]->bg = 0x0; + video_drivers[VGA_VIDEO_DRIVER_INDEX]->clear(); + } + else if(opts[2].str[0] == '\0' || opts[3].str[0] == '\0') + { + printk(cmd_clear_opt_color.invalid_use_msg); + return STATUS_FAIL; + } + else + { + cmd_clear_opt_color.handler(cmd); + } + } + else if(strcmp(opts[1].str, "--help")==0) + { + printk(cmd_clear.help); + } + else + { + printk(cmd_clear.invalid_use_msg); + return STATUS_FAIL; + } + return STATUS_OK; +} diff --git a/bin/cursor/cursor.c b/bin/cursor/cursor.c index b6c6260..d7d78f2 100644 --- a/bin/cursor/cursor.c +++ b/bin/cursor/cursor.c @@ -15,11 +15,12 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + ** Ashish Ahuja + **/ #include #include @@ -29,7 +30,7 @@ #include #include -struct cmd_opt_t* cmd_cursor_opts[] = +struct cmd_opt_t* cmd_cursor_opts[] = { 0 }; @@ -40,15 +41,14 @@ int cmd_cursor_handler(char* cmd) if(num_opts == 1) { printk(cmd_cursor.invalid_use_msg); - return STATUS_OK; + return STATUS_FAIL; } - - main_cursor_opt_handler(cmd); - return STATUS_OK; + + return main_cursor_opt_handler(cmd); } -struct cmd_t cmd_cursor = +struct cmd_t cmd_cursor = { .name = "cursor", .usage ="cursor [-t ] [-t block] [-t def] [--help]", @@ -63,9 +63,9 @@ struct cmd_t cmd_cursor = "\t Option Summary \n " "\t\t [-t ] : cursor now changes to custom type.\n " "\t\t [-t block] : cursor is changed to a block cursor (START:0,END:20)\n " - "\t\t [-t def] : cursor changes to default underline. (START:15,END:15)\n", + "\t\t [-t def] : cursor changes to default underline. (START:15,END:15)\n", .cmd_opts = cmd_cursor_opts, - .handler = &cmd_cursor_handler, + .handler = &cmd_cursor_handler, .invalid_use_msg = "Invalid use of cursor command.\n" "Type in cursor --help for more help.\n", .privilege = USER diff --git a/bin/cursor/opts/main_cursor.c b/bin/cursor/opts/main_cursor.c index 7ce1923..74114d2 100644 --- a/bin/cursor/opts/main_cursor.c +++ b/bin/cursor/opts/main_cursor.c @@ -15,12 +15,13 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ - + ** Ashish Ahuja + **/ + #include #include #include @@ -33,36 +34,38 @@ int main_cursor_opt_handler(char *cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); - - if(strcmp(opts[1].str,"--help")==0) - printk(cmd_cursor.help); - else if(strcmp(opts[1].str,"-t")==0) - { - if(strcmp(opts[2].str,"def")==0) - video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor(video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column,15,15); - else if(strcmp(opts[2].str,"block")==0) - video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor(video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column,0,20); - else if((strcmp(opts[2].str,"")!=0) || (strcmp(opts[3].str,"")!=0)) - { - printk("%s , %s", opts[2].str, opts[3].str); - int _CRSR_START = atoi(opts[2].str); - int _CRSR_END = atoi(opts[3].str); - video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor(video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column,_CRSR_START,_CRSR_END); - } - else - printk(cmd_cursor.invalid_use_msg); - } - else - printk(cmd_cursor.invalid_use_msg); - - return STATUS_OK; -} - - + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd,opts); + if(strcmp(opts[1].str,"--help")==0) + printk(cmd_cursor.help); + else if(strcmp(opts[1].str,"-t")==0) + { + if(strcmp(opts[2].str,"def")==0) + video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor(video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column,15,15); + else if(strcmp(opts[2].str,"block")==0) + video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor(video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column,0,20); + else if((strcmp(opts[2].str,"")!=0) || (strcmp(opts[3].str,"")!=0)) + { + printk("%s , %s", opts[2].str, opts[3].str); + int _CRSR_START = atoi(opts[2].str); + int _CRSR_END = atoi(opts[3].str); + video_drivers[VGA_VIDEO_DRIVER_INDEX]->update_cursor(video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_row,video_drivers[VGA_VIDEO_DRIVER_INDEX]->video_column,_CRSR_START,_CRSR_END); + } + else + { + printk(cmd_cursor.invalid_use_msg); + return STATUS_FAIL; + } + } + else + { + printk(cmd_cursor.invalid_use_msg); + return STATUS_FAIL; + } + return STATUS_OK; +} diff --git a/bin/date/date.c b/bin/date/date.c index 0ca4335..eaf4823 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -15,9 +15,9 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale + ** Ashish Ahuja ** ** @contributors: - ** Amanuel Bogale : start ** Ashish Ahuja **/ @@ -47,7 +47,6 @@ int cmd_date_handler(char* cmd) return STATUS_OK; } - struct cmd_t cmd_date = { .name = "date", diff --git a/bin/date/opts/main_date.c b/bin/date/opts/main_date.c index 5187284..aa2585b 100644 --- a/bin/date/opts/main_date.c +++ b/bin/date/opts/main_date.c @@ -51,6 +51,6 @@ int main_date_opt_handler (char *cmd) else { printk (cmd_date.invalid_use_msg); - return STATUS_OK; + return STATUS_FAIL; } } diff --git a/bin/echo/echo.c b/bin/echo/echo.c index 416b212..e961f3d 100644 --- a/bin/echo/echo.c +++ b/bin/echo/echo.c @@ -15,11 +15,12 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + ** Ashish Ahuja + **/ #include #include @@ -31,7 +32,7 @@ -struct cmd_opt_t* cmd_echo_opts[] = +struct cmd_opt_t* cmd_echo_opts[] = { 0 }; @@ -42,16 +43,14 @@ int cmd_echo_handler(char* cmd) if(num_opts == 1) { printk(cmd_echo.invalid_use_msg); - return STATUS_OK; + return STATUS_FAIL; } - - main_echo_opt_handler(cmd); - - return STATUS_OK; + + return main_echo_opt_handler(cmd); } -struct cmd_t cmd_echo = +struct cmd_t cmd_echo = { .name = "echo", .usage ="echo [value] [--help]", @@ -63,7 +62,7 @@ struct cmd_t cmd_echo = "DESCRIPTION : \n " "\tPrints out the VALUE listed by option\n", .cmd_opts = cmd_echo_opts, - .handler = &cmd_echo_handler, + .handler = &cmd_echo_handler, .invalid_use_msg = "Invalid use of echo command.\n" "Type in echo --help for more help.\n", .privilege = USER diff --git a/bin/echo/opts/main_echo.c b/bin/echo/opts/main_echo.c index d76fc45..c28ea52 100644 --- a/bin/echo/opts/main_echo.c +++ b/bin/echo/opts/main_echo.c @@ -19,6 +19,7 @@ ** @contributors: ** Amanuel Bogale : start + ** Ashish Ahuja **/ #include @@ -32,60 +33,63 @@ int main_echo_opt_handler(char *cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd,opts); - char opts_one_key[strlen(opts[1].str)]; + char opts_one_key[strlen(opts[1].str)]; - for(int i=0; opts_one_key[i]; i++) opts_one_key[i] = 0; + for(int i=0; opts_one_key[i]; i++) opts_one_key[i] = 0; - if(strcmp(opts[1].str , "--help")==0) - printk(cmd_echo.help); - else if(num_opts >= 2) - { - if(opts[1].str[0] == '\'' && opts[num_opts-1].str[(strlen(opts[num_opts-1].str)-1)] == '\'') - { - for(size_t i=1; i= 2) + { + if(opts[1].str[0] == '\'' && opts[num_opts-1].str[(strlen(opts[num_opts-1].str)-1)] == '\'') + { + for(size_t i=1; i : start + ** Ashish Ahuja **/ #include @@ -64,9 +65,7 @@ int cmd_help_handler(char* cmd) return STATUS_OK; } - main_help_opt_handler(cmd); - - return STATUS_OK; + return main_help_opt_handler(cmd); } struct cmd_t cmd_help = diff --git a/bin/help/opts/help_cmd_opt.c b/bin/help/opts/help_cmd_opt.c index 989153a..4a3c2c1 100644 --- a/bin/help/opts/help_cmd_opt.c +++ b/bin/help/opts/help_cmd_opt.c @@ -15,11 +15,12 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ + ** Ashish Ahuja + **/ #include #include @@ -29,34 +30,35 @@ #include #include - - // handles help -cmd int cmd_help_opt_cmd_handler(char* cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); - - char* __user_cmd = opts[2].str; - int __found__user_cmd = 0; - - for(int i=0; cmds[i]; i++) - { - if(strcmp(cmds[i]->name,__user_cmd)==0) - { - printk(cmds[i]->help); - __found__user_cmd=1; - } - } - - if(__found__user_cmd == 0) - printk("Command Not Found. type in command help for listings of command\n"); - - return STATUS_OK; + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd,opts); + + char* __user_cmd = opts[2].str; + int __found__user_cmd = 0; + + for(int i=0; cmds[i]; i++) + { + if(strcmp(cmds[i]->name,__user_cmd)==0) + { + printk(cmds[i]->help); + __found__user_cmd=1; + } + } + + if(__found__user_cmd == 0) + { + printk("Command Not Found. Type in `help` for listings of command\n"); + return STATUS_FAIL; + } + + return STATUS_OK; } -struct cmd_opt_t cmd_help_opt_cmd = +struct cmd_opt_t cmd_help_opt_cmd = { .help = "help(1) \t\t\t\t BoneOS Terminal Manual \n" "NAME : \n " @@ -70,13 +72,11 @@ struct cmd_opt_t cmd_help_opt_cmd = "OPTIONS : \n " "\t Option Summary \n " "\t\t[-cmd ] : calls help handler of command name\n", - .cmd_opt_name = "-cmd" , - .handler = &cmd_help_opt_cmd_handler, - .invalid_use_msg = "Invalid Use of -cmd option. Use command help --cmd --help for instructions\n" - "on how to use the clear command\n" + .cmd_opt_name = "-cmd" , + .handler = &cmd_help_opt_cmd_handler, + .invalid_use_msg = "Invalid Use of -cmd option. Use command help -cmd --help for instructions\n" + "on how to use the cmd option of the help command\n" }; - - diff --git a/bin/help/opts/main_help.c b/bin/help/opts/main_help.c index fbcfde0..52d472d 100644 --- a/bin/help/opts/main_help.c +++ b/bin/help/opts/main_help.c @@ -15,12 +15,13 @@ ** along with BoneOS. If not, see . ** ** @main_author : Amanuel Bogale - ** + ** ** @contributors: ** Amanuel Bogale : start - **/ - + ** Ashish Ahuja + **/ + #include #include #include @@ -33,31 +34,28 @@ int main_help_opt_handler(char *cmd) { - size_t num_opts = get_opt_count(cmd); - str_t opts[num_opts]; - get_opt(cmd,opts); - - if(strcmp(opts[1].str,"-cmd")==0) - { - if(strcmp(opts[2].str,"--help")==0) - printk(cmd_help_opt_cmd.help); - else - cmd_help_opt_cmd.handler(cmd); - } - else if(strcmp(opts[1].str , "--help")==0) - { - printk(cmd_help.help); - } - else - { - printk(cmd_help.invalid_use_msg); - } - - return STATUS_OK; + size_t num_opts = get_opt_count(cmd); + str_t opts[num_opts]; + get_opt(cmd,opts); + + if(strcmp(opts[1].str,"-cmd")==0) + { + if(strcmp(opts[2].str,"--help")==0) + printk(cmd_help_opt_cmd.help); + else + return cmd_help_opt_cmd.handler(cmd); + } + else if(strcmp(opts[1].str , "--help")==0) + { + printk(cmd_help.help); + } + else + { + printk(cmd_help.invalid_use_msg); + return STATUS_FAIL; + } + + return STATUS_OK; } - - - - diff --git a/bin/logname/logname.c b/bin/logname/logname.c index bd24bda..301e1f1 100644 --- a/bin/logname/logname.c +++ b/bin/logname/logname.c @@ -38,26 +38,25 @@ struct cmd_opt_t* cmd_logname_opts[] = int cmd_logname_handler (char *cmd) { - main_logname_opt_handler (cmd); - return STATUS_OK; + return main_logname_opt_handler (cmd); } struct cmd_t cmd_logname = { - .name = "logname", - .usage ="logname [--help]", - .help = "logname(1) \t\t\t\t BoneOS Terminal Manual \n" + .name = "logname", + .usage ="logname [--help]", + .help = "logname(1) \t\t\t\t BoneOS Terminal Manual \n" "NAME : \n " "\tlogname\n" "SYNOPSIS : \n " "\tlogname [option] [--help]\n" "DESCRIPTION : \n " "\tPrints out the current user.\n", - .cmd_opts = cmd_logname_opts, - .handler = &cmd_logname_handler, - .invalid_use_msg = "Invalid use of logname command.\n" + .cmd_opts = cmd_logname_opts, + .handler = &cmd_logname_handler, + .invalid_use_msg = "Invalid use of logname command.\n" "Type in logname --help for more help.\n", - .privilege = USER + .privilege = USER }; diff --git a/bin/logname/opts/main_logname.c b/bin/logname/opts/main_logname.c index 1bd6062..b0ae53c 100644 --- a/bin/logname/opts/main_logname.c +++ b/bin/logname/opts/main_logname.c @@ -51,11 +51,11 @@ int main_logname_opt_handler (char *cmd) else { printk (cmd_logname.invalid_use_msg); - return STATUS_OK; + return STATUS_FAIL; } } - return STATUS_OK; + return STATUS_FAIL; } diff --git a/bin/pwd/opts/main_pwd.c b/bin/pwd/opts/main_pwd.c index adf9467..4b042f4 100644 --- a/bin/pwd/opts/main_pwd.c +++ b/bin/pwd/opts/main_pwd.c @@ -51,11 +51,11 @@ int main_pwd_opt_handler (char *cmd) else { printk (cmd_pwd.invalid_use_msg); - return STATUS_OK; + return STATUS_FAIL; } } - return STATUS_OK; + return STATUS_FAIL; } diff --git a/bin/pwd/pwd.c b/bin/pwd/pwd.c index 0b6639e..02bee75 100644 --- a/bin/pwd/pwd.c +++ b/bin/pwd/pwd.c @@ -38,26 +38,25 @@ struct cmd_opt_t* cmd_pwd_opts[] = int cmd_pwd_handler (char *cmd) { - main_pwd_opt_handler (cmd); - return STATUS_OK; + return main_pwd_opt_handler (cmd); } struct cmd_t cmd_pwd = { - .name = "pwd", - .usage ="pwd [--help]", - .help = "pwd(1) \t\t\t\t BoneOS Terminal Manual \n" + .name = "pwd", + .usage ="pwd [--help]", + .help = "pwd(1) \t\t\t\t BoneOS Terminal Manual \n" "NAME : \n " "\tpwd\n" "SYNOPSIS : \n " "\tpwd [option] [--help]\n" "DESCRIPTION : \n " "\tPrints out the current working directory.\n", - .cmd_opts = cmd_pwd_opts, - .handler = &cmd_pwd_handler, - .invalid_use_msg = "Invalid use of pwd command.\n" + .cmd_opts = cmd_pwd_opts, + .handler = &cmd_pwd_handler, + .invalid_use_msg = "Invalid use of pwd command.\n" "Type in pwd --help for more help.\n", - .privilege = USER + .privilege = USER };