toaruos/kernel/core/args.c

54 lines
1.1 KiB
C
Raw Normal View History

/*
* Kernel Argument Parser
2011-04-15 05:36:51 +04:00
*
* Parses arguments passed by, ie, a Multiboot bootloader.
*
* Part of the ToAruOS Kernel.
* (C) 2011 Kevin Lange
*/
#include <system.h>
2011-04-15 05:36:51 +04:00
/**
* Parse the given arguments to the kernel.
*
* @param arg A string containing all arguments, separated by spaces.
*/
void
2011-04-15 05:36:51 +04:00
parse_args(
char * arg /* Arguments */
) {
/* Sanity check... */
2011-03-29 05:34:53 +04:00
if (!arg) { return; }
2011-04-15 05:36:51 +04:00
char * pch; /* Tokenizer pointer */
char * save; /* We use the reentrant form of strtok */
char * argv[1024]; /* Command tokens (space-separated elements) */
int tokenid = 0; /* argc, basically */
/* Tokenize the arguments, splitting at spaces */
pch = strtok_r(arg," ",&save);
2011-04-15 05:36:51 +04:00
if (!pch) { return; }
while (pch != NULL) {
argv[tokenid] = (char *)pch;
++tokenid;
pch = strtok_r(NULL," ",&save);
}
argv[tokenid] = NULL;
2011-04-15 05:36:51 +04:00
/* Tokens are now stored in argv. */
for (int i = 0; i < tokenid; ++i) {
2011-04-15 05:36:51 +04:00
/* Parse each provided argument */
if (!strcmp(argv[i],"vid=qemu")) {
2011-04-15 05:36:51 +04:00
/* Bochs / Qemu Video Device */
graphics_install_bochs();
ansi_init(&bochs_write, 128, 64);
}
}
}
2011-04-15 05:36:51 +04:00
/*
* vim:tabstop=4
* vim:noexpandtab
*/