-
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.
- Loading branch information
1 parent
d56af92
commit 1f28964
Showing
8 changed files
with
149 additions
and
6 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,61 @@ | ||
/** | ||
** 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 <whoami/whoami.h> | ||
|
||
int main_whoami_opt_handler (char *cmd) | ||
{ | ||
size_t num_opts = get_opt_count(cmd); | ||
str_t opts[num_opts]; | ||
get_opt(cmd,opts); | ||
|
||
if (num_opts == 1) | ||
{ | ||
printk ("%s\n", VAR_USER); | ||
return STATUS_OK; | ||
} | ||
else if (num_opts > 1) | ||
{ | ||
if (strcmp (opts [1].str, "--help") == 0) | ||
{ | ||
printk (cmd_whoami.help); | ||
return STATUS_OK; | ||
} | ||
else | ||
{ | ||
printk (cmd_whoami.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 <whoami/whoami.h> | ||
#include <whoami/opts/main_whoami.h> | ||
|
||
struct cmd_opt_t* cmd_whoami_opts[] = | ||
{ | ||
0 | ||
}; | ||
|
||
int cmd_whoami_handler (char *cmd) | ||
{ | ||
main_whoami_opt_handler (cmd); | ||
return STATUS_OK; | ||
} | ||
|
||
struct cmd_t cmd_whoami = | ||
{ | ||
.name = "whoami", | ||
.usage ="whoami [--help]", | ||
.help = "whoami(1) \t\t\t\t BoneOS Terminal Manual \n" | ||
"NAME : \n " | ||
"\twhoami\n" | ||
"SYNOPSIS : \n " | ||
"\twhoami [option] [--help]\n" | ||
"DESCRIPTION : \n " | ||
"\tPrints out the current user.\n", | ||
.cmd_opts = cmd_whoami_opts, | ||
.handler = &cmd_whoami_handler, | ||
.invalid_use_msg = "Invalid use of whoami command.\n" | ||
"Type whoami --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 |
---|---|---|
|
@@ -4,5 +4,3 @@ | |
extern struct cmd_t cmd_logname; | ||
|
||
#endif /*_BIN_LOGNAME_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,8 @@ | ||
#ifndef _BIN_WHOAMI_MAINOPT_H_ | ||
#define _BIN_WHOAMI_MAINOPT_H_ | ||
|
||
int main_whoami_opt_handler (char *cmd); | ||
|
||
#endif /*_BIN_WHOAMI_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,8 @@ | ||
#ifndef _BIN_WHOAMI_H_ | ||
#define _BIN_WHOAMI_H_ | ||
|
||
extern struct cmd_t cmd_whoami; | ||
|
||
#endif /*_BIN_WHOAMI_H_*/ | ||
|
||
|