-
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 uptime command, still not ready for use #125
- Loading branch information
1 parent
c4e52d4
commit 34f321b
Showing
8 changed files
with
158 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
** 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 <stdlib/itoa/itoa.h> | ||
#include <string/string.h> | ||
#include <sh/values.h> | ||
#include <uptime/uptime.h> | ||
#include <sh/shell.h> | ||
|
||
int main_uptime_opt_handler (char *cmd) | ||
{ | ||
size_t num_opts = get_opt_count(cmd); | ||
str_t opts[num_opts]; | ||
get_opt(cmd,opts); | ||
|
||
rtc_t curr = rtc_get_time(); | ||
rtc_t time_since_start; | ||
time_since_start.second = 0; | ||
time_since_start.month = curr.month - start_time.month; | ||
time_since_start.day = curr.day - start_time.day; | ||
time_since_start.hour = curr.hour - start_time.hour; | ||
time_since_start.minute = (uint8_t)(curr.minute - start_time.minute); | ||
time_since_start.second =(uint8_t) (curr.second - start_time.second); | ||
if (num_opts == 1) | ||
{ | ||
printk ("%x:%x", time_since_start.minute, time_since_start.second); | ||
return STATUS_OK; | ||
} | ||
else if (num_opts > 1) | ||
{ | ||
if (strcmp (opts [1].str, "--help") == 0) | ||
{ | ||
printk (cmd_uptime.help); | ||
return STATUS_OK; | ||
} | ||
else | ||
{ | ||
printk (cmd_uptime.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,63 @@ | ||
/** | ||
** 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 <uptime/uptime.h> | ||
#include <uptime/opts/main_uptime.h> | ||
|
||
struct cmd_opt_t* cmd_uptime_opts[] = | ||
{ | ||
0 | ||
}; | ||
|
||
int cmd_uptime_handler (char *cmd) | ||
{ | ||
main_uptime_opt_handler (cmd); | ||
return STATUS_OK; | ||
} | ||
|
||
struct cmd_t cmd_uptime = | ||
{ | ||
.name = "uptime", | ||
.usage ="uptime [--help]", | ||
.help = "uptime(1) \t\t\t\t BoneOS Terminal Manual \n" | ||
"NAME : \n " | ||
"\tuptime\n" | ||
"SYNOPSIS : \n " | ||
"\tuptime [option] [--help]\n" | ||
"DESCRIPTION : \n " | ||
"\tTells how long the system has been running.\n", | ||
.cmd_opts = cmd_uptime_opts, | ||
.handler = &cmd_uptime_handler, | ||
.invalid_use_msg = "Invalid use of uptime command.\n" | ||
"Type in uptime --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_UPTIME_MAINOPT_H_ | ||
#define _BIN_UPTIME_MAINOPT_H_ | ||
|
||
int main_uptime_opt_handler (char *cmd); | ||
|
||
#endif /*_BIN_UPTIME_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_UPTIME_H_ | ||
#define _BIN_UPTIME_H_ | ||
|
||
extern struct cmd_t cmd_uptime; | ||
|
||
#endif /*_BIN_UPTIME_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