From 4da9a2f3213cb3d678b29f64369cefe5c714a496 Mon Sep 17 00:00:00 2001 From: Caleb W <51061101+calebrwalk5@users.noreply.github.com> Date: Wed, 9 Jun 2021 09:06:58 -0400 Subject: [PATCH 1/6] Create fortune.h --- kernel/advanced_cmds/fortune.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 kernel/advanced_cmds/fortune.h diff --git a/kernel/advanced_cmds/fortune.h b/kernel/advanced_cmds/fortune.h new file mode 100644 index 0000000..0561f7f --- /dev/null +++ b/kernel/advanced_cmds/fortune.h @@ -0,0 +1,10 @@ +#pragma once +#include "../../drivers/display.h" + +void ksh_fortune() { + const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares"}; + kprintc("\n"); + int RandIndex = rand() % 3; + kprintc(arrayNum[RandIndex]); + kprintc("\n"); +} From 3f35c5ba96d7cab3a7f0fa66ec206732e6489b84 Mon Sep 17 00:00:00 2001 From: Caleb W <51061101+calebrwalk5@users.noreply.github.com> Date: Wed, 9 Jun 2021 09:09:55 -0400 Subject: [PATCH 2/6] Update ksh.h --- kernel/ksh.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/ksh.h b/kernel/ksh.h index 833aa7c..4745b41 100644 --- a/kernel/ksh.h +++ b/kernel/ksh.h @@ -16,6 +16,7 @@ char* theme; #include "advanced_cmds/write_to_file.h" #include "advanced_cmds/make_file.h" #include "advanced_cmds/remove_file.h" +#include "advanced_cmds/fortune.h" #define KSH_OK 0x0 #define KSH_EXIT 0x1 @@ -74,6 +75,7 @@ byte ksh_interpret(char* command) kprints("mk create new file\n"); kprints("rm delete file\n"); kprints("in read file content\n"); + kprints("fortune fortune cookie\n"); break; case 2: kprints("Hello World!\n"); @@ -140,6 +142,9 @@ byte ksh_interpret(char* command) case 18: ksh_write_to_file(); break; + case 19: + ksh_fortune(); + break; default: kprints(KERNEL_INFO_SHELL_UNKNOWN_COMMAND); break; From db9b0cc11c990a9fd62293f153010075f5f280fd Mon Sep 17 00:00:00 2001 From: Caleb W <51061101+calebrwalk5@users.noreply.github.com> Date: Wed, 9 Jun 2021 09:15:41 -0400 Subject: [PATCH 3/6] Update fortune.h --- kernel/advanced_cmds/fortune.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/advanced_cmds/fortune.h b/kernel/advanced_cmds/fortune.h index 0561f7f..292090f 100644 --- a/kernel/advanced_cmds/fortune.h +++ b/kernel/advanced_cmds/fortune.h @@ -2,9 +2,9 @@ #include "../../drivers/display.h" void ksh_fortune() { - const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares"}; + const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."}; kprintc("\n"); - int RandIndex = rand() % 3; + int RandIndex = rand() % sizeof(fortunes); kprintc(arrayNum[RandIndex]); kprintc("\n"); } From b64be30c9a4389ddec4210d45de53c7ce12c7564 Mon Sep 17 00:00:00 2001 From: GandelXIV <61948151+GandelXIV@users.noreply.github.com> Date: Wed, 9 Jun 2021 15:36:00 +0200 Subject: [PATCH 4/6] Update ksh.h Added the new $fortune command to ListOfOwnCmds --- kernel/ksh.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/ksh.h b/kernel/ksh.h index 4745b41..3617cf9 100644 --- a/kernel/ksh.h +++ b/kernel/ksh.h @@ -43,7 +43,8 @@ byte ksh_interpret(char* command) "mk", "rm", "in", - "to" + "to", + "fortune" }; for (int i = 0; i < sizeof(ListOfOwnCmds) / sizeof(char*); i++) { From 8996e5f99b5bc826787fcd702f8aeaf25f66b0db Mon Sep 17 00:00:00 2001 From: GandelXIV <61948151+GandelXIV@users.noreply.github.com> Date: Wed, 9 Jun 2021 15:40:03 +0200 Subject: [PATCH 5/6] Update fortune.h --- kernel/advanced_cmds/fortune.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/advanced_cmds/fortune.h b/kernel/advanced_cmds/fortune.h index 292090f..5de884b 100644 --- a/kernel/advanced_cmds/fortune.h +++ b/kernel/advanced_cmds/fortune.h @@ -1,10 +1,11 @@ #pragma once +#include "../io.h" #include "../../drivers/display.h" void ksh_fortune() { const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."}; - kprintc("\n"); + kprintc('\n'); int RandIndex = rand() % sizeof(fortunes); - kprintc(arrayNum[RandIndex]); - kprintc("\n"); + kprints(arrayNum[RandIndex]); + kprintc('\n'); } From 10be0b5f0c54c70ba3964a2f499d978ae6eb8dba Mon Sep 17 00:00:00 2001 From: GandelXIV <61948151+GandelXIV@users.noreply.github.com> Date: Wed, 9 Jun 2021 22:28:32 +0200 Subject: [PATCH 6/6] Update fortune.h --- kernel/advanced_cmds/fortune.h | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/advanced_cmds/fortune.h b/kernel/advanced_cmds/fortune.h index 5de884b..2276ee0 100644 --- a/kernel/advanced_cmds/fortune.h +++ b/kernel/advanced_cmds/fortune.h @@ -1,5 +1,6 @@ #pragma once #include "../io.h" +#include "../../lib/rand.h" #include "../../drivers/display.h" void ksh_fortune() {