xref: /haiku/src/bin/safemode.c (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
1 /*
2  * (c) 2004, Jérôme DUVAL for Haiku
3  * released under the MIT licence.
4  */
5 
6 
7 #include <drivers/driver_settings.h>
8 #include <syscalls.h>
9 
10 #include <stdio.h>
11 #include <strings.h>
12 
13 
14 int
15 main(int argc, char **argv)
16 {
17 	const char *optionName = B_SAFEMODE_SAFE_MODE;
18 	bool realString = false;
19 	char buffer[B_FILE_NAME_LENGTH];
20 	size_t size = sizeof(buffer);
21 	status_t status;
22 	int i;
23 
24 	for (i = 1; i < argc; i++) {
25 		if (!strcmp(argv[i], "-s"))
26 			realString = true;
27 		else
28 			optionName = argv[i];
29 	}
30 
31 	status = _kern_get_safemode_option(optionName, buffer, &size);
32 	if (status == B_OK) {
33 		if (realString) {
34 			puts(buffer);
35 			return 0;
36 		}
37 		if (!strncasecmp(buffer, "true", size)
38 			|| !strncasecmp(buffer, "yes", size)
39 			|| !strncasecmp(buffer, "on", size)
40 			|| !strncasecmp(buffer, "enabled", size)) {
41 			puts("yes");
42 			return 1;
43 		}
44 	}
45 
46 	puts("no");
47 	return 0;
48 }
49 
50