2014-03-10 10:01:30 +04:00
|
|
|
#include <system.h>
|
|
|
|
#include <hashmap.h>
|
2014-03-12 10:56:08 +04:00
|
|
|
#include <module.h>
|
|
|
|
#include <logging.h>
|
2014-03-10 10:01:30 +04:00
|
|
|
|
2014-03-15 10:37:42 +04:00
|
|
|
#include <mod/shell.h>
|
|
|
|
|
2014-03-10 06:36:28 +04:00
|
|
|
extern char * special_thing;
|
|
|
|
|
2014-03-12 10:56:08 +04:00
|
|
|
char test_module_string[] = "I am a char[] in the module.";
|
|
|
|
char * test_module_string_ptr = "I am a char * in the module.";
|
2014-03-10 09:31:34 +04:00
|
|
|
|
2014-03-12 11:18:55 +04:00
|
|
|
int a_function(void) {
|
|
|
|
debug_print(WARNING, ("I am an exported function in the module."));
|
2014-03-10 06:36:28 +04:00
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
|
2014-03-15 10:37:42 +04:00
|
|
|
DEFINE_SHELL_FUNCTION(test_mod, "A function installed by a module!") {
|
|
|
|
fs_printf(tty, "Hello world!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-12 11:18:55 +04:00
|
|
|
static int hello(void) {
|
2014-03-12 10:56:08 +04:00
|
|
|
debug_print(NOTICE, special_thing);
|
|
|
|
a_function();
|
|
|
|
debug_print(NOTICE, test_module_string);
|
|
|
|
debug_print(NOTICE, test_module_string_ptr);
|
2014-03-10 10:01:30 +04:00
|
|
|
|
|
|
|
hashmap_t * map = hashmap_create(10);
|
|
|
|
|
2014-03-12 10:56:08 +04:00
|
|
|
debug_print(NOTICE, "Inserting into hashmap...");
|
2014-03-10 10:01:30 +04:00
|
|
|
|
2014-03-12 10:56:08 +04:00
|
|
|
hashmap_set(map, "hello", (void *)"cake");
|
|
|
|
debug_print(NOTICE, "getting value: %s", hashmap_get(map, "hello"));
|
2014-03-10 10:01:30 +04:00
|
|
|
|
|
|
|
hashmap_free(map);
|
|
|
|
free(map);
|
|
|
|
|
2014-03-15 10:37:42 +04:00
|
|
|
debug_shell_install(&shell_test_mod_desc);
|
|
|
|
BIND_SHELL_FUNCTION(test_mod);
|
|
|
|
|
2014-03-10 06:36:28 +04:00
|
|
|
return 25;
|
|
|
|
}
|
|
|
|
|
2014-03-12 11:18:55 +04:00
|
|
|
static int goodbye(void) {
|
2014-03-12 10:56:08 +04:00
|
|
|
debug_print(NOTICE, "Goodbye!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-12 11:18:55 +04:00
|
|
|
MODULE_DEF(test, hello, goodbye);
|
2014-03-19 07:11:56 +04:00
|
|
|
MODULE_DEPENDS(debugshell);
|
2014-03-12 10:56:08 +04:00
|
|
|
|