xref: /haiku/src/bin/safemode.c (revision 99d1318ec02694fc520a0dc38ae38565db7e8c3c)
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 <string.h>
12 #include <strings.h>
13 
14 
15 int
16 main(int argc, char **argv)
17 {
18 	const char *optionName = B_SAFEMODE_SAFE_MODE;
19 	bool realString = false;
20 	char buffer[B_FILE_NAME_LENGTH];
21 	size_t size = sizeof(buffer);
22 	status_t status;
23 	int i;
24 
25 	for (i = 1; i < argc; i++) {
26 		if (!strcmp(argv[i], "-s"))
27 			realString = true;
28 		else
29 			optionName = argv[i];
30 	}
31 
32 	status = _kern_get_safemode_option(optionName, buffer, &size);
33 	if (status == B_OK) {
34 		if (realString) {
35 			puts(buffer);
36 			return 0;
37 		}
38 		if (!strncasecmp(buffer, "true", size)
39 			|| !strncasecmp(buffer, "yes", size)
40 			|| !strncasecmp(buffer, "on", size)
41 			|| !strncasecmp(buffer, "enabled", size)) {
42 			puts("yes");
43 			return 1;
44 		}
45 	}
46 
47 	puts("no");
48 	return 0;
49 }
50 
51