summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Mangano2013-10-30 18:02:21 +0100
committerFrédéric Mangano2013-10-30 18:02:21 +0100
commitdbaa1148bb3c3ef80b0351159ccbe4f5789542ee (patch)
tree800b5d3647a65cf7b12014ac87d77400b5a80d77
parent951b2f5346d8da51a0b0df67cec4e3ff4f017634 (diff)
downloadlastos-dbaa1148bb3c3ef80b0351159ccbe4f5789542ee.tar.gz
lastos-dbaa1148bb3c3ef80b0351159ccbe4f5789542ee.zip
memory manipulator
-rw-r--r--kernel.c2
-rw-r--r--shell.c26
2 files changed, 28 insertions, 0 deletions
diff --git a/kernel.c b/kernel.c
index 24f0da3..23d84df 100644
--- a/kernel.c
+++ b/kernel.c
@@ -9,6 +9,7 @@ static void echo(struct irc_message *msg, void *data)
static struct irc_peer echo_bot = { IRC_BOT, "echo", "echo", "kernel", { .bot = { echo } } };
extern struct irc_peer shell_bot;
+extern struct irc_peer mem_bot;
static struct irc_peer serial_user = { IRC_SERIAL, "root", "root", "serial" };
@@ -27,6 +28,7 @@ void kmain()
irc_add_peer(&serial_user);
irc_add_peer(&echo_bot);
irc_add_peer(&shell_bot);
+ irc_add_peer(&mem_bot);
for (;;) {
line = sgetline();
msg = irc_parse(line);
diff --git a/shell.c b/shell.c
index 0227c3b..a7a10e2 100644
--- a/shell.c
+++ b/shell.c
@@ -10,3 +10,29 @@ static void shell(struct irc_message *msg, void *data)
}
struct irc_peer shell_bot = { IRC_BOT, "taco", "shell", "kernel", { .bot = { shell } } };
+
+static void mem(struct irc_message *msg, void *data)
+{
+ char buffer[32];
+ char *cmd = msg->message.privmsg.message;
+ char *dst = msg->prefix->nick;
+ uint32_t arg;
+ static char *debug = "I don't get it";
+ if (msg->type != IRC_PRIVMSG || !*cmd)
+ return;
+ arg = hextou32(cmd + 1);
+ switch (*cmd) {
+ case '+':
+ (*((uint32_t*) arg))++;
+ case '*':
+ irc_privmsg(dst, u32tohex(buffer, *((uint32_t*) arg)));
+ break;
+ case 'd':
+ irc_privmsg(dst, u32tohex(buffer, (uint32_t) debug));
+ break;
+ default:
+ irc_privmsg(dst, debug);
+ }
+}
+
+struct irc_peer mem_bot = { IRC_BOT, "mem", "memory", "kernel", { .bot = { mem } } };