-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some work on 'watch', still not ready for use #125
- Loading branch information
1 parent
268d457
commit 0824835
Showing
14 changed files
with
263 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/** | ||
** This file is part of BoneOS. | ||
** | ||
** BoneOS is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** BoneOS is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** You should have received a copy of the GNU General Public License | ||
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** @main_author : Ashish Ahuja | ||
** | ||
** @contributors: | ||
** Ashish Ahuja<Fortunate-MAN>: start | ||
**/ | ||
|
||
#include <misc/status_codes.h> | ||
#include <sh/shell.h> | ||
#include <drv/video/video.h> | ||
#include <unistd/unistd.h> | ||
#include <stdio/stdio.h> | ||
#include <stdlib/stdlib.h> | ||
#include <string/string.h> | ||
#include <sh/values.h> | ||
#include <watch/watch.h> | ||
#include <strcmp/strcmp.h> | ||
#include <apps/sh/utils.h> | ||
#include <libc/assertk.h> | ||
#include <drv/pit/pit.h> | ||
#include <drv/ps2/kbd/kbd.h> | ||
#include <drv/driver.h> | ||
|
||
int main_watch_opt_handler (char *cmd) | ||
{ | ||
size_t num_opts = get_opt_count(cmd); | ||
str_t opts[num_opts]; | ||
get_opt(cmd,opts); | ||
unsigned interval = 2 * 1000; | ||
char command [125]; | ||
command [0] = '\0'; | ||
int actual_command_index = 0; | ||
|
||
if (num_opts == 1) | ||
{ | ||
printk (cmd_watch.invalid_use_msg); | ||
return STATUS_OK; | ||
} | ||
else if (num_opts > 1) | ||
{ | ||
if (strcmp (opts [1].str, "--help") == 0) | ||
{ | ||
printk (cmd_watch.help); | ||
return STATUS_OK; | ||
} | ||
else | ||
{ | ||
for (unsigned i = 1; i < num_opts; i ++) | ||
{ | ||
if (!strcmp (opts [i].str, "-n")) | ||
{ | ||
if (i == (num_opts - 1)) | ||
{ | ||
printk (cmd_watch.invalid_use_msg); | ||
return STATUS_OK; | ||
} | ||
else | ||
{ | ||
interval = atoi (opts [i + 1].str); | ||
interval *= 1000; | ||
i ++; | ||
} | ||
} | ||
else | ||
{ | ||
if (strlen (command) == 0) | ||
{ | ||
strcpy (command, opts [i].str); | ||
} | ||
else | ||
{ | ||
command [strlen (command)] = ' '; | ||
strcpy (command + (strlen (command)), opts [i].str); | ||
} | ||
if (!actual_command_index) | ||
{ | ||
actual_command_index = i; | ||
} | ||
} | ||
} | ||
|
||
for(int i=0; cmds[i]; i++) | ||
{ | ||
if(termcmp(cmds[i]->name, opts [actual_command_index].str)==0) | ||
{ | ||
again: cmds[i]->handler(command); | ||
printk (command); | ||
assertkm(device_initalized(PIT_DRIVER_INDEX) , "PIT NOT INITALIZED FOR SLEEP()"); | ||
int64_t expiry = pit_ticks + ((uint64_t)interval * IRQ_SEC_HIT) / 1000; | ||
|
||
while (pit_ticks < expiry) | ||
{ | ||
kbd_info.scancode = kbd_enc_read_input_buf(); | ||
if(kbd_info.scancode & 0x80); | ||
else | ||
{ | ||
kbd_info.key = key_press(kbd_info.scancode); | ||
if (kbd_info.key == 'q') | ||
{ | ||
return STATUS_OK; | ||
} | ||
} | ||
} | ||
|
||
goto again; | ||
} | ||
} | ||
|
||
printk (cmd_watch.invalid_use_msg); | ||
return STATUS_OK; | ||
} | ||
} | ||
|
||
return STATUS_OK; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
** This file is part of BoneOS. | ||
** | ||
** BoneOS is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** BoneOS is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** You should have received a copy of the GNU General Public License | ||
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** @main_author : Ashish Ahuja | ||
** | ||
** @contributors: | ||
** Ashish Ahuja<Fortunate-MAN>: start | ||
**/ | ||
|
||
#include <misc/status_codes.h> | ||
#include <sh/shell.h> | ||
#include <drv/video/video.h> | ||
#include <unistd/unistd.h> | ||
#include <stdio/stdio.h> | ||
#include <string/string.h> | ||
#include <sh/values.h> | ||
#include <watch/watch.h> | ||
#include <watch/opts/main_watch.h> | ||
|
||
struct cmd_opt_t* cmd_watch_opts[] = | ||
{ | ||
0 | ||
}; | ||
|
||
int cmd_watch_handler (char *cmd) | ||
{ | ||
size_t num_opts = get_opt_count(cmd); | ||
if (num_opts == 1) | ||
{ | ||
printk (cmd_watch.invalid_use_msg); | ||
return STATUS_OK; | ||
} | ||
main_watch_opt_handler (cmd); | ||
return STATUS_OK; | ||
} | ||
|
||
struct cmd_t cmd_watch = | ||
{ | ||
.name = "watch", | ||
.usage ="watch [--help]", | ||
.help = "watch(1) \t\t\t\t BoneOS Terminal Manual \n" | ||
"NAME : \n " | ||
"\twatch\n" | ||
"SYNOPSIS : \n " | ||
"\twatch [option] [command]\n" | ||
"DESCRIPTION : \n " | ||
"\tPrints out the current user.\n" | ||
"OPTIONS : \n " | ||
"[-n <seconds>] Sets the interval to the number of seconds specified.\n", | ||
.cmd_opts = cmd_watch_opts, | ||
.handler = &cmd_watch_handler, | ||
.invalid_use_msg = "Invalid use of watch command.\n" | ||
"Type in watch --help for more help.\n", | ||
.privilege = USER | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef _BIN_WATCH_MAINOPT_H_ | ||
#define _BIN_WATCH_MAINOPT_H_ | ||
|
||
int main_watch_opt_handler (char *cmd); | ||
|
||
#endif /*_BIN_WATCH_MAINOPT_H_*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef _BIN_WATCH_H_ | ||
#define _BIN_WATCH_H_ | ||
|
||
extern struct cmd_t cmd_watch; | ||
|
||
#endif /*_BIN_WATCH_H_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.