2 * This file is part of the Linux kernel, and is made available under
3 * the terms of the GNU General Public License version 2.
5 * Misc librarized functions for cmdline poking.
7 #include <linux/kernel.h>
8 #include <linux/string.h>
9 #include <linux/ctype.h>
10 #include <asm/setup.h>
12 static inline int myisspace(u8 c)
14 return c <= ' '; /* Close enough approximation */
18 * Find a boolean option (like quiet,noapic,nosmp....)
20 * @cmdline: the cmdline string
21 * @option: option string to look for
23 * Returns the position of that @option (starts counting with 1)
26 int cmdline_find_option_bool(const char *cmdline, const char *option)
29 int len, pos = 0, wstart = 0;
30 const char *opptr = NULL;
32 st_wordstart = 0, /* Start of word/after whitespace */
33 st_wordcmp, /* Comparing this word */
34 st_wordskip, /* Miscompare, skip */
35 } state = st_wordstart;
38 return -1; /* No command line */
40 len = min_t(int, strlen(cmdline), COMMAND_LINE_SIZE);
45 c = *(char *)cmdline++;
52 else if (myisspace(c))
62 if (!c || myisspace(c))
68 else if (c != *opptr++)
70 else if (!len) /* last word and is matching */
77 else if (myisspace(c))
83 return 0; /* Buffer overrun */